put the needle on the record and the dance beat goes like this...

(upstream patch by ian)
This commit is contained in:
Garvin Hicking 2016-09-23 11:13:16 +02:00
parent d156ea6567
commit 38acbfb011
16 changed files with 875 additions and 846 deletions

View file

@ -1,18 +1,30 @@
2.02
- IE CSS linklist fix
2.03 && 1.23:
-------------
2.01
- fix ul ident for csslist and simple option
- added new config option for "CSS List" usage only,
* Requirement and Consistent changes
* Use lang API
2.02:
-----
* IE CSS linklist fix
2.01:
-----
* fix ul ident for csslist and simple option
* added new config option for "CSS List" usage only,
to use a new SVG link icon by CSS (defaults true).
If set false, this will return the previous used world icon image,
which as a normal image will even work with very old and outdated browsers.
2.00
- silence cache lite non static PEAR errors on $obj->remove()
- minor preparations for the Serendipity 2.0 backend
- fix multiple dtree includements using a unique name
- add css seperators
2.00:
-----
* silence cache lite non static PEAR errors on $obj->remove()
* minor preparations for the Serendipity 2.0 backend
* fix multiple dtree includements using a unique name
* add css separators
1.99.1 - use serendipity_specialchars

View file

@ -1,4 +1,4 @@
<?php #
<?php
/**
* @version
@ -98,3 +98,4 @@
@define('PLUGIN_LINKS_USEDESC_BLAHBLAH', 'Използване на описанието на заглавието на връзката, ако има такова.');
@define('PLUGIN_LINKS_PREPEND', 'Въведете текст, който да бъде показван преди списъка на връзките.');
@define('PLUGIN_LINKS_APPEND', 'Въведете текст, който да бъде показван след списъка на връзките.');

View file

@ -105,3 +105,4 @@
@define('PLUGIN_LINKS_USEDESC_BLAHBLAH', 'Použít popis pro titulek odkazu, pokud je přítomen.');
@define('PLUGIN_LINKS_PREPEND', 'Zadej jakýkoliv text. Zobrazí se před seznamem odkazů.');
@define('PLUGIN_LINKS_APPEND', 'Zadej jakýkoliv text. Zobrazí se za seznamem odkazů.');

View file

@ -105,3 +105,4 @@
@define('PLUGIN_LINKS_USEDESC_BLAHBLAH', 'Použít popis pro titulek odkazu, pokud je přítomen.');
@define('PLUGIN_LINKS_PREPEND', 'Zadej jakýkoliv text. Zobrazí se před seznamem odkazů.');
@define('PLUGIN_LINKS_APPEND', 'Zadej jakýkoliv text. Zobrazí se za seznamem odkazů.');

View file

@ -1,4 +1,4 @@
<?php #
<?php
/**
* @version
@ -87,4 +87,3 @@
@define('PLUGIN_LINKS_STYLE', '「dtree」スタイルを使う');
@define('PLUGIN_LINKS_STYLE_BLAHBLAH', 'dtree スタイルの使用はより清潔な外観を提供しますが、リンクがロボットによって解析されることは許可しません。');
?>

View file

@ -1,4 +1,4 @@
<?php #
<?php
/**
* @version
@ -93,4 +93,4 @@
@define('PLUGIN_LINKLIST_ORDER_OUTSTYLE_SIMP_CSS', 'Prosty CSS');
@define('PLUGIN_LINKS_OUTSTYLE', 'Wybierz styl wyświetlania dla listy linków');
@define('PLUGIN_LINKS_OUTSTYLE_BLAHBLAH', 'Wybierz styl wyświetlania dla listy linków. Dtree używa javascriptu do tworzenia drzewa linków (skrypt działa we wszystkich popularnych przeglądarkach). Lista CSS używa divów i prostego javascriptu dla stworzenia efektu uzyskiwanego przez zastosowanie Dtree ale nie jest tak zaawansowany jak Dtree. Prosty CSS to metoda najlepsza jeśli chcesz by wyszukiwarki parsowały linki umieszczone na Twojej stronie. Prosty CSS wyświetli kontrolowaną przez CSS listę. UWAGA! Metody z użyciem Dtree zazwyczaj NIE umozliwiają wyszukiwarkom interentowym na parsowanie wyświetlanych przez nie linków.');
?>

View file

@ -1,4 +1,4 @@
<?php #
<?php
/**
* @version
@ -99,3 +99,4 @@
@define('PLUGIN_LINKS_USEDESC_BLAHBLAH', 'Използване на описанието на заглавието на връзката, ако има такова.');
@define('PLUGIN_LINKS_PREPEND', 'Въведете текст, който да бъде показван преди списъка на връзките.');
@define('PLUGIN_LINKS_APPEND', 'Въведете текст, който да бъде показван след списъка на връзките.');

View file

@ -105,3 +105,4 @@
@define('PLUGIN_LINKS_USEDESC_BLAHBLAH', 'Použít popis pro titulek odkazu, pokud je přítomen.');
@define('PLUGIN_LINKS_PREPEND', 'Zadej jakýkoliv text. Zobrazí se před seznamem odkazů.');
@define('PLUGIN_LINKS_APPEND', 'Zadej jakýkoliv text. Zobrazí se za seznamem odkazů.');

View file

@ -105,3 +105,4 @@
@define('PLUGIN_LINKS_USEDESC_BLAHBLAH', 'Použít popis pro titulek odkazu, pokud je přítomen.');
@define('PLUGIN_LINKS_PREPEND', 'Zadej jakýkoliv text. Zobrazí se před seznamem odkazů.');
@define('PLUGIN_LINKS_APPEND', 'Zadej jakýkoliv text. Zobrazí se za seznamem odkazů.');

View file

@ -1,4 +1,4 @@
<?php #
<?php
/**
* @version
@ -87,4 +87,3 @@
@define('PLUGIN_LINKS_STYLE', '「dtree」スタイルを使う');
@define('PLUGIN_LINKS_STYLE_BLAHBLAH', 'dtree スタイルの使用はより清潔な外観を提供しますが、リンクがロボットによって解析されることは許可しません。');
?>

View file

@ -1,4 +1,4 @@
<?php #
<?php
/**
* @version
@ -93,4 +93,4 @@
@define('PLUGIN_LINKLIST_ORDER_OUTSTYLE_SIMP_CSS', 'Prosty CSS');
@define('PLUGIN_LINKS_OUTSTYLE', 'Wybierz styl wyświetlania dla listy linków');
@define('PLUGIN_LINKS_OUTSTYLE_BLAHBLAH', 'Wybierz styl wyświetlania dla listy linków. Dtree używa javascriptu do tworzenia drzewa linków (skrypt działa we wszystkich popularnych przeglądarkach). Lista CSS używa divów i prostego javascriptu dla stworzenia efektu uzyskiwanego przez zastosowanie Dtree ale nie jest tak zaawansowany jak Dtree. Prosty CSS to metoda najlepsza jeśli chcesz by wyszukiwarki parsowały linki umieszczone na Twojej stronie. Prosty CSS wyświetli kontrolowaną przez CSS listę. UWAGA! Metody z użyciem Dtree zazwyczaj NIE umozliwiają wyszukiwarkom interentowym na parsowanie wyświetlanych przez nie linków.');
?>

View file

@ -1,3 +1,4 @@
/* serendipity_event_linklist.css start */
div.linklist span.menu_title {
@ -59,4 +60,3 @@ div.linklist a:hover {
}
/* serendipity_event_linklist.css end */

View file

@ -4,19 +4,14 @@ if (IN_serendipity !== true) {
die ("Don't hack!");
}
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
include_once dirname(__FILE__) . '/lang_en.inc.php';
class serendipity_event_linklist extends serendipity_event {
@serendipity_plugin_api::load_language(dirname(__FILE__));
class serendipity_event_linklist extends serendipity_event
{
var $title = PLUGIN_LINKLIST_TITLE;
function introspect(&$propbag) {
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', PLUGIN_LINKLIST_TITLE);
@ -30,9 +25,9 @@ class serendipity_event_linklist extends serendipity_event {
'external_plugin' => true
));
$propbag->add('author', 'Matthew Groeninger, Omid Mottaghi Rad');
$propbag->add('version', '2.02');
$propbag->add('version', '2.03');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'serendipity' => '1.6',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
@ -40,237 +35,13 @@ class serendipity_event_linklist extends serendipity_event {
$propbag->add('groups', array('FRONTEND_VIEWS', 'BACKEND_FEATURES'));
}
function decode($string) {
if (LANG_CHARSET != 'UTF-8') {
return utf8_decode($string);
}
return $string;
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'backend_sidebar_entries_event_display_linklist':
if ($this->get_config('active')!='true') {
return false;
}
if (isset($_POST['REMOVE'])) {
if (isset($_POST['serendipity']['link_to_remove'])) {
foreach ($_POST['serendipity']['link_to_remove'] as $key) {
$this->del_link($key);
}
} else {
if (isset($_POST['serendipity']['category_to_remove'])) {
foreach ($_POST['serendipity']['category_to_remove'] as $key) {
$this->del_category($key);
}
}
}
}
if (isset($_POST['SAVE'])) {
foreach ($_POST['serendipity']['link_to_recat'] AS $key => $row) {
$this->update_cat($key,$row);
}
}
if (isset($_POST['ADD'])) {
if (isset($_POST['serendipity']['add_link']['title']) && isset($_POST['serendipity']['add_link']['link'])) {
$this->add_link($_POST['serendipity']['add_link']['link'],$_POST['serendipity']['add_link']['title'],$_POST['serendipity']['add_link']['desc'],$_POST['serendipity']['link_to_recat']['cat']);
} else {
if (isset($_POST['serendipity']['add_category']['title'])) {
$this->add_cat($_POST['serendipity']['add_category']['title'],$_POST['serendipity']['link_to_recat']['cat']);
}
}
}
if (isset($_POST['EDIT'])) {
if (isset($_POST['serendipity']['add_link']['title']) && isset($_POST['serendipity']['add_link']['link'])&& isset($_POST['serendipity']['add_link']['id'])) {
$this->update_link($_POST['serendipity']['add_link']['id'],$_POST['serendipity']['add_link']['link'],$_POST['serendipity']['add_link']['title'],$_POST['serendipity']['add_link']['desc'],$_POST['serendipity']['link_to_recat']['cat']);
}
}
switch ($_GET['submit']){
case 'move up':
$this->move_up($_GET['serendipity']['link_to_move']);
break;
case 'move down':
$this->move_down($_GET['serendipity']['link_to_move']);
break;
}
if ($this->get_config('cache') == 'yes') {
if (@include_once("Cache/Lite.php")) {
$cache_obj = new Cache_Lite( array('cacheDir' => $serendipity['serendipityPath'].'templates_c/','automaticSerialization' => true));
$output = $this->generate_output(true);
$cache_obj->save($output,'linklist_cache');
} else {
$output = $this->generate_output(true);
$this->set_config('cached_output',$output);
}
}
if (isset($_GET['serendipity']['edit_link'])) {
$this->output_add_edit_linkadmin(TRUE,$_GET['serendipity']['edit_link']);
} else {
if (isset($_GET['serendipity']['manage_category'])) {
$this->output_categoryadmin(TRUE,$_GET['serendipity']['edit_link']);
} else {
$this->output_add_edit_linkadmin(FALSE);
$this->output_linkadmin();
}
}
return true;
break;
case 'backend_sidebar_entries':
if ($this->get_config('active')=='true' && $serendipity['version'][0] < 2) {
echo "\n".'<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist">' . PLUGIN_LINKLIST_ADMINLINK . '</a></li>';
}
return true;
break;
case 'backend_sidebar_admin_appearance':
if ($this->get_config('active')=='true' && $serendipity['version'][0] > 1) {
echo "\n".'<li><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist">' . PLUGIN_LINKLIST_ADMINLINK . '</a></li>';
}
return true;
break;
case 'css':
if ($this->get_config('style') == 'dtree') {
$searchstr = '.dtree';
$filename = 'serendipity_event_dtree.css';
} else {
$searchstr = '.linklist';
$filename = 'serendipity_event_linklist.css';
}
// class exists in CSS by another Plugin, or a User has customized it and we don't need default
$pos = strpos($eventData, $searchstr);
if ($pos === false) {
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
if (!$tfile || $tfile == $filename) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
$eventData .= file_get_contents($tfile);
}
return true;
break;
case 'external_plugin':
$uri_parts = explode('?', str_replace('&amp;', '&', $eventData));
$parts = explode('&', $uri_parts[0]);
$uri_part = $parts[0];
switch($uri_part) {
case 'lldtree.js': // name unique!
header('Content-Type: text/javascript');
echo file_get_contents(dirname(__FILE__).'/dtree.js');
break;
case 'linklist.js':
header('Content-Type: text/javascript');
echo file_get_contents(dirname(__FILE__).'/linklist.js');
break;
}
return true;
break;
case 'plugins_linklist_input':
$eventData['links'] = $this->generate_output(false);
return true;
break;
case 'plugins_linklist_conf':
$this->set_config('style', $eventData['style']);
$this->set_config('display', $eventData['display']);
$this->set_config('category', $eventData['category']);
$this->set_config('cache', $eventData['cache']);
$eventData['changed'] = 'false';
if ($eventData['enabled']=='true') {
if ($this->get_config('active')!='true') {
$eventData['changed'] = 'true';
$this->set_config('active','true');
$this->set_config('active','true');
$this->set_config('category','custom');
$q = 'SELECT count(id) FROM '.$serendipity['dbPrefix'].'links';
$sql = serendipity_db_query($q);
if ($sql[0][0] == 0) {
$xml = xml_parser_create('UTF-8');
xml_parse_into_struct($xml, '<list>'.serendipity_utf8_encode($eventData['links']).'</list>', $struct, $index);
xml_parser_free($xml);
$depth = -1;
for($level[]=0, $i=1, $j=1; isset($struct[$i]); $i++, $j++){
if (isset($struct[$i]['type'])){
if ($struct[$i]['type']=='open' && strtolower($struct[$i]['tag'])=='dir'){
$this->add_cat($this->decode($struct[$i]['attributes']['NAME']),$in_cat[0]);
$q = 'SELECT categoryid FROM '.$serendipity['dbPrefix'].'link_category where category_name = "'.serendipity_db_escape_string($this->decode($struct[$i]['attributes']['NAME'])).'"';
$sql = serendipity_db_query($q);
$in_cat[] = $sql[0][0];
$depth++;
} else if($struct[$i]['type']=='close' && strtolower($struct[$i]['tag'])=='dir'){
$blah = array_pop($in_cat);
$depth--;
} else if($struct[$i]['type']=='complete' && strtolower($struct[$i]['tag'])=='link'){
$this->add_link($this->decode($struct[$i]['attributes']['LINK']),$this->decode($struct[$i]['attributes']['NAME']),$this->decode($struct[$i]['attributes']['DESCRIP']),$in_cat[$depth]);
}
}
}
}
if ($eventData['cache'] == 'yes') {
if (@include_once("Cache/Lite.php")) {
$cache_obj = new Cache_Lite( array('cacheDir' => $serendipity['serendipityPath'].'templates_c/','automaticSerialization' => true));
$output = $this->generate_output(true);
$eventData['links'] = $output;
$cache_obj->save($output,'linklist_cache');
} else {
$output = $this->generate_output(true);
$eventData['links'] = $output;
$this->set_config('cached_output',$output);
}
}
}
} else {
if ($this->get_config('active') == 'true') {
$this->set_config('active', 'false');
$this->set_config('cache', 'no');
$this->set_config('display', 'category');
$eventData['links'] = $this->generate_output(true);
if (@include_once("Cache/Lite.php")) {
$cache_obj = new Cache_Lite(array('cacheDir' => $serendipity['serendipityPath'].'templates_c/','automaticSerialization' => true));
@$cache_obj->remove('linklist_cache');
} else {
$this->set_config('cached_output','');
}
$eventData['changed'] = 'true';
}
}
return true;
break;
default:
return false;
break;
}
} else {
return false;
}
}
function generate_content(&$title) {
function generate_content(&$title)
{
$title = $this->title;
}
function generate_output($ignorecache) {
function generate_output($ignorecache)
{
global $serendipity;
$cache = $this->get_config('cache');
if ($cache == 'yes' && $ignorecache == false) {
@ -388,9 +159,8 @@ class serendipity_event_linklist extends serendipity_event {
return $output;
}
function cleanup() {
function cleanup()
{
global $serendipity;
if ($this->get_config('cache') == 'yes') {
if (@include_once("Cache/Lite.php")) {
@ -405,7 +175,8 @@ class serendipity_event_linklist extends serendipity_event {
return true;
}
function install() {
function install()
{
global $serendipity;
// Create table
$q = "CREATE TABLE ".$serendipity['dbPrefix']."links (
@ -447,7 +218,8 @@ class serendipity_event_linklist extends serendipity_event {
$this->set_config('category','custom');
}
function uninstall(&$propbag) {
function uninstall(&$propbag)
{
global $serendipity;
// Drop table
$q = "DROP TABLE ".$serendipity['dbPrefix']."links";
@ -456,7 +228,227 @@ class serendipity_event_linklist extends serendipity_event {
$sql = serendipity_db_schema_import($q);
}
function add_link($link,$name,$desc,$catid = 0) {
function decode($string)
{
if (LANG_CHARSET != 'UTF-8') {
return utf8_decode($string);
}
return $string;
}
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'backend_sidebar_entries_event_display_linklist':
if (!serendipity_db_bool($this->get_config('active'))) {
return false;
}
if (isset($_POST['REMOVE'])) {
if (isset($_POST['serendipity']['link_to_remove'])) {
foreach ($_POST['serendipity']['link_to_remove'] as $key) {
$this->del_link($key);
}
} else {
if (isset($_POST['serendipity']['category_to_remove'])) {
foreach ($_POST['serendipity']['category_to_remove'] as $key) {
$this->del_category($key);
}
}
}
}
if (isset($_POST['SAVE'])) {
foreach ($_POST['serendipity']['link_to_recat'] AS $key => $row) {
$this->update_cat($key,$row);
}
}
if (isset($_POST['ADD'])) {
if (isset($_POST['serendipity']['add_link']['title']) && isset($_POST['serendipity']['add_link']['link'])) {
$this->add_link($_POST['serendipity']['add_link']['link'],$_POST['serendipity']['add_link']['title'],$_POST['serendipity']['add_link']['desc'],$_POST['serendipity']['link_to_recat']['cat']);
} else {
if (isset($_POST['serendipity']['add_category']['title'])) {
$this->add_cat($_POST['serendipity']['add_category']['title'],$_POST['serendipity']['link_to_recat']['cat']);
}
}
}
if (isset($_POST['EDIT'])) {
if (isset($_POST['serendipity']['add_link']['title']) && isset($_POST['serendipity']['add_link']['link'])&& isset($_POST['serendipity']['add_link']['id'])) {
$this->update_link($_POST['serendipity']['add_link']['id'],$_POST['serendipity']['add_link']['link'],$_POST['serendipity']['add_link']['title'],$_POST['serendipity']['add_link']['desc'],$_POST['serendipity']['link_to_recat']['cat']);
}
}
switch ($_GET['submit']){
case 'move up':
$this->move_up($_GET['serendipity']['link_to_move']);
break;
case 'move down':
$this->move_down($_GET['serendipity']['link_to_move']);
break;
}
if ($this->get_config('cache') == 'yes') {
if (@include_once("Cache/Lite.php")) {
$cache_obj = new Cache_Lite( array('cacheDir' => $serendipity['serendipityPath'].'templates_c/','automaticSerialization' => true));
$output = $this->generate_output(true);
$cache_obj->save($output,'linklist_cache');
} else {
$output = $this->generate_output(true);
$this->set_config('cached_output',$output);
}
}
if (isset($_GET['serendipity']['edit_link'])) {
$this->output_add_edit_linkadmin(TRUE,$_GET['serendipity']['edit_link']);
} else {
if (isset($_GET['serendipity']['manage_category'])) {
$this->output_categoryadmin(TRUE,$_GET['serendipity']['edit_link']);
} else {
$this->output_add_edit_linkadmin(FALSE);
$this->output_linkadmin();
}
}
break;
case 'backend_sidebar_entries':
if (serendipity_db_bool($this->get_config('active')) && $serendipity['version'][0] < 2) {
echo "\n".' <li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist">' . PLUGIN_LINKLIST_ADMINLINK . '</a></li>'."\n";
}
break;
case 'backend_sidebar_admin_appearance':
if (serendipity_db_bool($this->get_config('active')) && $serendipity['version'][0] > 1) {
echo "\n".' <li><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist">' . PLUGIN_LINKLIST_ADMINLINK . '</a></li>'."\n";
}
break;
case 'css':
if ($this->get_config('style') == 'dtree') {
$searchstr = '.dtree';
$filename = 'serendipity_event_dtree.css';
} else {
$searchstr = '.linklist';
$filename = 'serendipity_event_linklist.css';
}
// CSS class does NOT exist by user customized template styles, include default
// OR added by another Plugin
if (strpos($eventData, $searchstr) === false) {
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
if (!$tfile || $tfile == $filename) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
$eventData .= file_get_contents($tfile);
}
break;
case 'external_plugin':
$uri_parts = explode('?', str_replace('&amp;', '&', $eventData));
$parts = explode('&', $uri_parts[0]);
$uri_part = $parts[0];
switch($uri_part) {
case 'lldtree.js': // name unique!
header('Content-Type: text/javascript');
echo file_get_contents(dirname(__FILE__).'/dtree.js');
break;
case 'linklist.js':
header('Content-Type: text/javascript');
echo file_get_contents(dirname(__FILE__).'/linklist.js');
break;
}
break;
case 'plugins_linklist_input':
$eventData['links'] = $this->generate_output(false);
break;
case 'plugins_linklist_conf':
$this->set_config('style', $eventData['style']);
$this->set_config('display', $eventData['display']);
$this->set_config('category', $eventData['category']);
$this->set_config('cache', $eventData['cache']);
$eventData['changed'] = 'false';
if ($eventData['enabled']=='true') {
if (!serendipity_db_bool($this->get_config('active'))) {
$eventData['changed'] = 'true';
$this->set_config('active', 'true');
$this->set_config('category', 'custom');
$q = 'SELECT count(id) FROM '.$serendipity['dbPrefix'].'links';
$sql = serendipity_db_query($q);
if ($sql[0][0] == 0) {
$xml = xml_parser_create('UTF-8');
xml_parse_into_struct($xml, '<list>'.serendipity_utf8_encode($eventData['links']).'</list>', $struct, $index);
xml_parser_free($xml);
$depth = -1;
for($level[]=0, $i=1, $j=1; isset($struct[$i]); $i++, $j++){
if (isset($struct[$i]['type'])){
if ($struct[$i]['type']=='open' && strtolower($struct[$i]['tag'])=='dir'){
$this->add_cat($this->decode($struct[$i]['attributes']['NAME']),$in_cat[0]);
$q = 'SELECT categoryid FROM '.$serendipity['dbPrefix'].'link_category where category_name = "'.serendipity_db_escape_string($this->decode($struct[$i]['attributes']['NAME'])).'"';
$sql = serendipity_db_query($q);
$in_cat[] = $sql[0][0];
$depth++;
} else if ($struct[$i]['type']=='close' && strtolower($struct[$i]['tag'])=='dir'){
$blah = array_pop($in_cat);
$depth--;
} else if ($struct[$i]['type']=='complete' && strtolower($struct[$i]['tag'])=='link'){
$this->add_link($this->decode($struct[$i]['attributes']['LINK']),$this->decode($struct[$i]['attributes']['NAME']),$this->decode($struct[$i]['attributes']['DESCRIP']),$in_cat[$depth]);
}
}
}
}
if ($eventData['cache'] == 'yes') {
if (@include_once("Cache/Lite.php")) {
$cache_obj = new Cache_Lite( array('cacheDir' => $serendipity['serendipityPath'].'templates_c/','automaticSerialization' => true));
$output = $this->generate_output(true);
$eventData['links'] = $output;
$cache_obj->save($output,'linklist_cache');
} else {
$output = $this->generate_output(true);
$eventData['links'] = $output;
$this->set_config('cached_output',$output);
}
}
}
} else {
if (serendipity_db_bool($this->get_config('active'))) {
$this->set_config('active', 'false');
$this->set_config('cache', 'no');
$this->set_config('display', 'category');
$eventData['links'] = $this->generate_output(true);
if (@include_once("Cache/Lite.php")) {
$cache_obj = new Cache_Lite(array('cacheDir' => $serendipity['serendipityPath'].'templates_c/','automaticSerialization' => true));
@$cache_obj->remove('linklist_cache');
} else {
$this->set_config('cached_output','');
}
$eventData['changed'] = 'true';
}
}
break;
default:
return false;
}
return true;
} else {
return false;
}
}
function add_link($link,$name,$desc,$catid = 0)
{
global $serendipity;
$link = $this->clean_link($link);
@ -474,7 +466,8 @@ class serendipity_event_linklist extends serendipity_event {
serendipity_db_insert('links', $values);
}
function update_link($id, $link, $title, $desc, $catid) {
function update_link($id, $link, $title, $desc, $catid)
{
global $serendipity;
$link = $this->clean_link($link);
@ -487,7 +480,8 @@ class serendipity_event_linklist extends serendipity_event {
serendipity_db_update('links', $key, $values);
}
function del_link($id) {
function del_link($id)
{
global $serendipity;
$q = 'SELECT order_num FROM '.$serendipity['dbPrefix'].'links where id='.(int)$id;
@ -504,7 +498,8 @@ class serendipity_event_linklist extends serendipity_event {
}
}
function add_cat($name,$parent) {
function add_cat($name,$parent)
{
global $serendipity;
$values['category_name'] = $name;
@ -512,7 +507,8 @@ class serendipity_event_linklist extends serendipity_event {
serendipity_db_insert('link_category', $values);
}
function del_category($id) {
function del_category($id)
{
global $serendipity;
$q = 'DELETE FROM '.$serendipity['dbPrefix'].'link_category where categoryid='.(int)$id;
$sql = serendipity_db_query($q);
@ -522,14 +518,16 @@ class serendipity_event_linklist extends serendipity_event {
serendipity_db_update('links', $key, $values);
}
function update_cat($id,$cat) {
function update_cat($id,$cat)
{
global $serendipity;
$q = 'UPDATE '.$serendipity['dbPrefix'].'links SET category = '.serendipity_db_escape_string($cat).' where id = '.(int)$id;
$sql = serendipity_db_query($q);
}
function move_up($id) {
function move_up($id)
{
global $serendipity;
$q = 'SELECT order_num FROM '.$serendipity['dbPrefix'].'links where id='.(int)$id;
$sql = serendipity_db_query($q);
@ -548,7 +546,8 @@ class serendipity_event_linklist extends serendipity_event {
}
}
function move_down($id) {
function move_down($id)
{
global $serendipity;
$q = 'SELECT count(id) AS countit FROM '.$serendipity['dbPrefix'].'links';
@ -578,8 +577,8 @@ class serendipity_event_linklist extends serendipity_event {
}
}
function output_linkadmin() {
function output_linkadmin()
{
global $serendipity;
$display = $this->get_config('display');
$q = $this->set_query($display);
@ -660,7 +659,8 @@ class serendipity_event_linklist extends serendipity_event {
return $x . "</select>\n";
}
function output_add_edit_linkadmin($edit = FALSE,$id = -1) {
function output_add_edit_linkadmin($edit = FALSE,$id = -1)
{
global $serendipity;
$display = $this->get_config('display');
$categories = $this->build_categories();
@ -703,7 +703,8 @@ class serendipity_event_linklist extends serendipity_event {
</form>';
}
function output_categoryadmin() {
function output_categoryadmin()
{
global $serendipity;
$display = $this->get_config('display');
$categories = $this->build_categories();
@ -771,7 +772,8 @@ class serendipity_event_linklist extends serendipity_event {
}
function set_query($display) {
function set_query($display)
{
global $serendipity;
$q = 'SELECT s.link AS link,
s.title AS name,
@ -801,7 +803,8 @@ class serendipity_event_linklist extends serendipity_event {
return $q;
}
function build_categories() {
function build_categories()
{
global $serendipity;
if ($this->get_config('category') == 'custom') {
$table = $serendipity['dbPrefix'].'link_category';
@ -822,7 +825,8 @@ class serendipity_event_linklist extends serendipity_event {
return $categories;
}
function clean_link($link) {
function clean_link($link)
{
$parts_arr = parse_url($link);
if (strcmp($parts_arr['pass'], '') != 0) {
$ret_url .= $parts_arr['user'];
@ -846,5 +850,8 @@ class serendipity_event_linklist extends serendipity_event {
}
return $ret_url;
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>

View file

@ -4,13 +4,7 @@ if (IN_serendipity !== true) {
die ("Don't hack!");
}
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
include_once dirname(__FILE__) . '/lang_en.inc.php';
@serendipity_plugin_api::load_language(dirname(__FILE__));
class serendipity_plugin_linklist extends serendipity_plugin
{
@ -24,7 +18,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
$propbag->add('description', PLUGIN_LINKS_BLAHBLAH);
$propbag->add('stackable', true);
$propbag->add('author', 'Matthew Groeninger, Omid Mottaghi Rad');
$propbag->add('version', '1.22');
$propbag->add('version', '1.23');
$propbag->add('stackable', false);
$propbag->add('configuration', array(
'title',
@ -55,7 +49,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
'imgdir'));
$this->protected = TRUE; // If set to TRUE, only allows the owner of the plugin to modify its configuration
$propbag->add('requirements', array(
'serendipity' => '0.8',
'serendipity' => '1.6',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
@ -63,9 +57,12 @@ class serendipity_plugin_linklist extends serendipity_plugin
$propbag->add('groups', array('FRONTEND_FEATURES'));
}
function introspect_config_item($name, &$propbag) {
function introspect_config_item($name, &$propbag)
{
global $serendipity;
switch($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_LINKS_TITLE);
@ -103,7 +100,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
break;
case 'links':
if($this->get_config('directxml') == 'true') {
if (serendipity_db_bool($this->get_config('directxml', 'true'))) {
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_LINKS_LINKS);
$propbag->add('description', PLUGIN_LINKS_LINKS_BLAHBLAH);
@ -113,7 +110,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
break;
case 'display':
if($this->get_config('directxml') != 'true') {
if (!serendipity_db_bool($this->get_config('directxml', 'true'))) {
$select = array();
$select["alpha"] = PLUGIN_LINKLIST_ORDER_ALPHA;
$select["category"] = PLUGIN_LINKLIST_ORDER_CATEGORY;
@ -129,7 +126,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
break;
case 'category':
if($this->get_config('directxml') != 'true') {
if (!serendipity_db_bool($this->get_config('directxml', 'true'))) {
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_LINKLIST_CATEGORY_NAME);
$propbag->add('description', PLUGIN_LINKLIST_CATEGORY_NAME_DESC);
@ -322,7 +319,8 @@ class serendipity_plugin_linklist extends serendipity_plugin
return true;
}
function decode($string) {
function decode($string)
{
if (LANG_CHARSET != 'UTF-8') {
return utf8_decode($string);
}
@ -335,7 +333,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
global $serendipity;
$title = $this->get_config('title');
if(!$this->get_config('directxml')) {
if (!serendipity_db_bool($this->get_config('directxml', 'true'))) {
serendipity_plugin_api::hook_event('plugins_linklist_input', $linkcode);
$this->set_config('links',$linkcode['links']);
}
@ -366,13 +364,15 @@ class serendipity_plugin_linklist extends serendipity_plugin
}
function gen_output($links, $style) {
function gen_output($links, $style)
{
global $serendipity;
$imgdir = $this->get_config('imgdir');
$use_descrip = $this->get_config('use_description',false);
$use_descrip = serendipity_db_bool($this->get_config('use_description', 'false'));
/* XML definitaion */
/* XML definition */
$xml = xml_parser_create('UTF-8');
$linkxml = serendipity_utf8_encode($links);
xml_parse_into_struct($xml, '<list>' . $linkxml . '</list>', $struct, $index);
@ -385,9 +385,10 @@ class serendipity_plugin_linklist extends serendipity_plugin
$str = $this->get_config('prepend_text');
$str .= "\n\n";
if ($style == "dtree") {
$str .= "\n".'<script src="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/lldtree.js" type="text/javascript"></script>'."\n";
#$str .= "\n".'<script src="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/lldtree.js" type="text/javascript"></script>'."\n";
$str .= "\n".'<script type="text/javascript" src="'.$serendipity['serendipityHTTPPath'] . 'plugins/serendipity_event_linklist/lldtree.js"></script>'."\n";
if ($this->get_config('showOpenAndCloseLinks')=='true' && $this->get_config('locationOfOpenAndClose')=='top'){
if (serendipity_db_bool($this->get_config('showOpenAndCloseLinks', 'true')) && $this->get_config('locationOfOpenAndClose') == 'top'){
$str .= '<p><a href="javascript: d.openAll();">'.$this->get_config('openAllText').'</a> | <a href="javascript: d.closeAll();">'.$this->get_config('closeAllText').'</a></p>';
}
@ -396,12 +397,12 @@ class serendipity_plugin_linklist extends serendipity_plugin
d = new dTree("d","'.$imgdir.'");'."\n";
/* configuration section*/
if ($this->get_config('useSelection') != true) $str.='d.config.useSelection=false;'."\n";
if ($this->get_config('useCookies') != true) $str.='d.config.useCookies=false;'."\n";
if ($this->get_config('useLines') != true) $str.='d.config.useLines=false;'."\n";
if ($this->get_config('useIcons') != true) $str.='d.config.useIcons=false;'."\n";
if ($this->get_config('useStatusText') == true) $str.='d.config.useStatusText=true;'."\n";
if ($this->get_config('closeSameLevel') == true) $str.='d.config.closeSameLevel=true;'."\n";
if (!serendipity_db_bool($this->get_config('useSelection', 'false'))) $str.='d.config.useSelection=false;'."\n";
if (!serendipity_db_bool($this->get_config('useCookies', 'false'))) $str.='d.config.useCookies=false;'."\n";
if (!serendipity_db_bool($this->get_config('useLines', 'true'))) $str.='d.config.useLines=false;'."\n";
if (!serendipity_db_bool($this->get_config('useIcons', 'true'))) $str.='d.config.useIcons=false;'."\n";
if (serendipity_db_bool($this->get_config('useStatusText', 'true'))) $str.='d.config.useStatusText=true;'."\n";
if (serendipity_db_bool($this->get_config('closeSameLevel', 'false'))) $str.='d.config.closeSameLevel=true;'."\n";
$my_target = $this->get_config('target');
if (!empty($my_target)) {
$str .= 'd.config.target="'.$my_target.'";'."\n";
@ -434,12 +435,12 @@ class serendipity_plugin_linklist extends serendipity_plugin
//-->
</script>';
if($this->get_config('showOpenAndCloseLinks')=='true' && $this->get_config('locationOfOpenAndClose')=='bottom'){
if (serendipity_db_bool($this->get_config('showOpenAndCloseLinks', 'true')) && $this->get_config('locationOfOpenAndClose') == 'bottom'){
$str.='<p><a href="javascript: d.openAll();">'.$this->get_config('openAllText').'</a> | <a href="javascript: d.closeAll();">'.$this->get_config('closeAllText').'</a></p>';
}
} else {
if($this->get_config('call_markup') != 'true') {
if (!serendipity_db_bool($this->get_config('call_markup', 'false'))) {
$delimiter = "\n";
} else {
$delimiter = "";
@ -479,19 +480,19 @@ class serendipity_plugin_linklist extends serendipity_plugin
}
/* ???
//Process array into output
if ($this->get_config('useIcons')) {
if (serendipity_db_bool($this->get_config('useIcons', 'true'))) {
} else {
}
*/
$imagear['imgdir'] = $imgdir;
$imagear['uselines'] = $this->get_config('useLines');
$imagear['useicons'] = $this->get_config('useIcons');
$imagear['uselines'] = serendipity_db_bool($this->get_config('useLines', 'true'));
$imagear['useicons'] = serendipity_db_bool($this->get_config('useIcons', 'true'));
if ($imagear['useicons']) {
$imagear['folder'] = '/img/folder.gif';
$imagear['folderopen'] = '/img/folderopen.gif';
$imagear['page'] = '/img/page.gif';
}
if ($this->get_config('useLines')) {
if (serendipity_db_bool($this->get_config('useLines', 'true'))) {
$imagear['line'] = '/img/line.gif';
$imagear['join'] = '/img/join.gif';
$imagear['joinBottom'] = '/img/joinbottom.gif';
@ -512,7 +513,8 @@ class serendipity_plugin_linklist extends serendipity_plugin
}
if (!$lessformatting) {
$str .= '<script src="'.$serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '').'plugin/linklist.js" type="text/javascript"></script>'."\n";
#$str .= '<script src="'.$serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '').'plugin/linklist.js" type="text/javascript"></script>'."\n";
$str .= '<script type="text/javascript" src="'.$serendipity['serendipityHTTPPath'] . 'plugins/serendipity_event_linklist/linklist.js"></script>'."\n";
}
$class = !$lessformatting ? 'csslist' : 'simple';
$str .= '<div class="linklist"><ul class="'. $class .'">'.$delimiter;
@ -523,7 +525,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
$str .= $this->get_config('append_text');
if ($this->get_config('call_markup') == 'true') {
if (serendipity_db_bool($this->get_config('call_markup', 'false'))) {
$entry = array('html_nugget' => $str);
serendipity_plugin_api::hook_event('frontend_display', $entry);
return $entry['html_nugget'];
@ -533,7 +535,8 @@ class serendipity_plugin_linklist extends serendipity_plugin
}
function cleanup() {
function cleanup()
{
$cache = $this->get_config('cache');
if ($this->get_config('cache') == 'no') {
@ -548,7 +551,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
'style' => $this->get_config('style'),
'cache' => $cache);
if($this->get_config('directxml') != 'true') {
if (!serendipity_db_bool($this->get_config('directxml', 'true'))) {
$blah = $this->get_config('display');
if (!isset($blah)) {
$this->set_config('display','category');
@ -565,7 +568,8 @@ class serendipity_plugin_linklist extends serendipity_plugin
}
function build_tree ($fullarray, $rootdir, $imagearray, $more_track, $strtemp = "", $lessformatting = NULL, $delimiter = "\n", $use_descrip = false) {
function build_tree ($fullarray, $rootdir, $imagearray, $more_track, $strtemp = "", $lessformatting = NULL, $delimiter = "\n", $use_descrip = false)
{
$imgdir = $imagearray['imgdir'];
$uselines = $imagearray['uselines'];
$useicons = $imagearray['useicons'];
@ -632,7 +636,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
}
}
if ($useicons) {
if (serendipity_db_bool($this->get_config('useSVG', true))) {
if (serendipity_db_bool($this->get_config('useSVG', 'true'))) {
$page_icon = '<img class="svg"/>';
} else {
$page_icon = '<img src="'.$imgdir.$imagearray['page'].'" alt="" />';
@ -662,6 +666,8 @@ class serendipity_plugin_linklist extends serendipity_plugin
}
return $strtemp;
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>