当前位置: 首页>>代码示例>>PHP>>正文


PHP JUcmType::getTypeByAlias方法代码示例

本文整理汇总了PHP中JUcmType::getTypeByAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP JUcmType::getTypeByAlias方法的具体用法?PHP JUcmType::getTypeByAlias怎么用?PHP JUcmType::getTypeByAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUcmType的用法示例。


在下文中一共展示了JUcmType::getTypeByAlias方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:esorone,项目名称:efcpw,代码行数:86,代码来源:teamnaam.php

示例2: 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;
 }
开发者ID:namibia,项目名称:demo-joomla-3-component,代码行数:67,代码来源:look.php

示例3: 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);
//.........这里部分代码省略.........
开发者ID:ajodochus,项目名称:joomlaForDocker,代码行数:101,代码来源:category.php

示例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.
  *
  * @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;
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:86,代码来源:contact.php

示例5: testGetTypeByAlias

 /**
  * Tests the getTypeByAlias() method
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testGetTypeByAlias()
 {
     $this->assertEquals(1, $this->object->getTypeByAlias('com_content.article')->type_id, 'Articles are type_id = 1');
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:11,代码来源:JUcmTypeTest.php

示例6: 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);
     }
 }
开发者ID:ziyou-liu,项目名称:1line,代码行数:77,代码来源:categoryfeed.php

示例7: 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
//.........这里部分代码省略.........
开发者ID:templaza,项目名称:tz_portfolio_plus,代码行数:101,代码来源:category.php

示例8: testGetTypeByAlias

 /**
  * Tests the getTypeByAlias() method
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testGetTypeByAlias()
 {
     $this->markTestSkipped('The alias column is being casted to integer at present...');
     $this->assertEquals(1, $this->object->getTypeByAlias('com_content.article')->type_id, 'Articles are type_id = 1');
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:12,代码来源:JUcmTypeTest.php


注:本文中的JUcmType::getTypeByAlias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。