<?php
$FUNCS->register_shortcode( 'hello', 'hello_handler' );
$FUNCS->register_shortcode( 'image_fullwidth_caption', 'image_fullwidth_caption_handler' );
$FUNCS->register_shortcode( 'image_halfwidth_caption', 'image_halfwidth_caption_handler' );
$FUNCS->register_shortcode( 'olive_header', 'olive_header_handler' );
$FUNCS->register_shortcode( 'image_left_caption', 'image_left_caption_handler' );
$FUNCS->register_shortcode( 'image_right_caption', 'image_right_caption_handler' );
$FUNCS->register_shortcode( 'break', 'break_handler' );
$FUNCS->register_shortcode( 'ifwcz', 'ifwcz_handler' );
$FUNCS->register_shortcode( 'ihwcz', 'ihwcz_handler' );
$FUNCS->register_shortcode( 'autoim', 'autoim_handler' );
$FUNCS->register_shortcode( 'imhalf', 'imhalf_handler' );
$FUNCS->register_shortcode( 'im3qtr', 'im3qtr_handler' );
$FUNCS->register_shortcode( 'imfull', 'imfull_handler' );
$FUNCS->register_shortcode( 'vborder', 'vborder_handler' );
function vborder_handler( $params, $content=null){
return '<div class="ikimbalk"><span class="ikimbalktitle">ESSAYS</span> <span class="ikimbalkdesc"><i>'.$content.'</i></span></div>';
}
function imhalf_handler( $params, $content=null ){
return class_image( 'image_halfwidth_caption', $params, $content);
}
function im3qtr_handler( $params, $content=null ){
return class_image( 'image_3qtr_caption', $params, $content);
}
function imfull_handler( $params, $content=null ){
return class_image( 'image_fullwidth_caption', $params, $content);
}
function class_image( $class, $params, $content=null ){
global $FUNCS;
$para = $FUNCS->get_named_vars(array(
'caption' => '',
'url' => ''), $params);
if (strlen($para['url']) == 0)
{
// perhaps they sent the url in the content as an image
// <img alt="" src="https://www.mysite.com/uploads/images/1.jpg" style="width: 100px; height: 127px;" />
if (preg_match("/\<img.+src=\"(.+?\.)(jpg|png|tif|tiff|jpeg)\"/i", $content, $matches))
{
$para['url'] = $matches[1] . $matches[2];
}
}
if (strlen($para['caption']) == 0)
{
if (preg_match("|\<img.+alt=\"(.+?)\"|i", $content, $matches))
{
$para['caption'] = $matches[1];
}
}
// Create a 'thumbnail' also for the large version IF the uploaded
// file is over a certain size
$maxsize = 1280; $fullsize = $para['url'];
list($width, $height, $type, $attr) = getimagesize($para['url']);
if (($width > $maxsize) or ($height > $maxsize))
{
$fullsize = "<cms:thumbnail src='".$para['url']."' width='$maxsize' height='$maxsize' enforce_max='1' />";
}
else
{
//return "got w $width h $height";
}
if ($class == 'image_halfwidth_caption')
{
$rwidth = '664';
}
elseif ($class == 'image_fullwidth_caption')
{
$rwidth = '900'; // retina resize width for display im
}
elseif ($class == 'image_3qtr_caption')
{
$rwidth = '800';
}
$html = $para['url']."<div class='$class'><a href='$fullsize' class='fbx' rel='itex' title=\"".$para['caption']."\"><img src='<cms:thumbnail src='".$para['url']."' width='$rwidth' />' alt=\"".$para['caption']."\"></a>".$para['caption']."</div>";
// Pass on the code to Couch for execution using the 'embed' function
return $FUNCS->embed( $html, $is_code=1 );
}
function autoim_handler( $params, $content=null ){
global $FUNCS;
$para = $FUNCS->get_named_vars(array(
'width' => '',
'caption' => '',
'url' => ''), $params);
if (strlen($para['url']) == 0)
{
// perhaps they sent the url in the content as an image
// <img alt="" src="https://www.mysite.com/uploads/images/1.jpg" style="width: 100px; height: 127px;" />
if (preg_match("/\<img.+src=\"(.+?\.)(jpg|png|tif|tiff|jpeg)\"/i", $content, $matches))
{
$para['url'] = $matches[1] . $matches[2];
}
}
if (strlen($para['caption']) == 0)
{
if (preg_match("|\<img.+alt=\"(.+?)\"|i", $content, $matches))
{
$para['caption'] = $matches[1];
}
}
if (strlen($para['width'] == 0))
{
if (preg_match("|\<img.+style=\"\s*width:\s*(\d+?)px;|i", $content, $matches))
{
$para['width'] = $matches[1];
}
else
{
return $content;
}
}
// Create a 'thumbnail' also for the large version IF the uploaded
// file is over a certain size
$maxsize = 1280; $fullsize = $para['url'];
list($width, $height, $type, $attr) = getimagesize($para['url']);
if (($width > $maxsize) or ($height > $maxsize))
{
$fullsize = "<cms:thumbnail src='".$para['url']."' width='$maxsize' height='$maxsize' enforce_max='1' />";
}
else
{
//return "got w $width h $height";
}
$html = "<div style='width:".$para['width']."px; margin:0 auto;'><a href='$fullsize?123' class='fbx' rel='itex' title=\"".$para['caption']."\"><img src='<cms:thumbnail src='".$para['url']."' width='".intval(2*$para['width'])."' />' style='width:".$para['width']."px; height: auto;' alt=\"".$para['caption']."\"></a>".$para['caption']."</div>";
// Pass on the code to Couch for execution using the 'embed' function
return $FUNCS->embed( $html, $is_code=1 );
}
function ifwcz_handler( $params, $content=null ){
global $FUNCS;
$para = $FUNCS->get_named_vars(array(
'url' => '',
'caption' => ''), $params);
// Create automatically resized page and full zoom version of this image
// if not already done?
return "<div class='image_fullwidth_caption'><a href='".$para['url']."' title=\"".$para['caption']."\" class='fbx'><img src='".$para['url']."' alt=\"".$para['caption']."\"></a>".$para['caption']."</div>";
}
function ihwcz_handler( $params, $content=null ){
global $FUNCS;
$para = $FUNCS->get_named_vars(array(
'url' => '',
'caption' => ''), $params);
// Create automatically resized page and full zoom version of this image
// if not already done?
return "<div class='image_halfwidth_caption'><a href='".$para['url']."' title=\"".$para['caption']."\" class='fbx'><img src='".$para['url']."' alt=\"".$para['caption']."\"></a>".$para['caption']."</div>";
}
function hello_handler( $params, $content=null ){
return '<h1>Hello from a shortcode!</h1>';
}
function image_fullwidth_caption_handler( $params, $content=null ){
global $FUNCS;
/*extract( $FUNCS->get_named_vars(array(
'caption' => ''
), $params) );*/
return '<div class="image_fullwidth_caption">'.$content.'</div>';
}
function image_halfwidth_caption_handler( $params, $content=null ){
global $FUNCS;
/*extract( $FUNCS->get_named_vars(array(
'caption' => ''
), $params) );*/
return '<div class="image_halfwidth_caption">'.$content.'</div>';
}
function break_handler( $params, $content=null ){
global $FUNCS;
return '<div class="break"></div>';
}
function image_left_caption_handler( $params, $content=null ){
global $FUNCS;
/*extract( $FUNCS->get_named_vars(array(
'caption' => ''
), $params) );*/
return '<div class="image_left_caption">'.$content.'</div>';
}
function image_right_caption_handler( $params, $content=null ){
global $FUNCS;
/*extract( $FUNCS->get_named_vars(array(
'caption' => ''
), $params) );*/
return '<div class="image_right_caption">'.$content.'</div>';
}
function olive_header_handler( $params, $content=null ){
global $FUNCS;
/*extract( $FUNCS->get_named_vars(array(
'caption' => ''
), $params) );*/
return '<div class="olive_header">'.$content.'</div>';
}