Ejemplo n.º 1
0
 /**
  * Compiles a list of installed, version 4.5+ templates
  *
  * Based on xml files found.  If no xml file found the template
  * is ignored
  */
 public static function viewTemplates()
 {
     global $mainframe, $option;
     // Initialize some variables
     $db =& JFactory::getDBO();
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     // Initialize the pagination variables
     $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', 20, 'int');
     $limitstart = $mainframe->getUserStateFromRequest($option . '.' . $client->id . '.limitstart', 'limitstart', 0, 'int');
     $select[] = JHTML::_('select.option', '0', JText::_('Site'));
     $select[] = JHTML::_('select.option', '1', JText::_('Administrator'));
     $lists['client'] = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $client->id);
     $tBaseDir = $client->path . DS . 'templates';
     //get template xml file info
     $rows = array();
     $rows = TemplatesHelper::parseXMLTemplateFiles($tBaseDir);
     // set dynamic template information
     for ($i = 0; $i < count($rows); $i++) {
         $rows[$i]->assigned = TemplatesHelper::isTemplateAssigned($rows[$i]->directory);
         $rows[$i]->published = TemplatesHelper::isTemplateDefault($rows[$i]->directory, $client->id);
     }
     jimport('joomla.html.pagination');
     $page = new JPagination(count($rows), $limitstart, $limit);
     $rows = array_slice($rows, $page->limitstart, $page->limit);
     require_once JPATH_COMPONENT . DS . 'admin.templates.html.php';
     TemplatesView::showTemplates($rows, $lists, $page, $option, $client);
 }
Ejemplo n.º 2
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $size = $node->attributes('size');
     $multiple = $node->attributes('multiple');
     $subtemplates = $this->def($node->attributes('subtemplates'), 1);
     $control = $control_name . '[' . $name . ']';
     $attribs = 'class="inputbox"';
     if ($multiple) {
         if (!is_array($value)) {
             $value = explode(',', $value);
         }
         $attribs .= ' multiple="multiple"';
         $control .= '[]';
     }
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_templates' . DS . 'helpers' . DS . 'template.php';
     $rows = TemplatesHelper::parseXMLTemplateFiles(JPATH_ROOT . DS . 'templates');
     $options = $this->createList($rows, JPATH_ROOT . DS . 'templates', $subtemplates);
     if ($size) {
         $attribs .= ' size="' . $size . '"';
     } else {
         $attribs .= ' size="' . (count($options) > 10 ? 10 : count($options)) . '"';
     }
     $list = JHTML::_('select.genericlist', $options, $control, $attribs, 'value', 'text', $value, $control_name . $name);
     return $list;
 }
Ejemplo n.º 3
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     include_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/template.php';
     $template_path = JPATH_ADMINISTRATOR . '/templates';
     $templates = TemplatesHelper::parseXMLTemplateFiles($template_path);
     $options = array();
     $options[] = JHTML::_('select.option', '', JText::_('DEFAULT'));
     foreach ($templates as $t) {
         $options[] = JHTML::_('select.option', $t->directory, $t->name);
     }
     return JHTML::_('select.genericlist', $options, '' . $control_name . '[' . $name . '][]', 'class="inputbox"', 'value', 'text', $value);
 }
Ejemplo n.º 4
0
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     $size = (int) $this->def('size');
     $multiple = $this->def('multiple');
     $subtemplates = $this->def('subtemplates', 1);
     $show_system = $this->def('show_system', 1);
     if ($j15) {
         require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/template.php';
         $rows = TemplatesHelper::parseXMLTemplateFiles(JPATH_ROOT . '/templates');
         $options = $this->createList15($rows, JPATH_ROOT . '/templates', $subtemplates, $show_system);
     } else {
         require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
         $rows = TemplatesHelper::getTemplateOptions('0');
         $options = $this->createList($rows, JPATH_ROOT . '/templates', $subtemplates, $show_system);
     }
     require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
     return nnHTML::selectlist($options, $name, $value, $id, $size, $multiple, 0, $j15);
 }
