Exemple #1
0
 static function parse($node, $allow = null, $deny = null)
 {
     $find = array();
     $replace = array();
     foreach (self::$find as $n => $rule) {
         list($code, $expression) = $rule;
         $allowed = !$allow || $allow && in_array($code, $allow);
         $denied = $deny && in_array($code, $deny);
         if ($allowed && !$denied) {
             $find[] = $expression;
             $replace[] = self::$replace[$n];
         }
     }
     $xml = new xml();
     foreach ($node->children() as $child) {
         $xml->append($xml->import($child));
     }
     foreach ($xml->query('//text()') as $text) {
         $parent = $text->parent();
         $bbcode = preg_replace($find, $replace, $text->value());
         $bbcode = xml::parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><bbcode>{$bbcode}</bbcode>");
         foreach ($bbcode->query('/bbcode/* | /bbcode/text()') as $child) {
             $parent->insert($xml->import($child), $text);
         }
         $parent->remove($text);
     }
     return $xml;
 }
Exemple #2
0
 function getSiteInfo()
 {
     $xml = new xml();
     $xml->dd()->appendChild($xml->importNode($this->de()));
     $ns = $xml->query('/site/mysql | /site/users');
     foreach ($ns as $n) {
         $n->parentNode->removeChild($n);
     }
     return $xml;
 }
Exemple #3
0
 function install()
 {
     $xml_data = new xml(PATH_MODULE . $this->getName() . '/data.xml');
     $xml_sec = $this->getSection()->getXML();
     $ar = array('form_edit', 'form_add', 'banner_list');
     foreach ($ar as $id) {
         if (($e = $xml_data->query('//*[@id="' . $id . '"]')->item(0)) && !$xml_sec->evaluate('count(./*[@id="' . $id . '"])', $this->getRootElement())) {
             $xml_sec->elementIncludeTo($e, $this->getRootElement());
         }
     }
     $xml_sec->save();
     return true;
 }
Exemple #4
0
 function __construct(xml $xml, $tagName = null)
 {
     global $_struct;
     if (!$tagName) {
         $tagName = 'modules';
     }
     if ($modules = $xml->query($query = '/*/' . $tagName)->item(0)) {
     } else {
         $modules = $xml->de()->appendChild($xml->createElement($tagName));
     }
     parent::__construct($modules, 'module');
     $this->keyAttribute = 'id';
     $this->setStructure($_struct);
 }
Exemple #5
0
 function getSentData($form)
 {
     global $_site;
     $xml = new xml($form);
     $mysql = new mysql();
     $res = $xml->query('.//field', $form);
     $arRes = array('xml' => null, 'mysql' => null);
     $arRes['xml'] = new xml(null, 'email', null);
     $arRes['xml']->de()->setAttribute('domain', $_site->getDomain());
     $arRes['xml']->de()->setAttribute('hash', md5($mysql->getNextId($mysql->getTableName($form->getAttribute('dbTable')))));
     foreach ($res as $field) {
         $f = array('name' => $field->getAttribute('name'), 'label' => $field->getAttribute('label'));
         $val = param($field->getAttribute('name'));
         switch ($field->getAttribute('type')) {
             case 'file':
                 if (!($attach = $arRes['xml']->query('./attach', $arRes['xml']->de())->item(0))) {
                     $attach = $arRes['xml']->de()->appendChild($arRes['xml']->createElement('attach'));
                 }
                 $files = $_FILES[$field->getAttribute('name')];
                 switch (is_array($files['error'])) {
                     case true:
                         foreach ($files['error'] as $i => $code) {
                             if ($code == 0) {
                                 $attach->appendChild($arRes['xml']->createElement('item', array('name' => $files['name'][$i], 'path' => $files['tmp_name'][$i], 'size' => $files['size'][$i])));
                             }
                         }
                         break;
                     case false:
                         if ($files['error'] == 0) {
                             $attach->appendChild($arRes['xml']->createElement('item', array('name' => $files['name'], 'path' => $files['tmp_name'], 'size' => $files['size'])));
                         }
                         break;
                 }
                 break;
             case 'password':
                 $f['value'] = md5($val);
                 break;
             case 'checkbox':
                 $f['value'] = isset($_REQUEST[$field->getAttribute('name')]) ? "1" : "0";
                 break;
             case 'textarea':
                 $f['value'] = nl2br(strip_tags($val));
                 break;
             default:
                 $f['value'] = strip_tags($val);
         }
         if ($field->hasAttribute('mail')) {
             $arRes['xml']->de()->appendChild($arRes['xml']->createElement('field', array('name' => $field->getAttribute('name'), 'label' => $f['label']), $field->getAttribute('type') == 'password' ? $val : $f['value']));
         }
         if ($field->hasAttribute('uri')) {
             $arRes['mysql'][$field->getAttribute('name')] = $f['value'];
         }
     }
     if (!$arRes['xml']->query('//@label')->item(0) instanceof DOMAttr) {
         unset($arRes['xml']);
     }
     if (!$form->getAttribute('dbSave')) {
         unset($arRes['mysql']);
     }
     return $arRes;
 }
