public function phoneElement($name, $value = null, $attribs = null) { $a = $b = $c = ''; $helper = new Zend_View_Helper_FormText(); $helper->setView($this->view); if ($value) { list($a, $b, $c) = split('-', $value); } $this->html .= $helper->formText($name . '[a]', $a, array('size' => 3, 'maxlenght' => 3)); $this->html .= $helper->formText($name . '[b]', $b, array('size' => 3, 'maxlenght' => 3)); $this->html .= $helper->formText($name . '[c]', $c, array('size' => 3, 'maxlenght' => 3)); return $this->html; }
public function phoneElement($name, $value = null, $attribs = null) { $areanum = $geonum = $localnum = ''; if ($value) { list($areanum, $geonum, $localnum) = split('-', $value); } $helper = new Zend_View_Helper_FormText(); $helper->setView($this->view); $this->html .= $helper->formText($name . '[areanum]', $areanum, array('size' => 3, 'maxlength' => 3)); $this->html .= $helper->formText($name . '[geonum]', $geonum, array('size' => 3, 'maxlength' => 3)); $this->html .= $helper->formText($name . '[localnum]', $localnum, array('size' => 4, 'maxlength' => 4)); return $this->html; }
public function phoneElement($name, $value = null, $attribs = null) { $areanum = $geonum = $localnum = ''; $helper = new Zend_View_Helper_FormText(); $helper->setView($this->view); if (is_array($value)) { $areanum = isset($value['areanum']) ? $value['areanum'] : ''; $geonum = isset($value['geonum']) ? $value['geonum'] : ''; $localnum = isset($value['localnum']) ? $value['localnum'] : ''; } $this->html .= $helper->formText($name . '[areanum]', $areanum, array()); $this->html .= $helper->formText($name . '[geonum]', $geonum, array()); $this->html .= $helper->formText($name . '[localnum]', $localnum, array()); return $this->html; }
public function FormAutocompleteId($name, $value = null, $attribs = null) { $info = $this->_getInfo($name, $value, $attribs); extract($info); // name, value, attribs, options, listsep, disable if (!isset($attribs['source'])) { throw new Exception('Не задан источник для элемента формы "autocomplete" ' . $name); } $source = $attribs['source']; $minLength = isset($attribs['minLength']) ? $attribs['minLength'] : 1; unset($attribs['source']); unset($attribs['minLength']); $script = ' $("#' . $id . '_acString").autocomplete({ source: "' . $source . '", minLength: ' . $minLength . ', select: function(event, ui) { $("#' . $id . '").attr("value",ui.item.id); } }); '; jQuery::evalScript($script); $realvalue = ''; if ($value) { jQuery::evalScript(' $.ajax({ url: "' . $source . '?id=' . $value . '", success: function(data, textStatus, XMLHttpRequest){ $("#' . $id . '_acString").attr("value",data); }}); '); } return parent::formText($name . '_acString', $realvalue, $attribs) . parent::formText($name, $value, array('style' => 'display: none;')); }
public function formDatetime($name, $value = null, $attribs = null) { if ($value) { $value = strtotime($value); $value = date(@$attribs['showSecond'] ? 'd.m.Y H:i:s' : 'd.m.Y H:i', $value); } return parent::formText($name, $value, $attribs); }
public function formDate($name, $value = null, $attribs = null) { if ($value) { $value = strtotime($value); $value = date('d.m.Y', $value); } return parent::formText($name, $value, $attribs); }
public function formSpinner($name, $value = null, $attribs = null) { $options = $this->getOptions($attribs); $inlineScript = 'jQuery().ready(function($) { $(\'#' . $name . '\').spinner(' . $this->parseOptions($options) . '); });'; $xhtml = parent::formText($name, $value, $attribs); $res = $this->view->inlineScript()->setScript($inlineScript, $type = 'text/javascript', $attrs = array()); return $xhtml . $res; }
public function formDatepicker($name, $value = null, $attribs = null) { if (isset($attribs['class'])) { $attribs['class'] .= ' date hasDatepicker'; } else { $attribs['class'] = 'date hasDatepicker'; } $element = parent::formText($name, $value, $attribs); return $element . '<img class="ui-datepicker-trigger" src="/images/ui/calendar.png" alt="" />'; }
/** * @param string $name the name of the form element. * @param string $value the value of the form element. * @param array $arrtibs the attribs for the form element. * @return string $_xhtml the rendered xhtml for this form element. */ public function ssnElement($name, $value = null, $attribs = null) { // take the incoming SSN string break it up into three pieces for the // three elements that will make the composite element. $areanum = $groupnum = $serialnum = ''; if ($value) { $areanum = substr($value, 0, 3); $groupnum = substr($value, 3, 2); $serialnum = substr($value, 5, 4); } // Use Zend_View_Helper_FormText to build the elements that will form // the composite element. $helper = new Zend_View_Helper_FormText(); // Must assign a view since we are outside zend's normal MVC structure. $helper->setView($this->view); // Create the xhtml $this->_xhtml .= $helper->formText($name . '[areanum]', $areanum, array('size' => 3, 'maxlength' => 3)); $this->_xhtml .= $helper->formText($name . '[groupnum]', $groupnum, array('size' => 2, 'maxlength' => 2)); $this->_xhtml .= $helper->formText($name . '[serialnum]', $serialnum, array('size' => 4, 'maxlength' => 4)); return $this->_xhtml; }
/** * Generates a 'text' element. * * @access public * * @param string|array $name If a string, the element name. If an * array, all other parameters are ignored, and the array elements * are used in place of added parameters. * * @param mixed $value The element value. * * @param array $attribs Attributes for the element tag. * * @return string The element XHTML. */ public function formTextOverwrite($name, $value = null, $attribs = null) { $info = $this->_getInfo($name, $value, $attribs); extract($info); // name, value, attribs, options, listsep, disabled $viewHelperFormCheckbox = new Zend_View_Helper_FormCheckbox(); $viewHelperFormCheckbox->setView($this->view); $viewHelperFormElement = new Zend_View_Helper_FormText(); $viewHelperFormElement->setView($this->view); $checked = ''; if ($attribs['overwrite']) { $checked = 'checked'; $disabled = true; unset($attribs['overwrite']); } else { $disabled = false; if (isset($attribs['class']) && $attribs['class'] != '') { $attribs['class'] = $attribs['class'] . ' disabled'; } else { $attribs['class'] = 'disabled'; } } $separator = ''; if (isset($attribs['separator'])) { $separator = $attribs['separator']; unset($attribs['separator']); } $xhtml = '<div class="input-prepend">'; $xhtml .= '<label class="add-on">'; $xhtml .= $viewHelperFormCheckbox->formCheckbox($name . '[overwrite]', null, array_merge($attribs, array('checked' => $checked, 'class' => 'checkbox text-overwrite-checkbox'))); $xhtml .= '</label>'; $xhtml .= ' ' . $separator; if (!$disabled) { $xhtml .= $viewHelperFormElement->formText($name . '[value]', $value, array_merge($attribs, array('disabled' => 'disabled'))); } else { $xhtml .= $viewHelperFormElement->formText($name . '[value]', $value, $attribs); } $xhtml .= '</div>'; return $xhtml; }
public function FormAutocomplete($name, $value = null, $attribs = null) { $info = $this->_getInfo($name, $value, $attribs); extract($info); // name, value, attribs, options, listsep, disable if (!isset($attribs['source'])) { throw new Exception('Не задан источник для элемента формы "autocomplete" ' . $name); } $source = $attribs['source']; $minLength = isset($attribs['minLength']) ? $attribs['minLength'] : 1; unset($attribs['source']); unset($attribs['minLength']); $script = ' $("#' . $id . '").autocomplete({ source: "' . $source . '", minLength: ' . $minLength . ' }); '; jQuery::evalScript($script); return parent::formText($name, $value, $attribs); }
/** * Generates a 'text' element. * * @access public * * @param string|array $name If a string, the element name. If an * array, all other parameters are ignored, and the array elements * are used in place of added parameters. * * @param mixed $value The element value. * * @param array $attribs Attributes for the element tag. * * @return string The element XHTML. */ public function formText($name, $value = null, $attribs = null) { // $value = htmlspecialchars_decode($value, ENT_QUOTES); return parent::formText($name, $value, $attribs); }
public function formFileSelector($name, $value = null, $attribs = null) { $info = $this->_getInfo($name, $value, $attribs); extract($info); // name, value, attribs, options, listsep, disable if (isset($attribs['baseUrl'])) { $_SESSION['CKFINDER_BASEURL'] = $attribs['baseUrl']; unset($attribs['baseUrl']); } else { unset($_SESSION['CKFINDER_BASEURL']); } if (isset($attribs['baseDir'])) { $_SESSION['CKFINDER_BASEDIR'] = $attribs['baseDir']; unset($attribs['baseDir']); } else { unset($_SESSION['CKFINDER_BASEDIR']); } $this->view->headLink()->prependStylesheet($this->view->baseUrl('/scripts/jquery-plugins/fancybox/jquery.fancybox.css', false), 'screen'); $this->view->headScript()->prependFile($this->view->baseUrl('/scripts/jquery-plugins/mousewheel/jquery.mousewheel.js', false)); $this->view->headScript()->prependFile($this->view->baseUrl('/scripts/jquery-plugins/fancybox/jquery.fancybox.pack.js', false)); //$this->view->headScript()->appendFile($this->view->baseUrl('/scripts/ckfinder/ckfinder.js', false)); $jquery = $this->view->jQuery(); $jquery->enable()->uiEnable(); $elementId = $this->view->escape(str_replace('-', '_', $id)); $callBackFunction = 'setFieldValue' . md5($elementId); $idEscaped = $this->view->escape($id); $url = $this->view->baseUrl('/scripts/ckfinder/ckfinder.html?action=js&func=' . $callBackFunction . '', false); $js = <<<TOKEN var finder_{$elementId}_dialog; function {$callBackFunction}(value) { value = decodeURIComponent((value + '').replace(/\\+/g, '%20')); value = value.replace('system\\/file\\/download\\/\\?file=', ''); \$('#{$idEscaped}').val(value); \$.fancybox.close(); } TOKEN; $jsOnload = <<<TOKEN \$('#finder_{$id}_button').button().click(function() { finder_{$elementId}_dialog = \$.fancybox({ 'width' : '75%', 'height' : '75%', 'title' : '', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'centerOnScroll' : true, 'type' : 'iframe', 'href' : '{$url}' }); return false; }); TOKEN; $jquery->addJavascript($js); $jquery->addOnLoad($jsOnload); $xhtml = ''; if (array_key_exists('class', $attribs)) { if ($attribs['class'] != '') { $attribs['class'] .= ' '; } } else { $attribs['class'] = ''; } $attribs['class'] .= 'file-selector'; $xhtml .= parent::formText($name, $value, $attribs) . ' '; $xhtml .= '<a id="finder_' . $this->view->escape($id) . '_button" href="#">...</a>'; return $xhtml; }
public function testReadOnlyAttribute() { $helper = new Zend_View_Helper_FormText(); $element = $helper->formText('foo', null, array('readonly' => 'readonly')); $this->assertContains('readonly="readonly"', $element); }
/** * Generates a 'datepicker' element. * * @param string|array $name If a string, the element name. If an * array, all other parameters are ignored, and the array elements * are used in place of added parameters. * @param mixed $value The element value. * @param array $attribs Attributes for the element tag * @param array $options Options for this instance of the datePicker * * @return string The element XHTML. */ public function formDatePicker($name, $value = null, $attribs = null, $options = array()) { // load jquery environment $this->loadJQuery(); // add instance option to element if (!empty($options)) { $js = sprintf("\$('#%s').datepicker('option', %s);", $attribs['id'], Zend_Json::encode($options)); $this->view->jQuery()->addOnLoad($js); } // class handling if (isset($attribs['class'])) { if (is_string($attribs['class'])) { $attribs['class'] = array($attribs['class']); } $attribs['class'][] = self::DATE_PICKER_CLASS; } else { $attribs['class'] = self::DATE_PICKER_CLASS; } // return a text element return parent::formText($name, $value, $attribs); }