Ejemplo n.º 5
0
 /**
  * Creates the chooseable template list
  *
  * @author Max Milbers, impleri
  *
  * @param string defaultText Text for the empty option
  * @param boolean defaultOption you can supress the empty otion setting this to false
  * return array of Template objects
  */
 public static function renderTemplateList($defaultText = 0, $defaultOption = TRUE)
 {
     if (empty($defaultText)) {
         $defaultText = JText::_('COM_VIRTUEMART_TEMPLATE_DEFAULT');
     }
     $defaulttemplate = array();
     if ($defaultOption) {
         $defaulttemplate[0] = new stdClass();
         $defaulttemplate[0]->name = $defaultText;
         $defaulttemplate[0]->directory = 0;
         $defaulttemplate[0]->value = 'default';
     }
     if (JVM_VERSION === 1) {
         if (!class_exists('TemplatesHelper')) {
             require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_templates' . DS . 'helpers' . DS . 'template.php';
         }
         $jtemplates = TemplatesHelper::parseXMLTemplateFiles(JPATH_SITE . DS . 'templates');
         foreach ($jtemplates as $key => $template) {
             $template->value = $template->name;
         }
     } else {
         $q = 'SELECT * FROM `#__template_styles` WHERE `client_id`="0"';
         $db = JFactory::getDbo();
         $db->setQuery($q);
         $jtemplates = $db->loadObjectList();
         foreach ($jtemplates as $key => $template) {
             $template->name = $template->title;
             $template->value = $template->id;
             $template->directory = $template->template;
         }
     }
     return array_merge($defaulttemplate, $jtemplates);
 }
