/**
  * Builds the query for the ordering list.
  *
  * @return  JDatabaseQuery  The query for the ordering form field
  *
  * @since   3.2
  */
 protected function getQuery()
 {
     $categoryId = (int) $this->form->getValue('catid');
     $contentType = (string) $this->element['content_type'];
     $ucmType = new JUcmType();
     $ucmRow = $ucmType->getType($ucmType->getTypeId($contentType));
     $ucmMapCommon = json_decode($ucmRow->field_mappings)->common;
     if (is_object($ucmMapCommon)) {
         $ordering = $ucmMapCommon->core_ordering;
         $title = $ucmMapCommon->core_title;
     } elseif (is_array($ucmMapCommon)) {
         $ordering = $ucmMapCommon[0]->core_ordering;
         $title = $ucmMapCommon[0]->core_title;
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select(array($db->quoteName($ordering, 'value'), $db->quoteName($title, 'text')))->from($db->quoteName(json_decode($ucmRow->table)->special->dbtable))->where($db->quoteName('catid') . ' = ' . (int) $categoryId)->order('ordering');
     return $query;
 }
예제 #2
0
파일: tags.php 프로젝트: Rai-Ka/joomla-cms
 /**
  * Method to add tag rows to mapping table.
  *
  * @param   integer          $ucmId  ID of the #__ucm_content item being tagged
  * @param   JTableInterface  $table  JTable object being tagged
  * @param   array            $tags   Array of tags to be applied.
  *
  * @return  boolean  true on success, otherwise false.
  *
  * @since   3.1
  */
 public function addTagMapping($ucmId, JTableInterface $table, $tags = array())
 {
     $db = $table->getDbo();
     $key = $table->getKeyName();
     $item = $table->{$key};
     $ucm = new JUcmType($this->typeAlias, $db);
     $typeId = $ucm->getTypeId();
     // Insert the new tag maps
     if (strpos('#', implode(',', $tags)) === false) {
         $tags = self::createTagsFromField($tags);
     }
     // Prevent saving duplicate tags
     $tags = array_unique($tags);
     $query = $db->getQuery(true);
     $query->insert('#__contentitem_tag_map');
     $query->columns(array($db->quoteName('type_alias'), $db->quoteName('core_content_id'), $db->quoteName('content_item_id'), $db->quoteName('tag_id'), $db->quoteName('tag_date'), $db->quoteName('type_id')));
     foreach ($tags as $tag) {
         $query->values($db->quote($this->typeAlias) . ', ' . (int) $ucmId . ', ' . (int) $item . ', ' . $db->quote($tag) . ', ' . $query->currentTimestamp() . ', ' . (int) $typeId);
     }
     $db->setQuery($query);
     return (bool) $db->execute();
 }
예제 #3
0
 /**
  * Add the page title and toolbar.
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function addToolbar()
 {
     $extension = JFactory::getApplication()->input->get('extension');
     $user = JFactory::getUser();
     $userId = $user->id;
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     // Check to see if the type exists
     $ucmType = new JUcmType();
     $this->typeId = $ucmType->getTypeId($extension . '.category');
     // Avoid nonsense situation.
     if ($extension == 'com_categories') {
         return;
     }
     // The extension can be in the form com_foo.section
     $parts = explode('.', $extension);
     $component = $parts[0];
     $section = count($parts) > 1 ? $parts[1] : null;
     $componentParams = JComponentHelper::getParams($component);
     // 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, true) || $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component, null, false, true);
     // Load the category helper.
     require_once JPATH_COMPONENT . '/helpers/categories.php';
     // Get the results for each action.
     $canDo = $this->canDo;
     // If a component categories title string is present, let's use it.
     if ($lang->hasKey($component_title_key = $component . ($section ? "_{$section}" : '') . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_TITLE')) {
         $title = JText::_($component_title_key);
     } elseif ($lang->hasKey($component_section_key = $component . ($section ? "_{$section}" : ''))) {
         $title = JText::sprintf('COM_CATEGORIES_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_TITLE', $this->escape(JText::_($component_section_key)));
     } else {
         $title = JText::_('COM_CATEGORIES_CATEGORY_BASE_' . ($isNew ? 'ADD' : 'EDIT') . '_TITLE');
     }
     // Load specific css component
     JHtml::_('stylesheet', $component . '/administrator/categories.css', array(), true);
     // Prepare the toolbar.
     JToolbarHelper::title($title, 'folder category-' . ($isNew ? 'add' : 'edit') . ' ' . substr($component, 4) . ($section ? "-{$section}" : '') . '-category-' . ($isNew ? 'add' : 'edit'));
     // For new records, check the create permission.
     if ($isNew && count($user->getAuthorisedCategories($component, 'core.create')) > 0) {
         JToolbarHelper::apply('category.apply');
         JToolbarHelper::save('category.save');
         JToolbarHelper::save2new('category.save2new');
     } elseif (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_user_id == $userId)) {
         JToolbarHelper::apply('category.apply');
         JToolbarHelper::save('category.save');
         if ($canDo->get('core.create')) {
             JToolbarHelper::save2new('category.save2new');
         }
     }
     // If an existing item, can save to a copy.
     if (!$isNew && $canDo->get('core.create')) {
         JToolbarHelper::save2copy('category.save2copy');
     }
     if (empty($this->item->id)) {
         JToolbarHelper::cancel('category.cancel');
     } else {
         if ($componentParams->get('save_history', 0) && $user->authorise('core.edit')) {
             $typeAlias = $extension . '.category';
             JToolbarHelper::versions($typeAlias, $this->item->id);
         }
         JToolbarHelper::cancel('category.cancel', 'JTOOLBAR_CLOSE');
     }
     JToolbarHelper::divider();
     // Compute the ref_key if it does exist in the component
     if (!$lang->hasKey($ref_key = strtoupper($component . ($section ? "_{$section}" : '')) . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_HELP_KEY')) {
         $ref_key = 'JHELP_COMPONENTS_' . strtoupper(substr($component, 4) . ($section ? "_{$section}" : '')) . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT');
     }
     /* Get help for the category/section 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, $componentParams->exists('helpURL'), $url, $component);
 }
예제 #4
0
파일: tags.php 프로젝트: ziyou-liu/1line
 /**
  * Method to get the type id for a type alias.
  *
  * @param   string  $typeAlias  A type alias.
  *
  * @return  string  Name of the table for a type
  *
  * @since   3.1
  * @deprecated  4.0  Use JUcmType::getTypeId() instead
  */
 public function getTypeId($typeAlias)
 {
     $contentType = new JUcmType();
     return $contentType->getTypeId($typeAlias);
 }
예제 #5
0
 /**
  * Tests the getTypeId() method
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testGetTypeId()
 {
     $this->assertEquals(1, $this->object->getTypeId('com_content.article'), 'Articles are type_id = 1');
 }