/**
 * Campsite breadcrumb function plugin
 *
 * Type:     function
 * Name:     breadcrumb
 * Purpose:  builds the breadcrumb for the current page. A 'first_level'
 *           attribute can be passed who indicates where the breadcrumb
 *           should start.
 *
 * @param array
 *     $p_params the date in unixtime format from $smarty.now
 * @param object
 *     $p_smarty The Smarty object
 *
 * @return
 *     string the html string for the breadcrumb
 *
 * @todo make it linkable
 */
function smarty_function_breadcrumb($p_params, &$p_smarty)
{
    $p_smarty->smarty->loadPlugin('smarty_shared_escape_special_chars');
    $campsite = $p_smarty->getTemplateVars('gimme');
    if (!isset($p_params['first_level']) || empty($p_params['first_level'])) {
        $p_params['first_level'] = 'home';
    }
    if (!isset($p_params['separator']) || empty($p_params['separator'])) {
        $p_params['separator'] = ' > ';
    }
    $html = '';
    $breadcrumbStarted = 0;
    if ($p_params['first_level'] == 'home') {
        $html .= 'Home ' . $p_params['separator'];
        $breadcrumbStarted = 1;
    }
    if ($p_params['first_level'] == 'publication' || $breadcrumbStarted == 1 && $campsite->publication->defined) {
        $html .= smarty_function_escape_special_chars($campsite->publication->name) . $p_params['separator'];
        $breadcrumbStarted = 1;
    }
    if ($p_params['first_level'] == 'issue' || $breadcrumbStarted == 1 && $campsite->issue->defined) {
        $html .= smarty_function_escape_special_chars($campsite->issue->name) . $p_params['separator'];
        $breadcrumbStarted = 1;
    }
    if ($p_params['first_level'] == 'section' || $breadcrumbStarted == 1 && $campsite->section->defined) {
        $html .= smarty_function_escape_special_chars($campsite->section->name) . $p_params['separator'];
        $breadcrumbStarted = 1;
    }
    if ($campsite->article->defined) {
        $html .= smarty_function_escape_special_chars($campsite->article->name) . $p_params['separator'];
    }
    return $html;
}
function smarty_parse_html_options($options, $params, $html)
{
    /* @var $html XMLWriter */
    foreach ($options as $k => $v) {
        if (is_array($v)) {
            $html->startElement('optgroup');
            $html->writeAttribute('label', smarty_function_escape_special_chars($k));
            $html = smarty_parse_html_options($v, $params, $html);
            $html->endElement();
        } else {
            $html->startElement('option');
            if ($params['label_as_value']) {
                $html->writeAttribute('value', smarty_function_escape_special_chars($v));
                if ($params['selected'] == $v) {
                    $html->writeAttribute('selected', 'selected');
                }
            } else {
                $html->writeAttribute('value', smarty_function_escape_special_chars($k));
                if ($params['selected'] == $k) {
                    $html->writeAttribute('selected', 'selected');
                }
            }
            $html->writeRaw($v);
            $html->endElement();
        }
    }
    return $html;
}
/**
 * Smarty {oos_address_label} function plugin
 *
 * Type:     function
 * Name:     oos_address_label
 * Version:  1.0
 * -------------------------------------------------------------
 */

function smarty_function_oos_address_label($params, &$smarty)
{

    $customers_id = '';
    $address_id = 1;
    $html = true;
    $boln = '';
    $eoln = '<br>';

    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    MyOOS_CoreApi::requireOnce('lib/smarty-plugins/myoos/function.oos_address_format.php');

    foreach($params as $_key => $_val) {
      $$_key = smarty_function_escape_special_chars($_val);
    }

    $dbconn =& oosDBGetConn();
    $oostable =& oosDBGetTables();

    $address_result = $dbconn->Execute("SELECT entry_firstname AS firstname, entry_lastname AS lastname, entry_company AS company, entry_street_address AS street_address, entry_suburb AS suburb, entry_city AS city, entry_postcode AS postcode, entry_state AS state, entry_zone_id AS zone_id, entry_country_id AS country_id FROM " . $oostable['address_book'] . " WHERE customers_id = '" . (int)$customers_id . "' AND address_book_id = '" . (int)$address_id . "'");
    $address = $address_result->fields;

    $format_id = oos_get_address_format_id($address['country_id']);


    return smarty_function_oos_address_format(array('address_format_id' => $format_id,
                                                    'address'   => $address,
                                                    'html'      => $html),
                                                  $smarty);


}
/**
 * Campsite search_form block plugin
 *
 * Type:     block
 * Name:     search_form
 * Purpose:  Provides a...
 *
 * @param string $p_params
 *
 * @param string $p_content
 *
 * @param string $p_smarty
 *
 *
 * @return string $html
 */
