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

@ -11,341 +11,341 @@
// Node object
function Node(id, pid, name, url, title, target, icon, iconOpen, open) {
this.id = id;
this.pid = pid;
this.name = name;
this.url = url;
this.title = title;
this.target = target;
this.icon = icon;
this.iconOpen = iconOpen;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = false;
this._ai = 0;
this._p;
this.id = id;
this.pid = pid;
this.name = name;
this.url = url;
this.title = title;
this.target = target;
this.icon = icon;
this.iconOpen = iconOpen;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = false;
this._ai = 0;
this._p;
};
// Tree object
function dTree(objName, img_directory) {
this.config = {
target : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines : true,
useIcons : true,
useStatusText : false,
closeSameLevel : false,
inOrder : false
}
this.config = {
target : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines : true,
useIcons : true,
useStatusText : false,
closeSameLevel : false,
inOrder : false
}
this.icon = {
root : img_directory + '/img/base.gif',
folder : img_directory + '/img/folder.gif',
folderOpen : img_directory + '/img/folderopen.gif',
node : img_directory + '/img/page.gif',
empty : img_directory + '/img/empty.gif',
line : img_directory + '/img/line.gif',
join : img_directory + '/img/join.gif',
joinBottom : img_directory + '/img/joinbottom.gif',
plus : img_directory + '/img/plus.gif',
plusBottom : img_directory + '/img/plusbottom.gif',
minus : img_directory + '/img/minus.gif',
minusBottom : img_directory + '/img/minusbottom.gif',
nlPlus : img_directory + '/img/nolines_plus.gif',
nlMinus : img_directory + '/img/nolines_minus.gif'
};
this.obj = objName;
this.aNodes = [];
this.aIndent = [];
this.root = new Node(-1);
this.selectedNode = null;
this.selectedFound = false;
this.completed = false;
this.icon = {
root : img_directory + '/img/base.gif',
folder : img_directory + '/img/folder.gif',
folderOpen : img_directory + '/img/folderopen.gif',
node : img_directory + '/img/page.gif',
empty : img_directory + '/img/empty.gif',
line : img_directory + '/img/line.gif',
join : img_directory + '/img/join.gif',
joinBottom : img_directory + '/img/joinbottom.gif',
plus : img_directory + '/img/plus.gif',
plusBottom : img_directory + '/img/plusbottom.gif',
minus : img_directory + '/img/minus.gif',
minusBottom : img_directory + '/img/minusbottom.gif',
nlPlus : img_directory + '/img/nolines_plus.gif',
nlMinus : img_directory + '/img/nolines_minus.gif'
};
this.obj = objName;
this.aNodes = [];
this.aIndent = [];
this.root = new Node(-1);
this.selectedNode = null;
this.selectedFound = false;
this.completed = false;
};
// Adds a new node to the node array
dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
};
// Open/close all nodes
dTree.prototype.openAll = function() {
this.oAll(true);
this.oAll(true);
};
dTree.prototype.closeAll = function() {
this.oAll(false);
this.oAll(false);
};
// Outputs the tree to the page
dTree.prototype.toString = function() {
var str = '<div class="dtree">\n';
if (document.getElementById) {
if (this.config.useCookies) this.selectedNode = this.getSelected();
str += this.addNode(this.root);
} else str += 'Browser not supported.';
str += '</div>';
if (!this.selectedFound) this.selectedNode = null;
this.completed = true;
return str;
var str = '<div class="dtree">\n';
if (document.getElementById) {
if (this.config.useCookies) this.selectedNode = this.getSelected();
str += this.addNode(this.root);
} else str += 'Browser not supported.';
str += '</div>';
if (!this.selectedFound) this.selectedNode = null;
this.completed = true;
return str;
};
// Creates the tree structure
dTree.prototype.addNode = function(pNode) {
var str = '';
var n=0;
if (this.config.inOrder) n = pNode._ai;
for (n; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == pNode.id) {
var cn = this.aNodes[n];
cn._p = pNode;
cn._ai = n;
this.setCS(cn);
if (!cn.target && this.config.target) cn.target = this.config.target;
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
if (!this.config.folderLinks && cn._hc) cn.url = null;
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
cn._is = true;
this.selectedNode = n;
this.selectedFound = true;
}
str += this.node(cn, n);
if (cn._ls) break;
}
}
return str;
var str = '';
var n=0;
if (this.config.inOrder) n = pNode._ai;
for (n; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == pNode.id) {
var cn = this.aNodes[n];
cn._p = pNode;
cn._ai = n;
this.setCS(cn);
if (!cn.target && this.config.target) cn.target = this.config.target;
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
if (!this.config.folderLinks && cn._hc) cn.url = null;
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
cn._is = true;
this.selectedNode = n;
this.selectedFound = true;
}
str += this.node(cn, n);
if (cn._ls) break;
}
}
return str;
};
// Creates the node icon, url and text
dTree.prototype.node = function(node, nodeId) {
var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
if (this.config.useIcons) {
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
if (this.root.id == node.pid) {
node.icon = this.icon.root;
node.iconOpen = this.icon.root;
}
str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
}
if (node.url) {
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
if (node.title) str += ' title="' + node.title + '"';
if (node.target) str += ' target="' + node.target + '"';
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
str += '>';
}
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
str += node.name;
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
str += '</div>';
if (node._hc) {
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
str += this.addNode(node);
str += '</div>';
}
this.aIndent.pop();
return str;
var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
if (this.config.useIcons) {
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
if (this.root.id == node.pid) {
node.icon = this.icon.root;
node.iconOpen = this.icon.root;
}
str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
}
if (node.url) {
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
if (node.title) str += ' title="' + node.title + '"';
if (node.target) str += ' target="' + node.target + '"';
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
str += '>';
}
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
str += node.name;
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
str += '</div>';
if (node._hc) {
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
str += this.addNode(node);
str += '</div>';
}
this.aIndent.pop();
return str;
};
// Adds the empty and line icons
dTree.prototype.indent = function(node, nodeId) {
var str = '';
if (this.root.id != node.pid) {
for (var n=0; n<this.aIndent.length; n++)
str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
if (node._hc) {
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
str += '" alt="" /></a>';
} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
}
return str;
var str = '';
if (this.root.id != node.pid) {
for (var n=0; n<this.aIndent.length; n++)
str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
if (node._hc) {
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
str += '" alt="" /></a>';
} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
}
return str;
};
// Checks if a node has any children and if it is the last sibling
dTree.prototype.setCS = function(node) {
var lastId;
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id) node._hc = true;
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
}
if (lastId==node.id) node._ls = true;
var lastId;
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id) node._hc = true;
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
}
if (lastId==node.id) node._ls = true;
};
// Returns the selected node
dTree.prototype.getSelected = function() {
var sn = this.getCookie('cs' + this.obj);
return (sn) ? sn : null;
var sn = this.getCookie('cs' + this.obj);
return (sn) ? sn : null;
};
// Highlights the selected node
dTree.prototype.s = function(id) {
if (!this.config.useSelection) return;
var cn = this.aNodes[id];
if (cn._hc && !this.config.folderLinks) return;
if (this.selectedNode != id) {
if (this.selectedNode || this.selectedNode==0) {
eOld = document.getElementById("s" + this.obj + this.selectedNode);
eOld.className = "node";
}
eNew = document.getElementById("s" + this.obj + id);
eNew.className = "nodeSel";
this.selectedNode = id;
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
}
if (!this.config.useSelection) return;
var cn = this.aNodes[id];
if (cn._hc && !this.config.folderLinks) return;
if (this.selectedNode != id) {
if (this.selectedNode || this.selectedNode==0) {
eOld = document.getElementById("s" + this.obj + this.selectedNode);
eOld.className = "node";
}
eNew = document.getElementById("s" + this.obj + id);
eNew.className = "nodeSel";
this.selectedNode = id;
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
}
};
// Toggle Open or close
dTree.prototype.o = function(id) {
var cn = this.aNodes[id];
this.nodeStatus(!cn._io, id, cn._ls);
cn._io = !cn._io;
if (this.config.closeSameLevel) this.closeLevel(cn);
if (this.config.useCookies) this.updateCookie();
var cn = this.aNodes[id];
this.nodeStatus(!cn._io, id, cn._ls);
cn._io = !cn._io;
if (this.config.closeSameLevel) this.closeLevel(cn);
if (this.config.useCookies) this.updateCookie();
};
// Open or close all nodes
dTree.prototype.oAll = function(status) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
this.nodeStatus(status, n, this.aNodes[n]._ls)
this.aNodes[n]._io = status;
}
}
if (this.config.useCookies) this.updateCookie();
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
this.nodeStatus(status, n, this.aNodes[n]._ls)
this.aNodes[n]._io = status;
}
}
if (this.config.useCookies) this.updateCookie();
};
// Opens the tree to a specific node
dTree.prototype.openTo = function(nId, bSelect, bFirst) {
if (!bFirst) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].id == nId) {
nId=n;
break;
}
}
}
var cn=this.aNodes[nId];
if (cn.pid==this.root.id || !cn._p) return;
cn._io = true;
cn._is = bSelect;
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
if (this.completed && bSelect) this.s(cn._ai);
else if (bSelect) this._sn=cn._ai;
this.openTo(cn._p._ai, false, true);
if (!bFirst) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].id == nId) {
nId=n;
break;
}
}
}
var cn=this.aNodes[nId];
if (cn.pid==this.root.id || !cn._p) return;
cn._io = true;
cn._is = bSelect;
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
if (this.completed && bSelect) this.s(cn._ai);
else if (bSelect) this._sn=cn._ai;
this.openTo(cn._p._ai, false, true);
};
// Closes all nodes on the same level as certain node
dTree.prototype.closeLevel = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Closes all children of a node
dTree.prototype.closeAllChildren = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Change the status of a node(open or closed)
dTree.prototype.nodeStatus = function(status, id, bottom) {
eDiv = document.getElementById('d' + this.obj + id);
eJoin = document.getElementById('j' + this.obj + id);
if (this.config.useIcons) {
eIcon = document.getElementById('i' + this.obj + id);
eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
}
eJoin.src = (this.config.useLines)?
((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
((status)?this.icon.nlMinus:this.icon.nlPlus);
eDiv.style.display = (status) ? 'block': 'none';
eDiv = document.getElementById('d' + this.obj + id);
eJoin = document.getElementById('j' + this.obj + id);
if (this.config.useIcons) {
eIcon = document.getElementById('i' + this.obj + id);
eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
}
eJoin.src = (this.config.useLines)?
((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
((status)?this.icon.nlMinus:this.icon.nlPlus);
eDiv.style.display = (status) ? 'block': 'none';
};
// [Cookie] Clears a cookie
dTree.prototype.clearCookie = function() {
var now = new Date();
var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
this.setCookie('co'+this.obj, 'cookieValue', yesterday);
this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
var now = new Date();
var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
this.setCookie('co'+this.obj, 'cookieValue', yesterday);
this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};
// [Cookie] Sets value in a cookie
dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
};
// [Cookie] Gets a value from a cookie
dTree.prototype.getCookie = function(cookieName) {
var cookieValue = '';
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
else cookieValue = unescape(document.cookie.substring(posValue));
}
return (cookieValue);
var cookieValue = '';
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
else cookieValue = unescape(document.cookie.substring(posValue));
}
return (cookieValue);
};
// [Cookie] Returns ids of open nodes as a string
dTree.prototype.updateCookie = function() {
var str = '';
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
if (str) str += '.';
str += this.aNodes[n].id;
}
}
this.setCookie('co' + this.obj, str);
var str = '';
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
if (str) str += '.';
str += this.aNodes[n].id;
}
}
this.setCookie('co' + this.obj, str);
};
// [Cookie] Checks if a node id is in a cookie
dTree.prototype.isOpen = function(id) {
var aOpen = this.getCookie('co' + this.obj).split('.');
for (var n=0; n<aOpen.length; n++)
if (aOpen[n] == id) return true;
return false;
var aOpen = this.getCookie('co' + this.obj).split('.');
for (var n=0; n<aOpen.length; n++)
if (aOpen[n] == id) return true;
return false;
};
// If Push and pop is not implemented by the browser
if (!Array.prototype.push) {
Array.prototype.push = function array_push() {
for(var i=0;i<arguments.length;i++)
this[this.length]=arguments[i];
return this.length;
}
Array.prototype.push = function array_push() {
for(var i=0;i<arguments.length;i++)
this[this.length]=arguments[i];
return this.length;
}
};
if (!Array.prototype.pop) {
Array.prototype.pop = function array_pop() {
lastElement = this[this.length-1];
this.length = Math.max(this.length-1,0);
return lastElement;
}
};
Array.prototype.pop = function array_pop() {
lastElement = this[this.length-1];
this.length = Math.max(this.length-1,0);
return lastElement;
}
};

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

@ -32,4 +32,7 @@
}
.dtree .clip {
overflow: hidden;
}
}
/* linklist dtree end */

View file

@ -1,42 +1,46 @@
/* serendipity_event_linklist.css start */
div.linklist span.menu_title {
}
div.linklist {
padding: 0px;
margin: 0px;
text-align: left;
font-size: 11px;
color: #666;
white-space: nowrap;
direction: ltr;
padding: 0px;
margin: 0px;
text-align: left;
font-size: 11px;
color: #666;
white-space: nowrap;
direction: ltr;
}
div.linklist ul {
list-style: none;
margin: 0px;
padding: 0px;
text-align: left;
white-space: nowrap;
list-style: none;
margin: 0px;
padding: 0px;
text-align: left;
white-space: nowrap;
}
div.linklist li {
margin: 0px;
padding: 0px;
white-space: nowrap;
font-family: Arial, Helvetica, sans-serif;
white-space: nowrap;
margin: 0px;
padding: 0px;
white-space: nowrap;
font-family: Arial, Helvetica, sans-serif;
white-space: nowrap;
}
div.linklist img {
border: 0px;
vertical-align: middle;
border: 0px;
vertical-align: middle;
}
div.linklist a.folder {
text-decoration: none;
text-decoration: none;
}
div.linklist a.link {
text-decoration: underline;
text-decoration: underline;
}
div.linklist a:hover {
color: #333;
}
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);
}
return true;
$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;
@ -177,76 +184,78 @@ class serendipity_event_linklist extends serendipity_event {
break;
case 'plugins_linklist_input':
$eventData['links'] = $this->generate_output(false);
return true;
$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']);
$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]);
}
$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);
}
}
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;
} 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:
@ -279,17 +288,17 @@ class serendipity_event_linklist extends serendipity_event {
if ($this->get_config('category') == 'custom') {
$table = $serendipity['dbPrefix'].'link_category';
} else {
$table = $serendipity['dbPrefix'].'category';
$table = $serendipity['dbPrefix'].'category';
}
$output = $this->category_output($table,0,0);
} else {
$q = $this->set_query($display);
$q = $this->set_query($display);
$sql = serendipity_db_query($q);
if ($sql && is_array($sql)) {
foreach($sql AS $key => $row) {
$name = $row['name'];
$link = $row['link'];
$id = $row['id'];
$id = $row['id'];
$descrip = $row['descrip'];
$output .= '<link name="'.(function_exists('serendipity_specialchars') ? serendipity_specialchars($name) : htmlspecialchars($name, ENT_COMPAT, LANG_CHARSET)).'" link="http://'.$link.'" descrip="'.(function_exists('serendipity_specialchars') ? serendipity_specialchars($descrip) : htmlspecialchars($descrip, ENT_COMPAT, LANG_CHARSET)).'" />'."\n";
}
@ -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>';
}
}
@ -679,19 +688,20 @@ class serendipity_event_linklist extends serendipity_event {
echo '<h3>'.$maintitle.'</h3>';
?>
<form action="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=linklist" method="post">
<input type="hidden" name="serendipity[add_link][id]" value="<?php echo $id; ?>">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<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_LINK.'<div style="font-size: smaller;">'.PLUGIN_LINKLIST_LINK_EXAMPLE.'</div>'; ?></td><td><input class="input_textbox" type="text" name="serendipity[add_link][link]" value="<?php echo $link; ?>" size="30" /></td></tr>
<tr><td><?php echo PLUGIN_LINKLIST_LINK_NAME; ?></td><td><input class="input_textbox" type="text" name="serendipity[add_link][title]" value="<?php echo $title; ?>" size="30" /></td></tr>
<tr><td><?php echo CATEGORY; ?> <?php echo $catlink;?></td><td><?php echo $this->category_box('cat',$categories,$cat); ?></td></tr>
<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>
<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>
<?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">
@ -727,8 +743,8 @@ class serendipity_event_linklist extends serendipity_event {
<td><strong><?php echo CATEGORY; ?></strong></td>
</tr>
<?php
$q = 'SELECT s.* FROM '.$serendipity['dbPrefix'].'link_category AS s
ORDER BY s.category_name DESC';
$q = 'SELECT s.* FROM '.$serendipity['dbPrefix'].'link_category AS s
ORDER BY s.category_name DESC';
$categories = serendipity_db_query($q);
$categories = @serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
@ -737,37 +753,39 @@ class serendipity_event_linklist extends serendipity_event {
?>
<tr>
<td width="16">
<input class="input_checkbox" type="checkbox" name="serendipity[category_to_remove][]" value="<?php echo $category['categoryid']; ?>" />
<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>';
}
function set_query($display) {
global $serendipity;
$q = 'SELECT s.link AS link,
s.title AS name,
s.descrip AS descrip,
s.category AS cat_id,
s.id AS id
FROM '.$serendipity['dbPrefix'].'links AS s ';
$q = 'SELECT s.link AS link,
s.title AS name,
s.descrip AS descrip,
s.category AS cat_id,
s.id AS id
FROM '.$serendipity['dbPrefix'].'links AS s ';
switch($display) {
case 'category':
$q .= 'ORDER BY s.category';
$q .= 'ORDER BY s.category';
break;
case 'order_num':
$q .= 'ORDER BY s.order_num ASC';
$q .= 'ORDER BY s.order_num ASC';
break;
case 'dateacs':
@ -778,7 +796,7 @@ class serendipity_event_linklist extends serendipity_event {
$q .= 'ORDER BY date_added DESC';
break;
default:
$q .= 'ORDER BY s.title ASC';
$q .= 'ORDER BY s.title ASC';
break;
}
return $q;
@ -791,10 +809,10 @@ class serendipity_event_linklist extends serendipity_event {
} else {
$table = $serendipity['dbPrefix'].'category';
}
$q = 'SELECT s.categoryid AS id,
s.category_name AS name
FROM '.$table.' AS s
ORDER BY s.category_name DESC';
$q = 'SELECT s.categoryid AS id,
s.category_name AS name
FROM '.$table.' AS s
ORDER BY s.category_name DESC';
$sql = serendipity_db_query($q);
$categories['0'] = '';
if ($sql && is_array($sql)) {

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',
@ -134,7 +133,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
$propbag->add('description', PLUGIN_LINKLIST_CATEGORY_NAME_DESC);
$propbag->add('radio',
array( 'value' => array('custom','default'),
'desc' => array(PLUGIN_LINKLIST_CATEGORY_NAME_CUSTOM,PLUGIN_LINKLIST_CATEGORY_NAME_DEFAULT)
'desc' => array(PLUGIN_LINKLIST_CATEGORY_NAME_CUSTOM,PLUGIN_LINKLIST_CATEGORY_NAME_DEFAULT)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'custom');
@ -290,7 +289,7 @@ class serendipity_plugin_linklist extends serendipity_plugin
$propbag->add('description', PLUGIN_LINKLIST_CATEGORY_DEFAULT_OPEN_DESC);
$propbag->add('radio',
array( 'value' => array('closed','open'),
'desc' => array(PLUGIN_LINKLIST_CATEGORY_DEFAULT_OPEN_NAME_CLOSED,PLUGIN_LINKLIST_CATEGORY_DEFAULT_OPEN_NAME_OPEN)
'desc' => array(PLUGIN_LINKLIST_CATEGORY_DEFAULT_OPEN_NAME_CLOSED,PLUGIN_LINKLIST_CATEGORY_DEFAULT_OPEN_NAME_OPEN)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'closed');
@ -372,34 +371,33 @@ class serendipity_plugin_linklist extends serendipity_plugin
$imgdir = $serendipity['baseURL'] . 'plugins/' . $plugin_dir;
}
$str = $this->get_config('prepend_text');
$str.="\n\n";
$str = $this->get_config('prepend_text');
$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;
}
}
@ -476,32 +474,32 @@ class serendipity_plugin_linklist extends serendipity_plugin
$imagear['uselines'] = $this->get_config('useLines');
$imagear['useicons'] = $this->get_config('useIcons');
if ($imagear['useicons']) {
$imagear['folder'] = '/img/folder.gif';
$imagear['folderopen'] = '/img/folderopen.gif';
$imagear['page'] = '/img/page.gif';
$imagear['folder'] = '/img/folder.gif';
$imagear['folderopen'] = '/img/folderopen.gif';
$imagear['page'] = '/img/page.gif';
}
if ($this->get_config('useLines')) {
$imagear['line'] = '/img/line.gif';
$imagear['join'] = '/img/join.gif';
$imagear['joinBottom'] = '/img/joinbottom.gif';
$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['line'] = '/img/line.gif';
$imagear['join'] = '/img/join.gif';
$imagear['joinBottom'] = '/img/joinbottom.gif';
$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';
} else {
$imagear['line'] = '/img/empty.gif';
$imagear['join'] = '/img/empty.gif';
$imagear['joinBottom'] = '/img/empty.gif';
$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['line'] = '/img/empty.gif';
$imagear['join'] = '/img/empty.gif';
$imagear['joinBottom'] = '/img/empty.gif';
$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';
}
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,14 +508,14 @@ 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'];
} else {
return $str;
return $str;
}
}
@ -528,16 +526,16 @@ 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'),
$setdata = array('display' => $this->get_config('display'),
'category' => $this->get_config('category'),
'style' => $this->get_config('style'),
'cache' => $cache);
'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']);
}