Overview

Packages

  • None
  • Sesha

Classes

  • Horde_Core_UI_VarRenderer_Stockedit_Html
  • Sesha
  • Sesha_Api
  • Sesha_Driver
  • Sesha_Driver_Sql
  • Sesha_Exception
  • Sesha_Forms_Category
  • Sesha_Forms_CategoryDelete
  • Sesha_Forms_CategoryList
  • Sesha_Forms_Property
  • Sesha_Forms_PropertyDelete
  • Sesha_Forms_PropertyList
  • Sesha_Forms_Search
  • Sesha_Forms_Stock
  • Sesha_Forms_Type_Client
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Copyright 2004-2012 Horde LLC (http://www.horde.org/)
 4:  *
 5:  * See the enclosed file LICENSE for license information (GPL). If you
 6:  * did not receive this file, see http://www.horde.org/licenses/gpl.php.
 7:  *
 8:  * @author  Bo Daley <bo@darkwork.net>
 9:  * @package Sesha
10:  */
11: class Sesha_Forms_Category extends Horde_Form
12: {
13:     function __construct($vars)
14:     {
15:         parent::__construct($vars);
16:         // This is probably wrong. The library should get the driver 
17:         // or the properties passed
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: 
API documentation generated by ApiGen