示例#1
1
 /**
  * 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
0
 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
0
 /**
  * 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
0
 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
0
文件: helper.php 项目: 01J/topm
 /**
  * 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
0
文件: Tags.php 项目: Joal01/fof
 /**
  * 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');
         }
     }
 }
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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);
 }
示例#10
0
 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();
 }
示例#11
0
 /**
  * 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);
 }
示例#12
0
 /**
  * Overriden JTable::store to set modified data.
  *
  * @param   boolean	True to update fields even if they are null.
  * @return  boolean  True on success.
  * @since   1.6
  */
 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 newsfeed. A feed 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('Product', 'WcatalogTable');
     if ($table->load(array('category_id' => $this->category_id)) && ($table->id != $this->id || $this->id == 0))
     {
     	$this->setError(JText::_('COM_WCATALOG_ERROR_UNIQUE_ALIAS'));
     	return false;
     }
     */
     $this->tagsHelper->typeAlias = 'com_wcatalog.product';
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
示例#13
0
 /**
  * Overriden JTable::store to set modified data.
  *
  * @param   boolean	True to update fields even if they are null.
  * @return  boolean  True on success.
  * @since   1.6
  */
 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 newsfeed. A feed 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('Category', 'WcatalogTable');
     $this->tagsHelper->typeAlias = 'com_wcatalog.category';
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
示例#14
0
文件: Tags.php 项目: akeeba/fof
 /**
  * This event runs after unpublishing a record in a model
  *
  * @param   DataModel  &$model  The model which calls this event
  * @param   mixed      $data    An associative array or object to bind to the DataModel instance.
  *
  * @return  void
  */
 public function onAfterBind(&$model, &$data)
 {
     $tagField = $model->getBehaviorParam('tagFieldName', 'tags');
     if ($model->{$tagField}) {
         return;
     }
     $type = $model->getContentType();
     $model->addKnownField($tagField);
     $model->{$tagField} = $this->tagsHelper->getTagIds($model->getId(), $type);
 }
示例#15
0
文件: tag.php 项目: 01J/topm
 /**
  * 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;
 }
示例#16
0
 /**
  * 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();
 }
示例#17
0
 /**
  * Stores a contact
  *
  * @param   boolean	True to update fields even if they are null.
  *
  * @return  boolean  True on success, false on failure.
  *
  * @since   1.6
  */
 public function store($updateNulls = false)
 {
     // Transform the params field
     if (is_array($this->params)) {
         $registry = new JRegistry();
         $registry->loadArray($this->params);
         $this->params = (string) $registry;
     }
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         // Existing item
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New contact. A contact 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');
         }
     }
     // Set publish_up to null date if not set
     if (!$this->publish_up) {
         $this->publish_up = $this->_db->getNullDate();
     }
     // Set publish_down to null date if not set
     if (!$this->publish_down) {
         $this->publish_down = $this->_db->getNullDate();
     }
     // Set xreference to empty string if not set
     if (!$this->xreference) {
         $this->xreference = '';
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Contact', 'ContactTable');
     if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('COM_CONTACT_ERROR_UNIQUE_ALIAS'));
         return false;
     }
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
示例#18
0
 /**
  * Overridden JTable::store to set created/modified 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 category
         $this->modified_time = $date->toSql();
         $this->modified_user_id = $user->get('id');
     } else {
         // New category
         $this->created_time = $date->toSql();
         $this->created_user_id = $user->get('id');
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Category', 'JTable', array('dbo' => $this->getDbo()));
     if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'extension' => $this->extension)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
         return false;
     }
     $this->tagsHelper->typeAlias = $this->extension . '.category';
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
示例#19
0
 /**
  * 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;
 }
示例#20
0
 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;
 }
示例#21
0
文件: tag.php 项目: fur81/zofaxiopeu
 /**
  * Method to build an SQL query to load the list data of all items with a given tag.
  *
  * @return  string  An SQL query
  *
  * @since   3.1
  */
 protected function getListQuery()
 {
     $tagId = $this->getState('tag.id') ?: '';
     $typesr = $this->getState('tag.typesr');
     $orderByOption = $this->getState('list.ordering', 'c.core_title');
     $includeChildren = $this->state->params->get('include_children', 0);
     $orderDir = $this->getState('list.direction', 'ASC');
     $matchAll = $this->getState('params')->get('return_any_or_all', 1);
     $language = $this->getState('tag.language');
     $stateFilter = $this->getState('tag.state');
     // Optionally filter on language
     if (empty($language)) {
         $language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
     }
     $listQuery = new JHelperTags();
     $query = $listQuery->getTagItemsQuery($tagId, $typesr, $includeChildren, $orderByOption, $orderDir, $matchAll, $language, $stateFilter);
     if ($this->state->get('list.filter')) {
         $query->where($this->_db->quoteName('c.core_title') . ' LIKE ' . $this->_db->quote('%' . $this->state->get('list.filter') . '%'));
     }
     return $query;
 }
