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


PHP Engine_Api::typeToShort方法代码示例

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


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

示例1: indexAction

 public function indexAction()
 {
     $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('seo_admin_main', array(), 'seo_admin_main_manage');
     $items = array();
     foreach (Engine_Api::_()->getItemTypes() as $itemType) {
         $class = Engine_Api::_()->getItemClass($itemType);
         if (@class_exists($class)) {
             $reflector = new ReflectionMethod($class, 'getHref');
             if ($reflector->getDeclaringClass()->getName() == $class) {
                 $items[$itemType] = ucfirst(Engine_Api::typeToShort($itemType, Engine_Api::_()->getItemModule($itemType))) . ' (' . $itemType . ')';
             }
         }
     }
     $this->view->formFilter = $formFilter = new Seo_Form_Admin_Manage_Filter();
     // Populate types
     foreach ($items as $k => $v) {
         $formFilter->type->addMultiOption($k, $v);
     }
     // Process form
     $values = array();
     if ($formFilter->isValid($this->_getAllParams())) {
         $values = $formFilter->getValues();
     }
     foreach ($values as $key => $value) {
         if (null === $value) {
             unset($values[$key]);
         }
     }
     $this->view->assign($values);
     if (isset($values['type'])) {
         try {
             $table = Engine_Api::_()->getItemTable($values['type']);
             $select = $table->select();
         } catch (Engine_Api_Exception $e) {
         }
     }
     $this->view->paginator = $paginator = Zend_Paginator::factory(isset($select) ? $select : array());
     $paginator->setItemCountPerPage(25);
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     if (!isset($select)) {
         return;
     }
     // Set up select info
     $primary = array_shift($table->info('primary'));
     $values = array_merge(array('order' => $primary, 'order_direction' => 'DESC'), $values);
     $select->order((!empty($values['order']) ? $values['order'] == 'id' ? $primary : (in_array($values['order'], $table->info('cols')) ? $values['order'] : $primary) : $primary) . ' ' . (!empty($values['order_direction']) ? $values['order_direction'] : 'DESC'));
     if (in_array('title', $table->info('cols')) && !empty($values['title'])) {
         $select->where('title LIKE ?', '%' . $values['title'] . '%');
     }
     // Filter out junk
     $valuesCopy = array_filter($values);
     // Reset enabled bit
     if (isset($values['enabled']) && $values['enabled'] == 0) {
         $valuesCopy['enabled'] = 0;
     }
 }
开发者ID:rwetzlmayr,项目名称:seo-module,代码行数:56,代码来源:AdminManageController.php

示例2: getOwner

 public function getOwner($recurseType = null)
 {
     if (empty($recurseType)) {
         $recurseType = null;
     }
     // Just return self for users
     if ($this->getType() === 'user') {
         if (null === $recurseType || $recurseType === 'user') {
             return $this;
         } else {
             throw new Core_Model_Item_Exception('Cannot request owner of user of type other than user');
         }
     }
     // Get owner type
     $type = null;
     if (!empty($this->_owner_type)) {
         // Local definition
         $type = $this->_owner_type;
     } else {
         if (!empty($this->owner_type)) {
             // Db definition
             $type = $this->owner_type;
         } else {
             $type = 'user';
         }
     }
     if (null === $type) {
         throw new Core_Model_Item_Exception('No owner type defined and not overriden');
     }
     if (!Engine_Api::_()->hasItemType($type)) {
         throw new Core_Model_Item_Exception('Unknown owner type: ' . $type);
     }
     // Get parent id
     $id = null;
     if (!empty($this->owner_id)) {
         $id = $this->owner_id;
     } else {
         $short_type = Engine_Api::typeToShort($type, Engine_Api::_()->getItemModule($type));
         $prop = $short_type . '_id';
         if (!empty($this->{$prop})) {
             $id = $this->{$prop};
         }
     }
     if (null === $id) {
         throw new Core_Model_Item_Exception('No owner id defined');
     }
     if (!($owner = Engine_Api::_()->getItem($type, $id)) instanceof Core_Model_Item_Abstract || !$owner->getIdentity()) {
         //throw new Core_Model_Item_Exception('Owner missing');
         //instead of throwing exception return and empty user object, the user model should handle it gracefully
         return Engine_Api::_()->getItem($type, $id);
     }
     if (null !== $recurseType && $owner->getType() != $recurseType) {
         $newOwner = $owner->getOwner($recurseType);
         if ($newOwner->isSelf($owner)) {
             throw new Core_Model_Item_Exception('Infinite recursion detected in getOwner()');
         }
         return $newOwner;
     }
     return $owner;
 }
开发者ID:HiLeo1610,项目名称:tumlumsach,代码行数:60,代码来源:Abstract.php


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