Пример #1
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $mplme = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $frameResponseObject->setTitle("Mplme");
     if (isset($_REQUEST["xmlData"])) {
         $xmlDoc = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $mplme->get_path() . "/data.xml");
         if ($xmlDoc === 0 || !$xmlDoc instanceof \steam_document) {
             $xml = simplexml_load_string("<datasets></datasets>");
             $xmlDoc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "data.xml", $xml->asXML(), "text/xml");
             $xmlDoc->move($mplme);
         } else {
             $xmlRaw = $xmlDoc->get_content();
             $xml = simplexml_load_string($xmlRaw);
         }
         $xmlRequest = simplexml_load_string($_REQUEST["xmlData"]);
         $xmlRequestDom = new \domDocument();
         $xmlRequestDom->loadXML($xmlRequest->asXML());
         $xmlDom = new \domDocument();
         $xmlDom->loadXML($xml->asXML());
         $xmlDom->documentElement->appendChild($xmlDom->importNode($xmlRequestDom->documentElement, true));
         if ($_FILES && is_array($_FILES)) {
             foreach ($_FILES as $file) {
                 $content = file_get_contents($file["tmp_name"]);
                 $doc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $file["name"], $content, $file["type"]);
                 $doc->move($mplme);
             }
         }
         $xmlDoc->set_content($xmlDom->saveXML());
         //echo "<pre>" . htmlentities($xmlDom->saveXML()) . "</pre>";
         echo "ok";
     } else {
         echo "nix";
     }
     die;
     //echo "done";
     //$frameResponseObject->addWidget(new \Widgets\Blank());
     //return $frameResponseObject;
 }
Пример #2
0
 public function run($str = nULL)
 {
     if (!is_null($str)) {
         $regex = '/<([a-z0-9\\-]+)(.*?)>(?:(.*?)(<\\/\\1>))?/ix';
         if (is_a($str, jqmel)) {
             $str = $str->dom()->get()->lastdom;
         } elseif (is_callable($str)) {
             $str = call_user_func($str, array());
         }
         $str = preg_replace('/\\s+/', ' ', $str);
         if (preg_match($regex, $str, $match)) {
             $match[2] = rtrim($match[2], '/');
         }
         $document = jqm_use($this->node->_parentElement);
         $np = $this->node->next()->get();
         $npp = $this->node->prev()->get();
         $par = $this->node->parent();
         $wrap = $str;
         if (!is_a($par->get(), jqmel)) {
             return;
         }
         $rec = $document->_DOM;
         if ($rec->doctype) {
             $rec->removeChild($rec->doctype);
         }
         $xpath = new domxpath($rec);
         $find = $xpath->query($this->node->_path);
         if ($find->length > 0) {
             $child = new domDocument();
             $child->loadHtml($wrap);
             if ($child->doctype) {
                 $child->removeChild($child->doctype);
             }
             $chf = $child->getElementsByTagName($match[1]);
             $node = $this->node->__toDomElement();
             $frag = $child->importNode($node, true);
             $depth = $this->getDeepest($chf->item(0));
             $save = $depth->appendChild($frag);
             //Import to document
             $frag = $rec->importNode($chf->item(0), true);
             $newsave = $find->item(0)->parentNode->replaceChild($frag, $find->item(0));
             $new_path = explode('/', $frag->getNodePath());
             $p_path = array_filter(explode('/', $save->getNodePath()));
             //$p_path = array_pop($p_path);
             $htm = array_search('html', $p_path);
             if ($htm) {
                 unset($p_path[$htm]);
                 unset($p_path[$htm + 1]);
             }
             $new_path = array_merge($new_path, $p_path);
             $sh = array_pop($new_path);
             array_pop($new_path);
             $ele_path = ltrim($newsave->getNodePath(), '/');
             $this->node->_parent_path = implode('/', $new_path);
             $this->node->_path = $this->node->_parent_path . '/' . $sh;
             $wrap = $rec->saveHtml($frag->parentNode);
             $wrap = substr($wrap, strpos($wrap, '>') + 1);
             if (!empty($par->get()->_localName)) {
                 $wrap = substr($wrap, 0, strripos($wrap, $par->get()->_localName));
                 $par->get()->html($wrap);
             }
             $find = $this->node->getPathById();
             if ($find) {
                 $this->node->_path = $find;
             }
             if ($this->node->trace) {
                 $key = $this->node->trace->key();
                 $this->node->trace->next();
                 $n = $this->node->trace->current();
                 if ($key > 0) {
                     $this->node->trace->seek($key - 1);
                     $p = $this->node->trace->current();
                 }
                 if ($p and is_a($p, jqmel)) {
                     $find = $p->getPathById();
                     if ($find) {
                         $p->_path = $find;
                         //var_dump($key,$p);
                     }
                 }
                 if ($n and is_a($n, jqmel)) {
                     $find = $n->getPathById();
                     if ($find) {
                         $n->_path = $find;
                     }
                 }
                 unset($p);
                 unset($n);
             }
         }
     }
 }