Пример #1
0
/**
 * 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
Пример #2
0
 /**
  * Class constructor
  *
  * @param string $p_uri
  *      The requested URI
  */
 public function __construct($p_uri = null)
 {
     parent::__construct($p_uri);
     $this->setURLType(URLTYPE_TEMPLATE_PATH);
     $subdir = $this->m_config->getSetting('SUBDIR');
     $this->m_templatesPrefix = empty($subdir) ? 'tpl' : substr($subdir, 1) . '/tpl';
     $res = $this->setURL();
     if (PEAR::isError($res)) {
         $this->m_validURI = false;
         $this->m_errorCode = $res->getCode();
         if ($this->m_errorCode == self::INVALID_TEMPLATE && !is_null($this->m_publication)) {
             $tplId = CampSystem::GetInvalidURLTemplate($this->m_publication->identifier, null, null, !$this->m_preview);
             $template = new MetaTemplate($tplId);
             if ($template->defined()) {
                 $this->m_template = $template;
             }
         }
         CampTemplate::singleton()->trigger_error($res->getMessage());
     } else {
         foreach (CampURITemplatePath::$m_restrictedParameters as $parameter) {
             $this->setQueryVar($parameter);
         }
         $this->m_validURI = true;
     }
     $this->validateCache(false);
 }
Пример #3
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;
}
Пример #4
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;
}
Пример #5
0
    /**
     * Class constructor
     *
     * @param string $p_uri
     *      The full URI string
     */
    public function __construct($p_uri = null)
    {
        parent::__construct($p_uri);

        $this->setURLType(URLTYPE_SHORT_NAMES);
        $res = $this->setURL();
        if (PEAR::isError($res)) {
            $this->m_validURI = false;
            $this->m_errorCode = $res->getCode();
            if (!is_null($this->m_publication)) {
            	$tplId = CampSystem::GetInvalidURLTemplate($this->m_publication->identifier);
            	$template = new MetaTemplate($tplId);
            	if ($template->defined()) {
            		$this->m_template = $template;
            	}
            }
            CampTemplate::singleton()->trigger_error($res->getMessage());
        } else {
            $this->m_validURI = true;
        }
        $this->validateCache(false);
    } // fn __construct
Пример #6
0
 /**
  * Get template
  *
  * @return MetaTemplate
  */
 private function _getTemplate()
 {
     $templateId = CampRequest::GetVar(CampRequest::TEMPLATE_ID);
     $themePath = $this->m_issue->defined() ? $this->m_issue->theme_path : $this->m_publication->theme_path;
     $template = new MetaTemplate(parent::getTemplate($templateId), $themePath);
     if (!$template->defined()) {
         throw new InvalidArgumentException("Invalid template in URL or no default template specified.", self::INVALID_TEMPLATE);
     }
     CampTemplate::singleton()->config_dir = APPLICATION_PATH . '/../themes/' . $themePath . '_conf';
     return $template;
 }
Пример #7
0
/**
 * Campsite poll_form block plugin
 *
 * Type:     block
 * Name:     poll_form
 * Purpose:  Provides a form for an poll
 *
 * @param string
 *     $p_params
 * @param string
 *     $p_smarty
 * @param string
 *     $p_content
 *
 * @return
 *
 */
function smarty_block_poll_form($p_params, $p_content, &$p_smarty, &$p_repeat)
{
    global $Campsite;
    
    if (isset($p_content)) {
    	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['template'])) {
	        $template = new MetaTemplate($p_params['template']);
	        if (!$template->defined()) {
	            $template = null;
	        }
	    }
	    $templateId = is_null($template) ? $campsite->template->identifier : $template->identifier;
	    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 ($p_params['ajax'] == true && !Input::Get('f_poll_ajax_request')) {
	       $html .= 
'
<script language="javascript" src="'.$Campsite['WEBSITE_URL'].'/javascript/scriptaculous/prototype.js"></script>
<script language="javascript">
    function poll_'.$campsite->poll->identifier.'_vote()
    {
        var data = Form.serialize($("poll_'.$campsite->poll->identifier.'_form"));
        var func = poll_'.$campsite->poll->identifier.'_reload;
        
        // avoid building the div tag on ajax request
        data = data + "&f_poll_ajax_request=1";
        
        // debug:
        //alert("data: " + data);
        //alert("func: " + func);
    
        var myAjax = new Ajax.Request(
            $("poll_'.$campsite->poll->identifier.'_form").action,
                { 
                    method: "get",
                    parameters: data,
                    onComplete: func
                }
            ); 
    }
    
    function poll_'.$campsite->poll->identifier.'_reload(response)
    {   
        $("poll_'.$campsite->poll->identifier.'_div").innerHTML = response.responseText;  
    }
</script>	
';
	       $html .= '<div id="poll_'.$campsite->poll->identifier.'_div">';
	       
	       $mode_tag = "<input type=\"hidden\" name=\"f_poll_mode\" value=\"ajax\" />\n";
	    } else {
	       $mode_tag = "<input type=\"hidden\" name=\"f_poll_mode\" value=\"standard\" />\n";   
	    }
	    
        $url = $campsite->url;
        $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name);
        $html .= "<form name=\"poll\" id=\"poll_{$campsite->poll->identifier}_form\" action=\"" . $url->uri_path . "\" method=\"post\">\n";
        
        $html .= "<input type=\"hidden\" name=\"f_poll\" value=\"1\" />\n";
        $html .= "<input type=\"hidden\" name=\"f_poll_nr\" value=\"{$campsite->poll->number}\" />\n";
        $html .= "<input type=\"hidden\" name=\"f_poll_language_id\" value=\"{$campsite->poll->language_id}\" />\n";        $html .= $mode_tag;
        
        foreach ($campsite->url->form_parameters as $param) {
            $html .= '<input type="hidden" name="'.$param['name']
                .'" value="'.htmlentities($param['value'])."\" />\n";
        }
        $html .= "<input type=\"hidden\" name=\"tpl\" value=\"$templateId\" />\n";
        
        $html .= $p_content;
        
        if (strlen($p_params['submit_button']) && $campsite->poll->is_votable) { 
	        $html .= "<div align=\"center\">\n.
	        		 <input type=\"submit\" name=\"f_poll\" value=\"".
	        		 smarty_function_escape_special_chars($p_params['submit_button']).
	            	 "\" ".
	            	 $p_params['html_code']." />\n".
	            	 "</div>\n";
        }
        
        $html .= "</form>\n";
        
	    if ($p_params['div'] == true && !Input::Get('f_poll_ajax_request')) {
	       $html .= '</div>';
	    }
	    
        return $html;
	} 
} // fn smarty_block_poll_form
Пример #8
0
/**
 * Campsite debate_form block plugin
 *
 * Type:     block
 * Name:     debate_form
 * Purpose:  Provides a form for an debate
 *
 * @param string
 *     $p_params
 * @param string
 *     $p_smarty
 * @param string
 *     $p_content
 *
 * @return
 *
 */
function smarty_block_debate_form($p_params, $p_content, &$p_smarty, &$p_repeat)
{
    global $Campsite;
    if (isset($p_content)) {
        // gets the context variable
        $campsite = $p_smarty->get_template_vars('gimme');
        $html = '';
        if (isset($p_params['template'])) {
            $template = new MetaTemplate($p_params['template']);
            if (!$template->defined()) {
                $template = null;
            }
        }
        $templateId = is_null($template) ? $campsite->template->identifier : $template->identifier;
        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 ($p_params['ajax'] == true && !Input::Get('f_debate_ajax_request')) {
            $html .= '
<script language="javascript" src="/js/jquery/jquery.min.js"></script>
<script language="javascript"><!--
function debate_' . $campsite->debate->identifier . '_vote()
{
    var data = $("#debate_' . $campsite->debate->identifier . '_form").serialize();

    // avoid building the div tag on ajax request
    data = data + "&f_debate_ajax_request=1";

    $.get($("#debate_' . $campsite->debate->identifier . '_form").attr("action"),
        data,
        function(response) {
            $("#debate_' . $campsite->debate->identifier . '_div").html(response);
        });
}
//--></script>
';
            $html .= '<div id="debate_' . $campsite->debate->identifier . '_div">';
            $mode_tag = "<input type=\"hidden\" name=\"f_debate_mode\" value=\"ajax\" />\n";
        } else {
            $mode_tag = "<input type=\"hidden\" name=\"f_debate_mode\" value=\"standard\" />\n";
        }
        $url = $campsite->url;
        $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name);
        $html .= "<form name=\"debate\" id=\"debate_{$campsite->debate->identifier}_form\" action=\"" . $url->uri . "\" method=\"post\">\n";
        $html .= "<input type=\"hidden\" name=\"f_debate\" value=\"1\" />\n";
        $html .= "<input type=\"hidden\" name=\"f_debate_nr\" value=\"{$campsite->debate->number}\" />\n";
        $html .= "<input type=\"hidden\" name=\"f_debate_language_id\" value=\"{$campsite->debate->language_id}\" />\n";
        $html .= $mode_tag;
        foreach ($campsite->url->form_parameters as $param) {
            $html .= '<input type="hidden" name="' . $param['name'] . '" value="' . htmlentities($param['value']) . "\" />\n";
        }
        $html .= "<input type=\"hidden\" name=\"tpl\" value=\"{$templateId}\" />\n";
        $html .= $p_content;
        if (strlen($p_params['submit_button']) && $campsite->debate->is_votable) {
            $html .= "<div align=\"center\">\n.\n\t        \t\t <input type=\"submit\" name=\"f_debate\" value=\"" . smarty_function_escape_special_chars($p_params['submit_button']) . "\" " . $p_params['html_code'] . " />\n" . "</div>\n";
        }
        $html .= "</form>\n";
        if ($p_params['div'] == true && !Input::Get('f_debate_ajax_request')) {
            $html .= '</div>';
        }
        return $html;
    }
}
/**
 * Campsite subscription_form block plugin
 *
 * Type:     block
 * Name:     subscription_form
 * Purpose:  Provides a...
 *
 * @param string
 *     $p_params
 * @param string
 *     $p_smarty
 * @param string
 *     $p_content
 *
 * @return
 *
 */
