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


PHP Zend_Form::getTranslator方法代码示例

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


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

示例1: _recursivelyPrepareForm

 protected function _recursivelyPrepareForm(Zend_Form $form)
 {
     $belongsTo = $form instanceof Zend_Form ? $form->getElementsBelongTo() : null;
     $elementContent = '';
     $separator = $this->getSeparator();
     $translator = $form->getTranslator();
     $view = $form->getView();
     foreach ($form as $item) {
         $item->setView($view)->setTranslator($translator);
         if ($item instanceof Zend_Form_Element) {
             $item->setBelongsTo($belongsTo);
         } elseif (!empty($belongsTo) && $item instanceof Zend_Form) {
             if ($item->isArray()) {
                 $name = $this->mergeBelongsTo($belongsTo, $item->getElementsBelongTo());
                 $item->setElementsBelongTo($name, true);
             } else {
                 $item->setElementsBelongTo($belongsTo, true);
             }
             $this->_recursivelyPrepareForm($item);
         } elseif (!empty($belongsTo) && $item instanceof Zend_Form_DisplayGroup) {
             foreach ($item as $element) {
                 $element->setBelongsTo($belongsTo);
             }
         }
     }
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:26,代码来源:PrepareElements.php

示例2: testTranslatorFromRegistryUsedWhenNoneRegistered

    public function testTranslatorFromRegistryUsedWhenNoneRegistered()
    {
        $this->assertNull($this->form->getTranslator());
        $translator = new Zend_Translate('array', array());
        Zend_Registry::set('Zend_Translate', $translator);

        $received = Zend_Form::getDefaultTranslator();
        $this->assertSame($translator->getAdapter(), $received);

        $received = $this->form->getTranslator();
        $this->assertSame($translator->getAdapter(), $received);

        $form = new Zend_Form();
        $received = $form->getTranslator();
        $this->assertSame($translator->getAdapter(), $received);
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:16,代码来源:FormTest.php

示例3: addElementProjectStatus

 /**
  * Adds an element Status of Project as a Combobox.<br/>
  * Defaults:<br/>
  * name         = status<br/>
  * required     = true<br/>
  * label        = Status<br/>
  * dimension    = 6<br/>
  * modelfield   = status<br/>
  * class        = selectpicker<br/>
  * first-options= must be and array of array('value1', 'label'). Default is an empty array<br/>
  * sample of first-options: array(array('value'=>null, 'label'=>'Choose an option'))
  * 
  * @param Zend_Form $form The Zend_Form object where the element will be added
  * @param array $options The options to pass in the element
  * @return Zend_Form_Element Zend Form element just created
  */
 public function addElementProjectStatus($form, $options = array())
 {
     $elementName = isset($options['name']) ? $options['name'] : 'status';
     $modelField = isset($options['modelfield']) ? $options['modelfield'] : 'status';
     $form->addElement('select', $elementName, array('filters' => array('StringTrim'), 'label' => isset($options['label']) ? $options['label'] : 'Status', 'dimension' => isset($options['dimension']) ? $options['dimension'] : 6, 'required' => isset($options['required']) ? $options['required'] : true, 'value' => $this->_model ? $this->_model->{$modelField} : '', 'class' => isset($options['class']) ? $options['class'] : 'selectpicker'));
     $el = $form->getElement($elementName);
     if (isset($options['first-options'])) {
         foreach ($options['first-options'] as $op) {
             $el->addMultiOption($op['value'], $op['label']);
         }
     }
     $el->addMultiOption(Project_Model_Project::PROJECT_STATUS_DRAFT_ID, Project_Model_Project::PROJECT_STATUS_DRAFT_LABEL);
     $el->addMultiOption(Project_Model_Project::PROJECT_STATUS_ACTIVE_ID, Project_Model_Project::PROJECT_STATUS_ACTIVE_LABEL);
     $el->addMultiOption(Project_Model_Project::PROJECT_STATUS_FINISHED_ID, Project_Model_Project::PROJECT_STATUS_FINISHED_LABEL);
     $el->addMultiOption(Project_Model_Project::PROJECT_STATUS_CLOSED_ID, Project_Model_Project::PROJECT_STATUS_CLOSED_LABEL);
     $el->addMultiOption(Project_Model_Project::PROJECT_STATUS_PAUSED_ID, Project_Model_Project::PROJECT_STATUS_PAUSED_LABEL);
     $optionClasses[] = '" data-content="<span class=\'label\'>' . $form->getTranslator()->_(Project_Model_Project::PROJECT_STATUS_DRAFT_LABEL) . '</span>';
     $optionClasses[] = '" data-content="<span class=\'label label-success\'>' . $form->getTranslator()->_(Project_Model_Project::PROJECT_STATUS_ACTIVE_LABEL) . '</span>';
     $optionClasses[] = '" data-content="<span class=\'label label-info\'>' . $form->getTranslator()->_(Project_Model_Project::PROJECT_STATUS_FINISHED_LABEL) . '</span>';
     $optionClasses[] = '" data-content="<span class=\'label label-inverse\'>' . $form->getTranslator()->_(Project_Model_Project::PROJECT_STATUS_CLOSED_LABEL) . '</span>';
     $optionClasses[] = '" data-content="<span class=\'label label-warning\'>' . $form->getTranslator()->_(Project_Model_Project::PROJECT_STATUS_PAUSED_LABEL) . '</span>';
     $el->setAttrib('optionClasses', $optionClasses);
     if ($this->_model && $this->_model->{$modelField}) {
         $el->setValue($this->_model->{$modelField});
     } else {
         $el->setValue(null);
     }
     return $el;
 }
开发者ID:brunopbaffonso,项目名称:ongonline,代码行数:45,代码来源:Util.php

示例4: testCanDisableTranslation

 public function testCanDisableTranslation()
 {
     $this->testCanSetDefaultGlobalTranslator();
     $this->form->setDisableTranslator(true);
     $this->assertNull($this->form->getTranslator());
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:6,代码来源:FormTest.php

示例5: initTranslation

 protected function initTranslation(\Zend_Form $form, $id, $locale = null)
 {
     if ($locale === null) {
         $locale = \Zend_Locale::findLocale();
     }
     $trans = $this->translateForm($id, $locale);
     if ($locale != null && $locale != "") {
         if (null === $form->getTranslator()) {
             $form->setTranslator($trans);
         } else {
             $form->getTranslator()->addTranslation($trans);
         }
     }
 }
开发者ID:mkliche,项目名称:Zendformbuilder,代码行数:14,代码来源:Frontend.php


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