function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { // execute the code only if the field type match the plugin type if (!in_array($field->field_type, self::$field_types)) { return; } // Get isMobile / isTablet Flags static $isMobile = null; static $isTablet = null; static $useMobile = null; if ($useMobile === null) { $cparams = JComponentHelper::getParams('com_flexicontent'); $force_desktop_layout = $cparams->get('force_desktop_layout', 0); //$start_microtime = microtime(true); $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile; //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000); } $field->label = JText::_($field->label); // some parameter shortcuts $target = $field->parameters->get('targetblank', 0); $target_param = $target ? ' target="_blank"' : ''; $display_hits = $field->parameters->get('display_hits', 0); $add_hits_img = $display_hits == 1 || $display_hits == 3; $add_hits_txt = $display_hits == 2 || $display_hits == 3 || $isMobile; $rel_nofollow = $field->parameters->get('add_rel_nofollow', 0) ? ' rel="nofollow"' : ''; // This is field 's MAIN value property $link_usage = $field->parameters->get('link_usage', 0); $default_link = $link_usage == 2 ? $field->parameters->get('default_value_link', '') : ''; // Optional value properties $usetitle = $field->parameters->get('use_title', 0); $title_usage = $field->parameters->get('title_usage', 0); $default_title = $title_usage == 2 ? JText::_($field->parameters->get('default_value_title', '')) : ''; // Get field values $values = $values ? $values : $field->value; // DO NOT terminate yet if value is empty since a default value on empty may have been defined // Handle default value loading, instead of empty value if (empty($values) && !strlen($default_link)) { $field->{$prop} = ''; return; } else { if (empty($values) && strlen($default_link)) { $values = array(); $values[0]['link'] = JText::_($default_link); $values[0]['title'] = JText::_($default_title); $values[0]['hits'] = 0; $values[0] = serialize($values[0]); } } // Value handling parameters $multiple = $field->parameters->get('allow_multiple', 1); // Prefix - Suffix - Separator parameters, replacing other field values if found $remove_space = $field->parameters->get('remove_space', 0); $pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('pretext', ''), 'pretext'); $posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('posttext', ''), 'posttext'); $separatorf = $field->parameters->get('separatorf', 1); $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag'); $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag'); if ($pretext) { $pretext = $remove_space ? $pretext : $pretext . ' '; } if ($posttext) { $posttext = $remove_space ? $posttext : ' ' . $posttext; } 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; } // Optimization, do some stuff outside the loop static $hits_icon = null; if ($hits_icon === null && ($display_hits == 1 || $display_hits == 3)) { $_attribs = $display_hits == 1 ? 'class="hasTip" title=":: %s ' . JText::_('FLEXI_HITS', true) . '"' : ''; $hits_icon = FLEXI_J16GE ? JHTML::image('components/com_flexicontent/assets/images/' . 'user.png', JText::_('FLEXI_HITS'), $_attribs) : JHTML::_('image.site', 'user.png', 'components/com_flexicontent/assets/images/', NULL, NULL, JText::_('FLEXI_HITS'), $_attribs); } // needed for backend display //if ($display_hits) // $isAdmin = JFactory::getApplication()->isAdmin(); // initialise property $field->{$prop} = array(); $n = 0; foreach ($values as $value) { if (!strlen($value)) { continue; } // Compatibility for old unserialized values if (@unserialize($value) !== false || $value === 'b:0;') { $value = unserialize($value); } else { $value = array('link' => $value, 'title' => '', 'hits' => 0); } if (empty($value['link'])) { continue; } // no link ... // If not using property or property is empty, then use default property value // NOTE: default property values have been cleared, if (propertyname_usage != 2) $title = $usetitle && @$value['title'] ? $value['title'] : $default_title; $hits = (int) @$value['hits']; $link_params = $title ? ' title="' . $title . '"' : ''; $link_params .= $target_param; $link_params .= $rel_nofollow; if ($field->parameters->get('use_direct_link', 0)) { // Direct access to the web-link, hits counting not possible $href = $value['link']; } else { // Indirect access to the web-link, via calling FLEXIcontent component, thus counting hits too $href = JRoute::_('index.php?option=com_flexicontent&fid=' . $field->id . '&cid=' . $field->item_id . '&ord=' . ($n + 1) . '&task=weblink'); } // Create indirect link to web-link address with custom displayed text $linktext = $title ? $title : $this->cleanurl($value['link']); $field->{$prop}[$n] = $pretext . '<a href="' . $href . '" ' . $link_params . '>' . $linktext . '</a>' . $posttext; // HITS: either as icon or as inline text or both $hits_html = ''; if ($display_hits && $hits) { $hits_html = '<span class="fcweblink_hits">'; if ($add_hits_img && @$hits_icon) { $hits_html .= sprintf($hits_icon, $hits); } if ($add_hits_txt) { $hits_html .= '(' . $hits . ' ' . JTEXT::_('FLEXI_HITS') . ')'; } $hits_html .= '</span>'; if ($prop == 'display_hitsonly') { $field->{$prop}[$n] = $hits_html; } else { $field->{$prop}[$n] .= ' ' . $hits_html; } } $n++; if (!$multiple) { break; } // multiple values disabled, break out of the loop, not adding further values even if the exist } // Apply seperator and open/close tags if (count($field->{$prop})) { $field->{$prop} = implode($separatorf, $field->{$prop}); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } else { $field->{$prop} = ''; } }
/** * Method to decide which item layout to use * * @access public * @param int item identifier */ function decideLayout(&$params) { // ********************************************************************************* // Get category layout from configuration if not already set (e.g. via HTTP Request) // ********************************************************************************* //echo "decideLayout: ". $this->_clayout ."<br/>"; $clayout = $this->_clayout; if (!$clayout) { // 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; } $desktop_clayout = $params->get('clayout', 'blog'); $clayout = !$useMobile ? $desktop_clayout : $params->get('clayout_mobile', $desktop_clayout); } // Get cached template data, without loading language file, (this will be done at the view) $themes = flexicontent_tmpl::getTemplates(null); // ********************************* // Verify the category layout exists // ********************************* if (!isset($themes->category->{$clayout})) { $cat_default_layout = 'blog'; // Layout default $fixed_clayout = isset($themes->category->{$cat_default_layout}) ? $cat_default_layout : 'default'; JFactory::getApplication()->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 } // ***************************************************************************************** // Finally set the clayout (template name) into model / category's parameters / HTTP Request // ***************************************************************************************** $this->setCatLayout($clayout); $params->set('clayout', $clayout); JRequest::setVar('clayout', $clayout); }
/** * Method to decide which item layout to use * * @access public * @param int item identifier */ function decideLayout(&$compParams, &$typeParams, &$itemParams) { // Decide to use mobile or normal item template layout $useMobile = $compParams->get('use_mobile_layouts', 0); if ($useMobile) { $force_desktop_layout = $compParams->get('force_desktop_layout', 0); $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile; } $_ilayout = $useMobile ? 'ilayout_mobile' : 'ilayout'; // Get item layout (... if not already set), from the configuration parameter (that was decided above) $ilayout = $this->_ilayout == '__request__' ? JRequest::getVar($_ilayout, false) : false; if (!$ilayout) { $desktop_ilayout = $itemParams->get('ilayout', $typeParams->get('ilayout', 'default')); $ilayout = !$useMobile ? $desktop_ilayout : $itemParams->get('ilayout_mobile', $typeParams->get('ilayout_mobile', $desktop_ilayout)); } // Verify the layout is within allowed templates, that is Content Type 's default template OR Content Type allowed templates $allowed_tmpls = $typeParams->get('allowed_ilayouts'); $type_default_layout = $typeParams->get('ilayout', 'default'); if (empty($allowed_tmpls)) { $allowed_tmpls = array(); } else { if (!is_array($allowed_tmpls)) { $allowed_tmpls = explode("|", $allowed_tmpls); } } // Verify the item layout is within templates: Content Type default template OR Content Type allowed templates if ($ilayout != $type_default_layout && count($allowed_tmpls) && !in_array($ilayout, $allowed_tmpls)) { $app->enqueueMessage("<small>Current item Layout (template) is '{$ilayout}':<br/>- This is neither the Content Type Default Template, nor does it belong to the Content Type allowed templates.<br/>- Please correct this in the URL or in Content Type configuration.<br/>- Using Content Type Default Template Layout: '{$type_default_layout}'</small>", 'notice'); $ilayout = $type_default_layout; } // Get cached template data, without loading language file, (this will be done at the view) $themes = flexicontent_tmpl::getTemplates(null); // Verify the item layout exists if (!isset($themes->items->{$ilayout})) { $fixed_ilayout = isset($themes->items->{$type_default_layout}) ? $type_default_layout : 'default'; $app->enqueueMessage("<small>Current Item Layout Template is '{$ilayout}' does not exist<br/>- Please correct this in the URL or in Content Type configuration.<br/>- Using Template Layout: '{$fixed_ilayout}'</small>", 'notice'); $ilayout = $fixed_ilayout; FLEXIUtilities::loadTemplateLanguageFile($ilayout); // Manually load Template-Specific language file of back fall ilayout } // Finally set the ilayout (template name) into model / item's parameters / HTTP Request $this->setItemLayout($ilayout); $itemParams->set('ilayout', $ilayout); JRequest::setVar('ilayout', $ilayout); }
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { if (!in_array($field->field_type, self::$field_types)) { return; } $field->label = JText::_($field->label); // Some variables $is_ingroup = !empty($field->ingroup); $use_ingroup = $field->parameters->get('use_ingroup', 0); $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0); $image_source = $field->parameters->get('image_source', 0); // *********************** // One time initialization // *********************** static $initialized = null; static $app, $document, $option; static $isMobile, $isTablet, $useMobile; if ($initialized === null) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $option = JRequest::getVar('option'); jimport('joomla.filesystem'); // ***************************** // Get isMobile / isTablet Flags // ***************************** $cparams = JComponentHelper::getParams('com_flexicontent'); $force_desktop_layout = $cparams->get('force_desktop_layout', 0); //$start_microtime = microtime(true); $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile; //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000); } // ********************************************** // Static FLAGS indicating if JS libs were loaded // ********************************************** static $multiboxadded = false; static $fancyboxadded = false; static $gallerifficadded = false; static $elastislideadded = false; static $photoswipeadded = false; // ***************************** // Current view variable / FLAGs // ***************************** $realview = JRequest::getVar('view', FLEXI_ITEMVIEW); $view = JRequest::getVar('flexi_callview', $realview); $isFeedView = JRequest::getCmd('format', null) == 'feed'; $isItemsManager = $app->isAdmin() && $realview == 'items' && $option == 'com_flexicontent'; $isSite = $app->isSite(); // ************************************************* // TODO: implement MODES >= 2, and remove this CODE // ************************************************* if ($image_source > 1) { global $fc_folder_mode_err; if (empty($fc_folder_mode_err[$field->id])) { echo __FUNCTION__ . "(): folder-mode: " . $image_source . " not implemented please change image-source mode in image/gallery field with id: " . $field->id; $fc_folder_mode_err[$field->id] = 1; $image_source = 1; } } $all_media = $field->parameters->get('list_all_media_files', 0); $unique_thumb_method = $field->parameters->get('unique_thumb_method', 0); $dir = $field->parameters->get('dir'); $dir_url = str_replace('\\', '/', $dir); // Check if using folder of original content being translated $of_usage = $field->untranslatable ? 1 : $field->parameters->get('of_usage', 0); $u_item_id = $of_usage && $item->lang_parent_id && $item->lang_parent_id != $item->id ? $item->lang_parent_id : $item->id; // FLAG to indicate if images are shared across fields, has the effect of adding field id to image thumbnails $multiple_image_usages = !$image_source && $all_media && $unique_thumb_method == 0; $extra_prefix = $multiple_image_usages ? 'fld' . $field->id . '_' : ''; $usealt = $field->parameters->get('use_alt', 1); $alt_usage = $field->parameters->get('alt_usage', 0); $default_alt = $alt_usage == 2 ? $field->parameters->get('default_alt', '') : ''; $usetitle = $field->parameters->get('use_title', 1); $title_usage = $field->parameters->get('title_usage', 0); $default_title = $title_usage == 2 ? JText::_($field->parameters->get('default_title', '')) : ''; $usedesc = $field->parameters->get('use_desc', 1); $desc_usage = $field->parameters->get('desc_usage', 0); $default_desc = $desc_usage == 2 ? $field->parameters->get('default_desc', '') : ''; $usecust1 = $field->parameters->get('use_cust1', 0); $cust1_usage = $field->parameters->get('cust1_usage', 0); $default_cust1 = $cust1_usage == 2 ? JText::_($field->parameters->get('default_cust1', '')) : ''; $usecust2 = $field->parameters->get('use_cust2', 0); $cust2_usage = $field->parameters->get('cust2_usage', 0); $default_cust2 = $cust2_usage == 2 ? JText::_($field->parameters->get('default_cust2', '')) : ''; // Separators / enclosing characters $remove_space = $field->parameters->get('remove_space', 0); $pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('pretext', ''), 'pretext'); $posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('posttext', ''), 'posttext'); $separatorf = $field->parameters->get('separatorf', 0); $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag'); $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag'); if ($pretext) { $pretext = $remove_space ? $pretext : $pretext . ' '; } if ($posttext) { $posttext = $remove_space ? $posttext : ' ' . $posttext; } 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; } // ************************************************** // SETUP VALUES: retrieve, verify, load defaults, etc // ************************************************** $values = $values ? $values : $field->value; // Intro-full mode get their values from item's parameters if ($image_source == -1) { $values = array(); $_image_name = $view == 'item' ? 'fulltext' : 'intro'; if ($item->images) { if (!is_object($item->images)) { $item->images = new JRegistry($item->images); } //echo "<pre>"; print_r($item->images); echo "</pre>"; $_image_path = $item->images->get('image_' . $_image_name, ''); $image_by_params = array(); // field attributes (mode-specific) $image_by_params['image_size'] = $_image_name; $image_by_params['image_path'] = $_image_path; // field attributes (value) $image_by_params['originalname'] = basename($_image_path); $image_by_params['alt'] = $item->images->get('image_' . $_image_name . '_alt', ''); $image_by_params['title'] = $item->images->get('image_' . $_image_name . '_alt', ''); $image_by_params['desc'] = $item->images->get('image_' . $_image_name . '_caption', ''); $image_by_params['cust1'] = ''; $image_by_params['cust2'] = ''; $image_by_params['urllink'] = ''; $values = array(serialize($image_by_params)); //echo "<pre>"; print_r($image_by_params); echo "</pre>"; exit; } } // Check for deleted image files or image files that cannot be thumbnailed, // rebuilding thumbnails as needed, and then assigning checked values to a new array $usable_values = array(); if ($values) { foreach ($values as $index => $value) { $value = unserialize($value); if (plgFlexicontent_fieldsImage::rebuildThumbs($field, $value, $item)) { $usable_values[] = $values[$index]; } } } $values =& $usable_values; // Allow for thumbnailing of the default image $field->using_default_value = false; if (!count($values)) { // Create default image to be used if (a) no image assigned OR (b) images assigned have been deleted $default_image = $field->parameters->get('default_image', ''); if ($default_image) { $default_image_val = array(); // field attributes (default value specific) $default_image_val['default_image'] = $default_image; // holds complete relative path and indicates that it is default image for field // field attributes (value) $default_image_val['originalname'] = basename($default_image); $default_image_val['alt'] = $default_alt; $default_image_val['title'] = $default_title; $default_image_val['desc'] = $default_desc; $default_image_val['cust1'] = $default_cust1; $default_image_val['cust2'] = $default_cust2; $default_image_val['urllink'] = ''; // Create thumbnails for default image if (plgFlexicontent_fieldsImage::rebuildThumbs($field, $default_image_val, $item)) { $values = array(serialize($default_image_val)); } // Also default image can (possibly) be used across multiple fields, so set flag to add field id to filenames of thumbnails $multiple_image_usages = true; $extra_prefix = 'fld' . $field->id . '_'; $field->using_default_value = true; } } // ********************************************* // Check for no values, and return empty display // ********************************************* if (!count($values)) { $field->{$prop} = $is_ingroup ? array() : ''; return; } // Assign (possibly) altered value array to back to the field $field->value = $values; // This is not done for onDisplayFieldValue, TODO check if this is needed // ************************************** // Default display method depends on view // ************************************** if ($prop == 'display' && ($view == FLEXI_ITEMVIEW || $view == 'category')) { $_method = $view == FLEXI_ITEMVIEW ? $field->parameters->get('default_method_item', 'display') : $field->parameters->get('default_method_cat', 'display_single_total'); } else { $_method = $prop; } $cat_link_single_to = $field->parameters->get('cat_link_single_to', 1); // Calculate some flags, SINGLE image display and Link-to-Item FLAG $isSingle = isset(self::$single_displays[$_method]); $linkToItem = $_method == 'display_link' || $_method == 'display_single_link' || $_method == 'display_single_total_link' || $view != 'item' && $cat_link_single_to && $isSingle; // ************************ // JS gallery configuration // ************************ $usepopup = (int) $field->parameters->get('usepopup', 1); // use JS gallery $popuptype = (int) $field->parameters->get('popuptype', 1); // JS gallery type // Different for mobile clients $popuptype_mobile = (int) $field->parameters->get('popuptype_mobile', $popuptype); // this defaults to desktop when empty $popuptype = $useMobile ? $popuptype_mobile : $popuptype; // Enable/Disable GALLERY JS according to current view and according to other parameters $popupinview = $field->parameters->get('popupinview', array(FLEXI_ITEMVIEW, 'category', 'backend')); $popupinview = FLEXIUtilities::paramToArray($popupinview); if ($view == FLEXI_ITEMVIEW && !in_array(FLEXI_ITEMVIEW, $popupinview)) { $usepopup = 0; } if ($view == 'category' && !in_array('category', $popupinview)) { $usepopup = 0; } if ($view == 'module' && !in_array('module', $popupinview)) { $usepopup = 0; } if ($isItemsManager && !in_array('backend', $popupinview)) { $usepopup = 0; } // Enable/Disable GALLERY JS if linking to item view if ($linkToItem) { $usepopup = 0; } // Only allow multibox and fancybox in items manager, in other cases force fancybox if ($isItemsManager && !in_array($popuptype, array(1, 4))) { $popuptype = 4; } // Displays that need special container are not allowed when field in a group, force fancybox $no_container_needed = array(1, 2, 3, 4, 6); if ($is_ingroup && !in_array($popuptype, $no_container_needed)) { $popuptype = 4; } // Optionally group images from all image fields of current item ... or of all items in view too $grouptype = $field->parameters->get('grouptype', 1); $grouptype = $multiple ? 0 : $grouptype; // Field in gallery mode: Force grouping of images per field (current item) // Needed by some js galleries $thumb_w_s = $field->parameters->get('w_s', 120); $thumb_h_s = $field->parameters->get('h_s', 90); // ****************************** // Hovering ToolTip configuration // ****************************** $uselegend = $field->parameters->get('uselegend', 1); $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; // Enable/disable according to current view $legendinview = $field->parameters->get('legendinview', array(FLEXI_ITEMVIEW, 'category')); $legendinview = FLEXIUtilities::paramToArray($legendinview); if ($view == FLEXI_ITEMVIEW && !in_array(FLEXI_ITEMVIEW, $legendinview)) { $uselegend = 0; } if ($view == 'category' && !in_array('category', $legendinview)) { $uselegend = 0; } if ($isItemsManager && !in_array('backend', $legendinview)) { $uselegend = 0; } // load the tooltip library if required if ($uselegend && !FLEXI_J30GE) { JHTML::_('behavior.tooltip'); } // ************************************** // Title/Description in inline thumbnails // ************************************** $showtitle = $field->parameters->get('showtitle', 0); $showdesc = $field->parameters->get('showdesc', 0); // ************************* // Link to URL configuration // ************************* $linkto_url = $field->parameters->get('linkto_url', 0); $url_target = $field->parameters->get('url_target', '_self'); $isLinkToPopup = $linkto_url && ($url_target == 'multibox' || $url_target == 'fancybox'); // Force opening in new window in backend, if URL target is _self if ($isItemsManager && $url_target == '_self') { $url_target = "_blank"; } // Only allow multibox (and TODO: add fancybox) when linking to URL, in other cases force fancybox if ($isLinkToPopup && $url_target == 'multibox') { $popuptype = 1; } if ($isLinkToPopup && $url_target == 'fancybox') { $popuptype = 4; } else { if ($linkto_url) { $usepopup = 0; } } // ************************************ // Social website sharing configuration // ************************************ $useogp = $field->parameters->get('useogp', 0); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpthumbsize = $field->parameters->get('ogpthumbsize', 2); // ********************************************** // Load the configured (or the forced) JS gallery // ********************************************** // Do not load JS, for value only displays if (!isset(self::$value_only_displays[$prop])) { // MultiBox maybe added in extra cases besides popup // (a) in Item manager, (b) When linking to URL in popup target $view_allows_mb = $isItemsManager || $isSite && !$isFeedView; $config_needs_mb = $isLinkToPopup || $usepopup && $popuptype == 1; if ($view_allows_mb && $config_needs_mb) { if (!$multiboxadded) { flexicontent_html::loadFramework('jmultibox'); //echo $field->name.": multiboxadded"; $js = "\n\t\t\t\t\twindow.addEvent('domready', function(){\n\t\t\t\t\t\tjQuery('a.mb').jmultibox({\n\t\t\t\t\t\t\tinitialWidth: 250, //(number) the width of the box when it first opens while loading the item. Default: 250\n\t\t\t\t\t\t\tinitialHeight: 250, //(number) the width of the box when it first opens while loading the item. Default: 250\n\t\t\t\t\t\t\tcontainer: document.body, //(element) the element that the box will take it coordinates from. Default: document.body\n\t\t\t\t\t\t\tcontentColor: '#000', //(string) the color of the content area inside the box. Default: #000\n\t\t\t\t\t\t\tshowNumbers: " . ($isItemsManager ? 'false' : 'true') . ", //(boolean) show the number of the item e.g. 2/10. Default: true\n\t\t\t\t\t\t\tshowControls: " . ($isItemsManager ? 'false' : 'true') . ", //(boolean) show the navigation controls. Default: true\n\t\t\t\t\t\t\tdescClassName: 'multiBoxDesc', //(string) the classname of the divs that contain the description for the item. Default: false\n\t\t\t\t\t\t\tdescMinWidth: 400, //(number) the min width of the description text, useful when the item is small. Default: 400\n\t\t\t\t\t\t\tdescMaxWidth: 600, //(number) the max width of the description text, so it can wrap to multiple lines instead of being on a long single line. Useful when the item is large. Default: 600\n\t\t\t\t\t\t\tmovieWidth: 576, //(number) the default width of the box that contains content of a movie type. Default: 576\n\t\t\t\t\t\t\tmovieHeight: 324, //(number) the default height of the box that contains content of a movie type. Default: 324\n\t\t\t\t\t\t\toffset: {x: 0, y: 0}, //(object) containing x & y coords that adjust the positioning of the box. Default: {x:0, y:0}\n\t\t\t\t\t\t\tfixedTop: false, //(number) gives the box a fixed top position relative to the container. Default: false\n\t\t\t\t\t\t\tpath: '', //(string) location of the resources files, e.g. flv player, etc. Default: ''\n\t\t\t\t\t\t\topenFromLink: true, //(boolean) opens the box relative to the link location. Default: true\n\t\t\t\t\t\t\topac:0.7, //(decimal) overlay opacity Default: 0.7\n\t\t\t\t\t\t\tuseOverlay:false, //(boolean) use a semi-transparent background. Default: false\n\t\t\t\t\t\t\toverlaybg:'01.png', //(string) overlay image in 'overlays' folder. Default: '01.png'\n\t\t\t\t\t\t\tonOpen:function(){}, //(object) a function to call when the box opens. Default: function(){} \n\t\t\t\t\t\t\tonClose:function(){}, //(object) a function to call when the box closes. Default: function(){} \n\t\t\t\t\t\t\teasing:'swing', //(string) effect of jQuery Default: 'swing'\n\t\t\t\t\t\t\tuseratio:false, //(boolean) windows size follows ratio. (iframe or Youtube) Default: false\n\t\t\t\t\t\t\tratio:'90' //(number) window ratio Default: '90'\n\t\t\t\t\t\t});\n\t\t\t\t\t})"; $document->addScriptDeclaration($js); $multiboxadded = true; } } // Regardless if above has added multibox , we will add a different JS gallery if so configured because it maybe needed if (!$isSite || $isFeedView) { // Is backend OR it is a feed view, do not add any JS library } else { if ($usepopup) { switch ($popuptype) { // Add Fancybox image popup case 4: if (!$fancyboxadded) { $fancyboxadded = true; flexicontent_html::loadFramework('fancybox'); } break; // Add Galleriffic inline slideshow gallery // Add Galleriffic inline slideshow gallery case 5: $inline_gallery = 1; // unused if (!$gallerifficadded) { flexicontent_html::loadFramework('galleriffic'); $gallerifficadded = true; $js = "\n\t\t\t\t\t\t//document.write('<style>.noscript { display: none; }</style>');\n\t\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\t// We only want these styles applied when javascript is enabled\n\t\t\t\t\t\t\tjQuery('div.navigation').css({'width' : '150px', 'float' : 'left'});\n\t\t\t\t\t\t\tjQuery('div.content').css({'display' : 'inline-block', 'float' : 'none'});\n\t\t\t\n\t\t\t\t\t\t\t// Initially set opacity on thumbs and add\n\t\t\t\t\t\t\t// additional styling for hover effect on thumbs\n\t\t\t\t\t\t\tvar onMouseOutOpacity = 0.67;\n\t\t\t\t\t\t\tjQuery('#gf_thumbs ul.thumbs li').opacityrollover({\n\t\t\t\t\t\t\t\tmouseOutOpacity: onMouseOutOpacity,\n\t\t\t\t\t\t\t\tmouseOverOpacity: 1.0,\n\t\t\t\t\t\t\t\tfadeSpeed: 'fast',\n\t\t\t\t\t\t\t\texemptionSelector: '.selected'\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Initialize Advanced Galleriffic Gallery\n\t\t\t\t\t\t\tjQuery('#gf_thumbs').galleriffic({\n\t\t\t\t\t\t\t\t/*enableFancybox: true,*/\n\t\t\t\t\t\t\t\tdelay: 2500,\n\t\t\t\t\t\t\t\tnumThumbs: 4,\n\t\t\t\t\t\t\t\tpreloadAhead: 10,\n\t\t\t\t\t\t\t\tenableTopPager: true,\n\t\t\t\t\t\t\t\tenableBottomPager: true,\n\t\t\t\t\t\t\t\tmaxPagesToShow: 20,\n\t\t\t\t\t\t\t\timageContainerSel: '#gf_slideshow',\n\t\t\t\t\t\t\t\tcontrolsContainerSel: '#gf_controls',\n\t\t\t\t\t\t\t\tcaptionContainerSel: '#gf_caption',\n\t\t\t\t\t\t\t\tloadingContainerSel: '#gf_loading',\n\t\t\t\t\t\t\t\trenderSSControls: true,\n\t\t\t\t\t\t\t\trenderNavControls: true,\n\t\t\t\t\t\t\t\tplayLinkText: 'Play Slideshow',\n\t\t\t\t\t\t\t\tpauseLinkText: 'Pause Slideshow',\n\t\t\t\t\t\t\t\tprevLinkText: '‹ Previous Photo',\n\t\t\t\t\t\t\t\tnextLinkText: 'Next Photo ›',\n\t\t\t\t\t\t\t\tnextPageLinkText: 'Next ›',\n\t\t\t\t\t\t\t\tprevPageLinkText: '‹ Prev',\n\t\t\t\t\t\t\t\tenableHistory: false,\n\t\t\t\t\t\t\t\tautoStart: false,\n\t\t\t\t\t\t\t\tsyncTransitions: true,\n\t\t\t\t\t\t\t\tdefaultTransitionDuration: 900,\n\t\t\t\t\t\t\t\tonSlideChange: function(prevIndex, nextIndex) {\n\t\t\t\t\t\t\t\t\t// 'this' refers to the gallery, which is an extension of jQuery('#gf_thumbs')\n\t\t\t\t\t\t\t\t\tthis.find('ul.thumbs').children()\n\t\t\t\t\t\t\t\t\t\t.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()\n\t\t\t\t\t\t\t\t\t\t.eq(nextIndex).fadeTo('fast', 1.0);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonPageTransitionOut: function(callback) {\n\t\t\t\t\t\t\t\t\tthis.fadeTo('fast', 0.0, callback);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonPageTransitionIn: function() {\n\t\t\t\t\t\t\t\t\tthis.fadeTo('fast', 1.0);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\t"; $document->addScriptDeclaration($js); } break; // Add Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description) // Add Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description) case 7: if (!$elastislideadded) { flexicontent_html::loadFramework('elastislide'); $elastislideadded = true; } $uid = 'es_' . $field->name . "_fcitem" . $item->id; $js = file_get_contents(JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'elastislide' . DS . 'js' . DS . 'gallery_tmpl.js'); $js = str_replace('unique_gal_id', $uid, $js); $js = str_replace('__thumb_width__', $field->parameters->get('w_s', 120), $js); $document->addScriptDeclaration($js); $document->addCustomTag(' <script id="img-wrapper-tmpl_' . $uid . '" type="text/x-jquery-tmpl"> <div class="rg-image-wrapper"> {{if itemsCount > 1}} <div class="rg-image-nav"> <a href="#" class="rg-image-nav-prev">' . JText::_('FLEXI_PREVIOUS') . '</a> <a href="#" class="rg-image-nav-next">' . JText::_('FLEXI_NEXT') . '</a> </div> {{/if}} <div class="rg-image"></div> <div class="rg-loading"></div> <div class="rg-caption-wrapper"> <div class="rg-caption" style="display:none;"> <p></p> </div> </div> </div> </script> '); break; // Add PhotoSwipe popup carousel gallery // Add PhotoSwipe popup carousel gallery case 8: if (!$photoswipeadded) { flexicontent_html::loadFramework('photoswipe'); $photoswipeadded = true; } break; } } } } // ******************************* // Prepare for value handling loop // ******************************* // Extra thumbnails sub-folder for various if ($field->using_default_value) { $extra_folder = ''; // default value } else { if ($image_source == -1) { $extra_folder = 'intro_full'; // intro-full images mode } else { if ($image_source > 0) { $extra_folder = 'item_' . $u_item_id . '_field_' . $field->id; // folder-mode 1 if ($image_source > 1) { } // TODO } else { $extra_folder = ''; // db-mode } } } // Create thumbs/image Folder and URL paths $thumb_folder = JPATH_SITE . DS . JPath::clean($dir . ($extra_folder ? DS . $extra_folder : '')); $thumb_urlpath = $dir_url . ($extra_folder ? '/' . $extra_folder : ''); if ($field->using_default_value) { // default image of this field, these are relative paths up to site root $orig_urlpath = str_replace('\\', '/', dirname($default_image_val['default_image'])); } else { if ($image_source == -1) { // intro-full image values, these are relative paths up to the site root, must be calculated later !! $orig_urlpath = str_replace('\\', '/', dirname($image_by_params['image_path'])); } else { if ($image_source > 0) { // various folder-mode(s) $orig_urlpath = $thumb_urlpath . '/original'; } else { // db-mode $cparams = JComponentHelper::getParams('com_flexicontent'); $orig_urlpath = str_replace('\\', '/', JPath::clean($cparams->get('file_path', 'components/com_flexicontent/uploads'))); } } } // Initialize value handling arrays and loop's common variables $i = -1; $field->{$prop} = array(); $field->thumbs_src['backend'] = array(); $field->thumbs_src['small'] = array(); $field->thumbs_src['medium'] = array(); $field->thumbs_src['large'] = array(); $field->thumbs_src['original'] = array(); $field->{"display_backend_src"} = array(); $field->{"display_small_src"} = array(); $field->{"display_medium_src"} = array(); $field->{"display_large_src"} = array(); $field->{"display_original_src"} = array(); $cust1_label = JText::_('FLEXI_FIELD_IMG_CUST1'); $cust2_label = JText::_('FLEXI_FIELD_IMG_CUST2'); // Decide thumbnail to use $thumb_size = 0; if ($isItemsManager) { $thumb_size = -1; } else { if ($view == 'category') { $thumb_size = $field->parameters->get('thumbincatview', 1); } else { if ($view == FLEXI_ITEMVIEW) { $thumb_size = $field->parameters->get('thumbinitemview', 2); } } } // *************** // The values loop // *************** foreach ($values as $val) { // Unserialize value's properties and check for empty original name property $value = unserialize($val); $image_name = trim(@$value['originalname']); if (!strlen($image_name)) { if ($is_ingroup) { $field->{$prop}[] = ''; } // add empty position to the display array continue; } $i++; // Create thumbnails urls, note thumbnails have already been verified above $wl = $field->parameters->get('w_l', 800); $hl = $field->parameters->get('h_l', 600); // Optional properties $title = $usetitle && @$value['title'] ? $value['title'] : ''; $alt = $usealt && @$value['alt'] ? $value['alt'] : flexicontent_html::striptagsandcut($item->title, 60); $desc = $usedesc && @$value['desc'] ? $value['desc'] : ''; // Optional custom properties $cust1 = $usecust1 && @$value['cust1'] ? $value['cust1'] : ''; $desc .= $cust1 ? $cust1_label . ': ' . $cust1 : ''; // ... Append custom properties to description $cust2 = $usecust2 && @$value['cust2'] ? $value['cust2'] : ''; $desc .= $cust2 ? $cust2_label . ': ' . $cust2 : ''; // ... Append custom properties to description // HTML encode output $title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8'); $alt = htmlspecialchars($alt, ENT_COMPAT, 'UTF-8'); $desc = htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'); $srcb = $thumb_urlpath . '/b_' . $extra_prefix . $image_name; // backend $srcs = $thumb_urlpath . '/s_' . $extra_prefix . $image_name; // small $srcm = $thumb_urlpath . '/m_' . $extra_prefix . $image_name; // medium $srcl = $thumb_urlpath . '/l_' . $extra_prefix . $image_name; // large $srco = $orig_urlpath . '/' . $image_name; // original image // Create a popup url link $urllink = @$value['urllink'] ? $value['urllink'] : ''; if ($urllink && false === strpos($urllink, '://')) { $urllink = 'http://' . $urllink; } // Create a popup tooltip (legend) $class = 'fc_field_image'; if ($uselegend && (!empty($title) || !empty($desc))) { $class .= $tip_class; $legend = ' title="' . flexicontent_html::getToolTip($title, $desc, 0, 1) . '"'; } else { $legend = ''; } // Handle single image display, with/without total, TODO: verify all JS handle & ignore display none on the img TAG $style = $i != 0 && $isSingle ? 'display:none;' : ''; // Create a unique id for the link tags, and a class name for image tags $uniqueid = $item->id . '_' . $field->id . '_' . $i; switch ($thumb_size) { case -1: $src = $srcb; break; case 1: $src = $srcs; break; case 2: $src = $srcm; break; case 3: $src = $srcl; break; // this makes little sense, since both thumbnail and popup image are size 'large' // this makes little sense, since both thumbnail and popup image are size 'large' case 4: $src = $srco; break; default: $src = $srcs; break; } // Create a grouping name switch ($grouptype) { case 0: $group_name = 'fcview_' . $view . '_fcitem_' . $item->id . '_fcfield_' . $field->id; break; case 1: $group_name = 'fcview_' . $view . '_fcitem_' . $item->id; break; case 2: $group_name = 'fcview_' . $view; break; default: $group_name = ''; break; } // ADD some extra (display) properties that point to all sizes, currently SINGLE IMAGE only if ($is_ingroup) { // In case of field displayed via in fieldgroup, this is an array $field->{"display_backend_src"}[] = JURI::root(true) . '/' . $srcb; $field->{"display_small_src"}[] = JURI::root(true) . '/' . $srcs; $field->{"display_medium_src"}[] = JURI::root(true) . '/' . $srcm; $field->{"display_large_src"}[] = JURI::root(true) . '/' . $srcl; $field->{"display_original_src"}[] = JURI::root(true) . '/' . $srco; } else { if ($i == 0) { // Field displayed not via fieldgroup return only the 1st value $field->{"display_backend_src"} = JURI::root(true) . '/' . $srcb; $field->{"display_small_src"} = JURI::root(true) . '/' . $srcs; $field->{"display_medium_src"} = JURI::root(true) . '/' . $srcm; $field->{"display_large_src"} = JURI::root(true) . '/' . $srcl; $field->{"display_original_src"} = JURI::root(true) . '/' . $srco; } } $field->thumbs_src['backend'][] = JURI::root(true) . '/' . $srcb; $field->thumbs_src['small'][] = JURI::root(true) . '/' . $srcs; $field->thumbs_src['medium'][] = JURI::root(true) . '/' . $srcm; $field->thumbs_src['large'][] = JURI::root(true) . '/' . $srcl; $field->thumbs_src['original'][] = JURI::root(true) . '/' . $srco; $field->thumbs_path['backend'][] = JPATH_SITE . DS . $srcb; $field->thumbs_path['small'][] = JPATH_SITE . DS . $srcs; $field->thumbs_path['medium'][] = JPATH_SITE . DS . $srcm; $field->thumbs_path['large'][] = JPATH_SITE . DS . $srcl; $field->thumbs_path['original'][] = JPATH_SITE . DS . $srco; // Suggest image for external use, e.g. for Facebook etc if ($isSite && !$isFeedView && $useogp) { if (in_array($view, $ogpinview)) { switch ($ogpthumbsize) { case 1: $ogp_src = $field->thumbs_src['small'][$i]; break; // this maybe problematic, since it maybe too small or not accepted by social website // this maybe problematic, since it maybe too small or not accepted by social website case 2: $ogp_src = $field->thumbs_src['medium'][$i]; break; case 3: $ogp_src = $field->thumbs_src['large'][$i]; break; case 4: $ogp_src = $field->thumbs_src['original'][$i]; break; default: $ogp_src = $field->thumbs_src['medium'][$i]; break; } $document->addCustomTag('<link rel="image_src" href="' . $ogp_src . '" />'); $document->addCustomTag('<meta property="og:image" content="' . $ogp_src . '" />'); } } // **************************************************************** // CHECK if we were asked for value only display (e.g. image source) // if so we will not be creating the HTML code for Image / Gallery // **************************************************************** if (isset(self::$value_only_displays[$prop])) { continue; } // ********************************************************* // Create image tags (according to configuration parameters) // that will be used for the requested 'display' variable // ********************************************************* switch ($prop) { case 'display_backend': $img_legend = '<img src="' . JURI::root(true) . '/' . $srcb . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcb . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>'; break; case 'display_small': $img_legend = '<img src="' . JURI::root(true) . '/' . $srcs . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcs . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>'; break; case 'display_medium': $img_legend = '<img src="' . JURI::root(true) . '/' . $srcm . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcm . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>'; break; case 'display_large': $img_legend = '<img src="' . JURI::root(true) . '/' . $srcl . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcl . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>'; break; case 'display_original': $img_legend = '<img src="' . JURI::root(true) . '/' . $srco . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srco . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>'; break; case 'display': default: $img_legend = '<img src="' . JURI::root(true) . '/' . $src . '" alt="' . $alt . '"' . $legend . ' class="' . $class . '" itemprop="image"/>'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $src . '" alt="' . $alt . '" class="' . $class . '" itemprop="image"/>'; break; } // ************************************************* // Create thumbnail appending text (not linked text) // ************************************************* // For galleries that are not inline/special, we can have inline text ?? $inline_info = ''; if ($linkto_url || ($prop == 'display_large' || $prop == 'display_original') || !$usepopup || $popuptype != 5 && $popuptype != 7) { // Add inline display of title/desc if ($showtitle && $title || $showdesc && $desc) { $inline_info = '<div class="fc_img_tooltip_data alert alert-info" style="' . $style . '" >'; } if ($showtitle && $title) { $inline_info .= '<div class="fc_img_tooltip_title" style="line-height:1em; font-weight:bold;">' . $title . '</div>'; } if ($showdesc && $desc) { $inline_info .= '<div class="fc_img_tooltip_desc" style="line-height:1em;">' . $desc . '</div>'; } if ($showtitle && $title || $showdesc && $desc) { $inline_info .= '</div>'; } } // ********************************************* // FINALLY CREATE the field display variable ... // ********************************************* if ($linkToItem) { // CASE 0: Add single image display information (e.g. image count) $item_link = JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug, 0, $item)); $field->{$prop}[] = '<span style="display: inline-block; text-align:center; "> <a href="' . $item_link . '" style="display: inline-block;"> ' . $img_nolegend . ' </a><br/>' . ($_method == 'display_single_total' || $_method == 'display_single_total_link' ? ' <span class="fc_img_total_data badge badge-info" style="display: inline-block;" > ' . count($values) . ' ' . JText::_('FLEXI_IMAGES') . ' </span>' : '') . ' </span>'; // If single display and not in field group then do not add more images if (!$is_ingroup && $isSingle) { break; } } else { if ($linkto_url) { // CASE 1: Handle linking to a URL instead of image zooming popup if (!$urllink) { // CASE: Just image thumbnail since url link is empty $field->{$prop}[] = $pretext . '<div class="fc_img_container">' . $img_legend . $inline_info . '</div>' . $posttext; } else { if ($url_target == 'multibox') { // CASE: Link to URL that opens inside a popup via multibox $field->{$prop}[] = $pretext . ' <script>document.write(\'<a style="' . $style . '" href="' . $urllink . '" id="mb' . $uniqueid . '" class="mb" rel="width:\'+(jQuery(window).width()-150)+\',height:\'+(jQuery(window).height()-150)+\'">\')</script> ' . $img_legend . ' <script>document.write(\'</a>\')</script> <div class="multiBoxDesc mbox_img_url mb' . $uniqueid . '">' . ($desc ? $desc : $title) . '</div> ' . $inline_info . $posttext; } else { if ($url_target == 'fancybox') { // CASE: Link to URL that opens inside a popup via fancybox $field->{$prop}[] = $pretext . ' <span class="fc_image_thumb" style="' . $style . '; cursor: pointer;" ' . 'onclick="jQuery.fancybox.open([{ type: \'iframe\', href: \'' . $urllink . '\', topRatio: 0.9, leftRatio: 0.9, title: \'' . ($desc ? $title . ': ' . $desc : $title) . '\' }], { padding : 0});" > ' . $img_legend . ' </span> ' . $inline_info . $posttext; } else { // CASE: Just link to URL without popup $field->{$prop}[] = $pretext . ' <a href="' . $urllink . '" target="' . $url_target . '"> ' . $img_legend . ' </a> ' . $inline_info . $posttext; } } } } else { if (!$usepopup || ($prop == 'display_large' || $prop == 'display_original')) { // CASE 2: // No gallery code ... just apply pretext/posttext $field->{$prop}[] = $pretext . $img_legend . $inline_info . $posttext; } else { if ($popuptype == 5 || $popuptype == 7) { // CASE 3: Inline/special galleries OR --> GALLERIES THAT NEED SPECIAL ENCLOSERS // !!! ... pretext/posttext/inline_info/etc not meaningful or not supported or not needed switch ($popuptype) { case 5: // Galleriffic inline slideshow gallery $group_str = ''; // image grouping: not needed / not applicatble $field->{$prop}[] = '<a href="' . $srcl . '" class="fc_image_thumb thumb" name="drop"> ' . $img_legend . ' </a> <div class="caption"> <b>' . $title . '</b> <br/>' . $desc . ' </div>'; break; case 7: // Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description) // *** NEEDS: thumbnail list must be created with large size thubmnails, these will be then thumbnailed by the JS gallery code $title_attr = $desc ? $desc : $title; $img_legend_custom = ' <img src="' . JURI::root(true) . '/' . $src . '" alt ="' . $alt . '"' . $legend . ' class="' . $class . '" data-large="' . JURI::root(true) . '/' . $srcl . '" data-description="' . $title_attr . '" itemprop="image"/> '; $group_str = $group_name ? 'rel="[' . $group_name . ']"' : ''; $field->{$prop}[] = ' <li><a href="javascript:;" class="fc_image_thumb"> ' . $img_legend_custom . ' </a></li>'; break; default: // ERROR unhandled INLINE GALLERY case $field->{$prop}[] = ' Unhandled INLINE GALLERY case in image with field name: {$field->name} '; break; } } else { // CASE 4: Popup galleries switch ($popuptype) { case 1: // Multibox image popup $group_str = $group_name ? 'rel="[' . $group_name . ']"' : ''; $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" id="mb' . $uniqueid . '" class="fc_image_thumb mb" ' . $group_str . ' > ' . $img_legend . ' </a> <div class="multiBoxDesc mb' . $uniqueid . '">' . ($desc ? '<span class="badge">' . $title . '</span> ' . $desc : $title) . '</div>' . $inline_info . $posttext; break; case 2: // Rokbox image popup $title_attr = $desc ? $desc : $title; $group_str = ''; // no support for image grouping $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" rel="rokbox[' . $wl . ' ' . $hl . ']" ' . $group_str . ' title="' . $title_attr . '" class="fc_image_thumb" data-rokbox data-rokbox-caption="' . $title_attr . '"> ' . $img_legend . ' </a>' . $inline_info . $posttext; break; case 3: // JCE popup image popup $title_attr = $desc ? $title . ': ' . $desc : $title; // does not support HTML $group_str = $group_name ? 'rel="group[' . $group_name . ']"' : ''; $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" class="fc_image_thumb jcepopup" ' . $group_str . ' title="' . $title_attr . '"> ' . $img_nolegend . ' </a>' . $inline_info . $posttext; break; case 4: // Fancybox image popup $title_attr = $desc ? '<span class=\'badge\'>' . $title . '</span> ' . $desc : $title; $group_str = $group_name ? 'data-fancybox-group="' . $group_name . '"' : ''; $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" class="fc_image_thumb fancybox" ' . $group_str . ' title="' . $title_attr . '"> ' . $img_legend . ' </a>' . $inline_info . $posttext; break; case 6: // (Widgetkit) SPOTlight image popup $title_attr = $desc ? $desc : $title; $group_str = $group_name ? 'data-spotlight-group="' . $group_name . '"' : ''; $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" class="fc_image_thumb" data-lightbox="on" data-spotlight="effect:bottom" ' . $group_str . ' title="' . $title_attr . '"> ' . $img_legend . ' <div class="overlay"> ' . '<b>' . $title . '</b>: ' . $desc . ' </div> </a>' . $inline_info . $posttext; break; case 8: // PhotoSwipe popup carousel gallery $group_str = $group_name ? 'rel="[' . $group_name . ']"' : ''; $field->{$prop}[] = $pretext . '<a style="' . $style . '" href="' . $srcl . '" ' . $group_str . ' class="fc_image_thumb"> ' . $img_legend . ' </a>' . $inline_info . $posttext; break; default: // Unknown / Other Gallery Type, just add thumbails ... maybe pretext/posttext/separator/opentag/closetag will add a gallery $field->{$prop}[] = $pretext . $img_legend . $inline_info . $posttext; break; } } } } } } // ************************************************************** // Apply separator and open/close tags and handle SPECIAL CASEs: // by adding (container) HTML required by some JS image libraries // ************************************************************** // Using in field group, return array if ($is_ingroup) { return; } // Check for value only displays and return if (isset(self::$value_only_displays[$prop])) { return; } // Check for no values found if (!count($field->{$prop})) { $field->{$prop} = ''; return; } // Galleriffic inline slideshow gallery if ($usepopup && $popuptype == 5) { $field->{$prop} = ' <div id="gf_container"> <div id="gallery" class="content"> <div id="gf_controls" class="controls"></div> <div class="slideshow-container"> <div id="gf_loading" class="loader"></div> <div id="gf_slideshow" class="slideshow"></div> </div> <div id="gf_caption" class="caption-container"></div> </div> <div id="gf_thumbs" class="navigation"> <ul class="thumbs noscript"> <li> ' . implode("</li>\n<li>", $field->{$prop}) . ' </li> </ul> </div> <div style="clear: both;"></div> </div> '; } else { if ($usepopup && $popuptype == 7) { //$max_width = $field->parameters->get( 'w_l', 800 ); // this should be size of previewer aka size of large image thumbnail $uid = 'es_' . $field->name . "_fcitem" . $item->id; $field->{$prop} = ' <div id="rg-gallery_' . $uid . '" class="rg-gallery" > <div class="rg-thumbs"> <!-- Elastislide Carousel Thumbnail Viewer --> <div class="es-carousel-wrapper"> <div class="es-nav"> <span class="es-nav-prev">' . JText::_('FLEXI_PREVIOUS') . '</span> <span class="es-nav-next">' . JText::_('FLEXI_NEXT') . '</span> </div> <div class="es-carousel"> <ul> ' . implode('', $field->{$prop}) . ' </ul> </div> </div> <!-- End Elastislide Carousel Thumbnail Viewer --> </div><!-- rg-thumbs --> </div><!-- rg-gallery --> '; } else { if ($usepopup && $popuptype == 8) { $field->{$prop} = ' <span class="photoswipe_fccontainer" > ' . implode($separatorf, $field->{$prop}) . ' </span> '; } else { $field->{$prop} = implode($separatorf, $field->{$prop}); } } } // Apply open/close tags $field->{$prop} = $opentag . $field->{$prop} . $closetag; }
/** * 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); } }
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { if (!in_array($field->field_type, self::$field_types)) { return; } // Some variables $is_ingroup = !empty($field->ingroup); $use_ingroup = $field->parameters->get('use_ingroup', 0); $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 1); static $langs = null; if ($langs === null) { $langs = FLEXIUtilities::getLanguages('code'); } static $tooltips_added = false; static $isMobile = null; static $isTablet = null; static $useMobile = null; if ($useMobile === null) { $cparams = JComponentHelper::getParams('com_flexicontent'); $force_desktop_layout = $cparams->get('force_desktop_layout', 0); //$start_microtime = microtime(true); $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000); } if (!$tooltips_added) { FLEXI_J30GE ? JHtml::_('bootstrap.tooltip') : JHTML::_('behavior.tooltip'); $tooltips_added = true; } $field->label = JText::_($field->label); $values = $values ? $values : $field->value; // Check for no values and no default value, and return empty display if (empty($values)) { $field->{$prop} = $is_ingroup ? array() : ''; return; } // Prefix - Suffix - Separator parameters, replacing other field values if found $remove_space = $field->parameters->get('remove_space', 0); $pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('pretext', ''), 'pretext'); $posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('posttext', ''), 'posttext'); $separatorf = $field->parameters->get('separatorf', 1); $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag'); $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag'); // Microdata (classify the field values for search engines) $itemprop = ''; //$field->parameters->get('microdata_itemprop'); if ($pretext) { $pretext = $remove_space ? $pretext : $pretext . ' '; } if ($posttext) { $posttext = $remove_space ? $posttext : ' ' . $posttext; } // some parameter shortcuts $useicon = $field->parameters->get('useicon', 1); $lowercase_filename = $field->parameters->get('lowercase_filename', 1); $link_filename = $field->parameters->get('link_filename', 1); $display_filename = $field->parameters->get('display_filename', 1); $display_lang = $field->parameters->get('display_lang', 1); $display_size = $field->parameters->get('display_size', 0); $display_hits = $field->parameters->get('display_hits', 0); $display_descr = $field->parameters->get('display_descr', 1); $add_lang_img = $display_lang == 1 || $display_lang == 3; $add_lang_txt = $display_lang == 2 || $display_lang == 3 || $isMobile; $add_hits_img = $display_hits == 1 || $display_hits == 3; $add_hits_txt = $display_hits == 2 || $display_hits == 3 || $isMobile; $usebutton = $field->parameters->get('usebutton', 1); $buttonsposition = $field->parameters->get('buttonsposition', 1); $use_infoseptxt = $field->parameters->get('use_infoseptxt', 1); $use_actionseptxt = $field->parameters->get('use_actionseptxt', 1); $infoseptxt = $use_infoseptxt ? ' ' . $field->parameters->get('infoseptxt', '') . ' ' : ' '; $actionseptxt = $use_actionseptxt ? ' ' . $field->parameters->get('actionseptxt', '') . ' ' : ' '; $allowdownloads = $field->parameters->get('allowdownloads', 1); $downloadstext = $allowdownloads == 2 ? $field->parameters->get('downloadstext', 'FLEXI_DOWNLOAD') : 'FLEXI_DOWNLOAD'; $downloadstext = JText::_($downloadstext); $downloadsinfo = JText::_('FLEXI_FIELD_FILE_DOWNLOAD_INFO', true); $allowview = $field->parameters->get('allowview', 0); $viewtext = $allowview == 2 ? $field->parameters->get('viewtext', 'FLEXI_FIELD_FILE_VIEW') : 'FLEXI_FIELD_FILE_VIEW'; $viewtext = JText::_($viewtext); $viewinfo = JText::_('FLEXI_FIELD_FILE_VIEW_INFO', true); $allowshare = $field->parameters->get('allowshare', 0); $sharetext = $allowshare == 2 ? $field->parameters->get('sharetext', 'FLEXI_FIELD_FILE_EMAIL_TO_FRIEND') : 'FLEXI_FIELD_FILE_EMAIL_TO_FRIEND'; $sharetext = JText::_($sharetext); $shareinfo = JText::_('FLEXI_FIELD_FILE_EMAIL_TO_FRIEND_INFO', true); $allowaddtocart = $field->parameters->get('use_downloads_manager', 0); $addtocarttext = $allowaddtocart == 2 ? $field->parameters->get('addtocarttext', 'FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART') : 'FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART'; $addtocarttext = JText::_($addtocarttext); $addtocartinfo = JText::_('FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART_INFO', true); $noaccess_display = $field->parameters->get('noaccess_display', 1); $noaccess_url_unlogged = $field->parameters->get('noaccess_url_unlogged', false); $noaccess_url_logged = $field->parameters->get('noaccess_url_logged', false); $noaccess_msg_unlogged = JText::_($field->parameters->get('noaccess_msg_unlogged', '')); $noaccess_msg_logged = JText::_($field->parameters->get('noaccess_msg_logged', '')); $noaccess_addvars = $field->parameters->get('noaccess_addvars', 0); // Select appropriate messages depending if user is logged on $noaccess_url = JFactory::getUser()->guest ? $noaccess_url_unlogged : $noaccess_url_logged; $noaccess_msg = JFactory::getUser()->guest ? $noaccess_msg_unlogged : $noaccess_msg_logged; // VERIFY downloads manager module is installed and enabled static $mod_is_enabled = null; if ($allowaddtocart && $mod_is_enabled === null) { $db = JFactory::getDBO(); $query = "SELECT published FROM #__modules WHERE module = 'mod_flexidownloads' AND published = 1"; $db->setQuery($query); $mod_is_enabled = $db->loadResult(); if (!$mod_is_enabled) { JFactory::getApplication()->enqueueMessage("FILE FIELD: please disable parameter \"Use Downloads Manager Module\", the module is not install or not published", 'message'); } } $allowaddtocart = $allowaddtocart ? $mod_is_enabled : 0; // Downloads manager feature if ($allowshare) { if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php')) { $com_mailto_found = true; require_once JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php'; $status = 'width=700,height=360,menubar=yes,resizable=yes'; } else { $com_mailto_found = false; } } if ($pretext) { $pretext = $remove_space ? $pretext : $pretext . ' '; } if ($posttext) { $posttext = $remove_space ? $posttext : ' ' . $posttext; } 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; } // Get user access level (these are multiple for J2.5) $user = JFactory::getUser(); $aid_arr = JAccess::getAuthorisedViewLevels($user->id); $n = 0; // Get All file information at once (Data maybe cached already) // TODO (maybe) e.g. contentlists should could call this function ONCE for all file fields, // This may be done by adding a new method to fields to prepare multiple fields with a single call $files_data = $this->getFileData($values, $published = true); //if ($field->id==NNN) { echo "<pre>"; print_r($files_data); exit; } // Optimization, do some stuff outside the loop static $hits_icon = null; if ($hits_icon === null && ($display_hits == 1 || $display_hits == 3)) { if ($display_hits == 1) { $_tooltip_title = ''; $_tooltip_content = '%s ' . JText::_('FLEXI_HITS', true); $_attribs = 'class="hasTooltip fcicon-hits" title="' . JHtml::tooltipText($_tooltip_title, $_tooltip_content, 0, 0) . '"'; } else { $_attribs = ' class="fcicon-hits"'; } $hits_icon = JHTML::image('components/com_flexicontent/assets/images/' . 'user.png', JText::_('FLEXI_HITS'), $_attribs) . ' '; } $show_filename = $display_filename || $prop == 'namelist'; $public_acclevel = 1; $empty_file_data = array('filename' => false, 'filename_original' => false, 'altname' => false, 'description' => false, 'ext' => false, 'id' => 0); // Get layout name $viewlayout = $field->parameters->get('viewlayout', ''); $viewlayout = $viewlayout ? 'value_' . $viewlayout : 'value_InlineBoxes'; // Create field's HTML, using layout file $field->{$prop} = array(); //$this->values = $values; //$this->displayFieldValue( $prop, $viewlayout ); include self::getFormPath($this->fieldtypes[0], $viewlayout); if (!empty($fancybox_needed)) { flexicontent_html::loadFramework('fancybox'); } // Do not convert the array to string if field is in a group, and do not add: FIELD's opetag, closetag, value separator if (!$is_ingroup) { // Apply values separator $field->{$prop} = implode($separatorf, $field->{$prop}); if ($field->{$prop} !== '') { // Apply field 's opening / closing texts $field->{$prop} = $opentag . $field->{$prop} . $closetag; // Add microdata once for all values, if field -- is NOT -- in a field group if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } } } }
/** * 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); } }
/** * Utility function to load each JS Frameworks once * * @param string $text * @param int $nb * @return string * @since 1.5 */ static function loadFramework($framework, $mode = '', $params = null) { // Detect already loaded framework static $_loaded = array(); if (isset($_loaded[$framework])) { return $_loaded[$framework]; } $_loaded[$framework] = false; // Get frameworks that are configured to be loaded manually in frontend (e.g. via the Joomla template) $app = JFactory::getApplication(); static $load_frameworks = null; static $load_jquery = null; if (!isset($load_frameworks[$framework])) { $flexiparams = JComponentHelper::getParams('com_flexicontent'); //$load_frameworks = $flexiparams->get('load_frameworks', array('jQuery','image-picker','masonry','select2','inputmask','prettyCheckable','fancybox')); //$load_frameworks = FLEXIUtilities::paramToArray($load_frameworks); //$load_frameworks = array_flip($load_frameworks); //$load_jquery = isset($load_frameworks['jQuery']) || !$app->isSite(); if ($load_jquery === null) { $load_jquery = $flexiparams->get('loadfw_jquery', 1) == 1 || !$app->isSite(); } $load_framework = $flexiparams->get('loadfw_' . strtolower(str_replace('-', '_', $framework)), 1); $load_frameworks[$framework] = $load_framework == 1 || $load_framework == 2 && !$app->isSite(); } // Set loaded flag $_loaded[$framework] = $load_frameworks[$framework]; // Do not progress further if it is disabled if (!$load_frameworks[$framework]) { return false; } // Load Framework $document = JFactory::getDocument(); $lib_path = '/components/com_flexicontent/librairies'; $js = ""; $css = ""; switch ($framework) { case 'jQuery': if ($load_jquery) { flexicontent_html::loadJQuery(1, 1, 1, 1, $params); } break; case 'mCSB': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/mCSB'; $document->addScript($framework_path . '/jquery.mCustomScrollbar.min.js'); $document->addStyleSheet($framework_path . '/jquery.mCustomScrollbar.css'); $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('.fc_add_scroller').mCustomScrollbar({\n\t\t\t\t\t\t\ttheme:'dark-thick',\n\t\t\t\t\t\t\tadvanced:{updateOnContentResize: true}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tjQuery('.fc_add_scroller_horizontal').mCustomScrollbar({\n\t\t\t\t\t\t\ttheme:'dark-thick',\n\t\t\t\t\t\t\thorizontalScroll:true,\n\t\t\t\t\t\t\tadvanced:{updateOnContentResize: true}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'image-picker': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/image-picker'; $document->addScript($framework_path . '/image-picker.min.js'); $document->addStyleSheet($framework_path . '/image-picker.css'); break; case 'masonry': $framework_path = JURI::root(true) . $lib_path . '/masonry'; $document->addScript($framework_path . '/masonry.pkgd.min.js'); break; case 'select2': if ($load_jquery) { flexicontent_html::loadJQuery(); } // Replace chosen function (if loaded) //JHtml::_('formbehavior.chosen', '#_some_iiidddd_'); $js .= "\n\t\t\t\tif (typeof jQuery.fn.chosen == 'function') { \n\t\t\t\t\tjQuery.fn.chosen_fc = jQuery.fn.chosen;\n\t\t\t\t\tjQuery.fn.chosen = function(){\n\t\t\t\t\t\tvar args = arguments;\n\t\t\t\t\t\tjQuery(this).each(function() {\n\t\t\t\t\t\t\tif (jQuery(this).hasClass('use_select2_lib')) return;\n\t\t\t\t\t\t\tjQuery(this).chosen_fc(args);\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\t"; $ver = '3.5.4'; $framework_path = JURI::root(true) . $lib_path . '/select2'; $framework_folder = JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'select2'; $document->addScriptVersion($framework_path . '/select2.min.js', $ver); $document->addStyleSheetVersion($framework_path . '/select2.css', $ver); $lang_code = flexicontent_html::getUserCurrentLang(); if ($lang_code && $lang_code != 'en') { // Try language shortcode if (file_exists($framework_folder . DS . 'select2_locale_' . $lang_code . '.js')) { $document->addScriptVersion($framework_path . '/select2_locale_' . $lang_code . '.js', $ver); } else { $country_code = flexicontent_html::getUserCurrentLang($short_tag = false); if ($country_code && file_exists($framework_folder . DS . 'select2_locale_' . $country_code . '.js')) { $document->addScriptVersion($framework_path . '/select2_locale_' . $country_code . '.js', $ver); } } } // Disable select2 JS in mobile devices $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $js .= "\n\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\t" . ($isMobile ? "\n\t\t\t\t\t\tjQuery('select.use_select2_lib')\n\t\t\t\t\t\t\t//.filter(function(){return !jQuery(this).attr('multiple');})\n\t\t\t\t\t\t\t.removeClass('use_select2_lib').addClass('fc_isselect').addClass('fc_ismobile');" : "") . "\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('select.use_select2_lib').select2({\n\t\t\t\t\t\t\t/*hideSelectionFromResult: function(selectedObject) { selectedObject.removeClass('select2-result-selectable').addClass('select2-result-unselectable').addClass('select2-disabled'); return false; },*/\n\t\t\t\t\t\t\tminimumResultsForSearch: 10\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery('div.use_select2_lib').each(function() {\n\t\t\t\t\t\t\tvar el_container = jQuery(this);\n\t\t\t\t\t\t\tvar el_select = el_container.next('select');\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar fc_label_text = el_select.attr('data-fc_label_text');\n\t\t\t\t\t\t\tif (!fc_label_text) fc_label_text = el_select.attr('fc_label_text');\n\t\t\t\t\t\t\tif (fc_label_text) {\n\t\t\t\t\t\t\t\tvar _label = (fc_label_text.length >= 30) ? fc_label_text.substring(0, 28) + '...' : fc_label_text;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tjQuery('<span/>', {\n\t\t\t\t\t\t\t\t\t'class': 'fc_has_inner_label fc_has_inner_label_select2',\n\t\t\t\t\t\t\t\t\t'text': _label\n\t\t\t\t\t\t\t\t}).prependTo(el_container.find('.select2-search-field'));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar fc_prompt_text = el_select.attr('data-fc_prompt_text');\n\t\t\t\t\t\t\tif (!fc_prompt_text) fc_prompt_text = el_select.attr('fc_prompt_text');\n\t\t\t\t\t\t\tif (fc_prompt_text) {\n\t\t\t\t\t\t\t\tvar _prompt = (fc_prompt_text.length >= 30) ? fc_prompt_text.substring(0, 28) + '...' : fc_prompt_text;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tjQuery('<span/>', {\n\t\t\t\t\t\t\t\t\t'class': 'fc_has_inner_prompt fc_has_inner_prompt_select2',\n\t\t\t\t\t\t\t\t\t'text': _prompt\n\t\t\t\t\t\t\t\t}).prependTo(el_container.find('.select2-search-field')).hide();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tif ( ! el_select.attr('multiple') && !el_select.hasClass('fc_skip_highlight') ) {\n\t\t\t\t\t\t\t\tvar el = el_container.find('.select2-choice');\n\t\t\t\t\t\t\t\tvar val = el_select.val();\n\t\t\t\t\t\t\t\tif (val === null) {\n\t\t\t\t\t\t\t\t\t//el.addClass('fc_highlight_disabled');\n\t\t\t\t\t\t\t\t} else if (!!val && val.length) {\n\t\t\t\t\t\t\t\t\tel.addClass('fc_highlight');\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tel.removeClass('fc_highlight');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('select.use_select2_lib').on('select2-open', function() {\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar el_container = jQuery(this).parent();\n\t\t\t\t\t\t\tvar el = jQuery(this).parent().find('.select2-input');\n\t\t\t\t\t\t\tvar el_label = el.prevAll('.fc_has_inner_label');\n\t\t\t\t\t\t\tif (el_label) el_label.hide();\n\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\tif (el_prompt) el_prompt.show();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tif (jQuery(this).hasClass('select2_list_selected')) {\n\t\t\t\t\t\t\t\tvar els = jQuery('#select2-drop').find('.select2-selected');\n\t\t\t\t\t\t\t\tels.addClass('select2-selected-highlight').addClass('select2-disabled').removeClass('select2-selected').removeClass('select2-result-selectable');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}).on('select2-close', function() {\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar el_container = jQuery(this).parent();\n\t\t\t\t\t\t\tvar el = jQuery(this).parent().find('.select2-input');\n\t\t\t\t\t\t\tvar el_label = el.prevAll('.fc_has_inner_label');\n\t\t\t\t\t\t\tif (el_label) el_label.show();\n\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\tif (el_prompt) el_prompt.hide();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tif (jQuery(this).hasClass('select2_list_selected')) {\n\t\t\t\t\t\t\t\tvar els = jQuery('#select2-drop').find('.select2-selected-highlight');\n\t\t\t\t\t\t\t\tels.removeClass('select2-selected-highlight').removeClass('select2-disabled').addClass('select2-result-selectable');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}).on\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\t('change', function() {\n\t\t\t\t\t\t\tvar el_select = jQuery(this);\n\t\t\t\t\t\t\tif ( ! el_select.attr('multiple') && !el_select.hasClass('fc_skip_highlight') ) {\n\t\t\t\t\t\t\t\tvar el = jQuery(this).prev('div').find('.select2-choice');\n\t\t\t\t\t\t\t\tvar val = el_select.val();\n\t\t\t\t\t\t\t\tif (!!val && val.length) {\n\t\t\t\t\t\t\t\t\tel.addClass('fc_highlight');\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tel.removeClass('fc_highlight');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('div.use_select2_lib.select2-container-multi input').on('keydown', function() {\n\t\t\t\t\t\t\tvar el = jQuery(this);\n\t\t\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\t\t\tvar val = el.val();\n\t\t\t\t\t\t\t\tif (!!val && val.length) {\n\t\t\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\t\t\tif (el_prompt) el_prompt.hide();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\t\t\tif (el_prompt) el_prompt.show();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}, 0);\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('select.use_select2_lib').on('loaded open', function() {\n\t\t\t\t\t\t\tvar ul = jQuery('#select2-drop ul.select2-results');\n\t\t\t\t\t\t\tvar needsScroll= ul.prop('scrollHeight') > ul.prop('clientHeight');\n\t\t\t\t\t\t\tif (needsScroll) ul.css('overflow-y', 'scroll');\n\t\t\t\t\t\t\telse ul.css('overflow-y', 'auto');\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'inputmask': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/inputmask'; $document->addScript($framework_path . '/jquery.inputmask.bundle.min.js'); // Extra inputmask declarations definitions, e.g. ... $js .= "\n\t\t\t\t"; // Attach inputmask to all input fields that have appropriate tag parameters $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tInputmask.extendAliases({\n\t\t\t\t\t\t\tdecimal: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tradixPoint: '.',\n\t\t\t\t\t\t\t\tgroupSeparator: ',',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdecimal_comma: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tradixPoint: ',',\n\t\t\t\t\t\t\t\tgroupSeparator: '.',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcurrency: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tprefix: '\$ ',\n\t\t\t\t\t\t\t\tgroupSeparator: ',',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tdigitsOptional: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcurrency_euro: {\n\t\t\t\t\t\t\t\talias: 'currency',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tprefix: '\\u20ac ',\n\t\t\t\t\t\t\t\tgroupSeparator: ',',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tdigitsOptional: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: false,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpercentage_zero_nolimit: {\n\t\t\t\t\t\t\t\talias: 'percentage',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tradixPoint: '.',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tmin: 0,\n\t\t\t\t\t\t\t\tmax: '',\n\t\t\t\t\t\t\t\tsuffix: ' %',\n\t\t\t\t\t\t\t\tallowPlus: false,\n\t\t\t\t\t\t\t\tallowMinus: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpercentage_nolimit_nolimit: {\n\t\t\t\t\t\t\t\talias: 'percentage',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tradixPoint: '.',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tmin: '',\n\t\t\t\t\t\t\t\tmax: '',\n\t\t\t\t\t\t\t\tsuffix: ' %',\n\t\t\t\t\t\t\t\tallowPlus: false,\n\t\t\t\t\t\t\t\tallowMinus: true,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tinteger: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 0,\n\t\t\t\t\t\t\t\tradixPoint: '',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tunsigned: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 0,\n\t\t\t\t\t\t\t\tradixPoint: '',\n\t\t\t\t\t\t\t\tallowPlus: false,\n\t\t\t\t\t\t\t\tallowMinus: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'mobile': {\n\t\t\t\t\t\t\t\t'mask': '9999 999 999',\n\t\t\t\t\t\t\t\t'autounmask': true,\n\t\t\t\t\t\t\t\t'insertMode': true,\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery('input.has_inputmask').inputmask();\n\t\t\t\t\t\tjQuery('input.inputmask-regex').inputmask('Regex');\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'prettyCheckable': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/prettyCheckable'; $document->addScript($framework_path . '/dev/prettyCheckable.js'); $document->addStyleSheet($framework_path . '/dist/prettyCheckable.css'); $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('input.use_prettycheckable').each(function() {\n\t\t\t\t\t\t\tvar elem = jQuery(this);\n\t\t\t\t\t\t\tvar lbl = elem.next('label');\n\t\t\t\t\t\t\tvar lbl_html = elem.next('label').html();\n\t\t\t\t\t\t\tlbl.remove();\n\t\t\t\t\t\t\telem.prettyCheckable({\n\t\t\t\t\t\t\t\tcolor: 'blue',\n\t\t\t\t\t\t\t\tlabel: lbl_html\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'multibox': case 'jmultibox': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/jmultibox'; // Add JS $document->addScript($framework_path . '/js/jmultibox.js'); $document->addScript($framework_path . '/js/jquery.vegas.js'); // Add CSS $document->addStyleSheet($framework_path . '/styles/multibox.css'); $document->addStyleSheet($framework_path . '/styles/jquery.vegas.css'); if (substr($_SERVER['HTTP_USER_AGENT'], 0, 34) == "Mozilla/4.0 (compatible; MSIE 6.0;") { $document->addStyleSheet($framework_path . '/styles/multibox-ie6.css'); } // Attach multibox to ... this will be left to the caller so that it will create a multibox object with custom options //$js .= ""; break; case 'fancybox': if ($load_jquery) { flexicontent_html::loadJQuery(); } $document->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/jquery-easing.js'); $framework_path = JURI::root(true) . $lib_path . '/fancybox'; // Add mousewheel plugin (this is optional) $document->addScript($framework_path . '/lib/jquery.mousewheel-3.0.6.pack.js'); // Add fancyBox CSS / JS $document->addStyleSheet($framework_path . '/source/jquery.fancybox.css'); $document->addScript($framework_path . '/source/jquery.fancybox.pack.js'); // Optionally add helpers - button, thumbnail and/or media $document->addStyleSheet($framework_path . '/source/helpers/jquery.fancybox-buttons.css'); $document->addScript($framework_path . '/source/helpers/jquery.fancybox-buttons.js'); $document->addScript($framework_path . '/source/helpers/jquery.fancybox-media.js'); $document->addStyleSheet($framework_path . '/source/helpers/jquery.fancybox-thumbs.css'); $document->addScript($framework_path . '/source/helpers/jquery.fancybox-thumbs.js'); // Attach fancybox to all elements having a specific CSS class $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('.fancybox').fancybox({\n\t\t\t\t\t\t\t'openEffect'\t: 'elastic',\n\t\t\t\t\t\t\t'closeEffect'\t: 'elastic',\n\t\t\t\t\t\t\t'openEasing' : 'easeOutCubic',\n\t\t\t\t\t\t\t'closeEasing' : 'easeInCubic',\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'galleriffic': if ($load_jquery) { flexicontent_html::loadJQuery(); } //flexicontent_html::loadFramework('fancybox'); $framework_path = JURI::root(true) . $lib_path . '/galleriffic'; //$document->addStyleSheet($framework_path.'/css/basic.css'); // This is too generic and should not be loaded $document->addStyleSheet($framework_path . '/css/galleriffic-3.css'); $document->addScript($framework_path . '/js/jquery.galleriffic.js'); $document->addScript($framework_path . '/js/jquery.opacityrollover.js'); break; case 'elastislide': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/elastislide'; $document->addStyleSheet($framework_path . '/css/style.css'); $document->addStyleSheet($framework_path . '/css/elastislide.css'); $document->addScript($framework_path . '/js/jquery.tmpl.min.js'); $document->addScript($framework_path . '/js/jquery.easing.1.3.js'); $document->addScript($framework_path . '/js/jquery.elastislide.js'); //$document->addScript($framework_path.'/js/gallery.js'); // replace with field specific: gallery_tmpl.js break; case 'photoswipe': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/photoswipe'; //$document->addStyleSheet($framework_path.'/lib/jquery.mobile/jquery.mobile.css'); $document->addStyleSheet($framework_path . '/photoswipe.css'); //$document->addScript($framework_path.'/lib/jquery.mobile/jquery.mobile.js'); $document->addScript($framework_path . '/lib/simple-inheritance.min.js'); //$document->addScript($framework_path.'/lib/jquery.animate-enhanced.min.js'); $document->addScript($framework_path . '/code.photoswipe.min.js'); $js .= "\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\tvar myPhotoSwipe = jQuery('.photoswipe_fccontainer a').photoSwipe(); \n\t\t\t\t});\n\t\t\t\t"; break; case 'fcxSlide': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/fcxSlide'; $document->addScriptVersion($framework_path . '/class.fcxSlide.js', FLEXI_VHASH); $document->addStyleSheetVersion($framework_path . '/fcxSlide.css', FLEXI_VHASH); //$document->addScriptVersion($framework_path.'/class.fcxSlide.packed.js', FLEXI_VHASH); break; case 'imagesLoaded': $framework_path = JURI::root(true) . $lib_path . '/imagesLoaded'; $document->addScript($framework_path . '/imagesloaded.pkgd.min.js'); break; case 'noobSlide': // Make sure mootools are loaded FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); $framework_path = JURI::root(true) . $lib_path . '/noobSlide'; //$document->addScript($framework_path.'/_class.noobSlide.js'); $document->addScript($framework_path . '/_class.noobSlide.packed.js'); break; case 'zTree': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/zTree'; $document->addStyleSheet($framework_path . '/css/flexi_ztree.css'); $document->addStyleSheet($framework_path . '/css/zTreeStyle/zTreeStyle.css'); $document->addScript($framework_path . '/js/jquery.ztree.all-3.5.min.js'); //$document->addScript($framework_path.'/js/jquery.ztree.core-3.5.js'); //$document->addScript($framework_path.'/js/jquery.ztree.excheck-3.5.js'); //$document->addScript($framework_path.'/js/jquery.ztree.exedit-3.5.js'); break; case 'plupload': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/plupload'; $document->addScript($framework_path . '/js/plupload.full.min.js'); if ($mode == 'ui') { $document->addStyleSheet($framework_path . '/js/jquery.ui.plupload/css/jquery.ui.plupload.css'); $document->addScript($framework_path . '/js/jquery.ui.plupload/jquery.ui.plupload.min.js'); $document->addScript($framework_path . '/js/themeswitcher.js'); } else { $document->addStyleSheet($framework_path . '/js/jquery.plupload.queue/css/jquery.plupload.queue.css'); $document->addScript($framework_path . '/js/jquery.plupload.queue/jquery.plupload.queue.js'); } $lang_code = flexicontent_html::getUserCurrentLang(); if ($lang_code && $lang_code != 'en') { // Try language shortcode if (file_exists($framework_folder . DS . 'js' . DS . $lang_code . '.js')) { $document->addScript($framework_path . '/js/' . $lang_code . '.js'); } else { $country_code = flexicontent_html::getUserCurrentLang($short_tag = false); if ($country_code && file_exists($framework_folder . DS . 'js' . DS . $country_code . '.js')) { $document->addScript($framework_path . '/js/' . $country_code . '.js'); } } } // For debugging //$document->addScript($framework_path.'/js/moxie.min.js'); //$document->addScript($framework_path.'/js/plupload.dev.js'); break; case 'nouislider': $framework_path = JURI::root(true) . $lib_path . '/nouislider'; $document->addStyleSheet($framework_path . '/nouislider.min.css'); $document->addScript($framework_path . '/nouislider.min.js'); break; case 'flexi_tmpl_common': if ($load_jquery) { flexicontent_html::loadJQuery(); } flexicontent_html::loadFramework('select2'); // make sure select2 is loaded // Make sure user cookie is set $jcookie = $app->input->cookie; $fc_uid = $jcookie->get('fc_uid', null); $hashedUA = JFactory::getUser()->id ? JUserHelper::getShortHashedUserAgent() : 'p'; if ($fc_uid != $hashedUA) { $jcookie->set('fc_uid', $hashedUA, 0); } $js .= "\n\t\t\t\t\tvar _FC_GET = " . json_encode($_GET) . ";\n\t\t\t\t"; $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/tmpl-common.js', FLEXI_VHASH); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/jquery-easing.js', FLEXI_VHASH); JText::script("FLEXI_APPLYING_FILTERING", true); JText::script("FLEXI_TYPE_TO_LIST", true); JText::script("FLEXI_TYPE_TO_FILTER", true); JText::script("FLEXI_UPDATING_CONTENTS", true); break; case 'flexi-lib': if ($load_jquery) { flexicontent_html::loadJQuery(); } $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/flexi-lib.js', FLEXI_VHASH); JText::script("FLEXI_NOT_AN_IMAGE_FILE", true); break; default: JFactory::getApplication()->enqueueMessage(__FUNCTION__ . ' Cannot load unknown Framework: ' . $framework, 'error'); break; } // Add custom JS & CSS code if ($js) { $document->addScriptDeclaration($js); } if ($css) { $document->addStyleDeclaration($css); } return $_loaded[$framework]; }
/** * Display the view */ function display($cachable = null, $urlparams = false) { // Debuging message //JError::raiseNotice(500, 'IN display()'); // TOREMOVE $CLIENT_CACHEABLE_PUBLIC = 1; $CLIENT_CACHEABLE_PRIVATE = 2; $jinput = JFactory::getApplication()->input; $userid = JFactory::getUser()->get('id'); $cc = $jinput->get('cc', null); $view = $jinput->get('view', '', 'cmd'); $layout = $jinput->get('layout', '', 'cmd'); // Access checking for --items-- viewing, will be handled by the items model, this is because THIS display() TASK is used by other views too // in future it maybe moved here to the controller, e.g. create a special task item_display() for item viewing, or insert some IF bellow // /////////////////////// // Display case: ITEM FORM // /////////////////////// // Also a compatibility check: Layout is form and task is not set: this is new item submit ... if ($jinput->get('layout', false) == "form" && !$jinput->get('task', false)) { $jinput->set('browser_cachable', 0); $jinput->set('task', 'add'); $this->add(); return; } // ////////////////////////////////////////////////////////////////////////// // Display case: FLEXIcontent frontend view (category, item, favourites, etc) // ////////////////////////////////////////////////////////////////////////// // ******************* // Handle SERVER Cache // ******************* // SHOW RECENT FAVOURED ITEMS IMMEDIATELY: do not cache the view if ($view == 'favourites' || $view == 'category' && $layout == 'favs') { $cachable = false; } else { if ($view == 'search' || $jinput->get('filter')) { $cachable = false; } else { $cachable = true; foreach ($_GET as $i => $v) { if (substr($i, 0, 7) === "filter_") { $cachable = false; break; } } } } // ******************** // Handle browser Cache // ******************** if ($cc !== null) { // Currently our plugin will ignore this and force 'private', because of risk to break 3rd party extensions doing cookie-based content per guest $browser_cachable = $userid ? $CLIENT_CACHEABLE_PRIVATE : $CLIENT_CACHEABLE_PUBLIC; } else { $browser_cachable = 0; } // CASE: urlparams were explicitely given if (!empty($urlparams)) { $safeurlparams =& $urlparams; } else { $safeurlparams = array(); // Add menu URL variables $menu = JFactory::getApplication()->getMenu()->getActive(); if ($menu) { foreach ($menu->query as $_varname => $_ignore) { $safeurlparams[$_varname] = 'STRING'; } } // Add any existing URL variables (=submitted via GET), ... we only need variable names, (so can use them unfiltered) foreach ($_GET as $_varname => $_ignore) { $safeurlparams[$_varname] = 'STRING'; } } // If component is serving different pages to logged users, this will avoid // having users seeing same page after login/logout when conservative caching is used if ($userid = JFactory::getUser()->get('id')) { $jinput->set('__fc_user_id__', $userid); $safeurlparams['__fc_user_id__'] = 'STRING'; } $cparams = JComponentHelper::getParams('com_flexicontent'); $use_mobile_layouts = $cparams->get('use_mobile_layouts', 0); $tabletSameAsDesktop = $cparams->get('force_desktop_layout', 0) == 1; // If component is serving different pages for mobile devices, this will avoid // having users seeing the same page regardless of being on desktop or mobile $mobileDetector = flexicontent_html::getMobileDetector(); //$client = JFactory::getApplication()->client; $isMobile = $client->mobile; $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); if ($use_mobile_layouts && $isMobile && (!$isTablet || !$tabletSameAsDesktop)) { $jinput->set('__fc_client__', 'Mobile'); $safeurlparams['__fc_client__'] = 'STRING'; } // Moved code for browser's cache control to system plugin to do at the latest possible point // =0, NOT user brower CACHEABLE // >0, user browser CACHEABLE, ask browser to store and redisplay it, without revalidating // *** Intermediary Cache control // 1 means CACHEABLE, PUBLIC content, proxies can cache: 'Cache-Control:public' // 2 means CACHEABLE, PRIVATE (logged user) content, proxies must not cache: 'Cache-Control:private' // null will let default (Joomla website) HTTP headers, e.g. re-validate $jinput->set('browser_cachable', $browser_cachable); //echo "cacheable: ".(int)$cachable." - " . print_r($safeurlparams, true) ."<br/>"; parent::display($cachable, $safeurlparams); }
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { // Get isMobile / isTablet Flags static $isMobile = null; static $isTablet = null; static $useMobile = null; if ($useMobile === null) { $cparams = JComponentHelper::getParams('com_flexicontent'); $force_desktop_layout = $cparams->get('force_desktop_layout', 0); //$start_microtime = microtime(true); $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile; //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000); } // execute the code only if the field type match the plugin type if (!in_array($field->field_type, self::$field_types)) { return; } $field->label = JText::_($field->label); static $multiboxadded = false; static $fancyboxadded = false; static $gallerifficadded = false; static $elastislideadded = false; static $photoswipeadded = false; $values = $values ? $values : $field->value; $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW)); $multiple = $field->parameters->get('allow_multiple', 0); $image_source = $field->parameters->get('image_source', 0); if ($image_source > 1) { global $fc_folder_mode_err; if (empty($fc_folder_mode_err[$field->id])) { echo __FUNCTION__ . "(): folder-mode: " . $image_source . " not implemented please change image-source mode in image/gallery field with id: " . $field->id; $fc_folder_mode_err[$field->id] = 1; $image_source = 1; } } $all_media = $field->parameters->get('list_all_media_files', 0); $unique_thumb_method = $field->parameters->get('unique_thumb_method', 0); $dir = $field->parameters->get('dir'); $dir_url = str_replace('\\', '/', $dir); // Check if using folder of original content being translated $of_usage = $field->untranslatable ? 1 : $field->parameters->get('of_usage', 0); $u_item_id = $of_usage && $item->lang_parent_id && $item->lang_parent_id != $item->id ? $item->lang_parent_id : $item->id; // FLAG to indicate if images are shared across fields, has the effect of adding field id to image thumbnails $multiple_image_usages = !$image_source && $all_media && $unique_thumb_method == 0; $extra_prefix = $multiple_image_usages ? 'fld' . $field->id . '_' : ''; $usealt = $field->parameters->get('use_alt', 1); $alt_usage = $field->parameters->get('alt_usage', 0); $default_alt = $alt_usage == 2 ? $field->parameters->get('default_alt', '') : ''; $usetitle = $field->parameters->get('use_title', 1); $title_usage = $field->parameters->get('title_usage', 0); $default_title = $title_usage == 2 ? JText::_($field->parameters->get('default_title', '')) : ''; $usedesc = $field->parameters->get('use_desc', 1); $desc_usage = $field->parameters->get('desc_usage', 0); $default_desc = $desc_usage == 2 ? $field->parameters->get('default_desc', '') : ''; // Separators / enclosing characters $remove_space = $field->parameters->get('remove_space', 0); $pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('pretext', ''), 'pretext'); $posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('posttext', ''), 'posttext'); $separatorf = $field->parameters->get('separatorf', 0); $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag'); $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag'); if ($pretext) { $pretext = $remove_space ? $pretext : $pretext . ' '; } if ($posttext) { $posttext = $remove_space ? $posttext : ' ' . $posttext; } 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; } // intro-full mode get their values from item's parameters if ($image_source == -1) { $values = array(); $_image_name = $view == 'item' ? 'full' : 'intro'; $_image_path = $item->images->get('image_' . $_image_name, ''); if ($_image_path) { $image_by_params = array(); // field attributes (mode-specific) $image_by_params['image_size'] = $_image_name; $image_by_params['image_path'] = $_image_path; // field attributes (value) $image_by_params['originalname'] = basename($_image_path); $image_by_params['alt'] = $item->images->get($_image_name . '_alt', ''); $image_by_params['title'] = $item->images->get($_image_name . '_alt', ''); $image_by_params['desc'] = $item->images->get($_image_name . '_caption', ''); $image_by_params['urllink'] = ''; $values = array(serialize($image_by_params)); } } // Check for deleted image files or image files that cannot be thumbnailed, // rebuilding thumbnails as needed, and then assigning checked values to a new array $usable_values = array(); if ($values) { foreach ($values as $index => $value) { $value = unserialize($value); if (plgFlexicontent_fieldsImage::rebuildThumbs($field, $value, $item)) { $usable_values[] = $values[$index]; } } } $values =& $usable_values; // Allow for thumbnailing of the default image $field->using_default_value = false; if (!count($values)) { // Create default image to be used if (a) no image assigned OR (b) images assigned have been deleted $default_image = $field->parameters->get('default_image', ''); if ($default_image) { $default_image_val = array(); // field attributes (default value specific) $default_image_val['default_image'] = $default_image; // holds complete relative path and indicates that it is default image for field // field attributes (value) $default_image_val['originalname'] = basename($default_image); $default_image_val['alt'] = $default_alt; $default_image_val['title'] = $default_title; $default_image_val['desc'] = $default_desc; $default_image_val['urllink'] = ''; // Create thumbnails for default image if (plgFlexicontent_fieldsImage::rebuildThumbs($field, $default_image_val, $item)) { $values = array(serialize($default_image_val)); } // Also default image can (possibly) be used across multiple fields, so set flag to add field id to filenames of thumbnails $multiple_image_usages = true; $extra_prefix = 'fld' . $field->id . '_'; $field->using_default_value = true; } } // Check for no values, and return empty display, otherwise assign (possibly) altered value array to back to the field if (!count($values)) { $field->{$prop} = ''; return; } $field->value = $values; $app = JFactory::getApplication(); $document = JFactory::getDocument(); $option = JRequest::getVar('option'); jimport('joomla.filesystem'); $isFeedView = JRequest::getCmd('format', null) == 'feed'; $isItemsManager = $app->isAdmin() && $view == 'items' && $option == 'com_flexicontent'; $isSite = $app->isSite(); // some parameter shortcuts $uselegend = $field->parameters->get('uselegend', 1); $usepopup = $field->parameters->get('usepopup', 1); $popuptype = $field->parameters->get('popuptype', 1); $popuptype_mobile = $field->parameters->get('popuptype_mobile', $popuptype); // this defaults to desktop when empty $popuptype = $useMobile ? $popuptype_mobile : $popuptype; $grouptype = $field->parameters->get('grouptype', 1); $grouptype = $multiple ? 0 : $grouptype; // Field in gallery mode: Force grouping of images per field (current item) // Needed by some js galleries $thumb_w_s = $field->parameters->get('w_s', 120); $thumb_h_s = $field->parameters->get('h_s', 90); // Check and disable 'uselegend' $legendinview = $field->parameters->get('legendinview', array(FLEXI_ITEMVIEW, 'category')); $legendinview = FLEXIUtilities::paramToArray($legendinview); if ($view == FLEXI_ITEMVIEW && !in_array(FLEXI_ITEMVIEW, $legendinview)) { $uselegend = 0; } if ($view == 'category' && !in_array('category', $legendinview)) { $uselegend = 0; } if ($isItemsManager && !in_array('backend', $legendinview)) { $uselegend = 0; } // Check and disable 'usepopup' $popupinview = $field->parameters->get('popupinview', array(FLEXI_ITEMVIEW, 'category', 'backend')); $popupinview = FLEXIUtilities::paramToArray($popupinview); if ($view == FLEXI_ITEMVIEW && !in_array(FLEXI_ITEMVIEW, $popupinview)) { $usepopup = 0; } if ($view == 'category' && !in_array('category', $popupinview)) { $usepopup = 0; } if ($view == 'module' && !in_array('module', $popupinview)) { $usepopup = 0; } if ($isItemsManager && !in_array('backend', $popupinview)) { $usepopup = 0; } // FORCE multibox popup in backend ... if ($isItemsManager) { $popuptype = 1; } // remaining parameters shortcuts $showtitle = $field->parameters->get('showtitle', 0); $showdesc = $field->parameters->get('showdesc', 0); $linkto_url = $field->parameters->get('linkto_url', 0); $url_target = $field->parameters->get('url_target', '_self'); $isLinkToPopup = $linkto_url && $url_target == 'multibox'; $useogp = $field->parameters->get('useogp', 0); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpthumbsize = $field->parameters->get('ogpthumbsize', 2); // load the tooltip library if redquired if ($uselegend) { JHTML::_('behavior.tooltip'); } // MultiBox maybe added in extra cases besides popup // (a) in Item manager, (b) When linking to URL in popup target $view_allows_mb = $isItemsManager || $isSite && !$isFeedView; $config_needs_mb = $isLinkToPopup || $usepopup && $popuptype == 1; if ($view_allows_mb && $config_needs_mb) { if (!$multiboxadded) { //echo $field->name.": multiboxadded"; FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); // Multibox integration use different version for FC v2x if (FLEXI_J16GE) { // Include MultiBox CSS files $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/Styles/multiBox.css'); // NEW ie6 hack if (substr($_SERVER['HTTP_USER_AGENT'], 0, 34) == "Mozilla/4.0 (compatible; MSIE 6.0;") { $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/Styles/multiBoxIE6.css'); } // This is the new code for new multibox version, old multibox hack is the following lines // Include MultiBox Javascript files $document->addScript(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/Scripts/overlay.js'); $document->addScript(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/Scripts/multiBox.js'); // Add js code for creating a multibox instance $extra_options = ''; if ($isItemsManager) { $extra_options .= '' . ',showNumbers: false' . ',showControls: false'; } $box = "\n\t\t\t\t\t\twindow.addEvent('domready', function(){\n\t\t\t\t\t\t\t//call multiBox\n\t\t\t\t\t\t\tvar initMultiBox = new multiBox({\n\t\t\t\t\t\t\t\tmbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)\n\t\t\t\t\t\t\t\tcontainer: \$(document.body),//where to inject multiBox\n\t\t\t\t\t\t\t\tdescClassName: 'multiBoxDesc',//the class name of the description divs\n\t\t\t\t\t\t\t\tpath: './Files/',//path to mp3 and flv players\n\t\t\t\t\t\t\t\tuseOverlay: true,//use a semi-transparent background. default: false;\n\t\t\t\t\t\t\t\tmaxSize: {w:4000, h:3000},//max dimensions (width,height) - set to null to disable resizing\n\t\t\t\t\t\t\t\taddDownload: false,//do you want the files to be downloadable?\n\t\t\t\t\t\t\t\tpathToDownloadScript: './Scripts/forceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)\n\t\t\t\t\t\t\t\taddRollover: true,//add rollover fade to each multibox link\n\t\t\t\t\t\t\t\taddOverlayIcon: true,//adds overlay icons to images within multibox links\n\t\t\t\t\t\t\t\taddChain: true,//cycle through all images fading them out then in\n\t\t\t\t\t\t\t\trecalcTop: true,//subtract the height of controls panel from top position\n\t\t\t\t\t\t\t\taddTips: true,//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)\n\t\t\t\t\t\t\t\tautoOpen: 0//to auto open a multiBox element on page load change to (1, 2, or 3 etc)\n\t\t\t\t\t\t\t\t" . $extra_options . "\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t"; $document->addScriptDeclaration($box); } else { // Include MultiBox CSS files $document->addStyleSheet(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/multibox.css'); // OLD ie6 hack $csshack = ' <!--[if lte IE 6]> <style type="text/css"> .MultiBoxClose, .MultiBoxPrevious, .MultiBoxNext, .MultiBoxNextDisabled, .MultiBoxPreviousDisabled { behavior: url(' . 'components/com_flexicontent/librairies/multibox/iepngfix.htc); } </style> <![endif]--> '; $document->addCustomTag($csshack); // Include MultiBox Javascript files $document->addScript(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/js/overlay.js'); $document->addScript(JURI::root(true) . '/components/com_flexicontent/librairies/multibox/js/multibox.js'); // Add js code for creating a multibox instance $extra_options = $isItemsManager ? ', showNumbers: false, showControls: false' : ''; $box = "\n\t\t\t\t\t\tvar box = {};\n\t\t\t\t\t\twindow.addEvent('domready', function(){\n\t\t\t\t\t\t\tbox = new MultiBox('mb', {descClassName: 'multiBoxDesc', useOverlay: true" . $extra_options . " });\n\t\t\t\t\t\t});\n\t\t\t\t\t"; $document->addScriptDeclaration($box); } $multiboxadded = true; } } // Regardless if above has added multibox , we will add a different JS gallery if so configured because it maybe needed if (!$isSite || $isFeedView) { // Is backend OR it is a feed view, do not add any JS library } else { if ($usepopup) { switch ($popuptype) { // Add Fancybox image popup case 4: if (!$fancyboxadded) { $fancyboxadded = true; flexicontent_html::loadFramework('fancybox'); } break; // Add Galleriffic inline slideshow gallery // Add Galleriffic inline slideshow gallery case 5: $inline_gallery = 1; if (!$gallerifficadded) { flexicontent_html::loadFramework('galleriffic'); $gallerifficadded = true; } break; // Add Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description) // Add Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description) case 7: if (!$elastislideadded) { flexicontent_html::loadFramework('elastislide'); $elastislideadded = true; } $uid = 'es_' . $field->name . "_fcitem" . $item->id; $js = file_get_contents(JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'elastislide' . DS . 'js' . DS . 'gallery_tmpl.js'); $js = str_replace('unique_gal_id', $uid, $js); $js = str_replace('__thumb_width__', $field->parameters->get('w_s', 120), $js); $document->addScriptDeclaration($js); $document->addCustomTag(' <script id="img-wrapper-tmpl_' . $uid . '" type="text/x-jquery-tmpl"> <div class="rg-image-wrapper"> {{if itemsCount > 1}} <div class="rg-image-nav"> <a href="#" class="rg-image-nav-prev">' . JText::_('FLEXI_PREVIOUS') . '</a> <a href="#" class="rg-image-nav-next">' . JText::_('FLEXI_NEXT') . '</a> </div> {{/if}} <div class="rg-image"></div> <div class="rg-loading"></div> <div class="rg-caption-wrapper"> <div class="rg-caption" style="display:none;"> <p></p> </div> </div> </div> </script> '); break; // Add PhotoSwipe popup carousel gallery // Add PhotoSwipe popup carousel gallery case 8: if (!$photoswipeadded) { flexicontent_html::loadFramework('photoswipe'); $photoswipeadded = true; } break; } } } // Extra thumbnails sub-folder for various if ($field->using_default_value) { $extra_folder = ''; // default value } else { if ($image_source == -1) { $extra_folder = 'intro_full'; // intro-full images mode } else { if ($image_source > 0) { $extra_folder = 'item_' . $u_item_id . '_field_' . $field->id; // folder-mode 1 if ($image_source > 1) { } // TODO } else { $extra_folder = ''; // db-mode } } } // Create thumbs/image Folder and URL paths $thumb_folder = JPATH_SITE . DS . JPath::clean($dir . ($extra_folder ? DS . $extra_folder : '')); $thumb_urlpath = $dir_url . ($extra_folder ? '/' . $extra_folder : ''); if ($field->using_default_value) { // default image of this field, these are relative paths up to site root $orig_urlpath = str_replace('\\', '/', dirname($default_image_val['default_image'])); } else { if ($image_source == -1) { // intro-full image values, these are relative paths up to the site root, must be calculated later !! $orig_urlpath = str_replace('\\', '/', dirname($image_by_params['image_path'])); } else { if ($image_source > 0) { // various folder-mode(s) $orig_urlpath = $thumb_urlpath . '/original'; } else { // db-mode $cparams = JComponentHelper::getParams('com_flexicontent'); $orig_urlpath = str_replace('\\', '/', JPath::clean($cparams->get('file_path', 'components/com_flexicontent/uploads'))); } } } $i = -1; $field->{$prop} = array(); $field->thumbs_src['backend'] = array(); $field->thumbs_src['small'] = array(); $field->thumbs_src['medium'] = array(); $field->thumbs_src['large'] = array(); $field->thumbs_src['original'] = array(); foreach ($values as $val) { // Unserialize value's properties and check for empty original name property $value = unserialize($val); $image_name = trim(@$value['originalname']); if (!strlen($image_name)) { continue; } $i++; // Create thumbnails urls, note thumbnails have already been verified above $wl = $field->parameters->get('w_l', 800); $hl = $field->parameters->get('h_l', 600); $title = @$value['title'] ? $value['title'] : ''; $alt = @$value['alt'] ? $value['alt'] : flexicontent_html::striptagsandcut($item->title, 60); $alt = flexicontent_html::escapeJsText($alt, 's'); $desc = @$value['desc'] ? $value['desc'] : ''; $srcb = $thumb_urlpath . '/b_' . $extra_prefix . $image_name; // backend $srcs = $thumb_urlpath . '/s_' . $extra_prefix . $image_name; // small $srcm = $thumb_urlpath . '/m_' . $extra_prefix . $image_name; // medium $srcl = $thumb_urlpath . '/l_' . $extra_prefix . $image_name; // large $srco = $orig_urlpath . '/' . $image_name; // original image // Create a popup url link $urllink = @$value['urllink'] ? $value['urllink'] : ''; if ($urllink && false === strpos($urllink, '://')) { $urllink = 'http://' . $urllink; } // Create a popup tooltip (legend) $tip = $title . '::' . $desc; $tip = flexicontent_html::escapeJsText($tip, 's'); $legend = $uselegend && (!empty($title) || !empty($desc)) ? ' class="hasTip" title="' . $tip . '"' : ''; // Create a unique id for the link tags, and a class name for image tags $uniqueid = $field->item_id . '_' . $field->id . '_' . $i; $class_img_field = 'fc_field_image'; // Decide thumbnail to use $thumb_size = 0; if ($isItemsManager) { $thumb_size = -1; } else { if ($view == 'category') { $thumb_size = $field->parameters->get('thumbincatview', 1); } else { if ($view == FLEXI_ITEMVIEW) { $thumb_size = $field->parameters->get('thumbinitemview', 2); } } } switch ($thumb_size) { case -1: $src = $srcb; break; case 1: $src = $srcs; break; case 2: $src = $srcm; break; case 3: $src = $srcl; break; // this makes little sense, since both thumbnail and popup image are size 'large' // this makes little sense, since both thumbnail and popup image are size 'large' case 4: $src = $srco; break; default: $src = $srcs; break; } // Create a grouping name switch ($grouptype) { case 0: $group_name = 'fcview_' . $view . '_fcitem_' . $field->item_id . '_fcfield_' . $field->id; break; case 1: $group_name = 'fcview_' . $view . '_fcitem_' . $field->item_id; break; case 2: $group_name = 'fcview_' . $view; break; default: $group_name = ''; break; } // ADD some extra (display) properties that point to all sizes, currently SINGLE IMAGE only if ($i == 0) { $field->{"display_backend_src"} = JURI::root(true) . '/' . $srcb; $field->{"display_small_src"} = JURI::root(true) . '/' . $srcs; $field->{"display_medium_src"} = JURI::root(true) . '/' . $srcm; $field->{"display_large_src"} = JURI::root(true) . '/' . $srcl; $field->{"display_original_src"} = JURI::root(true) . '/' . $srco; } $field->thumbs_src['backend'][] = JURI::root(true) . '/' . $srcb; $field->thumbs_src['small'][] = JURI::root(true) . '/' . $srcs; $field->thumbs_src['medium'][] = JURI::root(true) . '/' . $srcm; $field->thumbs_src['large'][] = JURI::root(true) . '/' . $srcl; $field->thumbs_src['original'][] = JURI::root(true) . '/' . $srco; $field->thumbs_path['backend'][] = JPATH_SITE . DS . $srcb; $field->thumbs_path['small'][] = JPATH_SITE . DS . $srcs; $field->thumbs_path['medium'][] = JPATH_SITE . DS . $srcm; $field->thumbs_path['large'][] = JPATH_SITE . DS . $srcl; $field->thumbs_path['original'][] = JPATH_SITE . DS . $srco; // Suggest image for external use, e.g. for Facebook etc if ($isSite && !$isFeedView && $useogp) { if (in_array($view, $ogpinview)) { switch ($ogpthumbsize) { case 1: $ogp_src = $field->{"display_small_src"}; break; // this maybe problematic, since it maybe too small or not accepted by social website // this maybe problematic, since it maybe too small or not accepted by social website case 2: $ogp_src = $field->{"display_medium_src"}; break; case 3: $ogp_src = $field->{"display_large_src"}; break; case 4: $ogp_src = $field->{"display_original_src"}; break; default: $ogp_src = $field->{"display_medium_src"}; break; } $document->addCustomTag('<link rel="image_src" href="' . $ogp_src . '" />'); $document->addCustomTag('<meta property="og:image" content="' . $ogp_src . '" />'); } } // Check if a custom URL-only (display) variable was requested and return it here, // without rendering the extra image parameters like legend, pop-up, etc if (in_array($prop, array("display_backend_src", "display_small_src", "display_medium_src", "display_large_src", "display_original_src"))) { return $field->{$prop}; } // Create image tags (according to configuration parameters) that will be used for the requested 'display' variable switch ($prop) { case 'display_backend': $img_legend = '<img src="' . JURI::root(true) . '/' . $srcb . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcb . '" alt="' . $alt . '" class="' . $class_img_field . '" />'; break; case 'display_small': $img_legend = '<img src="' . JURI::root(true) . '/' . $srcs . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcs . '" alt="' . $alt . '" class="' . $class_img_field . '" />'; break; case 'display_medium': $img_legend = '<img src="' . JURI::root(true) . '/' . $srcm . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcm . '" alt="' . $alt . '" class="' . $class_img_field . '" />'; break; case 'display_large': $img_legend = '<img src="' . JURI::root(true) . '/' . $srcl . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srcl . '" alt="' . $alt . '" class="' . $class_img_field . '" />'; break; case 'display_original': $img_legend = '<img src="' . JURI::root(true) . '/' . $srco . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $srco . '" alt="' . $alt . '" class="' . $class_img_field . '" />'; break; case 'display': default: $img_legend = '<img src="' . JURI::root(true) . '/' . $src . '" alt="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" />'; $img_nolegend = '<img src="' . JURI::root(true) . '/' . $src . '" alt="' . $alt . '" class="' . $class_img_field . '" />'; break; } // ********************************************* // FINALLY CREATE the field display variable ... // ********************************************* if ($isItemsManager) { // CASE 1: Handle image displayed in backend items manager if ($usepopup) { $field->{$prop} = ' <a href="../' . $srcl . '" id="mb' . $uniqueid . '" class="mb" rel="[images]" > ' . $img_legend . ' </a> <div class="multiBoxDesc mb' . $uniqueid . '">' . ($desc ? $desc : $title) . '</div> '; } else { $field->{$prop} = $img_legend; } return; // Single image always ... } else { if ($linkto_url && $urllink) { // CASE 2: Handle linking to a URL instead of image zooming popup if ($url_target == 'multibox') { // (a) Link to URL that opens inside a popup $field->{$prop}[] = ' <script>document.write(\'<a href="' . $urllink . '" id="mb' . $uniqueid . '" class="mb" rel="width:\'+((MooTools.version>=\'1.2.4\' ? window.getSize().x : window.getSize().size.x)-150)+\',height:\'+((MooTools.version>=\'1.2.4\' ? window.getSize().y : window.getSize().size.y)-150)+\'">\')</script> ' . $img_legend . ' <script>document.write(\'</a>\')</script> <div class="multiBoxDesc mbox_img_url mb' . $uniqueid . '">' . ($desc ? $desc : $title) . '</div> '; } else { // (b) Just link to URL $field->{$prop}[] = ' <a href="' . $urllink . '" target="' . $url_target . '"> ' . $img_legend . ' </a> '; } } else { if ($usepopup) { // CASE 3: Handle image zooming popup // no popup if image is the largest one if ($prop == 'display_large' || $prop == 'display_original') { $field->{$prop}[] = $img_legend; continue; } switch ($popuptype) { case 1: // Multibox image popup $group_str = $group_name ? 'rel="[' . $group_name . ']"' : ''; $field->{$prop}[] = ' <a href="' . $srcl . '" id="mb' . $uniqueid . '" class="mb" ' . $group_str . ' > ' . $img_legend . ' </a> <div class="multiBoxDesc mb' . $uniqueid . '">' . ($desc ? $desc : $title) . '</div> '; break; case 2: // Rokbox image popup $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's'); $group_str = ''; // no support for image grouping $field->{$prop}[] = ' <a href="' . $srcl . '" rel="rokbox[' . $wl . ' ' . $hl . ']" ' . $group_str . ' title="' . $title_attr . '" data-rokbox data-rokbox-caption="' . $title_attr . '"> ' . $img_nolegend . ' </a> '; break; case 3: // JCE popup image popup $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's'); $group_str = $group_name ? 'rel="group[' . $group_name . ']"' : ''; $field->{$prop}[] = ' <a href="' . $srcl . '" class="jcepopup" ' . $group_str . ' title="' . $title_attr . '"> ' . $img_nolegend . ' </a> '; break; case 4: // Fancybox image popup $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's'); $group_str = $group_name ? 'data-fancybox-group="' . $group_name . '"' : ''; $field->{$prop}[] = ' <a href="' . $srcl . '" class="fancybox" ' . $group_str . ' title="' . $title_attr . '"> ' . $img_nolegend . ' </a> '; break; case 5: // Galleriffic inline slideshow gallery $group_str = ''; // image grouping: not needed / not applicatble $field->{$prop}[] = ' <a class="thumb" name="drop" href="' . $srcl . '" style=""> ' . $img_legend . ' </a> <div class="caption"> ' . '<b>' . $title . '</b><br/>' . $desc . ' </div> '; break; case 6: // (Widgetkit) SPOTlight image popup $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's'); $group_str = $group_name ? 'data-spotlight-group="' . $group_name . '"' : ''; $field->{$prop}[] = ' <a href="' . $srcl . '" data-lightbox="on" data-spotlight="effect:bottom" ' . $group_str . ' title="' . $title_attr . '"> ' . $img_nolegend . ' <div class="overlay"> ' . '<b>' . $title . '</b>: ' . $desc . ' </div> </a> '; break; case 7: // Elastislide inline carousel gallery (Responsive image gallery with togglable thumbnail-strip, plus previewer and description) // *** NEEDS: thumbnail list must be created with large size thubmnails, these will be then thumbnailed by the JS gallery code $title_attr = flexicontent_html::escapeJsText($desc ? $desc : $title, 's'); $img_legend_custom = ' <img src="' . JURI::root(true) . '/' . $src . '" alt ="' . $alt . '"' . $legend . ' class="' . $class_img_field . '" data-large="' . JURI::root(true) . '/' . $srcl . '" data-description="' . $title_attr . '"/> '; $group_str = $group_name ? 'rel="[' . $group_name . ']"' : ''; $field->{$prop}[] = ' <li><a href="javascript:;"> ' . $img_legend_custom . ' </a></li> '; break; case 8: // PhotoSwipe popup carousel gallery $group_str = $group_name ? 'rel="[' . $group_name . ']"' : ''; $field->{$prop}[] = ' <a href="' . $srcl . '" ' . $group_str . ' > ' . $img_legend . ' </a> '; break; default: // Unknown Gallery Type, just add thumbails ... $field->{$prop}[] = $img_legend; break; } } else { // CASE 4: Plain Thumbnail List without any (popup / inline) gallery code $field->{$prop}[] = $img_legend; } } } $n = count($field->{$prop}) - 1; if ($showtitle && $title || $showdesc && $desc) { $field->{$prop}[$n] = '<div class="fc_img_tooltip_data" style="float:left; margin-right:8px;" >' . $field->{$prop}[$i]; } if ($showtitle && $title) { $field->{$prop}[$n] .= '<div class="fc_img_tooltip_title" style="line-height:1em; font-weight:bold;">' . $title . '</div>'; } if ($showdesc && $desc) { $field->{$prop}[$n] .= '<div class="fc_img_tooltip_desc" style="line-height:1em;">' . $desc . '</div>'; } if ($showtitle && $title || $showdesc && $desc) { $field->{$prop}[$n] .= '</div>'; } $field->{$prop}[$n] = $pretext . $field->{$prop}[$i] . $posttext; } // ************************************************************ // Apply separator and open/close tags and handle SPECIAL CASEs: // by add some exta html required by some JS image libraries // ************************************************************ // Check for no values found if (!count($field->{$prop})) { $field->{$prop} = ''; return; } // Galleriffic inline slideshow gallery if ($usepopup && $popuptype == 5) { $field->{$prop} = $opentag . ' <div id="gf_container"> <div id="gallery" class="content"> <div id="gf_controls" class="controls"></div> <div class="slideshow-container"> <div id="gf_loading" class="loader"></div> <div id="gf_slideshow" class="slideshow"></div> </div> <div id="gf_caption" class="caption-container"></div> </div> <div id="gf_thumbs" class="navigation"> <ul class="thumbs noscript"> <li> ' . implode("</li>\n<li>", $field->{$prop}) . ' </li> </ul> </div> <div style="clear: both;"></div> </div> ' . $closetag; } else { if ($usepopup && $popuptype == 7) { //$max_width = $field->parameters->get( 'w_l', 800 ); // this should be size of previewer aka size of large image thumbnail $field->{$prop} = ' <div id="rg-gallery_' . $uid . '" class="rg-gallery" > <div class="rg-thumbs"> <!-- Elastislide Carousel Thumbnail Viewer --> <div class="es-carousel-wrapper"> <div class="es-nav"> <span class="es-nav-prev">' . JText::_('FLEXI_PREVIOUS') . '</span> <span class="es-nav-next">' . JText::_('FLEXI_NEXT') . '</span> </div> <div class="es-carousel"> <ul> ' . implode('', $field->{$prop}) . ' </ul> </div> </div> <!-- End Elastislide Carousel Thumbnail Viewer --> </div><!-- rg-thumbs --> </div><!-- rg-gallery --> '; } else { if ($usepopup && $popuptype == 8) { $field->{$prop} = ' <span class="photoswipe_fccontainer" > ' . implode($separatorf, $field->{$prop}) . ' </span> '; } else { $field->{$prop} = implode($separatorf, $field->{$prop}); } } } // Apply open/close tags $field->{$prop} = $opentag . $field->{$prop} . $closetag; }
/** * Display the view */ function display($cachable = null, $urlparams = false) { // Debuging message //JError::raiseNotice(500, 'IN display()'); // TOREMOVE $jinput = JFactory::getApplication()->input; // Access checking for --items-- viewing, will be handled by the items model, this is because THIS display() TASK is used by other views too // in future it maybe moved here to the controller, e.g. create a special task item_display() for item viewing, or insert some IF bellow // Compatibility check: Layout is form and task is not set: this is new item submit ... if ($jinput->get('layout', false) == "form" && !$jinput->get('task', false)) { // 0 or 1, will allow browser to store without revalidating, null will let default (Joomla website) HTTP headers, e.g. re-validate JFactory::getSession()->set('fc_cachable', 0, 'flexicontent'); $jinput->set('task', 'add'); $this->add(); } else { // AVOID MAKING TOO LARGE: (case 1) SEARCH view or OTHER view with TEXT search active if ($jinput->get('view') == 'search' || $jinput->get('filter')) { $cachable = false; } else { $cachable = true; foreach ($_GET as $i => $v) { if (substr($i, 0, 7) === "filter_") { $cachable = false; break; } } } // CASE: urlparams were explicitely given if (!empty($urlparams)) { $safeurlparams =& $urlparams; } else { $safeurlparams = array(); // Add menu URL variables $menu = JFactory::getApplication()->getMenu()->getActive(); if ($menu) { foreach ($menu->query as $_varname => $_ignore) { $safeurlparams[$_varname] = 'STRING'; } } // Add any existing URL variables (=submitted via GET), ... we only need variable names, (so can use them unfiltered) foreach ($_GET as $_varname => $_ignore) { $safeurlparams[$_varname] = 'STRING'; } } // If component is serving different pages to logged users, this will avoid // having users seeing same page after login/logout when conservative caching is used if ($userid = JFactory::getUser()->get('id')) { $jinput->set('__fc_user_id__', $userid); $safeurlparams['__fc_user_id__'] = 'STRING'; } $cparams = JComponentHelper::getParams('com_flexicontent'); $use_mobile_layouts = $cparams->get('use_mobile_layouts', 0); $tabletSameAsDesktop = $cparams->get('force_desktop_layout', 0) == 1; // If component is serving different pages for mobile devices, this will avoid // having users seeing the same page regardless of being on desktop or mobile $mobileDetector = flexicontent_html::getMobileDetector(); //$client = JFactory::getApplication()->client; $isMobile = $client->mobile; $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); if ($use_mobile_layouts && $isMobile && (!$isTablet || !$tabletSameAsDesktop)) { $jinput->set('__fc_client__', 'Mobile'); $safeurlparams['__fc_client__'] = 'STRING'; } // Moved code for browser's cache control to system plugin to do at the latest possible point // 0 or 1, will allow browser to store without revalidating, null will let default (Joomla website) HTTP headers, e.g. re-validate JFactory::getSession()->set('fc_cachable', (int) $cachable, 'flexicontent'); //echo "cacheable: ".(int)$cachable." - " . print_r($safeurlparams, true) ."<br/>"; parent::display($cachable, $safeurlparams); } }
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { if (!in_array($field->field_type, self::$field_types)) { return; } // Get isMobile / isTablet Flags static $isMobile = null; static $isTablet = null; static $useMobile = null; if ($useMobile === null) { $cparams = JComponentHelper::getParams('com_flexicontent'); $force_desktop_layout = $cparams->get('force_desktop_layout', 0); //$start_microtime = microtime(true); $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile; //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000); } $field->label = JText::_($field->label); // Some variables $is_ingroup = !empty($field->ingroup); $use_ingroup = $field->parameters->get('use_ingroup', 0); $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0); // Value handling parameters $lang_filter_values = 0; //$field->parameters->get( 'lang_filter_values', 1); // some parameter shortcuts $target = $field->parameters->get('targetblank', 0); $target_param = $target ? ' target="_blank"' : ''; $display_hits = $field->parameters->get('display_hits', 0); $add_hits_img = $display_hits == 1 || $display_hits == 3; $add_hits_txt = $display_hits == 2 || $display_hits == 3 || $isMobile; $rel_nofollow = $field->parameters->get('add_rel_nofollow', 0) ? ' rel="nofollow"' : ''; // URL value $link_usage = $field->parameters->get('link_usage', 0); $default_link = $link_usage == 2 ? $field->parameters->get('default_value_link', '') : ''; $default_link = $default_link ? JText::_($default_link) : ''; // URL title & linking text (optional) $usetitle = $field->parameters->get('use_title', 0); $title_usage = $field->parameters->get('title_usage', 0); $default_title = $title_usage == 2 ? JText::_($field->parameters->get('default_value_title', '')) : ''; $default_title = $default_title ? JText::_($default_title) : ''; // Get field values $values = $values ? $values : $field->value; // Check for no values and no default value, and return empty display if (empty($values)) { if (!strlen($default_link)) { $field->{$prop} = $is_ingroup ? array() : ''; return; } $values = array(); $values[0]['link'] = $default_link; $values[0]['title'] = $default_title; $values[0]['hits'] = 0; $values[0] = serialize($values[0]); } // (* BECAUSE OF THIS, the value display loop expects unserialized values) foreach ($values as &$value) { // Compatibility for unserialized values or for NULL values in a field group if (!is_array($value)) { $v = !empty($value) ? @unserialize($value) : false; $value = $v !== false || $v === 'b:0;' ? $v : array('link' => $value, 'title' => '', 'hits' => 0); } } unset($value); // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!! // Prefix - Suffix - Separator parameters, replacing other field values if found $remove_space = $field->parameters->get('remove_space', 0); $pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('pretext', ''), 'pretext'); $posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('posttext', ''), 'posttext'); $separatorf = $field->parameters->get('separatorf', 1); $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag'); $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag'); if ($pretext) { $pretext = $remove_space ? $pretext : $pretext . ' '; } if ($posttext) { $posttext = $remove_space ? $posttext : ' ' . $posttext; } 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; } // Optimization, do some stuff outside the loop static $hits_icon = null; if ($hits_icon === null && ($display_hits == 1 || $display_hits == 3)) { $_hits_tip = flexicontent_html::getToolTip(null, '%s ' . JText::_('FLEXI_HITS', true), 0, 0); $_attribs = $display_hits == 1 ? 'class="' . (FLEXI_J30GE ? 'hasTooltip' : 'hasTip') . '" title="' . $_hits_tip . '"' : ''; $hits_icon = FLEXI_J16GE ? JHTML::image('components/com_flexicontent/assets/images/' . 'user.png', JText::_('FLEXI_HITS'), $_attribs) : JHTML::_('image.site', 'user.png', 'components/com_flexicontent/assets/images/', NULL, NULL, JText::_('FLEXI_HITS'), $_attribs); } // Initialise property with default value $field->{$prop} = array(); $n = 0; foreach ($values as $value) { if (empty($value['link']) && !$is_ingroup) { continue; } // Skip empty if not in field group if (empty($value['link'])) { $field->{$prop}[$n++] = ''; continue; } // If not using property or property is empty, then use default property value // NOTE: default property values have been cleared, if (propertyname_usage != 2) $title = $usetitle && @$value['title'] ? $value['title'] : $default_title; $linktext = ''; // no linktext for weblink for extended web link field if this is needed $hits = (int) @$value['hits']; $link_params = $title ? ' title="' . $title . '"' : ''; $link_params .= $target_param; $link_params .= $rel_nofollow; if ($field->parameters->get('use_direct_link', 0)) { // Direct access to the web-link, hits counting not possible $href = $value['link']; } else { // Indirect access to the web-link, via calling FLEXIcontent component, thus counting hits too $href = JRoute::_('index.php?option=com_flexicontent&fid=' . $field->id . '&cid=' . $item->id . '&ord=' . ($n + 1) . '&task=weblink'); } // Create indirect link to web-link address with custom displayed text if (empty($linktext)) { $linktext = $title ? $title : $this->cleanurl(FLEXI_J30GE ? JStringPunycode::urlToUTF8($value['link']) : $value['link']); } $html = '<a href="' . $href . '" ' . $link_params . ' itemprop="url">' . $linktext . '</a>'; // HITS: either as icon or as inline text or both $hits_html = ''; if ($display_hits && $hits) { $hits_html = '<span class="fcweblink_hits">'; if ($add_hits_img && @$hits_icon) { $hits_html .= sprintf($hits_icon, $hits); } if ($add_hits_txt) { $hits_html .= '(' . $hits . ' ' . JTEXT::_('FLEXI_HITS') . ')'; } $hits_html .= '</span>'; if ($prop == 'display_hitsonly') { $html = $hits_html; } else { $html .= ' ' . $hits_html; } } // Add prefix / suffix $field->{$prop}[$n] = $pretext . $html . $posttext; $n++; if (!$multiple) { break; } // multiple values disabled, break out of the loop, not adding further values even if the exist } if (!$is_ingroup) { // Apply separator and open/close tags $field->{$prop} = implode($separatorf, $field->{$prop}); if ($field->{$prop} !== '') { $field->{$prop} = $opentag . $field->{$prop} . $closetag; } else { $field->{$prop} = ''; } } }
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { // execute the code only if the field type match the plugin type if (!in_array($field->field_type, self::$field_types)) { return; } static $langs = null; if ($langs === null) { $langs = FLEXIUtilities::getLanguages('code'); } static $tooltips_added = false; static $isMobile = null; static $isTablet = null; static $useMobile = null; if ($useMobile === null) { $cparams = JComponentHelper::getParams('com_flexicontent'); $force_desktop_layout = $cparams->get('force_desktop_layout', 0); //$start_microtime = microtime(true); $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000); } if (!$tooltips_added) { FLEXI_J30GE ? JHtml::_('bootstrap.tooltip') : JHTML::_('behavior.tooltip'); $tooltips_added = true; } $field->label = JText::_($field->label); $values = $values ? $values : $field->value; if (empty($values)) { $field->{$prop} = ''; return; } // Prefix - Suffix - Separator parameters, replacing other field values if found $remove_space = $field->parameters->get('remove_space', 0); $pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('pretext', ''), 'pretext'); $posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('posttext', ''), 'posttext'); $separatorf = $field->parameters->get('separatorf', 1); $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag'); $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag'); if ($pretext) { $pretext = $remove_space ? $pretext : $pretext . ' '; } if ($posttext) { $posttext = $remove_space ? $posttext : ' ' . $posttext; } // some parameter shortcuts $useicon = $field->parameters->get('useicon', 1); $lowercase_filename = $field->parameters->get('lowercase_filename', 1); $link_filename = $field->parameters->get('link_filename', 1); $display_filename = $field->parameters->get('display_filename', 1); $display_lang = $field->parameters->get('display_lang', 1); $display_size = $field->parameters->get('display_size', 0); $display_hits = $field->parameters->get('display_hits', 0); $display_descr = $field->parameters->get('display_descr', 1); $add_lang_img = $display_lang == 1 || $display_lang == 3; $add_lang_txt = $display_lang == 2 || $display_lang == 3 || $isMobile; $add_hits_img = $display_hits == 1 || $display_hits == 3; $add_hits_txt = $display_hits == 2 || $display_hits == 3 || $isMobile; $usebutton = $field->parameters->get('usebutton', 1); $buttonsposition = $field->parameters->get('buttonsposition', 1); $use_infoseptxt = $field->parameters->get('use_infoseptxt', 1); $use_actionseptxt = $field->parameters->get('use_actionseptxt', 1); $infoseptxt = $use_infoseptxt ? ' ' . $field->parameters->get('infoseptxt', '') . ' ' : ' '; $actionseptxt = $use_actionseptxt ? ' ' . $field->parameters->get('actionseptxt', '') . ' ' : ' '; $allowdownloads = $field->parameters->get('allowdownloads', 1); $downloadstext = $allowdownloads == 2 ? $field->parameters->get('downloadstext', 'FLEXI_DOWNLOAD') : 'FLEXI_DOWNLOAD'; $downloadstext = JText::_($downloadstext); $downloadsinfo = JText::_('FLEXI_FIELD_FILE_DOWNLOAD_INFO', true); $allowview = $field->parameters->get('allowview', 0); $viewtext = $allowview == 2 ? $field->parameters->get('viewtext', 'FLEXI_FIELD_FILE_VIEW') : 'FLEXI_FIELD_FILE_VIEW'; $viewtext = JText::_($viewtext); $viewinfo = JText::_('FLEXI_FIELD_FILE_VIEW_INFO', true); $allowshare = $field->parameters->get('allowshare', 0); $sharetext = $allowshare == 2 ? $field->parameters->get('sharetext', 'FLEXI_FIELD_FILE_EMAIL_TO_FRIEND') : 'FLEXI_FIELD_FILE_EMAIL_TO_FRIEND'; $sharetext = JText::_($sharetext); $shareinfo = JText::_('FLEXI_FIELD_FILE_EMAIL_TO_FRIEND_INFO', true); $allowaddtocart = $field->parameters->get('use_downloads_manager', 0); $addtocarttext = $allowaddtocart == 2 ? $field->parameters->get('addtocarttext', 'FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART') : 'FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART'; $addtocarttext = JText::_($addtocarttext); $addtocartinfo = JText::_('FLEXI_FIELD_FILE_ADD_TO_DOWNLOADS_CART_INFO', true); $noaccess_display = $field->parameters->get('noaccess_display', 1); $noaccess_url_unlogged = $field->parameters->get('noaccess_url_unlogged', false); $noaccess_url_logged = $field->parameters->get('noaccess_url_logged', false); $noaccess_msg_unlogged = JText::_($field->parameters->get('noaccess_msg_unlogged', '')); $noaccess_msg_logged = JText::_($field->parameters->get('noaccess_msg_logged', '')); $noaccess_addvars = $field->parameters->get('noaccess_addvars', 0); // Select appropriate messages depending if user is logged on $noaccess_url = JFactory::getUser()->guest ? $noaccess_url_unlogged : $noaccess_url_logged; $noaccess_msg = JFactory::getUser()->guest ? $noaccess_msg_unlogged : $noaccess_msg_logged; // VERIFY downloads manager module is installed and enabled static $mod_is_enabled = null; if ($allowaddtocart && $mod_is_enabled === null) { $db = JFactory::getDBO(); $query = "SELECT published FROM #__modules WHERE module = 'mod_flexidownloads' AND published = 1"; $db->setQuery($query); $mod_is_enabled = $db->loadResult(); if (!$mod_is_enabled) { $app = JFactory::getApplication(); $app->enqueueMessage("FILE FIELD: please disable parameter \"Use Downloads Manager Module\", the module is not install or not published", 'message'); } } $allowaddtocart = $allowaddtocart ? $mod_is_enabled : 0; // Downloads manager feature if ($allowshare) { if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php')) { $com_mailto_found = true; require_once JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php'; $status = 'width=700,height=360,menubar=yes,resizable=yes'; } else { $com_mailto_found = false; } } if ($pretext) { $pretext = $remove_space ? $pretext : $pretext . ' '; } if ($posttext) { $posttext = $remove_space ? $posttext : ' ' . $posttext; } // Description as tooltip if ($display_descr == 2) { JHTML::_('behavior.tooltip'); } 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; } // initialise property $field->{$prop} = array(); // Get user access level (these are multiple for J2.5) $user = JFactory::getUser(); if (FLEXI_J16GE) { $aid_arr = JAccess::getAuthorisedViewLevels($user->id); } else { $aid = (int) $user->get('aid'); } $n = 0; // Get All file information at once (Data maybe cached already) // TODO (maybe) e.g. contentlists should could call this function ONCE for all file fields, // This may be done by adding a new method to fields to prepare multiple fields with a single call $files_data = $this->getFileData($values, $published = true); //print_r($files_data); exit; // Optimization, do some stuff outside the loop static $hits_icon = null; if ($hits_icon === null && ($display_hits == 1 || $display_hits == 3)) { if ($display_hits == 1) { $_tooltip_title = ''; $_tooltip_content = '%s ' . JText::_('FLEXI_HITS', true); $_attribs = FLEXI_J30GE ? 'class="hasTooltip icon-hits" title="' . JHtml::tooltipText($_tooltip_title, $_tooltip_content, 0, 0) . '"' : 'class="hasTip icon-hits" title="' . $_tooltip_title . '::' . $_tooltip_content . '"'; } else { $_attribs = ' class="icon-hits"'; } $hits_icon = FLEXI_J16GE ? JHTML::image('components/com_flexicontent/assets/images/' . 'user.png', JText::_('FLEXI_HITS'), $_attribs) : JHTML::_('image.site', 'user.png', 'components/com_flexicontent/assets/images/', NULL, NULL, JText::_('FLEXI_HITS'), $_attribs); $hits_icon .= ' '; } $show_filename = $display_filename || $prop == 'namelist'; $public_acclevel = !FLEXI_J16GE ? 0 : 1; foreach ($files_data as $file_id => $file_data) { // Check if it exists and get file size $basePath = $file_data->secure ? COM_FLEXICONTENT_FILEPATH : COM_FLEXICONTENT_MEDIAPATH; $abspath = str_replace(DS, '/', JPath::clean($basePath . DS . $file_data->filename)); if ($display_size) { $path_exists = file_exists($abspath); $file_data->size = $path_exists ? filesize($abspath) : 0; } // ***************************** // Check user access on the file // ***************************** $authorized = true; $is_public = true; if (!empty($file_data->access)) { if (FLEXI_J16GE) { $authorized = in_array($file_data->access, $aid_arr); $is_public = in_array($public_acclevel, $aid_arr); } else { $authorized = $file_data->access <= $aid; $is_public = $file_data->access <= $public_acclevel; } } // If no access and set not to show then continue if (!$authorized && !$noaccess_display) { continue; } // Initialize CSS classes variable $file_classes = !$authorized ? 'fcfile_noauth' : ''; // ***************************** // Prepare displayed information // ***************************** // a. ICON: create it according to filetype $icon = ''; if ($useicon) { $file_data = $this->addIcon($file_data); $_tooltip_title = ''; $_tooltip_content = JText::_('FLEXI_FIELD_FILE_TYPE', true) . ': ' . $file_data->ext; $icon = FLEXI_J30GE ? JHTML::image($file_data->icon, $file_data->ext, 'class="icon-mime hasTooltip" title="' . JHtml::tooltipText($_tooltip_title, $_tooltip_content, 1, 0) . '"') : JHTML::image($file_data->icon, $file_data->ext, 'class="icon-mime hasTip" title="' . $_tooltip_title . '::' . $_tooltip_content . '"'); $icon = '<span class="fcfile_mime">' . $icon . '</span>'; } // b. LANGUAGE: either as icon or as inline text or both $lang = ''; $lang_str = ''; $file_data->language = $file_data->language == '' ? '*' : $file_data->language; if ($display_lang && $file_data->language != '*') { $lang = '<span class="fcfile_lang">'; if ($add_lang_img && @$langs->{$file_data->language}->imgsrc) { if (!$add_lang_txt) { $_tooltip_title = JText::_('FLEXI_LANGUAGE', true); $_tooltip_content = $file_data->language == '*' ? JText::_("All") : $langs->{$file_data->language}->name; $_attribs = FLEXI_J30GE ? 'class="hasTooltip icon-lang" title="' . JHtml::tooltipText($_tooltip_title, $_tooltip_content, 0, 0) . '"' : 'class="hasTip icon-lang" title="' . $_tooltip_title . '::' . $_tooltip_content . '"'; } else { $_attribs = ' class="icon-lang"'; } $lang .= "\n" . '<img src="' . $langs->{$file_data->language}->imgsrc . '" ' . $_attribs . ' /> '; } if ($add_lang_txt) { $lang .= '[' . ($file_data->language == '*' ? JText::_("FLEXI_ALL_LANGUAGES") : $langs->{$file_data->language}->name) . ']'; } $lang .= '</span>'; } // c. SIZE: in KBs / MBs $sizeinfo = ''; if ($display_size) { $sizeinfo = '<span class="fcfile_size">'; if ($display_size == 1) { $sizeinfo .= '(' . number_format($file_data->size / 1024, 0) . ' ' . JTEXT::_('FLEXI_KBS') . ')'; } else { if ($display_size == 2) { $sizeinfo .= '(' . number_format($file_data->size / 1048576, 2) . ' ' . JTEXT::_('FLEXI_MBS') . ')'; } else { $sizeinfo .= '(' . number_format($file_data->size / 1073741824, 2) . ' ' . JTEXT::_('FLEXI_GBS') . ')'; } } $sizeinfo .= '</span>'; } // d. HITS: either as icon or as inline text or both $hits = ''; if ($display_hits) { $hits = '<span class="fcfile_hits">'; if ($add_hits_img && @$hits_icon) { $hits .= sprintf($hits_icon, $file_data->hits); } if ($add_hits_txt) { $hits .= '(' . $file_data->hits . ' ' . JTEXT::_('FLEXI_HITS') . ')'; } $hits .= '</span>'; } // e. FILENAME / TITLE: decide whether to show it (if we do not use button, then displaying of filename is forced) $_filetitle = $file_data->altname ? $file_data->altname : $file_data->filename; if ($lowercase_filename) { $_filetitle = mb_strtolower($_filetitle, "UTF-8"); } $filename_original = $file_data->filename_original ? $file_data->filename_original : $file_data->filename; ${$filename_original} = str_replace(array("'", "\""), array("\\'", ""), $filename_original); $filename_original = htmlspecialchars($filename_original, ENT_COMPAT, 'UTF-8'); $name_str = $display_filename == 2 ? $filename_original : $_filetitle; $name_classes = $file_classes . ($file_classes ? ' ' : '') . 'fcfile_title'; $name_html = '<span class="' . $name_classes . '">' . $name_str . '</span>'; // f. DESCRIPTION: either as tooltip or as inline text $descr_tip = $descr_inline = $descr_icon = ''; if (!empty($file_data->description)) { if (!$authorized) { if ($noaccess_display != 2) { $descr_tip = flexicontent_html::escapeJsText($name_str . '::' . $file_data->description, 's'); $descr_icon = '<img src="components/com_flexicontent/assets/images/comment.png" class="hasTip" title="' . $descr_tip . '"/>'; $descr_inline = ''; } } else { if ($display_descr == 1 || $prop == 'namelist') { // As tooltip $descr_tip = flexicontent_html::escapeJsText($name_str . '::' . $file_data->description, 's'); $descr_icon = '<img src="components/com_flexicontent/assets/images/comment.png" class="hasTip" title="' . $descr_tip . '"/>'; $descr_inline = ''; } else { if ($display_descr == 2) { // As inline text $descr_inline = ' <span class="fcfile_descr_inline fc-mssg fc-caption" style="max-wdith">' . nl2br($file_data->description) . '</span>'; } } } if ($descr_icon) { $descr_icon = ' <span class="fcfile_descr_tip">' . $descr_icon . '</span>'; } } // ***************************** // Create field's displayed html // ***************************** // [1]: either create the download link -or- use no authorized link ... if (!$authorized) { $dl_link = $noaccess_url; if ($noaccess_msg) { $str = '<span class="fcfile_noauth_msg fc-mssg-inline fc-noauth">' . $noaccess_msg . '</span> '; } } else { $dl_link = JRoute::_('index.php?option=com_flexicontent&id=' . $file_id . '&cid=' . $field->item_id . '&fid=' . $field->id . '&task=download'); $str = ''; } // SOME behavior FLAGS $not_downloadable = !$dl_link || $prop == 'namelist'; $filename_shown = !$authorized || $show_filename; $filename_shown_as_link = $filename_shown && $link_filename && !$usebutton; // [2]: Add information properties: filename, and icons with optional inline text $info_arr = array(); if ($filename_shown && !$filename_shown_as_link || $not_downloadable) { // Filename will be shown if not l $info_arr[] = $icon . ' ' . $name_html; } if ($lang) { $info_arr[] = $lang; } if ($sizeinfo) { $info_arr[] = $sizeinfo; } if ($hits) { $info_arr[] = $hits; } if ($descr_icon) { $info_arr[] = $descr_icon; } $str .= implode($info_arr, $infoseptxt); // [3]: Display the buttons: DOWNLOAD, SHARE, ADD TO CART $actions_arr = array(); // *********************** // CASE 1: no download ... // *********************** // EITHER (a) Current user NOT authorized to download file AND no access URL is not configured // OR (b) creating a file list with no download links, (the 'prop' display variable is 'namelist') if ($not_downloadable) { // nothing to do here, the file name/title will be shown above } else { if ($usebutton) { $file_classes .= ($file_classes ? ' ' : '') . 'fc_button fcsimple'; // Add an extra css class (button display) // DOWNLOAD: single file instant download if ($allowdownloads) { // NO ACCESS: add file info via form field elements, in case the URL target needs to use them $file_data_fields = ""; if (!$authorized && $noaccess_addvars) { $file_data_fields = '<input type="hidden" name="fc_field_id" value="' . $field->id . '"/>' . "\n" . '<input type="hidden" name="fc_item_id" value="' . $field->item_id . '"/>' . "\n" . '<input type="hidden" name="fc_file_id" value="' . $file_id . '"/>' . "\n"; } // The download button in a mini form ... $actions_arr[] = '' . '<form id="form-download-' . $field->id . '-' . ($n + 1) . '" method="post" action="' . $dl_link . '" style="display:inline-block;" >' . $file_data_fields . '<input type="submit" name="download-' . $field->id . '[]" class="' . $file_classes . ' fcfile_downloadFile" title="' . $downloadsinfo . '" value="' . $downloadstext . '"/>' . '</form>' . "\n"; } if ($authorized && $allowview && !$file_data->url) { $actions_arr[] = ' <a href="' . $dl_link . '?method=view" class="fancybox ' . $file_classes . ' fcfile_viewFile" data-fancybox-type="iframe" title="' . $viewinfo . '" style="line-height:1.3em;" > ' . $viewtext . ' </a>'; $fancybox_needed = 1; } // ADD TO CART: the link will add file to download list (tree) (handled via a downloads manager module) if ($authorized && $allowaddtocart && !$file_data->url) { // CSS class to anchor downloads list adding function $addtocart_classes = $file_classes . ($file_classes ? ' ' : '') . 'fcfile_addFile'; $attribs = ' class="' . $addtocart_classes . '"'; $attribs .= ' title="' . $addtocartinfo . '"'; $attribs .= ' filename="' . flexicontent_html::escapeJsText($_filetitle, 's') . '"'; $attribs .= ' fieldid="' . $field->id . '"'; $attribs .= ' contentid="' . $field->item_id . '"'; $attribs .= ' fileid="' . $file_data->id . '"'; $actions_arr[] = '<input type="button" ' . $attribs . ' value="' . $addtocarttext . '" />'; } // SHARE FILE VIA EMAIL: open a popup or inline email form ... if ($is_public && $allowshare && !$com_mailto_found) { // skip share popup form button if com_mailto is missing $actions_arr[] = ' com_mailto component not found, please disable <b>download link sharing parameter</b> in this file field'; } else { if ($is_public && $allowshare) { $send_onclick = 'window.open(\'%s\',\'win2\',\'' . $status . '\'); return false;'; $send_form_url = 'index.php?option=com_flexicontent&tmpl=component' . '&task=call_extfunc&exttype=plugins&extfolder=flexicontent_fields&extname=file&extfunc=share_file_form' . '&file_id=' . $file_id . '&content_id=' . $item->id . '&field_id=' . $field->id; $actions_arr[] = '<input type="button" class="' . $file_classes . ' fcfile_shareFile" onclick="' . sprintf($send_onclick, JRoute::_($send_form_url)) . '" title="' . $shareinfo . '" value="' . $sharetext . '" />'; } } } else { // DOWNLOAD: single file instant download if ($allowdownloads) { // NO ACCESS: add file info via URL variables, in case the URL target needs to use them if (!$authorized && $noaccess_addvars) { $dl_link .= '&fc_field_id="' . $field->id . '&fc_item_id="' . $field->item_id . '&fc_file_id="' . $file_id; } // The download link, if filename/title not shown, then display a 'download' prompt text $actions_arr[] = ($filename_shown && $link_filename ? $icon . ' ' : '') . '<a href="' . $dl_link . '" class="' . $file_classes . ' fcfile_downloadFile" title="' . $downloadsinfo . '" >' . ($filename_shown && $link_filename ? $name_str : $downloadstext) . '</a>'; } if ($authorized && $allowview && !$file_data->url) { $actions_arr[] = ' <a href="' . $dl_link . '?method=view" class="fancybox ' . $file_classes . ' fcfile_viewFile" data-fancybox-type="iframe" title="' . $viewinfo . '" > ' . $viewtext . ' </a>'; $fancybox_needed = 1; } // ADD TO CART: the link will add file to download list (tree) (handled via a downloads manager module) if ($authorized && $allowaddtocart && !$file_data->url) { // CSS class to anchor downloads list adding function $addtocart_classes = $file_classes . ($file_classes ? ' ' : '') . 'fcfile_addFile'; $attribs = ' class="' . $addtocart_classes . '"'; $attribs .= ' title="' . $addtocartinfo . '"'; $attribs .= ' filename="' . flexicontent_html::escapeJsText($_filetitle, 's') . '"'; $attribs .= ' fieldid="' . $field->id . '"'; $attribs .= ' contentid="' . $field->item_id . '"'; $attribs .= ' fileid="' . $file_data->id . '"'; $actions_arr[] = '<a href="javascript:;" ' . $attribs . ' >' . $addtocarttext . '</a>'; } // SHARE FILE VIA EMAIL: open a popup or inline email form ... if ($is_public && $allowshare && !$com_mailto_found) { // skip share popup form button if com_mailto is missing $str .= ' com_mailto component not found, please disable <b>download link sharing parameter</b> in this file field'; } else { if ($is_public && $allowshare) { $send_onclick = 'window.open(\'%s\',\'win2\',\'' . $status . '\'); return false;'; $send_form_url = 'index.php?option=com_flexicontent&tmpl=component' . '&task=call_extfunc&exttype=plugins&extfolder=flexicontent_fields&extname=file&extfunc=share_file_form' . '&file_id=' . $file_id . '&content_id=' . $item->id . '&field_id=' . $field->id; $actions_arr[] = '<a href="javascript:;" class="fcfile_shareFile" onclick="' . sprintf($send_onclick, JRoute::_($send_form_url)) . '" title="' . $shareinfo . '">' . $sharetext . '</a>'; } } } } //Display the buttons "DOWNLOAD, SHARE, ADD TO CART" before or after the filename if ($buttonsposition) { $str .= (count($actions_arr) ? $infoseptxt : "") . '<span class="fcfile_actions">' . implode($actions_arr, $actionseptxt) . '</span>'; } else { $str = (count($actions_arr) ? $infoseptxt : "") . '<span class="fcfile_actions">' . implode($actions_arr, $actionseptxt) . '</span>' . $str; } // [4]: Add the file description (if displayed inline) if ($descr_inline) { $str .= $descr_inline; } // Values Prefix and Suffix Texts $field->{$prop}[] = $pretext . $str . $posttext; // Some extra data for developers: (absolute) file URL and (absolute) file path $field->url[] = $dl_link; $file->abspath[] = $abspath; $field->file_data[] = $file_data; $n++; } if (!empty($fancybox_needed)) { flexicontent_html::loadFramework('fancybox'); } // Apply seperator and open/close tags if (count($field->{$prop})) { $field->{$prop} = implode($separatorf, $field->{$prop}); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } else { $field->{$prop} = ''; } }
/** * Creates the page's display * * @since 1.0 */ function display($tpl = null) { // check for form layout if ($this->getLayout() == 'form' || in_array(JRequest::getVar('task'), array('add', 'edit'))) { // Important set layout to be form since various category view SEF links have this variable set $this->setLayout('form'); $this->_displayForm($tpl); return; } else { $this->setLayout('item'); } // Get Content Types with no category links in item view pathways, and for unroutable (non-linkable) categories global $globalnoroute, $globalnopath, $globalcats; if (!is_array($globalnopath)) { $globalnopath = array(); } if (!is_array($globalnoroute)) { $globalnoroute = array(); } //initialize variables $dispatcher = JDispatcher::getInstance(); $app = JFactory::getApplication(); $session = JFactory::getSession(); $document = JFactory::getDocument(); $menus = $app->getMenu(); $menu = $menus->getActive(); $uri = JFactory::getURI(); $user = JFactory::getUser(); $aid = FLEXI_J16GE ? JAccess::getAuthorisedViewLevels($user->id) : (int) $user->get('aid'); $db = JFactory::getDBO(); $nullDate = $db->getNullDate(); // ****************************************************** // Get item, model and create form (that loads item data) // ****************************************************** // Get various data from the model $model = $this->getModel(); $cid = $model->_cid ? $model->_cid : $model->get('catid'); // Get current category id // we are in display() task, so we will load the current item version by default // 'preview' request variable will force last, and finally 'version' request variable will force specific // NOTE: preview and version variables cannot be used by users that cannot edit the item JRequest::setVar('loadcurrent', true); // Try to load existing item, an 404 error will be raised if item is not found. Also value 2 for check_view_access // indicates to raise 404 error for ZERO primary key too, instead of creating and returning a new item object $start_microtime = microtime(true); $item = $model->getItem(null, $check_view_access = 2); $_run_time = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; // Set item parameters as VIEW's parameters (item parameters are merged with component/page/type/current category/access parameters already) $params = $item->parameters; $print_logging_info = $params->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } if ($print_logging_info) { $fc_run_times['get_item_data'] = $_run_time; } // ******************************** // Load needed JS libs & CSS styles // ******************************** //add css file if (!$params->get('disablecss', '')) { $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css'); $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->'); } //allow css override if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) { $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css'); } //special to hide the joomfish language selector on item views if ($params->get('disable_lang_select', 0)) { $css = '#jflanguageselection { visibility:hidden; }'; $document->addStyleDeclaration($css); } // ******************** // ITEM LAYOUT handling // ******************** // (a) Decide to use mobile or normal item template layout $useMobile = $params->get('use_mobile_layouts', 0); if ($useMobile) { $force_desktop_layout = $params->get('force_desktop_layout', 0); $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile; } $_ilayout = $useMobile ? 'ilayout_mobile' : 'ilayout'; // (b) Get from item parameters, allowing URL override $ilayout = JRequest::getVar($_ilayout, false); if (!$ilayout) { $desktop_ilayout = $params->get('ilayout', 'default'); $ilayout = !$useMobile ? $desktop_ilayout : $params->get('ilayout_mobile', $desktop_ilayout); } // (c) Create the type parameters $tparams = $this->get('Typeparams'); $tparams = FLEXI_J16GE ? new JRegistry($tparams) : new JParameter($tparams); // (d) Verify the layout is within templates, Content Type default template OR Content Type allowed templates $allowed_tmpls = $tparams->get('allowed_ilayouts'); $type_default_layout = $tparams->get('ilayout', 'default'); if (empty($allowed_tmpls)) { $allowed_tmpls = array(); } else { if (!is_array($allowed_tmpls)) { $allowed_tmpls = !FLEXI_J16GE ? array($allowed_tmpls) : explode("|", $allowed_tmpls); } } // (e) Verify the item layout is within templates: Content Type default template OR Content Type allowed templates if ($ilayout != $type_default_layout && count($allowed_tmpls) && !in_array($ilayout, $allowed_tmpls)) { $app->enqueueMessage("<small>Current Item Layout Template is '{$ilayout}':<br/>- This is neither the Content Type Default Template, nor does it belong to the Content Type allowed templates.<br/>- Please correct this in the URL or in Content Type configuration.<br/>- Using Content Type Default Template Layout: '{$type_default_layout}'</small>", 'notice'); $ilayout = $type_default_layout; } // (f) Get cached template data $themes = flexicontent_tmpl::getTemplates($lang_files = array($ilayout)); // (g) Verify the item layout exists if (!isset($themes->items->{$ilayout})) { $fixed_ilayout = isset($themes->items->{$type_default_layout}) ? $type_default_layout : 'default'; $app->enqueueMessage("<small>Current Item Layout Template is '{$ilayout}' does not exist<br/>- Please correct this in the URL or in Content Type configuration.<br/>- Using Template Layout: '{$fixed_ilayout}'</small>", 'notice'); $ilayout = $fixed_ilayout; if (FLEXI_FISH || FLEXI_J16GE) { FLEXIUtilities::loadTemplateLanguageFile($ilayout); } // Manually load Template-Specific language file of back fall ilayout } // (h) finally set the template name back into the item's parameters $params->set('ilayout', $ilayout); // Bind Fields $_items = array(&$item); FlexicontentFields::getFields($_items, FLEXI_ITEMVIEW, $params, $aid); // Note : This parameter doesn't exist yet but it will be used by the future gallery template /*if ($params->get('use_panes', 1)) { jimport('joomla.html.pane'); $pane = JPane::getInstance('Tabs'); $this->assignRef('pane', $pane); }*/ $fields = $item->fields; // Pathway needed variables //$catshelper = new flexicontent_cats($cid); //$parents = $catshelper->getParentlist(); //echo "<pre>".print_r($parents,true)."</pre>"; $parents = array(); if ($cid && isset($globalcats[$cid]->ancestorsarray)) { $parent_ids = $globalcats[$cid]->ancestorsarray; foreach ($parent_ids as $parent_id) { $parents[] = $globalcats[$parent_id]; } } // ********************************************************** // Calculate a (browser window) page title and a page heading // ********************************************************** // Verify menu item points to current FLEXIcontent object if ($menu) { $view_ok = FLEXI_ITEMVIEW == @$menu->query['view'] || 'article' == @$menu->query['view']; $cid_ok = JRequest::getInt('cid') == (int) @$menu->query['cid']; $id_ok = JRequest::getInt('id') == (int) @$menu->query['id']; $menu_matches = $view_ok && $id_ok; //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params); // Get active menu item parameters } else { $menu_matches = false; } // MENU ITEM matched, use its page heading (but use menu title if the former is not set) if ($menu_matches) { $default_heading = FLEXI_J16GE ? $menu->title : $menu->name; // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->def('page_heading', $params->get('page_title', $default_heading)); $params->def('page_title', $params->get('page_heading', $default_heading)); $params->def('show_page_heading', $params->get('show_page_title', 0)); $params->def('show_page_title', $params->get('show_page_heading', 0)); } else { // Clear some menu parameters //$params->set('pageclass_sfx', ''); // CSS class SUFFIX is behavior, so do not clear it ? // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ... $default_heading = $item->title; // Decide to show page heading (=J1.5 page title), there is no need for this in item view $show_default_heading = 0; // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->set('page_title', $default_heading); $params->set('page_heading', $default_heading); $params->set('show_page_heading', $show_default_heading); $params->set('show_page_title', $show_default_heading); } // Prevent showing the page heading if (a) IT IS same as item title and (b) item title is already configured to be shown if ($params->get('show_title', 1)) { if ($params->get('page_heading') == $item->title) { $params->set('show_page_heading', 0); } if ($params->get('page_title') == $item->title) { $params->set('show_page_title', 0); } } // ************************************************************ // Create the document title, by from page title and other data // ************************************************************ // Use the page heading as document title, (already calculated above via 'appropriate' logic ...) // or the overriden custom <title> ... set via parameter $doc_title = !$params->get('override_title', 0) ? $params->get('page_title') : $params->get('custom_ititle', $item->title); // Check and prepend category title if ($params->get('addcat_title', 1) && count($parents)) { $parentcat = end($parents); $doc_title = (isset($parentcat->title) ? $parentcat->title . ' - ' : '') . $doc_title; } // Check and prepend or append site name if (FLEXI_J16GE) { // Not available in J1.5 // Add Site Name to page title if ($app->getCfg('sitename_pagetitles', 0) == 1) { $doc_title = $app->getCfg('sitename') . " - " . $doc_title; } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $doc_title = $doc_title . " - " . $app->getCfg('sitename'); } } // Finally, set document title $document->setTitle($doc_title); // ************************ // Set document's META tags // ************************ // Workaround for Joomla not setting the default value for 'robots', so component must do it $app_params = $app->getParams(); if ($_mp = $app_params->get('robots')) { $document->setMetadata('robots', $_mp); } // Set item's META data: desc, keyword, title, author if ($item->metadesc) { $document->setDescription($item->metadesc); } if ($item->metakey) { $document->setMetadata('keywords', $item->metakey); } // ?? Deprecated <title> tag is used instead by search engines if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $item->title); } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $item->author); } // Set remaining META keys $mdata = $item->metadata->toArray(); foreach ($mdata as $k => $v) { if ($v) { $document->setMetadata($k, $v); } } // Overwrite with menu META data if menu matched if (FLEXI_J16GE) { if ($menu_matches) { if ($_mp = $menu->params->get('menu-meta_description')) { $document->setDescription($_mp); } if ($_mp = $menu->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $_mp); } if ($_mp = $menu->params->get('robots')) { $document->setMetadata('robots', $_mp); } if ($_mp = $menu->params->get('secure')) { $document->setMetadata('secure', $_mp); } } } // ************************************ // Add rel canonical html head link tag (TODO: improve multi-page handing) // ************************************ $base = $uri->getScheme() . '://' . $uri->getHost(); $ucanonical = $base . JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $globalcats[$item->maincatid]->slug, 0, $item)); // $item->categoryslug if ($params->get('add_canonical')) { $head_obj = $document->addHeadLink($ucanonical, 'canonical', 'rel', ''); $defaultCanonical = flexicontent_html::getDefaultCanonical(); if (FLEXI_J30GE && $defaultCanonical != $ucanonical) { unset($head_obj->_links[$defaultCanonical]); } } // ************************* // increment the hit counter // ************************* // MOVED to flexisystem plugin due to ... /*if (FLEXIUtilities::count_new_hit($item->id) ) { $model->hit(); }*/ // Load template css/js and set template data variable $tmplvar = $themes->items->{$ilayout}->tmplvar; if ($ilayout) { // Add the templates css files if availables if (isset($themes->items->{$ilayout}->css)) { foreach ($themes->items->{$ilayout}->css as $css) { $document->addStyleSheet($this->baseurl . '/' . $css); } } // Add the templates js files if availables if (isset($themes->items->{$ilayout}->js)) { foreach ($themes->items->{$ilayout}->js as $js) { $document->addScript($this->baseurl . '/' . $js); } } // Set the template var $tmpl = $themes->items->{$ilayout}->tmplvar; } else { $tmpl = '.items.default'; } // Just put item's text (description field) inside property 'text' in case the events modify the given text, $item->text = isset($item->fields['text']->display) ? $item->fields['text']->display : ''; // Maybe here not to import all plugins but just those for description field ??? // Anyway these events are usually not very time consuming, so lets trigger all of them ??? JPluginHelper::importPlugin('content'); // Suppress some plugins from triggering for compatibility reasons, e.g. // (a) jcomments, jom_comment_bot plugins, because we will get comments HTML manually inside the template files $suppress_arr = array('jcomments', 'jom_comment_bot'); FLEXIUtilities::suppressPlugins($suppress_arr, 'suppress'); // Do some compatibility steps, Set the view and option to 'article' and 'com_content' JRequest::setVar('view', 'article'); JRequest::setVar('option', 'com_content'); JRequest::setVar("isflexicontent", "yes"); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); // These events return text that could be displayed at appropriate positions by our templates $item->event = new stdClass(); if (FLEXI_J16GE) { $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$params, 0)); } else { $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$item, &$params, $limitstart)); } $item->event->afterDisplayTitle = trim(implode("\n", $results)); if (FLEXI_J16GE) { $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$params, 0)); } else { $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$params, $limitstart)); } $item->event->beforeDisplayContent = trim(implode("\n", $results)); if (FLEXI_J16GE) { $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$params, 0)); } else { $results = $dispatcher->trigger('onAfterDisplayContent', array(&$item, &$params, $limitstart)); } $item->event->afterDisplayContent = trim(implode("\n", $results)); // Reverse the compatibility steps, set the view and option back to 'items' and 'com_flexicontent' JRequest::setVar('view', FLEXI_ITEMVIEW); JRequest::setVar('option', 'com_flexicontent'); // Restore suppressed plugins FLEXIUtilities::suppressPlugins($suppress_arr, 'restore'); // Put text back into the description field, THESE events SHOULD NOT modify the item text, but some plugins may do it anyway... , so we assign text back for compatibility if (!empty($item->positions)) { foreach ($item->positions as $pos_fields) { foreach ($pos_fields as $pos_field) { if ($pos_field->name !== 'text') { continue; } $pos_field->display =& $item->text; } } } $item->fields['text']->display =& $item->text; // (TOC) TABLE OF Contents has been created inside description field (named 'text') by // the pagination plugin, this should be assigned to item as a property with same name if (isset($item->fields['text']->toc)) { $item->toc =& $item->fields['text']->toc; } // ******************************************************************************************** // Create pathway, if automatic pathways is enabled, then path will be cleared before populated // ******************************************************************************************** $pathway = $app->getPathWay(); // Clear pathway, if automatic pathways are enabled if ($params->get('automatic_pathways', 0)) { $pathway_arr = $pathway->getPathway(); $pathway->setPathway(array()); //$pathway->set('_count', 0); // not needed ?? $item_depth = 0; // menu item depth is now irrelevant ???, ignore it } else { $item_depth = $params->get('item_depth', 0); } // Respect menu item depth, defined in menu item $p = $item_depth; while ($p < count($parents)) { // For some Content Types the pathway should not be populated with category links if (in_array($item->type_id, $globalnopath)) { break; } // Do not add to pathway unroutable categories if (in_array($parents[$p]->id, $globalnoroute)) { $p++; continue; } // Add current parent category $pathway->addItem($this->escape($parents[$p]->title), JRoute::_(FlexicontentHelperRoute::getCategoryRoute($parents[$p]->slug))); $p++; } if ($params->get('add_item_pathway', 1)) { $pathway->addItem($this->escape($item->title), JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug, 0, $item))); } // ********************************************************************** // Print link ... must include layout and current filtering url vars, etc // ********************************************************************** $curr_url = $_SERVER['REQUEST_URI']; $print_link = $curr_url . (strstr($curr_url, '?') ? '&' : '?') . '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; } }
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { if (!in_array($field->field_type, self::$field_types)) { return; } // Get isMobile / isTablet Flags static $isMobile = null; static $isTablet = null; static $useMobile = null; if ($useMobile === null) { $cparams = JComponentHelper::getParams('com_flexicontent'); $force_desktop_layout = $cparams->get('force_desktop_layout', 0); //$start_microtime = microtime(true); $mobileDetector = flexicontent_html::getMobileDetector(); $isMobile = $mobileDetector->isMobile(); $isTablet = $mobileDetector->isTablet(); $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile; //$time_passed = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; //printf('<br/>-- [Detect Mobile: %.3f s] ', $time_passed/1000000); } $field->label = JText::_($field->label); // Some variables $is_ingroup = !empty($field->ingroup); $use_ingroup = $field->parameters->get('use_ingroup', 0); $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0); // Value handling parameters $lang_filter_values = 0; //$field->parameters->get( 'lang_filter_values', 1); // some parameter shortcuts $target = $field->parameters->get('targetblank', 0); $target_param = $target ? ' target="_blank"' : ''; $display_hits = $field->parameters->get('display_hits', 0); $add_hits_img = $display_hits == 1 || $display_hits == 3; $add_hits_txt = $display_hits == 2 || $display_hits == 3 || $isMobile; $rel_nofollow = $field->parameters->get('add_rel_nofollow', 0) ? ' rel="nofollow"' : ''; // URL value $link_usage = $field->parameters->get('link_usage', 0); $default_link = $link_usage == 2 ? $field->parameters->get('default_value_link', '') : ''; $default_link = $default_link ? JText::_($default_link) : ''; // URL title & linking text (optional) $usetitle = $field->parameters->get('use_title', 0); $title_usage = $field->parameters->get('title_usage', 0); $default_title = $title_usage == 2 ? JText::_($field->parameters->get('default_value_title', '')) : ''; $default_title = $default_title ? JText::_($default_title) : ''; // Get field values $values = $values ? $values : $field->value; // Check for no values and no default value, and return empty display if (empty($values)) { if (!strlen($default_link)) { $field->{$prop} = $is_ingroup ? array() : ''; return; } $values = array(); $values[0]['link'] = $default_link; $values[0]['title'] = $default_title; $values[0]['hits'] = 0; $values[0] = serialize($values[0]); } $unserialize_vals = true; if ($unserialize_vals) { // (* BECAUSE OF THIS, the value display loop expects unserialized values) foreach ($values as &$value) { // Compatibility for unserialized values or for NULL values in a field group if (!is_array($value)) { $v = !empty($value) ? @unserialize($value) : false; $value = $v !== false || $v === 'b:0;' ? $v : array('link' => $value, 'title' => '', 'hits' => 0); } } unset($value); // Unset this or you are looking for trouble !!!, because it is a reference and reusing it will overwrite the pointed variable !!! } // Prefix - Suffix - Separator parameters, replacing other field values if found $remove_space = $field->parameters->get('remove_space', 0); $pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('pretext', ''), 'pretext'); $posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('posttext', ''), 'posttext'); $separatorf = $field->parameters->get('separatorf', 1); $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag'); $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag'); if ($pretext) { $pretext = $remove_space ? $pretext : $pretext . ' '; } if ($posttext) { $posttext = $remove_space ? $posttext : ' ' . $posttext; } 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; } // Get layout name $viewlayout = $field->parameters->get('viewlayout', ''); $viewlayout = $viewlayout ? 'value_' . $viewlayout : 'value_default'; // Create field's HTML, using layout file $field->{$prop} = array(); //$this->values = $values; //$this->displayFieldValue( $prop, $viewlayout ); include self::getFormPath($this->fieldtypes[0], $viewlayout); // Do not convert the array to string if field is in a group, and do not add: FIELD's opetag, closetag, value separator if (!$is_ingroup) { // Apply values separator $field->{$prop} = implode($separatorf, $field->{$prop}); if ($field->{$prop} !== '') { // Apply field 's opening / closing texts $field->{$prop} = $opentag . $field->{$prop} . $closetag; } } }