예제 #1
0
 function _initToolbar()
 {
     //		if (!class_exists('JToolBar')) {
     //            JLoader::register('JToolBar', JPATH_ADMINISTRATOR.'/libraries/joomla/html/toolbar.php');
     //            jimport('joomla.html.toolbar');
     //        }
     //require_once('rttoolbar.class.php');
     $bar = JToolBar::getInstance('toolbar');
     $buttons = $bar->getItems();
     //Toolbar is empty, attempt to see if it's a koowa toolbar
     //if it's not, then continue like always - TODO: find generic solution
     if (!$buttons && class_exists('KToolbarAbstract', false)) {
         $doc =& JFactory::getDocument();
         $buffer = $doc->getBuffer();
         if (is_array($buffer) && isset($buffer['modules']['toolbar'])) {
             $toolbar_buffer = $buffer['modules']['toolbar'];
             //use phpQuery to get the bits out
             if (!class_exists('phpQuery')) {
                 require_once dirname(__FILE__) . "/phpQuery.php";
             }
             $pq = phpQuery::newDocument($toolbar_buffer);
             $bits = pq('table')->find('a');
             $bar->addButtonPath($this->templatePath . DS . 'lib' . DS . 'buttons');
             foreach ($bits as $alink) {
                 $href = pq($alink)->attr('href');
                 $data = pq($alink)->attr('data');
                 $onclick = pq($alink)->attr('onclick');
                 $class = pq($alink)->attr('class');
                 $title = pq($alink)->find('span')->attr('title');
                 $bar->appendButton('koowa', $title, $href, $onclick, $data, $class);
             }
             $buttons = $bar->getItems();
         }
     }
     $newbar = array();
     $newhelp = array();
     $actions = array();
     $first = array();
     foreach ($buttons as $button) {
         if (strtolower($button[0]) == 'help') {
             $newhelp[] = $button;
         } elseif (isset($button[1]) && (strtolower($button[1]) == 'unarchive' or strtolower($button[1]) == 'archive' or strtolower($button[1]) == 'publish' or strtolower($button[1]) == 'unpublish' or strtolower($button[1]) == 'move' or strtolower($button[1]) == 'copy' or strtolower($button[1]) == 'trash' or strtolower($button[1]) == 'delete' or strtolower($button[1]) == 'tag')) {
             $actions[] = $button;
         } else {
             if (isset($button[1]) && (strtolower($button[1]) == 'new' or strtolower($button[1]) == 'apply' or strtolower($button[1]) == 'save')) {
                 $first[] = $button;
             } else {
                 $newbar[] = $button;
             }
         }
     }
     //create new toolbar object
     $toolbar = new JToolbar('toolbar');
     //$toolbar->_buttonPath[0] = $this->basePath.DS.'libraries'.DS.'joomla'.DS.'html'.DS.'toolbar'.DS.'button';
     $toolbar->setToolBar($newbar);
     //$toolbar->_bar = $newbar;
     $toolbar->setButtonPath($bar->getButtonPath());
     $toolbar->_actions = $actions;
     $toolbar->_first = $first;
     $this->toolbar = $toolbar;
     $this->actions = $actions;
     $this->first = $first;
     //new help button
     $helpbar = new JToolbar('help');
     //$helpbar->_buttonPath[0] = $this->basePath.DS.'libraries'.DS.'joomla'.DS.'html'.DS.'toolbar'.DS.'button';
     $helpbar->setToolbar($newhelp);
     $this->help = $helpbar;
 }
예제 #2
0
 function _initToolbar()
 {
     $bar = JToolBar::getInstance('toolbar');
     $buttons = $bar->getItems();
     $buffer = $this->document->getBuffer();
     //Toolbar is empty, attempt to see if it's a koowa toolbar
     //if it's not, then continue like always - TODO: find generic solution
     if (!$buttons && isset($buffer['modules']['toolbar'])) {
         $this->toolbar_output = $buffer['modules']['toolbar'];
         //new help button
         $helpbar = new JToolbar('help');
         $this->help = $helpbar;
         return;
     }
     $newbar = array();
     $newhelp = array();
     $actions = array();
     $first = array();
     foreach ($buttons as $button) {
         if (strtolower($button[0]) == 'help') {
             $newhelp[] = $button;
         } elseif (isset($button[1]) && (strtolower($button[1]) == 'unarchive' or strtolower($button[1]) == 'archive' or strtolower($button[1]) == 'publish' or strtolower($button[1]) == 'unpublish' or strtolower($button[1]) == 'move' or strtolower($button[1]) == 'copy' or strtolower($button[1]) == 'trash' or strtolower($button[1]) == 'delete' or strtolower($button[1]) == 'tag')) {
             $actions[] = $button;
         } else {
             if (isset($button[1]) && (strtolower($button[1]) == 'new' or strtolower($button[1]) == 'apply' or strtolower($button[1]) == 'save')) {
                 $first[] = $button;
             } else {
                 $newbar[] = $button;
             }
         }
     }
     //create new toolbar object
     $toolbar = new JToolbar('toolbar');
     $toolbar->setToolBar($newbar);
     $toolbar->setButtonPath($bar->getButtonPath());
     $toolbar->_actions = $actions;
     $toolbar->_first = $first;
     $this->toolbar = $toolbar;
     $this->actions = $actions;
     $this->first = $first;
     //new help button
     $helpbar = new JToolbar('help');
     $helpbar->setToolbar($newhelp);
     $this->help = $helpbar;
     $this->toolbar_output = $this->toolbar->render('toolbar');
 }