function smarty_block_subscription_form($p_params, $p_content, &$p_smarty, &$p_repeat)
{
    if (!isset($p_params['type']) || strtolower($p_params['type']) != 'by_section' && strtolower($p_params['type']) != 'by_publication') {
        return null;
    }
    // gets the context variable
    $campsite = $p_smarty->getTemplateVars('gimme');
    // gets the URL base
    $urlString = $campsite->url->base;
    if (strtolower($p_params['type']) == 'by_publication') {
        $campsite->subs_by_type = 'publication';
    } elseif (strtolower($p_params['type']) == 'by_section') {
        $campsite->subs_by_type = 'section';
    }
    $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');
    $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 subscription 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'] = '';
    }
    $subsType = strtolower(CampRequest::GetVar('SubsType'));
    if ($subsType != 'trial' && $subsType != 'paid') {
        return null;
    }
    $publication = $campsite->publication;
    $timeUnits = $subsType == 'trial' ? $publication->subscription_trial_time : $publication->subscription_paid_time;
    $sectionsNumber = Section::GetNumUniqueSections($publication->identifier, false);
    if (isset($template)) {
        $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name);
    }
    $html = "<form name=\"subscription_form\" action=\"" . $url->uri_path . "\" method=\"post\" " . $p_params['html_code'] . ">\n";
    $html .= "<input type=\"hidden\" name=\"subs_by_type\" value=\"" . $campsite->subs_by_type . "\" />\n";
    if (isset($template)) {
        $html .= "<input type=\"hidden\" name=\"tpl\" value=\"" . $template->identifier . "\" />\n";
    }
    $html .= "<input type=\"hidden\" name=\"SubsType\" value=\"{$subsType}\" />\n" . "<input type=\"hidden\" name=\"tx_subs\" value=\"{$timeUnits}\" />\n" . "<input type=\"hidden\" name=\"nos\" value=\"{$sectionsNumber}\" />\n" . "<input type=\"hidden\" name=\"unitcost\" value=\"" . $publication->subscription_unit_cost . "\" />\n" . "<input type=\"hidden\" name=\"unitcostalllang\" value=\"" . $publication->subscription_unit_cost_all_lang . "\" />\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;
    if ($subsType == 'paid' && isset($p_params['total']) != '') {
        $html .= $p_params['total'] . " <input type=\"text\" name=\"suma\" size=\"10\" " . "READONLY /> " . $currency;
    }
    $html .= "<input type=\"submit\" name=\"f_edit_subscription\" " . "id=\"subscriptionEdit\" value=\"" . smarty_function_escape_special_chars($p_params['submit_button']) . "\" " . $p_params['button_html_code'] . " />\n";
    $html .= "</form>\n";
    ?>
<script type="text/javascript">
/**
 * Returns true if the given object had the given property.
 */
function element_exists(object, property) {
	for (i in object) {
		if (object[i].name == property) {
			return true
		}
	}
	return false
}

/**
 * Used in subscription form; computes the subscription cost and updates
 * the corresponding field in the form.
 */
