1: <?php
2: 3: 4: 5: 6:
7: 8: 9:
10: require_once 'Horde/Form/Action.php';
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 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:
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:
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:
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:
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: