diff --git a/src/Controller/Action.php b/src/Controller/Action.php
index 5d2d13e..6045d5b 100644
--- a/src/Controller/Action.php
+++ b/src/Controller/Action.php
@@ -331,6 +331,7 @@ class Controller_Action
if ($this->view instanceof View_View) {
$this->view->assignValues($this->ctrlValues);
+ /*.Widgets_Widget.*/$node = null;
foreach ($this->childNodes as $name => $node) {
$node->make($this);
$this->view->setView($name, $node->view);
diff --git a/src/Controller/Component.php b/src/Controller/Component.php
index c389198..d77392e 100644
--- a/src/Controller/Component.php
+++ b/src/Controller/Component.php
@@ -23,7 +23,8 @@ class ComponentRequest {
if ($key == 'active_page') {
return $this->r->get($key);
}
- if ($arr = $this->r->get($key)) {
+ $arr = $this->r->get($key);
+ if ($arr !== NULL) {
if (is_array($arr)) {
return Arr::get($arr, $this->component_id, $default);
} else {
@@ -127,6 +128,14 @@ class Controller_Component
}
public function getTemplatePath($name) {
+ /*.Settings.*/$registry = $this->registry;
+ $template = ($this->template) ? $this->template : $registry->readKey(array('system', 'template'));
+ foreach ($this->viewPath as $index => $viewPath) {
+ if(is_dir(Path::join($this->viewPath[$index], 'templates', $template))) {
+ return Path::join($this->viewPath[$index], 'templates', $template, $name);
+ }
+ }
+
return Path::join($this->viewPath[0], 'templates', 'modern', $name);
}
@@ -182,7 +191,7 @@ class Controller_Component
$options = new Form_OptionFactory($this->db, $this->registry);
$settings = $this->getInfo();
- $form->addFieldList($settings['parameter'], $options);
+ $form->addFieldList($settings['parameter'], $options);
$view->form = $form;
$view->component = $settings['component'];
@@ -271,10 +280,9 @@ class Controller_Component
if(class_exists("Controller_Site")){ //Если мы в CMS2
$instance = Controller_Site::getInstance();
$instance->componentsConfig[] = $editor;
- }else{
+ } else {
global $componentsConfig;
$componentsConfig[] = $editor;
-
}
}
diff --git a/src/Controller/Service.php b/src/Controller/Service.php
index 46f96aa..a1f7185 100644
--- a/src/Controller/Service.php
+++ b/src/Controller/Service.php
@@ -5,11 +5,14 @@
*/
class Controller_Service
{
- public $viewPath = array();
+ public $viewPath = [];
+ public $webPath = [];
public $registry; // Registry->getInstance
public $template;
public $templatePath;
public $COMPONENTS_WEB;
+
+ public $db;
public function getTemplatePath($name)
{
@@ -58,5 +61,14 @@ class Controller_Service
}
return $result;
}
+
+ function getInfo() {
+ $filename = Path::join($this->viewPath[0], 'install.json');
+ if (file_exists($filename)) {
+ $settings = json_decode(File::getContents($filename), true);
+ return $settings;
+ }
+ return array();
+ }
}
diff --git a/src/Database.php b/src/Database.php
index b08d864..def3072 100644
--- a/src/Database.php
+++ b/src/Database.php
@@ -1,6 +1,7 @@
require_once "Database/PDOStatement.php";
+
/**
* Класс оболочка для PDO для замены Creole
*/
@@ -12,8 +13,14 @@ class Database extends PDO
{
parent::__construct($dsn, $username, $password);
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ $this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Database_PDOStatement', array()));
}
+
+ function prepare($sql, $args = []) {
+ $result = parent::prepare($sql, $args);
+ return $result;
+ }
public function getDSN()
{
@@ -34,6 +41,10 @@ class Database extends PDO
if ($dsn['phptype'] == 'pgsql') {
$connection->query('SET client_encoding="UTF-8"');
}
+
+ if (isset($dsn['schema'])) {
+ $connection->query('SET search_path TO ' . $dsn['schema']);
+ }
}
if ($dsn['phptype'] == 'sqlite') {
/*.Database.*/$connection = new static("{$dsn['phptype']}:{$dsn['database']}");
@@ -81,7 +92,7 @@ class Database extends PDO
/**
* Извлекает из базы первый элемент по запросу
*/
- public function fetchOneArray($query,$values=null)
+ public function fetchOneArray($query, $values = null)
{
/*.Database_PDOStatement.*/$sth = $this->prepare($query);
$prep = $this->prepareValues($values);
diff --git a/src/Database/PDOStatement.php b/src/Database/PDOStatement.php
index 0cbd058..43c7564 100644
--- a/src/Database/PDOStatement.php
+++ b/src/Database/PDOStatement.php
@@ -1,7 +1,5 @@
fields[$name];
+ return isset($this->fields[$name]) ? $this->fields[$name]: null;
}
function getBoolean($name) {
@@ -88,10 +86,16 @@ class Database_PDOStatement extends PDOStatement implements IteratorAggregate
}
function getArray($name) {
- return strToArray($this->fields[$name]);
+ return Tools_String::strToArray($this->fields[$name]);
}
function getRecordCount() {
return count($this->cache);
}
+
+ function execute($args = null) {
+ $result = parent::execute($args);
+ return $result;
+ }
+
}
diff --git a/src/Database/Statement.php b/src/Database/Statement.php
index 80b77da..dbcee3a 100644
--- a/src/Database/Statement.php
+++ b/src/Database/Statement.php
@@ -17,33 +17,27 @@ class Database_Statement
$this->conn = $conn;
}
- function setInt($n, $value)
- {
+ function setInt($n, $value) {
$this->binds [] = array($n, $value, PDO::PARAM_INT);
}
- function setString($n, $value)
- {
+ function setString($n, $value) {
$this->binds [] = array($n, $value, PDO::PARAM_STR);
}
- function setBlob($n, $value)
- {
+ function setBlob($n, $value) {
$this->binds [] = array($n, $value, PDO::PARAM_LOB);
}
- function setLimit($limit)
- {
+ function setLimit($limit) {
$this->limit = $limit;
}
- function setOffset($offset)
- {
+ function setOffset($offset) {
$this->offset = $offset;
}
- function executeQuery()
- {
+ function executeQuery() {
if ($this->limit) {
$this->query .= " LIMIT {$this->limit} OFFSET {$this->offset}";
}
diff --git a/src/Excel/Number.php b/src/Excel/Number.php
index 66dd6b6..dfc220a 100644
--- a/src/Excel/Number.php
+++ b/src/Excel/Number.php
@@ -6,7 +6,7 @@ class Excel_Number
function __construct($value)
{
- $this->value = intval($value);
+ $this->value = (int)($value);
}
function getString()
diff --git a/src/Filter/Filter.php b/src/Filter/Filter.php
index 8140e8f..e5135dc 100644
--- a/src/Filter/Filter.php
+++ b/src/Filter/Filter.php
@@ -6,7 +6,7 @@
class Filter_Filter
{
public $processor;
- public function __construct(/*.Filter_Filter.*/$processor)
+ public function __construct(/*.Controller_Action.*/$processor)
{
$this->processor = $processor;
}
diff --git a/src/Filter/Login.php b/src/Filter/Login.php
index 70ad01d..e2b5cff 100644
--- a/src/Filter/Login.php
+++ b/src/Filter/Login.php
@@ -13,12 +13,8 @@ class Filter_Login extends Filter_Filter
const SESSION_BROWSER_SIGN_SECRET = '@w3dsju45Msk#';
const SESSION_BROWSER_SIGN_KEYNAME = 'session.app.browser.sign';
public $mode = 'ajax';
+ public $user;
- //AJAX-Реквесты для которых не требуется авторизация, потребовалось для сбора статистики
- public $whiteRequestList = [['module' => "requiredcontent", "action" => "getcount"],
- ['module' => "requiredcontent", "action" => "teststructure"],
- ['module' => "requiredcontent", "action" => "specialdump"]
- ];
/**
* Проверка авторизации
* @return Boolean Авторизовани пользователь или нет
@@ -29,6 +25,7 @@ class Filter_Login extends Filter_Filter
session_start();
$db = $this->getConnection();
Filter_UserAccess::setUp($db); // Соединение
+
switch ($request->getAction()) {
// Авторизация по постоянному паролю
case 'login':
@@ -142,7 +139,7 @@ class Filter_Login extends Filter_Filter
// Параметры при неправильной авторизации
// Действия по умолчанию !! Возможно переход на форму регистрации
if ($request->get('mode') == 'ajax') {
- if (!$this->requestIsWhite($request, $this->whiteRequestList)) {
+ if (!$this->requestIsWhite($request)) {
return json_encode(array('result' => 'fail', 'message' =>"NOT_AUTHORIZED"));
}
} else {
@@ -165,11 +162,14 @@ class Filter_Login extends Filter_Filter
* Проверка на попадание реквеста в белый список
*/
- public function requestIsWhite(Collection $request, $whiteRequestList){
+ public function requestIsWhite(Collection $request) {
$module = $request->get('module');
$action = $request->get('action');
- foreach ($whiteRequestList as $whiteRequest) {
- if ($module == $whiteRequest['module'] && $action == $whiteRequest['action']) {
+
+ $file = Path::join(CMS_PATH, 'modules', $module, 'filters', 'white.php');
+ if (file_exists($file)) {
+ $whiteList = include $file;
+ if (in_array($action, $whiteList)) {
return true;
}
}
diff --git a/src/Filter/UserAccess.php b/src/Filter/UserAccess.php
index ce27a66..fbf97b4 100644
--- a/src/Filter/UserAccess.php
+++ b/src/Filter/UserAccess.php
@@ -62,7 +62,7 @@ class Filter_UserAccess
$time = time();
if ($time - $lasttime > self::LIFE_TIME) return null; // Вышло время сессии
$id = self::$id;
- self::$db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время последнего обращения входа
+ // self::$db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время последнего обращения входа
}
return $result;
}
diff --git a/src/Form/Form.php b/src/Form/Form.php
index 47a1854..2d6baab 100644
--- a/src/Form/Form.php
+++ b/src/Form/Form.php
@@ -105,8 +105,8 @@ class Form_Form extends View_View {
public function addFieldClass($name, $class)
{
$this->constructor [$name] = $class;
- }
-
+ }
+
/**
* Добавляет одно поле ввода на форму
*/
diff --git a/src/Path.php b/src/Path.php
index 9835f88..ba78789 100644
--- a/src/Path.php
+++ b/src/Path.php
@@ -126,7 +126,7 @@ class Path
*
* @return array
*/
- public static function listFromString ($path)
+ public static function listFromString($path)
{
assert(is_string($path));
@@ -287,7 +287,7 @@ class Path
$result [] = $parts->getParts();
}
// При обьединении ссылок можно обьеденить path, query, fragment
- $path = implode(self::SEPARATOR, call_user_func_array('array_merge', $result));
+ $path = implode(self::SEPARATOR, self::optimize(call_user_func_array('array_merge', $result)));
$parts0->url['path'] = ($parts0->isAbsolute()) ? '/' . $path : $path;
return $parts0;
}
diff --git a/src/Registry.php b/src/Registry.php
index f2b7673..5a2d871 100644
--- a/src/Registry.php
+++ b/src/Registry.php
@@ -1,6 +1,6 @@
+///
Добавьте текст
", 'component' => '', 'module' => ''); - } - $result = array(); - foreach($data as $key => $part) { - $result[] = $part['content']; - } - return implode("", $result); - } - - function replaceContent($match, $offset) - { - //$result = phptal_component($match, $offset); - /*.Controller_Component.*/$component = null; - - - if(class_exists("Controller_Site")){ //Если мы в CMS2 - $component = Controller_Site::loadComponent($match); - } else { - global $db, $registry; // - $component = Controller_Component::loadComponent($match, $db, $registry); - } - - $req = new HttpRequest(); - unset($req['active_page']); - - $info = $component->getInfo(); - $result = $component->execute($req); - - if (is_string($result)) { - return array('type' => 'page-component', 'content' => $result, 'component' => $match); - } else { - $this->setView('view' . $this->counter++, $result); - return array('type' => 'page-component', 'content' => $result->execute(), 'component' => $match); - } - } - - function execute() { - return $this->text; - } -} diff --git a/src/tales.php b/src/tales.php index 0d727e8..2c9bc91 100644 --- a/src/tales.php +++ b/src/tales.php @@ -48,7 +48,7 @@ function phptal_component ($expression) { $begin = floatval(microtime(true)); /*.Controller_Component.*/$component = null; - if(class_exists("Controller_Site")){ //Если мы в CMS2 + if (class_exists("Controller_Site")) { //Если мы в CMS2 $component = Controller_Site::loadComponent($expression); } else { global $db, $registry; // Иначе обращаемся к глобальным переменным