Projet

Général

Profil

Révision 18596a08

Ajouté par Assos Assos il y a presque 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/module_filter/module_filter.module
18 18
  return array(
19 19
    'administer module filter' => array(
20 20
      'title' => t('Administer Module Filter'),
21
      'description' => t('Configure how Module Filter performs.')
22
    )
21
      'description' => t('Configure how Module Filter performs.'),
22
    ),
23 23
  );
24 24
}
25 25

  
......
33 33
    'access arguments' => array('administer module filter'),
34 34
    'page callback' => 'drupal_get_form',
35 35
    'page arguments' => array('module_filter_settings'),
36
    'file' => 'module_filter.admin.inc'
36
    'file' => 'module_filter.admin.inc',
37 37
  );
38 38
  return $items;
39 39
}
......
63 63
    '#type' => 'module_filter',
64 64
    '#attached' => array(
65 65
      'js' => array(
66
        drupal_get_path('module', 'module_filter') . '/js/modules.js'
67
      )
68
    )
66
        drupal_get_path('module', 'module_filter') . '/js/modules.js' => array('weight' => 1),
67
      ),
68
    ),
69 69
  );
70 70
  $checkbox_defaults = array(
71 71
    ((isset($_GET['enabled'])) ? $_GET['enabled'] : 1) ? 'enabled' : '',
72 72
    ((isset($_GET['disabled'])) ? $_GET['disabled'] : 1) ? 'disabled' : '',
73 73
    ((isset($_GET['required'])) ? $_GET['required'] : 1) ? 'required' : '',
74
    ((isset($_GET['unavailable'])) ? $_GET['unavailable'] : 1) ? 'unavailable' : ''
74
    ((isset($_GET['unavailable'])) ? $_GET['unavailable'] : 1) ? 'unavailable' : '',
75 75
  );
76 76
  $form['module_filter']['show'] = array(
77 77
    '#type' => 'checkboxes',
78 78
    '#default_value' => array_filter($checkbox_defaults),
79 79
    '#options' => array('enabled' => t('Enabled'), 'disabled' => t('Disabled'), 'required' => t('Required'), 'unavailable' => t('Unavailable')),
80 80
    '#prefix' => '<div id="module-filter-show-wrapper">',
81
    '#suffix' => '</div>'
81
    '#suffix' => '</div>',
82 82
  );
83 83

  
84 84
  if (variable_get('module_filter_tabs', 1)) {
85
    $form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') .'/css/module_filter_tab.css';
85
    $form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') . '/css/module_filter_tab.css';
86 86
    $form['module_filter']['#attached']['library'][] = array('system', 'jquery.bbq');
87
    $form['module_filter']['#attached']['js'][] = drupal_get_path('module', 'module_filter') .'/js/module_filter_tab.js';
87
    $form['module_filter']['#attached']['js'][drupal_get_path('module', 'module_filter') . '/js/module_filter_tab.js'] = array('weight' => 2);
88 88

  
89 89
    if (!module_exists('page_actions') && variable_get('module_filter_dynamic_save_position', 1)) {
90
      $form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') .'/css/dynamic_position.css';
91
      $form['module_filter']['#attached']['js'][] = drupal_get_path('module', 'module_filter') .'/js/dynamic_position.js';
90
      $form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') . '/css/dynamic_position.css';
91
      $form['module_filter']['#attached']['js'][drupal_get_path('module', 'module_filter') . '/js/dynamic_position.js'] = array('weight' => 3);
92 92
    }
93 93

  
94 94
    $form['#attached']['css'][] = drupal_get_path('module', 'module_filter') . '/css/modules.css';
......
128 128
    '#process' => array('form_process_module_filter', 'ajax_process_form'),
129 129
    '#weight' => -1,
130 130
    '#tree' => TRUE,
131
    '#theme' => 'module_filter'
131
    '#theme' => 'module_filter',
132 132
  );
133 133
  return $types;
134 134
}
......
153 153
  );
154 154
}
155 155

  
156
/**
157
 * Create and add new textfield element.
158
 *
159
 * @param $element
160
 *   An associative array containing the properties and children of the
161
 *   form actions container.
162
 * @param $form_state
163
 *   The $form_state array for the form this element belongs to.
164
 *
165
 * @return
166
 *   The processed element.
167
 */
156 168
function form_process_module_filter($element, &$form_state) {
157 169
  $element['name'] = array(
158 170
    '#type' => 'textfield',
......
163 175
    '#attributes' => ((isset($element['#attributes'])) ? $element['#attributes'] : array()) + array('autocomplete' => 'off'),
164 176
    '#attached' => array(
165 177
      'css' => array(
166
        drupal_get_path('module', 'module_filter') . '/css/module_filter.css'
178
        drupal_get_path('module', 'module_filter') . '/css/module_filter.css',
167 179
      ),
168 180
      'js' => array(
169 181
        'misc/jquery.cookie.js',
......
182 194
              'trackRecent' => variable_get('module_filter_track_recent_modules', 1),
183 195
              'rememberActiveTab' => variable_get('module_filter_remember_active_tab', 1),
184 196
              'rememberUpdateState' => variable_get('module_filter_remember_update_state', 0),
185
            )
197
              'expandedDescription' => variable_get('module_filter_expanded_description', 0),
198
            ),
186 199
          ),
187
          'type' => 'setting'
188
        )
189
      )
190
    )
200
          'type' => 'setting',
201
        ),
202
      ),
203
    ),
191 204
  );
192 205
  if (isset($element['#description'])) {
193 206
    $element['name']['#description'] = $element['#description'];
......
195 208
  return $element;
196 209
}
197 210

  
211
/**
212
 * Form submission handler to filters module list.
213
 */
198 214
function module_filter_system_modules_submit_redirect($form, &$form_state) {
199 215
  $query = array();
200 216
  if (!empty($form_state['values']['module_filter']['name'])) {
201 217
    $query['filter'] = $form_state['values']['module_filter']['name'];
202 218
  }
203
  $query['enabled'] = (int)(!empty($form_state['values']['module_filter']['show']['enabled']));
204
  $query['disabled'] = (int)(!empty($form_state['values']['module_filter']['show']['disabled']));
205
  $query['required'] = (int)(!empty($form_state['values']['module_filter']['show']['required']));
206
  $query['unavailable'] = (int)(!empty($form_state['values']['module_filter']['show']['unavailable']));
219
  $query['enabled'] = (int) (!empty($form_state['values']['module_filter']['show']['enabled']));
220
  $query['disabled'] = (int) (!empty($form_state['values']['module_filter']['show']['disabled']));
221
  $query['required'] = (int) (!empty($form_state['values']['module_filter']['show']['required']));
222
  $query['unavailable'] = (int) (!empty($form_state['values']['module_filter']['show']['unavailable']));
207 223

  
208 224
  $form_state['redirect'] = array(
209 225
    'admin/modules',
......
211 227
  );
212 228
}
213 229

  
230
/**
231
 * Form submission handler to track recently enabled/disabled modules
232
 */
214 233
function module_filter_system_modules_submit_recent($form, &$form_state) {
215 234
  $recent_modules = variable_get('module_filter_recent_modules', array());
216 235

  
......
225 244
  variable_set('module_filter_recent_modules', $recent_modules);
226 245
}
227 246

  
247
/**
248
 * Create list of newly added modules (within a week)
249
 * @return
250
 *   An array of newly added modules.
251
 */
228 252
function module_filter_new_modules() {
229 253
  // Get current list of modules.
230 254
  $files = system_rebuild_module_data();
......
249 273
  return $new_modules;
250 274
}
251 275

  
276
/**
277
 * Function to replace special characters with hyphen.
278
 * @param string $text
279
 * @return
280
 *   String
281
 */
252 282
function module_filter_get_id($text) {
253 283
  $id = strtolower($text);
254 284
  $id = preg_replace('/([^a-z0-9]+)/', '-', $id);
255 285
  return trim($id, '-');
256 286
}
257 287

  
288
/**
289
 * Function to return true/false depending on module changed time and a week timestamp
290
 * @param integer $var
291
 * @return
292
 *   Boolean indicating
293
 */
258 294
function module_filter_recent_filter($var) {
259
  return (!($var < REQUEST_TIME - 60*60*24*7));
295
  return (!($var < REQUEST_TIME - 60 * 60 * 24 * 7));
260 296
}

Formats disponibles : Unified diff