|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 'image': |
|
|
case 'image': |
|
|
$key=$request[1]; |
|
|
|
|
|
$image=""; |
|
|
|
|
|
// if(!$key) { |
|
|
|
|
|
// $new=self::warn("Content Module \"Image\" needs name of a file (without extension)"); |
|
|
|
|
|
// break; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
foreach($this->structs as $domain=>$destination) { |
|
|
|
|
|
if(array_key_exists($key, $this->structs[$domain]['pic'])) { |
|
|
|
|
|
$image = $this->structs[$domain]['pic'][$key]; |
|
|
|
|
|
unset($this->structs[$domain]['pic'][$key]); |
|
|
|
|
|
unset($this->content[$this->domains[$domain]][$key]); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($image) { |
|
|
|
|
|
if( in_array($request[2],array('left','right','full'))) { |
|
|
|
|
|
$class = $request[2]; |
|
|
|
|
|
} else { |
|
|
|
|
|
$class = 'full'; |
|
|
|
|
|
} |
|
|
|
|
|
$img = new \Image($image); |
|
|
|
|
|
$ratio = ($img->width() >= $img->height()) |
|
|
|
|
|
? "landscape" |
|
|
|
|
|
: "portrait" |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
$cached = new CachedImage($image); |
|
|
|
|
|
foreach ($body as $k=>$line) { |
|
|
|
|
|
if (strpos($line,"©") !== FALSE |
|
|
|
|
|
|| strpos($line,"©") !== FALSE) { |
|
|
|
|
|
$body[$k] = sprintf("<span class=\"copyright\">%s</span>",$line); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$new=sprintf("<div class='content_element_image %s'>" |
|
|
|
|
|
."<div class=\"media %s\"><a href=\"%s\" data-featherlight=\"image\"><img src=\"%s\" alt=\"user supplied image\" /></a></div>" |
|
|
|
|
|
."<img src=\"%s\" style=\"display:none;\" alt=\"user supplied image\" />" |
|
|
|
|
|
."<div class=\"caption\">%s</div>" |
|
|
|
|
|
."</div>", |
|
|
|
|
|
$class, |
|
|
|
|
|
$ratio, |
|
|
|
|
|
$cached->get_src(1600), |
|
|
|
|
|
$cached->get_src(1600), |
|
|
|
|
|
$cached->get_src(1600), |
|
|
|
|
|
$md->text(implode("\n",$body)) |
|
|
|
|
|
); |
|
|
|
|
|
} else { |
|
|
|
|
|
$new=sprintf("<div class='content_element_image %s'>\n" |
|
|
|
|
|
."<div class=\"media %s\">\n" |
|
|
|
|
|
."<div class=\"caption\">\n%s\n</div>\n" |
|
|
|
|
|
."</div>\n", |
|
|
|
|
|
$class, |
|
|
|
|
|
$ratio, |
|
|
|
|
|
$md->text(implode("\n",$body)) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$module = new CEimage($request, $body, $this->structs, $this->content); |
|
|
|
|
|
$new = $module->index(); |
|
|
|
|
|
unset($module); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 'devide': |
|
|
case 'devide': |
|
|
|
|
|
|
|
|
return sprintf("<div class=\"warning\">%s</div>",$message); |
|
|
return sprintf("<div class=\"warning\">%s</div>",$message); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CEimage |
|
|
|
|
|
{ |
|
|
|
|
|
var $r; |
|
|
|
|
|
var $b; |
|
|
|
|
|
var $structs; |
|
|
|
|
|
var $content; |
|
|
|
|
|
|
|
|
|
|
|
function __construct($request,$body=[],$structs=false,$content=false) { |
|
|
|
|
|
$this->r = $request; |
|
|
|
|
|
$this->b = $body; |
|
|
|
|
|
$this->structs = &$structs; |
|
|
|
|
|
$this->content = &$content; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function index() { |
|
|
|
|
|
$md = new \freaParsedown(); |
|
|
|
|
|
$request = $this->r; |
|
|
|
|
|
$body = $this->b; |
|
|
|
|
|
$key=$request[1]; |
|
|
|
|
|
$image=""; |
|
|
|
|
|
$new=""; |
|
|
|
|
|
|
|
|
|
|
|
// see if we can find image |
|
|
|
|
|
if ( is_file($request[1])) { |
|
|
|
|
|
$image= $request[1]; |
|
|
|
|
|
} else if ($this->structs) { |
|
|
|
|
|
foreach($this->structs as $domain=>$destination) { |
|
|
|
|
|
if(array_key_exists($key, $this->structs[$domain]['pic'])) { |
|
|
|
|
|
$image = $this->structs[$domain]['pic'][$key]; |
|
|
|
|
|
unset($this->structs[$domain]['pic'][$key]); |
|
|
|
|
|
unset($this->content[$this->domains[$domain]][$key]); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($image) { |
|
|
|
|
|
|
|
|
|
|
|
// image positioning |
|
|
|
|
|
if( in_array($request[2],array('left','right','full'))) { |
|
|
|
|
|
$class = $request[2]; |
|
|
|
|
|
} else { |
|
|
|
|
|
$class = 'full'; |
|
|
|
|
|
} |
|
|
|
|
|
if (isset($request[3])) { |
|
|
|
|
|
$gallery = 'gallery'; |
|
|
|
|
|
} else { |
|
|
|
|
|
$gallery = 'fl'; |
|
|
|
|
|
} |
|
|
|
|
|
// image orientation? |
|
|
|
|
|
$img = new \Image($image); |
|
|
|
|
|
// $ratio = "landscape"; |
|
|
|
|
|
$ratio = ($img->width() >= $img->height()) |
|
|
|
|
|
? "landscape" |
|
|
|
|
|
: "portrait" |
|
|
|
|
|
; |
|
|
|
|
|
unset($img); |
|
|
|
|
|
$cached = new CachedImage($image); |
|
|
|
|
|
|
|
|
|
|
|
// identify if caption contains a copyright note |
|
|
|
|
|
// if so, indicate with a class |
|
|
|
|
|
foreach ($body as $k=>$line) { |
|
|
|
|
|
if (strpos($line,"©") !== FALSE |
|
|
|
|
|
|| strpos($line,"©") !== FALSE) { |
|
|
|
|
|
$body[$k] = sprintf("<span class=\"copyright\">%s</span>",$line); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$new=sprintf("<div class='content_element_image %s'>" |
|
|
|
|
|
."<div class=\"media %s\"><a href=\"%s\" class=\"$gallery\"><img src=\"%s\" alt=\"user supplied image\" /></a></div>" |
|
|
|
|
|
."<img src=\"%s\" style=\"display:none;\" alt=\"user supplied image\" />" |
|
|
|
|
|
."<div class=\"caption\">%s</div>" |
|
|
|
|
|
."</div>", |
|
|
|
|
|
$class, |
|
|
|
|
|
$ratio, |
|
|
|
|
|
$cached->get_src(1600), |
|
|
|
|
|
$cached->get_src(1600), |
|
|
|
|
|
$cached->get_src(1600), |
|
|
|
|
|
$md->text(implode("\n",$body)) |
|
|
|
|
|
); |
|
|
|
|
|
unset($cached); |
|
|
|
|
|
} else { |
|
|
|
|
|
// image not found |
|
|
|
|
|
$new=sprintf("<div class='content_element_image %s'>\n" |
|
|
|
|
|
."<div class=\"media %s\">\n" |
|
|
|
|
|
."<div class=\"caption\">\n%s\n</div>\n" |
|
|
|
|
|
."</div>\n", |
|
|
|
|
|
$class, |
|
|
|
|
|
$ratio, |
|
|
|
|
|
$md->text(implode("\n",$body)) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $new; |
|
|
|
|
|
} |
|
|
|
|
|
} |