function smarty_block_search_form($p_params, $p_content, &$p_smarty)
{
    if (!isset($p_content)) {
        return '';
    }

    require_once $p_smarty->_get_plugin_filepath('shared','escape_special_chars');

    // gets the context variable
    $campsite = $p_smarty->get_template_vars('gimme');

    $url = $campsite->url;
    $url->uri_parameter = "";
    $template = null;
    if (isset($p_params['template'])) {
        $template = new MetaTemplate($p_params['template']);
        if (!$template->defined()) {
            CampTemplate::singleton()->trigger_error('invalid template "' . $p_params['template']
            . '" specified in the search form');
            return false;
        }
    } elseif (is_numeric($url->get_parameter('tpl'))) {
        $template = $campsite->default_template;
    }
    if (!isset($p_params['submit_button'])) {
        $p_params['submit_button'] = 'Submit';
    }
    if (!isset($p_params['html_code']) || empty($p_params['html_code'])) {
        $p_params['html_code'] = '';
    }
    if (!isset($p_params['button_html_code']) || empty($p_params['button_html_code'])) {
        $p_params['button_html_code'] = '';
    }

    $searchListIdPrefix = $campsite->list_id_prefix('SearchResultsList');
    if (isset($template)) {
        $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name);
    }
    $html = "<form name=\"search_articles\" action=\"" . $url->uri_path . "\" method=\"post\" "
    .$p_params['html_code'].">\n";
    if (isset($template)) {
        $html .= "<input type=\"hidden\" name=\"tpl\" value=\"" . $template->identifier . "\" />\n";
    }
    foreach ($campsite->url->form_parameters as $param) {
        if (strncasecmp($param[name], $searchListIdPrefix, strlen($searchListIdPrefix)) == 0) {
            continue;
        }
        if ($param['name'] == 'tpl') {
            continue;
        }
        $html .= '<input type="hidden" name="'.$param['name']
        .'" value="'.htmlentities($param['value'])."\" />\n";
    }
    $html .= $p_content;
    $html .= "<input type=\"submit\" name=\"f_search_articles\" value=\""
    .smarty_function_escape_special_chars($p_params['submit_button'])
    ."\" ".$p_params['button_html_code']." />\n</form>\n";

    return $html;
} // fn smarty_block_search_form
Beispiel #5
0
/**
 * Smarty {from_to} function plugin
 *
 * Type:       function<br>
 * Name:       from_to<br>
 * Date:       2008/09/07<br>
 * Input:
 * <pre>
 *           - from       (required) - string 
 *           - to         (required) - string 
 *           - separator  (optional) - string default " ~ ". ie "-", "~<br />". 常にエスケープせずに出力するので注意.
 *           - escape     (optional) - string default true. other false. エスケープするか否か。
 * </pre>
 * Examples:
 * <pre>
 * {html_radios from="-1" to="2"} → -1 ~ 2
 * {html_radios from="B" to="a" separator="~<br />"}  → B~<br />a
 * </pre>
 * @author     Seasoft 塚田将久
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_from_to($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
    $from = null;
    $to = null;
    $separator = ' ~ ';
    $escape = true;
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'from':
            case 'to':
            case 'separator':
            case 'escape':
                ${$_key} = (string) $_val;
                break;
            default:
                $smarty->trigger_error("from_to: extra attribute '{$_key}' is unknown.", E_USER_NOTICE);
                break;
        }
    }
    if ($escape) {
        $from = smarty_function_escape_special_chars($from);
        $to = smarty_function_escape_special_chars($to);
    }
    if ($from === $to) {
        return $from;
    } else {
        return $from . $separator . $to;
    }
}
/**
 * Smarty {rating_input} function plugin
 *
 * File:       function.rating_input.php<br>
 * Type:       function<br>
 * Name:       rating_input<br>
 * Purpose:    Prints out a rating input control<br>
 * Input:<br>
 *           - name       (optional) - string default "checkbox"
 *           - value      (required) - string
 *           - id         (optional) - checkbox id (name is default)
 * @return string
 */
function smarty_function_rating_input($params, &$smarty)
{
    require_once SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php';
    //$smarty->loadPlugin('Smarty_shared_escape_special_chars');
    $name = 'rating';
    $value = null;
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'name':
            case 'id':
            case 'value':
                ${$_key} = $_val;
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("rating_input: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    // assign default id
    if (empty($id)) {
        $id = $name;
    }
    $_output = '';
    $_output .= '<input type="text" size="10" maxlength="4"' . ' name="' . smarty_function_escape_special_chars($name) . '"' . ' id="' . smarty_function_escape_special_chars($id) . '"' . ' value="' . smarty_function_escape_special_chars($value) . '"';
    $_output .= $extra . ' />';
    for ($i = 1; $i <= 10; $i++) {
        $_output .= " <a href='#' onclick='document.edi." . $name . ".value=\"" . $i . '.0"\'>' . $i . '</a>';
    }
    return $_output;
}
/**
 * Smarty {html_hidden} function plugin
 *
 * Type:     function<br>
 * Name:     html_hidden<br>
 * Input:<br>
 *           - values     (required) - array
 * 
 * Purpose:  Prints the list of <hidden> tags for array parameter values
 * 
 * @author Mitsutaka Sato
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_html_hidden($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
    $values = null;
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'values':
                ${$_key} = $_val;
                break;
        }
    }
    if (!is_array($values)) {
        return '';
    }
    $_html_result = '';
    foreach ($values as $_key => $_val) {
        if (is_array($_val)) {
            foreach ($_val as $i => $v) {
                $_html_result .= '<input type="hidden" name="' . smarty_function_escape_special_chars($_key . '[' . $i . ']') . '" value="' . smarty_function_escape_special_chars($v) . '" />' . "\n";
            }
        } else {
            $_html_result .= '<input type="hidden" name="' . smarty_function_escape_special_chars($_key) . '" value="' . smarty_function_escape_special_chars($_val) . '" />' . "\n";
        }
    }
    return $_html_result;
}
/**
 * Smarty {html_js_inputbox} function plugin
 *
 * File:       function.html_js_inputbox.php<br>
 * Type:       function<br>
 * Name:       js_inputbox<br>
 * Date:       06.Oct.2005<br>
 * Purpose:    Prints out a list of text input types<br>
 * Examples:
 * <pre>
 * {html_js_inputbox values=$ids}
 * {html_js_inputbox class='inputbox' name='searchword' value=$lang.text }
 * </pre>
 * @author r23 <*****@*****.**>
 * @version    1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_html_js_inputbox($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $class = 'inputbox';
    $name = 'keywords';
    $size = '20';
    $maxlength = '40';
    $value = 'search...';
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'class':
            case 'name':
            case 'value':
                ${$_key} = (string) $_val;
                break;
            case 'size':
            case 'maxlength':
                ${$_key} = intval($_val);
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("html_js_inputbox: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    return '<input class="' . $class . '" type="text" name="' . $name . '" size="' . $size . '" maxlength="' . $maxlength . '"  value="' . $value . '"  onblur="if(this.value==\'\') this.value=\'' . $value . '\';" onfocus="if(this.value==\'' . $value . '\') this.value=\'\';" />';
}
Beispiel #9
0
/**
 * Campsite user_form block plugin
 *
 * Type:     block
 * Name:     user_form
 * Purpose:  Provides a...
 *
 * @param string
 *     $p_params
 * @param string
 *     $p_smarty
 * @param string
 *     $p_content
 *
 * @return
 *
 */
function smarty_block_user_form($p_params, $p_content, &$p_smarty, &$p_repeat)
{
    $p_smarty->smarty->loadPlugin('smarty_function_get_resource_id');
    $resourceId = smarty_function_get_resource_id($p_params, $p_smarty);
    if (!isset($p_content)) {
        return null;
    }
    $p_smarty->smarty->loadPlugin('smarty_shared_escape_special_chars');
    $campsite = $p_smarty->getTemplateVars('gimme');
    $url = $campsite->url;
    $url->uri_parameter = "";
    $template = null;
    if (isset($p_params['template'])) {
        $template = new MetaTemplate($resourceId);
        if (!$template->defined()) {
            CampTemplate::singleton()->trigger_error('invalid template "' . $p_params['template'] . '" specified in the user form');
            return false;
        }
    } elseif (is_numeric($url->get_parameter('tpl'))) {
        $template = $campsite->default_template;
    }
    if (!isset($p_params['submit_button'])) {
        require_once $GLOBALS['g_campsiteDir'] . '/admin-files/localizer/Localizer.php';
        if (!isGS('Submit')) {
            camp_load_translation_strings("globals", $campsite->language->code);
        }
        $p_params['submit_button'] = getGS('Submit');
    }
    if (!isset($p_params['html_code']) || empty($p_params['html_code'])) {
        $p_params['html_code'] = '';
    }
    if (!isset($p_params['button_html_code']) || empty($p_params['button_html_code'])) {
        $p_params['button_html_code'] = '';
    }
    if (isset($template)) {
        $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name);
    }
    if ($campsite->user->defined && $campsite->user->subscription->defined) {
        $subsType = $campsite->user->subscription->type == 'T' ? 'trial' : 'paid';
    } else {
        $subsType = null;
    }
    $html = "<form name=\"edit_user\" action=\"" . $url->uri_path . "\" method=\"post\" " . $p_params['html_code'] . ">\n";
    if (!is_null($subsType)) {
        $html .= "<input type=\"hidden\" name=\"f_substype\" value=\"" . $subsType . "\" />\n";
    }
    if (isset($template)) {
        $html .= "<input type=\"hidden\" name=\"tpl\" value=\"" . $template->identifier . "\" />\n";
    }
    foreach ($campsite->url->form_parameters as $param) {
        if ($param['name'] == 'tpl') {
            continue;
        }
        $html .= '<input type="hidden" name="' . $param['name'] . '" value="' . htmlentities($param['value']) . "\" />\n";
    }
    $html .= $p_content;
    $html .= "<input type=\"submit\" name=\"f_edit_user\" value=\"" . smarty_function_escape_special_chars($p_params['submit_button']) . "\" " . $p_params['button_html_code'] . " />\n</form>\n";
    return $html;
}
function smarty_function_html_options_optgroup($key,$values,$selected) {
$optgroup_html = '<optgroup label="'.smarty_function_escape_special_chars($key) .'">'."\n";
foreach ($values as $key =>$value) {
$optgroup_html .= smarty_function_html_options_optoutput($key,$value,$selected);
}
$optgroup_html .= "</optgroup>\n";
return $optgroup_html;
}
/**
 * Newscoop paypal_payment_form block plugin
 *
 * Type:     block
 * Name:     paypal_payment_form
 * Purpose:  Displays a form for paypal cart
 *
 * @param string
 *     $params
 * @param string
 *     $p_smarty
 * @param string
 *     $content
 *
 * @return
 *
 */
function smarty_block_paypal_payment_form($params, $content, &$smarty, &$repeat)
{
    if (!isset($content)) {
        return '';
    }
    $smarty->smarty->loadPlugin('smarty_shared_escape_special_chars');
    $context = $smarty->getTemplateVars('gimme');
    $container = \Zend_Registry::get('container');
    $subscriptionService = $container->getService('paywall.subscription.service');
    $subscriptionsConfig = $subscriptionService->getSubscriptionsConfig();
    $url = $context->url;
    $choosenSubscription = $subscriptionService->getOneById($params['subscriptionId']);
    if (!$choosenSubscription) {
        throw new Exception("Subscription don't exists", 1);
    }
    $formData = array('seller_email' => $subscriptionsConfig['paypal_config']['seller_email'], 'paypal_url' => 'https://www.paypal.com/cgi-bin/webscr', 'subscription_id' => $choosenSubscription->getId(), 'subscription_amount' => $choosenSubscription->getToPay(), 'subscription_currency' => $choosenSubscription->getCurrency(), 'subscription_item_name' => str_replace('%publication_name%', $context->publication->name, $subscriptionsConfig['paypal_config']['item_name_format']), 'language_code' => $context->language->code);
    if (isset($params['test'])) {
        $formData['paypal_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
        $formData['seller_email'] = $subscriptionsConfig['paypal_config']['test_seller_email'];
    }
    if (!isset($params['submit_button'])) {
        $params['submit_button'] = 'Buy subscription';
    }
    if (!isset($params['html_code']) || empty($params['html_code'])) {
        $params['html_code'] = '';
    }
    if (!isset($params['button_html_code']) || empty($params['button_html_code'])) {
        $params['button_html_code'] = '';
    }
    $html = '<form name="subscribe_content" action="' . $formData['paypal_url'] . '" method="post" ' . $params['html_code'] . '>' . "\n";
    if (isset($template)) {
        $html .= "<input type=\"hidden\" name=\"tpl\" value=\"" . $template->identifier . "\" />\n";
    }
    $html .= '<input type="hidden" name="cmd" value="_xclick">' . "\n";
    $html .= '<input type="hidden" name="business" value="' . $formData['seller_email'] . '">' . "\n";
    $html .= '<input type="hidden" name="item_name" value="' . smarty_function_escape_special_chars($formData['subscription_item_name']) . '">' . "\n";
    $html .= '<input type="hidden" name="item_number" value="' . $formData['subscription_id'] . '">' . "\n";
    $html .= '<input type="hidden" name="amount" value="' . $formData['subscription_amount'] . '">' . "\n";
    $html .= '<input type="hidden" name="display" value="1">' . "\n";
    $html .= '<input type="hidden" name="no_shipping" value="1">' . "\n";
    $html .= '<input type="hidden" name="no_note" value="1"> ' . "\n";
    $html .= '<input type="hidden" name="currency_code" value="' . $formData['subscription_currency'] . '"> ' . "\n";
    $html .= '<input type="hidden" name="lc" value="' . $formData['language_code'] . '">' . "\n";
    $html .= '<input type="hidden" name="return" value="' . $container->get('router')->generate('newscoop_paywall_default_statussuccess', array(), true) . '">' . "\n";
    $html .= '<input type="hidden" name="cancel_return" value="' . $container->get('router')->generate('newscoop_paywall_default_statuscancel', array(), true) . '">' . "\n";
    $html .= '<input type="hidden" name="notify_url" value="' . $container->get('router')->generate('newscoop_paywall_default_callback', array(), true) . '">' . "\n";
    $html .= '<input type="hidden" name="custom" value="' . $choosenSubscription->getId() . '__' . $choosenSubscription->getUser()->getId() . '">' . "\n";
    foreach ($context->url->form_parameters as $param) {
        if ($param['name'] == 'tpl') {
            continue;
        }
        $html .= '<input type="hidden" name="' . $param['name'] . '" value="' . htmlentities($param['value']) . "\" />\n";
    }
    $html .= $content;
    $html .= "<input type=\"submit\" name=\"submit_form\" id=\"paypal_form_submit\" value=\"" . smarty_function_escape_special_chars($params['submit_button']) . "\" " . $params['button_html_code'] . " />\n";
    $html .= "</form>\n";
    return $html;
}
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator)
{
    $_output = '<input type="checkbox" name="' . smarty_function_escape_special_chars($name) . '[]" value="' . smarty_function_escape_special_chars($value) . '"';
    if (in_array($value, $selected)) {
        $_output .= ' checked="checked"';
    }
    $_output .= $extra . ' />' . $output . $separator . "\n";
    return $_output;
}
Beispiel #13
0
/**
 * Campsite comment_form block plugin
 *
 * Type:     block
 * Name:     comment_form
 * Purpose:  Displays a form for comment input
 *
 * @param string
 *     $p_params
 * @param string
 *     $p_smarty
 * @param string
 *     $p_content
 *
 * @return
 *
 */
