/** * 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); } }
/** * Method to perform batch operations on an item or a set of items. * * @param array $commands An array of commands to perform. * @param array $pks An array of item ids. * @param array $contexts An array of item contexts. * * @return boolean Returns true on success, false on failure. * * @since 12.2 */ public function batch($commands, $pks, $contexts) { // Sanitize ids. $pks = array_unique($pks); JArrayHelper::toInteger($pks); // Remove any values of zero. if (array_search(0, $pks, true)) { unset($pks[array_search(0, $pks, true)]); } if (empty($pks)) { $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); return false; } $done = false; // Set some needed variables. $this->user = JFactory::getUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new ContentTableUcmType(); $this->type = $this->contentType->getTypeByTable($this->tableClassName); $this->batchSet = true; if ($this->type == false) { $type = new ContentTableUcmType(); $this->type = $type->getTypeByAlias($this->typeAlias); } if ($this->type === false) { $type = new ContentTableUcmType(); $this->type = $type->getTypeByAlias($this->typeAlias); $typeAlias = $this->type->type_alias; } else { $typeAlias = $this->type->type_alias; } $this->tagsObserver = $this->table->getObserverOfClass('TagsTableObserverTags'); if (!empty($commands['category_id'])) { $cmd = JArrayHelper::getValue($commands, 'move_copy', 'c'); if ($cmd == 'c') { $result = $this->batchCopy($commands['category_id'], $pks, $contexts); if (is_array($result)) { $pks = $result; } else { return false; } } elseif ($cmd == 'm' && !$this->batchMove($commands['category_id'], $pks, $contexts)) { return false; } $done = true; } if (!empty($commands['assetgroup_id'])) { if (!$this->batchAccess($commands['assetgroup_id'], $pks, $contexts)) { return false; } $done = true; } if (!empty($commands['language_id'])) { if (!$this->batchLanguage($commands['language_id'], $pks, $contexts)) { return false; } $done = true; } if (!empty($commands['tag'])) { if (!$this->batchTag($commands['tag'], $pks, $contexts)) { return false; } $done = true; } if (!$done) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); return false; } // Clear the cache $this->cleanCache(); return true; }