Exemple #6
0
 function getList($param = false)
 {
     $xml = new xml(PATH_MODULE . $this->getName() . '/data.xml');
     if ($e = $xml->query('/data/rowlist')->item(0)) {
         $modules = $this->getModuleList();
         $modules_this_section = $this->getModules();
         $rl = new rowlist($e, $modules_this_section->getNum(), param('page'));
         if (!$param) {
             $modules_sec = array();
             foreach ($modules_this_section as $m) {
                 $modules_sec[$m->getId()] = array('idmodule' => $m->getId(), 'title' => $m->getTitle(), 'name' => $m->getName(), 'active' => $m->getRootElement()->hasAttribute('readonly'));
             }
             $modules_new = array();
             foreach ($modules_sec as $key => $m) {
                 if (isset($modules[$m['name']])) {
                     $modules_new[$key] = $modules_sec[$key];
                     $modules_new[$key]['name'] = $modules[$m["name"]]['name'];
                     $modules_new[$key]['version'] = $modules[$m["name"]]['version'];
                     $modules_new[$key]['description'] = $modules[$m["name"]]['description'];
                     $modules_new[$key]['data'] = $modules[$m["name"]]['data'];
                 } else {
                     //модуль в разделе есть а в папке с модулями его нет, непонятно !(
                     $modules_new[$key] = $m;
                 }
             }
             $modules = $modules_new;
         }
         if (count($modules)) {
             foreach ($modules as $i => $module) {
                 if ($i >= $rl->getStartIndex() && $i <= $rl->getFinishIndex()) {
                     $rl->addRow($i, $module);
                 }
             }
         }
         return $rl->getRootElement();
     }
 }
Exemple #7
0
 function getButtons()
 {
     $xml = new xml($this->e);
     if ($e = $xml->query('buttons', $this->e)->item(0)) {
     } else {
         $e = $this->e->appendChild($xml->createElement('buttons'));
     }
     if ($e) {
         return new taglist($e, 'b');
     }
 }
Exemple #8
0
 static function seclist($e, $ff, $arExclude = null)
 {
     //список разделов для селекта
     $xml = new xml($e);
     $shift = str_repeat('- ', $xml->evaluate('count(ancestor-or-self::sec)', $e));
     $res = $xml->query('sec', $e);
     foreach ($res as $sec) {
         if (!($arExclude && in_array($sec->getAttribute('id'), $arExclude))) {
             $ff->addOption($sec->getAttribute('id'), $shift . $sec->getAttribute('title'));
             apSectionEdit::seclist($sec, $ff, $arExclude);
         }
     }
 }
Exemple #9
0
 function install()
 {
     if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/classes/feedback.php')) {
         copy($_SERVER['DOCUMENT_ROOT'] . '/ap/modules/' . get_class($this) . '/client/feedback.php', $_SERVER['DOCUMENT_ROOT'] . '/classes/feedback.php');
     }
     if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/xml/templates/email_feedback.xsl')) {
         copy($_SERVER['DOCUMENT_ROOT'] . '/ap/modules/' . get_class($this) . '/client/email_feedback.xsl', $_SERVER['DOCUMENT_ROOT'] . '/xml/templates/email_feedback.xsl');
     }
     if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/xml/templates/email_feedback_user.xsl')) {
         copy($_SERVER['DOCUMENT_ROOT'] . '/ap/modules/' . get_class($this) . '/client/email_feedback_user.xsl', $_SERVER['DOCUMENT_ROOT'] . '/xml/templates/email_feedback_user.xsl');
     }
     $xml_data = new xml(PATH_MODULE . get_class($this) . '/data.xml');
     $this->xml = $this->getSection()->getXML();
     $ar = array('feedback_addForm', 'feedback_editForm', 'feedback_list_fields');
     foreach ($ar as $id) {
         $e = $xml_data->query('//*[@id="' . $id . '"]')->item(0);
         if ($e && !$this->xml->evaluate('count(./*[@id="' . $id . '"])', $this->getRootElement())) {
             $this->xml->elementIncludeTo($e, $this->getRootElement());
         }
     }
     $this->xml->save();
     if ($sec = ap::getClientSection($this->getSection()->getId())) {
         $modules = $sec->getModules();
         if (!$modules->getById($this->getId())) {
             $modules->add('feedback', $this->getTitle(), $this->getId());
             $e = $xml_data->query('//*[@id="feedback_form"]')->item(0);
             $m = $modules->getXML();
             if ($e && !$this->xml->evaluate('count(./*[@id="feedback_form"])', $this->getRootElement())) {
                 $m->elementIncludeTo($e, $m->getElementById('feedback', 'name'));
             }
             $m->save();
         }
         return true;
     }
 }
Exemple #10
0
 function query($query)
 {
     $xml = new xml($this->e);
     return $xml->query($query, $this->e);
 }
Exemple #11
0
 function getChildren()
 {
     $ar = array();
     $xml = new xml($this->getElement());
     $res = $xml->query('sec', $this->getElement());
     foreach ($res as $e) {
         $ar[] = new section($e, $this->xmlPath, $this->getTemplatePath());
     }
     return count($ar) ? $ar : null;
 }