public static function createPageByController($module = "") { if (count($_GET) == 0 || !isset($_GET["controller"])) { $controller = new SiteController(); $controller->indexAction(); } else { if (isset($_GET["controller"]) && !empty($_GET["controller"])) { $urlController = ucfirst(strtolower(filterGetValue($_GET["controller"]))); $command = new CCommand(); $controller = $command->createObj($module ? $module . '\\' . $urlController : $urlController); if (isset($_GET["view"]) && !empty($_GET["view"])) { $view = filterGetValue($_GET["view"]); } else { $view = "index"; } $action = $command->createAction($view); if (isset($_GET["param"]) && !empty($_GET["param"]) || isset($_GET["id"]) && !empty($_GET["id"])) { $param = $_GET["param"] ? filterGetValue($_GET["param"]) : filterGetValue($_GET["id"]); $controller->{$action}($param); } else { $controller->{$action}(); } } } return; }
public function result403() { Core::import('Modules.Main'); $oController = new SiteController(); $oResult = $oController->run('403', array()); Core::app()->response()->setStatus(403); Core::app()->theme()->getLayout()->setContent($oResult->getHtml()); Core::app()->response()->setResponseText(Core::app()->theme()->fetch()); Core::app()->end(); Core::app()->hardEnd(); }
public function testDeletePhoto() { $count1 = PhotoActiveRecord::find()->count(); $photo->userId = 1; $photo->photo = file_get_contents("./web/img/user.png"); $photo->posted = date("Y-m-d H-i-s"); $photo->save(); $controller = new SiteController(); $controller->actionDeletephoto($photo->id); $count2 = PhotoActiveRecord::find()->count(); $this->assert($count1, $count2, 'count before inserting and after deleting are not equals'); /*if($count1 != $count2){ $this->fire('myevent', new TestEvent($this)); }*/ }
function __construct($view_class = null) { if ($view_class === null) { $view_class = "TestView"; } parent::__construct($view_class); }
private static function serializeVkSongs($arr) { $data = array(); //data format is one singer to a lot of [song , download link ,enabled (it will be downloaded)] $struct = array(); // contains array of Singer objects if (!is_array($arr)) { throw new CHttpException(400, 'error when serialize'); } self::$songsCount = count($arr[1]); for ($i = 0; $i < self::$songsCount; ++$i) { $arr[2][$i] = Folder::cleaning($arr[2][$i]); $arr[3][$i] = Folder::cleaning($arr[3][$i]); $item = array('song' => $arr[3][$i], 'link' => $arr[1][$i], 'enabled' => true); $data[$arr[2][$i]][] = $item; } $options = new XMLOptions(); foreach ($data as $singer => $items) { // try to get real name from XML $name = $options->getNameByAlias($singer); // if it isset merge array of songs if ($name && isset($struct[$name])) { $struct[$name]->music = array_merge($struct[$name]->music, $items); continue; } $name = $name ? $name : $singer; $obj = new stdClass(); $obj->name = $name; $obj->music = $items; $obj->enabled = true; $struct[$name] = $obj; } return $struct; }
/** * @throws Exception */ public function init() { parent::init(); if (empty($this->model)) { throw new Exception('Model is not implemented'); } }
function __construct($view_class = null) { if ($view_class === null) { $view_class = "BlogViewSocieties"; } parent::__construct($view_class); }
function __construct($view_class = null) { if ($view_class === null) { $view_class = "SubscribeView"; } parent::__construct($view_class); }
public function __construct() { if ($view_class === null) { $view_class = "ArticleView"; } parent::__construct($view_class); }
function __construct($view_class = null) { if ($view_class === null) { $view_class = "MessagesView"; } parent::__construct($view_class); }
function __construct($view_class = null) { if ($view_class === null) { $view_class = "ArbitrationView"; } parent::__construct($view_class); }
protected function _BaseSiteData(&$data) { $data['tab_main_list'] = "Каталог позиций"; $data['tab_last_add_pos_list'] = "Последние позиции"; $data['tab_user_list'] = "Мои позиции"; $data['tab_soc_pos_add'] = "Добавление позиции"; parent::BaseSiteData(); }
public function __construct() { $view_class = "GroupsView"; parent::__construct($view_class); $this->request = Project::getRequest()->getKeys(); $this->session = Project::getSession()->getKeys(); $this->current_user_id = Project::getUser()->getDbUser()->id; }
function __construct($view_class = null) { if ($view_class === null) { $view_class = "DevView"; } $this->request = Project::getRequest(); parent::__construct($view_class); }
protected function _BaseSiteData(&$data) { $data['tab_list_name'] = "Каталог закладок"; $data['tab_most_visit'] = "Популярные закладки"; $data['tab_my_list_name'] = "Мои закладки"; $data['tab_add_bookmark'] = "Добавить закладку"; $data['tab_category_edit'] = "Категория"; $data['tab_bookmarks_import'] = "Импорт"; parent::BaseSiteData(); }
function __construct($view_class = null) { $this->tabs_map['main_tabs'][0] = array('name' => 'Новости'); $this->tabs_map['main_tabs'][1] = array('name' => 'Статьи'); $this->tabs_map['main_tabs'][2] = array('name' => 'Фотоальбом'); $this->tabs_map['main_tabs'][3] = array('name' => 'Вопросы-ответы'); if ($view_class === null) { $view_class = "HomeView"; } parent::__construct($view_class); }
/** * Метод принимающий управление от фронт контроллера * @return void */ public function run() { //получение строки запроса $uri = $this->getUri(); $i = 1; //проверка наличия данного запроса в routes.php foreach ($this->routes as $uriPattern => $path) { if (preg_match("~{$uriPattern}~", $uri)) { //получаем внутренний путь из внешнего согласно параметру $internalRoute = preg_replace("~{$uriPattern}~", $path, $uri); //определение контроллера и экшена обрабатывающего запрос $segments = explode('/', $internalRoute); $controllerName = ucfirst(array_shift($segments) . 'Controller'); $actionName = 'action' . ucfirst(array_shift($segments)); $parameters = $segments; //проверка на существование контроллера и его экшена if (!class_exists($controllerName) || !method_exists(new $controllerName(), $actionName)) { $controllerName = 'SiteController'; $actionName = 'actionIndex'; } //Создание объекта контроллера и вызов его экшена $controllerObject = new $controllerName(); /* Вызываем необходимый метод ($actionName) у определенного * класса ($controllerObject) с заданными ($parameters) параметрами */ $result = call_user_func_array(array($controllerObject, $actionName), $parameters); if ($result != null) { break; } } else { if (count($this->routes) == $i) { //если нет совпадений или введен не существующий адрес, то вызовет SiteController $controllerObject = new SiteController(); $result = $controllerObject->actionIndex(); } } $i++; } }
function __construct($view_class = null) { if ($view_class === null) { $view_class = "PlacesView"; } $this->session = Project::getSession(); parent::__construct($view_class); $this->_view->assign('tab_list', TabController::getOwnTabs(true)); $this->user = Project::getUser()->getShowedUser(); $this->_view->assign('user_profile', $this->user->data()); $this->_view->assign('session', $this->session); $this->_view->assign('user_default_avatar', $this->user->getUserAvatar($this->user->id)); }
function __construct($view_class = null) { if ($this->getParam("album_per_page")) { $this->DEFAULT_ALBUM_PER_PAGE = $this->getParam("album_per_page"); } if ($this->getParam("photo_per_page")) { $this->DEFAULT_ALBUM_PER_PAGE = $this->getParam("photo_per_page"); } if ($view_class === null) { $view_class = "AlbumView"; } parent::__construct($view_class); }
public static function init() { self::setRoutes(); self::setGetParams(); $controller = self::$routes[1]; $action = self::$routes[2]; if (empty($controller)) { $controller = self::$defaultController; } if (empty($action)) { $action = self::$defaultAction; } $route = trim(strtolower($controller) . '/' . trim(strtolower($action))); $controller_name = ucfirst(trim(strtolower($controller))) . "Controller"; $method_name = trim(strtolower($action)); $controller = new $controller_name(); if (method_exists($controller, $method_name) && App::$access->checkAccess($route)) { $controller->{$method_name}(); } else { $controller = new SiteController(); $controller->error404(); } }
public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow(array('view', 'addresses')); if (in_array($this->action, array('view', 'members', 'edit', 'vacancies')) && isset($this->passedArgs[0])) { $group = $this->Group->findById($this->passedArgs[0]); if ($group) { $isGroupAdmin = Hash::get($group, 'Group.owner_id') == $this->currUserID; $isGroupResponsible = Hash::get($group, 'Group.responsible_id') == $this->currUserID && Hash::get($group, 'Group.responsible_id') != null; $this->set('isGroupAdmin', $isGroupAdmin); $this->set('isGroupResponsible', $isGroupResponsible); } } }
/** * load config */ protected function __construct($class = '') { parent::__construct(); $this->s->auth(); // load module config file if ($class != '') { $class .= '/'; } $class .= substr(get_class($this), 0, -1); $parts = explode('/', $class); foreach ($parts as $key => $value) { $parts[$key] = from_camel_case($value); } $class = implode('/', $parts); $this->config = (require "modules/" . $class . "/config.inc.php"); // load config for sub modules (actions / menu items) if (is_array($this->config['sub'])) { foreach ($this->config['sub'] as $sub) { $sub_config = (require "modules/" . $class . "/" . $sub . "/config.inc.php"); foreach ($sub_config['actions'] as $area => $actions) { foreach ($actions as $name => $title) { $this->config['actions'][$area][$sub . '-' . $name] = $title; } } foreach ($sub_config['menu'] as $section => $items) { foreach ($items as $key => $item) { $item['action'] = $sub . '-' . $item['action']; if ($section == 'root') { $this->config['menu'][$section][$key] = $item; } else { $this->config['menu'][$section][] = $item; } } } } } }
public function init() { parent::init(); $this->title = "Land"; }
public function add() { //verifications formulaire inscription $data = array(); if (isset($_POST['cli_pseudo']) && isset($_POST['cli_motpasse']) && isset($_POST['mdp_confirm']) && isset($_POST['cli_mel']) && isset($_POST['mail_confirm']) && isset($_POST['cli_nom']) && isset($_POST['cli_prenom']) && isset($_POST['cli_telfixe']) && isset($_POST['cli_telportable'])) { $pattern = '/[\\[\\]* + ? | { } () ^ ." <> ! $ ; : § , ¨ & ~ \\\\ \\/ @ = ]/'; $patterntelfixe = '/^0[1-58][0-9]{8}$/'; $patterntelport = '/^0[67][0-9]{8}$/'; $pattern_nom = '/[0-9\\[\\]* + ? | { } () ^ ." <> ! $ ; : § , ¨ & ~ \\\\ \\/ @ = ]/'; //verif civilité if (empty($_POST['cli_civilite'])) { $msgerror = "Veuillez choisir une civilité"; $data[] = $msgerror; } //verif pseudos if (empty($_POST['cli_pseudo'])) { $msgerror = "Le champ Pseudo est vide"; $data[] = $msgerror; } elseif (preg_match($pattern, $_POST['cli_pseudo'])) { $msgerror = "Caractères spéciaux interdits dans le champ Pseudo"; $data[] = $msgerror; } $listeclients = T_e_client_cli::findAll(); foreach ($listeclients as $t_e_client_cli) { if (strtolower($_POST['cli_pseudo']) == strtolower($t_e_client_cli->cli_pseudo)) { $msgerror = "Pseudo déjà enregistré"; $data[] = $msgerror; } } //verifs mdp & confirmation if (empty($_POST['cli_motpasse'])) { $msgerror = "Le champ Mot de passe est vide"; $data[] = $msgerror; } if (empty($_POST['mdp_confirm'])) { $msgerror = "Le champ Confirmez votre mot de passe est vide"; $data[] = $msgerror; } if (preg_match($pattern, $_POST['cli_motpasse'])) { $msgerror = "Caractères spéciaux interdits dans le champ Mot de passe"; $data[] = $msgerror; } if (strlen($_POST['cli_motpasse']) < 8 || strlen($_POST['cli_motpasse']) > 15) { $msgerror = "Le mot de passe doit contenir entre 8 et 15 caractères alphanumériques"; $data[] = $msgerror; } if ($_POST['cli_motpasse'] != $_POST['mdp_confirm']) { $msgerror = "Le mot de passe et la confirmation ne correspondent pas"; $data[] = $msgerror; } //verif mail if (empty($_POST['cli_mel'])) { $msgerror = "Le champ Adresse email est vide"; $data[] = $msgerror; } else { if (!filter_var($_POST['cli_mel'], FILTER_VALIDATE_EMAIL)) { $msgerror = "Le format de l'adresse mail est invalide"; $data[] = $msgerror; } } $listeclients = T_e_client_cli::findAll(); foreach ($listeclients as $t_e_client_cli) { if ($_POST['cli_mel'] == $t_e_client_cli->cli_mel) { $msgerror = "Adresse email déjà utilisée"; $data[] = $msgerror; } } if (empty($_POST['mail_confirm'])) { $msgerror = "Le champ Confirmez votre adresse email est vide"; $data[] = $msgerror; } if ($_POST['cli_mel'] != $_POST['mail_confirm']) { $msgerror = "L\\'email et la confirmation ne correspondent pas"; $data[] = $msgerror; } //verif nom et prenom if (empty($_POST['cli_nom'])) { $msgerror = "Le champ Nom est vide"; $data[] = $msgerror; } elseif (preg_match($pattern_nom, $_POST['cli_nom'])) { $msgerror = "Veuillez rentrer un nom valide"; $data[] = $msgerror; } if (empty($_POST['cli_prenom'])) { $msgerror = "Le champ Prénom est vide"; $data[] = $msgerror; } elseif (preg_match($pattern_nom, $_POST['cli_prenom'])) { $msgerror = "Veuillez rentrer un prénom valide"; $data[] = $msgerror; } //verif tel if (empty($_POST['cli_telfixe']) && empty($_POST['cli_telportable'])) { $msgerror = "Au moins un numéro de téléphone doit être renseigné"; $data[] = $msgerror; } if (!empty($_POST['cli_telfixe']) && !preg_match($patterntelfixe, $_POST['cli_telfixe'])) { $msgerror = "Format téléphone fixe invalide"; $data[] = $msgerror; } if (!empty($_POST['cli_telportable']) && !preg_match($patterntelport, $_POST['cli_telportable'])) { $msgerror = "Format téléphone portable invalide"; $data[] = $msgerror; } foreach ($listeclients as $t_e_client_cli) { if ($_POST['cli_telportable'] == $t_e_client_cli->cli_telportable && $_POST['cli_telportable'] != null) { $msgerror = "Numéro de téléphone portable déjà utilisé"; $data[] = $msgerror; break; } } if (!empty($data)) { $this->render("add", $data); } else { $client = new T_e_client_cli(); $client->cli_mel = parameters()["cli_mel"]; $client->cli_motpasse = md5(parameters()["cli_motpasse"]); $client->cli_pseudo = parameters()["cli_pseudo"]; $client->cli_civilite = parameters()["cli_civilite"]; $client->cli_nom = parameters()["cli_nom"]; $client->cli_prenom = parameters()["cli_prenom"]; $client->cli_telfixe = parameters()["cli_telfixe"]; $client->cli_telportable = parameters()["cli_telportable"]; $client2 = new T_e_client_cli($client->cli_id); $_SESSION['client'] = serialize($client2); $c = new SiteController(); $c->index(); } } else { $this->render("add"); } }
public function init() { parent::init(); $this->title = 'Family'; }
<?php require_once dirname(__FILE__) . '/mvc/controllers/site_controller.php'; $siteController = new SiteController(); $siteController->show();
if (isset($_GET)) { foreach ($_GET as $k => $v) { $parameters[$k] = $v; } } // Pour accès ultérieur sans "global" function parameters() { global $parameters; return $parameters; } // Gestion des la route : paramètre r = controller/action if (isset(parameters()["r"])) { try { $route = parameters()["r"]; if (strpos($route, "/") === FALSE) { list($controller, $action) = array($route, "index"); } else { list($controller, $action) = explode("/", $route); } $controller = ucfirst($controller) . "Controller"; $c = new $controller(); $c->{$action}(); } catch (Exception $e) { $c = new SiteController(); $c->error404(); } } else { $c = new SiteController(); $c->index(); }
public function __construct(Controller $parent, AddonVendor $vendor) { $this->parent = $parent; $this->vendor = $vendor; parent::__construct(); }
<?php require_once dirname(__FILE__) . '/mvc/controllers/site_controller.php'; $siteController = new SiteController(); $siteController->showPatternPrimer();
public function init() { parent::init(); $this->title = 'My Account'; }