diff options
Diffstat (limited to 'lib/Minz')
| -rw-r--r-- | lib/Minz/ActionController.php | 4 | ||||
| -rw-r--r-- | lib/Minz/Configuration.php | 2 | ||||
| -rw-r--r-- | lib/Minz/ExtensionManager.php | 35 | ||||
| -rw-r--r-- | lib/Minz/FrontController.php | 35 | ||||
| -rw-r--r-- | lib/Minz/Log.php | 44 | ||||
| -rw-r--r-- | lib/Minz/Mailer.php | 115 | ||||
| -rw-r--r-- | lib/Minz/ModelArray.php | 2 | ||||
| -rw-r--r-- | lib/Minz/ModelPdo.php | 152 | ||||
| -rw-r--r-- | lib/Minz/Request.php | 13 | ||||
| -rw-r--r-- | lib/Minz/View.php | 58 |
10 files changed, 340 insertions, 120 deletions
diff --git a/lib/Minz/ActionController.php b/lib/Minz/ActionController.php index 232a4ef9b..123b9054c 100644 --- a/lib/Minz/ActionController.php +++ b/lib/Minz/ActionController.php @@ -14,7 +14,9 @@ class Minz_ActionController { * Constructeur */ public function __construct () { - $this->view = new Minz_View (); + $this->view = new Minz_View(); + $view_path = Minz_Request::controllerName() . '/' . Minz_Request::actionName() . '.phtml'; + $this->view->_path($view_path); $this->view->attributeParams (); } diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index aae3accc6..93f6b494c 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -198,7 +198,7 @@ class Minz_Configuration { return false; } - // Clear PHP 5.5+ cache for include + // Clear PHP cache for include if (function_exists('opcache_invalidate')) { opcache_invalidate($this->config_filename); } diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index b086c4001..2240b7642 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -27,14 +27,30 @@ class Minz_ExtensionManager { 'list' => array(), 'signature' => 'OneToOne', ), - 'post_update' => array( // function(none) -> none + 'freshrss_init' => array( // function() -> none 'list' => array(), 'signature' => 'NoneToNone', ), + 'menu_admin_entry' => array( // function() -> string + 'list' => array(), + 'signature' => 'NoneToString', + ), + 'menu_configuration_entry' => array( // function() -> string + 'list' => array(), + 'signature' => 'NoneToString', + ), + 'menu_other_entry' => array( // function() -> string + 'list' => array(), + 'signature' => 'NoneToString', + ), 'nav_reading_modes' => array( // function($readingModes = array) -> array | null 'list' => array(), 'signature' => 'OneToOne', ), + 'post_update' => array( // function(none) -> none + 'list' => array(), + 'signature' => 'NoneToNone', + ), 'simplepie_before_init' => array( // function($simplePie, $feed) -> none 'list' => array(), 'signature' => 'PassArguments', @@ -307,6 +323,23 @@ class Minz_ExtensionManager { } /** + * Call a hook which takes no argument and returns a string. + * + * The result is concatenated between each hook and the final string is + * returned. + * + * @param string $hook_name is the hook to call. + * @return a concatenated string, result of the call to all the hooks. + */ + private static function callNoneToString($hook_name) { + $result = ''; + foreach (self::$hook_list[$hook_name]['list'] as $function) { + $result = $result . call_user_func($function); + } + return $result; + } + + /** * Call a hook which takes no argument and returns nothing. * * This case is simpler than callOneToOne because hooks are called one by diff --git a/lib/Minz/FrontController.php b/lib/Minz/FrontController.php index 066278b7c..e09b022fc 100644 --- a/lib/Minz/FrontController.php +++ b/lib/Minz/FrontController.php @@ -115,21 +115,26 @@ class Minz_FrontController { } private function setReporting() { - $conf = Minz_Configuration::get('system'); - switch($conf->environment) { - case 'production': - error_reporting(E_ALL); - ini_set('display_errors', 'Off'); - ini_set('log_errors', 'On'); - break; - case 'development': - error_reporting(E_ALL); - ini_set('display_errors', 'On'); - ini_set('log_errors', 'On'); - break; - case 'silent': - error_reporting(0); - break; + $envType = getenv('FRESHRSS_ENV'); + if ($envType == '') { + $conf = Minz_Configuration::get('system'); + $envType = $conf->environment; + } + switch ($envType) { + case 'development': + error_reporting(E_ALL); + ini_set('display_errors', 'On'); + ini_set('log_errors', 'On'); + break; + case 'silent': + error_reporting(0); + break; + case 'production': + default: + error_reporting(E_ALL); + ini_set('display_errors', 'Off'); + ini_set('log_errors', 'On'); + break; } } } diff --git a/lib/Minz/Log.php b/lib/Minz/Log.php index a8dbf8350..3e6a25f27 100644 --- a/lib/Minz/Log.php +++ b/lib/Minz/Log.php @@ -9,25 +9,13 @@ */ class Minz_Log { /** - * Les différents niveau de log - * ERROR erreurs bloquantes de l'application - * WARNING erreurs pouvant géner le bon fonctionnement, mais non bloquantes - * NOTICE erreurs mineures ou messages d'informations - * DEBUG Informations affichées pour le déboggage - */ - const ERROR = 2; - const WARNING = 4; - const NOTICE = 8; - const DEBUG = 16; - - /** * Enregistre un message dans un fichier de log spécifique * Message non loggué si * - environment = SILENT - * - level = WARNING et environment = PRODUCTION - * - level = NOTICE et environment = PRODUCTION + * - level = LOG_WARNING et environment = PRODUCTION + * - level = LOG_NOTICE et environment = PRODUCTION * @param $information message d'erreur / information à enregistrer - * @param $level niveau d'erreur + * @param $level niveau d'erreur https://php.net/function.syslog * @param $file_name fichier de log * @throws Minz_PermissionDeniedException */ @@ -41,7 +29,7 @@ class Minz_Log { if (! ($env === 'silent' || ($env === 'production' - && ($level >= Minz_Log::NOTICE)))) { + && ($level >= LOG_NOTICE)))) { if ($file_name === null) { $username = Minz_Session::param('currentUser', ''); if ($username == '') { @@ -51,16 +39,16 @@ class Minz_Log { } switch ($level) { - case Minz_Log::ERROR : + case LOG_ERR : $level_label = 'error'; break; - case Minz_Log::WARNING : + case LOG_WARNING : $level_label = 'warning'; break; - case Minz_Log::NOTICE : + case LOG_NOTICE : $level_label = 'notice'; break; - case Minz_Log::DEBUG : + case LOG_DEBUG : $level_label = 'debug'; break; default : @@ -71,6 +59,10 @@ class Minz_Log { . ' [' . $level_label . ']' . ' --- ' . $information . "\n"; + if (defined('COPY_LOG_TO_SYSLOG') && COPY_LOG_TO_SYSLOG) { + syslog($level, '[' . $username . '] ' . $log); + } + self::ensureMaxLogSize($file_name); if (file_put_contents($file_name, $log, FILE_APPEND | LOCK_EX) === false) { @@ -120,8 +112,8 @@ class Minz_Log { $msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, true)); $msg_post = str_replace("\n", '', '$_POST content : ' . print_r($_POST, true)); - self::record($msg_get, Minz_Log::DEBUG, $file_name); - self::record($msg_post, Minz_Log::DEBUG, $file_name); + self::record($msg_get, LOG_DEBUG, $file_name); + self::record($msg_post, LOG_DEBUG, $file_name); } /** @@ -129,15 +121,15 @@ class Minz_Log { * Parameters are the same of those of the record() method. */ public static function debug($msg, $file_name = null) { - self::record($msg, Minz_Log::DEBUG, $file_name); + self::record($msg, LOG_DEBUG, $file_name); } public static function notice($msg, $file_name = null) { - self::record($msg, Minz_Log::NOTICE, $file_name); + self::record($msg, LOG_NOTICE, $file_name); } public static function warning($msg, $file_name = null) { - self::record($msg, Minz_Log::WARNING, $file_name); + self::record($msg, LOG_WARNING, $file_name); } public static function error($msg, $file_name = null) { - self::record($msg, Minz_Log::ERROR, $file_name); + self::record($msg, LOG_ERR, $file_name); } } diff --git a/lib/Minz/Mailer.php b/lib/Minz/Mailer.php new file mode 100644 index 000000000..04392982b --- /dev/null +++ b/lib/Minz/Mailer.php @@ -0,0 +1,115 @@ +<?php + +use PHPMailer\PHPMailer\PHPMailer; +use PHPMailer\PHPMailer\Exception; + +/** + * Allow to send emails. + * + * The Minz_Mailer class must be inherited by classes under app/Mailers. + * They work similarly to the ActionControllers in the way they have a view to + * which you can pass params (eg. $this->view->foo = 'bar'). + * + * The view file is not determined automatically, so you have to select one + * with, for instance: + * + * ``` + * $this->view->_path('user_mailer/email_need_validation.txt') + * ``` + * + * Minz_Mailer uses the PHPMailer library under the hood. The latter requires + * PHP >= 5.5 to work. If you instantiate a Minz_Mailer with PHP < 5.5, a + * warning will be logged. + * + * The email is sent by calling the `mail` method. + */ +class Minz_Mailer { + /** + * The view attached to the mailer. + * You should set its file with `$this->view->_path($path)` + * + * @var Minz_View + */ + protected $view; + + /** + * Constructor. + * + * If PHP version is < 5.5, a warning is logged. + */ + public function __construct () { + if (version_compare(PHP_VERSION, '5.5') < 0) { + Minz_Log::warning('Minz_Mailer cannot be used with a version of PHP < 5.5.'); + } + + $this->view = new Minz_View(); + $this->view->_layout(false); + $this->view->attributeParams(); + + $conf = Minz_Configuration::get('system'); + $this->mailer = $conf->mailer; + $this->smtp_config = $conf->smtp; + + // According to https://github.com/PHPMailer/PHPMailer/wiki/SMTP-Debugging#debug-levels + // we should not use debug level above 2 unless if we have big trouble + // to connect. + if ($conf->environment === 'development') { + $this->debug_level = 2; + } else { + $this->debug_level = 0; + } + } + + /** + * Send an email. + * + * @param string $to The recipient of the email + * @param string $subject The subject of the email + * + * @return bool true on success, false if a SMTP error happens + */ + public function mail($to, $subject) { + ob_start(); + $this->view->render(); + $body = ob_get_contents(); + ob_end_clean(); + + PHPMailer::$validator = 'html5'; + + $mail = new PHPMailer(true); + try { + // Server settings + $mail->SMTPDebug = $this->debug_level; + $mail->Debugoutput = 'error_log'; + + if ($this->mailer === 'smtp') { + $mail->isSMTP(); + $mail->Hostname = $this->smtp_config['hostname']; + $mail->Host = $this->smtp_config['host']; + $mail->SMTPAuth = $this->smtp_config['auth']; + $mail->Username = $this->smtp_config['username']; + $mail->Password = $this->smtp_config['password']; + $mail->SMTPSecure = $this->smtp_config['secure']; + $mail->Port = $this->smtp_config['port']; + } else { + $mail->isMail(); + } + + // Recipients + $mail->setFrom($this->smtp_config['from']); + $mail->addAddress($to); + + // Content + $mail->isHTML(false); + $mail->CharSet = 'utf-8'; + $mail->Subject = $subject; + $mail->Body = $body; + + $mail->send(); + return true; + } catch (Exception $e) { + Minz_Log::error('Minz_Mailer cannot send a message: ' . $mail->ErrorInfo); + return false; + } + } +} diff --git a/lib/Minz/ModelArray.php b/lib/Minz/ModelArray.php index 1ac2b313d..4938f4b1d 100644 --- a/lib/Minz/ModelArray.php +++ b/lib/Minz/ModelArray.php @@ -48,7 +48,7 @@ class Minz_ModelArray { throw new Minz_PermissionDeniedException($this->filename); } if (function_exists('opcache_invalidate')) { - opcache_invalidate($this->filename); //Clear PHP 5.5+ cache for include + opcache_invalidate($this->filename); //Clear PHP cache for include } return true; } diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index 733982c14..69785c253 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -6,43 +6,35 @@ /** * La classe Model_sql représente le modèle interragissant avec les bases de données - * Seul la connexion MySQL est prise en charge pour le moment */ class Minz_ModelPdo { /** * Partage la connexion à la base de données entre toutes les instances. */ - public static $useSharedBd = true; - private static $sharedBd = null; + public static $usesSharedPdo = true; + private static $sharedPdo = null; private static $sharedPrefix; private static $sharedCurrentUser; - protected static $sharedDbType; - - /** - * $bd variable représentant la base de données - */ - protected $bd; + protected $pdo; protected $current_user; - protected $prefix; - - public function dbType() { - return self::$sharedDbType; - } /** * Créé la connexion à la base de données à l'aide des variables * HOST, BASE, USER et PASS définies dans le fichier de configuration */ - public function __construct($currentUser = null) { + public function __construct($currentUser = null, $currentPdo = null) { if ($currentUser === null) { $currentUser = Minz_Session::param('currentUser'); } - if (self::$useSharedBd && self::$sharedBd != null && - ($currentUser == null || $currentUser === self::$sharedCurrentUser)) { - $this->bd = self::$sharedBd; - $this->prefix = self::$sharedPrefix; + if ($currentPdo != null) { + $this->pdo = $currentPdo; + return; + } + if (self::$usesSharedPdo && self::$sharedPdo != null && + ($currentUser == '' || $currentUser === self::$sharedCurrentUser)) { + $this->pdo = self::$sharedPdo; $this->current_user = self::$sharedCurrentUser; return; } @@ -52,34 +44,40 @@ class Minz_ModelPdo { $conf = Minz_Configuration::get('system'); $db = $conf->db; - $driver_options = isset($conf->db['pdo_options']) && is_array($conf->db['pdo_options']) ? $conf->db['pdo_options'] : array(); + $driver_options = isset($db['pdo_options']) && is_array($db['pdo_options']) ? $db['pdo_options'] : []; $dbServer = parse_url('db://' . $db['host']); + $dsn = ''; + $dsnParams = empty($db['connection_uri_params']) ? '' : (';' . $db['connection_uri_params']); try { switch ($db['type']) { case 'mysql': - $string = 'mysql:host=' . (empty($dbServer['host']) ? $db['host'] : $dbServer['host']) . ';dbname=' . $db['base'] . ';charset=utf8mb4'; + $dsn = 'mysql:host=' . (empty($dbServer['host']) ? $db['host'] : $dbServer['host']) . ';charset=utf8mb4'; + if (!empty($db['base'])) { + $dsn .= ';dbname=' . $db['base']; + } if (!empty($dbServer['port'])) { - $string .= ';port=' . $dbServer['port']; + $dsn .= ';port=' . $dbServer['port']; } $driver_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES utf8mb4'; - $this->prefix = $db['prefix'] . $currentUser . '_'; - $this->bd = new MinzPDOMySql($string, $db['user'], $db['password'], $driver_options); + $this->pdo = new MinzPDOMySql($dsn . $dsnParams, $db['user'], $db['password'], $driver_options); + $this->pdo->setPrefix($db['prefix'] . $currentUser . '_'); break; case 'sqlite': - $string = 'sqlite:' . join_path(DATA_PATH, 'users', $currentUser, 'db.sqlite'); - $this->prefix = ''; - $this->bd = new MinzPDOSQLite($string, $db['user'], $db['password'], $driver_options); - $this->bd->exec('PRAGMA foreign_keys = ON;'); + $dsn = 'sqlite:' . join_path(DATA_PATH, 'users', $currentUser, 'db.sqlite'); + $this->pdo = new MinzPDOSQLite($dsn . $dsnParams, $db['user'], $db['password'], $driver_options); + $this->pdo->setPrefix(''); break; case 'pgsql': - $string = 'pgsql:host=' . (empty($dbServer['host']) ? $db['host'] : $dbServer['host']) . ';dbname=' . $db['base']; + $dsn = 'pgsql:host=' . (empty($dbServer['host']) ? $db['host'] : $dbServer['host']); + if (!empty($db['base'])) { + $dsn .= ';dbname=' . $db['base']; + } if (!empty($dbServer['port'])) { - $string .= ';port=' . $dbServer['port']; + $dsn .= ';port=' . $dbServer['port']; } - $this->prefix = $db['prefix'] . $currentUser . '_'; - $this->bd = new MinzPDOPGSQL($string, $db['user'], $db['password'], $driver_options); - $this->bd->exec("SET NAMES 'UTF8';"); + $this->pdo = new MinzPDOPGSQL($dsn . $dsnParams, $db['user'], $db['password'], $driver_options); + $this->pdo->setPrefix($db['prefix'] . $currentUser . '_'); break; default: throw new Minz_PDOConnectionException( @@ -88,86 +86,122 @@ class Minz_ModelPdo { ); break; } - self::$sharedBd = $this->bd; - self::$sharedDbType = $db['type']; - self::$sharedPrefix = $this->prefix; + self::$sharedPdo = $this->pdo; } catch (Exception $e) { throw new Minz_PDOConnectionException( - $string, + $dsn . $dsnParams, $db['user'], Minz_Exception::ERROR ); } } public function beginTransaction() { - $this->bd->beginTransaction(); + $this->pdo->beginTransaction(); } public function inTransaction() { - return $this->bd->inTransaction(); //requires PHP >= 5.3.3 + return $this->pdo->inTransaction(); } public function commit() { - $this->bd->commit(); + $this->pdo->commit(); } public function rollBack() { - $this->bd->rollBack(); + $this->pdo->rollBack(); } public static function clean() { - self::$sharedBd = null; - self::$sharedPrefix = ''; + self::$sharedPdo = null; + self::$sharedCurrentUser = ''; } +} - public function disableBuffering() { - if ((self::$sharedDbType === 'mysql') && defined('PDO::MYSQL_ATTR_USE_BUFFERED_QUERY')) { - $this->bd->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - } +abstract class MinzPDO extends PDO { + public function __construct($dsn, $username = null, $passwd = null, $options = null) { + parent::__construct($dsn, $username, $passwd, $options); + $this->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + } + + abstract public function dbType(); + + private $prefix = ''; + public function prefix() { return $this->prefix; } + public function setPrefix($prefix) { $this->prefix = $prefix; } + + private function autoPrefix($sql) { + return str_replace('`_', '`' . $this->prefix, $sql); } -} -class MinzPDO extends PDO { - private static function check($statement) { + protected function preSql($statement) { if (preg_match('/^(?:UPDATE|INSERT|DELETE)/i', $statement)) { invalidateHttpCache(); } + return $this->autoPrefix($statement); } - protected function compatibility($statement) { - return $statement; + public function lastInsertId($name = null) { + if ($name != null) { + $name = $this->preSql($name); + } + return parent::lastInsertId($name); } public function prepare($statement, $driver_options = array()) { - MinzPDO::check($statement); - $statement = $this->compatibility($statement); + $statement = $this->preSql($statement); return parent::prepare($statement, $driver_options); } public function exec($statement) { - MinzPDO::check($statement); - $statement = $this->compatibility($statement); + $statement = $this->preSql($statement); return parent::exec($statement); } public function query($statement) { - MinzPDO::check($statement); - $statement = $this->compatibility($statement); + $statement = $this->preSql($statement); return parent::query($statement); } } class MinzPDOMySql extends MinzPDO { + public function __construct($dsn, $username = null, $passwd = null, $options = null) { + parent::__construct($dsn, $username, $passwd, $options); + $this->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + } + + public function dbType() { + return 'mysql'; + } + public function lastInsertId($name = null) { return parent::lastInsertId(); //We discard the name, only used by PostgreSQL } } class MinzPDOSQLite extends MinzPDO { + public function __construct($dsn, $username = null, $passwd = null, $options = null) { + parent::__construct($dsn, $username, $passwd, $options); + $this->exec('PRAGMA foreign_keys = ON;'); + } + + public function dbType() { + return 'sqlite'; + } + public function lastInsertId($name = null) { return parent::lastInsertId(); //We discard the name, only used by PostgreSQL } } class MinzPDOPGSQL extends MinzPDO { - protected function compatibility($statement) { + public function __construct($dsn, $username = null, $passwd = null, $options = null) { + parent::__construct($dsn, $username, $passwd, $options); + $this->exec("SET NAMES 'UTF8';"); + } + + public function dbType() { + return 'pgsql'; + } + + protected function preSql($statement) { + $statement = parent::preSql($statement); return str_replace(array('`', ' LIKE '), array('"', ' ILIKE '), $statement); } } diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 912c354ac..9235f873a 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -52,6 +52,12 @@ class Minz_Request { } return null; } + public static function paramBoolean($key) { + if (null === $value = self::paramTernary($key)) { + return false; + } + return $value; + } public static function defaultControllerName() { return self::$default_controller_name; } @@ -98,6 +104,13 @@ class Minz_Request { self::initJSON(); } + public static function is($controller_name, $action_name) { + return ( + self::$controller_name === $controller_name && + self::$action_name === $action_name + ); + } + /** * Return true if the request is over HTTPS, false otherwise (HTTP) */ diff --git a/lib/Minz/View.php b/lib/Minz/View.php index d6bf6ea2c..5b6676690 100644 --- a/lib/Minz/View.php +++ b/lib/Minz/View.php @@ -9,11 +9,11 @@ */ class Minz_View { const VIEWS_PATH_NAME = '/views'; - const LAYOUT_PATH_NAME = '/layout'; - const LAYOUT_FILENAME = '/layout.phtml'; + const LAYOUT_PATH_NAME = '/layout/'; + const LAYOUT_DEFAULT = 'layout'; private $view_filename = ''; - private $use_layout = true; + private $layout_filename = ''; private static $base_pathnames = array(APP_PATH); private static $title = ''; @@ -26,21 +26,27 @@ class Minz_View { * Constructeur * Détermine si on utilise un layout ou non */ - public function __construct () { - $this->change_view(Minz_Request::controllerName(), - Minz_Request::actionName()); - + public function __construct() { + $this->_layout(self::LAYOUT_DEFAULT); $conf = Minz_Configuration::get('system'); self::$title = $conf->title; } /** - * Change le fichier de vue en fonction d'un controller / action + * [deprecated] Change the view file based on controller and action. */ public function change_view($controller_name, $action_name) { - $this->view_filename = self::VIEWS_PATH_NAME . '/' - . $controller_name . '/' - . $action_name . '.phtml'; + Minz_Log::warning('Minz_View::change_view is deprecated, it will be removed in a future version. Please use Minz_View::_path instead.'); + $this->_path($controller_name. '/' . $action_name . '.phtml'); + } + + /** + * Change the view file based on a pathname relative to VIEWS_PATH_NAME. + * + * @param string $path the new path + */ + public function _path($path) { + $this->view_filename = self::VIEWS_PATH_NAME . '/' . $path; } /** @@ -58,7 +64,7 @@ class Minz_View { * Construit la vue */ public function build () { - if ($this->use_layout) { + if ($this->layout_filename !== '') { $this->buildLayout (); } else { $this->render (); @@ -92,7 +98,9 @@ class Minz_View { */ public function buildLayout () { header('Content-Type: text/html; charset=UTF-8'); - $this->includeFile(self::LAYOUT_PATH_NAME . self::LAYOUT_FILENAME); + if (!$this->includeFile($this->layout_filename)) { + Minz_Log::notice('File not found: `' . $this->layout_filename . '`'); + } } /** @@ -137,11 +145,29 @@ class Minz_View { } /** - * Permet de choisir si on souhaite utiliser le layout - * @param $use true si on souhaite utiliser le layout, false sinon + * Choose the current view layout. + * @param $layout the layout name to use, false to use no layouts. + */ + public function _layout($layout) { + if ($layout) { + $this->layout_filename = self::LAYOUT_PATH_NAME . $layout . '.phtml'; + } else { + $this->layout_filename = ''; + } + } + + /** + * [deprecated] Choose if we want to use the layout or not. + * Please use the `_layout` function instead. + * @param $use true if we want to use the layout, false else */ public function _useLayout ($use) { - $this->use_layout = $use; + Minz_Log::warning('Minz_View::_useLayout is deprecated, it will be removed in a future version. Please use Minz_View::_layout instead.'); + if ($use) { + $this->_layout(self::LAYOUT_DEFAULT); + } else { + $this->_layout(false); + } } /** |
