private function getXMLParams()
 {
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_menus' . DS . 'models' . DS . 'item.php';
     $item = MenusModelItem::getItem();
     $xml_params = new JParameter($item->params);
     $path = JPATH_SITE . DS . 'plugins' . DS . 'system' . DS . 'addkeywords' . DS . 'metadata.xml';
     if (file_exists($path)) {
         $xml =& JFactory::getXMLParser('Simple');
         if ($xml->loadFile($path)) {
             $xml_document =& $xml->document;
             $xml_params->setXML($xml_document->getElementByPath('state/params'));
         }
     }
     return $xml_params;
 }
 function &getItem()
 {
     static $item;
     if (isset($item)) {
         return $item;
     }
     $table = parent::getItem();
     $clone = clone $table;
     // get an empty version for the defalut
     JRequest::setVar("edit", false);
     $table = null;
     JRequest::setVar('cid', array(0));
     $table = parent::getItem();
     $item = clone $table;
     $item->componentid = $clone->componentid;
     $item->type = $clone->type;
     $item->menutype = $clone->menutype;
     $component = $this->getComponent();
     // restore original
     $table = $clone;
     return $item;
 }
 public function getItem($translation = null)
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_menus/tables');
     $table = clone parent::getItem();
     // I could pick up the URL here or treat as a special content element field type?
     if ($table->type == 'component') {
         // Note that to populate the initial value of the urlparams
         $conf = JFactory::getConfig();
         $elementTable = $conf->getValue('joomfish.elementTable', false);
         foreach ($elementTable->Fields as $efield) {
             if ($efield->Name == "link" && isset($efield->translationContent->value) && $efield->translationContent->value !== "") {
                 $uri = new JURI($efield->translationContent->value);
                 if ($uri->getVar("option", false)) {
                     $table->link = $efield->translationContent->value;
                 }
             }
         }
         $url = str_replace('index.php?', '', $table->link);
         $url = str_replace('&', '&', $url);
         $table->linkparts = null;
         if (strpos($url, '&') !== false) {
             $url = str_replace('&', '&', $url);
         }
         parse_str($url, $table->linkparts);
         $db = $this->getDBO();
         if ($component = @$table->linkparts['option']) {
             $query = 'SELECT `extension_id`' . ' FROM `#__extensions`' . ' WHERE `element` = "' . $db->getEscaped($component) . '"';
             $db->setQuery($query);
             $table->componentid = $db->loadResult();
         }
     }
     $item = $table;
     return $item;
 }