From b070daa95241bc0c7d46011a3de7674fbf0c5e68 Mon Sep 17 00:00:00 2001 From: Fx Nion Date: Sun, 13 May 2012 19:56:15 +0200 Subject: v2.4 --- .../widgets/latest_events_index/content.php | 95 +++++++++++++++++++++ views/default/widgets/latest_events_index/edit.php | 96 ++++++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 views/default/widgets/latest_events_index/content.php create mode 100644 views/default/widgets/latest_events_index/edit.php (limited to 'views/default/widgets/latest_events_index') diff --git a/views/default/widgets/latest_events_index/content.php b/views/default/widgets/latest_events_index/content.php new file mode 100644 index 000000000..7c5ae40f3 --- /dev/null +++ b/views/default/widgets/latest_events_index/content.php @@ -0,0 +1,95 @@ +pluginspath.'event_calendar/models/model.php'); + + if(!function_exists('getLastDayOfMonth')){ + function getLastDayOfMonth($month,$year) { + return idate('d', mktime(0, 0, 0, ($month + 1), 0, $year)); + } + } + + $object_type ='event_calendar'; + + $num_items = $vars['entity']->num_items; + if (!isset($num_items)) + $num_items = 10; + + $widget_group = $vars["entity"]->widget_group; + if (!isset($widget_group)) + $widget_group = 0; + + $mode = $vars['mode']->mode; + if (!isset($mode)) + $mode = "month"; + + $site_categories = $vars['config']->site->categories; + $widget_categorie = $vars['entity']->widget_categorie; + $widget_context_mode = $vars['entity']->widget_context_mode; + if (!isset($widget_context_mode)) + $widget_context_mode = 'search'; + + elgg_set_context($widget_context_mode); + + + $original_start_date = date('Y-m-d'); + $day = 60*60*24; + $week = 7*$day; + $month = 31*$day; + + + if ($mode == "day") { + $start_date = $original_start_date; + $end_date = $start_date; + $start_ts = strtotime($start_date); + $end_ts = strtotime($end_date)+$day-1; + } else if ($mode == "week") { + + $start_ts = strtotime($original_start_date); + $start_ts -= date("w",$start_ts)*$day; + $end_ts = $start_ts + 6*$day; + + $start_date = date('Y-m-d',$start_ts); + $end_date = date('Y-m-d',$end_ts); + } else { + $start_ts = strtotime($original_start_date); + $month = date('m',$start_ts); + $year = date('Y',$start_ts); + $start_date = $year.'-'.$month.'-1'; + $end_date = $year.'-'.$month.'-'.getLastDayOfMonth($month,$year); + } + + if ($event_calendar_first_date && ($start_date < $event_calendar_first_date)) { + $start_date = $event_calendar_first_date; + } + + if ($event_calendar_last_date && ($end_date > $event_calendar_last_date)) { + $end_date = $event_calendar_last_date; + } + + $start_ts = strtotime($start_date); + + if ($mode == "day") { + $end_ts = strtotime($end_date)+$day-1; + } else if ($mode == "week") { + $end_ts = $start_ts + 6*$day; + } else { + $end_ts = strtotime($end_date); + } + + $count = event_calendar_get_events_between($start_ts,$end_ts,true,$num_items,0,$widget_group,'-'); + $events = event_calendar_get_events_between($start_ts,$end_ts,false,$num_items,0,$widget_group,'-'); + //$widget_datas= $event_list = elgg_view_entity_list($events, $count, 0, $num_items, false, false); + + $options = array( + 'list_class' => 'elgg-list-entity', + 'full_view' => FALSE, + 'pagination' => TRUE, + 'list_type' => 'listing', + 'list_type_toggle' => FALSE, + 'offset' => $vars['offset'], + 'limit' => $vars['limit'], + ); + $widget_datas = elgg_view_entity_list($events, $options); + echo $widget_datas; +?> + diff --git a/views/default/widgets/latest_events_index/edit.php b/views/default/widgets/latest_events_index/edit.php new file mode 100644 index 000000000..3aa20f574 --- /dev/null +++ b/views/default/widgets/latest_events_index/edit.php @@ -0,0 +1,96 @@ + num_items; + if (!isset($num_items)) $num_items = 10; + + $widget_group = $vars["entity"]->widget_group; + if (!isset($widget_group)) $widget_group = 0; + + $site_categories = $vars['config']->site->categories; + $widget_categorie = $vars['entity']->widget_categorie; + $widget_context_mode = $vars['entity']->widget_context_mode; + if (!isset($widget_context_mode)) $widget_context_mode = 'search'; + + $widget_title = $vars['entity']->widget_title; + $widget_group = $vars["entity"]->widget_group; + + $guest_only = $vars['entity']->guest_only; + if (!isset($guest_only)) $guest_only = "no"; + + $box_style = $vars['entity']->box_style; + if (!isset($box_style)) $box_style = "collapsable"; + ?> +

+ + : + 'params[widget_title]', 'value'=>$widget_title)); + ?> +

+

+ + : + 'group','limit'=>100)); + $group_list = array(); + $group_list[0] = elgg_echo('custom_index_widgets:widget_all_groups'); + if ($groups) { + foreach ($groups as $group) { + $group_list[$group->getGUID()] = $group->name; + } + } + echo elgg_view('input/dropdown', array('name'=>'params[widget_group]', 'options_values'=>$group_list, 'value'=>$widget_group)); + ?> +

+ +

+ + : + ''), array_combine($site_categories, $site_categories)); + echo elgg_view('input/dropdown', array('name'=>'params[widget_categorie]', 'options_values'=>$categories_with_empty_choice, 'value'=>$widget_categorie)); + ?> +

+ +

+ + : + 'params[widget_context_mode]', 'options_values'=>array('search'=>elgg_echo('custom_index_widgets:context_list'), 'detail'=>elgg_echo('custom_index_widgets:context_detail')), 'value'=>$widget_context_mode)); + ?> +

+

+ + : + 'params[num_items]', 'options_values'=>array('1'=>'1', '3'=>'3', '5'=>'5', '8'=>'8', '10'=>'10', '12'=>'12', '15'=>'15', '20'=>'20', '30'=>'30', '40'=>'40', '50'=>'50', '100'=>'100', ), 'value'=>$num_items)); + ?> +

+

+ + : + 'params[mode]', + 'options_values'=>array('day'=>elgg_echo('event_calendar:day_label'), + 'week'=>elgg_echo('event_calendar:week_label'), + 'month'=>elgg_echo('event_calendar:month_label')), + 'value'=>$num_items)); + ?> +

+

+ + : + 'params[box_style]', + 'options_values'=>array('plain'=>'Plain', 'plain collapsable'=>'Plain and collapsable', 'collapsable'=>'Collapsable', 'standard' => 'No Collapsable'), + 'value'=>$box_style)); + ?> +

+

+ + : + 'params[guest_only]', + 'options_values'=>array('yes'=>'yes', 'no'=>'no'), + 'value'=>$guest_only)); + ?> +

-- cgit v1.2.3