Browse Source

fix: recursive content and effected image module

master
Dominik Schmidt-Philipp 3 days ago
parent
commit
9727ce1ac4
3 changed files with 44 additions and 29 deletions
  1. +17
    -13
      app/modules/ceimage.php
  2. +24
    -4
      app/modules/elementdispatcher.php
  3. +3
    -12
      app/modules/filesinfolders.php

+ 17
- 13
app/modules/ceimage.php View File

public $b; public $b;
public $structs; public $structs;
public $content; public $content;
public $domains;
function __construct($request,$body=[],$structs=false,$content=false) { function __construct($request,$body=[],$structs=false,$content=false,$domains=false) {
$this->r = $request; $this->r = $request;
$this->b = $body; $this->b = $body;
$this->structs = &$structs; $this->structs = &$structs;
$this->content = &$content; $this->content = &$content;
$this->domains = &$domains;
} }
function is_width($string) { function is_width($string) {
} }
} }


// image positioning
if( in_array($request[2],array('left','right','full','auto'))) {
$class = $request[2];
} else {
$class = 'full';
}
if (isset($request[3])) {
$width=self::is_width($request[3]) ? $request[3] : false;
}

if ($image) { if ($image) {


// image positioning
if( in_array($request[2],array('left','right','full','auto'))) {
$class = $request[2];
} else {
$class = 'full';
}
if (isset($request[3])) {
$width=self::is_width($request[3]) ? $request[3] : false;
}
$gallery = "gallery"; $gallery = "gallery";
// image orientation? // image orientation?
$img = new \Image($image); $img = new \Image($image);
// $ratio = "landscape"; // $ratio = "landscape";
$ratio = ($img->width() >= $img->height()) $ratio = ($img->width() >= $img->height())
? "landscape" ? "landscape"
: "portrait" : "portrait"
."</div>", ."</div>",
$class, $class,
$ratio, $ratio,
($width ? "style=\"flex-basis:$width;\"" : ''), (isset($width) ? "style=\"flex-basis:$width;\"" : ''),
$cached->get_src(1600), $cached->get_src(1600),
$cached->get_src(1600), $cached->get_src(1600),
$cached->get_src(1600), $cached->get_src(1600),
."<div class=\"caption\">\n%s\n</div>\n" ."<div class=\"caption\">\n%s\n</div>\n"
."</div>\n", ."</div>\n",
$class, $class,
$ratio, "landscape",
$md->text(implode("\n",$body)) $md->text(implode("\n",$body))
); );
} }

+ 24
- 4
app/modules/elementdispatcher.php View File

private $folder = ""; private $folder = "";
private $config = []; private $config = [];
public $structs = null;
public $content = null;
public $domains = null;
function __construct($folder = "",$config = []) { function __construct($folder = "",$config = [],$structs=false,$content=false,$domains=false) {
if (is_string($folder)) { if (is_string($folder)) {
$this->folder = $folder; $this->folder = $folder;
} }
if (is_array($config)) { if (is_array($config)) {
$this->config = $config; $this->config = $config;
} }
$this->structs = &$structs;
$this->content = &$content;
$this->domains = &$domains;
}

function dispatch($string) {
// find occorances of {| keyword |}
$pattern = "/\{\|(.+?)\|\}/s";
$f = preg_match_all($pattern, $string,$matches,PREG_PATTERN_ORDER);

for ($i=0;$i<$f;$i++) {
$body = preg_split("/\R/",trim($matches[1][$i]));
$request = explode(":", trim(array_shift($body)));
$new = $this->content_element($request,$body);
$string = str_replace($matches[0][$i],$new,$string);
}
return $string;
} }
function content_element($request = [], $body = null) { function content_element($request = [], $body = null) {
} }
if (count($request) >= 2) { if (count($request) >= 2) {
$body=str_replace([$request[0],$request[1]],["{|","|}"],$body); $body=str_replace([$request[0],$request[1]],["{|","|}"],$body);
$body=$this->content_element($body); $body=$this->dispatch($body);
} }
$hash=md5($body); $hash=md5($body);
$add=sprintf("<div id=\"%s\" class=\"content_elment_box_body\">\n%s\n</div>", $add=sprintf("<div id=\"%s\" class=\"content_elment_box_body\">\n%s\n</div>",
$new = $checkout->html_cart(); $new = $checkout->html_cart();
break; break;
case 'image': case 'image':
$module = new CEimage($request, $body, $this->structs, $this->content); $module = new CEimage($request, $body, $this->structs, $this->content, $this->domains);
$new = $module->index(); $new = $module->index();
unset($module); unset($module);
break; break;
$counter++; $counter++;
if (count($request) >= 4) { if (count($request) >= 4) {
$part=str_replace([$request[2],$request[3]],["{|","|}"],$part); $part=str_replace([$request[2],$request[3]],["{|","|}"],$part);
$part=$this->content_element($part); $part=$this->dispatch($part);
} }
$new .= sprintf("<div>\n%s\n</div>", $new .= sprintf("<div>\n%s\n</div>",
$md->text($part) $md->text($part)

+ 3
- 12
app/modules/filesinfolders.php View File

private $folder; private $folder;
public $content = array(); public $content = array();
public $extras = array(); public $extras = array();
private $domains = array('default'=>'default'); public $domains = array('default'=>'default');
private $keyfiles = array(); private $keyfiles = array();
public $structs = array(); public $structs = array();
public $EXT=array( public $EXT=array(
} }
function content_element_dispatcher($string) { function content_element_dispatcher($string) {
$f3 = \Base::instance(); $f3 = \Base::instance();
$ED = new ElementDispatcher($this->folder,$this->config); $ED = new ElementDispatcher($this->folder,$this->config,$this->structs,$this->content,$this->domains);
$string = $ED->dispatch($string);


// find occorances of {| keyword |}
$pattern = "/\{\|(.+?)\|\}/s";
$f = preg_match_all($pattern, $string,$matches,PREG_PATTERN_ORDER);
for ($i=0;$i<$f;$i++) {
$body = preg_split("/\R/",trim($matches[1][$i]));
$request = explode(":", trim(array_shift($body)));
$new = $ED->content_element($request,$body);
$string = str_replace($matches[0][$i],$new,$string);
}
return $string; return $string;
} }

Loading…
Cancel
Save