/** * function addFormItem * <pre> * Stores a Form Item entry * </pre> * @param $name [STRING] the name of the form item * @param $value [STRING] default value of this form item * @param $error [STRING] error message related to this form item * @param $type [STRING] type of form item * @param $options [ARRAY] list of alternate parameters for specific form types * @return [void] */ function addFormItem($name, $value, $error, $type, $options) { $xmlItem = new XMLObject(XMLObject_AdminBox::XML_NODE_FORMITEM); $xmlItem->addElement(XMLObject_AdminBox::XML_ELEMENT_FORMITEM_NAME, $name); $xmlItem->addElement(XMLObject_AdminBox::XML_ELEMENT_FORMITEM_VALUE, $value); $xmlItem->addElement(XMLObject_AdminBox::XML_ELEMENT_FORMITEM_ERROR, $error); $xmlItem->addElement(XMLObject_AdminBox::XML_ELEMENT_FORMITEM_TYPE, $type); switch ($type) { case 'D': // on a date type, add the start and end years $key = XMLObject_AdminBox::XML_ELEMENT_FORMITEM_DATE_STARTYEAR; $xmlItem->addElement($key, $options[$key]); $key = XMLObject_AdminBox::XML_ELEMENT_FORMITEM_DATE_ENDYEAR; $xmlItem->addElement($key, $options[$key]); break; case 'L': // add each list item to the form item foreach ($options as $value => $label) { $xmlOption = new XMLObject(XMLObject_AdminBox::XML_NODE_FORMITEM_LIST_ITEM); $xmlOption->addElement(XMLObject_AdminBox::XML_ELEMENT_FORMITEM_LIST_ITEM_LABEL, $label); $xmlOption->addElement(XMLObject_AdminBox::XML_ELEMENT_FORMITEM_LIST_ITEM_VALUE, $value); $xmlItem->addXmlObject($xmlOption); } break; } $this->form->addXmlObject($xmlItem); }
/** * function loadData * <pre> * gathers the label data from the DB * </pre> * @return [void] */ function loadData() { // build sql for gathering data // $fieldNames = str_replace('label_moddate','FROM_UNIXTIME(label_moddate) as label_moddate', $this->fieldNames); $sql = 'SELECT * FROM '; $sql .= SITE_DB_NAME . '.' . XMLObject_MultilingualManager::DB_TABLE_LABEL; $sql .= ' WHERE page_id="' . $this->pageID . '" AND label_key="' . $this->labelKey . '"'; $this->db->runSQL($sql); // for each label while ($row = $this->db->retrieveRow()) { // create new XML Object $currentLabel = new XMLObject(XMLObject_Multilingual_Label::NODE_LABEL); // load Values into XML Object for ($indx = 0; $indx < count($this->fieldList); $indx++) { $fieldName = $this->fieldList[$indx]; $currentLabel->addElement($fieldName, $row[$fieldName]); } // Load any translation requests for this label $translationRequests = new XMLObject_Multilingual_Translation($row['label_id']); $currentLabel->addXmlObject($translationRequests); // store XML Object into array $this->labelsList[] = $currentLabel; } // next label // Add Each Label entry to this element for ($indx = 0; $indx < count($this->labelsList); $indx++) { $this->addXmlObject($this->labelsList[$indx]); } // next Label }