protected function _render() { $utils = Utils::getInstance(); if ($utils->globals->session('send_operation') && $utils->globals->session('target_form') == $this->ref) { $this->_oNode->setAttribute('method', 'get'); $this->_oNode->setAttribute('action', '#'); DOMParser::replaceNodeContent($this->_getSendedMessage(), $this->_oNode); } else { if ($this->ignored !== $this->_getIgnoredInputs()) { $this->ignored = $this->_getIgnoredInputs(); $this->save(); } if ($utils->globals->has('send_operation', 'session') && $utils->globals->session('target_form') == $this->ref) { DOMNode::appendToNode($this->_getErrorMessage(), $this->_oNode); } $this->_oNode->setAttribute('method', 'post'); if ($this->_sLang) { $this->_oNode->setAttribute('action', '/' . $this->_sLang . '/form/' . $this->ref . '/send.html'); } else { $this->_oNode->setAttribute('action', '/form/' . $this->ref . '/send.html'); } } unset($_SESSION['target_form']); unset($_SESSION['send_operation']); }
protected function _render($bAdminMode = false) { $sContent = $this->content; if ($bAdminMode) { $oTMPDocument = new DOMDocument(); $oTMPDocument->loadXML('<root>' . str_replace('&', '&', $sContent) . '</root>'); if ($oTMPDocument->firstChild->childNodes->length == 1 && $oTMPDocument->firstChild->childNodes->item(0)->nodeType == XML_TEXT_NODE) { $oTMPDocument->loadXML('<root><p>' . $sContent . '</p></root>'); } foreach ($oTMPDocument->firstChild->childNodes as $oChildNode) { if ($oChildNode->nodeType == XML_TEXT_NODE) { continue; } if ($oChildNode->nodeName == 'div') { $oChildNode->parentNode->removeChild($oChildNode); continue; } foreach ($this->_oNode->attributes as $oOriginalNodeAttribute) { $oChildNode->setAttribute($oOriginalNodeAttribute->name, $oOriginalNodeAttribute->value); } // $oChildNode->setAttribute( 'data-brick', $this->ref ); $oChildNode->setAttribute('data-brick-parsed', 'yes'); DOMParser::addClassTo('posib-editable', $oChildNode); } $sContent = null; DOMParser::getNodeContent($oTMPDocument->firstChild, $sContent); } DOMParser::replaceNodeWithContent(str_replace('& ', '& ', $this->_cleanContent($sContent)), $this->_oNode); }
public static function replaceNodeContent($sContent, DOMNode $oNode) { DOMParser::emptyNodeContent($oNode); $oTMPContentDocument = new DOMDocument(); $oTMPContentDocument->loadXML('<root>' . $sContent . '</root>'); foreach ($oTMPContentDocument->firstChild->childNodes as $oChildNode) { $oInsertedNode = $oNode->ownerDocument->importNode($oChildNode, true); $oNode->appendChild($oInsertedNode); } }
protected function _render() { DOMParser::emptyNodeContent($this->_oNode); // TODO : use pubdate if member of article ! $this->_oNode->setAttribute('datetime', date(DATE_W3C, $this->datetime)); if (is_null(self::$_sLocale)) { $this->_setLocale(); } $this->_oNode->appendChild(new DOMText(strftime($this->format, $this->datetime))); }
public function render($bAdminMode = false, $sLang = null) { if ($bAdminMode && $this->_oNode->hasAttribute('data-brick-parsed')) { return false; } $this->_render($bAdminMode); if ($bAdminMode) { if (!$this->_oNode->hasAttribute('data-brick-parsed')) { $this->_oNode->setAttribute('data-brick-parsed', 'yes'); } DOMParser::addClassTo('posib-editable', $this->_oNode); } else { $this->_clean(); } return true; }
protected function _render() { $this->_bTableMode = strtolower($this->_oNode->nodeName) == 'table'; $oListElementNode = $this->_bTableMode ? $this->_oNode->getElementsByTagName('tr')->item(0) : $this->_oNode->getElementsByTagName('li')->item(0); $sCode = ''; foreach ($this->content as $iIndex => $sListElementKey) { $oClonedListElementNode = $oListElementNode->cloneNode(true); foreach (DOMParser::findBricks($oClonedListElementNode) as $oSubBrickNode) { $oSubBrickNode->setAttribute('data-brick', $this->ref . '.' . $sListElementKey . '.' . $oSubBrickNode->getAttribute('data-brick')); $oSubBrickNode->setAttribute('data-list-ref', $this->ref); $oSubBrickNode->setAttribute('data-list-index', $iIndex + 1); } DOMParser::getNodeContent($oClonedListElementNode, $sClonedListElementNodeContent); if ($this->_bTableMode) { $sCode .= '<tr>' . $sClonedListElementNodeContent . '</tr>'; } else { $sCode .= '<li>' . $sClonedListElementNodeContent . '</li>'; } unset($oClonedListElementNode, $sClonedListElementNodeContent); } DOMParser::replaceNodeContent($sCode, $this->_oNode); $this->_clean(); }
protected function _render() { DOMParser::emptyNodeContent($this->_oNode); $this->_oNode->appendChild(new DOMText(str_replace('&', '&', $this->content))); }
function handleIncludes($content = 'index.html') { global $doc; require 'classes.php'; $Cdom = new DOMParser($content, array('request' => 'include')); $includes = $Cdom->get('include', array('src', 'parts', 'id')); session_start(); $_SESSION['cookie']; debug('in handleIncludes'); while ($includes) { foreach ($includes as $include) { $Tdom = new DOMParser(pick($doc . $include['src'], 'parts.php'), array('request' => 'include')); if ($include['parts']) { foreach (explode(',', $include['parts']) as $part) { $part = trim($part); $rp = $Tdom->get("#{$part}", 'outerHTML', 'string'); $replaces = $replaces . $rp; } $Tdom = new DOMParser($replaces); } $cookie[$include['src']][pick($include['parts'], 'html')][] = '#' . $include['id']; //adapt to allow for more than one instance calling the same parts. //debug($Cdom->get('include[src='.$include['src'].']>[id]'), 'include ids'); foreach ($Cdom->get('include[src=' . $include['src'] . ']>[id]', 'id', 'array', 'outerHTML') as $el) { //debug($el, 'el'); $Tdom->set('#' . $el['id'], $el['content'], 'outerHTML'); $cookie[$include['src']][pick($include['parts'], 'html')][] = '#' . $el['id']; } $Cdom->set('include[src=' . $include['src'] . ']', $Tdom->set(), 'outerHTML', 'queue'); if (++$catch > 500) { echo "your loopy - Infinite loop alert #1!"; break; } } $Cdom->set(); $includes = $Cdom->get('include', array('src', 'parts')); if (++$catch > 500) { echo "You're loopy! - It is looping on line 54, as there is always another 'include tag'"; break; } //debug('in while'); } if ($cookie) { $_SESSION['cookie'] = $cookie; } //else echo "no cookie here"; #$scripts = array('php'=>'','css'=>'','head'=>'','foot'=>'');//debug($funcs['edit'], 'funcs[edit]');//debug($scripts, 'scripts, after first merge'); #if($_GET['edit']) $scripts =array_merge_recursive($scripts, $funcs['edit']); $scripts = array(); foreach ($_GET as $get => $truth) { //flags should be merged into same array if ($truth && ($loc = $funcs[$get]['url'])) { $funcs[$get][$loc] = $funcs[$get]['js']; $scripts = array_merge_recursive($scripts, $funcs[$get]); $scriptname .= $get; } } foreach ((array) $Cdom->get('[class^~=sr_]', array('class', 'id')) as $el) { $cs = explode('sr_', $el['class']); array_shift($cs); foreach ($cs as $c) { $c = array_shift(explode(' ', $c)); if (!$funcs[$c]) { $funcs[$c] = array('php' => "{$c}/index.php", 'css' => "{$c}/styles.css", 'head' => "", 'foot' => array("{$c}/scripts.js", "{$c}/{$c}.js")); } $scripts = array_merge_recursive($scripts, $funcs[$c]); $scriptname .= $c; } } //debug($scripts, 'scripts'); //debug($_GET, 'get'); #if(file_exists($doc."siteroller/cache/$type/$scriptname.$extension")){}else{ unset($scripts['js'], $scripts['url']); foreach ($scripts as $key => $val) { $scripts[$key] = array_unique((array) $val); } //debug($scripts, 'scripts'); foreach ((array) array_shift($scripts) as $php) { if ($php) { include $doc . "siteroller/classes/{$php}"; } } foreach ($scripts as $type => $script) { $data = ''; $extension = $type == 'head' || $type == 'foot' ? 'js' : $type; foreach ($script as $add) { $data .= file_get_contents($doc . "siteroller/classes/{$add}"); } file_put_contents($doc . "siteroller/cache/{$type}/{$scriptname}.{$extension}", $data); //debug($type, '$type');//debug($script, '$script');//debug($data, '$data'); } #} if (!$Cdom->get('head')) { } //add head if it doesn't exist; $Cdom->set('head', 'bottom', "\n\t\t<script type='text/javascript' src='siteroller/cache/head/{$scriptname}.js'></script>\n\t\t<link rel='stylesheet' type='text/css' href='siteroller/cache/css/{$scriptname}.css'/> \n\t"); //debug($Cdom->set('body', 'pickles'), 'body'); $Cdom->set('body', 'bottom', "<div class='srRemove'><script type='text/javascript' src='siteroller/cache/foot/{$scriptname}.js'></script></div>"); //ob_start('ob_gzhandler'); echo $Cdom->set(); //ob_end_flush(); }
function template($content, $src) { $cont = new DOMParser($content, $opts); foreach ($cont->get("include[src='{$src}']>div[id]", array('properties' => 'id', 'action' => 'run')) as $item) { $this->set('#' . $item['id'], $item['content'], 'queue'); } return $this->set(); }
$utils->globals->session('admin', true); } else { if ($oUsers->isRegularUser($utils->globals->post('login'), $utils->globals->post('password'))) { $utils->globals->session('connected', true); } else { $wout->redirect('/admin/connect.html?error'); } } } $wout->redirect('/admin/'); } else { $wout->redirect('/admin/connect.html'); } }); $wout->get('/admin/:page', 'admin_middleware', function ($sPageName) use($wout, $utils) { $oParser = new DOMParser($sPageName, true, $utils->globals->session('lang') ?: $utils->getDefaultLanguage()); if ($utils->globals->has('stored_data', 'session')) { $oParser->display($utils->globals->session('stored_data')); unset($_SESSION['stored_data']); } else { $oParser->display(); } die; }); $wout->get('/admin/langswitch/:lang.html', 'admin_middleware', function ($sLang) use($wout, $utils) { if (in_array($sLang, $utils->data->get(':config:lang', array()))) { $utils->globals->session('lang', $sLang); } else { $utils->globals->session('lang', $utils->getDefaultLanguage()); } $sReferer = str_replace('http://' . $utils->globals->server('http_host') . '/', '/', $utils->globals->server('http_referer'));
private function _getDefaultAddress() { DOMParser::getNodeContent($this->_oNode, $sNodeContent); return strip_tags(Utils::getInstance()->br2nl($sNodeContent)); }
protected function _render() { DOMParser::emptyNodeContent($this->_oNode); $this->_oNode->setAttribute('href', '/download/' . $this->ref . '/' . $this->file); $this->_oNode->appendChild(new DOMText(str_replace('&', '&', $this->label))); }
$wout->redirect('/' . $sDefaultLang . '/' . $sPageName); } else { $oParser = new DOMParser($sPageName); if (!$oParser->exists()) { $aSitemap = $utils->getTemplates(); $bChanges = false; foreach ($aSitemap as $sPage) { if (is_null($utils->data->get(UtilsData::SP . 'pages' . UtilsData::SP . $sPage))) { $utils->data->set(UtilsData::SP . 'pages' . UtilsData::SP . $sPage . UtilsData::SP . 'name', $sPage); $utils->data->set(UtilsData::SP . 'pages' . UtilsData::SP . $sPage . UtilsData::SP . 'template', $sPage); $bChanges = true; } } if ($bChanges) { $utils->data->save(); $oParser = new DOMParser($sPageName, false, $sLang); if (!$oParser->exists()) { return $wout->callError(404); } } else { return $wout->callError(404); } } $oParser->display(); die; } } }); $wout->get('/:lang/', function ($sLang) use($wout, $utils) { if (strlen($sLang) !== 2) { $wout->callError(404);