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


PHP JModelAdmin::checkCategoryId方法代码示例

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


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

示例1: batchCopy

 /**
  * Batch copy items to a new category or current.
  *
  * @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   11.1
  */
 protected function batchCopy($value, $pks, $contexts)
 {
     $categoryId = (int) $value;
     $newIds = array();
     if (!parent::checkCategoryId($categoryId)) {
         return false;
     }
     // Parent exists so we let's proceed
     while (!empty($pks)) {
         // 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('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
                 continue;
             }
         }
         // Alter the title & alias
         $data = $this->generateNewTitle($categoryId, $this->table->alias, $this->table->title);
         $this->table->title = $data['0'];
         $this->table->alias = $data['1'];
         // Reset the ID because we are making a copy
         $this->table->id = 0;
         // Reset hits because we are making a copy
         $this->table->hits = 0;
         // Unpublish because we are making a copy
         $this->table->state = 0;
         // New category ID
         $this->table->catid = $categoryId;
         // TODO: Deal with ordering?
         // $table->ordering	= 1;
         // Check the row.
         if (!$this->table->check()) {
             $this->setError($this->table->getError());
             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;
         }
         // Get the new item ID
         $newId = $this->table->get('id');
         // Add the new ID to the array
         $newIds[$pk] = $newId;
     }
     // Clean the cache
     $this->cleanCache();
     return $newIds;
 }
开发者ID:saity74,项目名称:com_catalogue,代码行数:69,代码来源:item.php

示例2: batchCopy

 /**
  * Batch copy items to a new category or current.
  *
  * @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   11.1
  */
 protected function batchCopy($value, $pks, $contexts)
 {
     $categoryId = (int) $value;
     $i = 0;
     if (!parent::checkCategoryId($categoryId)) {
         return false;
     }
     // Parent exists so we let's proceed
     while (!empty($pks)) {
         // 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('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
                 continue;
             }
         }
         // Alter the title & alias
         $data = $this->generateNewTitle($categoryId, $this->table->alias, $this->table->title);
         $this->table->title = $data['0'];
         $this->table->alias = $data['1'];
         // Reset the ID because we are making a copy
         $this->table->id = 0;
         // New category ID
         $this->table->catid = $categoryId;
         // TODO: Deal with ordering?
         //$table->ordering	= 1;
         // Get the featured state
         $featured = $this->table->featured;
         // Check the row.
         if (!$this->table->check()) {
             $this->setError($this->table->getError());
             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;
         }
         // Get the new item ID
         $newId = $this->table->get('id');
         // Add the new ID to the array
         $newIds[$i] = $newId;
         $i++;
         // Check if the article was featured and update the #__content_frontpage table
         if ($featured == 1) {
             $db = $this->getDbo();
             $query = $db->getQuery(true)->insert($db->quoteName('#__content_frontpage'))->values($newId . ', 0');
             $db->setQuery($query);
             $db->execute();
         }
     }
     // Clean the cache
     $this->cleanCache();
     return $newIds;
 }
开发者ID:01J,项目名称:topm,代码行数:75,代码来源:article.php

示例3: batchCopy

 /**
  * Batch copy items to a new category or current.
  *
  * @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    11.1
  */
 protected function batchCopy($value, $pks, $contexts)
 {
     $categoryId = (int) $value;
     $newIds = [];
     /** @type ChurchDirectoryTableMember $table */
     $table = $this->getTable();
     $i = 0;
     if (!parent::checkCategoryId($categoryId)) {
         return false;
     }
     // Check that the category exists
     if ($categoryId) {
         $categoryTable = JTable::getInstance('Category');
         if (!$categoryTable->load($categoryId)) {
             if ($error = $categoryTable->getError()) {
                 // Fatal error
                 JFactory::getApplication()->enqueueMessage($error, 'error');
                 return false;
             } else {
                 $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
                 return false;
             }
         }
     }
     if (empty($categoryId)) {
         $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
         return false;
     }
     // Check that the user has create permission for the component
     $user = JFactory::getUser();
     if (!$user->authorise('core.create', 'com_churchdirectory.category.' . $categoryId)) {
         $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'));
         return false;
     }
     // Parent exists so we let's proceed
     while (!empty($pks)) {
         // 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('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
                 continue;
             }
         }
         // Alter the title & alias
         $data = $this->generateNewTitle($categoryId, $this->table->alias, $this->table->name);
         $this->table->name = $data['0'];
         $this->table->alias = $data['1'];
         // Reset the ID because we are making a copy
         $this->table->id = 0;
         // New category ID
         $this->table->catid = $categoryId;
         // Unpublish because we are making a copy
         $this->table->published = 0;
         // Check the row.
         if (!$table->check()) {
             $this->setError($table->getError());
             return false;
         }
         $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
         // Store the row.
         if (!$this->table->store()) {
             $this->setError($this->table->getError());
             return false;
         }
         // Get the new item ID
         $newId = $this->table->get('id');
         // Add the new ID to the array
         $newIds[$i] = $newId;
     }
     // Clean the cache
     $this->cleanCache();
     return $newIds;
 }
开发者ID:Joomla-Bible-Study,项目名称:joomla_churchdirectory,代码行数:92,代码来源:member.php


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