Ejemplo n.º 1
0
 public function get()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/item.php';
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
     $model = JModel::getInstance('item', 'K2Model');
     $item = (object) $model->getData()->getProperties();
     if (JRequest::getVar('formready', 1)) {
         jimport('joomla.html.parameter');
         $meta = new JParameter($item->metadata);
         $item->metadata = $meta->toObject();
         $item->params = json_decode($item->params);
         $item->tags = $model->getCurrentTags($item->id);
     }
     $this->plugin->setResponse($item);
 }
Ejemplo n.º 2
0
 /**
  * Legacy function, use {@link JParameter::toObject() JParameter->toObject()} instead
  *
  * @deprecated As of version 1.5
  */
 function toObject()
 {
     parent::toObject();
 }
Ejemplo n.º 3
0
 /**
  * Internal function to get the component settings
  *
  * @return	an object with global settings
  * @since	0.5.7
  * @throws	Exception
  */
 public function getParams()
 {
     // Getting the categories id's
     $query = "SELECT params\n\t\t\t\t\t\t\tFROM jos_components AS c\n\t\t\t\t\t\t\tWHERE c.option = 'com_jupgrade'";
     $this->db_old->setQuery($query);
     $params = $this->db_old->loadResult();
     // Check for query error.
     $error = $this->db_old->getErrorMsg();
     if ($error) {
         throw new Exception($error);
         return false;
     }
     $temp = new JParameter($params);
     $object = $temp->toObject();
     return $object;
 }
Ejemplo n.º 4
0
 function loadMenu()
 {
     $user =& JFactory::getUser();
     $children = array();
     $aid = $user->get('aid', 0);
     // Get Menu Items
     $menu =& JSite::getMenu();
     $rows = $menu->getItems('menutype', $this->getParam('menutype'));
     if (!count($rows)) {
         $this->setParam('menutype', 'mainmenu');
         $rows = $menu->getItems('menutype', 'mainmenu');
     }
     // search the active tree
     $open = array();
     $active = $menu->getActive();
     if (isset($active)) {
         if ($active->menutype != $this->getParam('menutype')) {
             //detect the active in this menu: point to same link or is alias
             foreach ($rows as $index => $v) {
                 if ($v->link == $active->link || $v->type == 'menulink' && !empty($v->query['Itemid'])) {
                     $open = array_reverse($v->tree);
                     break;
                 }
             }
         } else {
             $open = array_reverse($active->tree);
         }
     }
     $this->open = $open;
     if (!count($rows)) {
         return;
     }
     // first pass - collect children
     $cacheIndex = array();
     $this->items = array();
     foreach ($rows as $index => $v) {
         if (isset($v->title)) {
             $v->name = $v->title;
         }
         $v->name = str_replace('&', '&', str_replace('&', '&', $v->name));
         if ($v->access <= $aid) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             $v->megaparams = $this->parseTitle($v->name);
             $v->megaparams->set('class', str_replace(',', ' ', $v->megaparams->get('class', '')));
             $v->name = trim($v->megaparams->get('title'));
             //Load params added by plugin
             $vparams = new JParameter($v->params);
             //get mega params
             $megaparams = $vparams->toObject();
             if ($megaparams) {
                 foreach (get_object_vars($megaparams) as $mega_name => $mega_value) {
                     if (preg_match('/mega_(.+)/', $mega_name, $matches)) {
                         if ($matches[1] == 'colxw') {
                             if (preg_match_all('/([^\\s]+)=([^\\s]+)/', $mega_value, $colwmatches)) {
                                 for ($i = 0; $i < count($colwmatches[0]); $i++) {
                                     $v->megaparams->set($colwmatches[1][$i], $colwmatches[2][$i]);
                                 }
                             }
                         } else {
                             if (is_array($mega_value)) {
                                 $mega_value = implode(',', $mega_value);
                             }
                             $v->megaparams->set($matches[1], $mega_value);
                         }
                     }
                 }
             }
             //reset cols for group item
             //if ($v->megaparams->get('group')) $v->megaparams->set('cols', 1);
             if ($this->getParam('megamenu')) {
                 $modules = $this->loadModules($v->megaparams);
                 //Update title: clear title if not show - Not clear title => causing none title when showing menu in other module
                 //if (!$v->megaparams->get ('showtitle', 1)) $v->name = '';
                 if ($modules && count($modules) > 0) {
                     $v->content = "";
                     $total = count($modules);
                     $cols = min($v->megaparams->get('cols'), $total);
                     for ($col = 0; $col < $cols; $col++) {
                         $pos = $col == 0 ? 'first' : ($col == $cols - 1 ? 'last' : '');
                         if ($cols > 1) {
                             $v->content .= $this->beginSubMenuModules($v->id, 1, $pos, $col, true);
                         }
                         $i = $col;
                         while ($i < $total) {
                             $mod = $modules[$i];
                             if (!isset($mod->name)) {
                                 $mod->name = $mod->module;
                             }
                             $i += $cols;
                             $mod_params = new JParameter($mod->params);
                             //$v->content .= JModuleHelper::renderModule($mod, array('style'=>$v->megaparams->get('style','jaxhtml')));
                             $v->content .= "<jdoc:include type=\"module\" name=\"{$mod->name}\" title=\"{$mod->title}\" style=\"" . $v->megaparams->get('style', 'jaxhtml') . "\" />";
                         }
                         if ($cols > 1) {
                             $v->content .= $this->endSubMenuModules($v->id, 1, true);
                         }
                     }
                     $v->cols = $cols;
                     $v->content = trim($v->content);
                     $this->items[$v->id] = $v;
                 }
             }
             switch ($v->type) {
                 case 'separator':
                     $v->url = '#';
                     break;
                 case 'url':
                     if (strpos($v->link, 'index.php?') !== false && strpos($v->link, 'Itemid=') === false) {
                         $v->url = $v->link . '&amp;Itemid=' . $v->id;
                     } else {
                         $v->url = $v->link;
                     }
                     break;
                 default:
                     $router = JSite::getRouter();
                     $v->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $v->id : $v->link . '&Itemid=' . $v->id;
                     break;
             }
             // Handle SSL links
             $iParams = $this->createParameterObject($v->params);
             $iSecure = $iParams->def('secure', 0);
             if ($v->home == 1) {
                 $v->url = JURI::base(true) . '/';
             } elseif (strcasecmp(substr($v->url, 0, 4), 'http') && strpos($v->link, 'index.php?') !== false) {
                 $v->url = JRoute::_($v->url, true, $iSecure);
             } else {
                 $v->url = str_replace('&', '&amp;', $v->url);
             }
             //calculate menu column
             if (!isset($v->clssfx)) {
                 $v->clssfx = $iParams->get('pageclass_sfx', '');
                 if ($v->megaparams->get('cols')) {
                     $v->cols = $v->megaparams->get('cols');
                     $v->col = array();
                     for ($i = 0; $i < $v->cols; $i++) {
                         if ($v->megaparams->get("col{$i}")) {
                             $v->col[$i] = $v->megaparams->get("col{$i}");
                         }
                     }
                 }
             }
             $v->_idx = count($list);
             array_push($list, $v);
             $children[$pt] = $list;
             $cacheIndex[$v->id] = $index;
             $this->items[$v->id] = $v;
         }
     }
     $this->children = $children;
     //unset item load module but no content
     foreach ($this->items as $v) {
         if (($v->megaparams->get('subcontent') || $v->megaparams->get('modid') || $v->megaparams->get('modname') || $v->megaparams->get('modpos')) && !isset($this->children[$v->id]) && (!isset($v->content) || !$v->content)) {
             $this->remove_item($this->items[$v->id]);
             unset($this->items[$v->id]);
         }
     }
     // $this->items = $rows;
 }
Ejemplo n.º 5
0
 /**
  * Convert JSON data to JParameter Object
  * @param $data JSON data
  */
 public static function toObject($data)
 {
     $param = new JParameter('');
     $param->bind($data);
     return $param->toObject();
 }
Ejemplo n.º 6
0
 function loadMenu()
 {
     $user =& JFactory::getUser();
     $children = array();
     $aid = $user->get('aid', 0);
     // Get Menu Items
     $items =& JSite::getMenu();
     $rows = $items->getItems('menutype', $this->getParam('menutype'));
     if (!count($rows)) {
         $rows = $items->getItems('menutype', 'mainmenu');
     }
     if (!count($rows)) {
         return;
     }
     // first pass - collect children
     $cacheIndex = array();
     $this->items = array();
     foreach ($rows as $index => $v) {
         $v->name = str_replace('&', '&amp;', str_replace('&amp;', '&', $v->name));
         if ($v->access <= $aid) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             $v->megaparams = $this->parseTitle($v->name);
             $v->megaparams->set('class', str_replace(',', ' ', $v->megaparams->get('class', '')));
             $v->name = trim($v->megaparams->get('title'));
             //Load params added by plugin
             $vparams = new JParameter($v->params);
             //get mega params
             $megaparams = $vparams->toObject();
             if ($megaparams) {
                 foreach (get_object_vars($megaparams) as $mega_name => $mega_value) {
                     if (preg_match('/mega_(.+)/', $mega_name, $matches)) {
                         if ($matches[1] == 'colxw') {
                             if (preg_match_all('/([^\\s]+)=([^\\s]+)/', $mega_value, $colwmatches)) {
                                 for ($i = 0; $i < count($colwmatches[0]); $i++) {
                                     $v->megaparams->set($colwmatches[1][$i], $colwmatches[2][$i]);
                                 }
                             }
                         } else {
                             if (is_array($mega_value)) {
                                 $mega_value = implode(',', $mega_value);
                             }
                             $v->megaparams->set($matches[1], $mega_value);
                         }
                     }
                 }
             }
             //reset cols for group item
             if ($v->megaparams->get('group')) {
                 $v->megaparams->set('cols', 1);
             }
             if ($this->getParam('megamenu')) {
                 $modules = $this->loadModules($v->megaparams);
                 //Update title: clear title if not show
                 if (!$v->megaparams->get('showtitle', 1)) {
                     $v->name = '';
                 }
                 //if ($v->name == 'FAQ') {print_r ($v->megaparams);exit;}
                 if ($modules && count($modules) > 0) {
                     $v->content = "";
                     $total = count($modules);
                     $cols = min($v->megaparams->get('cols'), $total);
                     for ($col = 0; $col < $cols; $col++) {
                         $pos = $col == 0 ? 'first' : ($col == $cols - 1 ? 'last' : '');
                         if ($cols > 1) {
                             $v->content .= $this->beginSubMenuModules($v->id, 1, $pos, $col, true);
                         }
                         $i = $col;
                         while ($i < $total) {
                             $mod = $modules[$i];
                             $i += $cols;
                             $mod_params = new JParameter($mod->params);
                             $v->content .= JModuleHelper::renderModule($mod, array('style' => $v->megaparams->get('style', 'xhtml')));
                         }
                         if ($cols > 1) {
                             $v->content .= $this->endSubMenuModules($v->id, 1, true);
                         }
                     }
                     $v->cols = $cols;
                     $v->content = trim($v->content);
                     $this->items[$v->id] = $v;
                 }
             }
             switch ($v->type) {
                 case 'separator':
                     $v->url = '#';
                     break;
                 case 'url':
                     if (strpos($v->link, 'index.php?') !== false && strpos($v->link, 'Itemid=') === false) {
                         $v->url = $v->link . '&amp;Itemid=' . $v->id;
                     } else {
                         $v->url = $v->link;
                     }
                     break;
                 default:
                     $router = JSite::getRouter();
                     $v->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $v->id : $v->link . '&Itemid=' . $v->id;
                     break;
             }
             // Handle SSL links
             $iParams = $this->createParameterObject($v->params);
             $iSecure = $iParams->def('secure', 0);
             if ($v->home == 1) {
                 $v->url = JURI::base();
             } elseif (strcasecmp(substr($v->url, 0, 4), 'http') && strpos($v->link, 'index.php?') !== false) {
                 $v->url = JRoute::_($v->url, true, $iSecure);
             } else {
                 $v->url = str_replace('&', '&amp;', $v->url);
             }
             //calculate menu column
             if (!isset($v->clssfx)) {
                 $v->clssfx = $iParams->get('pageclass_sfx', '');
                 if ($v->megaparams->get('cols')) {
                     $v->cols = $v->megaparams->get('cols');
                     $v->col = array();
                     for ($i = 0; $i < $v->cols; $i++) {
                         if ($v->megaparams->get("col{$i}")) {
                             $v->col[$i] = $v->megaparams->get("col{$i}");
                         }
                     }
                 }
             }
             $v->_idx = count($list);
             array_push($list, $v);
             $children[$pt] = $list;
             $cacheIndex[$v->id] = $index;
             $this->items[$v->id] = $v;
         }
     }
     $this->children = $children;
     //unset item load module but no content
     foreach ($this->items as $v) {
         if (($v->megaparams->get('modid') || $v->megaparams->get('modname') || $v->megaparams->get('modpos')) && !isset($this->children[$v->id]) && (!isset($v->content) || !$v->content)) {
             $this->remove_item($this->items[$v->id]);
             unset($this->items[$v->id]);
         }
     }
     // second pass - collect 'open' menus
     $open = array($this->Itemid);
     $count = 20;
     // maximum levels - to prevent runaway loop
     $id = $this->Itemid;
     while (--$count) {
         if (isset($cacheIndex[$id])) {
             $index = $cacheIndex[$id];
             if (isset($rows[$index]) && $rows[$index]->parent > 0) {
                 $id = $rows[$index]->parent;
                 $open[] = $id;
             } else {
                 break;
             }
         }
     }
     $this->open = $open;
     // $this->items = $rows;
 }