[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/administrator/includes/ -> menubar.html.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @author Mambo Foundation Inc see README.php
   5  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   6  * See COPYRIGHT.php for copyright notices and details.
   7  * @license GNU/GPL Version 2, see LICENSE.php
   8  *
   9  * Redistributions of files must retain the above copyright notice.
  10  *
  11  * Mambo is free software; you can redistribute it and/or
  12  * modify it under the terms of the GNU General Public License
  13  * as published by the Free Software Foundation; version 2 of the License.
  14  */
  15  
  16  /**
  17  * Utility class for the button bar
  18  */
  19  class mosMenuBar {
  20  
  21      /**
  22      * Writes the start of the button bar table
  23      */
  24      function startTable() {
  25          ?>
  26          <script type="text/javascript">
  27          <!--
  28  		function MM_swapImgRestore() { //v3.0
  29              var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  30          }
  31          //-->
  32          </script>
  33          <table cellpadding="3" cellspacing="0" border="0">
  34          <tr>
  35          <?php
  36      }
  37  
  38      /**
  39      * Writes a custom option and task button for the button bar
  40      * @param string The task to perform (picked up by the switch($task) blocks
  41      * @param string The image to display
  42      * @param string The image to display when moused over
  43      * @param string The alt text for the icon image
  44      * @param boolean True if required to check that a standard list item is checked
  45      */
  46      function custom( $task='', $icon='', $iconOver='', $alt='', $listSelect=true, $prefix='' ) {
  47          if ($listSelect) {
  48              $href = "javascript:if (document.adminForm.boxchecked.value == 0){ alert('".sprintf(T_('Please make a selection from the list to %s'),$alt)."');}else{".$prefix."submitbutton('$task')}";
  49          } else {
  50              $href = "javascript:".$prefix."submitbutton('$task')";
  51          }
  52          if ($icon && $iconOver) {
  53          ?>
  54          <td>
  55          <a class="toolbar" href="<?php echo $href;?>" onmouseout="MM_swapImgRestore();"  onmouseover="MM_swapImage('<?php echo $task;?>','','images/<?php echo $iconOver;?>',1);">
  56          <img name="<?php echo $task;?>" src="images/<?php echo $icon;?>" alt="<?php echo $alt;?>" border="0" align="middle" /><br />
  57          <?php echo $alt; ?></a>
  58          </td>
  59          <?php
  60          } else {
  61          ?>
  62          <td>
  63          <a class="toolbar" href="<?php echo $href;?>">
  64          <br />
  65          <?php echo $alt; ?></a>
  66          </td>
  67          <?php
  68          }
  69      }
  70  
  71      /**
  72      * Writes a custom option and task button for the button bar.
  73      * Extended version of custom() calling hideMainMenu() before submitbutton().
  74      * @param string The task to perform (picked up by the switch($task) blocks
  75      * @param string The image to display
  76      * @param string The image to display when moused over
  77      * @param string The alt text for the icon image
  78      * @param boolean True if required to check that a standard list item is checked
  79      */
  80      function customX( $task='', $icon='', $iconOver='', $alt='', $listSelect=true ) {
  81          mosMenuBar::custom ($task, $icon, $iconOver, $alt, $listSelect, 'hideMainMenu();');
  82      }
  83  
  84      /**
  85      * Standard routine for displaying toolbar icon
  86      * @param string An override for the task
  87      * @param string An override for the alt text
  88      * @param string The name to be used as a legend and as the image name
  89      * @param
  90      */
  91      function addToToolBar ($task, $alt, $name, $imagename, $extended=false, $listprompt='') {
  92          if (is_null($alt)) $alt = T_($name);
  93          $image = mosAdminMenus::ImageCheckAdmin( $imagename.'.png', '/administrator/images/', NULL, NULL, $alt, $task );
  94          $image2 = mosAdminMenus::ImageCheckAdmin( $imagename.'_f2.png', '/administrator/images/', NULL, NULL, $alt, $task, 0 );
  95          ?>
  96          <td>
  97          <a class="toolbar" href="javascript:<?php echo mosMenuBar::makeJavaScript ($task, $extended, $listprompt); ?>" onmouseout="MM_swapImgRestore();"  onmouseover="MM_swapImage('<?php echo $task;?>','','<?php echo $image2; ?>',1);">
  98          <?php
  99          echo $image;
 100          echo '<br />';
 101          echo $alt;
 102          ?>
 103          </a>
 104          </td>
 105          <?php
 106      }
 107  
 108      function makeJavaScript ($task, $extended, $listprompt='') {
 109          $script = '';
 110          if ($listprompt) $script .= "if (document.adminForm.boxchecked.value == 0){ alert('$listprompt'); } else";
 111          $script .= '{';
 112          if ($extended) $script .= 'hideMainMenu();';
 113          $script .= "submitbutton('$task')}";
 114          return $script;
 115      }
 116  
 117      // @RawSQLUse, trivial_implementation, SELECT
 118      function getTemplate () {
 119          global $database;
 120          $sql = "SELECT template FROM #__templates_menu WHERE client_id='1' AND menuid='0'";
 121          $database->setQuery( $sql );
 122          return $database->loadResult();
 123      }
 124  
 125      /**
 126      * Writes the common 'new' icon for the button bar
 127      * @param string An override for the task
 128      * @param string An override for the alt text
 129      */
 130      function addNew( $task='new', $alt=null ) {
 131          mosMenuBar::addToToolBar ($task, $alt, T_('New'), 'new');
 132      }
 133  
 134      /**
 135      * Writes the common 'new' icon for the button bar.
 136      * Extended version of addNew() calling hideMainMenu() before submitbutton().
 137      * @param string An override for the task
 138      * @param string An override for the alt text
 139      */
 140      function addNewX( $task='new', $alt=null ) {
 141          mosMenuBar::addToToolBar ($task, $alt, T_('New'), 'new', true);
 142      }
 143  
 144      /**
 145      * Writes a common 'publish' button
 146      * @param string An override for the task
 147      * @param string An override for the alt text
 148      */
 149      function publish( $task='publish', $alt=null ) {
 150          mosMenuBar::addToToolBar ($task, $alt, T_('Publish'), 'publish');
 151      }
 152  
 153      /**
 154      * Writes a common 'publish' button for a list of records
 155      * @param string An override for the task
 156      * @param string An override for the alt text
 157      */
 158      function publishList( $task='publish', $alt=null ) {
 159          $listprompt = T_('Please make a selection from the list to publish');
 160          mosMenuBar::addToToolBar ($task, $alt, T_('Publish'), 'publish', false, $listprompt);
 161      }
 162  
 163      /**
 164      * Writes a common 'default' button for a record
 165      * @param string An override for the task
 166      * @param string An override for the alt text
 167      */
 168      function makeDefault( $task='default', $alt=null ) {
 169          $listprompt = T_('Please select an item to make default');
 170          mosMenuBar::addToToolBar ($task, $alt, T_('Default'), 'publish', false, $listprompt);
 171      }
 172  
 173      /**
 174      * Writes a common 'assign' button for a record
 175      * @param string An override for the task
 176      * @param string An override for the alt text
 177      */
 178      function assign( $task='assign', $alt=null ) {
 179          $listprompt = T_('Please select an item to assign');
 180          mosMenuBar::addToToolBar ($task, $alt, T_('Assign'), 'publish', false, $listprompt);
 181      }
 182  
 183      /**
 184      * Writes a common 'unpublish' button
 185      * @param string An override for the task
 186      * @param string An override for the alt text
 187      */
 188      function unpublish( $task='unpublish', $alt=null ) {
 189          mosMenuBar::addToToolBar ($task, $alt, T_('Unpublish'), 'unpublish');
 190      }
 191  
 192      /**
 193      * Writes a common 'unpublish' button for a list of records
 194      * @param string An override for the task
 195      * @param string An override for the alt text
 196      */
 197      function unpublishList( $task='unpublish', $alt=null ) {
 198          $listprompt = T_('Please make a selection from the list to unpublish');
 199          mosMenuBar::addToToolBar ($task, $alt, T_('Unpublish'), 'unpublish', false, $listprompt);
 200      }
 201  
 202      /**
 203      * Writes a common 'archive' button for a list of records
 204      * @param string An override for the task
 205      * @param string An override for the alt text
 206      */
 207      function archiveList( $task='archive', $alt=null ) {
 208          $listprompt = T_('Please make a selection from the list to archive');
 209          mosMenuBar::addToToolBar ($task, $alt, T_('Archive'), 'archive', false, $listprompt);
 210      }
 211  
 212      /**
 213      * Writes an unarchive button for a list of records
 214      * @param string An override for the task
 215      * @param string An override for the alt text
 216      */
 217      function unarchiveList( $task='unarchive', $alt=null ) {
 218          $listprompt = T_('Please select a news story to unarchive');
 219          mosMenuBar::addToToolBar ($task, $alt, T_('Unarchive'), 'unarchive', false, $listprompt);
 220      }
 221  
 222      /**
 223      * Writes a common 'edit' button for a list of records
 224      * @param string An override for the task
 225      * @param string An override for the alt text
 226      */
 227      function editList( $task='edit', $alt=null ) {
 228          $listprompt = T_('Please select an item from the list to edit');
 229          mosMenuBar::addToToolBar ($task, $alt, T_('Edit'), 'edit', false, $listprompt);
 230      }
 231  
 232      /**
 233      * Writes a common 'edit' button for a list of records.
 234      * Extended version of editList() calling hideMainMenu() before submitbutton().
 235      * @param string An override for the task
 236      * @param string An override for the alt text
 237      */
 238      function editListX( $task='edit', $alt=null ) {
 239          $listprompt = T_('Please select an item from the list to edit');
 240          mosMenuBar::addToToolBar ($task, $alt, T_('Edit'), 'edit', true, $listprompt);
 241      }
 242  
 243      /**
 244      * Writes a common 'edit' button for a template html
 245      * @param string An override for the task
 246      * @param string An override for the alt text
 247      */
 248      function editHtml( $task='edit_source', $alt=null ) {
 249          $listprompt = T_('Please select an item from the list to edit');
 250          mosMenuBar::addToToolBar ($task, $alt, T_('Edit HTML'), 'html', false, $listprompt);
 251      }
 252  
 253      /**
 254      * Writes a common 'edit' button for a template html.
 255      * Extended version of editHtml() calling hideMainMenu() before submitbutton().
 256      * @param string An override for the task
 257      * @param string An override for the alt text
 258      */
 259      function editHtmlX( $task='edit_source', $alt=null ) {
 260          $listprompt = T_('Please select an item from the list to edit');
 261          mosMenuBar::addToToolBar ($task, $alt, T_('Edit HTML'), 'html', true, $listprompt);
 262      }
 263  
 264      /**
 265      * Writes a common 'edit' button for a template css
 266      * @param string An override for the task
 267      * @param string An override for the alt text
 268      */
 269      function editCss( $task='edit_css', $alt=null ) {
 270          $listprompt = T_('Please select an item from the list to edit');
 271          mosMenuBar::addToToolBar ($task, $alt, T_('Edit CSS'), 'css', false, $listprompt);
 272      }
 273  
 274      /**
 275      * Writes a common 'edit' button for a template css.
 276      * Extended version of editCss() calling hideMainMenu() before submitbutton().
 277      * @param string An override for the task
 278      * @param string An override for the alt text
 279      */
 280      function editCssX( $task='edit_css', $alt=null ) {
 281          $listprompt = T_('Please select an item from the list to edit');
 282          mosMenuBar::addToToolBar ($task, $alt, T_('Edit CSS'), 'css', true, $listprompt);
 283      }
 284  
 285      /**
 286      * Writes a common 'delete' button for a list of records
 287      * @param string  Postscript for the 'are you sure' message
 288      * @param string An override for the task
 289      * @param string An override for the alt text
 290      */
 291      function deleteList( $msg='', $task='remove', $alt=null ) {
 292          $listprompt = T_('Please make a selection from the list to delete');
 293          mosMenuBar::addToToolBar ($task, $alt, T_('Delete'), 'delete', false, $listprompt);
 294      }
 295  
 296      /**
 297      * Writes a common 'delete' button for a list of records.
 298      * Extended version of deleteList() calling hideMainMenu() before submitbutton().
 299      * @param string  Postscript for the 'are you sure' message
 300      * @param string An override for the task
 301      * @param string An override for the alt text
 302      */
 303      function deleteListX( $msg='', $task='remove', $alt=null ) {
 304          $listprompt = T_('Please make a selection from the list to delete');
 305          mosMenuBar::addToToolBar ($task, $alt, T_('Delete'), 'delete', true, $listprompt);
 306      }
 307  
 308      /**
 309      * Write a trash button that will move items to Trash Manager
 310      */
 311      function trash( $task='remove', $alt=null ) {
 312          mosMenuBar::addToToolBar ($task, $alt, T_('Trash'), 'delete');
 313      }
 314  
 315      /**
 316      * Writes a preview button for a given option (opens a popup window)
 317      * @param string The name of the popup file (excluding the file extension)
 318      */
 319      function preview( $popup='', $updateEditors=false ) {
 320          $image = mosAdminMenus::ImageCheckAdmin( 'preview.png', '/administrator/images/', NULL, NULL, T_('Preview'), 'preview' );
 321          $image2 = mosAdminMenus::ImageCheckAdmin( 'preview_f2.png', '/administrator/images/', NULL, NULL, T_('Preview'), 'preview', 0 );
 322          $cur_template = mosMenuBar::getTemplate();
 323          ?>
 324          <td>
 325          <script type="text/javascript">
 326  		function popup() {
 327              <?php
 328              if ($popup == 'contentwindow') {
 329                  getEditorContents( 'editor1', 'introtext' );
 330                  getEditorContents( 'editor2', 'fulltext' );
 331              }
 332              elseif ($popup == 'modulewindow') getEditorContents( 'editor1', 'content' );
 333              ?>
 334              window.open('index3.php?pop=/<?php echo $popup;?>.php&amp;t=<?php echo $cur_template; ?>', 'win1', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no');
 335          }
 336          </script>
 337           <a class="toolbar" href="#" onclick="popup();" onmouseout="MM_swapImgRestore();"  onmouseover="MM_swapImage('preview','','<?php echo $image2; ?>',1);">
 338          <?php echo $image; ?><br />
 339          <?php echo T_('Preview'); ?>
 340          </a>
 341          </td>
 342          <?php
 343      }
 344  
 345      /**
 346      * Writes a preview button for a given option (opens a popup window)
 347      * @param string The name of the popup file (excluding the file extension for an xml file)
 348      * @param boolean Use the help file in the component directory
 349      */
 350      function help( $ref, $com=false ) {
 351          $image = mosAdminMenus::ImageCheckAdmin( 'help.png', '/administrator/images/', NULL, NULL, T_('Help'), 'help' );
 352          $image2 = mosAdminMenus::ImageCheckAdmin( 'help_f2.png', '/administrator/images/', NULL, NULL, T_('Help'), 'help', 0 );
 353          $mosConfig_live_site = mamboCore::get('mosConfig_live_site');
 354          $rootpath = mamboCore::get('rootPath');
 355          /*$helpUrl = mosGetParam( $GLOBALS, 'mosConfig_helpurl', '' );
 356          if ($helpUrl) {
 357          $url = $helpUrl . '/index2.php?option=com_content&amp;task=findkey&pop=1&keyref=' . urlencode( $ref );
 358          } else {*/
 359          $option = $GLOBALS['option'];
 360          if (substr($option,0,4) != 'com_') $option = "com_$option";
 361          $component = substr($option, 4);
 362          if ($com) {
 363              $url = '/administrator/components/' . $option . '/help/';
 364          }else{
 365              $url = '/help/';
 366          }
 367          $ref = $component.'.'.$ref . '.html';
 368          $url .= $ref;
 369  
 370          if (!file_exists($rootpath.'/help/'.$ref)) return false;
 371          $url = $mosConfig_live_site . $url;
 372  
 373          
 374          /*}*/
 375  
 376          ?>
 377          <td>
 378          <a class="toolbar" href="#" onclick="window.open('<?php echo $url;?>', 'mambo_help_win', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no');" onmouseout="MM_swapImgRestore();"  onmouseover="MM_swapImage('help','','<?php echo $image2; ?>',1);">
 379          <?php echo $image . '<br />' . T_('Help'); ?>
 380          </a>
 381          </td>
 382          <?php
 383      }
 384  
 385      /**
 386      * Writes a save button for a given option
 387      * Apply operation leads to a save action only (does not leave edit mode)
 388      * @param string An override for the task
 389      * @param string An override for the alt text
 390      */
 391      function apply( $task='apply', $alt=null ) {
 392          mosMenuBar::addToToolBar ($task, $alt, T_('Apply'), 'apply');
 393      }
 394  
 395      /**
 396      * Writes a save button for a given option
 397      * Save operation leads to a save and then close action
 398      * @param string An override for the task
 399      * @param string An override for the alt text
 400      */
 401      function save( $task='save', $alt=null ) {
 402          mosMenuBar::addToToolBar ($task, $alt, T_('Save'), 'save');
 403      }
 404  
 405      /**
 406      * Writes a save button for a given option (NOTE this is being deprecated)
 407      */
 408      function savenew() {
 409          $image = mosAdminMenus::ImageCheckAdmin( 'save.png', '/administrator/images/', NULL, NULL, 'save', 'save' );
 410          $image2 = mosAdminMenus::ImageCheckAdmin( 'save_f2.png', '/administrator/images/', NULL, NULL, 'save', 'save', 0 );
 411          ?>
 412          <td>
 413          <a class="toolbar" href="javascript:submitbutton('savenew');" onmouseout="MM_swapImgRestore();"  onmouseover="MM_swapImage('save','','<?php echo $image2; ?>',1);">
 414          <?php echo $image; ?><br />
 415          <?php echo T_('Save'); ?>
 416          </a>
 417          </td>
 418          <?php
 419      }
 420  
 421      /**
 422      * Writes a save button for a given option (NOTE this is being deprecated)
 423      */
 424      function saveedit() {
 425          $image = mosAdminMenus::ImageCheckAdmin( 'save.png', '/administrator/images/', NULL, NULL, 'save', 'save' );
 426          $image2 = mosAdminMenus::ImageCheckAdmin( 'save_f2.png', '/administrator/images/', NULL, NULL, 'save', 'save', 0 );
 427          ?>
 428          <td>
 429          <a class="toolbar" href="javascript:submitbutton('saveedit');" onmouseout="MM_swapImgRestore();"  onmouseover="MM_swapImage('save','','<?php echo $image2; ?>',1);">
 430          <?php echo $image; ?><br />
 431          <?php echo T_('Save'); ?>
 432          </a>
 433          </td>
 434          <?php
 435      }
 436  
 437      /**
 438      * Writes a cancel button and invokes a cancel operation (eg a checkin)
 439      * @param string An override for the task
 440      * @param string An override for the alt text
 441      */
 442      function cancel( $task='cancel', $alt=null ) {
 443          mosMenuBar::addToToolBar ($task, $alt, T_('Cancel'), 'cancel');
 444      }
 445  
 446      /**
 447      * Writes a cancel button that will go back to the previous page without doing
 448      * any other operation
 449      */
 450      function back( $alt=null, $href='' ) {
 451          if (is_null($alt)) $alt = T_('Back');
 452          $image = mosAdminMenus::ImageCheckAdmin( 'back.png', '/administrator/images/', NULL, NULL, 'back', 'cancel' );
 453          $image2 = mosAdminMenus::ImageCheckAdmin( 'back_f2.png', '/administrator/images/', NULL, NULL, 'back', 'cancel', 0 );
 454          if ( $href ) {
 455              $link = $href;
 456          } else {
 457              $link = 'javascript:window.history.back();';
 458          }
 459          ?>
 460          <td>
 461          <a class="toolbar" href="<?php echo $link; ?>" onmouseout="MM_swapImgRestore();"  onmouseover="MM_swapImage('cancel','','<?php echo $image2; ?>',1);">
 462          <?php echo $image; ?><br />
 463          <?php echo $alt;?>
 464          </a>
 465          </td>
 466          <?php
 467      }
 468  
 469      /**
 470      * Write a divider between menu buttons
 471      */
 472      function divider() {
 473          $image = mosAdminMenus::ImageCheckAdmin( 'menu_divider.png', '/administrator/images/' );
 474          ?>
 475          <td>
 476          <?php echo $image; ?>
 477          </td>
 478          <?php
 479      }
 480  
 481      /**
 482      * Writes a media_manager button
 483      * @param string The sub-drectory to upload the media to
 484      */
 485      function media_manager( $directory = '', $alt=null ) {
 486          if (is_null($alt)) $alt = T_('Upload');
 487          $cur_template = mosMenuBar::getTemplate();
 488          $image = mosAdminMenus::ImageCheckAdmin( 'upload.png', '/administrator/images/', NULL, NULL, T_('Upload Image'), 'uploadPic' );
 489          $image2 = mosAdminMenus::ImageCheckAdmin( 'upload_f2.png', '/administrator/images/', NULL, NULL, T_('Upload Image'), 'uploadPic', 0 );
 490          ?>
 491          <td>
 492          <a class="toolbar" href="#" onclick="popupWindow('index3.php?pop=uploadimage.php&amp;directory=<?php echo $directory; ?>&amp;t=<?php echo $cur_template; ?>','win1',350,100,'no');" onmouseout="MM_swapImgRestore();"  onmouseover="MM_swapImage('uploadPic','','<?php echo $image2; ?>',1);">
 493          <?php echo $image; ?><br />
 494          <?php echo $alt;?>
 495          </a>
 496          </td>
 497          <?php
 498      }
 499  
 500      /**
 501      * Writes a spacer cell
 502      * @param string The width for the cell
 503      */
 504      function spacer( $width='' )
 505      {
 506          if ($width != '') {
 507  ?>
 508          <td width="<?php echo $width;?>">&nbsp;</td>
 509  <?php
 510          } else {
 511  ?>
 512          <td>&nbsp;</td>
 513  <?php
 514          }
 515      }
 516  
 517      /**
 518      * Writes the end of the menu bar table
 519      */
 520      function endTable() {
 521          ?>
 522          </tr>
 523          </table>
 524          <?php
 525      }
 526  }
 527  ?>