Projet

Général

Profil

Révision ca0757b9

Ajouté par Assos Assos il y a plus de 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/media/includes/media.browser.inc
12 12
  $output = array();
13 13
  $output['#attached']['library'][] = array('media', 'media_browser_page');
14 14

  
15
  $params = media_set_browser_params();
15
  $params = media_get_browser_params();
16 16

  
17 17
  // If one or more files have been selected, the browser interaction is now
18 18
  // complete. Return empty page content to the dialog which now needs to close,
......
77 77
      continue;
78 78
    }
79 79

  
80
    // We need to get a submit and cancel button on each tab. If the plugin
81
    // is not returning a form element we need to add a submit button.
80
    // We need to ensure that a submit button is available on each tab. If the
81
    // plugin is not returning a form element we need to add a submit button.
82 82
    // This is a fairly broad assumption.
83 83
    if (empty($plugin_output[$key]['#form']) && !empty($plugin_output[$key]['#markup'])) {
84 84
      $fake_buttons = '<div class="form-actions form-wrapper">';
......
87 87
          'class' => array('button', 'button-yes', 'fake-submit', $key),
88 88
        ),
89 89
      ));
90
      $fake_buttons .= l(t('Cancel'), '', array(
91
        'attributes' => array(
92
          'class' => array('button', 'button-no', 'fake-cancel', $key),
93
        ),
94
      ));
95 90
      $fake_buttons .= '</div>';
96 91
      $plugin_output[$key]['#markup'] .= $fake_buttons;
97 92
    }
98

  
99
    // I'm not sure if it is ever the case that a plugin form will ever have
100
    // the correct cancel button so we add it here. Put it inline with the
101
    // current submit button. This is a fairly broad assumption.
102
    if (!empty($plugin_output[$key]['form']['actions']) && !isset($plugin_output[$key]['form']['actions']['cancel'])) {
103
      $plugin_output[$key]['form']['actions']['cancel'] = array(
104
        '#type' => 'link',
105
        '#title' => t('Cancel'),
106
        '#href' => '',
107
        '#attributes' => array(
108
          'class' => array(
109
            'button',
110
            'button-no',
111
            'fake-cancel',
112
            $key,
113
          ),
114
        ),
115
        '#weight' => 100,
116
      );
117
    }
118 93
  }
119 94

  
120 95
  // Allow modules to change the tab names or whatever else they want to change
......
162 137

  
163 138
  drupal_add_js($settings, 'setting');
164 139

  
165
  $output['title'] = array(
166
    '#markup' => t('Select a file')
167
  );
168

  
169 140
  $output['tabset']['tabs'] = array(
170 141
    '#theme' => 'menu_local_tasks',
171 142
    '#attributes' => array('class' => array('tabs', 'primary')),
......
177 148
  return $output;
178 149
}
179 150

  
180
/**
181
 * Provides a singleton of the params passed to the media browser.
182
 *
183
 * This is useful in situations like form alters because callers can pass
184
 * id="wysiywg_form" or whatever they want, and a form alter could pick this up.
185
 * We may want to change the hook_media_browser_plugin_view() implementations to
186
 * use this function instead of being passed params for consistency.
187
 *
188
 * It also offers a chance for some meddler to meddle with them.
189
 *
190
 * @see media_browser()
191
 */
192
function media_set_browser_params() {
193
  $params = &drupal_static(__FUNCTION__, array());
194

  
195
  if (empty($params)) {
196
    // Build out browser settings. Permissions- and security-related behaviors
197
    // should not rely on these parameters, since they come from the HTTP query.
198
    // @TODO make sure we treat parameters as user input.
199
    $params = drupal_get_query_parameters() + array(
200
      'types' => array(),
201
      'multiselect' => FALSE,
202
    );
203

  
204
    // Transform text 'true' and 'false' to actual booleans.
205
    foreach ($params as $k => $v) {
206
      if ($v === 'true') {
207
        $params[$k] = TRUE;
208
      }
209
      elseif ($v === 'false') {
210
        $params[$k] = FALSE;
211
      }
212
    }
213

  
214
    array_walk_recursive($params, 'media_recursive_check_plain');
215

  
216
    // Allow modules to alter the parameters.
217
    drupal_alter('media_browser_params', $params);
218
  }
219

  
220
  return $params;
221
}
222

  
223

  
224
/**
225
 * For sanity in grammar.
226
 *
227
 * @see media_set_browser_params()
228
 */
229
function media_get_browser_params() {
230
  return media_set_browser_params();
231
}
232

  
233 151
/**
234 152
 * Attaches media browser javascript to an element.
235 153
 *
......
251 169
function media_browser_js() {
252 170
  $settings = array(
253 171
    'browserUrl' => url('media/browser', array(
254
        'query' => array('render' => 'media-popup'),
255
      )
172
      'query' => array(
173
        'render' => 'media-popup'
174
      ))
256 175
    ),
257 176
    'styleSelectorUrl' => url('media/-media_id-/format-form', array(
258
        'query' => array('render' => 'media-popup'),
259
      )
177
      'query' => array(
178
        'render' => 'media-popup'
179
      ))
180
    ),
181
    'dialogOptions' => array(
182
      'dialogclass' => variable_get('media_dialogclass', 'media-wrapper'),
183
      'modal' => (boolean)variable_get('media_modal', TRUE),
184
      'draggable' => (boolean)variable_get('media_draggable', FALSE),
185
      'resizable' => (boolean)variable_get('media_resizable', FALSE),
186
      'minwidth' => (int)variable_get('media_minwidth', 500),
187
      'width' => (int)variable_get('media_width', 670),
188
      'height' => (int)variable_get('media_height', 280),
189
      'position' => variable_get('media_position', 'center'),
190
      'overlay' => array(
191
        'backgroundcolor' => variable_get('media_backgroundcolor', '#000000'),
192
        'opacity' => (float)variable_get('media_opacity', 0.4),
193
      ),
194
      'zindex' => (int)variable_get('media_zindex', 10000),
260 195
    ),
261 196
  );
262 197

  
263
  $js = array(
198
  return array(
264 199
    'library' => array(
265 200
      array('media', 'media_browser'),
266 201
    ),
267 202
    'js' => array(
268 203
      array(
269
        'data' => array('media' => $settings),
270
        'type' => 'setting',
204
       'data' => array('media' => $settings),
205
       'type' => 'setting',
271 206
      ),
272 207
    ),
273 208
  );
274
  return $js;
275 209
}
276 210

  
277 211
/**

Formats disponibles : Unified diff