function smarty_block_comment_form($p_params, $p_content, &$p_smarty, &$p_repeat)
{
    if (!isset($p_content)) {
        return '';
    }
    $p_smarty->smarty->loadPlugin('smarty_shared_escape_special_chars');
    $campsite = $p_smarty->getTemplateVars('gimme');
    if (!$campsite->article->comments_enabled) {
        return '';
    }
    $url = $campsite->url;
    $url->uri_parameter = "";
    $template = null;
    if (isset($p_params['template'])) {
        $themePath = $campsite->issue->defined() ? $campsite->issue->theme_path : $campsite->publication->theme_path;
        $template = new MetaTemplate($p_params['template'], $themePath);
        if (!$template->defined()) {
            CampTemplate::singleton()->trigger_error('invalid template "' . $p_params['template'] . '" specified in the comment form');
            return false;
        }
    } elseif (is_numeric($url->get_parameter('tpl'))) {
        $template = $campsite->default_template;
    }
    if (!isset($p_params['submit_button'])) {
        $p_params['submit_button'] = 'Submit';
    }
    $anchor = isset($p_params['anchor']) ? '#' . $p_params['anchor'] : null;
    if (!isset($p_params['html_code']) || empty($p_params['html_code'])) {
        $p_params['html_code'] = '';
    }
    if (!isset($p_params['button_html_code']) || empty($p_params['button_html_code'])) {
        $p_params['button_html_code'] = '';
    }
    if (isset($template)) {
        $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name);
    }
    $html = "<form name=\"submit_comment\" action=\"" . $url->uri_path . "{$anchor}\" " . "method=\"post\" " . $p_params['html_code'] . ">\n";
    if (isset($template)) {
        $html .= "<input type=\"hidden\" name=\"tpl\" value=\"" . $template->identifier . "\" />\n";
    }
    foreach ($campsite->url->form_parameters as $param) {
        if ($param['name'] == 'tpl') {
            continue;
        }
        $html .= '<input type="hidden" name="' . $param['name'] . '" value="' . htmlentities($param['value']) . "\" />\n";
    }
    if ($campsite->comment->identifier > 0) {
        $html .= "<input type=\"hidden\" name=\"acid\" " . "value=\"" . $campsite->comment->identifier . "\" />\n";
    }
    $html .= $p_content;
    $html .= "<input type=\"submit\" name=\"f_submit_comment\" " . "id=\"article_comment_submit\" value=\"" . smarty_function_escape_special_chars($p_params['submit_button']) . "\" " . $p_params['button_html_code'] . " />\n";
    if (isset($p_params['preview_button']) && !empty($p_params['preview_button'])) {
        $html .= "<input type=\"submit\" name=\"f_preview_comment\" " . "id=\"article_comment_preview\" value=\"" . smarty_function_escape_special_chars($p_params['preview_button']) . "\" " . $p_params['button_html_code'] . " />\n";
    }
    $html .= "</form>\n";
    return $html;
}
/**
 * Campsite interview_edit function plugin
 *
 * Type:     function
 * Name:     camp_edit
 * Purpose:  
 *
 * @param array
 *     $p_params the date in unixtime format from $smarty.now
 * @param object
 *     $p_smarty the date format wanted
 *
 * @return
 *     string the html form element
 *     string empty if something is wrong
 */
function smarty_function_interviewitem_edit($p_params, &$p_smarty)
{
    global $g_ado_db;

    require_once $p_smarty->_get_plugin_filepath('shared','escape_special_chars');

    // gets the context variable
    $campsite = $p_smarty->get_template_vars('gimme');
    $html = '';

    if (!isset($p_params['attribute'])) {
        return $html;
    }
    if (!isset($p_params['html_code']) || empty($p_params['html_code'])) {
        $p_params['html_code'] = '';
    }

    $object = strtolower($p_params['object']);
    $attribute = strtolower($p_params['attribute']);

    // gets the attribute value from the context
    $attrValue = $campsite->interviewitem->$attribute;

    $txtAreaFields = array('question', 'answer');
    $selectFields = array('status');

    if (in_array($attribute, $txtAreaFields)) {
        $html = '<textarea name="f_interviewitem_'.$attribute.'" cols="40" rows="4" '.$p_params['html_code'].'>';
        $html .= isset($_REQUEST["f_interviewitem_$attribute"]) ? 
            smarty_function_escape_special_chars($_REQUEST["f_interviewitem_$attribute"]) : 
            smarty_function_escape_special_chars($attrValue);
        $html .= '</textarea>';
            
    } elseif (in_array($attribute, $selectFields)) {
        require_once $p_smarty->_get_plugin_filepath('function','html_options');
        
        switch ($attribute) {            
            case 'status':
                $options = array('draft' => 'draft', 'pending' => 'pending', 'published' => 'published', 'rejected' => 'rejected');   

                $html = '<select name="f_interviewitem_status" id="interview_"'.$attribute.'>';
                $html.= smarty_function_html_options(array(
                    'options' => $options,
                    'selected' => isset($_REQUEST['f_interview_status']) ? $_REQUEST['f_interview_status']: $attrValue,
                    'print_result' => false),
                    $p_smarty
                );
                $html .= '</select>';
            break;
        } 
    }
    
    return $html;
} // fn smarty_function_interview_edit
function smarty_function_oos_cost($params, &$smarty)
{
    global $oCurrencies;
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $price = '';
    $tax = '';
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    print $oCurrencies->format(oos_add_tax($price, $tax));
}
/**
 * Smarty {html_image} function plugin
 *
 * Type:     function<br>
 * Name:     html_image<br>
 * Date:     Feb 24, 2003<br>
 * Purpose:  format HTML tags for the image<br>
 * Input:<br>
 *         - file = file (and path) of image (required)
 *         - height = image height (optional, default actual height)
 *         - width = image width (optional, default actual width)
 *         - basedir = base directory for absolute paths, default
 *                     is environment variable DOCUMENT_ROOT
 *
 * Examples: {html_image file="images/masthead.gif"}
 * Output:   <img src="images/masthead.gif" width=400 height=23>
 * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image}
 *      (Smarty online manual)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @author credits to Duda <*****@*****.**> - wrote first image function
 *           in repository, helped with lots of functionality
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_jscalendar($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
    $name = null;
    $values = null;
    $options = null;
    $selected = array();
    $output = null;
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'field':
                ${$_key} = (string) $_val;
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("html_options: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    //$values = util::getUF();
    if (!isset($field)) {
        $smarty->trigger_error("javascript_date: field é obrigatório", E_USER_NOTICE);
        return '';
    }
    $vet = split("\\.", $field);
    if (sizeof($vet) != 3) {
        $smarty->trigger_error("javascript_date: field deve ter o formato \"document.form_name.field_name\"", E_USER_NOTICE);
        return '';
    }
    $field_name = $vet[2];
    $form_name = $vet[0] . "." . $vet[1];
    $_js_result = '
	<script language="javascript" type="text/javascript">';
    $_js_result .= '
		Calendar.setup({
			inputField     :    "' . $field_name . '",
			ifFormat       :    "%d-%m-%Y",
			showsTime      :    false,
			onUpdate       :    atualiza_' . $field_name . '
		});
		function atualiza_' . $field_name . '(cal) {
			var date = cal.date;
			' . $form_name . '.' . $field_name . '.value = date.print("%d/%m/%Y");
		}
	';
    $_js_result .= '
	</script>';
    return $_js_result;
}
/**
 * Smarty {oos_add_tax} function plugin
 *
 * Type:     function
 * Name:     oos_get_zone_name
 * Version:  1.0
 * -------------------------------------------------------------
 */
