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


PHP Centurion_Db::getSingleton方法代码示例

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


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

示例1: registerProfile

 /**
  * Register a profile automatically if it not exists.
  *
  * @param string $result result row of authentication
  * @return void
  */
 public function registerProfile($signal)
 {
     if (!Centurion_Auth::getInstance()->getProfile()) {
         $identity = Centurion_Auth::getInstance()->getIdentity();
         Centurion_Db::getSingleton('user/profile')->insert(array('nickname' => $identity->username, 'user_id' => $identity->id));
     }
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:13,代码来源:Bootstrap.php

示例2: testDateFormatForDatePicker

 public function testDateFormatForDatePicker()
 {
     //Without time
     $date = new Zend_Date('1/12/2009', 'dd/MM/YYYY');
     $form = new Cms_Form_Model_Flatpage();
     $form->setDateFormat('dd/MM/yy');
     $row = Centurion_Db::getSingleton('cms/flatpage')->createRow();
     $row->published_at = $date->get('YYYY-MM-dd HH:mm:ss');
     $form->setInstance($row);
     $expected = $date->get('dd/MM/yy');
     $value = $form->getElement('published_at')->getValue();
     $this->assertEquals($expected, $value);
     $values = $form->processValues($form->getValues());
     $this->assertEquals($date->get('YYYY-MM-dd HH:mm:ss'), $values['published_at']);
     //With Time
     $date = new Zend_Date('1/12/2009 11:32', 'dd/MM/YYYY HH:mm');
     $form = new Cms_Form_Model_Flatpage();
     $form->setDateFormat('dd/MM/yy', 'hh:mm');
     $row = Centurion_Db::getSingleton('cms/flatpage')->createRow();
     $row->published_at = $date->get('YYYY-MM-dd HH:mm:ss');
     $form->setInstance($row);
     $expected = $date->get('dd/MM/yy hh:mm');
     $value = $form->getElement('published_at')->getValue();
     $this->assertEquals($expected, $value);
     $values = $form->processValues($form->getValues());
     $this->assertEquals($date->get('YYYY-MM-dd HH:mm:ss'), $values['published_at']);
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:27,代码来源:ModelTest.php

示例3: getPx

 public static function getPx()
 {
     if (null == self::$_px) {
         self::$_px = Centurion_Db::getSingleton('media/file')->findOneByfile_id('88888888');
     }
     return self::$_px;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:7,代码来源:File.php

示例4: init

 public function init()
 {
     $controller = $this->getActionController();
     if (!($requestedLocale = $controller->getRequest()->getParam('language', false))) {
         $local = new Zend_Locale();
         $requestedLocale = $local->getLanguage();
     }
     if (is_array($requestedLocale)) {
         $requestedLocale = current($requestedLocale);
     }
     $requestedLocale = strtolower($requestedLocale);
     try {
         Centurion_Db::getSingleton('translation/language')->get(array('locale' => $requestedLocale));
     } catch (Centurion_Db_Table_Row_Exception_DoesNotExist $e) {
         $requestedLocale = Translation_Traits_Common::getDefaultLanguage();
         $requestedLocale = $requestedLocale->locale;
     }
     Zend_Registry::get('Zend_Translate')->setLocale($requestedLocale);
     Zend_Locale::setDefault($requestedLocale);
     Zend_Registry::set('Zend_Locale', $requestedLocale);
     $options = Centurion_Db_Table_Abstract::getDefaultFrontendOptions();
     if (!isset($options['cache_id_prefix'])) {
         $options['cache_id_prefix'] = '';
     }
     $options['cache_id_prefix'] = $requestedLocale . '_' . $options['cache_id_prefix'];
     Centurion_Db_Table_Abstract::setDefaultFrontendOptions($options);
     //TODO: fix this when in test unit environment
     if (!APPLICATION_ENV === 'testing') {
         $this->getActionController()->getFrontController()->getParam('bootstrap')->getResource('cachemanager')->addIdPrefix($requestedLocale . '_');
     }
     if (Centurion_Config_Manager::get('translation.global_param')) {
         $this->getFrontController()->getRouter()->setGlobalParam('language', $requestedLocale);
     }
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:34,代码来源:ManageLanguageParam.php

示例5: __construct

 public function __construct($options = array(), Centurion_Db_Table_Row_Abstract $instance = null)
 {
     $this->_model = Centurion_Db::getSingleton('cms/flatpage');
     $this->_exclude = array('created_at', 'id', 'updated_at', 'mptt_lft', 'mptt_rgt', 'slug', 'mptt_level', 'mptt_tree_id', 'faltpage_type', 'cover_id', 'mptt_parent_id');
     $this->_elementLabels = array('title' => $this->_translate('Title'), 'description' => $this->_translate('Description'), 'keywords' => $this->_translate('Keywords'), 'url' => $this->_translate('URL'), 'body' => $this->_translate('Content'), 'cover_id' => $this->_translate('Cover'), 'flatpage_template_id' => $this->_translate('Template'), 'mptt_parent_id' => $this->_translate('Parent'), 'published_at' => $this->_translate('Date to publish'), 'is_published' => $this->_translate('Is published'), 'order' => $this->_translate('Order'), 'route' => $this->_translate('Route'));
     parent::__construct($options, $instance);
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:7,代码来源:Flatpage.php

示例6: getAction

 public function getAction()
 {
     $this->getHelper('layout')->disableLayout();
     $this->getHelper('viewRenderer')->setNoRender(true);
     $media = $this->getInvokeArg('bootstrap')->getOption('media');
     if (!(null != ($fileRow = $this->_getParam('file')) && $fileRow instanceof Media_Model_DbTable_Row_File)) {
         $mediaAdapter = Media_Model_Adapter::factory($media['adapter'], $media['params']);
         $id = bin2hex(Centurion_Inflector::urlDecode($this->_request->getParam('id')));
         $key = bin2hex(Centurion_Inflector::urlDecode($this->_request->getParam('key')));
         $fileRow = $this->_helper->getObjectOr404('media/file', array('id' => $id));
         $this->forward404If(!$mediaAdapter->isValidKey($fileRow, $key, '', $media['key_lifetime']));
     }
     $source = $media['uploads_dir'] . DIRECTORY_SEPARATOR . $fileRow->local_filename;
     if (null == $this->_getParam('noAdapter', null)) {
         $isSaved = $mediaAdapter->save($source, $fileRow->getRelativePath(null, false, true), true);
         if ($isSaved) {
             Centurion_Db::getSingleton('media/duplicate')->insert(array('file_id' => $fileRow->id, 'adapter' => $media['adapter'], 'params' => serialize($media['params']), 'dest' => $fileRow->getRelativePath(null, false, true)));
             return $this->getHelper('redirector')->gotoUrlAndExit($fileRow->getStaticUrl());
         }
     }
     $offset = 24 * 60 * 60 * 365;
     $this->getResponse()->setHeader('Content-type', $fileRow->mime)->setHeader('Content-Length', filesize($source))->setHeader('Content-Disposition', sprintf('inline; filename="%s";', $fileRow->filename))->setHeader('Cache-Control', sprintf('max-age=%d, public', $offset))->setHeader('Expires', sprintf('%s GMT', gmdate('D, d M Y H:i:s', time() + $offset)))->sendHeaders();
     while (@ob_end_flush()) {
     }
     $fp = fopen($source, 'rb');
     fpassthru($fp);
     fclose($fp);
     $this->getResponse()->clearHeaders();
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:29,代码来源:FileController.php

示例7: __construct

 /**
  * Constructor
  *
  * @param   array|Zend_Config           $options    Options
  * @param   Centurion_Db_Table_Abstract $instance   Instance attached to the form
  * @return void
  */
 public function __construct($options = array(), Centurion_Db_Table_Row_Abstract $instance = null)
 {
     $this->_model = Centurion_Db::getSingleton('core/navigation');
     $this->_exclude = array('mptt_parent_id');
     $this->_elementLabels = array('label' => $this->_translate('Label'), 'module' => $this->_translate('Module name'), 'controller' => $this->_translate('Controller name'), 'action' => $this->_translate('Action name'), 'params' => $this->_translate('Params (json)'), 'route' => $this->_translate('Route name'), 'uri' => $this->_translate('URI'), 'is_visible' => $this->_translate('Visible?'), 'class' => $this->_translate('Stylesheet'), 'proxy' => $this->_translate('Proxy'));
     return parent::__construct($options, $instance);
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:14,代码来源:Navigation.php

示例8: testModel

 public function testModel()
 {
     try {
         $guidelineTable = Centurion_Db::getSingleton('cms/flatpage');
     } catch (Centurion_Db_Exception $e) {
         $this->fail('Table does not exists');
     }
     $this->assertTrue($guidelineTable->hasColumn('id'));
     $this->assertTrue($guidelineTable->hasColumn('title'));
     $this->assertTrue($guidelineTable->hasColumn('slug'));
     $this->assertTrue($guidelineTable->hasColumn('description'));
     $this->assertTrue($guidelineTable->hasColumn('keywords'));
     $this->assertTrue($guidelineTable->hasColumn('body'));
     $this->assertTrue($guidelineTable->hasColumn('url'));
     $this->assertTrue($guidelineTable->hasColumn('id'));
     $this->assertTrue($guidelineTable->hasColumn('flatpage_template_id'));
     $this->assertTrue($guidelineTable->hasColumn('published_at'));
     $this->assertTrue($guidelineTable->hasColumn('created_at'));
     $this->assertTrue($guidelineTable->hasColumn('updated_at'));
     $this->assertTrue($guidelineTable->hasColumn('is_published'));
     $this->assertTrue($guidelineTable->hasColumn('mptt_lft'));
     $this->assertTrue($guidelineTable->hasColumn('mptt_rgt'));
     $this->assertTrue($guidelineTable->hasColumn('mptt_level'));
     $this->assertTrue($guidelineTable->hasColumn('mptt_tree_id'));
     $this->assertTrue($guidelineTable->hasColumn('mptt_parent_id'));
     $this->assertTrue($guidelineTable->hasColumn('original_id'));
     $this->assertTrue($guidelineTable->hasColumn('language_id'));
     $this->assertTrue($guidelineTable->hasColumn('forward_url'));
     $this->assertTrue($guidelineTable->hasColumn('flatpage_type'));
     $this->assertTrue($guidelineTable->hasColumn('route'));
     $this->assertTrue($guidelineTable->hasColumn('class'));
     $this->assertTrue($guidelineTable->hasColumn('cover_id'));
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:33,代码来源:FlatPageTest.php

示例9: prePopulate

 public function prePopulate($signal, $sender, $values)
 {
     if (isset($values[Translation_Traits_Model_DbTable::ORIGINAL_FIELD]) || $this->hasInstance() && null !== $this->getInstance()->{Translation_Traits_Model_DbTable::ORIGINAL_FIELD}) {
         try {
             $value = $this->getModel()->get(array('id' => $values[Translation_Traits_Model_DbTable::ORIGINAL_FIELD]));
         } catch (Centurion_Db_Table_Row_Exception $e) {
             return;
         }
         $spec = $this->_form->getModel()->getTranslationSpec();
         if (!$this->hasInstance()) {
             foreach ($spec[Translation_Traits_Model_DbTable::TRANSLATED_FIELDS] as $field) {
                 $element = $this->getElement($field);
                 if (null !== $element) {
                     $element->setValue($value->{$field});
                 }
             }
         }
         $f = $this->_getInfoField(Translation_Traits_Model_DbTable::ORIGINAL_FIELD);
         $f->setValue((string) $value);
         $value = Centurion_Db::getSingleton('translation/language')->get(array('id' => $values[Translation_Traits_Model_DbTable::LANGUAGE_FIELD]));
         $f = $this->_getInfoField(Translation_Traits_Model_DbTable::LANGUAGE_FIELD);
         $f->setValue((string) $value->name);
         $fields = array_merge($spec[Translation_Traits_Model_DbTable::DUPLICATED_FIELDS], $spec[Translation_Traits_Model_DbTable::SET_NULL_FIELDS]);
         foreach ($fields as $field) {
             $this->removeElement($field);
             $this->addExclude($field);
         }
     }
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:29,代码来源:Model.php

示例10: indexAction

 public function indexAction()
 {
     $form = new Centurion_Form();
     $form->addElement('text', 'module_name', array('required' => true, 'label' => $this->view->translate('Module:')));
     $form->addElement('text', 'controller_name', array('required' => true, 'label' => $this->view->translate('Controller:')));
     $form->addElement('text', 'ressource_name', array('required' => true, 'label' => $this->view->translate('Ressource:')));
     $form->addElement('submit', 'submit', array('label' => $this->view->translate('Submit')));
     $post = $this->_request->getParams();
     if ($form->isValid($post)) {
         $this->view->message = 'Les permission ont bien été ajoutées. <br />';
         $permissionTable = Centurion_Db::getSingleton('auth/permission');
         $tab = array('index' => 'View %s %s index', 'list' => 'View %s %s list', 'get' => 'View an %s %s', 'post' => 'Create an %s %s', 'new' => 'Access to creation of an %s %s', 'delete' => 'Delete an %s %s', 'put' => 'Update an %s %s', 'batch' => 'Batch an %s %s', 'switch' => 'Switch an %s %s');
         foreach ($tab as $key => $description) {
             list($row, $created) = $permissionTable->getOrCreate(array('name' => $post['module_name'] . '_' . $post['controller_name'] . '_' . $key));
             if ($created) {
                 $row->description = sprintf($description, $post['module_name'], $post['ressource_name']);
                 $row->save();
             }
         }
         /*
             INSERT INTO \`auth_permission\` (\`name\`,\`description\`)
             VALUES
             ('${1:module}_${2:controller}_index', 'View ${1:module} ${3:resource} index'),
             ('${1:module}_${2:controller}_list', 'View ${1:module} ${3:resource} list'),
             ('${1:module}_${2:controller}_get', 'View an ${1:module} ${3:resource}'),
             ('${1:module}_${2:controller}_post', 'Create an ${1:module} ${3:resource}'),
             ('${1:module}_${2:controller}_new', 'Access to creation of an ${1:module} ${3:resource}'),
             ('${1:module}_${2:controller}_delete', 'Delete an ${1:module} ${3:resource}'),
             ('${1:module}_${2:controller}_put', 'Update an ${1:module} ${3:resource}');
         */
     }
     $this->view->form = $form;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:33,代码来源:AdminScriptPermissionController.php

示例11: notice

 public function notice($param)
 {
     if (!is_array($param)) {
         return;
     }
     $inserted = false;
     if (!isset($this->_testedLanguage[$param[1]])) {
         $languageTable = Centurion_Db::getSingleton('translation/language');
         $languageRow = $languageTable->findOneByLocale($param[1]);
         if (null === $languageRow) {
             $inserted = true;
             $languageRow = $languageTable->insert(array('locale' => $param[1]));
         }
         $this->_testedLanguage[$param[1]] = true;
     }
     if (!isset($this->_testedUid[$param[0]]) && trim($param[0]) !== '') {
         $uidTable = Centurion_Db::getSingleton('translation/uid');
         list($uidRow, $inserted) = $uidTable->getOrCreate(array('uid' => $param[0]));
         /*if (null === $uidRow) {
               $inserted = true;
               $uidRow = $uidTable->insert(array('uid' => $param[0]));
           }*/
         if ($inserted) {
             //TODO: send a signal to bootstrap for clearing cache
             Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('core')->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('translation'));
         }
         $this->_testedUid[$param[0]] = true;
     }
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:29,代码来源:Translation.php

示例12: __construct

 public function __construct($options = array())
 {
     $this->_model = Centurion_Db::getSingleton('user/profile');
     $this->_exclude = array('user_id', 'created_at', 'updated_at', 'id', 'avatar_id');
     $this->_elementLabels = array('nickname' => 'Nickname', 'about' => 'About', 'website' => 'Website', 'facebook_pageid' => 'Facebook Page ID');
     parent::__construct($options);
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:7,代码来源:AdminProfile.php

示例13: __construct

 public function __construct($options = array(), Centurion_Db_Table_Row_Abstract $instance = null)
 {
     $this->_model = Centurion_Db::getSingleton('cms/flatpage_template');
     $this->_exclude = array();
     $this->_elementLabels = array('name' => $this->_translate('Name'), 'view_script' => $this->_translate('View script'));
     $this->setLegend($this->_translate('Edit flatpage template'));
     parent::__construct($options, $instance);
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:8,代码来源:FlatpageTemplate.php

示例14: __construct

 public function __construct($options = array())
 {
     $this->_model = Centurion_Db::getSingleton('user/profile');
     $this->_elementLabels = array('nickname' => 'Nickname', 'function' => 'Function', 'about' => 'About', 'website' => 'Website', 'user_id' => 'User Parent');
     $this->_exclude = array('created_at', 'updated_at', 'id', 'avatar_id');
     $this->setLegend($this->_translate('Edit User'));
     parent::__construct($options);
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:8,代码来源:Profile.php

示例15: checkNavigationAction

 public function checkNavigationAction()
 {
     $roots = Centurion_Db::getSingleton('core/navigation')->getRootNodes()->fetchAll();
     foreach ($roots as $node) {
         $this->_recursiveCheckLeftRight($node);
     }
     die;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:8,代码来源:NavigationController.php


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