[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare SiteMgr - Web Content Management * 4 * http://www.egroupware.org * 5 * -------------------------------------------- * 6 * This program is free software; you can redistribute it and/or modify it * 7 * under the terms of the GNU General Public License as published by the * 8 * Free Software Foundation; either version 2 of the License, or (at your * 9 * option) any later version. * 10 \**************************************************************************/ 11 12 /* $Id: class.module_news.inc.php 22670 2006-10-18 06:10:37Z ralfbecker $ */ 13 14 class module_news extends Module 15 { 16 function module_news() 17 { 18 //specification of options is postponed into the get_user_interface function 19 $this->arguments = array( 20 'category' => array('type' => 'select', 'label' => lang('Choose a category'), 'options' => array()), 21 'rsslink' => array('type' => 'checkbox', 'label' => lang('Do you want to publish a RSS feed for this news category')), 22 'limit' => array( 23 'type' => 'textfield', 24 'label' => lang('Number of news items to be displayed on page'), 25 'params' => array('size' => 3) 26 ), 27 'layout' => array( 28 'type' => 'select', 29 'label' => lang('Choose news layout'), 30 'options' => array( 31 'complete' => lang('Complete News'), 32 'header' => lang('show only headers containing links for complete news') 33 ), 34 ), 35 ); 36 $this->get = array('item','start'); 37 $this->session = array('item','start'); 38 $this->properties = array(); 39 $this->title = lang('News module'); 40 $this->description = lang('This module publishes news from the news_admin application on your website. Be aware of news_admin\'s ACL restrictions.'); 41 $this->template; 42 } 43 44 function get_user_interface() 45 { 46 if (!is_dir(EGW_SERVER_ROOT.'/news_admin') || !isset($GLOBALS['egw_info']['apps']['news_admin'])) 47 { 48 return lang("Application '%1' is not installed !!!<br>Please install it, to be able to use the block.",'news_admin'); 49 } 50 //we could put this into the module's constructor, but by putting it here, we make it execute only when the block is edited, 51 //and not when it is generated for the web site, thus speeding the latter up slightly 52 $cat = createobject('phpgwapi.categories','','news_admin'); 53 $cats = $cat->return_array('all',0,False,'','','cat_name',True); 54 if ($cats) 55 { 56 $cat_ids['all'] = lang('All categories'); 57 while (list(,$category) = each($cats)) 58 { 59 $cat_ids[$category['id']] = $category['name']; 60 } 61 } 62 $this->arguments['category']['options'] = $cat_ids; 63 return parent::get_user_interface(); 64 } 65 66 function get_content(&$arguments,$properties) 67 { 68 if (!is_dir(EGW_SERVER_ROOT.'/news_admin') || !isset($GLOBALS['egw_info']['apps']['news_admin'])) 69 { 70 return lang("Application '%1' is not installed !!!<br>Please install it, to be able to use the block.",'news_admin'); 71 } 72 $bonews =& CreateObject('news_admin.bonews'); 73 74 $arguments['layout'] = $arguments['layout'] ? $arguments['layout'] : 'complete'; 75 $this->template = Createobject('phpgwapi.Template',$this->find_template_dir()); 76 $this->template->set_file('news',$arguments['layout'].'_style.tpl'); 77 $this->template->set_block('news','NewsBlock','newsitem'); 78 $this->template->set_block('news','RssBlock','rsshandle'); 79 80 $limit = $arguments['limit'] ? $arguments['limit'] : 5; 81 82 if ($arguments['rsslink']) 83 { 84 $this->template->set_var('rsslink', 85 $GLOBALS['egw_info']['server']['webserver_url'] . '/news_admin/website/export.php?cat_id=' . $arguments['category']); 86 $this->template->parse('rsshandle','RssBlock'); 87 } 88 else 89 { 90 $this->template->set_var('rsshandle',''); 91 } 92 93 // somehow $arguments['item'] is set to some whitespace 94 // i have no idea why :( 95 // so i added trim 96 // lkneschke 2004-02-24 97 $item = $arguments['item'] ? $arguments['item'] : $_GET['item']; 98 trim($item); 99 if ($item) 100 { 101 $newsitem = $bonews->get_news($item); 102 if ($newsitem && ($newsitem['category'] == $arguments['category'])) 103 { 104 $this->render($newsitem,$arguments['layout']); 105 $link_data['item'] = 0; 106 $this->template->set_var('morelink', 107 '<a href="' . $this->link($link_data) . '">' . lang('More news') . '</a>' 108 ); 109 return $this->template->parse('out','news'); 110 // return $this->template->get_var('newsitem'); 111 } 112 else 113 { 114 return lang('No matching news item'); 115 } 116 } 117 118 119 $newslist = $bonews->get_newslist($arguments['category'],$arguments['start'],'','',$limit,True); 120 121 while (list(,$newsitem) = @each($newslist)) 122 { 123 $this->render($newsitem,$arguments['layout']); 124 } 125 if ($arguments['start']) 126 { 127 $link_data['start'] = $arguments['start'] - $limit; 128 $this->template->set_var('lesslink', 129 '<a href="' . $this->link($link_data) . '"><<<</a>' 130 ); 131 } 132 if ($bonews->total > $arguments['start'] + $limit) 133 { 134 $link_data['start'] = $arguments['start'] + $limit; 135 $this->template->set_var('morelink', 136 '<a href="' . $this->link($link_data) . '">' . lang('More news') . '</a>' 137 ); 138 } 139 return $this->template->parse('out','news'); 140 } 141 142 function render($newsitem,$layout='complete') 143 { 144 switch($layout) 145 { 146 case 'header' : 147 $this->template->set_var(array( 148 'news_date' => $arguments['header_show_date'] ? $GLOBALS['egw']->common->show_date($newsitem['date'],'d.m.y') : '', 149 'news_title' => '<a href="'. $this->link(false,false,array( 0 => 150 array( 151 'module_name' => 'news', 152 'arguments' => array( 153 'layout' => 'complete', 154 'item' => $newsitem['id'], 155 'category' => $newsitem['category'], 156 ), 157 'page' => false, 158 'area' => false, 159 'sort_order' => false 160 ) 161 )). '">'. $newsitem['subject']. '</a>' 162 )); 163 break; 164 165 default: 166 case 'complete' : 167 $data = $GLOBALS['egw']->accounts->get_account_data($newsitem['submittedby']); 168 $this->template->set_var(array( 169 'news_title' => $newsitem['subject'], 170 'news_submitter' => lang('Submitted by') . ' ' . $data[$newsitem['submittedby']]['fullname'], 171 'news_date' => $GLOBALS['egw']->common->show_date($newsitem['date']), 172 'news_content' => $newsitem['content'] 173 )); 174 break; 175 } 176 $this->template->parse('newsitem','NewsBlock',True); 177 } 178 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |