2004-08-01 17:36:04 +02:00
< ? php
2007-03-09 12:39:47 +01:00
/**
* eGroupWare - Calendar ' s shared base - class of all UI classes
*
* @ link http :// www . egroupware . org
* @ package calendar
* @ author Ralf Becker < RalfBecker - AT - outdoor - training . de >
2009-04-20 17:44:24 +02:00
* @ copyright ( c ) 2004 - 9 by RalfBecker - At - outdoor - training . de
2007-03-09 12:39:47 +01:00
* @ license http :// opensource . org / licenses / gpl - license . php GPL - GNU General Public License
* @ version $Id $
*/
2004-08-01 17:36:04 +02:00
/**
2005-11-09 00:15:14 +01:00
* Shared base - class of all calendar UserInterface classes
2004-08-01 17:36:04 +02:00
*
* It manages eg . the state of the controls in the UI and generated the calendar navigation ( sidebox - menu )
*
2005-11-09 00:15:14 +01:00
* The new UI , BO and SO classes have a strikt definition , in which time - zone they operate :
* UI only operates in user - time , so there have to be no conversation at all !!!
* BO ' s functions take and return user - time only ( ! ), they convert internaly everything to servertime , because
* SO operates only on server - time
*
* All permanent debug messages of the calendar - code should done via the debug - message method of the bocal class ! ! !
2004-08-01 17:36:04 +02:00
*/
2008-06-07 19:45:33 +02:00
class calendar_ui
2004-08-01 17:36:04 +02:00
{
/**
* @ var $debug mixed integer level or string function - name
*/
2005-11-09 00:15:14 +01:00
var $debug = false ;
2004-08-01 17:36:04 +02:00
/**
2006-08-22 18:50:45 +02:00
* instance of the bocal or bocalupdate class
2008-05-08 17:02:35 +02:00
*
2008-06-07 19:45:33 +02:00
* @ var calendar_boupdate
2004-08-01 17:36:04 +02:00
*/
2006-08-22 18:50:45 +02:00
var $bo ;
/**
* instance of jscalendar
*
* @ var jscalendar
*/
var $jscal ;
/**
* Reference to global datetime class
*
* @ var datetime
*/
var $datetime ;
/**
2009-11-25 13:58:09 +01:00
* Instance of categories class
2006-08-22 18:50:45 +02:00
*
* @ var categories
*/
2009-11-25 13:58:09 +01:00
var $categories ;
2006-08-22 18:50:45 +02:00
/**
* Reference to global uiaccountsel class
*
* @ var uiaccountsel
*/
var $accountsel ;
2005-11-09 00:15:14 +01:00
/**
* @ var array $common_prefs reference to $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ]
*/
var $common_prefs ;
/**
* @ var array $cal_prefs reference to $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'calendar' ]
*/
var $cal_prefs ;
/**
* @ var int $wd_start user pref . workday start
*/
var $wd_start ;
/**
* @ var int $wd_start user pref . workday end
*/
var $wd_end ;
/**
* @ var int $interval_m user pref . interval
*/
var $interval_m ;
/**
* @ var int $user account_id of loged in user
*/
var $user ;
/**
* @ var string $date session - state : date ( Ymd ) of shown view
*/
var $date ;
/**
* @ var int $cat_it session - state : selected category
*/
var $cat_id ;
/**
2006-11-02 22:33:00 +01:00
* @ var int $filter session - state : selected filter , at the moment all or hideprivate
2005-11-09 00:15:14 +01:00
*/
var $filter ;
/**
* @ var int / array $owner session - state : selected owner ( s ) of shown calendar ( s )
*/
var $owner ;
/**
* @ var string $sortby session - state : filter of planner : 'category' or 'user'
*/
var $sortby ;
/**
* @ var string $view session - state : selected view
*/
var $view ;
/**
* @ var string $view menuaction of the selected view
*/
var $view_menuaction ;
2008-05-08 17:02:35 +02:00
2005-11-09 00:15:14 +01:00
/**
* @ var int $first first day of the shown view
*/
var $first ;
/**
* @ var int $last last day of the shown view
*/
var $last ;
2009-04-20 17:44:24 +02:00
2008-10-07 10:57:09 +02:00
/**
* @ var array $states_to_save all states that will be saved to the user prefs
*/
2009-09-29 21:58:51 +02:00
var $states_to_save = array ( 'owner' , 'filter' );
2004-08-01 17:36:04 +02:00
/**
* Constructor
2005-11-09 00:15:14 +01:00
*
2008-06-07 19:45:33 +02:00
* @ param boolean $use_boupdate use bocalupdate as parenent instead of bocal
2005-11-09 00:15:14 +01:00
* @ param array $set_states = null to manualy set / change one of the states , default NULL = use $_REQUEST
2004-08-01 17:36:04 +02:00
*/
2008-06-07 19:45:33 +02:00
function __construct ( $use_boupdate = false , $set_states = NULL )
2004-08-01 17:36:04 +02:00
{
2008-06-07 19:45:33 +02:00
if ( $use_boupdate )
{
$this -> bo = new calendar_boupdate ();
}
else
{
$this -> bo = new calendar_bo ();
}
2008-03-21 21:30:19 +01:00
$this -> jscal = $GLOBALS [ 'egw' ] -> jscalendar ;
$this -> datetime = $GLOBALS [ 'egw' ] -> datetime ;
$this -> accountsel = $GLOBALS [ 'egw' ] -> uiaccountsel ;
2009-11-25 13:58:09 +01:00
$this -> categories = new categories ( $this -> user , 'calendar' );
2010-03-07 23:07:34 +01:00
2005-11-09 00:15:14 +01:00
$this -> common_prefs = & $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ];
$this -> cal_prefs = & $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'calendar' ];
2007-04-26 17:29:15 +02:00
$this -> bo -> check_set_default_prefs ();
2005-11-09 00:15:14 +01:00
$this -> wd_start = 60 * $this -> cal_prefs [ 'workdaystarts' ];
$this -> wd_end = 60 * $this -> cal_prefs [ 'workdayends' ];
$this -> interval_m = $this -> cal_prefs [ 'interval' ];
2004-08-01 17:36:04 +02:00
2005-11-09 00:15:14 +01:00
$this -> user = $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_id' ];
2004-08-01 17:36:04 +02:00
2005-11-09 00:15:14 +01:00
$this -> manage_states ( $set_states );
2004-08-01 17:36:04 +02:00
$GLOBALS [ 'uical' ] = & $this ; // make us available for ExecMethod, else it creates a new instance
2008-05-08 17:02:35 +02:00
2004-08-01 17:36:04 +02:00
// calendar does not work with hidden sidebox atm.
2005-11-09 00:15:14 +01:00
unset ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'auto_hide_sidebox' ]);
2004-08-01 17:36:04 +02:00
}
2008-05-08 17:02:35 +02:00
2006-03-03 19:51:46 +01:00
/**
2006-03-04 10:54:31 +01:00
* Checks and terminates ( or returns for home ) with a message if $this -> owner include a user / resource we have no read - access to
*
* If currentapp == 'home' we return the error instead of terminating with it !!!
*
* @ return boolean / string false if there ' s no error or string with error - message
2006-03-03 19:51:46 +01:00
*/
function check_owners_access ()
{
2006-03-04 10:54:31 +01:00
$no_access = $no_access_group = array ();
2006-03-03 19:51:46 +01:00
foreach ( explode ( ',' , $this -> owner ) as $owner )
{
2009-12-04 11:22:33 +01:00
$owner = trim ( $owner );
2006-03-04 10:54:31 +01:00
if ( is_numeric ( $owner ) && $GLOBALS [ 'egw' ] -> accounts -> get_type ( $owner ) == 'g' )
{
foreach ( $GLOBALS [ 'egw' ] -> accounts -> member ( $owner ) as $member )
{
$member = $member [ 'account_id' ];
2009-06-09 14:16:15 +02:00
if ( ! $this -> bo -> check_perms ( EGW_ACL_READ | EGW_ACL_READ_FOR_PARTICIPANTS | EGW_ACL_FREEBUSY , 0 , $member ))
2006-03-04 10:54:31 +01:00
{
$no_access_group [ $member ] = $this -> bo -> participant_name ( $member );
2008-05-08 17:02:35 +02:00
}
2006-03-04 10:54:31 +01:00
}
}
2009-06-09 14:16:15 +02:00
elseif ( ! $this -> bo -> check_perms ( EGW_ACL_READ | EGW_ACL_READ_FOR_PARTICIPANTS | EGW_ACL_FREEBUSY , 0 , $owner ))
2006-03-03 19:51:46 +01:00
{
$no_access [ $owner ] = $this -> bo -> participant_name ( $owner );
}
}
if ( count ( $no_access ))
{
2006-03-04 10:54:31 +01:00
$msg = '<p class="redItalic" align="center">' . lang ( 'Access denied to the calendar of %1 !!!' , implode ( ', ' , $no_access )) . " </p> \n " ;
2008-05-08 17:02:35 +02:00
2006-03-04 10:54:31 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'currentapp' ] == 'home' )
{
return $msg ;
}
2006-03-03 19:51:46 +01:00
$GLOBALS [ 'egw' ] -> common -> egw_header ();
2006-03-04 10:54:31 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]) parse_navbar ();
echo $msg ;
2006-03-03 19:51:46 +01:00
$GLOBALS [ 'egw' ] -> common -> egw_footer ();
$GLOBALS [ 'egw' ] -> common -> egw_exit ();
}
2006-03-04 10:54:31 +01:00
if ( count ( $no_access_group ))
{
$this -> group_warning = lang ( 'Groupmember(s) %1 not included, because you have no access.' , implode ( ', ' , $no_access_group ));
}
return false ;
}
2008-05-08 17:02:35 +02:00
2006-03-04 10:54:31 +01:00
/**
* show the egw - framework plus possible messages ( $_GET [ 'msg' ] and $this -> group_warning from check_owner_access )
*/
function do_header ()
{
2006-12-15 21:05:47 +01:00
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'include_xajax' ] = true ;
2006-03-04 10:54:31 +01:00
$GLOBALS [ 'egw' ] -> common -> egw_header ();
2008-05-08 17:02:35 +02:00
2008-03-21 21:30:19 +01:00
if ( $_GET [ 'msg' ]) echo '<p class="redItalic" align="center">' . html :: htmlspecialchars ( $_GET [ 'msg' ]) . " </p> \n " ;
2006-03-04 10:54:31 +01:00
if ( $this -> group_warning ) echo '<p class="redItalic" align="center">' . $this -> group_warning . " </p> \n " ;
2006-03-03 19:51:46 +01:00
}
2004-08-01 17:36:04 +02:00
/**
* Manages the states of certain controls in the UI : date shown , category selected , ...
*
* The state of all these controls is updated if they are set in $_REQUEST or $set_states and saved in the session .
* The following states are used :
* - date or year , month , day : the actual date of the period displayed
* - cat_id : the selected category
* - owner : the owner of the displayed calendar
* - save_owner : the overriden owner of the planner
2006-11-02 22:33:00 +01:00
* - filter : the used filter : all or hideprivate
2004-08-01 17:36:04 +02:00
* - sortby : category or user of planner
2005-11-09 00:15:14 +01:00
* - view : the actual view , where dialogs should return to or which they refresh
2009-08-04 19:14:16 +02:00
* @ param array $set_states array to manualy set / change one of the states , default NULL = use $_REQUEST
2004-08-01 17:36:04 +02:00
*/
function manage_states ( $set_states = NULL )
{
2005-11-09 00:15:14 +01:00
$states = $states_session = $GLOBALS [ 'egw' ] -> session -> appsession ( 'session_data' , 'calendar' );
2009-04-20 17:44:24 +02:00
2008-10-07 10:57:09 +02:00
// retrieve saved states from prefs
if ( ! $states )
{
2009-04-20 17:44:24 +02:00
$states = unserialize ( $this -> bo -> cal_prefs [ 'saved_states' ]);
2008-10-07 10:57:09 +02:00
}
2009-04-20 17:44:24 +02:00
// only look at _REQUEST, if we are in the calendar (prefs and admin show our sidebox menu too!)
2004-08-01 17:36:04 +02:00
if ( is_null ( $set_states ))
{
2009-04-20 17:44:24 +02:00
$set_states = substr ( $_GET [ 'menuaction' ], 0 , 9 ) == 'calendar.' ? $_REQUEST : array ();
2004-08-01 17:36:04 +02:00
}
if ( ! $states [ 'date' ] && $states [ 'year' ] && $states [ 'month' ] && $states [ 'day' ])
{
$states [ 'date' ] = $this -> bo -> date2string ( $states );
}
foreach ( array (
'date' => $this -> bo -> date2string ( $this -> bo -> now_su ),
'cat_id' => 0 ,
'filter' => 'all' ,
'owner' => $this -> user ,
'save_owner' => 0 ,
'sortby' => 'category' ,
2005-11-09 00:15:14 +01:00
'planner_days' => 0 , // full month
'view' => $this -> bo -> cal_prefs [ 'defaultcalendar' ],
2007-03-09 12:39:47 +01:00
'listview_days' => '' , // no range
2004-08-01 17:36:04 +02:00
) as $state => $default )
{
if ( isset ( $set_states [ $state ]))
{
2006-03-06 08:11:39 +01:00
if ( $state == 'owner' )
{
// only change the owners of the same resource-type as given in set_state[owner]
2006-03-09 19:19:33 +01:00
$set_owners = explode ( ',' , $set_states [ 'owner' ]);
2006-09-25 10:50:02 +02:00
if (( string ) $set_owners [ 0 ] === '0' ) // set exactly the specified owners (without the 0)
2006-03-06 08:11:39 +01:00
{
2006-09-25 10:50:02 +02:00
$set_states [ 'owner' ] = substr ( $set_states [ 'owner' ], 2 );
2006-03-06 08:11:39 +01:00
}
2006-09-25 10:50:02 +02:00
else // change only the owners of the given type
2006-03-06 08:11:39 +01:00
{
2008-05-08 17:02:35 +02:00
$res_type = is_numeric ( $set_owners [ 0 ]) ? false : $set_owners [ 0 ][ 0 ];
2006-09-25 10:50:02 +02:00
$owners = explode ( ',' , $states [ 'owner' ] ? $states [ 'owner' ] : $default );
foreach ( $owners as $key => $owner )
{
2008-05-08 17:02:35 +02:00
if ( ! $res_type && is_numeric ( $owner ) || $res_type && $owner [ 0 ] == $res_type )
2006-09-25 10:50:02 +02:00
{
unset ( $owners [ $key ]);
}
}
if ( ! $res_type || ! in_array ( $res_type . '0' , $set_owners ))
{
$owners = array_merge ( $owners , $set_owners );
}
$set_states [ 'owner' ] = implode ( ',' , $owners );
2006-03-06 08:11:39 +01:00
}
}
2006-03-16 19:17:18 +01:00
// for the uiforms class (eg. edit), dont store the (new) owner, as it might change the view
2009-07-09 11:50:47 +02:00
if ( substr ( $_GET [ 'menuaction' ], 0 , 25 ) == 'calendar.calendar_uiforms' )
2006-03-16 19:17:18 +01:00
{
$this -> owner = $set_states [ $state ];
continue ;
}
2004-08-01 17:36:04 +02:00
$states [ $state ] = $set_states [ $state ];
}
elseif ( ! is_array ( $states ) || ! isset ( $states [ $state ]))
{
$states [ $state ] = $default ;
}
if ( $state == 'date' )
{
$date_arr = $this -> bo -> date2array ( $states [ 'date' ]);
foreach ( array ( 'year' , 'month' , 'day' ) as $name )
{
$this -> $name = $states [ $name ] = $date_arr [ $name ];
}
}
$this -> $state = $states [ $state ];
}
2005-11-09 00:15:14 +01:00
if ( substr ( $this -> view , 0 , 8 ) == 'planner_' )
{
$states [ 'sortby' ] = $this -> sortby = $this -> view == 'planner_cat' ? 'category' : 'user' ;
$states [ 'view' ] = $this -> view = 'planner' ;
}
2004-08-01 17:36:04 +02:00
// set the actual view as return_to
2009-04-20 17:44:24 +02:00
if ( isset ( $_GET [ 'menuaction' ]))
2006-03-03 19:51:46 +01:00
{
list ( $app , $class , $func ) = explode ( '.' , $_GET [ 'menuaction' ]);
2008-06-12 10:25:57 +02:00
if ( $func == 'index' )
{
$func = $this -> view ; $this -> view = 'index' ; // switch to the default view
}
2006-03-03 19:51:46 +01:00
}
else // eg. calendar/index.php
{
$func = $this -> view ;
2008-06-12 10:25:57 +02:00
$class = $this -> view == 'listview' ? 'calendar_uilist' : 'calendar_uiviews' ;
2006-03-03 19:51:46 +01:00
}
2008-06-12 10:25:57 +02:00
if ( $class == 'calendar_uiviews' || $class == 'calendar_uilist' )
2004-08-01 17:36:04 +02:00
{
2005-11-09 00:15:14 +01:00
// if planner_start_with_group is set in the users prefs: switch owner for planner to planner_start_with_group and back
if ( $this -> cal_prefs [ 'planner_start_with_group' ])
{
2006-05-16 06:08:12 +02:00
if ( $this -> cal_prefs [ 'planner_start_with_group' ] > 0 ) $this -> cal_prefs [ 'planner_start_with_group' ] *= - 1 ; // fix old 1.0 pref
2008-05-08 17:02:35 +02:00
if ( ! $states_session && ! $_GET [ 'menuaction' ]) $this -> view = '' ; // first call to calendar
2006-03-03 19:51:46 +01:00
2005-11-09 00:15:14 +01:00
if ( $func == 'planner' && $this -> view != 'planner' && $this -> owner == $this -> user )
{
//echo "<p>switched for planner to {$this->cal_prefs['planner_start_with_group']}, view was $this->view, func=$func, owner was $this->owner</p>\n";
$states [ 'save_owner' ] = $this -> save_owner = $this -> owner ;
$states [ 'owner' ] = $this -> owner = $this -> cal_prefs [ 'planner_start_with_group' ];
}
elseif ( $func != 'planner' && $this -> view == 'planner' && $this -> owner == $this -> cal_prefs [ 'planner_start_with_group' ] && $this -> save_owner )
{
//echo "<p>switched back to $this->save_owner, view was $this->view, func=$func, owner was $this->owner</p>\n";
$states [ 'owner' ] = $this -> owner = $this -> save_owner ;
$states [ 'save_owner' ] = $this -> save_owner = 0 ;
}
}
$this -> view = $states [ 'view' ] = $func ;
2004-08-01 17:36:04 +02:00
}
2008-06-07 19:45:33 +02:00
$this -> view_menuaction = $this -> view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.' . $this -> view ;
2005-11-23 15:21:20 +01:00
2007-03-09 12:39:47 +01:00
if ( $this -> debug > 0 || $this -> debug == 'manage_states' ) $this -> bo -> debug_message ( 'uical::manage_states(%1) session was %2, states now %3' , True , $set_states , $states_session , $states );
2004-08-01 17:36:04 +02:00
// save the states in the session
2005-11-09 00:15:14 +01:00
$GLOBALS [ 'egw' ] -> session -> appsession ( 'session_data' , 'calendar' , $states );
2008-10-07 10:57:09 +02:00
// save defined states into the user-prefs
if ( ! empty ( $states ) && is_array ( $states ))
{
2009-10-12 11:34:56 +02:00
$saved_states = serialize ( array_intersect_key ( $states , array_flip ( $this -> states_to_save )));
if ( $saved_states != $this -> cal_prefs [ 'saved_states' ])
{
$GLOBALS [ 'egw' ] -> preferences -> add ( 'calendar' , 'saved_states' , $saved_states );
2010-01-08 03:39:03 +01:00
$GLOBALS [ 'egw' ] -> preferences -> save_repository ( false , 'user' , true );
2009-10-12 11:34:56 +02:00
}
2008-10-07 10:57:09 +02:00
}
2004-08-01 17:36:04 +02:00
}
/**
* gets the icons displayed for a given event
*
2009-08-04 19:14:16 +02:00
* @ param array $event
2004-08-01 17:36:04 +02:00
* @ return array of 'img' / 'title' pairs
*/
function event_icons ( $event )
{
2005-11-09 00:15:14 +01:00
$is_private = ! $event [ 'public' ] && ! $this -> bo -> check_perms ( EGW_ACL_READ , $event );
$viewable = ! $this -> bo -> printer_friendly && $this -> bo -> check_perms ( EGW_ACL_READ , $event );
2004-08-01 17:36:04 +02:00
if ( ! $is_private )
{
if ( $event [ 'priority' ] == 3 )
{
2008-03-21 21:30:19 +01:00
$icons [] = html :: image ( 'calendar' , 'high' , lang ( 'high priority' ));
2004-08-01 17:36:04 +02:00
}
2005-11-09 00:15:14 +01:00
if ( $event [ 'recur_type' ] != MCAL_RECUR_NONE )
2004-08-01 17:36:04 +02:00
{
2008-03-21 21:30:19 +01:00
$icons [] = html :: image ( 'calendar' , 'recur' , lang ( 'recurring event' ));
2004-08-01 17:36:04 +02:00
}
2006-03-06 08:11:39 +01:00
// icons for single user, multiple users or group(s) and resources
foreach ( $event [ 'participants' ] as $uid => $status )
{
2008-05-08 17:02:35 +02:00
if ( is_numeric ( $uid ) || ! isset ( $this -> bo -> resources [ $uid [ 0 ]][ 'icon' ]))
2006-03-06 08:11:39 +01:00
{
if ( isset ( $icons [ 'single' ]) || $GLOBALS [ 'egw' ] -> accounts -> get_type ( $uid ) == 'g' )
{
unset ( $icons [ 'single' ]);
2008-03-21 21:30:19 +01:00
$icons [ 'multiple' ] = html :: image ( 'calendar' , 'users' );
2006-03-06 08:11:39 +01:00
}
elseif ( ! isset ( $icons [ 'multiple' ]))
{
2008-03-21 21:30:19 +01:00
$icons [ 'single' ] = html :: image ( 'calendar' , 'single' );
2006-03-06 08:11:39 +01:00
}
2008-05-08 17:02:35 +02:00
}
elseif ( ! isset ( $icons [ $uid [ 0 ]]) && isset ( $this -> bo -> resources [ $uid [ 0 ]]) && isset ( $this -> bo -> resources [ $uid [ 0 ]][ 'icon' ]))
2006-03-06 08:11:39 +01:00
{
2008-05-08 17:02:35 +02:00
$icons [ $uid [ 0 ]] = html :: image ( $this -> bo -> resources [ $uid [ 0 ]][ 'app' ],
( $this -> bo -> resources [ $uid [ 0 ]][ 'icon' ] ? $this -> bo -> resources [ $uid [ 0 ]][ 'icon' ] : 'navbar' ),
lang ( $this -> bo -> resources [ $uid [ 0 ]][ 'app' ]),
2006-03-06 08:11:39 +01:00
'width="16px" height="16px"' );
}
}
2004-08-01 17:36:04 +02:00
}
2006-03-16 19:17:18 +01:00
if ( $event [ 'non_blocking' ])
{
2008-03-21 21:30:19 +01:00
$icons [] = html :: image ( 'calendar' , 'nonblocking' , lang ( 'non blocking' ));
2006-03-16 19:17:18 +01:00
}
2004-08-01 17:36:04 +02:00
if ( $event [ 'public' ] == 0 )
{
2008-03-21 21:30:19 +01:00
$icons [] = html :: image ( 'calendar' , 'private' , lang ( 'private' ));
2004-08-01 17:36:04 +02:00
}
if ( isset ( $event [ 'alarm' ]) && count ( $event [ 'alarm' ]) >= 1 && ! $is_private )
{
2008-03-21 21:30:19 +01:00
$icons [] = html :: image ( 'calendar' , 'alarm' , lang ( 'alarm' ));
2004-08-01 17:36:04 +02:00
}
2009-11-18 14:58:01 +01:00
if ( $event [ 'participants' ][ $this -> user ][ 0 ] == 'U' )
{
$icons [] = html :: image ( 'calendar' , 'cnr-pending' , lang ( 'Needs action' ));
}
2004-08-01 17:36:04 +02:00
return $icons ;
}
/**
* Create a select - box item in the sidebox - menu
* @ privat used only by sidebox_menu !
*/
function _select_box ( $title , $name , $options , $baseurl = '' )
{
if ( $baseurl ) // we append the value to the baseurl
{
2009-04-20 17:44:24 +02:00
if ( substr ( $baseurl , - 1 ) != '=' ) $baseurl .= strpos ( $baseurl , '?' ) === False ? '?' : '&' ;
2004-08-01 17:36:04 +02:00
$onchange = " location=' $baseurl '+this.value; " ;
}
else // we add $name=value to the actual location
{
$onchange = " location=location+(location.search.length ? '&' : '?')+' " . $name . " ='+this.value; " ;
}
2005-11-09 00:15:14 +01:00
$select = ' <select style="width: 185px;" name="' . $name . '" onchange="' . $onchange . '" title="' .
2004-08-01 17:36:04 +02:00
lang ( 'Select a %1' , lang ( $title )) . '">' .
$options . " </select> \n " ;
return array (
'text' => $select ,
'no_lang' => True ,
'link' => False
);
}
2005-11-09 00:15:14 +01:00
/**
* Generate a link to add an event , incl . the necessary popup
*
* @ param string $content content of the link
* @ param string $date = null which date should be used as start - and end - date , default null = $this -> date
* @ param int $hour = null which hour should be used for the start , default null = $this -> hour
* @ param int $minute = 0 start - minute
2009-11-25 21:16:41 +01:00
* @ param array $extra_vars = null
2005-11-09 00:15:14 +01:00
* @ return string the link incl . content
*/
2009-11-25 21:16:41 +01:00
function add_link ( $content , $date = null , $hour = null , $minute = 0 , array $vars = null )
2005-11-09 00:15:14 +01:00
{
2009-11-25 21:16:41 +01:00
$vars [ 'menuaction' ] = 'calendar.calendar_uiforms.edit' ;
$vars [ 'date' ] = $date ? $date : $this -> date ;
2005-11-09 00:15:14 +01:00
if ( ! is_null ( $hour ))
{
$vars [ 'hour' ] = $hour ;
$vars [ 'minute' ] = $minute ;
}
2008-03-21 21:30:19 +01:00
return html :: a_href ( $content , '/index.php' , $vars , ' target="_blank" title="' . html :: htmlspecialchars ( lang ( 'Add' )) .
2005-11-09 00:15:14 +01:00
'" onclick="' . $this -> popup ( 'this.href' , 'this.target' ) . '; return false;"' );
}
2008-05-08 17:02:35 +02:00
2005-11-09 00:15:14 +01:00
/**
* returns javascript to open a popup window : window . open ( ... )
*
* @ param string $link link or this . href
* @ param string $target = '_blank' name of target or this . target
* @ param int $width = 750 width of the window
* @ param int $height = 400 height of the window
* @ return string javascript ( using single quotes )
*/
2010-04-15 20:23:02 +02:00
function popup ( $link , $target = '_blank' , $width = 750 , $height = 410 )
2008-02-07 14:59:34 +01:00
{
2009-08-04 19:14:16 +02:00
return 'egw_openWindowCentered2(' . ( $link == 'this.href' ? $link : " ' " . $link . " ' " ) . ',' .
( $target == 'this.target' ? $target : " ' " . $target . " ' " ) . " , $width , $height ,'yes') " ;
2008-02-07 14:59:34 +01:00
}
2005-11-09 00:15:14 +01:00
2004-08-01 17:36:04 +02:00
/**
* creates the content for the sidebox - menu , called as hook
*/
function sidebox_menu ()
{
$base_hidden_vars = $link_vars = array ();
if ( @ $_POST [ 'keywords' ])
{
$base_hidden_vars [ 'keywords' ] = $_POST [ 'keywords' ];
}
$n = 0 ; // index for file-array
2005-11-09 00:15:14 +01:00
$planner_days_for_view = false ;
switch ( $this -> view )
{
case 'month' : $planner_days_for_view = 0 ; break ;
case 'week' : $planner_days_for_view = $this -> cal_prefs [ 'days_in_weekview' ] == 5 ? 5 : 7 ; break ;
case 'day' : $planner_days_for_view = 1 ; break ;
}
2004-08-01 17:36:04 +02:00
// Toolbar with the views
$views = '<table style="width: 100%;"><tr>' . " \n " ;
foreach ( array (
2005-11-09 00:15:14 +01:00
'add' => array ( 'icon' => 'new' , 'text' => 'add' ),
2008-06-07 19:45:33 +02:00
'day' => array ( 'icon' => 'today' , 'text' => 'Today' , 'menuaction' => 'calendar.calendar_uiviews.day' , 'date' => $this -> bo -> date2string ( $this -> bo -> now_su )),
'week' => array ( 'icon' => 'week' , 'text' => 'Weekview' , 'menuaction' => 'calendar.calendar_uiviews.week' ),
2009-11-22 15:01:48 +01:00
'weekN' => array ( 'icon' => 'multiweek' , 'text' => 'Multiple week view' , 'menuaction' => 'calendar.calendar_uiviews.weekN' ),
2008-06-07 19:45:33 +02:00
'month' => array ( 'icon' => 'month' , 'text' => 'Monthview' , 'menuaction' => 'calendar.calendar_uiviews.month' ),
'planner' => array ( 'icon' => 'planner' , 'text' => 'Group planner' , 'menuaction' => 'calendar.calendar_uiviews.planner' , 'sortby' => $this -> sortby ),
'list' => array ( 'icon' => 'list' , 'text' => 'Listview' , 'menuaction' => 'calendar.calendar_uilist.listview' ),
2004-08-01 17:36:04 +02:00
) as $view => $data )
{
2005-11-09 00:15:14 +01:00
$icon = array_shift ( $data );
$title = array_shift ( $data );
$vars = array_merge ( $link_vars , $data );
2008-07-24 10:48:50 +02:00
$icon = html :: image ( 'calendar' , $icon , lang ( $title ), " class=sideboxstar " ); //to avoid jscadender from not displaying with pngfix
2008-03-21 21:30:19 +01:00
$link = $view == 'add' ? $this -> add_link ( $icon ) : html :: a_href ( $icon , '/index.php' , $vars );
2005-11-09 00:15:14 +01:00
2006-03-02 19:15:25 +01:00
$views .= '<td align="center">' . $link . " </td> \n " ;
2004-08-01 17:36:04 +02:00
}
$views .= " </tr></table> \n " ;
2005-11-09 00:15:14 +01:00
2009-11-19 19:56:04 +01:00
// hack to disable invite ACL column, if not enabled in config
if ( $_GET [ 'menuaction' ] == 'preferences.uiaclprefs.index' &&
( ! $this -> bo -> require_acl_invite || $this -> bo -> require_acl_invite == 'groups' && ! ( $_REQUEST [ 'owner' ] < 0 )))
{
$views .= " <style type='text/css'> \n \t .aclInviteColumn { display: none; } \n </style> \n " ;
}
2004-08-01 17:36:04 +02:00
$file [ ++ $n ] = array ( 'text' => $views , 'no_lang' => True , 'link' => False , 'icon' => False );
// special views and view-options menu
$options = '' ;
foreach ( array (
array (
'text' => lang ( 'dayview' ),
2008-06-07 19:45:33 +02:00
'value' => 'menuaction=calendar.calendar_uiviews.day' ,
2006-03-03 19:51:46 +01:00
'selected' => $this -> view == 'day' ,
2004-08-01 17:36:04 +02:00
),
2006-06-02 21:38:08 +02:00
array (
'text' => lang ( 'four days view' ),
2008-06-07 19:45:33 +02:00
'value' => 'menuaction=calendar.calendar_uiviews.day4' ,
2006-06-02 21:38:08 +02:00
'selected' => $this -> view == 'day4' ,
),
2004-08-01 17:36:04 +02:00
array (
2005-11-09 00:15:14 +01:00
'text' => lang ( 'weekview with weekend' ),
2008-06-07 19:45:33 +02:00
'value' => 'menuaction=calendar.calendar_uiviews.week&days=7' ,
2006-03-03 19:51:46 +01:00
'selected' => $this -> view == 'week' && $this -> cal_prefs [ 'days_in_weekview' ] != 5 ,
2004-08-01 17:36:04 +02:00
),
array (
'text' => lang ( 'weekview without weekend' ),
2008-06-07 19:45:33 +02:00
'value' => 'menuaction=calendar.calendar_uiviews.week&days=5' ,
2006-03-03 19:51:46 +01:00
'selected' => $this -> view == 'week' && $this -> cal_prefs [ 'days_in_weekview' ] == 5 ,
2004-08-01 17:36:04 +02:00
),
2008-03-20 09:54:18 +01:00
array (
'text' => lang ( 'Multiple week view' ),
2008-06-07 19:45:33 +02:00
'value' => 'menuaction=calendar.calendar_uiviews.weekN' ,
2008-03-20 09:54:18 +01:00
'selected' => $this -> view == 'weekN' ,
),
2004-08-01 17:36:04 +02:00
array (
'text' => lang ( 'monthview' ),
2008-06-07 19:45:33 +02:00
'value' => 'menuaction=calendar.calendar_uiviews.month' ,
2006-03-03 19:51:46 +01:00
'selected' => $this -> view == 'month' ,
2004-08-01 17:36:04 +02:00
),
array (
'text' => lang ( 'planner by category' ),
2008-06-07 19:45:33 +02:00
'value' => 'menuaction=calendar.calendar_uiviews.planner&sortby=category' .
2005-11-09 00:15:14 +01:00
( $planner_days_for_view !== false ? '&planner_days=' . $planner_days_for_view : '' ),
2006-03-03 19:51:46 +01:00
'selected' => $this -> view == 'planner' && $this -> sortby != 'user' ,
2004-08-01 17:36:04 +02:00
),
array (
'text' => lang ( 'planner by user' ),
2008-06-07 19:45:33 +02:00
'value' => 'menuaction=calendar.calendar_uiviews.planner&sortby=user' .
2005-11-09 00:15:14 +01:00
( $planner_days_for_view !== false ? '&planner_days=' . $planner_days_for_view : '' ),
2006-03-03 19:51:46 +01:00
'selected' => $this -> view == 'planner' && $this -> sortby == 'user' ,
2004-08-01 17:36:04 +02:00
),
array (
2005-11-09 00:15:14 +01:00
'text' => lang ( 'listview' ),
2008-06-07 19:45:33 +02:00
'value' => 'menuaction=calendar.calendar_uilist.listview' ,
2006-03-03 19:51:46 +01:00
'selected' => $this -> view == 'listview' ,
2004-08-01 17:36:04 +02:00
),
) as $data )
{
2008-03-21 21:30:19 +01:00
$options .= '<option value="' . $data [ 'value' ] . '"' . ( $data [ 'selected' ] ? ' selected="1"' : '' ) . '>' . html :: htmlspecialchars ( $data [ 'text' ]) . " </option> \n " ;
2004-08-01 17:36:04 +02:00
}
2005-11-09 00:15:14 +01:00
$file [ ++ $n ] = $this -> _select_box ( 'displayed view' , 'view' , $options , $GLOBALS [ 'egw' ] -> link ( '/index.php' ));
2004-08-01 17:36:04 +02:00
// Search
2008-03-21 21:30:19 +01:00
$blur = addslashes ( html :: htmlspecialchars ( lang ( 'Search' ) . '...' ));
$value = @ $_POST [ 'keywords' ] ? html :: htmlspecialchars ( $_POST [ 'keywords' ]) : $blur ;
2004-08-01 17:36:04 +02:00
$file [ ++ $n ] = array (
2008-03-21 21:30:19 +01:00
'text' => html :: form ( '<input name="keywords" value="' . $value . '" style="width: 185px;"' .
2004-08-01 17:36:04 +02:00
' onFocus="if(this.value==\'' . $blur . '\') this.value=\'\';"' .
' onBlur="if(this.value==\'\') this.value=\'' . $blur . '\';" title="' . lang ( 'Search' ) . '">' ,
2008-06-07 19:45:33 +02:00
'' , '/index.php' , array ( 'menuaction' => 'calendar.calendar_uilist.listview' )),
2004-08-01 17:36:04 +02:00
'no_lang' => True ,
'link' => False ,
);
// Minicalendar
2005-11-09 00:15:14 +01:00
$link = array ();
2004-08-01 17:36:04 +02:00
foreach ( array (
2008-06-07 19:45:33 +02:00
'day' => 'calendar.calendar_uiviews.day' ,
'week' => 'calendar.calendar_uiviews.week' ,
'month' => 'calendar.calendar_uiviews.month' ) as $view => $menuaction )
2004-08-01 17:36:04 +02:00
{
2008-05-08 17:02:35 +02:00
if ( $this -> view == 'planner' || $this -> view == 'listview' )
2005-11-09 00:15:14 +01:00
{
switch ( $view )
{
2007-03-09 12:39:47 +01:00
case 'day' : $link_vars [ $this -> view . '_days' ] = $this -> view == 'planner' ? 1 : '' ; break ;
case 'week' : $link_vars [ $this -> view . '_days' ] = $this -> cal_prefs [ 'days_in_weekview' ] == 5 ? 5 : 7 ; break ;
case 'month' : $link_vars [ $this -> view . '_days' ] = 0 ; break ;
2005-11-09 00:15:14 +01:00
}
$link_vars [ 'menuaction' ] = $this -> view_menuaction ; // stay in the planner
}
2008-03-20 09:54:18 +01:00
elseif ( substr ( $this -> view , 0 , 4 ) == 'week' && $view == 'week' )
{
$link_vars [ 'menuaction' ] = $this -> view_menuaction ; // stay in the N-week-view
}
2007-03-09 12:39:47 +01:00
elseif ( $view == 'day' && $this -> view == 'day4' )
2005-11-09 00:15:14 +01:00
{
2007-03-09 12:39:47 +01:00
$link_vars [ 'menuaction' ] = $this -> view_menuaction ; // stay in the day-view
2005-11-09 00:15:14 +01:00
}
else
{
$link_vars [ 'menuaction' ] = $menuaction ;
}
2004-08-01 17:36:04 +02:00
unset ( $link_vars [ 'date' ]); // gets set in jscal
2005-11-09 00:15:14 +01:00
$link [ $view ] = $l = $GLOBALS [ 'egw' ] -> link ( '/index.php' , $link_vars );
2004-08-01 17:36:04 +02:00
}
2005-11-09 00:15:14 +01:00
$jscalendar = $GLOBALS [ 'egw' ] -> jscalendar -> flat ( $link [ 'day' ], $this -> date ,
2004-08-01 17:36:04 +02:00
$link [ 'week' ], lang ( 'show this week' ), $link [ 'month' ], lang ( 'show this month' ));
$file [ ++ $n ] = array ( 'text' => $jscalendar , 'no_lang' => True , 'link' => False , 'icon' => False );
2009-04-20 17:44:24 +02:00
// set a baseurl for selectboxes, if we are not running inside calendar (eg. prefs or admin)
if ( substr ( $_GET [ 'menuaction' ], 0 , 9 ) != 'calendar.' )
{
$baseurl = egw :: link ( '/index.php' , array ( 'menuaction' => 'calendar.calendar_uiviews.index' ));
}
2004-08-01 17:36:04 +02:00
// Category Selection
$file [ ++ $n ] = $this -> _select_box ( 'Category' , 'cat_id' ,
'<option value="0">' . lang ( 'All categories' ) . '</option>' .
2009-11-25 13:58:09 +01:00
$this -> categories -> formatted_list ( 'select' , 'all' , $this -> cat_id , 'True' ), $baseurl ? $baseurl . '&cat_id=' : '' );
2004-08-01 17:36:04 +02:00
2006-11-02 22:33:00 +01:00
// Filter all or hideprivate
2009-09-29 21:58:51 +02:00
$options = '' ;
foreach ( array (
2009-11-19 19:56:04 +01:00
'default' => array ( lang ( 'Not rejected' ), lang ( 'Show all status, but rejected' )),
'accepted' => array ( lang ( 'Accepted' ), lang ( 'Show only accepted events' )),
'unknown' => array ( lang ( 'Invitations' ), lang ( 'Show only invitations, not yet accepted or rejected' )),
'tentative' => array ( lang ( 'Tentative' ), lang ( 'Show only tentative accepted events' )),
2010-03-07 23:07:34 +01:00
'delegated' => array ( lang ( 'Delegated' ), lang ( 'Show only delegated events' )),
2009-11-19 19:56:04 +01:00
'rejected' => array ( lang ( 'Rejected' ), lang ( 'Show only rejected events' )),
'owner' => array ( lang ( 'Owner too' ), lang ( 'Show also events just owned by selected user' )),
'all' => array ( lang ( 'All incl. rejected' ), lang ( 'Show all status incl. rejected events' )),
'hideprivate' => array ( lang ( 'Hide private infos' ), lang ( 'Show all events, as if they were private' )),
2010-05-03 16:03:11 +02:00
'showonlypublic' => array ( lang ( 'Hide private events' ), lang ( 'Show only events flagged as public, (not checked as private)' )),
2009-11-19 19:56:04 +01:00
'no-enum-groups' => array ( lang ( 'only group-events' ), lang ( 'Do not include events of group members' )),
2009-09-29 21:58:51 +02:00
) as $value => $label )
{
2009-11-19 19:56:04 +01:00
list ( $label , $title ) = $label ;
$options .= '<option value="' . $value . '"' . ( $this -> filter == $value ? ' selected="selected"' : '' ) . ' title="' . $title . '">' . $label . '</options>' . " \n " ;
2009-09-29 21:58:51 +02:00
}
$file [] = $this -> _select_box ( 'Filter' , 'filter' , $options , $baseurl ? $baseurl . '&filter=' : '' );
2006-11-02 22:33:00 +01:00
2004-08-01 17:36:04 +02:00
// Calendarselection: User or Group
2006-08-22 18:50:45 +02:00
if ( count ( $this -> bo -> grants ) > 0 && $this -> accountsel -> account_selection != 'none' )
2004-08-01 17:36:04 +02:00
{
$grants = array ();
foreach ( $this -> bo -> list_cals () as $grant )
{
$grants [] = $grant [ 'grantor' ];
}
2005-11-09 00:15:14 +01:00
// exclude non-accounts from the account-selection
$accounts = array ();
foreach ( explode ( ',' , $this -> owner ) as $owner )
{
if ( is_numeric ( $owner )) $accounts [] = $owner ;
}
2006-09-25 10:50:02 +02:00
if ( ! $accounts ) $grants [ '' ] = lang ( 'None' );
2004-08-29 22:32:56 +02:00
$file [] = array (
'text' => "
2004-08-01 17:36:04 +02:00
< script type = \ " text/javascript \" >
function load_cal ( url , id ) {
2005-11-21 09:19:56 +01:00
var owner = '' ;
2004-08-01 17:36:04 +02:00
selectBox = document . getElementById ( id );
for ( i = 0 ; i < selectBox . length ; ++ i ) {
if ( selectBox . options [ i ] . selected ) {
owner += ( owner ? ',' : '' ) + selectBox . options [ i ] . value ;
}
}
if ( owner ) {
location = url + '&owner=' + owner ;
}
}
</ script >
" .
2006-03-06 08:11:39 +01:00
$this -> accountsel -> selection ( 'owner' , 'uical_select_owner' , $accounts , 'calendar+' , count ( $accounts ) > 1 ? 4 : 1 , False ,
2007-05-07 20:59:05 +02:00
' style="width: ' . ( count ( $accounts ) > 1 && in_array ( $this -> common_prefs [ 'account_selection' ], array ( 'selectbox' , 'groupmembers' )) ? '100%' : '165px' ) . ';"' .
2004-08-29 22:32:56 +02:00
' title="' . lang ( 'select a %1' , lang ( 'user' )) . '" onchange="load_cal(\'' .
2005-11-09 00:15:14 +01:00
$GLOBALS [ 'egw' ] -> link ( '/index.php' , array (
'menuaction' => $this -> view_menuaction ,
2004-08-29 22:32:56 +02:00
'date' => $this -> date ,
)) . '\',\'uical_select_owner\');"' , '' , $grants ),
'no_lang' => True ,
'link' => False
);
2004-08-01 17:36:04 +02:00
}
// Import & Export
2005-11-09 00:15:14 +01:00
$file [] = array (
2008-06-07 19:45:33 +02:00
'text' => lang ( 'Export' ) . ': ' . html :: a_href ( lang ( 'iCal' ), 'calendar.calendar_uiforms.export' , $this -> first ? array (
2005-11-09 00:15:14 +01:00
'start' => $this -> bo -> date2string ( $this -> first ),
'end' => $this -> bo -> date2string ( $this -> last ),
) : false ),
'no_lang' => True ,
'link' => False ,
);
$file [] = array (
2008-06-07 19:45:33 +02:00
'text' => lang ( 'Import' ) . ': ' . html :: a_href ( lang ( 'iCal' ), 'calendar.calendar_uiforms.import' ) .
2008-03-21 21:30:19 +01:00
' & ' . html :: a_href ( lang ( 'CSV' ), '/calendar/csv_import.php' ),
2005-11-09 00:15:14 +01:00
'no_lang' => True ,
'link' => False ,
);
/*
$print_functions = array (
2008-06-07 19:45:33 +02:00
'calendar.calendar_uiviews.day' => 'calendar.pdfcal.day' ,
'calendar.calendar_uiviews.week' => 'calendar.pdfcal.week' ,
2005-11-09 00:15:14 +01:00
);
if ( isset ( $print_functions [ $_GET [ 'menuaction' ]]))
{
$file [] = array (
'text' => 'pdf-export / print' ,
'link' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , array (
'menuaction' => $print_functions [ $_GET [ 'menuaction' ]],
'date' => $this -> date ,
)),
'target' => '_blank' ,
);
2008-05-08 17:02:35 +02:00
}
2005-11-09 00:15:14 +01:00
*/
$appname = 'calendar' ;
2006-03-02 19:15:25 +01:00
$menu_title = lang ( 'Calendar Menu' );
2004-08-01 17:36:04 +02:00
display_sidebox ( $appname , $menu_title , $file );
2008-05-08 17:02:35 +02:00
2005-11-09 00:15:14 +01:00
// resources menu hooks
foreach ( $this -> bo -> resources as $resource )
{
if ( ! is_array ( $resource [ 'cal_sidebox' ])) continue ;
$menu_title = $resource [ 'cal_sidebox' ][ 'menu_title' ] ? $resource [ 'cal_sidebox' ][ 'menu_title' ] : lang ( $resource [ 'app' ]);
2006-03-06 08:11:39 +01:00
$file = ExecMethod ( $resource [ 'cal_sidebox' ][ 'file' ], array (
'menuaction' => $this -> view_menuaction ,
'owner' => $this -> owner ,
));
2005-11-09 00:15:14 +01:00
display_sidebox ( $appname , $menu_title , $file );
}
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'preferences' ])
2004-08-01 17:36:04 +02:00
{
$menu_title = lang ( 'Preferences' );
$file = Array (
2005-11-09 00:15:14 +01:00
'Calendar preferences' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=preferences.uisettings.index&appname=calendar' ),
'Grant Access' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=preferences.uiaclprefs.index&acl_app=calendar' ),
'Edit Categories' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=preferences.uicategories.index&cats_app=calendar&cats_level=True&global_cats=True' ),
2004-08-01 17:36:04 +02:00
);
display_sidebox ( $appname , $menu_title , $file );
}
2005-11-09 00:15:14 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'admin' ])
2004-08-01 17:36:04 +02:00
{
$menu_title = lang ( 'Administration' );
$file = Array (
2005-11-09 00:15:14 +01:00
'Configuration' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiconfig.index&appname=calendar' ),
'Custom Fields' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.customfields.edit&appname=calendar' ),
'Holiday Management' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=calendar.uiholiday.admin' ),
'Global Categories' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uicategories.index&appname=calendar' ),
2004-08-01 17:36:04 +02:00
);
display_sidebox ( $appname , $menu_title , $file );
}
}
}