]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Adding a datetime view for use with blog publication.
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 5 Apr 2010 22:21:29 +0000 (22:21 +0000)
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 5 Apr 2010 22:21:29 +0000 (22:21 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@5630 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/blog/actions/blog/save.php
mod/blog/views/default/blog/css.php
mod/blog/views/default/blog/forms/edit.php
mod/blog/views/default/input/datetime.php [new file with mode: 0644]

index 7115acaa42b8f50b89ca3e5fb7729aa038e2d1bc..db9ea77e8a1660470ea34f8bb6256ab8014ac8fa 100644 (file)
@@ -45,7 +45,6 @@ $values = array(
        'title' => '',
        'description' => '',
        'status' => 'draft',
-       'publish_date' => time(),
        'access_id' => ACCESS_DEFAULT,
        'comments_on' => 'On',
        'excerpt' => '',
@@ -99,14 +98,6 @@ foreach ($values as $name => $default) {
                        }
                        break;
 
-               case 'publish_date':
-                       if (!$value = strtotime($value)) {
-                               $value = time();
-                       }
-
-                       $values[$name] = $value;
-                       break;
-
                // don't try to set the guid
                case 'guid':
                        unset($values['guid']);
@@ -118,6 +109,15 @@ foreach ($values as $name => $default) {
        }
 }
 
+// build publish_date
+$publish_month = get_input('publish_month');
+$publish_day = get_input('publish_day');
+$publish_year = get_input('publish_year');
+$publish_hour = get_input('publish_hour');
+$publish_minute = get_input('publish_minute');
+$datetime = "$publish_year-$publish_month-$publish_day $publish_hour:$publish_minute:00";
+$values['publish_date'] = date('U', strtotime($datetime));
+
 // assign values to the entity, stopping on error.
 if (!$error) {
        foreach ($values as $name => $value) {
index 3cddd31056b8b178b74d44124b0185f58bcdcbbf..834be737e834c5f2b6597e4387e7ecc0f46321ba 100644 (file)
 }
 .blogpost .body p {
        line-height: 1.4em;
+}
+
+input.blog_publish_day,
+input.blog_publish_hour,
+input.blog_publish_minute {
+       width: 25px;
+}
+
+input.blog_publish_year {
+       width: 50px;
 }
\ No newline at end of file
index b2b494c7a4bdb642c88913349a26ee53a25f42ce..7fc5d6c91d94125b582c204d5a695e390bf0d16b 100644 (file)
@@ -137,7 +137,7 @@ $access_input = elgg_view('input/access', array(
 ));
 
 $publish_date_label = elgg_echo('blog:publish_date');
-$publish_date_input = elgg_view('input/datepicker', array(
+$publish_date_input = elgg_view('input/datetime', array(
        'internalname' => 'publish_date',
        'internalid' => 'blog_publish_date',
        'value' => $values['publish_date']
diff --git a/mod/blog/views/default/input/datetime.php b/mod/blog/views/default/input/datetime.php
new file mode 100644 (file)
index 0000000..5586464
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * A date-time view for the blog publication date.
+ */
+
+// default date to current time
+$publish_date = ($vars['value']) ? $vars['value'] : time();
+
+$months = array();
+for ($i=1; $i <= 12; $i++) {
+       $value = str_pad($i, 2, '0', STR_PAD_LEFT);
+       $months[$value] = date('M', strtotime("$value/01/2010"));
+}
+
+$month = elgg_view('input/pulldown', array(
+       'internalname' => 'publish_month',
+       'value' => date('m', $publish_date),
+       'options_values' => $months,
+       'class' => 'blog_publish_month',
+));
+
+$day = elgg_view('input/text', array(
+       'internalname' => 'publish_day',
+       'value' => date('d', $publish_date),
+       'class' => 'blog_publish_day',
+));
+
+$year = elgg_view('input/text', array(
+       'internalname' => 'publish_year',
+       'value' => date('Y', $publish_date),
+       'class' => 'blog_publish_year',
+));
+
+$hour = elgg_view('input/text', array(
+       'internalname' => 'publish_hour',
+       'value' => date('H', $publish_date),
+       'class' => 'blog_publish_hour',
+));
+
+$minute = elgg_view('input/text', array(
+       'internalname' => 'publish_minute',
+       'value' => date('i', $publish_date),
+       'class' => 'blog_publish_minute',
+));
+
+echo "$month $day, $year @ $hour:$minute";