phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] news_admin/inc class.bonews.inc.php, 1.5 class.soacl.


From: skwashd
Subject: [Phpgroupware-cvs] news_admin/inc class.bonews.inc.php, 1.5 class.soacl.inc.php, 1.2 class.boexport.inc.php, 1.2 class.boacl.inc.php, 1.2 class.soexport.inc.php, 1.2 class.sonews.inc.php, 1.5 hook_home.inc.php, 1.4 hook_admin.inc.php, 1.10 class.uinews.inc.php, 1.28 class.uiacl.inc.php, 1.2 class.uiexport.inc.php, 1.2
Date: Wed, 25 May 2005 03:19:00 +0200

Update of news_admin/inc

Modified Files:
     Branch: MAIN
            class.bonews.inc.php lines: +2 -84
            class.soacl.inc.php lines: +16 -4
            class.boexport.inc.php lines: +1 -1
            class.boacl.inc.php lines: +14 -4
            class.soexport.inc.php lines: +1 -1
            class.sonews.inc.php lines: +0 -0
            hook_home.inc.php lines: +3 -3
            hook_admin.inc.php lines: +1 -1
            class.uinews.inc.php lines: +283 -82
            class.uiacl.inc.php lines: +1 -1
            class.uiexport.inc.php lines: +9 -3

Log Message:
New CSS version, also supports WYSIWYG editor, still has some kinks to be 
ironed out

====================================================
Index: news_admin/inc/class.bonews.inc.php
diff -u news_admin/inc/class.bonews.inc.php:1.4 
news_admin/inc/class.bonews.inc.php:1.5
--- news_admin/inc/class.bonews.inc.php:1.4     Sun May 15 12:25:42 2005
+++ news_admin/inc/class.bonews.inc.php Wed May 25 01:19:51 2005
@@ -183,67 +183,6 @@
                        }
                }

-               //return the selectboxes with calculated defaults, and change 
begin and end by sideaffect
-               function get_options(&$news)
-               {
-                       $now = time();
-                       //always is default
-                       if (!isset($news['begin']))
-                       {
-                               //these are only displayed values not 
necessarily the ones that will get stored
-                               $news['begin'] = $now;
-                               $news['end'] = $now;
-                               $from = 1;
-                               $until = 1;
-                       }
-                       //if enddate is in the past set option to never
-                       elseif ($news['end'] < $now)
-                       {
-                               $news['begin'] = $now;
-                               $news['end'] = $now;
-                               $from = 0;
-                               $until = 1;
-                       }
-                       else
-                       {
-                               if ($news['begin'] < $now)
-                               {
-                                       $news['begin'] = $now;
-                                       if ($news['end'] == 
$this->unixtimestampmax)
-                                       {
-                                               $news['end'] = $now;
-                                               $from = 1;
-                                               $until = 1;
-                                       }
-                                       else
-                                       {
-                                               $from = 0.5;
-                                               $until = 0.5;
-                                       }
-                               }
-                               else
-                               {
-                                       if ($news['end'] == 
$this->unixtimestampmax)
-                                       {
-                                               $news['end'] = $now;
-                                               $from = 0.5;
-                                               $until = 1;
-                                       }
-                                       else
-                                       {
-                                               $from = 0.5;
-                                               $until = 0.5;
-                                       }
-                               }
-                       }
-                       $options['from'] = '<option value="1"' . (($from == 1) 
? ' selected="selected"' : '') . '>' . lang('Always') . '</option>';
-                       $options['from'] .= '<option value="0"' . (($from == 0) 
? ' selected="selected"' : '') . '>' . lang('Never') . '</option>';
-                       $options['from'] .= '<option value="0.5"' . (($from == 
0.5) ? ' selected="selected"' : '') . '>' . lang('From') . '</option>';
-                       $options['until'] = '<option value="1"' . (($until == 
1) ? ' selected="selected"' : '') . '>' . lang('Always') . '</option>';
-                       $options['until'] .= '<option value="0.5"' . (($until 
== 0.5) ? ' selected="selected"' : '') . '>' . lang('until') . '</option>';
-                       return $options;
-               }
-
                //set the begin and end dates
                function set_dates($from,$until,&$news)
                {
@@ -260,34 +199,13 @@
                                        $news['end'] = 0;
                                        break;
                                default:
-                                       $news['begin'] = 
mktime(0,0,0,intval($news['begin_m']), intval($news['begin_d']), 
intval($news['begin_y']));
-                                       switch($until)
+                                       if ( $until )
                                        {
-                                               case 1:
-                                                       $news['end'] = 
$this->unixtimestampmax;
-                                                       break;
-                                               default:
-                                                       $news['end'] = 
mktime(0,0,0,intval($news['end_m']), intval($news['end_d']), 
intval($news['end_y']));
+                                               $news['end'] = 
$this->unixtimestampmax;
                                        }
                        }
                }

-//             function format_fields($fields)
-//             {
-//                     $cat = createobject('phpgwapi.categories','news_admin');
-
-//                     $item = array(
-//                             'id'          => $fields['id'],
-//                             'date'        => 
$GLOBALS['phpgw']->common->show_date($fields['date']),
-//                             'subject'     => 
$GLOBALS['phpgw']->strip_html($fields['subject']),
-//                             'submittedby' => $fields['submittedby'],
-//                             'content'     => $fields['content'],
-//                             'status'      => lang($fields['status']),
-//                             'cat'         => $cat->id2name($fields['cat'])
-//                     );
-//                     return $item;
-//             }
-
                function get_news($news_id)
                {
                        $news = $this->sonews->get_news($news_id);

====================================================
Index: news_admin/inc/class.soacl.inc.php
diff -u news_admin/inc/class.soacl.inc.php:1.1 
news_admin/inc/class.soacl.inc.php:1.2
--- news_admin/inc/class.soacl.inc.php:1.1      Tue Jun  3 03:15:12 2003
+++ news_admin/inc/class.soacl.inc.php  Wed May 25 01:19:51 2005
@@ -39,14 +39,26 @@
                        $this->db->query($sql,__LINE__,__FILE__);
                }

-               function get_permissions($user)
+               function get_permissions($user, $inc_groups)
                {
+                       $groups = 
$GLOBALS['phpgw']->acl->get_location_list_for_id('phpgw_group', 1, $user);
                        $result = array();
-                       $sql = "select acl_location, acl_rights from phpgw_acl 
where acl_appname = 'news_admin' and acl_account = $user";
+                       $sql  = 'SELECT acl_location, acl_rights FROM phpgw_acl 
';
+                       $sql .= "WHERE acl_appname = 'news_admin' ";
+                       if($inc_groups)
+                       {
+                               $sql .= 'AND acl_account IN('. intval($user);
+                               $sql .= ($groups ? ',' . implode(',', $groups) 
: '');
+                               $sql .= ')';
+                       }
+                       else
+                       {
+                               $sql .= 'AND acl_account ='. intval($user);
+                       }
                        $this->db->query($sql,__LINE__,__FILE__);
                        while ($this->db->next_record())
                        {
-                               $result[$this->db->f('acl_location')] = 
$this->db->f('acl_rights');
+                               $result[$this->db->f('acl_location')] |= 
$this->db->f('acl_rights');
                        }
                        return $result;
                }

====================================================

====================================================
Index: news_admin/inc/class.boacl.inc.php
diff -u news_admin/inc/class.boacl.inc.php:1.1 
news_admin/inc/class.boacl.inc.php:1.2
--- news_admin/inc/class.boacl.inc.php:1.1      Tue Jun  3 03:15:12 2003
+++ news_admin/inc/class.boacl.inc.php  Wed May 25 01:19:51 2005
@@ -52,7 +52,7 @@
 //                             $this->cats = 
array_merge($main_cat,$this->catbo->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True));
                                $this->cats = 
$this->catbo->return_array('all',$this->start,True,$this->query,$this->sort,'cat_name',True);
                        }
