Esempio n. 1
0
 public function renderLabel(Zend_Form_Element $element, Zend_View_Interface $view)
 {
     $label = $element->getLabel();
     if (empty($label)) {
         $label = $element->getName();
     }
     return '<div class="pointer" onClick = goToErrorLabel(\'' . $element->getId() . '\')>' . $this->getMarkupElementLabelStart() . $view->escape($label) . $this->getMarkupElementLabelEnd() . '</div>';
 }
 /**
  * Get value
  *
  * If element type is one of the button types, returns the label.
  *
  * @param \Zend_Form_Element $element
  *
  * @return string|null
  */
 public function getValue($element)
 {
     if (!$element instanceof \Zend_Form_Element) {
         return null;
     }
     foreach ($this->_buttonTypes as $type) {
         if ($element instanceof $type) {
             if (stristr($type, 'submit')) {
                 $element->content = $element->getLabel();
                 return $element->getValue();
             }
             if (stristr($type, 'button')) {
                 $element->content = $element->getLabel();
                 return $element->getValue();
             }
             return $element->getLabel();
         }
     }
     return $element->getValue();
 }
 /**
  * Enter description here ...
  * @param Zend_Form_Element $element
  * @author Tung Ly
  */
 public function renderFormElement($element, $vertical = 0)
 {
     if ($element->getType() != "Zend_Form_Element_Checkbox") {
         $element->setAttrib('class', $element->getAttrib('class') . ' form-control');
     }
     if ($element->isRequired()) {
         $element->setLabel($element->getLabel() . ' *');
         $element->setAttrib('class', $element->getAttrib('class') . ' required');
     }
     switch ($element->getType()) {
         case 'Zend_Form_Element_Textarea':
             $element->setAttrib('rows', 5);
             $element->setAttrib('cols', 80);
             break;
         case 'Zend_Form_Element_Hidden':
             return $element;
         default:
             break;
     }
     $error = '';
     if ($element->hasErrors()) {
         $error = 'has-error';
     }
     if ($element->getType() == 'Zend_Form_Element_Textarea') {
     }
     $btn = array('Zend_Form_Element_Submit', 'Zend_Form_Element_Reset');
     if (in_array($element->getType(), $btn)) {
         //$t ='<button type="reset" class="btn"><i class="icon-refresh"></i> '.$element->getLabel().'</button>';
         $t = '<div class="span2">' . $element . '</div>';
     } else {
         $label = trim(preg_replace("/([A-Z])/", " \$1", "{$element->getLabel()}"), ' ');
         $variables = array('%%ERROR_CLASS%%' => $error, '%%ELEMENT_NAME%%' => $element->getName(), '%%ELEMENT_LABEL%%' => $label, '%%ELEMENT%%' => $element, '%%HELP_MESSAGE%%' => current($element->getMessages()));
         $t = str_replace(array_keys($variables), $variables, $this->_getTemplate($vertical));
     }
     return $t;
 }
Esempio n. 4
0
 /**
  * Render element label
  *
  * @param  Zend_Form_Element $element
  * @param  Zend_View_Interface $view
  * @return string
  */
 public function renderLabel(Zend_Form_Element $element, Zend_View_Interface $view)
 {
     $label = $element->getLabel();
     if (empty($label)) {
         $label = $element->getName();
     }
     return $this->getMarkupElementLabelStart() . $view->escape($label) . $this->getMarkupElementLabelEnd();
 }
Esempio n. 5
0
 public function testPassingConfigObjectToConstructorSetsObjectState()
 {
     $config = new Zend_Config($this->getOptions());
     $element = new Zend_Form_Element($config);
     $this->assertEquals('changed', $element->getName());
     $this->assertEquals('foo', $element->getValue());
     $this->assertEquals('bar', $element->getLabel());
     $this->assertEquals(50, $element->getOrder());
     $this->assertFalse($element->isRequired());
     $this->assertEquals('bar', $element->foo);
     $this->assertEquals('bat', $element->baz);
 }
Esempio n. 6
0
 /**
  * Render element label
  *
  * @param  Zend_Form_Element $element
  * @param  Zend_View_Interface $view
  * @return string
  */
 public function renderLabel(Zend_Form_Element $element, Zend_View_Interface $view)
 {
     $label = $element->getLabel();
     if (empty($label)) {
         $label = $element->getName();
         // Translate element name
         if (null !== ($translator = $element->getTranslator())) {
             $label = $translator->translate($label);
         }
     }
     if ($this->getEscape()) {
         $label = $view->escape($label);
     }
     return $this->getMarkupElementLabelStart() . $label . $this->getMarkupElementLabelEnd();
 }
Esempio n. 7
0
 /**
  * Remove cookie.jar if configs change and convert form password to password element
  * @param string $section
  * @param string $namespace
  * @param unknown_type $key
  * @param Zend_Form_Element $element
  * @param Zend_Form $form
  * @param Zend_Controller_Action $controller
  */
 public function prepareConfigElement($section, $namespace, $key, Zend_Form_Element $element, Zend_Form $form, Zend_Controller_Action $controller)
 {
     // nothing to do if this isn't the right section
     if ($namespace != $this->getId()) {
         return;
     }
     switch ($key) {
         // i have to convert it to a password element
         case 'plugins_weebtv_auth_password':
             $password = $form->createElement('password', 'plugins_weebtv_auth_password', array('label' => $element->getLabel(), 'description' => $element->getDescription(), 'renderPassword' => true));
             $form->plugins_weebtv_auth_password = $password;
             break;
     }
 }
 /**
  * Returns the label of the compared element.
  *
  * @return string
  */
 protected function getCompareLabel()
 {
     return $this->element->getLabel();
 }