function smarty_function_oos_add_tax($params, &$smarty)
{
    global $oCurrencies;
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    if ($_SESSION['member']->group['show_price_tax'] == 1) {
        return round($price, $oCurrencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + oos_calculate_tax($price, $tax);
    } else {
        return round($price, $oCurrencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
    }
}
function smarty_function_html_checkboxes_output($name,$value,$output,$selected,$extra,$separator,$labels) {
$_output = '';
if ($labels) $_output .= '<label>';
$_output .= '<input type="checkbox" name="'
.smarty_function_escape_special_chars($name) .'[]" value="'
.smarty_function_escape_special_chars($value) .'"';
if (in_array((string)$value,$selected)) {
$_output .= ' checked="checked"';
}
$_output .= $extra .' />'.$output;
if ($labels) $_output .= '</label>';
$_output .=  $separator;
return $_output;
}
/**
 * Smarty {swap_product_image} function plugin
 *
 * Type:     function<br>
 * Name:     swap_product_image<br>
 * Date:     Oct 09, 2006<br>
 * Purpose:  format HTML tags for the image<br>
 * Input:<br>
 *         - image = image width (optional, default actual width)
 *         - border = border width (optional, default 0)
 *         - height = image height (optional, default actual height)
 *
 * Examples: {swap_product_image id="featured" image=$random.products_image alt=$random.products_name|strip_tags}
 * Output:   <img id="featured" src="images/product_image.jpg" border="0" alt="products_name" onmouseover="imgSwap(this)" onmouseout="imgSwap(this)"/>
 * @author   r23 <*****@*****.**>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_swap_product_image($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');

    $basedir = OOS_IMAGES;
    $height = SMALL_IMAGE_HEIGHT;
    $width = SMALL_IMAGE_WIDTH;
    $border = 0;
    $alt = '';
    $image = '';
    $extra = '';

    $sLanguage = oos_var_prep_for_os($_SESSION['language']);

    foreach($params as $_key => $_val) {
      switch($_key) {
        case 'id':
        case 'image':
        case 'border':
        case 'height':
        case 'width':
        case 'basedir':
        case 'alt':
           if (!is_array($_val)) {
             $$_key = smarty_function_escape_special_chars($_val);
           } else {
             $smarty->trigger_error("small_product_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
           }
           break;

        default:
           if (!is_array($_val)) {
             $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
           } else {
             $smarty->trigger_error("small_product_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
           }
           break;
      }
    }

    $image = $basedir . $image;

    if ((empty($image) || ($image == OOS_IMAGES)) && (IMAGE_REQUIRED == '0')) {
        return false;
    }

    return '<img id="'.$id.'" src="'.$image.'" alt="'.$alt.'" border="'.$border.'" width="'.$width.'" height="'.$height.'"'.$extra.' onmouseover="imgSwap(this)" onmouseout="imgSwap(this)" />';

}
function smarty_function_oos_display_price($params, &$smarty)
{
    global $oCurrencies;
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $price = '';
    $tax = '';
    $qty = '';
    $calculate_currency_value = true;
    $currency = '';
    $currency_value = '';
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    print $oCurrencies->format(oos_add_tax($price, $tax) * $qty, $calculate_currency_value, $currency, $currency_value);
}
/**
 * Smarty {oos_check_stock} function plugin
 *
 * Type:     function
 * Name:     oos_check_stock
 * Version:  1.0
 * -------------------------------------------------------------
 */
function smarty_function_oos_check_stock($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $products_id = '';
    $products_quantity = '';
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    $stock_left = oos_get_products_stock($products_id) - $products_quantity;
    $out_of_stock = '';
    if ($stock_left < 0) {
        $out_of_stock = '<span class="oos-MarkProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>';
    }
    return $out_of_stock;
}
/**
 * Smarty {html_checkbox} function plugin
 *
 * File:       function.html_checkbox.php<br>
 * Type:       function<br>
 * Name:       html_checkbox<br>
 * Purpose:    Prints out a checkbox input<br>
 * Input:<br>
 *           - name       (optional) - string default "checkbox"
 *           - value      (required) - string
 *           - checked    (optional) - array default not set
 *           - id         (optional) - checkbox id (name is default)
 *           - label      (optional) - string for checkbox label
 * Examples:
 * <pre>
 * {html_checkbox value=1 name=horst}
 * {html_checkbox value=1 name=horst label="Select Horst"}
 * </pre>
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_html_checkbox($params, $template)
{
    require_once SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php';
    $name = 'checkbox';
    $value = null;
    $selected = null;
    $label = null;
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'name':
            case 'id':
            case 'value':
            case 'label':
                ${$_key} = $_val;
                break;
            case 'checked':
            case 'selected':
                $selected = (bool) $_val;
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    trigger_error("html_checkbox: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    // assign default id
    if (empty($id)) {
        $id = $name;
    }
    $_output = '';
    if ($label) {
        $_output .= '<nobr><label for="' . smarty_function_escape_special_chars($id) . '">';
    }
    $_output .= '<input type="checkbox" name="' . smarty_function_escape_special_chars($name) . '" id="' . smarty_function_escape_special_chars($id) . '" value="' . smarty_function_escape_special_chars($value) . '"';
    if ($selected) {
        $_output .= ' checked="checked"';
    }
    $_output .= $extra . ' />';
    if ($label) {
        $_output .= $label . '</label></nobr>';
    }
    return $_output;
}
/**
 * Smarty {html_iframe} function plugin
 *
 * Type:     function<br>
 * Name:     html_image_button<br>
 * Date:     September 15, 2003
 * Input:<br>
 *         - button = button (and path) of image (required)
 *         - border = border width (optional, default 0)
 *         - height = image height (optional, default actual height)
 *         - basedir = base directory
 *
 * Examples: {html_iframe doc="gpl.html" class="license" frameborder="0" scrolling="auto"}
 * @author r23 <*****@*****.**>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_html_iframe($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');

    $doc = '';
    $class = 'license';
    $frameborder = 0;
    $height = '';
    $scrolling = 'auto';
    $extra = '';
    // $sTheme = oos_var_prep_for_os($_SESSION['theme']);
    $sLanguage = oos_var_prep_for_os($_SESSION['language']);
    $dir = OOS_SHOP . OOS_MEDIA . $sLanguage . '/';

    foreach($params as $_key => $_val) {
        switch($_key) {

            case 'doc':
            case 'class':
            case 'frameborder':
            case 'scrolling':
                if(!is_array($_val)) {
                 $$_key = smarty_function_escape_special_chars($_val);
                } else {
                  $smarty->trigger_error("html_iframe: attribute '$_key' cannot be an array", E_USER_NOTICE);
                }
                break;

            default:
                if(!is_array($_val)) {
                    $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
                } else {
                    $smarty->trigger_error("html_iframe: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }

    if (empty($doc)) {
        $smarty->trigger_error("html_iframe: missing 'doc' parameter", E_USER_NOTICE);
        return;
    }

    return '<iframe src="'.$dir.$doc.'" class="'.$class.'" frameborder="'.$frameborder.'" scrolling="'.$scrolling.'"'.$extra.' /></iframe>';


}
/**
 * Campsite breadcrumb function plugin
 *
 * Type:     function
 * Name:     breadcrumb
 * Purpose:  builds the breadcrumb for the current page. A 'first_level'
 *           attribute can be passed who indicates where the breadcrumb
 *           should start.
 *
 * @param array
 *     $p_params the date in unixtime format from $smarty.now
 * @param object
 *     $p_smarty The Smarty object
 *
 * @return
 *     string the html string for the breadcrumb
 *
 * @todo make it linkable
 */
function smarty_function_breadcrumb($p_params, &$p_smarty)
{
    require_once $p_smarty->_get_plugin_filepath('shared','escape_special_chars');

    // gets the context variable
    $campsite = $p_smarty->get_template_vars('gimme');

    if (!isset($p_params['first_level']) || empty($p_params['first_level'])) {
        $p_params['first_level'] = 'home';
    }
    if (!isset($p_params['separator']) || empty($p_params['separator'])) {
        $p_params['separator'] = '&nbsp;&gt;&nbsp;';
    }

    $html = '';
    $breadcrumbStarted = 0;
    if ($p_params['first_level'] == 'home') {
        $html .= 'Home ' . $p_params['separator'];
        $breadcrumbStarted = 1;
    }
    if ($p_params['first_level'] == 'publication' || $breadcrumbStarted == 1
            && $campsite->publication->defined) {
        $html .= smarty_function_escape_special_chars($campsite->publication->name)
              . $p_params['separator'];
        $breadcrumbStarted = 1;
    }
    if ($p_params['first_level'] == 'issue' || $breadcrumbStarted == 1
            && $campsite->issue->defined) {
        $html .= smarty_function_escape_special_chars($campsite->issue->name)
              . $p_params['separator'];
        $breadcrumbStarted = 1;
    }
    if ($p_params['first_level'] == 'section' || $breadcrumbStarted == 1
            && $campsite->section->defined) {
        $html .= smarty_function_escape_special_chars($campsite->section->name)
              . $p_params['separator'];
        $breadcrumbStarted = 1;
    }
    if ($campsite->article->defined) {
        $html .= smarty_function_escape_special_chars($campsite->article->name)
              . $p_params['separator'];
    }

    return $html;

} // fn smarty_function_breadcrumb
function smarty_function_print_checkbox_output($name, $value, $output, $checked, $readonly, $submit)
{
    if ($checked) {
        $checked = "checked='checked'";
    }
    if (!empty($readonly)) {
        $readonly = "disabled='disabled'";
    }
    if (!empty($submit)) {
        $submit = "onclick='javascript:this.form.submit()'";
    }
    $_output = '<tr>
					<td class="form1">' . $output . '</td>
						<td class="form1" width="100%">
						<input class="fcheckbox1" type="checkbox" name="' . smarty_function_escape_special_chars($name) . '" value="' . smarty_function_escape_special_chars($value) . '"';
    $_output .= $checked . $readonly . $submit . ' /></td></tr>';
    return $_output;
}
/**
 * Smarty {oos_get_zone_name} function plugin
 *
 * Type:     function
 * Name:     oos_get_zone_name
 * Version:  1.0
 * -------------------------------------------------------------
 */
function smarty_function_oos_get_zone_name($params, &$smarty)
{
    $country_id = '';
    $zone_id = '';
    $default_zone = '';
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    $dbconn =& oosDBGetConn();
    $oostable =& oosDBGetTables();
    $zone = $dbconn->Execute("SELECT zone_name FROM " . $oostable['zones'] . " WHERE zone_country_id = '" . intval($country_id) . "' AND zone_id = '" . intval($zone_id) . "'");
    if ($zone->RecordCount()) {
        return $zone->fields['zone_name'];
    } else {
        return $default_zone;
    }
}
/**
 * Campsite interview_form block plugin
 *
 * Type:     block
 * Name:     interview_form
 * Purpose:  Provides a form for an interview
 *
 * @param string
 *     $p_params
 * @param string
 *     $p_smarty
 * @param string
 *     $p_content
 *
 * @return
 *
 */
function smarty_block_interview_form($p_params, $p_content, &$p_smarty, &$p_repeat)
{
    require_once $p_smarty->_get_plugin_filepath('shared','escape_special_chars');
    
    // gets the context variable
    $campsite = $p_smarty->get_template_vars('gimme');
    $html = '';
    
    if (0) {
        $Interview = new Interview($campsite->interview->identifier);
        return $Interview->getForm('/en/first/interview/', '', true);
    }
    
    if (isset($p_params['template'])) {
        $template = new Template($p_params['template']);
        $tpl_id = $template->getTemplateId();
    }
    if (!isset($p_params['submit_button'])) {
        $p_params['submit_button'] = 'Submit';
    }
    if (!isset($p_params['html_code']) || empty($p_params['html_code'])) {
        $p_params['html_code'] = '';
    }

    if (isset($p_content)) {
        $html = "<form name=\"interview\" action=\"{$campsite->url->uri_path}\" method=\"post\" enctype=\"multipart/form-data\">\n";
        $html .= "<input type=\"hidden\" name=\"_qf__interview\">\n";
        $html .= "<input type=\"hidden\" name=\"f_interview\" value=\"edit\">\n";
        
        if ($tpl_id) {
            $html .= "<input type=\"hidden\" name=\"".TEMPLATE_ID."\" value=\"$tpl_id\" />\n";
        }
        if ($campsite->interview->identifier) {
            $html .= "<input type=\"hidden\" name=\"f_interview_id\" value=\"{$campsite->interview->identifier}\" />\n";
        }
        $html .= $p_content;
        $html .= "<input type=\"submit\" name=\"f_interview_submit\" value=\""
              .smarty_function_escape_special_chars($p_params['submit_button'])
              ."\" ".$p_params['html_code']." />\n</form>\n";
    }

    return $html;
} // fn smarty_block_poll_form
function smarty_function_oos_price($params, &$smarty)
{

   global $oCurrencies;

   MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');

   $price = '';
   $tax = '';
   $qty = '';


   foreach($params as $_key => $_val) {
     $$_key = smarty_function_escape_special_chars($_val);
   }

   print $oCurrencies->display_price($price, $tax, $qty);

}
/**
 * Smarty {oos_get_country_list} function plugin
 *
 * Type:     function
 * Name:     oos_get_country_list
 * Version:  1.0
 * -------------------------------------------------------------
 */
function smarty_function_oos_get_country_list($params, &$smarty)
{
    global $aLang;
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    require_once $smarty->_get_plugin_filepath('function', 'html_options');
    /* Set the name of the <select> tag. */
    $name = 'country';
    /* <select size>'s of <select> tag.
       If not set, uses default dropdown. */
    $size = null;
    /* Unparsed attributes common to *ALL* the <select>/<input> tags.
       An example might be in the template: extra ='class ="foo"'. */
    $extra = null;
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    $countries = array();
    $countries_names = array();
    $countries_values = array();
    $countries = oos_get_countries();
    $countries_values[] = '';
    $countries_names[] = $aLang['pull_down_default'];
    $nArrayCountCountries = count($countries);
    for ($i = 0, $n = $nArrayCountCountries; $i < $n; $i++) {
        $countries_values[] = $countries[$i]['countries_id'];
        $countries_names[] = $countries[$i]['countries_name'];
    }
    $html_result .= '<select name="' . $name . '" id="entry_' . $name . '"';
    if (null !== $class) {
        $html_result .= ' class="' . $class . '"';
    }
    if (null !== $size) {
        $html_result .= ' size="' . $size . '"';
    }
    if (null !== $extra) {
        $html_result .= ' ' . $extra;
    }
    $html_result .= '>' . "\n";
    $html_result .= smarty_function_html_options(array('output' => $countries_names, 'values' => $countries_values, 'selected' => $selected, 'print_result' => false), $smarty);
    $html_result .= '</select>';
    print $html_result;
}
/**
 * Smarty {css_reset_button} function plugin
 *
 * Type:     function<br>
 * Name:     css_reset_button<br>
 * Input:<br>
 *         - value = button
 *
 * Examples: {css_reset_button value=$lang.image_button_login}
 * @author r23 <*****@*****.**>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 * @Version:  $Revision: 1.1 $ - changed by $Author: r23 $ on $Date: 2008/01/08 04:33:07 $
 */
function smarty_function_css_reset_button($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $value = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'value':
                ${$_key} = (string) $_val;
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("css_reset_button: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    $value = decode($value);
    return '<input type="button" id="reset_btn" value="' . $value . '" class="btn" />';
}