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


PHP Centurion_Db::getSingletonByClassName方法代码示例

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


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

示例1: _getProxy

 /**
  * Get the proxy
  *
  * @return Centurion_Db_Table_Row_Abstract
  */
 protected function _getProxy($model, $pk)
 {
     if (null === $this->_proxy && null !== $pk) {
         $proxyTable = Centurion_Db::getSingletonByClassName($model);
         $this->_proxy = $proxyTable->find($pk)->current();
     }
     return $this->_proxy;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:13,代码来源:Proxy.php

示例2: render

 /**
  * Get the row referenced by the value and set it to the element before rendering it.
  * @param Zend_View_Interface $view
  * @return string
  */
 public function render(Zend_View_Interface $view = null)
 {
     if ($this->getValue() !== null) {
         $relatedModel = Centurion_Db::getSingletonByClassName($this->_reference);
         $this->setValue($relatedModel->findOneById($this->getValue()));
     }
     return parent::render($view);
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:13,代码来源:Reference.php

示例3: getNavigation

 /**
  * Retrieve navigation object.
  *
  * @return Zend_Navigation
  */
 public function getNavigation()
 {
     if (null === $this->_navigation) {
         $options = $this->getOptions();
         $this->_navigation = new Zend_Navigation(Centurion_Db::getSingletonByClassName($options['adapter'])->getCache()->toNavigation());
         $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
         Zend_Registry::set($key, $this->_navigation);
     }
     return $this->_navigation;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:15,代码来源:Navigation.php

示例4: _getProxy

 protected function _getProxy($model, $pk)
 {
     if (null !== $model) {
         if (null === $this->_proxy) {
             $proxyTable = Centurion_Db::getSingletonByClassName($model);
             if (null !== $pk) {
                 $this->_proxy = $proxyTable->findOneById($pk);
             }
         }
         return $this->_proxy;
     }
     return false;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:13,代码来源:File.php

示例5: translateAction

 public function translateAction()
 {
     $form = $this->_getForm();
     $fromPk = $this->_controller->getRequest()->getParam('from');
     $targetLang = $this->_controller->getRequest()->getParam('lang');
     $this->_controller->getRequest()->setParam('from', null);
     $this->_controller->getRequest()->setParam('lang', null);
     $model = Centurion_Db::getSingletonByClassName(get_class($form->getModel()));
     Centurion_Db_Table_Abstract::setFiltersStatus(false);
     try {
         $row = $model->get(array('language_id' => $targetLang, 'original_id' => $fromPk));
         Centurion_Db_Table_Abstract::restoreFiltersStatus();
         $this->_form = null;
         $this->_controller->getRequest()->setParam('id', $row->id);
         self::$_filters = false;
         Centurion_Db_Table_Abstract::setFiltersStatus(self::$_filters);
         $this->getAction();
     } catch (Centurion_Db_Table_Row_Exception_DoesNotExist $e) {
         $this->_controller->getRequest()->setParam(Centurion_Controller_CRUD::PARAM_FORM_VALUES, array('original_id' => $fromPk, 'language_id' => $targetLang));
         $this->newAction();
     }
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:22,代码来源:CRUD.php

示例6: getTestableModel

 protected function getTestableModel()
 {
     global $application;
     $bootstrap = $application->getBootstrap();
     $bootstrap->bootstrap('FrontController');
     $bootstrap->bootstrap('modules');
     $bootstrap->bootstrap('db');
     $moduleRessource = $bootstrap->getResource('modules');
     if (null == $this->_testableModel) {
         $this->_testableModel = array();
         $front = Centurion_Controller_Front::getInstance();
         $modules = $front->getControllerDirectory();
         $moduleEnabled = Centurion_Config_Manager::get('resources.modules');
         foreach ($modules as $moduleName => $module) {
             if (!in_array($moduleName, $moduleEnabled)) {
                 continue;
             }
             $dbTableDir = realpath($module . '/../models/DbTable');
             if (!file_exists($dbTableDir)) {
                 continue;
             }
             $dir = new Centurion_Iterator_DbTableFilter($dbTableDir);
             foreach ($dir as $fileInfo) {
                 $filename = $fileInfo->getFilenameWithoutExtension();
                 $className = sprintf('%s_Model_DbTable_%s', ucfirst($moduleName), $filename);
                 $model = Centurion_Db::getSingletonByClassName($className);
                 if (method_exists($model, 'getTestCondition')) {
                     $testCondition = $model->getTestCondition();
                     if (null !== $testCondition) {
                         $this->_testableModel[] = array($model, $model->getTestCondition());
                     }
                 }
             }
         }
     }
     return $this->_testableModel;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:37,代码来源:ModelTest.php

示例7: uploadAction

 public function uploadAction()
 {
     $this->getHelper('layout')->disableLayout();
     $this->getHelper('viewRenderer')->setNoRender(true);
     $ticket = $this->_getParam('uploadTicket');
     $ticket = Centurion_Db::getSingleton('media/multiupload_ticket')->findOneByTicket($ticket);
     if (null === $ticket) {
         echo Zend_Json::encode(array('code' => false, 'message' => 'Invalid Ticket'));
         return;
     }
     $originalForm = new $ticket->form_class_model->name();
     if (null !== $ticket->proxy_pk) {
         $instance = Centurion_Db::getSingletonByClassName($ticket->proxy_model->name)->find($ticket->proxy_pk);
         $instance = $instance->current();
         $originalForm->setInstance($instance);
     }
     if ($ticket->values !== null) {
         $originalForm->populate(unserialize($ticket->values));
     }
     $result = array();
     $form = $originalForm->getElement($ticket->element_name)->getFile();
     if ($form->isValid(array())) {
         $file = $form->save();
         if (method_exists($originalForm, 'postMultiuploadSuccess')) {
             $originalForm->postMultiuploadSuccess($file);
         }
         $result['code'] = true;
         if ($file->isImage()) {
             $result['thumb'] = $file->getStaticUrl(array('resize' => array('maxWidth' => 100, 'maxHeight' => 100)));
         }
         $result['fileId'] = $file->id;
     } else {
         $result['code'] = false;
         $result['message'] = $form->getErrorMessages();
     }
     echo Zend_Json::encode($result);
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:37,代码来源:UploadController.php

示例8: _joinUsingVia

 /**
  * Adds a JOIN table and columns to the query with the referenceMap.
  *
  * @param  string $key                 The referenceMap key
  * @param  array|string $cols          The columns to select from the joined table.
  * @param  string $schema              The database name to specify, if any.
  * @return Centurion_Db_Table_Select   This Centurion_Db_Table_Select object.
  */
 protected function _joinUsingVia($key, $type, $cols = '*', $schema = null)
 {
     if (empty($this->_parts[self::FROM])) {
         require_once 'Zend/Db/Select/Exception.php';
         throw new Zend_Db_Select_Exception("You can only perform a joinUsing after specifying a FROM table");
     }
     $referenceMap = $this->getTable()->getReferenceMap(Centurion_Inflector::tableize($key));
     $refTable = Centurion_Db::getSingletonByClassName($referenceMap['refTableClass']);
     $name = $refTable->info('name');
     $join = $this->_adapter->quoteIdentifier(key($this->_parts[self::FROM]), true);
     $from = $this->_adapter->quoteIdentifier($name);
     $primary = $refTable->info('primary');
     $cond1 = $join . '.' . $referenceMap['columns'];
     $cond2 = $from . '.' . $primary[1];
     $cond = $cond1 . ' = ' . $cond2;
     return $this->_join($type, $name, $cond, $cols, $schema);
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:25,代码来源:Select.php

示例9: _initDbTable

 /**
  * Initialize DbTable for each loaded module.
  *
  * @return void
  */
 protected function _initDbTable()
 {
     $cache = $this->_getCache('core');
     if (!($references = $cache->load('references_apps'))) {
         $this->bootstrap('FrontController');
         $this->bootstrap('db');
         $this->bootstrap('modules');
         $front = $this->getResource('FrontController');
         $modules = $front->getControllerDirectory();
         $references = array();
         $moduleEnabled = Centurion_Config_Manager::get('resources.modules');
         foreach ($modules as $moduleName => $module) {
             if (!in_array($moduleName, $moduleEnabled)) {
                 continue;
             }
             $dbTableDir = realpath($module . '/../models/DbTable');
             if (!file_exists($dbTableDir)) {
                 continue;
             }
             $dir = new Centurion_Iterator_DbTableFilter($dbTableDir);
             foreach ($dir as $fileInfo) {
                 $filename = $fileInfo->getFilenameWithoutExtension();
                 $className = sprintf('%s_Model_DbTable_%s', ucfirst($moduleName), $filename);
                 $model = Centurion_Db::getSingletonByClassName($className);
                 $meta = $model->getMeta();
                 $metaData = $model->info('metadata');
                 foreach ($model->getReferenceMap() as $key => $referenceMap) {
                     $refTableClass = $referenceMap['refTableClass'];
                     $referencedModel = Centurion_Db::getSingletonByClassName($refTableClass);
                     $plural = true;
                     if (isset($metaData[$referenceMap['columns']]['UNIQUE']) && $metaData[$referenceMap['columns']]['UNIQUE'] == true) {
                         $plural = false;
                     }
                     if ($plural) {
                         $dependentTableKey = $meta['verbosePlural'];
                     } else {
                         $dependentTableKey = $meta['verboseName'];
                     }
                     if (array_key_exists($dependentTableKey, $referencedModel->getDependentTables())) {
                         continue;
                     }
                     if (!array_key_exists($refTableClass, $references)) {
                         $references[$refTableClass] = array();
                     }
                     $references[$refTableClass][$dependentTableKey] = $className;
                 }
             }
         }
         $cache->save($references, 'references_apps');
     }
     Centurion_Db::setReferences($references);
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:57,代码来源:Bootstrap.php

示例10: setFilters

 public function setFilters($filters)
 {
     $this->cleanForm();
     foreach ($filters as $key => &$filterData) {
         if (!is_array($filterData)) {
             $filterData = array('label' => $filterData);
             if ($this->_table !== null) {
                 $reference = $this->_table->info(Centurion_Db_Table_Abstract::REFERENCE_MAP);
                 if (isset($reference[$key])) {
                     $refTable = Centurion_Db::getSingletonByClassName($reference[$key]['refTableClass']);
                     $rowset = $refTable->all();
                     $data = array();
                     foreach ($rowset as $row) {
                         $data[] = (string) $row;
                     }
                     $filterData['type'] = Centurion_Controller_CRUD::FILTER_TYPE_CHECKBOX;
                     $filterData['data'] = $data;
                 }
             }
         }
         if (isset($filterData['label'])) {
             $label = $filterData['label'];
         } else {
             $label = '';
         }
         $checkboxType = 'multiCheckbox';
         $element = null;
         if (!isset($filterData['type'])) {
             $filterData['type'] = Centurion_Controller_CRUD::FILTER_TYPE_TEXT;
         }
         if (!isset($filterData['column'])) {
             $filterData['column'] = $key;
         }
         if (!isset($filterData['behavior'])) {
             $filterData['behavior'] = Centurion_Controller_CRUD::FILTER_BEHAVIOR_CONTAINS;
         }
         switch ($filterData['type']) {
             case Centurion_Controller_CRUD::FILTER_TYPE_RADIO:
                 $checkboxType = 'radio';
             case Centurion_Controller_CRUD::FILTER_TYPE_SELECT:
                 if ($checkboxType === 'multiCheckbox') {
                     $checkboxType = 'select';
                 }
             case Centurion_Controller_CRUD::FILTER_TYPE_CHECKBOX:
                 $element = $this->createElement($checkboxType, $key, array('label' => $label));
                 if (!isset($filterData['data'])) {
                     $manyDependentTables = $this->_table->info('manyDependentTables');
                     if (isset($manyDependentTables[$key])) {
                         $refRowSet = Centurion_Db::getSingletonByClassName($manyDependentTables[$key]['refTableClass'])->fetchAll();
                         $filterData['data'] = array();
                         foreach ($refRowSet as $refRow) {
                             $filterData['data'][$refRow->id] = $refRow->__toString();
                         }
                         asort($filterData['data']);
                     }
                 }
                 $element->addMultiOptions($filterData['data']);
                 $element->setSeparator('');
                 if ($checkboxType === 'multiCheckbox') {
                     $element->setIsArray(true);
                 }
                 break;
             case Centurion_Controller_CRUD::FILTER_TYPE_TEXT:
             case Centurion_Controller_CRUD::FILTER_TYPE_NUMERIC:
                 $element = $this->createElement('text', $key, array('label' => $label));
                 break;
             case Centurion_Controller_CRUD::FILTER_TYPE_DATE:
                 $element = $this->createElement('text', $key, array('label' => $label, 'class' => 'datepicker'));
                 break;
             case Centurion_Controller_CRUD::FILTER_TYPE_BETWEEN_DATE:
             case Centurion_Controller_CRUD::FILTER_TYPE_BETWEEN_DATETIME:
                 $form = new self();
                 if ($filterData['type'] == Centurion_Controller_CRUD::FILTER_TYPE_BETWEEN_DATETIME) {
                     $class = 'field-datetimepicker';
                 } else {
                     $class = 'datepicker';
                 }
                 $element = $form->createElement('text', 'gt', array('class' => $class, 'belongsTo' => $key, 'label' => $this->_translate('From'), 'value' => '26/08/11 03:00'));
                 $form->addElement($element, 'gt');
                 $element = $form->createElement('text', 'lt', array('class' => $class, 'belongsTo' => $key, 'label' => $this->_translate('To'), 'value' => '26/08/11 03:00'));
                 $form->addElement($element, 'lt');
                 $element = null;
                 $form->setDescription($label);
                 $this->addSubForm($form, $key);
                 $this->getSubForm($key)->setDecorators($this->defaultDisplayGroupDecorators);
                 $form->getElement('lt')->setDecorators($this->defaultElementDecoratorsInDisplayGroup);
                 $form->getElement('gt')->setDecorators($this->defaultElementDecoratorsInDisplayGroup);
                 //                    $this->addDisplayGroup(array('lt', 'gt'), $key, array('description' => $label));
                 break;
         }
         if (null !== $element) {
             $this->addElement($element, $key);
         }
     }
     $this->_filters = $filters;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:96,代码来源:Filter.php

示例11: getProxy

 public function getProxy()
 {
     if (null === $this->_proxy && null !== $this->proxy_pk) {
         $proxyTable = Centurion_Db::getSingletonByClassName($this->model->name);
         $tableName = $proxyTable->info(Centurion_Db_Table_Abstract::NAME);
         $this->_proxy = $proxyTable->select(true)->where($tableName . '.id=?', $this->proxy_pk)->fetchRow();
         //Reverse binding
         if (null !== $this->_proxy && method_exists($this->_proxy, 'setNavigation')) {
             $this->_proxy->setNavigation($this);
         }
     }
     return $this->_proxy;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:13,代码来源:Navigation.php

示例12: __wakeup

 /**
  * @return void
  * @todo documentation
  */
 public function __wakeup()
 {
     $this->_table = Centurion_Db::getSingletonByClassName($this->_tableClass);
     $this->_connected = true;
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:9,代码来源:Abstract.php

示例13: getProfile

 /**
  * Retrieve the profile attached to the user instance.
  *
  * @return Centurion_Db_Table_Row_Abstract
  */
 public function getProfile()
 {
     if (null === $this->_profile) {
         $options = Centurion_Config_Manager::get('centurion');
         if (!isset($options['auth_profile'])) {
             throw new Centurion_Exception('No site profile module available: you have to set a centurion.auth_profile in your application.ini');
         }
         if (!class_exists($options['auth_profile'])) {
             throw new Centurion_Exception('The class in centurion.auth_profile option does not exists.');
         }
         $this->_profile = Centurion_Db::getSingletonByClassName($options['auth_profile'])->findOneByUserId($this->pk);
     }
     return $this->_profile;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:19,代码来源:User.php

示例14: _getTableFromString

 /**
  * Override the getter, if we get and related object of a related object.
  *
  * @param string $tableName
  * @return void
  */
 protected function _getTableFromString($tableName)
 {
     return Centurion_Db::getSingletonByClassName($tableName);
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:10,代码来源:Abstract.php

示例15: _columnToElements

 /**
  * Parse columns to fields.
  *
  * @param   array   $options
  * @todo Add CSRF key, for security.
  * @return  array   Elements.
  */
 protected function _columnToElements()
 {
     $info = $this->getModel()->info();
     $metadata = $info['metadata'];
     $elements = array();
     foreach ($metadata as $columnName => $columnDetails) {
         if ($this->isExcluded($columnName)) {
             continue;
         }
         if (!isset($this->_elementLabels[$columnName])) {
             continue;
         }
         if ($columnDetails['IDENTITY']) {
             $config = array('hidden', array());
         } elseif (substr($columnName, 0, 2) == 'is' || substr($columnName, 0, 6) == 'can_be' || substr($columnName, 0, 3) == 'has') {
             $config = array('onOff', array());
         } elseif (substr($columnName, 0, -3) == 'pwd' || $columnName == 'password') {
             $config = array('password', array());
         } elseif (preg_match('/^enum/i', $columnDetails['DATA_TYPE'])) {
             preg_match_all('/\'(.*?)\'/', $columnDetails['DATA_TYPE'], $matches);
             $options = true === $columnDetails['NULLABLE'] ? array(null => '') : array();
             foreach ($matches[1] as $match) {
                 $options[$match] = $match;
             }
             $config = array('select', array('multioptions' => $options));
         } elseif (false !== ($reference = $this->getModel()->getReferenceByColumnName($columnName))) {
             if ($this->isDisabled($columnName)) {
                 $config = array('Reference', array('reference' => $reference));
             } else {
                 $relatedTable = Centurion_Db::getSingletonByClassName($reference);
                 $options = $this->_buildOptions($relatedTable, $columnName, true === $columnDetails['NULLABLE']);
                 $config = array('select', array('multioptions' => $options));
             }
         } else {
             $datatype = $columnDetails['DATA_TYPE'];
             $config = array($this->_columnTypes[$datatype], array());
             if (array_key_exists($datatype, $this->_columnValidators)) {
                 $config[1]['validators'] = array(array('validator' => $this->_columnValidators[$datatype]));
                 if ($this->_columnValidators[$datatype] == 'StringLength') {
                     $config[1]['validators'][0]['options'] = array(0, $columnDetails['LENGTH']);
                 }
             }
             if (array_key_exists($datatype, $this->_columnFilters)) {
                 $config[1]['filters'] = $this->_columnFilters[$datatype];
             }
         }
         $config[1] = array_merge($config[1], array('label' => $this->_getElementLabel($columnName), 'required' => isset($columnDetails['NULLABLE']) ? (bool) $columnDetails['NULLABLE'] != true : false));
         if ($this->isDisabled($columnName)) {
             $config[1] = array_merge($config[1], array('disabled' => 'disabled'));
         }
         $elements[$columnName] = $config;
     }
     $manyDependentTables = $this->getModel()->info(Centurion_Db_Table_Abstract::MANY_DEPENDENT_TABLES);
     foreach ($manyDependentTables as $key => $manyDependentTable) {
         if ($this->isExcluded($key)) {
             continue;
         }
         $options = array('label' => $this->_getElementLabel($key));
         //TODO: remove this Media_Model_DbTable_File reference from core
         if ($manyDependentTable['refTableClass'] !== 'Media_Model_DbTable_File') {
             $table = Centurion_Db::getSingletonByClassName($manyDependentTable['refTableClass']);
             $intersectionTable = Centurion_Db::getSingletonByClassName($manyDependentTable['intersectionTable']);
             $options['multioptions'] = $this->_buildOptions($table, $key, false);
             if ($intersectionTable->hasColumn('order')) {
                 $options['class'] = 'sortable';
             }
             $elementName = 'multiselect';
         } else {
             $elementName = new Media_Form_Element_MultiFile($key, array('parentForm' => $this));
         }
         $elements[$key] = array($elementName, $options);
     }
     return $elements;
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:81,代码来源:Abstract.php


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