From 5ffe5cf541d0d1c7524537b034d0cde3da18f6e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 2 Aug 2013 23:00:57 +0200 Subject: [PATCH] rename pocheTool -> pocheTools --- inc/config.php | 3 ++- inc/poche/pocheCore.php | 18 ++++++++++-------- inc/poche/pochePictures.php | 12 ++++-------- ...ocheTool.class.php => pocheTools.class.php} | 6 ++++-- 4 files changed, 20 insertions(+), 19 deletions(-) rename inc/poche/{pocheTool.class.php => pocheTools.class.php} (94%) 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'; diff --git a/inc/poche/pocheCore.php b/inc/poche/pocheCore.php index 52c603ac..34c15d84 100644 --- a/inc/poche/pocheCore.php +++ b/inc/poche/pocheCore.php @@ -136,10 +136,16 @@ function fetch_url_content($url) function display_view($view, $id = 0, $full_head = 'yes') { - global $tpl, $store, $msg; + global $tpl, $store; switch ($view) { + case 'install': + pocheTool::logm('install mode'); + break; + case 'import'; + pocheTool::logm('import mode'); + break; case 'export': $entries = $store->retrieveAll(); $tpl->assign('export', pocheTool::renderJson($entries)); @@ -157,8 +163,8 @@ function display_view($view, $id = 0, $full_head = 'yes') break; case 'view': $entry = $store->retrieveOneById($id); - if ($entry != NULL) { + pocheTool::logm('view link #' . $id); $tpl->assign('id', $entry['id']); $tpl->assign('url', $entry['url']); $tpl->assign('title', $entry['title']); @@ -177,12 +183,9 @@ function display_view($view, $id = 0, $full_head = 'yes') else { pocheTool::logm('error in view call : entry is NULL'); } - - pocheTool::logm('view link #' . $id); break; default: # home view $entries = $store->getEntriesByView($view); - $tpl->assign('entries', $entries); if ($full_head == 'yes') { @@ -192,7 +195,6 @@ function display_view($view, $id = 0, $full_head = 'yes') } $tpl->draw('entries'); - if ($full_head == 'yes') { $tpl->draw('js'); $tpl->draw('footer'); @@ -202,11 +204,11 @@ function display_view($view, $id = 0, $full_head = 'yes') } /** - * Appel d'une action (mark as fav, archive, delete) + * Call action (mark as fav, archive, delete, etc.) */ function action_to_do($action, $url, $id = 0) { - global $store, $msg; + global $store; switch ($action) { diff --git a/inc/poche/pochePictures.php b/inc/poche/pochePictures.php index bfc80657..0d73a149 100644 --- a/inc/poche/pochePictures.php +++ b/inc/poche/pochePictures.php @@ -15,11 +15,9 @@ function filtre_picture($content, $url, $id) { $matches = array(); preg_match_all('#<\s*(img)[^>]+src="([^"]*)"[^>]*>#Si', $content, $matches, PREG_SET_ORDER); - foreach($matches as $i => $link) - { + foreach($matches as $i => $link) { $link[1] = trim($link[1]); - if (!preg_match('#^(([a-z]+://)|(\#))#', $link[1]) ) - { + if (!preg_match('#^(([a-z]+://)|(\#))#', $link[1])) { $absolute_path = get_absolute_link($link[2],$url); $filename = basename(parse_url($absolute_path, PHP_URL_PATH)); $directory = create_assets_directory($id); @@ -36,8 +34,7 @@ function filtre_picture($content, $url, $id) /** * Retourne le lien absolu */ -function get_absolute_link($relative_link, $url) -{ +function get_absolute_link($relative_link, $url) { /* return if already absolute URL */ if (parse_url($relative_link, PHP_URL_SCHEME) != '') return $relative_link; @@ -68,7 +65,6 @@ function get_absolute_link($relative_link, $url) /** * Téléchargement des images */ - function download_pictures($absolute_path, $fullpath) { $rawdata = get_external_file($absolute_path); @@ -111,4 +107,4 @@ function remove_directory($directory) } return rmdir($directory); } -} +} \ No newline at end of file diff --git a/inc/poche/pocheTool.class.php b/inc/poche/pocheTools.class.php similarity index 94% rename from inc/poche/pocheTool.class.php rename to inc/poche/pocheTools.class.php index cade115e..8907c18e 100644 --- a/inc/poche/pocheTool.class.php +++ b/inc/poche/pocheTools.class.php @@ -118,7 +118,9 @@ class pocheTools public static function logm($message) { - $t = strval(date('Y/m/d_H:i:s')).' - '.$_SERVER["REMOTE_ADDR"].' - '.strval($message)."\n"; - file_put_contents('./log.txt',$t,FILE_APPEND); + if (DEBUG_POCHE) { + $t = strval(date('Y/m/d_H:i:s')) . ' - ' . $_SERVER["REMOTE_ADDR"] . ' - ' . strval($message) . "\n"; + file_put_contents('./log.txt', $t, FILE_APPEND); + } } } \ No newline at end of file -- 2.41.0