Ejemplo n.º 6
0
 function getListsAdmin($filters)
 {
     $db =& JFactory::getDBO();
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     // get list of Positions for dropdown filter
     $query = 'SELECT m.position AS value, m.position AS text' . ' FROM #__modules as m' . ' WHERE m.client_id = ' . (int) $client->id . ' GROUP BY m.position' . ' ORDER BY m.position';
     $db->setQuery($query);
     $options[] = JHTML::_('select.option', '0', '- ' . JText::_('Position') . ' -');
     $options = array_merge($options, $db->loadObjectList());
     $lists['position'] = JHTML::_('select.genericlist', $options, 'filter_position', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->position}");
     // get list of Types for dropdown filter
     $query = 'SELECT module AS value, module AS text' . ' FROM #__modules' . ' WHERE client_id = ' . (int) $client->id . ' GROUP BY module' . ' ORDER BY module';
     $db->setQuery($query);
     $options = array(JHTML::_('select.option', '0', '- ' . JText::_('Type') . ' -'));
     $options = array_merge($options, $db->loadObjectList());
     $lists['type'] = JHTML::_('select.genericlist', $options, 'filter_type', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->type}");
     // state filter
     $lists['state'] = JHTML::_('grid.state', $filters->state);
     // state access
     if (true || $client->id == 1) {
         // Administrator modules
         $query = 'SELECT id AS value, name AS text' . ' FROM #__groups' . ' ORDER BY id';
         $db->setQuery($query);
         $options = array(JHTML::_('select.option', '', '- ' . JText::_('AMM_ACCESS_LEVEL') . ' -'));
         $options = array_merge($options, $db->loadObjectList());
         $lists['access'] = JHTML::_('select.genericlist', $options, 'filter_access', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', $filters->access);
     } else {
         // TODO: ... still have to think about this!
         // Site modules
         $options = array();
         $options[] = JHTML::_('select.option', '', '- ' . JText::_('AMM_ACCESS_LEVEL') . ' -');
         $options[] = JHTML::_('select.option', '0', JText::_('NN_NOT_REGISTERED') . ' / ' . JText::_('NN_LOGGED_IN'));
         $acl =& JFactory::getACL();
         $options = array_merge($options, $acl->get_group_children_tree(null, 'USERS', 0));
         $lists['access'] = JHTML::_('select.genericlist', $options, 'filter_access_adv', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', $filters->access_adv);
     }
     // template assignment filter
     if (true || $client->id == 1) {
         // Administrator modules
         $query = 'SELECT DISTINCT( template ) AS text, template AS value' . ' FROM #__templates_menu' . ' WHERE client_id = ' . (int) $client->id;
         $db->setQuery($query);
         $options = array();
         $options[] = JHTML::_('select.option', '0', '- ' . JText::_('Template') . ' -');
         $options = array_merge($options, $db->loadObjectList());
         $lists['template'] = JHTML::_('select.genericlist', $options, 'filter_template', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->template}");
     } else {
         // TODO: ... still have to think about this!
         // Site modules
         require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_templates' . DS . 'helpers' . DS . 'template.php';
         $templates = array();
         $templates = TemplatesHelper::parseXMLTemplateFiles(JPATH_ROOT . DS . 'templates');
         $options = array();
         $options[] = JHTML::_('select.option', '0', '- ' . JText::_('Template') . ' -');
         foreach ($templates as $template) {
             $options[] = JHTML::_('select.option', $template->directory, $template->name);
         }
         $lists['template'] = JHTML::_('select.genericlist', $options, 'filter_template', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->template}");
     }
     // template assignment filter
     $query = 'SELECT DISTINCT( template ) AS text, template AS value' . ' FROM #__templates_menu' . ' WHERE client_id = ' . (int) $client->id;
     $db->setQuery($query);
     // get list of Menu Item Assignments for dropdown filter
     // load the list of menu types
     $query = 'SELECT menutype, title' . ' FROM #__menu_types' . ' ORDER BY title';
     $db->setQuery($query);
     $menuTypes = $db->loadObjectList();
     $query = 'SELECT m.id, m.parent, m.name, m.menutype, m.type, m.published, mm.moduleid as assignment' . ' FROM #__menu as m' . ' LEFT JOIN #__modules_menu AS mm ON mm.menuid = m.id' . ' WHERE m.published != -2' . ' GROUP BY m.id' . ' ORDER BY m.menutype, m.parent, m.ordering';
     $db->setQuery($query);
     $menuItems = $db->loadObjectList();
     // establish the hierarchy of the menu
     $children = array();
     if ($menuItems) {
         // first pass - collect children
         foreach ($menuItems as $v) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble into menutype groups
     $n = count($list);
     $groupedList = array();
     foreach ($list as $k => $v) {
         $groupedList[$v->menutype][] =& $list[$k];
     }
     // assemble menu items to the array
     $options = array();
     $options[] = JHTML::_('select.option', '', '- ' . JText::_('AMM_MENU_ITEM_ASSIGNMENT') . ' -');
     $options[] = JHTML::_('select.option', 'all', JText::_('All'));
     $options[] = JHTML::_('select.option', 'none', JText::_('None'));
     $options[] = JHTML::_('select.option', 'varies', JText::_('Varies'));
     $options[] = JHTML::_('select.option', '-', '----------------------------------------', 'value', 'text', true);
     $count = 0;
     foreach ($menuTypes as $type) {
         if (isset($groupedList[$type->menutype])) {
             if ($count > 0) {
                 $options[] = JHTML::_('select.option', '-', '&nbsp;', 'value', 'text', true);
             }
             $count++;
             $options[] = JHTML::_('select.option', $type->menutype, '[ ' . $type->title . ' ]', 'value', 'text', true);
             $n = count($groupedList[$type->menutype]);
             for ($i = 0; $i < $n; $i++) {
                 $item =& $groupedList[$type->menutype][$i];
                 //If menutype is changed but item is not saved yet, use the new type in the list
                 if (JRequest::getString('option', '', 'get') == 'com_menus') {
                     $currentItemArray = JRequest::getVar('cid', array(0), '', 'array');
                     $currentItemId = (int) $currentItemArray['0'];
                     $currentItemType = JRequest::getString('type', $item->type, 'get');
                     if ($currentItemId == $item->id && $currentItemType != $item->type) {
                         $item->type = $currentItemType;
                     }
                 }
                 $item_name = $item->treename;
                 $item_id = $item->id;
                 if ($item->published == 0) {
                     $item_name = '*' . $item_name . ' (' . JText::_('Unpublished') . ')';
                     $item_id .= '" style="font-style:italic;';
                 }
                 $options[] = JHTML::_('select.option', $item_id, '&nbsp;&nbsp;&nbsp;' . $item_name, 'value', 'text', $item->assignment ? 0 : 1);
             }
         }
     }
     $lists['menuitems'] = JHTML::_('select.genericlist', $options, 'filter_menuitems', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->menuitems}");
     // table ordering
     $lists['order_Dir'] = $filters->order_Dir;
     $lists['order'] = $filters->order;
     // search filter
     $lists['search'] = $filters->search;
     return $lists;
 }
Ejemplo n.º 7
0
 function listing()
 {
     $app = JFactory::getApplication();
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->limit = new stdClass();
     $pageInfo->filter->client_id = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.client_id', 'client_id', 2, 'int');
     $pageInfo->filter->template = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.template', 'template', '', 'string');
     $pageInfo->filter->component = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.component', 'component', '', 'string');
     $pageInfo->filter->viewType = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.viewType', 'viewType', '', 'string');
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.limit', 'limit', $app->getCfg('list_limit'), 'int');
     if (empty($pageInfo->limit->value)) {
         $pageInfo->limit->value = 500;
     }
     if (JRequest::getVar('search') != $app->getUserState($this->paramBase . ".search")) {
         $app->setUserState($this->paramBase . '.limitstart', 0);
         $pageInfo->limit->start = 0;
     } else {
         $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int');
     }
     $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . '.search', 'search', '', 'string');
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . '.filter_order', 'filter_order', 'a.user_id', 'cmd');
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . '.filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
     $views = array();
     switch ($pageInfo->filter->client_id) {
         case 0:
             $views[0] = HIKASHOP_FRONT . 'views' . DS;
             break;
         case 1:
             $views[1] = HIKASHOP_BACK . 'views' . DS;
             break;
         default:
             $views[0] = HIKASHOP_FRONT . 'views' . DS;
             $views[1] = HIKASHOP_BACK . 'views' . DS;
             break;
     }
     JPluginHelper::importPlugin('hikashop');
     $dispatcher = JDispatcher::getInstance();
     $pluginViews = array();
     $dispatcher->trigger('onViewsListingFilter', array(&$pluginViews, $pageInfo->filter->client_id));
     if (!empty($pluginViews)) {
         $i = 2;
         foreach ($pluginViews as $pluginView) {
             $views[$i++] = $pluginView;
         }
     }
     $this->assignRef('pluginViews', $pluginViews);
     jimport('joomla.filesystem.folder');
     if (version_compare(JVERSION, '1.6', '<')) {
         require_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_templates' . DS . 'helpers' . DS . 'template.php';
     }
     $templates = array();
     $templateValues = array();
     foreach ($views as $client_id => $view) {
         $component_name = '';
         $component = HIKASHOP_COMPONENT;
         if (is_array($view)) {
             $client_id = $view['client_id'];
             $component_name = $view['name'];
             $component = $view['component'];
             $view = $view['view'];
         }
         if (!empty($pageInfo->filter->component) && $pageInfo->filter->component != $component) {
             continue;
         }
         $folders = JFolder::folders($view);
         if (empty($folders)) {
             continue;
         }
         $clientTemplates = array();
         foreach ($folders as $folder) {
             if (JFolder::exists($view . $folder . DS . 'tmpl')) {
                 $files = JFolder::files($view . $folder . DS . 'tmpl');
                 if (!empty($files)) {
                     foreach ($files as $file) {
                         if (substr($file, -4) == '.php') {
                             $obj = new stdClass();
                             $obj->path = $view . $folder . DS . 'tmpl' . DS . $file;
                             $obj->filename = $file;
                             $obj->folder = $view . $folder . DS . 'tmpl' . DS;
                             $obj->client_id = $client_id;
                             $obj->view = $folder;
                             $obj->type = 'component';
                             $obj->type_name = $component;
                             $obj->file = substr($file, 0, strlen($file) - 4);
                             $clientTemplates[] = $obj;
                         }
                     }
                 }
             }
         }
         if ($client_id == 0 && $component == HIKASHOP_COMPONENT) {
             $plugins_folder = rtrim(JPATH_PLUGINS, DS) . DS . 'hikashoppayment';
             if (Jfolder::exists($plugins_folder)) {
                 $files = Jfolder::files($plugins_folder);
                 foreach ($files as $file) {
                     if (preg_match('#^.*_(?!configuration).*\\.php$#', $file)) {
                         $obj = new stdClass();
                         $obj->path = $plugins_folder . DS . $file;
                         $obj->filename = $file;
                         $obj->folder = $plugins_folder;
                         $obj->client_id = $client_id;
                         $obj->type = 'plugin';
                         $obj->view = '';
                         $obj->type_name = 'hikashoppayment';
                         $obj->file = substr($file, 0, strlen($file) - 4);
                         $clientTemplates[] = $obj;
                     }
                 }
             }
         }
         if (!empty($clientTemplates)) {
             $client = JApplicationHelper::getClientInfo($client_id);
             $tBaseDir = $client->path . DS . 'templates';
             if (version_compare(JVERSION, '1.6', '<')) {
                 $joomlaTemplates = TemplatesHelper::parseXMLTemplateFiles($tBaseDir);
             } else {
                 $query = 'SELECT * FROM ' . hikashop_table('extensions', false) . ' WHERE type=\'template\' AND client_id=' . (int) $client_id;
                 $db = JFactory::getDBO();
                 $db->setQuery($query);
                 $joomlaTemplates = $db->loadObjectList();
                 foreach ($joomlaTemplates as $k => $v) {
                     $joomlaTemplates[$k]->assigned = $joomlaTemplates[$k]->protected;
                     $joomlaTemplates[$k]->published = $joomlaTemplates[$k]->enabled;
                     $joomlaTemplates[$k]->directory = $joomlaTemplates[$k]->element;
                 }
             }
             for ($i = 0; $i < count($joomlaTemplates); $i++) {
                 if (version_compare(JVERSION, '1.6', '<')) {
                     $joomlaTemplates[$i]->assigned = TemplatesHelper::isTemplateAssigned($joomlaTemplates[$i]->directory);
                     $joomlaTemplates[$i]->published = TemplatesHelper::isTemplateDefault($joomlaTemplates[$i]->directory, $client->id);
                 }
                 if ($joomlaTemplates[$i]->published || $joomlaTemplates[$i]->assigned) {
                     if (!empty($pageInfo->filter->template) && $joomlaTemplates[$i]->directory != $pageInfo->filter->template) {
                         continue;
                     }
                     $templateValues[$joomlaTemplates[$i]->directory] = $joomlaTemplates[$i]->directory;
                     $templateFolder = $tBaseDir . DS . $joomlaTemplates[$i]->directory . DS;
                     foreach ($clientTemplates as $template) {
                         $templatePerJoomlaTemplate = clone $template;
                         $templatePerJoomlaTemplate->template = $joomlaTemplates[$i]->directory;
                         $templatePerJoomlaTemplate->component = $component_name;
                         $templatePerJoomlaTemplate->override = $templateFolder . 'html' . DS . $template->type_name . DS;
                         if ($template->type == 'component') {
                             $templatePerJoomlaTemplate->override .= $template->view . DS;
                         }
                         $templatePerJoomlaTemplate->override .= $template->filename;
                         $templatePerJoomlaTemplate->overriden = false;
                         if (file_exists($templatePerJoomlaTemplate->override)) {
                             $templatePerJoomlaTemplate->overriden = true;
                         }
                         $templatePerJoomlaTemplate->id = $templatePerJoomlaTemplate->client_id . '|' . $templatePerJoomlaTemplate->template . '|' . $templatePerJoomlaTemplate->type . '|' . $templatePerJoomlaTemplate->type_name . '|' . $templatePerJoomlaTemplate->view . '|' . $templatePerJoomlaTemplate->filename;
                         $key = $templatePerJoomlaTemplate->client_id . '|' . $templatePerJoomlaTemplate->template . '|' . $templatePerJoomlaTemplate->type_name . '|' . $templatePerJoomlaTemplate->view . '|' . $templatePerJoomlaTemplate->filename;
                         if (!empty($pageInfo->filter->viewType) && $templatePerJoomlaTemplate->view != $pageInfo->filter->viewType) {
                             continue;
                         }
                         $templates[$key] = $templatePerJoomlaTemplate;
                     }
                     if (JFolder::exists($templateFolder . 'html' . DS . $component . DS)) {
                         $folders = JFolder::folders($templateFolder . 'html' . DS . $component . DS);
                         if (!empty($folders)) {
                             foreach ($folders as $folder) {
                                 $files = JFolder::files($templateFolder . 'html' . DS . $component . DS . $folder);
                                 if (empty($files)) {
                                     continue;
                                 }
                                 foreach ($files as $file) {
                                     if (substr($file, -4) != '.php') {
                                         continue;
                                     }
                                     $filename = $templateFolder . 'html' . DS . $component . DS . $folder . DS . $file;
                                     $found = false;
                                     foreach ($templates as $tpl) {
                                         if ($tpl->override == $filename) {
                                             $found = true;
                                             break;
                                         }
                                     }
                                     if (!$found) {
                                         $obj = new stdClass();
                                         $obj->path = $view . $folder . DS . 'tmpl' . DS . $file;
                                         $obj->filename = $file;
                                         $obj->folder = $view . $folder . DS . 'tmpl' . DS;
                                         $obj->client_id = $client_id;
                                         $obj->view = $folder;
                                         $obj->template = $joomlaTemplates[$i]->directory;
                                         $obj->type = 'component';
                                         $obj->type_name = $component;
                                         $obj->file = substr($file, 0, strlen($file) - 4);
                                         $obj->override = $filename;
                                         $obj->overriden = true;
                                         $obj->id = $obj->client_id . '|' . $obj->template . '|' . $obj->type . '|' . $obj->type_name . '|' . $obj->view . '|' . $obj->filename;
                                         $key = $obj->client_id . '|' . $obj->template . '|' . $obj->view . '|' . $obj->filename;
                                         $templates[$key] = $obj;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     ksort($templates);
     $searchMap = array('filename', 'view', 'template');
     if (!empty($pageInfo->search)) {
         $unset = array();
         foreach ($templates as $k => $template) {
             $found = false;
             foreach ($searchMap as $field) {
                 if (strpos($template->{$field}, $pageInfo->search) !== false) {
                     $found = true;
                 }
             }
             if (!$found) {
                 $unset[] = $k;
             }
         }
         if (!empty($unset)) {
             foreach ($unset as $u) {
                 unset($templates[$u]);
             }
         }
         $templates = hikashop_search($pageInfo->search, $templates, 'id');
     }
     $viewTypes = array('0' => JHTML::_('select.option', 0, JText::_('ALL_VIEWS')));
     foreach ($templates as $temp) {
         if (!isset($viewTypes[strip_tags($temp->view)]) && !empty($temp->view)) {
             $viewTypes[strip_tags($temp->view)] = JHTML::_('select.option', strip_tags($temp->view), strip_tags($temp->view));
         }
     }
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = count($templates);
     if ($pageInfo->limit->value == 500) {
         $pageInfo->limit->value = 100;
     }
     $this->assignRef('pageInfo', $pageInfo);
     $this->getPagination();
     $templates = array_slice($templates, $this->pagination->limitstart, $this->pagination->limit);
     $pageInfo->elements->page = count($templates);
     $this->assignRef('viewTypes', $viewTypes);
     $this->assignRef('rows', $templates);
     $this->assignRef('templateValues', $templateValues);
     $viewType = hikashop_get('type.view');
     $this->assignRef('viewType', $viewType);
     $templateType = hikashop_get('type.template');
     $this->assignRef('templateType', $templateType);
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $config =& hikashop_config();
     $manage = hikashop_isAllowed($config->get('acl_view_manage', 'all'));
     $this->assignRef('manage', $manage);
     $delete = hikashop_isAllowed($config->get('acl_view_delete', 'all'));
     $this->assignRef('delete', $delete);
     $this->toolbar = array(array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
     jimport('joomla.client.helper');
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $this->assignRef('ftp', $ftp);
 }
Ejemplo n.º 8
0
 protected function getTemplateOptions()
 {
     // Get the template-options
     if (MageBridgeHelper::isJoomla15()) {
         require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/template.php';
         $options = TemplatesHelper::parseXMLTemplateFiles(JPATH_SITE . '/templates');
     } else {
         require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
         $options = TemplatesHelper::getTemplateOptions(0);
     }
     // Construct an empty option
     $option = new stdClass();
     if (MageBridgeHelper::isJoomla15()) {
         $option->directory = null;
         $option->name = null;
     } else {
         $option->value = null;
         $option->text = null;
     }
     array_unshift($options, $option);
     // Return the options
     return $options;
 }
Ejemplo n.º 9
0
 /**
  * Creates the chooseable template list
  *
  * @author Max Milbers, impleri
  *
  * @param string defaultText Text for the empty option
  * @param boolean defaultOption you can supress the empty otion setting this to false
  * return array of Template objects
  */
 public static function renderTemplateList($defaultText = 0, $defaultOption = TRUE)
 {
     if (empty($defaultText)) {
         $defaultText = JText::_('COM_VIRTUEMART_TEMPLATE_DEFAULT');
     }
     $defaulttemplate = array();
     if ($defaultOption) {
         $defaulttemplate[0] = new stdClass();
         $defaulttemplate[0]->name = $defaultText;
         $defaulttemplate[0]->directory = 0;
         $defaulttemplate[0]->value = 'default';
     }
     if (JVM_VERSION === 1) {
         if (!class_exists('TemplatesHelper')) {
             require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_templates' . DS . 'helpers' . DS . 'template.php';
         }
         $jtemplates = TemplatesHelper::parseXMLTemplateFiles(JPATH_SITE . DS . 'templates');
     } else {
         require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_templates' . DS . 'helpers' . DS . 'templates.php';
         require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_templates' . DS . 'models' . DS . 'templates.php';
         $templatesModel = new TemplatesModelTemplates();
         $jtemplates = $templatesModel->getItems();
     }
     foreach ($jtemplates as $key => $template) {
         $template->value = $template->name;
         if (JVM_VERSION === 2) {
             if ($template->client_id == '0') {
                 $template->directory = $template->element;
             } else {
                 unset($jtemplates[$key]);
             }
         }
     }
     return array_merge($defaulttemplate, $jtemplates);
 }