-
-
- >home -
- >favorites -
- >archive -
- poche it ! -
diff --git a/inc/config.php b/inc/config.php index f9a4701..6d8be9e 100644 --- a/inc/config.php +++ b/inc/config.php @@ -13,4 +13,14 @@ include 'db.php'; include 'functions.php'; require_once 'Readability.php'; require_once 'Encoding.php'; +require_once 'rain.tpl.class.php'; + +$db = new db(DB_PATH); + +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(); ?> \ No newline at end of file diff --git a/inc/functions.php b/inc/functions.php index 0b9eb93..ffd400e 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -3,7 +3,7 @@ /** * Permet de générer l'URL de poche pour le bookmarklet */ -function url() +function get_poche_url() { $protocol = "http"; if(isset($_SERVER['HTTPS'])) { @@ -15,29 +15,6 @@ function url() return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } -/** - * Génération de la page "vue d'un article" - */ -function generate_page($entry) -{ - raintpl::$tpl_dir = './tpl/'; - raintpl::$cache_dir = "./cache/"; - raintpl::$base_url = url(); - raintpl::configure( 'path_replace', false ); - raintpl::configure('debug', false); - - $tpl = new raintpl(); - - $tpl->assign("id", $entry['id']); - $tpl->assign("url", $entry['url']); - $tpl->assign("title", $entry['title']); - $tpl->assign("content", $entry['content']); - $tpl->assign("is_fav", $entry['is_fav']); - $tpl->assign("is_read", $entry['is_read']); - - $tpl->draw( "index"); -} - // function define to retrieve url content function get_external_file($url, $timeout) { @@ -111,6 +88,9 @@ function get_external_file($url, $timeout) } } +/** + * Préparation de l'URL avec récupération du contenu avant insertion en base + */ function prepare_url($url) { $parametres = array(); diff --git a/index.php b/index.php index 8c695cd..ef18254 100755 --- a/index.php +++ b/index.php @@ -9,7 +9,6 @@ */ include dirname(__FILE__).'/inc/config.php'; -$db = new db(DB_PATH); $action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : ''; $view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : ''; @@ -19,15 +18,12 @@ $url = (isset ($_GET['url'])) ? $_GET['url'] : ''; switch ($action) { case 'add': - if ($url == '') continue; $parametres_url = prepare_url($url); - - $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'; + $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'; $params_action = array($url, $parametres_url['title'], $parametres_url['content']); - break; case 'delete': $sql_action = "DELETE FROM entries WHERE id=?"; @@ -80,79 +76,9 @@ catch (Exception $e) die('view query error : '.$e->getMessage()); } -?> - - - - - - -
- - - -