codes = $codes; } function addCodes($codesArray) { //необходимо реализовать подгрузку кодов ошибок для файлов модулей :( echo "подгрузка кодов..."; } function handleError($errorCode) { echo "handling error $errorCode..."; } } //class } //if (!defined("_CErrorMonitor_CLASS_")) /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * function for formatting list of option tags * parameters: * - $array - accociative array of values for list * key - is a value attribute for option tag, value will display in control * - $selected - determines selected options * may be array (if multiple select) and single variable - for usual select * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ ?> CSimpleObject($table, $key_field); if ($id != -1) $this->Load($id); $this -> parameters = array(); $this -> deleteFiles = true; $this -> addSlashesControls = array("text","textarea","wisiwyg"); $this -> addBrControls = array("textarea"); $this -> replQuotControls = array("text","textarea","wisiwyg"); } function setParameters($array) { foreach ($this->parameters as $key => $attr_array) { if (isset($array[$key]["formValue"])) { $this->parameters[$key]["formValue"] = $array[$key]["formValue"]; $this->$key = $array[$key]["formValue"]; } } } function setParameter($key,$value) { $this->$key = $value; $this->parameters[$key]["formValue"] = $value; } //????? function handleError($errorCode) { global $errorMonitor; $errorMonitor -> handleError($errorCode); } function oCreate() { $this->prepare2Save(); return $this->Create(); } function oDelete($id = -1) { global $DocumentRoot; //delete all uploaded files foreach ($this->parameters as $key => $attr_array) { //add Slashes where needed if ($attr_array["control"]=='file'&&$attr_array["formValue"]) { $split_name = split_filename($attr_array["formValue"]); //if previews defined delete them $file = $DocumentRoot.$attr_array["upload_dir"].$attr_array["formValue"]; unlink($file); if (isset($attr_array["previews"])) foreach ($attr_array["previews"] as $index => $props) { $preview = $DocumentRoot.$attr_array["upload_dir"].$split_name["name"].$props["preview_tail"].".jpg"; unlink($preview); } } } return $this->Delete($id); } function oLoad($id = -1) { $this->prepare2Show(); return $this->Load($id); } function oSave($id = -1) { $this->prepare2Save(); if ($id != -1) $this->Save($id); else { $this->lastFormUpdated = ''; $this->Create(); } } function prepare2Save() { foreach ($this->parameters as $key => $attr_array) { //replace quotes where need if (in_array($attr_array["control"],$this -> replQuotControls)) { $this->parameters[$key]["formValue"] = str_replace ('"', """, $attr_array["formValue"]); $this->parameters[$key]["formValue"] = str_replace ("'", "’", $attr_array["formValue"]); $attr_array["formValue"] = $this->parameters[$key]["formValue"]; $this->$key = $this->parameters[$key]["formValue"]; } //add Slashes where needed if (in_array($attr_array["control"],$this -> addSlashesControls)) { $this->parameters[$key]["formValue"] = addSlashes($attr_array["formValue"]); $this->$key = $attr_array["formValue"]; } } } function prepare2Show() { global $ADD_BR_FLAG; foreach ($this->parameters as $key => $attr_array) { //strip Slashes where needed if (in_array($attr_array["control"],$this -> addSlashesControls)) { $this->parameters[$key]["formValue"] = stripSlashes($attr_array["formValue"]); $this->$key = $attr_array["formValue"]; } if (in_array($attr_array["control"],$this -> addBrControls)&&$ADD_BR_FLAG) { $this->parameters[$key]["formValue"] = nl2br($attr_array["formValue"]); $this->$key = nl2br($attr_array["formValue"]); } } } } //class } //if !defined ?> CCommonObject($table, $key_field, $id); $this->idField = $idField; $this->rootStringValue = $rootStringValue; } /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * Функция возвращает значение некоторого поля объекта. * параметры: $field_name - название поля, значение которого необходимо вернуть * $root_value - значение, которое возвращается в случае, если элемент корневой * значение: Если узел корневой и $root_value="", возвращает $this->rootStringValue * Если узел корневой и $root_value оперделено и не пустая строка, вовращает $root_value * Если узел не корневой, то возвращает значание поля, имя которого задано в пер $field_name * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ function getFieldValue($field_name,$root_value="default") { if ($this -> {$this->idField} == 0) { if ($root_value != "default") return $root_value; else return $this->rootStringValue; } else return $this -> $field_name; } /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * Функция возвращает распарсенный из шаблона вид навигационной строки * параметры: $base_href - путь к скрипту, который будет обрабатывать ссылки с нав. строки * $parametr_name - название параметра, в котором будет содержаться идентификатор категории * $template - шаблон, в соотвествии с которым отображатся навигационная строка * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ function getNavigationString($base_href,$template="navigation_string") { global $Page; $this -> getHierarchy(); $depth = count($this -> hierarchy); $i = 0; if (is_array($this -> hierarchy)) foreach ($this -> hierarchy as $key => $value) if ($key < $depth-1) { $template_data[$i]["condition"] = "passive"; $template_data[$i]["link"] = $base_href.$value["category_id"]; $template_data[$i++]["text"] = $value["category_title"]; } else { $template_data[$i]["condition"] = "active"; $template_data[$i]["link"] = $base_href.$value["category_id"]; $template_data[$i++]["text"] = $value["category_title"]; } $Page->addRows($template, $template_data, "NAVSTR_"); return $Page->getParsedTemplate($template); } function getNavigationMenu($base_href,$template) { global $Page,$g_db,$menu_mode; $result = ""; $this -> getHierarchy(); if ($this->hierarchy[0]["category_id"]) { $g_db->Query("select category_id, category_title from " . CATEGORY_TABLE . " where category_parent_id = '".$this->hierarchy[0]["category_id"]."'"); $level1_count = $g_db -> datacount; $level1_data = $g_db -> data; $c = 0; for ($i = 0; $i < $level1_count; $i++) { $level1_template_data[$c]["link"] = $base_href.$level1_data[$i]["category_id"]; $level1_template_data[$c]["text"] = $level1_data[$i]["category_title"]; $level1_template_data[$c++]["condition"] = "level1"; //select subcetegories if ($level1_data[$i]["category_id"]&&($menu_mode=='full'||$menu_mode=='mid')) { $g_db->Query("select category_id, category_title from " . CATEGORY_TABLE . " where category_parent_id = '".$level1_data[$i]["category_id"]."'"); $level2_count = $g_db -> datacount; $level2_data = $g_db -> data; for ($j = 0; $j < $level2_count; $j++) { $level1_template_data[$c]["link"] = $base_href.$level2_data[$j]["category_id"]; $level1_template_data[$c]["text"] = $level2_data[$j]["category_title"]; $level1_template_data[$c++]["condition"] = "level2"; if ($level2_data[$j]["category_id"]&&$menu_mode=='full') { $g_db->Query("select category_id, category_title from " . CATEGORY_TABLE . " where category_parent_id = '".$level2_data[$j]["category_id"]."'"); $level3_count = $g_db -> datacount; $level3_data = $g_db -> data; if ($level3_count > 0) { $Page->clearTemplate("level3_cells"); $level2_template_data = array(); for ($k = 0; $k < $level3_count; $k++) { $level2_template_data[$k]["text"] = $level3_data[$k]["category_title"]; $level2_template_data[$k]["link"] = $base_href.$level3_data[$k]["category_id"]; } $Page->addRows( "level3_cells", $level2_template_data, "CATALOG_MENU_"); $level1_template_data[$c]["text"] = $Page->getParsedTemplate( "level3_cells"); $level1_template_data[$c++]["condition"] = "level3"; } } } } } } $Page->addRows( "catalog_menu_row", $level1_template_data, "CATALOG_MENU_"); return $Page->getParsedTemplate($template); } function getHierarchy($refill=false) { global $g_db; $result = array(); $current_node = $this->category_id; if (is_array($this -> hierarchy)&&!$refill) return true; for( $i = 0; ($i < 100)&&($current_node>0); $i++ ) { $g_db->Query("select category_parent_id, category_title from " . CATEGORY_TABLE . " where category_id = '".$current_node."'"); if ($g_db->datacount > 0) { $result[] = array("category_id"=>$current_node,"category_title"=>$g_db->data[0]["category_title"]); $current_node = $g_db->data[0]["category_parent_id"]; } else $current_node = 0; } $this -> hierarchy = array_reverse($result); } } //class } //if !defined ?>