Overview

Packages

  • Jonah
  • None

Classes

  • Jonah
  • Jonah_Api
  • Jonah_Block_Latest
  • Jonah_Driver
  • Jonah_Driver_Sql
  • Jonah_Exception
  • Jonah_Factory_Driver
  • Jonah_Form_Feed
  • Jonah_Form_Story
  • Jonah_Test
  • Jonah_View_ChannelDelete
  • Jonah_View_ChannelEdit
  • Jonah_View_ChannelList
  • Jonah_View_StoryDelete
  • Jonah_View_StoryEdit
  • Jonah_View_StoryList
  • Jonah_View_StoryPdf
  • Jonah_View_StoryView
  • Jonah_View_TagSearchList
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Form for editing a new Story.
  4:  *
  5:  * @package Jonah
  6:  */
  7: /**
  8:  * Horde_Form_Action
  9:  */
 10: require_once 'Horde/Form/Action.php';
 11: 
 12: /**
 13:  * This class extends Horde_Form to provide the form to add/edit
 14:  * stories.
 15:  *
 16:  * Copyright 2002-2012 Horde LLC (http://www.horde.org/)
 17:  *
 18:  * See the enclosed file LICENSE for license information (BSD). If you
 19:  * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
 20:  *
 21:  * @author Marko Djukic <marko@oblo.com>
 22:  * @author Chuck Hagenbuch <chuck@horde.org>
 23:  * @package Jonah
 24:  */
 25: class Jonah_Form_Story extends Horde_Form
 26: {
 27:     /**
 28:      */
 29:     function __construct(&$vars)
 30:     {
 31:         parent::Horde_Form($vars, $vars->get('id') ? _("Edit Story") : _("Add New Story"));
 32: 
 33:         $this->setButtons(_("Save"));
 34:         $channel_id = $this->addHidden('', 'channel_id', 'int', false);
 35:         $channel = $vars->get('channel_id');
 36:         if ($channel) {
 37:             $channel_id->setDefault($channel_id);
 38:         }
 39:         $this->addHidden('', 'id', 'int', false);
 40:         $this->addHidden('', 'read', 'int', false);
 41:         $this->addVariable(_("Story Title (Headline)"), 'title', 'text', true);
 42:         $this->addVariable(_("Short Description"), 'description', 'longtext', true, false, null, array(2, 80));
 43:         $this->addVariable(_("Publish Now?"), 'publish_now', 'boolean', false);
 44: 
 45:         $published = $vars->get('published');
 46:         if ($published) {
 47:             $date_params = array(min(date('Y', $published), date('Y')),
 48:                                  max(date('Y', $published), date('Y') + 10));
 49:         } else {
 50:             $date_params = array();
 51:         }
 52: 
 53:         $d = &$this->addVariable(_("Or publish on this date:"), 'publish_date', 'monthdayyear', false, false, null, $date_params);
 54:         $d->setDefault($published);
 55: 
 56:         $t = &$this->addVariable('', 'publish_time', 'hourminutesecond', false);
 57:         $t->setDefault($published);
 58: 
 59:         $v = &$this->addVariable(_("Story body type"), 'body_type', 'enum', false, false, null, array(Jonah::getBodyTypes()));
 60:         $v->setAction(Horde_Form_Action::factory('submit'));
 61:         $v->setOption('trackchange', true);
 62: 
 63:         /* If no body type specified, default to one. */
 64:         $body_type = $vars->get('body_type');
 65:         if (empty($body_type)) {
 66:             $body_type = Jonah::getDefaultBodyType();
 67:             $vars->set('body_type', $body_type);
 68:         }
 69: 
 70:         /* Set up the fields according to what the type of body requested. */
 71:         if ($body_type == 'text') {
 72:             $this->addVariable(_("Full Story Text"), 'body', 'longtext', false, false, null, array(15, 80));
 73:         } elseif ($body_type == 'richtext') {
 74:             $this->addVariable(_("Full Story Text"), 'body', 'longtext', false, false, null, array(20, 80, array('rte')));
 75:         }
 76: 
 77:         $this->addVariable(_("Tags"), 'tags', 'text', false, false, _("Enter keywords to tag this story, separated by commas"));
 78:         /* Only show URL insertion if it has been enabled in config. */
 79:         if (in_array('links', $GLOBALS['conf']['news']['story_types'])) {
 80:             $this->addVariable(_("Story URL"), 'url', 'text', false, false, _("If you enter a URL without a full story text, clicking on the story will send the reader straight to the URL, otherwise it will be shown at the end of the full story."));
 81:         }
 82:     }
 83: 
 84:     /**
 85:      */
 86:     function getInfo(&$vars, &$info)
 87:     {
 88:         parent::getInfo($vars, $info);
 89: 
 90:         /* Build release date. */
 91:         if (!empty($info['publish_now'])) {
 92:             $info['published'] = time();
 93:         } elseif (!empty($info['publish_date'])) {
 94:             $info['published'] = mktime(
 95:                 (int)$info['publish_time']['hour'],
 96:                 (int)$info['publish_time']['minute'],
 97:                 0,
 98:                 date('n', $info['publish_date']),
 99:                 date('j', $info['publish_date']),
100:                 date('Y', $info['publish_date']));
101:         } else {
102:             $info['published'] = null;
103:         }
104: 
105:         unset($info['publish_now']);
106:         unset($info['publish_date']);
107:         unset($info['publish_time']);
108:     }
109: 
110: }
111: 
API documentation generated by ApiGen