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


PHP CMbArray::makeXmlAttributes方法代码示例

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


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

示例1: getFormHtmlElement

 /**
  * @see parent::getFormHtmlElement()
  */
 function getFormHtmlElement($object, $params, $value, $className)
 {
     $field = CMbString::htmlSpecialChars($this->fieldName);
     $value = CMbString::htmlSpecialChars($value);
     $class = CMbString::htmlSpecialChars("{$className} {$this->prop}");
     $form = CMbArray::extract($params, "form");
     $extra = CMbArray::makeXmlAttributes($params);
     return "<input type=\"tel\" name=\"{$field}\" value=\"{$value}\" class=\"{$class} styled-element\" {$extra} />";
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:12,代码来源:CPhoneSpec.class.php

示例2: getFormHtmlElement

 /**
  * @see parent::getFormHtmlElement()
  */
 function getFormHtmlElement($object, $params, $value, $className)
 {
     $field = CMbString::htmlSpecialChars($this->fieldName);
     $form = CMbArray::extract($params, "form");
     $extra = CMbArray::makeXmlAttributes($params);
     $readonly = CMbArray::extract($params, "readonly");
     $default_color = $this->default ? $this->default : "ffffff";
     $reset_value = $this->notNull ? $default_color : "";
     $bg_reset = $reset_value ? "#{$reset_value}" : "transparent";
     $value = !$value && ($this->notNull || $this->default) ? $default_color : $value;
     $sHtml = "\n    <input type=\"text\" class=\"color_picker\" name=\"{$field}\" value=\"{$value}\" {$extra} />\n    <button type=\"button\" onclick=\"var elem = \$(this).previous('input'); \$V(elem, '{$reset_value}', true); elem.setStyle({backgroundColor: '{$bg_reset}'});\" class='cancel notext'></button>\n    ";
     if ($form && !$readonly) {
         $js_params = "{}";
         if (!$this->notNull) {
             $js_params = "{required:false}";
         }
         $sHtml .= "<script type=\"text/javascript\">\n        Main.add(function(){\n          var _e = getForm('" . $form . "').elements['" . $field . "'];\n          new jscolor.color(_e, {$js_params});\n        })\n      </script>";
     }
     return $sHtml;
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:23,代码来源:CColorSpec.class.php

示例3: getFormHtmlElement

 /**
  * @see parent::getFormHtmlElement()
  */
 function getFormHtmlElement($object, $params, $value, $className)
 {
     $form = CMbArray::extract($params, "form");
     // needs to be extracted
     $field = CMbString::htmlSpecialChars($this->fieldName);
     $extra = CMbArray::makeXmlAttributes($params);
     $sHtml = '<input type="password" name="' . $field . '" class="' . CMbString::htmlSpecialChars(trim($className . ' ' . $this->prop)) . ' styled-element" ';
     if ($this->revealable) {
         $sHtml .= ' value="' . CMbString::htmlSpecialChars($value) . '" ';
     }
     $sHtml .= $extra . ' />';
     if ($this->revealable) {
         $sHtml .= '<button class="lookup notext" type="button" onclick="var i=$(this).previous(\'input\');i.type=(i.type==\'password\')?\'text\':\'password\'"></button>';
     }
     if ($this->randomizable) {
         $random_call = "getRandomPassword('{$object->_class}', '{$field}');";
         $title = CAppUI::tr("common-action-Get random password");
         $sHtml .= '<button class="change notext" type="button" onclick="' . $random_call . '" title="' . $title . '"></button>';
     }
     $sHtml .= '<span id="' . $field . '_message"></span>';
     return $sHtml;
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:25,代码来源:CPasswordSpec.class.php

示例4: getFormHtmlElement

 /**
  * @see parent::getFormHtmlElement()
  */
 function getFormHtmlElement($object, $params, $value, $className)
 {
     $sHtml = "";
     $field = CMbString::htmlSpecialChars($this->fieldName);
     $typeEnum = CMbArray::extract($params, "typeEnum", $this->typeEnum ? $this->typeEnum : "radio");
     $separator = CMbArray::extract($params, "separator");
     $disabled = CMbArray::extract($params, "disabled");
     $readonly = CMbArray::extract($params, "readonly");
     $default = CMbArray::extract($params, "default", $this->default);
     $form = CMbArray::extract($params, "form");
     // needs to be extracted
     $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}"));
     $extra = CMbArray::makeXmlAttributes($params);
     // Empty label
     if ($emptyLabel = CMbArray::extract($params, "emptyLabel")) {
         $emptyLabel = "&mdash; " . CAppUI::tr($emptyLabel);
     }
     switch ($typeEnum) {
         case "radio":
             // Attributes for all inputs
             $attributes = array("type" => "radio", "name" => $field);
             if (null === $value) {
                 $value = "{$default}";
             }
             for ($i = 1; $i >= 0; $i--) {
                 $attributes["value"] = "{$i}";
                 $attributes["checked"] = $value === "{$i}" ? "checked" : null;
                 $attributes["disabled"] = $disabled === "{$i}" || $readonly ? "disabled" : null;
                 $attributes["class"] = $className;
                 $xmlAttributes = CMbArray::makeXmlAttributes($attributes);
                 $sHtml .= "\n<input {$xmlAttributes} {$extra} />";
                 $sTr = CAppUI::tr("bool.{$i}");
                 $sHtml .= "\n<label for=\"{$field}_{$i}\">{$sTr}</label> ";
                 if ($separator && $i != 0) {
                     $sHtml .= "\n{$separator}";
                 }
             }
             return $sHtml;
         case "checkbox":
             $disabled = $readonly ? "disabled=\"1\"" : $disabled;
             if (null === $value) {
                 $value = "{$default}";
             }
             if ($value !== null && $value == 1) {
                 $checked = " checked=\"checked\"";
             } else {
                 $checked = "";
                 $value = "0";
             }
             $sHtml = '<input type="checkbox" name="__' . $field . '" 
       onclick="$V(this.form.' . $field . ', $V(this)?1:0);" ' . $checked . ' ' . $disabled . ' />';
             $sHtml .= '<input type="hidden" name="' . $field . '" ' . $extra . ' value="' . $value . '" />';
             return $sHtml;
         case "select":
             $disabled = $readonly ? "disabled=\"1\"" : $disabled;
             $sHtml = "<select name=\"{$field}\" class=\"{$className}\" {$disabled} {$extra}>";
             if ($emptyLabel) {
                 if ($value === null) {
                     $sHtml .= "\n<option value=\"\" selected=\"selected\">{$emptyLabel}</option>";
                 } else {
                     $sHtml .= "\n<option value=\"\">{$emptyLabel}</option>";
                 }
             }
             foreach ($this->_locales as $key => $item) {
                 if ($value !== null && $value === "{$key}" || $value === null && "{$key}" === "{$this->default}" && !$emptyLabel) {
                     $selected = " selected=\"selected\"";
                 } else {
                     $selected = "";
                 }
                 $sHtml .= "\n<option value=\"{$key}\" {$selected}>{$item}</option>";
             }
             $sHtml .= "\n</select>";
             return $sHtml;
     }
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:78,代码来源:CBoolSpec.class.php

示例5: testMakeXmlAttributesHasRightReturn

 public function testMakeXmlAttributesHasRightReturn()
 {
     $array = array("key" => "val");
     $this->assertEquals('', $this->stub->makeXmlAttributes(array()));
     $this->assertEquals("key=\"val\" ", $this->stub->makeXmlAttributes($array));
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:6,代码来源:CMbArrayTest.php

示例6: getFormHtmlElement

 /**
  * @see parent::getFormHtmlElement()
  */
 function getFormHtmlElement($object, $params, $value, $className)
 {
     $field = CMbString::htmlSpecialChars($this->fieldName);
     $locales = $this->_locales;
     $typeEnum = CMbArray::extract($params, "typeEnum", $this->typeEnum ? $this->typeEnum : "checkbox");
     $separator = CMbArray::extract($params, "separator", $this->vertical ? "<br />" : null);
     $cycle = CMbArray::extract($params, "cycle", 1);
     $alphabet = CMbArray::extract($params, "alphabet", false);
     $size = CMbArray::extract($params, "size", 0);
     $onchange = CMbArray::get($params, "onchange");
     $form = CMbArray::extract($params, "form");
     // needs to be extracted
     $readonly = CMbArray::extract($params, "readonly") == 1;
     $extra = CMbArray::makeXmlAttributes($params);
     $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}"));
     if ($alphabet) {
         asort($locales);
     }
     $uid = uniqid();
     $value_array = $this->getListValues($value);
     switch ($typeEnum) {
         case "select":
             if ($readonly) {
                 $readonly = "readonly";
             }
             $sHtml = "<script type=\"text/javascript\">\n          Main.add(function(){\n            var select = \$\$('select[data-select_set={$uid}]')[0],\n                element = select.previous(),\n                tokenField = new TokenField(element, {" . ($onchange ? "onChange: function(){ {$onchange} }.bind(element)" : "") . "});\n\n            select.observe('change', function(event){\n              tokenField.setValues(\$A(select.options).filter(function(o){return o.selected}).pluck('value'));\n\n              element.fire('ui:change');\n            });\n          });\n        </script>";
             $sHtml .= "<input type=\"hidden\" name=\"{$field}\" value=\"{$value}\" class=\"{$className}\" {$extra} />\n";
             $sHtml .= "<select class=\"{$className}\" multiple=\"multiple\" size=\"{$size}\" data-select_set=\"{$uid}\" {$extra} {$readonly}>";
             foreach ($locales as $key => $item) {
                 if (!empty($value_array) && in_array($key, $value_array)) {
                     $selected = " selected=\"selected\"";
                 } else {
                     $selected = "";
                 }
                 $sHtml .= "\n<option value=\"{$key}\" {$selected}>{$item}</option>";
             }
             $sHtml .= "\n</select>";
             break;
         default:
         case "checkbox":
             $sHtml = "<span id=\"set-container-{$uid}\">\n";
             $sHtml .= "<input type=\"hidden\" name=\"{$field}\" value=\"{$value}\" class=\"{$className}\" {$extra} />\n";
             $sHtml .= "<script type=\"text/javascript\">\n          Main.add(function(){\n            var cont = \$('set-container-{$uid}'),\n                element = cont.down('input[type=hidden]'),\n                tokenField = new TokenField(element, {" . ($onchange ? "onChange: function(){ {$onchange} }.bind(element)" : "") . "});\n\n            cont.select('input[type=checkbox]').invoke('observe', 'click', function(event){\n              var elt = Event.element(event);\n              tokenField.toggle(elt.value, elt.checked);\n\n              element.fire('ui:change');\n            });\n          });\n        </script>";
             $compteur = 0;
             if ($readonly) {
                 $readonly = "disabled";
             }
             foreach ($locales as $key => $item) {
                 $selected = "";
                 if (!empty($value_array) && in_array($key, $value_array)) {
                     $selected = " checked=\"checked\"";
                 }
                 $sHtml .= "\n<label>\n              <input type=\"checkbox\" name=\"_{$field}_{$key}\" value=\"{$key}\" class=\"set-checkbox token{$uid}\" {$selected} {$readonly}  />\n              {$item}\n            </label> ";
                 $compteur++;
                 $modulo = $compteur % $cycle;
                 if ($separator != null && $modulo == 0 && $compteur < count($locales)) {
                     $sHtml .= $separator;
                 }
             }
             $sHtml .= "</span>\n";
     }
     return $sHtml;
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:66,代码来源:CSetSpec.class.php

示例7: getFormHtmlElement

 /**
  * @see parent::getFormHtmlElement()
  */
 function getFormHtmlElement($object, $params, $value, $className)
 {
     $field = CMbString::htmlSpecialChars($this->fieldName);
     $typeEnum = CMbArray::extract($params, "typeEnum", $this->typeEnum ? $this->typeEnum : "select");
     $columns = CMbArray::extract($params, "columns", $this->columns ? $this->columns : 1);
     $separator = CMbArray::extract($params, "separator");
     $cycle = CMbArray::extract($params, "cycle", 1);
     $alphabet = CMbArray::extract($params, "alphabet", false);
     $form = CMbArray::extract($params, "form");
     // needs to be extracted
     // Empty label
     if ($emptyLabel = CMbArray::extract($params, "emptyLabel")) {
         $emptyLabel = CAppUI::tr($emptyLabel);
     }
     // Extra info por HTML generation
     $extra = CMbArray::makeXmlAttributes($params);
     $locales = $this->_locales;
     $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}"));
     $html = "";
     // Alpha sorting
     if ($alphabet) {
         asort($locales);
     }
     // Turn readonly to disabled
     $readonly = CMbArray::extract($params, "readonly");
     $disabled = $readonly ? "disabled=\"1\"" : "";
     switch ($typeEnum) {
         default:
         case "select":
             $html .= "<select name=\"{$field}\" class=\"{$className}\" {$disabled} {$extra}>";
             // Empty option label
             if ($emptyLabel) {
                 $emptyLabel = "&mdash; {$emptyLabel}";
                 if ($value === null) {
                     $html .= "\n<option value=\"\" selected=\"selected\">{$emptyLabel}</option>";
                 } else {
                     $html .= "\n<option value=\"\">{$emptyLabel}</option>";
                 }
             }
             // All other options
             foreach ($locales as $key => $item) {
                 $selected = "";
                 if ($value !== null && $value === "{$key}" || $value === null && "{$key}" === "{$this->default}" && !$emptyLabel) {
                     $selected = " selected=\"selected\"";
                 }
                 $html .= "\n<option value=\"{$key}\" {$selected}>{$item}</option>";
             }
             $html .= "\n</select>";
             return $html;
         case "radio":
             $compteur = 0;
             // Empty radio label
             if ($emptyLabel) {
                 if ($value === null) {
                     $html .= "\n<input type=\"radio\" name=\"{$field}\" value=\"\" checked=\"checked\" />";
                 } else {
                     $html .= "\n<input type=\"radio\" name=\"{$field}\" value=\"\" />";
                 }
                 $html .= "<label for=\"{$field}_\">{$emptyLabel}</label> ";
             }
             // All other radios
             foreach ($locales as $key => $item) {
                 $selected = "";
                 if ($value !== null && $value === "{$key}" || $value === null && "{$key}" === "{$this->default}") {
                     $selected = " checked=\"checked\"";
                 }
                 $html .= "\n<input type=\"radio\" name=\"{$field}\" value=\"{$key}\" {$selected} class=\"{$className}\" {$disabled} {$extra} />\n                       <label for=\"{$field}_{$key}\">{$item}</label> ";
                 $compteur++;
                 $modulo = $compteur % $cycle;
                 if ($separator != null && $modulo == 0 && $compteur < count($locales)) {
                     $html .= $separator;
                 }
                 if ($this->vertical) {
                     $html .= "<br />\n";
                 }
             }
             return $html;
     }
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:82,代码来源:CEnumSpec.class.php

示例8: getFormHtmlElement

 /**
  * @param array $params Template params:
  *   - options : array of objects with IDs
  *   - choose  : string alternative for Choose default option
  *   - size    : interger for size of text input 
  * @see classes/CMbFieldSpec#getFormHtmlElement($object, $params, $value, $className)
  *
  * @return string
  */
 function getFormHtmlElement($object, $params, $value, $className)
 {
     if ($options = CMbArray::extract($params, "options")) {
         $field = CMbString::htmlSpecialChars($this->fieldName);
         $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}"));
         $extra = CMbArray::makeXmlAttributes($params);
         $choose = CMbArray::extract($params, "choose", "Choose");
         $choose = CAppUI::tr($choose);
         $html = "\n<select name=\"{$field}\" class=\"{$className}\" {$extra}>";
         $html .= "\n<option value=\"\">&mdash; {$choose}</option>";
         foreach ($options as $_option) {
             $selected = $value == $_option->_id ? "selected=\"selected\"" : "";
             $html .= "\n<option value=\"{$_option->_id}\" {$selected}>{$_option->_view}</option>";
         }
         $html .= "\n</select>";
         return $html;
     }
     CMbArray::defaultValue($params, "size", 25);
     return $this->getFormElementText($object, $params, $value, $className);
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:29,代码来源:CRefSpec.class.php

示例9: getFormElementDateTime

 /**
  * Get an HTML form datetime input corresponding to the bound object value
  * 
  * @param object $object    Object holding the field
  * @param array  $params    Extra parameters
  * @param string $value     The actual value
  * @param string $className Extra CSS class name
  * @param string $format    Optional datetime format
  *  
  * @return string HTML form datetime string
  */
 function getFormElementDateTime($object, $params, $value, $className, $format = "%d/%m/%Y %H:%M")
 {
     if ($object->_locked) {
         $params["readonly"] = "readonly";
     }
     $class = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}"));
     $field = CMbString::htmlSpecialChars($this->fieldName);
     // Format the date
     $date = "";
     if ($value && $value != '0000-00-00' && $value != '00:00:00' && $value != '0000-00-00 00:00:00') {
         $date = $this instanceof CDateSpec && $this->progressive ? $this->getValue($object, null, $params) : CMbDT::format($value, $format);
     }
     $form = CMbArray::extract($params, "form");
     $register = CMbArray::extract($params, "register");
     $style = CMbArray::extract($params, "style");
     $tabindex = CMbArray::extract($params, "tabindex");
     $readonly = CMbArray::get($params, "readonly");
     $extra = CMbArray::makeXmlAttributes($params);
     $html = array();
     $html[] = '<input name="' . $field . '_da" type="text" value="' . $date . '" class="' . $class . ' styled-element" 
                   readonly="readonly" ' . (isset($tabindex) ? 'tabindex="' . $tabindex . '" ' : '') . ' style="' . $style . '" />';
     $html[] = '<input name="' . $field . '" type="hidden" value="' . $value . '" class="' . $class . '" ' . $extra . ' data-visual-element="' . $field . '_da"  />';
     if ($form && !$readonly && ($register || $this instanceof CTimeSpec)) {
         $register = $this instanceof CDateSpec && $this->progressive ? 'regProgressiveField' : 'regField';
         $html[] = '<script type="text/javascript">
     Main.add(function(){Calendar.' . $register . '(getForm("' . $form . '").elements["' . $field . '"])})
   </script>';
     }
     return implode("\n", $html);
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:41,代码来源:CMbFieldSpec.class.php


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