示例#22
0
文件: tags.php 项目: fur81/zofaxiopeu
 /**
  * Sets the new tags to be added/replaced to the table row
  *
  * @param   array    $newTags      New tags to be added or replaced
  * @param   boolean  $replaceTags  Replace tags (true) or add them (false)
  *
  * @return  boolean
  */
 public function setNewTags($newTags, $replaceTags)
 {
     $this->parseTypeAlias();
     return $this->tagsHelper->postStoreProcess($this->table, $newTags, $replaceTags);
 }
示例#23
0
 /**
  * Generates the head HTML and return the results as a string
  *
  * @param   JDocumentHtml  $document  The document for which the head will be created
  *
  * @return  string  The head hTML
  *
  * @since   3.5
  * @deprecated  4.0  Method code will be moved into the render method
  */
 public function fetchHead($document)
 {
     // Convert the tagids to titles
     if (isset($document->_metaTags['name']['tags'])) {
         $tagsHelper = new JHelperTags();
         $document->_metaTags['name']['tags'] = implode(', ', $tagsHelper->getTagNames($document->_metaTags['name']['tags']));
     }
     // Trigger the onBeforeCompileHead event
     $app = JFactory::getApplication();
     $app->triggerEvent('onBeforeCompileHead');
     // Get line endings
     $lnEnd = $document->_getLineEnd();
     $tab = $document->_getTab();
     $tagEnd = ' />';
     $buffer = '';
     // Generate charset when using HTML5 (should happen first)
     if ($document->isHtml5()) {
         $buffer .= $tab . '<meta charset="' . $document->getCharset() . '" />' . $lnEnd;
     }
     // Generate base tag (need to happen early)
     $base = $document->getBase();
     if (!empty($base)) {
         $buffer .= $tab . '<base href="' . $base . '" />' . $lnEnd;
     }
     // Generate META tags (needs to happen as early as possible in the head)
     foreach ($document->_metaTags as $type => $tag) {
         foreach ($tag as $name => $content) {
             if ($type == 'http-equiv' && !($document->isHtml5() && $name == 'content-type')) {
                 $buffer .= $tab . '<meta http-equiv="' . $name . '" content="' . htmlspecialchars($content, ENT_COMPAT, 'UTF-8') . '" />' . $lnEnd;
             } elseif ($type != 'http-equiv' && !empty($content)) {
                 $buffer .= $tab . '<meta ' . $type . '="' . $name . '" content="' . htmlspecialchars($content, ENT_COMPAT, 'UTF-8') . '" />' . $lnEnd;
             }
         }
     }
     // Don't add empty descriptions
     $documentDescription = $document->getDescription();
     if ($documentDescription) {
         $buffer .= $tab . '<meta name="description" content="' . htmlspecialchars($documentDescription, ENT_COMPAT, 'UTF-8') . '" />' . $lnEnd;
     }
     // Don't add empty generators
     $generator = $document->getGenerator();
     if ($generator) {
         $buffer .= $tab . '<meta name="generator" content="' . htmlspecialchars($generator, ENT_COMPAT, 'UTF-8') . '" />' . $lnEnd;
     }
     $buffer .= $tab . '<title>' . htmlspecialchars($document->getTitle(), ENT_COMPAT, 'UTF-8') . '</title>' . $lnEnd;
     // Generate link declarations
     foreach ($document->_links as $link => $linkAtrr) {
         $buffer .= $tab . '<link href="' . $link . '" ' . $linkAtrr['relType'] . '="' . $linkAtrr['relation'] . '"';
         if (is_array($linkAtrr['attribs'])) {
             if ($temp = ArrayHelper::toString($linkAtrr['attribs'])) {
                 $buffer .= ' ' . $temp;
             }
         }
         $buffer .= ' />' . $lnEnd;
     }
     $defaultCssMimes = array('text/css');
     // Generate stylesheet links
     foreach ($document->_styleSheets as $strSrc => $strAttr) {
         $buffer .= $tab . '<link rel="stylesheet" href="' . $strSrc . '"';
         if (!is_null($strAttr['mime']) && (!$document->isHtml5() || !in_array($strAttr['mime'], $defaultCssMimes))) {
             $buffer .= ' type="' . $strAttr['mime'] . '"';
         }
         if (!is_null($strAttr['media'])) {
             $buffer .= ' media="' . $strAttr['media'] . '"';
         }
         if (is_array($strAttr['attribs'])) {
             if ($temp = ArrayHelper::toString($strAttr['attribs'])) {
                 $buffer .= ' ' . $temp;
             }
         }
         $buffer .= $tagEnd . $lnEnd;
     }
     // Generate stylesheet declarations
     foreach ($document->_style as $type => $content) {
         $buffer .= $tab . '<style';
         if (!is_null($type) && (!$document->isHtml5() || !in_array($type, $defaultCssMimes))) {
             $buffer .= ' type="' . $type . '"';
         }
         $buffer .= '>' . $lnEnd;
         // This is for full XHTML support.
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '/*<![CDATA[*/' . $lnEnd;
         }
         $buffer .= $content . $lnEnd;
         // See above note
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '/*]]>*/' . $lnEnd;
         }
         $buffer .= $tab . '</style>' . $lnEnd;
     }
     $defaultJsMimes = array('text/javascript', 'application/javascript', 'text/x-javascript', 'application/x-javascript');
     // Generate script file links
     foreach ($document->_scripts as $strSrc => $strAttr) {
         $buffer .= $tab . '<script src="' . $strSrc . '"';
         if (!is_null($strAttr['mime']) && (!$document->isHtml5() || !in_array($strAttr['mime'], $defaultJsMimes))) {
             $buffer .= ' type="' . $strAttr['mime'] . '"';
         }
         if ($strAttr['defer']) {
             $buffer .= ' defer';
             if (!$document->isHtml5()) {
                 $buffer .= '="defer"';
             }
         }
         if ($strAttr['async']) {
             $buffer .= ' async';
             if (!$document->isHtml5()) {
                 $buffer .= '="async"';
             }
         }
         $buffer .= '></script>' . $lnEnd;
     }
     // Generate scripts options
     $scriptOptions = $document->getScriptOptions();
     if (!empty($scriptOptions)) {
         $buffer .= $tab . '<script type="text/javascript">' . $lnEnd;
         // This is for full XHTML support.
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//<![CDATA[' . $lnEnd;
         }
         $pretyPrint = JDEBUG && defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : false;
         $jsonOptions = json_encode($scriptOptions, $pretyPrint);
         $jsonOptions = $jsonOptions ? $jsonOptions : '{}';
         // TODO: use .extend(Joomla.optionsStorage, options) when it will be safe
         $buffer .= $tab . 'var Joomla = Joomla || {};' . $lnEnd;
         $buffer .= $tab . 'Joomla.optionsStorage = ' . $jsonOptions . ';' . $lnEnd;
         // See above note
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//]]>' . $lnEnd;
         }
         $buffer .= $tab . '</script>' . $lnEnd;
     }
     // Generate script declarations
     foreach ($document->_script as $type => $content) {
         $buffer .= $tab . '<script';
         if (!is_null($type) && (!$document->isHtml5() || !in_array($type, $defaultJsMimes))) {
             $buffer .= ' type="' . $type . '"';
         }
         $buffer .= '>' . $lnEnd;
         // This is for full XHTML support.
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//<![CDATA[' . $lnEnd;
         }
         $buffer .= $content . $lnEnd;
         // See above note
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//]]>' . $lnEnd;
         }
         $buffer .= $tab . '</script>' . $lnEnd;
     }
     // Generate script language declarations.
     if (count(JText::script())) {
         $buffer .= $tab . '<script';
         if (!$document->isHtml5()) {
             $buffer .= ' type="text/javascript"';
         }
         $buffer .= '>' . $lnEnd;
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//<![CDATA[' . $lnEnd;
         }
         $buffer .= $tab . $tab . '(function() {' . $lnEnd;
         $buffer .= $tab . $tab . $tab . 'Joomla.JText.load(' . json_encode(JText::script()) . ');' . $lnEnd;
         $buffer .= $tab . $tab . '})();' . $lnEnd;
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//]]>' . $lnEnd;
         }
         $buffer .= $tab . '</script>' . $lnEnd;
     }
     // Output the custom tags - array_unique makes sure that we don't output the same tags twice
     foreach (array_unique($document->_custom) as $custom) {
         $buffer .= $tab . $custom . $lnEnd;
     }
     return $buffer;
 }
