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


PHP aTools::getEngines方法代码示例

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


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

示例1: configure

 public function configure()
 {
     parent::configure();
     // We must explicitly limit the fields because otherwise tables with foreign key relationships
     // to the pages table will extend the form whether it's appropriate or not. If you want to do
     // those things on behalf of an engine used in some pages, define a form class called
     // enginemodulenameEngineForm. It will automatically be instantiated with the engine page
     // as an argument to the constructor, and rendered beneath the main page settings form.
     // On submit, it will be bound to the parameter name that begins its name format and, if valid,
     // saved consecutively after the main page settings form. The form will be rendered via
     // the _renderPageSettingsForm partial in your engine module, which must exist, although it
     // can be as simple as echo $form. (Your form is passed to the partial as $form.)
     //
     // We would use embedded forms if we could. Unfortunately Symfony has unresolved bugs relating
     // to one-to-many relations in embedded forms.
     $this->useFields(array('slug', 'template', 'engine', 'archived', 'view_is_secure'));
     unset($this['author_id'], $this['deleter_id'], $this['Accesses'], $this['created_at'], $this['updated_at'], $this['view_credentials'], $this['edit_credentials'], $this['lft'], $this['rgt'], $this['level']);
     $this->setWidget('template', new sfWidgetFormSelect(array('choices' => aTools::getTemplates())));
     $this->setWidget('engine', new sfWidgetFormSelect(array('choices' => aTools::getEngines())));
     // On vs. off makes more sense to end users, but when we first
     // designed this feature we had an 'archived vs. unarchived'
     // approach in mind
     $this->setWidget('archived', new sfWidgetFormChoice(array('expanded' => true, 'choices' => array(false => "Published", true => "Unpublished"), 'default' => false)));
     if ($this->getObject()->hasChildren()) {
         $this->setWidget('cascade_archived', new sfWidgetFormInputCheckbox());
         $this->setValidator('cascade_archived', new sfValidatorBoolean(array('true_values' => array('true', 't', 'on', '1'), 'false_values' => array('false', 'f', 'off', '0', ' ', ''))));
         $this->setWidget('cascade_view_is_secure', new sfWidgetFormInputCheckbox());
         $this->setValidator('cascade_view_is_secure', new sfValidatorBoolean(array('true_values' => array('true', 't', 'on', '1'), 'false_values' => array('false', 'f', 'off', '0', ' ', ''))));
     }
     $this->setWidget('view_is_secure', new sfWidgetFormChoice(array('expanded' => true, 'choices' => array(false => "Public", true => "Login Required"), 'default' => false)));
     $this->addPrivilegeWidget('edit', 'editors');
     $this->addPrivilegeWidget('manage', 'managers');
     $this->setValidator('slug', new aValidatorSlug(array('required' => true, 'allow_slashes' => true), array('required' => 'The slug cannot be empty.', 'invalid' => 'The slug must contain only slashes, letters, digits, dashes and underscores. Also, you cannot change a slug to conflict with an existing slug.')));
     $this->setValidator('template', new sfValidatorChoice(array('required' => true, 'choices' => array_keys(aTools::getTemplates()))));
     // Making the empty string one of the choices doesn't seem to be good enough
     // unless we expressly clear 'required'
     $this->setValidator('engine', new sfValidatorChoice(array('required' => false, 'choices' => array_keys(aTools::getEngines()))));
     // The slug of the home page cannot change (chicken and egg problems)
     if ($this->getObject()->getSlug() === '/') {
         unset($this['slug']);
     } else {
         $this->validatorSchema->setPostValidator(new sfValidatorDoctrineUnique(array('model' => 'aPage', 'column' => 'slug'), array('invalid' => 'There is already a page with that slug.')));
     }
     $this->widgetSchema->setIdFormat('a_settings_%s');
     $this->widgetSchema->setNameFormat('settings[%s]');
     $this->widgetSchema->setFormFormatterName('list');
     $user = sfContext::getInstance()->getUser();
     if (!$user->hasCredential('cms_admin')) {
         unset($this['editors']);
         unset($this['managers']);
         unset($this['slug']);
     }
     // We changed the form formatter name, so we have to reset the translation catalogue too
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe');
 }
开发者ID:quafzi,项目名称:timpany-prototype,代码行数:55,代码来源:BaseaPageSettingsForm.class.php

示例2: getTemplates

 /**
  * Get template choices in the new format, then provide bc with the old format
  * (one level with no engines specified), and also add entries for any engines
  * listed in the old way that don't have templates specified in the new way
  * @return mixed
  */
 public static function getTemplates()
 {
     if (sfConfig::get('app_a_get_templates_method')) {
         $method = sfConfig::get('app_a_get_templates_method');
         return call_user_func($method);
     }
     $templates = sfConfig::get('app_a_templates', array('a' => array('default' => 'Default Page', 'home' => 'Home Page')));
     // Provide bc
     $newTemplates = $templates;
     foreach ($templates as $key => $value) {
         if (!is_array($value)) {
             $newTemplates['a'][$key] = $value;
             unset($newTemplates[$key]);
         }
     }
     $templates = $newTemplates;
     $engines = aTools::getEngines();
     foreach ($engines as $name => $label) {
         if (!strlen($name)) {
             // Ignore the "template-based" engine option
             continue;
         }
         if (!isset($templates[$name])) {
             $templates[$name] = array('default' => $label);
         }
     }
     return $templates;
 }
开发者ID:hashir,项目名称:UoA,代码行数:34,代码来源:BaseaTools.class.php


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