-                       $this->permissions = $this->get_permissions();
+                       $this->permissions = $this->get_permissions(True);
                }

                function save_sessiondata()
@@ -90,6 +90,16 @@
                        return $this->permissions['L'.$cat_id] & $right;
                }

+               function is_readable($cat_id)
+               {
+                       return $this->is_permitted($cat_id,PHPGW_ACL_READ);
+               }
+
+               function is_writeable($cat_id)
+               {
+                       return $this->is_permitted($cat_id,PHPGW_ACL_ADD);
+               }
+
                function set_rights($cat_id,$read,$write)
                {
                        $readcat = $read ? $read : array();
@@ -112,8 +122,8 @@
                }

                //access permissions for current user
-               function get_permissions()
+               function get_permissions($inc_groups = False)
                {
-                       return 
$this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id']);
+                       return 
$this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id'], 
$inc_groups);
                }
        }
\ No newline at end of file

====================================================

====================================================

====================================================
Index: news_admin/inc/hook_home.inc.php
diff -u news_admin/inc/hook_home.inc.php:1.3 
news_admin/inc/hook_home.inc.php:1.4
--- news_admin/inc/hook_home.inc.php:1.3        Sat Dec 29 12:48:10 2001
+++ news_admin/inc/hook_home.inc.php    Wed May 25 01:19:51 2005
@@ -14,6 +14,6 @@

        /* $Id$ */

-       $news = createobject('news_admin.uinews');
-       $news->show_news_home();
+//     $news = createobject('news_admin.uinews');
+//     $news->show_news_home();
 ?>

====================================================

====================================================
Index: news_admin/inc/class.uinews.inc.php
diff -u news_admin/inc/class.uinews.inc.php:1.27 
news_admin/inc/class.uinews.inc.php:1.28
--- news_admin/inc/class.uinews.inc.php:1.27    Sun May 15 12:25:42 2005
+++ news_admin/inc/class.uinews.inc.php Wed May 25 01:19:51 2005
@@ -8,8 +8,10 @@
        *  Free Software Foundation; either version 2 of the License, or (at 
your  *
        *  option) any later version.                                           
   *
        * --------------------------------------------                          
   *
-       * This program was sponsered by Golden Glair productions                
   *
-       * http://www.goldenglair.com                                            
   *
+       * The original version of this program                                  
   *
+       * was sponsered by Golden Glair productions - 
http://www.goldenglair.com   *
+       *                                                                       
   *
+       * Many enhancements were sponsored by ecotrader.net                     
   *
        
\**************************************************************************/

        /* $Id$ */
@@ -50,7 +52,7 @@
                }

                //with $default, we are called from the news form
-               function selectlist($type,$default=false)
+               function selectlist($type, $default=false)
                {
                        $link_data['menuaction'] = ($type == 'read') ? 
'news_admin.uinews.read_news' : 'news_admin.uinews.write_news';
                        $link_data['start'] = 0;
@@ -79,73 +81,165 @@
                        return $selectlist;
                }

+               /**
+               * Display a list of news items for the user to read
+               */
                function read_news()
                {
                        $limit = ($GLOBALS['phpgw_info']['common']['maxmatchs']
-                                ? 
$GLOBALS['phpgw_info']['common']['maxmatchs'] : 5);
+                                ? 
$GLOBALS['phpgw_info']['common']['maxmatchs'] : 10 );

-                       $news_id = get_var('news_id',Array('GET'));
+                       $news_id = get_var('news_id', array('GET'));

                        $news = $news_id ? array($news_id => 
$this->bo->get_news($news_id)) :
                                
$this->bo->get_newslist($this->cat_id,$this->start,'','',$limit,True);

