コード例 #1
0
ファイル: data.img.php プロジェクト: kailIII/liberty
function data_img($pData, $pParams)
{
    $cssStyle = '';
    $cssClass = '';
    foreach ($pParams as $key => $value) {
        if (!empty($value)) {
            switch ($key) {
                // rename a couple of parameters
                case 'width':
                case 'height':
                    if (preg_match("/^\\d+(em|px|%|pt)\$/", trim($value))) {
                        $cssStyle .= $key . ':' . $value . ';';
                    } elseif (preg_match("/^\\d+\$/", $value)) {
                        $cssStyle .= $key . ':' . $value . 'px;';
                    }
                    // remove values from the hash that they don't get used in the div as well
                    $pParams[$key] = NULL;
                    break;
                case 'class':
                    $cssClass .= $value . ' ';
                    break;
                case 'style':
                    $cssStyle .= ';' . $value;
                    break;
            }
        }
    }
    $wrapper = liberty_plugins_wrapper_style($pParams);
    // check if we have a source to load an image from
    if (!empty($pParams['src'])) {
        // set up image first
        $alt = !empty($wrapper['description']) ? $wrapper['description'] : tra('Image');
        $ret = '<img alt="' . $alt . '" title="' . $alt . '" src="' . $pParams['src'] . '" style="' . $cssStyle . '" class="img-responsive ' . $cssClass . ' ' . (!empty($wrapper['class']) ? $wrapper['class'] : '') . '"/>';
        // if this image is linking to something, wrap the image with the <a>
        if (!empty($wrapper['link'])) {
            $ret = '<a href="' . trim($wrapper['link']) . '">' . $ret . '</a>';
        }
        // finally, wrap the image
        if (!empty($wrapper['style']) || !empty($class) || !empty($wrapper['description'])) {
            $ret = '<' . $wrapper['wrapper'] . ' class="img-plugin" style="' . $wrapper['style'] . '">' . $ret . (!empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '') . '</' . $wrapper['wrapper'] . '>';
        }
    } else {
        $ret = '<span class="warning">' . tra('When using <strong>{img}</strong> the <strong>src</strong> parameter is required.') . '</span>';
    }
    return $ret;
}
コード例 #2
0
ファイル: data.biticon.php プロジェクト: kailIII/liberty
function data_biticon($pData, $pParams)
{
    global $gBitSmarty;
    $ret = tra('Please provide an icon name as iname parameter. You can <a href="' . THEMES_PKG_URL . 'icon_browser.php">select icons here</a>.');
    if (!empty($pParams['iname'])) {
        $gBitSmarty->loadPlugin('smarty_function_biticon');
        // sanitise biticon parameters before they are passed to the function
        $biticon['iname'] = $pParams['iname'];
        $biticon['ipackage'] = !empty($pParams['ipackage']) ? $pParams['ipackage'] : 'icons';
        $biticon['iexplain'] = !empty($pParams['iexplain']) ? $pParams['iexplain'] : 'icon';
        $biticon['ipath'] = !empty($pParams['ipath']) ? $pParams['ipath'] : '';
        $ret = smarty_function_biticon($biticon, $gBitSmarty);
        $wrapper = liberty_plugins_wrapper_style($pParams, FALSE);
        if (!empty($wrapper['style'])) {
            $ret = '<' . $wrapper['wrapper'] . ' class="' . (!empty($wrapper['class']) ? $wrapper['class'] : "biticon-plugin") . '" style="' . $wrapper['style'] . '">' . $ret . '</' . $wrapper['wrapper'] . '>';
        }
    }
    return $ret;
}
コード例 #3
0
ファイル: data.gallery.php プロジェクト: bitweaver/fisheye
function data_gallery($pData, $pParams)
{
    global $gBitSystem, $gBitSmarty;
    $ret = ' ';
    $imgStyle = '';
    $wrapper = liberty_plugins_wrapper_style($pParams);
    $description = !isset($wrapper['description']) ? $wrapper['description'] : NULL;
    foreach ($pParams as $key => $value) {
        if (!empty($value)) {
            switch ($key) {
                // rename a couple of parameters
                case 'width':
                case 'height':
                    if (preg_match("/^\\d+(em|px|%|pt)\$/", trim($value))) {
                        $imgStyle .= $key . ':' . $value . ';';
                    } elseif (preg_match("/^\\d+\$/", $value)) {
                        $imgStyle .= $key . ':' . $value . 'px;';
                    }
                    // remove values from the hash that they don't get used in the div as well
                    $pParams[$key] = NULL;
                    break;
            }
        }
    }
    $wrapper = liberty_plugins_wrapper_style($pParams);
    if (!empty($pParams['src'])) {
        $thumbUrl = $pParams['src'];
    } elseif (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('fisheye')) {
        require_once FISHEYE_PKG_PATH . 'FisheyeImage.php';
        $gBitSmarty->loadPlugin('smarty_modifier_display_bytes');
        $gallery = new FisheyeImage();
        $listHash = $pParams;
        $listHash['size'] = 'small';
        $listHash['gallery_id'] = $pParams['id'];
        $listHash['max_records'] = 3;
        $listHash['sort_mode'] = 'random';
        $images = $gallery->getList($listHash);
        $out = '<div>';
        foreach ($images as $image) {
            // insert source url if we need the original file
            if (!empty($pParams['size']) && $pParams['size'] == 'original') {
                $thumbUrl = $image['source_url'];
            } elseif ($image['thumbnail_url']) {
                $thumbUrl = $image['thumbnail_url'];
            }
            if (empty($image['$description'])) {
                $description = !isset($wrapper['description']) ? $wrapper['description'] : $image['title'];
            }
            // check if we have a valid thumbnail
            if (!empty($thumbUrl)) {
                // set up image first
                $ret = '<img class="img-responsive"' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumbUrl . '"' . ' style="float:left; ' . $imgStyle . '"' . ' />';
                if (!empty($pParams['nolink'])) {
                } elseif (!empty($wrapper['link'])) {
                    // if this image is linking to something, wrap the image with the <a>
                    $ret = '<a href="' . trim($wrapper['link']) . '">' . $ret . '</a>';
                } elseif (empty($pParams['size']) || $pParams['size'] != 'original') {
                    if ($image['source_url']) {
                        $ret = '<a href="' . trim($image['source_url']) . '">' . $ret . '</a>';
                    }
                }
                if (!empty($wrapper['style']) || !empty($class) || !empty($wrapper['description'])) {
                    $ret = '<' . $wrapper['wrapper'] . ' class="' . (!empty($wrapper['class']) ? $wrapper['class'] : "img-responsive") . '" style="' . $wrapper['style'] . '">' . $ret . (!empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '') . '</' . $wrapper['wrapper'] . '>';
                }
            } else {
                $ret = tra("Unknown Gallery");
            }
            $out .= $ret;
        }
        $out .= '</div>';
    }
    return $out;
}
コード例 #4
0
ファイル: data.file.php プロジェクト: bitweaver/treasury
function data_file($pData, $pParams)
{
    global $gBitSystem, $gBitSmarty;
    $ret = ' ';
    if (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('treasury')) {
        require_once TREASURY_PKG_PATH . 'TreasuryItem.php';
        $gBitSmarty->loadPlugin('smarty_modifier_display_bytes');
        $item = new TreasuryItem();
        $item->mContentId = $item->getContentIdFromAttachmentId($pParams['id']);
        if ($item->load()) {
            // insert source url if we need the original file
            if (!empty($pParams['size']) && $pParams['size'] == 'original') {
                $thumburl = $item->getField('source_url');
            } elseif ($item->getField('thumbnail_url')) {
                $thumburl = !empty($pParams['size']) && !empty($item->mInfo['thumbnail_url'][$pParams['size']]) ? $item->mInfo['thumbnail_url'][$pParams['size']] : $item->mInfo['thumbnail_url']['medium'];
            }
            // check if we have a valid thumbnail
            if (!empty($thumburl)) {
                $wrapper = liberty_plugins_wrapper_style($pParams);
                $description = !empty($wrapper['description']) ? $wrapper['description'] : $item->getField('data', tra('Image'));
                // set up image first
                $ret = '<img' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumburl . '"' . ' />';
                if ($item->getField('file_size')) {
                    $ret .= '<br />' . $item->getField('title') . "<br /><small>(" . $item->getField('mime_type') . " " . smarty_modifier_display_bytes($item->getField('file_size')) . ")</small>";
                }
                if (!empty($description) && !empty($pParams['output']) && ($pParams['output'] == 'desc' || $pParams['output'] == 'description')) {
                    $ret = $description;
                    $nowrapper = TRUE;
                } else {
                    $ret .= !empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '';
                }
                // use specified link as href. insert default link to source only when
                // source not already displayed
                if (!empty($pParams['link']) && $pParams['link'] == 'false') {
                } elseif (!empty($pParams['link'])) {
                    if (strstr($pParams['link'], $_SERVER["SERVER_NAME"]) || !strstr($pParams['link'], '//')) {
                        $class = '';
                    } else {
                        $class = 'class="external"';
                    }
                    $ret = '<a ' . $class . ' href="' . trim($pParams['link']) . '">' . $ret . '</a>';
                } elseif (empty($pParams['download']) && $item->getField('display_url')) {
                    $ret = '<a href="' . trim($item->getField('display_url')) . '">' . $ret . '</a>';
                } elseif (!empty($pParams['download']) && ($pParams['download'] = 'direct')) {
                    $ret = '<a href="' . trim($item->getField('source_url')) . '">' . $ret . '</a>';
                } elseif (!empty($pParams['download']) && $item->getField('download_url')) {
                    $ret = '<a href="' . trim($item->getField('download_url')) . '">' . $ret . '</a>';
                } elseif (empty($pParams['size']) || $pParams['size'] != 'original') {
                    $ret = '<a href="' . trim($item->getField('source_url')) . '">' . $ret . '</a>';
                }
                // finally, wrap the output.
                if (empty($nowrapper)) {
                    $ret = '<!-- ~np~ --><' . $wrapper['wrapper'] . ' class="' . (isset($wrapper) && !empty($wrapper['class']) ? $wrapper['class'] : "att-plugin") . '" style="' . $wrapper['style'] . '">' . $ret . '</' . $wrapper['wrapper'] . '><!-- ~/np~ -->';
                }
            } else {
                $ret = tra("There was a problem getting an image for the file.");
            }
        } else {
            $ret = tra("The attachment id given is not valid.");
        }
    } else {
        $ret = tra("The attachment id given is not valid.");
    }
    return $ret;
}
コード例 #5
0
ファイル: data.attachment.php プロジェクト: kailIII/liberty
function data_attachment($pData, $pParams, $pCommonObject, $pParseHash)
{
    require_once LIBERTY_PKG_PATH . 'LibertyMime.php';
    // at a minimum, return blank string (not empty) so we still replace the tag
    $ret = ' ';
    // The Manditory Parameter is missing. we are not gonna trow an error, and
    // just return empty since many sites use the old style required second
    // "closing" empty tag
    if (empty($pParams['id'])) {
        return $ret;
    }
    if (!($att = $pCommonObject->getAttachment($pParams['id'], $pParams))) {
        $ret = tra("The attachment id given is not valid.");
        return $ret;
    }
    global $gBitSmarty, $gLibertySystem, $gContent;
    // convert parameters into display properties
    $wrapper = liberty_plugins_wrapper_style($pParams);
    // work out custom display_url if there is one
    if (@BitBase::verifyId($pParams['page_id'])) {
        // link to page by page_id
        // avoid endless loops
        require_once WIKI_PKG_PATH . 'BitPage.php';
        $wp = new BitPage($pParams['page_id']);
        if ($wp->load()) {
            $wrapper['display_url'] = $wp->getDisplayUrl();
        }
    } elseif (@BitBase::verifyId($pParams['content_id'])) {
        // link to any content by content_id
        if ($obj = LibertyBase::getLibertyObject($pParams['content_id'])) {
            $wrapper['display_url'] = $obj->getDisplayUrl();
        }
    } elseif (!empty($pParams['page_name'])) {
        // link to page by page_name
        require_once WIKI_PKG_PATH . 'BitPage.php';
        $wp = new BitPage();
        $wrapper['display_url'] = $wp->getDisplayUrl($pParams['page_name']);
    } elseif (!empty($pParams['link']) && $pParams['link'] == 'false') {
        // no link
    } elseif (!empty($pParams['link'])) {
        // Allow the use of icon, avatar, small, medium and large to link to certain size of image directly
        if (!empty($att['thumnail_url'][$pParams['link']])) {
            $pParams['link'] = $att['thumnail_url'][$pParams['link']];
            // Allow the use of 'original' to link to original file directly
        } elseif ($pParams['link'] == 'original' && !empty($att['source_url'])) {
            $pParams['link'] = $att['source_url'];
            // Allow the use of 'download' to link to download link. this will allow us to count downloads
        } elseif ($pParams['link'] == 'download' && !empty($att['download_url'])) {
            $pParams['link'] = $att['download_url'];
            // Adjust class name if we are leaving this server
        } elseif (!strstr($pParams['link'], $_SERVER["SERVER_NAME"]) && strstr($pParams['link'], '//')) {
            $wrapper['href_class'] = 'class="external"';
        }
        $wrapper['display_url'] = $pParams['link'];
    } elseif (!empty($att['display_url'])) {
        $wrapper['display_url'] = $att['display_url'];
    }
    if (!empty($wrapper['description'])) {
        $parseHash['content_id'] = $pParseHash['content_id'];
        $parseHash['user_id'] = $pParseHash['user_id'];
        $parseHash['no_cache'] = TRUE;
        $parseHash['data'] = $wrapper['description'];
        $wrapper['description_parsed'] = $pCommonObject->parseData($parseHash);
    }
    // pass stuff to the template
    $gBitSmarty->assign('attachment', $att);
    $gBitSmarty->assign('wrapper', $wrapper);
    $gBitSmarty->assign('thumbsize', !empty($pParams['size']) && ($pParams['size'] == 'original' || !empty($att['thumbnail_url'][$pParams['size']])) ? $pParams['size'] : 'medium');
    //Carry only these attributes to the image tags
    $width = !empty($pParams['width']) ? $pParams['width'] : '';
    $gBitSmarty->assign('width', $width);
    $height = !empty($pParams['height']) ? $pParams['height'] : '';
    $gBitSmarty->assign('height', $height);
    $mimehandler = !empty($wrapper['output']) && $wrapper['output'] == 'thumbnail' ? LIBERTY_DEFAULT_MIME_HANDLER : $att['attachment_plugin_guid'];
    $ret = $gBitSmarty->fetch($gLibertySystem->getMimeTemplate('attachment', $mimehandler));
    return $ret;
}
コード例 #6
0
ファイル: data.image.php プロジェクト: bitweaver/fisheye
function data_image($pData, $pParams)
{
    global $gBitSystem, $gBitSmarty;
    $ret = ' ';
    $imgStyle = '';
    $wrapper = liberty_plugins_wrapper_style($pParams);
    $description = !isset($wrapper['description']) ? $wrapper['description'] : NULL;
    foreach ($pParams as $key => $value) {
        if (!empty($value)) {
            switch ($key) {
                // rename a couple of parameters
                case 'width':
                case 'height':
                    if (preg_match("/^\\d+(em|px|%|pt)\$/", trim($value))) {
                        $imgStyle .= $key . ':' . $value . ';';
                    } elseif (preg_match("/^\\d+\$/", $value)) {
                        $imgStyle .= $key . ':' . $value . 'px;';
                    }
                    // remove values from the hash that they don't get used in the div as well
                    $pParams[$key] = NULL;
                    break;
            }
        }
    }
    $wrapper = liberty_plugins_wrapper_style($pParams);
    if (!empty($pParams['src'])) {
        $thumbUrl = $pParams['src'];
    } elseif (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('fisheye')) {
        require_once FISHEYE_PKG_PATH . 'FisheyeImage.php';
        $gBitSmarty->loadPlugin('smarty_modifier_display_bytes');
        $item = new FisheyeImage($pParams['id'], NULL);
        if ($item->load()) {
            // insert source url if we need the original file
            if (!empty($pParams['size']) && $pParams['size'] == 'original') {
                $thumbUrl = $item->getDownloadUrl();
            } elseif ($item->mInfo['thumbnail_url']) {
                $thumbUrl = !empty($pParams['size']) && !empty($item->mInfo['thumbnail_url'][$pParams['size']]) ? $item->mInfo['thumbnail_url'][$pParams['size']] : $item->mInfo['thumbnail_url']['medium'];
            }
            if (empty($description)) {
                $description = !isset($wrapper['description']) ? $wrapper['description'] : $item->getField('title', tra('Image'));
            }
        }
    }
    // check if we have a valid thumbnail
    if (!empty($thumbUrl)) {
        // set up image first
        $ret = '<img' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumbUrl . '"' . ' style="' . $imgStyle . '"' . ' />';
        if (!empty($pParams['nolink'])) {
        } elseif (!empty($wrapper['link'])) {
            // if this image is linking to something, wrap the image with the <a>
            $ret = '<a href="' . trim($wrapper['link']) . '">' . $ret . '</a>';
        } elseif (empty($pParams['size']) || $pParams['size'] != 'original') {
            if ($gBitSystem->isFeatureActive('site_fancy_zoom') and !empty($item->mInfo['source_url'])) {
                $ret = '<a href="' . trim(str_replace(' ', '%20', $item->mInfo['source_url'])) . '">' . $ret . '</a>';
            } else {
                if ($item->getDownloadUrl()) {
                    $ret = '<a href="' . trim($item->getDownloadUrl()) . '">' . $ret . '</a>';
                } else {
                    if (!empty($item->mInfo['media_url'])) {
                        $ret = '<a href="' . trim($item->mInfo['media_url']) . '">' . $ret . '</a>';
                    }
                }
            }
        }
        if (!empty($wrapper['style']) || !empty($class) || !empty($wrapper['description'])) {
            $ret = '<' . $wrapper['wrapper'] . ' class="' . (!empty($wrapper['class']) ? $wrapper['class'] : "img-plugin") . '" style="' . $wrapper['style'] . '">' . $ret . (!empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '') . '</' . $wrapper['wrapper'] . '>';
        }
    } else {
        $ret = tra("Unknown Image");
    }
    return $ret;
}
コード例 #7
0
ファイル: data.carousel.php プロジェクト: bitweaver/fisheye
function data_carousel($pData, $pParams)
{
    global $gBitSystem, $gBitSmarty;
    $ret = ' ';
    $imgStyle = '';
    $wrapper = liberty_plugins_wrapper_style($pParams);
    $description = !isset($wrapper['description']) ? $wrapper['description'] : NULL;
    foreach ($pParams as $key => $value) {
        if (!empty($value)) {
            switch ($key) {
                // rename a couple of parameters
                case 'width':
                case 'height':
                    if (preg_match("/^\\d+(em|px|%|pt)\$/", trim($value))) {
                        $imgStyle .= $key . ':' . $value . ';';
                    } elseif (preg_match("/^\\d+\$/", $value)) {
                        $imgStyle .= $key . ':' . $value . 'px;';
                    }
                    // remove values from the hash that they don't get used in the div as well
                    $pParams[$key] = NULL;
                    break;
            }
        }
    }
    $wrapper = liberty_plugins_wrapper_style($pParams);
    $pParams['nolink'] = 'yes';
    if (!empty($pParams['src'])) {
        $thumbUrl = $pParams['src'];
    } elseif (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('fisheye')) {
        require_once FISHEYE_PKG_PATH . 'FisheyeImage.php';
        $gBitSmarty->loadPlugin('smarty_modifier_display_bytes');
        $gallery = new FisheyeImage();
        $listHash = $pParams;
        $listHash['size'] = 'large';
        $listHash['gallery_id'] = $pParams['id'];
        $listHash['max_records'] = 10;
        $listHash['sort_mode'] = 'item_position_asc';
        $images = $gallery->getList($listHash);
        $num = count($images);
        $out = '<div class="carousel slide" data-ride="carousel" id="myCarousel">';
        $out .= '<ol class="carousel-indicators">';
        $out .= '<li class="active" data-slide-to="0" data-target="#myCarousel">&nbsp;</li>';
        for ($i = 1; $i < $num; $i++) {
            $out .= '<li data-slide-to="' . $i . '" data-target="#myCarousel">&nbsp;</li>';
        }
        $out .= '</ol>';
        $out .= '<div class="carousel-inner" role="listbox">';
        $i = 0;
        foreach ($images as $image) {
            // insert source url if we need the original file
            if (!empty($pParams['size']) && $pParams['size'] == 'original') {
                $thumbUrl = $image['source_url'];
            } elseif ($image['thumbnail_url']) {
                $thumbUrl = $image['thumbnail_url'];
            }
            if (empty($image['$description'])) {
                $description = !isset($wrapper['description']) ? $wrapper['description'] : $image['title'];
            }
            // check if we have a valid thumbnail
            if (!empty($thumbUrl)) {
                if ($i == 0) {
                    $active = ' active';
                } else {
                    $active = '';
                }
                $i++;
                // set up image first
                $ret = '<div class="item' . $active . '"><img class="img-responsive"' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumbUrl . '"' . ' height="103" width="800"' . ' /></div>';
                if (!empty($pParams['nolink'])) {
                } elseif (!empty($wrapper['link'])) {
                    // if this image is linking to something, wrap the image with the <a>
                    $ret = '<a href="' . trim($wrapper['link']) . '">' . $ret . '</a>';
                } elseif (empty($pParams['size']) || $pParams['size'] != 'original') {
                    if ($image['source_url']) {
                        $ret = '<a href="' . trim($image['source_url']) . '">' . $ret . '</a>';
                    }
                }
                if (!empty($wrapper['style']) || !empty($class) || !empty($wrapper['description'])) {
                    $ret = '<' . $wrapper['wrapper'] . ' class="' . (!empty($wrapper['class']) ? $wrapper['class'] : "img-responsive") . '" style="' . $wrapper['style'] . '">' . $ret . (!empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '') . '</' . $wrapper['wrapper'] . '>';
                }
            } else {
                $ret = tra("Unknown Gallery");
            }
            $out .= $ret;
        }
        $out .= '</div>';
        $out .= '<a class="left carousel-control" data-slide="prev" href="#myCarousel" role="button">';
        $out .= '<span class="sr-only">Previous</span> </a>';
        $out .= '<a class="right carousel-control" data-slide="next" href="#myCarousel" role="button">';
        $out .= '<span class="sr-only">Next</span> </a></div>';
        $out .= '</div>';
    }
    return $out;
}