| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: toolbar.php 15180 2010-03-04 22:58:32Z ian $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 6 * @license GNU/GPL, see LICENSE.php 7 * Joomla! is free software. This version may have been modified pursuant 8 * to the GNU General Public License, and as distributed it includes or 9 * is derivative of works licensed under the GNU General Public License or 10 * other free or open source software licenses. 11 * See COPYRIGHT.php for copyright notices and details. 12 */ 13 14 // Check to ensure this file is included in Joomla! 15 defined('_JEXEC') or die( 'Restricted access' ); 16 17 jimport('joomla.html.toolbar'); 18 19 /** 20 * Utility class for the button bar 21 * 22 * @package Joomla 23 */ 24 class JToolBarHelper 25 { 26 27 /** 28 * Title cell 29 * For the title and toolbar to be rendered correctly, 30 * this title fucntion must be called before the starttable function and the toolbars icons 31 * this is due to the nature of how the css has been used to postion the title in respect to the toolbar 32 * @param string The title 33 * @param string The name of the image 34 * @since 1.5 35 */ 36 function title($title, $icon = 'generic.png') 37 { 38 global $mainframe; 39 40 //strip the extension 41 $icon = preg_replace('#\.[^.]*$#', '', $icon); 42 43 $html = "<div class=\"header icon-48-$icon\">\n"; 44 $html .= "$title\n"; 45 $html .= "</div>\n"; 46 47 $mainframe->set('JComponentTitle', $html); 48 } 49 50 /** 51 * Writes a spacer cell 52 * @param string The width for the cell 53 * @since 1.0 54 */ 55 function spacer($width = '') 56 { 57 $bar = & JToolBar::getInstance('toolbar'); 58 // Add a spacer 59 $bar->appendButton( 'Separator', 'spacer', $width ); 60 } 61 62 /** 63 * Write a divider between menu buttons 64 * @since 1.0 65 */ 66 function divider() 67 { 68 $bar = & JToolBar::getInstance('toolbar'); 69 // Add a divider 70 $bar->appendButton( 'Separator', 'divider' ); 71 } 72 73 /** 74 * Writes a custom option and task button for the button bar 75 * @param string The task to perform (picked up by the switch($task) blocks 76 * @param string The image to display 77 * @param string The image to display when moused over 78 * @param string The alt text for the icon image 79 * @param boolean True if required to check that a standard list item is checked 80 * @param boolean True if required to include callinh hideMainMenu() 81 * @since 1.0 82 */ 83 function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true, $x = false) 84 { 85 $bar = & JToolBar::getInstance('toolbar'); 86 87 //strip extension 88 $icon = preg_replace('#\.[^.]*$#', '', $icon); 89 90 // Add a standard button 91 $bar->appendButton( 'Standard', $icon, $alt, $task, $listSelect, $x ); 92 } 93 94 /** 95 * Writes a custom option and task button for the button bar. 96 * Extended version of custom() calling hideMainMenu() before submitbutton(). 97 * @param string The task to perform (picked up by the switch($task) blocks 98 * @param string The image to display 99 * @param string The image to display when moused over 100 * @param string The alt text for the icon image 101 * @param boolean True if required to check that a standard list item is checked 102 * @since 1.0 103 * (NOTE this is being deprecated) 104 */ 105 function customX($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true) 106 { 107 $bar = & JToolBar::getInstance('toolbar'); 108 109 //strip extension 110 $icon = preg_replace('#\.[^.]*$#', '', $icon); 111 112 // Add a standard button 113 $bar->appendButton( 'Standard', $icon, $alt, $task, $listSelect, true ); 114 } 115 116 /** 117 * Writes a preview button for a given option (opens a popup window) 118 * @param string The name of the popup file (excluding the file extension) 119 * @since 1.0 120 */ 121 function preview($url = '', $updateEditors = false) 122 { 123 $bar = & JToolBar::getInstance('toolbar'); 124 // Add a preview button 125 $bar->appendButton( 'Popup', 'preview', 'Preview', "$url&task=preview" ); 126 } 127 128 /** 129 * Writes a preview button for a given option (opens a popup window) 130 * @param string The name of the popup file (excluding the file extension for an xml file) 131 * @param boolean Use the help file in the component directory 132 * @since 1.0 133 */ 134 function help($ref, $com = false) 135 { 136 $bar = & JToolBar::getInstance('toolbar'); 137 // Add a help button 138 $bar->appendButton( 'Help', $ref, $com ); 139 } 140 141 /** 142 * Writes a cancel button that will go back to the previous page without doing 143 * any other operation 144 * @since 1.0 145 */ 146 function back($alt = 'Back', $href = 'javascript:history.back();') 147 { 148 $bar = & JToolBar::getInstance('toolbar'); 149 // Add a back button 150 $bar->appendButton( 'Link', 'back', $alt, $href ); 151 } 152 153 /** 154 * Writes a media_manager button 155 * @param string The sub-drectory to upload the media to 156 * @since 1.0 157 */ 158 function media_manager($folder = '', $alt = 'Upload') 159 { 160 $bar = & JToolBar::getInstance('toolbar'); 161 // Add an upload button 162 $bar->appendButton( 'Popup', 'upload', $alt, "index.php?option=com_media&tmpl=component&task=popupUpload&folder=$folder", 640, 520 ); 163 } 164 165 /** 166 * Writes the common 'new' icon for the button bar 167 * @param string An override for the task 168 * @param string An override for the alt text 169 * @since 1.0 170 */ 171 function addNew($task = 'add', $alt = 'New') 172 { 173 $bar = & JToolBar::getInstance('toolbar'); 174 // Add a new button 175 $bar->appendButton( 'Standard', 'new', $alt, $task, false, false ); 176 } 177 178 /** 179 * Writes the common 'new' icon for the button bar. 180 * Extended version of addNew() calling hideMainMenu() before submitbutton(). 181 * @param string An override for the task 182 * @param string An override for the alt text 183 * @since 1.0 184 */ 185 function addNewX($task = 'add', $alt = 'New') 186 { 187 $bar = & JToolBar::getInstance('toolbar'); 188 // Add a new button (hide menu) 189 $bar->appendButton( 'Standard', 'new', $alt, $task, false, true ); 190 } 191 192 /** 193 * Writes a common 'publish' button 194 * @param string An override for the task 195 * @param string An override for the alt text 196 * @since 1.0 197 */ 198 function publish($task = 'publish', $alt = 'Publish') 199 { 200 $bar = & JToolBar::getInstance('toolbar'); 201 // Add a publish button 202 //$bar->appendButton( 'Publish', false, $alt, $task ); 203 $bar->appendButton( 'Standard', 'publish', $alt, $task, false, false ); 204 } 205 206 /** 207 * Writes a common 'publish' button for a list of records 208 * @param string An override for the task 209 * @param string An override for the alt text 210 * @since 1.0 211 */ 212 function publishList($task = 'publish', $alt = 'Publish') 213 { 214 $bar = & JToolBar::getInstance('toolbar'); 215 // Add a publish button (list) 216 $bar->appendButton( 'Standard', 'publish', $alt, $task, true, false ); 217 } 218 219 /** 220 * Writes a common 'default' button for a record 221 * @param string An override for the task 222 * @param string An override for the alt text 223 * @since 1.0 224 */ 225 function makeDefault($task = 'default', $alt = 'Default') 226 { 227 $bar = & JToolBar::getInstance('toolbar'); 228 // Add a default button 229 $bar->appendButton( 'Standard', 'default', $alt, $task, true, false ); 230 } 231 232 /** 233 * Writes a common 'assign' button for a record 234 * @param string An override for the task 235 * @param string An override for the alt text 236 * @since 1.0 237 */ 238 function assign($task = 'assign', $alt = 'Assign') 239 { 240 $bar = & JToolBar::getInstance('toolbar'); 241 // Add an assign button 242 $bar->appendButton( 'Standard', 'assign', $alt, $task, true, false ); 243 } 244 245 /** 246 * Writes a common 'unpublish' button 247 * @param string An override for the task 248 * @param string An override for the alt text 249 * @since 1.0 250 */ 251 function unpublish($task = 'unpublish', $alt = 'Unpublish') 252 { 253 $bar = & JToolBar::getInstance('toolbar'); 254 // Add an unpublish button 255 $bar->appendButton( 'Standard', 'unpublish', $alt, $task, false, false ); 256 } 257 258 /** 259 * Writes a common 'unpublish' button for a list of records 260 * @param string An override for the task 261 * @param string An override for the alt text 262 * @since 1.0 263 */ 264 function unpublishList($task = 'unpublish', $alt = 'Unpublish') 265 { 266 $bar = & JToolBar::getInstance('toolbar'); 267 // Add an unpublish button (list) 268 269 $bar->appendButton( 'Standard', 'unpublish', $alt, $task, true, false ); 270 } 271 272 /** 273 * Writes a common 'archive' button for a list of records 274 * @param string An override for the task 275 * @param string An override for the alt text 276 * @since 1.0 277 */ 278 function archiveList($task = 'archive', $alt = 'Archive') 279 { 280 $bar = & JToolBar::getInstance('toolbar'); 281 // Add an archive button 282 $bar->appendButton( 'Standard', 'archive', $alt, $task, true, false ); 283 } 284 285 /** 286 * Writes an unarchive button for a list of records 287 * @param string An override for the task 288 * @param string An override for the alt text 289 * @since 1.0 290 */ 291 function unarchiveList($task = 'unarchive', $alt = 'Unarchive') 292 { 293 $bar = & JToolBar::getInstance('toolbar'); 294 // Add an unarchive button (list) 295 $bar->appendButton( 'Standard', 'unarchive', $alt, $task, true, false ); 296 } 297 298 /** 299 * Writes a common 'edit' button for a list of records 300 * @param string An override for the task 301 * @param string An override for the alt text 302 * @since 1.0 303 */ 304 function editList($task = 'edit', $alt = 'Edit') 305 { 306 $bar = & JToolBar::getInstance('toolbar'); 307 // Add an edit button 308 $bar->appendButton( 'Standard', 'edit', $alt, $task, true, false ); 309 } 310 311 /** 312 * Writes a common 'edit' button for a list of records. 313 * Extended version of editList() calling hideMainMenu() before submitbutton(). 314 * @param string An override for the task 315 * @param string An override for the alt text 316 * @since 1.0 317 */ 318 function editListX($task = 'edit', $alt = 'Edit') 319 { 320 $bar = & JToolBar::getInstance('toolbar'); 321 // Add an edit button (hide) 322 $bar->appendButton( 'Standard', 'edit', $alt, $task, true, true ); 323 } 324 325 /** 326 * Writes a common 'edit' button for a template html 327 * @param string An override for the task 328 * @param string An override for the alt text 329 * @since 1.0 330 */ 331 function editHtml($task = 'edit_source', $alt = 'Edit HTML') 332 { 333 $bar = & JToolBar::getInstance('toolbar'); 334 // Add an edit html button 335 $bar->appendButton( 'Standard', 'edithtml', $alt, $task, true, false ); 336 } 337 338 /** 339 * Writes a common 'edit' button for a template html. 340 * Extended version of editHtml() calling hideMainMenu() before submitbutton(). 341 * @param string An override for the task 342 * @param string An override for the alt text 343 * @since 1.0 344 */ 345 function editHtmlX($task = 'edit_source', $alt = 'Edit HTML') 346 { 347 $bar = & JToolBar::getInstance('toolbar'); 348 // Add an edit html button (hide) 349 $bar->appendButton( 'Standard', 'edithtml', $alt, $task, true, true ); 350 } 351 352 /** 353 * Writes a common 'edit' button for a template css 354 * @param string An override for the task 355 * @param string An override for the alt text 356 * @since 1.0 357 */ 358 function editCss($task = 'edit_css', $alt = 'Edit CSS') 359 { 360 $bar = & JToolBar::getInstance('toolbar'); 361 // Add an edit css button (hide) 362 $bar->appendButton( 'Standard', 'editcss', $alt, $task, true, false ); 363 } 364 365 /** 366 * Writes a common 'edit' button for a template css. 367 * Extended version of editCss() calling hideMainMenu() before submitbutton(). 368 * @param string An override for the task 369 * @param string An override for the alt text 370 * @since 1.0 371 */ 372 function editCssX($task = 'edit_css', $alt = 'Edit CSS') 373 { 374 $bar = & JToolBar::getInstance('toolbar'); 375 // Add an edit css button (hide) 376 $bar->appendButton( 'Standard', 'editcss', $alt, $task, true, true ); 377 } 378 379 /** 380 * Writes a common 'delete' button for a list of records 381 * @param string Postscript for the 'are you sure' message 382 * @param string An override for the task 383 * @param string An override for the alt text 384 * @since 1.0 385 */ 386 function deleteList($msg = '', $task = 'remove', $alt = 'Delete') 387 { 388 $bar = & JToolBar::getInstance('toolbar'); 389 // Add a delete button 390 if ($msg) { 391 $bar->appendButton( 'Confirm', $msg, 'delete', $alt, $task, true, false ); 392 } else { 393 $bar->appendButton( 'Standard', 'delete', $alt, $task, true, false ); 394 } 395 } 396 397 /** 398 * Writes a common 'delete' button for a list of records. 399 * Extended version of deleteList() calling hideMainMenu() before submitbutton(). 400 * @param string Postscript for the 'are you sure' message 401 * @param string An override for the task 402 * @param string An override for the alt text 403 * @since 1.0 404 */ 405 function deleteListX($msg = '', $task = 'remove', $alt = 'Delete') 406 { 407 $bar = & JToolBar::getInstance('toolbar'); 408 // Add a delete button (hide) 409 if ($msg) { 410 $bar->appendButton( 'Confirm', $msg, 'delete', $alt, $task, true, true ); 411 } else { 412 $bar->appendButton( 'Standard', 'delete', $alt, $task, true, true ); 413 } 414 } 415 416 /** 417 * Write a trash button that will move items to Trash Manager 418 * @since 1.0 419 */ 420 function trash($task = 'remove', $alt = 'Trash', $check = true) 421 { 422 $bar = & JToolBar::getInstance('toolbar'); 423 // Add a trash button 424 $bar->appendButton( 'Standard', 'trash', $alt, $task, $check, false ); 425 } 426 427 /** 428 * Writes a save button for a given option 429 * Apply operation leads to a save action only (does not leave edit mode) 430 * @param string An override for the task 431 * @param string An override for the alt text 432 * @since 1.0 433 */ 434 function apply($task = 'apply', $alt = 'Apply') 435 { 436 $bar = & JToolBar::getInstance('toolbar'); 437 // Add an apply button 438 $bar->appendButton( 'Standard', 'apply', $alt, $task, false, false ); 439 } 440 441 /** 442 * Writes a save button for a given option 443 * Save operation leads to a save and then close action 444 * @param string An override for the task 445 * @param string An override for the alt text 446 * @since 1.0 447 */ 448 function save($task = 'save', $alt = 'Save') 449 { 450 $bar = & JToolBar::getInstance('toolbar'); 451 // Add a save button 452 $bar->appendButton( 'Standard', 'save', $alt, $task, false, false ); 453 } 454 455 /** 456 * Writes a cancel button and invokes a cancel operation (eg a checkin) 457 * @param string An override for the task 458 * @param string An override for the alt text 459 * @since 1.0 460 */ 461 function cancel($task = 'cancel', $alt = 'Cancel') 462 { 463 $bar = & JToolBar::getInstance('toolbar'); 464 // Add a cancel button 465 $bar->appendButton( 'Standard', 'cancel', $alt, $task, false, false ); 466 } 467 468 /** 469 * Writes a configuration button and invokes a cancel operation (eg a checkin) 470 * @param string The name of the component, eg, com_content 471 * @param int The height of the popup 472 * @param int The width of the popup 473 * @param string The name of the button 474 * @param string An alternative path for the configuation xml relative to JPATH_SITE 475 * @since 1.0 476 */ 477 function preferences($component, $height='150', $width='570', $alt = 'Preferences', $path = '') 478 { 479 $user =& JFactory::getUser(); 480 if ($user->get('gid') != 25) { 481 return; 482 } 483 484 $component = urlencode( $component ); 485 $path = urlencode( $path ); 486 $bar = & JToolBar::getInstance('toolbar'); 487 // Add a configuration button 488 $bar->appendButton( 'Popup', 'config', $alt, 'index.php?option=com_config&controller=component&component='.$component.'&path='.$path, $width, $height ); 489 } 490 } 491 492 /** 493 * Utility class for the submenu 494 * 495 * @package Joomla 496 */ 497 class JSubMenuHelper 498 { 499 function addEntry($name, $link = '', $active = false) 500 { 501 $menu = &JToolBar::getInstance('submenu'); 502 $menu->appendButton($name, $link, $active); 503 } 504 } 505 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |