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


PHP xml::setElementText方法代码示例

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


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

示例1: setMeta

 function setMeta($name, $value, $readonly = false)
 {
     $e = $this->query('/*/meta[@name="' . htmlspecialchars($name) . '"]')->item(0);
     if (!$e) {
         $e = $this->de()->appendChild($this->createElement('meta', array('name' => $name)));
     }
     if ($e) {
         xml::setElementText($e, $value);
     }
     if ($readonly) {
         $e->setAttribute('readonly', 'readonly');
     } elseif ($e->hasAttribute('readonly')) {
         $e->removeAttribute('readonly');
     }
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:15,代码来源:out.php

示例2: setValue

 function setValue($value)
 {
     if ($this->hasCheck('num')) {
         if (is_numeric($value)) {
             $value = str_replace('.', ',', floatval($value));
         } else {
             $value = null;
         }
     }
     xml::setElementText($this->e, $value);
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:11,代码来源:form.php

示例3: __call

 function __call($m, $a)
 {
     $xml = new xml($this->e);
     switch ($m) {
         case 'rewind':
         case 'current':
         case 'key':
         case 'next':
         case 'valid':
         case 'setButton':
         case 'getButtons':
             return call_user_func(array($this, $m), $a);
         default:
             if (preg_match('/^get(\\w+)$/', $m, $res)) {
                 $name = strtolower($res[1]);
                 if ($name == row::IDATTR) {
                     return $this->e->getAttribute('id');
                 } elseif ($this->hasColumn($name) && ($e = $xml->query($name, $this->e)->item(0))) {
                     return xml::getElementText($e);
                 }
             } elseif (preg_match('/^set(\\w+)$/', $m, $res)) {
                 switch ($name = strtolower($res[1])) {
                     case row::IDATTR:
                         if ($val = $a[0]) {
                             $this->e->setAttribute('id', $val);
                         } elseif ($this->e->hasAttribute('id')) {
                             $this->e->removeAttribute('id');
                         }
                         break;
                     default:
                         if ($this->hasColumn($name)) {
                             $e = null;
                             if ($e = $xml->query('cell[@name="' . htmlspecialchars($name) . '"]', $this->e)->item(0)) {
                             } else {
                                 $e = $this->e->appendChild($xml->createElement('cell', array('name' => $name)));
                             }
                             if ($e) {
                                 xml::setElementText($e, $a[0]);
                             }
                         }
                 }
             }
     }
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:44,代码来源:rowlist.php

示例4: run

 function run()
 {
     global $_out;
     $captcha = new captcha();
     $captcha->setParamName('captcha');
     if ($form = $this->query('form')->item(0)) {
         //нашли форму
         if (!$form->getAttribute('action')) {
             $form->setAttribute('action', $_SERVER['REQUEST_URI']);
         }
         if ($this->isSent($form)) {
             //форму отправили
             if (!$this->check($form) && ($res = $this->getSentData($form))) {
                 $e = $this->getSection()->getXML()->createElement('final', null);
                 $resultSQL = $resultMail = true;
                 if (count($res['mysql'])) {
                     $resultSQL = $this->insertDB($res['mysql'], $form);
                 }
                 if ($res['xml']) {
                     $resultMail = $this->sendEmail($res['xml'], $form);
                 }
                 if ($resultSQL && $resultMail) {
                     xml::setElementText($e, xml::getElementText($this->getSection()->getXML()->query('good', $form)->item(0)));
                 } else {
                     xml::setElementText($e, xml::getElementText($this->getSection()->getXML()->query('fail', $form)->item(0)));
                 }
                 $form->appendChild($e);
             } else {
                 // Ошибка - заполняем форму
                 $this->fillForm($form);
             }
         }
         $_out->addSectionContent($form);
         $captcha->setLanguage('en');
         $captcha->create('userfiles/cptch.jpg');
     }
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:37,代码来源:feedback.php

示例5: save

 function save()
 {
     $files = array();
     foreach ($this->values as $fpath => $values) {
         if (!isset($files[$fpath])) {
             $files[$fpath] = $this->getXML($fpath, null, false);
         }
         $xml = $files[$fpath];
         foreach ($values as $xpath => $data) {
             //создаем недостающие элементы из xpath запроса
             $elemToCreate = array();
             $arQuery = explode('/', $xpath);
             $elem = null;
             while ($query = implode('/', $arQuery)) {
                 if ($elem = $xml->query($query)->item(0)) {
                     break;
                 } else {
                     array_unshift($elemToCreate, array_pop($arQuery));
                 }
             }
             if (!$elem) {
                 $elem = $xml->dd();
             }
             foreach ($elemToCreate as $str) {
                 if (preg_match('/^([\\w\\-]+)(?:\\[((?:@[\\w\\-]+|@[\\w\\-]+=["\'][\\w\\-]+["\']|\\s+|and|or|[0-9])+)\\]){0,1}$/', $str, $res)) {
                     $elem = $elem->appendChild($xml->createElement($res[1]));
                     if (isset($res[2])) {
                         $tmp = explode(' ', $res[2]);
                         //все атрибуты в условии запроса, у которых заданы значения, будут созданы
                         foreach ($tmp as $str) {
                             if (preg_match('/^@([\\w\\-]+)=["\']([\\w\\-]+)["\']$/', trim($str), $res)) {
                                 $elem->setAttribute($res[1], $res[2]);
                             }
                         }
                     }
                 } else {
                     break;
                 }
             }
             //Устанавливаем значения. Сначала получим целевой элемент
             if ($xpath == '/' && ($e = $xml->dd()) || ($e = $xml->query($xpath)->item(0)) || preg_match('/(.*)\\/@([\\w\\-]+)$/', $xpath, $matches) && ($tmp = $xml->query($matches[1])->item(0)) && ($e = $tmp->setAttribute($matches[2], null))) {
                 switch ($elementClass = get_class($e)) {
                     case 'DOMAttr':
                         if ($data['value']) {
                             if (!is_array($data['value'])) {
                                 $e->value = $data['value'];
                             }
                         } elseif ($e->ownerElement->hasAttribute($e->name)) {
                             $e->ownerElement->removeAttribute($e->name);
                         }
                         break;
                     case 'DOMDocument':
                     case 'DOMElement':
                         if ($data['hash']) {
                             if (preg_match('/^([\\w\\-]+)(?:\\[((?:@[\\w\\-]+|@[\\w\\-]+=["\'][\\w\\-]+["\']|\\s+|and)+)\\]){0,1}$/', $data['hash'] = trim($data['hash']), $res)) {
                                 $elem = null;
                                 if (!$elem) {
                                     $elem = $e->appendChild($xml->createElement($res[1], null, is_array($data['value']) ? null : $data['value']));
                                     if (isset($res[2])) {
                                         $tmp = explode('and', $res[2]);
                                         foreach ($tmp as $attr) {
                                             if (preg_match('/^@([\\w\\-]+)=["\']([\\w\\-]+)["\']$/', trim($attr), $res)) {
                                                 $elem->setAttribute($res[1], $res[2]);
                                             }
                                         }
                                     }
                                 }
                                 if (is_array($data['value'])) {
                                     foreach ($data['value'] as $name => $value) {
                                         if (!is_numeric($name)) {
                                             if ($value) {
                                                 $elem->setAttribute($name, $value);
                                             } elseif ($elem->hasAttribute($name)) {
                                                 $elem->removeAttribute($name);
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             if (is_array($data['value'])) {
                                 foreach ($data['value'] as $name => $value) {
                                     if (!is_numeric($name)) {
                                         if ($value) {
                                             $elem->setAttribute($name, $value);
                                         } elseif ($elem->hasAttribute($name)) {
                                             $elem->removeAttribute($name);
                                         }
                                     }
                                 }
                             } else {
                                 xml::setElementText($elem, $data['value']);
                             }
                         }
                         break;
                 }
             }
         }
         $xml->save();
     }
//.........这里部分代码省略.........
开发者ID:PapaKot,项目名称:Horowitz,代码行数:101,代码来源:xmlScheme.php


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