X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=1ab34193a3e8505c1a5f4f6e6ce925941210e0cc;hb=b4b7d3343ae158e9267ad7dfa9aa69f3e9e0fdf2;hp=6189e0b82c9ff4b919f65f2ef54ad1b34ff12535;hpb=4a1a1190a6c9f72f72bce7e8989541e58f366a90;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 6189e0b8..1ab34193 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ '); // Suffix to encapsulate data in PHP code. // http://server.com/x/shaarli --> /shaarli/ @@ -1490,6 +1490,7 @@ function renderPage() $PAGE = new pageBuilder; $PAGE->assign('linkcount',count($LINKSDB)); $PAGE->assign('token',getToken()); + $PAGE->assign('tags', $LINKSDB->allTags()); $PAGE->renderPage('changetag'); exit; } @@ -1633,6 +1634,7 @@ function renderPage() $PAGE->assign('link_is_new',false); $PAGE->assign('token',getToken()); // XSRF protection. $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); + $PAGE->assign('tags', $LINKSDB->allTags()); $PAGE->renderPage('editlink'); exit; } @@ -1704,6 +1706,7 @@ function renderPage() $PAGE->assign('link_is_new',$link_is_new); $PAGE->assign('token',getToken()); // XSRF protection. $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); + $PAGE->assign('tags', $LINKSDB->allTags()); $PAGE->renderPage('editlink'); exit; } @@ -2308,45 +2311,6 @@ if (!function_exists('json_encode')) { } } -// Webservices (for use with jQuery/jQueryUI) -// e.g. index.php?ws=tags&term=minecr -function processWS() -{ - if (empty($_GET['ws']) || empty($_GET['term'])) return; - $term = $_GET['term']; - $LINKSDB=new linkdb(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in). - header('Content-Type: application/json; charset=utf-8'); - - // Search in tags (case insensitive, cumulative search) - if ($_GET['ws']=='tags') - { - $tags=explode(' ',str_replace(',',' ',$term)); $last = array_pop($tags); // Get the last term ("a b c d" ==> "a b c", "d") - $addtags=''; if ($tags) $addtags=implode(' ',$tags).' '; // We will pre-pend previous tags - $suggested=array(); - /* To speed up things, we store list of tags in session */ - if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags(); - foreach($_SESSION['tags'] as $key=>$value) - { - if (startsWith($key,$last,$case=false) && !in_array($key,$tags)) $suggested[$addtags.$key.' ']=0; - } - echo json_encode(array_keys($suggested)); - exit; - } - - // Search a single tag (case sensitive, single tag search) - if ($_GET['ws']=='singletag') - { - /* To speed up things, we store list of tags in session */ - if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags(); - foreach($_SESSION['tags'] as $key=>$value) - { - if (startsWith($key,$term,$case=true)) $suggested[$key]=0; - } - echo json_encode(array_keys($suggested)); - exit; - } -} - // Re-write configuration file according to globals. // Requires some $GLOBALS to be set (login,hash,salt,title). // If the config file cannot be saved, an error message is displayed and the user is redirected to "Tools" menu. @@ -2603,7 +2567,6 @@ if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=r if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; } -if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'ws=')) { processWS(); exit; } // Webservices (for jQuery/jQueryUI) if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; renderPage(); ?>