/** * Constructor * * @param array $config A named configuration array for object construction. */ public function __construct($config = array()) { // Display only the component output JFactory::getApplication()->input->def('tmpl', 'component'); parent::__construct($config); // Load menu model $model = JSNBaseModel::getInstance('Menutypes', 'MenusModel'); $this->setModel($model, true); }
/** * Constructor * * @param array $config A named configuration array for object construction. */ public function __construct($config = array()) { // Display only the component output JFactory::getApplication()->input->def('tmpl', 'component'); parent::__construct($config); // Load category model $model = JSNBaseModel::getInstance('Categories', 'CategoriesModel'); $this->setModel($model, true); // Include the component HTML helpers $this->addTemplatePath(dirname(__FILE__) . '/tmpl'); JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); // Load assets JSNBaseHelper::loadAssets(); echo JSNHtmlAsset::loadScript('jsn/selectorFilter', array(), true); }
/** * Populate search and response results to client as json format * @return void */ function json() { header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past $keyword = JRequest::getString('keyword'); $coverages = array_map('trim', explode(',', JRequest::getString('coverages'))); $dispatcher =& JDispatcher::getInstance(); require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers/poweradmin.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers/plugin.php'; $params = JSNConfigHelper::get('com_poweradmin'); $resultLimit = (int) $params->get('search_result_num', 10); //JRequest::setVar('limit', $resultLimit); // Load language JFactory::getLanguage()->load('plg_system_jsnpoweradmin'); // Load model $model = JSNBaseModel::getInstance('Search', 'PowerAdminModel'); $model->setState('search.keyword', $keyword); $model->setState('search.pagination', false); $installedComponents = PoweradminHelper::getInstalledComponents(); $results = array(); foreach ($coverages as $coverage) { if ($coverage == 'adminmenus') { continue; } $components = array(); if ($coverage == 'components') { if (in_array('com_banners', $installedComponents)) { $components['com_banners'] = array('com_banners', 'com_banners_categories', 'com_banners_clients'); } if (in_array('com_contacts', $installedComponents)) { $components['com_contacts'] = array('com_contacts', 'com_contacts_categories'); } if (in_array('com_messages', $installedComponents)) { $components['com_messages'] = array('com_messages'); } if (in_array('com_newsfeeds', $installedComponents)) { $components['com_newsfeeds'] = array('com_newsfeeds', 'com_newsfeeds_categories'); } if (in_array('com_weblinks', $installedComponents)) { $components['com_weblinks'] = array('com_weblinks', 'com_weblinks_categories'); } } if (strpos($coverage, JSN_3RD_EXTENSION_STRING) !== false) { $_extName = explode(JSN_3RD_EXTENSION_STRING . "-", $coverage); $_extName = $_extName[1]; if ($_extName && in_array('com_' . $_extName, $installedComponents)) { JPluginHelper::importPlugin('jsnpoweradmin', $_extName); $_range = $dispatcher->trigger('addSearchRange'); if (count($_range[0])) { $components['com_' . strtolower($_extName)] = array(); foreach ($_range[0] as $key => $value) { array_push($components['com_' . strtolower($_extName)], $key); } } } else { continue; } } if (strpos($coverage, JSN_3RD_EXTENSION_NOT_INSTALLED_STRING) !== false) { $results[] = array('type' => 'notice', 'target' => 'index.php?option=com_poweradmin&view=configuration&s=maintainence&g=extensions', 'title' => JText::_('JSN_POWERADMIN_EXT_SPOTLIGHT_INSTALL_EXTENSION') . ' ' . str_ireplace(JSN_3RD_EXTENSION_NOT_INSTALLED_STRING . '-', 'com_', $coverage)); continue; } if (strpos($coverage, JSN_3RD_EXTENSION_NOT_ENABLED_STRING) !== false) { $results[] = array('type' => 'notice', 'link' => 'index.php?option=com_poweradmin&view=configuration', 'title' => JText::_('JSN_POWERADMIN_EXT_SPOTLIGHT_ENABLE_EXTENSION') . ' ' . str_ireplace(JSN_3RD_EXTENSION_NOT_ENABLED_STRING . '-', 'com_', $coverage)); continue; } if (!empty($components)) { foreach ($components as $key => $component) { $componentResults = array(); $type = $component; if (is_array($component)) { $type = $key; foreach ($component as $subsection) { $model->setState('search.coverage', $subsection); $componentResults = array_merge($componentResults, $model->getItems()); } } else { $model->setState('search.coverage', $component); $componentResults = array_merge($componentResults, $model->getItems()); } if (count($componentResults) > 0) { $results[] = array('title' => JText::_('PLG_JSNADMINBAR_SEARCH_COVERAGE_' . strtoupper($type), true), 'description' => '', 'type' => $type, 'coverage' => $coverage); $results = array_merge($results, $componentResults); } } continue; } $model->setState('search.coverage', $coverage); $total = $model->getTotal(); $items = $model->getItems(); if (count($items) > 0) { $results[] = array('title' => JText::_('PLG_JSNADMINBAR_SEARCH_COVERAGE_' . strtoupper($coverage)), 'description' => '', 'type' => $coverage, 'coverage' => $coverage, 'hasMore' => $total - $resultLimit); $results = array_merge($results, $items); } } echo json_encode($results); jexit(); }
function getItems() { $params = $this->getState()->get('params'); $limit = $this->getState('list.limit'); if ($this->_articles === null && ($category = $this->getCategory())) { $model = JSNBaseModel::getInstance('Articles', 'ContentModel', array('ignore_request' => true)); $model->setState('params', $this->state->params); $model->setState('filter.category_id', $category->id); $model->setState('filter.published', $this->getState('filter.published')); $model->setState('filter.access', $this->getState('filter.access')); $model->setState('filter.language', $this->getState('filter.language')); $model->setState('list.ordering', $this->_buildContentOrderBy()); $model->setState('list.start', $this->getState('list.start')); $model->setState('list.limit', $limit); $model->setState('list.direction', $this->getState('list.direction')); $model->setState('list.filter', $this->getState('list.filter')); // filter.subcategories indicates whether to include articles from subcategories in the list or blog $model->setState('filter.subcategories', $this->getState('filter.subcategories')); $model->setState('filter.max_category_levels', $this->setState('filter.max_category_levels')); $model->setState('list.links', $this->getState('list.links')); if ($limit >= 0) { $this->_articles = $model->getItems(); if ($this->_articles === false) { $this->setError($model->getError()); } } else { $this->_articles = array(); } $this->_pagination = $model->getPagination(); $this->_data->pagination = $this->_pagination; } return $this->_articles; }