Source for file menubar.html.php

Documentation is available at menubar.html.php

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

Documentation generated on Mon, 05 May 2008 16:21:10 +0400 by phpDocumentor 1.4.0