Esempio n. 9
0
 /**
  * Get value
  *
  * If element type is one of the button types, returns the label.
  * 
  * @param  Zend_Form_Element $element 
  * @return string|null
  */
 public function getValue($element)
 {
     if (!$element instanceof Zend_Form_Element) {
         return null;
     }
     $type = $element->getType();
     if (in_array($type, $this->_buttonTypes)) {
         return $element->getLabel();
     }
     return $element->getValue();
 }
Esempio n. 10
0
 /**
  * Remove cookie.jar if configs change and convert form password to password element
  * @param string $section
  * @param string $namespace
  * @param unknown_type $key
  * @param Zend_Form_Element $element
  * @param Zend_Form $form
  * @param Zend_Controller_Action $controller
  */
 public function prepareConfigElement($section, $namespace, $key, Zend_Form_Element $element, Zend_Form $form, Zend_Controller_Action $controller)
 {
     // nothing to do if this isn't the right section
     if ($namespace != $this->getId()) {
         return;
     }
     switch ($key) {
         // i have to convert it to a password element
         case 'plugins_megavideo_premium_password':
             $password = $form->createElement('password', 'plugins_megavideo_premium_password', array('label' => $element->getLabel(), 'description' => $element->getDescription(), 'renderPassword' => true));
             $form->plugins_megavideo_premium_password = $password;
             break;
     }
     // remove cookie.jar if somethings has value
     if (!$form->isErrors() && !is_null($element->getValue()) && file_exists(APPLICATION_PATH . '/../data/megavideo/cookie.jar')) {
         if (@(!unlink(APPLICATION_PATH . '/../data/megavideo/cookie.jar'))) {
             X_Debug::e("Error removing cookie.jar");
         }
     }
 }
 /**
  * Enter description here ...
  * 
  * @param Zend_Form_Element $field
  * @param unknown_type $label
  */
 public function setSelectDefaultOption(Zend_Form_Element $field, $label = null)
 {
     return $field->addMultiOption(self::SELECT_DEFAULT_VALUE, sprintf(self::SELECT_DEFAULT_LABEL, $label ? $label : $field->getLabel()));
 }
Esempio n. 12
0
 /**
  * Get value
  *
  * If element type is one of the button types, returns the label.
  * 
  * @param  Zend_Form_Element $element 
  * @return string|null
  */
 public function getValue($element)
 {
     if (!$element instanceof Zend_Form_Element) {
         return null;
     }
     foreach ($this->_buttonTypes as $type) {
         if ($element instanceof $type) {
             return $element->getLabel();
         }
     }
     return $element->getValue();
 }
 /**
  * Gets html content fot label
  *
  * @param Zend_Form_Element $element
  * @return string 
  */
 protected function getLabelHTML($element)
 {
     $label = $element->getLabel();
     if ($translator = $element->getTranslator()) {
         $label = $translator->translate($label);
     }
     $label = $element->getView()->formLabel($element->getName(), $label);
     if ($element->isRequired()) {
         $label .= '<span class="asterisk">*</span>';
     }
     return $label;
 }
 /**
  * Convert form password to password element
  * @param string $section
  * @param string $namespace
  * @param unknown_type $key
  * @param Zend_Form_Element $element
  * @param Zend_Form $form
  * @param Zend_Controller_Action $controller
  */
 public function prepareConfigElement($section, $namespace, $key, Zend_Form_Element $element, Zend_Form $form, Zend_Controller_Action $controller)
 {
     // nothing to do if this isn't the right section
     if ($namespace != $this->getId()) {
         return;
     }
     switch ($key) {
         // i have to convert it to a password element
         case 'plugins_rapidshare_premium_password':
             $password = $form->createElement('password', 'plugins_rapidshare_premium_password', array('label' => $element->getLabel(), 'description' => $element->getDescription(), 'renderPassword' => true));
             $form->plugins_rapidshare_premium_password = $password;
             break;
     }
     // remove cookie if somethings has value
     if (!$form->isErrors() && !is_null($element->getValue()) && ($key = 'plugins_rapidshare_premium_password')) {
         // clean cookies
         try {
             X_Debug::i("Cleaning up cookies in cache");
             /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
             $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
             try {
                 $cacheHelper->retrieveItem("rapidshare::cookie");
                 // set expire date to now!
                 $cacheHelper->storeItem("rapidshare::cookie", '', 0);
             } catch (Exception $e) {
                 // nothing to do
             }
             try {
                 $cacheHelper->retrieveItem("rapidshare::lastreloginflag");
                 // set expire date to now!
                 $cacheHelper->storeItem("realdebrid::lastreloginflag", '', 0);
             } catch (Exception $e) {
                 // nothing to do
             }
         } catch (Exception $e) {
             X_Debug::w("Cache plugin disabled? O_o");
         }
     }
 }