Inheritance: extends Controller
 public function handle($params)
 {
     if ($this->_cName == null) {
         // above parseRoute() failed (controller not found) => run Default Controller (if specified)
         global $app_i;
         $def = trim($app_i['default_controller']);
         if ($def != '' && file_exists(BASE . $def)) {
             require_once BASE . $def;
             $ctr = new DefaultController();
             $ctr->handle(null);
             $this->log->debug('Invalid URI. DefaultController called.');
             return;
         }
     }
     // URI parsed OK!
     $fullpath = '/app/' . $this->_cPath . '/' . $this->_cName . '.php';
     $this->log->debug('handle() route: ' . $fullpath);
     $fullpath = BASE . $fullpath;
     if (file_exists($fullpath)) {
         // load parsed Controller
         require_once $fullpath;
         $ctr = new $this->_cName();
         $ctr->handle($this->_cParams);
     } else {
         die('MainController: Error: Controller not found!');
     }
     $this->log->debug('handle() ended');
 }
Example #2
0
 public function __construct()
 {
     $this->splitUrl();
     if (!$this->url_controller) {
         require APP . 'controller/DefaultController.php';
         $page = new DefaultController();
         $page->index();
     } elseif (file_exists(APP . 'controller/' . ucfirst($this->url_controller) . 'Controller.php')) {
         $this->url_controller = ucfirst($this->url_controller) . 'Controller';
         require APP . 'controller/' . $this->url_controller . '.php';
         $this->url_controller = new $this->url_controller();
         if (method_exists($this->url_controller, $this->url_action)) {
             if (!empty($this->url_params)) {
                 call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params);
             } else {
                 $this->url_controller->{$this->url_action}();
             }
         } else {
             if (strlen($this->url_action) == 0) {
                 $this->url_controller->index();
             } else {
                 header('location: ' . URL . 'error');
             }
         }
     } else {
         header('location: ' . URL . 'error');
     }
 }
 public function testIndexAction()
 {
     $view = $this->getServiceMockBuilder('FooView')->getMock();
     $view->expects($this->once())->method('setTemplate')->with('FooBundle:Default:index.twig')->will($this->returnValue(null));
     $view->expects($this->once())->method('handle')->with()->will($this->returnValue('success'));
     $controller = new DefaultController($view);
     $this->assertEquals('success', $controller->indexAction());
 }
 public function testHelloWorld()
 {
     /**
      * @var \Waddle\Classes\App $app
      */
     $app = $this->getMockBuilder('Waddle\\Classes\\App')->disableOriginalConstructor()->getMock();
     $controller = new DefaultController($app);
     $this->expectOutputRegex('/<h1>Hello, World!<\\/h1>/');
     $controller->indexAction('World!');
 }
Example #5
0
 public static function socialLogin($uid, $name, $email, $password, $hash)
 {
     $model = UsersModel::model()->where("`social_uid`='{$uid}'  OR `email`='" . $email . "'")->findRow();
     if (!$model) {
         $random_password = rand(10000, 99999);
         $model = new UsersModel();
         $name = trim($name);
         $email = trim($email);
         $password = trim($password);
         $model->name = $name;
         $model->login = $email;
         $model->password = md5($password);
         $model->email = $email;
         $model->is_admin = 0;
         $model->status = 1;
         $model->card_main_id = 1;
         $model->card_main_new_id = 2;
         $model->social_uid = $uid;
         $model->hash = $hash;
         $model->type = 2;
         $model->save();
         DefaultController::sendEmailToUser($model->email, $password, $model->hash, $model->password);
     } else {
         if ($model->status != 0) {
             self::setFields($model);
         } else {
             header("Location: /deactivate");
             exit;
         }
         header("Location: /");
     }
     self::setFields($model);
     header("Location: /");
 }
Example #6
0
 /**
  * 
  */
 function display()
 {
     if (!$this->site_template) {
         return parent::display();
     }
     return parent::display($this->site_template);
 }
