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


PHP Loader::loadClassFromModule方法代码示例

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


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

示例1: smarty_function_selectmodobject

/**
 * render plugin for fetching a particular module object
 *
 * Examples
 *   {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"}
 *   {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"}
 *   {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"}
 *
 * Parameters:
 *  module      Name of the module storing the desired object (in DBObject mode)
 *  objecttype  Name of object type (in DBObject mode)
 *  recordClass Class name of an doctrine record. (in Doctrine mode)
 *  id          Identifier of desired object
 *  prefix      Optional prefix for class names (defaults to PN) (in DBObject mode)
 *  assign      Name of the returned object
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return void
 */
function smarty_function_selectmodobject($params, Zikula_View $view)
{
    if (isset($params['recordClass']) && !empty($params['recordClass'])) {
        $doctrineMode = true;
    } else {
        // DBObject checks
        if (!isset($params['module']) || empty($params['module'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module')));
        }
        if (!isset($params['objecttype']) || empty($params['objecttype'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype')));
        }
        if (!isset($params['prefix'])) {
            $params['prefix'] = 'PN';
        }
        $doctrineMode = false;
    }
    if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id')));
    }
    if (!isset($params['assign']) || empty($params['assign'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign')));
    }
    // load object depending on mode: doctrine or dbobject
    if (!$doctrineMode) {
        if (!ModUtil::available($params['module'])) {
            $view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject')));
        }
        ModUtil::dbInfoLoad($params['module']);
        $classname = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']);
        if (!class_exists($classname) && System::isLegacyMode()) {
            // BC check for PNObject old style.
            // load the object class corresponding to $params['objecttype']
            if (!($class = Loader::loadClassFromModule($params['module'], $params['objecttype'], false, false, $params['prefix']))) {
                z_exit(__f('Unable to load class [%s] for module [%s]', array(DataUtil::formatForDisplay($params['objecttype']), DataUtil::formatForDisplay($params['module']))));
            }
        }
        // intantiate object model
        $object = new $class();
        $idField = $object->getIDField();
        // assign object data
        // this performs a new database select operation
        // while the result will be saved within the object, we assign it to a local variable for convenience
        $objectData = $object->get(intval($params['id']), $idField);
        if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) {
            $view->trigger_error(__('Sorry! No such item found.'));
        }
    } else {
        $objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']);
        if ($objectData === false) {
            $view->trigger_error(__('Sorry! No such item found.'));
        }
    }
    $view->assign($params['assign'], $objectData);
}
开发者ID:projectesIF,项目名称:Sirius,代码行数:76,代码来源:function.selectmodobject.php

示例2: getSelector_ObjectArray

 /**
  * Creates an object array selector.
  *
  * @param string  $modname        Module name.
  * @param string  $objectType     Object type.
  * @param string  $name           Select field name.
  * @param string  $field          Value field.
  * @param string  $displayField   Display field.
  * @param string  $where          Where clause.
  * @param string  $sort           Sort clause.
  * @param string  $selectedValue  Selected value.
  * @param string  $defaultValue   Value for "default" option.
  * @param string  $defaultText    Text for "default" option.
  * @param string  $allValue       Value for "all" option.
  * @param string  $allText        Text for "all" option.
  * @param string  $displayField2  Second display field.
  * @param boolean $submit         Submit on choose.
  * @param boolean $disabled       Add Disabled attribute to select.
  * @param string  $fieldSeparator Field seperator if $displayField2 is given.
  * @param integer $multipleSize   Size for multiple selects.
  *
  * @return string The rendered output.
  */
 public static function getSelector_ObjectArray($modname, $objectType, $name, $field = '', $displayField = 'name', $where = '', $sort = '', $selectedValue = '', $defaultValue = 0, $defaultText = '', $allValue = 0, $allText = '', $displayField2 = null, $submit = true, $disabled = false, $fieldSeparator = ', ', $multipleSize = 1)
 {
     if (!$modname) {
         return z_exit(__f('Invalid %1$s passed to %2$s.', array('modname', 'HtmlUtil::getSelector_ObjectArray')));
     }
     if (!$objectType) {
         return z_exit(__f('Invalid %1$s passed to %2$s.', array('objectType', 'HtmlUtil::getSelector_ObjectArray')));
     }
     if (!ModUtil::dbInfoLoad($modname)) {
         return __f('Unavailable/Invalid %1$s [%2$s] passed to %3$s.', array('modulename', $modname, 'HtmlUtil::getSelector_ObjectArray'));
     }
     if (!SecurityUtil::checkPermission("{$objectType}::", '::', ACCESS_OVERVIEW)) {
         return __f('Security check failed for %1$s [%2$s] passed to %3$s.', array('modulename', $modname, 'HtmlUtil::getSelector_ObjectArray'));
     }
     $cacheKey = md5("{$modname}|{$objectType}|{$where}|{$sort}");
     if (isset($cache[$cacheKey])) {
         $dataArray = $cache[$cacheKey];
     } else {
         $classname = "{$modname}_DBObject_" . StringUtil::camelize($objectType) . 'Array';
         if (!class_exists($classname) && System::isLegacyMode()) {
             // BC check for PNObject old style.
             $classname = Loader::loadClassFromModule($modname, $objectType, true);
             if (!$classname) {
                 return __f('Unable to load class [%1$s] for module [%2$s].', array($objectType, $modname));
             }
         }
         $class = new $classname();
         //$dataArray = $class->get($where, $sort, -1, -1, '', false, $distinct);
         $dataArray = $class->get($where, $sort, -1, -1, '', false);
         $cache[$cacheKey] = $dataArray;
         if (!$field) {
             $field = $class->_objField;
         }
     }
     $data2 = array();
     foreach ($dataArray as $object) {
         $val = $object[$field];
         $disp = $object[$displayField];
         if ($displayField2) {
             $disp .= $fieldSeparator . $object[$displayField2];
         }
         $data2[$val] = $disp;
     }
     return self::getSelector_Generic($name, $data2, $selectedValue, $defaultValue, $defaultText, $allValue, $allText, $submit, $disabled, $multipleSize);
 }
开发者ID:planetenkiller,项目名称:core,代码行数:68,代码来源:HtmlUtil.php

示例3: _feeds_createdefaultcategory

    /**
     * create placeholder for categories
     */
    private function _feeds_createdefaultcategory($regpath = '/__SYSTEM__/Modules/Global')
    {
        // load necessary classes
        Loader::loadClass('CategoryUtil');
        Loader::loadClassFromModule('Categories', 'Category');
        Loader::loadClassFromModule('Categories', 'CategoryRegistry');

        // get the language code
        $lang = ZLanguage::getLanguageCode();
        $dom  = ZLanguage::getModuleDomain('Feeds');

        // get the category path for which we're going to insert our place holder category
        $rootcat = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules');
        $fCat    = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Feeds');

        if (!$fCat) {
            // create placeholder for all the module categories
            $cat = new Categories_DBObject_Category();
            $cat->setDataField('parent_id', $rootcat['id']);
            $cat->setDataField('name', 'Feeds');
            $cat->setDataField('display_name', array($lang => __('Feeds', $dom)));
            $cat->setDataField('display_desc', array($lang => __('Feed Reader.', $dom)));
            if (!$cat->validate('admin')) {
                return false;
            }
            $cat->insert();
            $cat->update();
        }

        // get the category path for which the feeds will be classified
        $rootcat = CategoryUtil::getCategoryByPath($regpath);
        if ($rootcat) {
            // create an entry in the categories registry
            $registry = new Categories_DBObject_Registry();
            $registry->setDataField('modname', 'Feeds');
            $registry->setDataField('table', 'feeds');
            $registry->setDataField('property', 'Main');
            $registry->setDataField('category_id', $rootcat['id']);
            $registry->insert();
        } else {
            return false;
        }

        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:48,代码来源:Installer.php


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