Exemplo n.º 1
0
function wikiplugin_translationof($data, $params)
{
    global $tracer;
    $smarty = TikiLib::lib('smarty');
    extract($params, EXTR_SKIP);
    $anchor_text = $orig_page;
    if (isset($translation_page) && $translation_page != '') {
        $anchor_text = $translation_page;
    }
    if (isset($orig_page)) {
        $orig_page = urlencode($orig_page);
    }
    $translation_name_arg = '';
    if (isset($translation_page)) {
        $translation_page = urlencode($translation_page);
        $translation_name_arg = "&translation_name={$translation_page}";
    }
    $translation_lang_arg = '';
    if (isset($translation_lang)) {
        $translation_lang_arg = "&target_lang={$translation_lang}";
    }
    $tracer->trace('wikiplugin_translationof', "** \$translation_lang={$translation_lang}");
    $link = 'javascript:void(0)';
    $popup_html = "<a href=\"tiki-edit_translation.php?page={$orig_page}{$translation_lang_arg}{$translation_name_arg}#new_translation\">" . tr("Translate this link") . "</a>";
    $popup_params = array('text' => $popup_html, 'sticky' => true, 'trigger' => 'mouseover');
    $smarty->loadPlugin('smarty_function_popup');
    $mouseover = ' ' . smarty_function_popup($popup_params, $smarty);
    $html = "<a href=\"tiki-index.php?page={$orig_page}\" {$mouseover}>{$anchor_text}</a>";
    return $html;
}
        ?>
,<?php 
        echo $this->_tpl_vars['user']->empl_id;
        ?>
)"<?php 
        echo $this->_tpl_vars['checkedcompl'];
        ?>
 />
        </td>
        <td style="cursor:pointer;" onclick="x_getEmplData(<?php 
        echo $this->_tpl_vars['employeelist'][$this->_sections['employee']['index']]->empl_id;
        ?>
)"
         <?php 
        if ($this->_tpl_vars['employeelist'][$this->_sections['employee']['index']]->empl_comment) {
            echo smarty_function_popup(array('text' => $this->_tpl_vars['comment'], 'caption' => $this->_tpl_vars['dict']['commentar'], 'fgcolor' => "#fafafa", 'width' => '400', 'offsety' => -70, 'offsetx' => -10, 'captionsize' => '2', 'textsize' => '2'), $this);
        }
        ?>
 class="standard<?php 
        echo $this->_tpl_vars['class'];
        ?>
"><?php 
        echo is_array($_tmp = $this->_tpl_vars['employeelist'][$this->_sections['employee']['index']]->empl_surname) ? $this->_run_mod_handler('escape', true, $_tmp, 'html') : smarty_modifier_escape($_tmp, 'html');
        ?>
, <?php 
        echo is_array($_tmp = $this->_tpl_vars['employeelist'][$this->_sections['employee']['index']]->empl_firstname) ? $this->_run_mod_handler('escape', true, $_tmp, 'html') : smarty_modifier_escape($_tmp, 'html');
        ?>
</td>
<?php 
        if ($this->_tpl_vars['employeelist'][$this->_sections['employee']['index']]->empl_position == 5) {
            ?>
Exemplo n.º 3
0
function wikiplugin_img($data, $params)
{
    global $tikidomain, $prefs, $smarty, $userlib, $user;
    $imgdata = array();
    $imgdata['src'] = '';
    $imgdata['id'] = '';
    $imgdata['fileId'] = '';
    $imgdata['randomGalleryId'] = '';
    $imgdata['galleryId'] = '';
    $imgdata['fgalId'] = '';
    $imgdata['sort_mode'] = '';
    $imgdata['attId'] = '';
    $imgdata['thumb'] = '';
    $imgdata['button'] = '';
    $imgdata['link'] = '';
    $imgdata['rel'] = '';
    $imgdata['usemap'] = '';
    $imgdata['height'] = '';
    $imgdata['width'] = '';
    $imgdata['max'] = '';
    $imgdata['imalign'] = '';
    $imgdata['styleimage'] = '';
    $imgdata['align'] = '';
    $imgdata['stylebox'] = '';
    $imgdata['styledesc'] = '';
    $imgdata['block'] = '';
    $imgdata['class'] = '';
    $imgdata['desc'] = '';
    $imgdata['title'] = '';
    $imgdata['metadata'] = '';
    $imgdata['alt'] = '';
    $imgdata['default'] = '';
    $imgdata['mandatory'] = '';
    $imgdata['fromFieldId'] = 0;
    // "private" params set by Tracker_Field_Files
    $imgdata['fromItemId'] = 0;
    // ditto
    $imgdata['checkItemPerms'] = 'y';
    // ditto
    $imgdata['noDrawIcon'] = 'n';
    $imgdata = array_merge($imgdata, $params);
    //function calls
    if (!empty($imgdata['default']) || !empty($imgdata['mandatory'])) {
        require_once 'lib/images/img_plugin_default_and_mandatory.php';
        if (!empty($imgdata['default'])) {
            $imgdata = apply_default_and_mandatory($imgdata, 'default');
            //first process defaults
            $imgdata = array_merge($imgdata, $params);
            //then apply user settings, overriding defaults
        }
        //apply mandatory settings, overriding user settings
        if (!empty($imgdata['mandatory'])) {
            $imgdata = apply_default_and_mandatory($imgdata, 'mandatory');
        }
    }
    //////////////////////////////////////////////////// Error messages and clean javascript //////////////////////////////
    // Must set at least one image identifier
    $set = !empty($imgdata['fileId']) + !empty($imgdata['id']) + !empty($imgdata['src']) + !empty($imgdata['attId']) + !empty($imgdata['randomGalleryId']) + !empty($imgdata['fgalId']);
    if ($set == 0) {
        return tra("''No image specified. One of the following parameters must be set: fileId, randomGalleryId, fgalId, attId, id.''");
    } elseif ($set > 1) {
        return tra("''Use one and only one of the following parameters: fileId, randomGalleryId, fgalId, attId, id, or src.''");
    }
    // Clean up src URLs to exclude javascript
    if (stristr(str_replace(' ', '', $imgdata['src']), 'javascript:')) {
        $imgdata['src'] = '';
    }
    if (strstr($imgdata['src'], 'javascript:')) {
        $imgdata['src'] = '';
    }
    if (!isset($data) or !$data) {
        $data = '&nbsp;';
    }
    include_once 'tiki-sefurl.php';
    //////////////////////Process multiple images //////////////////////////////////////
    //Process "|" or "," separated images
    $notice = '<!--' . tra('PluginImg: User lacks permission to view image') . '-->';
    $srcmash = $imgdata['fileId'] . $imgdata['id'] . $imgdata['attId'] . $imgdata['src'];
    if (strpos($srcmash, '|') !== false || strpos($srcmash, ',') !== false || !empty($imgdata['fgalId'])) {
        $separator = '';
        if (!empty($imgdata['id'])) {
            $id = 'id';
        } elseif (!empty($imgdata['fileId'])) {
            $id = 'fileId';
        } elseif (!empty($imgdata['attId'])) {
            $id = 'attId';
        } else {
            $id = 'src';
        }
        if (strpos($imgdata[$id], '|') !== false) {
            $separator = '|';
        } elseif (strpos($imgdata[$id], ',') !== false) {
            $separator = ',';
        }
        $repl = '';
        $id_list = array();
        if (!empty($separator)) {
            $id_list = explode($separator, $imgdata[$id]);
        } else {
            //fgalId parameter - show all images in a file gallery
            $filegallib = TikiLib::lib('filegal');
            $galdata = $filegallib->get_files(0, -1, 'created_desc', '', $imgdata['fgalId'], false, false, false, true, false, false, false, false, '', true, false, false);
            foreach ($galdata['data'] as $filedata) {
                $id_list[] = $filedata['id'];
            }
            $id = 'fileId';
        }
        $params[$id] = '';
        foreach ($id_list as $i => $value) {
            $params[$id] = trim($value);
            $params['fgalId'] = '';
            $repl .= wikiplugin_img($data, $params);
        }
        if (strpos($repl, $notice) !== false) {
            return $repl;
        } else {
            $repl = "\n\r" . '<br style="clear:both" />' . "\r" . $repl . "\n\r" . '<br style="clear:both" />' . "\r";
            return $repl;
            // return the multiple images
        }
    }
    $repl = '';
    //////////////////////Set src for html///////////////////////////////
    //Set variables for the base path for images in file galleries, image galleries and attachments
    global $base_url;
    $absolute_links = !empty(TikiLib::lib('parser')->option['absolute_links']) ? TikiLib::lib('parser')->option['absolute_links'] : false;
    $imagegalpath = ($absolute_links ? $base_url : '') . 'show_image.php?id=';
    $filegalpath = ($absolute_links ? $base_url : '') . 'tiki-download_file.php?fileId=';
    $attachpath = ($absolute_links ? $base_url : '') . 'tiki-download_wiki_attachment.php?attId=';
    //get random image and treat as file gallery image afterwards
    if (!empty($imgdata['randomGalleryId'])) {
        $filegallib = TikiLib::lib('filegal');
        $dbinfo = $filegallib->get_file(0, $imgdata['randomGalleryId']);
        $imgdata['fileId'] = $dbinfo['fileId'];
        $basepath = $prefs['fgal_use_dir'];
    }
    if (empty($imgdata['src'])) {
        if (!empty($imgdata['id'])) {
            $src = $imagegalpath . $imgdata['id'];
        } elseif (!empty($imgdata['fileId'])) {
            $smarty->loadPlugin('smarty_modifier_sefurl');
            $src = smarty_modifier_sefurl($imgdata['fileId'], 'file');
            if ($absolute_links) {
                $src = TikiLib::tikiUrl($src);
            }
        } else {
            //only attachments left
            $src = $attachpath . $imgdata['attId'];
        }
    } elseif (!empty($imgdata['src']) && $absolute_links && !preg_match('|^[a-zA-Z]+:\\/\\/|', $imgdata['src'])) {
        global $base_host, $url_path;
        $src = $base_host . ($imgdata['src'][0] == '/' ? '' : $url_path) . $imgdata['src'];
    } elseif (!empty($imgdata['src']) && $tikidomain && !preg_match('|^https?:|', $imgdata['src'])) {
        $src = preg_replace("~img/wiki_up/~", "img/wiki_up/{$tikidomain}/", $imgdata['src']);
    } elseif (!empty($imgdata['src'])) {
        $src = $imgdata['src'];
    }
    $browse_full_image = $src;
    $srcIsEditable = false;
    ///////////////////////////Get DB info for image size and metadata/////////////////////////////
    if (!empty($imgdata['height']) || !empty($imgdata['width']) || !empty($imgdata['max']) || !empty($imgdata['desc']) || strpos($imgdata['rel'], 'box') !== false || !empty($imgdata['stylebox']) || !empty($imgdata['styledesc']) || !empty($imgdata['button']) || !empty($imgdata['thumb']) || !empty($imgdata['align']) || !empty($imgdata['metadata']) || !empty($imgdata['fileId'])) {
        //Get ID numbers for images in galleries and attachments included in src as url parameter
        //So we can get db info for these too
        $parsed = parse_url($imgdata['src']);
        if (empty($parsed['host']) || !empty($parsed['host']) && strstr($base_url, $parsed['host'])) {
            if (strlen(strstr($imgdata['src'], $imagegalpath)) > 0) {
                $imgdata['id'] = substr(strstr($imgdata['src'], $imagegalpath), strlen($imagegalpath));
            } elseif (strlen(strstr($imgdata['src'], $filegalpath)) > 0) {
                $imgdata['fileId'] = substr(strstr($imgdata['src'], $filegalpath), strlen($filegalpath));
            } elseif (strlen(strstr($imgdata['src'], $attachpath)) > 0) {
                $imgdata['attId'] = substr(strstr($imgdata['src'], $attachpath), strlen($attachpath));
            }
        }
        $imageObj = '';
        require_once 'lib/images/images.php';
        //Deal with images with info in tiki databases (file and image galleries and attachments)
        if (empty($imgdata['randomGalleryId']) && (!empty($imgdata['id']) || !empty($imgdata['fileId']) || !empty($imgdata['attId']))) {
            //Try to get image from database
            if (!empty($imgdata['id'])) {
                global $imagegallib;
                include_once 'lib/imagegals/imagegallib.php';
                $dbinfo = $imagegallib->get_image_info($imgdata['id'], 'o');
                $dbinfo2 = $imagegallib->get_image($imgdata['id'], 'o');
                $dbinfo = isset($dbinfo) && isset($dbinfo2) ? array_merge($dbinfo, $dbinfo2) : array();
                $dbinfot = $imagegallib->get_image_info($imgdata['id'], 't');
                $dbinfot2 = $imagegallib->get_image($imgdata['id'], 't');
                $dbinfot = isset($dbinfot) && isset($dbinfot2) ? array_merge($dbinfot, $dbinfot2) : array();
                $basepath = $prefs['gal_use_dir'];
            } elseif (!isset($dbinfo) && !empty($imgdata['fileId'])) {
                $filegallib = TikiLib::lib('filegal');
                $dbinfo = $filegallib->get_file($imgdata['fileId']);
                $basepath = $prefs['fgal_use_dir'];
            } else {
                //only attachments left
                global $atts;
                global $wikilib;
                include_once 'lib/wiki/wikilib.php';
                $dbinfo = $wikilib->get_item_attachment($imgdata['attId']);
                $basepath = $prefs['w_use_dir'];
            }
            //Give error messages if file doesn't exist, isn't an image. Display nothing if user lacks permission
            if (!empty($imgdata['fileId']) || !empty($imgdata['id']) || !empty($imgdata['attId'])) {
                if (!$dbinfo) {
                    return '^' . tra('File not found.') . '^';
                } elseif (substr($dbinfo['filetype'], 0, 5) != 'image' and !preg_match('/thumbnail/i', $imgdata['fileId'])) {
                    return '^' . tra('File is not an image.') . '^';
                } elseif (!class_exists('Image')) {
                    return '^' . tra('Server does not support image manipulation.') . '^';
                } elseif (!empty($imgdata['fileId'])) {
                    if (!$userlib->user_has_perm_on_object($user, $dbinfo['galleryId'], 'file gallery', 'tiki_p_download_files')) {
                        return $notice;
                    }
                } elseif (!empty($imgdata['id'])) {
                    if (!$userlib->user_has_perm_on_object($user, $dbinfo['galleryId'], 'image gallery', 'tiki_p_view_image_gallery')) {
                        return $notice;
                    }
                } elseif (!empty($imgdata['attId'])) {
                    if (!$userlib->user_has_perm_on_object($user, $dbinfo['page'], 'wiki page', 'tiki_p_wiki_view_attachments')) {
                        return $notice;
                    }
                }
            }
        }
        //finished getting info from db for images in image or file galleries or attachments
        //get image to get height and width and iptc data
        if (!empty($dbinfo['data'])) {
            $imageObj = new Image($dbinfo['data'], false);
            $filename = $dbinfo['filename'];
        } elseif (!empty($dbinfo['path'])) {
            $imageObj = new Image($basepath . $dbinfo['path'], true);
            $filename = $dbinfo['filename'];
        } else {
            $imageObj = new Image($src, true);
            $filename = $src;
        }
        //if we need metadata
        $xmpview = !empty($imgdata['metadata']) ? true : false;
        if ($imgdata['desc'] == 'idesc' || $imgdata['desc'] == 'ititle' || $xmpview) {
            $dbinfoparam = isset($dbinfo) ? $dbinfo : false;
            $metadata = getMetadataArray($imageObj, $dbinfoparam);
            if ($imgdata['desc'] == 'idesc') {
                $idesc = getMetaField($metadata, array('User Data' => 'Description'));
            }
            if ($imgdata['desc'] == 'ititle') {
                $ititle = getMetaField($metadata, array('User Data' => 'Title'));
            }
        }
        $fwidth = '';
        $fheight = '';
        if (isset(TikiLib::lib('parser')->option['indexing']) && TikiLib::lib('parser')->option['indexing']) {
            $fwidth = 1;
            $fheight = 1;
        } else {
            $fwidth = $imageObj->get_width();
            $fheight = $imageObj->get_height();
        }
        //get image gal thumbnail image for height and width
        if (!empty($dbinfot['data']) || !empty($dbinfot['path'])) {
            if (!empty($dbinfot['data'])) {
                $imageObjt = new Image($dbinfot['data'], false);
            } elseif (!empty($dbinfot['path'])) {
                $imageObjt = new Image($basepath . $dbinfot['path'] . '.thumb', true);
            }
            $fwidtht = $imageObjt->get_width();
            $fheightt = $imageObjt->get_height();
        }
        /////////////////////////////////////Add image dimensions to src string////////////////////////////////////////////
        //Use url resizing parameters for file gallery images to set $height and $width
        //since they can affect other elements; overrides plugin parameters
        if (!empty($imgdata['fileId']) && strpos($src, '&') !== false) {
            $urlthumb = strpos($src, '&thumbnail');
            $urlprev = strpos($src, '&preview');
            $urldisp = strpos($src, '&display');
            preg_match('/(?<=\\&max=)[0-9]+(?=.*)/', $src, $urlmax);
            preg_match('/(?<=\\&x=)[0-9]+(?=.*)/', $src, $urlx);
            preg_match('/(?<=\\&y=)[0-9]+(?=.*)/', $src, $urly);
            preg_match('/(?<=\\&scale=)[0]*\\.[0-9]+(?=.*)/', $src, $urlscale);
            if (!empty($urlmax[0]) && $urlmax[0] > 0) {
                $imgdata['max'] = $urlmax[0];
            }
            if (!empty($urlx[0]) && $urlx[0] > 0) {
                $imgdata['width'] = $urlx[0];
            }
            if (!empty($urly[0]) && $urly[0] > 0) {
                $imgdata['height'] = $urly[0];
            }
            if (!empty($urlscale[0]) && $urlscale[0] > 0) {
                $height = floor($urlscale[0] * $fheight);
                $width = floor($urlscale[0] * $fwidth);
                $imgdata['width'] = '';
                $imgdata['height'] = '';
            }
            if ($urlthumb != false && empty($imgdata['height']) && empty($imgdata['width']) && empty($imgdata['max'])) {
                $imgdata['max'] = 120;
            }
            if ($urlprev != false && empty($urlscale[0]) && empty($imgdata['height']) && empty($imgdata['width']) && empty($imgdata['max'])) {
                $imgdata['max'] = 800;
            }
        }
        //Note if image gal url thumb parameter is used
        $imgalthumb = false;
        if (!empty($imgdata['id'])) {
            preg_match('/(?<=\\&thumb=1)[0-9]+(?=.*)/', $src, $urlimthumb);
            if (!empty($urlimthumb[0]) && $urlimthumb[0] > 0) {
                $imgalthumb = true;
            }
        }
        include_once 'lib/mime/mimetypes.php';
        global $mimetypes;
        //Now set dimensions based on plugin parameter settings
        if (!empty($imgdata['max']) || !empty($imgdata['height']) || !empty($imgdata['width']) || !empty($imgdata['thumb'])) {
            // find svg image size
            if (!empty($dbinfo['filetype']) && !empty($mimetypes['svg']) && $dbinfo['filetype'] == $mimetypes['svg']) {
                if (preg_match('/width="(\\d+)" height="(\\d+)"/', $dbinfo['data'], $svgdim)) {
                    $fwidth = $svgdim[1];
                    $fheight = $svgdim[2];
                }
            }
            //Convert % and px in height and width
            $scale = '';
            if (strpos($imgdata['height'], '%') !== false || strpos($imgdata['width'], '%') !== false) {
                if (strpos($imgdata['height'], '%') !== false && strpos($imgdata['width'], '%') !== false && (empty($imgdata['fileId']) || empty($urlx[0]) && empty($urly[0]))) {
                    $imgdata['height'] = floor(rtrim($imgdata['height'], '%') / 100 * $fheight);
                    $imgdata['width'] = floor(rtrim($imgdata['width'], '%') / 100 * $fwidth);
                } elseif (strpos($imgdata['height'], '%') !== false) {
                    if ($imgdata['fileId']) {
                        $scale = rtrim($imgdata['height'], '%') / 100;
                        $height = floor($scale * $fheight);
                    } else {
                        $imgdata['height'] = floor(rtrim($imgdata['height'], '%') / 100 * $fheight);
                    }
                } else {
                    if ($imgdata['fileId']) {
                        $scale = rtrim($imgdata['width'], '%') / 100;
                        $width = floor($scale * $fwidth);
                    } else {
                        $imgdata['width'] = floor(rtrim($imgdata['width'], '%') / 100 * $fwidth);
                    }
                }
            } elseif (strpos($imgdata['height'], 'px') !== false || strpos($imgdata['width'], 'px') !== false) {
                if (strpos($imgdata['height'], 'px') !== false) {
                    $imgdata['height'] = rtrim($imgdata['height'], 'px');
                } else {
                    $imgdata['width'] = rtrim($imgdata['width'], 'px');
                }
            }
            // Adjust for max setting, keeping aspect ratio
            if (!empty($imgdata['max'])) {
                if ($fwidth > $imgdata['max'] || $fheight > $imgdata['max']) {
                    //use image gal thumbs when possible
                    if (!empty($imgdata['id']) && $imgalthumb == false && ($imgdata['max'] < $fwidtht || $imgdata['max'] < $fheightt)) {
                        $src .= '&thumb=1';
                        $imgalthumb == true;
                    }
                    if ($fwidth > $fheight) {
                        $width = $imgdata['max'];
                        $height = floor($width * $fheight / $fwidth);
                    } else {
                        $height = $imgdata['max'];
                        $width = floor($height * $fwidth / $fheight);
                    }
                    //cases where max is set but image is smaller than max
                } else {
                    $height = $fheight;
                    $width = $fwidth;
                }
                // Adjust for user settings for height and width if max isn't set.
            } elseif (!empty($imgdata['height'])) {
                //use image gal thumbs when possible
                if (!empty($imgdata['id']) && $imgalthumb == false && $imgdata['height'] < $fheightt) {
                    $src .= '&thumb=1';
                    $imgalthumb == true;
                }
                $height = $imgdata['height'];
                if (empty($imgdata['width']) && $fheight > 0) {
                    $width = floor($height * $fwidth / $fheight);
                } else {
                    $width = $imgdata['width'];
                }
            } elseif (!empty($imgdata['width'])) {
                //use image gal thumbs when possible
                if (!empty($imgdata['id']) && $imgalthumb == false && $imgdata['width'] < $fwidtht) {
                    $src .= '&thumb=1';
                    $imgalthumb == true;
                }
                $width = $imgdata['width'];
                if (empty($imgdata['height']) && $fwidth > 0) {
                    $height = floor($width * $fheight / $fwidth);
                } else {
                    $height = $imgdata['height'];
                }
                // If not otherwise set, use default setting for thumbnail height if thumb is set
            } elseif ((!empty($imgdata['thumb']) || !empty($urlthumb)) && empty($scale)) {
                if (!empty($imgdata['fileId'])) {
                    $thumbdef = $prefs['fgal_thumb_max_size'];
                } else {
                    $thumbdef = 84;
                }
                //handle image gal thumbs
                if (!empty($imgdata['id']) && !empty($fwidtht) && !empty($fheightt)) {
                    $width = $fwidtht;
                    $height = $fheightt;
                    if ($imgalthumb == false) {
                        $src .= '&thumb=1';
                        $imgalthumb == true;
                    }
                } else {
                    if ($fwidth > $thumbdef || $fheight > $thumbdef) {
                        if ($fwidth > $fheight) {
                            $width = $thumbdef;
                            $height = floor($width * $fheight / $fwidth);
                        } else {
                            $height = $thumbdef;
                            $width = floor($height * $fwidth / $fheight);
                        }
                    }
                }
            }
        }
        //Set final height and width dimension string
        //handle file gallery images separately to use server-side resizing capabilities
        $imgdata_dim = '';
        if (!empty($imgdata['fileId'])) {
            if (empty($urldisp) && empty($urlthumb)) {
                $srcIsEditable = true;
                $src .= '&display';
            }
            if (!empty($scale) && empty($urlscale[0])) {
                $src .= '&scale=' . $scale;
            } elseif (!empty($imgdata['max']) && $imgdata['thumb'] != 'download' && (empty($urlthumb) && empty($urlmax[0]) && empty($urlprev))) {
                $src .= '&max=' . $imgdata['max'];
                $imgdata_dim .= ' width="' . $width . '"';
                $imgdata_dim .= ' height="' . $height . '"';
            } elseif (!empty($width) || !empty($height)) {
                if (!empty($width) && !empty($height) && (empty($urlx[0]) && empty($urly[0]) && empty($urlscale[0]))) {
                    $src .= '&x=' . $width . '&y=' . $height;
                    $imgdata_dim .= ' width="' . $width . '"';
                    $imgdata_dim .= ' height="' . $height . '"';
                } elseif (!empty($width) && (empty($urlx[0]) && empty($urlthumb) && empty($urlscale[0]))) {
                    $src .= '&x=' . $width;
                    $height = $fheight;
                    $imgdata_dim .= ' width="' . $width . '"';
                    $imgdata_dim .= ' height="' . $height . '"';
                } elseif (!empty($height) && (empty($urly[0]) && empty($urlthumb) && empty($urlscale[0]))) {
                    $src .= '&y=' . $height;
                    $imgdata_dim = '';
                    $width = $fwidth;
                }
            } else {
                $imgdata_dim = '';
                $height = $fheight;
                $width = $fwidth;
                if (!empty($width) && !empty($height)) {
                    $imgdata_dim .= ' width="' . $width . '"';
                    $imgdata_dim .= ' height="' . $height . '"';
                }
            }
        } else {
            if (!empty($height)) {
                $imgdata_dim = ' height="' . $height . '"';
            } else {
                $imgdata_dim = '';
                $height = $fheight;
            }
            if (!empty($width)) {
                $imgdata_dim .= ' width="' . $width . '"';
            } else {
                $imgdata_dim = '';
                $width = $fwidth;
            }
        }
    }
    ////////////////////////////////////////// Create the HTML img tag //////////////////////////////////////////////
    //Start tag with src and dimensions
    $src = filter_out_sefurl($src);
    $tagName = '';
    if (!empty($dbinfo['filetype']) && !empty($mimetypes['svg']) && $dbinfo['filetype'] == $mimetypes['svg']) {
        $tagName = 'div';
        $repldata = $dbinfo['data'];
        if (!empty($fwidth) && !empty($fheight) && !empty($imgdata_dim)) {
            // change svg attributes to show at the correct size
            $svgAttributes = $imgdata_dim . ' viewBox="0 0 ' . $fwidth . ' ' . $fheight . '" preserveAspectRatio="xMinYMin meet"';
            $repldata = preg_replace('/width="' . $fwidth . '" height="' . $fheight . '"/', $svgAttributes, $repldata);
        }
        $replimg = '<div type="image/svg+xml" ';
        $imgdata['class'] .= ' svgImage pluginImg' . $imgdata['fileId'];
        $imgdata['class'] = trim($imgdata['class']);
    } else {
        $tagName = 'img';
        $replimg = '<img src="' . $src . '" ';
        $imgdata['class'] .= ' regImage pluginImg' . $imgdata['fileId'];
        $imgdata['class'] = trim($imgdata['class']);
    }
    if (!empty($imgdata_dim)) {
        $replimg .= $imgdata_dim;
    }
    //Create style attribute allowing for shortcut inputs
    //First set alignment string
    $center = 'display:block; margin-left:auto; margin-right:auto;';
    //used to center image and box
    if (!empty($imgdata['imalign'])) {
        $imalign = '';
        if ($imgdata['imalign'] == 'center') {
            $imalign = $center;
        } else {
            $imalign = 'float:' . $imgdata['imalign'] . ';';
        }
    } elseif ($imgdata['stylebox'] == 'border') {
        $imalign = $center;
    }
    //set entire style string
    if (!empty($imgdata['styleimage']) || !empty($imalign)) {
        $border = '';
        $style = '';
        $borderdef = 'border:1px solid darkgray;';
        //default border when styleimage set to border
        if (!empty($imgdata['styleimage'])) {
            if (!empty($imalign)) {
                if (strpos(trim($imgdata['styleimage'], ' '), 'float:') !== false || strpos(trim($imgdata['styleimage'], ' '), 'display:') !== false) {
                    $imalign = '';
                    //override imalign setting if style image contains alignment syntax
                }
            }
            if ($imgdata['styleimage'] == 'border') {
                $border = $borderdef;
            } else {
                if (strpos($imgdata['styleimage'], 'hidden') === false && strpos($imgdata['styleimage'], 'position') === false) {
                    // quick filter for dangerous styles
                    $style = $imgdata['styleimage'];
                }
            }
        }
        $replimg .= ' style="' . $imalign . $border . $style . '"';
    }
    //alt
    if (!empty($imgdata['alt'])) {
        $replimg .= ' alt="' . $imgdata['alt'] . '"';
    } elseif (!empty($imgdata['desc'])) {
        $replimg .= ' alt="' . $imgdata['desc'] . '"';
    } elseif (!empty($dbinfo['description'])) {
        $replimg .= ' alt="' . $dbinfo['description'] . '"';
    } else {
        $replimg .= ' alt="Image"';
    }
    //usemap
    if (!empty($imgdata['usemap'])) {
        $replimg .= ' usemap="#' . $imgdata['usemap'] . '"';
    }
    //class
    if (!empty($imgdata['class'])) {
        $replimg .= ' class="' . $imgdata['class'] . '"';
    }
    //title (also used for description and link title below)
    //first set description, which is used for title if no title is set
    if (!empty($imgdata['desc']) || !empty($imgdata['title'])) {
        $desc = '';
        $imgname = '';
        $desconly = '';
        if (!empty($imgdata['desc'])) {
            //attachment database uses comment instead of description or name
            if (!empty($dbinfo['comment'])) {
                $desc = $dbinfo['comment'];
                $imgname = $dbinfo['comment'];
            } elseif (isset($dbinfo)) {
                $desc = !empty($dbinfo['description']) ? $dbinfo['description'] : '';
                $imgname = !empty($dbinfo['name']) ? $dbinfo['name'] : '';
            }
            switch ($imgdata['desc']) {
                case 'desc':
                    $desconly = $desc;
                    break;
                case 'idesc':
                    $desconly = $idesc;
                    break;
                case 'name':
                    $desconly = $imgname;
                    break;
                case 'ititle':
                    $desconly = $ititle;
                    break;
                case 'namedesc':
                    $desconly = $imgname . (!empty($imgname) && !empty($desc) ? ' - ' : '') . $desc;
                    break;
                default:
                    $desconly = $imgdata['desc'];
            }
        }
        //now set title
        $imgtitle = '';
        $titleonly = '';
        if (!empty($imgdata['title']) || !empty($desconly)) {
            $imgtitle = ' title="';
            if (!empty($imgdata['title'])) {
                switch ($imgdata['title']) {
                    case 'desc':
                        $titleonly = $desc;
                        break;
                    case 'name':
                        $titleonly = $imgname;
                        break;
                    case 'namedesc':
                        $titleonly = $imgname . (!empty($imgname) && !empty($desc) ? ' - ' : '') . $desc;
                        break;
                    default:
                        $titleonly = $imgdata['title'];
                }
                //use desc setting for title if title is empty
            } else {
                $titleonly = $desconly;
            }
            $imgtitle .= $titleonly . '"';
            $replimg .= $imgtitle;
        }
    }
    if (empty($repldata)) {
        $replimg .= ' />' . "\r";
    } else {
        $replimg .= '>' . $repldata . '</' . $tagName . '>';
    }
    ////////////////////////////////////////// Create the HTML link ///////////////////////////////////////////
    //Variable for identifying if javascript mouseover is set
    if ($imgdata['thumb'] == 'mouseover' || $imgdata['thumb'] == 'mousesticky') {
        $javaset = 'true';
    } else {
        $javaset = '';
    }
    // Set link to user setting or to image itself if thumb is set
    if (!empty($imgdata['link']) || !empty($imgdata['thumb']) && !(isset($params['link']) && empty($params['link']))) {
        $mouseover = '';
        if (!empty($imgdata['link'])) {
            $link = $imgdata['link'];
        } elseif (($imgdata['thumb'] == 'browse' || $imgdata['thumb'] == 'browsepopup') && !empty($imgdata['id'])) {
            $link = 'tiki-browse_image.php?imageId=' . $imgdata['id'];
        } elseif ($javaset == 'true') {
            $link = 'javascript:void(0)';
            $popup_params = array('text' => $data, 'width' => $fwidth, 'height' => $fheight, 'background' => $browse_full_image);
            if ($imgdata['thumb'] == 'mousesticky') {
                $popup_params['sticky'] = true;
            }
            $smarty->loadPlugin('smarty_function_popup');
            $mouseover = ' ' . smarty_function_popup($popup_params, $smarty);
        } else {
            if (!empty($imgdata['fileId']) && $imgdata['thumb'] != 'download' && empty($urldisp)) {
                $link = $browse_full_image . '&display';
            } else {
                $link = $browse_full_image;
            }
        }
        if ($imgdata['thumb'] == 'box' && empty($imgdata['rel'])) {
            $imgdata['rel'] = 'box';
        }
        // Set other link-related attributes
        // target
        $imgtarget = '';
        if ($prefs['popupLinks'] == 'y' && (preg_match('#^([a-z0-9]+?)://#i', $link) || preg_match('#^www\\.([a-z0-9\\-]+)\\.#i', $link)) || $imgdata['thumb'] == 'popup' || $imgdata['thumb'] == 'browsepopup') {
            if (!empty($javaset) || $imgdata['rel'] == 'box') {
                $imgtarget = '';
            } else {
                $imgtarget = ' target="_blank"';
            }
        }
        // rel
        !empty($imgdata['rel']) ? $linkrel = ' rel="' . $imgdata['rel'] . '"' : ($linkrel = '');
        // title
        !empty($imgtitle) ? $linktitle = $imgtitle : ($linktitle = '');
        $link = filter_out_sefurl($link);
        //Final link string
        $replimg = "\r\t" . '<a href="' . $link . '" class="internal"' . $linkrel . $imgtarget . $linktitle . $mouseover . '>' . "\r\t\t" . $replimg . "\r\t" . '</a>';
    }
    //Add link string to rest of string
    $repl .= $replimg;
    //////////////////////////Generate metadata dialog box and jquery (dialog icon added in next section)////////////////////////////////////
    if ($imgdata['metadata'] == 'view') {
        //create unique id's in case of multiple pictures
        static $lastval = 0;
        $id_meta = 'imgdialog-' . ++$lastval;
        $id_link = $id_meta . '-link';
        //use metadata stored in file gallery db if available
        include_once 'lib/metadata/metadatalib.php';
        $meta = new FileMetadata();
        $dialog = $meta->dialogTabs($metadata, $id_meta, $id_link, $filename);
        $repl .= $dialog;
    }
    //////////////////////  Create enlarge button, metadata icon, description and their divs////////////////////
    //Start div that goes around button and description if these are set
    if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['styledesc']) || !empty($imgdata['metadata'])) {
        //To set room for enlarge button under image if there is no description
        $descheightdef = 'height:17px;clear:left;';
        $repl .= "\r\t" . '<div class="mini" style="width:' . $width . 'px;';
        if (!empty($imgdata['styledesc'])) {
            if ($imgdata['styledesc'] == 'left' || $imgdata['styledesc'] == 'right') {
                $repl .= 'text-align:' . $imgdata['styledesc'] . '">';
            } else {
                $repl .= $imgdata['styledesc'] . '">';
            }
        } elseif (!empty($imgdata['button']) && empty($desconly)) {
            $repl .= $descheightdef . '">';
        } else {
            $repl .= '">';
        }
        //Start description div that also includes enlarge button div
        $repl .= "\r\t\t" . '<div class="thumbcaption">';
        //Enlarge button div and link string (innermost div)
        if (!empty($imgdata['button'])) {
            if (empty($link) || !empty($link) && !empty($javaset)) {
                if (($imgdata['button'] == 'browse' || $imgdata['button'] == 'browsepopup') && !empty($imgdata['id'])) {
                    $link_button = 'tiki-browse_image.php?imageId=' . $imgdata['id'];
                } else {
                    if (!empty($imgdata['fileId']) && $imgdata['button'] != 'download') {
                        $link_button = $browse_full_image . '&display';
                    } elseif (!empty($imgdata['attId']) && $imgdata['thumb'] == 'download') {
                        $link = $browse_full_image . '&download=y';
                    } else {
                        $link_button = $browse_full_image;
                    }
                }
            } else {
                $link_button = $link;
            }
            //Set button rel
            !empty($imgdata['rel']) ? $linkrel_button = ' rel="' . $imgdata['rel'] . '"' : ($linkrel_button = '');
            //Set button target
            if (empty($imgtarget) && (empty($imgdata['thumb']) || !empty($javaset))) {
                if ($imgdata['button'] == 'popup' || $imgdata['button'] == 'browsepopup') {
                    $imgtarget_button = ' target="_blank"';
                } else {
                    $imgtarget_button = '';
                }
            } else {
                $imgtarget_button = $imgtarget;
            }
            $repl .= "\r\t\t\t" . '<div class="magnify" style="float:right">';
            $repl .= "\r\t\t\t\t" . '<a href="' . $link_button . '"' . $linkrel_button . $imgtarget_button;
            $repl .= ' class="internal"';
            if (!empty($titleonly)) {
                $repl .= ' title="' . $titleonly . '"';
            }
            $repl .= ">\r\t\t\t\t" . '<img class="magnify" src="./img/icons/magnifier.png" alt="' . tra('Enlarge') . '" /></a>' . "\r\t\t\t</div>";
        }
        //Add metadata icon
        if ($imgdata['metadata'] == 'view') {
            $repl .= '<div style="float:right; margin-right:2px"><a href="#" id="' . $id_link . '"><img src="./img/icons/tag_orange.png" alt="' . tra('Metadata') . '" title="' . tra('Metadata') . '"/></a></div>';
        }
        //Add description based on user setting (use $desconly from above) and close divs
        isset($desconly) ? $repl .= $desconly : '';
        $repl .= "\r\t\t</div>";
        $repl .= "\r\t</div>";
    }
    ///////////////////////////////Wrap in overall div that includes image if needed////////////////
    //Need a box if any of these are set
    if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['metadata']) || !empty($imgdata['stylebox']) || !empty($imgdata['align'])) {
        //Make the div surrounding the image 2 pixels bigger than the image
        if (empty($height)) {
            $height = '';
        }
        if (empty($width)) {
            $width = '';
        }
        $boxwidth = $width + 2;
        $boxheight = $height + 2;
        $alignbox = '';
        $class = '';
        if (!empty($imgdata['align'])) {
            if ($imgdata['align'] == 'center') {
                $alignbox = $center;
            } else {
                $alignbox = 'float:' . $imgdata['align'] . '; margin-' . ($imgdata['align'] == 'left' ? 'right' : 'left') . ':5px;';
            }
        }
        //first set stylebox string if style box is set
        if (!empty($imgdata['stylebox']) || !empty($imgdata['align'])) {
            //create strings from shortcuts first
            if (!empty($imgdata['stylebox'])) {
                if ($imgdata['stylebox'] == 'border') {
                    $class = 'class="imgbox" ';
                    if (!empty($alignbox)) {
                        if (strpos(trim($imgdata['stylebox'], ' '), 'float:') !== false || strpos(trim($imgdata['stylebox'], ' '), 'display:') !== false) {
                            $alignbox = '';
                            //override align setting if stylebox contains alignment syntax
                        }
                    }
                } else {
                    $styleboxinit = $imgdata['stylebox'] . ';';
                }
            }
            if (empty($imgdata['button']) && empty($imgdata['desc']) && empty($styleboxinit)) {
                $styleboxplus = $alignbox . ' width:' . $boxwidth . 'px; height:' . $boxheight . 'px';
            } elseif (!empty($styleboxinit)) {
                if (strpos(trim($imgdata['stylebox'], ' '), 'height:') === false && strpos(trim($imgdata['stylebox'], ' '), 'width:') === false) {
                    $styleboxplus = $styleboxinit . ' width:' . $boxwidth . 'px;';
                } else {
                    $styleboxplus = $styleboxinit;
                }
            } else {
                $styleboxplus = $alignbox . ' width:' . $boxwidth . 'px;';
            }
        } elseif (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['metadata'])) {
            $styleboxplus = ' width:' . $boxwidth . 'px;';
        }
    }
    if (!empty($styleboxplus)) {
        $repl = "\r" . '<div ' . $class . 'style="' . $styleboxplus . '">' . $repl . "\r" . '</div>';
    }
    //////////////////////////////////////Place 'clear' block///////////////////////////////////////////////////////////
    if (!empty($imgdata['block'])) {
        switch ($imgdata['block']) {
            case 'top':
                $repl = "\n\r<br style=\"clear:both\" />\r" . $repl;
                break;
            case 'bottom':
                $repl = $repl . "\n\r<br style=\"clear:both\" />\r";
                break;
            case 'both':
                $repl = "\n\r<br style=\"clear:both\" />\r" . $repl . "\n\r<br style=\"clear:both\" />\r";
                break;
            case 'top':
                break;
        }
    }
    // Mobile
    if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') {
        $repl = '{img src=' . $src . "\"}\n<p>" . $imgdata['desc'] . '</p>';
    }
    if (!TikiLib::lib('parser')->option['suppress_icons'] && $prefs['feature_draw'] == 'y' && !empty($dbinfo['galleryId']) && $imgdata['noDrawIcon'] !== 'y') {
        global $tiki_p_edit;
        $globalperms = Perms::get(array('type' => 'file gallery', 'object' => $dbinfo['galleryId']));
        if ($imgdata['fromItemId']) {
            if ($imgdata['checkItemPerms'] !== 'n') {
                $perms_Accessor = Perms::get(array('type' => 'tracker item', 'object' => $imgdata['fromItemId']));
                $trackerItemPerms = $perms_Accessor->modify_tracker_items;
            } else {
                $trackerItemPerms = true;
            }
        } else {
            $trackerItemPerms = false;
        }
        if ($globalperms->upload_files == 'y' && (empty($src) == true || $srcIsEditable == true) && ($tiki_p_edit == 'y' || $trackerItemPerms)) {
            if ($prefs['wiki_edit_icons_toggle'] == 'y' && !isset($_COOKIE['wiki_plugin_edit_view']) && !$imgdata['fromItemId']) {
                $iconDisplayStyle = " style=\"display:none;\"";
            } else {
                $iconDisplayStyle = '';
            }
            $jsonParams = json_encode(array_filter($imgdata));
            $repl .= "<a href=\"tiki-edit_draw.php?fileId={$imgdata['fileId']}\" onclick=\"return \$(this).ajaxEditDraw();\" title=\"" . tr("Draw on the Image") . "\"" . " class=\"editplugin pluginImgEdit{$imgdata['fileId']}\" data-fileid=\"{$imgdata['fileId']}\" " . "data-galleryid=\"{$dbinfo['galleryId']}\"{$iconDisplayStyle} data-imgparams='{$jsonParams}'>" . "<img width='16' height='16' class='icon' alt='Edit' src='img/icons/page_edit.png' /></a>";
        }
    }
    return '~np~' . $repl . "\r" . '~/np~';
}
    ?>
></a>
	<?php 
    if ($this->_tpl_vars['itemstatistic']) {
        ?>

		<a href="/admin.php?mode=<?php 
        echo $_GET['mode'];
        ?>
"><font onmouseover="test.style.display='none';test2.style.display='';" onmouseout="test.style.display='';test2.style.display='none';">
			<img id="test" src="/templates/admin/images/eco.png" alt=" статистика " <?php 
        echo smarty_function_popup(array('text' => $this->_tpl_vars['itemstatistic'], 'fgcolor' => "#2f2f2f", 'caption' => "&nbsp;&nbsp;&#123; статистика &#125;", 'noclose' => true, 'sticky' => false, 'bgcolor' => '2f2f2f', 'width' => 200), $this);
        ?>
>
			<img id="test2" style="display:none;" src="/templates/admin/images/stat_active.png" alt=" статистика " <?php 
        echo smarty_function_popup(array('text' => $this->_tpl_vars['itemstatistic'], 'fgcolor' => "#2f2f2f", 'caption' => "&nbsp;&nbsp;&#123; статистика &#125;", 'noclose' => true, 'sticky' => false, 'bgcolor' => '2f2f2f', 'width' => 200), $this);
        ?>
>
		</font></a>
		<?php 
    }
    ?>

		<br/>
<?php 
}
?>

</center>
</td>
<tr>
Exemplo n.º 5
0
$smarty->loadPlugin('smarty_function_popup');
$smarty->loadPlugin('smarty_function_permission_link');
foreach ($categories as $category) {
    $perms = Perms::get(array('type' => 'category', 'object' => $category['categId']));
    if ($perms->admin_categories == 'y') {
        $data = '<a href="tiki-admin_categories.php?parentId=' . $category['parentId'] . '&amp;categId=' . $category['categId'] . '">' . smarty_function_icon(array('name' => 'edit', '_menu_text' => 'y', '_menu_icon' => 'y', 'alt' => tra('Edit')), $smarty) . '</a>';
        $data .= '<a href="tiki-admin_categories.php?parentId=' . $category['parentId'] . '&amp;removeCat=' . $category['categId'] . '">' . smarty_function_icon(array('name' => 'remove', '_menu_text' => 'y', '_menu_icon' => 'y', 'alt' => tra('Delete')), $smarty) . '</a>';
        if ($userlib->object_has_one_permission($category['categId'], 'category')) {
            $title = tra('Edit permissions for this category');
        } else {
            $title = tra('Assign permissions');
        }
        $data .= smarty_function_permission_link(['id' => $category['categId'], 'type' => 'category', 'mode' => 'text'], $smarty);
        $escapeddata = htmlspecialchars(strtr($data, array("\\" => "\\\\", "'" => "\\'", "\"" => "\\\"", "\r" => "\\r", "\n" => "\\n", "</" => "<\\/")), ENT_QUOTES, 'UTF-8', true);
        $popupparams = ['trigger' => 'click', 'fullhtml' => 1, 'center' => true, 'text' => $escapeddata];
        $newdata = '<a class="tips" title="' . tra('Actions') . '" href="#" ' . smarty_function_popup($popupparams, $smarty) . 'style="padding:0; margin:0; border:0">' . smarty_function_icon(['name' => 'wrench'], $smarty) . '</a>';
        $catlink = '<a class="catname" href="tiki-admin_categories.php?parentId=' . $category["categId"] . '" style="margin-left:5px">' . htmlspecialchars($category['name']) . '</a> ';
        $treeNodes[] = array('id' => $category['categId'], 'parent' => $category['parentId'], 'data' => $newdata . $catlink);
    }
}
include_once 'lib/tree/BrowseTreeMaker.php';
$treeMaker = new BrowseTreeMaker('categ');
$smarty->assign('tree', $treeMaker->make_tree(0, $treeNodes));
if (!isset($_REQUEST["sort_mode"])) {
    $sort_mode = 'name_asc';
} else {
    $sort_mode = $_REQUEST["sort_mode"];
}
$smarty->assign('sort_mode', $sort_mode);
if (!isset($_REQUEST["offset"])) {
    $offset = 0;
"><input type="hidden" name="edititem[]" value="<?php 
                echo $this->_tpl_vars['items'][$this->_sections['i']['index']]['id'];
                ?>
"></td>
<?php 
                if ($this->_tpl_vars['options']['useimages']) {
                    ?>
<td width="20"><?php 
                    if ($this->_tpl_vars['items'][$this->_sections['i']['index']]['idimg']) {
                        ob_start();
                        echo smarty_function_image(array('id' => $this->_tpl_vars['items'][$this->_sections['i']['index']]['idimg'], 'width' => 150), $this);
                        $this->_smarty_vars['capture']['gimage'] = ob_get_contents();
                        ob_end_clean();
                        ?>
<img src="/templates/admin/images/image.gif" width="16" height="16" <?php 
                        echo smarty_function_popup(array('text' => $this->_smarty_vars['capture']['gimage'], 'fgcolor' => "#F3FCFF", 'width' => 150, 'bgcolor' => "#86BECD", 'left' => true), $this);
                        ?>
><?php 
                    } else {
                        ?>
&nbsp;<?php 
                    }
                    ?>
</td><?php 
                }
                ?>
<td><a href="javascript:getedititemform(<?php 
                echo $this->_tpl_vars['items'][$this->_sections['i']['index']]['id'];
                ?>
)" title="Редактировать"><?php 
                echo $this->_tpl_vars['items'][$this->_sections['i']['index']]['name'];