function update_subscription_payment() {
	var sum = 0
	var i
	var my_form = document.forms["subscription_form"]
	var subs_all_lang = false
	var unitcost = my_form.unitcost.value
	var lang_count = 1
	if (element_exists(my_form.elements, "subs_all_languages")
		&& my_form.subs_all_languages.checked) {
		unitcost = my_form.unitcostalllang.value
	} else if (element_exists(my_form.elements, "subscription_language[]")) {
		lang_count = 0
		for (i=0; i<my_form["subscription_language[]"].options.length; i++) {
			if (my_form["subscription_language[]"].options[i].selected) {
				lang_count++
			}
		}
	}
	for (i = 0; i < my_form.nos.value; i++) {
		if (element_exists(my_form.elements, "by")
			&& my_form.by.value == "publication") {
			sum = parseInt(sum) + parseInt(my_form["tx_subs"].value)
			continue
		}
		if (!my_form["cb_subs[]"][i].checked) {
			continue
		}
		var section = my_form["cb_subs[]"][i].value
		var time_var_name = "tx_subs" + section
		if (element_exists(my_form.elements, time_var_name)) {
			sum = parseInt(sum) + parseInt(my_form[time_var_name].value)
		} else if (element_exists(my_form.elements, "tx_subs")) {
			sum = parseInt(sum) + parseInt(my_form["tx_subs"].value)
		}
	}
	my_form.suma.value = Math.round(100 * sum * unitcost * lang_count) / 100
}

function ToggleElementEnabled(id) {
	if (document.getElementById(id).disabled) {
		document.getElementById(id).disabled = false
	} else {
		document.getElementById(id).disabled = true
	}
}
</script>
<?php 
    return $html;
}
 /**
  * Performs the action; returns true on success, false on error.
  *
  * @param $p_context - the current context object
  * @return bool
  */
 public function takeAction(CampContext &$p_context)
 {
     if (isset($p_input['tpl'])) {
         $template = new MetaTemplate($p_input['tpl']);
         if ($template->defined()) {
             $this->m_properties['template'] = $template;
         } else {
             $this->m_properties['template'] = $p_context->template;
         }
     } else {
         $this->m_properties['template'] = $p_context->template;
     }
     $fields = array('f_search_articles', 'f_match_all', 'f_search_level', 'f_search_keywords', 'f_search_issue', 'f_search_section', 'f_search_start_date', 'f_search_end_date', 'f_search_topic_id', 'f_search_scope');
     foreach ($fields as $field) {
         $p_context->default_url->reset_parameter($field);
         $p_context->url->reset_parameter($field);
     }
     $operator = new Operator('is', 'integer');
     $this->m_properties['constraints'] = array();
     if ($this->m_properties['search_level'] >= MetaActionSearch_Articles::SEARCH_LEVEL_PUBLICATION && $p_context->publication->defined) {
         $this->m_properties['constraints'][] = new ComparisonOperation('Articles.IdPublication', $operator, $p_context->publication->identifier);
     }
     if ($this->m_properties['search_level'] >= MetaActionSearch_Articles::SEARCH_LEVEL_ISSUE && $p_context->issue->defined && $this->m_properties['search_issue'] == 0) {
         $this->m_properties['constraints'][] = new ComparisonOperation('Articles.NrIssue', $operator, $p_context->issue->number);
     }
     if ($this->m_properties['search_level'] >= MetaActionSearch_Articles::SEARCH_LEVEL_SECTION && $p_context->section->defined && $this->m_properties['search_section'] == 0) {
         $this->m_properties['constraints'][] = new ComparisonOperation('Articles.NrSection', $operator, $p_context->section->number);
     }
     if ($this->m_properties['search_issue'] > 0) {
         $this->m_properties['constraints'][] = new ComparisonOperation('Articles.NrIssue', $operator, $this->m_properties['search_issue']);
     }
     if ($this->m_properties['search_section'] > 0) {
         $this->m_properties['constraints'][] = new ComparisonOperation('Articles.NrSection', $operator, $this->m_properties['search_section']);
     }
     if (!empty($this->m_properties['start_date'])) {
         $startDateOperator = new Operator('greater_equal', 'date');
         $this->m_properties['constraints'][] = new ComparisonOperation('Articles.PublishDate', $startDateOperator, $this->m_properties['start_date']);
     }
     if (!empty($this->m_properties['end_date'])) {
         $endDateOperator = new Operator('smaller_equal', 'date');
         $this->m_properties['constraints'][] = new ComparisonOperation('Articles.PublishDate', $endDateOperator, $this->m_properties['end_date']);
     }
     if (!empty($this->m_properties['topic_id'])) {
         $this->m_properties['constraints'][] = new ComparisonOperation('ArticleTopics.TopicId', $operator, $this->m_properties['topic_id']);
     }
     return true;
 }
