diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 43 |
1 files changed, 3 insertions, 40 deletions
@@ -1491,6 +1491,7 @@ function renderPage() | |||
1491 | $PAGE = new pageBuilder; | 1491 | $PAGE = new pageBuilder; |
1492 | $PAGE->assign('linkcount',count($LINKSDB)); | 1492 | $PAGE->assign('linkcount',count($LINKSDB)); |
1493 | $PAGE->assign('token',getToken()); | 1493 | $PAGE->assign('token',getToken()); |
1494 | $PAGE->assign('tags', $LINKSDB->allTags()); | ||
1494 | $PAGE->renderPage('changetag'); | 1495 | $PAGE->renderPage('changetag'); |
1495 | exit; | 1496 | exit; |
1496 | } | 1497 | } |
@@ -1634,6 +1635,7 @@ function renderPage() | |||
1634 | $PAGE->assign('link_is_new',false); | 1635 | $PAGE->assign('link_is_new',false); |
1635 | $PAGE->assign('token',getToken()); // XSRF protection. | 1636 | $PAGE->assign('token',getToken()); // XSRF protection. |
1636 | $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); | 1637 | $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); |
1638 | $PAGE->assign('tags', $LINKSDB->allTags()); | ||
1637 | $PAGE->renderPage('editlink'); | 1639 | $PAGE->renderPage('editlink'); |
1638 | exit; | 1640 | exit; |
1639 | } | 1641 | } |
@@ -1705,6 +1707,7 @@ function renderPage() | |||
1705 | $PAGE->assign('link_is_new',$link_is_new); | 1707 | $PAGE->assign('link_is_new',$link_is_new); |
1706 | $PAGE->assign('token',getToken()); // XSRF protection. | 1708 | $PAGE->assign('token',getToken()); // XSRF protection. |
1707 | $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); | 1709 | $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); |
1710 | $PAGE->assign('tags', $LINKSDB->allTags()); | ||
1708 | $PAGE->renderPage('editlink'); | 1711 | $PAGE->renderPage('editlink'); |
1709 | exit; | 1712 | exit; |
1710 | } | 1713 | } |
@@ -2309,45 +2312,6 @@ if (!function_exists('json_encode')) { | |||
2309 | } | 2312 | } |
2310 | } | 2313 | } |
2311 | 2314 | ||
2312 | // Webservices (for use with jQuery/jQueryUI) | ||
2313 | // e.g. index.php?ws=tags&term=minecr | ||
2314 | function processWS() | ||
2315 | { | ||
2316 | if (empty($_GET['ws']) || empty($_GET['term'])) return; | ||
2317 | $term = $_GET['term']; | ||
2318 | $LINKSDB=new linkdb(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in). | ||
2319 | header('Content-Type: application/json; charset=utf-8'); | ||
2320 | |||
2321 | // Search in tags (case insensitive, cumulative search) | ||
2322 | if ($_GET['ws']=='tags') | ||
2323 | { | ||
2324 | $tags=explode(' ',str_replace(',',' ',$term)); $last = array_pop($tags); // Get the last term ("a b c d" ==> "a b c", "d") | ||
2325 | $addtags=''; if ($tags) $addtags=implode(' ',$tags).' '; // We will pre-pend previous tags | ||
2326 | $suggested=array(); | ||
2327 | /* To speed up things, we store list of tags in session */ | ||
2328 | if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags(); | ||
2329 | foreach($_SESSION['tags'] as $key=>$value) | ||
2330 | { | ||
2331 | if (startsWith($key,$last,$case=false) && !in_array($key,$tags)) $suggested[$addtags.$key.' ']=0; | ||
2332 | } | ||
2333 | echo json_encode(array_keys($suggested)); | ||
2334 | exit; | ||
2335 | } | ||
2336 | |||
2337 | // Search a single tag (case sensitive, single tag search) | ||
2338 | if ($_GET['ws']=='singletag') | ||
2339 | { | ||
2340 | /* To speed up things, we store list of tags in session */ | ||
2341 | if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags(); | ||
2342 | foreach($_SESSION['tags'] as $key=>$value) | ||
2343 | { | ||
2344 | if (startsWith($key,$term,$case=true)) $suggested[$key]=0; | ||
2345 | } | ||
2346 | echo json_encode(array_keys($suggested)); | ||
2347 | exit; | ||
2348 | } | ||
2349 | } | ||
2350 | |||
2351 | // Re-write configuration file according to globals. | 2315 | // Re-write configuration file according to globals. |
2352 | // Requires some $GLOBALS to be set (login,hash,salt,title). | 2316 | // Requires some $GLOBALS to be set (login,hash,salt,title). |
2353 | // If the config file cannot be saved, an error message is displayed and the user is redirected to "Tools" menu. | 2317 | // If the config file cannot be saved, an error message is displayed and the user is redirected to "Tools" menu. |
@@ -2604,7 +2568,6 @@ if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=r | |||
2604 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } | 2568 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } |
2605 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } | 2569 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } |
2606 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; } | 2570 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; } |
2607 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'ws=')) { processWS(); exit; } // Webservices (for jQuery/jQueryUI) | ||
2608 | if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; | 2571 | if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; |
2609 | renderPage(); | 2572 | renderPage(); |
2610 | ?> | 2573 | ?> |