Revision history for CalendarLinkAction


Revision [19245]

Last edited on 2008-01-28 00:14:44 by MasinAlDujaili [Modified links pointing to docs server]

No Differences

Revision [17044]

Edited on 2007-06-01 06:44:18 by MasinAlDujaili [update to 0.2 -- now with offset and date settings!]
Additions:
* @version 0.2
* default: 'today'
* 'latest': Returns the last entry before the current date.
* 'today': Returns the entry at the calculated date. If no date or offset is given, then it will result to the current date.
* @input int $date optional: a date in the form yyyymmdd
* If $link is given, $link will be calculated depending to the corresponding date
* @input int $offset optional: a number of days to offset
* If $date is given, the calculated entry will be $date + $offset. If $date is not given, the current date
* will be used. If $link is given, it will be calculated using this calculated date
* Example: {{calendarlink calendarname="MyCalendar" link="following" date="20070605" offset="60"}}
* The action will then link to the calendar entry following August 4th, 2007. Without link="following", the
* action will create a link to MyCalendar20070804 itself, appending the /edit handler if the page does not
* exist.
define('LAST_ENTRY','Letzter Eintrag');
define('FIRST_ENTRY','Erster Eintrag');
// echo 'currentpage='.$current_page; // debug
// print_r($cal_date); // debug
} // END of getting calendar name
else $mode = 'today';
// check parameter date has been provided
if(isset($vars['date']) && preg_match(REGEX_CAL_DATE,$vars['date'],$cal_date))
$date = $cal_date[0];
else // it has not been provided so we will use today as date
$cal_date = getdate();
$date = sprintf("%4d%02d%02d",$cal_date['year'],$cal_date['mon'],$cal_date['mday']);
if(isset($vars['offset']))
$offset = $vars['offset'];
list($year, $mon, $mday) = sscanf($date, "%4d%02d%02d");
$cal_date = getdate(mktime(0,0,0,$mon, $mday+$offset, $year));
$date = sprintf("%4d%02d%02d",$cal_date['year'],$cal_date['mon'],$cal_date['mday']);
if($mode!='today') // we only need the list of calendar entries if we want some other day than (calculated) today
$result = $this->Query('SELECT tag FROM ' . $this->config['table_prefix'] . "pages WHERE tag REGEXP('^$cal_name\[0-9]{8,8}') AND latest = 'Y'");
if (mysql_num_rows($result)) while ($row = mysql_fetch_array($result)) $tags[] = $row['tag'];
if($mode=='following'||$mode=='latest'||$mode=='today')
// creating a virtual calendar entry to use the code for $link=='next' or $link=='prev' on this virtual entry
$entry = sprintf("%s%8d",$cal_name,$date); // picking the relative origin based on calculated date
$entry = $this->GetPageTag(); // picking the relative origin based on current page assuming it is calendar page
sort($tags); //sorting tags -- in case of a virtual calendar entry this will be now be in order, else the calendar entries are just sorted
$key = array_search($entry,$tags); // getting position of our relative origin in the array
$date_found = FALSE;
$target_date = $tags[$key+1];
$date_found = TRUE;
$target_date = LAST_ENTRY;
$date_found = FALSE;
elseif($mode=='prev'||$mode=='latest')
$target_date = $tags[$key-1];
$date_found = TRUE;
$target_date = FIRST_ENTRY;
$date_found = FALSE;
elseif($mode=='today')
$target_date = $entry;
$date_found = TRUE;
if ($date_found)
echo $this->Link($target_date);
echo $target_date;
%%
Deletions:
* @version 0.1
* default: 'next' if action sits on a calendar page else 'following'
* @input int $scope optional: maximum number of days to search for desired entry
* default: 28
define('LAST_ENTRY','Last entry');
define('FIRST_ENTRY','First entry');
echo 'currentpage='.$current_page;
print_r($cal_date);
// END of getting calendar name
else $mode = 'next';
//echo $mode."<br />"; //debug command
//echo count($tags)."<br />"; // debug command
$result = $this->Query('SELECT tag, body FROM ' . $this->config['table_prefix'] . "pages WHERE tag REGEXP('^$cal_name\[0-9]{8,8}') AND latest = 'Y'");
if (mysql_num_rows($result)) while ($row = mysql_fetch_array($result)) $tags[] = $row['tag'];
if($vars['link']=='following')
$today = getdate();
$entry = sprintf("%s%4d%02d%02d",$cal_name,$today['year'],$today['mon'],$today['mday']);
$entry = $this->GetPageTag();
// echo $this->Format($entry); //debug command
sort($tags);
//echo $mode."<br />"; //debug command
//foreach ($tags as $key => $value) echo $key."=".$value."<br />"; //debug command
$key = array_search($entry,$tags);
echo $this->Link($tags[$key+1]);
echo LAST_ENTRY;
elseif($mode=='prev')
echo $this->Link($tags[$key-1]);
echo FIRST_ENTRY;
}%%


Revision [16263]

Edited on 2007-03-06 14:30:37 by MasinAlDujaili [more bug fixes]
Additions:
if($key<(count($tags)-1))
echo LAST_ENTRY;
if($key>0)
echo FIRST_ENTRY;
Deletions:
if($key!=(count($tags)-1))
echo $this->Format(LAST_ENTRY);
if($key!=(count($tags)-1))
echo $this->Format(FIRST_ENTRY);


Revision [16257]

Edited on 2007-03-05 19:53:31 by MasinAlDujaili [small bug fix]
Additions:
echo $this->Link($tags[$key+1]);
echo $this->Link($tags[$key-1]);
Deletions:
echo $this->Format($tags[$key+1]);
echo $this->Format($tags[$key-1]);


Revision [16256]

Edited on 2007-03-05 19:23:33 by MasinAlDujaili [created]
Additions:
=====Calendar Link Action=====
Documentation: CalendarLinkActionInfo.>>This is the development page for the Calendar Link action. The code still needs some cleanup.::c::
%%(php)
<?php
/**
* Displays a link to a calendar entry based on parameter or current calendar entry
*
* @package Actions
* @subpackage Date and Time
* @name calendarlink
*
* @authors {@link http://wikkawiki.org/MasinAlDujaili Masin Al-Dujaili}
* @version 0.1
* @since Wikka 1.1.6.2
*
* @input string $calendarname optional: prefix for the calendar pages to be created - Must be a CamelCase word;
* default: WikiName from the user if logged on, else it's checked if the action sits on a calendar page
* @input string $link optional: one of the following keywords: 'next', 'prev', 'following'
* default: 'next' if action sits on a calendar page else 'following'
* 'next': only available if action sits on a calendar page. Returns the entry in the future relative to the current entry.
* 'prev': only available if action sits on a calendar page. Returns the entry in the past relative to the current entry.
* 'following': Returns the next entry in the future relative to the current date.
* @input int $scope optional: maximum number of days to search for desired entry
* default: 28
*
* @output Link according to selection in parameter 'link'
*/
// l10n strings
define('LAST_ENTRY','Last entry');
define('FIRST_ENTRY','First entry');
// format string for locale-specific month (%B) + 4-digit year (%Y) used for caption and title attributes
// NOTE: monthname is locale-specific but order of month and year may need to be switched: hence the double quotes!
define ('USER_NAME',$this->GetUserName());
define ('BASE_URL',$this->config['base_url']); # i18n
define ('REGEX_CAMEL_WORD','([A-ZÄÖÜ]+[a-zßäöü]+[A-Z0-9ÄÖÜ][A-Za-z0-9ÄÖÜßäöü]*)');
define ('REGEX_CAL_DATE', '([0-9]{8,8})');
define ('REGEX_CAL_ENTRY', REGEX_CAMEL_WORD.REGEX_CAL_ENTRY);
// ***** END CONSTANTS section *****
// Get name of calendar to work with
$current_page = $this->GetPageTag();
if($this->getUser()) // Initialize $calendarname with current user's name if logged in
{
$cal_name = $this->getUser();
}
else // use current page tag
{
$cal_name = $current_page;
}
if(isset($vars['calendarname'])) // Check for parameter calendarname
{
$cal_name = $vars['calendarname'];
}
elseif(preg_match(REGEX_CAL_DATE,$current_page,$cal_date)) // Check if current page is a calendar entry and use the corresponding calendar.
{
echo 'currentpage='.$current_page;
print_r($cal_date);
$cal_name = substr($current_page,0,strpos($current_page, $cal_date[0]));
}
else // don't change prior init
{
$cal_name = $cal_name;
}
// END of getting calendar name
// Get link mode and convert to lower case
if(isset($vars['link'])) $mode = $vars['link'];
else $mode = 'next';
//echo $mode."<br />"; //debug command
$mode=mb_strtolower($mode);
// END link mode acquisition
//echo count($tags)."<br />"; // debug command
$result = $this->Query('SELECT tag, body FROM ' . $this->config['table_prefix'] . "pages WHERE tag REGEXP('^$cal_name\[0-9]{8,8}') AND latest = 'Y'");
if (mysql_num_rows($result)) while ($row = mysql_fetch_array($result)) $tags[] = $row['tag'];
if($vars['link']=='following')
{
$today = getdate();
$entry = sprintf("%s%4d%02d%02d",$cal_name,$today['year'],$today['mon'],$today['mday']);
$tags[] = $entry;
}
else
{
$entry = $this->GetPageTag();
}
// echo $this->Format($entry); //debug command
sort($tags);
//echo $mode."<br />"; //debug command
//foreach ($tags as $key => $value) echo $key."=".$value."<br />"; //debug command
$key = array_search($entry,$tags);
if($mode=='next'||$mode=='following')
{
if($key!=(count($tags)-1))
{
echo $this->Format($tags[$key+1]);
}
else
{
echo $this->Format(LAST_ENTRY);
}
}
elseif($mode=='prev')
{
if($key!=(count($tags)-1))
{
echo $this->Format($tags[$key-1]);
}
else
{
echo $this->Format(FIRST_ENTRY);
}
}%%
Deletions:
=====xxxxx Action=====
Documentation: xxxxxActionInfo.>>This is the development page for the xxxxx action.::c::
//This page is a **template**. It belongs to CategoryTemplate (which contains more handy templates). To create an action development page, [[http://wikka.jsnx.com/ActionTemplate/clone clone this page]] to a page called **xxxxxAction** (where xxxxx is the (capitalized) name of the action), replace all occurrences of 'xxxxx' with the name of the action and replace this paragraph with the actual content.//


Revision [16255]

The oldest known version of this page was created on 2007-03-05 19:21:29 by MasinAlDujaili [created]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki