function __construct($src = null, $params = array()) { global $db, $router, $section, $user; parent::__construct($src = null, $params); // we're setting the config here globably $this->grabConfig(); if (expTheme::inAction() && !empty($router->url_parts[1]) && ($router->url_parts[0] == "store" && $router->url_parts[1] == "showall")) { if (isset($router->url_parts[array_search('title', $router->url_parts) + 1]) && is_string($router->url_parts[array_search('title', $router->url_parts) + 1])) { $default_id = $db->selectValue('storeCategories', 'id', "sef_url='" . $router->url_parts[array_search('title', $router->url_parts) + 1] . "'"); $active = $db->selectValue('storeCategories', 'is_active', "sef_url='" . $router->url_parts[array_search('title', $router->url_parts) + 1] . "'"); if (empty($active) && $user->is_acting_admin != 1) { redirect_to(array("section" => SITE_DEFAULT_SECTION)); } expSession::set('catid', $default_id); } } elseif (expTheme::inAction() && !empty($router->url_parts[1]) && ($router->url_parts[0] == "store" && ($router->url_parts[1] == "show" || $router->url_parts[1] == "showByTitle"))) { if (isset($router->url_parts[array_search('id', $router->url_parts) + 1]) && $router->url_parts[array_search('id', $router->url_parts) + 1] != 0) { $default_id = $db->selectValue('product_storeCategories', 'storecategories_id', "product_id='" . $router->url_parts[array_search('id', $router->url_parts) + 1] . "'"); expSession::set('catid', $default_id); } else { $prod_id = $db->selectValue('product', 'id', "sef_url='" . $router->url_parts[array_search('title', $router->url_parts) + 1] . "'"); $default_id = $db->selectValue('product_storeCategories', 'storecategories_id', "product_id='" . $prod_id . "'"); expSession::set('catid', $default_id); } } elseif (isset($this->config['show_first_category']) || !expTheme::inAction() && $section == SITE_DEFAULT_SECTION) { if (!empty($this->config['show_first_category'])) { $default_id = $db->selectValue('storeCategories', 'id', 'lft=1'); } else { $default_id = 0; } expSession::set('catid', $default_id); } elseif (!isset($this->config['show_first_category']) && !expTheme::inAction()) { expSession::set('catid', 0); } else { $default_id = 0; } // figure out if we need to show all categories and products or default to showing the first category. // elseif (!empty($this->config['category'])) { // $default_id = $this->config['category']; // } elseif (ecomconfig::getConfig('show_first_category')) { // $default_id = $db->selectValue('storeCategories', 'id', 'lft=1'); // } else { // $default_id = 0; // } $this->parent = expSession::get('catid'); $this->category = new storeCategory($this->parent); // we're setting the config here for the category $this->grabConfig($this->category); }
public function makeSortDropdown($params) { global $router; if (!empty($this->columns) && is_array($this->columns)) { $this->sort_dropdown = array(); // get the parameters used to make this page. if (!expTheme::inAction()) { unset($params['section']); if (empty($params['controller'])) { $params['controller'] = $this->controller; } if (empty($params['action'])) { $params['action'] = $this->action; } } /*$current = ''; if (isset($params['order'])) { $current = $params['order']; unset($params['order']); } else { $current = $this->order; } */ //loop over the columns and build out a list of <th>'s to be used in the page table // eDebug($router); $defaultParams['controller'] = $params['controller']; $defaultParams['action'] = $params['action']; if (isset($params['title'])) { $defaultParams['title'] = $params['title']; } if (isset($params['page'])) { $defaultParams['page'] = $params['page']; } $this->sort_dropdown[$router->makeLink($defaultParams, null, null, true)] = "Default"; foreach ($this->columns as $colname => $col) { // if this is the column we are sorting on right now we need to setup some class info /*$class = isset($this->class) ? $this->class : 'page'; $params['dir'] = 'ASC';*/ /*if ($col == $current) { $class = 'current'; $class .= ' '.$this->order_direction; if (isset($_REQUEST['dir'])) { $params['dir'] = $_REQUEST['dir'] == 'ASC' ? 'DESC' : 'ASC'; } else { $params['dir'] = $this->order_direction == 'ASC' ? 'DESC' : 'ASC'; } } */ $params['order'] = $col; if (!empty($col)) { if ($colname == 'Price') { $params['dir'] = 'ASC'; $this->sort_dropdown[$router->makeLink($params, null, null, true)] = $colname . " - Lowest to Highest"; $params['dir'] = 'DESC'; $this->sort_dropdown[$router->makeLink($params, null, null, true)] = $colname . " - Highest to Lowest"; } else { $params['dir'] = 'ASC'; $this->sort_dropdown[$router->makeLink($params, null, null, true)] = $colname . " - A-Z"; $params['dir'] = 'DESC'; $this->sort_dropdown[$router->makeLink($params, null, null, true)] = $colname . " - Z-A"; } } } } }
# Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## /** @define "BASE" "." */ define('SCRIPT_EXP_RELATIVE', ''); define('SCRIPT_FILENAME', 'popup.php'); ob_start(); // Initialize the Exponent Framework require_once 'exponent.php'; $loc = expCore::makeLocation(isset($_GET['module']) ? $_GET['module'] : '', isset($_GET['src']) ? $_GET['src'] : '', isset($_GET['int']) ? $_GET['int'] : ''); if (expTheme::inAction()) { expTheme::runAction(); } else { if (isset($_GET['module']) && isset($_GET['view'])) { // expHistory::flowSet(SYS_FLOW_PUBLIC,SYS_FLOW_SECTIONAL); expHistory::set('viewable', $router->params); $mod = new $_GET['module'](); $mod->show($_GET['view'], $loc, isset($_GET['title']) ? $_GET['title'] : ''); } } $str = ob_get_contents(); ob_end_clean(); $template = new standalonetemplate('popup_' . (isset($_GET['template']) ? $_GET['template'] : 'general')); $template->assign('output', $str); $template->output();
public function setHistory($url_type, $params) { global $router; // if the history gets bigger than 10 then we will trim it. $size = empty($this->history[$url_type]) ? 0 : count($this->history[$url_type]); if ($size > 10) { array_shift($this->history[$url_type]); $size = $size - 1; } // if we're in an action, we'll only set history if the action we're trying to set // matches the action the we're in...otherwise if we're on a page we check to make sure // the page we're trying to set isn't the same as the last one we just set. This will keep // page refreshes the controllers on the same page from loading up the viewable array with a // bunch of identical entries $url = ''; if (stristr($router->current_url, 'EXPONENT.')) { return false; } if (expTheme::inAction()) { // we don't want to save history for these action...it screws up the flow when logging in if (!isset($router->params['action']) || $router->params['action'] == 'loginredirect' || $router->params['action'] == 'logout') { return false; } // figure out the module/controller names $router_name = isset($router->params['controller']) ? $router->params['controller'] : $router->params['module']; $params_name = isset($params['controller']) ? $params['controller'] : $params['module']; // make sure the controller action is the one specified via the URL if (expModules::getControllerName($router_name) == expModules::getControllerName($params_name) && $router->params['action'] == $params['action']) { $url = array('url_type' => $router->url_type, 'params' => $router->params); } } else { //if we hit here it should be a page, not an action $url = array('url_type' => $router->url_type, 'params' => $router->params); } if (!empty($url)) { $diff = array(); // if this url is the exact same as the last for this type we won't save it..that way refresh won't fill up our history if ($size > 0) { $diff = array_diff_assoc($router->params, $this->history[$url_type][$size - 1]['params']); } if (!empty($diff) || $size == 0) { $this->history[$url_type][] = $url; } // save the "lasts" information $this->history['lasts']['type'] = $url_type; if ($url_type != 'editable') { $this->history['lasts']['not_editable'] = $url_type; } } expSession::set('history', $this->history); }
public function getSection() { if (expTheme::inAction()) { if (isset($_REQUEST['section'])) { $section = $this->url_type == "sef" ? $this->getPageByName($_REQUEST['section']) : $_REQUEST['section']; } else { $section = expSession::is_set('last_section') ? expSession::get('last_section') : SITE_DEFAULT_SECTION; } } else { $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : SITE_DEFAULT_SECTION; } return $section; }
function exponent_theme_inAction() { return expTheme::inAction(); }
function renderAction(array $parms = array()) { global $user; //Get some info about the controller $baseControllerName = expModules::getControllerName($parms['controller']); $fullControllerName = expModules::getControllerClassName($parms['controller']); $controllerClass = new ReflectionClass($fullControllerName); // Figure out the action to use...if the specified action doesn't exist then // we look for the index action. if ($controllerClass->hasMethod($parms['action'])) { $action = $parms['action']; /* TODO: Not sure if this needs to be here. FJD $meth = $controllerClass->getMethod($action); if ($meth->isPrivate()) expQueue::flashAndFlow('error', 'The requested action could not be performed: Action not found');*/ } elseif ($controllerClass->hasMethod('index')) { $action = 'index'; } elseif ($controllerClass->hasMethod('showall')) { $action = 'showall'; } else { expQueue::flashAndFlow('error', gt('The requested action could not be performed: Action not found')); } // initialize the controller. $src = isset($parms['src']) ? $parms['src'] : null; $controller = new $fullControllerName($src, $parms); //Set up the template to use for this action global $template; $view = !empty($parms['view']) ? $parms['view'] : $action; $template = get_template_for_action($controller, $view, $controller->loc); // have the controller assign knowledge about itself to the template. // this has to be done after the controller get the template for its actions $controller->moduleSelfAwareness(); //if this controller is being called by a container then we should have a module title. if (isset($parms['moduletitle'])) { $template->assign('moduletitle', $parms['moduletitle']); } //setup some default models for this controller's actions to use foreach ($controller->getModels() as $model) { $controller->{$model} = new $model(null, false, false); //added null,false,false to reduce unnecessary queries. FJD } // add the $_REQUEST values to the controller <- pb: took this out and passed in the params to the controller constructor above //$controller->params = $parms; //check the perms for this action $perms = $controller->permissions(); //we have to treat the update permission a little different..it's tied to the create/edit //permissions. Really the only way this will fail will be if someone bypasses the perm check //on the edit form somehow..like a hacker trying to bypass the form and just submit straight to //the action. To safeguard, we'll catch if the action is update and change it either to create or //edit depending on whether an id param is passed to. that should be sufficient. $common_action = null; if ($parms['action'] == 'update') { $perm_action = !isset($parms['id']) || $parms['id'] == 0 ? 'create' : 'edit'; } elseif ($parms['action'] == 'saveconfig') { $perm_action = 'configure'; } else { // action convention for controllers that manage more than one model (datatype). // if you preface the name action name with a common crud action name we can check perms on // it with the developer needing to specify any...better safe than sorry. // i.e if the action is edit_mymodel it will be checked against the edit permission if (stristr($parms['action'], '_')) { $parts = explode("_", $parms['action']); } $common_action = isset($parts[0]) ? $parts[0] : null; $perm_action = $parms['action']; } if (array_key_exists($perm_action, $perms)) { if (!expPermissions::check($perm_action, $controller->loc)) { if (expTheme::inAction()) { flash('error', gt("You don't have permission to") . " " . $perms[$perm_action]); expHistory::returnTo('viewable'); } else { return false; } } } elseif (array_key_exists($common_action, $perms)) { if (!expPermissions::check($common_action, $controller->loc)) { if (expTheme::inAction()) { flash('error', gt("You don't have permission to") . " " . $perms[$common_action]); expHistory::returnTo('viewable'); } else { return false; } } } elseif (array_key_exists($perm_action, $controller->requires_login)) { // check if the action requires the user to be logged in if (!$user->isLoggedIn()) { $msg = empty($controller->requires_login[$perm_action]) ? gt("You must be logged in to perform this action") : $controller->requires_login[$perm_action]; flash('error', $msg); expHistory::redirecto_login(); } } elseif (array_key_exists($common_action, $controller->requires_login)) { // check if the action requires the user to be logged in if (!$user->isLoggedIn()) { $msg = empty($controller->requires_login[$common_action]) ? gt("You must be logged in to perform this action") : $controller->requires_login[$common_action]; flash('error', $msg); expHistory::redirecto_login(); } } // run the action $controller->{$action}(); //register this controllers permissions to the view for in view perm checks $template->register_permissions(array_keys($perms), $controller->loc); // pass this controllers config off to the view $template->assign('config', $controller->config); // globalizing $user inside all templates $template->assign('user', $user); //assign the controllers basemodel to the view $template->assign('modelname', $controller->basemodel_name); if (empty($parms['no_output'])) { $template->output(); } else { $html = $template->render(); return $html; } //$html = $template->output(); //return $html; }