Example #7
0
 public function error_404()
 {
     parent::setLayout('defaultLayout');
     parent::setView('404');
     $this->data['parameters'] = $this->parameters;
     parent::renderLayout();
 }
 /**
  * Trigger a controller according the act param from the url
  * 
  * @param   string $act
  */
 public function connectToController($act)
 {
     $act = ucfirst($act);
     if (!empty($act)) {
         $controllerName = __NAMESPACE__ . '\\' . $act . 'Controller';
         if (!$controllerName && !class_exists($controllerName)) {
             return;
         }
         //  instantiate the view specific controller
         $objController = new $controllerName($this->getSystemComponentController(), $this->cx);
     } else {
         // instantiate the default View Controller
         $objController = new DefaultController($this->getSystemComponentController(), $this->cx);
     }
     $objController->parsePage($this->template);
 }
Example #9
0
 public function __construct()
 {
     parent::__construct();
     # initialize the Perms controller
     $this->_model = new Perms();
     $this->activeSection = 'perms';
 }
 public function frmAction($id = NULL)
 {
     $disque = $this->getInstance($id);
     //TODO 4.4.1
     $this->view->setVars(array("disque" => $disque, "siteUrl" => $this->url->getBaseUri(), "baseHref" => $this->dispatcher->getControllerName()));
     parent::frmAction($id);
 }
 public function frmAction($id = NULL)
 {
     $message = $this->getInstance($id);
     $projects = Projet::find();
     $users = User::find();
     $this->view->setVars(array("message" => $message, "users" => $users, "projects" => $projects));
     parent::frmAction($id);
 }
 function display()
 {
     if (!$this->print_preview) {
         return parent::display();
     }
     $this->addStyleSheet('sheetgen/print.css');
     return parent::display('sheet_template', SHEETGEN_TEMPLATES);
 }
Example #13
0
 public function __construct()
 {
     parent::__construct();
     # initialize the auth controller
     $this->req_id = isset($this->req_id) ? $this->req_id : '';
     $this->_model = new Auth(is_numeric($this->req_id) ? $this->req_id : NULL);
     $this->activeSection = 'auth';
 }
Example #14
0
 public static function confirmarSenha($pwd1, $pwd2)
 {
     $pass = $pwd1 == $pwd2;
     if (!$pass) {
         DefaultController::defineException("senha", "Não foi possível confirmar sua senha!");
     }
     return $pass;
 }
Example #15
0
 public function skate()
 {
     parent::isAllowedToAccess();
     parent::setLayout('defaultLayout');
     parent::setView('skate');
     $this->data['parameters'] = $this->parameters;
     $this->data['orders'] = Statistics::getOrdersOverview(1, '2015-12-02', '2015-12-15');
     parent::renderLayout();
 }
 public function frmAction($id = NULL)
 {
     $tache = $this->getInstance($id);
     $usecases = Usecase::find();
     $users = User::find("idRole<>3");
     $this->view->setVars(array("tache" => $tache, "users" => $users, "usecases" => $usecases));
     $_SESSION['bread']['object'] = $tache;
     $this->jquery->exec("\$('input[type=\"range\"]').rangeslider({\n  \t\t\t\t\t\t\t\tpolyfill: false,\n\t\t\t\t\t\t\t\tonSlide: function(position, value) {\n\t\t\t\t\t\t\t\t\t\$('.avancement').html(value.toString()+'%');\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});", true);
     parent::frmAction($id);
 }
Example #17
0
 public function dispatch()
 {
     $flag = false;
     if (isset($_GET['ctrl'], $_GET['act'])) {
         $ctrlName = "Imie\\Controllers\\" . ucfirst($_GET['ctrl']) . 'Controller';
         if (class_exists($ctrlName)) {
             $ctrl = new $ctrlName();
             $actName = $_GET['act'] . 'Action';
             if (method_exists($ctrl, $actName)) {
                 $ctrl->{$actName}();
                 $flag = true;
             }
         }
     }
     if (!$flag) {
         $controller = new DefaultController();
         $controller->indexAction();
     }
 }
 public function frmAction($id = NULL)
 {
     $user = $this->getInstance($id);
     $select = new HtmlSelect("role", "Rôle", "Sélectionnez un rôle...");
     $select->fromArray(array("admin", "user", "author"));
     $select->setValue($user->getRole());
     $select->compile($this->jquery, $this->view);
     $this->view->setVars(array("user" => $user, "siteUrl" => $this->url->getBaseUri(), "baseHref" => $this->dispatcher->getControllerName()));
     parent::frmAction($id);
 }
 public function getInstance($id = NULL)
 {
     if ($id != NULL) {
         return parent::getInstance("code='" . $id . "'");
     } else {
         $uc = new Usecase();
         $uc->setAvancement(0);
         return $uc;
     }
 }
 public function frmAction($id = NULL)
 {
     $role = $this->getInstance($id);
     $controllers = array("Default" => array("name" => "Tous", "actions" => array("index" => "Lister", "frm" => "Modifiation des données Brutes", "update" => "Modifier/Ajouter", "delete" => "Supprimer", "show" => "Afficher les détails")), "Projects" => array("name" => "Projets", "actions" => array("manage" => "Ajouter/Modifier UseCases", "manageUc" => "Ajouter/Modifier Tâches")), "Roles" => array("name" => "Rôles", "actions" => array("updateACL" => "Mettre à jour es droits")), "Taches" => array("name" => "Tâches", "actions" => array()), "Messages" => array("name" => "Messages", "actions" => array()), "UseCases" => array("name" => "Use Cases", "actions" => array()), "Users" => array("name" => "Utilisateurs", "actions" => array()));
     $acls = Acl::find("idRole=" . $role->getId());
     $this->view->setVars(array("role" => $role, "acls" => AclController::toArray($acls), "controllers" => $controllers, "siteUrl" => $this->url->getBaseUri(), "baseHref" => $this->dispatcher->getControllerName()));
     $_SESSION['bread']['object'] = $role;
     $this->jquery->postFormOnClick(".validateACL", $this->dispatcher->getControllerName() . "/updateACL", "frmObject", "#content");
     parent::frmAction($id);
 }
Example #21
0
 public function defaultView()
 {
     parent::isAllowedToAccess();
     parent::setLayout('defaultLayout');
     parent::setView('default');
     $this->data['parameters'] = $this->parameters;
     $campaigns = new CampaignList();
     $this->data['campaigns'] = $campaigns->getCampaigns();
     $this->data['campaign_types'] = $campaigns->getCampaignTypes();
     parent::renderLayout();
 }
Example #22
0
 public function __construct()
 {
     parent::__construct();
     # initialize the Prefs controller
     /*
             $this->params['uid'] = (isset($this->params['uid'])) ? $this->params['uid'] : '';
     
             $this->_model = new Prefs((is_numeric($this->params['uid']) ? $this->params['uid'] : ''));
     */
     $this->_model = new Prefs();
     $this->activeSection = 'prefs';
 }
Example #23
0
 public function __construct()
 {
     parent::__construct();
     if (!isset($this->cache) || !is_array($this->cache)) {
         static::raiseError(__METHOD__ . '(), $cache property is not an array!', true);
         return;
     }
     if (!isset($this->cache_index) || !is_array($this->cache_index)) {
         static::raiseError(__METHOD__ . '(), $cache_index property is not an array!', true);
         return;
     }
 }
