/** * CP Values view display method * @return void **/ function display($tpl = null) { global $option; $this->_context = $option . 'tags'; // nombre del contexto $this->cid = JRequest::getVar('cid', 0, '', 'int'); $document = JFactory::getDocument(); $script = JUri::root() . '/administrator/components/com_customproperties/includes/customproperties_ext.js'; $document->addScript($script); $app =& JFactory::getApplication(); $user = JFactory::getUser(); $aid = $user->get('aid', 0); $gid = $user->get('gid', 0); $ce_file = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_customproperties' . DS . 'contentelement.class.php'; require_once $ce_file; // get the content element $option = JRequest::getVar('contentname'); if (!$option) { $ce = getContentElementByName("content"); } else { $ce = getContentElementByOption($option); } $this->assignRef('ce', $ce); $query = " SELECT DISTINCT f.id AS fid, f.label AS name, v.id AS vid, v.label, v.access_group AS ag\r\n FROM #__custom_properties AS cp\r\n\t\t\tINNER JOIN #__custom_properties_fields AS f\r\n\t\t\tON (cp.field_id = f.id)\r\n\t\t\tINNER JOIN #__custom_properties_values AS v\r\n\t\t\tON (cp.value_id = v.id)\r\n WHERE cp.ref_table = '" . $ce->table . "'\r\n\t\t\tAND cp.content_id = '{$this->cid}'\r\n\t\t\tAND f.published = '1'\r\n\t\t\tAND f.access <= '{$aid}'\r\n ORDER BY f.ordering, v.ordering "; $database = JFactory::getDBO(); $database->setQuery($query); $database->getErrorMsg(); $this->assignRef('tags', $database->loadObjectList()); $this->assignRef('app', $app); $this->assignRef('gid', $gid); parent::display($tpl); }
/** * Plugin method with the same name as the event will be called automatically. */ function onPrepareContent(&$row) { global $cp_config; // make sure component is installed $config_file = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_customproperties' . DS . 'cp_config.php'; $helper_file = JPATH_ROOT . DS . 'components' . DS . 'com_customproperties' . DS . 'helper.php'; $ce_file = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_customproperties' . DS . 'contentelement.class.php'; if (!file_exists($config_file) || !file_exists($helper_file) || !file_exists($ce_file)) { echo $row->text .= "<span class=\"alert\">Fatal Error: the component <b>com_customproperties</b> is not/badly installed. " . "Get it at <a href=\"http://www.solidsystem.it\">www.solidsystem.it</a></span>"; return true; } else { require $config_file; require_once $helper_file; require_once $ce_file; } // get the content element $option = JRequest::getVar('option'); if (!($ce = getContentElementByOption($option))) { return; } $this->_ce =& $ce; // parameter $params =& $this->_params; $tags_position = $params->def('tags_position', '0'); $show_tag_name = $params->def('show_tag_name', $cp_config['show_tag_name']); $linked_tags = $params->def('linked_tags', $cp_config['linked_tags']); $url_format = $params->def('url_format', $cp_config['url_format']); if ($cp_config['use_cp_css']) { $document = JFactory::getDocument(); $document->addStyleSheet('components/com_customproperties/css/customproperties.css'); } $params->def('frontend_tagging', $cp_config['frontend_tagging']); $params->def('editing_level', $cp_config['editing_level']); $params->def('publishing_group', $cp_config['publishing_group']); //append tag to meta only when in "detail / article" view if (JRequest::getVar('view', '') === $ce->href_view || JRequest::getVar('task', '') === $ce->href_task) { $tag_in_meta = $params->def('tag_in_meta', '1'); } else { $tag_in_meta = $params->set('tag_in_meta', '0'); } // saving item id for replacer $this->_cid = $row->id; // in case we are under PHP 4 $GLOBALS['botCpTagsContentId'] = $row->id; $GLOBALS['botCpTagsParams'] =& $this->_params; $GLOBALS['botCpTagsCe'] =& $this->_ce; switch ($tags_position) { case 0: // bottom $row->text .= showTags($ce, $row, $params, $tag_in_meta); break; case 1: // top $row->text = showTags($ce, $row, $params, $tag_in_meta) . $row->text; break; case 2: // custom if (strpos($row->text, 'cptags') === false) { return true; } // expression to search for $regex = '/{cptags}/i'; // find all instances of mambot and put in $matches preg_match_all($regex, $row->text, $matches); // Count mambots $count = count($matches[0]); if ($count) { $row->text = preg_replace_callback($regex, array('plgContentCpTags', 'CpTags_replacer'), $row->text); } break; } unset($GLOBALS['botCpTagsContentId']); unset($GLOBALS['botCpTagsParams']); unset($GLOBALS['botCpTagsCe']); return true; }