/** * * delete rows */ public function delete($table, $where) { global $wpdb; UniteFunctionsBiz::validateNotEmpty($table, "table name"); UniteFunctionsBiz::validateNotEmpty($where, "where"); $query = "delete from {$table} where {$where}"; $wpdb->query($query); $this->checkForErrors("Delete query error"); }
/** * update sortby option */ public function updatePostsSortbyFromData($data) { $sliderID = UniteFunctionsBiz::getVal($data, "sliderID"); $sortBy = UniteFunctionsBiz::getVal($data, "sortby"); UniteFunctionsBiz::validateNotEmpty($sortBy, "sortby"); $this->initByID($sliderID); $arrUpdate = array(); $arrUpdate["post_sortby"] = $sortBy; $this->updateParam($arrUpdate); }
/** * * must be templateID in the data */ private function getTemplateFromData($data) { $templateID = UniteFunctionsBiz::getVal($data, "templateID"); UniteFunctionsBiz::validateNotEmpty($templateID, "tempalte id"); $template = new ShowBizTemplate(); $template->initById($templateID); return $template; }
/** * * remove the custom wildcard from data */ public function removeFromData($data) { $name = UniteFunctionsBiz::getVal($data, "name"); UniteFunctionsBiz::validateNotEmpty($name); $this->removeCustomOption($name); $response = $data; return $response; }
/** * * load settings from xml file */ public function loadXMLFile($filepath) { if (!file_exists($filepath)) { UniteFunctionsBiz::throwError("File: '{$filepath}' not exists!!!"); } $obj = @simplexml_load_file($filepath); if (empty($obj)) { UniteFunctionsBiz::throwError("Wrong xml file format: {$filepath}"); } $fieldsets = $obj->fieldset; if (!@count($obj->fieldset)) { $fieldsets = array($fieldsets); } $this->addSection("Xml Settings"); foreach ($fieldsets as $fieldset) { //Add Section $attribs = $fieldset->attributes(); $sapName = (string) UniteFunctionsBiz::getVal($attribs, "name"); $sapLabel = (string) UniteFunctionsBiz::getVal($attribs, "label"); UniteFunctionsBiz::validateNotEmpty($sapName, "sapName"); UniteFunctionsBiz::validateNotEmpty($sapLabel, "sapLabel"); $this->addSap($sapLabel, $sapName); //--- add fields $fieldset = (array) $fieldset; $fields = $fieldset["field"]; if (is_array($fields) == false) { $fields = array($fields); } foreach ($fields as $field) { $attribs = $field->attributes(); $fieldType = (string) UniteFunctionsBiz::getVal($attribs, "type"); $fieldName = (string) UniteFunctionsBiz::getVal($attribs, "name"); $fieldLabel = (string) UniteFunctionsBiz::getVal($attribs, "label"); $fieldDefaultValue = (string) UniteFunctionsBiz::getVal($attribs, "default"); //all other params will be added to "params array". $arrMustParams = array("type", "name", "label", "default"); $arrParams = array(); foreach ($attribs as $key => $value) { $key = (string) $key; $value = (string) $value; //skip must params: if (in_array($key, $arrMustParams)) { continue; } $arrParams[$key] = $value; } $options = $this->getOptionsFromXMLField($field, $fieldName); //validate must fields: UniteFunctionsBiz::validateNotEmpty($fieldType, "type"); //validate name if ($fieldType != self::TYPE_HR && $fieldType != self::TYPE_CONTROL && $fieldType != "bulk_control_start" && $fieldType != "bulk_control_end") { UniteFunctionsBiz::validateNotEmpty($fieldName, "name"); } switch ($fieldType) { case self::TYPE_CHECKBOX: $fieldDefaultValue = UniteFunctionsBiz::strToBool($fieldDefaultValue); $this->addCheckbox($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_COLOR: $this->addColorPicker($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_HR: $this->addHr(); break; case self::TYPE_TEXT: $this->addTextBox($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_IMAGE: $this->addImage($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_IMAGE_LIBRARY: $this->addImageLibrary($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_SELECT: $this->addSelect($fieldName, $options, $fieldLabel, $fieldDefaultValue, $arrParams); break; case self::TYPE_RADIO: $this->addRadio($fieldName, $options, $fieldLabel, $fieldDefaultValue, $arrParams); break; case self::TYPE_TEXTAREA: $this->addTextArea($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_CUSTOM: $this->add($fieldName, $fieldDefaultValue, $fieldLabel, self::TYPE_CUSTOM, $arrParams); break; case self::TYPE_STATIC_TEXT: $this->addStaticText($fieldLabel, $fieldName, $arrParams); break; case self::TYPE_CONTROL: $parent = UniteFunctionsBiz::getVal($arrParams, "parent"); $child = UniteFunctionsBiz::getVal($arrParams, "child"); $ctype = UniteFunctionsBiz::getVal($arrParams, "ctype"); $value = UniteFunctionsBiz::getVal($arrParams, "value"); $this->addControl($parent, $child, $ctype, $value); break; case "bulk_control_start": $parent = UniteFunctionsBiz::getVal($arrParams, "parent"); $ctype = UniteFunctionsBiz::getVal($arrParams, "ctype"); $value = UniteFunctionsBiz::getVal($arrParams, "value"); $this->startBulkControl($parent, $ctype, $value); break; case "bulk_control_end": $this->endBulkControl(); break; default: UniteFunctionsBiz::throwError("wrong type: {$fieldType}"); break; } } } }