示例#24
0
 /**
  * Add the page title and toolbar.
  *
  * @since   1.6
  */
 protected function addToolbar()
 {
     $categoryId = $this->state->get('filter.category_id');
     $component = $this->state->get('filter.component');
     $section = $this->state->get('filter.section');
     $canDo = null;
     $user = JFactory::getUser();
     $extension = JFactory::getApplication()->input->get('extension', '', 'word');
     // Get the toolbar object instance
     $bar = JToolBar::getInstance('toolbar');
     // Avoid nonsense situation.
     if ($component == 'com_categories') {
         return;
     }
     // Need to load the menu language file as mod_menu hasn't been loaded yet.
     $lang = JFactory::getLanguage();
     $lang->load($component, JPATH_BASE, null, false, false) || $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component, null, false, false) || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component, $lang->getDefault(), false, false);
     // Load the category helper.
     require_once JPATH_COMPONENT . '/helpers/categories.php';
     // Get the results for each action.
     $canDo = CategoriesHelper::getActions($component, $categoryId);
     // If a component categories title string is present, let's use it.
     if ($lang->hasKey($component_title_key = strtoupper($component . ($section ? "_{$section}" : '')) . '_CATEGORIES_TITLE')) {
         $title = JText::_($component_title_key);
     } elseif ($lang->hasKey($component_section_key = strtoupper($component . ($section ? "_{$section}" : '')))) {
         $title = JText::sprintf('COM_CATEGORIES_CATEGORIES_TITLE', $this->escape(JText::_($component_section_key)));
     } else {
         $title = JText::_('COM_CATEGORIES_CATEGORIES_BASE_TITLE');
     }
     // Load specific css component
     JHtml::_('stylesheet', $component . '/administrator/categories.css', array(), true);
     // Prepare the toolbar.
     JToolbarHelper::title($title, 'categories ' . substr($component, 4) . ($section ? "-{$section}" : '') . '-categories');
     if ($canDo->get('core.create') || count($user->getAuthorisedCategories($component, 'core.create')) > 0) {
         JToolbarHelper::addNew('category.add');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolbarHelper::editList('category.edit');
     }
     if ($canDo->get('core.edit.state')) {
         JToolbarHelper::publish('categories.publish', 'JTOOLBAR_PUBLISH', true);
         JToolbarHelper::unpublish('categories.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolbarHelper::archiveList('categories.archive');
     }
     if (JFactory::getUser()->authorise('core.admin')) {
         JToolbarHelper::checkin('categories.checkin');
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete', $component)) {
         JToolbarHelper::deleteList('', 'categories.delete', 'JTOOLBAR_EMPTY_TRASH');
     } elseif ($canDo->get('core.edit.state')) {
         JToolbarHelper::trash('categories.trash');
     }
     // Add a batch button
     if ($user->authorise('core.create', $extension) & $user->authorise('core.edit', $extension) && $user->authorise('core.edit.state', $extension)) {
         JHtml::_('bootstrap.modal', 'collapseModal');
         $title = JText::_('JTOOLBAR_BATCH');
         // Instantiate a new JLayoutFile instance and render the batch button
         $layout = new JLayoutFile('joomla.toolbar.batch');
         $dhtml = $layout->render(array('title' => $title));
         $bar->appendButton('Custom', $dhtml, 'batch');
     }
     if ($canDo->get('core.admin')) {
         JToolbarHelper::custom('categories.rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false);
         JToolbarHelper::preferences($component);
     }
     // Compute the ref_key if it does exist in the component
     if (!$lang->hasKey($ref_key = strtoupper($component . ($section ? "_{$section}" : '')) . '_CATEGORIES_HELP_KEY')) {
         $ref_key = 'JHELP_COMPONENTS_' . strtoupper(substr($component, 4) . ($section ? "_{$section}" : '')) . '_CATEGORIES';
     }
     // Get help for the categories view for the component by
     // -remotely searching in a language defined dedicated URL: *component*_HELP_URL
     // -locally  searching in a component help file if helpURL param exists in the component and is set to ''
     // -remotely searching in a component URL if helpURL param exists in the component and is NOT set to ''
     if ($lang->hasKey($lang_help_url = strtoupper($component) . '_HELP_URL')) {
         $debug = $lang->setDebug(false);
         $url = JText::_($lang_help_url);
         $lang->setDebug($debug);
     } else {
         $url = null;
     }
     JToolbarHelper::help($ref_key, JComponentHelper::getParams($component)->exists('helpURL'), $url);
     JHtmlSidebar::setAction('index.php?option=com_categories&view=categories');
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_MAX_LEVELS'), 'filter_level', JHtml::_('select.options', $this->f_levels, 'value', 'text', $this->state->get('filter.level')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_LANGUAGE'), 'filter_language', JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language')));
     if (JHelperTags::getTypes('objectList', array($extension . '.category'), true)) {
         JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_TAG'), 'filter_tag', JHtml::_('select.options', JHtml::_('tag.options', true, true), 'value', 'text', $this->state->get('filter.tag')));
     }
 }
