本文整理汇总了PHP中JHelperTags类的典型用法代码示例。如果您正苦于以下问题:PHP JHelperTags类的具体用法?PHP JHelperTags怎么用?PHP JHelperTags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JHelperTags类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$section = $this->state->get('category.section') ? $this->state->get('category.section') . '.' : '';
$this->canDo = JHelperContent::getActions($this->state->get('category.component'), $section . 'category', $this->item->id);
$this->assoc = $this->get('Assoc');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
// Check for tag type
$this->checkTags = JHelperTags::getTypes('objectList', array($this->state->get('category.extension') . '.category'), true);
JFactory::getApplication()->input->set('hidemainmenu', true);
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例2: onCCK_FieldPrepareContent
public function onCCK_FieldPrepareContent(&$field, $value = '', &$config = array())
{
if (self::$type != $field->type) {
return;
}
parent::g_onCCK_FieldPrepareContent($field, $config);
$html = '';
if ($value || ($config['client'] == 'list' || $config['client'] == 'item')) {
$location = isset($config['location']) && $config['location'] ? $config['location'] : 'joomla_article';
$properties = array('context');
$properties = JCck::callFunc('plgCCK_Storage_Location' . $location, 'getStaticProperties', $properties);
/* temporary fix for content categories */
if ($properties['context'] == 'com_categories.category') {
$properties['context'] = 'com_content.category';
// todo: dynamic context per extension (#__categories)
}
/* temporary fix for content categories */
if (is_object($value) && isset($value->tags)) {
$value = $value->tags;
}
$tags = new JHelperTags();
$tags->getItemTags($properties['context'], $config['pk']);
$tagLayout = new JLayoutFile('joomla.content.tags');
$html = $tagLayout->render($tags->itemTags);
}
// Set
$field->value = $value;
$field->html = $html;
}
示例3: getItem
/**
* Method to get an object.
*
* @param integer $id The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($id = null)
{
if (!$id) {
$id = $this->getState($this->getName() . '.id');
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.id, a.title, a.description, a.votes, a.record_date, a.catid, a.user_id, a.status_id, a.hits, a.params, ' . $query->concatenate(array('a.id', 'a.alias'), '-') . ' AS slug, ' . 'b.name, b.username, ' . 'c.title AS category, ' . $query->concatenate(array('c.id', 'c.alias'), '-') . ' AS catslug, ' . 'd.name AS status_name, d.params AS status_params, d.default AS status_default');
$query->from($db->quoteName('#__uideas_items', 'a'));
$query->leftJoin($db->quoteName('#__users', 'b') . ' ON a.user_id = b.id');
$query->leftJoin($db->quoteName('#__categories', 'c') . ' ON a.catid = c.id');
$query->leftJoin($db->quoteName('#__uideas_statuses', 'd') . ' ON a.status_id = d.id');
$query->where('a.id = ' . (int) $id);
$db->setQuery($query);
$this->item = $db->loadObject();
// Prepare status object
if ($this->item !== null and (int) $this->item->id > 0) {
$this->prepareStatus($this->item);
$tags = new JHelperTags();
$this->item->tags = $tags->getItemTags('com_userideas.item', $this->item->id);
$registry = new Joomla\Registry\Registry();
$registry->loadString($this->item->params);
$this->item->params = $registry;
}
return $this->item;
}
示例4: getContentList
public static function getContentList($params)
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
//$matchtype = $params->get('matchtype', 'all');
$maximum = $params->get('maximum', 5);
$tagsHelper = new JHelperTags();
$option = $app->input->get('option');
$view = $app->input->get('view');
$prefix = $option . '.' . $view;
$id = (array) $app->input->getObject('id');
$selectedTag = $params->get('selected_tag');
// Strip off any slug data.
foreach ($id as $id) {
if (substr_count($id, ':') > 0) {
$idexplode = explode(':', $id);
$id = $idexplode[0];
}
}
$tagsToMatch = $selectedTag;
if (!$tagsToMatch || is_null($tagsToMatch)) {
return $results = false;
}
$query = $tagsHelper->getTagItemsQuery($tagsToMatch, $typesr = null, $includeChildren = false, $orderByOption = 'c.core_title', $orderDir = 'ASC', $anyOrAll = true, $languageFilter = 'all', $stateFilter = '0,1');
$db->setQuery($query, 0, $maximum);
$results = $db->loadObjectList();
foreach ($results as $result) {
$explodedAlias = explode('.', $result->type_alias);
$result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1] . '&id=' . $result->content_item_id . '-' . $result->core_alias;
}
return $results;
}
示例5: getList
/**
* Get a list of tags
*
* @param JRegistry &$params Module parameters
*
* @return mixed Results array / null
*/
public static function getList(&$params)
{
$app = JFactory::getApplication();
$option = $app->input->get('option');
$view = $app->input->get('view');
// For now assume com_tags and com_users do not have tags.
// This module does not apply to list views in general at this point.
if ($option == 'com_tags' || $view == 'category' || $option == 'com_users') {
return;
}
$db = JFactory::getDbo();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$matchtype = $params->get('matchtype', 'all');
$maximum = $params->get('maximum', 5);
$tagsHelper = new JHelperTags();
$prefix = $option . '.' . $view;
$id = $app->input->getInt('id');
$tagsToMatch = $tagsHelper->getTagIds($id, $prefix);
if (!$tagsToMatch || is_null($tagsToMatch)) {
return;
}
$tagCount = substr_count($tagsToMatch, ',') + 1;
$query = $db->getQuery(true)->select(array($db->quoteName('m.tag_id'), $db->quoteName('m.core_content_id'), $db->quoteName('m.content_item_id'), $db->quoteName('m.type_alias'), 'COUNT( ' . $db->quoteName('tag_id') . ') AS ' . $db->quoteName('count'), $db->quoteName('t.access'), $db->quoteName('t.id'), $db->quoteName('ct.router'), $db->quoteName('cc.core_title'), $db->quoteName('cc.core_alias'), $db->quoteName('cc.core_catid'), $db->quoteName('cc.core_language')));
$query->from($db->quoteName('#__contentitem_tag_map', 'm'));
$query->join('INNER', $db->quoteName('#__tags', 't') . ' ON m.tag_id = t.id')->join('INNER', $db->quoteName('#__ucm_content', 'cc') . ' ON m.core_content_id = cc.core_content_id')->join('INNER', $db->quoteName('#__content_types', 'ct') . ' ON m.type_alias = ct.type_alias');
$query->where($db->quoteName('m.tag_id') . ' IN (' . $tagsToMatch . ')');
$query->where('t.access IN (' . $groups . ')');
$query->where('(cc.core_access IN (' . $groups . ') OR cc.core_access = 0)');
// Don't show current item
$query->where('(' . $db->quoteName('m.content_item_id') . ' <> ' . $id . ' OR ' . $db->quoteName('m.type_alias') . ' <> ' . $db->quote($prefix) . ')');
// Only return published tags
$query->where($db->quoteName('cc.core_state') . ' = 1 ');
// Optionally filter on language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('cc.core_language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
$query->group($db->quoteName(array('m.core_content_id')));
if ($matchtype == 'all' && $tagCount > 0) {
$query->having('COUNT( ' . $db->quoteName('tag_id') . ') = ' . $tagCount);
} elseif ($matchtype == 'half' && $tagCount > 0) {
$tagCountHalf = ceil($tagCount / 2);
$query->having('COUNT( ' . $db->quoteName('tag_id') . ') >= ' . $tagCountHalf);
}
$query->order($db->quoteName('count') . ' DESC');
$db->setQuery($query, 0, $maximum);
$results = $db->loadObjectList();
foreach ($results as $result) {
$explodedAlias = explode('.', $result->type_alias);
$result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1] . '&id=' . $result->content_item_id . '-' . $result->core_alias;
}
return $results;
}
示例6: onAfterDelete
/**
* The event which runs after deleting a record
*
* @param DataModel &$model The model which calls this event
* @param integer $oid The PK value of the record which was deleted
*
* @return boolean True to allow the deletion without errors
*/
public function onAfterDelete(&$model, $oid)
{
// If this resource has tags, delete the tags first
if ($model->hasTags()) {
$tagsHelper = new \JHelperTags();
$tagsHelper->typeAlias = $model->getContentType();
if (!$tagsHelper->deleteTagData($model, $oid)) {
throw new \Exception('Error deleting Tags');
}
}
}
示例7: onAfterDelete
/**
* The event which runs after deleting a record
*
* @param FOFTable &$table The table which calls this event
* @param integer $oid The PK value of the record which was deleted
*
* @return boolean True to allow the deletion without errors
*/
public function onAfterDelete(&$table, $oid)
{
// If this resource has tags, delete the tags first
if ($table->hasTags()) {
$tagsHelper = new JHelperTags();
$tagsHelper->typeAlias = $table->getAssetKey();
if (!$tagsHelper->deleteTagData($table, $oid)) {
$table->setError('Error deleting Tags');
return false;
}
}
}
示例8: getTags
/**
* This method returns category description.
*
* <code>
* $categoryId = 1;
*
* $category = new Userideas\Category\Category(\JFactory::getDbo());
* $category->load($categoryId);
*
* $category->setTagsHelper(new \JHelperTags);
* </code>
*
* @param bool $getTagData If true, data from the tags table will be included, defaults to true.
*
* @return null|array
*/
public function getTags($getTagData = true)
{
if ($this->tags === null and $this->tagsHelper instanceof \JHelperTags) {
$this->tags = $this->tagsHelper->getItemTags($this->contentAlias, $this->id, $getTagData);
}
return $this->tags;
}
示例9: display
public function display($tpl = null)
{
//Get User Objects
$user = JFactory::getUser();
$canDo = PlayJoomHelper::getActions();
// get the Data
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->script = $script = $this->get('Script');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode('<br />', $errors));
return false;
}
if ($canDo->get('core.edit') || $canDo->get('core.create') && !JRequest::getVar('id') || JAccess::check($user->get('id'), 'core.admin') == 1) {
// Set the toolbar
$this->addToolBar();
// Display the template
parent::display($tpl);
} else {
JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Check for tag type
$this->checkTags = JHelperTags::getTypes('objectList', array('com_playjoom.track'), true);
// Set the document
$this->setDocument();
}
示例10: display
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$section = $this->state->get('category.section') ? $this->state->get('category.section') . '.' : '';
$this->canDo = JHelperContent::getActions($this->state->get('category.component'), $section . 'category', $this->item->id);
$this->assoc = $this->get('Assoc');
$input = JFactory::getApplication()->input;
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
// Check for tag type
$this->checkTags = JHelperTags::getTypes('objectList', array($this->state->get('category.extension') . '.category'), true);
$input->set('hidemainmenu', true);
if ($this->getLayout() == 'modal') {
$this->form->setFieldAttribute('language', 'readonly', 'true');
$this->form->setFieldAttribute('parent_id', 'readonly', 'true');
}
$this->addToolbar();
DigiComHelperDigiCom::addSubmenu('categories');
$this->sidebar = DigiComHelperDigiCom::renderSidebar();
parent::display($tpl);
}
示例11: getOptions
/**
* Method to get a list of tags
*
* @return array The field option objects.
*
* @since 3.1
*/
protected function getOptions()
{
$options = array();
$published = $this->element['published'] ? $this->element['published'] : array(0, 1);
$name = (string) $this->element['name'];
$db = F0FPlatform::getInstance()->getDbo();
$query = $db->getQuery(true)->select('a.id AS value, a.path, a.title AS text, a.level, a.published')->from('#__tags AS a')->join('LEFT', $db->quoteName('#__tags') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
$item = $this->form->getModel()->getItem();
if ($item instanceof F0FTable) {
// Fake value for selected tags
$keyfield = $item->getKeyName();
$content_id = $item->{$keyfield};
$type = $item->getContentType();
$selected_query = $db->getQuery(true);
$selected_query->select('tag_id')->from('#__contentitem_tag_map')->where('content_item_id = ' . (int) $content_id)->where('type_alias = ' . $db->quote($type));
$db->setQuery($selected_query);
$this->value = $db->loadColumn();
}
// Ajax tag only loads assigned values
if (!$this->isNested()) {
// Only item assigned values
$values = (array) $this->value;
F0FUtilsArray::toInteger($values);
$query->where('a.id IN (' . implode(',', $values) . ')');
}
// Filter language
if (!empty($this->element['language'])) {
$query->where('a.language = ' . $db->quote($this->element['language']));
}
$query->where($db->quoteName('a.alias') . ' <> ' . $db->quote('root'));
// Filter to only load active items
// Filter on the published state
if (is_numeric($published)) {
$query->where('a.published = ' . (int) $published);
} elseif (is_array($published)) {
F0FUtilsArray::toInteger($published);
$query->where('a.published IN (' . implode(',', $published) . ')');
}
$query->group('a.id, a.title, a.level, a.lft, a.rgt, a.parent_id, a.published, a.path')->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try {
$options = $db->loadObjectList();
} catch (RuntimeException $e) {
return false;
}
// Prepare nested data
if ($this->isNested()) {
$this->prepareOptionsNested($options);
} else {
$options = JHelperTags::convertPathsToNames($options);
}
return $options;
}
示例12: searchAjax
/**
* Method to search tags with AJAX
*
* @return void
*/
public function searchAjax()
{
// Required objects
$app = JFactory::getApplication();
// Receive request data
$filters = array('like' => trim($app->input->get('like', null)), 'title' => trim($app->input->get('title', null)), 'flanguage' => $app->input->get('flanguage', null), 'published' => $app->input->get('published', 1, 'integer'), 'parent_id' => $app->input->get('parent_id', null));
if ($results = JHelperTags::searchTags($filters)) {
// Output a JSON object
echo json_encode($results);
}
$app->close();
}
示例13: getOptions
/**
* Method to get a list of tags
*
* @return array The field option objects.
*
* @since 3.1
*/
protected function getOptions()
{
$published = $this->element['published'] ? $this->element['published'] : array(0, 1);
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('DISTINCT a.id AS value, a.path, a.title AS text, a.level, a.published, a.lft')->from('#__tags AS a')->join('LEFT', $db->qn('#__tags') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
// Filter language
if (!empty($this->element['language'])) {
$query->where('a.language = ' . $db->q($this->element['language']));
}
$query->where($db->qn('a.lft') . ' > 0');
// Filter on the published state
if (is_numeric($published)) {
$query->where('a.published = ' . (int) $published);
} elseif (is_array($published)) {
JArrayHelper::toInteger($published);
$query->where('a.published IN (' . implode(',', $published) . ')');
}
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try {
$options = $db->loadObjectList();
} catch (RuntimeException $e) {
return array();
}
// Block the possibility to set a tag as it own parent
if ($this->form->getName() == 'com_tags.tag') {
$id = (int) $this->form->getValue('id', 0);
foreach ($options as $option) {
if ($option->value == $id) {
$option->disable = true;
}
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
// Prepare nested data
if ($this->isNested()) {
$this->prepareOptionsNested($options);
} else {
$options = JHelperTags::convertPathsToNames($options);
}
return $options;
}
示例14: getList
public static function getList(&$params)
{
$list = array();
$show_tag = $params->get('item_tags_display', 0);
$show_description = $params->get('item_desc_display', 1);
$maxlength_desc = $params->get('item_desc_maxlength', 200);
$show_title = $params->get('title_display');
$maxlength_title = $params->get('item_title_maxlength', 25);
$articles = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$appParams = $app->getParams();
$articles->setState('params', $appParams);
$articles->setState('list.start', 0);
$articles->setState('list.limit', (int) $params->get('count', 0));
$articles->setState('filter.published', 1);
$access = !JComponentHelper::getParams('com_content')->get('show_noauth');
$authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
$articles->setState('filter.access', $access);
$catids = $params->get('catid');
if ($catids) {
if ($params->get('show_child_category_articles', 0) && (int) $params->get('levels', 0) > 0) {
$categories = JModelLegacy::getInstance('Categories', 'ContentModel', array('ignore_request' => true));
$categories->setState('params', $appParams);
$levels = $params->get('levels', 1) ? $params->get('levels', 1) : 9999;
$categories->setState('filter.get_children', $levels);
$categories->setState('filter.published', 1);
$categories->setState('filter.access', $access);
$additional_catids = array();
foreach ($catids as $catid) {
$categories->setState('filter.parentId', $catid);
$recursive = true;
$items = $categories->getItems($recursive);
if ($items) {
foreach ($items as $category) {
$condition = $category->level - $categories->getParent()->level <= $levels;
if ($condition) {
$additional_catids[] = $category->id;
}
}
}
}
$catids = array_unique(array_merge($catids, $additional_catids));
}
$articles->setState('filter.category_id', $catids);
}
$articles->setState('list.ordering', $params->get('article_ordering', 'a.ordering'));
$articles->setState('list.direction', $params->get('article_ordering_direction', 'ASC'));
$articles->setState('filter.featured', $params->get('show_front', 'show'));
$articles->setState('filter.language', $app->getLanguageFilter());
$items = $articles->getItems();
if (!empty($items)) {
foreach ($items as &$item) {
$item->slug = $item->id . ':' . $item->alias;
$item->catslug = $item->catid ? $item->catid . ':' . $item->category_alias : $item->catid;
if ($access || in_array($item->access, $authorised)) {
$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
} else {
$app = JFactory::getApplication();
$menu = $app->getMenu();
$menuitems = $menu->getItems('link', 'index.php?option=com_users&view=login');
if (isset($menuitems[0])) {
$Itemid = $menuitems[0]->id;
} elseif ($app->input->getInt('Itemid') > 0) {
$Itemid = $app->input->getInt('Itemid');
}
$item->link = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $Itemid);
}
$item->_introtext = self::_cleanText($item->introtext);
$item->_description = self::_trimEncode($item->_introtext) != '' && $show_description ? self::truncate($item->_introtext, $maxlength_desc) : '';
$item->tags = '';
if ($show_tag && class_exists('JHelperTags')) {
$tagLayout = new JLayoutFile('joomla.content.tags');
$tags = new JHelperTags();
$tags->getItemTags('com_content.article', $item->id);
$item->tags = $tagLayout->render($tags->itemTags);
}
$item->sub_title = $show_title ? self::truncate($item->title, $maxlength_title) : '';
$image = self::createThumbs($item, $params, 'imgf');
$attr = ' ';
$attr .= isset($image['title']) ? ' title = "' . $image['title'] . '"' : '';
$attr .= isset($image['alt']) ? ' alt = "' . $image['alt'] . '"' : '';
$attr .= isset($image['class']) ? ' class = "' . $image['class'] . '"' : '';
$item->image_src = isset($image['src']) ? $image['src'] : '';
$item->image_attr = $attr;
$item->link_target = self::linkTarget($params->get('link_target'));
$list[] = $item;
}
}
return $list;
}
示例15: store
/**
* Overrides JTable::store to set modified data and user id.
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success.
*
* @since 11.1
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
$this->modified = $date->toSql();
$this->modified_by = $user->get('id');
} else {
// New article. An article created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int) $this->created) {
$this->created = $date->toSql();
}
if (empty($this->created_by)) {
$this->created_by = $user->get('id');
}
}
// Verify that the alias is unique
$table = JTable::getInstance('Content', 'JTable');
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_ARTICLE_UNIQUE_ALIAS'));
return false;
}
$this->tagsHelper->typeAlias = 'com_content.article';
$this->tagsHelper->preStoreProcess($this);
$result = parent::store($updateNulls);
return $result && $this->tagsHelper->postStoreProcess($this);
}