本文整理汇总了PHP中JUcmType类的典型用法代码示例。如果您正苦于以下问题:PHP JUcmType类的具体用法?PHP JUcmType怎么用?PHP JUcmType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JUcmType类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCCK_Storage_LocationSaveOrder
public static function onCCK_Storage_LocationSaveOrder($pks = array(), $order = array())
{
$table = static::_getTable();
$tableClassName = get_class($table);
$contentType = new JUcmType();
$type = $contentType->getTypeByTable($tableClassName);
$tagsObserver = $table->getObserverOfClass('JTableObserverTags');
$conditions = array();
if (empty($pks)) {
return;
}
foreach ($pks as $i => $pk) {
$table->load((int) $pk);
/*
if ( !$this->canEditState( $table ) ) {
unset( $pks[$i] );
} else*/
if ($table->ordering != $order[$i]) {
$table->ordering = $order[$i];
if ($type) {
if (!empty($tagsObserver) && !empty($type)) {
$table->tagsHelper = new JHelperTags();
$table->tagsHelper->typeAlias = $type->type_alias;
$table->tagsHelper->tags = explode(',', $table->tagsHelper->getTagIds($pk, $type->type_alias));
}
}
if (!$table->store()) {
JFactory::getApplication()->enqueueMessage($table->getError(), 'error');
return false;
}
// Remember to reorder within position and client_id
$condition = static::_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 condition
foreach ($conditions as $cond) {
$table->load($cond[0]);
$table->reorder($cond[1]);
}
return true;
}
示例2: getQuery
/**
* 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;
}
示例3: addTagMapping
/**
* 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();
}
示例4: batch
/**
* 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.
*
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize user 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;
}
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType();
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
$this->batchSet = true;
if ($this->type === false) {
$type = new JUcmType();
$this->type = $type->getTypeByAlias($this->typeAlias);
$type_alias = $this->type->type_alias;
} else {
$type_alias = $this->type->type_alias;
}
$this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags');
$done = false;
//Check box selected to copy items and then apply changes
if (!empty($commands['copy_items']) and $commands['copy_items'] == '1') {
$result = $this->batchCopy(0, $pks, $contexts);
if (is_array($result)) {
$pks = $result;
// Build a new array of item contexts for the copied items
$contexts = array();
foreach ($pks as $pk) {
$contexts[$pk] = $this->context . '.' . $pk;
}
} else {
return false;
}
$done = true;
}
if (!empty($commands['category_id'])) {
if (!$this->batchCategory($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['tag'])) {
if (!$this->batchTag($commands['tag'], $pks, $contexts)) {
return false;
}
$done = true;
}
if (!empty($commands['language_id'])) {
if (!$this->batchLanguage($commands['language_id'], $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;
}
示例5: batchMove
/**
* Batch move categories to a new category.
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True on success.
*
* @since 1.6
*/
protected function batchMove($value, $pks, $contexts)
{
$parentId = (int) $value;
$type = new JUcmType();
$this->type = $type->getTypeByAlias($this->typeAlias);
$db = $this->getDbo();
$query = $db->getQuery(true);
$extension = JFactory::getApplication()->input->get('extension', '', 'word');
// Check that the parent exists.
if ($parentId) {
if (!$this->table->load($parentId)) {
if ($error = $this->table->getError()) {
// Fatal error.
$this->setError($error);
return false;
} else {
// Non-fatal error.
$this->setError(JText::_('JGLOBAL_BATCH_MOVE_PARENT_NOT_FOUND'));
$parentId = 0;
}
}
// Check that user has create permission for parent category.
if ($parentId == $this->table->getRootId()) {
$canCreate = $this->user->authorise('core.create', $extension);
} else {
$canCreate = $this->user->authorise('core.create', $extension . '.category.' . $parentId);
}
if (!$canCreate) {
// Error since user cannot create in parent category
$this->setError(JText::_('COM_CATEGORIES_BATCH_CANNOT_CREATE'));
return false;
}
// Check that user has edit permission for every category being moved
// Note that the entire batch operation fails if any category lacks edit permission
foreach ($pks as $pk) {
if (!$this->user->authorise('core.edit', $extension . '.category.' . $pk)) {
// Error since user cannot edit this category
$this->setError(JText::_('COM_CATEGORIES_BATCH_CANNOT_EDIT'));
return false;
}
}
}
// We are going to store all the children and just move the category
$children = array();
// Parent exists so let's proceed
foreach ($pks as $pk) {
// Check that the row actually exists
if (!$this->table->load($pk)) {
if ($error = $this->table->getError()) {
// Fatal error
$this->setError($error);
return false;
} else {
// Not fatal error
$this->setError(JText::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// Set the new location in the tree for the node.
$this->table->setLocation($parentId, 'last-child');
// Check if we are moving to a different parent
if ($parentId != $this->table->parent_id) {
// Add the child node ids to the children array.
$query->clear()->select('id')->from($db->quoteName('#__categories'))->where($db->quoteName('lft') . ' BETWEEN ' . (int) $this->table->lft . ' AND ' . (int) $this->table->rgt);
$db->setQuery($query);
try {
$children = array_merge($children, (array) $db->loadColumn());
} catch (RuntimeException $e) {
$this->setError($e->getMessage());
return false;
}
}
parent::createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
// Store the row.
if (!$this->table->store()) {
$this->setError($this->table->getError());
return false;
}
// Rebuild the tree path.
if (!$this->table->rebuildPath()) {
$this->setError($this->table->getError());
return false;
}
}
// Process the child rows
if (!empty($children)) {
// Remove any duplicates and sanitize ids.
$children = array_unique($children);
JArrayHelper::toInteger($children);
//.........这里部分代码省略.........
示例6: batch
/**
* 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 JUcmType();
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = DemoHelper::getActions('look');
$this->batchSet = true;
if (!$this->canDo->get('core.batch')) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false) {
$type = new JUcmType();
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy'])) {
$cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
if ($cmd == 'c') {
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result)) {
foreach ($result as $old => $new) {
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
} else {
return false;
}
} elseif ($cmd == 'm' && !$this->batchMove($commands, $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;
}
示例7: batch
/**
* 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 2.5
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize user 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 JUcmType();
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
$this->batchSet = true;
if ($this->type === false) {
$type = new JUcmType();
$this->type = $type->getTypeByAlias($this->typeAlias);
$typeAlias = $this->type->type_alias;
} else {
$typeAlias = $this->type->type_alias;
}
$this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags');
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 (strlen($commands['user_id']) > 0) {
if (!$this->batchUser($commands['user_id'], $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;
}
示例8: saveorder
/**
* 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 JUcmType();
$type = $contentType->getTypeByTable($tableClassName);
$tagsObserver = $table->getObserverOfClass('JTableObserverTags');
$conditions = array();
if (empty($pks)) {
return JError::raiseWarning(500, JText::_($this->text_prefix . '_ERROR_NO_ITEMS_SELECTED'));
}
// 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;
}
示例9: addToolbar
/**
* 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);
}
示例10: getTypeId
/**
* 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);
}
示例11: reorder
/**
* Saves the manually set order of records.
*
* @param array $pks An array of primary key ids.
* @param array $order THe new ordering list.
*
* @return mixed
*/
public function reorder($pks = null, $order = array())
{
$table = $this->getTable();
$tableClassName = get_class($table);
$contentType = new \JUcmType();
$type = $contentType->getTypeByTable($tableClassName);
$typeAlias = $type ? $type->type_alias : null;
$tagsObserver = $table->getObserverOfClass('JTableObserverTags');
$conditions = array();
$errors = array();
$orderCol = $this->state->get('reorder.column', 'ordering');
// Update ordering values
foreach ($pks as $i => $pk) {
$table->load($pk);
$table->{$orderCol} = $order[$i];
$this->createTagsHelper($tagsObserver, $type, $pk, $typeAlias, $table);
if (!$table->store()) {
$errors[] = $table->getError();
continue;
}
// Remember to reorder within position and client_id
$condition = $this->getReorderConditions($table);
$found = false;
// Found reorder condition if is cached.
foreach ($conditions as $cond) {
if ($cond['cond'] == $condition) {
$found = true;
break;
}
}
// If not found, we add this condition to cache.
if (!$found) {
$key = $table->getKeyName();
$conditions[] = array('pk' => $table->{$key}, 'cond' => $condition);
}
}
// Execute all reorder for each condition caches.
foreach ($conditions as $cond) {
$table->load($cond['pk']);
$table->reorder($cond['cond']);
}
$this->state->set('error.message', $errors);
// Clear the component's cache
$this->cleanCache();
return true;
}
示例12: display
/**
* 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 JUcmType();
$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);
}
}
示例13: batchCopy
/**
* Batch copy categories to a new category.
*
* @param integer $value The new category.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on failure.
*
* @since 1.6
*/
protected function batchCopy($value, $pks, $contexts)
{
$type = new JUcmType();
$this->type = $type->getTypeByAlias($this->typeAlias);
// $value comes as {parent_id}.{extension}
$parts = explode('.', $value);
$parentId = (int) JArrayHelper::getValue($parts, 0, 1);
$db = $this->getDbo();
$extension = JFactory::getApplication()->input->get('extension', '', 'word');
$newIds = array();
// Check that the parent exists
if ($parentId) {
if (!$this->table->load($parentId)) {
if ($error = $this->table->getError()) {
// Fatal error
$this->setError($error);
return false;
} else {
// Non-fatal error
$this->setError(JText::_('JGLOBAL_BATCH_MOVE_PARENT_NOT_FOUND'));
$parentId = 0;
}
}
// Check that user has create permission for parent category
if ($parentId == $this->table->getRootId()) {
$canCreate = $this->user->authorise('core.create', 'com_tz_portfolio_plus');
} else {
$canCreate = $this->user->authorise('core.create', 'com_tz_portfolio_plus.category.' . $parentId);
}
if (!$canCreate) {
// Error since user cannot create in parent category
$this->setError(JText::_('COM_TZ_PORTFOLIO_PLUS_CATEGORIES_BATCH_CANNOT_CREATE'));
return false;
}
}
// If the parent is 0, set it to the ID of the root item in the tree
if (empty($parentId)) {
if (!($parentId = $this->table->getRootId())) {
$this->setError($db->getErrorMsg());
return false;
} elseif (!$this->user->authorise('core.create', $extension)) {
$this->setError(JText::_('COM_TZ_PORTFOLIO_PLUS_CATEGORIES_BATCH_CANNOT_CREATE'));
return false;
}
}
// We need to log the parent ID
$parents = array();
// Calculate the emergency stop count as a precaution against a runaway loop bug
$query = $db->getQuery(true)->select('COUNT(id)')->from($db->quoteName('#__tz_portfolio_plus_categories'));
$db->setQuery($query);
try {
$count = $db->loadResult();
} catch (RuntimeException $e) {
$this->setError($e->getMessage());
return false;
}
// Parent exists so let's proceed
while (!empty($pks) && $count > 0) {
// Pop the first id off the stack
$pk = array_shift($pks);
$this->table->reset();
// Check that the row actually exists
if (!$this->table->load($pk)) {
if ($error = $this->table->getError()) {
// Fatal error
$this->setError($error);
return false;
} else {
// Not fatal error
$this->setError(JText::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// Copy is a bit tricky, because we also need to copy the children
$query->clear()->select('id')->from($db->quoteName('#__tz_portfolio_plus_categories'))->where('lft > ' . (int) $this->table->lft)->where('rgt < ' . (int) $this->table->rgt);
$db->setQuery($query);
$childIds = $db->loadColumn();
// Add child ID's to the array only if they aren't already there.
foreach ($childIds as $childId) {
if (!in_array($childId, $pks)) {
array_push($pks, $childId);
}
}
// Make a copy of the old ID and Parent ID
$oldId = $this->table->id;
$oldParentId = $this->table->parent_id;
// Reset the id because we are making a copy.
$this->table->id = 0;
// If we a copying children, the Old ID will turn up in the parents list
//.........这里部分代码省略.........
示例14: testGetTypeId
/**
* 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');
}