<?php if ($this->params->get('intro_use_image', 1) && $src) : ?> <figure class="image<?php echo $this->params->get('intro_position') ? ' right' : ' left'; ?>"> <?php if ($this->params->get('intro_link_image', 1)) : ?> <a href="<?php echo JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug, 0, $item)); ?>" class="hasTip" title="<?php echo JText::_( 'FLEXI_READ_MORE_ABOUT' ) . '::' . htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8'); ?>"> <img src="<?php echo $thumb; ?>" alt="<?php echo htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8'); ?>" /> </a> <?php else : ?> <img src="<?php echo $thumb; ?>" alt="<?php echo htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8'); ?>" /> <?php endif; ?> </figure> <?php endif; ?> <p> <?php FlexicontentFields::getFieldDisplay($item, 'text', $values=null, $method='display'); if ($this->params->get('intro_strip_html', 1)) : echo flexicontent_html::striptagsandcut( $item->fields['text']->display, $this->params->get('intro_cut_text', 200) ); else : echo $item->fields['text']->display; endif; ?> </p> </div> <!-- BOF under-description-line1 block --> <?php if (isset($item->positions['under-description-line1'])) : ?> <div class="lineinfo line3"> <?php foreach ($item->positions['under-description-line1'] as $field) : ?> <span class="element"> <?php if ($field->label) : ?> <span class="flexi label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span> <?php endif; ?>
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; } $field->label = JText::_($field->label); // 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 $default_value_use = $field->parameters->get('default_value_use', 0); $default_value = $default_value_use == 2 ? $field->parameters->get('default_value', '') : ''; if (empty($values) && !strlen($default_value)) { $field->{$prop} = ''; return; } else { if (empty($values) && strlen($default_value)) { $values = array($default_value); } } // Value handling parameters $multiple = $field->parameters->get('allow_multiple', 1); // Language filter the values $lang_filter_values = $field->parameters->get('lang_filter_values', 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; } // initialise property $field->{$prop} = array(); $n = 0; foreach ($values as $value) { if (!strlen($value)) { continue; } $field->{$prop}[$n] = $pretext . ($lang_filter_values ? JText::_($value) : $value) . $posttext; $n++; if (!$multiple) { break; } // multiple values disabled, break out of the loop, not adding further values even if the exist } // Apply separator and open/close tags $field->{$prop} = implode($separatorf, $field->{$prop}); if ($field->{$prop} !== '') { $field->{$prop} = $opentag . $field->{$prop} . $closetag; } else { $field->{$prop} = ''; } // Add OGP Data $useogp = $field->parameters->get('useogp', 0); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); $ogpusage = $field->parameters->get('ogpusage', 0); if ($useogp && $field->{$prop}) { $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW)); if (in_array($view, $ogpinview)) { switch ($ogpusage) { case 1: $usagetype = 'title'; break; case 2: $usagetype = 'description'; break; default: $usagetype = ''; break; } if ($usagetype) { $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:' . $usagetype . '" content="' . $content_val . '" />'); } } } }
/** * Creates the RSS for the View * * @since 1.0 */ function display($tpl = null) { $db = JFactory::getDBO(); $doc = JFactory::getDocument(); $app = JFactory::getApplication(); $params = $this->get('Params'); $doc->link = JRoute::_(FlexicontentHelperRoute::getCategoryRoute(JRequest::getVar('cid', null, '', 'int'))); $category = $this->get('Category'); // Prepare query to match feed data JRequest::setVar('limit', $params->get('feed_limit')); // Force a specific limit, this will be moved to the model $params->set('orderby', $params->get('feed_orderby', 'rdate')); $params->set('orderbycustomfield', $params->get('feed_orderbycustomfield', 1)); $params->set('orderbycustomfieldid', $params->get('feed_orderbycustomfieldid', 0)); $params->set('orderbycustomfielddir', $params->get('feed_orderbycustomfielddir', 'ASC')); $params->set('orderbycustomfieldint', $params->get('feed_orderbycustomfieldint', 0)); $params->set('orderby_2nd', $params->get('feed_orderby', 'alpha')); $params->set('orderbycustomfield_2nd', $params->get('feed_orderbycustomfield_2nd', 1)); $params->set('orderbycustomfieldid_2nd', $params->get('feed_orderbycustomfieldid_2nd', 0)); $params->set('orderbycustomfielddir_2nd', $params->get('feed_orderbycustomfielddir_2nd', 'ASC')); $params->set('orderbycustomfieldint_2nd', $params->get('feed_orderbycustomfieldint_2nd', 0)); $model = $this->getModel(); $model->setState('limit', $params->get('feed_limit', $model->getState('limit'))); $rows = $this->get('Data'); $feed_summary = $params->get('feed_summary', 0); $feed_summary_cut = $params->get('feed_summary_cut', 200); $feed_use_image = $params->get('feed_use_image', 1); $feed_link_image = $params->get('feed_link_image', 1); $feed_image_source = $params->get('feed_image_source', ''); $feed_image_size = $params->get('feed_image_size', ''); $feed_image_method = $params->get('feed_image_method', 1); $feed_image_width = $params->get('feed_image_width', 100); $feed_image_height = $params->get('feed_image_height', 80); // Retrieve default image for the image field if ($feed_use_image && $feed_image_source) { $query = 'SELECT attribs, name FROM #__flexicontent_fields WHERE id = ' . (int) $feed_image_source; $db->setQuery($query); $image_dbdata = $db->loadObject(); //$image_dbdata->params = FLEXI_J16GE ? new JRegistry($image_dbdata->params) : new JParameter($image_dbdata->params); $img_size_map = array('l' => 'large', 'm' => 'medium', 's' => 'small', '' => ''); $img_field_size = $img_size_map[$feed_image_size]; $img_field_name = $image_dbdata->name; } // TODO render and add extra fields here ... maybe via special display function for feeds view $extra_fields = $params->get('feed_extra_fields', ''); $extra_fields = array_unique(preg_split("/\\s*,\\s*/u", $extra_fields)); if ($extra_fields) { foreach ($extra_fields as $fieldname) { // Render given field for ALL ITEMS FlexicontentFields::getFieldDisplay($rows, $fieldname, $values = null, $method = 'display'); } } foreach ($rows as $row) { // strip html from feed item title $title = $this->escape($row->title); $title = html_entity_decode($title); // url link to article // & used instead of & as this is converted by feed creator $link = JRoute::_(FlexicontentHelperRoute::getItemRoute($row->slug, $category->slug, 0, $row)); // strip html from feed item description text $description = $feed_summary ? $row->introtext . $row->fulltext : $row->introtext; $description = flexicontent_html::striptagsandcut($description, $feed_summary_cut); if ($feed_use_image) { // feed image is enabled $src = ''; $thumb = ''; if ($feed_image_source) { // case 1 use an image field FlexicontentFields::getFieldDisplay($row, $img_field_name, null, 'display', 'module'); $img_field = $row->fields[$img_field_name]; if (!$img_field_size) { $src = str_replace(JURI::root(), '', $img_field->thumbs_src['large'][0]); } else { $src = ''; $thumb = $img_field->thumbs_src[$img_field_size][0]; } } else { // case 2 extract from item $src = flexicontent_html::extractimagesrc($row); } $RESIZE_FLAG = !$feed_image_source || !$img_field_size; if ($src && $RESIZE_FLAG) { // Resize image when src path is set and RESIZE_FLAG: (a) using image extracted from item main text OR (b) not using image field's already created thumbnails $h = '&h=' . $feed_image_height; $w = '&w=' . $feed_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $feed_image_method ? '&zc=' . $feed_image_method : ''; $ext = pathinfo($src, PATHINFO_EXTENSION); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : ''; $thumb = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $base_url . $src . $conf; } else { // Do not resize image when (a) image src path not set or (b) using image field's already created thumbnails } if ($thumb) { $description = "\n\t \t\t\t<div class='feed-description'>\n\t\t \t\t\t<a class='feed-readmore' target='_blank' href='" . $link . "'>\n\t\t \t\t\t\t<img src='" . $thumb . "' alt='" . $title . "' title='" . $title . "' align='left'/>\n\t\t \t\t\t</a>\n\t\t \t\t\t<p>" . $description . "</p>\n\t\t \t\t</div>"; } } if ($extra_fields) { foreach ($extra_fields as $fieldname) { if ($row->fields[$fieldname]->display) { $description .= '<br/><b>' . $row->fields[$fieldname]->label . ":</b> " . $row->fields[$fieldname]->display; } } } //$author = $row->created_by_alias ? $row->created_by_alias : $row->author; @($date = $row->created ? date('r', strtotime($row->created)) : ''); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; //$item->author = $author; $item->category = $this->escape($category->title); // loads item info into rss array $doc->addItem($item); } }
if ((int) $version->nr > 0) { ?> <tr<?php echo $class; ?> > <td class="versions"><span style="padding: 0 5px 0 0;"><?php echo '#' . $version->nr; ?> </span></td> <td class="versions"><span style="padding: 0 5px 0 0;"><?php echo JHTML::_('date', $version->nr == 1 ? $this->row->created : $version->date, $date_format); ?> </span></td> <td class="versions"><span style="padding: 0 5px 0 0;"><?php echo $version->nr == 1 ? flexicontent_html::striptagsandcut($this->row->creator, 25) : flexicontent_html::striptagsandcut($version->modifier, 25); ?> </span></td> <td class="versions"><a href="javascript:;" class="hasTip" title="Comment::<?php echo htmlspecialchars($version->comment, ENT_COMPAT, 'UTF-8'); ?> "><?php echo $commentimage; ?> </a><?php if ((int) $version->nr == (int) $this->row->current_version) { ?> <a onclick="javascript:return clickRestore('index.php?option=com_flexicontent&view=item&<?php echo $task_items; ?> edit&cid=<?php
<td headers="fc_title"> <a href="<?php echo $item_link; ?> "> <?php echo $this->escape($item->title); ?> </a> <?php echo $markup_tags; ?> </td> <td headers="fc_intro"> <?php echo flexicontent_html::striptagsandcut($item->introtext, 150); ?> </td> <?php if ($use_date) { ?> <td headers="fc_modified"> <?php echo JHTML::_('date', $item->modified ? $item->modified : $item->created, JText::_($dateformat)); ?> </td> <?php } ?>
function onDisplayCoreFieldValue(&$_field, &$_item, &$params, $_tags = null, $_categories = null, $_favourites = null, $_favoured = null, $_vote = null, $values = null, $prop = 'display') { $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW)); static $cat_links = array(); static $tag_links = array(); static $cparams = null; if ($cparams === null) { $cparams = JComponentHelper::getParams('com_flexicontent'); } if (!is_array($_item)) { $items = array(&$_item); } else { $items =& $_item; } // Prefix - Suffix - Separator parameters // these parameters should be common so we will retrieve them from the first item instead of inside the loop $item = reset($items); if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } $remove_space = $field->parameters->get('remove_space', 0); $_pretext = $field->parameters->get('pretext', ''); $_posttext = $field->parameters->get('posttext', ''); $separatorf = $field->parameters->get('separatorf', 3); $_opentag = $field->parameters->get('opentag', ''); $_closetag = $field->parameters->get('closetag', ''); $pretext_cacheable = $posttext_cacheable = $opentag_cacheable = $closetag_cacheable = false; switch ($separatorf) { case 0: $separatorf = ' '; break; case 1: $separatorf = '<br />'; break; case 2: $separatorf = ' | '; break; case 3: $separatorf = ', '; break; case 4: $separatorf = $closetag . $opentag; break; case 5: $separatorf = ''; break; default: $separatorf = ' '; break; } foreach ($items as $item) { //if (!is_object($_field)) echo $item->id." - ".$_field ."<br/>"; if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } if ($field->iscore != 1) { continue; } $field->item_id = $item->id; // Replace item properties or values of other fields if (!$pretext_cacheable) { $pretext = FlexicontentFields::replaceFieldValue($field, $item, $_pretext, 'pretext', $pretext_cacheable); if ($pretext && !$remove_space) { $pretext = $pretext . ' '; } } if (!$posttext_cacheable) { $posttext = FlexicontentFields::replaceFieldValue($field, $item, $_posttext, 'posttext', $posttext_cacheable); if ($posttext && !$remove_space) { $posttext = ' ' . $posttext; } } if (!$opentag_cacheable) { $opentag = FlexicontentFields::replaceFieldValue($field, $item, $_opentag, 'opentag', $opentag_cacheable); } // used by some fields if (!$closetag_cacheable) { $closetag = FlexicontentFields::replaceFieldValue($field, $item, $_closetag, 'closetag', $closetag_cacheable); } // used by some fields $field->value = array(); switch ($field->field_type) { case 'created': // created $field->value = array($item->created); // Get date format $customdate = $field->parameters->get('custom_date', 'Y-m-d'); $dateformat = $field->parameters->get('date_format', ''); $dateformat = $dateformat ? JText::_($dateformat) : ($field->parameters->get('lang_filter_format', 0) ? JText::_($customdate) : $customdate); // Add prefix / suffix $field->{$prop} = $pretext . JHTML::_('date', $item->created, $dateformat) . $posttext; // Add microdata property $itemprop = $field->parameters->get('microdata_itemprop', 'dateCreated'); if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } break; case 'createdby': // created by $field->value[] = $item->created_by; $field->{$prop} = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->cuname : $item->creator) . $posttext; break; case 'modified': // modified $field->value = array($item->modified); // Get date format $customdate = $field->parameters->get('custom_date', 'Y-m-d'); $dateformat = $field->parameters->get('date_format', ''); $dateformat = $dateformat ? JText::_($dateformat) : ($field->parameters->get('lang_filter_format', 0) ? JText::_($customdate) : $customdate); // Add prefix / suffix $field->{$prop} = $pretext . JHTML::_('date', $item->modified, $dateformat) . $posttext; // Add microdata property $itemprop = $field->parameters->get('microdata_itemprop', 'dateModified'); if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } break; case 'modifiedby': // modified by $field->value[] = $item->modified_by; $field->{$prop} = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->muname : $item->modifier) . $posttext; break; case 'title': // title $field->value[] = $item->title; $field->{$prop} = $pretext . $item->title . $posttext; // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:title" content="' . $content_val . '" />'); } } // Add microdata property (currently no parameter in XML for this field) $itemprop = $field->parameters->get('microdata_itemprop', 'name'); if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } break; case 'hits': // hits $field->value[] = $item->hits; $field->{$prop} = $pretext . $item->hits . $posttext; break; case 'type': // document type $field->value[] = $item->type_id; $field->{$prop} = $pretext . JText::_($item->typename) . $posttext; break; case 'version': // version $field->value[] = $item->version; $field->{$prop} = $pretext . $item->version . $posttext; break; case 'state': // state $field->value[] = $item->state; $field->{$prop} = $pretext . flexicontent_html::stateicon($item->state, $field->parameters) . $posttext; break; case 'voting': // voting button if ($_vote === false) { $vote =& $item->vote; } else { $vote =& $_vote; } $field->value[] = 'button'; // dummy value to force display $field->{$prop} = $pretext . flexicontent_html::ItemVote($field, 'all', $vote) . $posttext; break; case 'favourites': // favourites button if ($_favourites === false) { $favourites =& $item->favs; } else { $favourites =& $_favourites; } if ($_favoured === false) { $favoured =& $item->fav; } else { $favoured =& $_favoured; } $field->value[] = 'button'; // dummy value to force display $favs = flexicontent_html::favoured_userlist($field, $item, $favourites); $field->{$prop} = $pretext . ' <div class="fav-block"> ' . flexicontent_html::favicon($field, $favoured, $item) . ' <div id="fcfav-reponse_item_' . $item->id . '" class="fcfav-reponse-tip"> <div class="fc-mssg-inline fc-info fc-iblock fc-nobgimage ' . ($favoured ? 'fcfavs-is-subscriber' : 'fcfavs-isnot-subscriber') . '"> ' . JText::_($favoured ? 'FLEXI_FAVS_YOU_HAVE_SUBSCRIBED' : 'FLEXI_FAVS_CLICK_TO_SUBSCRIBE') . ' </div> ' . $favs . ' </div> </div> ' . $posttext; break; case 'categories': // assigned categories $field->{$prop} = ''; if ($_categories === false) { $categories =& $item->cats; } else { $categories =& $_categories; } if ($categories) { // Get categories that should be excluded from linking global $globalnoroute; if (!is_array($globalnoroute)) { $globalnoroute = array(); } // Create list of category links, excluding the "noroute" categories $field->{$prop} = array(); foreach ($categories as $category) { $cat_id = $category->id; if (in_array($cat_id, @$globalnoroute)) { continue; } if (!isset($cat_links[$cat_id])) { $cat_links[$cat_id] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug)); } $cat_link =& $cat_links[$cat_id]; $display = '<a class="fc_categories fc_category_' . $cat_id . ' link_' . $field->name . '" href="' . $cat_link . '">' . $category->title . '</a>'; $field->{$prop}[] = $pretext . $display . $posttext; $field->value[] = $category->title; } $field->{$prop} = implode($separatorf, $field->{$prop}); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } break; case 'tags': // assigned tags $use_catlinks = $cparams->get('tags_using_catview', 0); $field->{$prop} = ''; if ($_tags === false) { $tags =& $item->tags; } else { $tags =& $_tags; } if ($tags) { // Create list of tag links $field->{$prop} = array(); foreach ($tags as $tag) { $tag_id = $tag->id; if (!isset($tag_links[$tag_id])) { $tag_links[$tag_id] = $use_catlinks ? JRoute::_(FlexicontentHelperRoute::getCategoryRoute(0, 0, array('layout' => 'tags', 'tagid' => $tag->slug))) : JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug)); } $tag_link =& $tag_links[$tag_id]; $display = '<a class="fc_tags fc_tag_' . $tag->id . ' link_' . $field->name . '" href="' . $tag_link . '">' . $tag->name . '</a>'; $field->{$prop}[] = $pretext . $display . $posttext; $field->value[] = $tag->name; } $field->{$prop} = implode($separatorf, $field->{$prop}); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } break; case 'maintext': // main text // Special display variables if ($prop != 'display') { switch ($prop) { case 'display_if': $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; break; case 'display_i': $field->{$prop} = $item->introtext; break; case 'display_f': $field->{$prop} = $item->fulltext; break; } } else { if (!$item->fulltext) { $field->{$prop} = $item->introtext; } else { if ($view != FLEXI_ITEMVIEW) { if ($item->parameters->get('force_full', 0)) { $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->{$prop} = $item->introtext; } } else { if ($item->parameters->get('show_intro', 1)) { $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->{$prop} = $item->fulltext; } } } } // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { if ($item->metadesc) { JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $item->metadesc . '" />'); } else { $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $content_val . '" />'); } } } break; } } }
if ($infocount_str) { $infocount_str = ' (' . $infocount_str . ')'; } ?> <!-- EOF subcategory assigned/subcats_count --> <?php } ?> <?php if ($this->params->get($catid != $currcatid ? 'show_description_subcat' : 'show_description', 1)) { ?> <!-- BOF subcategory description --> <div class="catdescription group"> <?php echo flexicontent_html::striptagsandcut($sub->description, $this->params->get($catid != $currcatid ? 'description_cut_text_subcat' : 'description_cut_text', 120)); ?> </div> <!-- EOF subcategory description --> <?php } ?> </div> <?php if ($items) { ?> <!-- BOF subcategory items --> <div class="group">
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); $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW)); // Value handling parameters $lang_filter_values = 0; //$field->parameters->get( 'lang_filter_values', 1); $clean_output = $field->parameters->get('clean_output', 0); $encode_output = $field->parameters->get('encode_output', 0); $use_html = $field->field_type == 'maintext' ? !$field->parameters->get('hide_html', 0) : $field->parameters->get('use_html', 0); // Default value $value_usage = $field->parameters->get('default_value_use', 0); $default_value = $value_usage == 2 ? $field->parameters->get('default_value', '') : ''; $default_value = $default_value ? JText::_($default_value) : ''; // 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_value)) { $field->{$prop} = $is_ingroup ? array() : ''; return; } $values = array($default_value); } // ****************************************** // Language filter, clean output, encode HTML // ****************************************** if ($clean_output) { $ifilter = $clean_output == 1 ? JFilterInput::getInstance(null, null, 1, 1) : JFilterInput::getInstance(); } if ($lang_filter_values || $clean_output || $encode_output || !$use_html) { // (* BECAUSE OF THIS, the value display loop expects unserialized values) foreach ($values as &$value) { if (empty($value)) { continue; } // skip further actions if ($lang_filter_values) { $value = JText::_($value); } if ($clean_output) { $value = $ifilter->clean($value, 'string'); } if ($encode_output) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); } if (!$use_html) { $value = nl2br(preg_replace("/(\r\n|\r|\n){3,}/", "\n\n", $value)); } } 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; } // Create field's HTML $field->{$prop} = array(); $n = 0; foreach ($values as $value) { if (!strlen($value) && !$is_ingroup) { continue; } // Skip empty if not in field group if (!strlen($value)) { $field->{$prop}[$n++] = ''; continue; } // Add prefix / suffix $field->{$prop}[$n] = $pretext . $value . $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} = ''; } } // ************ // Add OGP tags // ************ if ($field->parameters->get('useogp', 0) && !empty($field->{$prop})) { // Get ogp configuration $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); $ogpusage = $field->parameters->get('ogpusage', 0); if (in_array($view, $ogpinview)) { switch ($ogpusage) { case 1: $usagetype = 'title'; break; case 2: $usagetype = 'description'; break; default: $usagetype = ''; break; } if ($usagetype) { $content_val = !$is_ingroup ? flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen) : flexicontent_html::striptagsandcut($opentag . implode($separatorf, $field->{$prop}) . $closetag, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:' . $usagetype . '" content="' . $content_val . '" />'); } } } }
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; }
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; $field->label = JText::_($field->label); // Some variables $document = JFactory::getDocument(); $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW)); // 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 $default_value_use= $field->parameters->get( 'default_value_use', 0 ) ; $default_value = ($default_value_use == 2) ? $field->parameters->get( 'default_value', '' ) : ''; if ( empty($values) && !strlen($default_value) ) { $field->{$prop} = ''; return; } else if ( empty($values) && strlen($default_value) ) { $values = array($default_value); } // Prefix - Suffix - Separator parameters, replacing other field values if found $opentag = FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'opentag', '' ), 'opentag' ); $closetag = FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'closetag', '' ), 'closetag' ); // some parameter shortcuts $use_html = $field->parameters->get( 'use_html', 0 ) ; // Get ogp configuration $useogp = $field->parameters->get('useogp', 0); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); $ogpusage = $field->parameters->get('ogpusage', 0); // Apply seperator and open/close tags if ($values) { $field->{$prop} = $use_html ? $values[0] : nl2br($values[0]); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } else { $field->{$prop} = ''; } if ($useogp && $field->{$prop}) { if ( in_array($view, $ogpinview) ) { switch ($ogpusage) { case 1: $usagetype = 'title'; break; case 2: $usagetype = 'description'; break; default: $usagetype = ''; break; } if ($usagetype) { $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen); $document->addCustomTag('<meta property="og:'.$usagetype.'" content="'.$content_val.'" />'); } } } //view if ( !$field->{$prop} ) { } else { $tmp_val = unserialize($field->{$prop}); //var_dump($tmp_val); $header_html = '<table class="flexitable">' .'<thead>' .'<tr>' .'<th style="font-size:80%;">'.JText::_("Страна").'</th>' .'<th style="font-size:80%;">'.JText::_("Наименование").'</th>' .'<th style="font-size:80%;">'.JText::_("Форма выпуска").'</th>' .'<th style="font-size:80%;">'.JText::_("Регистрационный №").'</th>' .'<th style="font-size:80%;">'.JText::_("Дата окончания регистрации").'</th>' .'</tr>' .'</thead>' .'<tbody>'; for($intA = 0; $intA < count($tmp_val['country']); $intA++){ $header_html .= '<tr>'; $header_html .= '<td>' . $tmp_val['country'][$intA] . '</td>'; $header_html .= '<td>' . $tmp_val['naimen'][$intA] . '</td>'; $header_html .= '<td>' . $tmp_val['vypusk'][$intA] . '</td>'; $header_html .= '<td>' . $tmp_val['reg'][$intA] . '</td>'; $header_html .= '<td>' . $tmp_val['date'][$intA] . '</td>'; $header_html .= '<tr>'; } $header_html .= '</tbody>'; $header_html .= '</table>'; $field->{$prop} = $header_html; //var_dump($field->{$prop}); //var_dump($field->value[0]); } }
/** * Download logic * * @access public * @since 1.0 */ function download() { // Import and Initialize some joomla API variables jimport('joomla.filesystem.file'); $app = JFactory::getApplication(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $task = JRequest::getVar('task', 'download'); $session = JFactory::getSession(); $method = JRequest::getVar('method', 'download'); if ($method != 'view' && $method != 'download') { die('unknown download method:' . $method); } // ******************************************************************************************************************* // Single file download (via HTTP request) or multi-file downloaded (via a folder structure in session or in DB table) // ******************************************************************************************************************* if ($task == 'download_tree') { // TODO: maybe move this part in module $cart_id = JRequest::getVar('cart_id', 0); if (!$cart_id) { // Get zTree data and parse JSON string $tree_var = JRequest::getVar('tree_var', ""); if ($session->has($tree_var, 'flexicontent')) { $ztree_nodes_json = $session->get($tree_var, false, 'flexicontent'); } $nodes = json_decode($ztree_nodes_json); } else { $cart_token = JRequest::getVar('cart_token', ''); $query = ' SELECT * FROM #__flexicontent_downloads_cart WHERE id=' . $cart_id; $db->setQuery($query); $cart = $db->loadObject(); if ($db->getErrorNum()) { JFactory::getApplication()->enqueueMessage(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()), 'error'); } if (!$cart) { echo JText::_('cart id no ' . $cart_id . ', was not found'); jexit(); } $cart_token_matches = $cart_token == $cart->token; // no access will be checked $nodes = json_decode($cart->json); } // Some validation check if (!is_array($nodes)) { $app->enqueueMessage("Tree structure is empty or invalid", 'notice'); $this->setRedirect('index.php', ''); return; } $app = JFactory::getApplication(); $tmp_ffname = 'fcmd_uid_' . $user->id . '_' . date('Y-m-d__H-i-s'); $targetpath = JPath::clean($app->getCfg('tmp_path') . DS . $tmp_ffname); $tree_files = $this->_traverseFileTree($nodes, $targetpath); //echo "<pre>"; print_r($tree_files); jexit(); if (empty($tree_files)) { $app->enqueueMessage("No files selected for download", 'notice'); $this->setRedirect('index.php', ''); return; } } else { $file_node = new stdClass(); $file_node->fieldid = JRequest::getInt('fid', 0); $file_node->contentid = JRequest::getInt('cid', 0); $file_node->fileid = JRequest::getInt('id', 0); $coupon_id = JRequest::getInt('conid', 0); $coupon_token = JRequest::getString('contok', ''); if ($coupon_id) { $_nowDate = 'UTC_TIMESTAMP()'; $_nullDate = $db->Quote($db->getNullDate()); $query = ' SELECT *' . ', CASE WHEN ' . ' expire_on = ' . $_nullDate . ' OR expire_on > ' . $_nowDate . ' THEN 0 ELSE 1 END AS has_expired' . ', CASE WHEN ' . ' hits_limit = -1 OR hits < hits_limit' . ' THEN 0 ELSE 1 END AS has_reached_limit' . ' FROM #__flexicontent_download_coupons' . ' WHERE id=' . $coupon_id . ' AND token=' . $db->Quote($coupon_token); $db->setQuery($query); $coupon = $db->loadObject(); if ($db->getErrorNum()) { echo __FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()); jexit(); } if ($coupon) { $slink_valid_coupon = !$coupon->has_reached_limit && !$coupon->has_expired; if (!$slink_valid_coupon) { $query = ' DELETE FROM #__flexicontent_download_coupons WHERE id=' . $coupon->id; $db->setQuery($query); $db->execute(); } } $file_node->coupon = !empty($coupon) ? $coupon : false; // NULL will not be catched by isset() } $tree_files = array($file_node); } // ************************************************** // Create and Execute SQL query to retrieve file info // ************************************************** // Create SELECT OR JOIN / AND clauses for checking Access $access_clauses['select'] = ''; $access_clauses['join'] = ''; $access_clauses['and'] = ''; $using_access = empty($cart_token_matches) && empty($slink_valid_coupon); if ($using_access) { // note CURRENTLY multi-download feature does not use coupons $access_clauses = $this->_createFieldItemAccessClause($get_select_access = true, $include_file = true); } // *************************** // Get file data for all files // *************************** $fields_props = array(); $fields_conf = array(); $valid_files = array(); $email_recipients = array(); foreach ($tree_files as $file_node) { // Get file variable shortcuts (reforce being int) $field_id = (int) $file_node->fieldid; $content_id = (int) $file_node->contentid; $file_id = (int) $file_node->fileid; if (!isset($fields_conf[$field_id])) { $q = 'SELECT attribs, name, field_type FROM #__flexicontent_fields WHERE id = ' . (int) $field_id; $db->setQuery($q); $fld = $db->loadObject(); $fields_conf[$field_id] = new JRegistry($fld->attribs); $fields_props[$field_id] = $fld; } $field_type = $fields_props[$field_id]->field_type; $query = 'SELECT f.id, f.filename, f.filename_original, f.altname, f.secure, f.url, f.hits' . ', i.title as item_title, i.introtext as item_introtext, i.fulltext as item_fulltext, u.email as item_owner_email' . ', i.access as item_access, i.language as item_language, ie.type_id as item_type_id' . ', CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(\':\', i.id, i.alias) ELSE i.id END as itemslug' . ', CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug' . ', dh.id as history_id' . $access_clauses['select'] . ' FROM #__flexicontent_files AS f ' . ($field_type == 'file' ? ' LEFT JOIN #__flexicontent_fields_item_relations AS rel ON rel.field_id = ' . $field_id : '') . ' LEFT JOIN #__flexicontent_fields AS fi ON fi.id = ' . $field_id . ' LEFT JOIN #__content AS i ON i.id = ' . $content_id . ' LEFT JOIN #__categories AS c ON c.id = i.catid' . ' LEFT JOIN #__flexicontent_items_ext AS ie ON ie.item_id = i.id' . ' LEFT JOIN #__flexicontent_types AS ty ON ie.type_id = ty.id' . ' LEFT JOIN #__users AS u ON u.id = i.created_by' . ' LEFT JOIN #__flexicontent_download_history AS dh ON dh.file_id = f.id AND dh.user_id = ' . (int) $user->id . $access_clauses['join'] . ' WHERE i.id = ' . $content_id . ' AND fi.id = ' . $field_id . ' AND f.id = ' . $file_id . ' AND f.published= 1' . $access_clauses['and']; $db->setQuery($query); $file = $db->loadObject(); if ($db->getErrorNum()) { echo __FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()); jexit(); } //echo "<pre>". print_r($file, true) ."</pre>"; exit; // ************************************************************** // Check if file was found AND IF user has required Access Levels // ************************************************************** if (empty($file) || $using_access && (!$file->has_content_access || !$file->has_field_access || !$file->has_file_access)) { if (empty($file)) { $msg = JText::_('FLEXI_FDC_FAILED_TO_FIND_DATA'); // Failed to match DB data to the download URL data } else { $msg = JText::_('FLEXI_ALERTNOTAUTH'); if (!empty($file_node->coupon)) { if ($file_node->coupon->has_expired) { $msg .= JText::_('FLEXI_FDC_COUPON_HAS_EXPIRED'); } else { if ($file_node->coupon->has_reached_limit) { $msg .= JText::_('FLEXI_FDC_COUPON_REACHED_USAGE_LIMIT'); } else { $msg = "unreachable code in download coupon handling"; } } } else { if (isset($file_node->coupon)) { $msg .= "<br/> <small>" . JText::_('FLEXI_FDC_COUPON_NO_LONGER_USABLE') . "</small>"; } $msg .= '' . (!$file->has_content_access ? "<br/><br/> " . JText::_('FLEXI_FDC_NO_ACCESS_TO') . " -- " . JText::_('FLEXI_FDC_CONTENT_CONTAINS') . " " . JText::_('FLEXI_FDC_WEBLINK') . "<br/><small>(" . JText::_('FLEXI_FDC_CONTENT_EXPLANATION') . ")</small>" : '') . (!$file->has_field_access ? "<br/><br/> " . JText::_('FLEXI_FDC_NO_ACCESS_TO') . " -- " . JText::_('FLEXI_FDC_FIELD_CONTAINS') . " " . JText::_('FLEXI_FDC_WEBLINK') : '') . (!$file->has_file_access ? "<br/><br/> " . JText::_('FLEXI_FDC_NO_ACCESS_TO') . " -- " . JText::_('FLEXI_FDC_FILE') . " " : ''); } $msg .= "<br/><br/> " . JText::sprintf('FLEXI_FDC_FILE_DATA', $file_id, $content_id, $field_id); $app->enqueueMessage($msg, 'notice'); } // Only abort for single file download if ($task != 'download_tree') { $this->setRedirect('index.php', ''); return; } } // **************************************************** // (for non-URL) Create file path and check file exists // **************************************************** if (!$file->url) { $basePath = $file->secure ? COM_FLEXICONTENT_FILEPATH : COM_FLEXICONTENT_MEDIAPATH; $file->abspath = str_replace(DS, '/', JPath::clean($basePath . DS . $file->filename)); if (!JFile::exists($file->abspath)) { $msg = JText::_('FLEXI_REQUESTED_FILE_DOES_NOT_EXIST_ANYMORE'); $app->enqueueMessage($msg, 'notice'); // Only abort for single file download if ($task != 'download_tree') { $this->setRedirect('index.php', ''); return; } } } // ********************************************************************* // Increment hits counter of file, and hits counter of file-user history // ********************************************************************* $filetable = JTable::getInstance('flexicontent_files', ''); $filetable->hit($file_id); if (empty($file->history_id)) { $query = ' INSERT #__flexicontent_download_history ' . ' SET user_id = ' . (int) $user->id . ' , file_id = ' . $file_id . ' , last_hit_on = NOW()' . ' , hits = 1'; } else { $query = ' UPDATE #__flexicontent_download_history ' . ' SET last_hit_on = NOW()' . ' , hits = hits + 1' . ' WHERE id = ' . (int) $file->history_id; } $db->setQuery($query); $db->execute(); // ************************************************************************************************** // Increment hits on download coupon or delete the coupon if it has expired due to date or hits limit // ************************************************************************************************** if (!empty($file_node->coupon)) { if (!$file_node->coupon->has_reached_limit && !$file_node->coupon->has_expired) { $query = ' UPDATE #__flexicontent_download_coupons' . ' SET hits = hits + 1' . ' WHERE id=' . $file_node->coupon->id; $db->setQuery($query); $db->execute(); } } // ************************** // Special case file is a URL // ************************** if ($file->url) { // Check for empty URL $url = $file->filename_original ? $file->filename_original : $file->filename; if (empty($url)) { $msg = "File URL is empty: " . $file->url; $app->enqueueMessage($msg, 'error'); return false; } // skip url-based file if downloading multiple files if ($task == 'download_tree') { $msg = "Skipped URL based file: " . $url; $app->enqueueMessage($msg, 'notice'); continue; } // redirect to the file download link @header("Location: " . $url . ""); $app->close(); } // ********************************************************************* // Set file (tree) node and assign file into valid files for downloading // ********************************************************************* $file->node = $file_node; $valid_files[$file_id] = $file; $file->hits++; $per_downloads = $fields_conf[$field_id]->get('notifications_hits_step', 20); if ($fields_conf[$field_id]->get('send_notifications') && $file->hits % $per_downloads == 0) { // Calculate (once per file) some text used for notifications $file->__file_title__ = $file->altname && $file->altname != $file->filename ? $file->altname . ' [' . $file->filename . ']' : $file->filename; $item = new stdClass(); $item->access = $file->item_access; $item->type_id = $file->item_type_id; $item->language = $file->item_language; $file->__item_url__ = JRoute::_(FlexicontentHelperRoute::getItemRoute($file->itemslug, $file->catslug, 0, $item)); // Parse and identify language strings and then make language replacements $notification_tmpl = $fields_conf[$field_id]->get('notification_tmpl'); if (empty($notification_tmpl)) { $notification_tmpl = JText::_('FLEXI_HITS') . ": " . $file->hits; $notification_tmpl .= '%%FLEXI_FDN_FILE_NO%% __file_id__: "__file_title__" ' . "\n"; $notification_tmpl .= '%%FLEXI_FDN_FILE_IN_ITEM%% "__item_title__":' . "\n"; $notification_tmpl .= '__item_url__'; } $result = preg_match_all("/\\%\\%([^%]+)\\%\\%/", $notification_tmpl, $translate_matches); $translate_strings = $result ? $translate_matches[1] : array(); foreach ($translate_strings as $translate_string) { $notification_tmpl = str_replace('%%' . $translate_string . '%%', JText::_($translate_string), $notification_tmpl); } $file->notification_tmpl = $notification_tmpl; // Send to hard-coded email list $send_all_to_email = $fields_conf[$field_id]->get('send_all_to_email'); if ($send_all_to_email) { $emails = preg_split("/[\\s]*;[\\s]*/", $send_all_to_email); foreach ($emails as $email) { $email_recipients[$email][] = $file; } } // Send to item owner $send_to_current_item_owner = $fields_conf[$field_id]->get('send_to_current_item_owner'); if ($send_to_current_item_owner) { $email_recipients[$file->item_owner_email][] = $file; } // Send to email assigned to email field in same content item $send_to_email_field = (int) $fields_conf[$field_id]->get('send_to_email_field'); if ($send_to_email_field) { $q = 'SELECT value ' . ' FROM #__flexicontent_fields_item_relations ' . ' WHERE field_id = ' . $send_to_email_field . ' AND item_id=' . $content_id; $db->setQuery($q); $email_values = $db->loadColumn(); foreach ($email_values as $i => $email_value) { if (@unserialize($email_value) !== false || $email_value === 'b:0;') { $email_values[$i] = unserialize($email_value); } else { $email_values[$i] = array('addr' => $email_value, 'text' => ''); } $addr = @$email_values[$i]['addr']; if ($addr) { $email_recipients[$addr][] = $file; } } } } } //echo "<pre>". print_r($valid_files, true) ."</pre>"; //echo "<pre>". print_r($email_recipients, true) ."</pre>"; //sjexit(); if (!empty($email_recipients)) { ob_start(); $sendermail = $app->getCfg('mailfrom'); $sendermail = JMailHelper::cleanAddress($sendermail); $sendername = $app->getCfg('sitename'); $subject = JText::_('FLEXI_FDN_FILE_DOWNLOAD_REPORT'); $message_header = JText::_('FLEXI_FDN_FILE_DOWNLOAD_REPORT_BY') . ': ' . $user->name . ' [' . $user->username . ']'; // **************************************************** // Send email notifications about file being downloaded // **************************************************** // Personalized email per subscribers foreach ($email_recipients as $email_addr => $files_arr) { $to = JMailHelper::cleanAddress($email_addr); $_message = $message_header; foreach ($files_arr as $filedata) { $_mssg_file = $filedata->notification_tmpl; $_mssg_file = str_ireplace('__file_id__', $filedata->id, $_mssg_file); $_mssg_file = str_ireplace('__file_title__', $filedata->__file_title__, $_mssg_file); $_mssg_file = str_ireplace('__item_title__', $filedata->item_title, $_mssg_file); //$_mssg_file = str_ireplace('__item_title_linked__', $filedata->password, $_mssg_file); $_mssg_file = str_ireplace('__item_url__', $filedata->__item_url__, $_mssg_file); $count = 0; $_mssg_file = str_ireplace('__file_hits__', $filedata->hits, $_mssg_file, $count); if ($count == 0) { $_mssg_file = JText::_('FLEXI_HITS') . ": " . $file->hits . "\n" . $_mssg_file; } $_message .= "\n\n" . $_mssg_file; } //echo "<pre>". $_message ."</pre>"; $from = $sendermail; $fromname = $sendername; $recipient = array($to); $html_mode = false; $cc = null; $bcc = null; $attachment = null; $replyto = null; $replytoname = null; $send_result = FLEXI_J16GE ? JFactory::getMailer()->sendMail($from, $fromname, $recipient, $subject, $_message, $html_mode, $cc, $bcc, $attachment, $replyto, $replytoname) : JUtility::sendMail($from, $fromname, $recipient, $subject, $_message, $html_mode, $cc, $bcc, $attachment, $replyto, $replytoname); } ob_end_clean(); } // * Required for IE, otherwise Content-disposition is ignored if (ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); } if ($task == 'download_tree') { // Create target (top level) folder JFolder::create($targetpath, 0755); // Copy Files foreach ($valid_files as $file) { JFile::copy($file->abspath, $file->node->targetpath); } // Create text/html file with ITEM title / descriptions // TODO replace this with a TEMPLATE file ... $desc_filename = $targetpath . DS . "_descriptions"; $handle_txt = fopen($desc_filename . ".txt", "w"); $handle_htm = fopen($desc_filename . ".htm", "w"); fprintf($handle_htm, ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr" > <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body> '); foreach ($valid_files as $file) { fprintf($handle_txt, "%s", $file->item_title . "\n\n"); fprintf($handle_txt, "%s", flexicontent_html::striptagsandcut($file->item_introtext) . "\n\n"); if (strlen($file->item_fulltext)) { fprintf($handle_txt, "%s", flexicontent_html::striptagsandcut($file->item_fulltext) . "\n\n"); } fprintf($handle_htm, "%s", "<h2>" . $file->item_title . "</h2>"); fprintf($handle_htm, "%s", "<blockquote>" . $file->item_introtext . "</blockquote><br/>"); if (strlen($file->item_fulltext)) { fprintf($handle_htm, "%s", "<blockquote>" . $file->item_fulltext . "</blockquote><br/>"); } fprintf($handle_htm, "<hr/><br/>"); } fclose($handle_txt); fclose($handle_htm); // Get file list recursively, and calculate archive filename $fileslist = JFolder::files($targetpath, '.', $recurse = true, $fullpath = true); $archivename = $tmp_ffname . '.zip'; $archivepath = JPath::clean($app->getCfg('tmp_path') . DS . $archivename); // ****************** // Create the archive // ****************** /*$app = JFactory::getApplication('administrator'); $files = array(); foreach ($fileslist as $i => $filename) { $files[$i]=array(); $files[$i]['name'] = preg_replace("%^(\\\|/)%", "", str_replace($targetpath, "", $filename) ); // STRIP PATH for filename inside zip $files[$i]['data'] = implode('', file($filename)); // READ contents into string, here we use full path $files[$i]['time'] = time(); } $packager = JArchive::getAdapter('zip'); if (!$packager->create($archivepath, $files)) { $msg = JText::_('FLEXI_OPERATION_FAILED'). ": compressed archive could not be created"; $app->enqueueMessage($msg, 'notice'); $this->setRedirect('index.php', ''); return; }*/ $za = new flexicontent_zip(); $res = $za->open($archivepath, ZipArchive::CREATE); if ($res !== true) { $msg = JText::_('FLEXI_OPERATION_FAILED') . ": compressed archive could not be created"; $app->enqueueMessage($msg, 'notice'); $this->setRedirect('index.php', ''); return; } $za->addDir($targetpath, ""); $za->close(); // ********************************* // Remove temporary folder structure // ********************************* if (!JFolder::delete($targetpath)) { $msg = "Temporary folder " . $targetpath . " could not be deleted"; $app->enqueueMessage($msg, 'notice'); } // Delete old files (they can not be deleted during download time ...) $tmp_path = JPath::clean($app->getCfg('tmp_path')); $matched_files = JFolder::files($tmp_path, 'fcmd_uid_.*', $recurse = false, $fullpath = true); foreach ($matched_files as $archive_file) { //echo "Seconds passed:". (time() - filemtime($tmp_folder)) ."<br>". "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($tmp_folder)) . "<br>"; if (time() - filemtime($archive_file) > 3600) { JFile::delete($archive_file); } } // Delete old tmp folder (in case that the some archiving procedures were interrupted thus their tmp folder were not deleted) $matched_folders = JFolder::folders($tmp_path, 'fcmd_uid_.*', $recurse = false, $fullpath = true); foreach ($matched_folders as $tmp_folder) { //echo "Seconds passed:". (time() - filemtime($tmp_folder)) ."<br>". "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($tmp_folder)) . "<br>"; JFolder::delete($tmp_folder); } $dlfile = new stdClass(); $dlfile->filename = 'cart_files_' . date('m-d-Y_H-i-s') . '.zip'; // a friendly name instead of $archivename $dlfile->abspath = $archivepath; } else { $dlfile = reset($valid_files); } // Get file filesize and extension $dlfile->size = filesize($dlfile->abspath); $dlfile->ext = strtolower(JFile::getExt($dlfile->filename)); // Set content type of file (that is an archive for multi-download) $ctypes = array("pdf" => "application/pdf", "exe" => "application/octet-stream", "rar" => "application/zip", "zip" => "application/zip", "txt" => "text/plain", "doc" => "application/msword", "xls" => "application/vnd.ms-excel", "ppt" => "application/vnd.ms-powerpoint", "gif" => "image/gif", "png" => "image/png", "jpeg" => "image/jpg", "jpg" => "image/jpg", "mp3" => "audio/mpeg"); $dlfile->ctype = isset($ctypes[$dlfile->ext]) ? $ctypes[$dlfile->ext] : "application/force-download"; // ***************************************** // Output an appropriate Content-Type header // ***************************************** header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); // required for certain browsers header("Content-Type: " . $dlfile->ctype); //quotes to allow spaces in filenames $download_filename = strlen($dlfile->filename_original) ? $dlfile->filename_original : $dlfile->filename; if ($method == 'view') { header("Content-Disposition: inline; filename=\"" . $download_filename . "\";"); } else { header("Content-Disposition: attachment; filename=\"" . $download_filename . "\";"); } header("Content-Transfer-Encoding: binary"); header("Content-Length: " . $dlfile->size); // ******************************* // Finally read file and output it // ******************************* if (!FLEXIUtilities::funcIsDisabled('set_time_limit')) { @set_time_limit(0); } $chunksize = 1 * (1024 * 1024); // 1MB, highest possible for fread should be 8MB if (1 || $dlfile->size > $chunksize) { $handle = @fopen($dlfile->abspath, "rb"); while (!feof($handle)) { print @fread($handle, $chunksize); ob_flush(); flush(); } fclose($handle); } else { // This is good for small files, it will read an output the file into // memory and output it, it will cause a memory exhausted error on large files ob_clean(); flush(); readfile($dlfile->abspath); } // **************************************************** // In case of multi-download clear the session variable // **************************************************** //if ($task=='download_tree') $session->set($tree_var, false,'flexicontent'); // Done ... terminate execution $app->close(); }
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; $field->label = JText::_($field->label); // Some variables $document = JFactory::getDocument(); $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW)); // 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 $default_value_use= $field->parameters->get( 'default_value_use', 0 ) ; $default_value = ($default_value_use == 2) ? $field->parameters->get( 'default_value', '' ) : ''; if ( empty($values) && !strlen($default_value) ) { $field->{$prop} = ''; return; } else if ( empty($values) && strlen($default_value) ) { $values = array($default_value); } // Prefix - Suffix - Separator parameters, replacing other field values if found $opentag = FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'opentag', '' ), 'opentag' ); $closetag = FlexicontentFields::replaceFieldValue( $field, $item, $field->parameters->get( 'closetag', '' ), 'closetag' ); // some parameter shortcuts $use_html = $field->parameters->get( 'use_html', 0 ) ; // Get ogp configuration $useogp = $field->parameters->get('useogp', 0); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); $ogpusage = $field->parameters->get('ogpusage', 0); // Apply seperator and open/close tags if ($values) { $field->{$prop} = $use_html ? $values[0] : nl2br($values[0]); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } else { $field->{$prop} = ''; } if ($useogp && $field->{$prop}) { if ( in_array($view, $ogpinview) ) { switch ($ogpusage) { case 1: $usagetype = 'title'; break; case 2: $usagetype = 'description'; break; default: $usagetype = ''; break; } if ($usagetype) { $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen); $document->addCustomTag('<meta property="og:'.$usagetype.'" content="'.$content_val.'" />'); } } } }
/** * Method to add flexi extended datas to standard content * * @params object the unassociated items rows * @params boolean add the records from the items_ext table * @return boolean * @since 1.5 */ function bindExtData($rows) { if (!$rows || !count($rows)) { return; } $default_lang = flexicontent_html::getSiteDefaultLang(); $typeid = JRequest::getVar('typeid', 1); $default_cat = (int) JRequest::getVar('default_cat', ''); // Get invalid cats, to avoid using them during binding, this is only done once $session = JFactory::getSession(); $badcats_fixed = $session->get('badcats', null, 'flexicontent'); if ($badcats_fixed === null) { // Correct non-existent main category in content table $query = 'UPDATE #__content as c ' . ' LEFT JOIN #__categories as cat ON c.catid=cat.id' . ' SET c.catid=' . $default_cat . ' WHERE cat.id IS NULL'; $this->_db->setQuery($query); $this->_db->query(); $session->set('badcats_fixed', 1, 'flexicontent'); } // Calculate item data to be used for current bind STEP $catrel = array(); foreach ($rows as $row) { $row_catid = (int) $row->catid; $catrel[] = '(' . $row_catid . ', ' . (int) $row->id . ')'; // append the text property to the object if (JString::strlen($row->fulltext) > 1) { $row->text_stripped = $row->introtext . '<hr id="system-readmore" />' . $row->fulltext; } else { $row->text_stripped = flexicontent_html::striptagsandcut($row->introtext); } } // Insert main category-item relation via single query $catrel = implode(', ', $catrel); $query = "INSERT INTO #__flexicontent_cats_item_relations (`catid`, `itemid`) " . " VALUES " . $catrel . " ON DUPLICATE KEY UPDATE ordering=ordering"; $this->_db->setQuery($query); $this->_db->query(); // Insert items_ext datas, // NOTE: we will not use a single query for creating multiple records, instead we will create only e.g. 100 at once, // because of the column search_index which can be quite long $itemext = array(); $id_arr = array(); $row_count = count($rows); $n = 0; foreach ($rows as $row) { if (FLEXI_J16GE) { $ilang = $row->language ? $row->language : $default_lang; } else { $ilang = $default_lang; } // J1.5 has no language setting $itemext[] = '(' . (int) $row->id . ', ' . $typeid . ', ' . $this->_db->Quote($ilang) . ', ' . $this->_db->Quote($row->title . ' | ' . $row->text_stripped) . ', ' . (int) $row->id . ')'; $id_arr[] = (int) $row->id; $n++; if ($n % 101 == 0 || $n == $row_count) { $itemext_list = implode(', ', $itemext); $query = "INSERT INTO #__flexicontent_items_ext (`item_id`, `type_id`, `language`, `search_index`, `lang_parent_id`)" . " VALUES " . $itemext_list . " ON DUPLICATE KEY UPDATE type_id=VALUES(type_id), language=VALUES(language), search_index=VALUES(search_index)"; $this->_db->setQuery($query); $this->_db->query(); $itemext = array(); $query = "UPDATE #__flexicontent_items_tmp" . " SET type_id=" . $typeid . " WHERE id IN(" . implode(',', $id_arr) . ")"; $this->_db->setQuery($query); $this->_db->query(); } } // Update temporary item data $this->updateItemCountingData($rows); }
" alt="<?php echo $title_encoded; ?> " /> <?php } ?> </div> <?php } ?> <p> <?php //FlexicontentFields::getFieldDisplay($item, 'text', $values=null, $method='display'); if ($this->params->get('intro_strip_html', 1)) { echo flexicontent_html::striptagsandcut($item->fields['text']->display, $intro_cut_text, $uncut_length); } else { echo $item->fields['text']->display; } ?> </p> </div> <!-- BOF under-description-line1 block --> <?php if (isset($item->positions['under-description-line1'])) { ?> <div class="lineinfo line3"> <?php foreach ($item->positions['under-description-line1'] as $field) { ?>
function sendNotificationEmails(&$notify_vars, &$params, $manual_approval_request = 0) { $needs_version_reviewal = $notify_vars->needs_version_reviewal; $needs_publication_approval = $notify_vars->needs_publication_approval; $isnew = $notify_vars->isnew; $notify_emails = $notify_vars->notify_emails; $notify_text = $notify_vars->notify_text; $before_cats = $notify_vars->before_cats; $after_cats = $notify_vars->after_cats; $oitem = $notify_vars->original_item; if (!count($notify_emails)) { return true; } $app = JFactory::getApplication(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $use_versioning = $this->_cparams->get('use_versioning', 1); // Get category titles of categories add / removed from the item if (!$isnew) { $cats_added_ids = array_diff(array_keys($after_cats), array_keys($before_cats)); foreach ($cats_added_ids as $cats_added_id) { $cats_added_titles[] = $after_cats[$cats_added_id]->title; } $cats_removed_ids = array_diff(array_keys($before_cats), array_keys($after_cats)); foreach ($cats_removed_ids as $cats_removed_id) { $cats_removed_titles[] = $before_cats[$cats_removed_id]->title; } $cats_altered = count($cats_added_ids) + count($cats_removed_ids); $after_maincat = $this->get('catid'); } // Get category titles in the case of new item or categories unchanged if ($isnew || !$cats_altered) { foreach ($after_cats as $after_cat) { $cats_titles[] = $after_cat->title; } } // ************** // CREATE SUBJECT // ************** $srvname = preg_replace('#www\\.#', '', $_SERVER['SERVER_NAME']); $url = parse_url($srvname); $domain = !empty($url["host"]) ? $url["host"] : $url["path"]; $subject = '[' . $domain . '] - '; if (!$manual_approval_request) { // (a) ADD INFO of being new or updated $subject .= JText::_($isnew ? 'FLEXI_NF_NEW_CONTENT_SUBMITTED' : 'FLEXI_NF_EXISTING_CONTENT_UPDATED') . " "; // (b) ADD INFO about editor's name and username (or being guest) $subject .= !$user->id ? JText::sprintf('FLEXI_NF_BY_GUEST') : JText::sprintf('FLEXI_NF_BY_USER', $user->get('name'), $user->get('username')); // (c) (new items) ADD INFO for content needing publication approval if ($isnew) { $subject .= ": "; $subject .= JText::_($needs_publication_approval ? 'FLEXI_NF_NEEDS_PUBLICATION_APPROVAL' : 'FLEXI_NF_NO_APPROVAL_NEEDED'); } // (d) (existing items with versioning) ADD INFO for content needing version reviewal if (!$isnew && $use_versioning) { $subject .= ": "; $subject .= JText::_($needs_version_reviewal ? 'FLEXI_NF_NEEDS_VERSION_REVIEWAL' : 'FLEXI_NF_NO_REVIEWAL_NEEDED'); } } else { $subject .= JText::_('FLEXI_APPROVAL_REQUEST'); } // ******************* // CREATE MESSAGE BODY // ******************* $nf_extra_properties = $params->get('nf_extra_properties', array('creator', 'modifier', 'created', 'modified', 'viewlink', 'editlinkfe', 'editlinkbe', 'introtext', 'fulltext')); $nf_extra_properties = FLEXIUtilities::paramToArray($nf_extra_properties); // ADD INFO for item title $body = '<u>' . JText::_('FLEXI_NF_CONTENT_TITLE') . "</u>: "; if (!$isnew) { $_changed = $oitem->title != $this->get('title'); $body .= " [ " . JText::_($_changed ? 'FLEXI_NF_MODIFIED' : 'FLEXI_NF_UNCHANGED') . " ] : <br/>\r\n"; $body .= !$_changed ? "" : $oitem->title . " ==> "; } $body .= $this->get('title') . "<br/>\r\n<br/>\r\n"; // ADD INFO about state $state_names = array(1 => 'FLEXI_PUBLISHED', -5 => 'FLEXI_IN_PROGRESS', 0 => 'FLEXI_UNPUBLISHED', -3 => 'FLEXI_PENDING', -4 => 'FLEXI_TO_WRITE', FLEXI_J16GE ? 2 : -1 => 'FLEXI_ARCHIVED', -2 => 'FLEXI_TRASHED'); $body .= '<u>' . JText::_('FLEXI_NF_CONTENT_STATE') . "</u>: "; if (!$isnew) { $_changed = $oitem->state != $this->get('state'); $body .= " [ " . JText::_($_changed ? 'FLEXI_NF_MODIFIED' : 'FLEXI_NF_UNCHANGED') . " ] : <br/>\r\n"; $body .= !$_changed ? "" : JText::_($state_names[$oitem->state]) . " ==> "; } $body .= JText::_($state_names[$this->get('state')]) . "<br/><br/>\r\n"; // ADD INFO for author / modifier if (in_array('creator', $nf_extra_properties)) { $body .= '<u>' . JText::_('FLEXI_NF_CREATOR_LONG') . "</u>: "; if (!$isnew) { $_changed = $oitem->created_by != $this->get('created_by'); $body .= " [ " . JText::_($_changed ? 'FLEXI_NF_MODIFIED' : 'FLEXI_NF_UNCHANGED') . " ] : <br/>\r\n"; $body .= !$_changed ? "" : $oitem->creator . " ==> "; } $body .= $this->get('creator') . "<br/>\r\n"; } if (in_array('modifier', $nf_extra_properties) && !$isnew) { $body .= '<u>' . JText::_('FLEXI_NF_MODIFIER_LONG') . "</u>: "; $body .= $this->get('modifier') . "<br/>\r\n"; } $body .= "<br/>\r\n"; // ADD INFO about creation / modification times. Use site's timezone !! we must // (a) set timezone to be site's timezone then // (b) call $date_OBJECT->format() with s local flag parameter set to true $tz_offset = JFactory::getApplication()->getCfg('offset'); if (FLEXI_J16GE) { $tz = new DateTimeZone($tz_offset); } $tz_offset_str = FLEXI_J16GE ? $tz->getOffset(new JDate()) / 3600 : $tz_offset; $tz_offset_str = ' (UTC+' . $tz_offset_str . ') '; if (in_array('created', $nf_extra_properties)) { $date_created = JFactory::getDate($this->get('created')); if (FLEXI_J16GE) { $date_created->setTimezone($tz); } else { $date_created->setOffset($tz_offset); } $body .= '<u>' . JText::_('FLEXI_NF_CREATION_TIME') . "</u>: "; $body .= FLEXI_J16GE ? $date_created->format($format = 'D, d M Y H:i:s', $local = true) : $date_created->toFormat($format = '%Y-%m-%d %H:%M:%S'); $body .= $tz_offset_str . "<br/>\r\n"; } if (in_array('modified', $nf_extra_properties) && !$isnew) { $date_modified = JFactory::getDate($this->get('modified')); if (FLEXI_J16GE) { $date_modified->setTimezone($tz); } else { $date_modified->setOffset($tz_offset); } $body .= '<u>' . JText::_('FLEXI_NF_MODIFICATION_TIME') . "</u>: "; $body .= FLEXI_J16GE ? $date_modified->format($format = 'D, d M Y H:i:s', $local = true) : $date_modified->toFormat($format = '%Y-%m-%d %H:%M:%S'); $body .= $tz_offset_str . "<br/>\r\n"; } $body .= "<br/>\r\n"; // ADD INFO about category assignments $body .= '<u>' . JText::_('FLEXI_NF_CATEGORIES_ASSIGNMENTS') . '</u>'; if (!$isnew) { $body .= " [ " . JText::_($cats_altered ? 'FLEXI_NF_MODIFIED' : 'FLEXI_NF_UNCHANGED') . " ] : <br/>\r\n"; } else { $body .= " : <br/>\r\n"; } foreach ($cats_titles as $i => $cats_title) { $body .= " " . ($i + 1) . ". " . $cats_title . "<br/>\r\n"; } // ADD INFO for category assignments added or removed if (!empty($cats_added_titles) && count($cats_added_titles)) { $body .= '<u>' . JText::_('FLEXI_NF_ITEM_CATEGORIES_ADDED') . "</u> : <br/>\r\n"; foreach ($cats_added_titles as $i => $cats_title) { $body .= " " . ($i + 1) . ". " . $cats_title . "<br/>\r\n"; } } if (!empty($cats_removed_titles) && count($cats_removed_titles)) { $body .= '<u>' . JText::_('FLEXI_NF_ITEM_CATEGORIES_REMOVED') . "</u> : <br/>\r\n"; foreach ($cats_removed_titles as $i => $cats_title) { $body .= " " . ($i + 1) . ". " . $cats_title . "<br/>\r\n"; } } $body .= "<br/>\r\n<br/>\r\n"; $lang = '&lang=' . substr($this->get('language'), 0, 2); // ADD INFO for custom notify text $subject .= ' ' . JText::_($notify_text); // ADD INFO for view/edit link if (in_array('viewlink', $nf_extra_properties)) { $body .= '<u>' . JText::_('FLEXI_NF_VIEW_IN_FRONTEND') . "</u> : <br/>\r\n "; $link = JRoute::_(JURI::root(false) . FlexicontentHelperRoute::getItemRoute($this->get('id'), $this->get('catid')) . $lang); $body .= '<a href="' . $link . '" target="_blank">' . $link . "</a><br/>\r\n<br/>\r\n"; // THIS IS BOGUS *** for unicode menu aliases //$body .= $link . "<br/>\r\n<br/>\r\n"; } if (in_array('editlinkfe', $nf_extra_properties)) { $body .= '<u>' . JText::_('FLEXI_NF_EDIT_IN_FRONTEND') . "</u> : <br/>\r\n "; $link = JRoute::_(JURI::root(false) . 'index.php?option=com_flexicontent&view=' . FLEXI_ITEMVIEW . '&cid=' . $this->get('catid') . '&id=' . $this->get('id') . '&task=edit'); $body .= '<a href="' . $link . '" target="_blank">' . $link . "</a><br/>\r\n<br/>\r\n"; // THIS IS BOGUS *** for unicode menu aliases //$body .= $link . "<br/>\r\n<br/>\r\n"; } if (in_array('editlinkbe', $nf_extra_properties)) { $body .= '<u>' . JText::_('FLEXI_NF_EDIT_IN_BACKEND') . "</u> : <br/>\r\n "; $fc_ctrl_task = FLEXI_J16GE ? 'task=items.edit' : 'controller=items&task=edit'; $link = JRoute::_(JURI::root(false) . 'administrator/index.php?option=com_flexicontent&' . $fc_ctrl_task . '&cid=' . $this->get('id')); $body .= '<a href="' . $link . '" target="_blank">' . $link . "</a><br/>\r\n<br/>\r\n"; // THIS IS BOGUS *** for unicode menu aliases //$body .= $link . "<br/>\r\n<br/>\r\n"; } // ADD INFO for introtext/fulltext if ($params->get('nf_add_introtext')) { //echo "<pre>"; print_r($this->_item); exit; $body .= "<br/><br/>\r\n"; $body .= "*************************************************************** <br/>\r\n"; $body .= JText::_('FLEXI_NF_INTROTEXT_LONG') . "<br/>\r\n"; $body .= "*************************************************************** <br/>\r\n"; $body .= flexicontent_html::striptagsandcut($this->get('introtext'), 200); } if ($params->get('nf_add_fulltext')) { $body .= "<br/><br/>\r\n"; $body .= "*************************************************************** <br/>\r\n"; $body .= JText::_('FLEXI_NF_FULLTEXT_LONG') . "<br/>\r\n"; $body .= "*************************************************************** <br/>\r\n"; $body .= flexicontent_html::striptagsandcut($this->get('fulltext'), 200); } // ********** // Send email // ********** $from = $app->getCfg('mailfrom'); $fromname = $app->getCfg('fromname'); $recipient = $params->get('nf_send_as_bcc', 0) ? array($from) : $notify_emails; $html_mode = true; $cc = null; $bcc = $params->get('nf_send_as_bcc', 0) ? $notify_emails : null; $attachment = null; $replyto = null; $replytoname = null; if (!FLEXI_J16GE) { jimport('joomla.utilities.utility'); } $send_result = FLEXI_J16GE ? JFactory::getMailer()->sendMail($from, $fromname, $recipient, $subject, $body, $html_mode, $cc, $bcc, $attachment, $replyto, $replytoname) : JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $html_mode, $cc, $bcc, $attachment, $replyto, $replytoname); $debug_str = "" . "<br/>FROM: {$from}" . "<br/>FROMNAME: {$fromname} <br/>" . "<br/>RECIPIENTS: " . implode(",", $recipient) . "<br/>BCC: " . ($bcc ? implode(",", $bcc) : '') . "<br/>" . "<br/>SUBJECT: {$subject} <br/>" . "<br/><br/>**********<br/>BODY<br/>**********<br/> {$body} <br/>"; if ($send_result) { // OK if ($params->get('nf_enable_debug', 0)) { $app->enqueueMessage("Sending WORKFLOW notification emails SUCCESS", 'message'); $app->enqueueMessage($debug_str, 'message'); } } else { // NOT OK if ($params->get('nf_enable_debug', 0)) { $app->enqueueMessage("Sending WORKFLOW notification emails FAILED", 'warning'); $app->enqueueMessage($debug_str, 'message'); } } return $send_result; }
public static function getCategoryData(&$params) { if (!$params->get('apply_config_per_category', 0)) { return false; } $app = JFactory::getApplication(); $db = JFactory::getDBO(); $view = JRequest::getVar('view'); $option = JRequest::getVar('option'); $currcat_custom_display = $params->get('currcat_custom_display', 0); $currcat_source = $params->get('currcat_source', 0); // 0 item view, 1 category view, 2 both $isflexi_itemview = $option == 'com_flexicontent' && $view == FLEXI_ITEMVIEW; $isflexi_catview = $option == 'com_flexicontent' && $view == 'category'; $currcat_valid_case = $currcat_source == 2 && ($isflexi_itemview || $isflexi_catview) || $currcat_source == 0 && $isflexi_itemview || $currcat_source == 1 && $isflexi_catview; if ($currcat_custom_display && $currcat_valid_case) { $id = JRequest::getInt('id', 0); // id of current item $cid = JRequest::getInt('cid', 0); // current category id of current item $catconf = new stdClass(); $catconf->orderby = ''; $catconf->fallback_maincat = $params->get('currcat_fallback_maincat', 0); $catconf->showtitle = $params->get('currcat_showtitle', 0); $catconf->showdescr = $params->get('currcat_showdescr', 0); $catconf->cuttitle = (int) $params->get('currcat_cuttitle', 40); $catconf->cutdescr = (int) $params->get('currcat_cutdescr', 200); $catconf->link_title = $params->get('currcat_link_title'); $catconf->show_image = $params->get('currcat_show_image'); $catconf->image_source = $params->get('currcat_image_source'); $catconf->link_image = $params->get('currcat_link_image'); $catconf->image_width = (int) $params->get('currcat_image_width', 80); $catconf->image_height = (int) $params->get('currcat_image_height', 80); $catconf->image_method = (int) $params->get('currcat_image_method', 1); $catconf->show_default_image = (int) $params->get('currcat_show_default_image', 0); // parameter not added yet $catconf->readmore = (int) $params->get('currcat_currcat_readmore', 1); if ($catconf->fallback_maincat && !$cid && $id) { $query = 'SELECT catid FROM #__content WHERE id = ' . $id; $db->setQuery($query); $cid = $db->loadResult(); } if ($cid) { $cids = array($cid); } } if (empty($cids)) { $catconf = new stdClass(); // Check if using a dynamic set of categories, that was decided by getItems() $dynamic_cids = $params->get('dynamic_catids', false); $static_cids = $params->get('catids', array()); $cids = $dynamic_cids ? unserialize($dynamic_cids) : $static_cids; $cids = !is_array($cids) ? array($cids) : $cids; $catconf->orderby = $params->get('cats_orderby', 'alpha'); $catconf->showtitle = $params->get('cats_showtitle', 0); $catconf->showdescr = $params->get('cats_showdescr', 0); $catconf->cuttitle = (int) $params->get('cats_cuttitle', 40); $catconf->cutdescr = (int) $params->get('cats_cutdescr', 200); $catconf->link_title = $params->get('cats_link_title'); $catconf->show_image = $params->get('cats_show_image'); $catconf->image_source = $params->get('cats_image_source'); $catconf->link_image = $params->get('cats_link_image'); $catconf->image_width = (int) $params->get('cats_image_width', 80); $catconf->image_height = (int) $params->get('cats_image_height', 80); $catconf->image_method = (int) $params->get('cats_image_method', 1); $catconf->show_default_image = (int) $params->get('cats_show_default_image', 0); // parameter not added yet $catconf->readmore = (int) $params->get('cats_readmore', 1); } if (empty($cids) || !count($cids)) { return false; } // initialize variables $orderby = ''; if ($catconf->orderby) { $orderby = flexicontent_db::buildCatOrderBy($params, $catconf->orderby, $request_var = '', $config_param = '', $cat_tbl_alias = 'c', $user_tbl_alias = 'u', $default_order = '', $default_order_dir = ''); } $query = 'SELECT c.id, c.title, c.description, c.params ' . (FLEXI_J16GE ? '' : ', c.image ') . ', CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as categoryslug' . ' FROM #__categories AS c' . (FLEXI_J16GE ? ' LEFT JOIN #__users AS u ON u.id = c.created_user_id' : '') . ' WHERE c.id IN (' . implode(',', $cids) . ')' . $orderby; $db->setQuery($query); $catdata_arr = $db->loadObjectList('id'); if ($db->getErrorNum()) { JFactory::getApplication()->enqueueMessage(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()), 'error'); } if (!$catdata_arr) { return false; } $joomla_image_path = $app->getCfg('image_path', FLEXI_J16GE ? '' : 'images' . DS . 'stories'); foreach ($catdata_arr as $i => $catdata) { $catdata->params = new JRegistry($catdata->params); // Category Title $catdata->title = flexicontent_html::striptagsandcut($catdata->title, $catconf->cuttitle); $catdata->showtitle = $catconf->showtitle; // Category image $catdata->image = FLEXI_J16GE ? $catdata->params->get('image') : $catdata->image; $catimage = ""; if ($catconf->show_image) { $catdata->introtext =& $catdata->description; $catdata->fulltext = ""; if ($catconf->image_source && $catdata->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . DS . $catdata->image)) { $src = JURI::base(true) . "/" . $joomla_image_path . "/" . $catdata->image; $h = '&h=' . $catconf->image_height; $w = '&w=' . $catconf->image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $catconf->image_method ? '&zc=' . $catconf->image_method : ''; $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION)); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $catimage = JURI::base() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf; } else { if ($catconf->image_source != 1 && ($src = flexicontent_html::extractimagesrc($catdata))) { $h = '&h=' . $catconf->image_height; $w = '&w=' . $catconf->image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $catconf->image_method ? '&zc=' . $catconf->image_method : ''; $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION)); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : ''; $catimage = JURI::base() . 'components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $base_url . $src . $conf; } } $catdata->image = $catimage; } // Category Description if (!$catconf->showdescr) { unset($catdata->description); } else { $catdata->description = flexicontent_html::striptagsandcut($catdata->description, $catconf->cutdescr); } // Category Links (title and image links) if ($catconf->link_title || $catconf->link_image || $catconf->readmore) { $catlink = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($catdata->categoryslug)); $catdata->titlelink = $catlink; $catdata->imagelink = $catlink; } $catdata->conf = $catconf; } return $catdata_arr; }
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { if (!in_array($field->field_type, self::$field_types)) { return; } $view = JRequest::getString('view', FLEXI_ITEMVIEW); //if ($view != FLEXI_ITEMVIEW) return; if (JRequest::getCmd('print')) { return; } global $mainframe, $addthis; //$scheme = JURI::getInstance()->getScheme(); // we replaced http(s):// with // $document = JFactory::getDocument(); $lang = $document->getLanguage(); $lang = $item->params->get('language', $lang); $lang = $lang ? $lang : 'en-GB'; $lang = substr($lang, 0, 2); $lang = in_array($lang, array('en', 'es', 'it', 'th')) ? $lang : 'en'; // parameters shortcuts $display_comments = $field->parameters->get('display_comments', 1) && $item->parameters->get('comments', 0); $display_resizer = $field->parameters->get('display_resizer', 1); $display_print = $field->parameters->get('display_print', 1); $display_email = $field->parameters->get('display_email', 1); $display_voice = $field->parameters->get('display_voice', 1); $display_pdf = 0; //$field->parameters->get('display_pdf', 1); $load_css = $field->parameters->get('load_css', 1); $display_social = $field->parameters->get('display_social', 1); $addthis_user = $field->parameters->get('addthis_user', ''); $addthis_pubid = $field->parameters->get('addthis_pubid', $addthis_user); $spacer_size = $field->parameters->get('spacer_size', 21); $module_position = $field->parameters->get('module_position', ''); $default_size = $field->parameters->get('default_size', 12); $default_line = $field->parameters->get('default_line', 16); $target = $field->parameters->get('target', 'flexicontent'); $voicetarget = $field->parameters->get('voicetarget', 'flexicontent'); $spacer = ' style="width:' . $spacer_size . 'px;"'; // define a global variable to be sure the script is loaded only once $addthis = isset($addthis) ? $addthis : 0; if ($load_css) { $document->addStyleSheet(JURI::root(true) . '/plugins/flexicontent_fields/toolbar/toolbar/toolbar.css'); } if ($display_social || $display_comments || $display_email || $display_print) { $item_url = FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug); $server = JURI::getInstance()->toString(array('scheme', 'host', 'port')); $item_link = $server . JRoute::_($item_url); // NOTE: this uses current SSL setting (e.g menu item), and not URL scheme: http/https //$item_link = JRoute::_($item_url, true, -1); } $display = '<div class="flexitoolbar">'; // begin of the toolbar container // comments button if ($display_comments) { $comment_link = $item_link . '#addcomments'; $display .= ' <div class="flexi-react toolbar-element"> <span class="comments-bubble">' . ($module_position ? '<!-- jot ' . $module_position . ' s -->' : '') . $this->_getCommentsCount($item->id) . ($module_position ? '<!-- jot ' . $module_position . ' e -->' : '') . '</span> <span class="comments-legend flexi-legend"><a href="' . $comment_link . '" title="' . JText::_('FLEXI_FIELD_TOOLBAR_COMMENT') . '">' . JText::_('FLEXI_FIELD_TOOLBAR_COMMENT') . '</a></span> </div> <div class="toolbar-spacer"' . $spacer . '></div> '; } // text resizer if ($display_resizer) { $document->addScriptDeclaration('var textsize = ' . $default_size . '; var lineheight = ' . $default_line . '; function fsize(size,line,unit,id){ var vfontsize = document.getElementById(id); if(vfontsize){ vfontsize.style.fontSize = size + unit; vfontsize.style.lineHeight = line + unit; } } function changetextsize(up){ if(up){ textsize = parseFloat(textsize)+2; lineheight = parseFloat(lineheight)+2; }else{ textsize = parseFloat(textsize)-2; lineheight = parseFloat(lineheight)-2; } }'); $display .= ' <div class="flexi-resizer toolbar-element"> <a class="decrease" href="javascript:fsize(textsize,lineheight,\'px\',\'' . $target . '\');" onclick="changetextsize(0);">' . JText::_("FLEXI_FIELD_TOOLBAR_DECREASE") . '</a> <a class="increase" href="javascript:fsize(textsize,lineheight,\'px\',\'' . $target . '\');" onclick="changetextsize(1);">' . JText::_("FLEXI_FIELD_TOOLBAR_INCREASE") . '</a> <span class="flexi-legend">' . JText::_("FLEXI_FIELD_TOOLBAR_SIZE") . '</span> </div> <div class="toolbar-spacer"' . $spacer . '></div> '; } // email button if ($display_email) { require_once JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php'; $url = 'index.php?option=com_mailto&tmpl=component&link=' . MailToHelper::addLink($item_link); $estatus = 'width=400,height=400,menubar=yes,resizable=yes'; $display .= ' <div class="flexi-email toolbar-element"> <span class="email-legend flexi-legend"><a rel="nofollow" href="' . JRoute::_($url) . '" onclick="window.open(this.href,\'win2\',\'' . $estatus . '\'); return false;" title="' . JText::_('FLEXI_FIELD_TOOLBAR_SEND') . '">' . JText::_('FLEXI_FIELD_TOOLBAR_SEND') . '</a></span> </div> <div class="toolbar-spacer"' . $spacer . '></div> '; } // print button if ($display_print) { $pop = JRequest::getInt('pop'); $pstatus = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no'; $print_link = $pop ? '#' : $item_link . (strstr($item_link, '?') ? '&' : '?') . 'pop=1&print=1&tmpl=component'; $js_link = $pop ? 'onclick="window.print();return false;"' : 'onclick="window.open(this.href,\'win2\',\'' . $pstatus . '\'); return false;"'; $display .= ' <div class="flexi-print toolbar-element"> <span class="print-legend flexi-legend"><a rel="nofollow" href="' . $print_link . '" ' . $js_link . ' title="' . JText::_('FLEXI_FIELD_TOOLBAR_PRINT') . '">' . JText::_('FLEXI_FIELD_TOOLBAR_PRINT') . '</a></span> </div> <div class="toolbar-spacer"' . $spacer . '></div> '; } // pdf button if ($display_voice) { $display .= "\n\t\t\t<div class=\"flexi-voice toolbar-element\">"; if ($lang == 'th') { // Special case language case, maybe la=laos, and Bhutan languages in the future (NECTEC support these languages) $document->addScript(JURI::root(true) . '/plugins/flexicontent_fields/toolbar/toolbar/th.js'); $display .= "\n\t\t\t\t\t<span class=\"voice-legend flexi-legend\"><a href=\"javascript:void(0);\" onclick=\"openwindow('" . $voicetarget . "','" . $lang . "');\" class=\"mainlevel-toolbar-article-horizontal\" rel=\"nofollow\">" . JTEXT::_('FLEXI_FIELD_TOOLBAR_VOICE') . "</a></span>\n\t\t\t\t\t"; } else { $document->addScript('//vozme.com/get_text.js'); $display .= "\n\t\t\t\t\t<span class=\"voice-legend flexi-legend\"><a href=\"javascript:void(0);\" onclick=\"get_id('" . $voicetarget . "','" . $lang . "','fm');\" class=\"mainlevel-toolbar-article-horizontal\" rel=\"nofollow\">" . JTEXT::_('FLEXI_FIELD_TOOLBAR_VOICE') . "</a></span>\n\t\t\t\t\t"; } $display .= "\n\t\t\t</div>\n\t\t\t<div class=\"toolbar-spacer\"" . $spacer . "></div>\n\t\t\t\t"; } // pdf button if ($display_pdf) { $pdflink = 'index.php?view=items&cid=' . $item->categoryslug . '&id=' . $item->slug . '&format=pdf'; $display .= ' <div class="flexi-pdf toolbar-element"> <span class="pdf-legend flexi-legend"><a href="' . JRoute::_($pdflink) . '" title="' . JText::_('FLEXI_FIELD_TOOLBAR_PDF') . '">' . JText::_('FLEXI_FIELD_TOOLBAR_PDF') . '</a></span> </div> <div class="toolbar-spacer"' . $spacer . '></div> '; } // AddThis social SHARE buttons, also optionally add OPEN GRAPH TAGs if ($display_social) { // *************** // OPEN GRAPH TAGs // *************** // OPEN GRAPH: site name if ($field->parameters->get('add_og_site_name')) { $document->addCustomTag("<meta property=\"og:site_name\" content=\"" . JFactory::getApplication()->getCfg('sitename') . "\" />"); } // OPEN GRAPH: title if ($field->parameters->get('add_og_title')) { $title = flexicontent_html::striptagsandcut($item->title); $document->addCustomTag("<meta property=\"og:title\" content=\"{$title}\" />"); } // OPEN GRAPH: description if ($field->parameters->get('add_og_descr')) { if ($item->metadesc) { $document->addCustomTag('<meta property="og:description" content="' . $item->metadesc . '" />'); } else { $text = flexicontent_html::striptagsandcut($item->text); $document->addCustomTag("<meta property=\"og:description\" content=\"{$text}\" />"); } } // OPEN GRAPH: type $og_type = (int) $field->parameters->get('add_og_type'); if ($og_type) { if ($og_type > 2) { $og_type = 1; } $og_type_names = array(1 => 'article', 2 => 'website'); $document->addCustomTag("<meta property=\"og:type\" content=\"" . $og_type_names[$og_type] . "\">"); } // OPEN GRAPH: image (extracted from item's description text) if ($field->parameters->get('add_og_image')) { $og_image_field = $field->parameters->get('og_image_field'); $og_image_fallback = $field->parameters->get('og_image_fallback'); $og_image_thumbsize = $field->parameters->get('og_image_thumbsize'); if ($og_image_field) { $imageurl = FlexicontentFields::getFieldDisplay($item, $og_image_field, null, 'display_' . $og_image_thumbsize . '_src', 'module'); if ($imageurl) { $img_field = $item->fields[$og_image_field]; if (!$imageurl && $og_image_fallback == 1 || $imageurl && $og_image_fallback == 2 && $img_field->using_default_value) { $imageurl = $this->_extractimageurl($item); } } } else { $imageurl = $this->_extractimageurl($item); } // Add image if fould, making sure it is converted to ABSOLUTE URL if ($imageurl) { $is_absolute = (bool) parse_url($imageurl, PHP_URL_SCHEME); // preg_match("#^http|^https|^ftp#i", $imageurl); $imageurl = $is_absolute ? $imageurl : JURI::root() . $imageurl; $document->addCustomTag("<meta property=\"og:image\" content=\"{$imageurl}\" />"); } } // Add og-URL explicitely as this is required by facebook ? if ($item_link) { $document->addCustomTag("<meta property=\"og:url\" content=\"" . $item_link . "\" />"); } // **************************** // AddThis social SHARE buttons // **************************** $addthis_outside_toolbar = $field->parameters->get('addthis_outside_toolbar', 0); $addthis_custom_code = $field->parameters->get('addthis_custom_code', false); $addthis_custom_predefined = $field->parameters->get('addthis_custom_predefined', false); $addthis_code = ''; if ($addthis_custom_code) { $addthis_code = str_replace('_item_url_', $item_link, $addthis_custom_code); $addthis_code = str_replace('_item_title_', htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8'), $addthis_code); } else { switch ($addthis_custom_predefined) { case 1: $addthis_code .= ' <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_default_style addthis_counter_style" addthis:url="' . $item_link . '" addthis:title="' . htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '"> <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> <a class="addthis_button_tweet"></a> <a class="addthis_button_pinterest_pinit"></a> <a class="addthis_counter addthis_pill_style"></a> </div> <!-- AddThis Button END --> '; break; case 2: $addthis_code .= ' <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url="' . $item_link . '" addthis:title="' . htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '"> <a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a> <a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a> <a class="addthis_button_compact"></a> <a class="addthis_counter addthis_bubble_style"></a> </div> <!-- AddThis Button END --> '; break; default: case 3: $addthis_code .= ' <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_default_style addthis_16x16_style" addthis:url="' . $item_link . '" addthis:title="' . htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '"> <a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a> <a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a> <a class="addthis_button_compact"></a> <a class="addthis_counter addthis_bubble_style"></a> </div> <!-- AddThis Button END --> '; break; case 4: $addthis_code .= ' <!-- AddThis Button BEGIN --> <a class="addthis_button" href="//www.addthis.com/bookmark.php?v=300&pubid=' . $addthis_pubid . '"><img src="//s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="' . JText::_('FLEXI_FIELD_TOOLBAR_SHARE') . '" style="border:0"/></a> <!-- AddThis Button END --> '; break; case 5: $addthis_code .= ' <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_floating_style addthis_counter_style" style="left:50px;top:50px;" addthis:url="' . $item_link . '" addthis:title="' . htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '"> <a class="addthis_button_facebook_like" fb:like:layout="box_count"></a> <a class="addthis_button_tweet" tw:count="vertical"></a> <a class="addthis_button_google_plusone" g:plusone:size="tall"></a> <a class="addthis_counter"></a> </div> <!-- AddThis Button END --> '; break; case 6: $addthis_code .= ' <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_floating_style addthis_32x32_style" style="left:50px;top:50px;" addthis:url="' . $item_link . '" addthis:title="' . htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '"> <a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a> <a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a> <a class="addthis_button_compact"></a> </div> <!-- AddThis Button END --> '; break; case 7: $addthis_code .= ' <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_floating_style addthis_16x16_style" style="left:50px;top:50px;" addthis:url="' . $item_link . '" addthis:title="' . htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '"> <a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a> <a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a> <a class="addthis_button_compact"></a> </div> <!-- AddThis Button END --> '; break; } } if ($addthis_outside_toolbar) { $display .= '<div class="flexi-socials-outside">' . $addthis_code . '</div>'; } else { $display .= '<div class="flexi-socials toolbar-element">' . $addthis_code . '</div>'; } if (!$addthis) { $document->addCustomTag(' <script type="text/javascript"> var addthis_config = { services_exclude: "print,email" } </script> <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js' . ($addthis_pubid ? '#pubid=' . $addthis_pubid : '') . '"></script> '); $addthis = 1; } } $display .= '</div>'; // end of the toolbar container $field->{$prop} = $display; }
static function dataFilter($v, $maxlength = 0, $validation = 'string', $check_callable = 0) { if ($validation == '-1') { return flexicontent_html::striptagsandcut($v, $maxlength); } $v = $maxlength ? substr($v, 0, $maxlength) : $v; if ($check_callable) { if (strpos($validation, '::') !== false && is_callable(explode('::', $validation))) { return call_user_func(explode('::', $validation), $v); } elseif (function_exists($validation)) { return call_user_func($validation, $v); } // A callback function } // Do filtering if ($validation == '1') { $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); } else { if ($validation != '2') { $noHtmlFilter = JFilterInput::getInstance(); } } switch ($validation) { case '1': // Allow safe HTML $v = $safeHtmlFilter->clean($v, 'string'); break; case '2': // Filter according to user group Text Filters $v = JComponentHelper::filterText($v); break; case 'URL': case 'url': // This cleans some of the more dangerous characters but leaves special characters that are valid. $v = trim($noHtmlFilter->clean($v, 'HTML')); // <>" are never valid in a uri see http://www.ietf.org/rfc/rfc1738.txt. $v = str_replace(array('<', '>', '"'), '', $v); // Convert to Punycode string $v = FLEXI_J30GE ? JStringPunycode::urlToPunycode($v) : $v; break; case 'EMAIL': case 'email': // This cleans some of the more dangerous characters but leaves special characters that are valid. $v = trim($noHtmlFilter->clean($v, 'HTML')); // <>" are never valid in a email ? $v = str_replace(array('<', '>', '"'), '', $v); // Convert to Punycode string $v = FLEXI_J30GE ? JStringPunycode::emailToPunycode($v) : $v; // Check for valid email (punycode is ASCII so this should work with UTF-8 too) $email_regexp = "/^[a-zA-Z0-9.!#\$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\$/"; if (!preg_match($email_regexp, $v)) { $v = ''; } break; default: // Filter using JFilterInput $v = $noHtmlFilter->clean($v, $validation); break; } $v = trim($v); return $v; }
" alt="<?php echo flexicontent_html::striptagsandcut($item->fulltitle, 60); ?> " /> </a> <?php } else { ?> <img style="<?php echo $img_force_dims; ?> " src="<?php echo $item->image; ?> " alt="<?php echo flexicontent_html::striptagsandcut($item->fulltitle, 60); ?> " /> <?php } ?> </div> <?php } ?> <?php $captured_image = ob_get_clean(); $hasImage = (bool) trim($captured_image); ?> <!-- BOF current item's image -->
function onDisplayCoreFieldValue(&$_field, &$_item, &$params, $_tags = null, $_categories = null, $_favourites = null, $_favoured = null, $_vote = null, $values = null, $prop = 'display') { // this function is a mess and need complete refactoring // execute the code only if the field type match the plugin type $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW)); static $cat_links = array(); static $tag_links = array(); if (!is_array($_item)) { $items = array(&$_item); } else { $items =& $_item; } // Prefix - Suffix - Separator parameters // these parameters should be common so we will retrieve them from the first item instead of inside the loop $item = reset($items); if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } $remove_space = $field->parameters->get('remove_space', 0); $_pretext = $field->parameters->get('pretext', ''); $_posttext = $field->parameters->get('posttext', ''); $separatorf = $field->parameters->get('separatorf', 3); $_opentag = $field->parameters->get('opentag', ''); $_closetag = $field->parameters->get('closetag', ''); $pretext_cacheable = $posttext_cacheable = $opentag_cacheable = $closetag_cacheable = false; foreach ($items as $item) { //if (!is_object($_field)) echo $item->id." - ".$_field ."<br/>"; if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } if ($field->iscore != 1) { continue; } $field->item_id = $item->id; // Replace item properties or values of other fields if (!$pretext_cacheable) { $pretext = FlexicontentFields::replaceFieldValue($field, $item, $_pretext, 'pretext', $pretext_cacheable); if ($pretext && !$remove_space) { $pretext = $pretext . ' '; } } if (!$posttext_cacheable) { $posttext = FlexicontentFields::replaceFieldValue($field, $item, $_posttext, 'posttext', $posttext_cacheable); if ($posttext && !$remove_space) { $posttext = ' ' . $posttext; } } if (!$opentag_cacheable) { $opentag = FlexicontentFields::replaceFieldValue($field, $item, $_opentag, 'opentag', $opentag_cacheable); } // used by some fields if (!$closetag_cacheable) { $closetag = FlexicontentFields::replaceFieldValue($field, $item, $_closetag, 'closetag', $closetag_cacheable); } // used by some fields switch ($separatorf) { case 0: $separatorf = ' '; break; case 1: $separatorf = '<br />'; break; case 2: $separatorf = ' | '; break; case 3: $separatorf = ', '; break; case 4: $separatorf = $closetag . $opentag; break; case 5: $separatorf = ''; break; default: $separatorf = ' '; break; } $field->value = array(); switch ($field->field_type) { case 'created': // created $field->value[] = $item->created; $dateformat = $field->parameters->get('date_format', ''); $customdate = $field->parameters->get('custom_date', ''); $dateformat = $dateformat ? $dateformat : $customdate; $field->display = $pretext . JHTML::_('date', $item->created, JText::_($dateformat)) . $posttext; break; case 'createdby': // created by $field->value[] = $item->created_by; $field->display = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->cuname : $item->creator) . $posttext; break; case 'modified': // modified $field->value[] = $item->modified; $dateformat = $field->parameters->get('date_format', ''); $customdate = $field->parameters->get('custom_date', ''); $dateformat = $dateformat ? $dateformat : $customdate; $field->display = $pretext . JHTML::_('date', $item->modified, JText::_($dateformat)) . $posttext; break; case 'modifiedby': // modified by $field->value[] = $item->modified_by; $field->display = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->muname : $item->modifier) . $posttext; break; case 'title': // title $field->value[] = $item->title; $field->display = $pretext . $item->title . $posttext; // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { $content_val = flexicontent_html::striptagsandcut($field->display, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:title" content="' . $content_val . '" />'); } } break; case 'hits': // hits $field->value[] = $item->hits; $field->display = $pretext . $item->hits . $posttext; break; case 'type': // document type $field->value[] = $item->type_id; $field->display = $pretext . JText::_($item->typename) . $posttext; break; case 'version': // version $field->value[] = $item->version; $field->display = $pretext . $item->version . $posttext; break; case 'state': // state $field->value[] = $item->state; $field->display = $pretext . flexicontent_html::stateicon($item->state, $field->parameters) . $posttext; break; case 'voting': // voting button if ($_vote === false) { $vote =& $item->vote; } else { $vote =& $_vote; } $field->value[] = 'button'; // dummy value to force display $field->display = $pretext . flexicontent_html::ItemVote($field, 'all', $vote) . $posttext; break; case 'favourites': // favourites button if ($_favourites === false) { $favourites =& $item->favs; } else { $favourites =& $_favourites; } if ($_favoured === false) { $favoured =& $item->fav; } else { $favoured =& $_favoured; } $field->value[] = 'button'; // dummy value to force display $favs = flexicontent_html::favoured_userlist($field, $item, $favourites); $field->display = $pretext . ' <span class="fav-block"> ' . flexicontent_html::favicon($field, $favoured, $item) . ' <span id="fcfav-reponse_' . $field->item_id . '" class="fcfav-reponse"> <small>' . $favs . '</small> </span> </span> ' . $posttext; break; case 'categories': // assigned categories $field->display = ''; if ($_categories === false) { $categories =& $item->cats; } else { $categories =& $_categories; } if ($categories) { // Get categories that should be excluded from linking global $globalnoroute; if (!is_array($globalnoroute)) { $globalnoroute = array(); } // Create list of category links, excluding the "noroute" categories $field->display = array(); foreach ($categories as $category) { $cat_id = $category->id; if (in_array($cat_id, @$globalnoroute)) { continue; } if (!isset($cat_links[$cat_id])) { $cat_links[$cat_id] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug)); } $cat_link = $cat_links[$cat_id]; $display = '<a class="fc_categories fc_category_' . $cat_id . ' link_' . $field->name . '" href="' . $cat_link . '">' . $category->title . '</a>'; $field->display[] = $pretext . $display . $posttext; $field->value[] = $category->title; } $field->display = implode($separatorf, $field->display); $field->display = $opentag . $field->display . $closetag; } break; case 'tags': // assigned tags $field->display = ''; if ($_tags === false) { $tags =& $item->tags; } else { $tags =& $_tags; } if ($tags) { // Create list of tag links $field->display = array(); foreach ($tags as $tag) { $tag_id = $tag->id; if (!isset($tag_links[$tag_id])) { $tag_links[$tag_id] = JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug)); } $tag_link = $tag_links[$tag_id]; $display = '<a class="fc_tags fc_tag_' . $tag->id . ' link_' . $field->name . '" href="' . $tag_link . '">' . $tag->name . '</a>'; $field->display[] = $pretext . $display . $posttext; $field->value[] = $tag->name; } $field->display = implode($separatorf, $field->display); $field->display = $opentag . $field->display . $closetag; } break; case 'maintext': // main text // Special display variables if ($prop != 'display') { switch ($prop) { case 'display_if': $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; break; case 'display_i': $field->{$prop} = $item->introtext; break; case 'display_f': $field->{$prop} = $item->fulltext; break; } } else { if (!$item->fulltext) { $field->display = $item->introtext; } else { if ($view != FLEXI_ITEMVIEW) { if ($item->parameters->get('force_full', 0)) { $field->display = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->display = $item->introtext; } } else { if ($item->parameters->get('show_intro', 1)) { $field->display = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->display = $item->fulltext; } } } } // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { if ($item->metadesc) { JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $item->metadesc . '" />'); } else { $content_val = flexicontent_html::striptagsandcut($field->display, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $content_val . '" />'); } } } break; } } }
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); $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW)); // Value handling parameters $lang_filter_values = $field->parameters->get('lang_filter_values', 0); $clean_output = $field->parameters->get('clean_output', 0); $encode_output = $field->parameters->get('encode_output', 0); $format_output = $field->parameters->get('format_output', 0); if ($format_output > 0) { // 1: decimal, 2: integer $decimal_digits_displayed = $format_output == 2 ? 0 : (int) $field->parameters->get('decimal_digits_displayed', 2); $decimal_digits_sep = $field->parameters->get('decimal_digits_sep', '.'); $decimal_thousands_sep = $field->parameters->get('decimal_thousands_sep', ','); $output_prefix = JText::_($field->parameters->get('output_prefix', '')); $output_suffix = JText::_($field->parameters->get('output_suffix', '')); } else { if ($format_output == -1) { $output_custom_func = $field->parameters->get('output_custom_func', ''); } } // Default value $value_usage = $field->parameters->get('default_value_use', 0); $default_value = $value_usage == 2 ? $field->parameters->get('default_value', '') : ''; $default_value = $default_value ? JText::_($default_value) : ''; // 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_value)) { $field->{$prop} = $is_ingroup ? array() : ''; return; } $values = array($default_value); } // ****************************************** // Language filter, clean output, encode HTML // ****************************************** if ($clean_output) { $ifilter = $clean_output == 1 ? JFilterInput::getInstance(null, null, 1, 1) : JFilterInput::getInstance(); } if ($lang_filter_values || $clean_output || $encode_output || $format_output) { // (* BECAUSE OF THIS, the value display loop expects unserialized values) foreach ($values as &$value) { if (!strlen($value)) { continue; } // skip further actions if ($format_output > 0) { // 1: decimal, 2: integer $value = @number_format($value, $decimal_digits_displayed, $decimal_digits_sep, $decimal_thousands_sep); $value = $value === NULL ? 0 : $value; $value = $output_prefix . $value . $output_suffix; } else { if (!empty($output_custom_func)) { $value = eval("\$value= \"{$value}\";" . $output_custom_func); } } if ($lang_filter_values) { $value = JText::_($value); } if ($clean_output) { $value = $ifilter->clean($value, 'string'); } if ($encode_output) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); } } 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'); // 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; } 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; // 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>'; } } } // ************ // Add OGP tags // ************ if ($field->parameters->get('useogp', 0) && !empty($field->{$prop})) { // Get ogp configuration $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); $ogpusage = $field->parameters->get('ogpusage', 0); if (in_array($view, $ogpinview)) { switch ($ogpusage) { case 1: $usagetype = 'title'; break; case 2: $usagetype = 'description'; break; default: $usagetype = ''; break; } if ($usagetype) { $content_val = !$is_ingroup ? flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen) : flexicontent_html::striptagsandcut($opentag . implode($separatorf, $field->{$prop}) . $closetag, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:' . $usagetype . '" content="' . $content_val . '" />'); } } } }
<?php if ($mod_use_image && $item->image_rendered) : ?> <div class="image_standard"> <?php if ($mod_link_image) : ?> <a href="<?php echo $item->link; ?>"><?php echo $item->image_rendered; ?></a> <?php else : ?> <?php echo $item->image_rendered; ?> <?php endif; ?> </div> <?php elseif ($mod_use_image && $item->image) : ?> <div class="image_standard"> <?php if ($mod_link_image) : ?> <a href="<?php echo $item->link; ?>"><img <?php echo $force_height." ".$force_width; ?> src="<?php echo $item->image; ?>" alt="<?php echo flexicontent_html::striptagsandcut($item->fulltitle, 60); ?>" /></a> <?php else : ?> <img <?php echo $force_height." ".$force_width; ?> src="<?php echo $item->image; ?>" alt="<?php echo flexicontent_html::striptagsandcut($item->fulltitle, 60); ?>" /> <?php endif; ?> </div> <?php endif; ?> <!-- BOF current item's image --> <!-- BOF current item's content --> <?php if ($display_date || $display_text || $display_hits || $display_voting || $display_comments || $mod_readmore || ($use_fields && @$item->fields && $fields)) : ?> <div class="content_standard"> <?php if ($display_date && $item->date_created) : ?> <div class="fc_block"> <div class="fc_inline fcitem_date created"> <?php echo $item->date_created; ?> </div>
/** * Method to add flexi extended datas to standard content * * @params object the unassociated items rows * @params boolean add the records from the items_ext table * @return boolean * @since 1.5 */ function bindExtData($rows) { if (!$rows || !count($rows)) { return; } $app = JFactory::getApplication(); $jinput = $app->input; $search_prefix = $this->cparams->get('add_search_prefix') ? 'vvv' : ''; // SEARCH WORD Prefix $typeid = $jinput->get('typeid', 1, 'int'); $default_cat = $jinput->get('default_cat', 0, 'int'); $default_lang = flexicontent_html::getSiteDefaultLang(); // Get invalid cats, to avoid using them during binding, this is only done once $session = JFactory::getSession(); $badcats_fixed = $session->get('badcats', null, 'flexicontent'); if ($badcats_fixed === null) { // Correct non-existent main category in content table $query = 'UPDATE #__content as c ' . ' LEFT JOIN #__categories as cat ON c.catid=cat.id' . ' SET c.catid=' . $default_cat . ' WHERE cat.id IS NULL'; $this->_db->setQuery($query); $this->_db->execute(); $session->set('badcats_fixed', 1, 'flexicontent'); } // Calculate item data to be used for current bind STEP $catrel = array(); foreach ($rows as $row) { $row_catid = (int) $row->catid; $catrel[] = '(' . $row_catid . ', ' . (int) $row->id . ')'; // append the text property to the object if (JString::strlen($row->fulltext) > 1) { $row->text_stripped = $row->introtext . '<hr id="system-readmore" />' . $row->fulltext; } else { $row->text_stripped = flexicontent_html::striptagsandcut($row->introtext); } } // Insert main category-item relation via single query $catrel = implode(', ', $catrel); $query = "INSERT INTO #__flexicontent_cats_item_relations (`catid`, `itemid`) " . " VALUES " . $catrel . " ON DUPLICATE KEY UPDATE ordering=ordering"; $this->_db->setQuery($query); $this->_db->execute(); $query = "SHOW VARIABLES LIKE 'max_allowed_packet'"; $this->_db->setQuery($query); $_dbvariable = $this->_db->loadObject(); $max_allowed_packet = flexicontent_upload::parseByteLimit(@$_dbvariable->Value); $max_allowed_packet = $max_allowed_packet ? $max_allowed_packet : 256 * 1024; $query_lim = (int) (3 * $max_allowed_packet / 4); // Insert items_ext datas, // NOTE: we will not use a single query for creating multiple records, instead we will create only e.g. 100 at once, // because of the column search_index which can be quite long $itemext = array(); $id_arr = array(); $row_count = count($rows); $n = 0; $i = 0; $query_len = 0; foreach ($rows as $row) { $ilang = $row->language ? $row->language : $default_lang; if ($search_prefix) { $_search_index = preg_replace('/(\\b[^\\s,\\.]+\\b)/u', $search_prefix . '$0', $row->title . ' | ' . $row->text_stripped); } else { $_search_index = $row->title . ' | ' . $row->text_stripped; } $itemext[$i] = '(' . (int) $row->id . ', ' . $typeid . ', ' . $this->_db->Quote($ilang) . ', ' . $this->_db->Quote($_search_index) . ', 0)'; $id_arr[$i] = (int) $row->id; $query_len += strlen($itemext[$i]) + 2; // Sum of query length so far $n++; $i++; if ($n % 101 == 0 || $n == $row_count || $query_len > $query_lim) { $itemext_list = implode(', ', $itemext); $query = "INSERT INTO #__flexicontent_items_ext (`item_id`, `type_id`, `language`, `search_index`, `lang_parent_id`)" . " VALUES " . $itemext_list . " ON DUPLICATE KEY UPDATE type_id=VALUES(type_id), language=VALUES(language), search_index=VALUES(search_index)"; $this->_db->setQuery($query); $this->_db->execute(); // reset the item array $itemext = array(); $query = "UPDATE #__flexicontent_items_tmp" . " SET type_id=" . $typeid . " WHERE id IN(" . implode(',', $id_arr) . ")"; $this->_db->setQuery($query); $this->_db->execute(); // reset the item id array $id_arr = array(); $i = 0; // reset sub-counter, and query length $query_len = 0; } } // Update temporary item data $this->updateItemCountingData($rows); }
} $subcats_html[$i] .= " <span class='catinfo ".$subcat_info_class."'>\n"; // b. Category title with link and optional item counts $cat_link = ($layout=='myitems' || $layout=='author') ? $this->action .(strstr($this->action, '?') ? '&' : '?'). 'cid='.$sub->slug : JRoute::_( FlexicontentHelperRoute::getCategoryRoute($sub->slug) ); $infocount_str = ''; if ($show_itemcount) $infocount_str .= (int) $sub->assigneditems . $itemcount_label; if ($show_subcatcount) $infocount_str .= ($show_itemcount ? ' / ' : '').count($sub->subcats) . $subcatcount_label; if (strlen($infocount_str)) $infocount_str = ' (' . $infocount_str . ')'; $subcats_html[$i] .= " <a class='catlink' href='".$cat_link."'>".$this->escape($sub->title)."</a>".$infocount_str."</span>\n"; // c. Optional sub-category description stripped of HTML and cut to given length if ($show_description_subcat && $sub->description) { $subcats_html[$i] .= " <span class='catdescription'>". flexicontent_html::striptagsandcut( $sub->description, $description_cut_text_subcat )."</span>"; } $subcats_html[$i] .= "</span>\n"; // d. Add prefix, suffix to the HTML of current sub-category $subcats_html[$i] = $pretext.$subcats_html[$i].$posttext; $i++; } // Create the HTML of sub-category list , add configured separator $subcats_html = implode($separatorf, $subcats_html); // Add open/close tag to the HTML $subcats_html = $opentag .$subcats_html. $closetag; // Add optional sub-categories list label if ($show_label_subcats) {
<?php if ($image) { ?> <span class="fcsubcat_image_box"><?php echo $image; ?> </span> <?php } ?> <?php if ($show_subcat_descr && $subcat->description) { ?> <span class="fcsubcat_descr"><?php echo flexicontent_html::striptagsandcut($subcat->description, $cat_descr_cut); ?> </span> <?php } ?> <div class='clear'></div> </li> <?php } ?> </ul> </div>
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; }
<?php if ($mod_link_image) : ?> <a href="<?php echo $item->link; ?>"><?php echo $item->image_rendered; ?></a> <?php else : ?> <?php echo $item->image_rendered; ?> <?php endif; ?> </div> <?php elseif ($mod_use_image && $item->image) : ?> <div class="image_standard"> <?php if ($mod_link_image) : ?> <a href="<?php echo $item->link; ?>"> <img style="<?php echo $img_force_dims; ?>" src="<?php echo $item->image; ?>" alt="<?php echo flexicontent_html::striptagsandcut($item->fulltitle, 60); ?>" /> </a> <?php else : ?> <img style="<?php echo $img_force_dims; ?>" src="<?php echo $item->image; ?>" alt="<?php echo flexicontent_html::striptagsandcut($item->fulltitle, 60); ?>" /> <?php endif; ?> </div> <?php endif; ?> <!-- BOF current item's image --> <!-- BOF current item's content --> <?php if ($display_date || $display_text || $display_hits || $display_voting || $display_comments || $mod_readmore || ($use_fields && @$item->fields && $fields)) : ?> <div class="content_standard"> <?php if ($display_date && $item->date_created) : ?> <div class="fc_block"> <div class="fc_inline fcitem_date created"> <?php echo $item->date_created; ?> </div>
/** * Creates the RSS for the View * * @since 1.0 */ function display($tpl = null) { $db = JFactory::getDBO(); $doc = JFactory::getDocument(); $app = JFactory::getApplication(); $params = $this->get('Params'); $doc->link = JRoute::_('index.php?option=com_flexicontent&view=flexicontent&rootcat=' . (int) $params->get('rootcat', FLEXI_J16GE ? 1 : 0)); JRequest::setVar('limit', $params->get('feed_limit')); // Force a specific limit, this will be moved to the model $cats = $this->get('Feed'); //$feed_summary = $params->get('feed_summary', 0); $feed_summary_cut = $params->get('feed_summary_cut', 200); $feed_use_image = $params->get('feed_use_image', 1); $feed_image_source = $params->get('feed_image_source', ''); $feed_link_image = $params->get('feed_link_image', 1); $feed_image_method = $params->get('feed_image_method', 1); $feed_image_width = $params->get('feed_image_width', 100); $feed_image_height = $params->get('feed_image_height', 80); // Retrieve default image for the image field if ($feed_use_image && $feed_image_source) { $query = 'SELECT attribs, name FROM #__flexicontent_fields WHERE id = ' . (int) $feed_image_source; $db->setQuery($query); $image_dbdata = $db->loadObject(); //$image_dbdata->params = FLEXI_J16GE ? new JRegistry($image_dbdata->params) : new JParameter($image_dbdata->params); $img_size_map = array('l' => 'large', 'm' => 'medium', 's' => 'small', '' => ''); $img_field_size = $img_size_map[$image_size]; $img_field_name = $image_dbdata->name; } foreach ($cats as $cat) { // strip html from feed item title $title = $this->escape($cat->title); $title = html_entity_decode($title); // url link to article // & used instead of & as this is converted by feed creator $link = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)); // strip html from feed item description text $description = $cat->description; //$feed_summary ? $cat->description : ''; $description = flexicontent_html::striptagsandcut($description, $feed_summary_cut); if ($feed_use_image) { // feed image is enabled // Get some variables $joomla_image_path = $app->getCfg('image_path', FLEXI_J16GE ? '' : 'images' . DS . 'stories'); $joomla_image_url = str_replace(DS, '/', $joomla_image_path); $joomla_image_path = $joomla_image_path ? $joomla_image_path . DS : ''; $joomla_image_url = $joomla_image_url ? $joomla_image_url . '/' : ''; // ************** // CATEGORY IMAGE // ************** // category image params $show_cat_image = $params->get('show_description_image', 0); // we use different name for variable $cat_image_source = $params->get('cat_image_source', 2); // 0: extract, 1: use param, 2: use both $cat_link_image = $params->get('cat_link_image', 1); $cat_image_method = $params->get('cat_image_method', 1); $cat_image_width = $params->get('cat_image_width', 80); $cat_image_height = $params->get('cat_image_height', 80); $cat =& $category; $thumb = ""; if ($cat->id && $show_cat_image) { $cat->image = FLEXI_J16GE ? $params->get('image') : $cat->image; $thumb = ""; $cat->introtext =& $cat->description; $cat->fulltext = ""; if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) { $src = JURI::base(true) . "/" . $joomla_image_url . $cat->image; $h = '&h=' . $cat_image_height; $w = '&w=' . $cat_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $cat_image_method ? '&zc=' . $cat_image_method : ''; $ext = pathinfo($src, PATHINFO_EXTENSION); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $thumb = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf; } else { if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) { $h = '&h=' . $feed_image_height; $w = '&w=' . $feed_image_width; $aoe = '&aoe=1'; $q = '&q=95'; $zc = $feed_image_method ? '&zc=' . $feed_image_method : ''; $ext = pathinfo($src, PATHINFO_EXTENSION); $f = in_array($ext, array('png', 'ico', 'gif')) ? '&f=' . $ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : ''; $src = $base_url . $src; $thumb = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf; } } } if ($thumb) { $description = "<a href='" . $link . "'><img src='" . $thumb . "' alt='" . $title . "' title='" . $title . "' align='left'/></a><p>" . $description . "</p>"; } } //$author = $cat->created_by_alias ? $cat->created_by_alias : $cat->author; @($date = $cat->created ? date('r', strtotime($cat->created)) : ''); // load individual item creator class $item = new JFeedItem(); $item->title = $title . ' (' . (int) $cat->assigneditems . ')'; $item->link = $link; $item->description = $description; $item->date = $date; //$item->author = $author; //$item->category = $this->escape( $category->title ); // loads item info into rss array $doc->addItem($item); } }
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); $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW)); // Value handling parameters $lang_filter_values = $field->parameters->get('lang_filter_values', 0); $clean_output = $field->parameters->get('clean_output', 0); $encode_output = $field->parameters->get('encode_output', 0); $format_output = $field->parameters->get('format_output', 0); if ($format_output == 1) { $decimal_digits_displayed = (int) $field->parameters->get('decimal_digits_displayed', 2); $decimal_digits_sep = $field->parameters->get('decimal_digits_sep', '.'); $decimal_thousands_sep = $field->parameters->get('decimal_thousands_sep', ','); } // Default value $value_usage = $field->parameters->get('default_value_use', 0); $default_value = $value_usage == 2 ? $field->parameters->get('default_value', '') : ''; $default_value = $default_value ? JText::_($default_value) : ''; // Get field values $values = $values ? $values : $field->value; // Load default value if (empty($values)) { if (!strlen($default_value)) { $field->{$prop} = $is_ingroup ? array() : ''; return; } $values = array($default_value); } // Language filter, clean output, encode HTML if ($clean_output) { $ifilter = $clean_output == 1 ? JFilterInput::getInstance(null, null, 1, 1) : JFilterInput::getInstance(); } if ($lang_filter_values || $clean_output || $encode_output || $format_output) { // (* BECAUSE OF THIS, the value display loop expects unserialized values) foreach ($values as &$value) { if ($format_output == 1) { $value = @number_format($value, $decimal_digits_displayed, $decimal_digits_sep, $decimal_thousands_sep); $value = $value === NULL ? 0 : ''; } if (!strlen($value)) { continue; } // skip further actions if ($lang_filter_values) { $value = JText::_($value); } if ($clean_output) { $value = $ifilter->clean($value, 'string'); } if ($encode_output) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); } } 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'); $itemprop = $field->parameters->get('microdata_itemprop'); 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; } // Initialise property with default value $field->{$prop} = array(); $n = 0; foreach ($values as $value) { if (!strlen($value) && !$is_ingroup) { continue; } // Skip empty if not in field group if (!strlen($value)) { $field->{$prop}[$n++] = ''; continue; } // Add prefix / suffix $field->{$prop}[$n] = $pretext . $value . $posttext; // Add microdata to every value if field -- is -- in a field group if ($is_ingroup && $itemprop) { $field->{$prop}[$n] = '<span itemprop="' . $itemprop . '" >' . $field->{$prop}[$n] . '</span>'; } $n++; if (!$multiple) { break; } // multiple values disabled, break out of the loop, not adding further values even if the exist } // 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} = '<span itemprop="' . $itemprop . '" >' . $field->{$prop} . '</span>'; } } } // ************ // Add OGP tags // ************ if ($field->parameters->get('useogp', 0) && !empty($field->{$prop})) { // Get ogp configuration $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); $ogpusage = $field->parameters->get('ogpusage', 0); if (in_array($view, $ogpinview)) { switch ($ogpusage) { case 1: $usagetype = 'title'; break; case 2: $usagetype = 'description'; break; default: $usagetype = ''; break; } if ($usagetype) { $content_val = !$is_ingroup ? flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen) : flexicontent_html::striptagsandcut($opentag . implode($separatorf, $field->{$prop}) . $closetag, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:' . $usagetype . '" content="' . $content_val . '" />'); } } } }