Exemple #1
0
function getAjaxUri($app = 'jreviews')
{
    return getXajaxUri($app);
}
Exemple #2
0
 function beforeFilter()
 {
     # Init Access
     if (isset($this->Access)) {
         $this->Access->init($this->Config);
     }
     # Dynamic Community integration loading
     $community_extension = Configure::read('Community.extension');
     $community_extension = $community_extension != '' ? $community_extension : 'community_builder';
     App::import('Model', $community_extension, 'jreviews');
     $this->Community = new CommunityModel();
     # Set Theme
     $this->viewTheme = $this->Config->template;
     $this->viewImages = S2Paths::get('jreviews', 'S2_THEMES_URL') . 'default' . _DS . 'theme_images' . _DS;
     # Set template type for lists and template suffix
     $this->__initTemplating();
     # Set pagination vars
     // First check url, then menu parameter. Otherwise the limit list in pagination doesn't respond b/c menu params always wins
     $this->limit = Sanitize::getInt($this->params, 'limit', Sanitize::getInt($this->data, 'limit_special', Sanitize::getInt($this->data, 'limit')));
     //		$this->passedArgs['limit'] = $this->limit;
     $this->page = Sanitize::getInt($this->data, 'page', Sanitize::getInt($this->params, 'page', 1));
     if (!$this->limit) {
         if (Sanitize::getVar($this->params, 'action') == 'myreviews') {
             $this->limit = Sanitize::getInt($this->params, 'limit', $this->Config->user_limit);
         } else {
             $this->limit = Sanitize::getInt($this->params, 'limit', $this->Config->list_limit);
         }
     }
     // Set a hard code limit to prevent abuse
     $this->limit = max(min($this->limit, 50), 1);
     // Need to normalize the limit var for modules
     if (isset($this->params['module'])) {
         $module_limit = Sanitize::getInt($this->params['module'], 'module_limit', 5);
     } else {
         $module_limit = 5;
     }
     $this->module_limit = Sanitize::getInt($this->data, 'module_limit', $module_limit);
     $this->module_page = Sanitize::getInt($this->data, 'module_page', 1);
     $this->module_page = $this->module_page === 0 ? 1 : $this->module_page;
     $this->module_offset = (int) ($this->module_page - 1) * $this->module_limit;
     if ($this->module_offset < 0) {
         $this->module_offset = 0;
     }
     $this->page = $this->page === 0 ? 1 : $this->page;
     $this->offset = (int) ($this->page - 1) * $this->limit;
     if ($this->offset < 0) {
         $this->offset = 0;
     }
     # Add global javascript variables
     if (!defined('MVC_GLOBAL_JS_VARS') && !$this->ajaxRequest && $this->action != '_save') {
         cmsFramework::addScript('<script type="text/javascript">
         //<![CDATA[
         var xajaxUri = "' . getXajaxUri() . '";
         //]]>
         </script>');
         cmsFramework::addScript('<script type="text/javascript">
         //<![CDATA[
         var s2AjaxUri = "' . getAjaxUri() . '";
         //]]>
         </script>');
         cmsFramework::addScript('<script type="text/javascript">
             var jr_translate= new Array();
             jr_translate["cancel"] = "' . __t("Cancel", true) . '";
             jr_translate["submit"] = "' . __t("Submit", true) . '";
         </script>');
         $javascriptcode = '<script type="text/javascript">%s</script>';
         # Set calendar image
         cmsFramework::addScript(sprintf($javascriptcode, 'var datePickerImage = "' . $this->viewImages . 'calendar.gif";'));
         # Find and set one public Itemid to use for Ajax requests
         $menu_id = '';
         if (!defined('MVC_FRAMEWORK_ADMIN')) {
             App::import('Model', 'menu', 'jreviews');
             $MenuModel = RegisterClass::getInstance('MenuModel');
             $menu_id = $MenuModel->get('jreviews_public');
             $menu_id = $menu_id != '' ? $menu_id : 99999;
             $this->set('public_menu_id', $menu_id);
         }
         # Set JReviews public menu
         cmsFramework::addScript(sprintf($javascriptcode, 'var jr_publicMenu = ' . $menu_id . ';'));
         define('MVC_GLOBAL_JS_VARS', 1);
     }
     # Init plugin system
     $this->_initPlugins();
 }