From a4565e88edbc8e3bd092a475469769c86a4c350c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 2 Aug 2013 22:40:51 +0200 Subject: add Twig & refactor poche --- inc/config.php | 76 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 36 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 6e3f80b8..7470f0c3 100644 --- a/inc/config.php +++ b/inc/config.php @@ -9,65 +9,69 @@ */ define ('POCHE_VERSION', '0.3'); - -if (!is_dir('db/')) { - @mkdir('db/',0705); -} - define ('MODE_DEMO', FALSE); -define ('ABS_PATH', 'assets/'); -define ('CONVERT_LINKS_FOOTNOTES', TRUE); -define ('REVERT_FORCED_PARAGRAPH_ELEMENTS',FALSE); -define ('DOWNLOAD_PICTURES', TRUE); +define ('CONVERT_LINKS_FOOTNOTES', FALSE); +define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); +define ('DOWNLOAD_PICTURES', FALSE); define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX'); +define ('ABS_PATH', 'assets/'); +define ('TPL', './tpl'); +define ('LOCALE', './locale'); +define ('CACHE', './cache'); define ('LANG', 'fr_FR.UTF8'); -putenv("LC_ALL=".LANG); -setlocale(LC_ALL, LANG); -bindtextdomain(LANG, "./locale"); -textdomain(LANG); - $storage_type = 'sqlite'; # sqlite or file -include 'functions.php'; +# /!\ Be careful if you change the lines below /!\ + +require_once 'pocheCore.php'; require_once 'Readability.php'; require_once 'Encoding.php'; -require_once 'rain.tpl.class.php'; -require_once 'MyTool.class.php'; +require_once 'pocheTool.class.php'; require_once 'Session.class.php'; +require_once 'Twig/Autoloader.php'; require_once 'store/store.class.php'; -require_once 'store/sqlite.class.php'; -require_once 'store/file.class.php'; -require_once 'class.messages.php'; +require_once 'store/' . $storage_type . '.class.php'; -Session::init(); +if (DOWNLOAD_PICTURES) { + require_once 'pochePicture.php'; +} + +# i18n +putenv('LC_ALL=' . LANG); +setlocale(LC_ALL, LANG); +bindtextdomain(LANG, LOCALE); +textdomain(LANG); + +# template engine +Twig_Autoloader::register(); +$loader = new Twig_Loader_Filesystem(TPL); +$twig = new Twig_Environment($loader, array( + 'cache' => CACHE, +)); +$twig->addExtension(new Twig_Extensions_Extension_I18n()); -$store = new $storage_type(); -# initialisation de RainTPL -raintpl::$tpl_dir = './tpl/'; -raintpl::$cache_dir = './cache/'; -raintpl::$base_url = get_poche_url(); -raintpl::configure('path_replace', false); -raintpl::configure('debug', false); -$tpl = new raintpl(); +Session::init(); +$store = new $storage_type(); +# installation if(!$store->isInstalled()) { - logm('poche still not installed'); - $tpl->draw('install'); + pocheTool::logm('poche still not installed'); + echo $twig->render('install.twig', array( + 'token' => Session::getToken(), + )); if (isset($_GET['install'])) { if (($_POST['password'] == $_POST['password_repeat']) && $_POST['password'] != "" && $_POST['login'] != "") { + # let's rock, install poche baby ! $store->install($_POST['login'], encode_string($_POST['password'] . $_POST['login'])); Session::logout(); - MyTool::redirect(); + pocheTool::redirect(); } } exit(); } $_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin(); -$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword(); - -$msg = new Messages(); -$tpl->assign('msg', $msg); \ No newline at end of file +$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword(); \ No newline at end of file -- cgit v1.2.3 From 8069e235fd2971675ee5fc05026ffa9bce5cbbb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 2 Aug 2013 22:43:56 +0200 Subject: move Twig in 3rdparty --- inc/config.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 7470f0c3..65b2b9cc 100644 --- a/inc/config.php +++ b/inc/config.php @@ -24,17 +24,17 @@ $storage_type = 'sqlite'; # sqlite or file # /!\ Be careful if you change the lines below /!\ -require_once 'pocheCore.php'; -require_once 'Readability.php'; -require_once 'Encoding.php'; -require_once 'pocheTool.class.php'; -require_once 'Session.class.php'; -require_once 'Twig/Autoloader.php'; +require_once 'poche/pocheTool.class.php'; +require_once 'poche/pocheCore.php'; +require_once '3rdparty/Readability.php'; +require_once '3rdparty/Encoding.php'; +require_once '3rdparty/Session.class.php'; +require_once '3rdparty/Twig/Autoloader.php'; require_once 'store/store.class.php'; require_once 'store/' . $storage_type . '.class.php'; if (DOWNLOAD_PICTURES) { - require_once 'pochePicture.php'; + require_once 'poche/pochePicture.php'; } # i18n -- cgit v1.2.3 From 5ffe5cf541d0d1c7524537b034d0cde3da18f6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 2 Aug 2013 23:00:57 +0200 Subject: rename pocheTool -> pocheTools --- inc/config.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 65b2b9cc..58abb535 100644 --- a/inc/config.php +++ b/inc/config.php @@ -10,6 +10,7 @@ define ('POCHE_VERSION', '0.3'); define ('MODE_DEMO', FALSE); +define ('DEBUG_POCHE', TRUE); define ('CONVERT_LINKS_FOOTNOTES', FALSE); define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); define ('DOWNLOAD_PICTURES', FALSE); @@ -24,7 +25,7 @@ $storage_type = 'sqlite'; # sqlite or file # /!\ Be careful if you change the lines below /!\ -require_once 'poche/pocheTool.class.php'; +require_once 'poche/pocheTools.class.php'; require_once 'poche/pocheCore.php'; require_once '3rdparty/Readability.php'; require_once '3rdparty/Encoding.php'; -- cgit v1.2.3 From 161395d7098ec2bd86671d15d5b54f39148e2d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 2 Aug 2013 23:04:24 +0200 Subject: mv pochetool pochetools --- inc/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 58abb535..c4898cc9 100644 --- a/inc/config.php +++ b/inc/config.php @@ -58,7 +58,7 @@ $store = new $storage_type(); # installation if(!$store->isInstalled()) { - pocheTool::logm('poche still not installed'); + pocheTools::logm('poche still not installed'); echo $twig->render('install.twig', array( 'token' => Session::getToken(), )); @@ -68,7 +68,7 @@ if(!$store->isInstalled()) # let's rock, install poche baby ! $store->install($_POST['login'], encode_string($_POST['password'] . $_POST['login'])); Session::logout(); - pocheTool::redirect(); + pocheTools::redirect(); } } exit(); -- cgit v1.2.3 From 8cbb2a88024969f7efd90f8053f3b0805fa2f8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 3 Aug 2013 08:25:11 +0200 Subject: twig implementation --- inc/config.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index c4898cc9..b78147ab 100644 --- a/inc/config.php +++ b/inc/config.php @@ -10,7 +10,7 @@ define ('POCHE_VERSION', '0.3'); define ('MODE_DEMO', FALSE); -define ('DEBUG_POCHE', TRUE); +define ('DEBUG_POCHE', FALSE); define ('CONVERT_LINKS_FOOTNOTES', FALSE); define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); define ('DOWNLOAD_PICTURES', FALSE); @@ -21,7 +21,7 @@ define ('LOCALE', './locale'); define ('CACHE', './cache'); define ('LANG', 'fr_FR.UTF8'); -$storage_type = 'sqlite'; # sqlite or file +$storage_type = 'sqlite'; # sqlite, file # /!\ Be careful if you change the lines below /!\ @@ -75,4 +75,6 @@ if(!$store->isInstalled()) } $_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin(); -$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword(); \ No newline at end of file +$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword(); + +pocheTools::initPhp(); \ No newline at end of file -- cgit v1.2.3 From 4f5b44bd3bd490309eb2ba7b44df4769816ba729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 3 Aug 2013 19:26:54 +0200 Subject: twig implementation --- inc/config.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index b78147ab..495dbb85 100644 --- a/inc/config.php +++ b/inc/config.php @@ -24,15 +24,14 @@ define ('LANG', 'fr_FR.UTF8'); $storage_type = 'sqlite'; # sqlite, file # /!\ Be careful if you change the lines below /!\ - require_once 'poche/pocheTools.class.php'; require_once 'poche/pocheCore.php'; require_once '3rdparty/Readability.php'; require_once '3rdparty/Encoding.php'; require_once '3rdparty/Session.class.php'; -require_once '3rdparty/Twig/Autoloader.php'; require_once 'store/store.class.php'; require_once 'store/' . $storage_type . '.class.php'; +require_once './vendor/autoload.php'; if (DOWNLOAD_PICTURES) { require_once 'poche/pochePicture.php'; @@ -45,7 +44,7 @@ bindtextdomain(LANG, LOCALE); textdomain(LANG); # template engine -Twig_Autoloader::register(); +// Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem(TPL); $twig = new Twig_Environment($loader, array( 'cache' => CACHE, -- cgit v1.2.3 From eb1af592194e225bf887e4893e697f0ab8dd9a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sun, 4 Aug 2013 20:58:31 +0200 Subject: refactoring --- inc/config.php | 79 ---------------------------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 inc/config.php (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php deleted file mode 100644 index 495dbb85..00000000 --- a/inc/config.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright 2013 - * @license http://www.wtfpl.net/ see COPYING file - */ - -define ('POCHE_VERSION', '0.3'); -define ('MODE_DEMO', FALSE); -define ('DEBUG_POCHE', FALSE); -define ('CONVERT_LINKS_FOOTNOTES', FALSE); -define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); -define ('DOWNLOAD_PICTURES', FALSE); -define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX'); -define ('ABS_PATH', 'assets/'); -define ('TPL', './tpl'); -define ('LOCALE', './locale'); -define ('CACHE', './cache'); -define ('LANG', 'fr_FR.UTF8'); - -$storage_type = 'sqlite'; # sqlite, file - -# /!\ Be careful if you change the lines below /!\ -require_once 'poche/pocheTools.class.php'; -require_once 'poche/pocheCore.php'; -require_once '3rdparty/Readability.php'; -require_once '3rdparty/Encoding.php'; -require_once '3rdparty/Session.class.php'; -require_once 'store/store.class.php'; -require_once 'store/' . $storage_type . '.class.php'; -require_once './vendor/autoload.php'; - -if (DOWNLOAD_PICTURES) { - require_once 'poche/pochePicture.php'; -} - -# i18n -putenv('LC_ALL=' . LANG); -setlocale(LC_ALL, LANG); -bindtextdomain(LANG, LOCALE); -textdomain(LANG); - -# template engine -// Twig_Autoloader::register(); -$loader = new Twig_Loader_Filesystem(TPL); -$twig = new Twig_Environment($loader, array( - 'cache' => CACHE, -)); -$twig->addExtension(new Twig_Extensions_Extension_I18n()); - -Session::init(); -$store = new $storage_type(); - -# installation -if(!$store->isInstalled()) -{ - pocheTools::logm('poche still not installed'); - echo $twig->render('install.twig', array( - 'token' => Session::getToken(), - )); - if (isset($_GET['install'])) { - if (($_POST['password'] == $_POST['password_repeat']) - && $_POST['password'] != "" && $_POST['login'] != "") { - # let's rock, install poche baby ! - $store->install($_POST['login'], encode_string($_POST['password'] . $_POST['login'])); - Session::logout(); - pocheTools::redirect(); - } - } - exit(); -} - -$_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin(); -$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword(); - -pocheTools::initPhp(); \ No newline at end of file -- cgit v1.2.3