/**
 * GreyBox (gb_pageset) プラグイン
 *
 * @copyright   Copyright &copy; 2009, Katsumi Saito <*****@*****.**>
 * @version     $Id: gb_pageset.inc.php,v 0.1 2009/03/31 00:37:00 upk Exp $
 * @link	http://orangoo.com/labs/GreyBox/
 */
function plugin_gb_pageset_convert()
{
    global $script, $vars;
    static $get_greybox = true;
    if ($get_greybox) {
        $get_greybox = false;
        if (exist_plugin('greybox')) {
            greybox_set_head_tags();
        } else {
            die_message('greybox plugin not found.');
        }
    }
    $argv = func_get_args();
    $argc = func_num_args();
    $field = array('page_set_name', 'caption', 'url');
    for ($i = 0; $i < $argc; $i++) {
        ${$field}[$i] = htmlspecialchars($argv[$i], ENT_QUOTES);
    }
    if (empty($page_set_name) || empty($url)) {
        return 'usage: #gb_pageset(page_set_name, caption, url)';
    }
    if (empty($caption)) {
        $caption = 'no title';
    }
    $caption = str_replace('&amp;#039;', '\'', $caption);
    // ' の対応
    return '<a href="' . $url . '" title="' . $caption . '" rel="gb_pageset[' . $page_set_name . ']">' . $caption . "</a>\n";
}
/**
 * GreyBox プラグイン
 *
 * @copyright   Copyright &copy; 2006,2009, Katsumi Saito <*****@*****.**>
 * @version     $Id: greybox.inc.php,v 0.9 2009/11/08 02:33:00 upk Exp $
 * @link	http://orangoo.com/labs/GreyBox/
 */
function plugin_greybox_convert()
{
    global $script, $vars;
    greybox_set_head_tags();
    $argv = func_get_args();
    $argc = func_num_args();
    $field = array('caption', 'url', 'img', 'height', 'width');
    for ($i = 0; $i < $argc; $i++) {
        ${$field}[$i] = htmlspecialchars($argv[$i], ENT_QUOTES);
    }
    if (empty($url)) {
        return 'usage: #greybox(caption, url, img, height, width)';
    }
    if (empty($caption)) {
        $caption = 'no title';
    }
    if (empty($img)) {
        $img = '';
    }
    $is_full = false;
    if (empty($height)) {
        $is_full = true;
        $height = 470;
    }
    if (empty($width)) {
        $is_full = true;
        $width = 600;
    }
    if (!empty($img)) {
        // <img src="" alt="" title="" width="127" height="38" />
        $caption2 = '<img src="' . $img . '" alt="' . $caption . '" title="' . $caption . '" />';
    } else {
        $caption2 = $caption;
    }
    $caption2 = str_replace('&amp;#039;', '\'', $caption2);
    // ' の対応
    if ($is_full) {
        return '<a href="' . $url . '" title="' . $caption . '" rel="gb_page_fs[]">' . $caption2 . "</a>\n";
    } else {
        return '<a href="' . $url . '" title="' . $caption . '" rel="gb_page_center[' . $width . ', ' . $height . ']">' . $caption2 . "</a>\n";
    }
}