aliroAdminToolbar.php

Go to the documentation of this file.
00001 <?php
00006 class aliroAdminToolbar extends aliroFriendlyBase  {
00007 
00008     private static $instance = __CLASS__;
00009 
00010     private $template = null;
00011 
00012     protected function __construct() {
00013         $this->template = $this->getTemplateObject();
00014     }
00015 
00016     private function __clone () {
00017         // Enforce singleton
00018     }
00019 
00020     public static function getInstance () {
00021         return is_object(self::$instance) ? self::$instance : (self::$instance = new self::$instance());
00022     }
00023 
00024     function show () {
00025         $version = version::getInstance();
00026         $aliroVersion = $version->RELEASE.'/'.$version->DEV_STATUS.'/'.$version->DEV_LEVEL;
00027         if ($component = $this->getComponentObject()) {
00028             if ($class = $component->adminclass) {
00029                 $controller = new $class($component, "Aliro", $aliroVersion);
00030                 $controller->toolbar();
00031             }
00032             else {
00033                 if ($path = mosMainFrame::getInstance()->getPath( 'toolbar', $this->getOption() ) AND file_exists($path)) {
00034                     $this->invokeRetroCode($path);
00035                 }
00036             }
00037         }
00038     }
00039 
00040     public function imageCheck ( $file, $directory, $param=NULL, $param_directory=NULL, $alt=NULL, $name=NULL, $type=1, $align='middle' ) {
00041         if (is_null($param_directory)) $param_directory = $this->admin_dir.'/images/';
00042         if ($param) $image = $this->getCfg('live_site').$param_directory.$param;
00043         else {
00044             $morepath = '/templates/'.$this->getTemplate().'/images/'.$file;
00045             $image = file_exists($this->admin_absolute_path.$morepath) ? $this->getCfg('admin_site').$morepath : $this->getCfg('live_site').$directory.$file;
00046         }
00047         if ($type) $image = <<<IMAGE
00048         <img src="$image" align="$align" alt="$alt" name="$name" border="0" />
00049 IMAGE;
00050 
00051         return $image;
00052     }
00053 
00054     public function addToToolBar ($task, $alt, $name, $imagename, $extended=false, $listprompt='') {
00055         if (!$alt) $alt = $name;
00056         $image = $this->imageCheck ( $imagename.'.png', $this->admin_dir.'/images/', NULL, NULL, $alt, $task );
00057         $image2 = $this->imageCheck ( $imagename.'_f2.png', $this->admin_dir.'/images/', NULL, NULL, $alt, $task, 0 );
00058         $href = 'javascript:'.$this->template->makeJavaScript ($task, $extended, $listprompt);
00059         $this->template->toolBarItemHTML($task, $alt, $href, $image, $image2);
00060     }
00061 
00062     public function custom($task='', $icon='', $iconOver='', $alt='', $listSelect=true, $prefix='' ) {
00063         // if ($prefix) trigger_error(T_('Aliro does not support the prefix parameter for toolbar entries'));
00064         if ($listSelect) {
00065             $message = sprintf(T_('Please make a selection from the list to %s'),$alt);
00066             $href = <<<TOOL_SCRIPT
00067         javascript:if (document.adminForm.boxchecked.value == 0)
00068         { alert('$message'); }
00069         else{{$prefix}submitbutton('$task')}
00070 TOOL_SCRIPT;
00071             /*
00072             $href = <<<TOOL_HREF
00073 javascript:selectAlert('$message','$task')
00074 TOOL_HREF;
00075         */
00076         }
00077         else $href = "javascript:{$prefix}submitbutton('$task')";
00078         $icon = $this->imageCheck ($icon, '', $icon, NULL, $alt, $task);
00079         $this->template->toolBarItemHTML ($task, $alt, $href, $icon, $this->getCfg('admin_site').'/images/'.$iconOver);
00080     }
00081 
00082     public function customX( $task='', $icon='', $iconOver='', $alt='', $listSelect=true ) {
00083         $this->custom ($task, $icon, $iconOver, $alt, $listSelect, 'hideMainMenu();');
00084     }
00085 
00086     public function addNew( $task='new', $alt=null ) {
00087         $this->addToToolBar ($task, $alt, T_('New'), 'new');
00088     }
00089 
00090     public function addNewX( $task='new', $alt=null ) {
00091         $this->addToToolBar ($task, $alt, T_('New'), 'new', true);
00092     }
00093 
00094     public function publish( $task='publish', $alt=null ) {
00095         $this->addToToolBar ($task, $alt, T_('Publish'), 'publish');
00096     }
00097 
00098     public function publishList( $task='publish', $alt=null ) {
00099         $listprompt = T_('Please make a selection from the list to publish');
00100         $this->addToToolBar ($task, $alt, T_('Publish'), 'publish', false, $listprompt);
00101     }
00102 
00103     public function makeDefault( $task='default', $alt=null ) {
00104         $listprompt = T_('Please select an item to make default');
00105         $this->addToToolBar ($task, $alt, T_('Default'), 'publish', false, $listprompt);
00106     }
00107 
00108     public function assign( $task='assign', $alt=null ) {
00109         $listprompt = T_('Please select an item to assign');
00110         $this->addToToolBar ($task, $alt, T_('Assign'), 'publish', false, $listprompt);
00111     }
00112 
00113     public function unpublish( $task='unpublish', $alt=null ) {
00114         $this->addToToolBar ($task, $alt, T_('Unpublish'), 'unpublish');
00115     }
00116 
00117     public function unpublishList( $task='unpublish', $alt=null ) {
00118         $listprompt = T_('Please make a selection from the list to unpublish');
00119         $this->addToToolBar ($task, $alt, T_('Unpublish'), 'unpublish', false, $listprompt);
00120     }
00121 
00122     function archiveList( $task='archive', $alt=null ) {
00123         $listprompt = T_('Please make a selection from the list to archive');
00124         $this->addToToolBar ($task, $alt, T_('Archive'), 'archive', false, $listprompt);
00125     }
00126 
00127     public function unarchiveList( $task='unarchive', $alt=null ) {
00128         $listprompt = T_('Please select a news story to unarchive');
00129         $this->addToToolBar ($task, $alt, T_('Unarchive'), 'unarchive', false, $listprompt);
00130     }
00131 
00132     public function editList( $task='edit', $alt=null ) {
00133         $listprompt = T_('Please select an item from the list to edit');
00134         $this->addToToolBar ($task, $alt, T_('Edit'), 'edit', false, $listprompt);
00135     }
00136 
00137     public function editListX( $task='edit', $alt=null ) {
00138         $listprompt = T_('Please select an item from the list to edit');
00139         $this->addToToolBar ($task, $alt, T_('Edit'), 'edit', true, $listprompt);
00140     }
00141 
00142     public function editHtml( $task='edit_source', $alt=null ) {
00143         $listprompt = T_('Please select an item from the list to edit');
00144         $this->addToToolBar ($task, $alt, T_('Edit HTML'), 'html', false, $listprompt);
00145     }
00146 
00147     public function editHtmlX( $task='edit_source', $alt=null ) {
00148         $listprompt = T_('Please select an item from the list to edit');
00149         $this->addToToolBar ($task, $alt, T_('Edit HTML'), 'html', true, $listprompt);
00150     }
00151 
00152     public function editCss( $task='edit_css', $alt=null ) {
00153         $listprompt = T_('Please select an item from the list to edit');
00154         $this->addToToolBar ($task, $alt, T_('Edit CSS'), 'css', false, $listprompt);
00155     }
00156 
00157     public function editCssX( $task='edit_css', $alt=null ) {
00158         $listprompt = T_('Please select an item from the list to edit');
00159         $this->addToToolBar ($task, $alt, T_('Edit CSS'), 'css', true, $listprompt);
00160     }
00161 
00162     public function deleteList( $msg='', $task='remove', $alt=null ) {
00163         $listprompt = T_('Please make a selection from the list to delete');
00164         $this->addToToolBar ($task, $alt, T_('Delete'), 'delete', false, $listprompt);
00165     }
00166 
00167     public function deleteListX( $msg='', $task='remove', $alt=null ) {
00168         $listprompt = T_('Please make a selection from the list to delete');
00169         $this->addToToolBar ($task, $alt, T_('Delete'), 'delete', true, $listprompt);
00170     }
00171 
00172     public function trash( $task='remove', $alt=null ) {
00173         $this->addToToolBar ($task, $alt, T_('Trash'), 'delete');
00174     }
00175 
00176     // Aliro does not support popup windows because of accessibility problems
00177     // Components requiring preview should adapt their code accordingly
00178     public function preview( $popup='', $updateEditors=false ) {
00179     }
00180 
00181     public function help( $ref, $com=false ) {
00182         $image = $this->imageCheck ( 'help.png', $this->admin_dir.'/images/', NULL, NULL, T_('Help'), 'help' );
00183         $image2 = $this->imageCheck ( 'help_f2.png', $this->admin_dir.'/images/', NULL, NULL, T_('Help'), 'help', 0 );
00184         $url = $this->getCfg('live_site').'/help/';
00185         $option = $this->getOption();
00186         if ($com) $url = $this->getCfg('admin_site').'/components/'.$option.'/help/';
00187         $url .= substr($option, 4).'.'.$ref . '.html';
00188         $this->template->toolBarItemHTML ('help', T_('Help'), $url, $image, $image2, false);
00189     }
00190 
00191     public function apply( $task='apply', $alt=null ) {
00192         $this->addToToolBar ($task, $alt, T_('Apply'), 'apply');
00193     }
00194 
00195     public function save( $task='save', $alt=null ) {
00196         $this->addToToolBar ($task, $alt, T_('Save'), 'save');
00197     }
00198 
00202     public function savenew() {
00203         $this->addToToolBar ('savenew', null, T_('Save'), 'save');
00204     }
00205 
00209     public function saveedit() {
00210         $this->addToToolBar ('saveedit', null, T_('Save'), 'save');
00211     }
00212 
00213     public function cancel( $task='cancel', $alt=null ) {
00214         $this->addToToolBar ($task, $alt, T_('Cancel'), 'cancel');
00215     }
00216 
00222     public function back( $alt=null, $href='' ) {
00223         if (is_null($alt)) $alt = T_('Back');
00224         $image = $this->imageCheck ( 'back.png', $this->admin_dir.'/images/', NULL, NULL, 'back', 'cancel' );
00225         $image2 = $this->imageCheck ( 'back_f2.png', $this->admin_dir.'/images/', NULL, NULL, 'back', 'cancel', 0 );
00226         if ($href OR $this->getStickyAliroParam($_POST, 'alironoscript')) $link = $href;
00227         else $link = 'javascript:window.history.back();';
00228         if ($link) $this->template->toolBarItemHTML ('back', $alt, $link, $image, $image2, (strpos($href, 'javascript:') === false));
00229     }
00230 
00234     public function divider() {
00235         $image = $this->imageCheck ('menu_divider.png', $this->admin_dir.'/images/');
00236         $this->template->divider($image);
00237     }
00238 
00243     public function mediaManager( $directory = '', $alt=null ) {
00244         if (is_null($alt)) $alt = T_('Upload');
00245         $image = mosAdminMenus::ImageCheckAdmin( 'upload.png', $this->admin_dir.'/images/', NULL, NULL, T_('Upload Image'), 'uploadPic' );
00246         $image2 = mosAdminMenus::ImageCheckAdmin( 'upload_f2.png', $this->admin_dir.'/images/', NULL, NULL, T_('Upload Image'), 'uploadPic', 0 );
00247         $href = $this->getCfg('admin_site').'/index.php?option=com_media';
00248         $this->template->toolBarItemHTML ('uploadPic', $alt, $href, $image, $image2, false);
00249     }
00250 
00254     public function endTable() {
00255     }
00256 
00257 }

Generated on Wed May 14 13:01:55 2008 for ALIRO by  doxygen 1.5.5