Exemplo n.º 1
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     //initialize variables
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $view = JRequest::getCmd('view');
     // Get view's Model
     $model = $this->getModel();
     // Get tag and set tag parameters as VIEW's parameters (tag parameters are merged with component/page(=menu item) and optionally with tag cloud parameters)
     $tag = $model->getTag();
     if (empty($tag)) {
         // Raise a 404 error, if tag doesn't exist or access isn't permitted, maybe move this into model ??
         $tid = JRequest::getInt('id', 0);
         $msg = JText::sprintf($tid ? 'Tag id was not set (is 0)' : 'Tag #%d not found', $tid);
         if (FLEXI_J16GE) {
             throw new Exception($msg, 404);
         } else {
             JError::raiseError(404, $msg);
         }
     }
     // Get parameters via model
     $params = $model->getParams();
     // Get various data from the model
     $items = $this->get('Data');
     $total = $this->get('Total');
     // Make sure field values were retrieved e.g. we need 'item->categories' for template classes
     $items = FlexicontentFields::getFields($items, $view, $params);
     // Calculate CSS classes needed to add special styling markups to the items
     flexicontent_html::calculateItemMarkups($items, $params);
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('flexi_tmpl_common');
     //add css file
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css');
         $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
     }
     //allow css override
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
         $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css');
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = 'tags' == @$menu->query['view'];
         $tid_ok = $tag->id == (int) @$menu->query['id'];
         $menu_matches = $view_ok && $tid_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         // meta_params->get('page_title') is meant for <title> but let's use as ... default page heading
         $default_heading = JText::_('FLEXI_ITEMS_WITH_TAG') . ": " . $tag->name;
         // Decide to show page heading (=J1.5 page title), this is always yes
         $show_default_heading = 1;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if ... currently no reason
     if (0) {
         $params->set('show_page_heading', 0);
         $params->set('show_page_title', 0);
     }
     // ************************************************************
     // Create the document title, by from page title and other data
     // ************************************************************
     // Use the page heading as document title, (already calculated above via 'appropriate' logic ...)
     $doc_title = $params->get('page_title');
     // Check and prepend or append site name
     if (FLEXI_J16GE) {
         // Not available in J1.5
         // Add Site Name to page title
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = $app->getCfg('sitename') . " - " . $doc_title;
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = $doc_title . " - " . $app->getCfg('sitename');
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     // Overwrite with menu META data if menu matched
     if (FLEXI_J16GE) {
         if ($menu_matches) {
             if ($_mp = $menu->params->get('menu-meta_description')) {
                 $document->setDescription($_mp);
             }
             if ($_mp = $menu->params->get('menu-meta_keywords')) {
                 $document->setMetadata('keywords', $_mp);
             }
             if ($_mp = $menu->params->get('robots')) {
                 $document->setMetadata('robots', $_mp);
             }
             if ($_mp = $menu->params->get('secure')) {
                 $document->setMetadata('secure', $_mp);
             }
         }
     }
     // ************************************
     // Add rel canonical html head link tag (TODO: improve multi-page handing)
     // ************************************
     $base = $uri->getScheme() . '://' . $uri->getHost();
     $start = JRequest::getVar('start', '');
     $start = $start ? "&start=" . $start : "";
     $ucanonical = $base . JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->id) . $start);
     if ($params->get('add_canonical')) {
         $head_obj = $document->addHeadLink($ucanonical, 'canonical', 'rel', '');
         $defaultCanonical = flexicontent_html::getDefaultCanonical();
         if (FLEXI_J30GE && $defaultCanonical != $ucanonical) {
             unset($head_obj->_links[$defaultCanonical]);
         }
     }
     //ordering
     $filter_order = JRequest::getCmd('filter_order', 'i.title');
     $filter_order_Dir = JRequest::getCmd('filter_order_Dir', 'ASC');
     $filter = JRequest::getString('filter');
     $lists = array();
     $lists['filter_order'] = $filter_order;
     $lists['filter_order_Dir'] = $filter_order_Dir;
     $lists['filter'] = $filter;
     // Create the pagination object
     $pageNav = $this->get('pagination');
     // Create links, etc
     $link = JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug), false);
     //$print_link = JRoute::_('index.php?view=tags&id='.$tag->slug.'&pop=1&tmpl=component');
     $curr_url = $_SERVER['REQUEST_URI'];
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('action', $link);
     // $uri->toString()
     $this->assignRef('print_link', $print_link);
     $this->assignRef('tag', $tag);
     $this->assignRef('items', $items);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('pageNav', $pageNav);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $print_logging_info = $params->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
         $start_microtime = microtime(true);
     }
     parent::display($tpl);
     if ($print_logging_info) {
         @($fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
 }
Exemplo n.º 2
0
 /**
  * Method to render (display method) a field on demand and return the display
  * 
  * @access public
  * @return object
  * @since 1.5.5
  */
 static function &getFieldDisplay(&$item_arr, $fieldname, $single_item_vals = null, $method = 'display', $view = FLEXI_ITEMVIEW)
 {
     // 1. Convert to array of items if not an array already
     if (empty($item_arr)) {
         $err_msg = __FUNCTION__ . "(): empty item data given";
         return $err_msg;
     } else {
         if (!is_array($item_arr)) {
             $items = array(&$item_arr);
         } else {
             $items =& $item_arr;
         }
     }
     // 2. Make sure that fields have been created for all given items
     $_items = array();
     foreach ($items as $i => $item) {
         if (!isset($item->fields)) {
             $_items[] =& $items[$i];
         }
     }
     if (count($_items)) {
         FlexicontentFields::getFields($_items, $view);
     }
     // 3. Check and create HTML display for the given field name
     $_return = array();
     foreach ($items as $item) {
         // Check if we have already created the display and skip current item
         if (isset($item->onDemandFields[$fieldname]->{$method})) {
             continue;
         }
         // Find the field inside item
         foreach ($item->fields as $field) {
             if (!empty($field->name) && $field->name == $fieldname) {
                 break;
             }
         }
         // Check for not found field, and skip it, this is either due to no access or wrong name ...
         $item->onDemandFields[$fieldname] = new stdClass();
         if (empty($field->name) || $field->name != $fieldname) {
             $item->onDemandFields[$fieldname]->label = '';
             $item->onDemandFields[$fieldname]->noaccess = true;
             $item->onDemandFields[$fieldname]->errormsg = 'field not assigned to this type of item or current user has no access';
             $item->onDemandFields[$fieldname]->{$method} = '';
             continue;
         }
         // Get field's values if they were custom values were not given
         if ($single_item_vals !== null && count($items) == 1) {
             // $values is used only if rendering a single item
             $values = $single_item_vals;
         } else {
             $values = isset($item->fieldvalues[$field->id]) ? $item->fieldvalues[$field->id] : array();
         }
         // Set other field data like label and field itself !!!
         $item->onDemandFields[$fieldname]->label = $field->label;
         $item->onDemandFields[$fieldname]->noaccess = false;
         $item->onDemandFields[$fieldname]->field =& $field;
         // Render the (display) method of the field
         if (!isset($field->{$method})) {
             $field = FlexicontentFields::renderField($item, $field, $values, $method, $view);
         }
         if (!isset($field->{$method})) {
             $field->{$method} = '';
         }
         $item->onDemandFields[$fieldname]->{$method} =& $field->{$method};
         $_method_html[$item->id] =& $field->{$method};
     }
     // Return field(s) HTML (in case of multiple items this will be an array indexable by item ids
     if (!is_array($item_arr)) {
         $_method_html = @$_method_html[$item_arr->id];
         // Suppress field name not found ...
     }
     return $_method_html;
 }
Exemplo n.º 3
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     // check for form layout
     if ($this->getLayout() == 'form' || in_array(JRequest::getVar('task'), array('add', 'edit'))) {
         // Important set layout to be form since various category view SEF links have this variable set
         $this->setLayout('form');
         $this->_displayForm($tpl);
         return;
     } else {
         $this->setLayout('item');
     }
     // Get Content Types with no category links in item view pathways, and for unroutable (non-linkable) categories
     global $globalnoroute, $globalnopath, $globalcats;
     if (!is_array($globalnopath)) {
         $globalnopath = array();
     }
     if (!is_array($globalnoroute)) {
         $globalnoroute = array();
     }
     //initialize variables
     $dispatcher = JDispatcher::getInstance();
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $document = JFactory::getDocument();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $aid = JAccess::getAuthorisedViewLevels($user->id);
     $db = JFactory::getDBO();
     $nullDate = $db->getNullDate();
     // ******************************************************
     // Get item, model and create form (that loads item data)
     // ******************************************************
     // Get model
     $model = $this->getModel();
     $cid = $model->_cid ? $model->_cid : $model->get('catid');
     // Get current category id
     // Decide version to load
     $version = JRequest::getVar('version', 0, 'request', 'int');
     // Load specific item version (non-zero), 0 version: is unversioned data, -1 version: is latest version (=default for edit form)
     $preview = JRequest::getVar('preview', 0, 'request', 'int');
     // Preview versioned data FLAG ... if previewing and version is not set then ... we load version -1 (=latest version)
     $version = $preview && !$version ? -1 : $version;
     // Allow iLayout from HTTP request, this will be checked during loading item parameters
     $model->setItemLayout('__request__');
     // Try to load existing item, an 404 error will be raised if item is not found. Also value 2 for check_view_access
     // indicates to raise 404 error for ZERO primary key too, instead of creating and returning a new item object
     $start_microtime = microtime(true);
     $item = $model->getItem(null, $check_view_access = 2, $no_cache = $version || $preview, $force_version = $version || $preview ? $version : 0);
     // ZERO means unversioned data
     $_run_time = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
     // Get item parameters as VIEW's parameters (item parameters are merged parameters in order: component/category/layout/type/item/menu/access)
     $params =& $item->parameters;
     // Get item 's layout as this may have been altered
     $ilayout = $params->get('ilayout');
     $print_logging_info = $params->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
     }
     if ($print_logging_info) {
         $fc_run_times['get_item_data'] = $_run_time;
     }
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     //add css file
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css');
         $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
     }
     //allow css override
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
         $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css');
     }
     //special to hide the joomfish language selector on item views
     if ($params->get('disable_lang_select', 0)) {
         $css = '#jflanguageselection { visibility:hidden; }';
         $document->addStyleDeclaration($css);
     }
     // *************************************************************
     // Get cached template data, loading any template language files
     // *************************************************************
     $themes = flexicontent_tmpl::getTemplates($lang_files = array($ilayout));
     // *****************
     // Get Item's Fields
     // *****************
     $_items = array(&$item);
     FlexicontentFields::getFields($_items, FLEXI_ITEMVIEW, $params, $aid);
     $fields = $item->fields;
     // ****************************************
     // Get category titles needed by pathway,
     // this will allow Falang to translate them
     // ****************************************
     $catshelper = new flexicontent_cats($cid);
     $parents = $catshelper->getParentlist($all_cols = false);
     //echo "<pre>".print_r($parents,true)."</pre>";
     /*$parents = array();
     		if ( $cid && isset($globalcats[$cid]->ancestorsarray) ) {
     			$parent_ids = $globalcats[$cid]->ancestorsarray;
     			foreach ($parent_ids as $parent_id) $parents[] = $globalcats[$parent_id];
     		}*/
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = FLEXI_ITEMVIEW == @$menu->query['view'] || 'article' == @$menu->query['view'];
         $cid_ok = JRequest::getInt('cid') == (int) @$menu->query['cid'];
         $id_ok = JRequest::getInt('id') == (int) @$menu->query['id'];
         $menu_matches = $view_ok && $id_ok;
         //$menu_params = $menu->params;  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         $default_heading = $item->title;
         // Decide to show page heading (=J1.5 page title), there is no need for this in item view
         $show_default_heading = 0;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if (a) IT IS same as item title and (b) item title is already configured to be shown
     if ($params->get('show_title', 1)) {
         if ($params->get('page_heading') == $item->title) {
             $params->set('show_page_heading', 0);
         }
         if ($params->get('page_title') == $item->title) {
             $params->set('show_page_title', 0);
         }
     }
     // ************************************************************
     // Create the document title, by from page title and other data
     // ************************************************************
     // Use the page heading as document title, (already calculated above via 'appropriate' logic ...)
     // or the overriden custom <title> ... set via parameter
     $doc_title = !$params->get('override_title', 0) ? $params->get('page_title') : $params->get('custom_ititle', $item->title);
     // Check and prepend category title
     if ($params->get('addcat_title', 1) && count($parents)) {
         $parentcat = end($parents);
         if (isset($item->category_title)) {
             if ($params->get('addcat_title', 1) == 1) {
                 // On Left
                 $doc_title = JText::sprintf('FLEXI_PAGETITLE_SEPARATOR', $item->category_title, $doc_title);
             } else {
                 // On Right
                 $doc_title = JText::sprintf('FLEXI_PAGETITLE_SEPARATOR', $doc_title, $item->category_title);
             }
         }
     }
     // Check and prepend or append site name to page title
     if ($doc_title != $app->getCfg('sitename')) {
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $doc_title);
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = JText::sprintf('JPAGETITLE', $doc_title, $app->getCfg('sitename'));
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     // Set item's META data: desc, keyword, title, author
     if ($item->metadesc) {
         $document->setDescription($item->metadesc);
     }
     if ($item->metakey) {
         $document->setMetadata('keywords', $item->metakey);
     }
     // ?? Deprecated <title> tag is used instead by search engines
     if ($app->getCfg('MetaTitle') == '1') {
         $document->setMetaData('title', $item->title);
     }
     if ($app->getCfg('MetaAuthor') == '1') {
         $document->setMetaData('author', $item->author);
     }
     // Set remaining META keys
     $mdata = $item->metadata->toArray();
     foreach ($mdata as $k => $v) {
         if ($v) {
             $document->setMetadata($k, $v);
         }
     }
     // Overwrite with menu META data if menu matched
     if ($menu_matches) {
         if ($_mp = $menu->params->get('menu-meta_description')) {
             $document->setDescription($_mp);
         }
         if ($_mp = $menu->params->get('menu-meta_keywords')) {
             $document->setMetadata('keywords', $_mp);
         }
         if ($_mp = $menu->params->get('robots')) {
             $document->setMetadata('robots', $_mp);
         }
         if ($_mp = $menu->params->get('secure')) {
             $document->setMetadata('secure', $_mp);
         }
     }
     // ****************************************************************
     // Make sure Joomla SEF plugin has inserted a correct REL canonical
     // or that it has not insert any REL if current URL is sufficient
     // ****************************************************************
     if ($params->get('add_canonical')) {
         // Get canonical URL that SEF plugin adds, also $domain passed by reference, to get the domain configured in SEF plugin (multi-domain website)
         $domain = null;
         $defaultCanonical = flexicontent_html::getDefaultCanonical($domain);
         $domain = $domain ? $domain : $uri->toString(array('scheme', 'host', 'port'));
         // Create desired REL canonical URL
         $ucanonical = $domain . JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $globalcats[$item->maincatid]->slug, 0, $item));
         // $item->categoryslug
         // Check if SEF plugin inserted a different REL canonical
         if ($defaultCanonical != $ucanonical) {
             // Add REL canonical only if different than current URL
             $head_obj = $document->addHeadLink(htmlspecialchars($ucanonical), 'canonical', 'rel', '');
             if ($uri->toString() == $ucanonical) {
                 unset($head_obj->_links[htmlspecialchars($ucanonical)]);
             }
             // Remove canonical inserted by SEF plugin
             unset($head_obj->_links[htmlspecialchars($defaultCanonical)]);
         }
     }
     // *************************
     // increment the hit counter
     // *************************
     // MOVED to flexisystem plugin due to ...
     /*if (FLEXIUtilities::count_new_hit($item->id) ) {
     			$model->hit();
     		}*/
     // Load template css/js and set template data variable
     $tmplvar = $themes->items->{$ilayout}->tmplvar;
     if ($ilayout) {
         // Add the templates css files if availables
         if (isset($themes->items->{$ilayout}->css)) {
             foreach ($themes->items->{$ilayout}->css as $css) {
                 $document->addStyleSheet($this->baseurl . '/' . $css);
             }
         }
         // Add the templates js files if availables
         if (isset($themes->items->{$ilayout}->js)) {
             foreach ($themes->items->{$ilayout}->js as $js) {
                 $document->addScript($this->baseurl . '/' . $js);
             }
         }
         // Set the template var
         $tmpl = $themes->items->{$ilayout}->tmplvar;
     } else {
         $tmpl = '.items.default';
     }
     // Just put item's text (description field) inside property 'text' in case the events modify the given text,
     $item->text = isset($item->fields['text']->display) ? $item->fields['text']->display : '';
     // Maybe here not to import all plugins but just those for description field ???
     // Anyway these events are usually not very time consuming, so lets trigger all of them ???
     JPluginHelper::importPlugin('content');
     // Suppress some plugins from triggering for compatibility reasons, e.g.
     // (a) jcomments, jom_comment_bot plugins, because we will get comments HTML manually inside the template files
     $suppress_arr = array('jcomments', 'jom_comment_bot');
     FLEXIUtilities::suppressPlugins($suppress_arr, 'suppress');
     // Do some compatibility steps, Set the view and option to 'article' and 'com_content'
     JRequest::setVar('view', 'article');
     JRequest::setVar('option', 'com_content');
     JRequest::setVar("isflexicontent", "yes");
     $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     // These events return text that could be displayed at appropriate positions by our templates
     $item->event = new stdClass();
     $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$params, $limitstart));
     $item->event->afterDisplayTitle = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$params, $limitstart));
     $item->event->beforeDisplayContent = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$params, $limitstart));
     $item->event->afterDisplayContent = trim(implode("\n", $results));
     // Reverse the compatibility steps, set the view and option back to 'items' and 'com_flexicontent'
     JRequest::setVar('view', FLEXI_ITEMVIEW);
     JRequest::setVar('option', 'com_flexicontent');
     // Restore suppressed plugins
     FLEXIUtilities::suppressPlugins($suppress_arr, 'restore');
     // Put text back into the description field, THESE events SHOULD NOT modify the item text, but some plugins may do it anyway... , so we assign text back for compatibility
     if (!empty($item->positions)) {
         foreach ($item->positions as $pos_fields) {
             foreach ($pos_fields as $pos_field) {
                 if ($pos_field->name !== 'text') {
                     continue;
                 }
                 $pos_field->display =& $item->text;
             }
         }
     }
     $item->fields['text']->display =& $item->text;
     // (TOC) TABLE OF Contents has been created inside description field (named 'text') by
     // the pagination plugin, this should be assigned to item as a property with same name
     if (isset($item->fields['text']->toc)) {
         $item->toc =& $item->fields['text']->toc;
     }
     // ********************************************************************************************
     // Create pathway, if automatic pathways is enabled, then path will be cleared before populated
     // ********************************************************************************************
     $pathway = $app->getPathWay();
     // Clear pathway, if automatic pathways are enabled
     if ($params->get('automatic_pathways', 0)) {
         $pathway_arr = $pathway->getPathway();
         $pathway->setPathway(array());
         //$pathway->set('_count', 0);  // not needed ??
         $item_depth = 0;
         // menu item depth is now irrelevant ???, ignore it
     } else {
         $item_depth = $params->get('item_depth', 0);
     }
     // Respect menu item depth, defined in menu item
     $p = $item_depth;
     while ($p < count($parents)) {
         // For some Content Types the pathway should not be populated with category links
         if (in_array($item->type_id, $globalnopath)) {
             break;
         }
         // Do not add to pathway unroutable categories
         if (in_array($parents[$p]->id, $globalnoroute)) {
             $p++;
             continue;
         }
         // Add current parent category
         $pathway->addItem($this->escape($parents[$p]->title), JRoute::_(FlexicontentHelperRoute::getCategoryRoute($parents[$p]->slug)));
         $p++;
     }
     if ($params->get('add_item_pathway', 1)) {
         $pathway->addItem($this->escape($item->title), JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug, 0, $item)));
     }
     // **********************************************************************
     // Print link ... must include layout and current filtering url vars, etc
     // **********************************************************************
     $curr_url = $_SERVER['REQUEST_URI'];
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     //$print_link = JRoute::_('index.php?view='.FLEXI_ITEMVIEW.'&cid='.$item->categoryslug.'&id='.$item->slug.'&pop=1&tmpl=component&print=1');
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('item', $item);
     $this->assignRef('user', $user);
     $this->assignRef('params', $params);
     $this->assignRef('print_link', $print_link);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $this->assignRef('parentcat', $parentcat);
     $this->assignRef('fields', $item->fields);
     $this->assignRef('tmpl', $tmpl);
     /*
      * Set template paths : this procedure is issued from K2 component
      *
      * "K2" Component by JoomlaWorks for Joomla! 1.5.x - Version 2.1
      * Copyright (c) 2006 - 2009 JoomlaWorks Ltd. All rights reserved.
      * Released under the GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
      * More info at http://www.joomlaworks.gr and http://k2.joomlaworks.gr
      * Designed and developed by the JoomlaWorks team
      */
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates');
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates');
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . 'default');
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . 'default');
     if ($ilayout) {
         $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . $ilayout);
         $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $ilayout);
     }
     if ($print_logging_info) {
         $start_microtime = microtime(true);
     }
     parent::display($tpl);
     if ($print_logging_info) {
         $fc_run_times['template_render'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
     }
 }
Exemplo n.º 4
0
    function renderFields($context, &$row, &$params, $page = 0)
    {
        JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables');
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'defineconstants.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.fields.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'models' . DS . FLEXI_ITEMVIEW . '.php';
        $app = JFactory::getApplication();
        $user = JFactory::getUser();
        $aid = JAccess::getAuthorisedViewLevels($user->id);
        $itemmodel = new FlexicontentModelItem();
        $item = $itemmodel->getItem($row->id, $check_view_access = false);
        $view = 'com_content.article' ? FLEXI_ITEMVIEW : 'category';
        $items = FlexicontentFields::getFields($item, $view, $_item_params = null, $aid = null, $use_tmpl = false);
        // $_item_params == null means only retrieve fields
        // Only Render custom fields
        $displayed_fields = array();
        foreach ($item->fields as $field) {
            if ($field->iscore) {
                continue;
            }
            $displayed_fields[$field->name] = $field;
            $values = isset($item->fieldvalues[$field->id]) ? $item->fieldvalues[$field->id] : array();
            FlexicontentFields::renderField($item, $field, $values, $method = 'display', $view);
        }
        if (!count($displayed_fields)) {
            return null;
        }
        // Render the list of groups
        $field_html = array();
        foreach ($displayed_fields as $field_name => $field) {
            $_values = null;
            if (!isset($field->display)) {
                continue;
            }
            $field_html[] = '
				<div class="fc-field-box">
					' . ($field->parameters->get('display_label') ? '
					<span class="flexi label">' . $field->label . '</span>' : '') . '
					<div class="flexi value">' . $field->display . '</div>
				</div>
				';
        }
        $_display = '<div class="fc-custom-fields-box">' . implode('', $field_html) . '</div>';
        return $_display;
    }
 /**
  * Function to render the item view of a given item id
  *
  * @param 	int 		$item_id
  * @return 	string  : the HTML of the item view, also the CSS / JS file would have been loaded
  * @since 1.5
  */
 function renderItem($item_id, $view = FLEXI_ITEMVIEW, $ilayout = '')
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables');
     require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.fields.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'models' . DS . FLEXI_ITEMVIEW . '.php';
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $itemmodel = new FlexicontentModelItem();
     $item = $itemmodel->getItem($item_id, $check_view_access = false);
     $aid = JAccess::getAuthorisedViewLevels($user->id);
     list($item) = FlexicontentFields::getFields($item, $view, $item->parameters, $aid);
     // Get Item's specific ilayout
     if ($ilayout == '') {
         $ilayout = $item->parameters->get('ilayout', '');
     }
     // Get type's ilayout
     if ($ilayout == '') {
         $type = JTable::getInstance('flexicontent_types', '');
         $type->id = $item->type_id;
         $type->load();
         $type->params = new JRegistry($type->attribs);
         $ilayout = $type->params->get('ilayout', 'default');
     }
     $this->item =& $item;
     $this->params_saved = @$this->params;
     $this->params =& $item->parameters;
     $this->tmpl = '.item.' . $ilayout;
     $this->print_link = JRoute::_('index.php?view=' . FLEXI_ITEMVIEW . '&id=' . $item->slug . '&pop=1&tmpl=component');
     $this->pageclass_sfx = '';
     if (!isset($this->item->event)) {
         $this->item->event = new stdClass();
     }
     $this->item->event->beforeDisplayContent = '';
     $this->item->event->afterDisplayTitle = '';
     $this->item->event->afterDisplayContent = '';
     $this->fields =& $this->item->fields;
     // start capturing output into a buffer
     ob_start();
     // Include the requested template filename in the local scope (this will execute the view logic).
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $ilayout)) {
         include JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $ilayout . DS . 'item.php';
     } else {
         if (file_exists(JPATH_COMPONENT . DS . 'templates' . DS . $ilayout)) {
             include JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'templates' . DS . $ilayout . DS . 'item.php';
         } else {
             include JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'templates' . DS . 'default' . DS . 'item.php';
         }
     }
     // done with the requested template; get the buffer and clear it.
     $item_html = ob_get_contents();
     ob_end_clean();
     $this->params = $this->params_saved;
     return $item_html;
 }
Exemplo n.º 6
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     //initialize variables
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $view = JRequest::getCmd('view');
     // Get view's Model
     $model = $this->getModel();
     // Get parameters via model
     $params = $model->getParams();
     // Get various data from the model
     $items = $this->get('Data');
     $total = $this->get('Total');
     // Make sure field values were retrieved e.g. we need 'item->categories' for template classes
     $items = FlexicontentFields::getFields($items, $view, $params);
     // Calculate CSS classes needed to add special styling markups to the items
     flexicontent_html::calculateItemMarkups($items, $params);
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('flexi_tmpl_common');
     // Add css files to the document <head> section (also load CSS joomla template override)
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheetVersion($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css', FLEXI_VHASH);
         //$document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
     }
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
         $document->addStyleSheetVersion($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css', FLEXI_VHASH);
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = 'favourites' == @$menu->query['view'];
         $menu_matches = $view_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         // meta_params->get('page_title') is meant for <title> but let's use as ... default page heading
         $default_heading = JText::_('FLEXI_YOUR_FAVOURED_ITEMS');
         // Decide to show page heading (=J1.5 page title), this is always yes
         $show_default_heading = 1;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if ... currently no reason
     if (0) {
         $params->set('show_page_heading', 0);
         $params->set('show_page_title', 0);
     }
     // ************************************************************
     // Create the document title, by from page title and other data
     // ************************************************************
     // Use the page heading as document title, (already calculated above via 'appropriate' logic ...)
     $doc_title = $params->get('page_title');
     // Check and prepend or append site name to page title
     if ($doc_title != $app->getCfg('sitename')) {
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $doc_title);
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = JText::sprintf('JPAGETITLE', $doc_title, $app->getCfg('sitename'));
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     // Overwrite with menu META data if menu matched
     if ($menu_matches) {
         if ($_mp = $menu->params->get('menu-meta_description')) {
             $document->setDescription($_mp);
         }
         if ($_mp = $menu->params->get('menu-meta_keywords')) {
             $document->setMetadata('keywords', $_mp);
         }
         if ($_mp = $menu->params->get('robots')) {
             $document->setMetadata('robots', $_mp);
         }
         if ($_mp = $menu->params->get('secure')) {
             $document->setMetadata('secure', $_mp);
         }
     }
     // Disable features, that are not supported by the view
     $params->set('use_filters', 0);
     $params->set('show_alpha', 0);
     $params->set('clayout_switcher', 0);
     //ordering
     $filter_order = JRequest::getCmd('filter_order', 'i.title');
     $filter_order_Dir = JRequest::getCmd('filter_order_Dir', 'ASC');
     $filter = JRequest::getString('filter');
     $lists = array();
     $lists['filter_order'] = $filter_order;
     $lists['filter_order_Dir'] = $filter_order_Dir;
     $lists['filter'] = $filter;
     // Create the pagination object
     $pageNav = $this->get('pagination');
     // URL-encode filter values
     foreach ($_GET as $i => $v) {
         if (substr($i, 0, 6) === "filter") {
             $_revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')');
             $v = str_replace('&', '__amp__', $v);
             $v = strtr(rawurlencode($v), $_revert);
             $pageNav->setAdditionalUrlParam($i, $v);
         }
     }
     // Create links, etc
     $link = JRoute::_(FlexicontentHelperRoute::getFavsRoute(0, $menu_matches ? $menu->id : 0));
     //$print_link  = JRoute::_('index.php?view=favourites&pop=1&tmpl=component');
     $curr_url = str_replace('&', '&amp;', $_SERVER['REQUEST_URI']);
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('action', $link);
     // $uri->toString()
     $this->assignRef('print_link', $print_link);
     $this->assignRef('items', $items);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('pageNav', $pageNav);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $print_logging_info = $params->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
         $start_microtime = microtime(true);
     }
     parent::display($tpl);
     if ($print_logging_info) {
         @($fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
 }
Exemplo n.º 7
0
 public static function getList(&$params)
 {
     global $modfc_jprof, $mod_fc_run_times;
     $forced_itemid = $params->get('forced_itemid');
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     // Get IDs of user's access view levels
     if (!FLEXI_J16GE) {
         $aid = (int) $user->get('aid');
     } else {
         $aid_arr = JAccess::getAuthorisedViewLevels($user->id);
     }
     // get the component parameters
     $flexiparams = JComponentHelper::getParams('com_flexicontent');
     // get module ordering parameters
     $ordering = $params->get('ordering', array());
     $count = (int) $params->get('count', 5);
     $featured = (int) $params->get('count_feat', 1);
     // Default ordering is 'added' if none ordering is set. Also make sure $ordering is an array (of ordering groups)
     if (empty($ordering)) {
         $ordering = array('added');
     }
     if (!is_array($ordering)) {
         $ordering = explode(',', $ordering);
     }
     // get other module parameters
     $method_curlang = (int) $params->get('method_curlang', 0);
     // standard
     $display_title = $params->get('display_title');
     $link_title = $params->get('link_title');
     $cuttitle = $params->get('cuttitle');
     $display_date = $params->get('display_date');
     $display_text = $params->get('display_text');
     $display_hits = $params->get('display_hits');
     $display_voting = $params->get('display_voting');
     $display_comments = $params->get('display_comments');
     $mod_readmore = $params->get('mod_readmore');
     $mod_cut_text = $params->get('mod_cut_text');
     $mod_do_stripcat = $params->get('mod_do_stripcat', 1);
     $mod_use_image = $params->get('mod_use_image');
     $mod_image = $params->get('mod_image');
     $mod_link_image = $params->get('mod_link_image');
     $mod_default_img_show = $params->get('mod_default_img_show', 1);
     $mod_default_img_path = $params->get('mod_default_img_path', 'components/com_flexicontent/assets/images/image.png');
     $mod_width = (int) $params->get('mod_width', 80);
     $mod_height = (int) $params->get('mod_height', 80);
     $mod_method = (int) $params->get('mod_method', 1);
     // featured
     $display_title_feat = $params->get('display_title_feat');
     $link_title_feat = $params->get('link_title_feat');
     $cuttitle_feat = $params->get('cuttitle_feat');
     $display_date_feat = $params->get('display_date_feat');
     $display_text_feat = $params->get('display_text');
     $display_hits_feat = $params->get('display_hits_feat');
     $display_voting_feat = $params->get('display_voting_feat');
     $display_comments_feat = $params->get('display_comments_feat');
     $mod_readmore_feat = $params->get('mod_readmore_feat');
     $mod_cut_text_feat = $params->get('mod_cut_text_feat');
     $mod_do_stripcat_feat = $params->get('mod_do_stripcat_feat', 1);
     $mod_use_image_feat = $params->get('mod_use_image_feat');
     $mod_link_image_feat = $params->get('mod_link_image_feat');
     $mod_width_feat = (int) $params->get('mod_width_feat', 140);
     $mod_height_feat = (int) $params->get('mod_height_feat', 140);
     $mod_method_feat = (int) $params->get('mod_method_feat', 1);
     // Common for image of standard/feature image
     $mod_image_custom_display = $params->get('mod_image_custom_display');
     $mod_image_custom_url = $params->get('mod_image_custom_url');
     $mod_image_fallback_img = $params->get('mod_image_fallback_img');
     // Retrieve default image for the image field and also create field parameters so that they can be used
     if ($mod_image) {
         $query = 'SELECT attribs, name FROM #__flexicontent_fields WHERE id = ' . (int) $mod_image;
         $db->setQuery($query);
         $mod_image_dbdata = $db->loadObject();
         $mod_image_name = $mod_image_dbdata->name;
         //$img_fieldparams = new JRegistry($mod_image_dbdata->attribs);
     }
     if ($mod_default_img_show) {
         $src = $mod_default_img_path;
         // Default image featured
         $h = '&amp;h=' . $mod_height;
         $w = '&amp;w=' . $mod_width;
         $aoe = '&amp;aoe=1';
         $q = '&amp;q=95';
         $zc = $mod_method ? '&amp;zc=' . $mod_method : '';
         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
         $conf = $w . $h . $aoe . $q . $zc . $f;
         $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
         $thumb_default = JURI::base() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $base_url . $src . $conf;
         // Default image standard
         $h = '&amp;h=' . $mod_height_feat;
         $w = '&amp;w=' . $mod_width_feat;
         $aoe = '&amp;aoe=1';
         $q = '&amp;q=95';
         $zc = $mod_method_feat ? '&amp;zc=' . $mod_method_feat : '';
         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
         $conf = $w . $h . $aoe . $q . $zc . $f;
         $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
         $thumb_default_feat = JURI::base() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $base_url . $src . $conf;
     }
     // Retrieve custom displayed field data (including their parameters and access):  hits/voting/etc
     if ($display_hits || $display_hits_feat || $display_voting || $display_voting_feat) {
         $query = 'SELECT * FROM #__flexicontent_fields';
         $disp_field_where = array();
         if ($display_hits || $display_hits_feat) {
             $disp_field_where[] = 'field_type="hits"';
         }
         if ($display_voting || $display_voting_feat) {
             $disp_field_where[] = 'field_type="voting"';
         }
         $query .= ' WHERE ' . implode($disp_field_where, ' OR ');
         $db->setQuery($query);
         $disp_fields_data = $db->loadObjectList('field_type');
         if ($display_hits || $display_hits_feat) {
             $hitsfield = $disp_fields_data['hits'];
             $hitsfield->parameters = new JRegistry($hitsfield->attribs);
             $has_access_hits = in_array($hitsfield->access, $aid_arr);
         }
         if ($display_voting || $display_voting_feat) {
             $votingfield = $disp_fields_data['voting'];
             $votingfield->parameters = new JRegistry($votingfield->attribs);
             $has_access_voting = in_array($votingfield->access, $aid_arr);
         }
     }
     // get module fields parameters
     $use_fields = $params->get('use_fields', 1);
     $display_label = $params->get('display_label');
     $fields = array_map('trim', explode(',', $params->get('fields')));
     if ($fields[0] == '') {
         $fields = array();
     }
     // get fields that when empty cause an item to be skipped
     $skip_items = (int) $params->get('skip_items', 0);
     $skiponempty_fields = array_map('trim', explode(',', $params->get('skiponempty_fields')));
     if ($skiponempty_fields[0] == '') {
         $skiponempty_fields = array();
     }
     if ($params->get('maxskipcount', 50) > 100) {
         $params->set('maxskipcount', 100);
     }
     $striptags_onempty_fields = $params->get('striptags_onempty_fields');
     $onempty_fields_combination = $params->get('onempty_fields_combination');
     // featured
     $use_fields_feat = $params->get('use_fields_feat', 1);
     $display_label_feat = $params->get('display_label_feat');
     $fields_feat = array_map('trim', explode(',', $params->get('fields_feat')));
     if ($fields_feat[0] == '') {
         $fields_feat = array();
     }
     //$mod_fc_run_times['query_items']= $modfc_jprof->getmicrotime();
     $cat_items_arr = array();
     if (!is_array($ordering)) {
         $ordering = explode(',', $ordering);
     }
     foreach ($ordering as $ord) {
         $items_arr = modFlexicontentHelper::getItems($params, $ord);
         if (empty($items_arr)) {
             continue;
         }
         foreach ($items_arr as $catid => $items) {
             if (!isset($cat_items_arr[$catid])) {
                 $cat_items_arr[$catid] = array();
             }
             for ($i = 0; $i < count($items); $i++) {
                 $items[$i]->featured = $i < $featured ? 1 : 0;
                 $items[$i]->fetching = $ord;
                 $cat_items_arr[$catid][] = $items[$i];
             }
         }
     }
     //$mod_fc_run_times['query_items'] = $modfc_jprof->getmicrotime() - $mod_fc_run_times['query_items'];
     // Impementation of Empty Field Filter.
     // The cost of the following code is minimal.
     // The big time cost goes into rendering the fields ...
     // We need to create the display of the fields before examining if they are empty.
     // The hardcoded limit of max items skipped is 100.
     if ($skip_items && count($skiponempty_fields)) {
         $mod_fc_run_times['empty_fields_filter'] = $modfc_jprof->getmicrotime();
         // 0. Add ONLY skipfields to the list of fields to be rendered
         $fields_list = implode(',', $skiponempty_fields);
         //$skip_params = new JRegistry();
         //$skip_params->set('fields',$fields_list);
         foreach ($cat_items_arr as $catid => $cat_items) {
             // 1. The filtered rows
             $filtered_rows = array();
             $order_count = array();
             // 2. Get field values (we pass null parameters to only retrieve field values and not render (YET) the 'skip-onempty' fields
             FlexicontentFields::getFields($cat_items, 'module', $skip_params = null);
             // 3. Skip Items with empty fields (if this filter is enabled)
             foreach ($cat_items as $i => $item) {
                 //echo "$i . {$item->title}<br/>";
                 // Check to initialize counter for this ordering
                 if (!isset($order_count[$item->fetching])) {
                     $order_count[$item->fetching] = 0;
                 }
                 // Check if enough encountered for this ordering
                 if ($order_count[$item->fetching] >= $count) {
                     continue;
                 }
                 // Initialize skip property ZERO for 'any' and ONE for 'all'
                 $skip_curritem = $onempty_fields_combination == 'any' ? 0 : 1;
                 // Now check for empty field display or empty field values, if so item must be skipped
                 foreach ($skiponempty_fields as $skipfield_name) {
                     if ($skip_items == 2) {
                         // We will check field's display
                         FlexicontentFields::getFieldDisplay($item, $skipfield_name, null, 'display', 'module');
                         $skipfield_data = @$item->fields[$skipfield_name]->display;
                     } else {
                         // We will check field's value
                         $skipfield_iscore = $item->fields[$skipfield_name]->iscore;
                         $skipfield_id = $item->fields[$skipfield_name]->id;
                         $skipfield_data = $skipfield_iscore ? $item->{$skipfield_name} : @$item->fieldvalues[$skipfield_id];
                     }
                     // Strip HTML Tags
                     if ($striptags_onempty_fields) {
                         $skipfield_data = strip_tags($skipfield_data);
                     }
                     // Decide if field is empty
                     $skipfield_isempty = is_array($skipfield_data) ? !count($skipfield_data) : !strlen(trim($skipfield_data));
                     if ($skipfield_isempty) {
                         if ($onempty_fields_combination == 'any') {
                             $skip_curritem = 1;
                             break;
                         }
                     } else {
                         if ($onempty_fields_combination == 'all') {
                             $skip_curritem = 0;
                             break;
                         }
                     }
                 }
                 if ($skip_curritem) {
                     //echo "Skip: $i . {$item->title}<br/>";
                     if (!isset($order_skipcount[$item->fetching])) {
                         $order_skipcount[$item->fetching] = 0;
                     }
                     $order_skipcount[$item->fetching]++;
                     continue;
                 }
                 // 4. Increment counter for item's ordering and Add item to list of displayed items
                 $order_count[$item->fetching]++;
                 $filtered_rows[] = $item;
             }
             $filtered_rows_arr[$catid] = $filtered_rows;
         }
         $mod_fc_run_times['empty_fields_filter'] = $modfc_jprof->getmicrotime() - $mod_fc_run_times['empty_fields_filter'];
     } else {
         $filtered_rows_arr =& $cat_items_arr;
     }
     $mod_fc_run_times['item_list_creation'] = $modfc_jprof->getmicrotime();
     // *** OPTIMIZATION: we only render the fields after skipping unwanted items
     if ($use_fields && count($fields) || $use_fields_feat && count($fields_feat)) {
         $all_fields = array();
         if ($use_fields && count($fields)) {
             $all_fields = array_merge($all_fields, $fields);
         }
         if ($use_fields_feat && count($fields_feat)) {
             $all_fields = array_merge($all_fields, $fields_feat);
         }
         $all_fields = array_unique($all_fields);
         $fields_list = implode(',', $all_fields);
         $params->set('fields', $fields_list);
     }
     // *** OPTIMIZATION: we should create some variables outside the loop ... TODO MORE
     if (($display_hits_feat || $display_hits) && $has_access_hits) {
         $hits_icon = FLEXI_J16GE ? JHTML::image('components/com_flexicontent/assets/images/' . 'user.png', JText::_('FLEXI_HITS_L')) : JHTML::_('image.site', 'user.png', 'components/com_flexicontent/assets/images/', NULL, NULL, JText::_('FLEXI_HITS_L'));
     }
     if ($display_comments_feat || $display_comments) {
         $comments_icon = FLEXI_J16GE ? JHTML::image('components/com_flexicontent/assets/images/' . 'comments.png', JText::_('FLEXI_COMMENTS_L')) : JHTML::_('image.site', 'comments.png', 'components/com_flexicontent/assets/images/', NULL, NULL, JText::_('FLEXI_COMMENTS_L'));
     }
     $option = JRequest::getVar('option');
     $view = JRequest::getVar('view');
     $isflexi_itemview = $option == 'com_flexicontent' && $view == FLEXI_ITEMVIEW;
     $active_item_id = JRequest::getInt('id', 0);
     $lists_arr = array();
     foreach ($filtered_rows_arr as $catid => $filtered_rows) {
         if (empty($filtered_rows)) {
             $rows = array();
         } else {
             if ($use_fields && count($fields) || $use_fields_feat && count($fields_feat)) {
                 $rows = FlexicontentFields::getFields($filtered_rows, 'module', $params);
             } else {
                 $rows =& $filtered_rows;
             }
         }
         // For Debuging
         /*foreach ($order_skipcount as $skipordering => $skipcount) {
         		  echo "SKIPS $skipordering ==> $skipcount<br>\n";
         		}*/
         $lists = array();
         foreach ($ordering as $ord) {
             $lists[$ord] = array();
         }
         $ord = "__start__";
         foreach ($rows as $row) {
             if ($ord != $row->fetching) {
                 // Detect change of next ordering group
                 $ord = $row->fetching;
                 $i = 0;
             }
             if ($row->featured) {
                 // image processing
                 $thumb = '';
                 $thumb_rendered = '';
                 if ($mod_use_image_feat) {
                     if ($mod_image_custom_display) {
                         @(list($fieldname, $varname) = preg_split('/##/', $mod_image_custom_display));
                         $fieldname = trim($fieldname);
                         $varname = trim($varname);
                         $varname = $varname ? $varname : 'display';
                         $thumb_rendered = FlexicontentFields::getFieldDisplay($row, $fieldname, null, $varname, 'module');
                         $src = '';
                     } else {
                         if ($mod_image_custom_url) {
                             @(list($fieldname, $varname) = preg_split('/##/', $mod_image_custom_url));
                             $fieldname = trim($fieldname);
                             $varname = trim($varname);
                             $varname = $varname ? $varname : 'display';
                             $src = FlexicontentFields::getFieldDisplay($row, $fieldname, null, $varname, 'module');
                         } else {
                             if ($mod_image) {
                                 FlexicontentFields::getFieldDisplay($row, $mod_image_name, null, 'display_large_src', 'module');
                                 // just makes sure thumbs are created by requesting a '*_src' display
                                 $img_field =& $row->fields[$mod_image_name];
                                 if ($mod_use_image_feat == 1) {
                                     $src = str_replace(JURI::root(), '', @$img_field->thumbs_src['large'][0]);
                                 } else {
                                     $src = '';
                                     $thumb = @$img_field->thumbs_src[$mod_use_image_feat][0];
                                 }
                                 if (!$src && $mod_image_fallback_img == 1 || $src && $mod_image_fallback_img == 2 && $img_field->using_default_value) {
                                     $src = flexicontent_html::extractimagesrc($row);
                                 }
                             } else {
                                 $src = flexicontent_html::extractimagesrc($row);
                             }
                         }
                     }
                     if (!$thumb && !$src && $mod_default_img_show) {
                         $thumb = $thumb_default_feat;
                     }
                     if ($src) {
                         $h = '&amp;h=' . $mod_height_feat;
                         $w = '&amp;w=' . $mod_width_feat;
                         $aoe = '&amp;aoe=1';
                         $q = '&amp;q=95';
                         $zc = $mod_method_feat ? '&amp;zc=' . $mod_method_feat : '';
                         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                         $conf = $w . $h . $aoe . $q . $zc . $f;
                         $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
                         $thumb = JURI::base() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $base_url . $src . $conf;
                     }
                 }
                 $lists[$ord]['featured'][$i] = new stdClass();
                 $lists[$ord]['featured'][$i]->_row = $row;
                 $lists[$ord]['featured'][$i]->id = $row->id;
                 $lists[$ord]['featured'][$i]->is_active_item = $isflexi_itemview && $row->id == $active_item_id;
                 //date
                 if ($display_date_feat == 1) {
                     $dateformat = JText::_($params->get('date_format_feat', 'DATE_FORMAT_LC3'));
                     if ($dateformat == JText::_('custom')) {
                         $dateformat = $params->get('custom_date_format_feat', JText::_('DATE_FORMAT_LC3'));
                     }
                     $date_fields_feat = $params->get('date_fields_feat', array('created'));
                     $date_fields_feat = !is_array($date_fields_feat) ? array($date_fields_feat) : $date_fields_feat;
                     $lists[$ord]['featured'][$i]->date_created = "";
                     if (in_array('created', $date_fields_feat)) {
                         // Created
                         $lists[$ord]['featured'][$i]->date_created .= $params->get('date_label_feat', 1) ? '<span class="date_label_feat">' . JText::_('FLEXI_DATE_CREATED') . '</span> ' : '';
                         $lists[$ord]['featured'][$i]->date_created .= '<span class="date_value_feat">' . JHTML::_('date', $row->created, $dateformat) . '</span>';
                     }
                     $lists[$ord]['featured'][$i]->date_modified = "";
                     if (in_array('modified', $date_fields_feat)) {
                         // Modified
                         $lists[$ord]['featured'][$i]->date_modified .= $params->get('date_label_feat', 1) ? '<span class="date_label_feat">' . JText::_('FLEXI_DATE_MODIFIED') . '</span> ' : '';
                         $modified_date = $row->modified != $db->getNullDate() ? JHTML::_('date', $row->modified, $dateformat) : JText::_('FLEXI_DATE_NEVER');
                         $lists[$ord]['featured'][$i]->date_modified .= '<span class="date_value_feat">' . $modified_date . '</span>';
                     }
                 }
                 $lists[$ord]['featured'][$i]->image_rendered = $thumb_rendered;
                 $lists[$ord]['featured'][$i]->image = $thumb;
                 $lists[$ord]['featured'][$i]->hits = $row->hits;
                 $lists[$ord]['featured'][$i]->hits_rendered = '';
                 if ($display_hits_feat && $has_access_hits) {
                     FlexicontentFields::loadFieldConfig($hitsfield, $row);
                     $lists[$ord]['featured'][$i]->hits_rendered .= $params->get('hits_label_feat') ? '<span class="hits_label_feat">' . JText::_($hitsfield->label) . '</span> ' : '';
                     $lists[$ord]['featured'][$i]->hits_rendered .= $hits_icon;
                     $lists[$ord]['featured'][$i]->hits_rendered .= ' (' . $row->hits . (!$params->get('hits_label_feat') ? ' ' . JTEXT::_('FLEXI_HITS_L') : '') . ')';
                 }
                 $lists[$ord]['featured'][$i]->voting = '';
                 if ($display_voting_feat && $has_access_voting) {
                     FlexicontentFields::loadFieldConfig($votingfield, $row);
                     $lists[$ord]['featured'][$i]->voting .= $params->get('voting_label_feat') ? '<span class="voting_label_feat">' . JText::_($votingfield->label) . '</span> ' : '';
                     $lists[$ord]['featured'][$i]->voting .= '<div class="voting_value_feat">' . flexicontent_html::ItemVoteDisplay($votingfield, $row->id, $row->rating_sum, $row->rating_count, 'main', '', $params->get('vote_stars_feat', 1), $params->get('allow_vote_feat', 0), $params->get('vote_counter_feat', 1), !$params->get('voting_label_feat')) . '</div>';
                 }
                 if ($display_comments_feat) {
                     $lists[$ord]['featured'][$i]->comments = $row->comments_total;
                     $lists[$ord]['featured'][$i]->comments_rendered = $params->get('comments_label_feat') ? '<span class="comments_label_feat">' . JText::_('FLEXI_COMMENTS') . '</span> ' : '';
                     $lists[$ord]['featured'][$i]->comments_rendered .= $comments_icon;
                     $lists[$ord]['featured'][$i]->comments_rendered .= ' (' . $row->comments_total . (!$params->get('comments_label_feat') ? ' ' . JTEXT::_('FLEXI_COMMENTS_L') : '') . ')';
                 }
                 $lists[$ord]['featured'][$i]->catid = $row->catid;
                 $lists[$ord]['featured'][$i]->itemcats = explode(",", $row->itemcats);
                 $lists[$ord]['featured'][$i]->link = JRoute::_(FlexicontentHelperRoute::getItemRoute($row->slug, $row->categoryslug, $forced_itemid, $row) . ($method_curlang == 1 ? "&lang=" . substr($row->language, 0, 2) : ""));
                 $lists[$ord]['featured'][$i]->title = strlen($row->title) > $cuttitle_feat ? JString::substr($row->title, 0, $cuttitle_feat) . '...' : $row->title;
                 $lists[$ord]['featured'][$i]->alias = $row->alias;
                 $lists[$ord]['featured'][$i]->fulltitle = $row->title;
                 $lists[$ord]['featured'][$i]->text = $mod_do_stripcat_feat ? flexicontent_html::striptagsandcut($row->introtext, $mod_cut_text_feat) : $row->introtext;
                 $lists[$ord]['featured'][$i]->typename = $row->typename;
                 $lists[$ord]['featured'][$i]->access = $row->access;
                 $lists[$ord]['featured'][$i]->featured = 1;
                 if ($use_fields_feat && @$row->fields && $fields_feat) {
                     $lists[$ord]['featured'][$i]->fields = array();
                     foreach ($fields_feat as $field) {
                         if (!isset($row->fields[$field])) {
                             continue;
                         }
                         /*$lists[$ord]['featured'][$i]->fields[$field] = new stdClass();
                         		$lists[$ord]['featured'][$i]->fields[$field]->display 	= @$row->fields[$field]->display ? $row->fields[$field]->display : '';
                         		$lists[$ord]['featured'][$i]->fields[$field]->name = $row->fields[$field]->name;
                         		$lists[$ord]['featured'][$i]->fields[$field]->id   = $row->fields[$field]->id;*/
                         // Expose field to the module template  ... the template should NOT modify this ...
                         if (!isset($row->fields[$field]->display)) {
                             $row->fields[$field]->display = '';
                         }
                         $lists[$ord]['featured'][$i]->fields[$field] = $row->fields[$field];
                     }
                 }
                 $i++;
             } else {
                 // image processing
                 $thumb = '';
                 $thumb_rendered = '';
                 if ($mod_use_image) {
                     if ($mod_image_custom_display) {
                         @(list($fieldname, $varname) = preg_split('/##/', $mod_image_custom_display));
                         $fieldname = trim($fieldname);
                         $varname = trim($varname);
                         $varname = $varname ? $varname : 'display';
                         $thumb_rendered = FlexicontentFields::getFieldDisplay($row, $fieldname, null, $varname, 'module');
                         $src = '';
                         // Clear src no rendering needed
                     } else {
                         if ($mod_image_custom_url) {
                             @(list($fieldname, $varname) = preg_split('/##/', $mod_image_custom_url));
                             $fieldname = trim($fieldname);
                             $varname = trim($varname);
                             $varname = $varname ? $varname : 'display';
                             $src = FlexicontentFields::getFieldDisplay($row, $fieldname, null, $varname, 'module');
                         } else {
                             if ($mod_image) {
                                 FlexicontentFields::getFieldDisplay($row, $mod_image_name, null, 'display_large_src', 'module');
                                 // just makes sure thumbs are created by requesting a '*_src' display
                                 $img_field =& $row->fields[$mod_image_name];
                                 if ($mod_use_image == 1) {
                                     $src = str_replace(JURI::root(), '', @$img_field->thumbs_src['large'][0]);
                                 } else {
                                     $src = '';
                                     $thumb = @$img_field->thumbs_src[$mod_use_image][0];
                                 }
                                 if (!$src && $mod_image_fallback_img == 1 || $src && $mod_image_fallback_img == 2 && $img_field->using_default_value) {
                                     $src = flexicontent_html::extractimagesrc($row);
                                 }
                             } else {
                                 $src = flexicontent_html::extractimagesrc($row);
                             }
                         }
                     }
                     if (!$thumb && !$src && $mod_default_img_show) {
                         $thumb = $thumb_default;
                     }
                     if ($src) {
                         $h = '&amp;h=' . $mod_height;
                         $w = '&amp;w=' . $mod_width;
                         $aoe = '&amp;aoe=1';
                         $q = '&amp;q=95';
                         $zc = $mod_method ? '&amp;zc=' . $mod_method : '';
                         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                         $conf = $w . $h . $aoe . $q . $zc . $f;
                         $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
                         $thumb = JURI::base() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $base_url . $src . $conf;
                     }
                 }
                 // START population of item's custom properties
                 $lists[$ord]['standard'][$i] = new stdClass();
                 $lists[$ord]['standard'][$i]->_row = $row;
                 $lists[$ord]['standard'][$i]->id = $row->id;
                 $lists[$ord]['standard'][$i]->is_active_item = $isflexi_itemview && $row->id == $active_item_id;
                 //date
                 if ($display_date == 1) {
                     $dateformat = JText::_($params->get('date_format', 'DATE_FORMAT_LC3'));
                     if ($dateformat == JText::_('custom')) {
                         $dateformat = $params->get('custom_date_format', JText::_('DATE_FORMAT_LC3'));
                     }
                     $date_fields = $params->get('date_fields', array('created'));
                     $date_fields = !is_array($date_fields) ? array($date_fields) : $date_fields;
                     $lists[$ord]['standard'][$i]->date_created = "";
                     if (in_array('created', $date_fields)) {
                         // Created
                         $lists[$ord]['standard'][$i]->date_created .= $params->get('date_label', 1) ? '<span class="date_label">' . JText::_('FLEXI_DATE_CREATED') . '</span> ' : '';
                         $lists[$ord]['standard'][$i]->date_created .= '<span class="date_value">' . JHTML::_('date', $row->created, $dateformat) . '</span>';
                     }
                     $lists[$ord]['standard'][$i]->date_modified = "";
                     if (in_array('modified', $date_fields)) {
                         // Modified
                         $lists[$ord]['standard'][$i]->date_modified .= $params->get('date_label', 1) ? '<span class="date_label">' . JText::_('FLEXI_DATE_MODIFIED') . '</span> ' : '';
                         $modified_date = $row->modified != $db->getNullDate() ? JHTML::_('date', $row->modified, $dateformat) : JText::_('FLEXI_DATE_NEVER');
                         $lists[$ord]['standard'][$i]->date_modified .= '<span class="date_value_feat">' . $modified_date . '</span>';
                     }
                 }
                 $lists[$ord]['standard'][$i]->image_rendered = $thumb_rendered;
                 $lists[$ord]['standard'][$i]->image = $thumb;
                 $lists[$ord]['standard'][$i]->hits = $row->hits;
                 $lists[$ord]['standard'][$i]->hits_rendered = '';
                 if ($display_hits && $has_access_hits) {
                     FlexicontentFields::loadFieldConfig($hitsfield, $row);
                     $lists[$ord]['standard'][$i]->hits_rendered .= $params->get('hits_label') ? '<span class="hits_label">' . JText::_($hitsfield->label) . '</span> ' : '';
                     $lists[$ord]['standard'][$i]->hits_rendered .= $hits_icon;
                     $lists[$ord]['standard'][$i]->hits_rendered .= ' (' . $row->hits . (!$params->get('hits_label') ? ' ' . JTEXT::_('FLEXI_HITS_L') : '') . ')';
                 }
                 $lists[$ord]['standard'][$i]->voting = '';
                 if ($display_voting && $has_access_voting) {
                     FlexicontentFields::loadFieldConfig($votingfield, $row);
                     $lists[$ord]['standard'][$i]->voting .= $params->get('voting_label') ? '<span class="voting_label">' . JText::_($votingfield->label) . '</span> ' : '';
                     $lists[$ord]['standard'][$i]->voting .= '<div class="voting_value">' . flexicontent_html::ItemVoteDisplay($votingfield, $row->id, $row->rating_sum, $row->rating_count, 'main', '', $params->get('vote_stars', 1), $params->get('allow_vote', 0), $params->get('vote_counter', 1), !$params->get('voting_label')) . '</div>';
                 }
                 if ($display_comments) {
                     $lists[$ord]['standard'][$i]->comments = $row->comments_total;
                     $lists[$ord]['standard'][$i]->comments_rendered = $params->get('comments_label') ? '<span class="comments_label">' . JText::_('FLEXI_COMMENTS') . '</span> ' : '';
                     $lists[$ord]['standard'][$i]->comments_rendered .= $comments_icon;
                     $lists[$ord]['standard'][$i]->comments_rendered .= ' (' . $row->comments_total . (!$params->get('comments_label') ? ' ' . JTEXT::_('FLEXI_COMMENTS_L') : '') . ')';
                 }
                 $lists[$ord]['standard'][$i]->catid = $row->catid;
                 $lists[$ord]['standard'][$i]->itemcats = explode(",", $row->itemcats);
                 $lists[$ord]['standard'][$i]->link = JRoute::_(FlexicontentHelperRoute::getItemRoute($row->slug, $row->categoryslug, $forced_itemid, $row) . ($method_curlang == 1 ? "&lang=" . substr($row->language, 0, 2) : ""));
                 $lists[$ord]['standard'][$i]->title = strlen($row->title) > $cuttitle ? JString::substr($row->title, 0, $cuttitle) . '...' : $row->title;
                 $lists[$ord]['standard'][$i]->alias = $row->alias;
                 $lists[$ord]['standard'][$i]->fulltitle = $row->title;
                 $lists[$ord]['standard'][$i]->text = $mod_do_stripcat ? flexicontent_html::striptagsandcut($row->introtext, $mod_cut_text) : $row->introtext;
                 $lists[$ord]['standard'][$i]->typename = $row->typename;
                 $lists[$ord]['standard'][$i]->access = $row->access;
                 $lists[$ord]['standard'][$i]->featured = 0;
                 if ($use_fields && @$row->fields && $fields) {
                     $lists[$ord]['standard'][$i]->fields = array();
                     foreach ($fields as $field) {
                         if (!isset($row->fields[$field])) {
                             continue;
                         }
                         /*$lists[$ord]['standard'][$i]->fields[$field] = new stdClass();
                         		$lists[$ord]['standard'][$i]->fields[$field]->display 	= @$row->fields[$field]->display ? $row->fields[$field]->display : '';
                         		$lists[$ord]['standard'][$i]->fields[$field]->name = $row->fields[$field]->name;
                         		$lists[$ord]['standard'][$i]->fields[$field]->id   = $row->fields[$field]->id;*/
                         // Expose field to the module template  ... the template should NOT modify this ...
                         if (!isset($row->fields[$field]->display)) {
                             $row->fields[$field]->display = '';
                         }
                         $lists[$ord]['standard'][$i]->fields[$field] = $row->fields[$field];
                         // Expose field to the module template  ... but template may modify it ...
                     }
                 }
                 $i++;
             }
         }
         $lists_arr[$catid] = $lists;
     }
     $mod_fc_run_times['item_list_creation'] = $modfc_jprof->getmicrotime() - $mod_fc_run_times['item_list_creation'];
     return $lists_arr;
 }
Exemplo n.º 8
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     // Get Non-routing Categories, and Category Tree
     global $globalnoroute, $globalcats;
     if (!is_array($globalnoroute)) {
         $globalnoroute = array();
     }
     //initialize variables
     $dispatcher = JDispatcher::getInstance();
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $option = JRequest::getVar('option');
     $document = JFactory::getDocument();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $aid = FLEXI_J16GE ? JAccess::getAuthorisedViewLevels($user->id) : (int) $user->get('aid');
     // Get category and set category parameters as VIEW's parameters (category parameters are merged with component/page/author parameters already)
     $category = $this->get('Category');
     $params = $category->parameters;
     if ($category->id && FLEXI_J16GE) {
         $meta_params = new JRegistry($category->metadata);
     } else {
         $meta_params = false;
     }
     // Get various data from the model
     $categories = $this->get('Childs');
     // this will also count sub-category items is if  'show_itemcount'  is enabled
     $peercats = $this->get('Peers');
     // this will also count sub-category items is if  'show_subcatcount_peercat'  is enabled
     $items = $this->get('Data');
     $total = $this->get('Total');
     $filters = $this->get('Filters');
     if ($params->get('show_comments_count', 0)) {
         $comments = $this->get('CommentsInfo');
     } else {
         $comments = null;
     }
     $alpha = $params->get('show_alpha', 1) ? $this->get('Alphaindex') : array();
     // This is somwhat expensive so calculate it only if required
     // Request variables, WARNING, must be loaded after retrieving items, because limitstart may have been modified
     $limitstart = JRequest::getInt('limitstart');
     $format = JRequest::getCmd('format', null);
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('flexi_tmpl_common');
     //add css file
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css');
         $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
     }
     //allow css override
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
         $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css');
     }
     // ************************
     // CATEGORY LAYOUT handling
     // ************************
     // (a) Decide to use mobile or normal category template layout
     $useMobile = $params->get('use_mobile_layouts', 0);
     if ($useMobile) {
         $force_desktop_layout = $params->get('force_desktop_layout', 0);
         $mobileDetector = flexicontent_html::getMobileDetector();
         $isMobile = $mobileDetector->isMobile();
         $isTablet = $mobileDetector->isTablet();
         $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile;
     }
     $_clayout = $useMobile ? 'clayout_mobile' : 'clayout';
     // (b) Get from category parameters, allowing URL override
     $clayout = JRequest::getCmd($_clayout, false);
     if (!$clayout) {
         $desktop_clayout = $params->get('clayout', 'blog');
         $clayout = !$useMobile ? $desktop_clayout : $params->get('clayout_mobile', $desktop_clayout);
     }
     // (c) Get cached template data
     $themes = flexicontent_tmpl::getTemplates($lang_files = array($clayout));
     // (d) Verify the category layout exists
     if (!isset($themes->category->{$clayout})) {
         $fixed_clayout = 'blog';
         $app->enqueueMessage("<small>Current Category Layout Template is '{$clayout}' does not exist<br>- Please correct this in the URL or in Content Type configuration.<br>- Using Template Layout: '{$fixed_clayout}'</small>", 'notice');
         $clayout = $fixed_clayout;
         if (FLEXI_FISH || FLEXI_J16GE) {
             FLEXIUtilities::loadTemplateLanguageFile($clayout);
         }
         // Manually load Template-Specific language file of back fall clayout
     }
     // (e) finally set the template name back into the category's parameters
     $params->set('clayout', $clayout);
     // Get URL variables
     $cid = JRequest::getInt('cid', 0);
     $authorid = JRequest::getInt('authorid', 0);
     $tagid = JRequest::getInt('tagid', 0);
     $layout = JRequest::getCmd('layout', '');
     $mcats_list = JRequest::getVar('cids', '');
     if (!is_array($mcats_list)) {
         $mcats_list = preg_replace('/[^0-9,]/i', '', (string) $mcats_list);
         $mcats_list = explode(',', $mcats_list);
     }
     // make sure given data are integers ... !!
     $cids = array();
     foreach ($mcats_list as $i => $_id) {
         if ((int) $_id) {
             $cids[] = (int) $_id;
         }
     }
     $cids = implode(',', $cids);
     $authordescr_item = false;
     if ($authorid && $params->get('authordescr_itemid') && $format != 'feed') {
         $authordescr_itemid = $params->get('authordescr_itemid');
     }
     // Bind Fields
     if ($format != 'feed') {
         $items = FlexicontentFields::getFields($items, 'category', $params, $aid);
     }
     //Set layout
     $this->setLayout('category');
     $limit = $app->getUserStateFromRequest('com_flexicontent' . $category->id . '.category.limit', 'limit', $params->def('limit', 0), 'int');
     // Pathway needed variables
     //$catshelper = new flexicontent_cats($cid);
     //$parents    = $catshelper->getParentlist();
     //echo "<pre>".print_r($parents,true)."</pre>";
     $parents = array();
     if ($cid && isset($globalcats[$cid]->ancestorsarray)) {
         $parent_ids = $globalcats[$cid]->ancestorsarray;
         foreach ($parent_ids as $parent_id) {
             $parents[] = $globalcats[$parent_id];
         }
     }
     $rootcat = (int) $params->get('rootcat');
     if ($rootcat) {
         $root_parents = $globalcats[$rootcat]->ancestorsarray;
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = 'category' == @$menu->query['view'];
         $cid_ok = $cid == (int) @$menu->query['cid'];
         $layout_ok = $layout == @$menu->query['layout'];
         // null is equal to empty string
         $authorid_ok = $authorid == (int) @$menu->query['authorid'];
         // null is equal to zero
         $tagid_ok = $tagid == (int) @$menu->query['tagid'];
         // null is equal to zero
         $menu_matches = $view_ok && $cid_ok && $layout_ok && $authorid_ok && $tagid_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         switch ($layout) {
             case '':
                 $default_heading = $category->title;
                 break;
             case 'myitems':
                 $default_heading = JText::_('FLEXICONTENT_MYITEMS');
                 break;
             case 'author':
                 $default_heading = JText::_('FLEXICONTENT_AUTHOR') . ': ' . JFactory::getUser($authorid)->get('name');
                 break;
             default:
                 $default_heading = JText::_('FLEXICONTENT_CATEGORY');
         }
         if ($layout && $cid) {
             // Non-single category listings, limited to a specific category
             $default_heading .= ', ' . JText::_('FLEXI_IN_CATEGORY') . ': ' . $category->title;
         }
         // Decide to show page heading (=J1.5 page title) only if a custom layout is used (=not a single category layout)
         $show_default_heading = $layout ? 1 : 0;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if (a) IT IS same as category title and (b) category title is already configured to be shown
     if ($params->get('show_cat_title', 1)) {
         if ($params->get('page_heading') == $category->title) {
             $params->set('show_page_heading', 0);
         }
         if ($params->get('page_title') == $category->title) {
             $params->set('show_page_title', 0);
         }
     }
     // ************************************************************
     // Create the document title, by from page title and other data
     // ************************************************************
     // Use the page heading as document title, (already calculated above via 'appropriate' logic ...)
     // or the overriden custom <title> ... set via parameter
     $doc_title = !$meta_params ? $params->get('page_title') : $meta_params->get('page_title', $params->get('page_title'));
     // Check and prepend or append site name
     if (FLEXI_J16GE) {
         // Not available in J1.5
         // Add Site Name to page title
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = $app->getCfg('sitename') . " - " . $doc_title;
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = $doc_title . " - " . $app->getCfg('sitename');
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     if ($category->id) {
         // possibly not set for author items OR my items
         if (FLEXI_J16GE) {
             if ($category->metadesc) {
                 $document->setDescription($category->metadesc);
             }
             if ($category->metakey) {
                 $document->setMetadata('keywords', $category->metakey);
             }
             // meta_params are always set if J1.6+ and category id is set
             if ($meta_params->get('robots')) {
                 $document->setMetadata('robots', $meta_params->get('robots'));
             }
             // ?? Deprecated <title> tag is used instead by search engines
             if ($app->getCfg('MetaTitle') == '1') {
                 $meta_title = $meta_params->get('page_title') ? $meta_params->get('page_title') : $category->title;
                 $document->setMetaData('title', $meta_title);
             }
             if ($app->getCfg('MetaAuthor') == '1') {
                 if ($meta_params->get('author')) {
                     $meta_author = $meta_params->get('author');
                 } else {
                     $table = JUser::getTable();
                     $meta_author = $table->load($category->created_user_id) ? $table->name : '';
                 }
                 $document->setMetaData('author', $meta_author);
             }
         } else {
             // ?? Deprecated <title> tag is used instead by search engines
             if ($app->getCfg('MetaTitle') == '1') {
                 $document->setMetaData('title', $category->title);
             }
         }
     }
     // Overwrite with menu META data if menu matched
     if (FLEXI_J16GE) {
         if ($menu_matches) {
             if ($_mp = $menu->params->get('menu-meta_description')) {
                 $document->setDescription($_mp);
             }
             if ($_mp = $menu->params->get('menu-meta_keywords')) {
                 $document->setMetadata('keywords', $_mp);
             }
             if ($_mp = $menu->params->get('robots')) {
                 $document->setMetadata('robots', $_mp);
             }
             if ($_mp = $menu->params->get('secure')) {
                 $document->setMetadata('secure', $_mp);
             }
         }
     }
     // ************************************
     // Add rel canonical html head link tag (TODO: improve multi-page handing)
     // ************************************
     $base = $uri->getScheme() . '://' . $uri->getHost();
     $start = JRequest::getInt('start', '');
     $start = $start ? "&start=" . $start : "";
     $ucanonical = $base . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug) . $start);
     if ($params->get('add_canonical')) {
         $head_obj = $document->addHeadLink($ucanonical, 'canonical', 'rel', '');
         $defaultCanonical = flexicontent_html::getDefaultCanonical();
         if (FLEXI_J30GE && $defaultCanonical != $ucanonical) {
             unset($head_obj->_links[$defaultCanonical]);
         }
     }
     if ($params->get('show_feed_link', 1) == 1) {
         //add alternate feed link
         $link = '&format=feed';
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
     }
     // ********************************************************************************************
     // Create pathway, if automatic pathways is enabled, then path will be cleared before populated
     // ********************************************************************************************
     $pathway = $app->getPathWay();
     // Clear pathway, if automatic pathways are enabled
     if ($params->get('automatic_pathways', 0)) {
         $pathway_arr = $pathway->getPathway();
         $pathway->setPathway(array());
         //$pathway->set('_count', 0);  // not needed ??
         $item_depth = 0;
         // menu item depth is now irrelevant ???, ignore it
     } else {
         $item_depth = $params->get('item_depth', 0);
     }
     // Respect menu item depth, defined in menu item
     $p = $item_depth;
     while ($p < count($parents)) {
         // Do not add the directory root category or its parents (this when coming from a directory view)
         if (!empty($root_parents) && in_array($parents[$p]->id, $root_parents)) {
             $p++;
             continue;
         }
         // Do not add to pathway unroutable categories
         if (in_array($parents[$p]->id, $globalnoroute)) {
             $p++;
             continue;
         }
         // Add current parent category
         $pathway->addItem($this->escape($parents[$p]->title), JRoute::_(FlexicontentHelperRoute::getCategoryRoute($parents[$p]->slug)));
         $p++;
     }
     $authordescr_item_html = false;
     if ($authordescr_item) {
         $flexi_html_helper = new flexicontent_html();
         $authordescr_item_html = $flexi_html_helper->renderItem($authordescr_itemid);
     }
     //echo $authordescr_item_html; exit();
     if ($clayout) {
         // Add the templates css files if availables
         if (isset($themes->category->{$clayout}->css)) {
             foreach ($themes->category->{$clayout}->css as $css) {
                 $document->addStyleSheet($this->baseurl . '/' . $css);
             }
         }
         // Add the templates js files if availables
         if (isset($themes->category->{$clayout}->js)) {
             foreach ($themes->category->{$clayout}->js as $js) {
                 $document->addScript($this->baseurl . '/' . $js);
             }
         }
         // Set the template var
         $tmpl = $themes->category->{$clayout}->tmplvar;
     } else {
         $tmpl = '.category.default';
     }
     // @TODO trigger the plugin selectively
     // and delete the plugins tags if not active
     if ($params->get('trigger_onprepare_content_cat')) {
         JPluginHelper::importPlugin('content');
         // Allow to trigger content plugins on category description
         // NOTE: for J2.5, we will trigger the plugins as if description text was an article text, using ... 'com_content.article'
         $category->text = $category->description;
         if (FLEXI_J16GE) {
             $results = $dispatcher->trigger('onContentPrepare', array('com_content.article', &$category, &$params, 0));
         } else {
             $results = $dispatcher->trigger('onPrepareContent', array(&$category, &$params, 0));
         }
         $category->description = $category->text;
     }
     // Maybe here not to import all plugins but just those for description field or add a parameter for this
     // Anyway these events are usually not very time consuming as is the the event onPrepareContent(J1.5)/onContentPrepare(J1.6+)
     JPluginHelper::importPlugin('content');
     foreach ($items as $item) {
         $item->event = new stdClass();
         $item->params = FLEXI_J16GE ? new JRegistry($item->attribs) : new JParameter($item->attribs);
         // !!! The triggering of the event onPrepareContent(J1.5)/onContentPrepare(J1.6+) of content plugins
         // !!! for description field (maintext) along with all other flexicontent
         // !!! fields is handled by flexicontent.fields.php
         // !!! Had serious performance impact
         // CODE REMOVED
         // We must check if the current category is in the categories of the item ..
         $item_in_category = false;
         if ($item->catid == $category->id) {
             $item_in_category = true;
         } else {
             foreach ($item->cats as $cat) {
                 if ($cat->id == $category->id) {
                     $item_in_category = true;
                     break;
                 }
             }
         }
         // ADVANCED CATEGORY ROUTING (=set the most appropriate category for the item ...)
         // CHOOSE APPROPRIATE category-slug FOR THE ITEM !!! ( )
         if ($item_in_category && !in_array($category->id, $globalnoroute)) {
             // 1. CATEGORY SLUG: CURRENT category
             // Current category IS a category of the item and ALSO routing (creating links) to this category is allowed
             $item->categoryslug = $category->slug;
         } else {
             if (!in_array($item->catid, $globalnoroute)) {
                 // 2. CATEGORY SLUG: ITEM's MAIN category   (alread SET, ... no assignment needed)
                 // Since we cannot use current category (above), we will use item's MAIN category
                 // ALSO routing (creating links) to this category is allowed
             } else {
                 // 3. CATEGORY SLUG: ANY ITEM's category
                 // We will use the first for which routing (creating links) to the category is allowed
                 $allcats = array();
                 $item->cats = $item->cats ? $item->cats : array();
                 foreach ($item->cats as $cat) {
                     if (!in_array($cat->id, $globalnoroute)) {
                         $item->categoryslug = $globalcats[$cat->id]->slug;
                         break;
                     }
                 }
             }
         }
         // Just put item's text (description field) inside property 'text' in case the events modify the given text,
         $item->text = isset($item->fields['text']->display) ? $item->fields['text']->display : '';
         // Set the view and option to 'category' and 'com_content'  (actually view is already called category)
         JRequest::setVar('option', 'com_content');
         JRequest::setVar("isflexicontent", "yes");
         // These events return text that could be displayed at appropriate positions by our templates
         $item->event = new stdClass();
         if (FLEXI_J16GE) {
             $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$params, 0));
         } else {
             $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$item, &$params, $limitstart));
         }
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         if (FLEXI_J16GE) {
             $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$params, 0));
         } else {
             $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$params, $limitstart));
         }
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         if (FLEXI_J16GE) {
             $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$params, 0));
         } else {
             $results = $dispatcher->trigger('onAfterDisplayContent', array(&$item, &$params, $limitstart));
         }
         $item->event->afterDisplayContent = trim(implode("\n", $results));
         // Set the option back to 'com_flexicontent'
         JRequest::setVar('option', 'com_flexicontent');
         // Put text back into the description field, THESE events SHOULD NOT modify the item text, but some plugins may do it anyway... , so we assign text back for compatibility
         $item->fields['text']->display =& $item->text;
     }
     // Calculate CSS classes needed to add special styling markups to the items
     flexicontent_html::calculateItemMarkups($items, $params);
     // *****************************************************
     // Remove unroutable categories from sub/peer categories
     // *****************************************************
     // sub-cats
     $_categories = array();
     foreach ($categories as $i => $cat) {
         if (in_array($cat->id, $globalnoroute)) {
             continue;
         }
         $_categories[] = $categories[$i];
     }
     $categories = $_categories;
     // peer-cats
     $_categories = array();
     foreach ($peercats as $i => $cat) {
         if (in_array($cat->id, $globalnoroute)) {
             continue;
         }
         $_categories[] = $peercats[$i];
     }
     $peercats = $_categories;
     // ************************************
     // Get some variables needed for images
     // ************************************
     $joomla_image_path = $app->getCfg('image_path', FLEXI_J16GE ? '' : 'images' . DS . 'stories');
     $joomla_image_url = str_replace(DS, '/', $joomla_image_path);
     $joomla_image_path = $joomla_image_path ? $joomla_image_path . DS : '';
     $joomla_image_url = $joomla_image_url ? $joomla_image_url . '/' : '';
     // **************
     // CATEGORY IMAGE
     // **************
     // category image params
     $show_cat_image = $params->get('show_description_image', 0);
     // we use different name for variable
     $cat_image_source = $params->get('cat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('cat_link_image', 1);
     $cat_image_method = $params->get('cat_image_method', 1);
     $cat_image_width = $params->get('cat_image_width', 80);
     $cat_image_height = $params->get('cat_image_height', 80);
     $cat = $category;
     $image = "";
     if ($cat) {
         if ($cat->id && $show_cat_image) {
             $cat->image = FLEXI_J16GE ? $params->get('image') : $cat->image;
             $image = "";
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = JURI::base(true) . "/" . $joomla_image_url . $cat->image;
                 $h = '&amp;h=' . $cat_image_height;
                 $w = '&amp;w=' . $cat_image_width;
                 $aoe = '&amp;aoe=1';
                 $q = '&amp;q=95';
                 $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                 $ext = pathinfo($src, PATHINFO_EXTENSION);
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $h = '&amp;h=' . $cat_image_height;
                     $w = '&amp;w=' . $cat_image_width;
                     $aoe = '&amp;aoe=1';
                     $q = '&amp;q=95';
                     $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                     $ext = pathinfo($src, PATHINFO_EXTENSION);
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
                     $src = $base_url . $src;
                     $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 //$image = '<div class="fccat_image" style="height:'.$cat_image_height.'px;width:'.$cat_image_width.'px;" ></div>';
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // ******************************
     // SUBCATEGORIES (some templates)
     // ******************************
     // sub-category image params
     $show_cat_image = $params->get('show_description_image_subcat', 1);
     // we use different name for variable
     $cat_image_source = $params->get('subcat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('subcat_link_image', 1);
     $cat_image_method = $params->get('subcat_image_method', 1);
     $cat_image_width = $params->get('subcat_image_width', 24);
     $cat_image_height = $params->get('subcat_image_height', 24);
     // Create sub-category image/description/etc data
     foreach ($categories as $cat) {
         $image = "";
         if ($show_cat_image) {
             if (FLEXI_J16GE && !is_object($cat->params)) {
                 $cat->params = new JRegistry($cat->params);
             }
             $cat->image = FLEXI_J16GE ? $cat->params->get('image') : $cat->image;
             $image = "";
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = JURI::base(true) . "/" . $joomla_image_url . $cat->image;
                 $h = '&amp;h=' . $cat_image_height;
                 $w = '&amp;w=' . $cat_image_width;
                 $aoe = '&amp;aoe=1';
                 $q = '&amp;q=95';
                 $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                 $ext = pathinfo($src, PATHINFO_EXTENSION);
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $h = '&amp;h=' . $cat_image_height;
                     $w = '&amp;w=' . $cat_image_width;
                     $aoe = '&amp;aoe=1';
                     $q = '&amp;q=95';
                     $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                     $ext = pathinfo($src, PATHINFO_EXTENSION);
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
                     $src = $base_url . $src;
                     $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 //$image = '<div class="fccat_image" style="height:'.$cat_image_height.'px;width:'.$cat_image_width.'px;" ></div>';
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // *******************************
     // PEERCATEGORIES (some templates)
     // *******************************
     // peer-category image params
     $show_cat_image = $params->get('show_description_image_peercat', 1);
     // we use different name for variable
     $cat_image_source = $params->get('peercat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('peercat_link_image', 1);
     $cat_image_method = $params->get('peercat_image_method', 1);
     $cat_image_width = $params->get('peercat_image_width', 24);
     $cat_image_height = $params->get('peercat_image_height', 24);
     // Create peer-category image/description/etc data
     foreach ($peercats as $cat) {
         $image = "";
         if ($show_cat_image) {
             if (FLEXI_J16GE && !is_object($cat->params)) {
                 $cat->params = new JRegistry($cat->params);
             }
             $cat->image = FLEXI_J16GE ? $cat->params->get('image') : $cat->image;
             $image = "";
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = JURI::base(true) . "/" . $joomla_image_url . $cat->image;
                 $h = '&amp;h=' . $cat_image_height;
                 $w = '&amp;w=' . $cat_image_width;
                 $aoe = '&amp;aoe=1';
                 $q = '&amp;q=95';
                 $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                 $ext = pathinfo($src, PATHINFO_EXTENSION);
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $h = '&amp;h=' . $cat_image_height;
                     $w = '&amp;w=' . $cat_image_width;
                     $aoe = '&amp;aoe=1';
                     $q = '&amp;q=95';
                     $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                     $ext = pathinfo($src, PATHINFO_EXTENSION);
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
                     $src = $base_url . $src;
                     $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 //$image = '<div class="fccat_image" style="height:'.$cat_image_height.'px;width:'.$cat_image_width.'px;" ></div>';
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // remove previous alpha index filter
     //$uri->delVar('letter');
     // remove filter variables (includes search box and sort order)
     preg_match_all('/filter[^=]*/', $uri->toString(), $matches);
     foreach ($matches[0] as $match) {
         //$uri->delVar($match);
     }
     // Build Lists
     $lists = array();
     //ordering
     $lists['filter_order'] = JRequest::getCmd('filter_order', 'i.title', 'default');
     $lists['filter_order_Dir'] = JRequest::getCmd('filter_order_Dir', 'ASC', 'default');
     $lists['filter'] = JRequest::getString('filter', '', 'default');
     // Add html to filter objects
     $form_name = 'adminForm';
     if ($filters) {
         FlexicontentFields::renderFilters($params, $filters, $form_name);
     }
     // ****************************
     // Create the pagination object
     // ****************************
     $pageNav = $this->get('pagination');
     $resultsCounter = $pageNav->getResultsCounter();
     // for overriding model's result counter
     // *********************************************************************
     // Create category link, but also consider current 'layout', and use the
     // layout specific variables so that filtering form will work properly
     // *********************************************************************
     $Itemid = $menu ? $menu->id : 0;
     $layout_vars = array();
     if ($layout) {
         $layout_vars['layout'] = $layout;
     }
     if ($authorid) {
         $layout_vars['authorid'] = $authorid;
     }
     if ($tagid) {
         $layout_vars['tagid'] = $tagid;
     }
     if ($cids) {
         $layout_vars['cids'] = $cids;
     }
     // Category link for single/multiple category(-ies)  --OR--  "current layout" link for myitems/author layouts
     if ($cid) {
         $category_link = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug, $Itemid, $layout_vars), false);
     } else {
         $urlvars_str = '';
         foreach ($layout_vars as $urlvar_name => $urlvar_val) {
             $urlvars_str .= '&' . $urlvar_name . '=' . $urlvar_val;
         }
         $category_link = JRoute::_('index.php?Itemid=' . $Itemid . '&option=com_flexicontent&view=category' . $urlvars_str . ($Itemid ? '&Itemid=' . $Itemid : ''));
     }
     // **********************************************************************
     // Print link ... must include layout and current filtering url vars, etc
     // **********************************************************************
     $curr_url = $_SERVER['REQUEST_URI'];
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('action', $category_link);
     // $uri->toString()
     $this->assignRef('print_link', $print_link);
     $this->assignRef('category', $category);
     $this->assignRef('categories', $categories);
     $this->assignRef('peercats', $peercats);
     $this->assignRef('items', $items);
     $this->assignRef('authordescr_item_html', $authordescr_item_html);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('pageNav', $pageNav);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $this->assignRef('pagination', $pageNav);
     // compatibility Alias for old templates
     $this->assignRef('resultsCounter', $resultsCounter);
     // for overriding model's result counter
     $this->assignRef('limitstart', $limitstart);
     // compatibility shortcut
     $this->assignRef('filters', $filters);
     $this->assignRef('comments', $comments);
     $this->assignRef('alpha', $alpha);
     $this->assignRef('tmpl', $tmpl);
     /*
      * Set template paths : this procedure is issued from K2 component
      *
      * "K2" Component by JoomlaWorks for Joomla! 1.5.x - Version 2.1
      * Copyright (c) 2006 - 2009 JoomlaWorks Ltd. All rights reserved.
      * Released under the GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
      * More info at http://www.joomlaworks.gr and http://k2.joomlaworks.gr
      * Designed and developed by the JoomlaWorks team
      */
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates');
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates');
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . 'default');
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . 'default');
     if ($clayout) {
         $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . $clayout);
         $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $clayout);
     }
     // **************************************************
     // increment the hit counter ONLY once per user visit
     // **************************************************
     // MOVED to flexisystem plugin due to ...
     /*if (FLEXI_J16GE && $category->id && empty($layout)) {
     			$hit_accounted = false;
     			$hit_arr = array();
     			if ($session->has('cats_hit', 'flexicontent')) {
     				$hit_arr 	= $session->get('cats_hit', array(), 'flexicontent');
     				$hit_accounted = isset($hit_arr[$category->id]);
     			}
     			if (!$hit_accounted) {
     				//add hit to session hit array
     				$hit_arr[$category->id] = $timestamp = time();  // Current time as seconds since Unix epoc;
     				$session->set('cats_hit', $hit_arr, 'flexicontent');
     				$this->getModel()->hit();
     			}
     		}*/
     $print_logging_info = $params->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
         $start_microtime = microtime(true);
     }
     parent::display($tpl);
     if ($print_logging_info) {
         @($fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
 }
Exemplo n.º 9
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     // Get Non-routing Categories, and Category Tree
     global $globalnoroute, $globalcats;
     if (!is_array($globalnoroute)) {
         $globalnoroute = array();
     }
     //initialize variables
     $dispatcher = JDispatcher::getInstance();
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $option = JRequest::getVar('option');
     $format = JRequest::getCmd('format', 'html');
     $document = JFactory::getDocument();
     // Check for Joomla issue with system plugins creating JDocument in early events forcing it to be wrong type, when format as url suffix is enabled
     if ($format && $document->getType() != strtolower($format)) {
         echo '<div class="alert">WARNING: &nbsp; Document format should be: <b>' . $format . '</b> but current document is: <b>' . $document->getType() . '</b> <br/>Some system plugin may have forced current document type</div>';
     }
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $aid = JAccess::getAuthorisedViewLevels($user->id);
     // Get model
     $model = $this->getModel();
     // Get category and set category parameters as VIEW's parameters (category parameters are merged with component/page/author parameters already)
     $category = $this->get('Category');
     $params = $category->parameters;
     if ($category->id) {
         $meta_params = new JRegistry($category->metadata);
     }
     // Get various data from the model
     $categories = $this->get('Childs');
     // this will also count sub-category items is if  'show_itemcount'  is enabled
     $peercats = $this->get('Peers');
     // this will also count sub-category items is if  'show_subcatcount_peercat'  is enabled
     $items = $this->get('Data');
     $total = $this->get('Total');
     $filters = $this->get('Filters');
     if ($params->get('show_comments_count', 0)) {
         $comments = $this->get('CommentsInfo');
     } else {
         $comments = null;
     }
     $alpha = $params->get('show_alpha', 1) ? $this->get('Alphaindex') : array();
     // This is somwhat expensive so calculate it only if required
     // Request variables, WARNING, must be loaded after retrieving items, because limitstart may have been modified
     $limitstart = JRequest::getInt('limitstart');
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('flexi_tmpl_common');
     // Add css files to the document <head> section (also load CSS joomla template override)
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheetVersion($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css', FLEXI_VHASH);
         //$document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
     }
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
         $document->addStyleSheetVersion($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css', FLEXI_VHASH);
     }
     // ************************
     // CATEGORY LAYOUT handling
     // ************************
     // (a) Decide to use mobile or normal category template layout
     $useMobile = $params->get('use_mobile_layouts', 0);
     if ($useMobile) {
         $force_desktop_layout = $params->get('force_desktop_layout', 0);
         $mobileDetector = flexicontent_html::getMobileDetector();
         $isMobile = $mobileDetector->isMobile();
         $isTablet = $mobileDetector->isTablet();
         $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile;
     }
     $_clayout = $useMobile ? 'clayout_mobile' : 'clayout';
     // (b) Get from category parameters, allowing URL override
     $clayout = JRequest::getCmd($_clayout, false);
     if (!$clayout) {
         $desktop_clayout = $params->get('clayout', 'blog');
         $clayout = !$useMobile ? $desktop_clayout : $params->get('clayout_mobile', $desktop_clayout);
     }
     // (c) Get cached template data
     $themes = flexicontent_tmpl::getTemplates($lang_files = array($clayout));
     // (d) Verify the category layout exists
     if (!isset($themes->category->{$clayout})) {
         $fixed_clayout = 'blog';
         $app->enqueueMessage("<small>Current Category Layout Template is '{$clayout}' does not exist<br>- Please correct this in the URL or in Content Type configuration.<br>- Using Template Layout: '{$fixed_clayout}'</small>", 'notice');
         $clayout = $fixed_clayout;
         FLEXIUtilities::loadTemplateLanguageFile($clayout);
         // Manually load Template-Specific language file of back fall clayout
     }
     // (e) finally set the template name back into the category's parameters
     $params->set('clayout', $clayout);
     // Get URL variables
     $layout_vars = flexicontent_html::getCatViewLayoutVars($model);
     $layout = $layout_vars['layout'];
     $authorid = $layout_vars['authorid'];
     $tagid = $layout_vars['tagid'];
     $cids = $layout_vars['cids'];
     $cid = $layout_vars['cid'];
     // Get Tag data if current layout is 'tags'
     if ($tagid) {
         $tag = $this->get('Tag');
     }
     $authordescr_item = false;
     if ($authorid && $params->get('authordescr_itemid') && $format != 'feed') {
         $authordescr_itemid = $params->get('authordescr_itemid');
     }
     // Bind Fields to items and render their display HTML, but check for document type, due to Joomla issue
     // with system plugins creating JDocument in early events forcing it to be wrong type, when format as url suffix is enabled
     if ($format != 'feed') {
         $items = FlexicontentFields::getFields($items, 'category', $params, $aid);
     }
     //Set layout
     $this->setLayout('category');
     $limit = $app->getUserStateFromRequest('com_flexicontent' . $category->id . '.category.limit', 'limit', $params->def('limit', 0), 'int');
     // Get category titles needed by pathway, this will allow Falang to translate them
     $catshelper = new flexicontent_cats($cid);
     $parents = $catshelper->getParentlist($all_cols = false);
     //echo "<pre>".print_r($parents,true)."</pre>";
     /*$parents = array();
     		if ( $cid && isset($globalcats[$cid]->ancestorsarray) ) {
     			$parent_ids = $globalcats[$cid]->ancestorsarray;
     			foreach ($parent_ids as $parent_id) $parents[] = $globalcats[$parent_id];
     		}*/
     $rootcat = (int) $params->get('rootcat');
     if ($rootcat) {
         $root_parents = $globalcats[$rootcat]->ancestorsarray;
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = 'category' == @$menu->query['view'];
         $cid_ok = $cid == (int) @$menu->query['cid'];
         $layout_ok = $layout == @$menu->query['layout'];
         // null is equal to empty string
         $authorid_ok = $authorid == (int) @$menu->query['authorid'];
         // null is equal to zero
         $tagid_ok = $tagid == (int) @$menu->query['tagid'];
         // null is equal to zero
         $menu_matches = $view_ok && $cid_ok && $layout_ok && $authorid_ok && $tagid_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         switch ($layout) {
             case '':
                 $default_heading = $category->title;
                 break;
             case 'myitems':
                 $default_heading = JText::_('FLEXI_MY_CONTENT');
                 break;
             case 'author':
                 $default_heading = JText::_('FLEXI_CONTENT_BY_AUTHOR') . ': ' . JFactory::getUser($authorid)->get('name');
                 break;
             case 'tags':
                 $default_heading = JText::_('FLEXI_ITEMS_WITH_TAG') . ': ' . $tag->name;
                 break;
             case 'favs':
                 $default_heading = JText::_('FLEXI_YOUR_FAVOURED_ITEMS');
                 break;
             default:
                 $default_heading = JText::_('FLEXI_CONTENT_IN_CATEGORY');
         }
         if ($layout && $cid) {
             // Non-single category listings, limited to a specific category
             $default_heading .= ', ' . JText::_('FLEXI_IN_CATEGORY') . ': ' . $category->title;
         }
         // Decide to show page heading (=J1.5 page title) only if a custom layout is used (=not a single category layout)
         $show_default_heading = $layout ? 1 : 0;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if (a) IT IS same as category title and (b) category title is already configured to be shown
     if ($params->get('show_cat_title', 1)) {
         if ($params->get('page_heading') == $category->title) {
             $params->set('show_page_heading', 0);
         }
         if ($params->get('page_title') == $category->title) {
             $params->set('show_page_title', 0);
         }
     }
     // ************************************************************
     // Create the document title, by from page title and other data
     // ************************************************************
     // Use the page heading as document title, (already calculated above via 'appropriate' logic ...)
     // or the overriden custom <title> ... set via parameter
     $doc_title = empty($meta_params) ? $params->get('page_title') : $meta_params->get('page_title', $params->get('page_title'));
     // Check and prepend or append site name to page title
     if ($doc_title != $app->getCfg('sitename')) {
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $doc_title);
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = JText::sprintf('JPAGETITLE', $doc_title, $app->getCfg('sitename'));
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     if ($category->id) {
         // possibly not set for author items OR my items
         if ($category->metadesc) {
             $document->setDescription($category->metadesc);
         }
         if ($category->metakey) {
             $document->setMetadata('keywords', $category->metakey);
         }
         // meta_params are always set if J1.6+ and category id is set
         if ($meta_params->get('robots')) {
             $document->setMetadata('robots', $meta_params->get('robots'));
         }
         // ?? Deprecated <title> tag is used instead by search engines
         if ($app->getCfg('MetaTitle') == '1') {
             $meta_title = $meta_params->get('page_title') ? $meta_params->get('page_title') : $category->title;
             $document->setMetaData('title', $meta_title);
         }
         if ($app->getCfg('MetaAuthor') == '1') {
             if ($meta_params->get('author')) {
                 $meta_author = $meta_params->get('author');
             } else {
                 $table = JUser::getTable();
                 $meta_author = $table->load($category->created_user_id) ? $table->name : '';
             }
             $document->setMetaData('author', $meta_author);
         }
     }
     // Overwrite with menu META data if menu matched
     if ($menu_matches) {
         if ($_mp = $menu->params->get('menu-meta_description')) {
             $document->setDescription($_mp);
         }
         if ($_mp = $menu->params->get('menu-meta_keywords')) {
             $document->setMetadata('keywords', $_mp);
         }
         if ($_mp = $menu->params->get('robots')) {
             $document->setMetadata('robots', $_mp);
         }
         if ($_mp = $menu->params->get('secure')) {
             $document->setMetadata('secure', $_mp);
         }
     }
     // *********************************************************************
     // Create category link, but also consider current 'layout', and use the
     // layout specific variables so that filtering form will work properly
     // *********************************************************************
     $non_sef_link = null;
     $category_link = flexicontent_html::createCatLink($category->slug, $non_sef_link, $model);
     // ****************************************************************
     // Make sure Joomla SEF plugin has inserted a correct REL canonical
     // or that it has not insert any REL if current URL is sufficient
     // ****************************************************************
     if ($params->get('add_canonical')) {
         // Get canonical URL that SEF plugin adds, also $domain passed by reference, to get the domain configured in SEF plugin (multi-domain website)
         $domain = null;
         $defaultCanonical = flexicontent_html::getDefaultCanonical($domain);
         $domain = $domain ? $domain : $uri->toString(array('scheme', 'host', 'port'));
         // Create desired REL canonical URL
         $start = JRequest::getInt('start', '');
         $ucanonical = $domain . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug) . ($start ? "&start=" . $start : ''));
         // Check if SEF plugin inserted a different REL canonical
         if ($defaultCanonical != $ucanonical) {
             // Add REL canonical only if different than current URL
             $head_obj = $document->addHeadLink(htmlspecialchars($ucanonical), 'canonical', 'rel', '');
             if ($uri->toString() == $ucanonical) {
                 unset($head_obj->_links[htmlspecialchars($ucanonical)]);
             }
             // Remove canonical inserted by SEF plugin
             unset($head_obj->_links[htmlspecialchars($defaultCanonical)]);
         }
     }
     if ($params->get('show_feed_link', 1) == 1) {
         //add alternate feed link
         $link = $non_sef_link . '&format=feed';
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
     }
     // ********************************************************************************************
     // Create pathway, if automatic pathways is enabled, then path will be cleared before populated
     // ********************************************************************************************
     $pathway = $app->getPathWay();
     // Clear pathway, if automatic pathways are enabled
     if ($params->get('automatic_pathways', 0)) {
         $pathway_arr = $pathway->getPathway();
         $pathway->setPathway(array());
         //$pathway->set('_count', 0);  // not needed ??
         $item_depth = 0;
         // menu item depth is now irrelevant ???, ignore it
     } else {
         $item_depth = $params->get('item_depth', 0);
     }
     // Respect menu item depth, defined in menu item
     $p = $item_depth;
     while ($p < count($parents)) {
         // Do not add the directory root category or its parents (this when coming from a directory view)
         if (!empty($root_parents) && in_array($parents[$p]->id, $root_parents)) {
             $p++;
             continue;
         }
         // Do not add to pathway unroutable categories
         if (in_array($parents[$p]->id, $globalnoroute)) {
             $p++;
             continue;
         }
         // Add current parent category
         $pathway->addItem($this->escape($parents[$p]->title), JRoute::_(FlexicontentHelperRoute::getCategoryRoute($parents[$p]->slug)));
         $p++;
     }
     //echo "<pre>"; print_r($pathway); echo "</pre>";
     $authordescr_item_html = false;
     if ($authordescr_item) {
         $flexi_html_helper = new flexicontent_html();
         $authordescr_item_html = $flexi_html_helper->renderItem($authordescr_itemid);
     }
     //echo $authordescr_item_html; exit();
     if ($clayout) {
         // Add the templates css files if availables
         if (isset($themes->category->{$clayout}->css)) {
             foreach ($themes->category->{$clayout}->css as $css) {
                 $document->addStyleSheet($this->baseurl . '/' . $css);
             }
         }
         // Add the templates js files if availables
         if (isset($themes->category->{$clayout}->js)) {
             foreach ($themes->category->{$clayout}->js as $js) {
                 $document->addScript($this->baseurl . '/' . $js);
             }
         }
         // Set the template var
         $tmpl = $themes->category->{$clayout}->tmplvar;
     } else {
         $tmpl = '.category.default';
     }
     // @TODO trigger the plugin selectively
     // and delete the plugins tags if not active
     if ($params->get('trigger_onprepare_content_cat')) {
         JPluginHelper::importPlugin('content');
         // Allow to trigger content plugins on category description
         // NOTE: for J2.5, we will trigger the plugins as if description text was an article text, using ... 'com_content.article'
         $category->text = $category->description;
         $results = $dispatcher->trigger('onContentPrepare', array('com_content.article', &$category, &$params, 0));
         JRequest::setVar('layout', $layout);
         // Restore LAYOUT variable should some plugin have modified it
         $category->description = $category->text;
     }
     // Maybe here not to import all plugins but just those for description field or add a parameter for this
     // Anyway these events are usually not very time consuming as is the the event onPrepareContent(J1.5)/onContentPrepare(J1.6+)
     JPluginHelper::importPlugin('content');
     $noroute_cats = array_flip($globalnoroute);
     $type_attribs = flexicontent_db::getTypeAttribs($force = true, $typeid = 0);
     $type_params = array();
     foreach ($items as $item) {
         $item->event = new stdClass();
         if (!isset($type_params[$item->type_id])) {
             $type_params[$item->type_id] = new JRegistry($type_attribs[$item->type_id]);
         }
         $item->params = clone $type_params[$item->type_id];
         $item->params->merge(new JRegistry($item->attribs));
         //$item->cats = isset($item->cats) ? $item->cats : array();
         // !!! The triggering of the event onPrepareContent(J1.5)/onContentPrepare(J1.6+) of content plugins
         // !!! for description field (maintext) along with all other flexicontent
         // !!! fields is handled by flexicontent.fields.php
         // !!! Had serious performance impact
         // CODE REMOVED
         // We must check if the current category is in the categories of the item ..
         $item_in_category = false;
         if ($item->catid == $category->id) {
             $item_in_category = true;
         } else {
             foreach ($item->cats as $cat) {
                 if ($cat->id == $category->id) {
                     $item_in_category = true;
                     break;
                 }
             }
         }
         // ADVANCED CATEGORY ROUTING (=set the most appropriate category for the item ...)
         // CHOOSE APPROPRIATE category-slug FOR THE ITEM !!! ( )
         if ($item_in_category && !isset($noroute_cats[$category->id])) {
             // 1. CATEGORY SLUG: CURRENT category
             // Current category IS a category of the item and ALSO routing (creating links) to this category is allowed
             $item->categoryslug = $category->slug;
         } else {
             if (!isset($noroute_cats[$item->catid])) {
                 // 2. CATEGORY SLUG: ITEM's MAIN category   (already SET, ... no assignment needed)
                 // Since we cannot use current category (above), we will use item's MAIN category
                 // ALSO routing (creating links) to this category is allowed
             } else {
                 // 3. CATEGORY SLUG: ANY ITEM's category
                 // We will use the first for which routing (creating links) to the category is allowed
                 $allcats = array();
                 foreach ($item->cats as $cat) {
                     if (!isset($noroute_cats[$cat->id])) {
                         $item->categoryslug = $globalcats[$cat->id]->slug;
                         break;
                     }
                 }
             }
         }
         // Just put item's text (description field) inside property 'text' in case the events modify the given text,
         $item->text = isset($item->fields['text']->display) ? $item->fields['text']->display : '';
         // Set the view and option to 'category' and 'com_content'  (actually view is already called category)
         JRequest::setVar('option', 'com_content');
         JRequest::setVar("isflexicontent", "yes");
         // These events return text that could be displayed at appropriate positions by our templates
         $item->event = new stdClass();
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$params, 0));
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$params, 0));
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$params, 0));
         $item->event->afterDisplayContent = trim(implode("\n", $results));
         // Set the option back to 'com_flexicontent'
         JRequest::setVar('option', 'com_flexicontent');
         // Put text back into the description field, THESE events SHOULD NOT modify the item text, but some plugins may do it anyway... , so we assign text back for compatibility
         $item->fields['text']->display =& $item->text;
     }
     // Calculate CSS classes needed to add special styling markups to the items
     flexicontent_html::calculateItemMarkups($items, $params);
     // *****************************************************
     // Remove unroutable categories from sub/peer categories
     // *****************************************************
     // sub-cats
     $_categories = array();
     foreach ($categories as $i => $cat) {
         if (in_array($cat->id, $globalnoroute)) {
             continue;
         }
         $_categories[] = $categories[$i];
     }
     $categories = $_categories;
     // peer-cats
     $_categories = array();
     foreach ($peercats as $i => $cat) {
         if (in_array($cat->id, $globalnoroute)) {
             continue;
         }
         $_categories[] = $peercats[$i];
     }
     $peercats = $_categories;
     // ************************************
     // Get some variables needed for images
     // ************************************
     $joomla_image_path = $app->getCfg('image_path', '');
     $joomla_image_url = str_replace(DS, '/', $joomla_image_path);
     $joomla_image_path = $joomla_image_path ? $joomla_image_path . DS : '';
     $joomla_image_url = $joomla_image_url ? $joomla_image_url . '/' : '';
     $phpThumbURL = $this->baseurl . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=';
     // **************
     // CATEGORY IMAGE
     // **************
     // category image params
     $show_cat_image = $params->get('show_description_image', 0);
     // we use different name for variable
     $cat_image_source = $params->get('cat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('cat_link_image', 1);
     $cat_image_method = $params->get('cat_image_method', 1);
     $cat_image_width = $params->get('cat_image_width', 80);
     $cat_image_height = $params->get('cat_image_height', 80);
     $cat_default_image = $params->get('cat_default_image', '');
     if ($show_cat_image) {
         $h = '&amp;h=' . $cat_image_height;
         $w = '&amp;w=' . $cat_image_width;
         $aoe = '&amp;aoe=1';
         $q = '&amp;q=95';
         $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
     }
     if ($cat_default_image) {
         $src = $this->baseurl . "/" . $joomla_image_url . $cat_default_image;
         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
         $conf = $w . $h . $aoe . $q . $zc . $f;
         $default_image = $phpThumbURL . $src . $conf;
         $default_image = '<img class="fccat_image" style="float:' . $cat_image_float . '" src="' . $default_image . '" alt="%s" title="%s"/>';
     } else {
         $default_image = '';
     }
     // Create category image/description/etc data
     $cat = $category;
     $image = "";
     if ($cat) {
         if ($cat->id && $show_cat_image) {
             $cat->image = $params->get('image');
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = $this->baseurl . "/" . $joomla_image_url . $cat->image;
                 $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = $phpThumbURL . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? $this->baseurl . '/' : '';
                     $src = $base_url . $src;
                     $image = $phpThumbURL . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 if ($default_image) {
                     $image = sprintf($default_image, $cat->title, $cat->title);
                 }
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // ******************************
     // SUBCATEGORIES (some templates)
     // ******************************
     // sub-category image params
     $show_cat_image = $params->get('show_description_image_subcat', 1);
     // we use different name for variable
     $cat_image_source = $params->get('subcat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('subcat_link_image', 1);
     $cat_image_method = $params->get('subcat_image_method', 1);
     $cat_image_width = $params->get('subcat_image_width', 24);
     $cat_image_height = $params->get('subcat_image_height', 24);
     $cat_default_image = $params->get('subcat_default_image', '');
     if ($show_cat_image) {
         $h = '&amp;h=' . $cat_image_height;
         $w = '&amp;w=' . $cat_image_width;
         $aoe = '&amp;aoe=1';
         $q = '&amp;q=95';
         $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
     }
     if ($cat_default_image) {
         $src = $this->baseurl . "/" . $joomla_image_url . $cat_default_image;
         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
         $conf = $w . $h . $aoe . $q . $zc . $f;
         $default_image = $phpThumbURL . $src . $conf;
         $default_image = '<img class="fccat_image" style="float:' . $cat_image_float . '" src="' . $default_image . '" alt="%s" title="%s"/>';
     } else {
         $default_image = '';
     }
     // Create sub-category image/description/etc data
     foreach ($categories as $cat) {
         $image = "";
         if ($show_cat_image) {
             if (!is_object($cat->params)) {
                 $cat->params = new JRegistry($cat->params);
             }
             $cat->image = $cat->params->get('image');
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = $this->baseurl . "/" . $joomla_image_url . $cat->image;
                 $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = $phpThumbURL . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? $this->baseurl . '/' : '';
                     $src = $base_url . $src;
                     $image = $phpThumbURL . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 if ($default_image) {
                     $image = sprintf($default_image, $cat->title, $cat->title);
                 }
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // *******************************
     // PEERCATEGORIES (some templates)
     // *******************************
     // peer-category image params
     $show_cat_image = $params->get('show_description_image_peercat', 1);
     // we use different name for variable
     $cat_image_source = $params->get('peercat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('peercat_link_image', 1);
     $cat_image_method = $params->get('peercat_image_method', 1);
     $cat_image_width = $params->get('peercat_image_width', 24);
     $cat_image_height = $params->get('peercat_image_height', 24);
     $cat_default_image = $params->get('peercat_default_image', '');
     if ($show_cat_image) {
         $h = '&amp;h=' . $cat_image_height;
         $w = '&amp;w=' . $cat_image_width;
         $aoe = '&amp;aoe=1';
         $q = '&amp;q=95';
         $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
     }
     if ($cat_default_image) {
         $src = $this->baseurl . "/" . $joomla_image_url . $cat_default_image;
         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
         $conf = $w . $h . $aoe . $q . $zc . $f;
         $default_image = $phpThumbURL . $src . $conf;
         $default_image = '<img class="fccat_image" style="float:' . $cat_image_float . '" src="' . $default_image . '" alt="%s" title="%s"/>';
     } else {
         $default_image = '';
     }
     // Create peer-category image/description/etc data
     foreach ($peercats as $cat) {
         $image = "";
         if ($show_cat_image) {
             if (!is_object($cat->params)) {
                 $cat->params = new JRegistry($cat->params);
             }
             $cat->image = $cat->params->get('image');
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = $this->baseurl . "/" . $joomla_image_url . $cat->image;
                 $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = $phpThumbURL . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? $this->baseurl . '/' : '';
                     $src = $base_url . $src;
                     $image = $phpThumbURL . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 if ($default_image) {
                     $image = sprintf($default_image, $cat->title, $cat->title);
                 }
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // remove previous alpha index filter
     //$uri->delVar('letter');
     // remove filter variables (includes search box and sort order)
     preg_match_all('/filter[^=]*/', $uri->toString(), $matches);
     foreach ($matches[0] as $match) {
         //$uri->delVar($match);
     }
     // Build Lists
     $lists = array();
     //ordering
     $lists['filter_order'] = JRequest::getCmd('filter_order', 'i.title', 'default');
     $lists['filter_order_Dir'] = JRequest::getCmd('filter_order_Dir', 'ASC', 'default');
     $lists['filter'] = JRequest::getString('filter', '', 'default');
     // Add html to filter objects
     $form_name = 'adminForm';
     if ($filters) {
         FlexicontentFields::renderFilters($params, $filters, $form_name);
     }
     // ****************************
     // Create the pagination object
     // ****************************
     $pageNav = $this->get('pagination');
     $_revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')');
     // URL-encode filter values
     foreach ($_GET as $i => $v) {
         if (substr($i, 0, 6) === "filter") {
             if (is_array($v)) {
                 foreach ($v as $ii => &$vv) {
                     $vv = str_replace('&', '__amp__', $vv);
                     $vv = strtr(rawurlencode($vv), $_revert);
                     $pageNav->setAdditionalUrlParam($i . '[' . $ii . ']', $vv);
                 }
                 unset($vv);
             } else {
                 $v = str_replace('&', '__amp__', $v);
                 $v = strtr(rawurlencode($v), $_revert);
                 $pageNav->setAdditionalUrlParam($i, $v);
             }
         }
     }
     $resultsCounter = $pageNav->getResultsCounter();
     // for overriding model's result counter
     // **********************************************************************
     // Print link ... must include layout and current filtering url vars, etc
     // **********************************************************************
     $curr_url = str_replace('&', '&amp;', $_SERVER['REQUEST_URI']);
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('layout_vars', $layout_vars);
     $this->assignRef('action', $category_link);
     $this->assignRef('print_link', $print_link);
     $this->assignRef('category', $category);
     $this->assignRef('categories', $categories);
     $this->assignRef('peercats', $peercats);
     $this->assignRef('items', $items);
     $this->assignRef('authordescr_item_html', $authordescr_item_html);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('pageNav', $pageNav);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $this->assignRef('pagination', $pageNav);
     // compatibility Alias for old templates
     $this->assignRef('resultsCounter', $resultsCounter);
     // for overriding model's result counter
     $this->assignRef('limitstart', $limitstart);
     // compatibility shortcut
     $this->assignRef('filters', $filters);
     $this->assignRef('comments', $comments);
     $this->assignRef('alpha', $alpha);
     $this->assignRef('tmpl', $tmpl);
     // NOTE: Moved decision of layout into the model, function decideLayout() layout variable should never be empty
     // It will consider things like: template exists, is allowed, client is mobile, current frontend user override, etc
     // !!! The following method of loading layouts, is Joomla legacy view loading of layouts
     // TODO: EXAMINE IF NEEDED to re-use these layouts, and use JLayout ??
     // Despite layout variable not being empty, there may be missing some sub-layout files,
     // e.g. category_somefilename.php for this reason we will use a fallback layout that surely has these files
     $fallback_layout = $params->get('category_fallback_layout', 'blog');
     // parameter does not exist yet
     if ($clayout != $fallback_layout) {
         $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . $fallback_layout);
         $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $fallback_layout);
     }
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . $clayout);
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $clayout);
     // **************************************************
     // increment the hit counter ONLY once per user visit
     // **************************************************
     // MOVED to flexisystem plugin due to ...
     $print_logging_info = $params->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
         $start_microtime = microtime(true);
     }
     parent::display($tpl);
     if ($print_logging_info) {
         @($fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
 }
Exemplo n.º 10
0
 function getData($number)
 {
     nextendimport('nextend.database.database');
     $db = NextendDatabase::getInstance();
     $data = array();
     $query = 'SELECT ';
     $query .= 'con.id ';
     $query .= 'FROM #__content AS con ';
     $query .= 'LEFT JOIN #__flexicontent_cats_item_relations AS fcat ON fcat.itemid = con.id ';
     $query .= 'LEFT JOIN #__categories AS cat ON fcat.catid = cat.id ';
     $where = array();
     $category = array_map('intval', explode('||', $this->_data->get('sourcecategory', '')));
     if (!in_array('0', $category) && !in_array('1', $category)) {
         $where[] = 'fcat.catid IN (' . implode(',', $category) . ') ';
     }
     if ($this->_data->get('sourcepublished', 1)) {
         $where[] = 'con.state = 1 ';
     }
     if ($this->_data->get('sourcefeatured', 0)) {
         $where[] = 'con.featured = 1 ';
     }
     $language = $this->_data->get('sourcelanguage', '*');
     if ($language) {
         $where[] = 'con.language = ' . $db->quote($language) . ' ';
     }
     if (count($where)) {
         $query .= ' WHERE ' . implode(' AND ', $where);
     }
     $query .= 'GROUP BY con.id ';
     $order = NextendParse::parse($this->_data->get('order1', 'con.title|*|asc'));
     if ($order[0]) {
         $query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' ';
         $order = NextendParse::parse($this->_data->get('order2', 'con.title|*|asc'));
         if ($order[0]) {
             $query .= ', ' . $order[0] . ' ' . $order[1] . ' ';
         }
     }
     $query .= 'LIMIT 0, ' . $number . ' ';
     $db->setQuery($query);
     $result = $db->loadAssocList();
     $lng = JFactory::getLanguage();
     $adminapp = JFactory::$application;
     $siteapp = JApplicationCms::getInstance('site');
     $siteapp->loadLanguage($lng);
     require_once JPATH_ADMINISTRATOR . DS . 'components/com_flexicontent/defineconstants.php';
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables');
     require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php';
     require_once JPATH_SITE . DS . "components/com_flexicontent/classes/flexicontent.fields.php";
     require_once JPATH_SITE . DS . "components/com_flexicontent/classes/flexicontent.helper.php";
     require_once JPATH_SITE . '/components/com_flexicontent/models/item.php';
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $aid = FLEXI_J16GE ? $user->getAuthorisedViewLevels() : (int) $user->get('aid');
     $itemmodel = FLEXI_J16GE ? new FlexicontentModelItem() : new FlexicontentModelItems();
     for ($i = 0; $i < count($result); $i++) {
         $data[$i] = array();
         JFactory::$application = $siteapp;
         $item = $itemmodel->getItem($result[$i]['id'], $check_view_access = false);
         list($item) = FlexicontentFields::getFields($item, '', $item->parameters, $aid);
         JFactory::$application = $adminapp;
         $data[$i]['link'] = FlexicontentHelperRoute::getItemRoute($item->id, $item->catid);
         foreach ($item->fields as $k => $field) {
             $data[$i][$k] = FlexicontentFields::getFieldDisplay($item, $k, $values = null, $method = 'display');
         }
     }
     JFactory::$application = $adminapp;
     return $data;
 }
Exemplo n.º 11
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     // check for form layout
     if ($this->getLayout() == 'form' || in_array(JRequest::getVar('task'), array('add', 'edit'))) {
         // Important set layout to be form since various category view SEF links have this variable set
         $this->setLayout('form');
         $this->_displayForm($tpl);
         return;
     } else {
         $this->setLayout('item');
     }
     // Get Content Types with no category links in item view pathways, and for unroutable (non-linkable) categories
     global $globalnoroute, $globalnopath, $globalcats;
     if (!is_array($globalnopath)) {
         $globalnopath = array();
     }
     if (!is_array($globalnoroute)) {
         $globalnoroute = array();
     }
     //initialize variables
     $dispatcher = JDispatcher::getInstance();
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $document = JFactory::getDocument();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $aid = FLEXI_J16GE ? JAccess::getAuthorisedViewLevels($user->id) : (int) $user->get('aid');
     $db = JFactory::getDBO();
     $nullDate = $db->getNullDate();
     // ******************************************************
     // Get item, model and create form (that loads item data)
     // ******************************************************
     // Get various data from the model
     $model = $this->getModel();
     $cid = $model->_cid ? $model->_cid : $model->get('catid');
     // Get current category id
     // we are in display() task, so we will load the current item version by default
     // 'preview' request variable will force last, and finally 'version' request variable will force specific
     // NOTE: preview and version variables cannot be used by users that cannot edit the item
     JRequest::setVar('loadcurrent', true);
     // Try to load existing item, an 404 error will be raised if item is not found. Also value 2 for check_view_access
     // indicates to raise 404 error for ZERO primary key too, instead of creating and returning a new item object
     $start_microtime = microtime(true);
     $item = $model->getItem(null, $check_view_access = 2);
     $_run_time = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
     // Set item parameters as VIEW's parameters (item parameters are merged with component/page/type/current category/access parameters already)
     $params = $item->parameters;
     $print_logging_info = $params->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
     }
     if ($print_logging_info) {
         $fc_run_times['get_item_data'] = $_run_time;
     }
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     //add css file
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css');
         $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
     }
     //allow css override
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
         $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css');
     }
     //special to hide the joomfish language selector on item views
     if ($params->get('disable_lang_select', 0)) {
         $css = '#jflanguageselection { visibility:hidden; }';
         $document->addStyleDeclaration($css);
     }
     // ********************
     // ITEM LAYOUT handling
     // ********************
     // (a) Decide to use mobile or normal item template layout
     $useMobile = $params->get('use_mobile_layouts', 0);
     if ($useMobile) {
         $force_desktop_layout = $params->get('force_desktop_layout', 0);
         $mobileDetector = flexicontent_html::getMobileDetector();
         $isMobile = $mobileDetector->isMobile();
         $isTablet = $mobileDetector->isTablet();
         $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile;
     }
     $_ilayout = $useMobile ? 'ilayout_mobile' : 'ilayout';
     // (b) Get from item parameters, allowing URL override
     $ilayout = JRequest::getVar($_ilayout, false);
     if (!$ilayout) {
         $desktop_ilayout = $params->get('ilayout', 'default');
         $ilayout = !$useMobile ? $desktop_ilayout : $params->get('ilayout_mobile', $desktop_ilayout);
     }
     // (c) Create the type parameters
     $tparams = $this->get('Typeparams');
     $tparams = FLEXI_J16GE ? new JRegistry($tparams) : new JParameter($tparams);
     // (d) Verify the layout is within templates, Content Type default template OR Content Type allowed templates
     $allowed_tmpls = $tparams->get('allowed_ilayouts');
     $type_default_layout = $tparams->get('ilayout', 'default');
     if (empty($allowed_tmpls)) {
         $allowed_tmpls = array();
     } else {
         if (!is_array($allowed_tmpls)) {
             $allowed_tmpls = !FLEXI_J16GE ? array($allowed_tmpls) : explode("|", $allowed_tmpls);
         }
     }
     // (e) Verify the item layout is within templates: Content Type default template OR Content Type allowed templates
     if ($ilayout != $type_default_layout && count($allowed_tmpls) && !in_array($ilayout, $allowed_tmpls)) {
         $app->enqueueMessage("<small>Current Item Layout Template is '{$ilayout}':<br/>- This is neither the Content Type Default Template, nor does it belong to the Content Type allowed templates.<br/>- Please correct this in the URL or in Content Type configuration.<br/>- Using Content Type Default Template Layout: '{$type_default_layout}'</small>", 'notice');
         $ilayout = $type_default_layout;
     }
     // (f) Get cached template data
     $themes = flexicontent_tmpl::getTemplates($lang_files = array($ilayout));
     // (g) Verify the item layout exists
     if (!isset($themes->items->{$ilayout})) {
         $fixed_ilayout = isset($themes->items->{$type_default_layout}) ? $type_default_layout : 'default';
         $app->enqueueMessage("<small>Current Item Layout Template is '{$ilayout}' does not exist<br/>- Please correct this in the URL or in Content Type configuration.<br/>- Using Template Layout: '{$fixed_ilayout}'</small>", 'notice');
         $ilayout = $fixed_ilayout;
         if (FLEXI_FISH || FLEXI_J16GE) {
             FLEXIUtilities::loadTemplateLanguageFile($ilayout);
         }
         // Manually load Template-Specific language file of back fall ilayout
     }
     // (h) finally set the template name back into the item's parameters
     $params->set('ilayout', $ilayout);
     // Bind Fields
     $_items = array(&$item);
     FlexicontentFields::getFields($_items, FLEXI_ITEMVIEW, $params, $aid);
     // Note : This parameter doesn't exist yet but it will be used by the future gallery template
     /*if ($params->get('use_panes', 1)) {
     			jimport('joomla.html.pane');
     			$pane = JPane::getInstance('Tabs');
     			$this->assignRef('pane', $pane);
     		}*/
     $fields = $item->fields;
     // Pathway needed variables
     //$catshelper = new flexicontent_cats($cid);
     //$parents    = $catshelper->getParentlist();
     //echo "<pre>".print_r($parents,true)."</pre>";
     $parents = array();
     if ($cid && isset($globalcats[$cid]->ancestorsarray)) {
         $parent_ids = $globalcats[$cid]->ancestorsarray;
         foreach ($parent_ids as $parent_id) {
             $parents[] = $globalcats[$parent_id];
         }
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = FLEXI_ITEMVIEW == @$menu->query['view'] || 'article' == @$menu->query['view'];
         $cid_ok = JRequest::getInt('cid') == (int) @$menu->query['cid'];
         $id_ok = JRequest::getInt('id') == (int) @$menu->query['id'];
         $menu_matches = $view_ok && $id_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         $default_heading = $item->title;
         // Decide to show page heading (=J1.5 page title), there is no need for this in item view
         $show_default_heading = 0;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if (a) IT IS same as item title and (b) item title is already configured to be shown
     if ($params->get('show_title', 1)) {
         if ($params->get('page_heading') == $item->title) {
             $params->set('show_page_heading', 0);
         }
         if ($params->get('page_title') == $item->title) {
             $params->set('show_page_title', 0);
         }
     }
     // ************************************************************
     // Create the document title, by from page title and other data
     // ************************************************************
     // Use the page heading as document title, (already calculated above via 'appropriate' logic ...)
     // or the overriden custom <title> ... set via parameter
     $doc_title = !$params->get('override_title', 0) ? $params->get('page_title') : $params->get('custom_ititle', $item->title);
     // Check and prepend category title
     if ($params->get('addcat_title', 1) && count($parents)) {
         $parentcat = end($parents);
         $doc_title = (isset($parentcat->title) ? $parentcat->title . ' - ' : '') . $doc_title;
     }
     // Check and prepend or append site name
     if (FLEXI_J16GE) {
         // Not available in J1.5
         // Add Site Name to page title
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = $app->getCfg('sitename') . " - " . $doc_title;
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = $doc_title . " - " . $app->getCfg('sitename');
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     // Set item's META data: desc, keyword, title, author
     if ($item->metadesc) {
         $document->setDescription($item->metadesc);
     }
     if ($item->metakey) {
         $document->setMetadata('keywords', $item->metakey);
     }
     // ?? Deprecated <title> tag is used instead by search engines
     if ($app->getCfg('MetaTitle') == '1') {
         $document->setMetaData('title', $item->title);
     }
     if ($app->getCfg('MetaAuthor') == '1') {
         $document->setMetaData('author', $item->author);
     }
     // Set remaining META keys
     $mdata = $item->metadata->toArray();
     foreach ($mdata as $k => $v) {
         if ($v) {
             $document->setMetadata($k, $v);
         }
     }
     // Overwrite with menu META data if menu matched
     if (FLEXI_J16GE) {
         if ($menu_matches) {
             if ($_mp = $menu->params->get('menu-meta_description')) {
                 $document->setDescription($_mp);
             }
             if ($_mp = $menu->params->get('menu-meta_keywords')) {
                 $document->setMetadata('keywords', $_mp);
             }
             if ($_mp = $menu->params->get('robots')) {
                 $document->setMetadata('robots', $_mp);
             }
             if ($_mp = $menu->params->get('secure')) {
                 $document->setMetadata('secure', $_mp);
             }
         }
     }
     // ************************************
     // Add rel canonical html head link tag (TODO: improve multi-page handing)
     // ************************************
     $base = $uri->getScheme() . '://' . $uri->getHost();
     $ucanonical = $base . JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $globalcats[$item->maincatid]->slug, 0, $item));
     // $item->categoryslug
     if ($params->get('add_canonical')) {
         $head_obj = $document->addHeadLink($ucanonical, 'canonical', 'rel', '');
         $defaultCanonical = flexicontent_html::getDefaultCanonical();
         if (FLEXI_J30GE && $defaultCanonical != $ucanonical) {
             unset($head_obj->_links[$defaultCanonical]);
         }
     }
     // *************************
     // increment the hit counter
     // *************************
     // MOVED to flexisystem plugin due to ...
     /*if (FLEXIUtilities::count_new_hit($item->id) ) {
     			$model->hit();
     		}*/
     // Load template css/js and set template data variable
     $tmplvar = $themes->items->{$ilayout}->tmplvar;
     if ($ilayout) {
         // Add the templates css files if availables
         if (isset($themes->items->{$ilayout}->css)) {
             foreach ($themes->items->{$ilayout}->css as $css) {
                 $document->addStyleSheet($this->baseurl . '/' . $css);
             }
         }
         // Add the templates js files if availables
         if (isset($themes->items->{$ilayout}->js)) {
             foreach ($themes->items->{$ilayout}->js as $js) {
                 $document->addScript($this->baseurl . '/' . $js);
             }
         }
         // Set the template var
         $tmpl = $themes->items->{$ilayout}->tmplvar;
     } else {
         $tmpl = '.items.default';
     }
     // Just put item's text (description field) inside property 'text' in case the events modify the given text,
     $item->text = isset($item->fields['text']->display) ? $item->fields['text']->display : '';
     // Maybe here not to import all plugins but just those for description field ???
     // Anyway these events are usually not very time consuming, so lets trigger all of them ???
     JPluginHelper::importPlugin('content');
     // Suppress some plugins from triggering for compatibility reasons, e.g.
     // (a) jcomments, jom_comment_bot plugins, because we will get comments HTML manually inside the template files
     $suppress_arr = array('jcomments', 'jom_comment_bot');
     FLEXIUtilities::suppressPlugins($suppress_arr, 'suppress');
     // Do some compatibility steps, Set the view and option to 'article' and 'com_content'
     JRequest::setVar('view', 'article');
     JRequest::setVar('option', 'com_content');
     JRequest::setVar("isflexicontent", "yes");
     $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     // These events return text that could be displayed at appropriate positions by our templates
     $item->event = new stdClass();
     if (FLEXI_J16GE) {
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$params, 0));
     } else {
         $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$item, &$params, $limitstart));
     }
     $item->event->afterDisplayTitle = trim(implode("\n", $results));
     if (FLEXI_J16GE) {
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$params, 0));
     } else {
         $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$params, $limitstart));
     }
     $item->event->beforeDisplayContent = trim(implode("\n", $results));
     if (FLEXI_J16GE) {
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$params, 0));
     } else {
         $results = $dispatcher->trigger('onAfterDisplayContent', array(&$item, &$params, $limitstart));
     }
     $item->event->afterDisplayContent = trim(implode("\n", $results));
     // Reverse the compatibility steps, set the view and option back to 'items' and 'com_flexicontent'
     JRequest::setVar('view', FLEXI_ITEMVIEW);
     JRequest::setVar('option', 'com_flexicontent');
     // Restore suppressed plugins
     FLEXIUtilities::suppressPlugins($suppress_arr, 'restore');
     // Put text back into the description field, THESE events SHOULD NOT modify the item text, but some plugins may do it anyway... , so we assign text back for compatibility
     if (!empty($item->positions)) {
         foreach ($item->positions as $pos_fields) {
             foreach ($pos_fields as $pos_field) {
                 if ($pos_field->name !== 'text') {
                     continue;
                 }
                 $pos_field->display =& $item->text;
             }
         }
     }
     $item->fields['text']->display =& $item->text;
     // (TOC) TABLE OF Contents has been created inside description field (named 'text') by
     // the pagination plugin, this should be assigned to item as a property with same name
     if (isset($item->fields['text']->toc)) {
         $item->toc =& $item->fields['text']->toc;
     }
     // ********************************************************************************************
     // Create pathway, if automatic pathways is enabled, then path will be cleared before populated
     // ********************************************************************************************
     $pathway = $app->getPathWay();
     // Clear pathway, if automatic pathways are enabled
     if ($params->get('automatic_pathways', 0)) {
         $pathway_arr = $pathway->getPathway();
         $pathway->setPathway(array());
         //$pathway->set('_count', 0);  // not needed ??
         $item_depth = 0;
         // menu item depth is now irrelevant ???, ignore it
     } else {
         $item_depth = $params->get('item_depth', 0);
     }
     // Respect menu item depth, defined in menu item
     $p = $item_depth;
     while ($p < count($parents)) {
         // For some Content Types the pathway should not be populated with category links
         if (in_array($item->type_id, $globalnopath)) {
             break;
         }
         // Do not add to pathway unroutable categories
         if (in_array($parents[$p]->id, $globalnoroute)) {
             $p++;
             continue;
         }
         // Add current parent category
         $pathway->addItem($this->escape($parents[$p]->title), JRoute::_(FlexicontentHelperRoute::getCategoryRoute($parents[$p]->slug)));
         $p++;
     }
     if ($params->get('add_item_pathway', 1)) {
         $pathway->addItem($this->escape($item->title), JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug, 0, $item)));
     }
     // **********************************************************************
     // Print link ... must include layout and current filtering url vars, etc
     // **********************************************************************
     $curr_url = $_SERVER['REQUEST_URI'];
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     //$print_link = JRoute::_('index.php?view='.FLEXI_ITEMVIEW.'&cid='.$item->categoryslug.'&id='.$item->slug.'&pop=1&tmpl=component&print=1');
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('item', $item);
     $this->assignRef('user', $user);
     $this->assignRef('params', $params);
     $this->assignRef('print_link', $print_link);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $this->assignRef('parentcat', $parentcat);
     $this->assignRef('fields', $item->fields);
     $this->assignRef('tmpl', $tmpl);
     /*
      * Set template paths : this procedure is issued from K2 component
      *
      * "K2" Component by JoomlaWorks for Joomla! 1.5.x - Version 2.1
      * Copyright (c) 2006 - 2009 JoomlaWorks Ltd. All rights reserved.
      * Released under the GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
      * More info at http://www.joomlaworks.gr and http://k2.joomlaworks.gr
      * Designed and developed by the JoomlaWorks team
      */
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates');
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates');
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . 'default');
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . 'default');
     if ($ilayout) {
         $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . $ilayout);
         $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $ilayout);
     }
     if ($print_logging_info) {
         $start_microtime = microtime(true);
     }
     parent::display($tpl);
     if ($print_logging_info) {
         $fc_run_times['template_render'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
     }
 }