當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。