Пример #11
0
 /**
  * Get template
  *
  * @return MetaTemplate
  */
 private function _getTemplate()
 {
     $templateId = CampRequest::GetVar(CampRequest::TEMPLATE_ID);
     $themePath = $this->m_issue->defined() ? $this->m_issue->theme_path : $this->m_publication->theme_path;
     $template = new MetaTemplate(parent::getTemplate($templateId), $themePath);
     if (!$template->defined()) {
         throw new InvalidArgumentException("Invalid template in URL or no default template specified.", self::INVALID_TEMPLATE);
     }
     return $template;
 }
Пример #12
0
 /**
  *
  */
 public function getTemplate($p_templateIdOrName = null)
 {
     if (!is_null($this->m_template)) {
         return $this->m_template->name;
     }
     if (!empty($p_templateIdOrName)) {
         $tplObj = new MetaTemplate($p_templateIdOrName);
         if (!$tplObj->defined()) {
             $template = CampSystem::GetInvalidURLTemplate($this->publication->identifier, $this->issue->number, $this->language->number, !$this->m_preview);
             $template = substr($template, strlen($this->getThemePath()));
         } else {
             $template = $tplObj->name;
         }
     } elseif (is_null($this->m_errorCode)) {
         $template = CampSystem::GetTemplate($this->language->number, $this->publication->identifier, $this->issue->number, $this->section->number, $this->article->number);
         if (is_null($template)) {
             $template = CampSystem::GetInvalidURLTemplate($this->publication->identifier, $this->issue->number, $this->language->number, !$this->m_preview);
         }
         $template = substr($template, strlen($this->getThemePath()));
     } else {
         return null;
     }
     $filePath = CS_PATH_TEMPLATES . DIR_SEP . $this->getThemePath() . $template;
     if (!file_exists($filePath)) {
         return null;
     }
     return $template;
 }
Пример #13
0
/**
 * Campsite blog_form block plugin
 *
 * Type:     block
 * Name:     blog_form
 * Purpose:  Provides a form for an blog entry
 *
 * @param string
 *     $p_params
 * @param string
 *     $p_smarty
 * @param string
 *     $p_content
 *
 * @return
 *
 */
function smarty_block_blog_form($p_params, $p_content, &$p_smarty, &$p_repeat)
{
    // gets the context variable
    $campsite = $p_smarty->get_template_vars('gimme');

    if (!$campsite->user->identifier) {
        return getGS('Only registered users are allowed to blog.');
    }
    
    if ($campsite->blog->defined && ($campsite->blog->user_id != $campsite->user->identifier) && !$campsite->user->has_permission('plugin_blog')) {
        // owner or blog superuser
        return getGS('You are not allowed to edit this blog.');
    }

    if (isset($p_content)) {
        require_once $p_smarty->_get_plugin_filepath('shared','escape_special_chars');
        $html = '';

        if (isset($p_params['template'])) {
            $template = new MetaTemplate($p_params['template']);
            if (!$template->defined()) {
                $template = null;
            }
        }
        $templateId = is_null($template) ? $campsite->template->identifier : $template->identifier;

        /*
        if (!isset($p_params['submit_button'])) {
            $p_params['submit_button'] = 'Submit';
        }
                
        if (!isset($p_params['preview_button'])) {
            $p_params['preview_button'] = 'Preview';
        }
        */
                
        if (!isset($p_params['html_code']) || empty($p_params['html_code'])) {
            $p_params['html_code'] = '';
        }

        $url = $campsite->url;
        $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name);
        $html .= "<form name=\"blog\" action=\"" . $url->uri_path . "\" method=\"post\">\n";

        $html .= "<input type=\"hidden\" name=\"f_blog\" value=\"1\" />\n";
        
        if ($campsite->blog->identifier) {
            $html .= '<input type="hidden" name="f_blog_id" value="'.$campsite->blog->identifier."\" />\n";    
        }

        foreach ($campsite->url->form_parameters as $param) {
            $html .= '<input type="hidden" name="'.$param['name'].'" value="'.htmlentities($param['value'])."\" />\n";
        }

        $html .= $p_content;

        $html .= "</form>\n";

        return $html;
    }
} // fn smarty_block_blog_form