示例#25
0
文件: head.php 项目: naka211/compac
 /**
  * Generates the head HTML and return the results as a string
  *
  * @param   JDocument  $document  The document for which the head will be created
  *
  * @return  string  The head hTML
  *
  * @since   11.1
  */
 public function fetchHead($document)
 {
     // Convert the tagids to titles
     if (isset($document->_metaTags['standard']['tags'])) {
         $tagsHelper = new JHelperTags();
         $document->_metaTags['standard']['tags'] = implode(', ', $tagsHelper->getTagNames($document->_metaTags['standard']['tags']));
     }
     // Trigger the onBeforeCompileHead event
     $app = JFactory::getApplication();
     $app->triggerEvent('onBeforeCompileHead');
     // Get line endings
     $lnEnd = $document->_getLineEnd();
     $tab = $document->_getTab();
     $tagEnd = ' />';
     $buffer = '';
     // Generate charset when using HTML5 (should happen first)
     if ($document->isHtml5()) {
         $buffer .= $tab . '<meta charset="' . $document->getCharset() . '" />' . $lnEnd;
     }
     // Generate base tag (need to happen early)
     $base = $document->getBase();
     if (!empty($base)) {
         $buffer .= $tab . '<base href="' . $document->getBase() . '" />' . $lnEnd;
     }
     // Generate META tags (needs to happen as early as possible in the head)
     foreach ($document->_metaTags as $type => $tag) {
         foreach ($tag as $name => $content) {
             if ($type == 'http-equiv' && !($document->isHtml5() && $name == 'content-type')) {
                 $buffer .= $tab . '<meta http-equiv="' . $name . '" content="' . htmlspecialchars($content) . '" />' . $lnEnd;
             } elseif ($type == 'standard' && !empty($content)) {
                 $buffer .= $tab . '<meta name="' . $name . '" content="' . htmlspecialchars($content) . '" />' . $lnEnd;
             }
         }
     }
     // Don't add empty descriptions
     $documentDescription = $document->getDescription();
     if ($documentDescription) {
         $buffer .= $tab . '<meta name="description" content="' . htmlspecialchars($documentDescription) . '" />' . $lnEnd;
     }
     // Don't add empty generators
     $generator = $document->getGenerator();
     if ($generator) {
         //$buffer .= $tab . '<meta name="generator" content="' . htmlspecialchars($generator) . '" />' . $lnEnd;
         $buffer .= $tab . '<meta name="author" content="My Web Creations" />' . $lnEnd;
     }
     $buffer .= $tab . '<title>' . htmlspecialchars($document->getTitle(), ENT_COMPAT, 'UTF-8') . '</title>' . $lnEnd;
     // Generate link declarations
     foreach ($document->_links as $link => $linkAtrr) {
         $buffer .= $tab . '<link href="' . $link . '" ' . $linkAtrr['relType'] . '="' . $linkAtrr['relation'] . '"';
         if ($temp = JArrayHelper::toString($linkAtrr['attribs'])) {
             $buffer .= ' ' . $temp;
         }
         $buffer .= ' />' . $lnEnd;
     }
     // Generate stylesheet links
     foreach ($document->_styleSheets as $strSrc => $strAttr) {
         $buffer .= $tab . '<link rel="stylesheet" href="' . $strSrc . '"';
         if (!is_null($strAttr['mime']) && (!$document->isHtml5() || $strAttr['mime'] != 'text/css')) {
             $buffer .= ' type="' . $strAttr['mime'] . '"';
         }
         if (!is_null($strAttr['media'])) {
             $buffer .= ' media="' . $strAttr['media'] . '"';
         }
         if ($temp = JArrayHelper::toString($strAttr['attribs'])) {
             $buffer .= ' ' . $temp;
         }
         $buffer .= $tagEnd . $lnEnd;
     }
     // Generate stylesheet declarations
     foreach ($document->_style as $type => $content) {
         $buffer .= $tab . '<style type="' . $type . '">' . $lnEnd;
         // This is for full XHTML support.
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '/*<![CDATA[*/' . $lnEnd;
         }
         $buffer .= $content . $lnEnd;
         // See above note
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '/*]]>*/' . $lnEnd;
         }
         $buffer .= $tab . '</style>' . $lnEnd;
     }
     // Generate script file links
     foreach ($document->_scripts as $strSrc => $strAttr) {
         $buffer .= $tab . '<script src="' . $strSrc . '"';
         $defaultMimes = array('text/javascript', 'application/javascript', 'text/x-javascript', 'application/x-javascript');
         if (!is_null($strAttr['mime']) && (!$document->isHtml5() || !in_array($strAttr['mime'], $defaultMimes))) {
             $buffer .= ' type="' . $strAttr['mime'] . '"';
         }
         if ($strAttr['defer']) {
             $buffer .= ' defer="defer"';
         }
         if ($strAttr['async']) {
             $buffer .= ' async="async"';
         }
         $buffer .= '></script>' . $lnEnd;
     }
     // Generate script declarations
     foreach ($document->_script as $type => $content) {
         $buffer .= $tab . '<script type="' . $type . '">' . $lnEnd;
         // This is for full XHTML support.
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//<![CDATA[' . $lnEnd;
         }
         $buffer .= $content . $lnEnd;
         // See above note
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//]]>' . $lnEnd;
         }
         $buffer .= $tab . '</script>' . $lnEnd;
     }
     // Generate script language declarations.
     if (count(JText::script())) {
         $buffer .= $tab . '<script type="text/javascript">' . $lnEnd;
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//<![CDATA[' . $lnEnd;
         }
         $buffer .= $tab . $tab . '(function() {' . $lnEnd;
         $buffer .= $tab . $tab . $tab . 'Joomla.JText.load(' . json_encode(JText::script()) . ');' . $lnEnd;
         $buffer .= $tab . $tab . '})();' . $lnEnd;
         if ($document->_mime != 'text/html') {
             $buffer .= $tab . $tab . '//]]>' . $lnEnd;
         }
         $buffer .= $tab . '</script>' . $lnEnd;
     }
     foreach ($document->_custom as $custom) {
         $buffer .= $tab . $custom . $lnEnd;
     }
     return $buffer;
 }
