1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11: class Sesha_Forms_Category extends Horde_Form
12: {
13: function __construct($vars)
14: {
15: parent::__construct($vars);
16:
17:
18: $sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
19: $this->appendButtons(_("Save Category"));
20:
21: $category_id = $vars->get('category_id');
22:
23: $priorities = array();
24: for ($i = 0; $i < 100; $i++) {
25: $priorities[] = $i;
26: }
27:
28: try {
29: $allproperties = $sesha_driver->getProperties();
30: }
31: catch (Sesha_Exception $e) {
32: throw new Sesha_Exception($e);
33: }
34: $a = array();
35: foreach ($allproperties as $p) {
36: $a[$p['property_id']] = $p['property'];
37: }
38: if (!empty($category_id)) {
39: try {
40: $properties = $sesha_driver->getPropertiesForCategories($category_id);
41: } catch (Sesha_Exception $e) {
42: throw new Sesha_Exception($e);
43: }
44: $current = array();
45: foreach ($properties as $s) {
46: $current[$s['property_id']] = $s['property'];
47: }
48: }
49:
50: $this->addHidden('', 'actionID', 'text', false, false, null);
51: $this->addHidden('', 'category_id', 'text', false, false, null);
52: $this->addHidden('', 'submitbutton', 'text', false, false, null);
53: $this->addVariable(_("Category Name"), 'category', 'text', true);
54: $this->addVariable(_("Description"), 'description', 'longtext', false);
55: $this->addVariable(_("Sort Weight"), 'priority', 'enum', false, false, _("When categories are displayed, they will be shown in weight order from highest to lowest"), array($priorities));
56: if (!count($a)) {
57: $fieldtype = 'invalid';
58: $a = _("No properties are currently configured. Use the 'Manage Properties' tab (above) to add some.");
59: } else {
60: $fieldtype = 'multienum';
61: }
62: $mp = &$this->addVariable(_("Properties"), 'properties', $fieldtype, true, false, null, array($a));
63: if (!empty($current)) {
64: $mp->setDefault(array_keys($current));
65: }
66:
67: $action = Horde_Form_Action::factory('submit');
68: }
69: }
70: