linklist bugfix update

This commit is contained in:
Ian 2015-06-02 19:03:36 +02:00
parent 82cf98b3ba
commit 8be5a8a643
7 changed files with 495 additions and 462 deletions

View file

@ -1 +1,11 @@
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
1.99.1 - use serendipity_specialchars
1.99 - compat fixes
1.98 - remove short tag occurences

View file

@ -1,5 +1,5 @@
function hide_unhide(thing, path, lines, icons, bottom){
nav=document.getElementById(thing).style
nav=document.getElementById(thing).style;
if (lines) {
if (bottom) {
plus = path + '/img/plus.gif';

View file

@ -33,3 +33,6 @@
.dtree .clip {
overflow: hidden;
}
/* linklist dtree end */

View file

@ -1,3 +1,5 @@
/* serendipity_event_linklist.css start */
div.linklist span.menu_title {
}
@ -26,7 +28,6 @@ div.linklist li {
white-space: nowrap;
}
div.linklist img {
border: 0px;
vertical-align: middle;
@ -40,3 +41,6 @@ div.linklist a.link {
div.linklist a:hover {
color: #333;
}
/* serendipity_event_linklist.css end */

View file

@ -1,5 +1,4 @@
<?php #
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
@ -24,13 +23,14 @@ class serendipity_event_linklist extends serendipity_event {
$propbag->add('description', PLUGIN_LINKLIST_DESC);
$propbag->add('event_hooks', array('backend_sidebar_entries_event_display_linklist' => true,
'backend_sidebar_entries' => true,
'backend_sidebar_admin_appearance' => true,
'plugins_linklist_input' => true,
'css' => true,
'plugins_linklist_conf' => true,
'external_plugin' => true
));
$propbag->add('author', 'Matthew Groeninger, Omid Mottaghi Rad');
$propbag->add('version', '1.99.1');
$propbag->add('version', '2.00');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
@ -128,34 +128,41 @@ class serendipity_event_linklist extends serendipity_event {
break;
case 'backend_sidebar_entries':
if ($this->get_config('active')=='true') {
echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist">'.PLUGIN_LINKLIST_ADMINLINK.'</a></li>';
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") {
if ($this->get_config('style') == 'dtree') {
$searchstr = '.dtree';
$filename = "serendipity_event_dtree.css";
$filename = 'serendipity_event_dtree.css';
} else {
$searchstr = '.linklist';
$filename = "serendipity_event_linklist.css";
$filename = 'serendipity_event_linklist.css';
}
if (stristr($eventData, $searchstr)) {
// class exists in CSS, so a user has customized it and we don't need default
if (strpos($eventData, $searchstr)) {
// class exists in CSS by another Plugin, or a user has customized it and we don't need default
return true;
break;
}
$out = serendipity_getTemplateFile($filename, 'serendipityPath');
if ($out && $out != $filename) {
$eventData .= file_get_contents($out);
} else {
$eventData .= file_get_contents(dirname(__FILE__) . '/'.$filename);
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
if (!$tfile || $tfile == $filename) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
echo file_get_contents($tfile);
return true;
break;
@ -164,7 +171,7 @@ class serendipity_event_linklist extends serendipity_event {
$parts = explode('&', $uri_parts[0]);
$uri_part = $parts[0];
switch($uri_part) {
case 'dtree.js':
case 'lldtree.js': // name unique!
header('Content-Type: text/javascript');
echo file_get_contents(dirname(__FILE__).'/dtree.js');
break;
@ -178,6 +185,7 @@ class serendipity_event_linklist extends serendipity_event {
case 'plugins_linklist_input':
$eventData['links'] = $this->generate_output(false);
return true;
break;
@ -202,8 +210,8 @@ class serendipity_event_linklist extends serendipity_event {
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'){
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);
@ -239,13 +247,14 @@ class serendipity_event_linklist extends serendipity_event {
$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');
@$cache_obj->remove('linklist_cache');
} else {
$this->set_config('cached_output','');
}
$eventData['changed'] = 'true';
}
}
return true;
break;
@ -577,7 +586,7 @@ class serendipity_event_linklist extends serendipity_event {
$q = $this->set_query($display);
$categories = $this->build_categories();
echo '<h3>'.PLUGIN_LINKLIST_ADMINLINK.'</h3>';
echo '<h3>'.PLUGIN_LINKLIST_ADMINLINK.'</h3>'."\n\n";
?>
<form action="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist" method="post">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
@ -632,14 +641,14 @@ class serendipity_event_linklist extends serendipity_event {
<?php
$sort_idx++;
}
echo '<br />';
echo '</table>';
echo '<div>';
echo '<input type="submit" name="REMOVE" title="'.REMOVE.'" value="'.DELETE.'" class="serendipityPrettyButton input_button" />';
echo '&nbsp;';
echo '<input type="submit" name="SAVE" title="'.SAVE.'" value="'.SAVE.'" class="serendipityPrettyButton input_button" />';
echo '</div>';
echo '</form>';
echo '
</table>
<div>
<input type="submit" name="REMOVE" title="'.REMOVE.'" value="'.DELETE.'" class="serendipityPrettyButton input_button state_cancel" />
<span>&nbsp;</span>
<input type="submit" name="SAVE" title="'.SAVE.'" value="'.SAVE.'" class="serendipityPrettyButton input_button" />
</div>
</form>';
}
}
@ -687,11 +696,12 @@ class serendipity_event_linklist extends serendipity_event {
<tr><td valign="top"><?php echo PLUGIN_LINKLIST_LINKDESC; ?></td><td><textarea style="width: 100%" name="serendipity[add_link][desc]" id="serendipity[add_link][desc]" cols="80" rows="3"><?php echo $desc; ?></textarea></td></tr>
<?php
echo '</table>';
echo '<div>';
echo $button;
echo '</div>';
echo '</form>';
echo '
</table>
<div>
' . $button . '
</div>
</form>';
}
function output_categoryadmin() {
@ -699,25 +709,31 @@ class serendipity_event_linklist extends serendipity_event {
$display = $this->get_config('display');
$categories = $this->build_categories();
$maintitle = PLUGIN_LINKLIST_ADD_CAT;
$button = '<input type="submit" name="ADD" title="'.ADD.'" value="'.ADD.'" class="serendipityPrettyButton input_button" />';
$button = '<input type="submit" name="ADD" title="' . ADD . '" value="' . ADD . '" class="serendipityPrettyButton input_button" />';
echo '<h3>'.$maintitle.'</h3>';
?>
<form action="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist&amp;serendipity[manage_category]=1" method="post">
<input type="hidden" name="serendipity[add_link][id]" value="<?php echo $id; ?>">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr><td><?php echo PLUGIN_LINKLIST_CAT_NAME; ?></td><td><input class="input_textbox" type="text" name="serendipity[add_category][title]" size="30" /></td></tr>
<tr><td><?php echo PLUGIN_LINKLIST_PARENT_CATEGORY; ?></td><td><?php echo $this->category_box('cat',$categories,$cat); ?></td></tr>
<tr>
<td><?php echo PLUGIN_LINKLIST_CAT_NAME; ?></td>
<td><input class="input_textbox" type="text" name="serendipity[add_category][title]" size="30" /></td>
</tr>
<tr>
<td><?php echo PLUGIN_LINKLIST_PARENT_CATEGORY; ?></td>
<td><?php echo $this->category_box('cat',$categories,$cat); ?></td>
</tr>
<?php
echo '</table>';
echo '<div>';
echo $button;
echo '</div>';
echo '</form>';
echo '
</table>
<div>
' . $button . '
</div>
</form>
echo '<h3>'.PLUGIN_LINKLIST_ADMINCAT.'</h3>';
echo '<a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist">'.PLUGIN_LINKLIST_ADMINLINK.'</a>';
<h3>' . PLUGIN_LINKLIST_ADMINCAT . '</h3>
<a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist">' . PLUGIN_LINKLIST_ADMINLINK . '</a>';
?>
<form action="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist&amp;serendipity[manage_category]=1" method="post">
@ -739,17 +755,19 @@ class serendipity_event_linklist extends serendipity_event {
<td width="16">
<input class="input_checkbox" type="checkbox" name="serendipity[category_to_remove][]" value="<?php echo $category['categoryid']; ?>" />
</td>
<td width="300" style="padding-left: <?php echo ($category['depth']*15)+20 ?>px"><img src="<?php echo serendipity_getTemplateFile('admin/img/folder.png') ?>" style="vertical-align: bottom;"> <?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($category['category_name']) : htmlspecialchars($category['category_name'], ENT_COMPAT, LANG_CHARSET)) ?></td>
<td width="300" style="padding-left: <?php echo ($category['depth']*15)+20 ?>px">
<img src="<?php echo serendipity_getTemplateFile('admin/img/folder.png') ?>" style="vertical-align: bottom;"> <?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($category['category_name']) : htmlspecialchars($category['category_name'], ENT_COMPAT, LANG_CHARSET)) ?>
</td>
</tr>
<?php
}
echo '<br />';
echo '</table>';
echo '<div>';
echo '<input type="submit" name="REMOVE" title="'.REMOVE.'" value="'.DELETE.'" class="serendipityPrettyButton input_button" />';
echo '</div>';
echo '<div style="font-size: smaller;">'.PLUGIN_LINKLIST_DELETE_WARN.'</div>';
echo '</form>';
echo '
</table>
<div>
<input type="submit" name="REMOVE" title="' . REMOVE . '" value="' . DELETE . '" class="serendipityPrettyButton input_button state_cancel" />
</div>
<div style="font-size: smaller;">' . PLUGIN_LINKLIST_DELETE_WARN . '</div>
</form>';
}

View file

@ -1,5 +1,4 @@
<?php #
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
@ -25,7 +24,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.20');
$propbag->add('version', '1.21');
$propbag->add('stackable', false);
$propbag->add('configuration', array(
'title',
@ -373,33 +372,32 @@ class serendipity_plugin_linklist extends serendipity_plugin
}
$str = $this->get_config('prepend_text');
$str.="\n\n";
$str .= "\n\n";
if ($style == "dtree") {
$str.='<script src="'.$serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '').'plugin/dtree.js" type="text/javascript"></script>';
$str .= "\n".'<script src="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/lldtree.js" type="text/javascript"></script>'."\n";
if($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>';
if ($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>';
}
$str.='<script type="text/javascript">
$str .= '<script type="text/javascript">
<!--
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 ($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";
$my_target = $this->get_config('target');
if (!empty($my_target)) {
$str.='d.config.target="'.$my_target.'";'."\n";
$str .= 'd.config.target="'.$my_target.'";'."\n";
}
/* Add Directory and Links */
$str.='d.add(0,-1,"'.$this->get_config('top_level').'");'."\n";
$str .= 'd.add(0,-1,"'.$this->get_config('top_level').'");'."\n";
for($level[]=0, $i=1, $j=1; isset($struct[$i]); $i++, $j++){
if(isset($struct[$i]['type'])){
@ -430,7 +428,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
}
} else {
if($this->get_config('call_markup')!='true') {
if($this->get_config('call_markup') != 'true') {
$delimiter = "\n";
} else {
$delimiter = "";
@ -444,26 +442,26 @@ class serendipity_plugin_linklist extends serendipity_plugin
$link_array = array();
$dirname = array();
$level = array();
$dir_array['']=array('dirname'=>'','level'=>1,linkcount=>0,'links'=>$link_array,'dircount'=>0,'directories'=>$link_array);
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'){
$dir_array[''] = array('dirname' => '','level' => 1,linkcount => 0,'links' => $link_array,'dircount' => 0,'directories' => $link_array);
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'){
$dir_array[$dirname[0]]['directories'][] = $this->decode($struct[$i]['attributes']['NAME']);
$dir_array[$dirname[0]]['dircount']++;
array_unshift($dirname, $this->decode($struct[$i]['attributes']['NAME']));
array_unshift($level,$j);
$dir_array[$dirname[0]] = array('dirname'=>$dirname[0],'level'=>count($level),'linkcount'=>0,'links'=>$link_array,'dircount'=>0,'directories'=>$link_array);
} else if($struct[$i]['type']=='close' && strtolower($struct[$i]['tag'])=='dir'){
$dir_array[$dirname[0]] = array('dirname' => $dirname[0],'level' => count($level),'linkcount' => 0,'links' => $link_array,'dircount' => 0,'directories' => $link_array);
} else if($struct[$i]['type'] == 'close' && strtolower($struct[$i]['tag']) == 'dir'){
$dump=array_shift($dirname);
$dump=array_shift($level);
} else if($struct[$i]['type']=='complete' && strtolower($struct[$i]['tag'])=='link'){
} else if($struct[$i]['type'] == 'complete' && strtolower($struct[$i]['tag']) == 'link'){
$dir_array[$dirname[0]]['linkcount']++;
if (count($level) == 0) {
$level_pass = 1;
} else {
$level_pass = count($level)+1;
}
$basic_array = array('linkloc'=>$this->decode($struct[$i]['attributes']['LINK']),'name'=>$this->decode($struct[$i]['attributes']['NAME']),'descr'=>$this->decode($struct[$i]['attributes']['DESCRIP']),'level'=>$level_pass,'dirname'=>$dirname,'hcard'=>$this->decode($struct[$i]['attributes']['HCARD']),'rel'=>$this->decode($struct[$i]['attributes']['REL']));
$basic_array = array('linkloc' => $this->decode($struct[$i]['attributes']['LINK']),'name' => $this->decode($struct[$i]['attributes']['NAME']),'descr' => $this->decode($struct[$i]['attributes']['DESCRIP']),'level' => $level_pass,'dirname' => $dirname,'hcard' => $this->decode($struct[$i]['attributes']['HCARD']),'rel' => $this->decode($struct[$i]['attributes']['REL']));
$dir_array[$dirname[0]]['links'][] = $basic_array;
}
}
@ -487,8 +485,8 @@ class serendipity_plugin_linklist extends serendipity_plugin
$imagear['plus'] = '/img/plus.gif';
$imagear['plusBottom'] = '/img/plusbottom.gif';
$imagear['minus'] = '/img/minus.gif';
$imagear['minusBottom']= '/img/minusbottom.gif';
$imagear['empty_image']= '/img/empty.gif';
$imagear['minusBottom'] = '/img/minusbottom.gif';
$imagear['empty_image'] = '/img/empty.gif';
} else {
$imagear['line'] = '/img/empty.gif';
$imagear['join'] = '/img/empty.gif';
@ -496,12 +494,12 @@ class serendipity_plugin_linklist extends serendipity_plugin
$imagear['plus'] = '/img/nolines_plus.gif';
$imagear['plusBottom'] = '/img/nolines_plus.gif';
$imagear['minus'] = '/img/nolines_minus.gif';
$imagear['minusBottom']= '/img/nolines_minus.gif';
$imagear['empty_image']= '/img/empty.gif';
$imagear['minusBottom'] = '/img/nolines_minus.gif';
$imagear['empty_image'] = '/img/empty.gif';
}
if (!$lessformatting) {
$str.='<script src="'.$serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '').'plugin/linklist.js" type="text/javascript"></script>';
$str .= '<script src="'.$serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '').'plugin/linklist.js" type="text/javascript"></script>';
}
$str .= '<div class="linklist"><ul>'.$delimiter;
@ -510,9 +508,9 @@ class serendipity_plugin_linklist extends serendipity_plugin
$str .= '</ul></div>';
}
$str.=$this->get_config('append_text');
$str .= $this->get_config('append_text');
if($this->get_config('call_markup')=='true') {
if ($this->get_config('call_markup') == 'true') {
$entry = array('html_nugget' => $str);
serendipity_plugin_api::hook_event('frontend_display', $entry);
return $entry['html_nugget'];
@ -528,8 +526,8 @@ class serendipity_plugin_linklist extends serendipity_plugin
if ($this->get_config('cache') == 'no') {
if (@include_once("Cache/Lite.php")) {
$cache_obj = new Cache_Lite( array('cacheDir' => $serendipity['serendipityPath'].'templates_c/','automaticSerialization' => true));
$cache_obj->remove('linklist_html');
$cache_obj->remove('linklist_xmlhash');
@$cache_obj->remove('linklist_html');
@$cache_obj->remove('linklist_xmlhash');
}
}
$setdata = array('display' => $this->get_config('display'),
@ -537,7 +535,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
'style' => $this->get_config('style'),
'cache' => $cache);
if($this->get_config('directxml')!='true') {
if($this->get_config('directxml') != 'true') {
$blah = $this->get_config('display');
if (!isset($blah)) {
$this->set_config('display','category');
@ -548,7 +546,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
$setdata['enabled'] = 'false';
}
serendipity_plugin_api::hook_event('plugins_linklist_conf',$setdata);
if ($setdata['changed']=='true') {
if ($setdata['changed'] == 'true') {
$this->set_config('links',$setdata['links']);
}