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


PHP aTools::getTemplateChoices方法代码示例

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


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

示例1: configure

 /**
  * DOCUMENT ME
  */
 public function configure()
 {
     parent::configure();
     $manage = $this->getObject()->isNew() ? true : $this->getObject()->userHasPrivilege('manage');
     $user = sfContext::getInstance()->getUser();
     // $page->setArchived(!sfConfig::get('app_a_default_published', sfConfig::get('app_a_default_on', true)));
     // 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.
     $fields = array('slug', 'archived');
     if ($user->hasCredential('cms_admin')) {
         $fields[] = 'edit_admin_lock';
     }
     $this->useFields($fields);
     $object = $this->getObject();
     // The states we really have now are:
     // Public
     // Login required, with various settings plus a boolean for "guest" access
     // Admin only (for which we have added view_admin_lock)
     // The problem is that right now, public and "guest" are distinguished by a single boolean.
     // It's a pain to turn that into an enumeration.
     // So we need an additional "view_guest" boolean consulted when "view_is_secure" is true, and
     // that new boolean should default to true.
     // In 2.0 we'll probably clean these flags up a bit.
     $choices = array('public' => 'Public', 'login' => 'Login Required', 'admin' => 'Admins Only');
     if (!$user->hasCredential('cms_admin')) {
         // You can't stop yourself and your peers from viewing a page
         unset($choices['admin']);
     }
     $default = 'public';
     if ($object->view_admin_lock) {
         $default = 'admin';
     } elseif ($object->view_is_secure) {
         $default = 'login';
     }
     if ($manage) {
         $this->setWidget('view_options', new sfWidgetFormChoice(array('choices' => $choices, 'expanded' => true, 'default' => $default)));
         $this->setValidator('view_options', new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => true)));
         if ($this->getObject()->hasChildren(false)) {
             $this->setWidget('view_options_apply_to_subpages', new sfWidgetFormInputCheckbox(array('label' => 'Apply to Subpages')));
             $this->setValidator('view_options_apply_to_subpages', new sfValidatorBoolean(array('true_values' => array('true', 't', 'on', '1'), 'false_values' => array('false', 'f', 'off', '0', ' ', ''))));
         }
         $this->setWidget('view_individuals', new sfWidgetFormInputHidden(array('default' => $this->getViewIndividualsJSON())));
         $this->setValidator('view_individuals', new sfValidatorCallback(array('callback' => array($this, 'validateViewIndividuals'), 'required' => true)));
         $this->setWidget('view_groups', new sfWidgetFormInputHidden(array('default' => $this->getViewGroupsJSON())));
         $this->setValidator('view_groups', new sfValidatorCallback(array('callback' => array($this, 'validateViewGroups'), 'required' => true)));
     }
     // Changed the name so Doctrine doesn't get uppity
     $engine = $object->engine;
     $template = $object->template;
     if (!strlen($object->template)) {
         $object->template = 'default';
     }
     if (!is_null($object->engine)) {
         $joinedTemplateName = $object->engine . ':' . $object->template;
     } else {
         $joinedTemplateName = 'a' . ':' . $object->template;
     }
     $choices = aTools::getTemplateChoices();
     $this->setWidget('joinedtemplate', new sfWidgetFormSelect(array('choices' => $choices, 'default' => $joinedTemplateName)));
     $this->setValidator('joinedtemplate', new sfValidatorChoice(array('required' => true, 'choices' => array_keys($choices))));
     // Published vs. Unpublished 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(false)) {
         $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', ' ', ''))));
     }
     // Tags
     $options['default'] = implode(', ', $this->getObject()->getTags());
     // added a space after the comma for readability
     if (sfConfig::get('app_a_all_tags', true)) {
         $options['all-tags'] = PluginTagTable::getAllTagNameWithCount();
     } else {
         sfContext::getInstance()->getConfiguration()->loadHelpers('Url');
         $options['typeahead-url'] = url_for('taggableComplete/complete');
     }
     $options['popular-tags'] = PluginTagTable::getPopulars(null, array('sort_by_popularity' => true), false, 10);
     $options['commit-selector'] = '#' . ($this->getObject()->isNew() ? 'a-create-page' : 'a-page-settings') . '-submit';
     $options['tags-label'] = '';
     // class tag-input enabled for typeahead support
     $this->setWidget('tags', new pkWidgetFormJQueryTaggable($options, array('class' => 'tags-input')));
     $this->setValidator('tags', new sfValidatorString(array('required' => false)));
     // Meta Description
     // Call the widget real_meta_description to avoid conflicts with the automatic behavior
     // of Doctrine forms (which will call setMetaDescription before the page is saved, something
     // that newAreaVersion does not support)
//.........这里部分代码省略.........
开发者ID:hashir,项目名称:UoA,代码行数:101,代码来源:BaseaPageSettingsForm.class.php


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