public function summaryFields() { $fields = parent::summaryFields(); if (FeatureGroup::get()->exists()) { $fields['Group.Title'] = 'Group'; } return $fields; }
/** * Override features list with grouping. */ function GroupedFeatures($showungrouped = false) { $features = $this->owner->Features()->innerJoin("Feature", "Feature.ID = ProductFeatureValue.FeatureID"); //figure out feature groups $groupids = FeatureGroup::get()->innerJoin("Feature", "Feature.GroupID = FeatureGroup.ID")->innerJoin("ProductFeatureValue", "Feature.ID = ProductFeatureValue.FeatureID")->filter("ProductID", $this->owner->ID)->getIDList(); //pack existin features into seperate lists $result = new ArrayList(); foreach ($groupids as $groupid) { $group = FeatureGroup::get()->byID($groupid); $result->push(new ArrayData(array('Group' => $group, 'Children' => $features->filter("GroupID", $groupid)))); } //ungrouped $ungrouped = $features->filter("GroupID:not", $groupids); if ($ungrouped->exists() && $showungrouped) { $result->push(new ArrayData(array('Children' => $ungrouped))); } return $result; }
/** * Display form for edit list of features of particular group */ public function displayForm() { global $currentIndex, $cookie; $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(); $obj = $this->loadObject(true); if (!$obj->id_group) { $obj->id_group = isset($_GET["id_group"]) ? intval($_GET["id_group"]) : NULL; } ?> <script type="text/javascript"> id_language = Number(<?php echo $defaultLanguage; ?> ); </script> <form action="<?php echo $currentIndex; ?> &token=<?php echo $this->token; ?> " method="post"> <?php echo $obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : ''; ?> <fieldset class="width3"> <legend> <img src="../img/t/AdminFeatures.gif" /><?php echo $this->l('Feature'); ?> </legend> <label><?php echo $this->l('Name:'); ?> </label> <div class="margin-form"> <?php foreach ($languages as $language) { ?> <div id="name_<?php echo $language['id_lang']; ?> " style="display: <?php echo $language['id_lang'] == $defaultLanguage ? 'block' : 'none'; ?> ; float: left;"> <input size="33" type="text" name="name_<?php echo $language['id_lang']; ?> " value="<?php echo htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8'); ?> " /><sup> *</sup> <span class="hint" name="help_box"><?php echo $this->l('Invalid characters:') . "<>;=#{}"; ?> <span class="hint-pointer"> </span></span> </div> <?php } ?> <?php echo $this->displayFlags($languages, $defaultLanguage, 'name', 'name'); ?> <div style="clear: both;"></div> </div> <label><?php echo $this->l('Group: '); ?> </label> <div class="margin-form"> <select name="id_group"> <option value=''>---</option> <?php echo $featureGroups = FeatureGroup::getFeatureGroups(intval($cookie->id_lang)); foreach ($featureGroups as $fg) { ?> <option value='<?php echo $fg["id_group"]; ?> ' <?php if (intval($fg["id_group"]) == intval($obj->id_group)) { ?> selected="selected" <?php } ?> ><?php echo $fg["name"]; ?> </option> <?php } ?> </select> </div> <label><?php echo $this->l('Position: '); ?> </label> <div class="margin-form"> <input size=5 maxlength=5 type="text" name="position" value="<?php echo htmlentities($this->getFieldValue($obj, 'position', NULL), ENT_COMPAT, 'UTF-8'); ?> " /> <span class="hint" name="help_box"><?php echo $this->l('Only digital allowed!'); ?> <span class="hint-pointer"> </span></span> </div> <div class="margin-form"> <input type="submit" value="<?php echo $this->l(' Save '); ?> " name="submitAdd<?php echo $this->table; ?> " class="button" /> </div> <div class="small"><sup>*</sup> <?php echo $this->l('Required field'); ?> </div> </fieldset> </form> <?php }