| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: yui_editor.admin.inc,v 1.1.2.5 2008/11/21 23:05:28 jeffcd Exp $ 3 4 /** 5 * @file 6 * YUI Editor admin pages. 7 */ 8 9 /** 10 * The profile list page. 11 */ 12 function yui_editor_profile_list() { 13 $header = array(t('Priority'), t('Name'), t('Roles'), t('Operations')); 14 $rows = array(); 15 $profiles = variable_get('yui_editor_profiles', array()); 16 $roles = user_roles(); 17 18 foreach ($profiles as $priority => $list) { 19 foreach ($list as $pid => $profile) { 20 $user_roles = ''; 21 foreach ($profile['roles'] as $rid => $status) { 22 if ($status == $rid) { 23 $user_roles .= $roles[$rid]; 24 } 25 } 26 $rows[] = array($priority, $profile['name'], $user_roles, l(t('Edit'), 'admin/settings/yui_editor/edit/'. $pid) .' | '. l(t('Delete'), 'admin/settings/yui_editor/delete/'. $priority .'/'. $pid)); 27 } 28 } 29 30 return theme_table($header, $rows); 31 } 32 33 /** 34 * Delete profile. 35 */ 36 function yui_editor_profile_delete($priority, $pid) { 37 $profiles = variable_get('yui_editor_profiles', array()); 38 unset($profiles[$priority][$pid]); 39 variable_set('yui_editor_profiles', $profiles); 40 41 drupal_set_message(t('Profile deleted.')); 42 drupal_goto('admin/settings/yui_editor'); 43 } 44 45 /** 46 * Return a default profile configuration. 47 */ 48 function yui_editor_profile_default() { 49 return array( 50 'name' => 'Default', 51 'weight' => 10, 52 'roles' => array(2 => 2), 53 'include' => '', 54 'type' => '', 55 'ids' => '', 56 'title' => '', 57 'titlebar' => 0, 58 'height' => '250px', 59 'width' => '100%', 60 'markup' => 'xhtml', 61 'resize' => 0, 62 'plaintext' => 0, 63 'coder' => 0, 64 'collapse' => 0, 65 'draggable' => 0, 66 'dom' => 1, 67 'ptags' => 0, 68 'img_upload' => 0, 69 'flickr' => 0, 70 'flickr_api_key' => '', 71 'button_type' => 'simple', 72 'button_profile' => 'yui_editor_toolbar_default.js', 73 ); 74 } 75 76 /** 77 * The profile add/edit page. 78 */ 79 function yui_editor_profile() { 80 yui_editor_load_libs(); 81 82 if (arg(3) == 'edit' && arg(4)) { 83 $profiles = variable_get('yui_editor_profiles', array()); 84 foreach ($profiles as $priority => $list) { 85 foreach ($list as $pid => $profile) { 86 if ($pid == arg(4)) { 87 $form['old_weight'] = array( 88 '#type' => 'hidden', 89 '#value' => $profile['weight'], 90 ); 91 $form['id'] = array( 92 '#type' => 'hidden', 93 '#value' => arg(4), 94 ); 95 break 2; 96 } 97 } 98 } 99 } 100 101 if ($profile == NULL) { 102 $profile = yui_editor_profile_default(); 103 $profile['name'] = ''; 104 } 105 106 $form['name'] = array( 107 '#type' => 'textfield', 108 '#title' => t('Profile name'), 109 '#required' => TRUE, 110 '#default_value' => $profile['name'], 111 '#description' => t('The name you want to give this profile'), 112 ); 113 $form['display'] = array( 114 '#type' => 'fieldset', 115 '#title' => t('Profile priority and configuration'), 116 '#description' => t('Limit where the editor shows up based on role, path, and ID. NOTE: Only ONE profile will be applied per page. If the user has access to the YUI Editor, then the module looks at each profile in order based on the priority. For each profile it compares the user roles and the page path against the profile roles and paths. IDs are NOT used when selecting which profile to apply to a given page, but IDs are useful for specifying which textareas should be applied if the profile is a match (otherwise, it will just place the YUI Editor on the body field -- edit-body).'), 117 '#collapsible' => TRUE, 118 '#collapsed' => FALSE, 119 ); 120 $form['display']['weight'] = array( 121 '#type' => 'weight', 122 '#title' => 'Priority', 123 '#default_value' => $profile['weight'], 124 '#description' => t('Priority of this profile in relation to the others (i.e. the weight of this profile)'), 125 ); 126 $form['display']['roles'] = array( 127 '#type' => 'checkboxes', 128 '#title' => 'Roles', 129 '#default_value' => $profile['roles'], 130 '#options' => user_roles(), 131 '#description' => t('Define which roles YUI should apply this profile. Note: A user only needs to be in one of the roles for this to apply.'), 132 ); 133 $form['display']['include'] = array( 134 '#type' => 'textarea', 135 '#title' => t('Paths'), 136 '#default_value' => $profile['include'], 137 '#description' => t('Define where should YUI replace the body textarea, each path on a new line. You can use wildcards (*). (Leave blank for every form)'), 138 '#rows' => 5, 139 '#cols' => 60, 140 ); 141 $form['display']['type'] = array( 142 '#type' => 'textarea', 143 '#title' => t('Content types'), 144 '#default_value' => $profile['type'], 145 '#description' => t('For node/add/* and node/*/edit paths, list the content-types where YUI should appear, each content-type on a new line. (Leave blank for all content-types)'), 146 '#rows' => 5, 147 '#cols' => 60); 148 $form['display']['ids'] = array( 149 '#type' => 'textarea', 150 '#title' => t('IDs'), 151 '#default_value' => $profile['ids'], 152 '#description' => t('Define which textareas do you want the editor to replace, write the ID of each textarea on a seperate line. (if empty the editor will only replace the body textarea)'), 153 '#rows' => 5, 154 '#cols' => 20, 155 ); 156 $form['basic'] = array( 157 '#type' => 'fieldset', 158 '#title' => t('Basic editor settings'), 159 '#description' => t('Basic settings for the editor displayed using this profile'), 160 '#collapsible' => TRUE, 161 '#collapsed' => FALSE, 162 ); 163 $form['basic']['title'] = array( 164 '#type' => 'textfield', 165 '#title' => t('Title'), 166 '#default_value' => $profile['title'], 167 '#description' => t('The title to give the editor'), 168 ); 169 $form['basic']['titlebar'] = array( 170 '#type' => 'checkbox', 171 '#title' => t('Show titlebar'), 172 '#default_value' => $profile['titlebar'], 173 '#description' => t('Toggle the YUI editor titlebar'), 174 ); 175 $form['basic']['height'] = array( 176 '#type' => 'textfield', 177 '#title' => t('Height'), 178 '#default_value' => $profile['height'], 179 '#description' => t('The height of the editor (i.e. 250px)'), 180 ); 181 $form['basic']['width'] = array( 182 '#type' => 'textfield', 183 '#title' => t('Width'), 184 '#default_value' => $profile['width'], 185 '#description' => t('The width of the editor (i.e. 100%)'), 186 ); 187 $form['advanced'] = array( 188 '#type' => 'fieldset', 189 '#title' => t('Advanced editor settings'), 190 '#description' => t('Advanced settings for the editor displayed using this profile'), 191 '#collapsible' => TRUE, 192 '#collapsed' => FALSE, 193 ); 194 $form['advanced']['markup'] = array( 195 '#type' => 'textfield', 196 '#title' => t('Markup'), 197 '#default_value' => $profile['markup'], 198 '#description' => t('Set the YUI editor markup'), 199 ); 200 $form['advanced']['collapse'] = array( 201 '#type' => 'checkbox', 202 '#title' => t('Collapsible titlebar'), 203 '#default_value' => $profile['collapse'], 204 '#description' => t('Allow user to collapse the titlebar'), 205 ); 206 $form['advanced']['draggable'] = array( 207 '#type' => 'checkbox', 208 '#title' => t('Draggable titlebar'), 209 '#default_value' => $profile['draggable'], 210 '#description' => t('Allow user to drag the titlebar'), 211 ); 212 $form['advanced']['dom'] = array( 213 '#type' => 'checkbox', 214 '#default_value' => $profile['dom'], 215 '#title' => t('Show DOM'), 216 '#description' => t('Toggle the YUI editor DOM display (at the bottom of the editor)'), 217 ); 218 $form['advanced']['ptags'] = array( 219 '#type' => 'checkbox', 220 '#default_value' => $profile['ptags'], 221 '#title' => t('Use P tags'), 222 '#description' => t('Use P tags instead of BR tags for paragraphs. (Shift+enter to get BR tag when this is turned on) Note: This option appears to only work in IE.'), 223 ); 224 $form['plugins'] = array( 225 '#type' => 'fieldset', 226 '#title' => t('Plugins'), 227 '#description' => t('Plugins to apply/enable for editors using this profile'), 228 '#collapsible' => TRUE, 229 '#collapsed' => FALSE, 230 ); 231 $form['buttns'] = array( 232 '#type' => 'fieldset', 233 '#title' => t('Buttons'), 234 '#description' => t('Configure which buttons are applied/enabled for this profile'), 235 '#collapsible' => TRUE, 236 '#collapsed' => FALSE, 237 ); 238 $form['buttns']['button_type'] = array( 239 '#type' => 'select', 240 '#title' => t('Button type'), 241 '#default_value' => $profile['button_type'], 242 '#options' => array('simple' => 'Simple', 'advanced' => 'Advanced'), 243 '#description' => t('Select the appropriate button profile'), 244 ); 245 $form['buttns']['button_profile'] = array( 246 '#type' => 'select', 247 '#title' => t('Button profile'), 248 '#default_value' => $profile['button_profile'], 249 '#options' => array('yui_editor_toolbar_default.js' => 'Default', 'yui_editor_toolbar_no_style.js' => 'No Style Tags', '1' => 'Custom'), 250 '#description' => t('Select the appropriate button profile. If you choose "Custom", then you will be able to build your own toolbar below.'), 251 ); 252 $form['buttns']['_custom_html'] = array( 253 '#type' => 'hidden', 254 '#default_value' => '', 255 ); 256 $form['buttns']['custom'] = array( 257 '#prefix' => ($profile['button_profile'] == 1 ? '<div id="custom_button_profile_wrapper">'. $profile['_custom_html'] .'</div>' : ' 258 <div id="custom_button_profile_wrapper" style="display: none;"> 259 <div id="status">You have selected the "Custom" button profile. You may click and drag buttons. You may double click on a button group title and change it.</div> 260 <div id="custom_button_profile" class="yui-toolbar-container yui-toolbar-grouped" tabindex="-1"><fieldset> 261 <div class="yui-toolbar-subcont"> 262 <div class="yui-toolbar-group"> 263 <h3 class="editable">Font Name and Size</h3> 264 <ul> 265 <li class="yui-toolbar-groupitem"> 266 <span class="yui-button yui-push-button yui-toolbar-heading" tabindex="-1" role="button" type="select" value="fontname" unselectable="on" title="Arial" menu="[ { text: \'Arial\', checked: true }, { text: \'Arial Black\' }, { text: \'Comic Sans MS\' }, { text: \'Courier New\' }, { text: \'Lucida Console\' }, { text: \'Tahoma\' }, { text: \'Times New Roman\' }, { text: \'Trebuchet MS\' }, { text: \'Verdana\' } ]"> 267 <span class="yui-toolbar-icon"/> 268 <span class="first-child">Font 269 </span> 270 </span> 271 </li> 272 <li class="yui-toolbar-groupitem"> 273 <span class="yui-button yui-push-button yui-toolbar-heading" tabindex="-1" role="button" type="spin" value="fontsize" unselectable="on" title="13" range="[ 9, 75 ]"> 274 <span class="yui-toolbar-icon"/> 275 <span class="first-child">Size 276 </span> 277 </span> 278 </li> 279 </ul> 280 </div> 281 <span class="yui-toolbar-separator">|</span> 282 <div class="yui-toolbar-group"> 283 <h3 class="editable">Font Style</h3> 284 <ul> 285 <li class="yui-toolbar-groupitem"> 286 <span class="yui-button yui-push-button yui-toolbar-bold" tabindex="-1" role="button" type="push" value="bold" unselectable="on" title="Bold"> 287 <span class="yui-toolbar-icon"/> 288 <span class="first-child"> 289 </span> 290 </span> 291 </li> 292 <li class="yui-toolbar-groupitem"> 293 <span class="yui-button yui-push-button yui-toolbar-italic" tabindex="-1" role="button" type="push" value="italic" unselectable="on" title="Italic"> 294 <span class="yui-toolbar-icon"/> 295 <span class="first-child"> 296 </span> 297 </span> 298 </li> 299 <li class="yui-toolbar-groupitem"> 300 <span class="yui-button yui-push-button yui-toolbar-underline" tabindex="-1" role="button" type="push" value="underline" unselectable="on" title="Underline"> 301 <span class="yui-toolbar-icon"/> 302 <span class="first-child"> 303 </span> 304 </span> 305 </li> 306 <li class="yui-toolbar-groupitem"> 307 <span class="yui-toolbar-separator yui-toolbar-separator-1">|</span> 308 </li> 309 <li class="yui-toolbar-groupitem"> 310 <span class="yui-button yui-push-button yui-toolbar-superscript" tabindex="-1" role="button" type="push" value="superscript" unselectable="on" title="Superscript"> 311 <span class="yui-toolbar-icon"/> 312 <span class="first-child"> 313 </span> 314 </span> 315 </li> 316 <li class="yui-toolbar-groupitem"> 317 <span class="yui-button yui-push-button yui-toolbar-subscript" tabindex="-1" role="button" type="push" value="subscript" unselectable="on" title="Subscript"> 318 <span class="yui-toolbar-icon"/> 319 <span class="first-child"> 320 </span> 321 </span> 322 </li> 323 <li class="yui-toolbar-groupitem"> 324 <span class="yui-toolbar-separator yui-toolbar-separator-1">|</span> 325 </li> 326 <li class="yui-toolbar-groupitem"> 327 <span class="yui-button yui-push-button yui-toolbar-forecolor" tabindex="-1" role="button" type="color" value="forecolor" unselectable="on" title="Font color"> 328 <span class="yui-toolbar-icon"/> 329 <span class="first-child"> 330 </span> 331 </span> 332 </li> 333 <li class="yui-toolbar-groupitem"> 334 <span class="yui-button yui-push-button yui-toolbar-backcolor" tabindex="-1" role="button" type="color" value="backcolor" unselectable="on" title="Background color"> 335 <span class="yui-toolbar-icon"/> 336 <span class="first-child"> 337 </span> 338 </span> 339 </li> 340 <li class="yui-toolbar-groupitem"> 341 <span class="yui-toolbar-separator yui-toolbar-separator-1">|</span> 342 </li> 343 <li class="yui-toolbar-groupitem"> 344 <span class="yui-button yui-push-button yui-toolbar-removeformat" tabindex="-1" role="button" type="push" value="removeformat" unselectable="on" title="Remove formatting"> 345 <span class="yui-toolbar-icon"/> 346 <span class="first-child"> 347 </span> 348 </span> 349 </li> 350 <li class="yui-toolbar-groupitem"> 351 <span class="yui-button yui-push-button yui-toolbar-hiddenelements" tabindex="-1" role="button" type="push" value="hiddenelements" unselectable="on" title="Show/Hide hidden elements"> 352 <span class="yui-toolbar-icon"/> 353 <span class="first-child"> 354 </span> 355 </span> 356 </li> 357 </ul> 358 </div> 359 <span class="yui-toolbar-separator">|</span> 360 <div class="yui-toolbar-group"> 361 <h3 class="editable">Alignment</h3> 362 <ul> 363 <li class="yui-toolbar-groupitem"> 364 <span class="yui-button yui-push-button yui-toolbar-justifyleft" tabindex="-1" role="button" type="push" value="justifyleft" unselectable="on" title="Align left"> 365 <span class="yui-toolbar-icon"/> 366 <span class="first-child"> 367 </span> 368 </span> 369 </li> 370 <li class="yui-toolbar-groupitem"> 371 <span class="yui-button yui-push-button yui-toolbar-justifycenter" tabindex="-1" role="button" type="push" value="justifycenter" unselectable="on" title="Align center"> 372 <span class="yui-toolbar-icon"/> 373 <span class="first-child"> 374 </span> 375 </span> 376 </li> 377 <li class="yui-toolbar-groupitem"> 378 <span class="yui-button yui-push-button yui-toolbar-justifyright" tabindex="-1" role="button" type="push" value="justifyright" unselectable="on" title="Align right"> 379 <span class="yui-toolbar-icon"/> 380 <span class="first-child"> 381 </span> 382 </span> 383 </li> 384 <li class="yui-toolbar-groupitem"> 385 <span class="yui-button yui-push-button yui-toolbar-justifyfull" tabindex="-1" role="button" type="push" value="justifyfull" unselectable="on" title="Justify"> 386 <span class="yui-toolbar-icon"/> 387 <span class="first-child"> 388 </span> 389 </span> 390 </li> 391 </ul> 392 </div> 393 <span class="yui-toolbar-separator">|</span> 394 <div class="yui-toolbar-group"> 395 <h3 class="editable">Paragraph Style</h3> 396 <ul> 397 <li class="yui-toolbar-groupitem"> 398 <span class="yui-button yui-push-button yui-toolbar-heading" tabindex="-1" role="button" type="select" value="heading" unselectable="on" title="Normal" menu="[ { text: \'Normal\', value: \'none\', checked: true }, { text: \'Header 1\', value: \'h1\' }, { text: \'Header 2\', value: \'h2\' }, { text: \'Header 3\', value: \'h3\' }, { text: \'Header 4\', value: \'h4\' }, { text: \'Header 5\', value: \'h5\' }, { text: \'Header 6\', value: \'h6\' } ]"> 399 <span class="yui-toolbar-icon"/> 400 <span class="first-child">Paragraph 401 </span> 402 </span> 403 </li> 404 </ul> 405 </div> 406 <span class="yui-toolbar-separator">|</span> 407 <div class="yui-toolbar-group"> 408 <h3 class="editable">Insert Item</h3> 409 <ul> 410 <li class="yui-toolbar-groupitem"> 411 <span class="yui-button yui-push-button yui-toolbar-indent" tabindex="-1" role="button" type="push" value="indent" unselectable="on" title="Indent"> 412 <span class="yui-toolbar-icon"/> 413 <span class="first-child"> 414 </span> 415 </span> 416 </li> 417 <li class="yui-toolbar-groupitem"> 418 <span class="yui-button yui-push-button yui-toolbar-outdent" tabindex="-1" role="button" type="push" value="outdent" unselectable="on" title="Outdent"> 419 <span class="yui-toolbar-icon"/> 420 <span class="first-child"> 421 </span> 422 </span> 423 </li> 424 <li class="yui-toolbar-groupitem"> 425 <span class="yui-button yui-push-button yui-toolbar-insertunorderedlist" tabindex="-1" role="button" type="push" value="insertunorderedlist" unselectable="on" title="Create an unordered list"> 426 <span class="yui-toolbar-icon"/> 427 <span class="first-child"> 428 </span> 429 </span> 430 </li> 431 <li class="yui-toolbar-groupitem"> 432 <span class="yui-button yui-push-button yui-toolbar-insertorderedlist" tabindex="-1" role="button" type="push" value="insertorderedlist" unselectable="on" title="Create an ordered list"> 433 <span class="yui-toolbar-icon"/> 434 <span class="first-child"> 435 </span> 436 </span> 437 </li> 438 </ul> 439 </div> 440 <span class="yui-toolbar-separator">|</span> 441 <div class="yui-toolbar-group"> 442 <h3 class="editable">Indenting and Lists</h3> 443 <ul> 444 <li class="yui-toolbar-groupitem"> 445 <span class="yui-button yui-push-button yui-toolbar-createlink" tabindex="-1" role="button" type="push" value="createlink" unselectable="on" title="HTML Link"> 446 <span class="yui-toolbar-icon"/> 447 <span class="first-child"> 448 </span> 449 </span> 450 </li> 451 <li class="yui-toolbar-groupitem"> 452 <span class="yui-button yui-push-button yui-toolbar-insertimage" tabindex="-1" role="button" type="push" value="insertimage" unselectable="on" title="Insert image"> 453 <span class="yui-toolbar-icon"/> 454 <span class="first-child"> 455 </span> 456 </span> 457 </li> 458 </ul> 459 </div> 460 </div> 461 </fieldset></div> 462 <br /><br /> 463 <div class="yui-toolbar-container yui-toolbar-grouped"><fieldset> 464 <div class="yui-toolbar-subcont"> 465 <div class="yui-toolbar-group"> 466 <ul id="holdingpen" style="height: 45px;"> 467 <h3>Removed buttons that are available to be added</h3> 468 </ul> 469 </div> 470 </div> 471 </fieldset></div></div>'), 472 '#type' => 'hidden', 473 ); 474 $form['submit'] = array( 475 '#type' => 'submit', 476 '#value' => t('Save profile'), 477 ); 478 479 _yui_editor_plugin('settings', $form, $profile); 480 drupal_add_js(drupal_get_path('module', 'yui_editor') .'/yui_editor_admin.js'); 481 482 return $form; 483 } 484 485 function yui_editor_profile_submit($form, &$form_state) { 486 $profiles = variable_get('yui_editor_profiles', array()); 487 488 if (isset($form_state['values']['id'])) { 489 drupal_set_message(t('The profile has been updated.')); 490 unset($profiles[$form_state['values']['old_weight']][$form_state['values']['id']]); 491 } 492 else { 493 drupal_set_message(t('The profile has been created.')); 494 } 495 $form_state['values']['form_token'] = time(); 496 $profiles[$form_state['values']['weight']][$form_state['values']['form_token']] = $form_state['values']; 497 498 ksort($profiles); 499 ksort($profiles[$form_state['values']['weight']]); 500 variable_set('yui_editor_profiles', $profiles); 501 502 drupal_goto('admin/settings/yui_editor'); 503 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |