public static function getCategoryData(&$params) { if (!$params->get('apply_config_per_category', 0)) { return false; } $app = JFactory::getApplication(); $db = JFactory::getDBO(); $view = JRequest::getVar('view'); $option = JRequest::getVar('option'); $currcat_custom_display = $params->get('currcat_custom_display', 0); $currcat_source = $params->get('currcat_source', 0); // 0 item view, 1 category view, 2 both $isflexi_itemview = $option == 'com_flexicontent' && $view == FLEXI_ITEMVIEW; $isflexi_catview = $option == 'com_flexicontent' && $view == 'category'; $currcat_valid_case = $currcat_source == 2 && ($isflexi_itemview || $isflexi_catview) || $currcat_source == 0 && $isflexi_itemview || $currcat_source == 1 && $isflexi_catview; if ($currcat_custom_display && $currcat_valid_case) { $id = JRequest::getInt('id', 0); // id of current item $cid = JRequest::getInt('cid', 0); // current category id of current item $catconf = new stdClass(); $catconf->orderby = ''; $catconf->fallback_maincat = $params->get('currcat_fallback_maincat', 0); $catconf->showtitle = $params->get('currcat_showtitle', 0); $catconf->showdescr = $params->get('currcat_showdescr', 0); $catconf->cuttitle = (int) $params->get('currcat_cuttitle', 40); $catconf->cutdescr = (int) $params->get('currcat_cutdescr', 200); $catconf->link_title = $params->get('currcat_link_title'); $catconf->show_image = $params->get('currcat_show_image'); $catconf->image_source = $params->get('currcat_image_source'); $catconf->link_image = $params->get('currcat_link_image'); $catconf->image_width = (int) $params->get('currcat_image_width', 80); $catconf->image_height = (int) $params->get('currcat_image_height', 80); $catconf->image_method = (int) $params->get('currcat_image_method', 1); $catconf->show_default_image = (int) $params->get('currcat_show_default_image', 0); // parameter not added yet $catconf->readmore = (int) $params->get('currcat_currcat_readmore', 1); if ($catconf->fallback_maincat && !$cid && $id) { $query = 'SELECT catid FROM #__content WHERE id = ' . $id; $db->setQuery($query); $cid = $db->loadResult(); } if ($cid) { $cids = array($cid); } } if (empty($cids)) { $catconf = new stdClass(); // Check if using a dynamic set of categories, that was decided by getItems() $dynamic_cids = $params->get('dynamic_catids', false); $static_cids = $params->get('catids', array()); $cids = $dynamic_cids ? unserialize($dynamic_cids) : $static_cids; $cids = !is_array($cids) ? array($cids) : $cids; $catconf->orderby = $params->get('cats_orderby', 'alpha'); $catconf->showtitle = $params->get('cats_showtitle', 0); $catconf->showdescr = $params->get('cats_showdescr', 0); $catconf->cuttitle = (int) $params->get('cats_cuttitle', 40); $catconf->cutdescr = (int) $params->get('cats_cutdescr', 200); $catconf->link_title = $params->get('cats_link_title'); $catconf->show_image = $params->get('cats_show_image'); $catconf->image_source = $params->get('cats_image_source'); $catconf->link_image = $params->get('cats_link_image'); $catconf->image_width = (int) $params->get('cats_image_width', 80); $catconf->image_height = (int) $params->get('cats_image_height', 80); $catconf->image_method = (int) $params->get('cats_image_method', 1); $catconf->show_default_image = (int) $params->get('cats_show_default_image', 0); // parameter not added yet $catconf->readmore = (int) $params->get('cats_readmore', 1); } if (empty($cids) || !count($cids)) { return false; } // initialize variables $orderby = ''; if ($catconf->orderby) { $orderby = flexicontent_db::buildCatOrderBy($params, $catconf->orderby, $request_var = '', $config_param = '', $cat_tbl_alias = 'c', $user_tbl_alias = 'u', $default_order = '', $default_order_dir = ''); } $query = 'SELECT c.id, c.title, c.description, c.params ' . (FLEXI_J16GE ? '' : ', c.image ') . ', CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as categoryslug' . ' FROM #__categories AS c' . (FLEXI_J16GE ? ' LEFT JOIN #__users AS u ON u.id = c.created_user_id' : '') . ' WHERE c.id IN (' . implode(',', $cids) . ')' . $orderby; $db->setQuery($query); $catdata_arr = $db->loadObjectList('id'); if ($db->getErrorNum()) { JFactory::getApplication()->enqueueMessage(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()), 'error'); } if (!$catdata_arr) { return false; } $joomla_image_path = $app->getCfg('image_path', FLEXI_J16GE ? '' : 'images' . DS . 'stories'); foreach ($catdata_arr as $i => $catdata) { $catdata->params = new JRegistry($catdata->params); // Category Title $catdata->title = flexicontent_html::striptagsandcut($catdata->title, $catconf->cuttitle); $catdata->showtitle = $catconf->showtitle; // Category image $catdata->image = FLEXI_J16GE ? $catdata->params->get('image') : $catdata->image; $catimage = ""; if ($catconf->show_image) { $catdata->introtext =& $catdata->description; $catdata->fulltext = ""; if ($catconf->image_source && $catdata->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . DS . $catdata->image)) { $src = JURI::base(true) . "/" . $joomla_image_path . "/" . $catdata->image; $h = '&h=' . $catconf->image_height; $w = '&w=' . $catconf->image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $catconf->image_method ? '&zc=' . $catconf->image_method : ''; $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION)); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $catimage = JURI::base() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf; } else { if ($catconf->image_source != 1 && ($src = flexicontent_html::extractimagesrc($catdata))) { $h = '&h=' . $catconf->image_height; $w = '&w=' . $catconf->image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $catconf->image_method ? '&zc=' . $catconf->image_method : ''; $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION)); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : ''; $catimage = JURI::base() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $base_url . $src . $conf; } } $catdata->image = $catimage; } // Category Description if (!$catconf->showdescr) { unset($catdata->description); } else { $catdata->description = flexicontent_html::striptagsandcut($catdata->description, $catconf->cutdescr); } // Category Links (title and image links) if ($catconf->link_title || $catconf->link_image || $catconf->readmore) { $catlink = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($catdata->categoryslug)); $catdata->titlelink = $catlink; $catdata->imagelink = $catlink; } $catdata->conf = $catconf; } return $catdata_arr; }
/** * Build the order clause for subcategory listing * * @access private * @return string */ function _buildCatOrderBy() { $request_var = ''; $config_param = 'subcat_orderby'; $default_order = 'c.lft'; $default_order_dir = 'ASC'; // Precedence: $request_var ==> $order ==> $config_param ==> $default_order return flexicontent_db::buildCatOrderBy($this->_params, $order = '', $request_var, $config_param, $cat_tbl_alias = 'c', $user_tbl_alias = 'u', $default_order, $default_order_dir); }
/** * Build the order clause * * @access private * @return string */ function _buildCatOrderBy($prefix) { $request_var = ''; $config_param = $prefix . 'orderby'; $default_order = $this->getState('filter_order', 'c.title'); $default_order_dir = $this->getState('filter_order_dir', 'ASC'); // Precedence: $request_var ==> $order ==> $config_param ==> $default_order return flexicontent_db::buildCatOrderBy($this->_params, $order = '', $request_var, $config_param, $cat_tbl_alias = 'c', $user_tbl_alias = 'u', $default_order, $default_order_dir); }