示例#26
0
 function getProduct($categories = array())
 {
     $this->onExecuteBefore('getProduct', array(&$categories));
     $id = JRequest::getInt('id');
     $product = KSSystem::loadDbItem($id, 'products');
     $product = KSMedia::setItemMedia($product, 'product');
     $product->categories = array();
     $product->properties = array();
     $product->childs = array();
     if (count($categories)) {
         $query = $this->_db->getQuery(true);
         $query->select('category_id')->from('#__ksenmart_products_categories')->where('product_id=' . $id)->where('is_default=1');
         $this->_db->setQuery($query);
         $is_default = $this->_db->loadResult();
         foreach ($categories as $category_id) {
             $category = new stdClass();
             $category->category_id = $category_id;
             $category->is_default = $category->category_id == $is_default ? 1 : 0;
             $product->categories[$category_id] = $category;
         }
     } else {
         $query = $this->_db->getQuery(true);
         $query->select('category_id, is_default')->from('#__ksenmart_products_categories')->where('product_id=' . $id);
         $this->_db->setQuery($query);
         $product->categories = $this->_db->loadObjectList('category_id');
     }
     if (count($product->categories)) {
         $query = $this->_db->getQuery(true);
         $query->select('p.*')->from('#__ksenmart_properties as p')->innerjoin('#__ksenmart_product_categories_properties as cp on cp.property_id=p.id')->where('cp.category_id in (' . implode(',', array_keys($product->categories)) . ')')->where('p.published=1');
         $this->_db->setQuery($query);
         $product->properties = $this->_db->loadObjectList('id');
         foreach ($product->properties as &$p) {
             $p->values = array();
         }
         if (!empty($product->properties)) {
             $in = array_keys($product->properties);
             $query = $this->_db->getQuery(true);
             $query->select('*')->from('#__ksenmart_product_properties_values')->where('product_id=' . $id)->where('property_id in (' . implode(',', $in) . ')');
             $this->_db->setQuery($query);
             $values = $this->_db->loadObjectList();
             foreach ($values as $v) {
                 if (isset($product->properties[$v->property_id])) {
                     $product->properties[$v->property_id]->values[$v->id] = $v;
                 }
             }
         }
     }
     if ($product->is_parent == 1) {
         $empty_group = new stdClass();
         $empty_group->id = 0;
         $empty_group->title = JText::_('KSM_CATALOG_PRODUCT_CHILDS_EMPTY_GROUP');
         $empty_group->product_id = $id;
         $empty_group->products = array();
         $empty_group->ordering = 0;
         $query = $this->_db->getQuery(true);
         $query->select('*')->from('#__ksenmart_products_child_groups')->where('product_id=' . $id)->order('ordering');
         $this->_db->setQuery($query);
         $product->childs = $this->_db->loadObjectList('id');
         array_unshift($product->childs, $empty_group);
         foreach ($product->childs as &$child) {
             $query = $this->_db->getQuery(true);
             $query->select('p.*')->from('#__ksenmart_products as p')->where('p.parent_id=' . $id)->where('p.childs_group =' . $child->id)->order('p.ordering');
             $query = KSMedia::setItemMainImageToQuery($query);
             $this->_db->setQuery($query);
             $child->products = $this->_db->loadObjectList('id');
             foreach ($child->products as &$prd) {
                 $prd->small_img = KSMedia::resizeImage($prd->filename, $prd->folder, $this->params->get('admin_product_thumb_image_width', 36), $this->params->get('admin_product_thumb_image_heigth', 36), json_decode($prd->params, true));
             }
         }
     }
     $query = $this->_db->getQuery(true);
     $query->select('p.*')->from('#__ksenmart_products as p')->innerjoin('#__ksenmart_products_relations as pr on pr.relative_id=p.id')->where('pr.relation_type=' . $this->_db->quote('relation'))->where('pr.product_id=' . $id);
     $query = KSMedia::setItemMainImageToQuery($query);
     $this->_db->setQuery($query);
     $product->relative = $this->_db->loadObjectList('id');
     foreach ($product->relative as &$prd) {
         $prd->small_img = KSMedia::resizeImage($prd->filename, $prd->folder, $this->params->get('admin_product_thumb_image_width', 36), $this->params->get('admin_product_thumb_image_heigth', 36), json_decode($prd->params, true));
     }
     $tagHelper = new JHelperTags();
     $product->tags = $tagHelper->getTagIds(array($product->id), 'com_ksenmart.product');
     $this->onExecuteAfter('getProduct', array(&$product));
     return $product;
 }
示例#27
0
文件: tag.php 项目: fur81/zofaxiopeu
 /**
  * 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('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');
     // Ajax tag only loads assigned values
     if (!$this->isNested()) {
         // Only item assigned values
         $values = (array) $this->value;
         JArrayHelper::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 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->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;
     }
     // 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;
 }
示例#28
0
 function getList()
 {
     $params =& $this->_params;
     $formatter = $params->get('style_displaying', 'title');
     $titleMaxChars = $params->get('title_max_chars', '100');
     $limit_title_by = $params->get('limit_title_by', 'char');
     $descriptionMaxChars = $params->get('description_max_chars', 100);
     $limitDescriptionBy = $params->get('limit_description_by', 'char');
     $isThumb = $params->get('image_thumb', 1);
     $thumbWidth = (int) $params->get('thumbnail_width', 280);
     $thumbHeight = (int) $params->get('thumbnail_height', 150);
     $quality = (int) $params->get('image_quality', 80);
     $showimage = $params->get('show_image', 1);
     $replacer = $params->get('replacer', '...');
     $isStrips = $params->get("auto_strip_tags", 1);
     $use_linka = $params->get('use_linka', 0);
     $use_introimg = $params->get('use_introimg', 1);
     $use_caption = $params->get('use_caption', 0);
     $stringtags = '';
     if ($isStrips) {
         $allow_tags = $params->get("allow_tags", '');
         $stringtags = '';
         if (!is_array($allow_tags)) {
             $allow_tags = explode(',', $allow_tags);
         }
         foreach ($allow_tags as $tag) {
             $stringtags .= '<' . $tag . '>';
         }
     }
     if (!$params->get('default_thumb', 1)) {
         $this->_defaultThumb = '';
     }
     $ordering = $params->get('ordering', 'created-asc');
     $db = JFactory::getDbo();
     // Get an instance of the generic articles model
     $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
     // Set application parameters in model
     $app = JFactory::getApplication();
     $appParams = $app->getParams();
     $model->setState('params', $appParams);
     $model->setState('list.select', 'a.urls, a.images, a.fulltext, a.id, a.title, a.alias, a.introtext, a.state, a.catid, a.created, a.created_by, a.created_by_alias,' . ' a.modified, a.modified_by,a.publish_up, a.publish_down, a.attribs, a.metadata, a.metakey, a.metadesc, a.access,' . ' a.hits, a.featured,' . ' LENGTH(a.fulltext) AS readmore');
     // Set the filters based on the module params
     $model->setState('list.start', 0);
     $model->setState('list.limit', (int) $params->get('limit_items', 12));
     $model->setState('filter.published', 1);
     // Access filter
     $userId = JFactory::getUser()->get('id');
     $access = !JComponentHelper::getParams('com_content')->get('show_noauth');
     $authorised = JAccess::getAuthorisedViewLevels($userId);
     $model->setState('filter.access', $access);
     $source = trim($params->get('source', 'category'));
     // User filter
     switch ($params->get('user_id')) {
         case 'by_me':
             $model->setState('filter.author_id', (int) $userId);
             break;
         case 'not_me':
             $model->setState('filter.author_id', $userId);
             $model->setState('filter.author_id.include', false);
             break;
         case 0:
             break;
         default:
             $model->setState('filter.author_id', (int) $params->get('user_id'));
             break;
     }
     // Filter by language
     $model->setState('filter.language', $app->getLanguageFilter());
     //  Featured switch
     switch ($params->get('show_featured')) {
         case 3:
             $model->setState('filter.featured', 'only');
             break;
         case 2:
             $model->setState('filter.featured', 'hide');
             break;
         default:
             $model->setState('filter.featured', 'show');
             break;
     }
     // Set ordering
     $ordering = explode('-', $ordering);
     if (trim($ordering[0]) == 'rand') {
         $model->setState('list.ordering', ' RAND() ');
     } else {
         if (trim($ordering[0]) == 'featured') {
             $model->setState('list.ordering', ' fp.ordering');
             $model->setState('list.direction', 'asc');
         } else {
             $model->setState('list.ordering', 'a.' . $ordering[0]);
             $model->setState('list.direction', $ordering[1]);
         }
     }
     //if category
     $items = array();
     if ($source == 'category') {
         $category_ids = self::getCategoryIds();
         if (!empty($category_ids) && $params->get('limit_items_for_each')) {
             $db->setQuery('SELECT id from #__categories where id in (' . implode($category_ids, ',') . ') order by lft');
             $category_ids = $db->loadColumn();
             foreach ($category_ids as $category_id) {
                 $model->setState('filter.category_id', array($category_id));
                 $itemsPerCategory = $model->getItems();
                 $items = array_merge($items, $itemsPerCategory);
             }
         } else {
             // Category filter
             $model->setState('filter.category_id', $category_ids);
             $items = $model->getItems();
         }
         //esle article_ids
     } else {
         if ($source == 'article_ids') {
             $ids = preg_split('/,/', $params->get('article_ids', ''));
             $tmp = array();
             foreach ($ids as $id) {
                 $tmp[] = (int) trim($id);
             }
             $model->setState('filter.article_id', $tmp);
             $items = $model->getItems();
         } else {
             $tagsHelper = new JHelperTags();
             $tagIds = $this->_params->get('joomla_tags');
             if ($tagsIds) {
                 $query = $tagsHelper->getTagItemsQuery(implode(',', $tagIds));
                 $db->setQuery($query);
                 $rs = $db->loadObjectList();
                 if (!$rs) {
                     $items = $model->getItems();
                 } else {
                     $articleIds = array();
                     foreach ($rs as $article) {
                         if ($article->type_alias != 'com_content.article') {
                             continue;
                         }
                         $articleIds[] = $article->content_item_id;
                     }
                     $model->setState('filter.article_id', $articleIds);
                     $items = $model->getItems();
                 }
             } else {
                 $items = $model->getItems();
             }
         }
     }
     foreach ($items as &$item) {
         // setting for route link
         $item->slug = $item->id . ':' . $item->alias;
         $item->catslug = $item->catid . ':' . $item->category_alias;
         // item link
         $item->link = '';
         if ($access || in_array($item->access, $authorised)) {
             // We know that user has the privilege to view the article
             //Item link
             if ($use_linka && $item->urls) {
                 $item->urls = json_decode($item->urls);
                 $item->link = $item->urls->urla;
             }
             if (!$item->link) {
                 $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, JFactory::getLanguage()->getTag()));
             }
         } else {
             $item->link = JRoute::_('index.php?option=com_users&view=login');
         }
         // format date
         $item->date = JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC2'));
         // thumbnail & caption
         $item->thumbnail = '';
         $item->mainImage = '';
         if (($use_introimg || $use_caption) && $item->images) {
             $item->images = json_decode($item->images);
         }
         if ($showimage) {
             if ($item->images && $use_introimg) {
                 $imgLink = $item->images->image_intro;
                 if (!$imgLink) {
                     $imgLink = $imgLink;
                 }
                 if ($imgLink) {
                     $item->mainImage = $imgLink;
                     if ($isThumb) {
                         $item->thumbnail = self::renderThumb($imgLink, $thumbWidth, $thumbHeight, $isThumb, $quality);
                     } else {
                         $item->thumbnail = $imgLink;
                     }
                 }
             }
             if (!$item->thumbnail) {
                 $item = $this->generateImages($item, $isThumb, $quality);
             }
         }
         // change introtext with caption
         if ($use_caption && $item->images) {
             $caption = $item->images->image_intro_caption;
             if (!$caption) {
                 $caption = $item->images->image_fulltext_caption;
             }
             if ($caption) {
                 $item->introtext = $caption;
             }
         }
         // set category link
         $item->categoryLink = JRoute::_(ContentHelperRoute::getCategoryRoute($item->catid, JFactory::getLanguage()->getTag()));
         // cut title
         if ($limit_title_by == 'word' && $titleMaxChars > 0) {
             $item->title_cut = self::substrword($item->title, $titleMaxChars, $replacer, $isStrips);
         } elseif ($limit_title_by == 'char' && $titleMaxChars > 0) {
             $item->title_cut = self::substring($item->title, $titleMaxChars, $replacer, $isStrips);
         }
         // escape html characters
         $item->title = htmlspecialchars($item->title);
         // import content prepare plugin
         if ($params->get('content_plugin')) {
             $item->introtext = JHtml::_('content.prepare', $item->introtext);
             //jrodriguez
         }
         // cut description
         if ($limitDescriptionBy == 'word' && $descriptionMaxChars > 0) {
             $item->description = self::substrword($item->introtext, $descriptionMaxChars, $replacer, $isStrips, $stringtags);
         } elseif ($limitDescriptionBy == 'char' && $descriptionMaxChars > 0) {
             $item->description = self::substring($item->introtext, $descriptionMaxChars, $replacer, $isStrips, $stringtags);
         }
         // set authorlink empty
         $item->authorLink = "#";
     }
     return $items;
 }
示例#29
0
文件: tag.php 项目: Rai-Ka/joomla-cms
 /**
  * Method to delete a node and, optionally, its child nodes from the table.
  *
  * @param   integer  $pk        The primary key of the node to delete.
  * @param   boolean  $children  True to delete child nodes, false to move them up a level.
  *
  * @return  boolean  True on success.
  *
  * @since   3.1
  */
 public function delete($pk = null, $children = false)
 {
     $return = parent::delete($pk, $children);
     if ($return) {
         $helper = new JHelperTags();
         $helper->tagDeleteInstances($pk);
     }
     return $return;
 }
