[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: sitemgr/modules class.module_administration.inc
From: |
Michael Totschnig <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: sitemgr/modules class.module_administration.inc.php,NONE,1.1 class.module_amazon.inc.php,NONE,1.1class.module_appdir.inc.php,NONE,1.1 class.module_calendar.inc.php,NONE,1.1 class.module_currentsection.inc.php,NONE,1.1 class.module_forum.inc.php,NONE,1.1class.module_galerie.inc.php,NONE,1.1 class.module_google.inc.php,NONE,1.1class.module_hello.inc.php,NONE,1.1 class.module_html.inc.php,NONE,1.1class.module_index.inc.php,NONE,1.1 class.module_index_block.inc.php,NONE,1.1 class.module_lang_block.inc.php,NONE,1.1 class.module_login.inc.php,NONE,1.1class.module_news.inc.php,NONE,1.1 class.module_redirect.inc.php,NONE,1.1 class.module_sitetree.inc.php,NONE,1.1class.module_toc.inc.php,NONE,1.1 class.module_toc_block.inc.php,NONE,1.1class.module_xml.inc.php,NONE,1.1 |
Date: |
Tue, 04 Mar 2003 12:57:02 -0500 |
Update of /cvsroot/phpgroupware/sitemgr/modules
In directory subversions:/tmp/cvs-serv3688
Added Files:
class.module_administration.inc.php
class.module_amazon.inc.php class.module_appdir.inc.php
class.module_calendar.inc.php
class.module_currentsection.inc.php class.module_forum.inc.php
class.module_galerie.inc.php class.module_google.inc.php
class.module_hello.inc.php class.module_html.inc.php
class.module_index.inc.php class.module_index_block.inc.php
class.module_lang_block.inc.php class.module_login.inc.php
class.module_news.inc.php class.module_redirect.inc.php
class.module_sitetree.inc.php class.module_toc.inc.php
class.module_toc_block.inc.php class.module_xml.inc.php
Log Message:
move modules to directory of their own
--- NEW FILE ---
<?php
class module_administration extends Module
{
function module_administration()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Administration";
$this->description = "This module presents a link back to the
sitemgr's administration menu. It is meant for registered users";
}
function get_content(&$arguments,$properties)
{
return
' <strong><big>·</big></strong><a
href="'.phpgw_link('/sitemgr/index.php').'">' . lang('Content Manager') .
'</a>';
}
}
--- NEW FILE ---
<?php
/**************************************************************\
* this was originally a phpNuke block. the amazon_id has been *
* changed. feel free to change it yourself, of course. the *
* below directions still apply. *
\**************************************************************/
/***************************************************************/
/* To use this block you only need to download .jpg or .gif */
/* images from amazon.com and copy them to the /images/amazon */
/* directory, then edit the $amazon_id variable to fit your ID */
/* of the Associates program. If you don't change the ID, all */
/* the comissions ($) will go to my account! You're advised. */
/* */
/* You need to know that any image in the amazon's directory */
/* has the same ASIN name as its filename given by Amazon. If */
/* you don't know what this is, leave it as is or disable it. */
/***************************************************************/
class module_amazon extends Module
{
function module_amazon()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Amazon";
$this->description = "Use this module for displaying book ads
for the amazon web site ";
}
function get_content(&$arguments,$properties)
{
$amazon_id = "phpgwsitemgr-20";
mt_srand((double)microtime()*1000000);
$imgs = dir('images/amazon');
while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file)) {
$imglist .= "$file ";
}
}
closedir($imgs->handle);
$imglist = explode(" ", $imglist);
$a = sizeof($imglist)-2;
$random = mt_rand(0, $a);
$image = $imglist[$random];
$asin = explode(".", $image);
return "<br><center><a
href=\"http://www.amazon.com/exec/obidos/ASIN/$asin[0]/$amazon_id\"
target=\"_blank\">" .
"<img src=\"images/amazon/$image\" border=\"0\"
alt=\"\"><br><br></center>";
}
}
--- NEW FILE ---
<?php
// this module is only for demonstrative purposes,
// a real appdir would be better defined as a real phpgw application
// and a sitemgr module would not have to handle the data, but only to fetch it
class module_appdir extends Module
{
function module_appdir()
{
$this->arguments = array();
$this->title = "An application directory";
$this->description = "This module demonstrates how handling
data stored in XML and building an interacvite interface from it";
}
function get_user_interface()
{
$interface = array();
$allapps = $this->block->arguments['directory'];
//xmltool2 is a slightly modified version of phpgwapi.xmltool
of HEAD
$xmltool = CreateObject('sitemgr.xmltool2');
$xmltool->import_xml($allapps);
$apparray = $xmltool->export_var();
$i = 0;
while (list(,$app) = @each($apparray['app']))
{
$element['label'] = '<hr>';
$element['form'] = '<hr>';
$interface[] = $element;
$element['label'] = '<b>'.$app['name'][0].'</b>';
$element['form'] = '';
$interface[] = $element;
foreach(array('name','maintainer','url','description')
as $key)
{
$elementname = 'element[' .$key . '][' . $i
.']';
$element['label'] = ucfirst($key);
$element['form'] = $this->build_input_element(
array(
'type' => ($key ==
'description') ? 'textarea' : 'textfield',
'params' => ($key ==
'description') ? array('cols' => 50,'rows' => 15) : array('size' => 50)),
$app[$key][0],
$elementname
);
$interface[] = $element;
}
$element['label'] = 'Delete this application';
$element['form'] = $this->build_input_element(
array('type' => 'checkbox'),
False,
'element[delete][' . $i . ']'
);
$interface[] = $element;
$i++;
}
$element['label'] = '<hr>';
$element['form'] = '<hr>';
$interface[] = $element;
$element['label'] = 'Add a new application';
$element['form'] = $this->build_input_element(
array('type' => 'checkbox'),
False,
'element[addnew]'
);
$interface[] = $element;
return $interface;
}
function validate(&$data)
{
$xmltool =
CreateObject('sitemgr.xmltool2','node','directory','');
$i = 0;
while (isset($data['name'][$i]))
{
if (!$data['delete'][$i])
{
$xmltool->import_var(
'app',
array(
'name' => $data['name'][$i],
'maintainer' =>
$data['maintainer'][$i],
'url' => $data['url'][$i],
'description' =>
$data['description'][$i],
)
);
}
$i++;
}
if ($data['addnew'])
{
$xmltool->import_var(
'app',
array(
'name' => 'New application',
'maintainer' => 'Maintainer',
'url' => 'http://',
'description' => 'Description'
)
);
}
$newdata['directory'] = $xmltool->export_xml();
$data = $newdata;
return true;
}
function set_block($block,$produce=False)
{
parent::set_block($block,$produce);
if ($produce)
{
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP
. 'inc' . SEP . 'class.xslt_transform.inc.php');
$this->add_transformer(new
xslt_transform($this->find_template_dir() . SEP . 'list.xsl'));
}
}
function get_content(&$arguments,$properties)
{
return $arguments['directory'];
}
}
--- NEW FILE ---
<?php
class module_calendar extends Module
{
function module_calendar()
{
$this->arguments = array();
$this->session = array('timestamp');
$this->post = array(
'prevmonth' => array(
'type' => 'image',
'src' =>
$GLOBALS['phpgw']->common->image('phpgwapi','left')
),
'nextmonth' => array(
'type' => 'image',
'src' =>
$GLOBALS['phpgw']->common->image('phpgwapi','right')
)
);
$this->title = "Calendar";
$this->description = "This module displays the current month";
$this->bo = CreateObject('calendar.bocalendar');
}
function get_content(&$arguments,$properties)
{
$t = Createobject('phpgwapi.Template');
$t->set_root($this->find_template_dir());
$t->set_file('mini_calendar','mini_cal.tpl');
if (!$arguments['timestamp'])
{
$arguments['timestamp'] = time();
}
if ($arguments['prevmonth'])
{
$arguments['timestamp'] =
mktime(0,0,0,date("m",$arguments['timestamp'])-1,date("d",$arguments['timestamp']),
date("Y",$arguments['timestamp']));
}
elseif ($arguments['nextmonth'])
{
$arguments['timestamp'] =
mktime(0,0,0,date("m",$arguments['timestamp'])+1,date("d",$arguments['timestamp']),
date("Y",$arguments['timestamp']));
}
$date =
$GLOBALS['phpgw']->datetime->gmtdate($arguments['timestamp']);
$month = $date['month'];
$day = $date['day'];
$year = $date['year'];
$this->bo->read_holidays($year);
$month_ago = intval(date('Ymd',mktime(0,0,0,$month -
1,$day,$year)));
$month_ahead = intval(date('Ymd',mktime(0,0,0,$month +
1,$day,$year)));
$monthstart = intval(date('Ymd',mktime(0,0,0,$month,1,$year)));
$monthend = intval(date('Ymd',mktime(0,0,0,$month +
1,0,$year)));
$weekstarttime =
$GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1);
$t->set_block('mini_calendar','mini_cal','mini_cal');
$t->set_block('mini_calendar','mini_week','mini_week');
$t->set_block('mini_calendar','mini_day','mini_day');
$linkdata['menuaction'] = 'calendar.uicalendar.month';
$linkdata['month'] =
$GLOBALS['phpgw']->common->show_date($date['raw'],'m');
$linkdata['year'] =
$GLOBALS['phpgw']->common->show_date($date['raw'],'Y');
$month = '<a href="'
.$GLOBALS['phpgw']->link('/index.php',$linkdata) . '" class="minicalendar">' .
lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).'
'.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y').'</a>';
$var = Array(
'cal_img_root' =>
$GLOBALS['phpgw']->common->image('calendar','mini-calendar-bar'),
'bgcolor' =>
$calui->theme['bg_color'],
'bgcolor1' =>
$calui->theme['bg_color'],
'month' => $month,
'bgcolor2' =>
$calui->theme['cal_dayview'],
'holiday_color' => $calui->holiday_color,
'navig' => '<form method="post">' .
$this->build_post_element('prevmonth') .
' ' .
$this->build_post_element('nextmonth') .
'</form>'
);
$t->set_var($var);
if(!$t->get_var('daynames'))
{
for($i=0;$i<7;$i++)
{
$var = Array(
'dayname' => '<b>' .
substr(lang($GLOBALS['phpgw']->datetime->days[$i]),0,2) . '</b>',
'day_image' => ''
);
$this->output_template_array($t,'daynames','mini_day',$var);
}
}
$today =
date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
unset($date);
for($i=$weekstarttime +
$GLOBALS['phpgw']->datetime->tz_offset;date('Ymd',$i)<=$monthend;$i += (24 *
3600 * 7))
{
unset($var);
$daily = $this->set_week_array($i -
$GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly);
@reset($daily);
while(list($date,$day_params) = each($daily))
{
$year = intval(substr($date,0,4));
$month = intval(substr($date,4,2));
$day = intval(substr($date,6,2));
$str = '';
unset($linkdata);
$linkdata['menuaction'] =
'calendar.uicalendar.day';
$linkdata['date']= $date;
$str = '<a href="'
.$GLOBALS['phpgw']->link('/index.php',$linkdata) .'" class="'
.$day_params['class'] .'">' .$day .'</a>';
$var[] = Array(
'day_image' =>
$day_params['day_image'],
'dayname' => $str
);
}
for($l=0;$l<count($var);$l++)
{
$this->output_template_array($t,'monthweek_day','mini_day',$var[$l]);
}
$t->parse('display_monthweek','mini_week',True);
$t->set_var('dayname','');
$t->set_var('monthweek_day','');
}
$return_value = $t->fp('out','mini_cal');
$t->set_var('display_monthweek','');
// $t->set_var('daynames','');
// unset($p);
return $return_value;
}
function output_template_array(&$p,$row,$list,$var)
{
if (!isset($var['hidden_vars']))
{
$var['hidden_vars'] = '';
}
$p->set_var($var);
$p->parse($row,$list,True);
}
function set_week_array($startdate,$cellcolor,$weekly)
{
for ($j=0,$datetime=$startdate;$j<7;$j++,$datetime += 86400)
{
$date = date('Ymd',$datetime + (60 * 60 * 2));
if($this->bo->cached_events[$date])
{
$appts = True;
}
else
{
$appts = False;
}
$holidays = $this->bo->cached_holidays[$date];
if($weekly)
{
$cellcolor =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor);
}
$day_image = '';
if($holidays)
{
$extra = '
bgcolor="'.$this->bo->holiday_color.'"';
$class = ($appts?'b':'').'minicalhol';
if ($date == $this->bo->today)
{
$day_image = '
background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"';
}
}
elseif ($date != $this->bo->today)
{
$extra = ' bgcolor="'.$cellcolor.'"';
$class = ($appts?'b':'').'minicalendar';
}
else
{
$extra = '
bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"';
$class = ($appts?'b':'').'minicalendar';
$day_image = '
background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"';
}
if($this->bo->check_perms(PHPGW_ACL_ADD))
{
$new_event = True;
}
else
{
$new_event = False;
}
$holiday_name = Array();
if($holidays)
{
for($k=0;$k<count($holidays);$k++)
{
$holiday_name[] = $holidays[$k]['name'];
}
}
$week = '';
if (!$j || (!$weekly && $j && substr($date,6,2) ==
'01'))
{
$week = lang('week').'
'.(int)((date('z',($startdate+(24*3600*4)))+7)/7);
}
$daily[$date] = Array(
'extra' => $extra,
'new_event' => $new_event,
'holidays' => $holiday_name,
'appts' => $appts,
'week' => $week,
'day_image' => $day_image,
'class' => $class
);
}
return $daily;
}
}
--- NEW FILE ---
<?php
class module_currentsection extends Module
{
function module_currentsection()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Current Section";
$this->description = "This block displays the current section's
table of contents";
}
function get_content(&$arguments,$properties)
{
global $page;
$catlinks =
$GLOBALS['objbo']->getCatLinks((int)$page->cat_id,false);
if (!$page->cat_id)
{
return '';
}
$pagelinks =
$GLOBALS['objbo']->getPageLinks($page->cat_id,false);
$category = $GLOBALS['objbo']->getcatwrapper($page->cat_id);
$this->block->title = $category->name;
$parent = $category->parent;
unset($category);
$content = '';
if ($parent)
{
$parentcat = $GLOBALS['objbo']->getcatwrapper($parent);
$content .= "\n".'<b>Parent
Section:</b><br> · <a href="'.
sitemgr_link2('/index.php','category_id='.$parent).'">'.$parentcat->name.
'</a><br><br>';
unset($parentcat);
}
if (count($catlinks))
{
$content .= "\n".'<b>Subsections:</b><br>';
foreach ($catlinks as $catlink)
{
$content .=
"\n".' · '.$catlink['link'].'<br>';
}
$content .= '<br>';
}
if (count($pagelinks)>1 || (count($pagelinks)>0 && $content))
{
$content .= "\n".'<b>Pages:</b>';
$content .= ' (<a
href="'.sitemgr_link2('/index.php','category_id='.$page->cat_id).
'"><i>show all</i></a>)<br>';
reset($pagelinks);
while(list($pagelink_id,$pagelink) = each($pagelinks))
{
if ($page->page_id && $page->page_id ==
$pagelink_id)
{
$content .=
' >'.$pagelink['link'].'<<br>';
}
else
{
$content .=
' · '.$pagelink['link'].'<br>';
}
}
}
return $content;
}
}
--- NEW FILE ---
<?php
class module_forum extends Module
{
var $template;
var $startlevel;
function module_forum()
{
$this->arguments = array(
'startlevel' => array(
'type' => 'select',
'label' => 'With which view should the module
be displayed in the beginning?',
'options' => array(
1 => 'Overview of all available
categories',
2 => 'Overview of one specific
category',
3 => 'Summary of one forum',
),
),
'startcat_id' => array(
'type' => 'select',
'label' => 'Select a category',
'options' => Array(),
),
'startforum_id' => array(
'type' => 'select',
'label' => 'Select a forum',
'options' => Array(),
),
);
$this->get =
array('level','cat_id','forum_id','msg','pos','view');
$this->session = array('level','cat_id','forum_id','view');
$this->title = "Discussions";
$this->description = "This module displays the phpgw forums on
the web site";
$this->bo = CreateObject('forum.boforum',1);
}
function get_user_interface()
{
$defaults = $this->block->arguments;
if ($defaults['startlevel'] == 2 || $defaults['startlevel'] ==
3)
{
$options=array();
$cats = $this->bo->get_all_cat_info();
while(list($key,$cat) = @each($cats))
{
$options[$cat['id']] = $cat['name'];
}
$this->arguments['startcat_id']['options'] = $options;
}
else
{
unset($this->arguments['startcat_id']);
}
if (($defaults['startlevel'] == 3) && $defaults['startcat_id'])
{
$options=array();
$forums =
$this->bo->get_forums_for_cat($defaults['startcat_id']);
while (list($key,$forum) = @each($forums))
{
$options[$forum['id']] = $forum['name'];
}
$this->arguments['startforum_id']['options'] = $options;
}
else
{
unset($this->arguments['startforum_id']);
}
return parent::get_user_interface();
}
function get_content(&$arguments,$properties)
{
$this->startlevel = $arguments['startlevel'];
if (!$arguments['level'] || $arguments['level'] <
$this->startlevel)
{
$arguments['level'] = $this->startlevel;
}
$this->template = CreateObject('phpgwapi.Template');
$this->template->set_root($this->find_template_dir());
if ($arguments['level'] == 1)
{
return $this->index();
}
//$arguments['level'] > 1
$cat_id = ($this->startlevel == 1) ? $arguments['cat_id'] :
$arguments['startcat_id'];
$cat = $cat_id ? $this->bo->get_cat_info($cat_id) : False;
if (!$cat)
{
$cats = array_values($this->bo->get_all_cat_info());
if (!$cats)
{
return lang('There are no categories');
}
$cat = $cats[0];
}
if ($arguments['level'] == 2)
{
return $this->forums($cat);
}
//$arguments['level'] > 2
$forum_id = ($this->startlevel > 3) ? $arguments['forum_id'] :
$arguments['startforum_id'];
$forum = $forum_id ?
$this->bo->get_forum_info($cat['id'],$forum_id) : False;
if (!$forum)
{
$forums =
array_values($this->bo->get_forums_for_cat($cat['id']));
if (!$forums)
{
return lang('There are no forums in this
category');
}
$forum = $forums[0];
}
if ($arguments['level'] == 3)
{
return
$this->threads($cat,$forum,(strcmp($arguments['view'],'collapsed') == 0));
}
//$arguments['level'] == 4, if msg is not defined we fall back
to level 3
return $arguments['msg'] ?
$this->read($cat,$forum,$arguments['msg']) :
$this->threads($cat,$forum,(strcmp($arguments['view'],'collapsed') == 0));
}
function index()
{
$this->template->set_file(
Array(
'INDEX' => 'index.body.tpl'
)
);
$this->template->set_block('INDEX','CategoryForum','CatF');
$var = Array(
'CAT_IMG' =>
$GLOBALS['phpgw']->common->image('forum','category'),
);
$this->template->set_var($var);
$cats = $this->bo->get_all_cat_info();
$rowon = true;
while(list($key,$cat) = @each($cats))
{
$rowon = !$rowon;
$var = Array(
'ROWONOFF' => $rowon ? 'rowon' : 'rowoff',
'CAT' => $cat['name'],
'DESC' => $cat['descr'],
'CAT_LINK' => $this->link(Array(
'level' => 2,
'cat_id' => $cat['id']
)),
'value_last_post' => $cat['last_post'],
'value_total'=> $cat['total']
);
$this->template->set_var($var);
$this->template->parse('CatF','CategoryForum',true);
}
$this->template->parse('Out','INDEX');
return $this->template->get('Out');
}
function forums($cat)
{
$this->template->set_file(
Array(
'_list' => 'forums.body.tpl'
)
);
$this->template->set_block('_list','row_empty');
$this->template->set_block('_list','list');
$this->template->set_block('_list','row');
$var = Array(
'FORUM_IMG' =>
$GLOBALS['phpgw']->common->image('forum','forum'),
'CATEGORY'=> $cat['name'],
'LANG_CATEGORY'=> lang('Category'),
'BACKLINK'=> (($this->startlevel == 1) ?
('<a href="' . $this->link(array('level' => 1))
. '">' . lang('All categories') . '</a>') :
''
)
);
$this->template->set_var($var);
$forum_info = $this->bo->get_forums_for_cat($cat['id']);
if(!$forum_info)
{
$this->template->set_var('lang_no_forums',lang('There
are no forums in this category'));
$this->template->fp('rows','row_empty');
}
else
{
$rowon = true;
while (list($key,$forum) = each($forum_info))
{
$rowon = !$rowon;
$this->template->set_var(
Array(
'ROWONOFF'=> $rowon ? 'rowon' :
'rowoff',
'NAME'=> $forum['name'],
'DESC'=> $forum['descr'],
'THREADS_LINK'=>
$this->link(Array(
'level' => 3,
'forum_id' =>
$forum['id']
)),
'value_last_post' =>
$forum['last_post'],
'value_total'=> $forum['total']
)
);
$this->template->fp('rows','row',True);
}
}
$this->template->parse('Out','list');
return $this->template->get('Out');
}
function threads($cat,$forum,$is_collapsed)
{
$pre_var = array(
'LANG_TOPIC'=> lang('Topic'),
'LANG_AUTHOR'=> lang('Author'),
'LANG_REPLIES'=> lang('Replies'),
'LANG_LATREP'=> lang('Latest Reply'),
'LANG_FORUM'=> lang('Forum'),
'FORUM'=> $forum['name'],
'BACKLINK'=> (($this->startlevel < 3) ?
('<a href="' .
$this->link(array('level' => 2))
. '">' .
lang('All forums in category
%1','<b>'.$cat['name'].'</b>') . '</a>'
) :
''
)
);
$thread_listing =
$this->bo->get_thread($cat['id'],$forum['id'],$is_collapsed);
if($is_collapsed)
{
$this->template->set_file(
Array(
'COLLAPSE' =>
'collapse.threads.tpl'
)
);
$this->template->set_block('COLLAPSE','CollapseThreads','CollapseT');
$this->template->set_var($pre_var);
$this->template->set_var('THREAD_IMG',$GLOBALS['phpgw']->common->image('forum','thread'));
$rowon = true;
while($thread_listing && list($key,$thread) =
each($thread_listing))
{
$rowon = !$rowon;
$var = Array(
'ROWONOFF' => $rowon ? 'rowon' :
'rowoff',
'TOPIC' =>
($thread['subject']?$thread['subject']:'[No subject]'),
'AUTHOR' =>
($thread['author']?$GLOBALS['phpgw']->common->grab_owner_name($thread['author']):lang('Unknown')),
'REPLIES' => $thread['replies'],
'READ_LINK' => $this->link(Array(
'level' => 4,
'msg' => $thread['id'],
)),
'LATESTREPLY' => $thread['last_reply']
);
$this->template->set_var($var);
$this->template->parse('CollapseT','CollapseThreads',true);
}
$var = Array(
'THREADS_LINK' => $this->link(Array(
'view' => 'threads',
)),
'LANG_THREADS' => lang('View Threads')
);
$this->template->set_var($var);
$this->template->parse('Out','COLLAPSE');
} //end if
//For viewing the normal view
else
{
$this->template->set_file(
Array(
'NORMAL' => 'normal.threads.tpl'
)
);
$this->template->set_block('NORMAL','NormalThreads','NormalT');
$this->template->set_var($pre_var);
$rowon = true;
$tr_color = $this->row_on_color;
while($thread_listing && list($key,$thread) =
each($thread_listing))
{
$rowon = !$rowon;
$move = '';
for($tmp = 1;$tmp <= $thread['depth']; $tmp++)
{
$move .= ' ';
}
$move .= '<img
src="'.$GLOBALS['phpgw']->common->image('forum','n').'">';
$move .= ' ';
$var = Array(
'ROWONOFF' => $rowon ? 'rowon' :
'rowoff',
'TOPIC' =>
($thread['subject']?$thread['subject']:'[No subject]'),
'AUTHOR' =>
($thread['author']?$GLOBALS['phpgw']->common->grab_owner_name($thread['author']):lang('Unknown')),
'REPLIES' => $thread['replies'],
'READ_LINK' => $this->link(Array(
'level' => 4,
'msg' => $thread['id'],
'pos' => $thread['pos']
)),
'LATESTREPLY' =>
$thread['last_reply'],
'DEPTH' => $move
);
$this->template->set_var($var);
$this->template->parse('NormalT','NormalThreads',true);
} //end while
$var = Array(
'THREADS_LINK' => $this->link(Array(
'view' => 'collapsed'
)),
'LANG_THREADS' => lang('Collapse Threads')
);
$this->template->set_var($var);
$this->template->parse('Out','NORMAL');
}
return $this->template->get('Out');
}
function read($cat,$forum,$msg)
{
$this->template->set_file(
Array(
'READ' => 'read.body.tpl'
)
);
$this->template->set_block('READ','read_body','read_body');
$this->template->set_block('READ','msg_template','msg_template');
$this->template->set_block('READ','post_template','post_template');
$var = array(
'LANG_TOPIC'=> lang('Topic'),
'LANG_AUTHOR'=> lang('Author'),
'LANG_REPLIES'=> lang('Replies'),
'LANG_LATREP'=> lang('Latest Reply'),
'LANG_FORUM'=> lang('Forum'),
'FORUM'=> $forum['name'],
'LANG_SEARCH'=> lang('Search'),
'BACKLINK' => ('<a href="' . $this->link(array('level'
=> 3)) . '">' . lang('Return to message list') . '</a>'),
'LANG_DATE'=> lang('Date'),
'LANG_SUBJECT' => lang('Subject'),
'LANG_THREADS' => lang('Return to forums')
);
$this->template->set_var($var);
//it does not make sense to implement posting in this module, since the forum
app is
//too badly designed to to this in a clean way.
// $var = array(
// 'POST_ACTION' => $this->link(array('level' => 5)),
// 'LANG_REPLYTOPIC' => lang('Post A Message To This
Thread').':',
// 'LANG_MESSAGE' => lang('Message'),
// 'LANG_SUBMIT'=> lang('Submit')
// );
// $this->template->set_var($var);
// $this->template->parse('POST_TEMPLATE','post_template',True);
$post_ul = '';
$pre_ul = '';
$messages = $this->bo->read_msg($cat['id'],$forum['id'],$msg);
while($messages && list($key,$message) = each($messages))
{
if($message['id'] == $msg)
{
$var = Array(
'THREAD'=> $message['thread'],
'DEPTH'=> $message['depth'],
'RE_SUBJECT' => (!strpos('
'.strtoupper($message['subject']),'RE: ')?'RE: ':'').$message['subject']
);
$this->template->set_var($var);
}
$var = Array(
'AUTHOR'=>
($message['thread_owner']?$GLOBALS['phpgw']->common->grab_owner_name($message['thread_owner']):lang('Unknown')),
'POSTDATE'=>
$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->from_timestamp($message['postdate'])),
'SUBJECT_LINK' => $this->link(Array(
'msg' => $message['id'],
'pos' => $message['pos']
)),
'SUBJECT'=> $message['subject'],
'MESSAGE' =>
nl2br($message['message']),
'NAME'=> $message['name'],
'EMAIL'=> $message['email']
);
if($key > 0)
{
for($i=$depth,$pre_ul='',$post_ul='';$i<($message['depth'] -
1);$i++,$pre_ul.='<ul>',$post_ul.='</ul>')
{
}
$this->template->set_var('UL_PRE',$pre_ul);
}
else
{
$depth = $message['depth'] - 1;
}
$this->template->set_var($var);
$this->template->parse('MESSAGE_TEMPLATE','msg_template',True);
$this->template->set_var('UL_PRE','');
}
if($post_ul)
{
$this->template->set_var('UL_POST',$post_ul);
}
$this->template->parse('Out','read_body');
return $this->template->get('Out');
}
}
--- NEW FILE ---
<?php
class module_galerie extends Module
{
function module_galerie()
{
$this->arguments = array(
'imagedirurl' => array(
'type' => 'textfield',
'label' => 'URL pointing to the directory where
the images are found (no trailing slash)'
),
'imagedirpath' => array(
'type' => 'textfield',
'label' => 'Filesystem path of the directory
where the images are found (no trailing slash)'
),
'imagename' => array(
'type' => 'textfield',
'label' => 'the images\' common name'
),
'imagetype' => array(
'type' => 'select',
'label' => 'image type',
'options' => array(
'jpeg' => 'jpeg',
'gif' => 'gif',
'png' => 'png'
)
),
);
$this->title = "Galerie";
$this->post = array(
'prev' => array(
'type' => 'submit',
'value' => "<---"
),
'next' => array(
'type' => 'submit',
'value' => "--->"
)
);
$this->session = array('filenumber');
$this->description = "A simple picture galery";
}
function get_user_interface()
{
$this->set_subtext_args();
return parent::get_user_interface();
}
function get_translation_interface($fromblock,$toblock)
{
$this->set_subtext_args();
return parent::get_translation_interface($fromblock,$toblock);
}
function set_subtext_args()
{
$defaults = $this->block->arguments;
if ($defaults['imagedirpath'] &&
is_dir($defaults['imagedirpath']))
{
$i = 1;
$this->arguments['subtext'] = array(
'type' => "array",
'i18n' => True
);
while (file_exists($defaults['imagedirpath'] . SEP .
$defaults['imagename'] . $i . '.' . $defaults['imagetype']))
{
$this->arguments['subtext'][$i-1] = array(
'type' => 'textfield',
'label' => 'Subtext for image ' . $i .
'<br /><img src="' .
$defaults['imagedirurl'] . SEP
. $defaults['imagename'] . $i . '.' . $defaults['imagetype'] . '" />',
'i18n' => True
);
$i++;
}
}
}
function set_block($block,$produce=False)
{
parent::set_block($block,$produce);
if ($produce)
{
if (!$this->block->arguments['filenumber'])
{
$this->block->arguments['filenumber'] = 1;
}
else
{
$this->block->arguments['filenumber'] =
(int)$this->block->arguments['filenumber'];
}
if ($this->block->arguments['next'])
{
$this->block->arguments['filenumber']++;
}
elseif ($this->block->arguments['prev'])
{
$this->block->arguments['filenumber']--;
}
if ($this->block->arguments['filenumber'] < 1 ||
!file_exists(
$this->block->arguments['imagedirpath']
. SEP . $this->block->arguments['imagename'] .
$this->block->arguments['filenumber'] .
'.' . $this->block->arguments['imagetype']
))
{
$this->block->arguments['filenumber'] = 1;
}
$prevlink = ($this->block->arguments['filenumber'] > 1)
? $this->build_post_element('prev') : '';
$nextlink =
(file_exists(
$this->block->arguments['imagedirpath']
. SEP . $this->block->arguments['imagename'] .
($this->block->arguments['filenumber']
+ 1) . '.' . $this->block->arguments['imagetype']
)) ?
$this->build_post_element('next') :
'';
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP
. 'inc' . SEP . 'class.browser_transform.inc.php');
$this->add_transformer(new
browser_transform($prevlink,$nextlink));
}
}
function get_content(&$arguments,$properties)
{
$content .= '<div align="center"><img hspace="20"
align="absmiddle" src="'. $arguments['imagedirurl'] . SEP .
$arguments['imagename'] . $arguments['filenumber'] . '.' .
$arguments['imagetype'] . '" /></div>';
$content .= '<div align="center" style="margin:5mm">' .
$arguments['subtext'][$arguments['filenumber']-1] . '</div><div
align="center">';
return $content;
}
}
--- NEW FILE ---
<?php
class module_google extends Module
{
function module_google()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Google";
$this->description = "Interface to Google website";
}
function get_content(&$arguments,$properties)
{
$content = '<form action="http://www.google.com/search"
name=f>';
$content .= '<img src="images/Google_25wht.gif" border="0"
align="middle" hspace="0" vspace="0"><br>';
$content .= '<center><input type=hidden name=hl value=en>';
$content .= '<input type=hidden name=ie value="ISO-8859-1">';
$content .= '<input maxLength=256 size=15 name=q value=""><br>';
$content .= '<input type=submit value="' . lang('Google
Search') . '" name=btnG></center>';
$content .= '</form>';
return $content;
}
}
--- NEW FILE ---
<?php
class module_hello extends Module
{
function module_hello()
{
$this->arguments = array(
'name' => array(
'type' => 'textfield',
'label' => 'The person to say hello to'
)
);
$this->post = array('name' => array('type' => 'textfield'));
$this->session = array('name');
$this->title = "Hello world";
$this->description = "This is a simple sample module";
}
function get_content(&$arguments,$properties)
{
$this->validate($arguments);
return lang('Hello') . ' ' . $arguments['name'] . '<br><form
method="post">' .
$this->build_post_element('name',lang('Enter a name')) .
'</form>';
}
function validate(&$data)
{
if (preg_match("/[[:upper:]]/",$data['name']))
{
$data['name'] = strtolower($data['name']);
$this->validation_error = "Name has been translated to
lower case";
}
return true;
}
}
--- NEW FILE ---
<?php
class module_html extends Module
{
function module_html()
{
$this->arguments = array(
'htmlcontent' => array(
'type' => 'textarea',
'label' => 'Enter the page content
here',
'i18n' => True,
'params' => Array('cols' => 50, 'rows'
=> 15)
)
);
$this->properties = array('striphtml' => array('type'
=> 'checkbox', 'label' => 'Strip HTML from block content?'));
$this->title = "HTML module";
$this->description = "This module is a simple HTML
editor";
}
function get_content(&$arguments,$properties)
{
return $properties['striphtml'] ?
$GLOBALS['phpgw']->strip_html($arguments['htmlcontent']) :
$arguments['htmlcontent'];
}
}
--- NEW FILE ---
<?php
class module_index extends Module
{
function module_index()
{
$this->arguments = array();
$this->title = "Site Index";
$this->description = "This module provides the site
index, it is automatically used by the index GET parameter";
}
function get_content(&$arguments,$properties)
{
global $objbo;
$indexarray = $objbo->getIndex();
$content = "\n".
'<table border="0" width="100%" align="left"
cellspacing="1" cellpadding="0">
<tr>';
$catname = '';
foreach($indexarray as $temppage)
{
$buffer = str_pad('',
$temppage['catdepth']*24,' ');
if ($catname!=$temppage['catname']) //category
name change
{
if ($catname!='') //not the first name
change
{
$content .=
'<br><br></td></tr></table></td></tr><tr>';
}
$content .= '<td>
<table border="0" width="100%"
cellspacing="0" align="left" cellpadding="0">
<tr><td>'.$buffer.'</td>
<td width="100%">';
$catname = $temppage['catname'];
if ($temppage['catdepth'])
{
$content .= '· ';
}
$content .= '<b>'.$catname.'</b>
– <i>'.
$temppage['catdescrip'].'</i>'."\n";
}
$content .=
"\n".'<br> · '.$temppage['pagelink'];
}
$content .= "\n".'</td></tr></table></td></tr></table>';
if (count($indexarray)==0)
{
$content=lang('You do not have access to any
content on this site.');
}
return $content;
}
}
?>
--- NEW FILE ---
<?php
class module_index_block extends Module
{
function module_index_block()
{
$this->arguments = array();
$this->title = "Root Site Index";
$this->description = "This module displays the root categories,
meant for side areas";
}
function get_content(&$arguments,$properties)
{
global $objbo;
$indexarray = $objbo->getIndex(false,true);
$content = "\n".'<table border="0" cellspacing="0"
cellpadding="0" width="100%">';
$catname = '';
foreach($indexarray as $page)
{
if ($catname!=$page['catname']) //category name change
{
if ($catname=='')
{
$break = '';
}
else
{
$break = '<br>';
}
$catname = $page['catname'];
$content.="\n".'<tr><td width="15%"
colspan="2">'.$break.' <b>'.
$page['catlink'].'</b></td></tr>'."\n";
}
if (!$page['hidden'])
{
$content .= "\n".'<tr><td align="right"
valign="top" width="15%">'.
'· </td><td>'.$page['pagelink'].'</td></tr>';
}
}
$content .= "\n</table>";
$content .= '<br> <i><a
href="'.sitemgr_link2('/index.php','index=1').'"><font size="1">(' . lang('View
full index') . ')</font></a></i>';
if (count($indexarray)==0)
{
$content=lang('You do not have access to any content on
this site.');
}
return $content;
}
}
?>
--- NEW FILE ---
<?php
class module_lang_block extends Module
{
function module_lang_block()
{
$this->arguments = array();
$this->properties = array();
$this->title = "Choose language";
$this->description = "This module lets users choose
language";
}
function get_content(&$arguments,$properties)
{
if ($GLOBALS['sitemgr_info']['sitelanguages'])
{
$content = '<form name="langselect"
method="post">';
$content .= '<select
onChange="this.form.submit()" name="language">';
foreach
($GLOBALS['sitemgr_info']['sitelanguages'] as $lang)
{
$selected='';
if ($lang ==
$GLOBALS['sitemgr_info']['userlang'])
{
$selected =
'selected="selected" ';
}
$content .= '<option ' . $selected .
'value="' . $lang . '">'. $GLOBALS['Common_BO']->getlangname($lang) .
'</option>';
}
$content .= '</select>';
$content .= '</form>';
return $content;
}
else
{
$content = lang('No sitelanguages configured');
}
}
}
--- NEW FILE ---
<?php
class module_login extends Module
{
function module_login()
{
$this->arguments = array(
'registration' => array(
'type' => 'checkbox',
'label' => 'Display link to autoregistration
below login form?'
)
);
$this->properties = array();
$this->title = "Login";
$this->description = "This module displays a login form";
}
function get_content(&$arguments,$properties)
{
$content = '<form name="login"
action="'.phpgw_link('/login.php').'" method="post">';
$content .= '<input type="hidden" name="passwd_type"
value="text">';
$content .= '<input type="hidden" name="phpgw_forward"
value="/sitemgr/">';
$content .= '<center><font class="content">' . lang('Login
Name') .'<br>';
$content .= '<input type="text" name="login" size="8"
value=""><br>';
$content .= lang('Password') . '<br>';
$content .= '<input name="passwd" size="8"
type="password"><br>';
$content .= '<input type="submit" value="' . lang('Login') .'"
name="submitit">';
$content .= '</font></center></form>';
if ($arguments['registration'])
{
$content .= '<center><font class="content">' .
lang("Don't have an account?") .' ';
$content .= '<a
href="'.phpgw_link('/registration/index.php').'">';
$content .= lang('Register for one now.') .
'</a></font></center>';
}
return $content;
}
}
--- NEW FILE ---
<?php
class news_transform
{
function news_transform(&$template)
{
$this->template = $template;
}
function apply_transform($title,$content)
{
$result ='';
while (list(,$newsitem) = @each($content))
{
$this->template->set_var(array(
'news_title' => $newsitem['subject'],
'news_submitter' =>
$GLOBALS['phpgw']->accounts->id2name($newsitem['submittedby']),
'news_date' =>
$GLOBALS['phpgw']->common->show_date($newsitem['submissiondate']),
'news_content' =>
nl2br($newsitem['content'])
));
$result .= $this->template->parse('out','news');
}
return $result;
}
}
class module_news extends Module
{
function module_news()
{
//specification of options is postponed into the
get_user_interface function
$this->arguments = array('category' => array('type' =>
'select', 'label' => 'Choose a category', 'options' => array()));
$this->properties = array();
$this->title = "News module";
$this->description = "This module is just a first trial
of hooking news_admin into sitmgr's new architecture.";
}
function get_user_interface()
{
//we could put this into the module's constructor, but
by putting it here, we make it execute only when the block is edited,
//and not when it is generated for the web site, thus
speeding the latter up slightly
$cat =
createobject('phpgwapi.categories','','news_admin');
$cats = $cat->return_array('mains',0);
$cat_ids = array(0 => 'Mains');
while (list(,$category) = @each($cats))
{
$cat_ids[$category['id']] = $category['name'];
}
$this->arguments['category']['options'] = $cat_ids;
return parent::get_user_interface();
}
function set_block($block,$produce=False)
{
parent::set_block($block,$produce);
if ($produce)
{
$t = Createobject('phpgwapi.Template');
$t->set_root($this->find_template_dir());
$t->set_file('news','newsblock.tpl');
$this->add_transformer(new news_transform($t));
}
}
function get_content(&$arguments,$properties)
{
$bonews = CreateObject('news_admin.bonews');
return $bonews->get_NewsList($arguments['category'],
false);
}
}
--- NEW FILE ---
<?php
class module_redirect extends Module
{
function module_redirect()
{
$this->arguments = array(
'URL' => array(
'type' => 'textfield',
'label' => 'The URL to redirect to'
)
);
$this->title = "Redirection";
$this->description = "This module lets you define pages that
redirect to another URL, if you use it, there should be no other block defined
for the page";
}
function get_content(&$arguments,$properties)
{
Header('Location: ' . $arguments['URL']);
exit;
}
}
--- NEW FILE ---
<?php
class module_sitetree extends Module
{
function module_sitetree()
{
$this->arguments = array();
$this->properties = array();
$this->cookie = array('menutree');
$this->title = "Site Tree Menu";
$this->description = "This block displays a javascript based
tree menu";
$this->expandedcats;
}
function showcat($cats)
{
while(list($cat_id,$cat) = each($cats))
{
$status = in_array($cat_id,$this->expandedcats);
$childrenandself =
array_keys($GLOBALS['objbo']->getCatLinks($cat_id));
$childrenandself[] = $cat_id;
$catcolour =
in_array($GLOBALS['page']->cat_id,$childrenandself) ? "red" : "black";
$tree .= "\n" .
'<tr><td width="10%">' .
'<img src="images/tree_' .
($status ? "collapse" : "expand") .
'.gif" onclick="toggle(this, \'' .
$cat_id .
'\')"></td><td><b title="' .
$cat['description'] .
'" style="color:' .
$catcolour .
'">'.
$cat['name'] .
'</b></td></tr>' .
"\n";
$subcats =
$GLOBALS['objbo']->getCatLinks($cat_id,False);
$pages = $GLOBALS['objbo']->getPageLinks($cat_id);
if ($subcats || $pages)
{
$tree .= '<tr><td></td><td><table
style="display:' .
($status ? "block" : "none") .
'" border="0" cellspacing="0"
cellpadding="0" width="100%" id="'.
$cat_id .
'">';
while(list($page_id,$page) = @each($pages))
{
//we abuse the subtitle in a
nonstandard way: we want it to serve as a *short title* that is displayed
//in the tree menu, so that we can have
long titles on the page that would not be nice in the tree menu
$title = $page['subtitle'] ?
$page['subtitle'] : $page['title'];
$tree .= '<tr><td colspan="2">' .
(($page_id ==
$GLOBALS['page']->id) ?
('<span
style="color:red">' . $title . '</span>') :
('<a href="' .
sitemgr_link('page_name='. $page['name']) . '">' . $title . '</a>')
) .
'</td></tr>';
}
if ($subcats)
{
$tree .=
$this->showcat($GLOBALS['objbo']->getCatLinks($cat_id,False));
}
$tree .= '</table></td></tr>';
}
}
return $tree;
}
function get_content(&$arguments,$properties)
{
$title = '';
if ($arguments['menutree'])
{
$this->expandedcats =
array_keys($arguments['menutree']);
}
else
{
$this->expandedcats = Array();
}
$topcats = $GLOBALS['objbo']->getCatLinks(0,False);
$content = "<script type='text/javascript'>
// the whole thing only works in a DOM capable browser or IE 4*/
function add(catid)
{
document.cookie = '".$this->block->module_name."[menutree][' + catid +
']=';
}
function remove(catid)
{
var now = new Date();
document.cookie = '".$this->block->module_name."[menutree][' + catid +
']=; expires=' + now.toGMTString();
}
function toggle(image, catid)
{
if (document.getElementById)
{ //DOM capable
styleObj = document.getElementById(catid);
}
else //we're helpless
{
return
}
if (styleObj.style.display == 'none')
{
add(catid);
image.src = 'images/tree_collapse.gif';
styleObj.style.display = 'block';
}
else
{
remove(catid);
image.src = 'images/tree_expand.gif';
styleObj.style.display = 'none';
}
}
</script>";
if (count($topcats)==0)
{
$content=lang('You do not have access to any content on
this site.');
}
else
{
$content .= "\n" .
'<table border="0" cellspacing="0"
cellpadding="0" width="100%">' .
$this->showcat($topcats) .
'</table>' .
"\n";
$content .= '<br><a
href="'.sitemgr_link('toc=1').'"><font size="1">(' . lang('Table of contents')
. ')</font></a>';
}
return $content;
}
}
--- NEW FILE ---
<?php
class module_toc extends Module
{
function module_toc()
{
$this->arguments = array('category_id' => array('type'
=> 'textfield', 'label' => 'The category to display, 0 for complete table of
contents'));
$this->title = "Table of contents";
$this->description = "This module provides a complete
table of contents, it is automatically used by the toc and category_id GET
parameters";
}
function get_content(&$arguments,$properties)
{
global $objbo;
$category_id = $arguments['category_id'];
if ($category_id)
{
if($objbo->acl->can_read_category($category_id))
{
$links =
$objbo->getPageLinks($category_id,true);
$cat =
$objbo->getcatwrapper($category_id);
$content = '';
if ($cat)
{
$content .= '<b><a
href="'.sitemgr_link2('/index.php','toc=1').'">' . lang('Up to table of
contents') . '</a></b>';
if ($cat->depth)
{
$content .= ' | <b><a
href="'.sitemgr_link2('/index.php','category_id='.$cat->parent).'">' . lang('Up
to parent') . '</a></b>';
}
$children =
$objbo->getCatLinks((int) $category_id,false);
if (count($children))
{
$content .=
'<br><br><b>' . lang('Subcategories') . ':</b><br>';
foreach ($children as
$child)
{
$content .=
'<br> · <b>'.
$child['link'].'</b> – '.$child['description'];
}
}
$content .= '<br><br><b>' .
lang('Pages') . ':</b><br>';
$links =
$objbo->getPageLinks($category_id,true);
if (count($links)>0)
{
foreach($links as $pg)
{
$content .=
"\n<br>".
' · '.$pg['link'];
if
(!empty($pg['subtitle']))
{
$content .= ' – <i>'.$pg['subtitle'].'</i>';
}
$content .= '';
}
}
else
{
$content .= '<li>' .
lang('There are no pages in this section') . '</li>';
}
}
else
{
$content = lang('There was an
error accessing the requested page. Either you do not have permission to view
this page, or the page does not exist.');
}
}
else
{
$content = lang('There was an error
accessing the requested page. Either you do not have permission to view this
page, or the page does not exist.');
}
}
else
{
$content = '<b>' . lang('Choose a category') .
':</b><br>';
$links = $objbo->getCatLinks();
if (count($links)>0)
{
foreach($links as $cat)
{
$buffer = str_pad('',
$cat['depth']*24,' ').'· ';
if (!$cat['depth'])
{
$buffer =
'<br>'.$buffer;
}
$content .=
"\n".$buffer.$cat['link'].' — <i>'.$cat['description'].
'</i><br>';
}
}
else
{
$content .= lang('There are no sections
available to you.');
}
}
return $content;
}
}
?>
--- NEW FILE ---
<?php
class module_toc_block extends Module
{
function module_toc_block()
{
$this->arguments = array();
$this->title = "Table of contents";
$this->description = "This module provides a condensed table of
contents, meant for side areas";
}
function get_content(&$arguments,$properties)
{
global $objbo;
$indexarray = $objbo->getCatLinks();
$content = "\n".'<table border="0" cellspacing="0"
cellpadding="0" width="100%">'.
'<tr><td>';
foreach($indexarray as $cat)
{
$space = str_pad('',$cat['depth']*18,' ');
$content .= "\n".'<table border="0" cellspacing="0"
cellpadding="0" '.
'width="100%"><tr><td align="right"
valign="top" width="5">'.
$space.'· </td><td
width="100%"><b>'.
$cat['link'].'</b></td></tr></table>';
}
$content .= "\n</td></tr></table>";
if (count($indexarray)==0)
{
$content=lang('You do not have access to any content on
this site.');
}
return $content;
}
}
?>
--- NEW FILE ---
<?php
class module_xml extends Module
{
var $filenumber;
function module_xml()
{
$this->arguments = array(
'dirpath' => array('type' => 'textfield', 'label' =>
'Filesystem path of the directory where XML files are stored'),
'filename' => array('type' => 'textfield', 'label' =>
'the XML files\' common name'),
'xsltfile' => array('type' => 'textfield', 'label' =>
'Full path of the XSLT file that should be applied to the XML files')
);
$this->post = array(
'prev' => array(
'type' => 'submit',
'value' => lang('Previous')
),
'next' => array(
'type' => 'submit',
'value' => lang('Next')
)
);
$this->session = array('filenumber');
$this->title = "XML browser";
$this->description = "This module permits browsing through XML
files stored in a directory, and transformed by XSLT";
}
function set_block($block,$produce=False)
{
parent::set_block($block,$produce);
if ($produce)
{
if (!$this->block->arguments['filenumber'])
{
$this->block->arguments['filenumber'] = 1;
}
else
{
$this->block->arguments['filenumber'] =
(int)$this->block->arguments['filenumber'];
}
if ($this->block->arguments['next'])
{
$this->block->arguments['filenumber']++;
}
elseif ($this->block->arguments['prev'])
{
$this->block->arguments['filenumber']--;
}
if ($this->block->arguments['filenumber'] < 1 ||
!file_exists(
$this->block->arguments['dirpath'] .
SEP . $this->block->arguments['filename'] .
$this->block->arguments['filenumber'] .
'.xml'
))
{
$this->block->arguments['filenumber'] = 1;
}
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP
. 'inc' . SEP . 'class.xslt_transform.inc.php');
$this->add_transformer(new
xslt_transform($this->block->arguments['xsltfile']));
$prevlink = ($this->block->arguments['filenumber'] > 1)
? $this->build_post_element('prev') : '';
$nextlink =
(file_exists(
$this->block->arguments['dirpath'] .
SEP . $this->block->arguments['filename'] .
($this->block->arguments['filenumber']
+ 1) . '.xml'
)) ?
$this->build_post_element('next') :
'';
require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP
. 'inc' . SEP . 'class.browser_transform.inc.php');
$this->add_transformer(new
browser_transform($prevlink,$nextlink,$this->block->module_name));
}
}
function get_content(&$arguments,$properties)
{
return implode('',@file($arguments['dirpath'] . SEP .
$arguments['filename'] . $arguments['filenumber'] . '.xml'));
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: sitemgr/modules class.module_administration.inc.php,NONE,1.1 class.module_amazon.inc.php,NONE,1.1class.module_appdir.inc.php,NONE,1.1 class.module_calendar.inc.php,NONE,1.1 class.module_currentsection.inc.php,NONE,1.1 class.module_forum.inc.php,NONE,1.1class.module_galerie.inc.php,NONE,1.1 class.module_google.inc.php,NONE,1.1class.module_hello.inc.php,NONE,1.1 class.module_html.inc.php,NONE,1.1class.module_index.inc.php,NONE,1.1 class.module_index_block.inc.php,NONE,1.1 class.module_lang_block.inc.php,NONE,1.1 class.module_login.inc.php,NONE,1.1class.module_news.inc.php,NONE,1.1 class.module_redirect.inc.php,NONE,1.1 class.module_sitetree.inc.php,NONE,1.1class.module_toc.inc.php,NONE,1.1 class.module_toc_block.inc.php,NONE,1.1class.module_xml.inc.php,NONE,1.1,
Michael Totschnig <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: sitemgr/inc class.module_administration.inc.php,1.1,NONE class.module_amazon.inc.php,1.2,NONEclass.module_appdir.inc.php,1.4,NONE class.module_calendar.inc.php,1.4,NONE class.module_currentsection.inc.php,1.1,NONE class.module_forum.inc.php,1.4,NONEclass.module_galerie.inc.php,1.3,NONE class.module_google.inc.php,1.1,NONEclass.module_hello.inc.php,1.3,NONE class.module_html.inc.php,1.1,NONEclass.module_index.inc.php,1.1,NONE class.module_index_block.inc.php,1.1,NONE class.module_lang_block.inc.php,1.2,NONE class.module_login.inc.php,1.2,NONEclass.module_news.inc.php,1.2,NONE class.module_redirect.inc.php,1.2,NONE class.module_sitetree.inc.php,1.4,NONEclass.module_toc.inc.php,1.1,NONE class.module_toc_block.inc.php,1.1,NONEclass.module_xml.inc.php,1.2,NONE
- Next by Date:
[Phpgroupware-cvs] CVS: wiki/admin index.php,1.3,1.4
- Previous by thread:
[Phpgroupware-cvs] CVS: sitemgr/inc class.module_administration.inc.php,1.1,NONE class.module_amazon.inc.php,1.2,NONEclass.module_appdir.inc.php,1.4,NONE class.module_calendar.inc.php,1.4,NONE class.module_currentsection.inc.php,1.1,NONE class.module_forum.inc.php,1.4,NONEclass.module_galerie.inc.php,1.3,NONE class.module_google.inc.php,1.1,NONEclass.module_hello.inc.php,1.3,NONE class.module_html.inc.php,1.1,NONEclass.module_index.inc.php,1.1,NONE class.module_index_block.inc.php,1.1,NONE class.module_lang_block.inc.php,1.2,NONE class.module_login.inc.php,1.2,NONEclass.module_news.inc.php,1.2,NONE class.module_redirect.inc.php,1.2,NONE class.module_sitetree.inc.php,1.4,NONEclass.module_toc.inc.php,1.1,NONE class.module_toc_block.inc.php,1.1,NONEclass.module_xml.inc.php,1.2,NONE
- Next by thread:
[Phpgroupware-cvs] CVS: wiki/admin index.php,1.3,1.4
- Index(es):