mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-04-22 10:52:09 +00:00
correction tagHandler
This commit is contained in:
parent
7ef1dda051
commit
7bd6b67ccf
@ -5,17 +5,17 @@ class Tag {
|
|||||||
private $DOM;
|
private $DOM;
|
||||||
private $doc;
|
private $doc;
|
||||||
private $debug;
|
private $debug;
|
||||||
|
|
||||||
public function __construct(DOMDocument $doc, DOMElement $DOMContent, bool $debug) {
|
public function __construct(DOMDocument $doc, DOMElement $DOMContent, bool $debug) {
|
||||||
$this->doc = $doc;
|
$this->doc = $doc;
|
||||||
$this->DOM = $DOMContent;
|
$this->DOM = $DOMContent;
|
||||||
$this->debug = $debug;
|
$this->debug = $debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDoc() {
|
public function getDoc() {
|
||||||
return $this->doc;
|
return $this->doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDOM() {
|
public function getDOM() {
|
||||||
return $this->DOM;
|
return $this->DOM;
|
||||||
}
|
}
|
||||||
@ -64,12 +64,12 @@ class Article extends Tag {
|
|||||||
|
|
||||||
$pok = $this->getDOM();
|
$pok = $this->getDOM();
|
||||||
$attr = $pok->getAttribute("column");
|
$attr = $pok->getAttribute("column");
|
||||||
|
|
||||||
$doc = $this->getDoc();
|
$doc = $this->getDoc();
|
||||||
|
|
||||||
$parent = $pok->parentNode;
|
$parent = $pok->parentNode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($attr == "content") {
|
if($attr == "content") {
|
||||||
appendHTML($pok->parentNode, $post[$attr]);
|
appendHTML($pok->parentNode, $post[$attr]);
|
||||||
@ -93,7 +93,7 @@ class Article extends Tag {
|
|||||||
*/
|
*/
|
||||||
class IsLoggedIn extends Tag {
|
class IsLoggedIn extends Tag {
|
||||||
public function render() {
|
public function render() {
|
||||||
|
|
||||||
$el = $this->getDOM();
|
$el = $this->getDOM();
|
||||||
|
|
||||||
//debugging purpose
|
//debugging purpose
|
||||||
@ -128,7 +128,7 @@ class Author extends Tag {
|
|||||||
|
|
||||||
$pok = $this->getDOM();
|
$pok = $this->getDOM();
|
||||||
$attr = $pok->getAttribute("column");
|
$attr = $pok->getAttribute("column");
|
||||||
|
|
||||||
$doc = $this->getDoc();
|
$doc = $this->getDoc();
|
||||||
|
|
||||||
$txt = $doc->createTextNode($post[$attr]);
|
$txt = $doc->createTextNode($post[$attr]);
|
||||||
@ -195,9 +195,13 @@ class Loop extends Tag {
|
|||||||
ORDER BY date DESC
|
ORDER BY date DESC
|
||||||
LIMIT 6;");
|
LIMIT 6;");
|
||||||
$posts = $query->fetchAll();
|
$posts = $query->fetchAll();
|
||||||
|
|
||||||
$parent = $el->parentNode;
|
$parent = $el->parentNode;
|
||||||
//var_dump($parent);
|
//var_dump($parent);
|
||||||
|
|
||||||
|
|
||||||
|
$limit = $limit > sizeof($posts) ? sizeof($posts) : $limit;
|
||||||
|
|
||||||
for ($i=0; $i < $limit; $i++) {
|
for ($i=0; $i < $limit; $i++) {
|
||||||
//var_dump($i);
|
//var_dump($i);
|
||||||
$pok = $el->childNodes->item(0)->cloneNode(true);
|
$pok = $el->childNodes->item(0)->cloneNode(true);
|
||||||
@ -242,7 +246,7 @@ function appendHTML(DOMNode $parent, $source) {
|
|||||||
if ($item->nodeType == XML_PI_NODE)
|
if ($item->nodeType == XML_PI_NODE)
|
||||||
$tmpDoc->removeChild($item);
|
$tmpDoc->removeChild($item);
|
||||||
$tmpDoc->encoding = 'UTF-8';
|
$tmpDoc->encoding = 'UTF-8';
|
||||||
|
|
||||||
foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) {
|
foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) {
|
||||||
$importedNode = $parent->ownerDocument->importNode($node, true);
|
$importedNode = $parent->ownerDocument->importNode($node, true);
|
||||||
$parent->appendChild($importedNode);
|
$parent->appendChild($importedNode);
|
||||||
@ -269,7 +273,7 @@ function loadTags($ctnt) {
|
|||||||
$p = file_get_contents("../html/includes/head.html");
|
$p = file_get_contents("../html/includes/head.html");
|
||||||
$t->appendXML($p);
|
$t->appendXML($p);
|
||||||
$head->item(0)->appendChild($t);
|
$head->item(0)->appendChild($t);
|
||||||
|
|
||||||
//charge et supprimme les tags
|
//charge et supprimme les tags
|
||||||
while($list->length >= 1) {
|
while($list->length >= 1) {
|
||||||
$lst = $list->item(0);
|
$lst = $list->item(0);
|
||||||
@ -277,12 +281,12 @@ function loadTags($ctnt) {
|
|||||||
$tg = new $tgs($dom, $lst, false);
|
$tg = new $tgs($dom, $lst, false);
|
||||||
|
|
||||||
$tg->render();
|
$tg->render();
|
||||||
|
|
||||||
$list[0]->parentNode->removeChild($list[0]);
|
$list[0]->parentNode->removeChild($list[0]);
|
||||||
|
|
||||||
$list = $dom->getElementsByTagName("tag");
|
$list = $dom->getElementsByTagName("tag");
|
||||||
}
|
}
|
||||||
$res = $dom->saveHTML();
|
$res = $dom->saveHTML();
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user