]> git.mxchange.org Git - friendica.git/commitdiff
more events framework
authorFriendika <info@friendika.com>
Tue, 7 Jun 2011 02:59:20 +0000 (19:59 -0700)
committerFriendika <info@friendika.com>
Tue, 7 Jun 2011 02:59:20 +0000 (19:59 -0700)
include/datetime.php
mod/events.php

index f7be5bdb11666d789af3f3a908515671583b7af9..67c4f42fad5b09219e3ebb8a6756a8233e545fe4 100644 (file)
@@ -108,9 +108,17 @@ function datesel($pre,$ymin,$ymax,$allow_blank,$y,$m,$d) {
                $o .= "<option value=\"0000\" $sel ></option>";
        }
 
-       for($x = $ymax; $x >= $ymin; $x --) {
-               $sel = (($x == $y) ? " selected=\"selected\" " : "");
-               $o .= "<option value=\"$x\" $sel>$x</option>";
+       if($ymax > $ymin) {
+               for($x = $ymax; $x >= $ymin; $x --) {
+                       $sel = (($x == $y) ? " selected=\"selected\" " : "");
+                       $o .= "<option value=\"$x\" $sel>$x</option>";
+               }
+       }
+       else {
+               for($x = $ymax; $x <= $ymin; $x ++) {
+                       $sel = (($x == $y) ? " selected=\"selected\" " : "");
+                       $o .= "<option value=\"$x\" $sel>$x</option>";
+               }
        }
   
        $o .= "</select> <select name=\"{$pre}month\" class=\"{$pre}month\" size=\"1\">";
@@ -131,6 +139,32 @@ function datesel($pre,$ymin,$ymax,$allow_blank,$y,$m,$d) {
        return $o;
 }}
 
+if(! function_exists('timesel')) {
+function timesel($pre,$h,$m) {
+
+       $o = '';
+       $o .= "<select name=\"{$pre}hour\" class=\"{$pre}hour\" size=\"1\">";
+       for($x = 0; $x < 24; $x ++) {
+               $sel = (($x == $h) ? " selected=\"selected\" " : "");
+               $o .= "<option value=\"$x\" $sel>$x</option>";
+       }
+       $o .= "</select> : <select name=\"{$pre}minute\" class=\"{$pre}minute\" size=\"1\">";
+       for($x = 0; $x < 60; $x ++) {
+               $sel = (($x == $m) ? " selected=\"selected\" " : "");
+               $o .= "<option value=\"$x\" $sel>$x</option>";
+       }
+
+       $o .= "</select>";
+       return $o;
+}}
+
+
+
+
+
+
+
+
 // implements "3 seconds ago" etc.
 // based on $posted_date, (UTC).
 // Results relative to current timezone
index 73328b959e31f2dbcd01113080952643cc9372a8..cca0f20746131f5c461a7abbda1a5cf2debb3f75 100644 (file)
@@ -82,3 +82,71 @@ function events_post(&$a) {
 }
 
 
+
+function events_content(&$a) {
+
+       if(! local_user()) {
+               notice( t('Permission denied.') . EOL);
+               return;
+       }
+
+       $mode = 'view';
+       $y = 0;
+       $m = 0;
+
+       if($a->argc > 1) {
+               if($a->argc > 2 && $a->argv[1] == 'event') {
+                       $mode = 'edit';
+                       $event_id = intval($a->argv[2]);
+               }
+               if($a->argv[1] === 'new') {
+                       $mode = 'new';
+                       $event_id = 0;
+               }
+               if($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
+                       $mode = 'view';
+                       $y = intval($a->argv[1]);
+                       $m = intval($a->argv[2]);
+               }
+       }
+
+       if($mode == 'view') {
+           $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
+       $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
+               if(! $y)
+                       $y = intval($thisyear);
+               if(! $m)
+                       $m = intval($thismonth);
+
+       
+               $o .= cal($y,$m,false);
+
+               return $o;
+       }
+
+       if($mode === 'edit' || $mode === 'new') {
+               $tpl = get_markup_template('event_form.tpl');
+
+               $year = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
+
+
+               $o .= replace_macros($tpl,array(
+                       '$post' => $a->get_baseurl() . '/events',
+                       '$e_text' => t('Event details'),
+                       '$s_text' => t('Starting date/time:'),
+                       '$s_dsel' => datesel('start',$year+5,$year,false,$year,0,0),
+                       '$s_tsel' => timesel('start',0,0),
+                       '$f_text' => t('Finish date/time:'),
+                       '$f_dsel' => datesel('start',$year+5,$year,false,$year,0,0),
+                       '$f_tsel' => timesel('start',0,0),
+                       '$d_text' => t('Description:'),
+                       '$d_orig' => '',
+                       '$l_text' => t('Location:'),
+                       '$l_orig' => '',
+                       '$submit' => t('Submit')
+
+               ));
+
+               return $o;
+       }
+}
\ No newline at end of file