/** * Creates the HTML of various form fields used in the item edit form * * @since 1.0 */ function _buildEditLists(&$perms, &$params, &$authorparams) { $db = JFactory::getDBO(); $user = JFactory::getUser(); // get current user $item = $this->get('Item'); // get the item from the model $document = JFactory::getDocument(); $session = JFactory::getSession(); global $globalcats; $categories = $globalcats; // get the categories tree $types = $this->get('Typeslist'); $typesselected = $this->get('Typesselected'); $subscribers = $this->get('SubscribersCount'); $isnew = !$item->id; // ******************************* // Get categories used by the item // ******************************* if ($isnew) { // Case for preselected main category for new items $maincat = $item->catid ? $item->catid : JRequest::getInt('maincat', 0); if ($maincat) { $selectedcats = array($maincat); $item->catid = $maincat; } else { $selectedcats = array(); } if ($params->get('cid_default')) { $selectedcats = $params->get('cid_default'); } if ($params->get('catid_default')) { $item->catid = $params->get('catid_default'); } } else { // NOTE: This will normally return the already set versioned value of categories ($item->categories) $selectedcats = $this->get('Catsselected'); } // ********************************************************************************************* // Build select lists for the form field. Only few of them are used in J1.6+, since we will use: // (a) form XML file to declare them and then (b) getInput() method form field to create them // ********************************************************************************************* // First clean form data, we do this after creating the description field which may contain HTML JFilterOutput::objectHTMLSafe($item, ENT_QUOTES); flexicontent_html::loadFramework('select2'); $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable'); $lists = array(); // build state list $non_publishers_stategrp = $perms['isSuperAdmin'] || $item->state == -3 || $item->state == -4; $special_privelege_stategrp = $item->state == 2 || $perms['canarchive'] || ($item->state == -2 || $perms['candelete']); $state = array(); // Using <select> groups if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_PUBLISHERS_WORKFLOW_STATES')); } $state[] = JHTML::_('select.option', 1, JText::_('FLEXI_PUBLISHED')); $state[] = JHTML::_('select.option', 0, JText::_('FLEXI_UNPUBLISHED')); $state[] = JHTML::_('select.option', -5, JText::_('FLEXI_IN_PROGRESS')); // States reserved for workflow if ($non_publishers_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_NON_PUBLISHERS_WORKFLOW_STATES')); } if ($item->state == -3 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -3, JText::_('FLEXI_PENDING')); } if ($item->state == -4 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -4, JText::_('FLEXI_TO_WRITE')); } // Special access states if ($special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_SPECIAL_ACTION_STATES')); } if ($item->state == 2 || $perms['canarchive']) { $state[] = JHTML::_('select.option', 2, JText::_('FLEXI_ARCHIVED')); } if ($item->state == -2 || $perms['candelete']) { $state[] = JHTML::_('select.option', -2, JText::_('FLEXI_TRASHED')); } // Close last <select> group if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); } $class = 'use_select2_lib'; $attribs = 'class="' . $class . '"'; $lists['state'] = JHTML::_('select.genericlist', $state, 'jform[state]', $attribs, 'value', 'text', $item->state, 'jform_state'); if (!FLEXI_J16GE) { $lists['state'] = str_replace('<optgroup label="">', '</optgroup>', $lists['state']); } // *** BOF: J2.5 SPECIFIC SELECT LISTS if (FLEXI_J16GE) { } // *** EOF: J1.5 SPECIFIC SELECT LISTS // build version approval list $fieldname = 'jform[vstate]'; $elementid = 'jform_vstate'; /* $options = array(); $options[] = JHTML::_('select.option', 1, JText::_( 'FLEXI_NO' ) ); $options[] = JHTML::_('select.option', 2, JText::_( 'FLEXI_YES' ) ); $attribs = FLEXI_J16GE ? ' style ="float:left!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['vstate'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', 2, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array(1 => JText::_('FLEXI_NO'), 2 => JText::_('FLEXI_YES')); $lists['vstate'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id == 2 ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['vstate'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['vstate'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['vstate'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } // build field for notifying subscribers if (!$subscribers) { $lists['notify'] = !$isnew ? JText::_('FLEXI_NO_SUBSCRIBERS_EXIST') : ''; } else { // b. Check if notification emails to subscribers , were already sent during current session $subscribers_notified = $session->get('subscribers_notified', array(), 'flexicontent'); if (!empty($subscribers_notified[$item->id])) { $lists['notify'] = JText::_('FLEXI_SUBSCRIBERS_ALREADY_NOTIFIED'); } else { // build favs notify field $fieldname = 'jform[notify]'; $elementid = 'jform_notify'; /* $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['notify'] = '<input type="checkbox" name="jform[notify]" id="jform_notify" '.$attribs.' /> '. $lbltxt; */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $lbltxt = $subscribers . ' ' . JText::_($subscribers > 1 ? 'FLEXI_SUBSCRIBERS' : 'FLEXI_SUBSCRIBER'); if (!$prettycheckable_added) { $lists['notify'] .= '<label class="fccheckradio_lbl" for="' . $elementid . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . $lbltxt . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['notify'] = ' <input type="checkbox" id="' . $elementid . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="1" ' . $extra_params . ' checked="checked" />'; if (!$prettycheckable_added) { $lists['notify'] .= ' ' . $lbltxt . '</label>'; } } } // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = !$authorparams ? 0 : intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; max_cat_overlimit_msg_fc = "' . JText::_('FLEXI_TOO_MANY_ITEM_CATEGORIES', true) . '"; '); // Creating categorories tree for item assignment, we use the 'create' privelege $actions_allowed = array('core.create'); // Featured categories form field $featured_cats_parent = $params->get('featured_cats_parent', 0); $featured_cats = array(); $enable_featured_cid_selector = $perms['multicat'] && $perms['canchange_featcat']; if ($featured_cats_parent) { $featured_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $featured_cats_parent, $depth_limit = 0); $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array(); $featured_sel = array(); foreach ($selectedcats as $item_cat) { if (isset($featured_tree[$item_cat])) { $featured_sel[] = $item_cat; } } $class = "use_select2_lib select2_list_selected"; $attribs = 'class="' . $class . '" multiple="multiple" size="8"'; $attribs .= $enable_featured_cid_selector ? '' : ' disabled="disabled"'; $fieldname = 'jform[featured_cid][]'; $lists['featured_cid'] = ($enable_featured_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($featured_tree, $fieldname, $featured_sel, 3, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { // Do not display, if not configured or not allowed to the user $lists['featured_cid'] = false; } // Multi-category form field, for user allowed to use multiple categories $lists['cid'] = ''; $enable_cid_selector = $perms['multicat'] && $perms['canchange_seccat']; if (1) { if ($params->get('cid_allowed_parent')) { $cid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $params->get('cid_allowed_parent'), $depth_limit = 0); $disabled_cats = $params->get('cid_allowed_parent_disable', 1) ? array($params->get('cid_allowed_parent')) : array(); } else { $cid_tree =& $categories; $disabled_cats = array(); } // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = !$authorparams ? 0 : intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; max_cat_overlimit_msg_fc = "' . JText::_('FLEXI_TOO_MANY_ITEM_CATEGORIES', true) . '"; '); $class = "mcat use_select2_lib select2_list_selected"; $class .= $max_cat_assign ? " validate-fccats" : " validate"; $attribs = 'class="' . $class . '" multiple="multiple" size="20"'; $attribs .= $enable_cid_selector ? '' : ' disabled="disabled"'; $fieldname = 'jform[cid][]'; $skip_subtrees = $featured_cats_parent ? array($featured_cats_parent) : array(); $lists['cid'] = ($enable_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($cid_tree, $fieldname, $selectedcats, false, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees, $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { if (count($selectedcats) > 1) { foreach ($selectedcats as $catid) { $cat_titles[$catid] = $globalcats[$catid]->title; } $lists['cid'] .= implode(', ', $cat_titles); } else { $lists['cid'] = false; } } // Main category form field $class = 'scat use_select2_lib'; if ($perms['multicat']) { $class .= ' validate-catid'; } else { $class .= ' required'; } $attribs = 'class="' . $class . '"'; $fieldname = 'jform[catid]'; $enable_catid_selector = $isnew && !$params->get('catid_default') || !$isnew && empty($item->catid) || $perms['canchange_cat']; if ($params->get('catid_allowed_parent')) { $catid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $params->get('catid_allowed_parent'), $depth_limit = 0); $disabled_cats = $params->get('catid_allowed_parent_disable', 1) ? array($params->get('catid_allowed_parent')) : array(); } else { $catid_tree =& $categories; $disabled_cats = array(); } $lists['catid'] = false; if (!empty($catid_tree)) { $disabled = $enable_catid_selector ? '' : ' disabled="disabled"'; $attribs .= $disabled; $lists['catid'] = ($enable_catid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($catid_tree, $fieldname, $item->catid, 2, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats, $empty_errmsg = JText::_('FLEXI_FORM_NO_MAIN_CAT_ALLOWED')); } else { if (!$isnew && $item->catid) { $lists['catid'] = $globalcats[$item->catid]->title; } } //buid types selectlist $class = 'required use_select2_lib'; $attribs = 'class="' . $class . '"'; $fieldname = 'jform[type_id]'; $elementid = 'jform_type_id'; $lists['type'] = flexicontent_html::buildtypesselect($types, $fieldname, $typesselected->id, 1, $attribs, $elementid, $check_perms = true); // build version approval list if ($params->get('allowdisablingcomments_fe')) { // Set to zero if disabled or to "" (aka use default) for any other value. THIS WILL FORCE comment field use default Global/Category/Content Type setting or disable it, // thus a per item commenting system cannot be selected. This is OK because it makes sense to have a different commenting system per CONTENT TYPE by not per Content Item $isdisabled = !$params->get('comments') && strlen($params->get('comments')); $fieldvalue = $isdisabled ? 0 : ""; $fieldname = 'jform[attribs][comments]'; $elementid = 'jform_attribs_comments'; /* $options = array(); $options[] = JHTML::_('select.option', "", JText::_( 'FLEXI_DEFAULT_BEHAVIOR' ) ); $options[] = JHTML::_('select.option', 0, JText::_( 'FLEXI_DISABLE' ) ); $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; $lists['disable_comments'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', $fieldvalue, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array("" => JText::_('FLEXI_DEFAULT_BEHAVIOR'), 0 => JText::_('FLEXI_DISABLE')); $lists['disable_comments'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id === $fieldvalue ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['disable_comments'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['disable_comments'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['disable_comments'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } } // find user's allowed languages $allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed', null); $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs); if (!$isnew && $allowed_langs) { $allowed_langs[] = $item->language; } // find globaly or per content type disabled languages $disable_langs = $params->get('disable_languages_fe', array()); // Build languages list if (FLEXI_J16GE || FLEXI_FISH) { $item_lang = $item->language; // Model has already set default language according to parameters $langdisplay = $params->get('langdisplay_fe', 2); $langconf = array(); $langconf['flags'] = $params->get('langdisplay_flags_fe', 1); $langconf['texts'] = $params->get('langdisplay_texts_fe', 1); $field_attribs = $langdisplay == 2 ? 'class="use_select2_lib"' : ''; $lists['languages'] = flexicontent_html::buildlanguageslist('jform[language]', $field_attribs, $item->language, $langdisplay, $allowed_langs, $published_only = 1, $disable_langs, $add_all = true, $langconf); } return $lists; }
static function calculateItemMarkups($items, $params) { global $globalcats; global $globalnoroute; $globalnoroute = !is_array($globalnoroute) ? array() : $globalnoroute; $db = JFactory::getDBO(); $user = JFactory::getUser(); $aids = JAccess::getAuthorisedViewLevels($user->id); // ************************************** // Get configuration about markups to add // ************************************** // Get addcss parameters $mu_addcss_cats = $params->get('mu_addcss_cats', array('featured')); $mu_addcss_cats = FLEXIUtilities::paramToArray($mu_addcss_cats); $mu_addcss_acclvl = $params->get('mu_addcss_acclvl', array('needed_acc', 'obtained_acc')); $mu_addcss_acclvl = FLEXIUtilities::paramToArray($mu_addcss_acclvl); $mu_addcss_radded = $params->get('mu_addcss_radded', 0); $mu_addcss_rupdated = $params->get('mu_addcss_rupdated', 0); // Calculate addcss flags $add_featured_cats = in_array('featured', $mu_addcss_cats); $add_other_cats = in_array('other', $mu_addcss_cats); $add_no_acc = in_array('no_acc', $mu_addcss_acclvl); $add_free_acc = in_array('free_acc', $mu_addcss_acclvl); $add_needed_acc = in_array('needed_acc', $mu_addcss_acclvl); $add_obtained_acc = in_array('obtained_acc', $mu_addcss_acclvl); // Get addtext parameters $mu_addtext_cats = $params->get('mu_addtext_cats', 1); $mu_addtext_acclvl = $params->get('mu_addtext_acclvl', array('no_acc', 'free_acc', 'needed_acc', 'obtained_acc')); $mu_addtext_acclvl = FLEXIUtilities::paramToArray($mu_addtext_acclvl); $mu_addtext_radded = $params->get('mu_addtext_radded', 1); $mu_addtext_rupdated = $params->get('mu_addtext_rupdated', 1); // Calculate addtext flags $add_txt_no_acc = in_array('no_acc', $mu_addtext_acclvl); $add_txt_free_acc = in_array('free_acc', $mu_addtext_acclvl); $add_txt_needed_acc = in_array('needed_acc', $mu_addtext_acclvl); $add_txt_obtained_acc = in_array('obtained_acc', $mu_addtext_acclvl); $mu_add_condition_obtainded_acc = $params->get('mu_add_condition_obtainded_acc', 1); $mu_no_acc_text = JText::_($params->get('mu_no_acc_text', 'FLEXI_MU_NO_ACC')); $mu_free_acc_text = JText::_($params->get('mu_free_acc_text', 'FLEXI_MU_NO_ACC')); // ******************************* // Prepare data needed for markups // ******************************* // a. Get Featured categories and language filter their titles $featured_cats_parent = $params->get('featured_cats_parent', 0); $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array(); $featured_cats = array(); if ($add_featured_cats && $featured_cats_parent) { $where[] = isset($globalcats[$featured_cats_parent]) ? 'id IN (' . $globalcats[$featured_cats_parent]->descendants . ')' : 'parent_id = ' . $featured_cats_parent; if (!empty($disabled_cats)) { $where[] = 'id NOT IN (' . implode(", ", $disabled_cats) . ')'; } // optionally exclude category root of featured subtree $query = 'SELECT c.id' . ' FROM #__categories AS c' . (count($where) ? ' WHERE ' . implode(' AND ', $where) : ''); $db->setQuery($query); $featured_cats = $db->loadColumn(); $featured_cats = $featured_cats ? array_flip($featured_cats) : array(); foreach ($featured_cats as $featured_cat => $i) { $featured_cats_titles[$featured_cat] = JText::_($globalcats[$featured_cat]->title); } } // b. Get Access Level names (language filter them) if ($add_needed_acc || $add_obtained_acc) { if (FLEXI_J16GE) { $db->setQuery('SELECT id, title FROM #__viewlevels'); $_arr = $db->loadObjectList(); $access_names = array(0 => 'Public'); // zero does not exist in J2.5+ but we set it for compatibility foreach ($_arr as $o) { $access_names[$o->id] = JText::_($o->title); } } else { $access_names = array(0 => 'Public', 1 => 'Registered', 2 => 'Special', 3 => 'Privileged'); } } // c. Calculate creation time intervals if ($mu_addcss_radded) { $nowdate_secs = time(); $ra_timeframes = trim($params->get('mu_ra_timeframe_intervals', '24h,2d,7d,1m,3m,1y,3y')); $ra_timeframes = preg_split("/\\s*,\\s*/u", $ra_timeframes); $ra_names = trim($params->get('mu_ra_timeframe_names', 'FLEXI_24H_RA , FLEXI_2D_RA , FLEXI_7D_RA , FLEXI_1M_RA , FLEXI_3M_RA , FLEXI_1Y_RA , FLEXI_3Y_RA')); $ra_names = preg_split("/\\s*,\\s*/u", $ra_names); $unit_hour_map = array('h' => 1, 'd' => 24, 'm' => 24 * 30, 'y' => 24 * 365); $unit_word_map = array('h' => 'hours', 'd' => 'days', 'm' => 'months', 'y' => 'years'); $unit_text_map = array('h' => 'FLEXI_MU_HOURS', 'd' => 'FLEXI_MU_DAYS', 'm' => 'FLEXI_MU_MONTHS', 'y' => 'FLEXI_MU_YEARS'); foreach ($ra_timeframes as $i => $timeframe) { $unit = substr($timeframe, -1); if (!isset($unit_hour_map[$unit])) { echo "Improper timeframe ': " . $timeframe . "' for recently added content, please fix in configuration"; continue; } $timeframe = (int) $timeframe; $ra_css_classes[$i] = '_item_added_within_' . $timeframe . $unit_word_map[$unit]; $ra_timeframe_secs[$i] = $timeframe * $unit_hour_map[$unit] * 3600; $ra_timeframe_text[$i] = @$ra_names[$i] ? JText::_($ra_names[$i]) : JText::_('FLEXI_MU_ADDED') . JText::sprintf($unit_text_map[$unit], $timeframe); } } // d. Calculate updated time intervals if ($mu_addcss_rupdated) { $nowdate_secs = time(); $ru_timeframes = trim($params->get('mu_ru_timeframe_intervals', '24h,2d,7d,1m,3m,1y,3y')); $ru_timeframes = preg_split("/\\s*,\\s*/u", $ru_timeframes); $ru_names = trim($params->get('mu_ru_timeframe_names', 'FLEXI_24H_RU , FLEXI_2D_RU , FLEXI_7D_RU , FLEXI_1M_RU , FLEXI_3M_RU , FLEXI_1Y_RU , FLEXI_3Y_RU')); $ru_names = preg_split("/\\s*,\\s*/u", $ru_names); $unit_hour_map = array('h' => 1, 'd' => 24, 'm' => 24 * 30, 'y' => 24 * 365); $unit_word_map = array('h' => 'hours', 'd' => 'days', 'm' => 'months', 'y' => 'years'); $unit_text_map = array('h' => 'FLEXI_MU_HOURS', 'd' => 'FLEXI_MU_DAYS', 'm' => 'FLEXI_MU_MONTHS', 'y' => 'FLEXI_MU_YEARS'); foreach ($ru_timeframes as $i => $timeframe) { $unit = substr($timeframe, -1); if (!isset($unit_hour_map[$unit])) { echo "Improper timeframe ': " . $timeframe . "' for recently updated content, please fix in configuration"; continue; } $timeframe = (int) $timeframe; $ru_css_classes[$i] = '_item_updated_within_' . $timeframe . $unit_word_map[$unit]; $ru_timeframe_secs[$i] = $timeframe * $unit_hour_map[$unit] * 3600; $ru_timeframe_text[$i] = @$ru_names[$i] ? JText::_($ru_names[$i]) : JText::_('FLEXI_MU_UPDATED') . JText::sprintf($unit_text_map[$unit], $timeframe); } } // ********************************** // Create CSS markup classes per item // ********************************** $public_acclvl = 1; foreach ($items as $item) { $item->css_markups = array(); //$item->categories = isset($item->categories) ? $item->categories : array(); // Category markups if ($add_featured_cats || $add_other_cats) { foreach ($item->categories as $item_cat) { $is_featured_cat = isset($featured_cats[$item_cat->id]); if ($is_featured_cat && !$add_featured_cats) { continue; } // not adding featured cats if (!$is_featured_cat && !$add_other_cats) { continue; } // not adding other cats if (in_array($item_cat->id, $globalnoroute)) { continue; } // non-linkable/routable 'special' category $item->css_markups['itemcats'][] = '_itemcat_' . $item_cat->id; $item->ecss_markups['itemcats'][] = ($is_featured_cat ? ' mu_featured_cat' : ' mu_normal_cat') . ($mu_addtext_cats ? ' mu_has_text' : ''); $item->title_markups['itemcats'][] = $mu_addtext_cats ? $is_featured_cat ? $featured_cats_titles[$item_cat->id] : (isset($globalcats[$item_cat->id]) ? $globalcats[$item_cat->id]->title : '') : ''; } } // recently-added Timeframe markups if ($mu_addcss_radded) { $item_timeframe_secs = $nowdate_secs - strtotime($item->created); $mr = -1; foreach ($ra_timeframe_secs as $i => $timeframe_secs) { // Check if item creation time has surpassed this time frame if ($item_timeframe_secs > $timeframe_secs) { continue; } // Check if this time frame is more recent than the best one found so far if ($mr != -1 && $timeframe_secs > $ra_timeframe_secs[$mr]) { continue; } // Use current time frame $mr = $i; } if ($mr >= 0) { $item->css_markups['timeframe'][] = $ra_css_classes[$mr]; $item->ecss_markups['timeframe'][] = ' mu_ra_timeframe' . ($mu_addtext_radded ? ' mu_has_text' : ''); $item->title_markups['timeframe'][] = $mu_addtext_radded ? $ra_timeframe_text[$mr] : ''; } } // recently-updated Timeframe markups if ($mu_addcss_rupdated) { $item_timeframe_secs = $nowdate_secs - strtotime($item->modified); $mr = -1; foreach ($ru_timeframe_secs as $i => $timeframe_secs) { // Check if item creation time has surpassed this time frame if ($item_timeframe_secs > $timeframe_secs) { continue; } // Check if this time frame is more recent than the best one found so far if ($mr != -1 && $timeframe_secs > $ru_timeframe_secs[$mr]) { continue; } // Use current time frame $mr = $i; } if ($mr >= 0) { $item->css_markups['timeframe'][] = $ru_css_classes[$mr]; $item->ecss_markups['timeframe'][] = ' mu_ru_timeframe' . ($mu_addtext_rupdated ? ' mu_has_text' : ''); $item->title_markups['timeframe'][] = $mu_addtext_rupdated ? $ru_timeframe_text[$mr] : ''; } } // Get item's access levels if this is needed if ($add_free_acc || $add_needed_acc || $add_obtained_acc) { $all_acc_lvls = array(); $all_acc_lvls[] = $item->access; $all_acc_lvls[] = $item->category_access; $all_acc_lvls[] = $item->type_access; $all_acc_lvls = array_unique($all_acc_lvls); } // No access markup if ($add_no_acc && !$item->has_access) { $item->css_markups['access'][] = '_item_no_access'; $item->ecss_markups['access'][] = $add_txt_no_acc ? ' mu_has_text' : ''; $item->title_markups['access'][] = $add_txt_no_acc ? $mu_no_acc_text : ''; } // Free access markup, Add ONLY if item has a single access level the public one ... if ($add_free_acc && $item->has_access && count($all_acc_lvls) == 1 && $public_acclvl == reset($all_acc_lvls)) { $item->css_markups['access'][] = '_item_free_access'; $item->ecss_markups['access'][] = $add_txt_free_acc ? ' mu_has_text' : ''; $item->title_markups['access'][] = $add_txt_free_acc ? $mu_free_acc_text : ''; } // Needed / Obtained access levels markups if ($add_needed_acc || $add_obtained_acc) { foreach ($all_acc_lvls as $all_acc_lvl) { if ($public_acclvl == $all_acc_lvl) { continue; } // handled separately above $has_acclvl = in_array($all_acc_lvl, $aids); if (!$has_acclvl) { if (!$add_needed_acc) { continue; } // not adding needed levels $item->css_markups['access'][] = '_acclvl_' . $all_acc_lvl; $item->ecss_markups['access'][] = ' mu_needed_acclvl' . ($add_txt_needed_acc ? ' mu_has_text' : ''); $item->title_markups['access'][] = $add_txt_needed_acc ? $access_names[$all_acc_lvl] : ''; } else { if (!$add_obtained_acc) { continue; } // not adding obtained levels if ($mu_add_condition_obtainded_acc == 0 && !$item->has_access) { continue; } // do not add obtained level markups if item is inaccessible $item->css_markups['access'][] = '_acclvl_' . $all_acc_lvl; $item->ecss_markups['access'][] = ' mu_obtained_acclvl' . ($add_txt_obtained_acc ? ' mu_has_text' : ''); $item->title_markups['access'][] = $add_txt_obtained_acc ? $access_names[$all_acc_lvl] : ''; } } } } }
/** * Creates the item page * * @since 1.0 */ function display($tpl = null) { // ******************************** // Initialize variables, flags, etc // ******************************** global $globalcats; $categories = $globalcats; $app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $document = JFactory::getDocument(); $config = JFactory::getConfig(); $session = JFactory::getSession(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $option = JRequest::getVar('option'); $nullDate = $db->getNullDate(); // Get the COMPONENT only parameters // Get component parameters $params = new JRegistry(); $cparams = JComponentHelper::getParams('com_flexicontent'); $params->merge($cparams); $params = clone JComponentHelper::getParams('com_flexicontent'); // Some flags $enable_translation_groups = flexicontent_db::useAssociations(); //$params->get("enable_translation_groups"); $print_logging_info = $params->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // ***************** // Load JS/CSS files // ***************** // Add css to document $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION); // Fields common CSS $document->addStyleSheetVersion(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_form_fields.css', FLEXI_VERSION); // Add JS frameworks flexicontent_html::loadFramework('select2'); $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable'); flexicontent_html::loadFramework('flexi-lib'); // Add js function to overload the joomla submitform validation JHTML::_('behavior.formvalidation'); // load default validation JS to make sure it is overriden $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VERSION); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VERSION); // Add js function for custom code used by FLEXIcontent item form $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/itemscreen.js', FLEXI_VERSION); // *********************** // Get data from the model // *********************** if ($print_logging_info) { $start_microtime = microtime(true); } $model = $this->getModel(); $item = $model->getItem(); $form = $this->get('Form'); if ($print_logging_info) { $fc_run_times['get_item_data'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // *************************** // Get Associated Translations // *************************** if ($enable_translation_groups) { $langAssocs = $this->get('LangAssocs'); } $langs = FLEXIUtilities::getLanguages('code'); // Get item id and new flag $cid = $model->getId(); $isnew = !$cid; // Create and set a unique item id for plugins that needed it if ($cid) { $unique_tmp_itemid = $cid; } else { $unique_tmp_itemid = $app->getUserState('com_flexicontent.edit.item.unique_tmp_itemid'); $unique_tmp_itemid = $unique_tmp_itemid ? $unique_tmp_itemid : date('_Y_m_d_h_i_s_', time()) . uniqid(true); } //print_r($unique_tmp_itemid); JRequest::setVar('unique_tmp_itemid', $unique_tmp_itemid); // Get number of subscribers $subscribers = $model->getSubscribersCount(); // ****************** // Version Panel data // ****************** // Get / calculate some version related variables $versioncount = $model->getVersionCount(); $versionsperpage = $params->get('versionsperpage', 10); $pagecount = (int) ceil($versioncount / $versionsperpage); // Data need by version panel: (a) current version page, (b) currently active version $current_page = 1; $k = 1; $allversions = $model->getVersionList(); foreach ($allversions as $v) { if ($k > 1 && ($k - 1) % $versionsperpage == 0) { $current_page++; } if ($v->nr == $item->version) { break; } $k++; } // Finally fetch the version data for versions in current page $versions = $model->getVersionList(($current_page - 1) * $versionsperpage, $versionsperpage); // Create display of average rating $ratings = $model->getRatingDisplay(); // ***************** // Type related data // ***************** // Get available types and the currently selected/requested type $types = $model->getTypeslist(); $typesselected = $model->getTypesselected(); // Get and merge type parameters $tparams = $this->get('Typeparams'); $tparams = new JRegistry($tparams); $params->merge($tparams); // Apply type configuration if it type is set // Get user allowed permissions on the item ... to be used by the form rendering // Also hide parameters panel if user can not edit parameters $perms = $this->_getItemPerms($item); if (!$perms['canparams']) { $document->addStyleDeclaration('#details-options {display:none;}'); } // ****************** // Create the toolbar // ****************** $toolbar = JToolBar::getInstance('toolbar'); $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; // SET toolbar title if ($cid) { JToolBarHelper::title(JText::_('FLEXI_EDIT_ITEM'), 'itemedit'); // Editing existing item } else { JToolBarHelper::title(JText::_('FLEXI_NEW_ITEM'), 'itemadd'); // Creating new item } // ************** // Common Buttons // ************** // Applying new item type is a special case that has not loaded custom fieds yet JToolBarHelper::apply($item->type_id ? 'items.apply' : 'items.apply_type', !$isnew ? 'FLEXI_APPLY' : ($typesselected->id ? 'FLEXI_ADD' : 'FLEXI_APPLY_TYPE'), false); /*if (!$isnew || $item->version) flexicontent_html::addToolBarButton( 'FLEXI_FAST_APPLY', $btn_name='apply_ajax', $full_js="Joomla.submitbutton('items.apply_ajax')", $msg_alert='', $msg_confirm='', $btn_task='items.apply_ajax', $extra_js='', $btn_list=false, $btn_menu=true, $btn_confirm=false, $btn_class="".$tip_class, $btn_icon="icon-loop", 'data-placement="bottom" title="Fast saving, without reloading the form. <br/><br/>Note: new files will not be uploaded, <br/>- in such a case please use \'Apply\'"');*/ if (!$isnew || $item->version) { JToolBarHelper::save('items.save'); } if (!$isnew || $item->version) { JToolBarHelper::custom('items.saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); } JToolBarHelper::cancel('items.cancel'); // *********************** // Add a preview button(s) // *********************** //$_sh404sef = JPluginHelper::isEnabled('system', 'sh404sef') && $config->get('sef'); $_sh404sef = defined('SH404SEF_IS_RUNNING') && $config->get('sef'); if ($cid) { // Domain URL and autologin vars $server = JURI::getInstance()->toString(array('scheme', 'host', 'port')); $autologin = ''; //$params->get('autoflogin', 1) ? '&fcu='.$user->username . '&fcp='.$user->password : ''; // Check if we are in the backend, in the back end we need to set the application to the site app instead // we do not remove 'isAdmin' check so that we can copy later without change, e.g. to a plugin $isAdmin = JFactory::getApplication()->isAdmin(); if ($isAdmin && !$_sh404sef) { JFactory::$application = JApplication::getInstance('site'); } // Create the URL $item_url = FlexicontentHelperRoute::getItemRoute($item->id . ':' . $item->alias, $categories[$item->catid]->slug) . ($item->language != '*' ? '&lang=' . substr($item->language, 0, 2) : ''); $item_url = $_sh404sef ? Sh404sefHelperGeneral::getSefFromNonSef($item_url, $fullyQualified = true, $xhtml = false, $ssl = null) : JRoute::_($item_url); // Check if we are in the backend again // In backend we need to remove administrator from URL as it is added even though we've set the application to the site app if ($isAdmin && !$_sh404sef) { $admin_folder = str_replace(JURI::root(true), '', JURI::base(true)); $item_url = str_replace($admin_folder . '/', '/', $item_url); // Restore application JFactory::$application = JApplication::getInstance('administrator'); } $previewlink = $item_url . (strstr($item_url, '?') ? '&' : '?') . 'preview=1' . $autologin; //$previewlink = str_replace('&', '&', $previewlink); //$previewlink = JRoute::_(JURI::root() . FlexicontentHelperRoute::getItemRoute($item->id.':'.$item->alias, $categories[$item->catid]->slug)) .$autologin; // PREVIEW for latest version if (!$params->get('use_versioning', 1) || $item->version == $item->current_version && $item->version == $item->last_version) { $toolbar->appendButton('Custom', '<button class="preview btn btn-small btn-info spaced-btn" onClick="window.open(\'' . $previewlink . '\');"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('Preview') . '</button>', 'preview'); } else { // Add a preview button for (currently) LOADED version of the item $previewlink_loaded_ver = $previewlink . '&version=' . $item->version; $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_loaded_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_FORM_LOADED_VERSION') . ' [' . $item->version . ']</button>', 'preview'); // Add a preview button for currently ACTIVE version of the item $previewlink_active_ver = $previewlink . '&version=' . $item->current_version; $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_active_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_FRONTEND_ACTIVE_VERSION') . ' [' . $item->current_version . ']</button>', 'preview'); // Add a preview button for currently LATEST version of the item $previewlink_last_ver = $previewlink; //'&version='.$item->last_version; $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_last_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_LATEST_SAVED_VERSION') . ' [' . $item->last_version . ']</button>', 'preview'); } JToolBarHelper::spacer(); JToolBarHelper::divider(); JToolBarHelper::spacer(); } // ************************ // Add modal layout editing // ************************ if ($perms['cantemplates']) { JToolBarHelper::divider(); if (!$isnew || $item->version) { flexicontent_html::addToolBarButton('FLEXI_EDIT_LAYOUT', $btn_name = 'apply_ajax', $full_js = "var url = jQuery(this).attr('data-href'); fc_showDialog(url, 'fc_modal_popup_container'); return false;", $msg_alert = '', $msg_confirm = '', $btn_task = 'items.apply_ajax', $extra_js = '', $btn_list = false, $btn_menu = true, $btn_confirm = false, $btn_class = "btn-info" . $tip_class, $btn_icon = "icon-pencil", 'data-placement="bottom" data-href="index.php?option=com_flexicontent&view=template&type=items&tmpl=component&ismodal=1&folder=' . $item->itemparams->get('ilayout', $tparams->get('ilayout', 'default')) . '" title="Edit the display layout of this item. <br/><br/>Note: this layout maybe assigned to content types or other items, thus changing it will effect them too"'); } } // Check if saving an item that translates an original content in site's default language $site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2); $is_content_default_lang = $site_default == substr($item->language, 0, 2); // ***************************************************************************** // Get (CORE & CUSTOM) fields and their VERSIONED values and then // (a) Apply Content Type Customization to CORE fields (label, description, etc) // (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField' // ***************************************************************************** if ($print_logging_info) { $start_microtime = microtime(true); } $fields = $this->get('Extrafields'); $item->fields =& $fields; if ($print_logging_info) { $fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } if ($print_logging_info) { $start_microtime = microtime(true); } $jcustom = $app->getUserState('com_flexicontent.edit.item.custom'); //print_r($jcustom); foreach ($fields as $field) { // a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description // NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations if ($field->iscore) { FlexicontentFields::loadFieldConfig($field, $item); } // b. Create field 's editing HTML (the form field) // NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow) if (!$field->iscore) { if (isset($jcustom[$field->name])) { $field->value = array(); foreach ($jcustom[$field->name] as $i => $_val) { $field->value[$i] = $_val; } } $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id); if ($is_editable) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item)); if ($field->untranslatable) { $field->html = (!isset($field->html) ? '<div class="fc-mssg-inline fc-warning" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_PLEASE_PUBLISH_THIS_PLUGIN') . '</div><div class="clear"></div>' : '') . '<div class="alert alert-info fc-small fc-iblock" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_FIELD_VALUE_IS_NON_TRANSLATABLE') . '</div>' . "\n" . (isset($field->html) ? '<div class="clear"></div>' . $field->html : ''); } } else { if ($field->valueseditable == 1) { $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>'; } else { if ($field->valueseditable == 2) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>' . "\n" . $field->display; } else { if ($field->valueseditable == 3) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = $field->display; } else { if ($field->valueseditable == 4) { $field->html = ''; $field->formhidden = 4; } } } } } } // c. Create main text field, via calling the display function of the textarea field (will also check for tabs) if ($field->field_type == 'maintext') { if (isset($item->item_translations)) { $shortcode = substr($item->language, 0, 2); foreach ($item->item_translations as $lang_id => $t) { if ($shortcode == $t->shortcode) { continue; } $field->name = array('jfdata', $t->shortcode, 'text'); $field->value[0] = html_entity_decode($t->fields->text->value, ENT_QUOTES, 'UTF-8'); FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); $t->fields->text->tab_labels = $field->tab_labels; $t->fields->text->html = $field->html; unset($field->tab_labels); unset($field->html); } } $field->name = 'text'; // NOTE: We use the text created by the model and not the text retrieved by the CORE plugin code, which maybe overwritten with JoomFish/Falang data $field->value[0] = $item->text; // do not decode special characters this was handled during saving ! // Render the field's (form) HTML FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); } } if ($print_logging_info) { $fc_run_times['render_field_html'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // ************************* // Get tags used by the item // ************************* $usedtagsIds = $this->get('UsedtagsIds'); // NOTE: This will normally return the already set versioned value of tags ($item->tags) $usedtags = $model->getUsedtagsData($usedtagsIds); // ******************************* // Get categories used by the item // ******************************* if ($isnew) { // Case for preselected main category for new items $maincat = $item->catid ? $item->catid : JRequest::getInt('maincat', 0); if (!$maincat) { $maincat = $app->getUserStateFromRequest($option . '.items.filter_cats', 'filter_cats', '', 'int'); } if ($maincat) { $selectedcats = array($maincat); $item->catid = $maincat; } else { $selectedcats = array(); } if ($tparams->get('cid_default')) { $selectedcats = $tparams->get('cid_default'); } if ($tparams->get('catid_default')) { $item->catid = $tparams->get('catid_default'); } } else { // NOTE: This will normally return the already set versioned value of categories ($item->categories) $selectedcats = $this->get('Catsselected'); } //$selectedcats = $isnew ? array() : $fields['categories']->value; //echo "<br/>row->tags: "; print_r($item->tags); //echo "<br/>usedtagsIds: "; print_r($usedtagsIds); //echo "<br/>usedtags (data): "; print_r($usedtags); //echo "<br/>row->categories: "; print_r($item->categories); //echo "<br/>selectedcats: "; print_r($selectedcats); // ********************************************************************************************* // Build select lists for the form field. Only few of them are used in J1.6+, since we will use: // (a) form XML file to declare them and then (b) getInput() method form field to create them // ********************************************************************************************* // First clean form data, we do this after creating the description field which may contain HTML JFilterOutput::objectHTMLSafe($item, ENT_QUOTES); $lists = array(); // build state list $non_publishers_stategrp = $perms['isSuperAdmin'] || $item->state == -3 || $item->state == -4; $special_privelege_stategrp = $item->state == 2 || $perms['canarchive'] || ($item->state == -2 || $perms['candelete']); $state = array(); // Using <select> groups if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_PUBLISHERS_WORKFLOW_STATES')); } $state[] = JHTML::_('select.option', 1, JText::_('FLEXI_PUBLISHED')); $state[] = JHTML::_('select.option', 0, JText::_('FLEXI_UNPUBLISHED')); $state[] = JHTML::_('select.option', -5, JText::_('FLEXI_IN_PROGRESS')); // States reserved for workflow if ($non_publishers_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_NON_PUBLISHERS_WORKFLOW_STATES')); } if ($item->state == -3 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -3, JText::_('FLEXI_PENDING')); } if ($item->state == -4 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -4, JText::_('FLEXI_TO_WRITE')); } // Special access states if ($special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_SPECIAL_ACTION_STATES')); } if ($item->state == 2 || $perms['canarchive']) { $state[] = JHTML::_('select.option', 2, JText::_('FLEXI_ARCHIVED')); } if ($item->state == -2 || $perms['candelete']) { $state[] = JHTML::_('select.option', -2, JText::_('FLEXI_TRASHED')); } // Close last <select> group if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); } $fieldname = 'jform[state]'; $elementid = 'jform_state'; $class = 'use_select2_lib'; $attribs = 'class="' . $class . '"'; $lists['state'] = JHTML::_('select.genericlist', $state, $fieldname, $attribs, 'value', 'text', $item->state, $elementid); if (!FLEXI_J16GE) { $lists['state'] = str_replace('<optgroup label="">', '</optgroup>', $lists['state']); } // *** BOF: J2.5 SPECIFIC SELECT LISTS if (FLEXI_J16GE) { // build featured flag $fieldname = 'jform[featured]'; $elementid = 'jform_featured'; /* $options = array(); $options[] = JHTML::_('select.option', 0, JText::_( 'FLEXI_NO' ) ); $options[] = JHTML::_('select.option', 1, JText::_( 'FLEXI_YES' ) ); $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['featured'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', $item->featured, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array(0 => JText::_('FLEXI_NO'), 1 => JText::_('FLEXI_YES')); $lists['featured'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id == $item->featured ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['featured'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['featured'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['featured'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } } // *** EOF: J1.5 SPECIFIC SELECT LISTS // build version approval list $fieldname = 'jform[vstate]'; $elementid = 'jform_vstate'; /* $options = array(); $options[] = JHTML::_('select.option', 1, JText::_( 'FLEXI_NO' ) ); $options[] = JHTML::_('select.option', 2, JText::_( 'FLEXI_YES' ) ); $attribs = FLEXI_J16GE ? ' style ="float:left!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['vstate'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', 2, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array(1 => JText::_('FLEXI_NO'), 2 => JText::_('FLEXI_YES')); $lists['vstate'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id == 2 ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['vstate'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['vstate'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['vstate'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } // build field for notifying subscribers if (!$subscribers) { $lists['notify'] = !$isnew ? JText::_('FLEXI_NO_SUBSCRIBERS_EXIST') : ''; } else { // b. Check if notification emails to subscribers , were already sent during current session $subscribers_notified = $session->get('subscribers_notified', array(), 'flexicontent'); if (!empty($subscribers_notified[$item->id])) { $lists['notify'] = JText::_('FLEXI_SUBSCRIBERS_ALREADY_NOTIFIED'); } else { // build favs notify field $fieldname = 'jform[notify]'; $elementid = 'jform_notify'; /* $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['notify'] = '<input type="checkbox" name="jform[notify]" id="jform_notify" '.$attribs.' /> '. $lbltxt; */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $lbltxt = $subscribers . ' ' . JText::_($subscribers > 1 ? 'FLEXI_SUBSCRIBERS' : 'FLEXI_SUBSCRIBER'); if (!$prettycheckable_added) { $lists['notify'] .= '<label class="fccheckradio_lbl" for="' . $elementid . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . $lbltxt . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['notify'] = ' <input type="checkbox" id="' . $elementid . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="1" ' . $extra_params . ' checked="checked" />'; if (!$prettycheckable_added) { $lists['notify'] .= ' ' . $lbltxt . '</label>'; } } } // Retrieve author configuration $authorparams = flexicontent_db::getUserConfig($user->id); // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; '); JText::script('FLEXI_TOO_MANY_ITEM_CATEGORIES', true); // Creating categorories tree for item assignment, we use the 'create' privelege $actions_allowed = array('core.create'); // Featured categories form field $featured_cats_parent = $params->get('featured_cats_parent', 0); $featured_cats = array(); $enable_featured_cid_selector = $perms['multicat'] && $perms['canchange_featcat']; if ($featured_cats_parent) { $featured_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $featured_cats_parent, $depth_limit = 0); $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array(); $featured_sel = array(); foreach ($selectedcats as $item_cat) { if (isset($featured_tree[$item_cat])) { $featured_sel[] = $item_cat; } } $class = "use_select2_lib select2_list_selected"; $attribs = 'class="' . $class . '" multiple="multiple" size="8"'; $attribs .= $enable_featured_cid_selector ? '' : ' disabled="disabled"'; $fieldname = 'jform[featured_cid][]'; $lists['featured_cid'] = ($enable_featured_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($featured_tree, $fieldname, $featured_sel, 3, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { // Do not display, if not configured or not allowed to the user $lists['featured_cid'] = false; } // Multi-category form field, for user allowed to use multiple categories $lists['cid'] = ''; $enable_cid_selector = $perms['multicat'] && $perms['canchange_seccat']; if (1) { if ($tparams->get('cid_allowed_parent')) { $cid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('cid_allowed_parent'), $depth_limit = 0); $disabled_cats = $tparams->get('cid_allowed_parent_disable', 1) ? array($tparams->get('cid_allowed_parent')) : array(); } else { $cid_tree =& $categories; $disabled_cats = array(); } // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = !$authorparams ? 0 : intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; '); $class = "mcat use_select2_lib select2_list_selected"; $class .= $max_cat_assign ? " validate-fccats" : " validate"; $attribs = 'class="' . $class . '" multiple="multiple" size="20"'; $attribs .= $enable_cid_selector ? '' : ' disabled="disabled"'; $fieldname = 'jform[cid][]'; $skip_subtrees = $featured_cats_parent ? array($featured_cats_parent) : array(); $lists['cid'] = ($enable_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($cid_tree, $fieldname, $selectedcats, false, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees, $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { if (count($selectedcats) > 1) { foreach ($selectedcats as $catid) { $cat_titles[$catid] = $globalcats[$catid]->title; } $lists['cid'] .= implode(', ', $cat_titles); } else { $lists['cid'] = false; } } // Main category form field $class = 'scat use_select2_lib'; if ($perms['multicat']) { $class .= ' validate-catid'; } else { $class .= ' required'; } $attribs = 'class="' . $class . '"'; $fieldname = 'jform[catid]'; $enable_catid_selector = $isnew && !$tparams->get('catid_default') || !$isnew && empty($item->catid) || $perms['canchange_cat']; if ($tparams->get('catid_allowed_parent')) { $catid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('catid_allowed_parent'), $depth_limit = 0); $disabled_cats = $tparams->get('catid_allowed_parent_disable', 1) ? array($tparams->get('catid_allowed_parent')) : array(); } else { $catid_tree =& $categories; $disabled_cats = array(); } $lists['catid'] = false; if (!empty($catid_tree)) { $disabled = $enable_catid_selector ? '' : ' disabled="disabled"'; $attribs .= $disabled; $lists['catid'] = ($enable_catid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($catid_tree, $fieldname, $item->catid, 2, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { if (!$isnew && $item->catid) { $lists['catid'] = $globalcats[$item->catid]->title; } } //buid types selectlist $class = 'required use_select2_lib'; $attribs = 'class="' . $class . '"'; $fieldname = 'jform[type_id]'; $elementid = 'jform_type_id'; $lists['type'] = flexicontent_html::buildtypesselect($types, $fieldname, $typesselected->id, 1, $attribs, $elementid, $check_perms = true); //build languages list $allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed', null); $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs); if (!$isnew && $allowed_langs) { $allowed_langs[] = $item->language; } // We will not use the default getInput() function of J1.6+ since we want to create a radio selection field with flags // we could also create a new class and override getInput() method but maybe this is an overkill, we may do it in the future $lists['languages'] = flexicontent_html::buildlanguageslist('jform[language]', 'class="use_select2_lib"', $item->language, 2, $allowed_langs); // Label for current item state: published, unpublished, archived etc switch ($item->state) { case 0: $published = JText::_('FLEXI_UNPUBLISHED'); break; case 1: $published = JText::_('FLEXI_PUBLISHED'); break; case -1: $published = JText::_('FLEXI_ARCHIVED'); break; case -3: $published = JText::_('FLEXI_PENDING'); break; case -5: $published = JText::_('FLEXI_IN_PROGRESS'); break; case -4: default: $published = JText::_('FLEXI_TO_WRITE'); break; } // ************************************************************** // Handle Item Parameters Creation and Load their values for J1.5 // In J1.6+ we declare them in the item form XML file // ************************************************************** if (JHTML::_('date', $item->publish_down, 'Y') <= 1969 || $item->publish_down == $db->getNullDate() || empty($item->publish_down)) { $form->setValue('publish_down', null, ''); // Setting to text will break form date element } // **************************** // Handle Template related work // **************************** // (a) Get the templates structures used to create form fields for template parameters $themes = flexicontent_tmpl::getTemplates(); $tmpls_all = $themes->items; // (b) Get Content Type allowed templates $allowed_tmpls = $tparams->get('allowed_ilayouts'); $type_default_layout = $tparams->get('ilayout', 'default'); if (empty($allowed_tmpls)) { $allowed_tmpls = array(); } else { if (!is_array($allowed_tmpls)) { $allowed_tmpls = explode("|", $allowed_tmpls); } } // (c) Add default layout, unless all templates allowed (=array is empty) if (count($allowed_tmpls) && !in_array($type_default_layout, $allowed_tmpls)) { $allowed_tmpls[] = $type_default_layout; } // (d) Create array of template data according to the allowed templates for current content type if (count($allowed_tmpls)) { foreach ($tmpls_all as $tmpl) { if (in_array($tmpl->name, $allowed_tmpls)) { $tmpls[] = $tmpl; } } } else { $tmpls = $tmpls_all; } // (e) Apply Template Parameters values into the form fields structures foreach ($tmpls as $tmpl) { $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; foreach ($tmpl->params->getGroup('attribs') as $field) { $fieldname = $field->__get('fieldname'); $value = $item->itemparams->get($fieldname); if (strlen($value)) { $tmpl->params->setValue($fieldname, 'attribs', $value); } } } // ****************************** // Assign data to VIEW's template // ****************************** $this->assignRef('document', $document); $this->assignRef('lists', $lists); $this->assignRef('row', $item); if (FLEXI_J16GE) { $this->assignRef('form', $form); } else { $this->assignRef('editor', $editor); $this->assignRef('pane', $pane); $this->assignRef('formparams', $formparams); } if ($enable_translation_groups) { $this->assignRef('lang_assocs', $langAssocs); } if (FLEXI_FISH || FLEXI_J16GE) { $this->assignRef('langs', $langs); } $this->assignRef('typesselected', $typesselected); $this->assignRef('published', $published); $this->assignRef('nullDate', $nullDate); $this->assignRef('subscribers', $subscribers); $this->assignRef('fields', $fields); $this->assignRef('versions', $versions); $this->assignRef('ratings', $ratings); $this->assignRef('pagecount', $pagecount); $this->assignRef('params', $params); $this->assignRef('tparams', $tparams); $this->assignRef('tmpls', $tmpls); $this->assignRef('usedtags', $usedtags); $this->assignRef('perms', $perms); $this->assignRef('current_page', $current_page); // Clear custom form data from session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', false); $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', false); $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', false); if ($print_logging_info) { $start_microtime = microtime(true); } parent::display($tpl); if ($print_logging_info) { $fc_run_times['form_rendering'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } }
public static function getItems(&$params, $ordering) { global $dump, $globalcats; global $modfc_jprof, $mod_fc_run_times; $app = JFactory::getApplication(); // For specific cache issues if (empty($globalcats)) { if (FLEXI_SECTION || FLEXI_CAT_EXTENSION) { JPluginHelper::importPlugin('system', 'flexisystem'); if (FLEXI_CACHE) { // add the category tree to categories cache $catscache = JFactory::getCache('com_flexicontent_cats'); $catscache->setCaching(1); //force cache $catscache->setLifeTime(84600); //set expiry to one day $globalcats = $catscache->call(array('plgSystemFlexisystem', 'getCategoriesTree')); } else { $globalcats = plgSystemFlexisystem::getCategoriesTree(); } } } // Initialize variables $db = JFactory::getDBO(); $user = JFactory::getUser(); $view = JRequest::getVar('view'); $option = JRequest::getVar('option'); $fparams = $app->getParams('com_flexicontent'); $show_noauth = $fparams->get('show_noauth', 0); // Date-Times are stored as UTC, we should use current UTC time to compare and not user time (requestTime), // thus the items are published globally at the time the author specified in his/her local clock //$now = $app->get('requestTime'); $now = JFactory::getDate()->toSql(); $nullDate = $db->getNullDate(); // $display_category_data $apply_config_per_category = (int) $params->get('apply_config_per_category', 0); // *** METHODS that their 'ALL' value is 0, (these do not use current item information) // current item scope parameters $method_curitem = (int) $params->get('method_curitem', 0); // current language scope parameters $method_curlang = (int) $params->get('method_curlang', 0); // current item scope parameters $method_curuserfavs = (int) $params->get('method_curuserfavs', 0); // featured items scope parameters $method_featured = (int) $params->get('method_featured', 0); // featured items scope parameters $method_states = (int) $params->get('method_states', 0); $item_states = $params->get('item_states'); $show_nocontent_msg = (int) $params->get('show_nocontent_msg', 1); // *** METHODS that their 'ALL' value is 1, that also have behaviour variable (most of them) // categories scope parameters $method_cat = (int) $params->get('method_cat', 1); $catids = $params->get('catids', array()); $behaviour_cat = $params->get('behaviour_cat', 0); $treeinclude = $params->get('treeinclude'); // types scope parameters $method_types = (int) $params->get('method_types', 1); $types = $params->get('types'); $behaviour_types = $params->get('behaviour_types', 0); // authors scope parameters $method_auth = (int) $params->get('method_auth', 1); $authors = trim($params->get('authors')); $behaviour_auth = $params->get('behaviour_auth'); // items scope parameters $method_items = (int) $params->get('method_items', 1); $items = trim($params->get('items')); $behaviour_items = $params->get('behaviour_items', 0); $excluded_tags = $params->get('excluded_tags', array()); $excluded_tags = !is_array($excluded_tags) ? array($excluded_tags) : $excluded_tags; $relitems_fields = $params->get('relitems_fields', array()); $relitems_fields = !is_array($relitems_fields) ? array($relitems_fields) : $relitems_fields; // tags scope parameters $method_tags = (int) $params->get('method_tags', 1); $tag_ids = $params->get('tag_ids', array()); $tag_combine = $params->get('tag_combine', 0); // date scope parameters $method_dates = (int) $params->get('method_dates', 1); // parameter added later, maybe not to break compatibility this should be INCLUDE=3 by default ? $date_type = (int) $params->get('date_type', 0); $nulldates = (int) $params->get('nulldates', 0); $bdate = $params->get('bdate', ''); $edate = $params->get('edate', ''); $raw_bdate = $params->get('raw_bdate', 0); $raw_edate = $params->get('raw_edate', 0); $behaviour_dates = $params->get('behaviour_dates', 0); $date_compare = $params->get('date_compare', 0); $datecomp_field = (int) $params->get('datecomp_field', 0); // Server date $sdate = explode(' ', $now); $cdate = $sdate[0] . ' 00:00:00'; // Set date comparators if ($date_type == 0) { // created $comp = 'i.created'; } else { if ($date_type == 1) { // modified $comp = 'i.modified'; } else { if ($date_type == 2) { // publish up $comp = 'i.publish_up'; } else { if ($date_type == 4) { // publish down $comp = 'i.publish_down'; } else { // $date_type == 3 $comp = 'dfrel.value'; } } } } // custom field scope $method_filt = (int) $params->get('method_filt', 1); // parameter added later, maybe not to break compatibility this should be INCLUDE=3 by default ? $behaviour_filt = (int) $params->get('behaviour_filt', 0); $static_filters = $params->get('static_filters', ''); $dynamic_filters = $params->get('dynamic_filters', ''); // get module fetching parameters if ($params->get('skip_items', 0)) { $count = (int) $params->get('maxskipcount', 50); } else { $count = (int) $params->get('count', 5); } // get module display parameters $mod_image = $params->get('mod_image'); // ************************************************************************************ // filter by publication state, (except for item state which is a special scope, below) // ************************************************************************************ $where = ' WHERE c.published = 1'; $where .= FLEXI_J16GE ? '' : ' AND i.sectionid = ' . FLEXI_SECTION; $ignore_up_down_dates = $params->get('ignore_up_down_dates', 0); // 1: ignore publish_up, 2: ignore publish_donw, 3: ignore both $ignoreState = $params->get('use_list_items_in_any_state_acl', 0) && $user->authorise('flexicontent.ignoreviewstate', 'com_flexicontent'); if (!$ignoreState && $ignore_up_down_dates != 3 && $ignore_up_down_dates != 1) { $where .= ' AND ( i.publish_up = ' . $db->Quote($nullDate) . ' OR i.publish_up <= ' . $db->Quote($now) . ' )'; } if (!$ignoreState && $ignore_up_down_dates != 3 && $ignore_up_down_dates != 2) { $where .= ' AND ( i.publish_down = ' . $db->Quote($nullDate) . ' OR i.publish_down >= ' . $db->Quote($now) . ' )'; } // ********************* // filter by permissions // ********************* $joinaccess = ''; if (!$show_noauth) { $aid_arr = JAccess::getAuthorisedViewLevels($user->id); $aid_list = implode(",", $aid_arr); $where .= ' AND ty.access IN (0,' . $aid_list . ')'; $where .= ' AND mc.access IN (0,' . $aid_list . ')'; $where .= ' AND i.access IN (0,' . $aid_list . ')'; } // ******************************************************* // NON-STATIC behaviors that need current item information // ******************************************************* $isflexi_itemview = $option == 'com_flexicontent' && $view == FLEXI_ITEMVIEW && JRequest::getInt('id'); $isflexi_catview = $option == 'com_flexicontent' && $view == 'category' && (JRequest::getInt('cid') || JRequest::getVar('cids')); $curritem_date_field_needed = $behaviour_dates && $date_compare && $date_type == 3 && $datecomp_field; // Date field selected if (($behaviour_cat || $behaviour_types || $behaviour_auth || $behaviour_items || $curritem_date_field_needed || $behaviour_filt) && $isflexi_itemview) { // initialize variables $cid = JRequest::getInt('cid'); $id = JRequest::getInt('id'); $Itemid = JRequest::getInt('Itemid'); // Check for new item nothing to retrieve, // NOTE: aborting execution if current view is not item view, but item view is required // and also proper usage of current item, both of these will be handled by SCOPEs $sel_date = ''; $join_date = ''; if ($curritem_date_field_needed) { $sel_date = ', dfrel.value as custom_date'; $join_date = ' LEFT JOIN #__flexicontent_fields_item_relations AS dfrel' . ' ON ( i.id = dfrel.item_id AND dfrel.valueorder = 1 AND dfrel.field_id = ' . $datecomp_field . ' )'; } if ($id) { $query = 'SELECT i.*, ie.*, GROUP_CONCAT(ci.catid SEPARATOR ",") as itemcats' . $sel_date . ' FROM #__content as i' . ' LEFT JOIN #__flexicontent_items_ext AS ie on ie.item_id = i.id' . ' LEFT JOIN #__flexicontent_cats_item_relations AS ci on ci.itemid = i.id' . $join_date . ' WHERE i.id = ' . $id . ' GROUP BY ci.itemid'; $db->setQuery($query); $curitem = $db->loadObject(); // Get item dates $idate = null; if ($date_type == 0) { // created $idate = $curitem->created; } else { if ($date_type == 1) { // modified $idate = $curitem->modified; } else { if ($date_type == 2) { // publish up $idate = $curitem->publish_up; } else { if (isset($curitem->custom_date)) { // $date_type == 3 $idate = $curitem->custom_date; } } } } if ($idate) { $idate = explode(' ', $idate); $cdate = $idate[0] . ' 00:00:00'; } $curritemcats = explode(',', $curitem->itemcats); } } // ****************** // current item scope // ****************** $currid = JRequest::getInt('id'); if ($method_curitem == 1) { // exclude method --- exclude current item $where .= ' AND i.id <> ' . $currid; } else { if ($method_curitem == 2) { // include method --- include current item ONLY $where .= ' AND i.id = ' . $currid; } else { // All Items including current } } // ********************** // current language scope // ********************** $lang = flexicontent_html::getUserCurrentLang(); if ($method_curlang == 1) { // exclude method --- exclude items of current language $where .= ' AND ie.language NOT LIKE ' . $db->Quote($lang . '%'); } else { if ($method_curlang == 2) { // include method --- include items of current language ONLY $where .= ' AND ( ie.language LIKE ' . $db->Quote($lang . '%') . (FLEXI_J16GE ? ' OR ie.language="*" ' : '') . ' ) '; } else { // Items of any language } } // ***************************** // current user favourites scope // ***************************** $curruserid = (int) $user->get('id'); if ($method_curuserfavs == 1) { // exclude method --- exclude currently logged user favourites $join_favs = ' LEFT OUTER JOIN #__flexicontent_favourites AS fav ON fav.itemid = i.id AND fav.userid = ' . $curruserid; $where .= ' AND fav.itemid IS NULL'; } else { if ($method_curuserfavs == 2) { // include method --- include currently logged user favourites $join_favs = ' LEFT JOIN #__flexicontent_favourites AS fav ON fav.itemid = i.id'; $where .= ' AND fav.userid = ' . $curruserid; } else { // All Items regardless of being favoured by current user $join_favs = ''; } } // ****************************** // joomla featured property scope // ****************************** if ($method_featured == 1) { // exclude method --- exclude currently logged user favourites $where .= ' AND i.featured=0'; } else { if ($method_featured == 2) { // include method --- include currently logged user favourites $where .= ' AND i.featured=1'; } else { // All Items regardless of being featured or not } } // ***************** // item states scope // ***************** $item_states = is_array($item_states) ? implode(',', $item_states) : $item_states; if ($method_states == 0) { if (!$ignoreState) { // method normal: Published item states $where .= ' AND i.state IN ( 1, -5 )'; } } else { // exclude trashed $where .= ' AND i.state <> -2'; if ($item_states) { if ($method_states == 1) { // exclude method --- exclude specified item states $where .= ' AND i.state NOT IN (' . $item_states . ')'; } else { if ($method_states == 2) { // include method --- include specified item states $where .= ' AND i.state IN (' . $item_states . ')'; } } } else { if ($method_states == 2) { // misconfiguration, when using include method with no state selected ... echo "<b>WARNING:</b> Misconfigured item states scope, select at least one state or set states scope to Normal <small>(Published)</small><br/>"; return; } } } // **************** // categories scope // **************** // ZERO 'behaviour' means statically selected records, but METHOD 1 is ALL records ... so NOTHING to do if (!$behaviour_cat && $method_cat == 1) { if ($apply_config_per_category) { echo "<b>WARNING:</b> Misconfiguration warning, APPLY CONFIGURATION PER CATEGORY is possible only if CATEGORY SCOPE is set to either (a) INCLUDE(static selection of categories) or (b) items in same category as current item / or current category of category view<br/>"; return; } } else { if (!$behaviour_cat) { // Check for empty statically selected records, and abort with error message if (empty($catids)) { echo "<b>WARNING:</b> Misconfigured category scope, select at least one category or set category scope to ALL<br/>"; return; } // Make sure categories is an array $catids = is_array($catids) ? $catids : array($catids); // Retrieve extra categories, such children or parent categories $catids_arr = flexicontent_cats::getExtraCats($catids, $treeinclude, array()); if (empty($catids_arr)) { if ($show_nocontent_msg) { echo JText::_("No viewable content in Current View for your Access Level"); } return; } if ($method_cat == 2) { // exclude method if ($apply_config_per_category) { echo "<b>WARNING:</b> Misconfiguration warning, APPLY CONFIGURATION PER CATEGORY is possible only if CATEGORY SCOPE is set to either (a) INCLUDE(static selection of categories) or (b) items in same category as current item / or current category of category view<br/>"; return; } $where .= ' AND c.id NOT IN (' . implode(',', $catids_arr) . ')'; } else { if ($method_cat == 3) { // include method if (!$apply_config_per_category) { $where .= ' AND c.id IN (' . implode(',', $catids_arr) . ')'; } else { // *** Applying configuration per category *** foreach ($catids_arr as $catid) { // The items retrieval query will be executed ... once per EVERY category $multiquery_cats[$catid] = ' AND c.id = ' . $catid; } $params->set('dynamic_catids', serialize($catids_arr)); // Set dynamic catids to be used by the getCategoryData } } } } else { if (($behaviour_cat == 2 || $behaviour_cat == 4) && $apply_config_per_category) { echo "<b>WARNING:</b> Misconfiguration warning, APPLY CONFIGURATION PER CATEGORY is possible only if CATEGORY SCOPE is set to either (a) INCLUDE(static selection of categories) or (b) items in same category as current item / or current category of category view<br/>"; return; } $currcat_valid_case = $behaviour_cat == 1 && $isflexi_itemview || $behaviour_cat == 3 && $isflexi_catview; if (!$currcat_valid_case) { return; // current view is not item OR category view ... , nothing to display } // IF $cid is not set then use the main category id of the (current) item if ($isflexi_itemview) { $cid = $cid ? $cid : $curitem->catid; // Retrieve extra categories, such children or parent categories $catids_arr = flexicontent_cats::getExtraCats(array($cid), $treeinclude, $curritemcats); } else { if ($isflexi_catview) { $cid = JRequest::getInt('cid', 0); if (!$cid) { $_cids = JRequest::getVar('cids', ''); if (!is_array($_cids)) { $_cids = preg_replace('/[^0-9,]/i', '', (string) $_cids); $_cids = explode(',', $_cids); } // make sure given data are integers ... !! $cids = array(); foreach ($_cids as $i => $_id) { if ((int) $_id) { $cids[] = (int) $_id; } } // Retrieve extra categories, such children or parent categories $catids_arr = flexicontent_cats::getExtraCats(array($cid), $treeinclude, array()); } } else { return; // nothing to display } } // Retrieve extra categories, such children or parent categories $catids_arr = flexicontent_cats::getExtraCats(array($cid), $treeinclude, $isflexi_itemview ? $curritemcats : array()); if (empty($catids_arr)) { if ($show_nocontent_msg) { echo JText::_("No viewable content in Current View for your Access Level"); } return; } if ($behaviour_cat == 1 || $behaviour_cat == 3) { if (!$apply_config_per_category) { $where .= ' AND c.id IN (' . implode(',', $catids_arr) . ')'; } else { // *** Applying configuration per category *** foreach ($catids_arr as $catid) { // The items retrieval query will be executed ... once per EVERY category $multiquery_cats[$catid] = ' AND c.id = ' . $catid; } $params->set('dynamic_catids', serialize($catids_arr)); // Set dynamic catids to be used by the getCategoryData } } else { $where .= ' AND c.id NOT IN (' . implode(',', $catids_arr) . ')'; } } } // Now check if no items need to be retrieved if ($count == 0) { return; } // *********** // types scope // *********** // ZERO 'behaviour' means statically selected records, but METHOD 1 is ALL records ... so NOTHING to do if (!$behaviour_types && $method_types == 1) { } else { if (!$behaviour_types) { // Check for empty statically selected records, and abort with error message if (empty($types)) { echo "<b>WARNING:</b> Misconfigured types scope, select at least one item type or set types scope to ALL<br/>"; return; } // Make types a comma separated string of ids $types = is_array($types) ? implode(',', $types) : $types; if ($method_types == 2) { // exclude method $where .= ' AND ie.type_id NOT IN (' . $types . ')'; } else { if ($method_types == 3) { // include method $where .= ' AND ie.type_id IN (' . $types . ')'; } } } else { if (!$isflexi_itemview) { return; // current view is not item view ... , nothing to display } if ($behaviour_types == 1) { $where .= ' AND ie.type_id = ' . (int) $curitem->type_id; } else { $where .= ' AND ie.type_id <> ' . (int) $curitem->type_id; } } } // ************ // author scope // ************ // ZERO 'behaviour' means statically selected records, but METHOD 1 is ALL records ... so NOTHING to do if (!$behaviour_auth && $method_auth == 1) { } else { if (!$behaviour_auth) { // Check for empty statically selected records, and abort with error message if (empty($authors)) { echo "<b>WARNING:</b> Misconfigured author scope, select at least one author or set author scope to ALL<br/>"; return; } if ($method_auth == 2) { // exclude method $where .= ' AND i.created_by NOT IN (' . $authors . ')'; } else { if ($method_auth == 3) { // include method $where .= ' AND i.created_by IN (' . $authors . ')'; } } } else { if (!$isflexi_itemview && $behaviour_auth < 3) { // Behaviour 3 is current user thus not related to current item return; // current view is not item view ... , nothing to display } if ($behaviour_auth == 1) { $where .= ' AND i.created_by = ' . (int) $curitem->created_by; } else { if ($behaviour_auth == 2) { $where .= ' AND i.created_by <> ' . (int) $curitem->created_by; } else { // $behaviour_auth == 3 $where .= ' AND i.created_by = ' . (int) $user->id; } } } } // *********** // items scope // *********** // ZERO 'behaviour' means statically selected records, but METHOD 1 is ALL records ... so NOTHING to do if (!$behaviour_items && $method_items == 1) { } else { if (!$behaviour_items) { // Check for empty statically selected records, and abort with error message if (empty($items)) { echo "<b>WARNING:</b> Misconfigured items scope, select at least one item or set items scope to ALL<br/>"; return; } if ($method_items == 2) { // exclude method $where .= ' AND i.id NOT IN (' . $items . ')'; } else { if ($method_items == 3) { // include method $where .= ' AND i.id IN (' . $items . ')'; } } } else { if ($behaviour_items == 2 || $behaviour_items == 3) { if (!$isflexi_itemview) { return; // current view is not item view ... , nothing to display } unset($related); // make sure this is no set ... if (count($relitems_fields)) { $where2 = count($relitems_fields) > 1 ? ' AND field_id IN (' . implode(',', $relitems_fields) . ')' : ' AND field_id = ' . $relitems_fields[0]; // select the item ids related to current item via the relation fields $query2 = 'SELECT DISTINCT ' . ($behaviour_items == 2 ? 'value' : 'item_id') . ' FROM #__flexicontent_fields_item_relations' . ' WHERE ' . ($behaviour_items == 2 ? 'item_id' : 'value') . ' = ' . (int) $id . $where2; $db->setQuery($query2); $related = $db->loadColumn(); $related = is_array($related) ? array_map('intval', $related) : $related; } if (isset($related) && count($related)) { $where .= count($related) > 1 ? ' AND i.id IN (' . implode(',', $related) . ')' : ' AND i.id = ' . $related[0]; } else { // No related items were found return; } } else { if ($behaviour_items == 1) { if (!$isflexi_itemview) { return; // current view is not item view ... , nothing to display } // select the tags associated to the item $query2 = 'SELECT tid' . ' FROM #__flexicontent_tags_item_relations' . ' WHERE itemid = ' . (int) $id; $db->setQuery($query2); $tags = $db->loadColumn(); $tags = array_diff($tags, $excluded_tags); unset($related); if ($tags) { $where2 = count($tags) > 1 ? ' AND tid IN (' . implode(',', $tags) . ')' : ' AND tid = ' . $tags[0]; // select the item ids related to current item via common tags $query2 = 'SELECT DISTINCT itemid' . ' FROM #__flexicontent_tags_item_relations' . ' WHERE itemid <> ' . (int) $id . $where2; $db->setQuery($query2); $related = $db->loadColumn(); } if (isset($related) && count($related)) { $where .= count($related) > 1 ? ' AND i.id IN (' . implode(',', $related) . ')' : ' AND i.id = ' . $related[0]; } else { // No related items were found return; } } } } } // ********** // tags scope // ********** if ($method_tags > 1) { // Check for empty statically selected records, and abort with error message if (empty($tag_ids)) { echo "<b>WARNING:</b> Misconfigured tags scope, select at least one tag or set tags scope to ALL<br/>"; return; } // Make sure tag_ids is an array $tag_ids = !is_array($tag_ids) ? array($tag_ids) : $tag_ids; // Create query to match item ids using the selected tags $query2 = 'SELECT ' . ($tag_combine ? 'itemid' : 'DISTINCT itemid') . ' FROM #__flexicontent_tags_item_relations' . ' WHERE tid IN (' . implode(',', $tag_ids) . ')' . ($tag_combine ? ' GROUP by itemid HAVING COUNT(*) >= ' . count($tag_ids) : ''); if ($method_tags == 2) { // exclude method $where .= ' AND i.id NOT IN (' . $query2 . ')'; } else { if ($method_tags == 3) { // include method $where .= ' AND i.id IN (' . $query2 . ')'; } } } // ********** // date scope // ********** // ZERO 'behaviour' means statically selected records, but METHOD 1 is ALL records ... so NOTHING to do // NOTE: currently we only have ALL, INCLUDE methods if (!$behaviour_dates && $method_dates == 1) { } else { if (!$behaviour_dates) { $negate_op = $method_dates == 2 ? 'NOT' : ''; if (!$raw_edate && $edate && !FLEXIUtilities::isSqlValidDate($edate)) { echo "<b>WARNING:</b> Misconfigured date scope, you have entered invalid -END- date:<br>(a) Enter a valid date via callendar OR <br>(b) leave blank OR <br>(c) choose (non-static behavior 'custom offset') and enter custom offset e.g. five days ago (be careful with space character): -5 d<br/>"; return; } else { if ($edate) { $where .= ' AND ( ' . $negate_op . ' ( ' . $comp . ' <= ' . (!$raw_edate ? $db->Quote($edate) : $edate) . ' )' . ($nulldates ? ' OR ' . $comp . ' IS NULL OR ' . $comp . '="" ' : '') . ' )'; } } if (!$raw_bdate && $bdate && !FLEXIUtilities::isSqlValidDate($bdate)) { echo "<b>WARNING:</b> Misconfigured date scope, you have entered invalid -BEGIN- date:<br>(a) Enter a valid date via callendar OR <br>(b) leave blank OR <br>(c) choose (non-static behavior 'custom offset') and enter custom offset e.g. five days ago (be careful with space character): -5 d<br/>"; return; } else { if ($bdate) { $where .= ' AND ( ' . $negate_op . ' ( ' . $comp . ' >= ' . (!$raw_bdate ? $db->Quote($bdate) : $bdate) . ' )' . ($nulldates ? ' OR ' . $comp . ' IS NULL OR ' . $comp . '="" ' : '') . ' )'; } } } else { if (!$isflexi_itemview && $date_compare == 1) { return; // date_compare == 1 means compare to current item, but current view is not an item view so we terminate } // FOR date_compare==0, $cdate is SERVER DATE // FOR date_compare==1, $cdate is CURRENT ITEM DATE of type created or modified or publish_up or CUSTOM date field switch ($behaviour_dates) { case '1': // custom offset if ($edate) { $edate = array(0 => preg_replace("/[^-+0-9\\s]/", "", $edate), 1 => preg_replace("/[0-9-+\\s]/", "", $edate)); if (empty($edate[1])) { echo "<b>WARNING:</b> Misconfigured date scope, you have entered invalid -END- date:Custom offset is invalid e.g. in order to enter five days ago (be careful with space character) use: -5 d (DO NOT FORGET the space between e.g. '-5 d')<br/>"; return; } else { $where .= ' AND ( ' . $comp . ' < ' . $db->Quote(date_time::shift_dates($cdate, $edate[0], $edate[1])) . ($nulldates ? ' OR ' . $comp . ' IS NULL OR ' . $comp . '="" ' : '') . ' )'; } } if ($bdate) { $bdate = array(0 => preg_replace("/[^-+0-9]/", "", $bdate), 1 => preg_replace("/[0-9-+]/", "", $bdate)); if (empty($bdate[1])) { echo "<b>WARNING:</b> Misconfigured date scope, you have entered invalid -BEGIN- date: Custom offset is invalid e.g. in order to enter five days ago (be careful with space character) use: -5 d (DO NOT FORGET the space between e.g. '-5 d')<br/>"; return; } else { $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote(date_time::shift_dates($cdate, $bdate[0], $bdate[1])) . ($nulldates ? ' OR ' . $comp . ' IS NULL OR ' . $comp . '="" ' : '') . ' )'; } } break; case '8': // same day $cdate = explode(' ', $cdate); $cdate = explode('-', $cdate[0]); $cdate = $cdate[0] . '-' . $cdate[1] . '-' . $cdate[2] . ' 00:00:00'; $where .= ' AND ( ' . $comp . ' < ' . $db->Quote(date_time::shift_dates($cdate, 1, 'd')) . ' )'; $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote($cdate) . ' )'; break; case '2': // same month $cdate = explode(' ', $cdate); $cdate = explode('-', $cdate[0]); $cdate = $cdate[0] . '-' . $cdate[1] . '-01 00:00:00'; $where .= ' AND ( ' . $comp . ' < ' . $db->Quote(date_time::shift_dates($cdate, 1, 'm')) . ' )'; $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote($cdate) . ' )'; break; case '3': // same year $cdate = explode(' ', $cdate); $cdate = explode('-', $cdate[0]); $cdate = $cdate[0] . '-01-01 00:00:00'; $where .= ' AND ( ' . $comp . ' < ' . $db->Quote(date_time::shift_dates($cdate, 1, 'Y')) . ' )'; $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote($cdate) . ' )'; break; case '9': // previous day $cdate = explode(' ', $cdate); $cdate = explode('-', $cdate[0]); $cdate = $cdate[0] . '-' . $cdate[1] . '-' . $cdate[2] . ' 00:00:00'; $where .= ' AND ( ' . $comp . ' < ' . $db->Quote($cdate) . ' )'; $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote(date_time::shift_dates($cdate, -1, 'd')) . ' )'; break; case '4': // previous month $cdate = explode(' ', $cdate); $cdate = explode('-', $cdate[0]); $cdate = $cdate[0] . '-' . $cdate[1] . '-01 00:00:00'; $where .= ' AND ( ' . $comp . ' < ' . $db->Quote($cdate) . ' )'; $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote(date_time::shift_dates($cdate, -1, 'm')) . ' )'; break; case '5': // previous year $cdate = explode(' ', $cdate); $cdate = explode('-', $cdate[0]); $cdate = $cdate[0] . '-01-01 00:00:00'; $where .= ' AND ( ' . $comp . ' < ' . $db->Quote($cdate) . ' )'; $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote(date_time::shift_dates($cdate, -1, 'Y')) . ' )'; break; case '10': // next day $cdate = explode(' ', $cdate); $cdate = explode('-', $cdate[0]); $cdate = $cdate[0] . '-' . $cdate[1] . '-' . $cdate[2] . ' 00:00:00'; $where .= ' AND ( ' . $comp . ' < ' . $db->Quote(date_time::shift_dates($cdate, 2, 'd')) . ' )'; $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote(date_time::shift_dates($cdate, 1, 'd')) . ' )'; break; case '6': // next month $cdate = explode(' ', $cdate); $cdate = explode('-', $cdate[0]); $cdate = $cdate[0] . '-' . $cdate[1] . '-01 00:00:00'; $where .= ' AND ( ' . $comp . ' < ' . $db->Quote(date_time::shift_dates($cdate, 2, 'm')) . ' )'; $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote(date_time::shift_dates($cdate, 1, 'm')) . ' )'; break; case '7': // next year $cdate = explode(' ', $cdate); $cdate = explode('-', $cdate[0]); $cdate = $cdate[0] . '-01-01 00:00:00'; $where .= ' AND ( ' . $comp . ' < ' . $db->Quote(date_time::shift_dates($cdate, 2, 'Y')) . ' )'; $where .= ' AND ( ' . $comp . ' >= ' . $db->Quote(date_time::shift_dates($cdate, 1, 'Y')) . ' )'; break; case '11': // same day of month, ignore year $where .= ' AND ( DAYOFMONTH(' . $comp . ') = ' . 'DAYOFMONTH(' . $db->Quote($cdate) . ') AND MONTH(' . $comp . ') = ' . 'MONTH(' . $db->Quote($cdate) . ') )'; break; case '12': // [-3d,+3d] days of month, IGNORE YEAR $where .= ' AND ((DAYOFMONTH(' . $db->Quote($cdate) . ')-3) <= DAYOFMONTH(' . $comp . ') AND DAYOFMONTH(' . $comp . ') <= (DAYOFMONTH(' . $db->Quote($cdate) . ')+4) AND MONTH(' . $comp . ') = ' . 'MONTH(' . $db->Quote($cdate) . ') )'; break; case '13': // same week of month, IGNORE YEAR $week_start = (int) $params->get('week_start', 0); // 0 is sunday, 5 is monday $week_of_month = '(WEEK(%s,5) - WEEK(DATE_SUB(%s, INTERVAL DAYOFMONTH(%s)-1 DAY),5)+1)'; $where .= ' AND (' . str_replace('%s', $comp, $week_of_month) . ' = ' . str_replace('%s', $db->Quote($cdate), $week_of_month) . ' AND ( MONTH(' . $comp . ') = ' . 'MONTH(' . $db->Quote($cdate) . ') ) )'; break; case '14': // same week of year, IGNORE YEAR $week_start = (int) $params->get('week_start', 0); // 0 is sunday, 5 is monday $where .= ' AND ( WEEK(' . $comp . ') = ' . 'WEEK(' . $db->Quote($cdate) . ',' . $week_start . ') )'; break; case '15': // same month of year, IGNORE YEAR $where .= ' AND ( MONTH(' . $comp . ') = ' . 'MONTH(' . $db->Quote($cdate) . ') )'; break; case '16': // same day of month, IGNORE MONTH, YEAR $where .= ' AND ( DAYOFMONTH(' . $comp . ') = ' . 'DAYOFMONTH(' . $db->Quote($cdate) . ') )'; break; case '17': // [-3d,+3d] days of month, IGNORE MONTH, YEAR $where .= ' AND ((DAYOFMONTH(' . $db->Quote($cdate) . ')-3) <= DAYOFMONTH(' . $comp . ') AND DAYOFMONTH(' . $comp . ') <= (DAYOFMONTH(' . $db->Quote($cdate) . ')+4) )'; break; case '18': // same week of month, IGNORE MONTH, YEAR $week_start = (int) $params->get('week_start', 0); // 0 is sunday, 5 is monday $week_of_month = '(WEEK(%s,5) - WEEK(DATE_SUB(%s, INTERVAL DAYOFMONTH(%s)-1 DAY),5)+1)'; $where .= ' AND (' . str_replace('%s', $comp, $week_of_month) . ' = ' . str_replace('%s', $db->Quote($cdate), $week_of_month) . ' )'; break; } } } // ***************************** // EXTRA joins for special cases // ***************************** // EXTRA joins when comparing to custom date field $join_date = ''; if ($behaviour_dates || $method_dates != 1) { // using date SCOPE: dynamic behaviour, or static behavior with (static) method != ALL(=1) if (($bdate || $edate || $behaviour_dates) && $date_type == 3) { if ($datecomp_field) { $join_date = ' LEFT JOIN #__flexicontent_fields_item_relations AS dfrel' . ' ON ( i.id = dfrel.item_id AND dfrel.field_id = ' . $datecomp_field . ' )'; } else { echo "<b>WARNING:</b> Misconfigured date scope, you have set DATE TYPE as CUSTOM DATE Field, but have not select any specific DATE Field to be used<br/>"; //$join_date = ''; return; } } } // ***************************************************************************************************************************** // Get orderby SQL CLAUSE ('ordering' is passed by reference but no frontend user override is used (we give empty 'request_var') // ***************************************************************************************************************************** $orderby = flexicontent_db::buildItemOrderBy($params, $ordering, $request_var = '', $config_param = 'ordering', $item_tbl_alias = 'i', $relcat_tbl_alias = 'rel', $default_order = '', $default_order_dir = '', $sfx = '', $support_2nd_lvl = true); //echo "<br/>" . print_r($ordering, true) ."<br/>"; // EXTRA join of field used in custom ordering // NOTE: if (1st/2nd level) custom field id is not set, THEN 'field' ordering was changed to level's default, by the ORDER CLAUSE creating function $orderby_join = ''; // Create JOIN for ordering items by a custom field (Level 1) if ('field' == $ordering[1]) { $orderbycustomfieldid = (int) $params->get('orderbycustomfieldid', 0); $orderby_join .= ' LEFT JOIN #__flexicontent_fields_item_relations AS f ON f.item_id = i.id AND f.field_id=' . $orderbycustomfieldid; } // Create JOIN for ordering items by a custom field (Level 2) if ('field' == $ordering[2]) { $orderbycustomfieldid_2nd = (int) $params->get('orderbycustomfieldid' . '_2nd', 0); $orderby_join .= ' LEFT JOIN #__flexicontent_fields_item_relations AS f2 ON f2.item_id = i.id AND f2.field_id=' . $orderbycustomfieldid_2nd; } // Create JOIN for ordering items by author's name if (in_array('author', $ordering) || in_array('rauthor', $ordering)) { $orderby_join .= ' LEFT JOIN #__users AS u ON u.id = i.created_by'; } // ***************************************************** // Decide Select Sub-Clause and Join-Clause for comments // ***************************************************** $display_comments = $params->get('display_comments'); $display_comments_feat = $params->get('display_comments_feat'); // Check (when needed) if jcomments are installed, and also clear 'commented' ordering if they jcomments is missing if ($display_comments_feat || $display_comments || in_array('commented', $ordering)) { // Handle jcomments integratio. No need to reset 'commented' ordering if jcomments not installed, // and neither print message, the ORDER CLAUSE creating function should have done this already if (!file_exists(JPATH_SITE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php')) { //echo "jcomments not installed, you need jcomments to use 'Most commented' ordering OR display comments information.<br>\n"; $jcomments_exist = false; } else { $jcomments_exist = true; } } // Decide to JOIN (or not) with comments TABLE, needed when displaying comments and/or when ordering by comments $add_comments = ($display_comments_feat || $display_comments || in_array('commented', $ordering)) && $jcomments_exist; // Additional select and joins for comments $select_comments = $add_comments ? ', COUNT(DISTINCT com.id) AS comments_total' : ''; $join_comments_type = $ordering[1] == 'commented' ? ' INNER JOIN' : ' LEFT JOIN'; // Do not require most commented for 2nd level ordering $join_comments = $add_comments ? $join_comments_type . ' #__jcomments AS com ON com.object_id = i.id AND com.object_group="com_flexicontent" AND com.published="1"' : ''; // ********************************************************** // Decide Select Sub-Clause and Join-Clause for voting/rating // ********************************************************** $display_voting = $params->get('display_voting'); $display_voting_feat = $params->get('display_voting_feat'); // Decide to JOIN (or not) with rating TABLE, needed when displaying ratings and/or when ordering by ratings $add_rated = $display_voting_feat || $display_voting || in_array('rated', $ordering); // Additional select and joins for ratings $select_rated = in_array('rated', $ordering) ? ', (cr.rating_sum / cr.rating_count) * 20 AS votes' : ''; $select_rated .= $add_rated ? ', cr.rating_sum as rating_sum, cr.rating_count as rating_count' : ''; $join_rated_type = in_array('rated', $ordering) ? ' INNER JOIN' : ' LEFT JOIN'; $join_rated = $add_rated ? $join_rated_type . ' #__content_rating AS cr ON cr.content_id = i.id' : ''; // *********************************************************** // Finally put together the query to retrieve the listed items // *********************************************************** // ****************** // Custom FIELD scope // ****************** $where_field_filters = ''; $join_field_filters = ''; // ZERO 'behaviour' means statically selected records, but METHOD 1 is ALL records ... so NOTHING to do if (!$behaviour_filt && $method_filt == 1) { } else { if ($behaviour_filt == 0 || $behaviour_filt == 2) { $negate_op = $method_filt == 2 ? 'NOT' : ''; // These field filters apply a STATIC filtering, regardless of current item being displayed. // Static Field Filters (These are a string that MAPs filter ID TO filter VALUES) $static_filters_data = FlexicontentFields::setFilterValues($params, 'static_filters', $is_persistent = 1, $set_method = "array"); // Dynamic Field Filters (THIS is filter IDs list) // These field filters apply a DYNAMIC filtering, that depend on current item being displayed. The items that have same value as currently displayed item will be included in the list. //$dynamic_filters = FlexicontentFields::setFilterValues( $params, 'dynamic_filters', $is_persistent=0); foreach ($static_filters_data as $filter_id => $filter_values) { // Handle single-valued filter as multi-valued if (!is_array($filter_values)) { $filter_values = array(0 => $filter_values); } // Single or Multi valued filter if (isset($filter_values[0])) { $in_values = array(); foreach ($filter_values as $val) { $in_values[] = $db->Quote($val); } // Quote in case they are strings !! $where_field_filters .= ' AND ' . $negate_op . ' (rel' . $filter_id . '.value IN (' . implode(',', $in_values) . ') ) '; } else { // Special case only one part of range provided ... must MATCH/INCLUDE empty values or NULL values ... $value_empty = !strlen(@$filter_values[1]) && strlen(@$filter_values[2]) ? ' OR rel' . $filter_id . '.value="" OR rel' . $filter_id . '.value IS NULL ' : ''; if (strlen(@$filter_values[1]) || strlen(@$filter_values[2])) { $where_field_filters .= ' AND ' . $negate_op . ' ( 1 '; if (strlen(@$filter_values[1])) { $where_field_filters .= ' AND (rel' . $filter_id . '.value >=' . $filter_values[1] . ') '; } if (strlen(@$filter_values[2])) { $where_field_filters .= ' AND (rel' . $filter_id . '.value <=' . $filter_values[2] . $value_empty . ') '; } $where_field_filters .= ' )'; } } $join_field_filters .= ' JOIN #__flexicontent_fields_item_relations AS rel' . $filter_id . ' ON rel' . $filter_id . '.item_id=i.id AND rel' . $filter_id . '.field_id = ' . $filter_id; } } } if ($behaviour_filt == 1 || $behaviour_filt == 2) { if (!$isflexi_itemview) { return; // current view is not item view ... , nothing to display } // 1. Get ids of dynamic filters //$dynamic_filter_ids = preg_split("/[\s]*,[\s]*/", $dynamic_filters); $dynamic_filter_ids = FLEXIUtilities::paramToArray($dynamic_filters, "/[\\s]*,[\\s]*/", "intval"); if (empty($dynamic_filter_ids)) { echo "Please enter at least 1 field in Custom field filtering SCOPE, or set behaviour to static"; } else { // 2. Get values of dynamic filters $where2 = count($dynamic_filter_ids) > 1 ? ' AND field_id IN (' . implode(',', $dynamic_filter_ids) . ')' : ' AND field_id = ' . $dynamic_filter_ids[0]; // select the item ids related to current item via the relation fields $query2 = 'SELECT DISTINCT value, field_id' . ' FROM #__flexicontent_fields_item_relations' . ' WHERE item_id = ' . (int) $id . $where2; $db->setQuery($query2); $curritem_vals = $db->loadObjectList(); //echo "<pre>"; print_r($curritem_vals); echo "</pre>"; // 3. Group values by field $_vals = array(); foreach ($curritem_vals as $v) { $_vals[$v->field_id][] = $v->value; } foreach ($dynamic_filter_ids as $filter_id) { // Handle non-existent value by requiring that matching item do not have a value for this field either if (!isset($_vals[$filter_id])) { $where_field_filters .= ' AND reldyn' . $filter_id . '.value IS NULL'; } else { $in_values = array(); foreach ($_vals[$filter_id] as $v) { $in_values[] = $db->Quote($v); } $where_field_filters .= ' AND reldyn' . $filter_id . '.value IN (' . implode(',', $in_values) . ') ' . "\n"; } $join_field_filters .= ' JOIN #__flexicontent_fields_item_relations AS reldyn' . $filter_id . ' ON reldyn' . $filter_id . '.item_id=i.id AND reldyn' . $filter_id . '.field_id = ' . $filter_id . "\n"; } //echo "<pre>"."\n\n".$join_field_filters ."\n\n".$where_field_filters."</pre>"; } } if (empty($items_query)) { // If a custom query has not been set above then use the default one ... $items_query = 'SELECT ' . ' i.id ' . (in_array('commented', $ordering) ? $select_comments : '') . (in_array('rated', $ordering) ? $select_rated : '') . ' FROM #__flexicontent_items_tmp AS i' . ' JOIN #__flexicontent_items_ext AS ie on ie.item_id = i.id' . ' JOIN #__flexicontent_types AS ty on ie.type_id = ty.id' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.itemid = i.id' . ' JOIN #__categories AS c ON c.id = rel.catid' . ' JOIN #__categories AS mc ON mc.id = i.catid' . $joinaccess . $join_favs . $join_date . (in_array('commented', $ordering) ? $join_comments : '') . (in_array('rated', $ordering) ? $join_rated : '') . $orderby_join . $join_field_filters . $where . ' ' . ($apply_config_per_category ? '__CID_WHERE__' : '') . $where_field_filters . ' GROUP BY i.id' . $orderby; // if using CATEGORY SCOPE INCLUDE ... then link though them ... otherwise via main category $_cl = !$behaviour_cat && $method_cat == 3 ? 'c' : 'mc'; $items_query_data = 'SELECT ' . ' i.*, ie.*, ty.name AS typename' . $select_comments . $select_rated . ', mc.title AS maincat_title, mc.alias AS maincat_alias' . ', CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(\':\', i.id, i.alias) ELSE i.id END as slug' . ', CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', ' . $_cl . '.id, ' . $_cl . '.alias) ELSE ' . $_cl . '.id END as categoryslug' . ', GROUP_CONCAT(rel.catid SEPARATOR ",") as itemcats' . ' FROM #__content AS i' . ' JOIN #__flexicontent_items_ext AS ie on ie.item_id = i.id' . ' JOIN #__flexicontent_types AS ty on ie.type_id = ty.id' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.itemid = i.id' . ' JOIN #__categories AS c ON c.id = rel.catid' . ' JOIN #__categories AS mc ON mc.id = i.catid' . $joinaccess . $join_favs . $join_date . $join_comments . $join_rated . $orderby_join . ' WHERE i.id IN (__content__)' . ' GROUP BY i.id'; } // ********************************** // Execute query once OR per category // ********************************** if (!isset($multiquery_cats)) { $multiquery_cats = array(0 => ""); } foreach ($multiquery_cats as $catid => $cat_where) { $_microtime = $modfc_jprof->getmicrotime(); // Get content list per given category $per_cat_query = str_replace('__CID_WHERE__', $cat_where, $items_query); $db->setQuery($per_cat_query, 0, $count); $content = $db->loadColumn(0); if ($db->getErrorNum()) { JFactory::getApplication()->enqueueMessage(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()), 'error'); } @($mod_fc_run_times['query_items'] += $modfc_jprof->getmicrotime() - $_microtime); // Check for no content found for given category if (empty($content)) { $cat_items_arr[$catid] = array(); continue; } $_microtime = $modfc_jprof->getmicrotime(); // Get content list data per given category $per_cat_query = str_replace('__content__', implode(',', $content), $items_query_data); $db->setQuery($per_cat_query, 0, $count); $_rows = $db->loadObjectList('item_id'); if ($db->getErrorNum()) { JFactory::getApplication()->enqueueMessage(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()), 'error'); } @($mod_fc_run_times['query_items_sec'] += $modfc_jprof->getmicrotime() - $_microtime); // Secondary content list ordering and assign content list per category $rows = array(); foreach ($content as $_id) { $rows[] = $_rows[$_id]; } $cat_items_arr[$catid] = $rows; // Get Original content ids for creating some untranslatable fields that have share data (like shared folders) flexicontent_db::getOriginalContentItemids($cat_items_arr[$catid]); } // ************************************************************************************************ // Return items indexed per category id OR via empty string if not apply configuration per category // ************************************************************************************************ return $cat_items_arr; }
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 display($tpl = null) { // ******************** // Initialise variables // ******************** $app = JFactory::getApplication(); $jinput = $app->input; $option = $jinput->get('option', '', 'cmd'); $view = $jinput->get('view', '', 'cmd'); $task = $jinput->get('task', '', 'cmd'); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $session = JFactory::getSession(); // Get model $model = $this->getModel(); // Some flags $has_zlib = function_exists("zlib_encode"); //version_compare(PHP_VERSION, '5.4.0', '>='); // Get session information $conf = $session->get('csvimport_config', "", 'flexicontent'); $conf = unserialize($conf ? $has_zlib ? zlib_decode(base64_decode($conf)) : base64_decode($conf) : ""); $lineno = $session->get('csvimport_lineno', 999999, 'flexicontent'); $session->set('csvimport_parse_log', null, 'flexicontent'); // This is the flag if CSV file has been parsed (import form already submitted), thus to display the imported data // ************************** // Add css and js to document // ************************** $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH); // Add JS frameworks flexicontent_html::loadFramework('select2'); $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable'); flexicontent_html::loadFramework('flexi-lib'); // Add js function to overload the joomla submitform validation JHTML::_('behavior.formvalidation'); // load default validation JS to make sure it is overriden $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VHASH); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VHASH); // ***************************** // Get user's global permissions // ***************************** $perms = FlexicontentHelperPerm::getPerm(); // ************************ // Create Submenu & Toolbar // ************************ // Create Submenu (and also check access to current view) FLEXISubmenu('CanImport'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_IMPORT'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'import'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $toolbar = JToolBar::getInstance('toolbar'); if (!empty($conf)) { if ($task != 'processcsv') { $ctrl_task = 'import.processcsv'; $import_btn_title = empty($lineno) ? 'FLEXI_IMPORT_START_TASK' : 'FLEXI_IMPORT_CONTINUE_TASK'; JToolBarHelper::custom($ctrl_task, 'save.png', 'save.png', $import_btn_title, $list_check = false); } $ctrl_task = 'import.clearcsv'; JToolBarHelper::custom($ctrl_task, 'cancel.png', 'cancel.png', 'FLEXI_IMPORT_CLEAR_TASK', $list_check = false); } else { $ctrl_task = 'import.initcsv'; JToolBarHelper::custom($ctrl_task, 'import.png', 'import.png', 'FLEXI_IMPORT_PREPARE_TASK', $list_check = false); $ctrl_task = 'import.testcsv'; JToolBarHelper::custom($ctrl_task, 'test.png', 'test.png', 'FLEXI_IMPORT_TEST_FILE_FORMAT', $list_check = false); } //JToolBarHelper::Back(); if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } // Get types $types = flexicontent_html::getTypesList($_type_ids = false, $_check_perms = false, $_published = true); // Get Languages $languages = FLEXIUtilities::getLanguages('code'); // Get categories global $globalcats; $categories = $globalcats; // ************************************ // Decide layout to load: 'import*.php' // ************************************ $this->setLayout('import'); $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null; // Execute the import task, load the log-like AJAX-based layout (import_process.php), to display results including any warnings if (!empty($conf) && $task == 'processcsv') { $this->assignRef('conf', $conf); parent::display('process'); return; } else { if (!empty($conf)) { $this->assignRef('conf', $conf); $this->assignRef('cparams', $cparams); $this->assignRef('types', $types); $this->assignRef('languages', $languages); $this->assignRef('categories', $globalcats); parent::display('list'); return; } } // Session config is empty, means import form has not been submited, display the form // We will display import form which is not 'default.php', it is 'import.php' // else ... // Check is session table DATA column is not mediumtext (16MBs, it can be 64 KBs ('text') in some sites that were not properly upgraded) $tblname = 'session'; $dbprefix = $app->getCfg('dbprefix'); $dbname = $app->getCfg('db'); $db->setQuery("SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . $dbname . "' AND TABLE_NAME = '" . $dbprefix . $tblname . "'"); $jession_coltypes = $db->loadAssocList('COLUMN_NAME'); $_dataColType = strtolower($jession_coltypes['data']['DATA_TYPE']); $_dataCol_wrongSize = $_dataColType != 'mediumtext' && $_dataColType != 'longtext'; // If data type is "text" it is safe to assume that it can be converted to "mediumtext", // since "text" means that session table is not memory storage, // plus it is already stored externally aka operation will be quick ? /*if ($_dataCol_wrongSize && $_dataColType == 'text') { $db->setQuery("ALTER TABLE `#__session` MODIFY `data` MEDIUMTEXT"); $db->execute(); $_dataCol_wrongSize = false; }*/ if ($_dataCol_wrongSize) { $app->enqueueMessage("Joomla DB table: <b>'session'</b> has a <b>'data'</b> column with type: <b>'" . $_dataColType . "'</b>, instead of expected type <b>'mediumtext'</b>. Trying to import large data files may fail", "notice"); } $formvals = array(); // Retrieve Basic configuration $formvals['type_id'] = $model->getState('type_id'); $formvals['language'] = $model->getState('language'); $formvals['state'] = $model->getState('state'); $formvals['access'] = $model->getState('access'); // Main and secondary categories, tags $formvals['maincat'] = $model->getState('maincat'); $formvals['maincat_col'] = $model->getState('maincat_col'); $formvals['seccats'] = $model->getState('seccats'); $formvals['seccats_col'] = $model->getState('seccats_col'); $formvals['tags_col'] = $model->getState('tags_col'); // Publication: Author/modifier $formvals['created_by_col'] = $model->getState('created_by_col'); $formvals['modified_by_col'] = $model->getState('modified_by_col'); // Publication: META data $formvals['metadesc_col'] = $model->getState('metadesc_col'); $formvals['metakey_col'] = $model->getState('metakey_col'); // Publication: dates $formvals['modified_col'] = $model->getState('modified_col'); $formvals['created_col'] = $model->getState('modified_col'); $formvals['publish_up_col'] = $model->getState('publish_up_col'); $formvals['publish_down_col'] = $model->getState('publish_down_col'); // Advanced configuration $formvals['ignore_unused_cols'] = $model->getState('ignore_unused_cols'); $formvals['id_col'] = $model->getState('id_col'); $formvals['items_per_step'] = $model->getState('items_per_step'); // CSV file format $formvals['mval_separator'] = $model->getState('mval_separator'); $formvals['mprop_separator'] = $model->getState('mprop_separator'); $formvals['field_separator'] = $model->getState('field_separator'); $formvals['enclosure_char'] = $model->getState('enclosure_char'); $formvals['record_separator'] = $model->getState('record_separator'); $formvals['debug_records'] = $model->getState('debug_records'); // ****************** // Create form fields // ****************** $lists['type_id'] = flexicontent_html::buildtypesselect($types, 'type_id', $formvals['type_id'], true, 'class="required use_select2_lib"', 'type_id'); $actions_allowed = array('core.create'); // Creating categorories tree for item assignment, we use the 'create' privelege // build the main category select list $attribs = 'class="use_select2_lib required"'; $fieldname = 'maincat'; $lists['maincat'] = flexicontent_cats::buildcatselect($categories, $fieldname, $formvals['maincat'], 2, $attribs, false, true, $actions_allowed); // build the secondary categories select list $class = "use_select2_lib"; $attribs = 'multiple="multiple" size="10" class="' . $class . '"'; $fieldname = 'seccats[]'; $lists['seccats'] = flexicontent_cats::buildcatselect($categories, $fieldname, $formvals['seccats'], false, $attribs, false, true, $actions_allowed, $require_all = true); // build languages list // Retrieve author configuration $authorparams = flexicontent_db::getUserConfig($user->id); $allowed_langs = $authorparams->get('langs_allowed', null); $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs); // We will not use the default getInput() function of J1.6+ since we want to create a radio selection field with flags // we could also create a new class and override getInput() method but maybe this is an overkill, we may do it in the future $lists['languages'] = flexicontent_html::buildlanguageslist('language', ' style="vertical-align:top;" onchange="var m=jQuery(\'#fc_import_about_langcol\'); this.value ? m.hide(600) : m.show(600);"', $formvals['language'], 6, $allowed_langs, $published_only = true, $disable_langs = null, $add_all = true, $conf = array('required' => true)) . ' <span class="fc-mssg-inline fc-note fc-nobgimage" id="fc_import_about_langcol" style="display:none;"> ' . JText::_('FLEXI_USE_LANGUAGE_COLUMN_TIP') . ' </span>'; $lists['states'] = flexicontent_html::buildstateslist('state', ' style="vertical-align:top;" onchange="var m=jQuery(\'#fc_import_about_statecol\'); this.value ? m.hide(600) : m.show(600);"', $formvals['state'], 2) . '<span class="fc-mssg-inline fc-note fc-nobgimage" id="fc_import_about_statecol" style="display:none;"> ' . JText::_('FLEXI_USE_STATE_COLUMN_TIP') . ' </span>'; // build access level filter $access_levels = JHtml::_('access.assetgroups'); array_unshift($access_levels, JHtml::_('select.option', '0', "Use 'access' column")); array_unshift($access_levels, JHtml::_('select.option', '', 'FLEXI_SELECT_ACCESS_LEVEL')); $fieldname = 'access'; // make multivalue $elementid = 'access'; $attribs = 'class="required use_select2_lib"'; $lists['access'] = JHTML::_('select.genericlist', $access_levels, $fieldname, $attribs, 'value', 'text', $formvals['access'], $elementid, $translate = true); // Ignore warnings because component may not be installed $warnHandlers = JERROR::getErrorHandling(E_WARNING); JERROR::setErrorHandling(E_WARNING, 'ignore'); // Reset the warning handler(s) foreach ($warnHandlers as $mode) { JERROR::setErrorHandling(E_WARNING, $mode); } // ******************************************************************************** // Get field names (from the header line (row 0), and remove it form the data array // ******************************************************************************** $file_field_types_list = '"image","file"'; $q = 'SELECT id, name, label, field_type FROM #__flexicontent_fields AS fi' . ' WHERE fi.field_type IN (' . $file_field_types_list . ')'; $db->setQuery($q); $file_fields = $db->loadObjectList('name'); //assign data to template $this->assignRef('model', $model); $this->assignRef('lists', $lists); $this->assignRef('user', $user); $this->assignRef('cparams', $cparams); $this->assignRef('file_fields', $file_fields); $this->assignRef('formvals', $formvals); parent::display($tpl); }
/** * Creates the item page * * @since 1.0 */ function display($tpl = null) { // ******************************** // Initialize variables, flags, etc // ******************************** global $globalcats; $categories = $globalcats; $app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $document = JFactory::getDocument(); $session = JFactory::getSession(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $option = JRequest::getVar('option'); $nullDate = $db->getNullDate(); // Get the COMPONENT only parameters $params = clone JComponentHelper::getParams('com_flexicontent'); if (!FLEXI_J16GE) { jimport('joomla.html.pane'); $pane = JPane::getInstance('sliders'); $editor = JFactory::getEditor(); } // Some flags $enable_translation_groups = $params->get("enable_translation_groups") && (FLEXI_J16GE || FLEXI_FISH); $print_logging_info = $params->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // ***************** // Load JS/CSS files // ***************** FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); flexicontent_html::loadFramework('jQuery'); flexicontent_html::loadFramework('select2'); $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable'); // Load custom behaviours: form validation, popup tooltips //JHTML::_('behavior.formvalidation'); JHTML::_('behavior.tooltip'); // Add css to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } // Add js function to overload the joomla submitform $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/admin.js'); $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/validate.js'); // Add js function for custom code used by FLEXIcontent item form $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/itemscreen.js'); // *********************** // Get data from the model // *********************** if ($print_logging_info) { $start_microtime = microtime(true); } $model = $this->getModel(); $item = $this->get('Item'); if (FLEXI_J16GE) { $form = $this->get('Form'); } if ($print_logging_info) { $fc_run_times['get_item_data'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // *************************** // Get Associated Translations // *************************** if ($enable_translation_groups) { $langAssocs = $this->get('LangAssocs'); } if (FLEXI_FISH || FLEXI_J16GE) { $langs = FLEXIUtilities::getLanguages('code'); } // Get item id and new flag $cid = $model->getId(); $isnew = !$cid; // Create and set a unique item id for plugins that needed it JRequest::setVar('unique_tmp_itemid', $cid ? $cid : date('_Y_m_d_h_i_s_', time()) . uniqid(true)); // Get number of subscribers $subscribers = $model->getSubscribersCount(); // ****************** // Version Panel data // ****************** // Get / calculate some version related variables $versioncount = $model->getVersionCount(); $versionsperpage = $params->get('versionsperpage', 10); $pagecount = (int) ceil($versioncount / $versionsperpage); // Data need by version panel: (a) current version page, (b) currently active version $current_page = 1; $k = 1; $allversions = $model->getVersionList(); foreach ($allversions as $v) { if ($k > 1 && ($k - 1) % $versionsperpage == 0) { $current_page++; } if ($v->nr == $item->version) { break; } $k++; } // Finally fetch the version data for versions in current page $versions = $model->getVersionList(($current_page - 1) * $versionsperpage, $versionsperpage); // ***************** // Type related data // ***************** // Get available types and the currently selected/requested type $types = $model->getTypeslist(); $typesselected = $model->getTypesselected(); // Get and merge type parameters $tparams = $this->get('Typeparams'); $tparams = FLEXI_J16GE ? new JRegistry($tparams) : new JParameter($tparams); $params->merge($tparams); // Apply type configuration if it type is set // Get user allowed permissions on the item ... to be used by the form rendering // Also hide parameters panel if user can not edit parameters $perms = $this->_getItemPerms($item, $typesselected); if (!$perms['canparams']) { $document->addStyleDeclaration((FLEXI_J16GE ? '#details-options' : '#det-pane') . '{display:none;}'); } // ****************** // Create the toolbar // ****************** $toolbar = JToolBar::getInstance('toolbar'); // SET toolbar title if ($cid) { JToolBarHelper::title(JText::_('FLEXI_EDIT_ITEM'), 'itemedit'); // Editing existing item } else { JToolBarHelper::title(JText::_('FLEXI_NEW_ITEM'), 'itemadd'); // Creating new item } // Add a preview button for LATEST version of the item if ($cid) { // Domain URL and autologin vars $server = JURI::getInstance()->toString(array('scheme', 'host', 'port')); $autologin = ''; //$params->get('autoflogin', 1) ? '&fcu='.$user->username . '&fcp='.$user->password : ''; // Check if we are in the backend, in the back end we need to set the application to the site app instead $isAdmin = JFactory::getApplication()->isAdmin(); if ($isAdmin && FLEXI_J16GE) { JFactory::$application = JApplication::getInstance('site'); } // Create the URL $item_url = JRoute::_(FlexicontentHelperRoute::getItemRoute($item->id . ':' . $item->alias, $categories[$item->catid]->slug) . $autologin); // Check if we are in the backend again // In backend we need to remove administrator from URL as it is added even though we've set the application to the site app if ($isAdmin) { if (FLEXI_J16GE) { $admin_folder = str_replace(JURI::root(true), '', JURI::base(true)); $item_url = str_replace($admin_folder, '', $item_url); // Restore application JFactory::$application = JApplication::getInstance('administrator'); } else { $item_url = JURI::root(true) . '/' . $item_url; } } $previewlink = $item_url . (strstr($item_url, '?') ? '&' : '?') . 'preview=1'; //$previewlink = str_replace('&', '&', $previewlink); //$previewlink = JRoute::_(JURI::root() . FlexicontentHelperRoute::getItemRoute($item->id.':'.$item->alias, $categories[$item->catid]->slug)) .$autologin; if (!$params->get('use_versioning', 1) || $item->version == $item->current_version && $item->version == $item->last_version) { $toolbar->appendButton('Custom', '<a class="preview btn btn-small" href="' . $previewlink . '" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-32-preview"></span>' . JText::_('Preview') . '</a>', 'preview'); } else { // Add a preview button for (currently) LOADED version of the item $previewlink_loaded_ver = $previewlink . '&version=' . $item->version; $toolbar->appendButton('Custom', '<a class="preview btn btn-small" href="' . $previewlink_loaded_ver . '" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-32-preview"></span>' . JText::_('FLEXI_PREVIEW_FORM_LOADED_VERSION') . ' [' . $item->version . ']</a>', 'preview'); // Add a preview button for currently ACTIVE version of the item $previewlink_active_ver = $previewlink . '&version=' . $item->current_version; $toolbar->appendButton('Custom', '<a class="preview btn btn-small" href="' . $previewlink_active_ver . '" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-32-preview"></span>' . JText::_('FLEXI_PREVIEW_FRONTEND_ACTIVE_VERSION') . ' [' . $item->current_version . ']</a>', 'preview'); // Add a preview button for currently LATEST version of the item $previewlink_last_ver = $previewlink; //'&version='.$item->last_version; $toolbar->appendButton('Custom', '<a class="preview btn btn-small" href="' . $previewlink_last_ver . '" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-32-preview"></span>' . JText::_('FLEXI_PREVIEW_LATEST_SAVED_VERSION') . ' [' . $item->last_version . ']</a>', 'preview'); } JToolBarHelper::spacer(); JToolBarHelper::divider(); JToolBarHelper::spacer(); } // Common Buttons if (FLEXI_J16GE) { JToolBarHelper::apply('items.apply'); if (!$isnew || $item->version) { JToolBarHelper::save('items.save'); } if (!$isnew || $item->version) { JToolBarHelper::custom('items.saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); } JToolBarHelper::cancel('items.cancel'); } else { JToolBarHelper::apply(); if (!$isnew || $item->version) { JToolBarHelper::save(); } if (!$isnew || $item->version) { JToolBarHelper::custom('saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); } JToolBarHelper::cancel(); } // Check if saving an item that translates an original content in site's default language $is_content_default_lang = substr(flexicontent_html::getSiteDefaultLang(), 0, 2) == substr($item->language, 0, 2); $modify_untraslatable_values = $enable_translation_groups && !$is_content_default_lang && $item->lang_parent_id && $item->lang_parent_id != $item->id; // ***************************************************************************** // Get (CORE & CUSTOM) fields and their VERSIONED values and then // (a) Apply Content Type Customization to CORE fields (label, description, etc) // (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField' // ***************************************************************************** if ($print_logging_info) { $start_microtime = microtime(true); } $fields = $this->get('Extrafields'); if ($print_logging_info) { $fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } if ($print_logging_info) { $start_microtime = microtime(true); } foreach ($fields as $field) { // a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description // NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations if ($field->iscore) { FlexicontentFields::loadFieldConfig($field, $item); } // b. Create field 's editing HTML (the form field) // NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow) if (!$field->iscore) { if (FLEXI_J16GE) { $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id); } else { if (FLEXI_ACCESS && $user->gid < 25) { $is_editable = !$field->valueseditable || FAccess::checkAllContentAccess('com_content', 'submit', 'users', $user->gmid, 'field', $field->id); } else { $is_editable = 1; } } if (!$is_editable) { $field->html = '<div class="fc-mssg fc-warning">' . JText::_('FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>'; } else { if ($modify_untraslatable_values && $field->untranslatable) { $field->html = '<div class="fc-mssg fc-note">' . JText::_('FLEXI_FIELD_VALUE_IS_UNTRANSLATABLE') . '</div>'; } else { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item)); } } } // c. Create main text field, via calling the display function of the textarea field (will also check for tabs) if ($field->field_type == 'maintext') { if (isset($item->item_translations)) { $shortcode = substr($item->language, 0, 2); foreach ($item->item_translations as $lang_id => $t) { if ($shortcode == $t->shortcode) { continue; } $field->name = array('jfdata', $t->shortcode, 'text'); $field->value[0] = html_entity_decode($t->fields->text->value, ENT_QUOTES, 'UTF-8'); FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); $t->fields->text->tab_labels = $field->tab_labels; $t->fields->text->html = $field->html; unset($field->tab_labels); unset($field->html); } } $field->name = 'text'; // NOTE: We use the text created by the model and not the text retrieved by the CORE plugin code, which maybe overwritten with JoomFish/Falang data $field->value[0] = $item->text; // do not decode special characters this was handled during saving ! // Render the field's (form) HTML FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); } } if ($print_logging_info) { $fc_run_times['render_field_html'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // ************************* // Get tags used by the item // ************************* $usedtagsIds = $this->get('UsedtagsIds'); // NOTE: This will normally return the already set versioned value of tags ($item->tags) $usedtags = $model->getUsedtagsData($usedtagsIds); // ******************************* // Get categories used by the item // ******************************* if ($isnew) { // Case for preselected main category for new items $maincat = $item->catid ? $item->catid : JRequest::getInt('maincat', 0); if (!$maincat) { $maincat = $app->getUserStateFromRequest($option . '.items.filter_cats', 'filter_cats', '', 'int'); } if ($maincat) { $selectedcats = array($maincat); $item->catid = $maincat; } else { $selectedcats = array(); } if ($tparams->get('cid_default')) { $selectedcats = $tparams->get('cid_default'); } if ($tparams->get('catid_default')) { $item->catid = $tparams->get('catid_default'); } } else { // NOTE: This will normally return the already set versioned value of categories ($item->categories) $selectedcats = $this->get('Catsselected'); } //$selectedcats = $isnew ? array() : $fields['categories']->value; //echo "<br/>row->tags: "; print_r($item->tags); //echo "<br/>usedtagsIds: "; print_r($usedtagsIds); //echo "<br/>usedtags (data): "; print_r($usedtags); //echo "<br/>row->categories: "; print_r($item->categories); //echo "<br/>selectedcats: "; print_r($selectedcats); // ********************************************************************************************* // Build select lists for the form field. Only few of them are used in J1.6+, since we will use: // (a) form XML file to declare them and then (b) getInput() method form field to create them // ********************************************************************************************* // First clean form data, we do this after creating the description field which may contain HTML JFilterOutput::objectHTMLSafe($item, ENT_QUOTES); $lists = array(); // build granular access list if (!FLEXI_J16GE) { if (FLEXI_ACCESS) { if (isset($user->level)) { $lists['access'] = FAccess::TabGmaccess($item, 'item', 1, 0, 0, 1, 0, 1, 0, 1, 1); } else { $lists['access'] = JText::_('Your profile has been changed, please logout to access to the permissions'); } } else { $lists['access'] = JHTML::_('list.accesslevel', $item); // created but not used in J1.5 backend form } } // build state list $_arc_ = FLEXI_J16GE ? 2 : -1; $non_publishers_stategrp = $perms['isSuperAdmin'] || $item->state == -3 || $item->state == -4; $special_privelege_stategrp = $item->state == $_arc_ || $perms['canarchive'] || ($item->state == -2 || $perms['candelete']); $state = array(); // Using <select> groups if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_PUBLISHERS_WORKFLOW_STATES')); } $state[] = JHTML::_('select.option', 1, JText::_('FLEXI_PUBLISHED')); $state[] = JHTML::_('select.option', 0, JText::_('FLEXI_UNPUBLISHED')); $state[] = JHTML::_('select.option', -5, JText::_('FLEXI_IN_PROGRESS')); // States reserved for workflow if ($non_publishers_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_NON_PUBLISHERS_WORKFLOW_STATES')); } if ($item->state == -3 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -3, JText::_('FLEXI_PENDING')); } if ($item->state == -4 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -4, JText::_('FLEXI_TO_WRITE')); } // Special access states if ($special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_SPECIAL_ACTION_STATES')); } if ($item->state == $_arc_ || $perms['canarchive']) { $state[] = JHTML::_('select.option', $_arc_, JText::_('FLEXI_ARCHIVED')); } if ($item->state == -2 || $perms['candelete']) { $state[] = JHTML::_('select.option', -2, JText::_('FLEXI_TRASHED')); } // Close last <select> group if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); } $fieldname = FLEXI_J16GE ? 'jform[state]' : 'state'; $elementid = FLEXI_J16GE ? 'jform_state' : 'state'; $class = 'use_select2_lib'; $attribs = 'class="' . $class . '"'; $lists['state'] = JHTML::_('select.genericlist', $state, $fieldname, $attribs, 'value', 'text', $item->state, $elementid); if (!FLEXI_J16GE) { $lists['state'] = str_replace('<optgroup label="">', '</optgroup>', $lists['state']); } // *** BOF: J2.5 SPECIFIC SELECT LISTS if (FLEXI_J16GE) { // build featured flag $fieldname = 'jform[featured]'; $elementid = 'jform_featured'; /* $options = array(); $options[] = JHTML::_('select.option', 0, JText::_( 'FLEXI_NO' ) ); $options[] = JHTML::_('select.option', 1, JText::_( 'FLEXI_YES' ) ); $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['featured'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', $item->featured, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array(0 => JText::_('FLEXI_NO'), 1 => JText::_('FLEXI_YES')); $lists['featured'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id == $item->featured ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['featured'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-label="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['featured'] .= ' <input type="radio" id="' . $elementid_no . '" element_group_id="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['featured'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } } // *** EOF: J1.5 SPECIFIC SELECT LISTS // build version approval list $fieldname = FLEXI_J16GE ? 'jform[vstate]' : 'vstate'; $elementid = FLEXI_J16GE ? 'jform_vstate' : 'vstate'; /* $options = array(); $options[] = JHTML::_('select.option', 1, JText::_( 'FLEXI_NO' ) ); $options[] = JHTML::_('select.option', 2, JText::_( 'FLEXI_YES' ) ); $attribs = FLEXI_J16GE ? ' style ="float:left!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['vstate'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', 2, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array(1 => JText::_('FLEXI_NO'), 2 => JText::_('FLEXI_YES')); $lists['vstate'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id == 2 ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['vstate'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-label="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['vstate'] .= ' <input type="radio" id="' . $elementid_no . '" element_group_id="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['vstate'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } // build field for notifying subscribers if (!$subscribers) { $lists['notify'] = !$isnew ? JText::_('FLEXI_NO_SUBSCRIBERS_EXIST') : ''; } else { // b. Check if notification emails to subscribers , were already sent during current session $subscribers_notified = $session->get('subscribers_notified', array(), 'flexicontent'); if (!empty($subscribers_notified[$item->id])) { $lists['notify'] = JText::_('FLEXI_SUBSCRIBERS_ALREADY_NOTIFIED'); } else { // build favs notify field $fieldname = FLEXI_J16GE ? 'jform[notify]' : 'notify'; $elementid = FLEXI_J16GE ? 'jform_notify' : 'notify'; /* $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['notify'] = '<input type="checkbox" name="jform[notify]" id="jform_notify" '.$attribs.' /> '. $lbltxt; */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $lbltxt = $subscribers . ' ' . JText::_($subscribers > 1 ? 'FLEXI_SUBSCRIBERS' : 'FLEXI_SUBSCRIBER'); if (!$prettycheckable_added) { $lists['notify'] .= '<label class="fccheckradio_lbl" for="' . $elementid . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-label="' . $lbltxt . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['notify'] = ' <input type="checkbox" id="' . $elementid . '" element_group_id="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="1" ' . $extra_params . ' checked="checked" />'; if (!$prettycheckable_added) { $lists['notify'] .= ' ' . $lbltxt . '</label>'; } } } // Retrieve author configuration $db->setQuery('SELECT author_basicparams FROM #__flexicontent_authors_ext WHERE user_id = ' . $user->id); if ($authorparams = $db->loadResult()) { $authorparams = FLEXI_J16GE ? new JRegistry($authorparams) : new JParameter($authorparams); } // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = !$authorparams ? 0 : intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; max_cat_overlimit_msg_fc = "' . JText::_('FLEXI_TOO_MANY_ITEM_CATEGORIES', true) . '"; '); // Creating categorories tree for item assignment, we use the 'create' privelege $actions_allowed = array('core.create'); // Featured categories form field $featured_cats_parent = $params->get('featured_cats_parent', 0); $featured_cats = array(); $enable_featured_cid_selector = $perms['multicat'] && $perms['canchange_featcat']; if ($featured_cats_parent) { $featured_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $featured_cats_parent, $depth_limit = 0); $featured_sel = array(); foreach ($selectedcats as $item_cat) { if (isset($featured_tree[$item_cat])) { $featured_sel[] = $item_cat; } } $class = "use_select2_lib select2_list_selected"; $attribs = 'class="' . $class . '" multiple="multiple" size="8"'; $attribs .= $enable_featured_cid_selector ? '' : ' disabled="disabled"'; $fieldname = FLEXI_J16GE ? 'jform[featured_cid][]' : 'featured_cid[]'; $lists['featured_cid'] = ($enable_featured_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($featured_tree, $fieldname, $featured_sel, 3, $attribs, true, true, $actions_allowed); } else { // Do not display, if not configured or not allowed to the user $lists['featured_cid'] = false; } // Multi-category form field, for user allowed to use multiple categories $lists['cid'] = ''; $enable_cid_selector = $perms['multicat'] && $perms['canchange_seccat']; if (1) { if ($tparams->get('cid_allowed_parent')) { $cid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('cid_allowed_parent'), $depth_limit = 0); } else { $cid_tree =& $categories; } // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = !$authorparams ? 0 : intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; max_cat_overlimit_msg_fc = "' . JText::_('FLEXI_TOO_MANY_ITEM_CATEGORIES', true) . '"; '); $class = "mcat use_select2_lib select2_list_selected"; $class .= $max_cat_assign ? " validate-fccats" : " validate"; $attribs = 'class="' . $class . '" multiple="multiple" size="20"'; $attribs .= $enable_cid_selector ? '' : ' disabled="disabled"'; $fieldname = FLEXI_J16GE ? 'jform[cid][]' : 'cid[]'; $skip_subtrees = $featured_cats_parent ? array($featured_cats_parent) : array(); $lists['cid'] = ($enable_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($cid_tree, $fieldname, $selectedcats, false, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees, $disable_subtrees = array()); } else { if (count($selectedcats) > 1) { foreach ($selectedcats as $catid) { $cat_titles[$catid] = $globalcats[$catid]->title; } $lists['cid'] .= implode(', ', $cat_titles); } else { $lists['cid'] = false; } } // Main category form field $class = 'scat use_select2_lib'; if ($perms['multicat']) { $class .= ' validate-catid'; } else { $class .= ' required'; } $attribs = 'class="' . $class . '"'; $fieldname = FLEXI_J16GE ? 'jform[catid]' : 'catid'; $enable_catid_selector = $isnew && !$tparams->get('catid_default') || !$isnew && empty($item->catid) || $perms['canchange_cat']; if ($tparams->get('catid_allowed_parent')) { $catid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('catid_allowed_parent'), $depth_limit = 0); } else { $catid_tree =& $categories; } $lists['catid'] = false; if (!empty($catid_tree)) { $disabled = $enable_catid_selector ? '' : ' disabled="disabled"'; $attribs .= $disabled; $lists['catid'] = ($enable_catid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($catid_tree, $fieldname, $item->catid, 2, $attribs, true, true, $actions_allowed); } else { if (!$isnew && $item->catid) { $lists['catid'] = $globalcats[$item->catid]->title; } } //buid types selectlist $class = 'required use_select2_lib'; $attribs = 'class="' . $class . '"'; $fieldname = FLEXI_J16GE ? 'jform[type_id]' : 'type_id'; $elementid = FLEXI_J16GE ? 'jform_type_id' : 'type_id'; $lists['type'] = flexicontent_html::buildtypesselect($types, $fieldname, $typesselected->id, 1, $attribs, $elementid, $check_perms = true); //build languages list $allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed', null); $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs); if (!$isnew && $allowed_langs) { $allowed_langs[] = $item->language; } // We will not use the default getInput() function of J1.6+ since we want to create a radio selection field with flags // we could also create a new class and override getInput() method but maybe this is an overkill, we may do it in the future $language_fieldname = FLEXI_J16GE ? 'jform[language]' : 'language'; if (FLEXI_FISH || FLEXI_J16GE) { $lists['languages'] = flexicontent_html::buildlanguageslist($language_fieldname, '', $item->language, 3, $allowed_langs); } // Label for current item state: published, unpublished, archived etc switch ($item->state) { case 0: $published = JText::_('FLEXI_UNPUBLISHED'); break; case 1: $published = JText::_('FLEXI_PUBLISHED'); break; case -1: $published = JText::_('FLEXI_ARCHIVED'); break; case -3: $published = JText::_('FLEXI_PENDING'); break; case -5: $published = JText::_('FLEXI_IN_PROGRESS'); break; case -4: default: $published = JText::_('FLEXI_TO_WRITE'); break; } // ************************************************************** // Handle Item Parameters Creation and Load their values for J1.5 // In J1.6+ we declare them in the item form XML file // ************************************************************** if (!FLEXI_J16GE) { // Create the form parameters object if (FLEXI_ACCESS) { $formparams = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'item2.xml'); } else { $formparams = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'item.xml'); } // Details Group $active = intval($item->created_by) ? intval($item->created_by) : $user->get('id'); if (!FLEXI_ACCESS) { $formparams->set('access', $item->access); } $formparams->set('created_by', $active); $formparams->set('created_by_alias', $item->created_by_alias); $formparams->set('created', JHTML::_('date', $item->created, '%Y-%m-%d %H:%M:%S')); $formparams->set('publish_up', JHTML::_('date', $item->publish_up, '%Y-%m-%d %H:%M:%S')); if (JHTML::_('date', $item->publish_down, '%Y') <= 1969 || $item->publish_down == $db->getNullDate() || empty($item->publish_down)) { $formparams->set('publish_down', JText::_('FLEXI_NEVER')); } else { $formparams->set('publish_down', JHTML::_('date', $item->publish_down, '%Y-%m-%d %H:%M:%S')); } // Advanced Group $formparams->loadINI($item->attribs); //echo "<pre>"; print_r($formparams->_xml['themes']->_children[0]); echo "<pre>"; print_r($formparams->_xml['themes']->param[0]); exit; foreach ($formparams->_xml['themes']->_children as $i => $child) { if (isset($child->_attributes['enableparam']) && !$params->get($child->_attributes['enableparam'])) { unset($formparams->_xml['themes']->_children[$i]); unset($formparams->_xml['themes']->param[$i]); } } // Metadata Group $formparams->set('description', $item->metadesc); $formparams->set('keywords', $item->metakey); $formparams->loadINI($item->metadata); } else { if (JHTML::_('date', $item->publish_down, 'Y') <= 1969 || $item->publish_down == $db->getNullDate() || empty($item->publish_down)) { $form->setValue('publish_down', null, JText::_('FLEXI_NEVER')); } } // **************************** // Handle Template related work // **************************** // (a) Get the templates structures used to create form fields for template parameters $themes = flexicontent_tmpl::getTemplates(); $tmpls_all = $themes->items; // (b) Get Content Type allowed templates $allowed_tmpls = $tparams->get('allowed_ilayouts'); $type_default_layout = $tparams->get('ilayout', 'default'); if (empty($allowed_tmpls)) { $allowed_tmpls = array(); } else { if (!is_array($allowed_tmpls)) { $allowed_tmpls = !FLEXI_J16GE ? array($allowed_tmpls) : explode("|", $allowed_tmpls); } } // (c) Add default layout, unless all templates allowed (=array is empty) if (count($allowed_tmpls) && !in_array($type_default_layout, $allowed_tmpls)) { $allowed_tmpls[] = $type_default_layout; } // (d) Create array of template data according to the allowed templates for current content type if (count($allowed_tmpls)) { foreach ($tmpls_all as $tmpl) { if (in_array($tmpl->name, $allowed_tmpls)) { $tmpls[] = $tmpl; } } } else { $tmpls = $tmpls_all; } // (e) Apply Template Parameters values into the form fields structures foreach ($tmpls as $tmpl) { if (FLEXI_J16GE) { $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; foreach ($tmpl->params->getGroup('attribs') as $field) { $fieldname = $field->__get('fieldname'); $value = $item->itemparams->get($fieldname); if (strlen($value)) { $tmpl->params->setValue($fieldname, 'attribs', $value); } } } else { $tmpl->params->loadINI($item->attribs); } } // ****************************** // Assign data to VIEW's template // ****************************** $this->assignRef('document', $document); $this->assignRef('lists', $lists); $this->assignRef('row', $item); if (FLEXI_J16GE) { $this->assignRef('form', $form); } else { $this->assignRef('editor', $editor); $this->assignRef('pane', $pane); $this->assignRef('formparams', $formparams); } if ($enable_translation_groups) { $this->assignRef('lang_assocs', $langAssocs); } if (FLEXI_FISH || FLEXI_J16GE) { $this->assignRef('langs', $langs); } $this->assignRef('typesselected', $typesselected); $this->assignRef('published', $published); $this->assignRef('nullDate', $nullDate); $this->assignRef('subscribers', $subscribers); $this->assignRef('fields', $fields); $this->assignRef('versions', $versions); $this->assignRef('pagecount', $pagecount); $this->assignRef('params', $params); $this->assignRef('tparams', $tparams); $this->assignRef('tmpls', $tmpls); $this->assignRef('usedtags', $usedtags); $this->assignRef('perms', $perms); $this->assignRef('current_page', $current_page); if ($print_logging_info) { $start_microtime = microtime(true); } parent::display($tpl); if ($print_logging_info) { $fc_run_times['form_rendering'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } }
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]); } }
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; }
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; }
$template = $app->getTemplate(); $btn_class = FLEXI_J30GE ? 'btn' : 'fc_button'; $tooltip_class = FLEXI_J30GE ? 'hasTooltip' : 'hasTip'; $edit_item_txt = JText::_('FLEXI_EDIT_ITEM'); // hide dashboard buttons $dashboard_buttons_hide = $this->params->get('dashboard_buttons_hide', array()); $dashboard_buttons_hide = FLEXIUtilities::paramToArray($dashboard_buttons_hide); $sbtns = array_flip($dashboard_buttons_hide); $skip_content_fieldset = isset($sbtns['items']) && isset($sbtns['additem']) && isset($sbtns['cats']) && isset($sbtns['addcat']) && isset($sbtns['comments']); $skip_types_fieldset = isset($sbtns['types']) && isset($sbtns['addtype']) && isset($sbtns['fields']) && isset($sbtns['addfield']) && isset($sbtns['tags']) && isset($sbtns['addtag']) && isset($sbtns['files']); $skip_contentviewing_fieldset = isset($sbtns['templates']) && isset($sbtns['index']) && isset($sbtns['stats']); $skip_users_fieldset = isset($sbtns['users']) && isset($sbtns['adduser']) && isset($sbtns['groups']) && isset($sbtns['addgroup']); $skip_expert_fieldset = isset($sbtns['import']) && isset($sbtns['plgfields']) && isset($sbtns['plgsystem']) && isset($sbtns['plgflexicontent']); // disable dashboard sliders $dashboard_sliders_disable = $this->params->get('dashboard_sliders_disable', array()); $dashboard_sliders_disable = FLEXIUtilities::paramToArray($dashboard_sliders_disable); // Other options $modal_item_edit = $this->params->get('dashboard_modal_item_edit', 1); $onclick_modal_edit = $modal_item_edit ? 'onclick="var url = jQuery(this).attr(\'href\'); fc_showDialog(url, \'fc_modal_popup_container\'); return false;"' : ''; $disable_fc_logo = $this->params->get('dashboard_disable_fc_logo', 0); $hide_fc_license_credits = $this->params->get('dashboard_hide_fc_license_credits', 1); /* hide inside sliders */ // Get/Check PHP requiremenets $php_lims = flexicontent_html::checkPHPLimits(); $ssliders = array_flip($dashboard_sliders_disable); $skip_sliders = isset($sbtns['pending']) && isset($sbtns['revised']) && isset($sbtns['inprogress']) && isset($sbtns['draft']) && isset($sbtns['version']); $skip_sliders = $skip_sliders && $this->dopostinstall && $this->allplgpublish && !$hide_fc_license_credits && !isset($php_lims['warning']); // ensures the PHP version is correct if (version_compare(PHP_VERSION, FLEXI_PHP_NEEDED, '<')) { echo '<div class="fc-mssg fc-error">'; echo JText::sprintf('FLEXI_UPGRADE_PHP_VERSION_GE', FLEXI_PHP_NEEDED) . '<br/>';
function display($tpl = null) { $mainframe = JFactory::getApplication(); //initialise variables $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $option = JRequest::getCmd('option'); $context = 'com_flexicontent'; $task = JRequest::getVar('task', ''); $cid = JRequest::getVar('cid', array()); $cparams = JComponentHelper::getParams('com_flexicontent'); $this->setLayout('import'); //initialise variables $user = JFactory::getUser(); $document = JFactory::getDocument(); $context = 'com_flexicontent'; $has_zlib = version_compare(PHP_VERSION, '5.4.0', '>='); FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); JHTML::_('behavior.tooltip'); //add css to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } // Get filter vars $filter_order = $mainframe->getUserStateFromRequest($context . '.import.filter_order', 'filter_order', '', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest($context . '.import.filter_order_Dir', 'filter_order_Dir', '', 'word'); // Get session information $session = JFactory::getSession(); $conf = $session->get('csvimport_config', "", 'flexicontent'); $conf = unserialize($conf ? $has_zlib ? zlib_decode(base64_decode($conf)) : base64_decode($conf) : ""); $lineno = $session->get('csvimport_lineno', 999999, 'flexicontent'); $session->set('csvimport_parse_log', null, 'flexicontent'); // Get User's Global Permissions $perms = FlexicontentHelperPerm::getPerm(); // Create Submenu (and also check access to current view) FLEXISubmenu('CanImport'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_IMPORT'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'import'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $toolbar = JToolBar::getInstance('toolbar'); if (!empty($conf)) { if ($task != 'processcsv') { $ctrl_task = FLEXI_J16GE ? 'import.processcsv' : 'processcsv'; $import_btn_title = empty($lineno) ? 'FLEXI_IMPORT_START_TASK' : 'FLEXI_IMPORT_CONTINUE_TASK'; JToolBarHelper::custom($ctrl_task, 'save.png', 'save.png', $import_btn_title, $list_check = false); } $ctrl_task = FLEXI_J16GE ? 'import.clearcsv' : 'clearcsv'; JToolBarHelper::custom($ctrl_task, 'cancel.png', 'cancel.png', 'FLEXI_IMPORT_CLEAR_TASK', $list_check = false); } else { $ctrl_task = FLEXI_J16GE ? 'import.initcsv' : 'initcsv'; JToolBarHelper::custom($ctrl_task, 'import.png', 'import.png', 'FLEXI_IMPORT_PREPARE_TASK', $list_check = false); $ctrl_task = FLEXI_J16GE ? 'import.testcsv' : 'testcsv'; JToolBarHelper::custom($ctrl_task, 'test.png', 'test.png', 'FLEXI_IMPORT_TEST_FILE_FORMAT', $list_check = false); } //JToolBarHelper::Back(); if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } if (!empty($conf) && $task == 'processcsv') { $this->assignRef('conf', $conf); parent::display('process'); return; } // Get types $query = 'SELECT id, name' . ' FROM #__flexicontent_types' . ' WHERE published = 1' . ' ORDER BY name ASC'; $db->setQuery($query); $types = $db->loadObjectList('id'); // Get Languages $languages = FLEXI_FISH || FLEXI_J16GE ? FLEXIUtilities::getLanguages('code') : array(); // Get categories global $globalcats; $categories = $globalcats; if (!empty($conf)) { $this->assignRef('conf', $conf); $this->assignRef('cparams', $cparams); $this->assignRef('types', $types); $this->assignRef('languages', $languages); $this->assignRef('categories', $globalcats); parent::display('list'); return; } // ****************** // Create form fields // ****************** $lists['type_id'] = flexicontent_html::buildtypesselect($types, 'type_id', '', true, 'class="fcfield_selectval" size="1"', 'type_id'); $actions_allowed = array('core.create'); // Creating categorories tree for item assignment, we use the 'create' privelege // build the secondary categories select list $class = "fcfield_selectmulval"; $attribs = 'multiple="multiple" size="10" class="' . $class . '"'; $fieldname = FLEXI_J16GE ? 'seccats[]' : 'seccats[]'; $lists['seccats'] = flexicontent_cats::buildcatselect($categories, $fieldname, '', false, $attribs, false, true, $actions_allowed, $require_all = true); // build the main category select list $attribs = 'class="fcfield_selectval"'; $fieldname = FLEXI_J16GE ? 'maincat' : 'maincat'; $lists['maincat'] = flexicontent_cats::buildcatselect($categories, $fieldname, '', 2, $attribs, false, true, $actions_allowed); /* // build the main category select list $lists['maincat'] = flexicontent_cats::buildcatselect($categories, 'maincat', '', 0, 'class="inputbox" size="10"', false, false); // build the secondary categories select list $lists['seccats'] = flexicontent_cats::buildcatselect($categories, 'seccats[]', '', 0, 'class="inputbox" multiple="multiple" size="10"', false, false); */ //build languages list // Retrieve author configuration $db->setQuery('SELECT author_basicparams FROM #__flexicontent_authors_ext WHERE user_id = ' . $user->id); if ($authorparams = $db->loadResult()) { $authorparams = FLEXI_J16GE ? new JRegistry($authorparams) : new JParameter($authorparams); } $allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed', null); $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs); // We will not use the default getInput() function of J1.6+ since we want to create a radio selection field with flags // we could also create a new class and override getInput() method but maybe this is an overkill, we may do it in the future if (FLEXI_FISH || FLEXI_J16GE) { $default_lang = $cparams->get('import_lang', '*'); $lists['languages'] = flexicontent_html::buildlanguageslist('language', '', $default_lang, 6, $allowed_langs, $published_only = true); } else { $default_lang = flexicontent_html::getSiteDefaultLang(); $_langs[] = JHTML::_('select.option', $default_lang, JText::_('Default') . ' (' . flexicontent_html::getSiteDefaultLang() . ')'); $lists['languages'] = JHTML::_('select.radiolist', $_langs, 'language', $class = '', 'value', 'text', $default_lang); } $default_state = $cparams->get('import_state', 1); $lists['states'] = flexicontent_html::buildstateslist('state', '', $default_state, 2); // Ignore warnings because component may not be installed $warnHandlers = JERROR::getErrorHandling(E_WARNING); JERROR::setErrorHandling(E_WARNING, 'ignore'); if (FLEXI_J30GE) { // J3.0+ adds an warning about component not installed, commented out ... till time ... $fleximport_comp_enabled = false; //JComponentHelper::isEnabled('com_fleximport'); } else { $fleximport_comp = JComponentHelper::getComponent('com_fleximport', true); $fleximport_comp_enabled = $fleximport_comp && $fleximport_comp->enabled; } // Reset the warning handler(s) foreach ($warnHandlers as $mode) { JERROR::setErrorHandling(E_WARNING, $mode); } if ($fleximport_comp_enabled) { $fleximport = JText::sprintf('FLEXI_FLEXIMPORT_INSTALLED', JText::_('FLEXI_FLEXIMPORT_INFOS')); } else { $fleximport = JText::sprintf('FLEXI_FLEXIMPORT_NOT_INSTALLED', JText::_('FLEXI_FLEXIMPORT_INFOS')); } // ******************************************************************************** // Get field names (from the header line (row 0), and remove it form the data array // ******************************************************************************** $file_field_types_list = '"image","file"'; $q = 'SELECT id, name, label, field_type FROM #__flexicontent_fields AS fi' . ' WHERE fi.field_type IN (' . $file_field_types_list . ')'; $db->setQuery($q); $file_fields = $db->loadObjectList('name'); //assign data to template $this->assignRef('lists', $lists); $this->assignRef('cid', $cid); $this->assignRef('user', $user); $this->assignRef('fleximport', $fleximport); $this->assignRef('cparams', $cparams); $this->assignRef('file_fields', $file_fields); parent::display($tpl); }
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.'" />'); } } } }
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 . '" />'); } } } }
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 . '" />'); } } } }
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; } } }
function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { if (!in_array($field->field_type, self::$field_types)) { return; } $field->label = JText::_($field->label); $field->{$prop} = ''; $values = $values ? $values : $field->value; $show_total_only = $field->parameters->get('show_total_only', 0); $total_show_auto_btn = $field->parameters->get('total_show_auto_btn', 0); $total_show_list = $field->parameters->get('total_show_list', 0); // ******************************************* // Check for special display : total info only // ******************************************* if ($prop == 'display_total') { $display_total = true; } else { if ($show_total_only == 1 || $show_total_only == 2 && count($values)) { $app = JFactory::getApplication(); $view = JRequest::getVar('view'); $option = JRequest::getVar('option'); $isItemsManager = $app->isAdmin() && $view == 'items' && $option == 'com_flexicontent'; $total_in_view = $field->parameters->get('total_in_view', array('backend')); $total_in_view = FLEXIUtilities::paramToArray($total_in_view); $display_total = $isItemsManager && in_array('backend', $total_in_view) || in_array($view, $total_in_view); } else { $display_total = false; } } // *********************************************************** // Create total info and terminate if not adding the item list // *********************************************************** if ($display_total) { $total_append_text = $field->parameters->get('total_append_text', ''); $field->{$prop} .= '<span class="fcrelation_field_total">' . count($values) . ' ' . $total_append_text . '</span>'; // Terminate if not adding any extra information if (!$total_show_list && !$total_show_auto_btn) { return; } // Override the item list HTML parameter ... $total_relitem_html = $field->parameters->get('total_relitem_html', ''); if ($total_relitem_html) { $field->parameters->set('relitem_html', $total_relitem_html); } } // *********************************************************** // Prepare item list data for rendering the related items list // *********************************************************** if ($field->field_type == 'relation_reverse') { $reverse_field = $field->parameters->get('reverse_field', 0); if (!$reverse_field) { $field->{$prop} .= 'Field [id:' . $field->id . '] : ' . JText::_('FLEXI_FIELD_NO_FIELD_SELECTED'); return; } $_itemids_catids = null; // Always ignore passed items, the DB query will determine the items } else { // Compatibility with old values, we no longer serialize all values to one, this way the field can be reversed !!! $values = ($field_data = @unserialize($values)) ? $field_data : $field->value; // No related items, just return empty display if (!$values || !count($values)) { return; } $_itemids_catids = array(); foreach ($values as $i => $val) { list($itemid, $catid) = explode(":", $val); $_itemids_catids[$itemid] = new stdClass(); $_itemids_catids[$itemid]->itemid = $itemid; $_itemids_catids[$itemid]->catid = $catid; $_itemids_catids[$itemid]->value = $val; } } // ********************************************** // Create the submit button for auto related item // ********************************************** $auto_relate_curritem = $field->parameters->get('auto_relate_curritem', 0); $auto_relate_menu_itemid = $field->parameters->get('auto_relate_menu_itemid', 0); $auto_relate_position = $field->parameters->get('auto_relate_position', 0); $auto_rel_btn = ''; if ($auto_relate_curritem && $auto_relate_menu_itemid && (!$display_total || $total_show_auto_btn)) { $_submit_text = $field->parameters->get('auto_relate_submit_text', 'FLEXI_ADD_RELATED'); $_show_to_unauth = $field->parameters->get('auto_relate_show_to_unauth', 0); $auto_relations[0] = new stdClass(); $auto_relations[0]->itemid = $item->id; $auto_relations[0]->fieldid = $field->id; $category = null; $auto_rel_btn = flexicontent_html::addbutton($field->parameters, $category, $auto_relate_menu_itemid, $_submit_text, $auto_relations, $_show_to_unauth); } // ***************************** // Finally, create the item list // ***************************** if (!$display_total || $total_show_list) { $add_before = $auto_rel_btn && ($auto_relate_position == 0 || $auto_relate_position == 2); $add_after = $auto_rel_btn && ($auto_relate_position == 1 || $auto_relate_position == 2); $field->{$prop} .= '' . ($add_before ? $auto_rel_btn : '') . FlexicontentFields::getItemsList($field->parameters, $_itemids_catids, $isform = 0, @$reverse_field, $field, $item) . ($add_after ? $auto_rel_btn : ''); } else { if ($auto_rel_btn) { $field->{$prop} .= $auto_rel_btn; } } }
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; }
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 . '" />'); } } } }