Hello,
I made a small change to the timeline and eventline result formats,
adding two new parameters:
1) timelinelabelwidth -- as the name suggests, allows longer labels to
be displayed properly
2) timelinelabelmode -- either 'full' or 'subpage'. The 'subpage' mode
removes any leading prefix from the label, up to the final '/' in the
name, if any.
I needed these options to get a better display of Task names in
ccTeamspace. If you think these parameters might be generally useful,
I'd be happy if the patch could be included in the main code base.
Incidentally, I also think I found a bug in SRF_timeline.js, line 66: it
should be "childs[i]" here, if I'm correct, instead of "childs[0]".
The patch is attached. Please have a look.
Cheers,
Andre
Index: Timeline/SRF_Timeline.php
===================================================================
--- Timeline/SRF_Timeline.php (revision 61566)
+++ Timeline/SRF_Timeline.php (working copy)
@@ -17,6 +17,8 @@
protected $m_tlsize = ''; // CSS-compatible size (such as 400px)
protected $m_tlbands = ''; // array of band IDs (MONTH, YEAR, ...)
protected $m_tlpos = ''; // position identifier (start, end, today, middle)
+ protected $m_tllmode = ''; // use full page name or subpage name as label (full, subpage)
+ protected $m_tllwidth = ''; // label width (CSS)
protected function readParameters($params,$outputmode) {
SMWResultPrinter::readParameters($params,$outputmode);
@@ -45,6 +47,16 @@
} else {
$this->m_tlpos = 'middle';
}
+ if (array_key_exists('timelinelabelmode', $params)) {
+ $this->m_tllmode = strtolower (trim($params['timelinelabelmode']));
+ } else {
+ $this->m_tllmode = 'full';
+ }
+ if (array_key_exists('timelinelabelwidth', $params)) {
+ $this->m_tllwidth = strtolower (trim($params['timelinelabelwidth']));
+ } else {
+ $this->m_tllwidth = '200';
+ }
}
public function getName() {
@@ -79,6 +91,9 @@
$result = "<div class=\"smwtimeline\" id=\"smwtimeline$smwgIQRunningNumber\" style=\"height: $this->m_tlsize\">";
$result .= '<span class="smwtlcomment">' . wfMsgForContent('smw_iq_nojs') . ' ' . $link->getText($outputmode,$this->mLinker) . '</span>'; // note for people without JavaScript
+ $result .= '<span class="smwtllabelmode">' . $this->m_tllmode . '</span>';
+ $result .= '<span class="smwtllabelwidth">' . $this->m_tllwidth . '</span>';
+
foreach ($this->m_tlbands as $band) {
$result .= '<span class="smwtlband">' . htmlspecialchars($band) . '</span>';
//just print any "band" given, the JavaScript will figure out what to make of it
Index: Timeline/SRF_timeline.js
===================================================================
--- Timeline/SRF_timeline.js (revision 61566)
+++ Timeline/SRF_timeline.js (working copy)
@@ -40,12 +40,13 @@
var l = childs.length;
var bands = [];
var bandcount = 0;
+ var labelmode = 'full';
var position = new Date(); //fallback position: today;
for (var i = 0; i < childs.length; div.removeChild(childs[0])) {
switch (childs[i].nodeType) {
case 1: //ELEMENT_NODE -- an event or some general data
if (childs[i].className == "smwtlevent")
- smw_add_event(childs[i],eventSource);
+ smw_add_event(childs[i],eventSource,labelmode);
else if (childs[i].className == "smwtlband") {
switch (childs[i].firstChild.data) {
case "MILLISECOND": bands[bandcount] = Timeline.DateTime.MILLISECOND; break;
@@ -62,8 +63,12 @@
default: bandcount--; //dont count unrecognized bands
}
bandcount++;
- } else if (childs[0].className == "smwtlposition") {
+ } else if (childs[i].className == "smwtlposition") {
position = Timeline.DateTime.parseIso8601DateTime(childs[i].firstChild.data);
+ } else if (childs[i].className == "smwtllabelwidth") {
+ theme.event.label.width = childs[i].firstChild.data;
+ } else if (childs[i].className == "smwtllabelmode") {
+ labelmode = childs[i].firstChild.data;
} /*else if (childs[i].className == "smwtlsize") {
div.setAttribute("style","height: " + childs[i].firstChild.data + ";");
}*/
@@ -146,7 +151,7 @@
}
}
-function smw_add_event(evspan,evs) {
+function smw_add_event(evspan,evs,labelmode) {
var startdate = null;
var enddate = null;
var desc = "";
@@ -229,6 +234,11 @@
}
desc = evspan.innerHTML; // the remaining nodes form the description of the event
+ if (labelmode == "subpage") {
+ var index = ttl.lastIndexOf ("/");
+ ttl = ttl.substring (index+1);
+ }
+
var parseDateTimeFunction = evs._events.getUnit().getParser("iso8601");
var evt = new Timeline.DefaultEventSource.Event(
parseDateTimeFunction(startdate),
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel