public static function handleException($e) { $fc = new FrontController(); $page = new Page('error/500', $fc); $page->process(); $fc->getResponse()->send(); }
/** * Configure ACL to deny everything, thus the request must be dispatched * to the authentication controller. * * @covers spriebsch\MVC\FrontController */ public function testExecute() { $this->request = $this->getMock('spriebsch\\MVC\\Request', array(), array(), '', false, false); $this->response = $this->getMock('spriebsch\\MVC\\Response', array(), array(), '', false, false); $this->session = $this->getMock('spriebsch\\MVC\\Session', array(), array(), '', false, false); $this->authAdapter = $this->getMock('spriebsch\\MVC\\AuthenticationAdapter', array(), array(), '', false, false); $this->controllerFactory = $this->getMock('spriebsch\\MVC\\ControllerFactory', array(), array(), '', false, false); $this->viewFactory = $this->getMock('spriebsch\\MVC\\ViewFactory', array(), array(), '', false, false); $this->acl = $this->getMock('spriebsch\\MVC\\Acl', array(), array(), '', false, false); $this->appController = $this->getMock('spriebsch\\MVC\\ApplicationController', array(), array(), '', false, false); $this->view = $this->getMock('spriebsch\\MVC\\View', array(), array(), '', false, false); $this->controller = $this->getMock('spriebsch\\MVC\\Controller', array(), array(), '', false, false); // Controller's execute method must be called once and return 'success'. $this->controller->expects($this->once())->method('execute')->will($this->returnValue('success')); // View's render method must be called once. $this->view->expects($this->once())->method('render'); // ->with($this->equalTo()); // @todo request and response as parameters // The controller factory returns the controller object. $this->controllerFactory->expects($this->once())->method('getController')->will($this->returnValue($this->controller)); // The application controller returns a controller name, class, and // method that we ignore anyway. $this->appController->expects($this->once())->method('getControllerName')->will($this->returnValue('controller')); $this->appController->expects($this->once())->method('getClass')->will($this->returnValue('class')); $this->appController->expects($this->once())->method('getMethod')->will($this->returnValue('method')); $this->appController->expects($this->once())->method('getView')->will($this->returnValue($this->view)); $fc = new FrontController($this->request, $this->response, $this->session, $this->authAdapter, $this->acl, $this->appController, $this->controllerFactory); $fc->execute(); }
/** * @covers FrontController::__construct * @covers FrontController::dispatch */ public function testDispatchingWorksCorrectly() { $request = new Request(array('REQUEST_URI' => '/test')); $response = new Response(); $router = new Router(); $router->set('test', 'TestController'); $frontController = new FrontController($request, $response, $router, new ControllerFactory(new MapperFactory(new PDO('sqlite::memory:'))), new ViewFactory()); $this->assertInstanceOf('TestView', $frontController->dispatch($router)); }
public function indexAction() { $fc = FrontController::getInstance(); $view = new DefaultModel(); $out = $view->showIndexPage(); $fc->setBody($out); }
public static function getInstance() { if (!self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; }
public static function getInstance() { if (!is_object(self::$_instance)) { self::$_instance = new FrontController(); } return self::$_instance; }
public function run() { if ($this->getConfigFolder() == null) { $this->setConfigFolder('../config'); } $this->frontController = FrontController::getInstance(); if ($this->router == null) { $this->router = new DefaultRouter(); } $this->frontController->setRouter($this->router); $sess = $this->config->app['session']; if (isset($sess['autostart'])) { if ($sess['type'] == 'native') { $s = new NativeSession($sess['name'], $sess['lifetime'], $sess['path'], $sess['domain'], $sess['secure']); $http = new HttpContext(null, $s); } $this->setHttpContext($http ?? new HttpContext()); } if (isset($this->config->app['identity']['userClass'])) { $userConfigClass = $this->config->app['identity']['userClass']; $this->identity = new Identity($userConfigClass, new SimpleDB()); } else { $this->identity = new Identity(new IdentityUser(null, null), new SimpleDB()); } $this->frontController->dispatch(); }
public function __construct() { $this->auth = false; $this->php_self = 'modals.php'; $this->ssl = true; parent::__construct(); }
public function init() { parent::init(); AuthController::requireLogin(); AuthController::requireShopSession(); $this->setSmarty(); }
public function initContent() { //pass data to template file $this->setTemplate(_PS_THEME_DIR_ . 'remboursementDon.tpl'); //call parent initcontent - this is for loading the site's default header, footer, left and right columns parent::initContent(); }
public function __construct() { $fc = FrontController::getInstance(); $this->params = $fc->getParams(); $this->format = $fc->getFormat(); $this->makeObj(); }
public function preProcess() { parent::preProcess(); $file_id = $_REQUEST['fid']; /* $file = UPLOAD_DIR.'/homepage_adimg.jpg'; echo $file; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } */ exit; }
/** * Returns an instance of FrontController object * @return FrontController */ public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; }
public static function getSubCategories($id_lang, $active = true, $id_category = 2, $p = 0, $n = 6) { $sql_groups_where = ''; $sql_groups_join = ''; if (Group::isFeatureActive()) { $sql_groups_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = c.`id_category`)'; $groups = FrontController::getCurrentCustomerGroups(); $sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . pSQL(implode(',', $groups)) . ')' : '=' . (int) Group::getCurrent()->id); } $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description FROM `' . _DB_PREFIX_ . 'category` c ' . Shop::addSqlAssociation('category', 'c') . ' LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = ' . (int) $id_lang . ' ' . Shop::addSqlRestrictionOnLang('cl') . ') ' . $sql_groups_join . ' WHERE `id_parent` = ' . (int) $id_category . ' ' . ($active ? 'AND `active` = 1' : '') . ' ' . $sql_groups_where . ' GROUP BY c.`id_category` ORDER BY `level_depth` ASC, category_shop.`position` ASC LIMIT ' . (int) $p . ', ' . (int) $n); foreach ($result as &$row) { $row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_ . $row['id_category'] . '.jpg') ? (int) $row['id_category'] : Language::getIsoById($id_lang) . '-default'; $row['legend'] = 'no picture'; } return $result; }
public function indexAction() { $fc = FrontController::getInstance(); $admin = new Admin(); $output = $admin->render(ADMIN_TEMPLATE, ADMIN_LOGIN); $fc->setBody($output); }
public function indexAction() { $fc = FrontController::getInstance(); $model = new PageModel(); header('HTTP/1.0 Not Found'); $fc->setBody($model->render('404.php', TEMPLATE)); }
public static function run($request) { if (!$request instanceof Request) { $request = new Request($request); } $file = $request->getFile(); $class = $request->getClass(); $method = $request->getMethod(); $args = $request->getArgs(); $front = FrontController::getInstance(); $registry = $front->getRegistry(); $registry->oRequest = $request; $front->setRegistry($registry); if (file_exists($file)) { require_once $file; $rc = new ReflectionClass($class); // if the controller exists and implements IController // if($rc->implementsInterface('IController')) if ($rc->isSubclassOf('BaseController')) { try { $controller = $rc->newInstance(); $classMethod = $rc->getMethod($method); return $classMethod->invokeArgs($controller, $args); } catch (ReflectionException $e) { throw new MvcException($e->getMessage()); } } else { // throw new MvcException("Interface iController must be implemented"); throw new MvcException("abstract class BaseController must be extended"); } } else { throw new MvcException("Controller file not found"); } }
public function showAll() { $fc = FrontController::getInstance(); $dbh = $fc->connect(); $sql = "\n\t\t\tSELECT listenerName, listenerTitle, status, moderatedTime\n\t\t\t\tFROM listener \n\t\t\t\t\tORDER by moderatedTime\n\t\t"; $sth = $dbh->prepare($sql); $sth->execute(); $result = $sth->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $item) { switch ($item['status']) { case 0: $status = "На модерации"; break; case 1: $status = "<span class='text-success'>Одобрено</span>"; break; case 2: $status = "<span class='text-danger'>Отклонено</span>"; break; case 3: $status = "<span class='text-info'>В архиве</span>"; break; } echo "<tr>\n\t\t\t\t\t<td>{$item['listenerName']}</td>\n\t\t\t\t\t<td>{$item['listenerTitle']}</td>\n\t\t\t\t\t<td>{$status}</td>\n\t\t\t\t\t<td>"; echo $item[moderatedTime] != 0 ? date("d-m-Y H:i:s", $item[moderatedTime]) : ""; echo "</td>\n\t\t\t\t</tr>"; } }
public static function getInstance() { if (self::$instance == false) { self::$instance = new FrontController(); } return self::$instance; }
public function __construct($obj) { parent::__construct($obj); $this->fc = FrontController::getInstance(); $this->error = ''; $this->isLoggedIn = $this->isLoggingOut = false; }
/** * @static * @return FrontController */ public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
public function init() { parent::init(); AuthController::getInstance()->requireLogin(); ErrorHandler::getInstance()->getUrlErrorMessage(); $this->setSmarty(); }
public static function getInstance() { if (!self::$_instance instanceof self) { self::$_instance = new FrontController(); } return self::$_instance; }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); if (in_array(Tools::strtolower(substr($_SERVER['REQUEST_URI'], -3)), array('png', 'jpg', 'gif'))) { $this->context->cookie->disallowWriting(); if ((bool) Configuration::get('PS_REWRITING_SETTINGS')) { preg_match('#([0-9]+)(\\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/(.+)\\.(png|jpg|gif)$#', $_SERVER['REQUEST_URI'], $matches); } if ((!isset($matches[2]) || empty($matches[2])) && !(bool) Configuration::get('PS_REWRITING_SETTINGS')) { preg_match('#/([0-9]+)(\\-[_a-zA-Z]*)\\.(png|jpg|gif)$#', $_SERVER['REQUEST_URI'], $matches); } if (is_array($matches) && !empty($matches[2]) && Tools::strtolower(substr($matches[2], -8)) != '_default' && is_numeric($matches[1])) { $matches[2] = substr($matches[2], 1, Tools::strlen($matches[2])) . '_default'; if (!isset($matches[4])) { $matches[4] = ''; } header('Location: ' . $this->context->link->getImageLink($matches[4], $matches[1], $matches[2]), true, 302); exit; } header('Content-Type: image/gif'); readfile(_PS_IMG_DIR_ . '404.gif'); exit; } elseif (in_array(Tools::strtolower(substr($_SERVER['REQUEST_URI'], -3)), array('.js', 'css'))) { $this->context->cookie->disallowWriting(); exit; } parent::initContent(); $this->setTemplate(_PS_THEME_DIR_ . '404.tpl'); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); parent::initContent(); $this->setTemplate(_PS_THEME_DIR_ . '404.tpl'); }
/** * initiates the Config object and fetches the configuration * * @access private * @global Database $db */ private function __construct() { $this->db =& FrontController::globalDatabase(); $this->log = new Log('config'); $this->log->write(1, 'init', 'No params needed, fetching config from Database'); $this->fetch(); }
/** * Singleton method that returns a unique instance of the class. * * @return FrontController */ private static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
public static function getInstance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->addJS(_THEME_JS_DIR_ . 'index.js'); $this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'), 'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'), 'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent'))); $this->setTemplate(_PS_THEME_DIR_ . 'index.tpl'); }
/** * save User ACL settings */ public function updateACL($section = '') { $id = $this->obj->getUid(); if (!$id) { return false; } $objLst = new AclModel(); $objLst->connectDb(); if (is_string($section)) { $objLst->where("section='{$section}'"); } if (!$objLst->loadList()) { return false; } $i = 0; $fc = FrontController::getInstance(); $db = DbConnector::getConnection(); $table = $objLst->dbTable('acl_user'); while ($objLst->next()) { if ($fc->getReqVar('acl_' . $objLst->get('name'))) { $db->query('INSERT IGNORE INTO `' . $table . '` SET `user_id`=' . $id . ', `acl_id`=' . $objLst->getUid()); } else { $db->query('DELETE IGNORE FROM `' . $table . '` WHERE `user_id`=' . $id . ' AND `acl_id`=' . $objLst->getUid()); } $i++; } return $i; }