示例#30
0
 private function _contact($id, &$xml, $options)
 {
     JLog::add(new JLogEntry(__METHOD__, JLOG::DEBUG, 'lib_j2xml'));
     JLog::add(new JLogEntry('id: ' . $id, JLOG::DEBUG, 'lib_j2xml'));
     JLog::add(new JLogEntry('options: ' . print_r($options, true), JLOG::DEBUG, 'lib_j2xml'));
     jimport('eshiol.j2xml.table.contact');
     $item = JTable::getInstance('contact', 'eshTable');
     if (!$item->load($id)) {
         return;
     }
     if ($xml->xpath("//j2xml/contact/id[text() = '" . $item->id . "']")) {
         return;
     }
     $doc = dom_import_simplexml($xml)->ownerDocument;
     $fragment = $doc->createDocumentFragment();
     $fragment->appendXML($item->toXML());
     $doc->documentElement->appendChild($fragment);
     if ($options['users']) {
         if ($item->created_by) {
             self::_user($item->created_by, $xml, $options);
         }
         if ($item->modified_by) {
             self::_user($item->modified_by, $xml, $options);
         }
     }
     if ($options['images']) {
         if (isset($item->image)) {
             self::_image($item->image, $xml, $options);
         }
     }
     if ($options['categories'] && $item->catid > 0) {
         self::_category($item->catid, $xml, $options);
     }
     if (class_exists('JHelperTags')) {
         $htags = new JHelperTags();
         $itemtags = $htags->getItemTags('com_contact.contact', $id);
         foreach ($itemtags as $itemtag) {
             self::_tag($itemtag->tag_id, $xml, $options);
         }
     }
 }