Example #24
0
 public function defaultView()
 {
     parent::isAllowedToAccess();
     parent::setLayout('defaultLayout');
     parent::setView('default');
     $this->data['parameters'] = $this->parameters;
     $this->data['clicks'] = Statistics::getClicksOverview(1, '1920x1080', 'www.skate-praha.cz/');
     $this->data['clicks2'] = Statistics::getClicksOverview(1, '1366x768', 'www.skate-praha.cz/');
     $this->data['clicks3'] = Statistics::getClicksOverview(1, '1920x1080', 'www.skate-praha.cz/kosik/');
     $this->data['clicks4'] = Statistics::getClicksOverview(1, '1920x1080', 'www.skate-praha.cz/pokladna/');
     $this->data['clicks5'] = Statistics::getClicksOverview(1, '1920x1080', 'www.skate-praha.cz/rekapitulace/');
     parent::renderLayout();
 }
Example #25
0
 /** ==+== Изменение кода НО и редирект на прошлую страницу **/
 public function actionChangeCode($code)
 {
     if (!isset($code) || !is_numeric($code)) {
         throw new CHttpException(400, "Неверный запрос. Не указан код налогового органа!");
     }
     if (!Organization::model()->exists('code=:code', array(':code' => $code))) {
         throw new CHttpException(400, "Неверный запрос. Указан не существующий код налогового органа!");
     }
     if (!User::checkNo($code)) {
         throw new CHttpException(401, "Вам запрещен доступ к данному налоговому органу!");
     }
     User::changeNo($code);
     DefaultController::redirect(Yii::app()->request->urlReferrer);
 }
Example #26
0
 public function password()
 {
     if (empty($_SESSION["logger_username"]) || empty($_SESSION["logger_nickname"])) {
         $this->redirect('login');
     }
     parent::setLayout('loginLayout');
     parent::setView('password');
     $this->data['parameters'] = $this->parameters;
     $this->data['nickname'] = ucfirst($_SESSION['logger_nickname']);
     $this->data['username'] = $_SESSION['logger_username'];
     $this->data['avatar'] = false;
     if (isset($_POST['confirm'])) {
         if ($this->checkPassword($this->data['username'], $_POST['password'])) {
             $_SESSION['logger_username_verified'] = $this->data['username'];
             $_SESSION['logged_login_time'] = strtotime('+ 1 min');
             $this->redirect('dashboard/');
         } else {
             $this->data['error_msg'] = 'Incorrect password!';
         }
     } else {
         $this->data['error_msg'] = '';
     }
     parent::renderLayout();
 }
Example #27
0
 public function __construct()
 {
     if (!$this->removeExpiredJobs()) {
         static::raiseError('removeExpiredJobs() returned false!', true);
         return false;
     }
     try {
         $this->registerHandler('delete-request', array($this, 'handleDeleteRequest'));
         $this->registerHandler('save-request', array($this, 'handleSaveRequest'));
     } catch (\Exception $e) {
         static::raiseError(__METHOD__ . '(), failed to register handlers!', true);
         return false;
     }
     // Define the JSON errors.
     $constants = get_defined_constants(true);
     $this->json_errors = array();
     foreach ($constants["json"] as $name => $value) {
         if (!strncmp($name, "JSON_ERROR_", 11)) {
             $this->json_errors[$value] = $name;
         }
     }
     parent::__construct();
     return true;
 }
Example #28
0
<?php

/**
 * Created by PhpStorm.
 * User: Home
 * Date: 14.12.2015
 * Time: 14:46
 */
include_once '../Model/DefaultModel.php';
include_once '../Controllers/DefaultController.php';
include_once '../View/BusinessView.php';
$model = new DefaultModel();
$controller = new DefaultController($model);
$view = new BusinessView($model);
$controller->actionGetHeaderCart();
$view->getBusinessPage();
Example #29
0
 function run()
 {
     require_once 'app/controller/default/default.php';
     $ctrl = new DefaultController();
     $ctrl->test();
 }
Example #30
0
 public function __construct(SearchModel $model)
 {
     parent::__construct($model);
     $this->model = $model;
 }