From fb5e5594bea149ca730bc6424dc547dab3347747 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Fri, 14 Jun 2013 20:53:12 +0200 Subject: Fix issue #82 : ajout direct de Minz sans devoir faire appel au script ./build.sh --- lib/minz/Request.php | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 lib/minz/Request.php (limited to 'lib/minz/Request.php') diff --git a/lib/minz/Request.php b/lib/minz/Request.php new file mode 100644 index 000000000..507630b84 --- /dev/null +++ b/lib/minz/Request.php @@ -0,0 +1,189 @@ + +*/ + +/** + * Request représente la requête http + */ +class Request { + private static $controller_name = ''; + private static $action_name = ''; + private static $params = array (); + + private static $default_controller_name = 'index'; + private static $default_action_name = 'index'; + + public static $reseted = true; + + /** + * Getteurs + */ + public static function controllerName () { + return self::$controller_name; + } + public static function actionName () { + return self::$action_name; + } + public static function params () { + return self::$params; + } + public static function param ($key, $default = false) { + if (isset (self::$params[$key])) { + return self::$params[$key]; + } else { + return $default; + } + } + public static function defaultControllerName () { + return self::$default_controller_name; + } + public static function defaultActionName () { + return self::$default_action_name; + } + + /** + * Setteurs + */ + public static function _controllerName ($controller_name) { + self::$controller_name = $controller_name; + } + public static function _actionName ($action_name) { + self::$action_name = $action_name; + } + public static function _params ($params) { + if (!is_array($params)) { + $params = array ($params); + } + + self::$params = $params; + } + public static function _param ($key, $value = false) { + if ($value === false) { + unset (self::$params[$key]); + } else { + self::$params[$key] = $value; + } + } + + /** + * Initialise la Request + */ + public static function init () { + self::magicQuotesOff (); + } + + /** + * Retourn le nom de domaine du site + */ + public static function getDomainName () { + return $_SERVER['HTTP_HOST']; + } + + /** + * Détermine la base de l'url + * @return la base de l'url + */ + public static function getBaseUrl () { + return Configuration::baseUrl (); + } + + /** + * Récupère l'URI de la requête + * @return l'URI + */ + public static function getURI () { + if (isset ($_SERVER['REQUEST_URI'])) { + $base_url = self::getBaseUrl (); + $uri = $_SERVER['REQUEST_URI']; + + $len_base_url = strlen ($base_url); + $real_uri = substr ($uri, $len_base_url); + } else { + $real_uri = ''; + } + + return $real_uri; + } + + /** + * Relance une requête + * @param $url l'url vers laquelle est relancée la requête + * @param $redirect si vrai, force la redirection http + * > sinon, le dispatcher recharge en interne + */ + public static function forward ($url = array (), $redirect = false) { + $url = Url::checkUrl ($url); + + if ($redirect) { + header ('Location: ' . Url::display ($url, 'php')); + exit (); + } else { + self::$reseted = true; + + self::_controllerName ($url['c']); + self::_actionName ($url['a']); + self::_params (array_merge ( + self::$params, + $url['params'] + )); + } + } + + /** + * Permet de récupérer une variable de type $_GET + * @param $param nom de la variable + * @param $default valeur par défaut à attribuer à la variable + * @return $_GET[$param] + * $_GET si $param = false + * $default si $_GET[$param] n'existe pas + */ + public static function fetchGET ($param = false, $default = false) { + if ($param === false) { + return $_GET; + } elseif (isset ($_GET[$param])) { + return $_GET[$param]; + } else { + return $default; + } + } + + /** + * Permet de récupérer une variable de type $_POST + * @param $param nom de la variable + * @param $default valeur par défaut à attribuer à la variable + * @return $_POST[$param] + * $_POST si $param = false + * $default si $_POST[$param] n'existe pas + */ + public static function fetchPOST ($param = false, $default = false) { + if ($param === false) { + return $_POST; + } elseif (isset ($_POST[$param])) { + return $_POST[$param]; + } else { + return $default; + } + } + + /** + * Méthode désactivant les magic_quotes pour les variables + * $_GET + * $_POST + * $_COOKIE + */ + private static function magicQuotesOff () { + if (get_magic_quotes_gpc ()) { + $_GET = Helper::stripslashes_r ($_GET); + $_POST = Helper::stripslashes_r ($_POST); + $_COOKIE = Helper::stripslashes_r ($_COOKIE); + } + } + + public static function isPost () { + return !empty ($_POST) || !empty ($_FILES); + } +} + + -- cgit v1.2.3 From 6d184ad1b8b84ab31e342f539844e0dc5738423b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Jun 2013 14:46:37 +0200 Subject: Fix issue #89 : meilleure vérification des champs de formulaires (géré par Minz) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/RSSConfiguration.php | 4 ++-- lib/minz/Request.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/minz/Request.php') diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index 50dbd2555..6ebc30e8e 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -85,7 +85,7 @@ class RSSConfiguration extends Model { $this->language = $value; } public function _postsPerPage ($value) { - if (is_int (intval ($value))) { + if (is_int (intval ($value)) && $value > 0) { $this->posts_per_page = $value; } else { $this->posts_per_page = 10; @@ -120,7 +120,7 @@ class RSSConfiguration extends Model { } } public function _oldEntries ($value) { - if (is_int (intval ($value))) { + if (is_int (intval ($value)) && $value > 0) { $this->old_entries = $value; } else { $this->old_entries = 3; diff --git a/lib/minz/Request.php b/lib/minz/Request.php index 507630b84..3463686bc 100644 --- a/lib/minz/Request.php +++ b/lib/minz/Request.php @@ -31,7 +31,12 @@ class Request { } public static function param ($key, $default = false) { if (isset (self::$params[$key])) { - return self::$params[$key]; + $p = self::$params[$key]; + if(is_array($p)) { + return array_map(htmlspecialchars, $p); + } else { + return htmlspecialchars($p); + } } else { return $default; } -- cgit v1.2.3 From 1863153b966af00078869b6634df1daa22cdcbfe Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Jun 2013 15:55:44 +0200 Subject: Fix issue #71 : remise en place du mode endless + correction bug à l'importation OPML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/feedController.php | 4 ++-- app/controllers/indexController.php | 1 + app/views/helpers/pagination.phtml | 2 +- lib/minz/Request.php | 8 +++++--- public/scripts/endless_mode.js | 31 +++++++++++++++++++++++++++++++ public/theme/freshrss.css | 4 ++++ public/theme/loader.gif | Bin 0 -> 4167 bytes 7 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 public/scripts/endless_mode.js create mode 100644 public/theme/loader.gif (limited to 'lib/minz/Request.php') diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index a41d7a33f..76da41c58 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -219,8 +219,8 @@ class feedController extends ActionController { $entryDAO = new EntryDAO (); $feedDAO = new FeedDAO (); - $categories = Request::param ('categories', array ()); - $feeds = Request::param ('feeds', array ()); + $categories = Request::param ('categories', array (), true); + $feeds = Request::param ('feeds', array (), true); // on ajoute les catégories en masse dans une fonction à part $this->addCategories ($categories); diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index f4f0b98b3..5403b82ed 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -12,6 +12,7 @@ class indexController extends ActionController { View::appendScript (Url::display ('/scripts/shortcut.js')); View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize'))); + View::appendScript (Url::display ('/scripts/endless_mode.js')); } $entryDAO = new EntryDAO (); diff --git a/app/views/helpers/pagination.phtml b/app/views/helpers/pagination.phtml index f029f281a..80c0976ad 100755 --- a/app/views/helpers/pagination.phtml +++ b/app/views/helpers/pagination.phtml @@ -8,7 +8,7 @@
  • next != '') { ?> next; ?> - + diff --git a/lib/minz/Request.php b/lib/minz/Request.php index 3463686bc..bd5fcb95e 100644 --- a/lib/minz/Request.php +++ b/lib/minz/Request.php @@ -29,11 +29,13 @@ class Request { public static function params () { return self::$params; } - public static function param ($key, $default = false) { + public static function param ($key, $default = false, $specialchars = false) { if (isset (self::$params[$key])) { $p = self::$params[$key]; - if(is_array($p)) { - return array_map(htmlspecialchars, $p); + if(is_object($p) || $specialchars) { + return $p; + } elseif(is_array($p)) { + return array_map('htmlspecialchars', $p); } else { return htmlspecialchars($p); } diff --git a/public/scripts/endless_mode.js b/public/scripts/endless_mode.js new file mode 100644 index 000000000..489b69f30 --- /dev/null +++ b/public/scripts/endless_mode.js @@ -0,0 +1,31 @@ +var url_load_more = ""; +var load = false; + +function init_load_more() { + url_load_more = $("a#load_more").attr("href"); + + $("#load_more").click (function () { + load_more_posts (); + + return false; + }); +} + +function load_more_posts () { + load = true; + $("#load_more").addClass("loading"); + $.get (url_load_more, function (data) { + $("#stream .flux:last").after($("#stream .flux", data)); + $(".pagination").html($(".pagination", data).html()); + + init_load_more(); + init_posts(); + + $("#load_more").removeClass("loading"); + load = false; + }); +} + +$(document).ready (function () { + init_load_more(); +}); \ No newline at end of file diff --git a/public/theme/freshrss.css b/public/theme/freshrss.css index 2a8f24ea7..f5d4f6a83 100644 --- a/public/theme/freshrss.css +++ b/public/theme/freshrss.css @@ -357,6 +357,10 @@ color: #333; font-style: italic; } +.loading { + background: url("loader.gif") center center no-repeat; + font-size: 0; +} /*** NOTIFICATION ***/ .notification { diff --git a/public/theme/loader.gif b/public/theme/loader.gif new file mode 100644 index 000000000..5ff26f0e3 Binary files /dev/null and b/public/theme/loader.gif differ -- cgit v1.2.3