function __construct() { $this->__core = Core::getInstance(); $this->__lib = $this->__core->getLib(); $this->__uri = $this->__core->getUri(); $this->__req = $this->__core->getRequest(); }
function main($url = null) { if (strtolower($_SERVER["REQUEST_METHOD"]) == "get") { //todo : if request method is get, require_once APPPATH . 'views' . DS . 'templates' . DS . 'template_login.php'; } else { //todo : if request method is post //todo : should we set session time out? if (isset($_POST["email"]) && isset($_POST["password"])) { $email = $_POST["email"]; $password = $_POST["password"]; $member = Core::getInstance("Member_md")->getMember($email, $password); if ($member) { //todo : redirect main page $_SESSION["member"] = $member[0]; $SID = session_id(); echo '1 : ', $SID; $this->redirect("/term"); //require_once APPPATH.'views'.DS.'templates'.DS.'template_term_list.php'; } else { //todo : invalid user information, } } } }
function getPersistenceObject() { $loader = \Core::getInstance()->getLoader(); if ($loader->has($this->_persistenceObject)) { return $loader->get($this->_persistenceObject); } }
public static function execRouterHook(_Core_Request $request, &$class, &$method, array &$chunks, &$templateEngine) { if (JS_MINIFY) { $templateEngine->append('js', 'global-min.js'); } else { foreach (file(SYS_DIR_INC . 'assets/js.list') as $js) { $templateEngine->append('js', $js); } } if (IS_DEMO) { $templateEngine->append('js', 'demo_message.js'); } /** * Динамическое подключение js файлов * в зависимости от модуля * */ $jsArr = array(); $urlArr = explode('/', $request->uri, 3); // первый элемент array_shift($urlArr); $module = strtolower(array_shift($urlArr)); if (array_key_exists($module, Core::getInstance()->js)) { $jsArr = Core::getInstance()->js[$module]; } foreach ($jsArr as $jsFile) { $templateEngine->append('js', $jsFile . '.js'); } }
/** * Controller constructor * @param [type] $view [description] */ public function __construct($view = null) { if ($view) { $this->view = $view; } $this->view = Core::getInstance("View"); }
function add($name, $schema) { $dataSet = \Core::getInstance()->getDatabase()->getDataSet(); if ($schema instanceof \DBAL\Data\Model) { $dataSet->addModel($schema); } return parent::add($name, $schema); }
public function __construct($templateEngine, _Core_Request $request) { //Проверяем авторизован ли пользователь. Если нет - редиректим на логин if (!Core::getInstance()->CurrentUserIsAuthorized()) { header('Location: /login/'); } parent::__construct($templateEngine, $request); }
protected function execute(&$source = null) { $result = parent::execute($source); if ($source instanceof \DBAL\Data\Source) { $core = \Core::getInstance(); $core->getDatabase()->Models->Data = \Util\Arrays\names($source->Data); } return $result; }
function getEntity() { $core = \Core::getInstance(); if (is_null($this->entity)) { $this->entity = $core->Database->Models[$this->EntityName]; } //TODO: entity by entityname if blank return $this->entity; }
/** * Конструктор * */ public final function __construct($templateEngine, _Core_Request $request) { parent::__construct($templateEngine, $request); // Если эксперт - редирект на дефолтную для экспертов if (Core::getInstance()->user->getType() == 1) { header('Location: /expert/'); exit; } }
/** * Конструктор класса * @return void */ function __construct() { if (is_null(Core::getInstance()->db)) { Core::getInstance()->initDB(); } $this->db = Core::getInstance()->db; // Загружаем список валют $this->loadCurrency(); }
/** * Удаляет у пользователя служебную почту */ function delete_service_mail() { $user = Core::getInstance()->user; if ($this->model->deleteServiceMail($user)) { $this->tpl->assign('result', array('text' => 'Ящик успешно удалён')); } else { $this->tpl->assign('error', array('text' => 'Ошибка при удалении ящика')); } }
/** * Initialize application and parse input parameters * */ public function __construct() { $this->_app = Core::getInstance(array('app' => 'shell', 'document_root' => dirname(__FILE__) . '/', 'app_root' => dirname(__FILE__) . '/../app/')); $this->_factory = FactoryModel::getInstance(); $this->_applyPhpVariables(); $this->_parseArgs(); $this->_validate(); $this->_showHelp(); }
/** * 写入记录 * @param string $message * @param string $level */ public static function write($message, $level = self::ERR) { if (!self::$status) { self::getConfig(); } $now = date(self::$config['time_format']); $message = Core::getInstance()->getHook()->apply("Log_write", $message, $level); error_log("[{$now}] " . URL_NOW . "; {$level}: {$message}\r\n", self::$config['type'], self::$config['destination'], self::$config['headers']); }
public static function getCurrent() { $user = null; //Временный хак под старый класс if (Core::getInstance()->user->getId()) { $user = Core::getInstance()->user; } return $user; }
function getEntity() { if (is_string($entity)) { $dataSet = \Core::getInstance()->getDatabase()->getDataSet(); if ($dataSet->hasModel($entity)) { $this->_entity = $dataSet->Models[$entity]; } } return $this->_entity; }
/** * Default service * */ function svcDefault() { // Process Data I/O. $data["entry"] = Core::getInstance("Term_md")->getRecentTerm(15); // Rendering preset. $this->view->title = "UB Root"; $this->view->setDiv(array("entry_pane")); //$this->view->div("power"); $this->view->render("tmpl_kiwi", $data); }
public function main($url = null) { if (isset($_GET["action"])) { $action = $_GET["action"]; } else { $action = "read"; } switch ($action) { case "create": if (strtolower($_SERVER["REQUEST_METHOD"]) == "get") { require_once APPPATH . 'views' . DS . 'templates' . DS . 'template_member_add.php'; } else { var_dump($_FILES); //todo : create new member if (isset($_POST["email"]) && isset($_POST["password"]) && isset($_POST["password_cfm"]) && isset($_POST["nickname"])) { if (!strcmp($_POST["password"], $_POST["password_cfm"])) { $member = array(); if (isset($_FILES["photo"]["tmp_name"]) && !empty($_FILES["photo"]["tmp_name"])) { //todo : restrict maximum file size by using constant in config.xml if ($_FILES["photo"]["size"] < 10000000) { $image_info = getimagesize($_FILES['photo']['tmp_name']); //todo : image resize (make thumbnail profile image) $member["img"] = fopen($_FILES["photo"]["tmp_name"], "rb"); } } $member["email"] = $_POST["email"]; $member["password"] = $_POST["password"]; $member["nickname"] = $_POST["nickname"]; try { if (Core::getInstance("Member_md")->addMember($member)) { //todo : return success page $this->redirect("/term"); } else { //todo : redirect 500 page } } catch (Exception $e) { //todo : redirect 500 page; echo $e; } } else { //todo : invalid password } } else { //todo : invalid parameter } } break; case "update": break; case "delete": break; case "read": default: } }
/** * Индексная страница * @param <array> $args mixed * @return void */ function index($args) { Core::getInstance()->user->destroy(); if (IS_DEMO) { header("Location: " . URL_ROOT_MAIN); exit; } else { header("Location: /"); exit; } }
private function loadDirectories() { $coreDirs = \Core::getInstance()->getDirectories(); $path = $this->getPath(); foreach ($coreDirs as $dir) { $match = substr($dir, 0, strlen($path)); if ($match === $path) { $this->addDirectory($dir); } } }
/** * Страница по умолчанию без параметров * @return void */ public function index() { // Эти числа были взяты из БД homemoney // Отвратительно, но если это выпилить, цифры на главной будут некрасивые $counters = array('users' => 7163 + 234, 'operations' => 996922); $counters['users'] += Core::getInstance()->db->selectCell("SELECT count(*) FROM users"); $counters['operations'] += Core::getInstance()->db->selectCell("SELECT count(*) FROM operation"); $this->tpl->assign('usersCount', number_format($counters['users'], 0, ',', ' ')); $this->tpl->assign('operationsCount', number_format($counters['operations'], 0, ',', ' ')); $this->tpl->assign('name_page', 'welcome'); }
function get_connection() { try { $Core = Core::getInstance(); $Connection = $Core->dbh; } catch (PDOException $Error) { exception_error($Error); die; } return $Connection; }
function match($data) { if ($this->hasModel()) { list($loadSchematic, $componentName) = $this->getLoaderPath($data); $core = \Core::getInstance(); if ($core->hasComponent($componentName, '')) { $module = $core->getComponentModule($componentName, ''); return $module->matchesComponent($componentName, ''); } } return false; }
/** * Индексная страница * @param $args array mixed * @return void */ function index($args) { //echo('<pre>'); //die(print_r(User::getUserTargets())); //$this->model->staticTargetUpdate(1); $this->tpl->assign('user_list_targets', $this->model->getLastList()); $this->tpl->assign('closed_targets', $this->model->countClose()); $this->tpl->assign('pop_list_targets', $this->model->getPopList()); $this->tpl->assign('category', get_tree_select()); $this->tpl->assign('accounts', Core::getInstance()->user->getUserAccounts()); $this->tpl->assign('template', 'default'); }
/** * SetUp */ protected final function setUp() { $_POST = array(); $_GET = array(); // Для тестов контроллера $_SERVER["SERVER_PORT"] = 443; $_SERVER["REQUEST_METHOD"] = 'GET'; $_SERVER["HTTP_HOST"] = trim(COOKIE_DOMEN, '.'); $_SERVER["REQUEST_URI"] = '/index.php'; $this->db = Core::getInstance()->db; $this->db->query("START TRANSACTION"); $this->_start(); }
/** * Key value setter * * @param mixed $key (string|array, array ex: ['k1' => 'v1', ...]) * @param mixed $value * @return void */ public static function set($key, $value = null) { if (!is_array($key)) { if (!self::has($key)) { Core::getInstance()->log->trace('Registry set key \'' . $key . '\'', Logger::CATEGORY_DRONE); } self::$__reg[$key] = $value; } else { foreach ($key as $k => $v) { self::set($k, $v); } } }
function setResource($resource) { $core = \Core::getInstance(); $dataSet = $core->getDatabase()->getDataSet(); if ($resource instanceof \DBAL\Data\Table) { $resource = $resource->getEntity(); } elseif (is_string($resource) && $dataSet->hasModel($resource, 'entity')) { $resource = $dataSet->getModel($resource); } if ($resource instanceof \DBAL\Data\Model) { parent::setResource($resource); } else { throw new \InvalidArgumentException(); } }
private function preserveKey(\Core\Object $dataItem) { $core = \Core::getInstance(); $dataSet = $core->getDatabase()->getDataSet(); if ($dataSet->hasModel($schematicName = $dataItem->Type->name)) { $entity = $dataSet->Models[$schematicName]; // PERSIST ENTITY ON NEW OBJECT $dataItem->Type->persist($entity); // PRESERVE KEYS $primaryKey = $entity->getPrimaryKey()->getInnerName(); $entity->Index++; $dataItem->{$primaryKey} = $entity->Index; } return $dataItem; }
/** * Индексная страница * @param $args array mixed * @return void */ function index($args) { $this->tpl->assign('reports', $this->_reports); //@FIXME Отвязать от смарти. Пусть данные берутся из res $this->tpl->assign('accounts', Core::getInstance()->user->getUserAccounts()); $this->tpl->assign('currency', Core::getInstance()->user->getUserCurrency()); $this->tpl->assign('dateFrom', date('01.m.Y')); $this->tpl->assign('dateTo', date(date('t') . '.m.Y')); $lastMonth = date('m') - 1; if ($lastMonth == 0) { $lastMonth = 12; } $lastYear = $lastMonth != 12 ? date('Y') : date('Y') - 1; $monthYear = $lastMonth . '.' . $lastYear; $this->tpl->assign('dateFrom2', '01' . '.' . $monthYear); $this->tpl->assign('dateTo2', cal_days_in_month(CAL_GREGORIAN, $lastMonth, $lastYear) . '.' . $monthYear); }
/** * [route description] * @return [type] [description] */ function route() { try { // Check if the url parameter is set if (isset($_GET["url"])) { foreach ($this->_routes as $_route) { if ($this->equals($_route, $_GET["url"], $_SERVER["REQUEST_METHOD"])) { return Core::getInstance($_route["controller"])->main(); } } } // If there is no mapped controller, route to 404 page. include ERROR404; } catch (Exception $e) { //todo : routing error, route to error page. } }