Ejemplo n.º 1
0
 function get($uri)
 {
     if ($e = $this->getNode($uri)) {
         switch (get_class($e)) {
             case 'DOMAttr':
                 return $e->value;
             case 'DOMDocument':
             case 'DOMElement':
                 return xml::getElementText($e);
         }
     }
 }
Ejemplo n.º 2
0
 function getListXML($tagName)
 {
     if ($xml = parent::getListXML($tagName)) {
         $ns = $xml->query('/*/row/article');
         foreach ($ns as $n) {
             if (($path = xml::getElementText($n)) && is_file($path)) {
                 $n->parentNode->appendChild($xml->createElement('file', array('path' => $path, 'size' => $this->file_size(filesize($path)), 'ext' => strtolower(pathinfo($path, PATHINFO_EXTENSION)))));
             }
             $n->parentNode->removeChild($n);
         }
     }
     return $xml;
 }
Ejemplo n.º 3
0
 static function getModuleList()
 {
     $ar = array();
     if ($dir = scandir(PATH_MODULE)) {
         foreach ($dir as $entry) {
             if ($entry != "." && $entry != ".." && is_dir($path = PATH_MODULE . $entry) && file_exists($path .= '/info.xml')) {
                 $ar[$entry] = array();
                 $xml = new xml($path);
                 $res = $xml->query('/*/*');
                 foreach ($res as $e) {
                     if ($e instanceof DOMElement) {
                         $ar[$entry][$e->tagName] = xml::getElementText($e);
                     }
                 }
             }
         }
     }
     return $ar;
 }
Ejemplo n.º 4
0
 function getValue()
 {
     return xml::getElementText($this->e);
 }
Ejemplo n.º 5
0
 function run()
 {
     global $_out;
     $ns = $this->query('form');
     foreach ($ns as $form) {
         if (!$form->getAttribute('action')) {
             $form->setAttribute('action', $_SERVER['REQUEST_URI']);
         }
         if ($this->isSent($form)) {
             //форму отправили
             $xml = new xml($form);
             if (!$this->check($form) && ($res = $this->getSentData($form))) {
                 $resultSQL = $resultMail = true;
                 if (count($res['mysql'])) {
                     $resultSQL = $this->insertDB($res['mysql'], $form);
                 }
                 if ($res['xml']) {
                     $resultMail = $this->sendEmail($res['xml'], $form);
                 }
                 $form->appendChild($xml->createElement('message', array('type' => $resultSQL && $resultMail ? 'success' : 'fail'), xml::getElementText($this->query($resultSQL && $resultMail ? 'form/good' : 'form/fail')->item(0))));
             } else {
                 // Ошибка - заполняем форму
                 $this->fillForm($form);
             }
         }
         if ($form->hasAttribute('appendTo')) {
             $_out->elementIncludeTo($form, $form->getAttribute('appendTo'));
         } elseif (!$this->getSection()) {
             $_out->elementIncludeTo($form, $_out->de());
         } else {
             $_out->addSectionContent($form);
         }
         if ($this->hasCaptcha($form)) {
             $captcha = new captcha();
             $captcha->setLanguage($_out->getLang());
             $captcha->setParamName('captcha');
             $captcha->create('userfiles/cptch.jpg');
         }
     }
 }
Ejemplo n.º 6
0
 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]);
                             }
                         }
                 }
             }
     }
 }
Ejemplo n.º 7
0
 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');
     }
 }