本文整理汇总了PHP中ZendX_JQuery::encodeJson方法的典型用法代码示例。如果您正苦于以下问题:PHP ZendX_JQuery::encodeJson方法的具体用法?PHP ZendX_JQuery::encodeJson怎么用?PHP ZendX_JQuery::encodeJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZendX_JQuery
的用法示例。
在下文中一共展示了ZendX_JQuery::encodeJson方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: accordionContainer
/**
* Render Accordion with the currently registered elements.
*
* If no arguments are given, the accordion object is returned so that
* chaining the {@link addPane()} function allows to register new elements
* for an accordion.
*
* @link http://docs.jquery.com/UI/Accordion
* @param string $id
* @param array $params
* @param array $attribs
* @return string|ZendX_JQuery_View_Helper_AccordionContainer
*/
public function accordionContainer($id = null, array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
if (!isset($attribs['id'])) {
$attribs['id'] = $id;
}
if (isset($this->_panes[$id])) {
$html = "";
foreach ($this->_panes[$id] as $element) {
$html .= sprintf($this->_elementHtmlTemplate, $element['name'], $element['content']) . PHP_EOL;
}
if (count($params) > 0) {
$params = ZendX_JQuery::encodeJson($params);
} else {
$params = "{}";
}
$js = sprintf('%s("#%s").accordion(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
$this->jquery->addOnLoad($js);
$html = '<div' . $this->_htmlAttribs($attribs) . '>' . PHP_EOL . $html . '</div>' . PHP_EOL;
return $html;
unset($this->_panes[$id]);
}
return '';
}
示例2: fileBrowser
/**
* Render a File browser
*
* @param string $id
* @param string $value
* @param array $params
* @param array $attribs
* @return string
*/
public function fileBrowser($id, $value = '', array $params = array(), array $attribs = array())
{
$attribs = $this->_prepareAttributes($id, $value, $attribs);
if (strlen($value) >= 6) {
$params['color'] = $value;
}
if (count($params) > 0) {
$params = ZendX_JQuery::encodeJson($params);
} else {
$params = "{}";
}
$js = sprintf('%s("#%s").click(function(){window.open("%s", "%s", "location=0,status=1,scrollbars=1,width=800,height=500");});', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'] . "_image", "/filemanager/file/browse?elementid=" . $attribs['id'], $attribs['id'] . "_window", $params);
$this->jquery->addOnLoad($js);
$js2 = sprintf("function callFunction(id, url, element_id) {\n \telement_id = '#' + element_id\n \tvar image_id = element_id + '_image';\n \t%s(image_id).attr('src', url);\n \t%s(element_id).attr('value', id);\n\t }", ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), ZendX_JQuery_View_Helper_JQuery::getJQueryHandler());
$this->view->headScript()->appendScript($js2);
// XHTML or HTML end tag?
$endTag = ' />';
if ($this->view instanceof Zend_View_Abstract && !$this->view->doctype()->isXhtml()) {
$endTag = '>';
}
if ($value && ($file = Zoo::getService('filemanager')->find($value)->current())) {
$xhtml = '<img id="' . $attribs['id'] . '_image" src="' . $file->getUrl(150, 150) . '" ' . $endTag;
} else {
$xhtml = '<img id="' . $attribs['id'] . '_image" src="/images/crystal_project/128x128/mimetypes/ascii.png" ' . $endTag;
}
$xhtml .= $this->view->formHidden($id, $value, $attribs);
return $xhtml;
}
示例3: dependentSelect
/**
* Builds an AutoComplete ready input field.
*
* This view helper builds an input field with the {@link Zend_View_Helper_FormText} FormText
* Helper and adds additional javascript to the jQuery stack to initialize an AutoComplete
* field. Make sure you have set one out of the two following options: $params['data'] or
* $params['url']. The first one accepts an array as data input to the autoComplete, the
* second accepts an url, where the autoComplete content is returned from. For the format
* see jQuery documentation.
*
* @link http://docs.jquery.com/UI/Autocomplete
* @throws ZendX_JQuery_Exception
* @param String $id
* @param String $value
* @param array $params
* @param array $attribs
* @return String
*/
public function dependentSelect($id, $value = null, array $params = array(), array $attribs = array())
{
if (is_array($value) && count($params) == 0 && count($attribs) == 0) {
$params = $value;
$value = null;
}
$attribs = $this->_prepareAttributes($id, $value, $attribs);
if (!isset($params['url']) || !isset($params['dependentElement'])) {
////require_once "ZendX/JQuery/Exception.php";
throw new ZendX_JQuery_Exception("Cannot construct DependentSelect field without specifying Parameters Url and DependentElement");
}
$params['dependentElement'] = '#' . $params['dependentElement'];
if ((!isset($attribs['translate']) || $attribs['translate']) && isset($params['defaultOption'])) {
$params['defaultOption'] = $this->view->translate($params['defaultOption']);
}
$params = ZendX_JQuery::encodeJson($params);
if (isset($attribs['translate'])) {
unset($attribs['translate']);
}
$js = sprintf('%s("#%s").dependentSelect(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
$this->jquery->addOnLoad($js);
if (isset($attribs['justDecorate']) && $attribs['justDecorate']) {
return '';
}
if (isset($attribs['justDecorate'])) {
unset($attribs['justDecorate']);
}
return $this->view->formText($id, $value, $attribs);
}
示例4: tooltip
/**
* Builds an AutoComplete ready input field.
*
* This view helper builds an input field with the {@link Zend_View_Helper_FormText} FormText
* Helper and adds additional javascript to the jQuery stack to initialize an AutoComplete
* field. Make sure you have set one out of the two following options: $params['data'] or
* $params['url']. The first one accepts an array as data input to the autoComplete, the
* second accepts an url, where the autoComplete content is returned from. For the format
* see jQuery documentation.
*
* @link http://docs.jquery.com/UI/Autocomplete
* @throws ZendX_JQuery_Exception
* @param String $id
* @param String $value
* @param array $params
* @param array $attribs
* @return String
*/
public function tooltip($id, $value = null, array $params = array(), array $attribs = array())
{
if (is_array($value) && count($params) == 0 && count($attribs) == 0) {
$params = $value;
$value = null;
} elseif (is_string($value) and !isset($params['content'])) {
$params['content'] = $value;
}
$params = array_merge(self::$_defaults, $params);
$attribs = $this->_prepareAttributes($id, $value, $attribs);
if ((!isset($attribs['translate']) || $attribs['translate']) && isset($params['content'])) {
$params['content'] = $this->view->translate($params['content']);
}
$params = ZendX_JQuery::encodeJson($params);
if (isset($attribs['translate'])) {
unset($attribs['translate']);
}
$js = sprintf('%s("#%s").wTooltip(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
$this->jquery->addOnLoad($js);
if (isset($attribs['justDecorate']) && $attribs['justDecorate']) {
return '';
}
if (isset($attribs['justDecorate'])) {
unset($attribs['justDecorate']);
}
return $this->view->formText($id, $value, $attribs);
}
示例5: datePicker
/**
* Create a jQuery UI Widget Date Picker
*
* @link http://docs.jquery.com/UI/Datepicker
* @param string $id
* @param string $value
* @param array $params jQuery Widget Parameters
* @param array $attribs HTML Element Attributes
* @return string
*/
public function datePicker($id, $value = null, array $params = array(), array $attribs = array())
{
$attribs = $this->_prepareAttributes($id, $value, $attribs);
if (Zend_Registry::isRegistered('Zend_Locale')) {
if (!isset($params['dateFormat'])) {
$params['dateFormat'] = self::resolveZendLocaleToDatePickerFormat();
}
$days = Zend_Locale::getTranslationList('Days');
if (!isset($params['dayNames'])) {
$params['dayNames'] = array_values($days['format']['wide']);
}
if (!isset($params['dayNamesShort'])) {
$params['dayNamesShort'] = array_values($days['format']['abbreviated']);
}
if (!isset($params['dayNamesMin'])) {
$params['dayNamesMin'] = array_values($days['stand-alone']['narrow']);
}
$months = Zend_Locale::getTranslationList('Months');
if (!isset($params['monthNames'])) {
$params['monthNames'] = array_values($months['stand-alone']['wide']);
}
if (!isset($params['monthNamesShort'])) {
$params['monthNamesShort'] = array_values($months['stand-alone']['narrow']);
}
}
// TODO: Allow translation of DatePicker Text Values to get this action from client to server
$params = ZendX_JQuery::encodeJson($params);
$js = sprintf('%s("#%s").datepicker(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
$this->jquery->addOnLoad($js);
return $this->view->formText($id, $value, $attribs);
}
示例6: submitAjax
/**
* Cria um campo texto com validador de email
*
* @param string $id
* @param string $value
* @param array $params jQuery Widget Parameters
* @param array $attribs HTML Element Attributes
* @return string
*/
public function submitAjax($id, $value = null, array $params = array(), array $attribs = array())
{
$attribs = $this->_prepareAttributes($id, $value, $attribs);
$params = ZendX_JQuery::encodeJson($params);
$js = sprintf('%s("#%s").click(function(){
var formFields = $(".required");
var requiredNull = "";
if(formFields.length > 1){
for(i=0;i<formFields.length;i++){
if(formFields[i].value == ""){
requiredNull = $("label[for=\'"+formFields[i].id+"\']").text();
}
}
}else{
if(formFields.val() == ""){
requiredNull = $("label[for=\'"+formFields.attr(\'id\')+"\']").text();
}
}
if(requiredNull != ""){
alert("O campo "+requiredNull+" é obrigatório");
}
//$("form").submit();
});', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
#$js = sprintf('%s("#%s").TEmail(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
$this->jquery->addOnLoad($js);
return $this->view->formText($id, $value, $attribs);
}
示例7: numeric
/**
* Cria um campo texto para numeros, com incremento, verificação, valor maximo e outro (ler arquivo TNumeric.js)
*
* @param string $id
* @param string $value
* @param array $params jQuery Widget Parameters
* @param array $attribs HTML Element Attributes
* @return string
*/
public function numeric($id, $value = null, array $attribs = array())
{
$this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TNumeric.js');
$this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/extra/autoNumeric.js');
$params = ZendX_JQuery::encodeJson($attribs['jQueryParams']);
unset($attribs['jQueryParams']);
$this->jquery->addOnLoad('jQuery("#' . $id . '").TNumeric(' . $params . ');');
/*$styles = explode(';', $attribs['style']);
if ($styles) {
foreach ($styles as $style) {
list($styleName,$styleValue) = explode(':',$style);
if ($styleName == 'width'){
$old = $style;
$width = (str_replace('px', '', trim($styleValue)) * 1);
$styleValue = $width - 25;
$new = 'width:'.$styleValue.'px';
}
}
$attribs['style'] = str_replace($old,$new,$attribs['style']);
}
if (!$width){
$width = 100;
$attribs['style'].= 'width:75px;';
}*/
$attribs['class'] .= ' item ui-input-num icon';
$btns = ' <span class="item numeric"> ' . ' <div class="ui-button ui-state-default up" nofocus="1" parent="' . $id . '" onClick="if(!$(this).attr(\'disabled\')){jQuery(\'#\' + $(this).attr(\'parent\')).Tdata(\'TNumeric\').incNumber();}" type="button"> ' . ' <span class="ui-icon ui-icon-triangle-1-n"/> ' . ' </div> ' . ' <div class="ui-button ui-state-default down" nofocus="1" parent="' . $id . '" onClick="if(!$(this).attr(\'disabled\')){jQuery(\'#\' + $(this).attr(\'parent\')).Tdata(\'TNumeric\').decNumber();}" type="button"> ' . ' <span class="ui-icon ui-icon-spinner-down"/> ' . ' </div> ' . ' </span> ';
$xhtml = '<div class="ui-form-group"> ' . ' ' . $this->view->formText($id, $value, $attribs) . $btns . '</div>';
return $xhtml;
}
示例8: LatLong
/**
* Рисуем элемент
*
* @param string $id Id HTML-элемента
* @param string $value Значение элемента
* @param array $params Массив опций из секции JQueryParams
* @param array $attribs Массив аттрибутов из секции options
* @return string
*/
public function LatLong($id, $value = null, array $params = array(), array $attribs = array())
{
$attribs = $this->_prepareAttributes($id, $value, $attribs);
$js = sprintf('%s("#%s").phormLatLong(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], ZendX_JQuery::encodeJson($params));
$this->jquery->addOnLoad($js);
return $this->view->formText($id, $value, $attribs);
}
示例9: zooColorPicker
/**
* Render a Color Picker in an FormText field.
*
* @link http://docs.jquery.com/UI/ColorPicker
* @param string $id
* @param string $value
* @param array $params
* @param array $attribs
* @return string
*/
public function zooColorPicker($id, $value = '', array $params = array(), array $attribs = array())
{
$this->jquery->addJavascriptFile(Zend_Controller_Front::getInstance()->getBaseUrl() . '/js/jquery/colorpicker/js/colorpicker.js', 'text/javascript');
$this->jquery->addStylesheet(Zend_Controller_Front::getInstance()->getBaseUrl() . "/js/jquery/colorpicker/css/colorpicker.css");
$attribs = $this->_prepareAttributes($id, $value, $attribs);
if (strlen($value) >= 6) {
$params['color'] = $value;
}
if (count($params) > 0) {
$params = ZendX_JQuery::encodeJson($params);
} else {
$params = "{}";
}
$js = sprintf('%s("#%s").ColorPicker({onSubmit: function(hsb, hex, rgb, el) {
%s(el).val(hex);
%s(el).ColorPickerHide();
},
onBeforeShow: function () {
%s(this).ColorPickerSetColor(this.value);
}
})
.bind("keyup", function(){
%s(this).ColorPickerSetColor(this.value);
});', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $params);
$this->jquery->addOnLoad($js);
return $this->view->formText($id, $value, $attribs);
}
示例10: comboCustom
/**
* Cria um campo de ComboCustom
*
* @param string $id
* @param string $value
* @param array $params jQuery Widget Parameters
* @param array $attribs HTML Element Attributes
* @return string
*/
public function comboCustom($id, $value = null, array $params = array(), array $attribs = array())
{
$this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TComboCustom.js')->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TOpenDownBox.js');
$params = ZendX_JQuery::encodeJson($params);
$js = sprintf('%s("#%s").TComboCustom(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
$this->jquery->addOnLoad($js);
return $this->view->formText($id, $value, $attribs);
}
示例11: dateMonthYear
/**
* Cria um campo texto com validador de data e datepicker
*
* @param string $id
* @param string $value
* @param array $params jQuery Widget Parameters
* @param array $attribs HTML Element Attributes
* @return string
*/
public function dateMonthYear($id, $value = null, array $attribs = array())
{
$this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/extra/jquery.maskedinput-1.4.1.min.js');
$this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TDateMonthYear.js');
$params = ZendX_JQuery::encodeJson($attribs['jQueryParams']);
unset($attribs['jQueryParams']);
$this->jquery->addOnLoad('jQuery("#' . $id . '").TDateMonthYear(' . $params . ');');
return $this->view->formText($id, $value, $attribs);
}
示例12: structuresResource
/**
* Рисуем элемент
*
* @param string $id Id HTML-элемента
* @param string $value Значение элемента
* @param array $params Массив конфигурации из секции options
* @return string
*/
public function structuresResource($id, $value = null, array $params = array(), array $options = array())
{
$translate = $params['translate'];
/**
* Определяем id выбранной структуры на основе текущего значения
*/
$structureid = null;
if (is_array($value)) {
foreach ($value as $structureid => $group) {
break;
}
}
/**
* Определяем массив опций для селекта структур и формируем сам селект
* @todo Добавить свой отдельный prepareAttribs
*/
if (count($params['forms']) > 1) {
$attribs = array();
foreach ($params as $k => $v) {
if (is_string($v) && $k != 'isexcluded') {
$attribs[$k] = $v;
}
}
$select = $this->view->formSelect(null, $structureid, $attribs, $options);
}
/**
* Определяем форму с элементами каждой из структур
* Добавляем форму в JS
*/
$js_var = $id . '_subforms';
if (isset($params['renderforms'])) {
$this->jquery->addJavascript('var ' . $js_var . ' = ' . ZendX_JQuery::encodeJson($params['renderforms']) . ';');
}
/**
* Вешаем JS-обработку на смену структуры в селекте
*/
$jquery_handler = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
$js = sprintf('%s(document).on("change","#%s",function(){
%s("#%s .zend_form").remove();
%s(this).after(%s[%s(this).val()]);
return false;
})', $jquery_handler, $id, $jquery_handler, $id . '-element', $jquery_handler, $js_var, $jquery_handler);
$this->jquery->addOnLoad($js);
/**
* Устанавливаем пришедшие значения
* Либо форму из первой структуры
*/
if (isset($params['forms'][$structureid])) {
$xhtml = $params['forms'][$structureid]->render();
} else {
foreach ($params['forms'] as $form) {
$xhtml = $form->render();
break;
}
}
return $select . $xhtml;
}
示例13: numericMulti
/**
* Cria um campo texto para numeros, com incremento, verificação, valor maximo e outro (ler arquivo TNumericMulti.js)
*
* @param string $id
* @param string $value
* @param array $params jQuery Widget Parameters
* @param array $attribs HTML Element Attributes
* @return string
*/
public function numericMulti($id, $value = null, array $attribs = array())
{
$this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TNumericMulti.js');
$this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/extra/autoNumeric.js');
$params = ZendX_JQuery::encodeJson($attribs['jQueryParams']);
unset($attribs['jQueryParams']);
$this->jquery->addOnLoad('jQuery("#' . $id . '").TNumericMulti(' . $params . ');');
return $this->view->formText($id, $value, $attribs);
}
示例14: tagIt
public function tagIt($id, $value = null, array $params = array(), array $attribs = array())
{
$attribs = $this->_prepareAttributes($id, $value, $attribs);
$this->jquery->addJavascriptFile($this->view->BaseUrl() . '/ui/tag-it/js/tag-it.min.js');
$this->jquery->addStyleSheet($this->view->BaseUrl() . '/ui/tag-it/css/jquery.tagit.css');
$params = ZendX_JQuery::encodeJson($params);
$js = sprintf('%s("#%s").tagit(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
$this->jquery->addOnLoad($js);
return $this->view->formText($id, $value, $attribs);
}
示例15: date
/**
* Cria um campo texto com validador de data e datepicker
*
* @param string $id
* @param string $value
* @param array $params jQuery Widget Parameters
* @param array $attribs HTML Element Attributes
* @return string
*/
public function date($id, $value = null, array $attribs = array())
{
$data = date('dmy');
$this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/layout/jquery/widget/TDate.js?' . $data);
$params = ZendX_JQuery::encodeJson($attribs['jQueryParams']);
unset($attribs['jQueryParams']);
$attribs['class'] .= ' ui-input-date';
$xhtml .= '<div class="ui-form-group">' . $this->view->formText($id, $value, $attribs) . '</div>';
$this->jquery->addOnLoad('jQuery("#' . $id . '").TDate(' . $params . ');');
return $xhtml;
}