-                       $this->template->set_file(array(
-                               'main' => 'read.tpl'
-                       ));
-                       $this->template->set_block('main','news_form');
-                       $this->template->set_block('main','row');
-                       $this->template->set_block('main','row_empty');
+                       $this->template->set_file('news', 'read.tpl');
+                       $this->template->set_block('news', 'cat_option', 
'cat_options');
+                       $this->template->set_block('news', 'cat_form', 
'cat_frm');
+                       $this->template->set_block('news', 'less_li', 'less');
+                       $this->template->set_block('news', 'maintain_li', 
'maintain');
+                       $this->template->set_block('news', 'more_li', 'more');
+                       $this->template->set_block('news', 'news_item', 
'news_items');
+                       $this->template->set_block('news', 'summary_item', 
'summary_items');
+                       $this->template->set_block('news','news_summary', 
'news_sum');
+
+                       $GLOBALS['phpgw_info']['flags']['css'] .= 
'</style><link rel="StyleSheet" href="news_admin/css/base.css"/><style 
type="text/css">';

                        $GLOBALS['phpgw']->common->phpgw_header();
                        echo parse_navbar();
-                       $this->template->set_block('main','category');
-                       $var['lang_read'] = lang('Read');
-                       $var['lang_write'] = lang('Write');
-                       $var['readable'] = $this->selectlist('read');
-                       $var['maintainlink'] = (($this->cat_id != 'all') && 
$this->bo->acl->is_permitted($this->cat_id,PHPGW_ACL_ADD)) ?
-                               ('<a href="' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.write_news&start=0&cat_id='.$this->cat_id)
 .
-                                       '">' . lang('Maintain') . '</a>') :
-                               '';
-                       $var['cat_name'] = ($this->cat_id != 'all') ? 
$this->bo->catbo->id2name($this->cat_id) : lang('All news');
+
+                       $cats = ( is_array($this->bo->cats) && 
count($this->bo->cats) ) ? $this->bo->cats : array();
+
+                       $this->template->set_var(
+                                               array
+                                                       (
+                                                               'cat_id'        
=> 0,
+                                                               'cat_name'      
=> lang('all news')
+                                                       )
+                                               );
+                       $this->template->parse('cat_options', 'cat_option', 
true);
+                       foreach($cats as $cat)
+                       {
+                               if($this->bo->acl->is_permitted($cat['id'], 
PHPGW_ACL_READ))
+                               {
+                                       $this->template->set_var(
+                                                               array
+                                                                       (
+                                                                               
'cat_id'        => (int) $cat['id'],
+                                                                               
'cat_name'      => htmlentities($cat['name']),
+                                                                               
'selected'      => ($this->bo->cat_id == $cat['id']
+                                                                               
                        ? 'selected="selected"'
+                                                                               
                        : '')
+                                                                       )
+                                                               );
+                                       $this->template->parse('cat_options', 
'cat_option', True);
+                               }
+                       }
+                       $this->template->set_var('lang_go', lang('go') );
+                       $this->template->parse('cat_frm', 'cat_form');
+
+                       $var['lang_read'] = lang('read');
+                       $var['lang_write'] = lang('write');
+                       $var['cat_name'] = ($this->cat_id != 'all') ? 
$this->bo->catbo->id2name($this->cat_id) : lang('all news');
                        $this->template->set_var($var);
-                       $this->template->parse('_category','category');

-                       
$this->template->set_var('icon',$GLOBALS['phpgw']->common->image('news_admin','news-corner.gif'));
+                       if ( ($this->cat_id != 'all') && 
$this->bo->acl->is_permitted($this->cat_id, PHPGW_ACL_ADD)
+                               || 
isset($GLOBALS['phpgw_info']['user']['apps']['admin']) )
+                       {
+                               $this->template->set_var(
+                                                       array
+                                                               (
+                                                                       
'href_maintain' => $GLOBALS['phpgw']->link('/index.php',
+                                                                               
                array(
+                                                                               
                        'menuaction'    => 'news_admin.uinews.write_news',
+                                                                               
                        'start'         => 0,
+                                                                               
                        'cat_id'        => $this->cat_id
+                                                                               
                        )
+                                                                               
                ),
+                                                                       
'lang_maintain' => lang('maintain')
+                                                               )
+                                                       );

-                       foreach($news as $newsitem)
+                               $this->template->parse('maintain', 
'maintain_li');
+                       }
+                       else
                        {
-                               $var = Array(
+                               $this->template->set_var('maintain', '&nbsp;');
+                       }
+
+                       if ( !$this->bo->total )
+                       {
+                               $this->template->set_var('content', lang('No 
entries found') );
+                               $this->template->parse('news_itm', 'news_item', 
True);
+                               $this->template->pfp('out', 'news');
+                               exit;
+                       }
+                       elseif ( $news_id )
+                       {
+                               $newsitem = &$news[$news_id];
+                               //echo '<pre>' . print_r($newsitem, True) . 
'</pre>';
+                               $var = array(
                                        'subject'       => $newsitem['subject'],
-                                       'submitedby'    => 'Submitted by ' . 
$GLOBALS['phpgw']->accounts->id2name($newsitem['submittedby']) . ' on ' . 
$GLOBALS['phpgw']->common->show_date($newsitem['date']),
+                                       'submission'    => lang('submitted by 
%1 on %2',
+                                                               
$GLOBALS['phpgw']->accounts->id2name($newsitem['submittedby']),
+                                                               
$GLOBALS['phpgw']->common->show_date($newsitem['date']) ),
                                        'content'       => 
($newsitem['is_html'] ? $newsitem['content'] : nl2br($newsitem['content'])),
                                );

                                $this->template->set_var($var);
-                               $this->template->parse('rows','row',True);
+                               $this->template->parse('news_items', 
'news_item', True);
+                       }
+                       else
+                       {
+                               foreach($news as $newsitem)
+                               {
+                                       $var = array(
+                                               'subject'       => 
$newsitem['subject'],
+                                               'submission'    => 
lang('submitted by %1 on %2',
+                                                                       
$GLOBALS['phpgw']->accounts->id2name($newsitem['submittedby']),
+                                                                       
$GLOBALS['phpgw']->common->show_date($newsitem['date']) ),
+                                               'summary'       => 
$newsitem['teaser'],
+                                               'lang_read'     => lang('read 
full story'),
+                                               'href_read'     => 
$GLOBALS['phpgw']->link('/index.php',
+                                                                       array
+                                                                               
(
+                                                                               
        'menuaction'    => 'news_admin.uinews.read_news',
+                                                                               
        'news_id'       => $newsitem['id']
+                                                                               
)
+                                                                       )
+                                       );
+
+                                       $this->template->set_var($var);
+                                       $this->template->parse('summary_items', 
'summary_item', True);
+                               }
+                               $this->template->parse('news_sum', 
'news_summary', True);
                        }
-                       if ($this->start)
+
+                       if ( !$news_id && $this->start )
                        {
                                $link_data['menuaction'] = 
'news_admin.uinews.read_news';
                                $link_data['start'] = $this->start - $limit;
-                               $this->template->set_var('lesslink',
-                                       '<a href="' . 
$GLOBALS['phpgw']->link('/index.php',$link_data) . '">&lt;&lt;&lt;</a>'
-                               );
+                               $this->template->set_var('lesslink', 
$GLOBALS['phpgw']->link('/index.php', $link_data) );
+                               $this->template->parse('less', 'less_li');
                        }
-                       if ($this->bo->total > $this->start + $limit)
+                       else
+                       {
+                               $this->template->set_var('less', '&nbsp;');
+                       }
+
+                       if ( !$news_id && ($this->bo->total > $this->start + 
$limit) )
                        {
                                $link_data['menuaction'] = 
'news_admin.uinews.read_news';
                                $link_data['start'] = $this->start + $limit;
-                               $this->template->set_var('morelink',
-                                       '<a href="' . 
$GLOBALS['phpgw']->link('/index.php',$link_data) . '">' . lang('More news') . 
'</a>'
-                               );
+                               $this->template->set_var('morelink', 
$GLOBALS['phpgw']->link('/index.php',$link_data) );
+                               $this->template->parse('more', 'less_li');
                        }
-                       if (! $this->bo->total)
+                       else
                        {
-                               $this->template->set_var('row_message',lang('No 
entries found'));
-                               $this->template->parse('rows','row_empty',True);
+                               $this->template->set_var('more', '&nbsp;');
                        }
-
-                       $this->template->pfp('_out','news_form');
+                       $this->template->pfp('out','news');
                }

                //this is currently broken
@@ -276,7 +370,7 @@
                        if($_POST['cancel'])
                        {
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.write_news'));
-                               return;
+                               exit;
                        }
                        if($_POST['submitit'])
                        {
@@ -348,6 +442,7 @@

                function edit()
                {
+                       $jscal = createObject('phpgwapi.jscalendar', False);
                        $this->news_data        = $_POST['news'];
                        $this->news_id          = (isset($_GET['news_id']) ? 
$_GET['news_id']
                                                                                
: $_POST['news']['id']);
@@ -368,9 +463,17 @@
                                        $errors[] = lang('The news content is 
missing');
                                }

+                               $begin = 
$jscal->input2date($this->news_data['begin']);
+                               $this->news_data['being'] = $begin['raw'];
+                               unset($begin);
+
+                               $end = 
$jscal->input2date($this->news_data['end']);
+                               $this->news_data['end']   = $end['raw'];
+                               unset($end);
+
                                if(!is_array($errors))
                                {
-                                       
$this->bo->set_dates($_POST['from'],$_POST['until'],$this->news_data);
+                                       $this->bo->set_dates($_POST['from'], 
$_POST['until'], $this->news_data);
                                        $this->bo->edit($this->news_data);
                                        $this->message = lang('News item has 
been updated');
                                }
@@ -379,31 +482,47 @@
                                        $this->message = $errors;
                                }
                        }
-                       /*else
-                       {*/
-                               $this->news_data = 
$this->bo->get_news($this->news_id,True);
-                               $this->news_data['date_d'] = 
date('j',$this->news_data['begin']);
-                               $this->news_data['date_m'] = 
date('n',$this->news_data['begin']);
-                               $this->news_data['date_y'] = 
date('Y',$this->news_data['begin']);
-                       /*}*/
+
+                       $this->news_data = 
$this->bo->get_news($this->news_id,True);
                        $this->modify();
                }

                function modify($type = 'edit')
                {
-                       $options = $this->bo->get_options($this->news_data);
+                       if ( !is_object($GLOBALS['phpgw']->js) )
+                       {
+                               $GLOBALS['phpgw']->js = 
CreateObject('phpgwapi.javascript');
+                       }
+
+                       $GLOBALS['phpgw']->js->validate_file('base', 'toggle', 
'news_admin');
+                       $GLOBALS['phpgw']->js->validate_file('fckeditor', 
'fckconfig', 'news_admin');
+                       $GLOBALS['phpgw']->js->validate_file('fckeditor', 
'fckeditor', 'news_admin');
+                       $GLOBALS['phpgw_info']['flags']['java_script'] = '
+                               <script type="text/javascript">
+                               <!--
+                               window.onload = function()
+                               {
+                                       var oFCKeditor = new 
FCKeditor(\'news[content]\');
+                                       oFCKeditor.ReplaceTextarea();
+                                       toggle();
+                               }
+                               //-->
+                               </script>';
+
+                       $jscal = createObject('phpgwapi.jscalendar');
+
+                       $GLOBALS['phpgw_info']['flags']['css'] .= 
'</style><link rel="StyleSheet" href="news_admin/css/base.css"/><style 
type="text/css">';
+
                        $GLOBALS['phpgw']->common->phpgw_header();
                        echo parse_navbar();

-                       $this->template->set_file(array(
-                               'form' => 'admin_form.tpl'
-                       ));
+                       $this->template->set_file( array('form' => 
'admin_form.tpl') );

-                       if (is_array($this->message))
+                       if ( is_array($this->message) )
                        {
                                
$this->template->set_var('errors',$GLOBALS['phpgw']->common->error_list($this->message));
                        }
-                       elseif($this->message)
+                       elseif ( $this->message )
                        {
                                
$this->template->set_var('errors',$this->message);
                        }
@@ -418,39 +537,34 @@

                        //echo '<br />UI:<br /><pre>'; 
print_r($this->news_data); echo '</pre>';

-                       $this->template->set_var(array(
-                               'form_button' => '<input type="submit" 
name="submitit" value="' . lang('save') . '">',
-                               'value_id' => $this->news_id,
-                               'done_button' => '<input type="submit" 
name="cancel" value="' . lang('Done') . '">',
-                               'label_subject' => lang('subject') . ':',
-                               'value_subject' => '<input name="news[subject]" 
size="60" value="' . htmlentities($this->news_data['subject']) . '">',
-                               'label_teaser' => lang('teaser') . ':',
-                               'value_teaser' => '<input name="news[teaser]" 
size="60" value="' . htmlentities($this->news_data['teaser']) . '" 
maxLength=100>',
-                               'label_content' => lang('Content') . ':',
-                               'value_content' => '<textarea cols="60" 
rows="6" name="news[content]" wrap="virtual">' . $this->news_data['content'] . 
'</textarea>',
-                               'label_category' => lang('Category') . ':',
-                               'value_category' => '<select 
name="news[category]">' . $this->selectlist('write', 
intval($this->news_data['category'])) . '</select>',
-                               'label_visible' => lang('Visible') . ':',
-                               'value_begin_d' =>  
$this->sbox->getDays('news[begin_d]',date('j',$this->news_data['begin'])),
-                               'value_begin_m' =>  
$this->sbox->getMonthText('news[begin_m]',date('n',$this->news_data['begin'])),
-                               'value_begin_y' =>  
$this->sbox->getYears('news[begin_y]',date('Y',$this->news_data['begin']),date('Y')),
-                               'select_from' => $options['from'],
-                               'select_until' => $options['until'],
-                               'value_end_d' =>  
$this->sbox->getDays('news[end_d]',date('j',$this->news_data['end'])) ,
-                               'value_end_m' =>  
$this->sbox->getMonthText('news[end_m]',date('n',$this->news_data['end'])),
-                               'value_end_y' =>  
$this->sbox->getYears('news[end_y]',date('Y',$this->news_data['end']),date('Y')),
-                               'label_is_html' => lang('Contains HTML'),
-                               'value_is_html' => '<input type="checkbox" 
name="news[is_html]" value="1" ' . ($this->news_data['is_html'] ? ' CHECKED' : 
'') .'>',
-                       ));
+                       $this->template->set_var( 
$this->_get_option_vals($this->news_data) );
+                       $this->template->set_var(
+                                               array
+                                                       (
+                                                               'form_button'   
=> lang('save'),
+                                                               'value_id'      
=> $this->news_id,
+                                                               'done_button'   
=> lang('done'),
+                                                               'label_subject' 
=> lang('subject'),
+                                                               'value_subject' 
=> htmlentities($this->news_data['subject']),
+                                                               'label_teaser'  
=> lang('summary'),
+                                                               'value_teaser'  
=> htmlentities($this->news_data['teaser']),
+                                                               'value_content' 
=> htmlentities($this->news_data['content']),
+                                                               
'label_category'=> lang('category'),
+                                                               
'value_category'=> $this->selectlist('write', 
intval($this->news_data['category'])),
+                                                               'label_visible' 
=> lang('visible'),
+                                                               'value_begin'   
=> $jscal->input('news[begin]', $this->news_data['begin']),
+                                                               'select_from'   
=> $options['from'],
+                                                               'select_until'  
=> $options['until'],
+                                                               'value_end'     
=> $jscal->input('news[end]', $this->news_data['end']),
+                                                       )
+                                               );

                        $this->template->pfp('out','form');
                }

                function write_news($message = '')
-               {
-                       $this->template->set_file(array(
-                               'main' => 'write.tpl'
-                       ));
+               {
+                       $this->template->set_file(array('main' => 'write.tpl'));
                        $this->template->set_block('main','list');
                        $this->template->set_block('main','row');
                        $this->template->set_block('main','row_empty');
@@ -523,5 +637,92 @@

                        $this->template->pfp('out','list');
                }
+
+               /**
+               * Get the values needed for build the date range fields in edit 
mode
+               */
+               function _get_option_vals(&$news)
+               {
+                       $now = time();
+                       if (!isset($news['begin'])) //always is default
+                       {
+                               //these are only displayed values not 
necessarily the ones that will get stored
+                               $news['begin'] = $now;
+                               $news['end'] = $now;
+                               $from = 1;
+                               $until = 1;
+                       }
+                       elseif ($news['end'] < $now) //if enddate is in the 
past set option to never
+                       {
+                               $news['begin'] = $now;
+                               $news['end'] = $now;
+                               $from = 0;
+                               $until = 1;
+                       }
+                       else
+                       {
+                               if ($news['begin'] < $now)
+                               {
+                                       $news['begin'] = $now;
+                                       if ($news['end'] == 
$this->unixtimestampmax)
+                                       {
+                                               $news['end'] = $now;
+                                               $from = 1;
+                                               $until = 1;
+                                       }
+                                       else
+                                       {
+                                               $from = 0.5;
+                                               $until = 0.5;
+                                       }
+                               }
+                               else
+                               {
+                                       if ($news['end'] == 
$this->unixtimestampmax)
+                                       {
+                                               $news['end'] = $now;
+                                               $from = 0.5;
+                                               $until = 1;
+                                       }
+                                       else
+                                       {
+                                               $from = 0.5;
+                                               $until = 0.5;
+                                       }
+                               }
+                       }
+                       $options['lang_always'] = lang('always');
+                       $options['lang_from']   = lang('from');
+                       $options['lang_never']  = lang('never');
+                       $options['lang_until']  = lang('until');
+
+                       $options['from_always_selected']= '';
+                       $options['from_never_selected'] = '';
+                       $options['from_from_selected']  = '';
+
+                       switch($from * 10)
+                       {
+                               case 0:
+                                       $options['from_never_selected'] = 
'selected="selected" ';
+                                       break;
+                               case 5:
+                                       $options['from_from_selected']  = 
'selected="selected" ';
+                                       break;
+                               default:
+                                       $options['from_always_selected']= 
'selected="selected" ';
+
+                       }
+
+                       switch($until * 10)
+                       {
+                               case 5:
+                                       $options['to_until_selected'] = 
'selected="selected" ';
+                                       break;
+                               default:
+                                       $options['to_always_selected'] = 
'selected="selected" ';
+
+                       }
+                       return $options;
+               }
        }
 ?>

====================================================

====================================================
Index: news_admin/inc/class.uiexport.inc.php
diff -u news_admin/inc/class.uiexport.inc.php:1.1 
news_admin/inc/class.uiexport.inc.php:1.2
--- news_admin/inc/class.uiexport.inc.php:1.1   Tue Jun  3 03:15:12 2003
+++ news_admin/inc/class.uiexport.inc.php       Wed May 25 01:19:51 2005
@@ -112,10 +112,16 @@
                                        'itemsyntaxselectlist' => 
$this->selectlist($this->itemsyntaxtypes,$config['itemsyntax'])
                                ));
                                
$GLOBALS['phpgw']->template->set_var('confblock','');
-                               foreach 
(array('title','link','description','img_title','img_url','img_link') as 
$setting)
+                               foreach (array(
+                                       'title'        => lang('Title'),
+                                       'link'         => lang('Link'),
+                                       'description'  => lang('description'),
+                                       'img_title'    => lang('Image Title'),
+                                       'img_url'      => lang('Image URL'),
+                                       'img_link'     => lang('Image Link')) 
as $setting => $label)
                                {
                                        
$GLOBALS['phpgw']->template->set_var(array(
-                                               'setting' => $setting,
+                                               'setting' => $label,
                                                'value' => ('<input size="80" 
type="text" name="inputconfig[' . $cat['id'] . '][' . $setting . ']" value="' .
                                                        $config[$setting] . '" 
/>'
                                                )






reply via email to

[Prev in Thread] Current Thread [Next in Thread]