コード例 #1
0
ファイル: admin.php プロジェクト: joomlatools/joomla-platform
 /**
  * Saves the manually set order of records.
  *
  * @param   array    $pks    An array of primary key ids.
  * @param   integer  $order  +1 or -1
  *
  * @return  mixed
  *
  * @since   12.2
  */
 public function saveorder($pks = null, $order = null)
 {
     $table = $this->getTable();
     $tableClassName = get_class($table);
     $contentType = new ContentTableUcmType();
     $type = $contentType->getTypeByTable($tableClassName);
     $tagsObserver = $table->getObserverOfClass('TagsTableObserverTags');
     $conditions = array();
     if (empty($pks)) {
         JFactory::getApplication()->enqueueMessage(JText::_($this->text_prefix . '_ERROR_NO_ITEMS_SELECTED'), 'error');
         return false;
     }
     // Update ordering values
     foreach ($pks as $i => $pk) {
         $table->load((int) $pk);
         // Access checks.
         if (!$this->canEditState($table)) {
             // Prune items that you can't change.
             unset($pks[$i]);
             JLog::add(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), JLog::WARNING, 'jerror');
         } elseif ($table->ordering != $order[$i]) {
             $table->ordering = $order[$i];
             if ($type) {
                 $this->createTagsHelper($tagsObserver, $type, $pk, $type->type_alias, $table);
             }
             if (!$table->store()) {
                 $this->setError($table->getError());
                 return false;
             }
             // Remember to reorder within position and client_id
             $condition = $this->getReorderConditions($table);
             $found = false;
             foreach ($conditions as $cond) {
                 if ($cond[1] == $condition) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $key = $table->getKeyName();
                 $conditions[] = array($table->{$key}, $condition);
             }
         }
     }
     // Execute reorder for each category.
     foreach ($conditions as $cond) {
         $table->load($cond[0]);
         $table->reorder($cond[1]);
     }
     // Clear the component's cache
     $this->cleanCache();
     return true;
 }
コード例 #2
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  *
  * @since   3.2
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $extension = $app->input->getString('option');
     $contentType = $extension . '.' . $this->viewName;
     $ucmType = new ContentTableUcmType();
     $ucmRow = $ucmType->getTypeByAlias($contentType);
     $ucmMapCommon = json_decode($ucmRow->field_mappings)->common;
     $createdField = null;
     $titleField = null;
     if (is_object($ucmMapCommon)) {
         $createdField = $ucmMapCommon->core_created_time;
         $titleField = $ucmMapCommon->core_title;
     } elseif (is_array($ucmMapCommon)) {
         $createdField = $ucmMapCommon[0]->core_created_time;
         $titleField = $ucmMapCommon[0]->core_title;
     }
     $document->link = JRoute::_(JHelperRoute::getCategoryRoute($app->input->getInt('id'), $language = 0, $extension));
     $app->input->set('limit', $app->get('feed_limit'));
     $siteEmail = $app->get('mailfrom');
     $fromName = $app->get('fromname');
     $feedEmail = $app->get('feed_email', 'author');
     $document->editor = $fromName;
     if ($feedEmail != 'none') {
         $document->editorEmail = $siteEmail;
     }
     // Get some data from the model
     $items = $this->get('Items');
     $category = $this->get('Category');
     foreach ($items as $item) {
         $this->reconcileNames($item);
         // Strip html from feed item title
         if ($titleField) {
             $title = $this->escape($item->{$titleField});
             $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
         } else {
             $title = '';
         }
         // URL link to article
         $router = new JHelperRoute();
         $link = JRoute::_($router->getRoute($item->id, $contentType, null, null, $item->catid));
         // Strip HTML from feed item description text.
         $description = $item->description;
         $author = $item->created_by_alias ? $item->created_by_alias : $item->author;
         if ($createdField) {
             $date = isset($item->{$createdField}) ? date('r', strtotime($item->{$createdField})) : '';
         } else {
             $date = '';
         }
         // Load individual item creator class.
         $feeditem = new JFeedItem();
         $feeditem->title = $title;
         $feeditem->link = $link;
         $feeditem->description = $description;
         $feeditem->date = $date;
         $feeditem->category = $category->title;
         $feeditem->author = $author;
         // We don't have the author email so we have to use site in both cases.
         if ($feedEmail == 'site') {
             $feeditem->authorEmail = $siteEmail;
         } elseif ($feedEmail === 'author') {
             $feeditem->authorEmail = $item->author_email;
         }
         // Loads item information into RSS array
         $document->addItem($feeditem);
     }
 }
コード例 #3
0
 /**
  * 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 ContentTableUcmType::getTypeId() instead
  */
 public function getTypeId($typeAlias)
 {
     $contentType = new ContentTableUcmType();
     return $contentType->getTypeId($typeAlias);
 }