public function getLinks($args) { $view = isset($args->view) ? $args->view : ''; if (!($view = 'category')) { return array(); } require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'route.php'; $items = array(); $CategoryId = $args->cid; //adding categoryes $db =& JFactory::getDBO(); $query = $db->getQuery(true); $query->clear(); $query->select('id, title, lft, CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug'); $query->from('#__categories'); $query->where('published = 1 AND extension = \'com_content\' AND parent_id = ' . $CategoryId); $query->order('lft ASC'); $db->setQuery($query); $categories = $db->loadObjectList(); foreach ($categories as $category) { $items[] = array('url' => FlexicontentHelperRoute::getCategoryRoute($category->slug), 'id' => 'index.php?option=com_flexicontent_items&view=category&cid=' . $category->id, 'name' => $category->title, 'class' => 'folderflexiitems'); } //adding items $query->clear(); $query->select(' i.id as iid, i.title AS ititle, c.id as catid,' . ' CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(\':\', i.id, i.alias) ELSE i.id END as slug,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug'); $query->from('#__content AS i' . ' LEFT JOIN #__flexicontent_cats_item_relations AS rel ON rel.itemid = i.id ' . ' LEFT JOIN #__categories AS c ON c.id = rel.catid '); $query->where('c.id = ' . $CategoryId); $query->order('i.title ASC'); $db->setQuery($query); $contents = $db->loadObjectList(); foreach ($contents as $content) { $items[] = array('url' => FlexicontentHelperRoute::getItemRoute($content->slug, $content->catslug), 'id' => 'index.php?option=com_flexicontent_items&view=category&cid=' . $category->id . '&id=' . $content->iid, 'name' => $content->ititle . '(id=' . $content->iid . ')', 'class' => 'fileflexiitems'); } return $items; }
/** * Method to get the associations for a given item * * @param integer $id Id of the item * @param string $view Name of the view * * @return array Array of associations for the item * * @since 3.0 */ public static function getAssociations($id = 0, $view = null) { jimport('helper.route', JPATH_COMPONENT_SITE); $app = JFactory::getApplication(); $jinput = $app->input; $view = is_null($view) ? $jinput->get('view') : $view; $id = empty($id) ? $jinput->getInt('id') : $id; if ($view == 'item') { if ($id) { //$associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $id); $associations = FlexicontentHelperAssociation::getItemAssociations($id); $return = array(); foreach ($associations as $tag => $item) { $return[$tag] = FlexicontentHelperRoute::getItemRoute($item->id, $item->catid, 0, $item); } return $return; } } else { if ($view == 'category') { $cid = $jinput->getInt('cid'); if ($cid) { $associations = FlexicontentHelperAssociation::getCatAssociations($cid); $return = array(); foreach ($associations as $tag => $item) { $return[$tag] = FlexicontentHelperRoute::getCategoryRoute($item->catid, 0, array(), $item); } return $return; } } } return array(); }
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { if (!in_array($field->field_type, self::$field_types)) { return; } static $author_links = array(); if (!isset($author_links[$item->created_by])) { $author_links[$item->created_by] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute(0, 0, array('layout' => 'author', 'authorid' => $item->created_by))); } $field->{$prop} = '<a href="' . $author_links[$item->created_by] . '" itemprop="author">' . JText::_('FLEXI_FIELD_AI_MORE_ITEMS_BY_THIS_AUTHOR') . '</a>'; }
/** * Logic to create SEF urls via AJAX requests * * @access public * @return void * @since 1.0 */ function getsefurl() { $view = JRequest::getVar('view'); if ($view == 'category') { $cid = (int) JRequest::getVar('cid'); if ($cid) { $db = JFactory::getDBO(); $query = 'SELECT CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as categoryslug' . ' FROM #__categories AS c WHERE c.id = ' . $cid; $db->setQuery($query); $categoryslug = $db->loadResult(); echo JRoute::_(FlexicontentHelperRoute::getCategoryRoute($categoryslug), false); } } jexit(); }
function onDisplayCoreFieldValue(&$_field, &$_item, &$params, $_tags = null, $_categories = null, $_favourites = null, $_favoured = null, $_vote = null, $values = null, $prop = 'display') { // this function is a mess and need complete refactoring // execute the code only if the field type match the plugin type $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW)); static $cat_links = array(); static $tag_links = array(); if (!is_array($_item)) { $items = array(&$_item); } else { $items =& $_item; } // Prefix - Suffix - Separator parameters // these parameters should be common so we will retrieve them from the first item instead of inside the loop $item = reset($items); if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } $remove_space = $field->parameters->get('remove_space', 0); $_pretext = $field->parameters->get('pretext', ''); $_posttext = $field->parameters->get('posttext', ''); $separatorf = $field->parameters->get('separatorf', 3); $_opentag = $field->parameters->get('opentag', ''); $_closetag = $field->parameters->get('closetag', ''); $pretext_cacheable = $posttext_cacheable = $opentag_cacheable = $closetag_cacheable = false; foreach ($items as $item) { //if (!is_object($_field)) echo $item->id." - ".$_field ."<br/>"; if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } if ($field->iscore != 1) { continue; } $field->item_id = $item->id; // Replace item properties or values of other fields if (!$pretext_cacheable) { $pretext = FlexicontentFields::replaceFieldValue($field, $item, $_pretext, 'pretext', $pretext_cacheable); if ($pretext && !$remove_space) { $pretext = $pretext . ' '; } } if (!$posttext_cacheable) { $posttext = FlexicontentFields::replaceFieldValue($field, $item, $_posttext, 'posttext', $posttext_cacheable); if ($posttext && !$remove_space) { $posttext = ' ' . $posttext; } } if (!$opentag_cacheable) { $opentag = FlexicontentFields::replaceFieldValue($field, $item, $_opentag, 'opentag', $opentag_cacheable); } // used by some fields if (!$closetag_cacheable) { $closetag = FlexicontentFields::replaceFieldValue($field, $item, $_closetag, 'closetag', $closetag_cacheable); } // used by some fields switch ($separatorf) { case 0: $separatorf = ' '; break; case 1: $separatorf = '<br />'; break; case 2: $separatorf = ' | '; break; case 3: $separatorf = ', '; break; case 4: $separatorf = $closetag . $opentag; break; case 5: $separatorf = ''; break; default: $separatorf = ' '; break; } $field->value = array(); switch ($field->field_type) { case 'created': // created $field->value[] = $item->created; $dateformat = $field->parameters->get('date_format', ''); $customdate = $field->parameters->get('custom_date', ''); $dateformat = $dateformat ? $dateformat : $customdate; $field->display = $pretext . JHTML::_('date', $item->created, JText::_($dateformat)) . $posttext; break; case 'createdby': // created by $field->value[] = $item->created_by; $field->display = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->cuname : $item->creator) . $posttext; break; case 'modified': // modified $field->value[] = $item->modified; $dateformat = $field->parameters->get('date_format', ''); $customdate = $field->parameters->get('custom_date', ''); $dateformat = $dateformat ? $dateformat : $customdate; $field->display = $pretext . JHTML::_('date', $item->modified, JText::_($dateformat)) . $posttext; break; case 'modifiedby': // modified by $field->value[] = $item->modified_by; $field->display = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->muname : $item->modifier) . $posttext; break; case 'title': // title $field->value[] = $item->title; $field->display = $pretext . $item->title . $posttext; // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { $content_val = flexicontent_html::striptagsandcut($field->display, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:title" content="' . $content_val . '" />'); } } break; case 'hits': // hits $field->value[] = $item->hits; $field->display = $pretext . $item->hits . $posttext; break; case 'type': // document type $field->value[] = $item->type_id; $field->display = $pretext . JText::_($item->typename) . $posttext; break; case 'version': // version $field->value[] = $item->version; $field->display = $pretext . $item->version . $posttext; break; case 'state': // state $field->value[] = $item->state; $field->display = $pretext . flexicontent_html::stateicon($item->state, $field->parameters) . $posttext; break; case 'voting': // voting button if ($_vote === false) { $vote =& $item->vote; } else { $vote =& $_vote; } $field->value[] = 'button'; // dummy value to force display $field->display = $pretext . flexicontent_html::ItemVote($field, 'all', $vote) . $posttext; break; case 'favourites': // favourites button if ($_favourites === false) { $favourites =& $item->favs; } else { $favourites =& $_favourites; } if ($_favoured === false) { $favoured =& $item->fav; } else { $favoured =& $_favoured; } $field->value[] = 'button'; // dummy value to force display $favs = flexicontent_html::favoured_userlist($field, $item, $favourites); $field->display = $pretext . ' <span class="fav-block"> ' . flexicontent_html::favicon($field, $favoured, $item) . ' <span id="fcfav-reponse_' . $field->item_id . '" class="fcfav-reponse"> <small>' . $favs . '</small> </span> </span> ' . $posttext; break; case 'categories': // assigned categories $field->display = ''; if ($_categories === false) { $categories =& $item->cats; } else { $categories =& $_categories; } if ($categories) { // Get categories that should be excluded from linking global $globalnoroute; if (!is_array($globalnoroute)) { $globalnoroute = array(); } // Create list of category links, excluding the "noroute" categories $field->display = array(); foreach ($categories as $category) { $cat_id = $category->id; if (in_array($cat_id, @$globalnoroute)) { continue; } if (!isset($cat_links[$cat_id])) { $cat_links[$cat_id] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug)); } $cat_link = $cat_links[$cat_id]; $display = '<a class="fc_categories fc_category_' . $cat_id . ' link_' . $field->name . '" href="' . $cat_link . '">' . $category->title . '</a>'; $field->display[] = $pretext . $display . $posttext; $field->value[] = $category->title; } $field->display = implode($separatorf, $field->display); $field->display = $opentag . $field->display . $closetag; } break; case 'tags': // assigned tags $field->display = ''; if ($_tags === false) { $tags =& $item->tags; } else { $tags =& $_tags; } if ($tags) { // Create list of tag links $field->display = array(); foreach ($tags as $tag) { $tag_id = $tag->id; if (!isset($tag_links[$tag_id])) { $tag_links[$tag_id] = JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug)); } $tag_link = $tag_links[$tag_id]; $display = '<a class="fc_tags fc_tag_' . $tag->id . ' link_' . $field->name . '" href="' . $tag_link . '">' . $tag->name . '</a>'; $field->display[] = $pretext . $display . $posttext; $field->value[] = $tag->name; } $field->display = implode($separatorf, $field->display); $field->display = $opentag . $field->display . $closetag; } break; case 'maintext': // main text // Special display variables if ($prop != 'display') { switch ($prop) { case 'display_if': $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; break; case 'display_i': $field->{$prop} = $item->introtext; break; case 'display_f': $field->{$prop} = $item->fulltext; break; } } else { if (!$item->fulltext) { $field->display = $item->introtext; } else { if ($view != FLEXI_ITEMVIEW) { if ($item->parameters->get('force_full', 0)) { $field->display = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->display = $item->introtext; } } else { if ($item->parameters->get('show_intro', 1)) { $field->display = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->display = $item->fulltext; } } } } // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { if ($item->metadesc) { JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $item->metadesc . '" />'); } else { $content_val = flexicontent_html::striptagsandcut($field->display, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $content_val . '" />'); } } } break; } } }
/** * 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, '?') ? '&' : '?') . 'pop=1&tmpl=component&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; } }
/** * Returns the URL for an article * * @param Table $row * @param boolean $htmlspecialchars * @param string $type 'article', 'section' or 'category' * @return string URL */ static public function getUrl( $row, $htmlspecialchars = true, $type = 'article' , $iid = 499) { global $_CB_framework; /** @noinspection PhpIncludeInspection */ require_once ( $_CB_framework->getCfg( 'absolute_path' ) . '/components/com_flexicontent/helpers/route.php' ); $categorySlug = $row->get( 'category' ) . ( $row->get( 'category_alias' ) ? ':' . $row->get( 'category_alias' ) : null ); $articleSlug = $row->get( 'id' ) . ( $row->get( 'alias' ) ? ':' . $row->get( 'alias' ) : null ); switch ( $type ) { case 'section': $url = FlexicontentHelperRoute::getCategoryRoute( $row->get( 'section' ) ); break; case 'category': $url = FlexicontentHelperRoute::getCategoryRoute( $categorySlug ); break; case 'article': default: $url = FlexicontentHelperRoute::getItemRoute( $articleSlug, $categorySlug , $iid ); //itemid 499 break; } if ( ! stristr( $url, 'Itemid' ) ) { $url = $_CB_framework->getCfg( 'live_site' ) . '/' . $url; } else { //$url = JRoute::_( $url, false ); } if ( $url ) { if ( $htmlspecialchars ) { $url = htmlspecialchars( $url ); } } return $url; }
<?php $html = '<span class="flexi fc-pagenav">'; $tooltip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; // CATEGORY back link if ($use_category_link) { $cat_image = $this->getCatThumb($category, $field->parameters); $limit = $item_count; $limit = $limit ? $limit : 10; $start = floor($location / $limit) * $limit; if (!empty($rows[$item->id]->categoryslug)) { $html .= ' <span class="fc-pagenav-return"> <a class="btn" href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($rows[$item->id]->categoryslug)) . '?start=' . $start . '">' . htmlspecialchars($category_label, ENT_NOQUOTES, 'UTF-8') . ($cat_image ? ' <br/> <img src="' . $cat_image . '" alt="Return"/>' : '') . ' </a> </span>'; } } // Item location and total count $html .= $show_prevnext_count ? '<span class="fc-pagenav-items-cnt badge badge-info">' . ($location + 1) . ' / ' . $item_count . '</span>' : ''; // Next item linking if ($field->prev) { $tooltip = $use_tooltip ? ' title="' . flexicontent_html::getToolTip($tooltip_title_prev, $field->prevtitle, 0) . '"' : ''; $html .= ' <span class="fc-pagenav-prev' . ($use_tooltip ? $tooltip_class : '') . '" ' . ($use_tooltip ? $tooltip : '') . '> <a class="btn" href="' . $field->prevurl . '"> <i class="icon-previous"></i> ' . ($use_title ? $field->prevtitle : htmlspecialchars($prev_label, ENT_NOQUOTES, 'UTF-8')) . ' ' . ($field->prevThumb ? '
function display($tpl = null) { global $globalcats; $app = JFactory::getApplication(); $user = JFactory::getUser(); $document = JFactory::getDocument(); if (FLEXI_J16GE) { JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, null, true); } // *********************************************************** // Get category data, and check if item is already checked out // *********************************************************** // Get data from the model $model = $this->getModel(); if (FLEXI_J16GE) { $row = $this->get('Item'); $form = $this->get('Form'); } else { $row = $this->get('Category'); } $catparams = FLEXI_J16GE ? new JRegistry($row->params) : new JParameter($row->params); $cid = $row->id; $isnew = !$cid; // Check category is checked out by different editor / administrator if (!$isnew && $model->isCheckedOut($user->get('id'))) { JError::raiseWarning('SOME_ERROR_CODE', $row->title . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN')); $app->redirect('index.php?option=com_flexicontent&view=categories'); } // *************************************************************************** // Currently access checking for category add/edit form , it is done here, for // most other views we force going though the controller and checking it there // *************************************************************************** // ********************************************************************************************* // Global Permssions checking (needed because this view can be called without a controller task) // ********************************************************************************************* // Get global permissions $perms = FlexicontentHelperPerm::getPerm(); // handles super admins correctly // Check no access to categories management (Global permission) if (!$perms->CanCats) { $app->redirect('index.php?option=com_flexicontent', JText::_('FLEXI_NO_ACCESS')); } // Check no privilege to create new categories (Global permission) if ($isnew && !$perms->CanAddCats) { JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_CREATE')); $app->redirect('index.php?option=com_flexicontent'); } // ************************************************************************************ // Record Permssions (needed because this view can be called without a controller task) // ************************************************************************************ // Get edit privilege for current category if (!$isnew) { if (FLEXI_J16GE) { $isOwner = $row->get('created_by') == $user->id; $rights = FlexicontentHelperPerm::checkAllItemAccess($user->id, 'category', $cid); $canedit_cat = in_array('edit', $rights) || in_array('edit.own', $rights) && $isOwner; } else { if (FLEXI_ACCESS) { $rights = FAccess::checkAllItemAccess('com_content', 'users', $user->gmid, 0, $row->id); $canedit_cat = $user->gid < 25 ? in_array('edit', $rights) || in_array('editown', $rights) : 1; } else { $canedit_cat = true; } } } // Get if we can create inside at least one (com_content) category if (!FLEXI_J16GE || $user->authorise('core.create', 'com_flexicontent')) { $cancreate_cat = true; } else { $usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true); $cancreate_cat = count($usercats) > 0; } // Creating new category: Check if user can create inside any existing category if ($isnew && !$cancreate_cat) { $acc_msg = JText::_('FLEXI_NO_ACCESS_CREATE') . "<br/>" . (FLEXI_J16GE ? JText::_('FLEXI_CANNOT_ADD_CATEGORY_REASON') : ""); JError::raiseWarning(403, $acc_msg); $app->redirect('index.php?option=com_flexicontent&view=categories'); } // Editing existing category: Check if user can edit existing (current) category if (!$isnew && !$canedit_cat) { $acc_msg = JText::_('FLEXI_NO_ACCESS_EDIT') . "<br/>" . JText::_('FLEXI_CANNOT_EDIT_CATEGORY_REASON'); JError::raiseWarning(403, $acc_msg); $app->redirect('index.php?option=com_flexicontent&view=categories'); } // ************************************************** // Include needed files and add needed js / css files // ************************************************** FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); flexicontent_html::loadFramework('jQuery'); flexicontent_html::loadFramework('select2'); // Load pane behavior jimport('joomla.html.pane'); // Load tooltips JHTML::_('behavior.tooltip'); // Add css to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } // Add js function to overload the joomla submitform $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/admin.js'); $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/validate.js'); // ******************** // Initialise variables // ******************** $editor_name = $user->getParam('editor', $app->getCfg('editor')); $editor = JFactory::getEditor($editor_name); $cparams = JComponentHelper::getParams('com_flexicontent'); $bar = JToolBar::getInstance('toolbar'); if (!FLEXI_J16GE) { $pane = JPane::getInstance('sliders'); $tpane = JPane::getInstance('tabs', array('startOffset' => 0, 'allowAllClose' => true, 'opacityTransition' => true, 'duration' => 600)); } $categories = $globalcats; // ****************** // Create the toolbar // ****************** // Create Toolbar title and add the preview button if (!$isnew) { JToolBarHelper::title(JText::_('FLEXI_EDIT_CATEGORY'), 'fc_categoryedit'); $autologin = $cparams->get('autoflogin', 1) ? '&fcu=' . $user->username . '&fcp=' . $user->password : ''; $previewlink = JRoute::_(JURI::root() . FlexicontentHelperRoute::getCategoryRoute($categories[$cid]->slug)) . $autologin; // Add a preview button $bar->appendButton('Custom', '<a class="preview btn btn-small" href="' . $previewlink . '" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-32-preview"></span>' . JText::_('Preview') . '</a>', 'preview'); } else { JToolBarHelper::title(JText::_('FLEXI_NEW_CATEGORY'), 'fc_categoryadd'); } // Add apply and save buttons if (FLEXI_J16GE) { JToolBarHelper::apply('category.apply'); JToolBarHelper::save('category.save'); } else { JToolBarHelper::apply(); JToolBarHelper::save(); } // Add a save and new button, if user can create inside at least one (com_content) category if ($cancreate_cat) { if (FLEXI_J16GE) { JToolBarHelper::save2new('category.save2new'); } else { JToolBarHelper::custom('saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); } } // Add a save as copy button, if editing an existing category (J2.5 only) if (FLEXI_J16GE && !$isnew && $cancreate_cat) { JToolBarHelper::save2copy('category.save2copy'); } // Add a cancel or close button if ($isnew) { if (FLEXI_J16GE) { JToolBarHelper::cancel('category.cancel'); } else { JToolBarHelper::cancel(); } } else { if (FLEXI_J16GE) { JToolBarHelper::cancel('category.cancel', 'JTOOLBAR_CLOSE'); } else { JToolBarHelper::custom('cancel', 'cancel.png', 'cancel.png', 'CLOSE', false); } } // ******************************************* // Prepare data to pass to the form's template // ******************************************* if (!FLEXI_J16GE) { //clean data JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'description'); // Create the form $form = new JParameter($row->params, JPATH_COMPONENT . DS . 'models' . DS . 'category.xml'); //$form->loadINI($row->attribs); //echo "<pre>"; print_r($form->_xml['templates']->_children[0]); echo "<pre>"; print_r($form->_xml['templates']->param[0]); exit; foreach ($form->_xml['templates']->_children as $i => $child) { if (isset($child->_attributes['enableparam']) && !$cparams->get($child->_attributes['enableparam'])) { unset($form->_xml['templates']->_children[$i]); unset($form->_xml['templates']->param[$i]); } } foreach ($form->_xml['special']->_children as $i => $child) { if (isset($child->_attributes['enableparam']) && !$cparams->get($child->_attributes['enableparam'])) { unset($form->_xml['special']->_children[$i]); unset($form->_xml['special']->param[$i]); } } } // ********************************************************************************** // Get Templates and apply Template Parameters values into the form fields structures // ********************************************************************************** $themes = flexicontent_tmpl::getTemplates(); $tmpls = $themes->category; foreach ($tmpls as $tmpl) { if (FLEXI_J16GE) { $jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; // ... values applied at the template form file } else { $tmpl->params->loadINI($row->params); } } //build selectlists $Lists = array(); if (!FLEXI_J16GE) { $javascript = "onchange=\"javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='../images/stories/' + document.forms[0].image.options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; $Lists['imagelist'] = JHTML::_('list.images', 'image', $row->image, $javascript, '/images/stories/'); $Lists['access'] = JHTML::_('list.accesslevel', $row); // build granular access list if (FLEXI_ACCESS) { $Lists['access'] = FAccess::TabGmaccess($row, 'category', 1, 1, 1, 1, 1, 1, 1, 1, 1); } } $check_published = false; $check_perms = true; $actions_allowed = array('core.create'); $fieldname = FLEXI_J16GE ? 'jform[parent_id]' : 'parent_id'; $Lists['parent_id'] = flexicontent_cats::buildcatselect($categories, $fieldname, $row->parent_id, $top = 1, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array($row->id)); $check_published = false; $check_perms = true; $actions_allowed = array('core.edit', 'core.edit.own'); $fieldname = FLEXI_J16GE ? 'jform[copycid]' : 'copycid'; $Lists['copycid'] = flexicontent_cats::buildcatselect($categories, $fieldname, '', $top = 2, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = false); $custom_options[''] = 'FLEXI_USE_GLOBAL'; $custom_options['0'] = 'FLEXI_COMPONENT_ONLY'; $custom_options['-1'] = 'FLEXI_PARENT_CAT_MULTI_LEVEL'; $check_published = false; $check_perms = true; $actions_allowed = array('core.edit', 'core.edit.own'); $fieldname = FLEXI_J16GE ? 'jform[special][inheritcid]' : 'params[inheritcid]'; $Lists['inheritcid'] = flexicontent_cats::buildcatselect($categories, $fieldname, $catparams->get('inheritcid', ''), $top = false, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = false, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options); // ************************ // Assign variables to view // ************************ $this->assignRef('document', $document); $this->assignRef('Lists', $Lists); $this->assignRef('row', $row); $this->assignRef('form', $form); $this->assignRef('perms', $perms); $this->assignRef('editor', $editor); $this->assignRef('tmpls', $tmpls); $this->assignRef('cparams', $cparams); if (!FLEXI_J16GE) { $this->assignRef('pane', $pane); $this->assignRef('tpane', $tpane); } parent::display($tpl); }
/** * Creates the RSS for the View * * @since 1.0 */ function display($tpl = null) { $db = JFactory::getDBO(); $doc = JFactory::getDocument(); $app = JFactory::getApplication(); $params = $this->get('Params'); $doc->link = JRoute::_(FlexicontentHelperRoute::getCategoryRoute(JRequest::getVar('cid', null, '', 'int'))); $category = $this->get('Category'); // Prepare query to match feed data JRequest::setVar('limit', $params->get('feed_limit')); // Force a specific limit, this will be moved to the model $params->set('orderby', $params->get('feed_orderby', 'rdate')); $params->set('orderbycustomfield', $params->get('feed_orderbycustomfield', 1)); $params->set('orderbycustomfieldid', $params->get('feed_orderbycustomfieldid', 0)); $params->set('orderbycustomfielddir', $params->get('feed_orderbycustomfielddir', 'ASC')); $params->set('orderbycustomfieldint', $params->get('feed_orderbycustomfieldint', 0)); $params->set('orderby_2nd', $params->get('feed_orderby', 'alpha')); $params->set('orderbycustomfield_2nd', $params->get('feed_orderbycustomfield_2nd', 1)); $params->set('orderbycustomfieldid_2nd', $params->get('feed_orderbycustomfieldid_2nd', 0)); $params->set('orderbycustomfielddir_2nd', $params->get('feed_orderbycustomfielddir_2nd', 'ASC')); $params->set('orderbycustomfieldint_2nd', $params->get('feed_orderbycustomfieldint_2nd', 0)); $model = $this->getModel(); $model->setState('limit', $params->get('feed_limit', $model->getState('limit'))); $rows = $this->get('Data'); $feed_summary = $params->get('feed_summary', 0); $feed_summary_cut = $params->get('feed_summary_cut', 200); $feed_use_image = $params->get('feed_use_image', 1); $feed_link_image = $params->get('feed_link_image', 1); $feed_image_source = $params->get('feed_image_source', ''); $feed_image_size = $params->get('feed_image_size', ''); $feed_image_method = $params->get('feed_image_method', 1); $feed_image_width = $params->get('feed_image_width', 100); $feed_image_height = $params->get('feed_image_height', 80); // Retrieve default image for the image field if ($feed_use_image && $feed_image_source) { $query = 'SELECT attribs, name FROM #__flexicontent_fields WHERE id = ' . (int) $feed_image_source; $db->setQuery($query); $image_dbdata = $db->loadObject(); //$image_dbdata->params = FLEXI_J16GE ? new JRegistry($image_dbdata->params) : new JParameter($image_dbdata->params); $img_size_map = array('l' => 'large', 'm' => 'medium', 's' => 'small', '' => ''); $img_field_size = $img_size_map[$feed_image_size]; $img_field_name = $image_dbdata->name; } // TODO render and add extra fields here ... maybe via special display function for feeds view $extra_fields = $params->get('feed_extra_fields', ''); $extra_fields = array_unique(preg_split("/\\s*,\\s*/u", $extra_fields)); if ($extra_fields) { foreach ($extra_fields as $fieldname) { // Render given field for ALL ITEMS FlexicontentFields::getFieldDisplay($rows, $fieldname, $values = null, $method = 'display'); } } foreach ($rows as $row) { // strip html from feed item title $title = $this->escape($row->title); $title = html_entity_decode($title); // url link to article // & used instead of & as this is converted by feed creator $link = JRoute::_(FlexicontentHelperRoute::getItemRoute($row->slug, $category->slug, 0, $row)); // strip html from feed item description text $description = $feed_summary ? $row->introtext . $row->fulltext : $row->introtext; $description = flexicontent_html::striptagsandcut($description, $feed_summary_cut); if ($feed_use_image) { // feed image is enabled $src = ''; $thumb = ''; if ($feed_image_source) { // case 1 use an image field FlexicontentFields::getFieldDisplay($row, $img_field_name, null, 'display', 'module'); $img_field = $row->fields[$img_field_name]; if (!$img_field_size) { $src = str_replace(JURI::root(), '', $img_field->thumbs_src['large'][0]); } else { $src = ''; $thumb = $img_field->thumbs_src[$img_field_size][0]; } } else { // case 2 extract from item $src = flexicontent_html::extractimagesrc($row); } $RESIZE_FLAG = !$feed_image_source || !$img_field_size; if ($src && $RESIZE_FLAG) { // Resize image when src path is set and RESIZE_FLAG: (a) using image extracted from item main text OR (b) not using image field's already created thumbnails $h = '&h=' . $feed_image_height; $w = '&w=' . $feed_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $feed_image_method ? '&zc=' . $feed_image_method : ''; $ext = 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) . '/' : ''; $thumb = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $base_url . $src . $conf; } else { // Do not resize image when (a) image src path not set or (b) using image field's already created thumbnails } if ($thumb) { $description = "\n\t \t\t\t<div class='feed-description'>\n\t\t \t\t\t<a class='feed-readmore' target='_blank' href='" . $link . "'>\n\t\t \t\t\t\t<img src='" . $thumb . "' alt='" . $title . "' title='" . $title . "' align='left'/>\n\t\t \t\t\t</a>\n\t\t \t\t\t<p>" . $description . "</p>\n\t\t \t\t</div>"; } } if ($extra_fields) { foreach ($extra_fields as $fieldname) { if ($row->fields[$fieldname]->display) { $description .= '<br/><b>' . $row->fields[$fieldname]->label . ":</b> " . $row->fields[$fieldname]->display; } } } //$author = $row->created_by_alias ? $row->created_by_alias : $row->author; @($date = $row->created ? date('r', strtotime($row->created)) : ''); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; //$item->author = $author; $item->category = $this->escape($category->title); // loads item info into rss array $doc->addItem($item); } }
function switchLangAssocItem( $args=null ) { $flexiparams = JComponentHelper::getParams('com_flexicontent'); $app = JFactory::getApplication(); $session = JFactory::getSession(); // Execute only in frontend if( $app->isAdmin() ) return; // Execute only if groups enabled and if plugin parameter for switching is enabled if ( !$flexiparams->get('enable_translation_groups') || !$this->params->get('switch_langassociated_items', 1) ) return; // Execute only if some languange switcher is available if ( !FLEXI_J16GE && !FLEXI_FISH ) return; // Execute only if not previewing if (JRequest::getVar('preview') || ( JRequest::getVar('fcu') && JRequest::getVar('fcp') ) ) return; if ( JRequest::getVar('format', 'html') != 'html' ) return; // Get current user language $cntLang = substr(JFactory::getLanguage()->getTag(), 0,2); // Current Content language (Can be natively switched in J2.5) $urlLang = JRequest::getWord('lang', '' ); // Language from URL (Can be switched via Joomfish in J1.5) $curr_lang = (FLEXI_J16GE || empty($urlLang)) ? $cntLang : $urlLang; // Get variables if (FLEXI_FISH) { $view = JRequest::getVar('view'); $option = JRequest::getVar('option'); $task = JRequest::getVar('task'); $item_slug = JRequest::getVar('id'); $item_id = (int) $item_slug; // Execute only if current page is a FLEXIcontent items view (viewing an individual item) if ( $view != FLEXI_ITEMVIEW || $option!='com_flexicontent' ) return; } else if (FLEXI_J16GE) { $menus = $app->getMenu('site', array()); $curr_menu = $menus->getActive(); $curr_menu_isitem = @$menu->query['option']=='com_flexicontent' && @$menu->query['view']==FLEXI_ITEMVIEW && @$menu->query['id']==(int)JRequest::getVar('id'); $curr_menu_iscat = @$menu->query['option']=='com_flexicontent' && @$menu->query['view']=='category' && @$menu->query['cid']==(int)JRequest::getVar('cid'); $flexi_advroute_url = $session->get('flexi_advroute_url'); $view = @$flexi_advroute_url['view']; $option = @$flexi_advroute_url['option']; $task = @$flexi_advroute_url['task']; $cat_slug = @$flexi_advroute_url['cid']; $item_slug = @$flexi_advroute_url['id']; $prev_lang_tag = @$flexi_advroute_url['lang_tag']; $prev_page_ishome = @$flexi_advroute_url['ishome']; $prev_menu_id = @$flexi_advroute_url['menu_id']; $prev_menu_isitem = @$flexi_advroute_url['menu_isitem']; $prev_menu_iscat = @$flexi_advroute_url['menu_iscat']; //print_r($flexi_advroute_url); echo "<br/>"; $curr_lang_tag = JFactory::getLanguage()->getTag(); $curr_page_ishome = $this->detectHomepage(); $curr_menu_id = @$curr_menu->id; if ($this->params->get('debug_lang_switch', 0)) { //$app->enqueueMessage( "Previous Page is HOME: $prev_page_ishome, "."Previous menu item ID: $prev_menu_id<br>", 'message'); //$app->enqueueMessage( "Current Page is HOME: $curr_page_ishome, "."Current menu item ID: $curr_menu_id<br>", 'message'); //$app->enqueueMessage( "Previous language $prev_lang_tag && Current language: $curr_lang_tag<br><br>", 'message'); } // Set variables for next function call (next page load) unset($flexi_advroute_url); $flexi_advroute_url['view'] = JRequest::getVar('view'); $flexi_advroute_url['option'] = JRequest::getVar('option'); $flexi_advroute_url['task'] = JRequest::getVar('task'); $flexi_advroute_url['id'] = JRequest::getVar('id'); $flexi_advroute_url['cid'] = JRequest::getVar('cid'); $flexi_advroute_url['lang_tag']= $curr_lang_tag; $flexi_advroute_url['ishome'] = $curr_page_ishome; $flexi_advroute_url['menu_id'] = $curr_menu_id; $flexi_advroute_url['menu_isitem']= $curr_menu_isitem; $flexi_advroute_url['menu_iscat'] = $curr_menu_iscat; // Set only if current page is a FLEXIcontent item or category view if ( $flexi_advroute_url['view']==FLEXI_ITEMVIEW || $flexi_advroute_url['view']=='category' ) { $session->set('flexi_advroute_url', $flexi_advroute_url); //print_r($flexi_advroute_url); echo "<br/>"; } else if ($prev_lang_tag!=$curr_lang_tag) { // language changed we should clear last flexi url $session->set('flexi_advroute_url', array()); } // Detect if already redirected once, this code must be after the code setting the 'flexi_advroute_url' session variable if ( $session->get('flexi_lang_switched') ) { $session->set('flexi_lang_switched', 0); return; } // Indentify previous and current flexicontent view $prev_page_isitemview = $view==FLEXI_ITEMVIEW && $option=='com_flexicontent'; $prev_page_iscatview = $view=='category' && $option=='com_flexicontent'; $curr_page_isitemview = JRequest::getVar('view')==FLEXI_ITEMVIEW && JRequest::getVar('option')=='com_flexicontent'; $curr_page_iscatview = JRequest::getVar('view')=='category' && JRequest::getVar('option')=='com_flexicontent'; // Execute only if previous page was a FLEXIcontent item or category view if ( !$prev_page_isitemview && !$prev_page_iscatview ) return; // Calculate flags needed to decide action to take $language_changed = $prev_lang_tag!=$curr_lang_tag; $prev_page_isflexi = $prev_page_isitemview || $prev_page_iscatview; $switching_language = $prev_page_isflexi && $curr_page_ishome && $language_changed; // Check Joomla switching language for (a) Home Page menu items OR (b) other language associated menu items if ( $curr_menu && $curr_menu->language!='*' && $curr_menu->language!=$prev_lang_tag ) { // (a) Home Page menu items if ($prev_page_ishome && $curr_page_ishome) { if ($this->params->get('debug_lang_switch', 0)) $app->enqueueMessage( "Joomla language switched Home Page menu items<br><br>", 'message'); $switching_language = false; } // (b) Other language associated menu items else { // Get menu item associations for previously activated menu item require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'menus.php'); $helper = new MenusHelper(); $associated = $helper->getAssociations($prev_menu_id); if ( isset($associated[$curr_lang_tag]) && $associated[$curr_lang_tag] == $curr_menu_id ) { if ($this->params->get('debug_lang_switch', 0)) $app->enqueueMessage( "Associated menu for $prev_menu_id: ".print_r($associated, true)."<br>" , 'message'); if ( ($prev_page_isitemview && !$prev_menu_isitem) || ($prev_page_iscatview && !$prev_menu_iscat) ){ if ($this->params->get('debug_lang_switch', 0)) $app->enqueueMessage( "Joomla language switched associated menu items that did not point to current content: Doing FLEXI switch<br>", 'message'); $switching_language = true; } else { if ($this->params->get('debug_lang_switch', 0)) $app->enqueueMessage( "Joomla language switched associated menu items: that do point to current content: Aborting FLEXI switch<br><br>", 'message'); $switching_language = false; } } } } /*echo "<br>prev_page_isflexi: $prev_page_isflexi, curr_page_ishome: $curr_page_ishome," ."<br>language_changed: $language_changed," ."<br>prev_page_isitemview: $prev_page_isitemview, prev_page_iscatview: $prev_page_iscatview" ."<br>curr_page_isitemview: $curr_page_isitemview, curr_page_iscatview: $curr_page_iscatview";*/ // Decide to execute switching: if ( !$switching_language && // (a) if previous page was a FLEXIcontent view (item or category view) and we switched language !$curr_page_isitemview // (b) if current page is FLEXIcontent item in order to check if language specified is not that of item's language ) return; $cat_id = (int) (($switching_language && $this->params->get('lang_switch_cats', 1)) ? $cat_slug : JRequest::getVar('cid')); $item_id = (int) ($switching_language ? $item_slug : JRequest::getVar('id')); $view = $switching_language ? $view : JRequest::getVar('view'); $option = $switching_language ? $option : JRequest::getVar('option'); $task = $switching_language ? $task : JRequest::getVar('task'); } if ( FLEXI_J16GE && $view=='category' ) { // Execute only if category id is set, and switching for categories is enabled if (!$cat_id) return; if (!$this->params->get('lang_switch_cats', 1)) return; if ($this->params->get('debug_lang_switch', 0)) $app->enqueueMessage( "*** Language switching category no: $cat_id<br><br>", 'message'); $session->set('flexi_lang_switched', 1); $cat_url = JRoute::_( FlexicontentHelperRoute::getCategoryRoute($cat_slug).'&lang='.$curr_lang, false ); $app->redirect( $cat_url ); } if (!$item_id) return; // Execute only if item id is set if ($task=="edit") return; // Execute only if not in item edit form if (!$this->params->get('lang_switch_items', 1)) return; // Execute only if switching for items is enabled // Execute only when not doing a task (e.g. edit) BROKEN !!! DISABLED //if ( !empty(JRequest::getVar('task')) ) return; // Get associated translating item for current language $lta = FLEXI_J16GE || $use_tmp ? 'i': 'ie'; $db = JFactory::getDBO(); $query = "SELECT i.id, CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(':', i.id, i.alias) ELSE i.id END as slug, ".$lta.".language, ie.type_id" . " FROM #__content AS i " . " LEFT JOIN #__flexicontent_items_ext AS ie ON ie.item_id = i.id " . " WHERE " . " ie.language LIKE ".$db->Quote( $curr_lang .'%' )." AND " . " ie.lang_parent_id = (SELECT lang_parent_id FROM #__flexicontent_items_ext WHERE item_id=".(int) $item_id.")"; ; $db->setQuery($query); $translation = $db->loadObject(); if( $db->getErrorNum() ) { $app->enqueueMessage( $db->getErrorMsg(), 'warning'); } if ( !$translation || $item_id==$translation->id ) return; // No associated item translation found if ($this->params->get('debug_lang_switch', 0)) $app->enqueueMessage( "*** Found translation of item {$item_id} for language $curr_lang. <br>Translating item is {$translation->id}<br><br>", 'message'); if (FLEXI_J16GE) { $item_url = JRoute::_( FlexicontentHelperRoute::getItemRoute($translation->slug, $cat_id, 0, $translation), false ); $session->set('flexi_lang_switched', 1); $app->redirect( $item_url ); } else { JRequest::setVar('id', $translation->id); } }
function onDisplayCoreFieldValue(&$_field, &$_item, &$params, $_tags = null, $_categories = null, $_favourites = null, $_favoured = null, $_vote = null, $values = null, $prop = 'display') { $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW)); static $cat_links = array(); static $tag_links = array(); static $cparams = null; if ($cparams === null) { $cparams = JComponentHelper::getParams('com_flexicontent'); } if (!is_array($_item)) { $items = array(&$_item); } else { $items =& $_item; } // Prefix - Suffix - Separator parameters // these parameters should be common so we will retrieve them from the first item instead of inside the loop $item = reset($items); if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } $remove_space = $field->parameters->get('remove_space', 0); $_pretext = $field->parameters->get('pretext', ''); $_posttext = $field->parameters->get('posttext', ''); $separatorf = $field->parameters->get('separatorf', 3); $_opentag = $field->parameters->get('opentag', ''); $_closetag = $field->parameters->get('closetag', ''); $pretext_cacheable = $posttext_cacheable = $opentag_cacheable = $closetag_cacheable = false; switch ($separatorf) { case 0: $separatorf = ' '; break; case 1: $separatorf = '<br />'; break; case 2: $separatorf = ' | '; break; case 3: $separatorf = ', '; break; case 4: $separatorf = $closetag . $opentag; break; case 5: $separatorf = ''; break; default: $separatorf = ' '; break; } foreach ($items as $item) { //if (!is_object($_field)) echo $item->id." - ".$_field ."<br/>"; if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } if ($field->iscore != 1) { continue; } $field->item_id = $item->id; // Replace item properties or values of other fields if (!$pretext_cacheable) { $pretext = FlexicontentFields::replaceFieldValue($field, $item, $_pretext, 'pretext', $pretext_cacheable); if ($pretext && !$remove_space) { $pretext = $pretext . ' '; } } if (!$posttext_cacheable) { $posttext = FlexicontentFields::replaceFieldValue($field, $item, $_posttext, 'posttext', $posttext_cacheable); if ($posttext && !$remove_space) { $posttext = ' ' . $posttext; } } if (!$opentag_cacheable) { $opentag = FlexicontentFields::replaceFieldValue($field, $item, $_opentag, 'opentag', $opentag_cacheable); } // used by some fields if (!$closetag_cacheable) { $closetag = FlexicontentFields::replaceFieldValue($field, $item, $_closetag, 'closetag', $closetag_cacheable); } // used by some fields $field->value = array(); switch ($field->field_type) { case 'created': // created $field->value = array($item->created); // Get date format $customdate = $field->parameters->get('custom_date', 'Y-m-d'); $dateformat = $field->parameters->get('date_format', ''); $dateformat = $dateformat ? JText::_($dateformat) : ($field->parameters->get('lang_filter_format', 0) ? JText::_($customdate) : $customdate); // Add prefix / suffix $field->{$prop} = $pretext . JHTML::_('date', $item->created, $dateformat) . $posttext; // Add microdata property $itemprop = $field->parameters->get('microdata_itemprop', 'dateCreated'); if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } break; case 'createdby': // created by $field->value[] = $item->created_by; $field->{$prop} = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->cuname : $item->creator) . $posttext; break; case 'modified': // modified $field->value = array($item->modified); // Get date format $customdate = $field->parameters->get('custom_date', 'Y-m-d'); $dateformat = $field->parameters->get('date_format', ''); $dateformat = $dateformat ? JText::_($dateformat) : ($field->parameters->get('lang_filter_format', 0) ? JText::_($customdate) : $customdate); // Add prefix / suffix $field->{$prop} = $pretext . JHTML::_('date', $item->modified, $dateformat) . $posttext; // Add microdata property $itemprop = $field->parameters->get('microdata_itemprop', 'dateModified'); if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } break; case 'modifiedby': // modified by $field->value[] = $item->modified_by; $field->{$prop} = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->muname : $item->modifier) . $posttext; break; case 'title': // title $field->value[] = $item->title; $field->{$prop} = $pretext . $item->title . $posttext; // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:title" content="' . $content_val . '" />'); } } // Add microdata property (currently no parameter in XML for this field) $itemprop = $field->parameters->get('microdata_itemprop', 'name'); if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } break; case 'hits': // hits $field->value[] = $item->hits; $field->{$prop} = $pretext . $item->hits . $posttext; break; case 'type': // document type $field->value[] = $item->type_id; $field->{$prop} = $pretext . JText::_($item->typename) . $posttext; break; case 'version': // version $field->value[] = $item->version; $field->{$prop} = $pretext . $item->version . $posttext; break; case 'state': // state $field->value[] = $item->state; $field->{$prop} = $pretext . flexicontent_html::stateicon($item->state, $field->parameters) . $posttext; break; case 'voting': // voting button if ($_vote === false) { $vote =& $item->vote; } else { $vote =& $_vote; } $field->value[] = 'button'; // dummy value to force display $field->{$prop} = $pretext . flexicontent_html::ItemVote($field, 'all', $vote) . $posttext; break; case 'favourites': // favourites button if ($_favourites === false) { $favourites =& $item->favs; } else { $favourites =& $_favourites; } if ($_favoured === false) { $favoured =& $item->fav; } else { $favoured =& $_favoured; } $field->value[] = 'button'; // dummy value to force display $favs = flexicontent_html::favoured_userlist($field, $item, $favourites); $field->{$prop} = $pretext . ' <div class="fav-block"> ' . flexicontent_html::favicon($field, $favoured, $item) . ' <div id="fcfav-reponse_item_' . $item->id . '" class="fcfav-reponse-tip"> <div class="fc-mssg-inline fc-info fc-iblock fc-nobgimage ' . ($favoured ? 'fcfavs-is-subscriber' : 'fcfavs-isnot-subscriber') . '"> ' . JText::_($favoured ? 'FLEXI_FAVS_YOU_HAVE_SUBSCRIBED' : 'FLEXI_FAVS_CLICK_TO_SUBSCRIBE') . ' </div> ' . $favs . ' </div> </div> ' . $posttext; break; case 'categories': // assigned categories $field->{$prop} = ''; if ($_categories === false) { $categories =& $item->cats; } else { $categories =& $_categories; } if ($categories) { // Get categories that should be excluded from linking global $globalnoroute; if (!is_array($globalnoroute)) { $globalnoroute = array(); } // Create list of category links, excluding the "noroute" categories $field->{$prop} = array(); foreach ($categories as $category) { $cat_id = $category->id; if (in_array($cat_id, @$globalnoroute)) { continue; } if (!isset($cat_links[$cat_id])) { $cat_links[$cat_id] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug)); } $cat_link =& $cat_links[$cat_id]; $display = '<a class="fc_categories fc_category_' . $cat_id . ' link_' . $field->name . '" href="' . $cat_link . '">' . $category->title . '</a>'; $field->{$prop}[] = $pretext . $display . $posttext; $field->value[] = $category->title; } $field->{$prop} = implode($separatorf, $field->{$prop}); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } break; case 'tags': // assigned tags $use_catlinks = $cparams->get('tags_using_catview', 0); $field->{$prop} = ''; if ($_tags === false) { $tags =& $item->tags; } else { $tags =& $_tags; } if ($tags) { // Create list of tag links $field->{$prop} = array(); foreach ($tags as $tag) { $tag_id = $tag->id; if (!isset($tag_links[$tag_id])) { $tag_links[$tag_id] = $use_catlinks ? JRoute::_(FlexicontentHelperRoute::getCategoryRoute(0, 0, array('layout' => 'tags', 'tagid' => $tag->slug))) : JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug)); } $tag_link =& $tag_links[$tag_id]; $display = '<a class="fc_tags fc_tag_' . $tag->id . ' link_' . $field->name . '" href="' . $tag_link . '">' . $tag->name . '</a>'; $field->{$prop}[] = $pretext . $display . $posttext; $field->value[] = $tag->name; } $field->{$prop} = implode($separatorf, $field->{$prop}); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } break; case 'maintext': // main text // Special display variables if ($prop != 'display') { switch ($prop) { case 'display_if': $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; break; case 'display_i': $field->{$prop} = $item->introtext; break; case 'display_f': $field->{$prop} = $item->fulltext; break; } } else { if (!$item->fulltext) { $field->{$prop} = $item->introtext; } else { if ($view != FLEXI_ITEMVIEW) { if ($item->parameters->get('force_full', 0)) { $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->{$prop} = $item->introtext; } } else { if ($item->parameters->get('show_intro', 1)) { $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->{$prop} = $item->fulltext; } } } } // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { if ($item->metadesc) { JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $item->metadesc . '" />'); } else { $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $content_val . '" />'); } } } break; } } }
$subcat_cont_class = $show_description_subcat ? "fc_block" : "fc_inline_block"; $subcat_info_class = $show_description_subcat ? "fc_inline_clear" : "fc_inline"; $subcats_html = array(); foreach ($this->categories as $sub) { if (!$show_empty_cats && $show_itemcount && $sub->assigneditems == 0) { continue; } $subsubcount = count($sub->subcats); // a. Optional sub-category image $subcats_html[$i] = "<span class='floattext subcat " . $subcat_cont_class . "'>\n"; if ($show_description_image_subcat && $sub->image) { $subcats_html[$i] .= " <span class='catimg'>" . $sub->image . "</span>\n"; } $subcats_html[$i] .= " <span class='catinfo " . $subcat_info_class . "'>\n"; // b. Category title with link and optional item counts $cat_link = $layout == 'myitems' || $layout == 'author' ? $this->action . (strstr($this->action, '?') ? '&' : '?') . 'cid=' . $sub->slug : JRoute::_(FlexicontentHelperRoute::getCategoryRoute($sub->slug)); $infocount_str = ''; if ($show_itemcount) { $infocount_str .= (int) $sub->assigneditems . $itemcount_label; } if ($show_subcatcount) { $infocount_str .= ($show_itemcount ? ' / ' : '') . count($sub->subcats) . $subcatcount_label; } if (strlen($infocount_str)) { $infocount_str = ' (' . $infocount_str . ')'; } $subcats_html[$i] .= " <a class='catlink' href='" . $cat_link . "'>" . $this->escape($sub->title) . "</a>" . $infocount_str . "</span>\n"; // c. Optional sub-category description stripped of HTML and cut to given length if ($show_description_subcat && $sub->description) { $subcats_html[$i] .= " <span class='catdescription'>" . flexicontent_html::striptagsandcut($sub->description, $description_cut_text_subcat) . "</span>"; }
<?php $html = '<span class="fcpagenav btn-group">'; $tooltip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; // CATEGORY back link if ($use_category_link) { $cat_image = $this->getCatThumb($category, $field->parameters); $limit = $item_count; $limit = $limit ? $limit : 10; $start = floor($location / $limit) * $limit; if (!empty($rows[$item->id]->categoryslug)) { $tooltip = $use_tooltip ? ' title="' . flexicontent_html::getToolTip($category_label, $category->title, 0) . '"' : ''; $html .= ' <a class="fcpagenav-return btn' . ($use_tooltip ? $tooltip_class : '') . '" ' . ($use_tooltip ? $tooltip : '') . ' href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($rows[$item->id]->categoryslug)) . '?start=' . $start . '"> <i class="icon-undo"></i> ' . htmlspecialchars($category->title, ENT_NOQUOTES, 'UTF-8') . ' ' . ($cat_image ? ' <br/><img src="' . $cat_image . '" alt="Return"/> ' : '') . ' </a>'; } } // Next item linking if ($field->prev) { $tooltip = $use_tooltip ? ' title="' . flexicontent_html::getToolTip($tooltip_title_prev, $field->prevtitle, 0) . '"' : ''; $html .= ' <a class="fcpagenav-prev btn' . ($use_tooltip ? $tooltip_class : '') . '" ' . ($use_tooltip ? $tooltip : '') . ' href="' . $field->prevurl . '"> <i class="icon-backward-circle"></i> ' . ($use_title ? $field->prevtitle : htmlspecialchars($prev_label, ENT_NOQUOTES, 'UTF-8')) . ' ' . ($field->prevThumb ? ' <br/><img src="' . $field->prevThumb . '" alt="Previous"/>
/** * 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: 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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&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')) ? '&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')) ? '&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')) ? '&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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&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')) ? '&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')) ? '&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')) ? '&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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&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')) ? '&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')) ? '&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')) ? '&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('&', '&', $_SERVER['REQUEST_URI']); $print_link = $curr_url . (strstr($curr_url, '?') ? '&' : '?') . 'pop=1&tmpl=component&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); } }
/** * Creates the email button * * @param string $print_link * @param array $params * @since 1.0 */ static function mailbutton($view, &$params, $slug = null, $itemslug = null, $item = null) { static $initialize = null; static $uri, $base; if ( !$params->get('show_email_icon') || JRequest::getCmd('print') ) return; if ($initialize === null) { if (file_exists ( JPATH_SITE.DS.'components'.DS.'com_mailto'.DS.'helpers'.DS.'mailto.php' )) { require_once(JPATH_SITE.DS.'components'.DS.'com_mailto'.DS.'helpers'.DS.'mailto.php'); $uri = JURI::getInstance(); $base = $uri->toString( array('scheme', 'host', 'port')); $initialize = true; } else { $initialize = false; } } if ( $initialize === false ) return; //TODO: clean this static stuff (Probs when determining the url directly with subdomains) if($view == 'category') { $link = $base . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($slug)); //$link = $base . JRoute::_( 'index.php?view='.$view.'&cid='.$slug, false ); } elseif($view == FLEXI_ITEMVIEW) { $link = $base . JRoute::_(FlexicontentHelperRoute::getItemRoute($itemslug, $slug, 0, $item)); //$link = $base . JRoute::_( 'index.php?view='.$view.'&cid='.$slug.'&id='.$itemslug, false ); } elseif($view == 'tags') { $link = $base . JRoute::_(FlexicontentHelperRoute::getTagRoute($itemslug)); //$link = $base . JRoute::_( 'index.php?view='.$view.'&id='.$slug, false ); } else { $link = $base . JRoute::_( 'index.php?view='.$view, false ); } $mail_to_url = JRoute::_('index.php?option=com_mailto&tmpl=component&link='.MailToHelper::addLink($link)); $status = 'width=400,height=300,menubar=yes,resizable=yes'; $onclick = ' window.open(this.href,\'win2\',\''.$status.'\'); return false; '; // This checks template image directory for image, if none found, default image is returned $show_icons = $params->get('show_icons'); if ( $show_icons ) { $attribs = ''; $image = FLEXI_J16GE ? JHTML::image(FLEXI_ICONPATH.'emailButton.png', JText::_( 'FLEXI_EMAIL' ), $attribs) : JHTML::_('image.site', 'emailButton.png', FLEXI_ICONPATH, NULL, NULL, JText::_( 'FLEXI_EMAIL' ), $attribs); } else { $image = ''; } $overlib = JText::_( 'FLEXI_EMAIL_TIP' ); $text = JText::_( 'FLEXI_EMAIL' ); $tooltip_class = 'fc_mailbutton'; if ( $show_icons==1 ) { $caption = ''; $tooltip_class .= ' editlinktip'; } else { $caption = $text; $tooltip_class .= FLEXI_J30GE ? ' btn btn-small' : ' fc_button fcsimple fcsmall'; } $tooltip_class .= FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $tooltip_title = flexicontent_html::getToolTip($text, $overlib, 0); // emailed link was set above $output = '<a href="'.$mail_to_url.'" class="'.$tooltip_class.'" title="'.$tooltip_title.'" onclick="'.$onclick.'" >'.$image.$caption.'</a>'; $output = JText::_( 'FLEXI_ICON_SEP' ) .$output. JText::_( 'FLEXI_ICON_SEP' ); return $output; }
function display($tpl = null) { global $globalcats; $app = JFactory::getApplication(); $user = JFactory::getUser(); $document = JFactory::getDocument(); JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR, null, true); // *********************************************************** // Get category data, and check if item is already checked out // *********************************************************** // Get data from the model $model = $this->getModel(); if (FLEXI_J16GE) { $row = $this->get('Item'); $form = $this->get('Form'); } else { $row = $this->get('Category'); } $catparams = new JRegistry($row->params); $cid = $row->id; $isnew = !$cid; // Check category is checked out by different editor / administrator if (!$isnew && $model->isCheckedOut($user->get('id'))) { JError::raiseWarning('SOME_ERROR_CODE', $row->title . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN')); $app->redirect('index.php?option=com_flexicontent&view=categories'); } // *************************************************************************** // Currently access checking for category add/edit form , it is done here, for // most other views we force going though the controller and checking it there // *************************************************************************** // ********************************************************************************************* // Global Permssions checking (needed because this view can be called without a controller task) // ********************************************************************************************* // Get global permissions $perms = FlexicontentHelperPerm::getPerm(); // handles super admins correctly // Check no access to categories management (Global permission) if (!$perms->CanCats) { $app->redirect('index.php?option=com_flexicontent', JText::_('FLEXI_NO_ACCESS')); } // Check no privilege to create new categories (Global permission) if ($isnew && !$perms->CanAddCats) { JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_CREATE')); $app->redirect('index.php?option=com_flexicontent'); } // ************************************************************************************ // Record Permssions (needed because this view can be called without a controller task) // ************************************************************************************ // Get edit privilege for current category if (!$isnew) { if (FLEXI_J16GE) { $isOwner = $row->get('created_by') == $user->id; $rights = FlexicontentHelperPerm::checkAllItemAccess($user->id, 'category', $cid); $canedit_cat = in_array('edit', $rights) || in_array('edit.own', $rights) && $isOwner; } else { if (FLEXI_ACCESS) { $rights = FAccess::checkAllItemAccess('com_content', 'users', $user->gmid, 0, $row->id); $canedit_cat = $user->gid < 25 ? in_array('edit', $rights) || in_array('editown', $rights) : 1; } else { $canedit_cat = true; } } } // Get if we can create inside at least one (com_content) category if ($user->authorise('core.create', 'com_flexicontent')) { $cancreate_cat = true; } else { $usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create'), $require_all = true, $check_published = true, $specific_catids = false, $find_first = true); $cancreate_cat = count($usercats) > 0; } // Creating new category: Check if user can create inside any existing category if ($isnew && !$cancreate_cat) { $acc_msg = JText::_('FLEXI_NO_ACCESS_CREATE') . "<br/>" . (FLEXI_J16GE ? JText::_('FLEXI_CANNOT_ADD_CATEGORY_REASON') : ""); JError::raiseWarning(403, $acc_msg); $app->redirect('index.php?option=com_flexicontent&view=categories'); } // Editing existing category: Check if user can edit existing (current) category if (!$isnew && !$canedit_cat) { $acc_msg = JText::_('FLEXI_NO_ACCESS_EDIT') . "<br/>" . JText::_('FLEXI_CANNOT_EDIT_CATEGORY_REASON'); JError::raiseWarning(403, $acc_msg); $app->redirect('index.php?option=com_flexicontent&view=categories'); } // ************************************************** // Include needed files and add needed js / css files // ************************************************** // Add css to document $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION); // Add JS frameworks flexicontent_html::loadFramework('select2'); // Add js function to overload the joomla submitform validation JHTML::_('behavior.formvalidation'); // load default validation JS to make sure it is overriden $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VERSION); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VERSION); //Load pane behavior jimport('joomla.html.pane'); // ******************** // Initialise variables // ******************** $editor_name = $user->getParam('editor', $app->getCfg('editor')); $editor = JFactory::getEditor($editor_name); $cparams = JComponentHelper::getParams('com_flexicontent'); $categories = $globalcats; $bar = JToolBar::getInstance('toolbar'); $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; // ****************** // Create the toolbar // ****************** // Create Toolbar title and add the preview button if (!$isnew) { JToolBarHelper::title(JText::_('FLEXI_EDIT_CATEGORY'), 'fc_categoryedit'); } else { JToolBarHelper::title(JText::_('FLEXI_NEW_CATEGORY'), 'fc_categoryadd'); } // Add apply and save buttons JToolBarHelper::apply('category.apply', 'FLEXI_APPLY'); /*if ( !$isnew ) flexicontent_html::addToolBarButton( 'FLEXI_FAST_APPLY', $btn_name='apply_ajax', $full_js="Joomla.submitbutton('category.apply_ajax')", $msg_alert='', $msg_confirm='', $btn_task='category.apply_ajax', $extra_js='', $btn_list=false, $btn_menu=true, $btn_confirm=false, $btn_class="", $btn_icon="icon-loop");*/ JToolBarHelper::save('category.save'); // Add a save and new button, if user can create inside at least one (com_content) category if ($cancreate_cat) { JToolBarHelper::save2new('category.save2new'); } // Add a save as copy button, if editing an existing category (J2.5 only) if (!$isnew && $cancreate_cat) { JToolBarHelper::save2copy('category.save2copy'); } // Add a cancel or close button if ($isnew) { JToolBarHelper::cancel('category.cancel'); } else { JToolBarHelper::cancel('category.cancel', 'JTOOLBAR_CLOSE'); } // ****************** // Add preview button // ****************** if (!$isnew) { JToolBarHelper::divider(); $autologin = ''; //$cparams->get('autoflogin', 1) ? '&fcu='.$user->username . '&fcp='.$user->password : ''; $previewlink = JRoute::_(JURI::root() . FlexicontentHelperRoute::getCategoryRoute($categories[$cid]->slug)) . $autologin; // Add a preview button $bar->appendButton('Custom', '<a class="preview btn btn-small btn-info spaced-btn" href="' . $previewlink . '" target="_blank" ><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('Preview') . '</a>', 'preview'); } // ************************ // Add modal layout editing // ************************ if (!$isnew && $perms->CanTemplates) { $inheritcid_comp = $cparams->get('inheritcid', -1); $inheritcid = $catparams->get('inheritcid', ''); $inherit_parent = $inheritcid === '-1' || $inheritcid === '' && $inheritcid_comp; if (!$inherit_parent || $row->parent_id === '1') { $row_clayout = $catparams->get('clayout', $cparams->get('clayout', 'blog')); } else { $row_clayout = $catparams->get('clayout', ''); if (!$row_clayout) { $_ancestors = $this->getModel()->getParentParams($row->id); // This is ordered by level ASC $row_clayout = $cparams->get('clayout', 'blog'); $cats_params = array(); foreach ($_ancestors as $_cid => $_cat) { $cats_params = new JRegistry($_cat->params); $row_clayout = $cats_params->get('clayout', '') ? $cats_params->get('clayout', '') : $row_clayout; } } } flexicontent_html::addToolBarButton('FLEXI_EDIT_LAYOUT', $btn_name = 'apply_ajax', $full_js = "var url = jQuery(this).attr('data-href'); fc_showDialog(url, 'fc_modal_popup_container'); return false;", $msg_alert = '', $msg_confirm = '', $btn_task = 'items.apply_ajax', $extra_js = '', $btn_list = false, $btn_menu = true, $btn_confirm = false, $btn_class = "btn-info" . $tip_class, $btn_icon = "icon-pencil", 'data-placement="bottom" data-href="index.php?option=com_flexicontent&view=template&type=category&tmpl=component&ismodal=1&folder=' . $row_clayout . '" title="Edit the display layout of this category. <br/><br/>Note: this layout maybe assigned to other categories, thus changing it will effect them too"'); } // ******************************************* // Prepare data to pass to the form's template // ******************************************* if (!FLEXI_J16GE) { //clean data JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'description'); // Create the form $form = new JParameter($row->params, JPATH_COMPONENT . DS . 'models' . DS . 'category.xml'); //$form->loadINI($row->attribs); //echo "<pre>"; print_r($form->_xml['templates']->_children[0]); echo "<pre>"; print_r($form->_xml['templates']->param[0]); exit; foreach ($form->_xml['templates']->_children as $i => $child) { if (isset($child->_attributes['enableparam']) && !$cparams->get($child->_attributes['enableparam'])) { unset($form->_xml['templates']->_children[$i]); unset($form->_xml['templates']->param[$i]); } } foreach ($form->_xml['special']->_children as $i => $child) { if (isset($child->_attributes['enableparam']) && !$cparams->get($child->_attributes['enableparam'])) { unset($form->_xml['special']->_children[$i]); unset($form->_xml['special']->param[$i]); } } } // ********************************************************************************** // Get Templates and apply Template Parameters values into the form fields structures // ********************************************************************************** $themes = flexicontent_tmpl::getTemplates(); $tmpls = $themes->category; foreach ($tmpls as $tmpl) { $jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; // ... values applied at the template form file } //build selectlists $Lists = array(); if (!FLEXI_J16GE) { $javascript = "onchange=\"javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='../images/stories/' + document.forms[0].image.options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; $Lists['imagelist'] = JHTML::_('list.images', 'image', $row->image, $javascript, '/images/stories/'); $Lists['access'] = JHTML::_('list.accesslevel', $row); // build granular access list if (FLEXI_ACCESS) { $Lists['access'] = FAccess::TabGmaccess($row, 'category', 1, 1, 1, 1, 1, 1, 1, 1, 1); } } $check_published = false; $check_perms = true; $actions_allowed = array('core.create'); $fieldname = FLEXI_J16GE ? 'jform[parent_id]' : 'parent_id'; $Lists['parent_id'] = flexicontent_cats::buildcatselect($categories, $fieldname, $row->parent_id, $top = 1, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array($row->id)); $check_published = false; $check_perms = true; $actions_allowed = array('core.edit', 'core.edit.own'); $fieldname = FLEXI_J16GE ? 'jform[copycid]' : 'copycid'; $Lists['copycid'] = flexicontent_cats::buildcatselect($categories, $fieldname, '', $top = 2, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = false); $custom_options[''] = 'FLEXI_USE_GLOBAL'; $custom_options['0'] = 'FLEXI_COMPONENT_ONLY'; $custom_options['-1'] = 'FLEXI_PARENT_CAT_MULTI_LEVEL'; $check_published = false; $check_perms = true; $actions_allowed = array('core.edit', 'core.edit.own'); $fieldname = FLEXI_J16GE ? 'jform[special][inheritcid]' : 'params[inheritcid]'; $Lists['inheritcid'] = flexicontent_cats::buildcatselect($categories, $fieldname, $catparams->get('inheritcid', ''), $top = false, 'class="use_select2_lib"', $check_published, $check_perms, $actions_allowed, $require_all = false, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options); // ************************ // Assign variables to view // ************************ $this->assignRef('document', $document); $this->assignRef('Lists', $Lists); $this->assignRef('row', $row); $this->assignRef('form', $form); $this->assignRef('perms', $perms); $this->assignRef('editor', $editor); $this->assignRef('tmpls', $tmpls); $this->assignRef('cparams', $cparams); parent::display($tpl); }
<li class="<?php echo $catid==$currcatid ? 'full' : ($count_cat%2 ? 'even' : 'odd'); ?> <?php echo $classspan; ?>"> <section class="group"> <header class="flexi-cat group"> <?php if (!empty($sub->image) && $this->params->get(($catid!=$currcatid? 'show_description_image_subcat' : 'show_description_image'), 1)) : ?> <!-- BOF subcategory image --> <figure class="catimg"> <?php echo $sub->image; ?> </figure> <!-- EOF subcategory image --> <?php endif; ?> <?php if ($catid!=$currcatid) { ?> <a class='fc_cat_title' href="<?php echo JRoute::_( FlexicontentHelperRoute::getCategoryRoute($sub->slug) ); ?>"> <?php } else { echo "<span class='fc_cat_title'>"; } ?> <!-- BOF subcategory title --> <?php echo $sub->title; ?> <!-- EOF subcategory title --> <?php if ($catid!=$currcatid) { ?> </a> <?php } else { echo "</span>"; } ?> <?php if ($catid!=$currcatid) : ?> <!-- BOF subcategory assigned/subcats_count --> <?php $infocount_str = ''; if ($show_itemcount) $infocount_str .= (int) $sub->assigneditems . $itemcount_label; if ($show_subcatcount) $infocount_str .= ($show_itemcount ? ' / ' : '').count($sub->subcats) . $subcatcount_label; if ($infocount_str) $infocount_str = ' (' . $infocount_str . ')'; ?> <!-- EOF subcategory assigned/subcats_count --> <?php endif; ?>
<?php foreach ($categories as $category) { $catid = $category->id; // Exclude the "noroute" categories (e.g. "Main slideshow", or other special categories that should NOT be displayed !) if (in_array($catid, @$globalnoroute)) { continue; } // Performance concern, only do routing once per category if ($link_to_view && !isset($cat_links[$catid])) { $cat_links[$catid] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug)); } // With / without link $isMain = $catid == $item->catid; $display = $link_to_view ? '<a class="fc_categories fc_category_' . $catid . ' ' . ($isMain ? 'fc_ismain_cat' : '') . ' link_' . $field->name . '" href="' . $cat_links[$catid] . '">' . $category->title . '</a>' : '<span class="fc_categories fc_category_' . $catid . ' ' . ($isMain ? 'fc_ismain_cat' : '') . ' nolink_' . $field->name . '">' . $category->title . '</span>'; $isMain ? array_unshift($field->{$prop}, $pretext . $display . $posttext) : ($field->{$prop}[] = $pretext . $display . $posttext); // Some extra data $field->value[] = $category->title; }
$q = '&q=95'; $zc = $subcat_image_method ? '&zc=' . $subcat_image_method : ''; $ext = 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) . '/' : ''; $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $base_url . $src . $conf; } } if ($image) { $image = '<img class="fcsubcat_image" src="' . $image . '" alt="' . $this->escape($subcat->title) . '" title="' . $this->escape($subcat->title) . '"/>'; } else { //$image = '<div class="fcsubcat_image" style="height:'.$subcat_image_height.'px;width:'.$subcat_image_width.'px;" ></div>'; } if ($subcat_link_image && $image) { $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($subcat->slug)) . '">' . $image . '</a>'; } } ?> <?php if ($image) { ?> <span class="fcsubcat_image_box"><?php echo $image; ?> </span> <?php } ?>
?> <tr class="<?php echo "row{$k}"; ?> "> <td><?php echo $this->pagination->getRowOffset($i); ?> </td> <td width="7"><?php echo $checked; ?> </td> <td width="1%" > <?php $cat_link = str_replace('&', '&', FlexicontentHelperRoute::getCategoryRoute($row->id)); $cat_link = JRoute::_(JURI::root() . $cat_link, $xhtml = false); // xhtml to false we do it manually above (at least the ampersand) also it has no effect because we prepended the root URL ? $previewlink = $cat_link . $autologin; echo '<a class="preview" href="' . $previewlink . '" target="_blank">' . $image_preview . '</a>'; ?> </td> <td width="1%" > <?php $rsslink = $cat_link . '&format=feed&type=rss'; echo '<a class="preview" href="' . $rsslink . '" target="_blank">' . $image_rsslist . '</a>'; ?> </td> <td align="left" class="col_title"> <?php if (FLEXI_J16GE) {
/** * 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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&zc=' . $cat_image_method : ''; $ext = pathinfo($src, PATHINFO_EXTENSION); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&zc=' . $cat_image_method : ''; $ext = 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) . '/' : ''; $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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&zc=' . $cat_image_method : ''; $ext = pathinfo($src, PATHINFO_EXTENSION); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&zc=' . $cat_image_method : ''; $ext = 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) . '/' : ''; $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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&zc=' . $cat_image_method : ''; $ext = pathinfo($src, PATHINFO_EXTENSION); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&zc=' . $cat_image_method : ''; $ext = 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) . '/' : ''; $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, '?') ? '&' : '?') . 'pop=1&tmpl=component&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); } }
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; }
static function createCatLink($slug, &$non_sef_link, $catmodel = null) { $menus = JFactory::getApplication()->getMenu(); $menu = $menus->getActive(); $Itemid = $menu ? $menu->id : 0; // Get URL variables $layout_vars = flexicontent_html::getCatViewLayoutVars($catmodel); $cid = $layout_vars['cid']; $urlvars = array(); if ($layout_vars['layout']) { $urlvars['layout'] = $layout_vars['layout']; } if ($layout_vars['authorid']) { $urlvars['authorid'] = $layout_vars['authorid']; } if ($layout_vars['tagid']) { $urlvars['tagid'] = $layout_vars['tagid']; } if ($layout_vars['cids']) { $urlvars['cids'] = $layout_vars['cids']; } // Category link for single/multiple category(-ies) --OR-- "current layout" link for myitems/author layouts $non_sef_link = FlexicontentHelperRoute::getCategoryRoute($slug, $Itemid, $urlvars); $category_link = JRoute::_($non_sef_link); return $category_link; }
$subcats_html = array(); foreach ($this->categories as $sub) { $subsubcount = count($sub->subcats); // a. Optional sub-category image $subcats_html[$i] = "<span class='floattext subcat ".$subcat_cont_class."'>\n"; if ($show_description_image_subcat && $sub->image) { $subcats_html[$i] .= " <span class='catimg'>".$sub->image."</span>\n"; } $subcats_html[$i] .= " <span class='catinfo ".$subcat_info_class."'>\n"; // b. Category title with link and optional item counts $cat_link = ($layout=='myitems' || $layout=='author') ? $this->action .(strstr($this->action, '?') ? '&' : '?'). 'cid='.$sub->slug : JRoute::_( FlexicontentHelperRoute::getCategoryRoute($sub->slug) ); $infocount_str = ''; if ($show_itemcount) $infocount_str .= (int) $sub->assigneditems . $itemcount_label; if ($show_subcatcount) $infocount_str .= ($show_itemcount ? ' / ' : '').count($sub->subcats) . $subcatcount_label; if (strlen($infocount_str)) $infocount_str = ' (' . $infocount_str . ')'; $subcats_html[$i] .= " <a class='catlink' href='".$cat_link."'>".$this->escape($sub->title)."</a>".$infocount_str."</span>\n"; // c. Optional sub-category description stripped of HTML and cut to given length if ($show_description_subcat && $sub->description) { $subcats_html[$i] .= " <span class='catdescription'>". flexicontent_html::striptagsandcut( $sub->description, $description_cut_text_subcat )."</span>"; } $subcats_html[$i] .= "</span>\n"; // d. Add prefix, suffix to the HTML of current sub-category $subcats_html[$i] = $pretext.$subcats_html[$i].$posttext;
static function getTags(&$params, &$module) { // Initialize $app = JFactory::getApplication(); $cparams = JComponentHelper::getParams('com_flexicontent'); $db = JFactory::getDBO(); $user = JFactory::getUser(); //$now = FLEXI_J16GE ? JFactory::getDate()->toSql() : JFactory::getDate()->toMySQL(); $_nowDate = 'UTC_TIMESTAMP()'; //$db->Quote($now); $nullDate = $db->getNullDate(); $show_noauth = $cparams->get('show_noauth', 0); // Get parameters $minsize = (int) $params->get('min_size', '1'); $maxsize = (int) $params->get('max_size', '10'); $limit = (int) $params->get('count', '25'); $method = (int) $params->get('method', '1'); $scope = $params->get('categories'); $scope = is_array($scope) ? implode(',', $scope) : $scope; $tagitemid = (int) $params->get('force_itemid', 0); $where = !FLEXI_J16GE ? ' WHERE i.sectionid = ' . FLEXI_SECTION : ' WHERE 1 '; $where .= ' AND i.state IN ( 1, -5 )'; $where .= ' AND ( i.publish_up = ' . $db->Quote($nullDate) . ' OR i.publish_up <= ' . $_nowDate . ' )'; $where .= ' AND ( i.publish_down = ' . $db->Quote($nullDate) . ' OR i.publish_down >= ' . $_nowDate . ' )'; $where .= ' AND c.published = 1'; $where .= ' AND tag.published = 1'; // filter by permissions if (!$show_noauth) { $aid_arr = JAccess::getAuthorisedViewLevels($user->id); $aid_list = implode(",", $aid_arr); $where .= ' AND i.access IN (' . $aid_list . ')'; } // category scope if ($method == 2) { // include method $where .= ' AND c.id NOT IN (' . $scope . ')'; } else { if ($method == 3) { // exclude method $where .= ' AND c.id IN (' . $scope . ')'; } } // count Tags $result = array(); $query = 'SELECT COUNT( t.tid ) AS no' . ' FROM #__flexicontent_tags_item_relations AS t' . ' LEFT JOIN #__content AS i ON i.id = t.itemid' . ' LEFT JOIN #__categories AS c ON c.id = i.catid' . ' LEFT JOIN #__flexicontent_tags as tag ON tag.id = t.tid' . $where . ' GROUP BY t.tid' . ' ORDER BY no DESC'; $db->setQuery($query, 0, $limit); $result = FLEXI_J30GE ? $db->loadColumn() : $db->loadResultArray(); //Do we have any tags? if (!$result) { return $result; } $max = (int) $result[0]; $min = (int) $result[sizeof($result) - 1]; $query = 'SELECT tag.id, tag.name, count( rel.tid ) AS no,' . ' CASE WHEN CHAR_LENGTH(tag.alias) THEN CONCAT_WS(\':\', tag.id, tag.alias) ELSE tag.id END as slug' . ' FROM #__flexicontent_tags AS tag' . ' LEFT JOIN #__flexicontent_tags_item_relations AS rel ON rel.tid = tag.id' . ' LEFT JOIN #__content AS i ON i.id = rel.itemid' . ' LEFT JOIN #__categories AS c ON c.id = i.catid' . $where . ' GROUP BY tag.id' . ' HAVING no >= ' . $min . ' ORDER BY tag.name'; $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $use_catlinks = $cparams->get('tags_using_catview', 0); $i = 0; $lists = array(); foreach ($rows as $row) { $lists[$i] = new stdClass(); $lists[$i]->size = modFlexiTagCloudHelper::sizer($min, $max, $row->no, $minsize, $maxsize); $lists[$i]->name = $row->name; $lists[$i]->screenreader = JText::sprintf('FLEXI_NR_ITEMS_TAGGED', $row->no); $lists[$i]->link = $use_catlinks ? FlexicontentHelperRoute::getCategoryRoute(0, $tagitemid, array('layout' => 'tags', 'tagid' => $row->slug)) : FlexicontentHelperRoute::getTagRoute($row->slug, $tagitemid); $lists[$i]->link = JRoute::_($lists[$i]->link . '&module=' . $module->id); $i++; } return $lists; }
$document->addStyleSheet(JURI::base(true) . '/templates/' . $app->getTemplate() . '/css/flexicontent.css'); } } } $form_target = ''; $default_target = $mcats_itemid ? JRoute::_('index.php?Itemid=' . $mcats_itemid) : JURI::base(true) . '/index.php?option=com_flexicontent&view=category&layout=mcats'; // !! target MCATS layout of category view when selecting multiple categories OR selecting single category but no default category set (or no current category) if ($display_cat_list && $mcats_selection || !$catid) { $form_target = $default_target; } else { if ($catid) { $db = JFactory::getDBO(); $query = 'SELECT CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as categoryslug' . ' FROM #__categories AS c WHERE c.id = ' . $catid; $db->setQuery($query); $categoryslug = $db->loadResult(); $form_target = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($categoryslug), false); } } // Render Layout require JModuleHelper::getLayoutPath('mod_flexifilter', $layout); // Add needed js $js = ""; /*if (!$display_cat_list || !empty($selected_cats)) { $js .= ' jQuery(document).ready(function() { jQuery("#'.$form_name.'_filter_box").css("display", "block"); }); '; } $document = JFactory::getDocument(); $document->addScriptDeclaration($js);*/
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { if (!in_array($field->field_type, self::$field_types)) { return; } $field->{$prop} = ''; $option = JRequest::getCmd('option'); $view = JRequest::getString('view', FLEXI_ITEMVIEW); $print = JRequest::getCMD('print'); // No output if it is not FLEXIcontent item view or view is "print" if ($view != FLEXI_ITEMVIEW || $option != 'com_flexicontent' || $print) { return; } // parameters shortcuts $load_css = $field->parameters->get('load_css', 1); $use_tooltip = $field->parameters->get('use_tooltip', 1); $use_title = $field->parameters->get('use_title', 0); $use_category_link = $field->parameters->get('use_category_link', 0); $show_prevnext_count = $field->parameters->get('show_prevnext_count', 1); $tooltip_title_next = JText::_($field->parameters->get('tooltip_title_next', 'FLEXI_FIELDS_PAGENAV_GOTONEXT')); $tooltip_title_prev = JText::_($field->parameters->get('tooltip_title_prev', 'FLEXI_FIELDS_PAGENAV_GOTOPREV')); $prev_label = JText::_($field->parameters->get('prev_label', 'FLEXI_FIELDS_PAGENAV_GOTOPREV')); $next_label = JText::_($field->parameters->get('next_label', 'FLEXI_FIELDS_PAGENAV_GOTONEXT')); $category_label = JText::_($field->parameters->get('category_label', 'FLEXI_FIELDS_PAGENAV_CATEGORY')); $cid = JRequest::getInt('cid'); $cid = $cid ? $cid : (int) $item->catid; // Get active category parameters $db = JFactory::getDBO(); $query = 'SELECT * FROM #__categories WHERE id = ' . $cid; $db->setQuery($query); $catdata = $db->loadObject(); $catdata->parameters = FLEXI_J16GE ? new JRegistry($catdata->params) : new JParameter($catdata->params); // Get list of ids of selected, TODO retrieve item ids from view: // --> this will allow special navigating layouts "mcats,author,myitems,tags,favs" and also utilize current filtering $ids = null; $list = $this->getItemList($field, $item, $ids, $cid, $catdata->parameters); // Location of current content item in array list $loc_to_ids = array_keys($list); $ids_to_loc = array_flip($loc_to_ids); $location = isset($ids_to_loc[$item->id]) ? $ids_to_loc[$item->id] : false; // Get previous and next item data $field->prev = null; $field->prevtitle = null; $field->prevurl = null; $field->next = null; $field->nexttitle = null; $field->nexturl = null; $field->category = null; $field->categorytitle = null; $field->categoryurl = null; // Get item data $rows = false; $prev_id = null; $next_id = null; if ($location !== false) { $prev_id = $location - 1 >= 0 ? $loc_to_ids[$location - 1] : null; $next_id = $location + 1 < count($list) ? $loc_to_ids[$location + 1] : null; $ids = array(); // Previous item if it exists if ($prev_id) { $ids[] = $prev_id; } // Current item may belong may not be list in main category so retrieve it to get a proper categoryslug $ids[] = $item->id; // Next item if it exists if ($next_id) { $ids[] = $next_id; } // Query specific ids $rows = $this->getItemList($field, $item, $ids, $cid, $catdata->parameters); // previous content item if ($prev_id) { $field->prev = $rows[$prev_id]; $field->prevtitle = $field->prev->title; $field->prevurl = JRoute::_(FlexicontentHelperRoute::getItemRoute($field->prev->slug, $field->prev->categoryslug, 0, $field->prev)); } // next content item if ($next_id) { $field->next = $rows[$next_id]; $field->nexttitle = $field->next->title; $field->nexturl = JRoute::_(FlexicontentHelperRoute::getItemRoute($field->next->slug, $field->next->categoryslug, 0, $field->next)); } } // Check if displaying nothing and stop if (!$field->prev && !$field->next && !$use_category_link) { return; } $html = '<span class="flexi fc-pagenav">'; $tooltip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; // CATEGORY back link if ($use_category_link) { $cat_image = $this->getCatThumb($catdata, $field->parameters); $limit = count($list); $limit = $limit ? $limit : 10; $start = floor($location / $limit) * $limit; if (!empty($rows[$item->id]->categoryslug)) { $html .= ' <span class="fc-pagenav-return"> <a class="btn btn-info" href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($rows[$item->id]->categoryslug)) . '?start=' . $start . '">' . htmlspecialchars($category_label, ENT_NOQUOTES, 'UTF-8') . ($cat_image ? ' <br/> <img src="' . $cat_image . '" alt="Return"/>' : '') . ' </a> </span>'; } } // Item location and total count $html .= $show_prevnext_count ? '<span class="fc-pagenav-items-cnt badge badge-info">' . ($location + 1) . '/' . count($list) . '</span>' : ''; // Get images $items_arr = array(); if ($field->prev) { $items_arr[$field->prev->id] = $field->prev; } if ($field->next) { $items_arr[$field->next->id] = $field->next; } $thumbs = $this->getItemThumbs($field->parameters, $items_arr); // Next item linking if ($field->prev) { $tooltip = $use_tooltip ? ' title="' . flexicontent_html::getToolTip($tooltip_title_prev, $field->prevtitle, 0) . '"' : ''; $html .= ' <span class="fc-pagenav-prev' . ($use_tooltip ? $tooltip_class : '') . '" ' . ($use_tooltip ? $tooltip : '') . '> <a class="btn" href="' . $field->prevurl . '"> <i class="icon-previous"></i> ' . ($use_title ? $field->prevtitle : htmlspecialchars($prev_label, ENT_NOQUOTES, 'UTF-8')) . ' ' . (isset($thumbs[$field->prev->id]) ? ' <br/> <img src="' . $thumbs[$field->prev->id] . '" alt="Previous"/> ' : '') . ' </a> </span>'; } else { $html .= ' <span class="fc-pagenav-prev"> <span class="btn disabled"> <i class="icon-previous"></i> ' . htmlspecialchars($prev_label, ENT_NOQUOTES, 'UTF-8') . ' </span> </span>'; } // Previous item linking if ($field->next) { $tooltip = $use_tooltip ? ' title="' . flexicontent_html::getToolTip($tooltip_title_next, $field->nexttitle, 0) . '"' : ''; $html .= ' <span class="fc-pagenav-next' . ($use_tooltip ? $tooltip_class : '') . '" ' . ($use_tooltip ? $tooltip : '') . '> <a class="btn" href="' . $field->nexturl . '"> <i class="icon-next"></i> ' . ($use_title ? $field->nexttitle : htmlspecialchars($next_label, ENT_NOQUOTES, 'UTF-8')) . ' ' . (isset($thumbs[$field->next->id]) ? ' <br/> <img src="' . $thumbs[$field->next->id] . '" alt="Next"/> ' : '') . ' </a> </span>'; } else { $html .= ' <span class="fc-pagenav-next"> <span class="btn disabled"> <i class="icon-next"></i> ' . htmlspecialchars($next_label, ENT_NOQUOTES, 'UTF-8') . ' </span> </span>'; } $html .= '</span>'; // Load needed JS/CSS if ($use_tooltip) { FLEXI_J30GE ? JHtml::_('bootstrap.tooltip') : JHTML::_('behavior.tooltip'); } if ($load_css) { JFactory::getDocument()->addStyleSheet(JURI::root(true) . '/plugins/flexicontent_fields/fcpagenav/' . (FLEXI_J16GE ? 'fcpagenav/' : '') . 'fcpagenav.css'); } $field->{$prop} = $html; }
/** * Creates the RSS for the View * * @since 1.0 */ function display($tpl = null) { $db = JFactory::getDBO(); $doc = JFactory::getDocument(); $app = JFactory::getApplication(); $params = $this->get('Params'); $doc->link = JRoute::_('index.php?option=com_flexicontent&view=flexicontent&rootcat=' . (int) $params->get('rootcat', FLEXI_J16GE ? 1 : 0)); JRequest::setVar('limit', $params->get('feed_limit')); // Force a specific limit, this will be moved to the model $cats = $this->get('Feed'); //$feed_summary = $params->get('feed_summary', 0); $feed_summary_cut = $params->get('feed_summary_cut', 200); $feed_use_image = $params->get('feed_use_image', 1); $feed_image_source = $params->get('feed_image_source', ''); $feed_link_image = $params->get('feed_link_image', 1); $feed_image_method = $params->get('feed_image_method', 1); $feed_image_width = $params->get('feed_image_width', 100); $feed_image_height = $params->get('feed_image_height', 80); // Retrieve default image for the image field if ($feed_use_image && $feed_image_source) { $query = 'SELECT attribs, name FROM #__flexicontent_fields WHERE id = ' . (int) $feed_image_source; $db->setQuery($query); $image_dbdata = $db->loadObject(); //$image_dbdata->params = FLEXI_J16GE ? new JRegistry($image_dbdata->params) : new JParameter($image_dbdata->params); $img_size_map = array('l' => 'large', 'm' => 'medium', 's' => 'small', '' => ''); $img_field_size = $img_size_map[$image_size]; $img_field_name = $image_dbdata->name; } foreach ($cats as $cat) { // strip html from feed item title $title = $this->escape($cat->title); $title = html_entity_decode($title); // url link to article // & used instead of & as this is converted by feed creator $link = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)); // strip html from feed item description text $description = $cat->description; //$feed_summary ? $cat->description : ''; $description = flexicontent_html::striptagsandcut($description, $feed_summary_cut); if ($feed_use_image) { // feed image is enabled // Get some variables $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; $thumb = ""; if ($cat->id && $show_cat_image) { $cat->image = FLEXI_J16GE ? $params->get('image') : $cat->image; $thumb = ""; $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 = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&zc=' . $cat_image_method : ''; $ext = pathinfo($src, PATHINFO_EXTENSION); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $thumb = 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 = '&h=' . $feed_image_height; $w = '&w=' . $feed_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $feed_image_method ? '&zc=' . $feed_image_method : ''; $ext = 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) . '/' : ''; $src = $base_url . $src; $thumb = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf; } } } if ($thumb) { $description = "<a href='" . $link . "'><img src='" . $thumb . "' alt='" . $title . "' title='" . $title . "' align='left'/></a><p>" . $description . "</p>"; } } //$author = $cat->created_by_alias ? $cat->created_by_alias : $cat->author; @($date = $cat->created ? date('r', strtotime($cat->created)) : ''); // load individual item creator class $item = new JFeedItem(); $item->title = $title . ' (' . (int) $cat->assigneditems . ')'; $item->link = $link; $item->description = $description; $item->date = $date; //$item->author = $author; //$item->category = $this->escape( $category->title ); // loads item info into rss array $doc->addItem($item); } }
$zc = $cat_image_method ? '&zc=' . $cat_image_method : ''; $phpThumbURL = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src='; } if ($cat_default_image) { $src = JURI::base(true) . "/" . $joomla_image_url . $cat_default_image; $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION)); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $default_image = $phpThumbURL . $src . $conf; $default_image = '<img src="' . $default_image . '" alt="%s" title="%s"/>'; } else { $default_image = ''; } foreach ($list as $cat) { $cat->slug = $cat->id . ':' . $cat->alias; $cat->link = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)); $image = ""; $src = ""; 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 = JURI::base(true) . "/" . $joomla_image_url . $cat->image; $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION)); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; } else {