Exemplo n.º 7
0
function wikiplugin_img($data, $params, $offset, $parseOptions = '')
{
    global $tikidomain, $prefs, $section, $smarty, $tikiroot;
    $imgdata = array();
    $imgdata['src'] = '';
    $imgdata['id'] = '';
    $imgdata['fileId'] = '';
    $imgdata['attId'] = '';
    $imgdata['thumb'] = '';
    $imgdata['button'] = '';
    $imgdata['link'] = '';
    $imgdata['rel'] = '';
    $imgdata['usemap'] = '';
    $imgdata['height'] = '';
    $imgdata['width'] = '';
    $imgdata['max'] = '';
    $imgdata['imalign'] = '';
    $imgdata['styleimage'] = '';
    $imgdata['align'] = '';
    $imgdata['stylebox'] = '';
    $imgdata['styledesc'] = '';
    $imgdata['block'] = '';
    $imgdata['class'] = '';
    $imgdata['desc'] = '';
    $imgdata['title'] = '';
    $imgdata['alt'] = '';
    $imgdata['default'] = '';
    $imgdata['mandatory'] = '';
    /*Admin default and mandatory settings (must be set by changing this fle or using plugin alias). Default will be used if not overridden
    	by user. Mandatory will override user settings.*/
    //Uncomment the following line to set the default parameter. Later items have priority. To override align default, put align parameter first
    //	$imgdata['default'] = 'default ? max = 200, align = right, styledesc = text-align: center; section_cms_article ? max= 400, width= , height=';
    // Uncomment the following line to set the default parameter. Force certain max and ignore any specified width or height.Later items have priority.
    //	$imgdata['mandatory'] = 'section_cms_article ? max = 400; module_* ? max = 150, width= , height=; mode_mobile ? max = 150, width= , height=;';
    //////////////////////////////////////////////////Old IMAGE code for default and mandatory parameters////////////////////////////////////////////////////
    // Start processing... first defaults, then given parameters, then mandatory settings.
    // Get parameters once in case there is a 'default' parameter.
    // This will be done again later so parameters can override defaults.
    $imgdata = array_merge($imgdata, $params);
    if (!empty($imgdata['default'])) {
        // If defaults have been specified
        $imgdata['default'] = trim($imgdata['default']) . ';';
        // trim whitespace and ensure at least one semicolon
        $img_conditions_array = explode(";", $imgdata['default']);
        // conditions separated by semicolons
        if (!empty($img_conditions_array)) {
            foreach ($img_conditions_array as $key => $var) {
                // for each condition
                if (!empty($var)) {
                    $img_condition = explode("?", $var);
                    // condition separated from parameters by question mark
                    if (!empty($img_condition)) {
                        $img_condition_name = trim($img_condition[0]);
                        if (!empty($img_condition[1])) {
                            // if there is at least one parameter
                            $img_condition[1] = trim($img_condition[1]) . ',';
                            // at least one comma
                            $img_parameters_array = explode(",", $img_condition[1]);
                            // separate multiple parameters
                            if (!empty($img_parameters_array)) {
                                // if a parameter has been extracted
                                foreach ($img_parameters_array as $param_key => $param_var) {
                                    // for each parameter
                                    if (!empty($param_var)) {
                                        // if a parameter exists
                                        $img_parameter_array = explode("=", trim($param_var));
                                        // separate parameters and values
                                        if (!empty($img_parameter_array[0])) {
                                            // if a parameter with a value has been extracted
                                            $img_condition_status = false;
                                            // initialise condition as not being true
                                            $img_condition_name = strtolower(trim($img_condition_name));
                                            switch ($img_condition_name) {
                                                case "default":
                                                    $img_condition_status = true;
                                                    // default is always true
                                                    break;
                                                case "mode_mobile":
                                                    if ($_REQUEST['mode'] == "mobile") {
                                                        $img_condition_status = true;
                                                    }
                                                    break;
                                                case "module_*":
                                                    if (!empty($smarty)) {
                                                        $image_module_params = $smarty->get_template_vars('module_params');
                                                        if (!empty($image_module_params)) {
                                                            $img_condition_status = true;
                                                        }
                                                    }
                                                    break;
                                                case "section_*":
                                                    if (!empty($section)) {
                                                        $img_condition_status = true;
                                                    }
                                                    break;
                                                case "section_cms_article":
                                                    if (!empty($section)) {
                                                        if ($section == "cms") {
                                                            if (!empty($smarty)) {
                                                                $image_article_type = $smarty->get_template_vars('type');
                                                                if (!empty($image_article_type)) {
                                                                    if (strtolower(trim($image_article_type)) == "article") {
                                                                        $img_condition_status = true;
                                                                    }
                                                                }
                                                                // if(!empty($image_article_type))
                                                            }
                                                            // if(!empty($smarty))
                                                        }
                                                    }
                                                    break;
                                                case "section_cms_review":
                                                    if (!empty($section)) {
                                                        if ($section == "cms") {
                                                            if (!empty($smarty)) {
                                                                $image_article_type = $smarty->get_template_vars('type');
                                                                if (!empty($image_article_type)) {
                                                                    if (strtolower(trim($image_article_type)) == "review") {
                                                                        $img_condition_status = true;
                                                                    }
                                                                }
                                                                // if(!empty($image_article_type))
                                                            }
                                                            // if(!empty($smarty))
                                                        }
                                                    }
                                                    break;
                                                case "section_cms_event":
                                                    if (!empty($section)) {
                                                        if ($section == "cms") {
                                                            if (!empty($smarty)) {
                                                                $image_article_type = $smarty->get_template_vars('type');
                                                                if (!empty($image_article_type)) {
                                                                    if (strtolower(trim($image_article_type)) == "event") {
                                                                        $img_condition_status = true;
                                                                    }
                                                                }
                                                                // if(!empty($image_article_type))
                                                            }
                                                            // if(!empty($smarty))
                                                        }
                                                    }
                                                    break;
                                                case "section_cms_classified":
                                                    if (!empty($section)) {
                                                        if ($section == "cms") {
                                                            if (!empty($smarty)) {
                                                                $image_article_type = $smarty->get_template_vars('type');
                                                                if (!empty($image_article_type)) {
                                                                    if (strtolower(trim($image_article_type)) == "classified") {
                                                                        $img_condition_status = true;
                                                                    }
                                                                }
                                                                // if(!empty($image_article_type))
                                                            }
                                                            // if(!empty($smarty))
                                                        }
                                                    }
                                                    break;
                                            }
                                            // switch ($img_condition_name)
                                            if ($img_condition_status != true) {
                                                // if match not found yet, examine more specific conditions
                                                if (!empty($section)) {
                                                    // if we have a section name
                                                    if (substr($img_condition_name, 0, 8) == "section_") {
                                                        if (strlen($img_condition_name) > 8) {
                                                            $img_condition_part = substr($img_condition, 8);
                                                            // get part after "section_"
                                                            $img_condition_part = strtolower($img_condition_part);
                                                            $img_condition_part = trim(strtr($img_condition_part, "_", " "));
                                                            // replace underscore with spaces
                                                            if ($section == $img_condition_part) {
                                                                $img_condition_status = true;
                                                            }
                                                        }
                                                        // if( length($img_condition_name) > 8 )
                                                    }
                                                    // if( substr($img_condition_name,0,8) == "section_" )
                                                }
                                                // if( !empty($section) )
                                            }
                                            if ($img_condition_status == true) {
                                                // set the parameters to their values
                                                switch (strtolower(trim($img_parameter_array[0]))) {
                                                    case 'src':
                                                        $imgdata['src'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'id':
                                                        $imgdata['id'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'fileId':
                                                        $imgdata['fileId'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'attId':
                                                        $imgdata['attId'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'thumb':
                                                        $imgdata['thumb'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'button':
                                                        $imgdata['button'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'link':
                                                        $imgdata['link'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'rel':
                                                        $imgdata['rel'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'usemap':
                                                        $imgdata['usemap'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'height':
                                                        $imgdata['height'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'width':
                                                        $imgdata['width'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'max':
                                                        $imgdata['max'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'imalign':
                                                        $imgdata['imalign'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'styleimage':
                                                        $imgdata['styleimage'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'align':
                                                        $imgdata['align'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'stylebox':
                                                        $imgdata['stylebox'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'styledesc':
                                                        $imgdata['styledesc'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'block':
                                                        $imgdata['block'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'class':
                                                        $imgdata['class'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'desc':
                                                        $imgdata['desc'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'title':
                                                        $imgdata['title'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'alt':
                                                        $imgdata['alt'] = trim($img_parameter_array[1]);
                                                        break;
                                                }
                                                // switch ($img_parameter_array[0])
                                            }
                                            // if( $img_condition_status == true )
                                        }
                                        // if( !empty($img_parameter_array[0] )
                                    }
                                    // if a parameter exists
                                }
                                // for each parameter
                            }
                            // if( !empty($img_parameters_array) )
                        }
                        // if( !empty($img_condition[1]) )
                    }
                    // if( !empty($img_condition) )
                }
                // if( !empty($var) )
            }
            // for each condition
        }
        // if( !empty($img_conditions_array) )
    }
    // if( !empty($imgdata['default']) )
    // merge specified parameters over default values
    $imgdata = array_merge($imgdata, $params);
    if (!empty($imgdata['mandatory'])) {
        // If defaults have been specified
        $imgdata['mandatory'] = trim($imgdata['mandatory']) . ';';
        // trim whitespace and ensure at least one semicolon
        $img_conditions_array = explode(";", $imgdata['mandatory']);
        // conditions separated by semicolons
        if (!empty($img_conditions_array)) {
            foreach ($img_conditions_array as $key => $var) {
                // for each condition
                if (!empty($var)) {
                    $img_condition = explode("?", $var);
                    // condition separated from parameters by question mark
                    if (!empty($img_condition)) {
                        $img_condition_name = trim($img_condition[0]);
                        if (!empty($img_condition[1])) {
                            // if there is at least one parameter
                            $img_condition[1] = trim($img_condition[1]) . ',';
                            // at least one comma
                            $img_parameters_array = explode(",", $img_condition[1]);
                            // separate multiple parameters
                            if (!empty($img_parameters_array)) {
                                // if a parameter has been extracted
                                foreach ($img_parameters_array as $param_key => $param_var) {
                                    // for each parameter
                                    if (!empty($param_var)) {
                                        // if a parameter exists
                                        $img_parameter_array = explode("=", trim($param_var));
                                        // separate parameters and values
                                        if (!empty($img_parameter_array[0])) {
                                            // if a parameter with a value has been extracted
                                            $img_condition_status = false;
                                            // initialise condition as not being true
                                            $img_condition_name = strtolower(trim($img_condition_name));
                                            switch ($img_condition_name) {
                                                case "default":
                                                    $img_condition_status = true;
                                                    // default is always true
                                                    break;
                                                case "mode_mobile":
                                                    if ($_REQUEST['mode'] == "mobile") {
                                                        $img_condition_status = true;
                                                    }
                                                    break;
                                                case "module_*":
                                                    if (!empty($smarty)) {
                                                        $image_module_params = $smarty->get_template_vars('module_params');
                                                        if (!empty($image_module_params)) {
                                                            $img_condition_status = true;
                                                        }
                                                    }
                                                    break;
                                                case "section_*":
                                                    if (!empty($section)) {
                                                        $img_condition_status = true;
                                                    }
                                                    break;
                                                case "section_cms_article":
                                                    if (!empty($section)) {
                                                        if ($section == "cms") {
                                                            if (!empty($smarty)) {
                                                                $image_article_type = $smarty->get_template_vars('type');
                                                                if (!empty($image_article_type)) {
                                                                    if (strtolower(trim($image_article_type)) == "article") {
                                                                        $img_condition_status = true;
                                                                    }
                                                                }
                                                                // if(!empty($image_article_type))
                                                            }
                                                            // if(!empty($smarty))
                                                        }
                                                    }
                                                    break;
                                                case "section_cms_review":
                                                    if (!empty($section)) {
                                                        if ($section == "cms") {
                                                            if (!empty($smarty)) {
                                                                $image_article_type = $smarty->get_template_vars('type');
                                                                if (!empty($image_article_type)) {
                                                                    if (strtolower(trim($image_article_type)) == "review") {
                                                                        $img_condition_status = true;
                                                                    }
                                                                }
                                                                // if(!empty($image_article_type))
                                                            }
                                                            // if(!empty($smarty))
                                                        }
                                                    }
                                                    break;
                                                case "section_cms_event":
                                                    if (!empty($section)) {
                                                        if ($section == "cms") {
                                                            if (!empty($smarty)) {
                                                                $image_article_type = $smarty->get_template_vars('type');
                                                                if (!empty($image_article_type)) {
                                                                    if (strtolower(trim($image_article_type)) == "event") {
                                                                        $img_condition_status = true;
                                                                    }
                                                                }
                                                                // if(!empty($image_article_type))
                                                            }
                                                            // if(!empty($smarty))
                                                        }
                                                    }
                                                    break;
                                                case "section_cms_classified":
                                                    if (!empty($section)) {
                                                        if ($section == "cms") {
                                                            if (!empty($smarty)) {
                                                                $image_article_type = $smarty->get_template_vars('type');
                                                                if (!empty($image_article_type)) {
                                                                    if (strtolower(trim($image_article_type)) == "classified") {
                                                                        $img_condition_status = true;
                                                                    }
                                                                }
                                                                // if(!empty($image_article_type))
                                                            }
                                                            // if(!empty($smarty))
                                                        }
                                                    }
                                                    break;
                                            }
                                            // switch ($img_condition_name)
                                            if ($img_condition_status != true) {
                                                // if match not found yet, examine more specific conditions
                                                if (!empty($section)) {
                                                    // if we have a section name
                                                    if (substr($img_condition_name, 0, 8) == "section_") {
                                                        if (strlen($img_condition_name) > 8) {
                                                            $img_condition_part = substr($img_condition, 8);
                                                            // get part after "section_"
                                                            $img_condition_part = strtolower($img_condition_part);
                                                            $img_condition_part = trim(strtr($img_condition_part, "_", " "));
                                                            // replace underscore with spaces
                                                            if ($section == $img_condition_part) {
                                                                $img_condition_status = true;
                                                            }
                                                        }
                                                        // if( length($img_condition_name) > 8 )
                                                    }
                                                    // if( substr($img_condition_name,0,8) == "section_" )
                                                }
                                                // if( !empty($section) )
                                            }
                                            if ($img_condition_status == true) {
                                                // set the parameters to their values
                                                switch (strtolower(trim($img_parameter_array[0]))) {
                                                    case 'src':
                                                        $imgdata['src'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'id':
                                                        $imgdata['id'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'fileId':
                                                        $imgdata['fileId'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'attId':
                                                        $imgdata['attId'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'thumb':
                                                        $imgdata['thumb'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'button':
                                                        $imgdata['button'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'link':
                                                        $imgdata['link'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'rel':
                                                        $imgdata['rel'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'usemap':
                                                        $imgdata['usemap'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'height':
                                                        $imgdata['height'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'width':
                                                        $imgdata['width'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'max':
                                                        $imgdata['max'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'imalign':
                                                        $imgdata['imalign'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'styleimage':
                                                        $imgdata['styleimage'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'align':
                                                        $imgdata['align'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'stylebox':
                                                        $imgdata['stylebox'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'styledesc':
                                                        $imgdata['styledesc'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'block':
                                                        $imgdata['block'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'class':
                                                        $imgdata['class'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'desc':
                                                        $imgdata['desc'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'title':
                                                        $imgdata['title'] = trim($img_parameter_array[1]);
                                                        break;
                                                    case 'alt':
                                                        $imgdata['alt'] = trim($img_parameter_array[1]);
                                                        break;
                                                }
                                                // switch ($img_parameter_array[0])
                                            }
                                            // if( $img_condition_status == true )
                                        }
                                        // if( !empty($img_parameter_array[0] )
                                    }
                                    // if a parameter exists
                                }
                                // for each parameter
                            }
                            // if( !empty($img_parameters_array) )
                        }
                        // if( !empty($img_condition[1]) )
                    }
                    // if( !empty($img_condition) )
                }
                // if( !empty($var) )
            }
            // for each condition
        }
        // if( !empty($img_conditions_array) )
    }
    // if( !empty($imgdata['default']) )
    //////////////////////////////////////////////////////////End of old IMAGE code for default and mandatory parameters////////////////////////////////////
    //////////////////////////////////////////////////// Error messages and clean javascript /////////////////////////////////////////////////
    // Must set at least one image identifier
    if (empty($imgdata['fileId']) and empty($imgdata['id']) and empty($imgdata['src']) and empty($imgdata['attId'])) {
        return tra("''No image specified. Either the fileId, attId, id, or src parameter must be specified.''");
    }
    // Can't set more than one image identifier
    if (!(!empty($imgdata['fileId']) xor !empty($imgdata['id']) xor !empty($imgdata['src']) xor !empty($imgdata['attId']))) {
        return tra("''Use one and only one of the following parameters: fileId, attId, id, or src.''");
    }
    // Clean up src URLs to exclude javascript
    if (stristr(str_replace(' ', '', $imgdata['src']), 'javascript:')) {
        $imgdata['src'] = '';
    }
    if (strstr($imgdata['src'], 'javascript:')) {
        $imgdata['src'] = '';
    }
    include_once 'tiki-sefurl.php';
    ///////////////////////////////////// If only old img parameters used, use old code and get out of program quickly ///////////////////
    if (!empty($imgdata['src']) && strpos($imgdata['src'], '|') == FALSE && strpos($imgdata['src'], ',') == FALSE && empty($imgdata['thumb']) && empty($imgdata['button']) && empty($imgdata['max']) && empty($imgdata['styleimage']) && empty($imgdata['stylebox']) && empty($imgdata['styledesc']) && empty($imgdata['block']) && $imgdata['desc'] != 'desc' && $imgdata['desc'] != 'idesc' && $imgdata['desc'] != 'name' && $imgdata['desc'] != 'ititle' && $imgdata['rel'] != 'box') {
        if ($tikidomain && !preg_match('|^https?:|', $imgdata['src'])) {
            $imgdata['src'] = preg_replace("~img/wiki_up/~", "img/wiki_up/{$tikidomain}/", $imgdata['src']);
        }
        // Handle absolute links (e.g. to send a newsletter with images that remains on the tiki site)
        $absolute_links = isset($parseOptions['absolute_links']) ? $parseOptions['absolute_links'] : false;
        if ($imgdata['src'] != '' && $absolute_links && !preg_match('|^[a-zA-Z]+:\\/\\/|', $imgdata['src'])) {
            global $base_host, $url_path;
            $imgdata['src'] = $base_host . ($imgdata['src'][0] == '/' ? '' : $url_path) . $imgdata['src'];
        }
        $imgdata_dim = '';
        if ($prefs['feature_filegals_manager'] == 'y') {
            global $detected_lib;
            include_once 'lib/images/images.php';
        } else {
            $detected_lib = '';
        }
        if ($detected_lib != '' && ereg('^' . $tikiroot . 'tiki-download_file.php\\?', $imgdata['src'])) {
            // If an image lib has been detected and if we are using an image from a file gallery,
            //   then also resize the image server-side, because it will generally imply less data to download from the user
            //   (i.e. speed up the page download) and a better image quality (browser resize algorithms are quick but bad)
            //
            //   Note: ctype_digit is used to ensure there is only digits in width and height strings (e.g. to avoid '50%', ...)
            //
            if ((int) $imgdata['width'] > 0 && ctype_digit($imgdata['width'])) {
                $imgdata['src'] .= '&amp;x=' . $imgdata['width'];
            }
            if ((int) $imgdata['height'] > 0 && ctype_digit($imgdata['height'])) {
                $imgdata['src'] .= '&amp;y=' . $imgdata['height'];
            }
        }
        $imgdata["src"] = filter_out_sefurl(htmlentities($imgdata["src"]), $smarty);
        if ($imgdata['width']) {
            $imgdata_dim .= ' width="' . $imgdata['width'] . '"';
        }
        if ($imgdata['height']) {
            $imgdata_dim .= ' height="' . $imgdata['height'] . '"';
        }
        $repl = '<img alt="' . $imgdata["alt"] . '" src="' . $imgdata["src"] . '" border="0" ' . $imgdata_dim;
        if ($imgdata['imalign']) {
            $repl .= ' style="float: ' . $imgdata['imalign'] . '"';
        }
        if ($imgdata['usemap']) {
            $repl .= ' usemap="#' . $imgdata['usemap'] . '"';
        }
        if ($imgdata['class']) {
            $repl .= ' class="' . $imgdata['class'] . '"';
        }
        $repl .= ' />';
        if ($imgdata['link']) {
            $imgtarget = '';
            if ($prefs['popupLinks'] == 'y' && (preg_match('#^([a-z0-9]+?)://#i', $imgdata['link']) || preg_match('#^www\\.([a-z0-9\\-]+)\\.#i', $imgdata['link']))) {
                $imgtarget = ' target="_blank"';
            }
            if ($imgdata['rel']) {
                $linkrel = ' rel="' . $imgdata['rel'] . '"';
            } else {
                $linkrel = '';
            }
            if ($imgdata['title']) {
                $linktitle = ' title="' . $imgdata['title'] . '"';
            } else {
                $linktitle = '';
            }
            $repl = '<a href="' . $imgdata['link'] . '"' . $linkrel . $imgtarget . $linktitle . '>' . $repl . '</a>';
        }
        if ($imgdata['desc']) {
            $repl = '<table cellpadding="0" cellspacing="0"><tr><td>' . $repl . '</td></tr><tr><td class="mini">' . $imgdata['desc'] . '</td></tr></table>';
        }
        if ($imgdata['align']) {
            $repl = '<div class="img" align="' . $imgdata["align"] . '">' . $repl . "</div>";
        } elseif (!$imgdata['desc']) {
            $repl = '<span class="img">' . $repl . "</span>";
        }
        return $repl;
        ///////////end of old IMG code////////////////////
    } else {
        ////////////////////////////////////////////// Default parameter and variable settings.//////////////////////////////////////////////
        // Set styling defaults
        $thumbdef = 84;
        //Thumbnail height max when none is set
        if (!empty($imgdata['fileId'])) {
            $thumbdef = 120;
            // filegals thumbnails size is hard-coded in lib/images/abstract.php
        }
        $descdef = 'font-size:12px; line-height:1.5em;';
        //default text style for description
        $descheightdef = 'height:15px;';
        //To set room for enlarge button under image if there is no description
        $borderdef = 'border:1px solid darkgray;';
        //default border when styleimage set to border
        $borderboxdef = 'border:1px solid darkgray; padding:5px; background-color: #f9f9f9;';
        //default border when stylebox set to border or y
        $center = 'display:block; margin-left:auto; margin-right:auto;';
        //used to center image and box
        $enlargedef = 'float:right; padding-top:.1cm;';
        //styling for the enlarge button div
        $captiondef = 'padding-top:2px;';
        //styling for the caption div
        //Variable for identifying if javascript mouseover is set
        if ($imgdata['thumb'] == 'mouseover' || $imgdata['thumb'] == 'mousesticky') {
            $javaset = 'true';
        } else {
            $javaset = '';
        }
        if (!isset($data) or !$data) {
            $data = '&nbsp;';
        }
        //Set variables for the base path for images in file galleries, image galleries and attachments
        $imagegalpath = 'show_image.php?id=';
        $filegalpath = 'tiki-download_file.php?fileId=';
        $attachpath = 'tiki-download_wiki_attachment.php?attId=';
        $repl = '';
        /////////////////////////////////////////////// Label images and set id variable based on location////////////////////////////
        // Set id's if user set path in src instead of id for images in file galleries, image galleries and attachments
        //This is so we can get db info
        if (strlen(strstr($imgdata['src'], $imagegalpath)) > 0) {
            //if the src parameter contains an image gallery path
            $imgdata['id'] = substr(strstr($imgdata['src'], $imagegalpath), strlen($imagegalpath));
            //then isolate id number and put it into $imgdata['id']
        } elseif (strlen(strstr($imgdata['src'], $filegalpath)) > 0) {
            //if file gallery path
            $imgdata['fileId'] = substr(strstr($imgdata['src'], $filegalpath), strlen($filegalpath));
            //then put fileId into $imgdata['fileId']
        } elseif (strlen(strstr($imgdata['src'], $attachpath)) > 0) {
            //if attachment path
            $imgdata['attId'] = substr(strstr($imgdata['src'], $attachpath), strlen($attachpath));
            //then put attId into $imgdata['attId']
        }
        //Identify location of source image and id for use later
        $sourcetype = '';
        $id = '';
        if (!empty($imgdata['id'])) {
            $sourcetype = 'imagegal';
            $id = 'id';
        } elseif (!empty($imgdata['fileId'])) {
            $sourcetype = 'filegal';
            $id = 'fileId';
        } elseif (!empty($imgdata['attId'])) {
            $sourcetype = 'attach';
            $id = 'attId';
        } else {
            $sourcetype = 'url';
            $id = 'src';
        }
        //////////////////////////////////////// Process lists of images ////////////////////////////////////////////////////////
        //Process "|" or "," separated images
        $separator = '';
        if (!empty($imgdata[$id]) && (strpos($imgdata[$id], '|') !== FALSE || strpos($imgdata[$id], ',') !== FALSE)) {
            if (strpos($imgdata[$id], '|') !== FALSE) {
                $separator = '|';
            } elseif (strpos($imgdata[$id], ',') !== FALSE) {
                $separator = ',';
            }
            $repl = '';
            $id_list = array();
            $id_list = explode($separator, $imgdata[$id]);
            $params[$id] = '';
            foreach ($id_list as $i => $value) {
                $params[$id] = trim($value);
                $repl .= wikiplugin_img($data, $params, $offset, $parseOptions);
            }
            $repl = "\n\r" . '<br style="clear:both" />' . "\r" . $repl . "\n\r" . '<br style="clear:both" />' . "\r";
            return $repl;
            // return the multiple images
        }
        //////////////////////////////////////////////////// Set image src ///////////////////////////////////////////////////////////
        // Clean up src URLs to exclude javascript
        if (stristr(str_replace(' ', '', $imgdata['src']), 'javascript:')) {
            $imgdata['src'] = '';
        }
        if (strstr($imgdata['src'], 'javascript:')) {
            $imgdata['src'] = '';
        }
        //Deal with images in tiki databases (file and image galleries and attachments)
        if (!empty($sourcetype)) {
            //Try to get image from database
            switch ($sourcetype) {
                case 'imagegal':
                    global $imagegallib;
                    include_once 'lib/imagegals/imagegallib.php';
                    $dbinfo = $imagegallib->get_image_info($imgdata['id'], 'o');
                    $basepath = $prefs['gal_use_dir'];
                    break;
                case 'filegal':
                    global $filegallib;
                    include_once 'lib/filegals/filegallib.php';
                    $dbinfo = $filegallib->get_file($imgdata['fileId']);
                    $basepath = $prefs['fgal_use_dir'];
                    break;
                case 'attach':
                    global $atts;
                    global $wikilib;
                    include_once 'lib/wiki/wikilib.php';
                    $dbinfo = $wikilib->get_item_attachment($imgdata['attId']);
                    $basepath = $prefs['w_use_dir'];
                    break;
            }
            //Give error messages if it doesn't exist or isn't an image
            if (empty($imgdata['src'])) {
                if (!$dbinfo) {
                    return '^' . tra('File not found.') . '^';
                } elseif (substr($dbinfo['filetype'], 0, 5) != 'image') {
                    return '^' . tra('File is not an image.') . '^';
                } else {
                    require_once 'lib/images/images.php';
                    if (!class_exists('Image')) {
                        return '^' . tra('Server does not support image manipulation.') . '^';
                    }
                }
            }
            //Now that we know it exists, finish getting info for image gallery files since the path and blob are in two different tables
            if ($sourcetype == 'imagegal') {
                global $imagegallib;
                include_once 'lib/imagegals/imagegallib.php';
                $dbinfo2 = $imagegallib->get_image($imgdata['id'], 'o');
                $dbinfo = array_merge($dbinfo, $dbinfo2);
            }
            //Set other variables from db info
            if (!empty($dbinfo['comment'])) {
                //attachment database uses comment instead of description or name
                $desc = $dbinfo['comment'];
                $imgname = $dbinfo['comment'];
            } else {
                $desc = $dbinfo['description'];
                $imgname = $dbinfo['name'];
            }
        }
        //finished getting info from db for images in image or file galleries or attachments
        //Set src (for html) and base path (for getimagesize)
        $absolute_links = !empty($parseOptions['absolute_links']) ? $parseOptions['absolute_links'] : false;
        $thumbstring = '';
        if (empty($imgdata['src'])) {
            switch ($sourcetype) {
                case 'imagegal':
                    $imgdata['src'] = $imagegalpath . $imgdata['id'];
                    if (!empty($imgdata['thumb'])) {
                        $thumbstring = '&thumb=1';
                    }
                    break;
                case 'filegal':
                    $imgdata['src'] = $filegalpath . $imgdata['fileId'];
                    if (!empty($imgdata['thumb'])) {
                        $thumbstring = '&thumbnail';
                    }
                    break;
                case 'attach':
                    $imgdata['src'] = $attachpath . $imgdata['attId'];
                    if (!empty($imgdata['thumb'])) {
                    }
                    break;
            }
        } elseif (!empty($imgdata['src']) && $absolute_links && !preg_match('|^[a-zA-Z]+:\\/\\/|', $imgdata['src'])) {
            global $base_host, $url_path;
            $imgdata['src'] = $base_host . ($imgdata['src'][0] == '/' ? '' : $url_path) . $imgdata['src'];
        } elseif (!empty($imgdata['src']) && $tikidomain && !preg_match('|^https?:|', $imgdata['src'])) {
            $imgdata['src'] = preg_replace("~img/wiki_up/~", "img/wiki_up/{$tikidomain}/", $imgdata['src']);
        } elseif (!empty($imgdata['src'])) {
            $imgdata['src'] = $imgdata['src'];
        }
        //Now get height, width, iptc data from actual image
        //First get the data. Images in db handled differently than those in directories or path
        global $imagesize, $iptc, $otherinfo;
        $otherinfo = array();
        if (!empty($dbinfo['data'])) {
            getimagesize_raw($dbinfo['data']);
            //images in databases, calls function in this program
        } else {
            if (!empty($dbinfo['path'])) {
                $imagesize = getimagesize($basepath . $dbinfo['path'], $otherinfo);
                //images in tiki directories
            } else {
                $imagesize = getimagesize($imgdata['src'], $otherinfo);
                //wiki_up and external images
            }
            if (isset($otherinfo['APP13'])) {
                $iptc = iptcparse($otherinfo['APP13']);
            }
        }
        //Set variables for height, width and iptc data from image data
        $fwidth = $imagesize[0];
        $fheight = $imagesize[1];
        $idesc = isset($iptc['2#120'][0]) ? trim($iptc['2#120'][0]) : '';
        //description from image iptc
        $ititle = isset($iptc['2#005'][0]) ? trim($iptc['2#005'][0]) : '';
        //title from image iptc
        // URL of original full size image
        $pos = strpos($imgdata['src'], '&thumb');
        if ($pos > 0) {
            //Strip off any thumbnail parameter
            $len = strlen($imgdata['src']);
            $browse_full_image = substr_replace($imgdata['src'], '', $pos, $len - ($len - $pos));
        } else {
            $browse_full_image = $imgdata['src'];
        }
        /////////////////////////////////////Add image dimensions to src string////////////////////////////////////////////////////////////////
        // Adjust for max setting, keeping aspect ratio
        if (!empty($imgdata['max']) && ctype_digit($imgdata['max'])) {
            if ($fwidth > $imgdata['max'] || $fheight > $imgdata['max']) {
                if ($fwidth > $fheight) {
                    $width = $imgdata['max'];
                    $height = floor($width * $fheight / $fwidth);
                } else {
                    $height = $imgdata['max'];
                    $width = floor($height * $fwidth / $fheight);
                }
            } else {
                //cases where max is set but image is smaller than max
                $height = $fheight;
                $width = $fwidth;
            }
            // Adjust for user settings for height and width if max isn't set.
        } elseif (!empty($imgdata['height']) && ctype_digit($imgdata['height'])) {
            $height = $imgdata['height'];
            if (empty($imgdata['width'])) {
                $width = floor($height * $fwidth / $fheight);
            } else {
                $width = $imgdata['width'];
            }
        } elseif (!empty($imgdata['width']) && ctype_digit($imgdata['width'])) {
            $width = $imgdata['width'];
            if (empty($imgdata['height'])) {
                $height = floor($width * $fheight / $fwidth);
            } else {
                $height = $imgdata['height'];
            }
            // If not otherwise set, use default setting for thumbnail height if thumb is set
        } elseif (!empty($imgdata['thumb'])) {
            if ($fwidth > $thumbdef || $fheight > $thumbdef) {
                if ($fwidth > $fheight) {
                    $width = $thumbdef;
                    $height = floor($width * $fheight / $fwidth);
                } else {
                    $height = $thumbdef;
                    $width = floor($height * $fwidth / $fheight);
                }
            }
        }
        //Set final height and width dimension string
        if (!empty($height)) {
            $imgdata_dim = ' height="' . $height . '"';
        } else {
            $imgdata_dim = '';
            $height = $fheight;
        }
        if (!empty($width)) {
            $imgdata_dim .= ' width="' . $width . '"';
        } else {
            $imgdata_dim = '';
            $width = $fwidth;
        }
        ////////////////////////////////////////// Create the HTML img tag ///////////////////////////////////////////////////////////////////
        //Start tag with src and dimensions
        $imgdata["src"] = filter_out_sefurl(htmlentities($imgdata["src"] . $thumbstring), $smarty);
        $replimg = "\r\t" . '<img src="' . $imgdata['src'] . '"';
        $replimg .= $imgdata_dim;
        //Create style attribute allowing for shortcut inputs
        //First set alignment string
        $imalign = '';
        $border = '';
        $style = '';
        if (!empty($imgdata['imalign'])) {
            if ($imgdata['imalign'] == 'center') {
                $imalign = $center;
            } else {
                $imalign = 'float:' . $imgdata['imalign'] . ';';
            }
        }
        //set entire style string
        if (!empty($imgdata['styleimage']) || !empty($imalign)) {
            if (!empty($imgdata['styleimage'])) {
                if (!empty($imalign)) {
                    if (strpos(trim($imgdata['styleimage'], ' '), 'float:') > 0 || strpos(trim($imgdata['styleimage'], ' '), 'display:') > 0) {
                        $imalign = '';
                        //override imalign setting is style image contains alignment syntax
                    }
                }
                if ($imgdata['styleimage'] == 'border') {
                    $border = $borderdef;
                } else {
                    if (strpos($imgdata['styleimage'], 'hidden') === false && strpos($imgdata['styleimage'], 'position') === false) {
                        // quick filter for dangerous styles
                        $style = $imgdata['styleimage'];
                    }
                }
            }
            $replimg .= ' style="' . $imalign . $border . $style . '"';
        }
        //alt
        if (!empty($imgdata['alt'])) {
            $replimg .= ' alt="' . $imgdata['alt'] . '"';
        }
        //usemap
        if (!empty($imgdata['usemap'])) {
            $replimg .= ' usemap="#' . $imgdata['usemap'] . '"';
        }
        //class
        if (!empty($imgdata['class'])) {
            $replimg .= ' class="' . $imgdata['class'] . '"';
        }
        //title (also used for description and link title below)
        //first set description, which is used for title if no title is set
        if (!empty($imgdata['desc'])) {
            switch ($imgdata['desc']) {
                case 'desc':
                    $desconly = $desc;
                    break;
                case 'idesc':
                    $desconly = $idesc;
                    break;
                case 'name':
                    $desconly = $imgname;
                    break;
                case 'ititle':
                    $desconly = $ititle;
                    break;
                default:
                    $desconly = $imgdata['desc'];
            }
        }
        //now set title
        if (!empty($imgdata['title']) || !empty($desconly)) {
            $imgtitle = ' title="';
            if (!empty($imgdata['title'])) {
                $titleonly = $imgdata['title'];
            } else {
                //use desc setting for title if title is empty
                $titleonly = $desconly;
            }
            $imgtitle .= $titleonly . '"';
            $replimg .= $imgtitle;
        }
        $replimg .= ' />';
        ////////////////////////////////////////// Create the HTML link ////////////////////////////////////////////////////////////////////////
        // Set link to user setting or to image itself if thumb is set
        if (!empty($imgdata['link']) || !empty($imgdata['thumb'])) {
            $mouseover = '';
            if (!empty($imgdata['link'])) {
                $link = $imgdata['link'];
            } elseif (($imgdata['thumb'] == 'browse' || $imgdata['thumb'] == 'browsepopup') && !empty($imgdata['id'])) {
                $link = 'tiki-browse_image.php?imageId=' . $imgdata['id'];
            } elseif ($javaset == 'true') {
                $link = 'javascript:void(0)';
                $popup_params = array('text' => $data, 'width' => $fwidth, 'height' => $fheight, 'background' => $browse_full_image);
                if ($imgdata['thumb'] == 'mousesticky') {
                    $popup_params['sticky'] = true;
                }
                require_once $smarty->_get_plugin_filepath('function', 'popup');
                $mouseover = ' ' . smarty_function_popup($popup_params, $smarty);
            } else {
                if ($sourcetype == 'filegal' && $imgdata['thumb'] != 'download') {
                    $link = $browse_full_image . '&display';
                } else {
                    $link = $browse_full_image;
                }
            }
            // Set other link-related attributes
            // target
            $imgtarget = '';
            if ($prefs['popupLinks'] == 'y' && (preg_match('#^([a-z0-9]+?)://#i', $link) || preg_match('#^www\\.([a-z0-9\\-]+)\\.#i', $link)) || $imgdata['thumb'] == 'popup' || $imgdata['thumb'] == 'browsepopup') {
                if (!empty($javaset) || $imgdata['rel'] == 'box') {
                    $imgtarget = '';
                } else {
                    $imgtarget = ' target="_blank"';
                }
            }
            // rel
            if (!empty($imgdata['rel'])) {
                if ($imgdata['rel'] == 'box') {
                    $linkrel = ' rel="box';
                    if (!empty($fwidth) && !empty($fheight)) {
                        $linkrel .= ";width={$fwidth};height={$fheight}";
                    }
                    /*if (!empty($desconly)) {
                    			$linkrel .= ";title=$desconly";
                    		}*/
                    $linkrel .= '"';
                } else {
                    $linkrel = ' rel="' . $imgdata['rel'] . '"';
                }
            } else {
                $linkrel = '';
            }
            // title
            if (!empty($imgtitle)) {
                $linktitle = $imgtitle;
            } else {
                $linktitle = '';
            }
            $link = filter_out_sefurl(htmlentities($link), $smarty);
            //Final link string
            $replimg = '<a href="' . $link . '" class="internal"' . $linkrel . $imgtarget . $linktitle . $mouseover . '>' . $replimg . '</a>';
        }
        //Add link string to rest of string
        $repl .= $replimg;
        /////////////////////////////////  Create enlarge button, description and their divs////////////////////////////////////////////////////
        //Start div that goes around button and description if these are set
        if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['styledesc'])) {
            $repl .= "\r\t" . '<div class="mini" style="width:' . $width . 'px;';
            if (!empty($imgdata['styledesc'])) {
                if ($imgdata['styledesc'] == 'left' || $imgdata['styledesc'] == 'right') {
                    $repl .= 'text-align:' . $imgdata['styledesc'] . '">';
                } else {
                    $repl .= $imgdata['styledesc'] . '">';
                }
            } elseif (!empty($imgdata['button']) && empty($desconly)) {
                $repl .= $descheightdef . '">';
            } else {
                $repl .= '">';
            }
            //Start description div that also includes enlarge button div
            $repl .= "\r\t\t" . '<div class="thumbcaption" style="' . $captiondef . '" >';
            //Enlarge button div and link string (innermost div)
            if (!empty($imgdata['button'])) {
                if (empty($link) || !empty($link) && !empty($javaset)) {
                    if (($imgdata['button'] == 'browse' || $imgdata['button'] == 'browsepopup') && !empty($imgdata['id'])) {
                        $link_button = 'tiki-browse_image.php?imageId=' . $imgdata['id'];
                    } else {
                        if ($sourcetype == 'filegal' && $imgdata['button'] != 'download') {
                            $link_button = $browse_full_image . '&display';
                        } else {
                            $link_button = $browse_full_image;
                        }
                    }
                } else {
                    $link_button = $link;
                }
                //Set button rel
                if (empty($linkrel) || !empty($javaset)) {
                    $linkrel_button = '';
                } else {
                    $linkrel_button = $linkrel;
                }
                //Set button target
                if (empty($imgtarget) && (empty($imgdata['thumb']) || !empty($javaset))) {
                    if ($imgdata['button'] == 'popup' || $imgdata['button'] == 'browsepopup') {
                        $imgtarget_button = ' target="_blank"';
                    } else {
                        $imgtarget_button = '';
                    }
                } else {
                    $imgtarget_button = $imgtarget;
                }
                $repl .= "\r\t\t\t" . '<div class="magnify" style="' . $enlargedef . '">';
                $repl .= "\r\t\t\t\t" . '<a href="' . $link_button . '"' . $linkrel_button . $imgtarget_button;
                $repl .= ' class="internal"';
                if (!empty($titleonly)) {
                    $repl .= ' title="' . $titleonly . '"';
                }
                $repl .= ">\r\t\t\t\t" . '<img src="./img/magnifying-glass-micro-icon.png" width="10" height="10" alt="Enlarge" /></a>' . "\r\t\t\t</div>";
            }
            //Add description based on user setting (use $desconly from above) and close divs
            $repl .= $desconly;
            $repl .= "\r\t\t</div>";
            $repl .= "\r\t</div>";
        }
        ///////////////////////////////Wrap in overall div that includes image if stylebox or button is set/////////////////////////////////////
        //Need a box if either button, desc or stylebox is set
        if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['stylebox']) || !empty($imgdata['align'])) {
            //Make the div surrounding the image 2 pixels bigger than the image
            $boxwidth = $width + 2;
            $boxheight = $height + 2;
            $alignbox = '';
            if (!empty($imgdata['align'])) {
                if ($imgdata['align'] == 'center') {
                    $alignbox = $center;
                } else {
                    $alignbox = 'float:' . $imgdata['align'] . ';';
                }
            }
            //first set stylebox string if style box is set
            if (!empty($imgdata['stylebox']) || !empty($imgdata['align'])) {
                //create strings from shortcuts first
                if (!empty($imgdata['stylebox'])) {
                    if ($imgdata['stylebox'] == 'border') {
                        $borderbox = $borderboxdef;
                        if (!empty($alignbox)) {
                            if (strpos(trim($imgdata['stylebox'], ' '), 'float:') > 0 || strpos(trim($imgdata['stylebox'], ' '), 'display:') > 0) {
                                $alignbox = '';
                                //override imalign setting is style image contains alignment syntax
                            }
                        }
                    } else {
                        $styleboxinit = $imgdata['stylebox'];
                    }
                }
                if (empty($imgdata['button']) && empty($imgdata['desc']) && empty($styleboxinit)) {
                    $styleboxplus = $alignbox . $borderbox . ' width:' . $boxwidth . 'px; height:' . $boxheight . 'px';
                } elseif (!empty($styleboxinit)) {
                    $styleboxplus = $styleboxinit;
                } else {
                    $styleboxplus = $alignbox . $borderbox . $descdef . ' width:' . $boxwidth . 'px';
                }
            } elseif (!empty($imgdata['button']) || !empty($imgdata['desc'])) {
                $styleboxplus = $descdef . ' width:' . $boxwidth . 'px;';
            }
        }
        if (!empty($styleboxplus)) {
            $repl = "\r" . '<div class="img" style="' . $styleboxplus . '">' . $repl . "\r</div>";
        }
        //////////////////////////////////////Place 'clear' block///////////////////////////////////////////////////////////////////////////////////
        if (!empty($imgdata['block'])) {
            switch ($imgdata['block']) {
                case 'top':
                    $repl = "\n\r<br style=\"clear:both\" />\r" . $repl;
                    break;
                case 'bottom':
                    $repl = $repl . "\n\r<br style=\"clear:both\" />\r";
                    break;
                case 'both':
                    $repl = "\n\r<br style=\"clear:both\" />\r" . $repl . "\n\r<br style=\"clear:both\" />\r";
                    break;
                case 'top':
                    break;
            }
        }
        // Mobile
        if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') {
            $repl = '{img src=' . $imgdata['src'] . "\"}\n<p>" . $imgdata['desc'] . '</p>';
        }
        return '~np~' . $repl . '~/np~';
    }
}
Exemplo n.º 8
0
/**
 * @param $descendants
 * @param $usercatwatches
 * @param $requestid
 * @param $categid
 * @param $deep
 * @param $user
 * @return bool|string
 */
function add_watch_icons($descendants, $usercatwatches, $requestid, $categid, $deep, $user, $name)
{
    global $prefs;
    if (!$user || $prefs["feature_user_watches"] != 'y') {
        return false;
    }
    global $prefsgroups, $tiki_p_admin_users, $tiki_p_admin;
    $categlib = TikiLib::lib('categ');
    $smarty = TikiLib::lib('smarty');
    $smarty->loadPlugin('smarty_function_icon');
    $smarty->loadPlugin('smarty_function_popup');
    $section = 'categories';
    $nodesc = count($descendants);
    $watch_desc = 'n';
    $watch_this = 'n';
    $eyes = $eyesgroup = '';
    if ($categid == 0) {
        $tip_rem_desc = tra('Stop watching all categories');
        $tip_add_desc = tra('Watch all categories');
        $tip_group = tra('Group watches for all categories');
    } else {
        $tip_rem_desc = tra('Stop watching this category and its descendants');
        $tip_add_desc = tra('Watch this category and its descendants');
        $tip_group = tra('Group watches for this category');
    }
    $eye_rem_desc = '<a href="tiki-browse_categories.php?' . 'parentId=' . $requestid . '&amp;watch_event=category_changed&amp;watch_object=' . $categid . '&amp;deep=' . $deep . '&amp;watch_action=remove_desc" class="catname">' . smarty_function_icon(['name' => 'stop-watching', '_menu_text' => 'y', '_menu_icon' => 'y', 'alt' => $tip_rem_desc], $smarty) . '</a>';
    $eye_rem = '<a href="tiki-browse_categories.php?' . 'parentId=' . $requestid . '&amp;watch_event=category_changed&amp;watch_object=' . $categid . '&amp;deep=' . $deep . '&amp;watch_action=remove" class="catname">' . smarty_function_icon(['name' => 'stop-watching', '_menu_text' => 'y', '_menu_icon' => 'y', 'alt' => tra('Stop watching this category')], $smarty) . '</a>';
    $eye_add_desc = '<a href="tiki-browse_categories.php?' . 'parentId=' . $requestid . '&amp;watch_event=category_changed&amp;watch_object=' . $categid . '&amp;deep=' . $deep . '&amp;watch_action=add_desc" class="catname">' . smarty_function_icon(['name' => 'watch', '_menu_text' => 'y', '_menu_icon' => 'y', 'alt' => $tip_add_desc], $smarty) . '</a>';
    $eye_add = '<a href="tiki-browse_categories.php?' . 'parentId=' . $requestid . '&amp;watch_event=category_changed&amp;watch_object=' . $categid . '&amp;deep=' . $deep . '&amp;watch_action=add">' . smarty_function_icon(['name' => 'watch', '_menu_text' => 'y', '_menu_icon' => 'y', 'alt' => tra('Watch this category')], $smarty) . '</a>';
    foreach ($descendants as $descendant) {
        if ($nodesc > 1) {
            //this category and descendants
            foreach ($usercatwatches as $usercatwatch) {
                if ($usercatwatch['object'] == $descendant || $descendant == 0) {
                    $watch_desc = 'y';
                    break;
                } else {
                    $watch_desc = 'n';
                }
            }
            if ($watch_desc == 'n') {
                $eyes = $eye_add_desc;
                break;
            } else {
                $eyes = $eye_rem_desc;
            }
        }
    }
    //this category only
    foreach ($usercatwatches as $usercatwatch) {
        if ($usercatwatch['object'] == $categid) {
            $watch_this = 'y';
            break;
        } else {
            $watch_this = 'n';
        }
    }
    if ($categid == 0) {
        $eyes .= '';
    } elseif ($watch_this == 'n') {
        $eyes = $eye_add . $eyes;
    } else {
        $eyes = $eye_rem . $eyes;
    }
    //group watches
    if ($prefsgroups == 'y' && ($tiki_p_admin_users == 'y' || $tiki_p_admin == 'y')) {
        $objName = '';
        if ($categid == 0) {
            $objName = 'Top';
        } else {
            $objName = $categlib->get_category_path_string_with_root($categid);
        }
        $eyesgroup = '<a href="tiki-object_watches.php?' . 'objectId=' . $categid . '&amp;watch_event=category_changed&amp;objectType=Category&amp;objectName=' . urlencode($objName) . '&amp;objectHref=tiki-browse_categories.php?parentId=' . $categid . '&amp;deep=' . $deep . '">' . smarty_function_icon(['name' => 'watch', '_menu_text' => 'y', '_menu_icon' => 'y', 'alt' => $tip_group], $smarty) . '</a>';
    }
    $alleyes = $eyes . $eyesgroup;
    $escapedeyes = htmlspecialchars(strtr($alleyes, array("\\" => "\\\\", "'" => "\\'", "\"" => "\\\"", "\r" => "\\r", "\n" => "\\n", "</" => "<\\/")), ENT_QUOTES, 'UTF-8', true);
    $popupparams = ['trigger' => 'click', 'fullhtml' => 1, 'center' => true, 'text' => $escapedeyes];
    return '<a class="tips" title="' . tra('Monitoring') . '" href="#" ' . smarty_function_popup($popupparams, $smarty) . 'style="padding:0; margin:0; border:0">' . smarty_function_icon(['name' => 'wrench'], $smarty) . '</a>';
    //	return $eyes . $eyesgroup;
}
$this->_sections['taetlist']['rownum'] = $this->_sections['taetlist']['iteration'];
$this->_sections['taetlist']['index_prev'] = $this->_sections['taetlist']['index'] - $this->_sections['taetlist']['step'];
$this->_sections['taetlist']['index_next'] = $this->_sections['taetlist']['index'] + $this->_sections['taetlist']['step'];
$this->_sections['taetlist']['first']      = ($this->_sections['taetlist']['iteration'] == 1);
$this->_sections['taetlist']['last']       = ($this->_sections['taetlist']['iteration'] == $this->_sections['taetlist']['total']);
 $this->assign('comment', ((is_array($_tmp=((is_array($_tmp=$this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_full_desc)) ? $this->_run_mod_handler('escape', true, $_tmp, 'html') : smarty_modifier_escape($_tmp, 'html')))) ? $this->_run_mod_handler('clearcomment', true, $_tmp) : smarty_modifier_clearcomment($_tmp)));  echo smarty_function_math(array('equation' => "21*((timestart - KTA)/60)/15+31+(timestart - KTA)/60/STEP",'timestart' => $this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_start,'KTA' => $this->_tpl_vars['taet']->KTA,'STEP' => $this->_tpl_vars['taet']->STEP,'assign' => 'divtop','format' => "%d"), $this);?>

<?php echo smarty_function_math(array('equation' => "21*((timefinish - timestart)/60)/15+(timefinish - timestart)/60/STEP-3",'timefinish' => $this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_finish,'timestart' => $this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_start,'STEP' => $this->_tpl_vars['taet']->STEP,'assign' => 'divheight','format' => "%d"), $this);?>

    <div id="div<?php echo $this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_id; ?>
" onclick="x_getTaetData(<?php echo $this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_id; ?>
)" style="position:absolute;width:592px;height:<?php echo $this->_tpl_vars['divheight']; ?>
px;border:1px solid #f0f0f0;top:<?php echo $this->_tpl_vars['divtop']; ?>
px;left:71px;cursor:pointer;" class="standarddiv" onmouseover="setHoverDiv(<?php echo $this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_id; ?>
)" onmouseout="setNormalDiv(<?php echo $this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_id; ?>
)"><div <?php if ($this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_full_desc):  echo smarty_function_popup(array('text' => ($this->_tpl_vars['comment']),'caption' => $this->_tpl_vars['dict']['commentar'],'fgcolor' => "#fafafa",'width' => '400','offsety' => -70,'offsetx' => -10,'captionsize' => '2','textsize' => '2'), $this); endif; ?>><?php echo ((is_array($_tmp=$this->_tpl_vars['taet']->taetObjList[$this->_sections['taetlist']['index']]->taet_short_desc)) ? $this->_run_mod_handler('escape', true, $_tmp, 'html') : smarty_modifier_escape($_tmp, 'html')); ?>
</div></div>
<?php endfor; endif; ?></div>
 <!--   <div style="position:absolute;width:592px;height:102px;background-color:#fafafa;border:1px solid #f0f0f0;top:157px;left:71px;cursor:pointer;">Tätigkeit 2</div> //-->
</div>

<div style="width:490px;float:left">
    <form action="index.php" method="post" name="rsform">
    <input name="formsend" value="1" type="hidden" />
    <input name="deletetaet" id="deletetaet" value="0" type="hidden" />
    <input name="taetid" id="taetid" value="<?php echo $this->_tpl_vars['formvars']->taet_id; ?>
" type="hidden" />
    <?php if ($this->_tpl_vars['errors']): ?><div id="errdiv">
    <span style="color:red;font-weight:bold"><?php echo $this->_tpl_vars['dict']['error']; ?>
</span>
        <ul style="color:red">
Exemplo n.º 10
0
function wikiplugin_img( $data, $params, $offset, $parseOptions='' )
{
	 global $tikidomain, $prefs, $section, $smarty, $tikiroot, $tikilib, $userlib, $user, $tiki_p_upload_files;

	$imgdata = array();
	
	$imgdata['src'] = '';
	$imgdata['id'] = '';
	$imgdata['fileId'] = '';
	$imgdata['randomGalleryId'] = '';
	$imgdata['fgalId'] = '';
	$imgdata['sort_mode'] = '';
	$imgdata['attId'] = '';
	$imgdata['thumb'] = '';
	$imgdata['button'] = '';
	$imgdata['link'] = '';
	$imgdata['rel'] = '';
	$imgdata['usemap'] = '';
	$imgdata['height'] = '';
	$imgdata['width'] = '';
	$imgdata['max'] = '';
	$imgdata['imalign'] = '';
	$imgdata['styleimage'] = '';
	$imgdata['align'] = '';
	$imgdata['stylebox'] = '';
	$imgdata['styledesc'] = '';
	$imgdata['block'] = '';
	$imgdata['class'] = '';
	$imgdata['desc'] = '';
	$imgdata['title'] = '';
	$imgdata['metadata'] = '';
	$imgdata['alt'] = '';
	$imgdata['default'] = '';
	$imgdata['mandatory'] = '';
	
	/*Admin default and mandatory settings (must be set by changing this fle or using plugin alias). Default will be used if not overridden
	by user. Mandatory will override user settings. Examples below set parameters depending on whether the image is in an article, a module, or 
	whether mobile mode is set, etc.*/
	//Uncomment the following line to set the default parameter. Later items have priority. To override align default, put align parameter first
//	$imgdata['default'] = 'default ? max = 200, align = right, styledesc = text-align: center; section_cms_article ? max= 400, width= , height=';
	// Uncomment the following line to set the default parameter. Force certain max and ignore any specified width or height. Later items have priority
//	$imgdata['mandatory'] = 'section_cms_article ? max = 400; module_* ? max = 150, width= , height=; mode_mobile ? max = 150, width= , height=;';

	$imgdata = array_merge($imgdata, $params);
//////////////////////////////////////////////////Function for processing default and mandatory parameters//////////////////////////////////////
	//function calls are just below function
	if (!function_exists('apply_default_and_mandatory')) {	
		function apply_default_and_mandatory($imgdata, $default) 
		{
			global $section, $smarty;
			$imgdata[$default] = trim($imgdata[$default]) . ';'; // trim whitespace and ensure at least one semicolon
			$img_conditions_array = explode(';', $imgdata[$default]); // conditions separated by semicolons
			if ( !empty($img_conditions_array) ) {
				foreach ($img_conditions_array as $key => $var) { // for each condition
					if ( !empty($var) ) {
						$img_condition = explode('?', $var); // condition separated from parameters by question mark
						if ( !empty($img_condition) ) {
							$img_condition_name = trim($img_condition[0]);
							if ( !empty($img_condition[1]) ) { // if there is at least one parameter
								$img_condition[1] = trim($img_condition[1]) . ',';	// at least one comma
								$img_parameters_array = explode(',', $img_condition[1]); // separate multiple parameters
								if ( !empty($img_parameters_array) ) {  // if a parameter has been extracted
									foreach ($img_parameters_array as $param_key => $param_var) {	// for each parameter
										if ( !empty($param_var) ) {	// if a parameter exists
											$img_parameter_array = explode('=', trim($param_var)); // separate parameters and values
											if ( !empty($img_parameter_array[0]) ) {  // if a parameter with a value has been extracted
	
												$img_condition_status = false;	// initialise condition as not being true
	
												$img_condition_name = strtolower(trim($img_condition_name));
												switch ($img_condition_name) {
													case 'default':
														$img_condition_status = true; // default is always true
    													break;
													case 'mode_mobile':
														if ( isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile' ) $img_condition_status = true;
	    												break;
													case 'module_*':
														if ( !empty($smarty) ) {
															$image_module_params = $smarty->getTemplateVars('module_params');
															if ( !empty($image_module_params) ) $img_condition_status = true;
														}
    													break;
													case 'section_*':
														if ( !empty($section) ) $img_condition_status = true;
	    												break;
													case 'section_cms_article':
														if ( !empty($section) ) {
															if ( $section == 'cms' ) {
																if ( !empty($smarty) ) {
																	$image_article_type = $smarty->getTemplateVars('type');
																	if ( !empty($image_article_type) ) {
																		if ( strtolower(trim($image_article_type)) == 'article' ) $img_condition_status = true;
																	} // if (!empty($image_article_type))
																} // if (!empty($smarty))
															}
														}
		    											break;
													case 'section_cms_review':
														if ( !empty($section) ) {
															if ( $section == 'cms' ) {
																if ( !empty($smarty) ) {
																	$image_article_type = $smarty->getTemplateVars('type');
																	if ( !empty($image_article_type) ) {
																		if ( strtolower(trim($image_article_type)) == 'review' ) $img_condition_status = true;
																	} // if (!empty($image_article_type))
																} // if (!empty($smarty))
															}
														}
			    										break;
													case 'section_cms_event':
														if ( !empty($section) ) {
															if ( $section == 'cms' ) {
																if ( !empty($smarty) ) {
																	$image_article_type = $smarty->getTemplateVars('type');
																	if ( !empty($image_article_type) ) {
																		if ( strtolower(trim($image_article_type)) == 'event' ) $img_condition_status = true;
																	} // if (!empty($image_article_type))
																} // if (!empty($smarty))
															}
														}
    													break;
													case 'section_cms_classified':
														if ( !empty($section) ) {
															if ( $section == 'cms' ) {
																if ( !empty($smarty) ) {
																	$image_article_type = $smarty->getTemplateVars('type');
																	if ( !empty($image_article_type) ) {
																		if ( strtolower(trim($image_article_type)) == 'classified' ) $img_condition_status = true;
																	} // if (!empty($image_article_type))
																} // if (!empty($smarty))
															}
														}
	    												break;
												} // switch ($img_condition_name)
	
												if ( $img_condition_status != true ) {
													// if match not found yet, examine more specific conditions
													if ( !empty($section) ) {	// if we have a section name
														if ( substr($img_condition_name, 0, 8) == 'section_' ) {
															if ( strlen($img_condition_name) > 8 ) {
																$img_condition_part = substr($img_condition, 8); // get part after "section_"
																$img_condition_part = strtolower($img_condition_part);
																$img_condition_part = trim(strtr($img_condition_part, '_', ' ')); // replace underscore with spaces
																if ( $section == $img_condition_part ) $img_condition_status = true;
															} // if ( length($img_condition_name) > 8 )
														} // if ( substr($img_condition_name,0,8) == "section_" )
													} // if ( !empty($section) )
												}
	
												if ( $img_condition_status == true ) {
													// set the parameters to their values
													switch (strtolower(trim($img_parameter_array[0]))) {
														case 'src':
															$imgdata['src'] = trim($img_parameter_array[1]);
     													break;
														case 'id':
															$imgdata['id'] = trim($img_parameter_array[1]);
	     												break;
														case 'fileId':
															$imgdata['fileId'] = trim($img_parameter_array[1]);
		     											break;
														case 'randomGalleryId':
															$imgdata['randomGalleryId'] = trim($img_parameter_array[1]);
				     									break;
														case 'fgalId':
															$imgdata['fgalId'] = trim($img_parameter_array[1]);
					     								break;
														case 'sort_mode':
															$imgdata['sort_mode'] = trim($img_parameter_array[1]);
     													break;
														case 'attId':
															$imgdata['attId'] = trim($img_parameter_array[1]);
     													break;
														case 'thumb':
															$imgdata['thumb'] = trim($img_parameter_array[1]);
     													break;
														case 'button':
															$imgdata['button'] = trim($img_parameter_array[1]);
	     												break;
														case 'link':
															$imgdata['link'] = trim($img_parameter_array[1]);
     													break;
														case 'rel':
															$imgdata['rel'] = trim($img_parameter_array[1]);
	      											break;
														case 'usemap':
															$imgdata['usemap'] = trim($img_parameter_array[1]);
			     										break;
														case 'height':
															$imgdata['height'] = trim($img_parameter_array[1]);
				     									break;
														case 'width':
															$imgdata['width'] = trim($img_parameter_array[1]);
 					    								break;
														case 'max':
															$imgdata['max'] = trim($img_parameter_array[1]);
 					    								break;
														case 'imalign':
															$imgdata['imalign'] = trim($img_parameter_array[1]);
 					    								break;
														case 'styleimage':
															$imgdata['styleimage'] = trim($img_parameter_array[1]);
 					    								break;
														case 'align':
															$imgdata['align'] = trim($img_parameter_array[1]);
 					    								break;
														case 'stylebox':
															$imgdata['stylebox'] = trim($img_parameter_array[1]);
 					    								break;
														case 'styledesc':
															$imgdata['styledesc'] = trim($img_parameter_array[1]);
 					    								break;
														case 'block':
															$imgdata['block'] = trim($img_parameter_array[1]);
 					    								break;
														case 'class':
															$imgdata['class'] = trim($img_parameter_array[1]);
 					    								break;
														case 'desc':
															$imgdata['desc'] = trim($img_parameter_array[1]);
 					    								break;
														case 'title':
															$imgdata['title'] = trim($img_parameter_array[1]);
 					    								break;
														case 'metadata':
															$imgdata['metadata'] = trim($img_parameter_array[1]);
 					    								break;
														case 'alt':
															$imgdata['alt'] = trim($img_parameter_array[1]);
 					    								break;
													} // switch ($img_parameter_array[0])
												} // if ( $img_condition_status == true )
	
											} // if ( !empty($img_parameter_array[0] )
										} // if a parameter exists
									} // for each parameter
								} // if ( !empty($img_parameters_array) )
							} // if ( !empty($img_condition[1]) )
						}  // if ( !empty($img_condition) )
					} // if ( !empty($var) )
				} // for each condition
			} // if ( !empty($img_conditions_array) )
		return $imgdata;
		}
	}
////////////////////////////////////End of function for processing default and mandatory parameters////////////////////
	//function calls
	if ( !empty($imgdata['default']) || !empty($imgdata['mandatory'])) {
		if (!empty($imgdata['default'])) { 
			$imgdata = apply_default_and_mandatory($imgdata, 'default');	//first process defaults
			$imgdata = array_merge($imgdata, $params);					//then apply user settings, overriding defaults
		}
		//apply mandatory settings, overriding user settings
		if (!empty($imgdata['mandatory'])) $imgdata = apply_default_and_mandatory($imgdata, 'mandatory');
	}

//////////////////////////////////////////////////// Error messages and clean javascript //////////////////////////////
	// Must set at least one image identifier
	$set = !empty($imgdata['fileId']) + !empty($imgdata['id']) + !empty($imgdata['src']) + !empty($imgdata['attId']) 
		+ !empty($imgdata['randomGalleryId']) + !empty($imgdata['fgalId']);
	if ($set == 0) {
		return tra("''No image specified. One of the following parameters must be set: fileId, randomGalleryId, fgalId, attId, id.''");
	} elseif ($set >1) {
		return tra("''Use one and only one of the following parameters: fileId, randomGalleryId, fgalId, attId, id, or src.''");
	}
	// Clean up src URLs to exclude javascript
	if (stristr(str_replace(' ', '', $imgdata['src']), 'javascript:')) {
		$imgdata['src']  = '';
	}
	if (strstr($imgdata['src'], 'javascript:')) {
		$imgdata['src']  = '';
	}
	
	if (!isset($data) or !$data) {
		$data = '&nbsp;';
	}

	include_once('tiki-sefurl.php');
	//////////////////////Process multiple images //////////////////////////////////////
	//Process "|" or "," separated images
	$notice = '<!--' . tra('PluginImg: User lacks permission to view image') . '-->';
	$srcmash = $imgdata['fileId'] . $imgdata['id'] . $imgdata['attId'] . $imgdata['src'];
	if (( strpos($srcmash, '|') !== false ) || (strpos($srcmash, ',') !== false ) || !empty($imgdata['fgalId'])) {
		$separator = '';
		$id = '';
		if (!empty($imgdata['id'])) {
			$id = 'id';
		} elseif (!empty($imgdata['fileId'])) {
			$id = 'fileId';
		} elseif (!empty($imgdata['attId'])) {
			$id = 'attId';
		} else {
			$id = 'src';
		}		
		if ( strpos($imgdata[$id], '|') !== false ) {
			$separator = '|';
		} elseif ( strpos($imgdata[$id], ',') !== false ) {
			$separator = ',';
		}
		$repl = '';
		$id_list = array();
		if (!empty($separator)) {
			$id_list = explode($separator, $imgdata[$id]);
		} else { //fgalId parameter - show all images in a file gallery
			$filegallib = TikiLib::lib('filegal');
			$galdata = $filegallib->get_files(0, -1, 'created_desc', '', $imgdata['fgalId'], false, false, false, true, false, false, false, false, '', true, false, false);
			foreach ($galdata['data'] as $filedata) {
				$id_list[] = $filedata['id'];
			}
			$id = 'fileId';
		}
		$params[$id] = '';
		foreach ($id_list as $i => $value) {
			$params[$id] = trim($value);
			$params['fgalId'] = '';
			$repl .= wikiplugin_img($data, $params, $offset, $parseOptions);
		}
		if (strpos($repl, $notice) !== false) {
			return $repl;
		} else {
			$repl = "\n\r" . '<br style="clear:both" />' . "\r" . $repl . "\n\r" . '<br style="clear:both" />' . "\r";
			return $repl; // return the multiple images
		}
	}
	
	$repl = '';

	//////////////////////Set src for html///////////////////////////////
	//Set variables for the base path for images in file galleries, image galleries and attachments
	global $base_url;
	$absolute_links = (!empty($parseOptions['absolute_links'])) ? $parseOptions['absolute_links'] : false;
	$imagegalpath = ($absolute_links ? $base_url : '') . 'show_image.php?id=';
	$filegalpath = ($absolute_links ? $base_url : '') . 'tiki-download_file.php?fileId=';
	$attachpath = ($absolute_links ? $base_url : '') . 'tiki-download_wiki_attachment.php?attId=';
	
	//get random image and treat as file gallery image afterwards
	if (!empty($imgdata['randomGalleryId'])) {
		$filegallib = TikiLib::lib('filegal');
		$dbinfo = $filegallib->get_file(0, $imgdata['randomGalleryId']);
		$imgdata['fileId'] = $dbinfo['fileId'];
		$basepath = $prefs['fgal_use_dir'];
	}

	if (empty($imgdata['src'])) {
		if (!empty($imgdata['id'])) {
			$src = $imagegalpath . $imgdata['id'];
		} elseif (!empty($imgdata['fileId'])) {
			$smarty->loadPlugin('smarty_modifier_sefurl');
			$src = smarty_modifier_sefurl($imgdata['fileId'], 'file');

			if ($absolute_links) {
				$src = TikiLib::tikiUrl($src);
			}
		} else {					//only attachments left
			$src = $attachpath . $imgdata['attId']; 
		}
	} elseif ( (!empty($imgdata['src'])) && $absolute_links && ! preg_match('|^[a-zA-Z]+:\/\/|', $imgdata['src']) ) {
		global $base_host, $url_path;
		$src = $base_host.( $imgdata['src'][0] == '/' ? '' : $url_path ) . $imgdata['src'];
	} elseif (!empty($imgdata['src']) && $tikidomain && !preg_match('|^https?:|', $imgdata['src'])) {
		$src = preg_replace("~img/wiki_up/~", "img/wiki_up/$tikidomain/", $imgdata['src']);
	} elseif (!empty($imgdata['src'])) {
		$src = $imgdata['src'];
	}
	
	$browse_full_image = $src; 

	///////////////////////////Get DB info for image size and metadata/////////////////////////////
	if (!empty($imgdata['height']) || !empty($imgdata['width']) || !empty($imgdata['max']) 
		|| !empty($imgdata['desc']) || strpos($imgdata['rel'], 'box') !== false 
		|| !empty($imgdata['stylebox']) || !empty($imgdata['styledesc']) || !empty($imgdata['button']) 
		|| !empty($imgdata['thumb'])  || !empty($imgdata['align']) || !empty($imgdata['metadata'])  || !empty($imgdata['fileId'])
	) {
		//Get ID numbers for images in galleries and attachments included in src as url parameter
		//So we can get db info for these too
		$parsed = parse_url($imgdata['src']);
		if (empty($parsed['host']) || (!empty($parsed['host']) && strstr($base_url, $parsed['host']))) {
			if (strlen(strstr($imgdata['src'], $imagegalpath)) > 0) {                                     
				$imgdata['id'] = substr(strstr($imgdata['src'], $imagegalpath), strlen($imagegalpath));   
			} elseif (strlen(strstr($imgdata['src'], $filegalpath)) > 0) {                                
				$imgdata['fileId'] = substr(strstr($imgdata['src'], $filegalpath), strlen($filegalpath)); 	
			} elseif (strlen(strstr($imgdata['src'], $attachpath)) > 0) {                                 
				$imgdata['attId'] = substr(strstr($imgdata['src'], $attachpath), strlen($attachpath));   
			}
		}
		$imageObj = '';
		require_once('lib/images/images.php');
		//Deal with images with info in tiki databases (file and image galleries and attachments)
		if (empty($imgdata['randomGalleryId']) && (!empty($imgdata['id']) || !empty($imgdata['fileId']) 
			|| !empty($imgdata['attId'])) 
		) {
			//Try to get image from database
			if (!empty($imgdata['id'])) {
				global $imagegallib; 
				include_once('lib/imagegals/imagegallib.php');
				$dbinfo = $imagegallib->get_image_info($imgdata['id'], 'o');
				$dbinfo2 = $imagegallib->get_image($imgdata['id'], 'o');
				$dbinfo = isset($dbinfo) && isset($dbinfo2) ? array_merge($dbinfo, $dbinfo2) : array();
				$dbinfot = $imagegallib->get_image_info($imgdata['id'], 't');
				$dbinfot2 = $imagegallib->get_image($imgdata['id'], 't');
				$dbinfot = isset($dbinfot) && isset($dbinfot2) ? array_merge($dbinfot, $dbinfot2) : array();
				$basepath = $prefs['gal_use_dir'];
			} elseif (!isset($dbinfo) && !empty($imgdata['fileId'])) {
				$filegallib = TikiLib::lib('filegal');
				$dbinfo = $filegallib->get_file($imgdata['fileId']);
				$basepath = $prefs['fgal_use_dir'];
			} else {					//only attachments left
				global $atts;
				global $wikilib;
				include_once('lib/wiki/wikilib.php');
				$dbinfo = $wikilib->get_item_attachment($imgdata['attId']);
				$basepath = $prefs['w_use_dir'];
			}		
			//Give error messages if file doesn't exist, isn't an image. Display nothing if user lacks permission
			if (!empty($imgdata['fileId']) || !empty($imgdata['id']) || !empty($imgdata['attId'])) {
				if ( ! $dbinfo ) {
					return '^' . tra('File not found.') . '^';
				} elseif ( substr($dbinfo['filetype'], 0, 5) != 'image' AND !preg_match('/thumbnail/i', $imgdata['fileId'])) {
					return '^' . tra('File is not an image.') . '^';
				} elseif (!class_exists('Image')) {
					return '^' . tra('Server does not support image manipulation.') . '^';
				} elseif (!empty($imgdata['fileId'])) {
					if (!$userlib->user_has_perm_on_object($user, $dbinfo['galleryId'], 'file gallery', 'tiki_p_download_files')) {
						return $notice;
					}
				} elseif (!empty($imgdata['id'])) {
					if (!$userlib->user_has_perm_on_object($user, $dbinfo['galleryId'], 'image gallery', 'tiki_p_view_image_gallery')) {
						return $notice;
					}
				} elseif (!empty($imgdata['attId'])) {
					if (!$userlib->user_has_perm_on_object($user, $dbinfo['page'], 'wiki page', 'tiki_p_wiki_view_attachments')) {
						return $notice;
					}
				}
			}
		} //finished getting info from db for images in image or file galleries or attachments

		//get image to get height and width and iptc data
		if (!empty($dbinfo['data'])) {
			$imageObj = new Image($dbinfo['data'], false);
			$filename = $dbinfo['filename'];
		} elseif (!empty($dbinfo['path'])) {
			$imageObj = new Image($basepath . $dbinfo['path'], true);	
			$filename = $dbinfo['filename'];
		} else {
			$imageObj = new Image($src, true);
			$filename = $src;
		}

		//if we need iptc data
		$xmpview = !empty($imgdata['metadata']) ? true : false;
		if ($imgdata['desc'] == 'idesc' || $imgdata['desc'] == 'ititle' || $xmpview) {
			$metadata = $imageObj->getMetadata(null, null, $xmpview)->typemeta;
			//description from image iptc
			$idesc = isset($metadata['iptc_raw']['2#120'][0]) ? $metadata['iptc_raw']['2#120'][0] : '';	
			//title from image iptc	
			$ititle = isset($metadata['iptc_raw']['2#005'][0]) ? $metadata['iptc_raw']['2#005'][0] : '';
		}
				
		$fwidth = '';
		$fheight = '';
		if (isset($parseOptions['indexing']) && $parseOptions['indexing']) {
			$fwidth = 1;
			$fheight = 1;
		} else {
			$fwidth = $imageObj->get_width();
			$fheight = $imageObj->get_height();
		}
		//get image gal thumbnail image for height and width
		if (!empty($dbinfot['data']) || !empty($dbinfot['path'])) {
			if (!empty($dbinfot['data'])) {
				$imageObjt = new Image($dbinfot['data'], false);
			} elseif (!empty($dbinfot['path'])) {
				$imageObjt = new Image($basepath . $dbinfot['path'] . '.thumb', true);	
			}
			$fwidtht = $imageObjt->get_width();
			$fheightt = $imageObjt->get_height();
		}
	/////////////////////////////////////Add image dimensions to src string////////////////////////////////////////////
		//Use url resizing parameters for file gallery images to set $height and $width
		//since they can affect other elements; overrides plugin parameters
		if (!empty($imgdata['fileId']) && strpos($src, '&') !== false) {
			$urlthumb = strpos($src, '&thumbnail');
			$urlprev = strpos($src, '&preview');
			$urldisp = strpos($src, '&display'); 
			preg_match('/(?<=\&max=)[0-9]+(?=.*)/', $src, $urlmax);
			preg_match('/(?<=\&x=)[0-9]+(?=.*)/', $src, $urlx);
			preg_match('/(?<=\&y=)[0-9]+(?=.*)/', $src, $urly);
			preg_match('/(?<=\&scale=)[0]*\.[0-9]+(?=.*)/', $src, $urlscale);
			if (!empty($urlmax[0]) && $urlmax[0] > 0) $imgdata['max'] = $urlmax[0];
			if (!empty($urlx[0]) && $urlx[0] > 0) $imgdata['width'] = $urlx[0];
			if (!empty($urly[0]) && $urly[0] > 0) $imgdata['height'] = $urly[0];
			if (!empty($urlscale[0]) && $urlscale[0] > 0) {
				$height = floor($urlscale[0] * $fheight);
				$width = floor($urlscale[0] * $fwidth);
				$imgdata['width'] = '';
				$imgdata['height'] = '';
			}	
			if ($urlthumb != false && empty($imgdata['height']) && empty($imgdata['width']) && empty($imgdata['max'])) $imgdata['max'] = 120;
			if ($urlprev != false && empty($urlscale[0]) && empty($imgdata['height']) && empty($imgdata['width']) && empty($imgdata['max']) ) $imgdata['max'] = 800;
		}
		//Note if image gal url thumb parameter is used
		$imgalthumb = false;
		if (!empty($imgdata['id'])) {
			preg_match('/(?<=\&thumb=1)[0-9]+(?=.*)/', $src, $urlimthumb);
			if (!empty($urlimthumb[0]) && $urlimthumb[0] > 0) $imgalthumb = true;
		}
			
		//Now set dimensions based on plugin parameter settings
		if (!empty($imgdata['max']) || !empty($imgdata['height']) || !empty($imgdata['width']) 
			|| !empty($imgdata['thumb'])
		) {
			//Convert % and px in height and width
			$scale = '';
			if (strpos($imgdata['height'], '%') !== false || strpos($imgdata['width'], '%') !== false) {
				if ((strpos($imgdata['height'], '%') !== false && strpos($imgdata['width'], '%') !== false) 
					&& (empty($imgdata['fileId']) || (empty($urlx[0]) && empty($urly[0])))) {
					$imgdata['height'] = floor(rtrim($imgdata['height'], '%') / 100 * $fheight);
					$imgdata['width'] = floor(rtrim($imgdata['width'], '%') / 100 * $fwidth);
				} elseif (strpos($imgdata['height'], '%') !== false) {
					if ($imgdata['fileId']) {
						$scale = rtrim($imgdata['height'], '%') / 100;
						$height = floor($scale * $fheight);
					} else {
						$imgdata['height'] = floor(rtrim($imgdata['height'], '%') / 100 * $fheight);
					}
				} else {
					if ($imgdata['fileId']) {
						$scale = rtrim($imgdata['width'], '%') / 100;
						$width = floor($scale * $fwidth);
					} else {
						$imgdata['width'] = floor(rtrim($imgdata['width'], '%') / 100 * $fwidth);
					}
				}
			} elseif (strpos($imgdata['height'], 'px') !== false || strpos($imgdata['width'], 'px') !== false) {
				if (strpos($imgdata['height'], 'px') !== false) {
					$imgdata['height'] = rtrim($imgdata['height'], 'px');
				} else {
					$imgdata['width'] = rtrim($imgdata['width'], 'px');
				}
			}
			// Adjust for max setting, keeping aspect ratio
			if (!empty($imgdata['max'])) {
				if (($fwidth > $imgdata['max']) || ($fheight > $imgdata['max'])) {
					//use image gal thumbs when possible
					if ((!empty($imgdata['id']) && $imgalthumb == false) 
						&& ($imgdata['max'] < $fwidtht || $imgdata['max'] < $fheightt)
					) {
						$src .= '&thumb=1';
						$imgalthumb == true;
					}
					if ($fwidth > $fheight) {
						$width = $imgdata['max'];
						$height = floor($width * $fheight / $fwidth);
					} else {
						$height = $imgdata['max'];
						$width = floor($height * $fwidth / $fheight);	
					}
				//cases where max is set but image is smaller than max 
				} else {                             
					$height = $fheight;
					$width = $fwidth;
				}
			// Adjust for user settings for height and width if max isn't set.	
			} elseif (!empty($imgdata['height']) ) {
				//use image gal thumbs when possible
				if ((!empty($imgdata['id']) && $imgalthumb == false) 
					&& ($imgdata['height'] < $fheightt)
				) {
					$src .= '&thumb=1';
					$imgalthumb == true;
				}
				$height = $imgdata['height'];
				if (empty($imgdata['width']) && $fheight > 0) {
					$width = floor($height * $fwidth / $fheight);
				} else {
					$width = $imgdata['width'];
				}
			} elseif (!empty($imgdata['width'])) {
				//use image gal thumbs when possible
				if ((!empty($imgdata['id']) && $imgalthumb == false) 
					&& ($imgdata['width'] < $fwidtht)
				) {
					$src .= '&thumb=1';
					$imgalthumb == true;
				}
				$width =  $imgdata['width'];
				if (empty($imgdata['height']) && $fwidth > 0) {
					$height = floor($width * $fheight / $fwidth);
				} else {
					$height = $imgdata['height'];
				}
			// If not otherwise set, use default setting for thumbnail height if thumb is set
			} elseif ((!empty($imgdata['thumb']) || !empty($urlthumb))  && empty($scale)) {
				if (!empty($imgdata['fileId'])) {
					$thumbdef = $prefs['fgal_thumb_max_size'];
				} else {
					$thumbdef = 84;  
				}
				//handle image gal thumbs
				if (!empty($imgdata['id']) && !empty($fwidtht)  && !empty($fheightt)) {
					$width = $fwidtht;
					$height = $fheightt;
					if ($imgalthumb == false) {
						$src .= '&thumb=1';
						$imgalthumb == true;
					}
				} else {
					if (($fwidth > $thumbdef) || ($fheight > $thumbdef)) {
						if ($fwidth > $fheight) {
							$width = $thumbdef;
							$height = floor($width * $fheight / $fwidth);
						} else {
							$height = $thumbdef;
							$width = floor($height * $fwidth / $fheight);	
						}
					} 
				}
			}
		}
		
		//Set final height and width dimension string
		//handle file gallery images separately to use server-side resizing capabilities
		$imgdata_dim = '';
		if (!empty($imgdata['fileId'])) {
			if (empty($urldisp) && empty($urlthumb)) {
				$src .= '&display';
			}
			if (!empty($scale) && empty($urlscale[0])) {
				$src .= '&scale=' . $scale;
			} elseif ((!empty($imgdata['max']) && $imgdata['thumb'] != 'download') 
					&& (empty($urlthumb) && empty($urlmax[0]) && empty($urlprev))
			) {
				$src .= '&max=' . $imgdata['max'];
			} elseif (!empty($width) || !empty($height)) {
				if ((!empty($width) && !empty($height)) && (empty($urlx[0]) && empty($urly[0]) && empty($urlscale[0]))) {
					$src .= '&x=' . $width . '&y=' . $height;
					$imgdata_dim .= ' width="' . $width . '"';
					$imgdata_dim .= ' height="' . $height . '"';
				} elseif (!empty($width) && (empty($urlx[0]) && empty($urlthumb) && empty($urlscale[0]))) {
					$src .= '&x=' . $width; 
					$height = $fheight;
					$imgdata_dim .= ' width="' . $width . '"';
					$imgdata_dim .= ' height="' . $height . '"';
				} elseif (!empty($height) && (empty($urly[0]) && empty($urlthumb) && empty($urlscale[0]))) {
					$src .= '&y=' . $height;
					$imgdata_dim = '';
					$width = $fwidth;
				}			
			} else {
				$imgdata_dim = '';
				$height = $fheight;
				$width = $fwidth;
				$imgdata_dim .= ' width="' . $width . '"';
				$imgdata_dim .= ' height="' . $height . '"';
			}
		} else {
			if (!empty($height)) {
				$imgdata_dim = ' height="' . $height . '"';
			} else {
				$imgdata_dim = '';
				$height = $fheight;
			}
			if (!empty($width)) {
				$imgdata_dim .= ' width="' . $width . '"';
			} else {
				$imgdata_dim = '';
				$width = $fwidth;
			}
		}
	}
		
	////////////////////////////////////////// Create the HTML img tag //////////////////////////////////////////////
	//Start tag with src and dimensions
	$src = filter_out_sefurl(htmlentities($src));

	include_once ('lib/mime/mimetypes.php');
	global $mimetypes;

	$tagName = '';
	if (!empty($dbinfo['filetype'])  && !empty($mimetypes['svg']) && $dbinfo['filetype'] == $mimetypes['svg']) {
		$tagName = 'div';
		$repldata = $dbinfo['data'];
		$replimg = '<div type="image/svg+xml" ';
		$imgdata['class'] .= ' svgImage pluginImg' . $imgdata['fileId'];
		$imgdata['class'] = trim($imgdata['class']);
	} else {
		$tagName = 'img';
		$replimg = '<img src="' . $src . '" ';
		$imgdata['class'] .= ' regImage pluginImg' . $imgdata['fileId'];
		$imgdata['class'] = trim($imgdata['class']);
	}

	if (!empty($imgdata_dim)) $replimg .= $imgdata_dim;
	
	//Create style attribute allowing for shortcut inputs 
	//First set alignment string
	$center = 'display:block; margin-left:auto; margin-right:auto;';	//used to center image and box
	if (!empty($imgdata['imalign'])) {
		$imalign = '';
		if ($imgdata['imalign'] == 'center') {
			$imalign = $center;
		} else {
			$imalign = 'float:' . $imgdata['imalign'] . ';';
		}
	} elseif ($imgdata['stylebox'] == 'border') {
		$imalign = $center;
	}
	//set entire style string
	if ( !empty($imgdata['styleimage']) || !empty($imalign) ) {
		$border = '';
		$style = '';
		$borderdef = 'border:1px solid darkgray;';   //default border when styleimage set to border
		if ( !empty($imgdata['styleimage'])) {
			if (!empty($imalign)) {
				if ((strpos(trim($imgdata['styleimage'], ' '), 'float:') !== false) 
					|| (strpos(trim($imgdata['styleimage'], ' '), 'display:') !== false)
				) {
					$imalign = '';			//override imalign setting if style image contains alignment syntax
				}
			}
			if ($imgdata['styleimage'] == 'border') {
				$border = $borderdef;
			} else if (strpos($imgdata['styleimage'], 'hidden') === false 
				&& strpos($imgdata['styleimage'], 'position') === false
			) {	// quick filter for dangerous styles
				$style = $imgdata['styleimage'];
			}
		}
		$replimg .= ' style="' . $imalign . $border . $style . '"';
	}
	//alt
	if ( !empty($imgdata['alt']) ) {
		$replimg .= ' alt="' . $imgdata['alt'] . '"';
	} elseif ( !empty($imgdata['desc']) ) {		
		$replimg .= ' alt="' . $imgdata['desc'] . '"';	
	} elseif (!empty($dbinfo['description'])) {		
		$replimg .= ' alt="' . $dbinfo['description'] . '"';		
	} else {
		$replimg .= ' alt="Image"';
	}
	//usemap
	if ( !empty($imgdata['usemap']) ) {
		$replimg .= ' usemap="#' . $imgdata['usemap'] . '"';
	}
	//class
	if ( !empty($imgdata['class']) ) {
		$replimg .= ' class="' . $imgdata['class'] . '"';
	}
	
	//title (also used for description and link title below)
	//first set description, which is used for title if no title is set
	if (!empty($imgdata['desc']) || !empty($imgdata['title'])) {
		$desc = '';
		$imgname = '';
		$desconly = '';
		if ( !empty($imgdata['desc']) ) {
			//attachment database uses comment instead of description or name
			if (!empty($dbinfo['comment'])) {
				$desc = $dbinfo['comment'];
				$imgname = $dbinfo['comment'];
			} elseif (isset($dbinfo)) {
				$desc = !empty($dbinfo['description']) ? $dbinfo['description'] : '';
				$imgname = !empty($dbinfo['name']) ? $dbinfo['name'] : '';
			}
			switch ($imgdata['desc']) {
				case 'desc':
					$desconly = $desc;
    				break;
				case 'idesc':
					$desconly = $idesc;
    				break;
				case 'name':
					$desconly = $imgname;
    				break;
				case 'ititle':
					$desconly = $ititle;
    				break;
				case 'namedesc':
					$desconly = $imgname.((!empty($imgname) && !empty($desc))?' - ':'').$desc;
    				break;
				default:
					$desconly = $imgdata['desc'];
			}
		}
		//now set title
		$imgtitle = '';
		$titleonly = '';
		if ( !empty($imgdata['title']) || !empty($desconly)) {
			$imgtitle = ' title="';
			if ( !empty($imgdata['title']) ) {
				switch ($imgdata['title']) {
				case 'desc':
					$titleonly = $desc;
    				break;
				case 'name':
					$titleonly = $imgname;
    				break;
				case 'namedesc':
					$titleonly = $imgname.((!empty($imgname) && !empty($desc))?' - ':'').$desc;
    				break;
				default:
					$titleonly = $imgdata['title'];
				}
			//use desc setting for title if title is empty
			} else {										
				$titleonly = $desconly;
			}
			$imgtitle .= $titleonly . '"';
			$replimg .= $imgtitle;
		}
	}	

	if (empty($repldata)) {
		$replimg .= ' />' . "\r";
	} else {
		$replimg .= '>' . $repldata . '</' . $tagName . '>';
	}

	////////////////////////////////////////// Create the HTML link ///////////////////////////////////////////
	//Variable for identifying if javascript mouseover is set
	if (($imgdata['thumb'] == 'mouseover') || ($imgdata['thumb'] == 'mousesticky')) {
		$javaset = 'true';
	} else {
		$javaset = '';
	}
	// Set link to user setting or to image itself if thumb is set
	if (!empty($imgdata['link']) || (!empty($imgdata['thumb']) && !(isset($params['link']) && empty($params['link'])))) {
		$mouseover = '';
		if (!empty($imgdata['link'])) {
			$link = $imgdata['link'];
		} elseif ((($imgdata['thumb'] == 'browse') || ($imgdata['thumb'] == 'browsepopup')) && !empty($imgdata['id'])) {
			$link = 'tiki-browse_image.php?imageId=' . $imgdata['id'];
		} elseif ($javaset == 'true') {
			$link = 'javascript:void(0)';
			$popup_params = array( 'text'=>$data, 'width'=>$fwidth, 'height'=>$fheight, 'background'=>$browse_full_image);
			if ($imgdata['thumb'] == 'mousesticky') {
				$popup_params['sticky'] = true;
			}
			$smarty->loadPlugin('smarty_function_popup');
			$mouseover = ' ' . smarty_function_popup($popup_params, $smarty);
		} else {
			if (!empty($imgdata['fileId']) && $imgdata['thumb'] != 'download' && empty($urldisp)) {
				$link = $browse_full_image . '&display';
			} else {
				$link = $browse_full_image;
			}
		}
		// Set other link-related attributes				
		// target
		$imgtarget= '';
		if (($prefs['popupLinks'] == 'y' && (preg_match('#^([a-z0-9]+?)://#i', $link) 
			|| preg_match('#^www\.([a-z0-9\-]+)\.#i', $link))) || ($imgdata['thumb'] == 'popup') 
			|| ($imgdata['thumb'] == 'browsepopup')
		) {
			if (!empty($javaset) || ($imgdata['rel'] == 'box')) {
				$imgtarget= '';
			} else {
				$imgtarget = ' target="_blank"';
			}
		}
		// rel
		!empty($imgdata['rel']) ? $linkrel = ' rel="'.$imgdata['rel'].'"' : $linkrel = '';
		// title
		!empty($imgtitle) ? $linktitle = $imgtitle : $linktitle = '';
		
		$link = filter_out_sefurl(htmlentities($link));

		//Final link string
		$replimg = "\r\t" . '<a href="' . $link . '" class="internal"' . $linkrel . $imgtarget . $linktitle 
					. $mouseover . '>' ."\r\t\t" . $replimg . "\r\t" . '</a>';
	}
	
	//Add link string to rest of string
	$repl .= $replimg;

//////////////////////////Generate metadata dialog box and jquery (dialog icon added in next section)////////////////////////////////////
	if ($imgdata['metadata'] == 'view') {
		//create unique id's in case of multiple pictures
		static $lastval = 0;
		$id = 'imgdialog-' . ++$lastval;
		$id_link = $id . '-link';
		$dialog = $imageObj->metadata->dialogMetadata($imageObj->metadata, $id, $filename);
		$repl .= $dialog;
		$jq = '$(document).ready(function() {
					$("#' . $id . '").css(\'z-index\', \'1005\').dialog({
							autoOpen: false,
							width: 700,
							zIndex: 1005
					});				
						
					$("#' . $id_link . '").click(function() {
							$("#' . $id . '").accordion({
								autoHeight: false,
								collapsible: true
							}).dialog(\'open\');
							return false;
					});
				});';
		global $headerlib;
		$headerlib->add_jq_onready($jq);
	}
	//////////////////////  Create enlarge button, metadata icon, description and their divs////////////////////
	//Start div that goes around button and description if these are set
	if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['styledesc']) || !empty($imgdata['metadata'])) {
		//To set room for enlarge button under image if there is no description
		$descheightdef = 'height:17px;clear:left;';						
		$repl .= "\r\t" . '<div class="mini" style="width:' . $width . 'px;';
		if ( !empty($imgdata['styledesc']) ) {
			if (($imgdata['styledesc'] == 'left') || ($imgdata['styledesc'] == 'right')) {
				$repl .= 'text-align:' . $imgdata['styledesc'] . '">';
			} else {
			$repl .= $imgdata['styledesc'] . '">';
			}
		} elseif ((!empty($imgdata['button'])) && (empty($desconly))) {
			$repl .= $descheightdef . '">';
		} else {
			$repl .= '">';
		}
		
		//Start description div that also includes enlarge button div
		$repl .= "\r\t\t" . '<div class="thumbcaption">';
		
		//Enlarge button div and link string (innermost div)
		if (!empty($imgdata['button'])) {
			if (empty($link) || (!empty($link) && !empty($javaset))) {
				if ((($imgdata['button'] == 'browse') || ($imgdata['button'] == 'browsepopup')) && !empty($imgdata['id'])) {
					$link_button = 'tiki-browse_image.php?imageId=' . $imgdata['id'];
				} else {
					if (!empty($imgdata['fileId']) && $imgdata['button'] != 'download') {
						$link_button = $browse_full_image . '&display';
					} elseif (!empty($imgdata['attId']) && $imgdata['thumb'] == 'download') {
						$link = $browse_full_image . '&download=y';
					} else {
						$link_button = $browse_full_image;
					}
				}
			} else {
				$link_button = $link;
			}
			//Set button rel
			!empty($imgdata['rel']) ? $linkrel_button = ' rel="'.$imgdata['rel'].'"' : $linkrel_button = '';
			//Set button target
			if (empty($imgtarget) && (empty($imgdata['thumb']) || !empty($javaset))) {
				if (($imgdata['button'] == 'popup') || ($imgdata['button'] == 'browsepopup')) {
					$imgtarget_button = ' target="_blank"';
				} else {
					$imgtarget_button = '';
				}
			} else {
				$imgtarget_button = $imgtarget;
			}
			$repl .= "\r\t\t\t" . '<div class="magnify" style="float:right">';
			$repl .= "\r\t\t\t\t" . '<a href="' . $link_button . '"' . $linkrel_button . $imgtarget_button ;
			$repl .= ' class="internal"';
			if (!empty($titleonly)) {
				$repl .= ' title="' . $titleonly . '"';
			}
			$repl .= ">\r\t\t\t\t" . '<img class="magnify" src="./img/icons/magnifier.png" alt="'.tra('Enlarge').'" /></a>' . "\r\t\t\t</div>";
		}
		//Add metadata icon
		if ($imgdata['metadata'] == 'view') {
			$repl .= '<div style="float:right; margin-right:2px"><a href="#" id="' . $id_link . '"><img src="./img/icons/tag_blue.png" alt="' . tra('Metadata') . '" title="' . tra('Metadata') . '"/></a></div>';
		}
		//Add description based on user setting (use $desconly from above) and close divs
		isset($desconly) ? $repl .= $desconly : '';
		$repl .= "\r\t\t</div>";
		$repl .= "\r\t</div>";
	}
	///////////////////////////////Wrap in overall div that includes image if needed////////////////	
	//Need a box if any of these are set
	if (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['metadata']) 
		|| !empty($imgdata['stylebox']) || !empty($imgdata['align'])
	) {
		//Make the div surrounding the image 2 pixels bigger than the image
		if (empty($height)) $height = '';
		if (empty($width)) $width = '';
		$boxwidth = $width + 2;
		$boxheight = $height + 2;
		$alignbox = '';
		$class = '';
		if (!empty($imgdata['align'])) {
			if ($imgdata['align'] == 'center') {
				$alignbox = $center;
			} else {
				$alignbox = 'float:' . $imgdata['align'] . '; margin-' . ($imgdata['align'] == 'left'? 'right': 'left') .':5px;';
			}
		}
		//first set stylebox string if style box is set
		if (!empty($imgdata['stylebox']) || !empty($imgdata['align'])) {		//create strings from shortcuts first
			if ( !empty($imgdata['stylebox'])) {
				if ($imgdata['stylebox'] == 'border') {
					$class = 'class="imgbox" ';
					if (!empty($alignbox)) {
						if ((strpos(trim($imgdata['stylebox'], ' '), 'float:') !== false) 
							|| (strpos(trim($imgdata['stylebox'], ' '), 'display:') !== false)
						) {
							$alignbox = '';			//override align setting if stylebox contains alignment syntax
						}
					}
				} else {
					$styleboxinit = $imgdata['stylebox'] . ';';
				}
			}
			if (empty($imgdata['button']) && empty($imgdata['desc']) && empty($styleboxinit)) {
				$styleboxplus = $alignbox . ' width:' . $boxwidth . 'px; height:' . $boxheight . 'px';
			} elseif (!empty($styleboxinit)) {
				if ((strpos(trim($imgdata['stylebox'], ' '), 'height:') === false) 
					&& (strpos(trim($imgdata['stylebox'], ' '), 'width:') === false)
				) {
					$styleboxplus = $styleboxinit . ' width:' . $boxwidth . 'px;';
				} else {
					$styleboxplus = $styleboxinit;
				}
			} else {
				$styleboxplus = $alignbox . ' width:' . $boxwidth . 'px;';
			}
		} elseif (!empty($imgdata['button']) || !empty($imgdata['desc']) || !empty($imgdata['metadata'])) {
		$styleboxplus = ' width:' . $boxwidth . 'px;';
		}
	}
	if ( !empty($styleboxplus)) {
		$repl = "\r" . '<div ' . $class . 'style="' . $styleboxplus . '">' . $repl . "\r" . '</div>';
	}
//////////////////////////////////////Place 'clear' block///////////////////////////////////////////////////////////
	if ( !empty($imgdata['block']) ) {
		switch ($imgdata['block']) {
		case 'top': 
			$repl = "\n\r<br style=\"clear:both\" />\r" . $repl;
    		break;
		case 'bottom': 
			$repl = $repl . "\n\r<br style=\"clear:both\" />\r";
    		break;
		case 'both': 
			$repl = "\n\r<br style=\"clear:both\" />\r" . $repl . "\n\r<br style=\"clear:both\" />\r";
    		break;
		case 'top': 
    		break;
		} 
	} 
	// Mobile
	if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') {
		$repl = '{img src=' . $src . "\"}\n<p>" . $imgdata['desc'] . '</p>'; 
	}

	global $tiki_p_edit, $fromTracker;
	$globalperms = Perms::get(array( 'type' => 'file gallery', 'object' => $imgdata['galleryId'] ));

	if (
		$prefs['feature_draw'] == 'y' &&
		$globalperms->upload_files == 'y' &&
		empty($src) == true &&
		(
			$tiki_p_edit == 'y' ||
			$fromTracker == true
		)
	) {
		if ($prefs['wiki_edit_icons_toggle'] == 'y' && !isset($_COOKIE['wiki_plugin_edit_view'])) {
			$iconDisplayStyle = " style='display:none;'";
		} else {
			$iconDisplayStyle = '';
		}
		$repl .= "<a href='tiki-edit_draw.php?fileId={$imgdata['fileId']}' onclick='return $(this).ajaxEditDraw();' title='".tr("Edit: Image") . " ".tr("(experimental)") . "'" .
					" class='editplugin pluginImgEdit{$imgdata['fileId']}' data-fileid='{$imgdata['fileId']}' data-galleryid='{$imgdata['galleryId']}'{$iconDisplayStyle}>" .
					"<img width='16' height='16' class='icon' alt='Edit' src='img/icons/page_edit.png' /></a>";
	}
	
	return '~np~' . $repl. "\r" . '~/np~';
}
Exemplo n.º 11
0
/**
 * Smarty {formhelp} function plugin
 *
 * Type:	function
 * Name:	formhelp
 * Input:
 *			- note		(optional)	words that are displayed, can also be an array, where: 'key: value'<br /> is printed
 *									only displayed if site_form_help is enabled
 *			- link		(optional)	provide a link to an internal page (avoids the problem with links being inerpreted
 *									prematurely by the tra() function
 *									<package>/<path to file>/<title>
 *			- package	(optional)	creates a page to 'Package'.ucfirst( $package ) and takes precedence over $page, should both be set.
 *									only dispalyed if help is enabled
 *			- install	(optional)	used for packages that require a separate installation
 *									passed in as an array:
 *										package => name of package to be installed
 *										file => path to installation file e.g.: admin/install.php
 *			- page		(optional)	page name on bitweaver
 *									only dispalyed if help is enabled
 *			- force		(optional)	if set, it will always dipslay this entry regardless of the feature settings
 */
function smarty_function_formhelp($pParams, &$gBitSmarty)
{
    $atts = $ret_note = $ret_page = $ret_link = $ret_install = '';
    if (!empty($pParams['hash'])) {
        $hash =& $pParams['hash'];
    } else {
        // maybe params were passed in separately
        $hash =& $pParams;
    }
    // we need to do some hash modification if we're in the installer
    if (!empty($hash['is_installer'])) {
        if (!empty($hash['note']['upgrade'])) {
            $hash['note']['version'] = $hash['note']['upgrade'];
            unset($hash['note']['upgrade']);
        }
    }
    foreach ($hash as $key => $val) {
        switch ($key) {
            case 'note':
            case 'warning':
            case 'link':
            case 'page':
                $rawHash[$key] = $val;
                break;
            case 'label':
            case 'package':
            case 'install':
            case 'force':
                ${$key} = $val;
                break;
            default:
                if ($val) {
                    $atts .= $key . '="' . $val . '" ';
                }
                break;
        }
    }
    if (!empty($package)) {
        $rawHash['page'] = ucfirst($package) . 'Package';
    }
    // if link was passed in as a string, convert it into an array
    if (!empty($rawHash['link']) && is_string($rawHash['link'])) {
        $l = explode('/', $rawHash['link']);
        unset($rawHash['link']);
        // package is first, title last, and all remaining elements file (can be 'foo/bar.php' as well)
        $rawHash['link']['package'] = array_shift($l);
        $rawHash['link']['title'] = array_pop($l);
        $rawHash['link']['file'] = implode('/', $l);
    }
    global $gBitSystem;
    if ($gBitSystem->isFeatureActive('site_online_help') || $gBitSystem->isFeatureActive('site_form_help') || $force == 'y') {
        if (!empty($rawHash)) {
            if (!empty($rawHash['page']) && ($gBitSystem->isFeatureActive('site_online_help') || $force == 'y')) {
                $ret_page = '<strong>' . tra('Online help') . '</strong>: <a class=\'external\' href=\'http://doc.bitweaver.org/wiki/index.php?page=' . $rawHash['page'] . '\'>' . $rawHash['page'] . '</a><br />';
            }
            if (!empty($rawHash['link']) && ($gBitSystem->isFeatureActive('site_online_help') || $force == 'y')) {
                if (is_array($rawHash['link'])) {
                    $ret_link = '<strong>' . tra('IntraLink') . '</strong>: ';
                    $ret_link .= '<a href=\'';
                    $ret_link .= constant(strtoupper($rawHash['link']['package']) . '_PKG_URL') . $rawHash['link']['file'];
                    $ret_link .= '\'>' . tra($rawHash['link']['title']) . '</a>';
                }
            }
            if (!empty($rawHash['note']) && $gBitSystem->isFeatureActive('site_form_help') || !empty($force) && !empty($rawHash['note'])) {
                if (is_array($rawHash['note'])) {
                    foreach ($rawHash['note'] as $name => $value) {
                        if ($name == 'install') {
                            $ret_install = '<strong>' . tra('Install') . '</strong>: ' . tra('To use this package, you will first have to run the package specific installer') . ': ';
                            $ret_install .= '<a href=\'';
                            $ret_install .= constant(strtoupper($value['package']) . '_PKG_URL') . $value['file'];
                            $ret_install .= '\'>' . ucfirst($value['package']) . '</a>';
                        } else {
                            $ret_note .= '<strong>' . ucfirst(tra($name)) . '</strong>: ' . tra($value) . '<br />';
                        }
                    }
                } else {
                    $ret_note .= tra($rawHash['note']) . '<br />';
                }
            }
            if (!empty($rawHash['warning'])) {
                $ret_note .= '<span class="warning">' . tra($rawHash['warning']) . '</span><br />';
            }
            // join all the output content into one string
            $content = $ret_note . $ret_page . $ret_link . $ret_install;
            $html = '';
            // using the overlib popup system
            if (!empty($content)) {
                if ($gBitSystem->isFeatureActive('site_help_popup')) {
                    $gBitSmarty->loadPlugin('smarty_modifier_popup');
                    $gBitSmarty->loadPlugin('smarty_function_biticon');
                    $gBitSmarty->assign('title', tra('Extended Help'));
                    $gBitSmarty->assign('content', $content);
                    $gBitSmarty->assign('closebutton', TRUE);
                    $text = $gBitSmarty->fetch('bitpackage:kernel/popup_box.tpl');
                    $text = preg_replace('/"/', "'", $text);
                    $popup = array('trigger' => 'onclick', 'text' => $text, 'fullhtml' => '1', 'sticky' => '1', 'timeout' => '8000');
                    $biticon = array('ipackage' => 'icons', 'iname' => 'dialog-information', 'iforce' => 'icon', 'iexplain' => 'Extended Help');
                    $html .= ' <span class="formhelppopup" ' . $atts . '>&nbsp;';
                    $html .= '<a ' . smarty_function_popup($popup, $gBitSmarty) . '>';
                    $html .= smarty_function_biticon($biticon, $gBitSmarty);
                    $html .= '</a>';
                    $html .= '</span>';
                } else {
                    $html .= '<span class="help-block" ' . $atts . '>' . $content . '</span>';
                }
            }
            return $html;
        }
    }
}
<?php 
}
if ($this->_tpl_vars['userinfo']['userId']) {
    ?>
<tr class="formcolor"><td>&nbsp;</td><td>
<input type="hidden" name="user" value="<?php 
    echo is_array($_tmp = $this->_tpl_vars['userinfo']['userId']) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp);
    ?>
" />
<input type="hidden" name="edituser" value="1" />
<input type="submit" name="submit" value="Save" />
<?php 
} else {
    ?>
<tr class="formcolor"><td>Batch upload (CSV file<a <?php 
    echo smarty_function_popup(array('text' => 'login,password,email,groups<br />user1,password1,email1,&quot;group1,group2&quot;<br />user2, password2,email2'), $this);
    ?>
><img src="img/icons/help.gif" border="0" height="16" width="16" alt='<?php 
    $this->_tag_stack[] = array('tr', array());
    $_block_repeat = true;
    smarty_block_tr($this->_tag_stack[count($this->_tag_stack) - 1][1], null, $this, $_block_repeat);
    while ($_block_repeat) {
        ob_start();
        ?>
help' /></a>)<?php 
        $_block_content = ob_get_contents();
        ob_end_clean();
        $_block_repeat = false;
        echo smarty_block_tr($this->_tag_stack[count($this->_tag_stack) - 1][1], $_block_content, $this, $_block_repeat);
    }
    array_pop($this->_tag_stack);
<br/>

----------------------------------------
<h3>popup 模拟到数组里 testing </h3>
<?php 
$_from = $this->_tpl_vars['arr'];
if (!is_array($_from) && !is_object($_from)) {
    settype($_from, 'array');
}
if (count($_from)) {
    foreach ($_from as $this->_tpl_vars['val']) {
        $this->assign('intro', $this->_tpl_vars['val']['age']);
        ?>

<a href="#" <?php 
        echo smarty_function_popup(array('sticky' => true, 'trigger' => 'onclick', 'caption' => "我的标题", 'closecolor' => 'yellow', 'captionsize' => 2, 'textsize' => 2, 'width' => 300, 'height' => 300, 'closetext' => "关闭", 'noclose' => true, 'fgcolor' => 'white', 'text' => "<img src='/smarty/Jellyfish.jpg' / width=150 height=150><ul>\r\n\r\n<li>Age=" . $this->_tpl_vars['intro'] . "</li><li>测试二</li><li>测试三</li><li>测试四</li></ul>"), $this);
        ?>
>
<?php 
        echo $this->_tpl_vars['val']['name'];
        ?>
</a>



<?php 
    }
}
unset($_from);
?>