public function renderGlobalHeaders($ajax_url = null) { if (is_null($ajax_url)) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); $active = $menus->getActive(); if ($active === null) $active = $menus->getDefault(); $ajax_url = 'index.php?option=com_roksprocket&task=ajax&format=raw&ItemId=' . $active->id; } parent::renderGlobalHeaders($ajax_url); }
/** * Get the items for the module and provider based on the filters passed and paginated * $params object should be a json like * <code> * { * "page": 3, * "items_per_page":6, * "module_id": 5, * "provider":"joomla", * "filters": {"1":{"root":{"access":"1"}},"2":{"root":{"author":"43"}}}, * "sortby":"date", * "get_remaining": true * } * </code> * * @param $params * * @throws Exception * @throws RokCommon_Ajax_Exception * @return \RokCommon_Ajax_Result */ public function getItems($params) { $result = new RokCommon_Ajax_Result(); try { $html = ''; $provider_filters = null; $provider_articles = null; if (isset($params->filters)) { $provider_filters = RokCommon_JSON::decode($params->filters); } if (isset($params->articles)) { $provider_articles = RokCommon_JSON::decode($params->articles); } $decoded_sort_parameters = array(); try { $decoded_sort_parameters = RokCommon_Utils_ArrayHelper::fromObject(RokCommon_JSON::decode($params->sort)); } catch (RokCommon_JSON_Exception $jse) { throw new RokCommon_Ajax_Exception('Invalid Sort Parameters passed in.'); } $sort_params = new RokCommon_Registry($decoded_sort_parameters); $sort_filters = RokCommon_Utils_ArrayHelper::fromObject($sort_params->get('rules')); $sort_append = $sort_params->get('append', 'after'); $sort_type = $sort_params->get('type'); $extras = array(); if (isset($params->extras)) { $extras = $params->extras; } if ($params->uuid != '0') { $params->module_id = $params->uuid; } $items = RokSprocket::getItemsWithFilters($params->module_id, $params->provider, $provider_filters, $provider_articles, $sort_filters, $sort_type, $sort_append, new RokCommon_Registry($extras), false, true); $container = RokCommon_Service::getContainer(); $template_path_param = sprintf('roksprocket.providers.registered.%s.templatepath', strtolower($params->provider)); if ($container->hasParameter($template_path_param)) { RokCommon_Composite::addPackagePath('roksprocket', $container->getParameter($template_path_param), 30); } $total_items_count = $items->count(); $page = $params->page; $more = false; $limit = 10; $offset = ($page - 1) * $limit; if ($params->load_all) { $limit = $total_items_count - $offset; } $items = $items->slice($offset, $limit); $page = (int) $page == 0 ? 1 : $page; $next_page = $page; if ($total_items_count > $offset + $limit) { $more = true; $next_page = $page + 1; } $order = 0; $this->loadLayoutLanguage($params->layout); ob_start(); foreach ($items as $article) { $per_item_form = $this->getPerItemsForm($params->layout); $per_item_form->setFormControl(sprintf('items[%s]', $article->getArticleId())); $per_item_form->bind(array('params' => $article->getParams())); echo RokCommon_Composite::get('roksprocket.module.edit')->load('edit_article.php', array('itemform' => $per_item_form, 'article' => $article, 'order' => $order)); $order++; } $html .= ob_get_clean(); $result->setPayload(array('more' => $more, 'page' => $page, 'next_page' => $next_page, 'amount' => $total_items_count, 'html' => $html)); } catch (Exception $e) { throw $e; } return $result; }
public function renderGlobalHeaders() { if (!self::$globalHeadersRendered) { RokCommon_Header::addScript(RokCommon_Composite::get($this->context_base . '.assets.js')->getUrl('mootools-mobile.js')); RokCommon_Header::addScript(RokCommon_Composite::get($this->context_base . '.assets.js')->getUrl('rokmediaqueries.js')); RokCommon_Header::addScript(RokCommon_Composite::get($this->context_base . '.assets.js')->getUrl('roksprocket.js')); $ns = array(); $ns[] = "if (typeof RokSprocket == 'undefined') RokSprocket = {};"; $ns[] = "Object.merge(RokSprocket, {"; $ns[] = "\tSiteURL: '" . str_replace('&', '&', JRoute::_(JURI::root(true), true)) . "',"; $ns[] = "\tCurrentURL: '" . str_replace('&', '&', JRoute::_(JURI::current(true), true)) . "',"; $ns[] = "\tAjaxURL: '" . str_replace('&', '&', JRoute::_(JURI::root(true) . '/index.php?option=com_roksprocket&task=ajax&format=raw')) . "'"; $ns[] = "});"; RokCommon_Header::addInlineScript(implode("\n", $ns) . "\n"); self::$globalHeadersRendered = true; } }
/** * @param null $ajax_path */ public function renderGlobalHeaders($ajax_path = null) { if (!self::$globalHeadersRendered) { if (defined('_JEXEC')) { JHtml::_('behavior.framework'); } RokCommon_Header::addScript(RokCommon_Composite::get($this->context_base . '.assets.js')->getUrl('mootools-mobile.js')); RokCommon_Header::addScript(RokCommon_Composite::get($this->context_base . '.assets.js')->getUrl('rokmediaqueries.js')); RokCommon_Header::addScript(RokCommon_Composite::get($this->context_base . '.assets.js')->getUrl('roksprocket.js')); /** @var $platforminfo RokCommon_IPlatformInfo */ $platforminfo = $this->container->getService('platforminfo'); $ns = array(); $ns[] = "if (typeof RokSprocket == 'undefined') RokSprocket = {};"; $ns[] = "Object.merge(RokSprocket, {"; $ns[] = "\tSiteURL: '" . str_replace('&', '&', $platforminfo->getSEOUrl($platforminfo->getRootUrl(), true)) . "',"; $ns[] = "\tCurrentURL: '" . str_replace('&', '&', $platforminfo->getSEOUrl($platforminfo->getRootUrl(), true)) . "',"; $ns[] = "\tAjaxURL: '" . str_replace('&', '&', $platforminfo->getSEOUrl($platforminfo->getRootUrl() . $ajax_path)) . "'"; $ns[] = "});"; RokCommon_Header::addInlineScript(implode("\n", $ns) . "\n"); self::$globalHeadersRendered = true; } }
public function _realGetData() { return parent::getData(); }
public function getArticles($module_id, $params) { return RokSprocket::getItemsWithParams($module_id, new RokCommon_Registry($params), false, true); }