private function sqlParameter($isADD, &$data, $name, &$field, &$EnumPrunecache, $isSerialized = false, $kA = '', $wS = '') { $output = false; $encapsulation = $isSerialized ? '' : '"'; switch ($field[CONS_XML_TIPO]) { case CONS_TIPO_INT: if (isset($data[$name]) && $data[$name] !== "" && is_numeric($data[$name])) { $output = $data[$name]; } else { if ($isADD && isset($field[CONS_XML_DEFAULT])) { $output = $field[CONS_XML_DEFAULT]; } } break; case CONS_TIPO_LINK: if ($field[CONS_XML_LINKTYPE] == CONS_TIPO_INT || $field[CONS_XML_LINKTYPE] == CONS_TIPO_FLOAT) { $encapsulation = ''; } if (isset($data[$name]) && ($data[$name] !== '' && $data[$name] !== 0 || !isset($field[CONS_XML_MANDATORY]))) { # non-mandatory links accept 0 values, otherwise 0 is not acceptable if ((!$isADD && isset($field[CONS_XML_IGNORENEDIT]) || $isADD) && ($data[$name] === 0 || $data[$name] === '')) { break; } else { if (($field[CONS_XML_LINKTYPE] == CONS_TIPO_INT || $field[CONS_XML_LINKTYPE] == CONS_TIPO_FLOAT) && ($data[$name] === '' || !is_numeric($data[$name]))) { $data[$name] = 0; } else { if ($field[CONS_XML_LINKTYPE] == CONS_TIPO_VC && $data[$name] != '') { if ($field[CONS_XML_SPECIAL] == "ucase") { $data[$name] = strtoupper($data[$name]); } if ($field[CONS_XML_SPECIAL] == "lcase") { $data[$name] = strtolower($data[$name]); } } } } # if this is a parent, check if this won't create a cyclic parenting if ($data[$name] !== 0 && $data[$name] !== '' && $field[CONS_XML_MODULE] == $this->name && $this->options[CONS_MODULE_PARENT] == $name) { if (!$isADD && $data[$name] == $data[$this->keys[0]]) { $data[$name] = 0; $this->parent->errorControl->raise(128, $name, $this->name, "Parent=Self"); if (isset($field[CONS_XML_MANDATORY])) { return false; } } else { $antiCicle = $isADD ? array() : array($data[$this->keys[0]]); $idP = isset($data[$name]) ? $data[$name] : 0; if ($idP == null) { $idP = 0; } while ($idP !== 0) { $idP = $this->parent->dbo->fetch("SELECT {$name} FROM " . $this->dbname . " WHERE " . $this->keys[0] . "={$idP}"); if ($idP == NULL) { $idP = 0; } if (in_array($idP, $antiCicle)) { break; } // cicle! $antiCicle[] = $idP; } unset($antiCicle); if ($idP !== 0) { # did not reach root $this->parent->errorControl->raise(128, $name, $this->name, "Initial parent was = " . $data[$name]); $data[$name] = 0; if (isset($field[CONS_XML_MANDATORY])) { return false; } } } } $output = $encapsulation . $data[$name] . $encapsulation; } else { if ($isADD && isset($field[CONS_XML_DEFAULT])) { if ($field[CONS_XML_DEFAULT] == "%UID%" && defined("CONS_AUTH_USERMODULE") && $field[CONS_XML_MODULE] == CONS_AUTH_USERMODULE && $_SESSION[CONS_SESSION_ACCESS_LEVEL] > 0 && isset($_SESSION[CONS_SESSION_ACCESS_USER]['id'])) { $output = $encapsulation . $_SESSION[CONS_SESSION_ACCESS_USER]['id'] . $encapsulation; } else { if ($field[CONS_XML_DEFAULT] != "%UID%") { $output = $encapsulation . $field[CONS_XML_DEFAULT] . $encapsulation; } } } } break; case CONS_TIPO_FLOAT: if (isset($data[$name]) && $data[$name] !== "") { $data[$name] = fv($data[$name]); if (is_numeric($data[$name])) { $output = str_replace(",", ".", $data[$name]); } else { if ($isADD && isset($field[CONS_XML_DEFAULT])) { $output = $field[CONS_XML_DEFAULT]; } } } else { if ($isADD && isset($field[CONS_XML_DEFAULT])) { $output = $field[CONS_XML_DEFAULT]; } } break; case CONS_TIPO_VC: if (isset($data[$name])) { if (!isset($field[CONS_XML_SPECIAL]) || $field[CONS_XML_SPECIAL] != "urla") { if (!isset($field[CONS_XML_CUSTOM])) { $data[$name] = cleanString($data[$name], isset($field[CONS_XML_HTML]), $_SESSION[CONS_SESSION_ACCESS_LEVEL] == 100, $this->parent->dbo); } else { if (!$isSerialized) { $data[$name] = addslashes_EX($data[$name], isset($field[CONS_XML_HTML]), $this->parent->dbo); } } } if (isset($field[CONS_XML_SPECIAL])) { if ($field[CONS_XML_SPECIAL] == "urla") { if (!isset($data[$name]) || $data[$name] == '') { $source = isset($field[CONS_XML_SOURCE]) ? $field[CONS_XML_SOURCE] : "{" . $this->title . "}"; $tp = new CKTemplate($this->parent->template); $tp->tbreak($source); $data[$name] = $tp->techo($data); unset($tp); } $data[$name] = str_replace(">", "", str_replace("<", "", str_replace(""", "", str_replace("'", "", $data[$name])))); $data[$name] = removeSimbols($data[$name], true, false, CONS_FLATTENURL); } if ($field[CONS_XML_SPECIAL] == "login" && $data[$name] != "") { if (!preg_match('/^([A-Za-z0-9_\\-\\.@]){4,20}$/', $data[$name])) { $data[$name] = ""; $this->parent->errorControl->raise(129, $name, $this->name); break; } } if ($field[CONS_XML_SPECIAL] == "mail" && $data[$name] != "") { if (!isMail($data[$name])) { $data[$name] = ""; $this->parent->errorControl->raise(130, $name, $this->name); break; } } if ($field[CONS_XML_SPECIAL] == "ucase" && $data[$name] != "") { $data[$name] = strtoupper($data[$name]); $data[$name] = addslashes_EX($data[$name], isset($field[CONS_XML_HTML]), $this->parent->dbo); } if ($field[CONS_XML_SPECIAL] == "lcase" && $data[$name] != "") { $data[$name] = strtolower($data[$name]); $data[$name] = addslashes_EX($data[$name], isset($field[CONS_XML_HTML]), $this->parent->dbo); } if ($field[CONS_XML_SPECIAL] == "path" && $data[$name] != "") { if (!preg_match('/^([A-Za-z0-9_\\/\\-]*)$/', $data[$name])) { $data[$name] = ""; $this->parent->errorControl->raise(131, $name, $this->name); break; } } if ($field[CONS_XML_SPECIAL] == "onlinevideo" && $data[$name] != "") { if (!preg_match('/^([A-Za-z0-9_\\-]){8,20}$/', $data[$name])) { $data[$name] = ""; $this->parent->errorControl->raise(132, $name, $this->name); break; } } if ($field[CONS_XML_SPECIAL] == "time" && $data[$name] != "") { if (!preg_match('/^([0-9]){1,2}(:)([0-9]){1,2}$/', $data[$name])) { $data[$name] = ""; $this->parent->errorControl->raise(133, $name, $this->name); break; } else { $data[$name] = explode(":", $data[$name]); $data[$name][0] = (strlen($data[$name][0]) == 1 ? "0" : "") . $data[$name][0]; $data[$name][1] = (strlen($data[$name][1]) == 1 ? "0" : "") . $data[$name][1]; $data[$name] = $data[$name][0] . ":" . $data[$name][1]; } } } if (!$isADD && isset($field[CONS_XML_IGNORENEDIT]) && $data[$name] == "") { break; } else { if ($isADD && (!isset($data[$name]) || $data[$name] == '') && isset($field[CONS_XML_DEFAULT])) { $data[$name] = $field[CONS_XML_DEFAULT]; } } $output = $encapsulation . $data[$name] . $encapsulation; } break; case CONS_TIPO_TEXT: if (isset($data[$name])) { # WYSIWYG garbage ... if (isset($field[CONS_XML_HTML]) && !isset($field[CONS_XML_CUSTOM])) { $data[$name] = str_replace(" ", " ", trim($data[$name])); if (isset($field[CONS_XML_SIMPLEEDITFORCE]) && $data[$name] != '') { if (!defined('C_XHTML_AUTOTAB')) { include CONS_PATH_INCLUDE . "xmlHandler.php"; } $data[$name] = parseHTML($data[$name], true); if ($data[$name] === false) { $this->parent->errorControl->raise(190, $name, $this->name); $data[$name] = ''; break; } } if ($this->invalidHTML($data[$name])) { # external editors garbage that can break HTML $this->parent->errorControl->raise(135, $name, $this->name); } } if (!isset($field[CONS_XML_CUSTOM])) { $data[$name] = cleanString($data[$name], isset($field[CONS_XML_HTML]), $_SESSION[CONS_SESSION_ACCESS_LEVEL] == 100, $this->parent->dbo); } else { if (!$isSerialized) { $data[$name] = addslashes_EX($data[$name], true, $this->parent->dbo); } } if (!$isADD && isset($field[CONS_XML_IGNORENEDIT]) && $data[$name] == "") { break; } $output = $encapsulation . $data[$name] . $encapsulation; } else { if ($isADD && isset($field[CONS_XML_DEFAULT])) { $output = $encapsulation . $field[CONS_XML_DEFAULT] . $encapsulation; } } break; case CONS_TIPO_DATETIME: case CONS_TIPO_DATE: if (!isset($data[$name]) || $data[$name] == '') { if (!$isADD && isset($field[CONS_XML_UPDATESTAMP])) { $output = "NOW()"; $data[$name] = date("Y-m-d") . ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME ? " " . date("H:i:s") : ""); // might be used by friendly url or such break; } else { if ($isADD && (isset($field[CONS_XML_TIMESTAMP]) || isset($field[CONS_XML_UPDATESTAMP]))) { $output = "NOW()"; $data[$name] = date("Y-m-d") . ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME ? " " . date("H:i:s") : ""); // might be used by friendly url or such break; } } } if (!isset($data[$name]) && isset($data[$name . "_day"])) { # date came into separated fields, merge them $theDate = $this->parent->intlControl->mergeDate($data, $name . "_"); if (!$theDate == false || ($theDate == "0000-00-00" || $theDate == "0000-00-00 00:00:00") && isset($field[CONS_XML_IGNORENEDIT])) { break; } # empty date can be ignored, or corrupt date $output = $encapsulation . $theDate . $encapsulation; } else { # came in mySQL format or i18n fromat if (isset($data[$name]) && $data[$name] != "") { $data[$name] = trim($data[$name]); $theDate = $data[$name]; $theDate = $this->parent->intlControl->dateToSql($theDate, $field[CONS_XML_TIPO] == CONS_TIPO_DATETIME); // handles any format of human or sql date if ($theDate === false) { if (substr($data[$name], 0, 5) == "NOW()") { $output = $data[$name]; $data[$name] = date("Y-m-d") . ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME ? " " . date("H:i:s") : ""); // might be used by friendly url or such } else { $this->parent->errorControl->raise(134, $name, $this->name); } } else { $output = $encapsulation . $theDate . $encapsulation; $data[$name] = $theDate; // other fields might need it } } else { if (isset($data[$name])) { // blank if (!$isADD && isset($field[CONS_XML_IGNORENEDIT])) { break; } $output = isset($field[CONS_XML_MANDATORY]) && $field[CONS_XML_MANDATORY] ? $encapsulation . "0000-00-00" . ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME ? " 00:00:00" : "") . $encapsulation : 'NULL'; } } } break; case CONS_TIPO_ENUM: if (isset($data[$name])) { if ($data[$name] == "") { # enum does not accept empty values, this means it's a NON-MANDATORY enum comming empty = NULL $output = "NULL"; } else { $data[$name] = str_replace("\"", "", str_replace("'", "", $data[$name])); $output = $encapsulation . $data[$name] . $encapsulation; if (isset($field[CONS_XML_AUTOPRUNE])) { // possible prune //$EnumPrunecache preg_match("@ENUM \\(([^)]*)\\).*@", $field[CONS_XML_SQL], $regs); $enums = explode(",", $regs[1]); $pruneRecipient = ""; for ($ec = 0; $ec < count($enums); $ec++) { if (isset($field[CONS_XML_AUTOPRUNE][$ec]) && $field[CONS_XML_AUTOPRUNE][$ec] == '*') { $pruneRecipient = $enums[$ec]; } } for ($ec = 0; $ec < count($enums); $ec++) { if ("'" . $data[$name] . "'" == $enums[$ec]) { if (isset($field[CONS_XML_AUTOPRUNE][$ec]) && $field[CONS_XML_AUTOPRUNE][$ec] != '0' && $field[CONS_XML_AUTOPRUNE][$ec] != '*') { $EnumPrunecache[] = array($name, $field[CONS_XML_AUTOPRUNE][$ec], $pruneRecipient); } break; // for } } } } } else { if ($isADD && isset($field[CONS_XML_DEFAULT])) { $output = $encapsulation . $field[CONS_XML_DEFAULT] . $encapsulation; } } break; case CONS_TIPO_OPTIONS: # must come as a string of 0 and 1 if (isset($data[$name]) && strlen($data[$name]) >= count($field[CONS_XML_OPTIONS])) { # test if they are all 0 and 1! $ok = true; for ($c = 0; $c < strlen($data[$name]); $c++) { if ($data[$name][$c] != "0" && $data[$name][$c] != "1") { $ok = false; break; } } if ($ok) { $output = $encapsulation . $data[$name] . ($isADD ? '0000' : '') . $encapsulation; } } break; case CONS_TIPO_UPLOAD: if (!$isADD) { # upload on add happens AFTER the SQL include, so if it fails, we don't even bother processing upload if (isset($data[$name . "_delete"]) || isset($_FILES[$name]) && $_FILES[$name]['error'] == 0) { // delete ou update $ids = ""; foreach ($this->keys as $key) { $ids .= $data[$key] . "_"; } $ids = substr($ids, 0, strlen($ids) - 1); $this->deleteUploads($data, $name, $ids); } $upOk = $this->prepareUpload($name, $kA, $data); $upvalue = $upOk == '0' ? 'y' : 'n'; if ($upOk != 0 && $upOk != 4) { # notification for the upload (4 = nothing sent, 0 = sent and ok) $this->parent->errorControl->raise(200 + $upOk, $upOk, $this->name, $name); } if ($upOk != 4) { $output = $encapsulation . $upvalue . $encapsulation; } else { // no change, but take this oportunity and check if the file exists! $upvalue = 'n'; $path = CONS_FMANAGER . $this->name . "/"; if (is_dir($path)) { if (isset($this->fields[$name][CONS_XML_FILEPATH])) { $path .= $this->fields[$name][CONS_XML_FILEPATH]; if ($path[strlen($path) - 1] != "/") { $path .= "/"; } if (!is_dir($path)) { safe_mkdir($path); } } # prepares filename with item keys $filename = $path . $name . "_"; foreach ($this->keys as $key) { $filename .= $data[$key] . "_"; } $filename .= "1"; $upvalue = locateAnyFile($filename, $ext, isset($this->fields[$name][CONS_XML_FILETYPES]) ? $this->fields[$name][CONS_XML_FILETYPES] : '') ? 'y' : 'n'; } $output = $encapsulation . $upvalue . $encapsulation; } } break; case CONS_TIPO_ARRAY: if (isset($data[$name])) { if (is_array($data[$name])) { $output = $data[$name]; } else { # came in serialized (JSON or php) if ($data[$name][0] == '[') { # JSON $output = @json_decode($data[$name]); } else { $output = @unserialize($data[$name]); } # we will serialize the whole thing if ($output === false) { $this->parent->errorControl->raise(189, $name, $this->name); $output = ""; } } } break; case CONS_TIPO_SERIALIZED: if (isset($data[$name])) { // came raw data, we store as is, YOU should serialize raw data $data[$name] = addslashes_EX($data[$name], true); if (isset($field[CONS_XML_IGNORENEDIT]) && $data[$name] == "") { break; } $output = $encapsulation . $data[$name] . $encapsulation; } else { if ($this->fields[$name][CONS_XML_SERIALIZED] > 1) { // set to WRITE or ALL // note: we ADD fields, never replace, because we should allow partial edits, thus we need to read the original data first $sql = "SELECT {$name} FROM " . $this->dbname . " WHERE {$wS}"; $serialized = $this->parent->dbo->fetch($sql); if ($serialized === false) { $serialized = array(); } else { $serialized = @unserialize($serialized); } $serializedFields = 0; foreach ($this->fields[$name][CONS_XML_SERIALIZEDMODEL] as $exname => &$exfield) { if (isset($data[$name . "_" . $exname])) { $outfield = $this->sqlParameter(true, $data, $name . "_" . $exname, $exfield, $EnumPrunecache, true); if ($outfield !== false && $outfield != 'NULL') { $serialized[$exname] = $outfield; } # we don't need to store NULL like in sql } } $output = $encapsulation . addslashes_EX(serialize($serialized), true, $this->parent->dbo) . $encapsulation; } } break; } # switch return $output; }
function showTemplate() { if (count($this->log) > 0) { $output = ""; foreach ($this->log as $saida) { $output .= $saida . "\n<br/>"; } $file = $this->debugFile; if ($this->debugFile == '' || !is_file($file)) { if (is_file(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/_debugarea.html")) { $file = CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/_debugarea.html"; } else { $file = CONS_PATH_SETTINGS . "defaults/_debugarea.html"; } } $tp = new CKTemplate($this->template); $tp->fetch($file); $tp->assign("CORE_DEBUG", $output); $tp->assign("CORE_DEBUGWARNING", $this->loglevel); // CONS_LOGGING_... $this->template->constants['CORE_DEBUG'] = $tp->techo(); unset($tp); } if (!is_object($this->template) || get_class($this->template) != "CKTemplate") { return; // huh, no template? oh well } # Echo dimconfig if something should be outputed $data = $this->cacheControl->getCachedContent('dimconfig_auto'); if ($data === false) { $data = $this->dimconfig; $dimconfigMD = unserialize(cReadFile(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/_dimconfig.dat")); foreach ($data as $name => $content) { if (isset($dimconfigMD[$name])) { if ($dimconfigMD[$name][CONS_XML_TIPO] == CONS_TIPO_UPLOAD) { $FirstfileName = CONS_FMANAGER . $dimconfigMD[$name]['location']; $path = explode("/", $FirstfileName); $fileName = array_pop($path); $path = implode("/", $path) . "/"; $hasFile = locateAnyFile($FirstfileName, $ext); if (isset($dimconfigMD[$name][CONS_XML_THUMBNAILS])) { // images $imgs = count($dimconfigMD[$name][CONS_XML_THUMBNAILS]); for ($c = 1; $c <= $imgs; $c++) { $fnamedata = $name . "_" . $c; $data[$fnamedata] = $FirstfileName; $data[$fnamedata . "w"] = ""; $data[$fnamedata . "h"] = ""; $data[$fnamedata . "t"] = ""; $data[$fnamedata . "tr"] = ""; $data[$fnamedata . "s"] = ""; if ($hasFile) { $data[$fnamedata] = $FirstfileName; $popped = explode("/", $FirstfileName); $data[$fnamedata . "filename"] = array_pop($popped); if (in_array(strtolower($ext), array("jpg", "gif", "png", "jpeg", "swf"))) { // image/flash $h = getimagesize($FirstfileName); $data[$fnamedata . "w"] = $h[0]; $data[$fnamedata . "h"] = $h[1]; $data[$fnamedata . "s"] = humanSize(filesize($FirstfileName)); if (in_array(strtolower($ext), array("jpg", "gif", "png", "jpeg"))) { $data[$fnamedata . "t"] = "<img src=\"" . $FirstfileName . "\" width='" . $h[0] . "' height='" . $h[1] . "' alt='' />"; $data[$fnamedata . "tr"] = "<img src=\"" . $FirstfileName . "\" width='100%' height='100%' alt='' />"; } else { if (strtolower($ext) == "swf") { $data[$fnamedata . "t"] = str_replace("{FILE}", $FirstfileName, str_replace("{H}", $h[1], str_replace("{W}", $h[0], SWF_OBJECT))); $data[$fnamedata . "tr"] = $data[$fnamedata . "t"]; } } } } } } else { if ($hasFile) { $fnamedata = $name . "_1"; $data[$fnamedata] = $FirstfileName; $data[$fnamedata . "s"] = humanSize(filesize($FirstfileName)); $popped = explode("/", $FirstfileName); $data[$fnamedata . "filename"] = array_pop($popped); } else { $fnamedata = $name . "_1"; $data[$fnamedata] = ""; $data[$fnamedata . "t"] = ""; $data[$fnamedata . "tr"] = ""; $data[$fnamedata . "s"] = ""; } } $this->template->fill($data); } else { $data[$name] = $content; } } else { $data[$name] = $content; } } $this->cacheControl->addCachedContent('dimconfig_auto', $data, true); } $this->template->fill($data); $this->template->constants['CHARSET'] = $this->charset; if ($this->doctype == "html" || CONS_BROWSER == "IE" && CONS_BROWSER_VERSION < 9) { $this->template->assign("_DOCTYPEXML"); } # metadata - fill default values if not set yet (plugins can set) if ($this->layout != 2) { if ((!isset($this->template->constants['METAKEYS']) || $this->template->constants['METAKEYS'] == '') && $this->dimconfig['metakeys'] != '') { $this->template->constants['METAKEYS'] = $this->dimconfig['metakeys']; } if ((!isset($this->template->constants['METADESC']) || $this->template->constants['METADESC'] == '') && $this->dimconfig['metadesc'] != '') { $this->template->constants['METADESC'] = $this->dimconfig['metadesc']; } // METAS if ($this->template->constants['CANONICAL'] == '') { $this->template->constants['CANONICAL'] = "http://" . $_SESSION['CANONICAL'] . $this->context_str . $this->action . ".html"; if (isset($_REQUEST['id'])) { $this->template->constants['CANONICAL'] .= "?id=" . $_REQUEST['id']; } } $metadata = $this->template->constants['METATAGS']; if (CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/_meta.xml") { $metadata .= cReadFile(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/_meta.xml"); } $metadata .= "\t<link rel=\"canonical\" href=\"" . $this->template->constants['CANONICAL'] . "\" />\n"; if ($this->template->constants['METAKEYS'] != '') { $metadata .= "\t<meta name=\"keywords\" content=\"" . str_replace("\"", "", $this->template->constants['METAKEYS']) . "\"/>\n"; } if ($this->template->constants['METADESC'] != '') { $metadata .= "\t<meta name=\"description\" content=\"" . str_replace("\"", "", $this->template->constants['METADESC']) . "\"/>\n"; $metadata .= "\t<meta property=\"og:description\" content=\"" . str_replace("\"", "", $this->template->constants['METADESC']) . "\"/>\n"; } $metadata .= "\t<meta property=\"og:type\" content=\"website\" />\n"; $metadata .= "\t<meta property=\"og:title\" content=\"" . str_replace("\"", "", $this->template->constants['PAGE_TITLE']) . "\" />\n"; $metadata .= "\t<meta property=\"og:url\" content=\"" . $this->template->constants['CANONICAL'] . "\" />\n"; if (isset($this->template->constants['METAFIGURE']) && $this->template->constants['METAFIGURE'] != "") { if ($this->template->constants['METAFIGURE'][0] != '/') { $this->template->constants['METAFIGURE'] = "/" . $this->template->constants['METAFIGURE']; } $metadata .= "\t<meta property=\"og:image\" content=\"http://" . $_SESSION['CANONICAL'] . $this->template->constants['METAFIGURE'] . "\" />\n"; $metadata .= "\t<link rel=\"image_src\" href=\"http://" . $_SESSION['CANONICAL'] . $this->template->constants['METAFIGURE'] . "\" />\n"; } $favfile = CONS_PATH_PAGES . $_SESSION['CODE'] . "/files/favicon"; if (locateFile($favfile, $ext)) { $favfile = CONS_INSTALL_ROOT . $favfile; $metadata .= "\t<link rel=\"shortcut icon\" href=\"/favicon." . $ext . "\" />\n"; } else { if (CONS_DEFAULT_FAVICON) { $favfile = "favicon"; if (locateFile($favfile, $ext)) { $favfile = CONS_INSTALL_ROOT . $favfile; $metadata .= "\t<link rel=\"shortcut icon\" href=\"/favicon." . $ext . "\" />\n"; } } } // Alternate Language and domains versions (only on root index) if ($this->context_str == "/" && $this->action == "index") { if (CONS_USE_I18N) { $langs = explode(",", CONS_POSSIBLE_LANGS); foreach ($langs as $lang) { if ($lang != $_SESSION[CONS_SESSION_LANG]) { if (count($this->languageTL) > 0) { foreach ($this->languageTL as $fl => $ln) { if ($ln == $lang) { $metadata .= "\t<link rel=\"alternate\" hreflang=\"{$lang}\" href=\"/{$fl}/index.html\"/>\n"; break; } } } else { $metadata .= "\t<link rel=\"alternate\" hreflang=\"{$lang}\" href=\"" . $this->template->constants['CANONICAL'] . "?lang={$lang}\"/>\n"; } } } } foreach ($this->parseRewrite as $domain => $settings) { if ($domain != $this->domain) { $metadata .= "\t<link rel=\"alternate\" hreflang=\"" . ($settings[0] == '' ? CONS_DEFAULT_LANG : $settings[0]) . "\" href=\"http://" . $domain . "\"/>\n"; } } } $this->template->constants['METATAGS'] = $metadata; } $this->removeAutoTags($this->template); // print version if ($this->template->get("printver") == '') { $printVersion = arrayToString($_GET, array("layout")); $printVersion .= "&layout=1"; $this->template->assign("printver", $this->action . ".html?" . $printVersion); } return $this->template->techo(); }
$h = getimagesize(CONS_FMANAGER . "presciator/conditionedimage_key_1_1." . $e); $h2 = getimagesize(CONS_FMANAGER . "presciator/conditionedimage_chave_1_1." . $e2); if ($h[0] !== 100 || $h[1] != 100 || $h2[0] !== 200 || $h[2] != 200) { $this->log[] = "<b>ERROR</b>: conditioned file-size were cropped to wrong size (tested key_1 and chave_1 conditionedimages)"; $ok = false; } else { $this->log[] = "Conditioned file-size seems working"; } $this->log[] = "Testing delete a file, no error expected"; $data = array('alpha' => 'key', 'beta' => 1, 'somefile_delete' => 'on'); $ok = $this->runAction('presciator', CONS_ACTION_UPDATE, $data); // will succeed, and delete somefile $this->errorState = false; clearstatcache(); $f = CONS_FMANAGER . "presciator/somefile_key_1_1"; $yes1 = locateAnyFile($f, $e); $f = CONS_FMANAGER . "presciator/someimage_key_1_1"; $yes2 = locateFile($f, $e); if (!$yes1 && $yes2) { $this->log[] = "Success, file has been deleted, other file fields intact!"; } else { $this->log[] = "<b>ERROR</b>: " . ($yes1 ? "File was not deleted!" : "") . (!$yes2 ? "Other files were also deleted, should only delete one field!" : ""); $ok = false; } } else { $this->log[] = "<b>ERROR</b>: some files on presciator key_1 were not found, all should be present:" . ($yes1 ? "somefile ok," : "somefile missing,") . ($yes2 ? "someimage ok," : "someimage missing,") . ($yes3 ? "conditionedimage ok." : "conditionedimage missing."); $ok = false; } $this->log[] = "Logging off ..."; $this->authControl->logsGuest(); if ($ok) {
// forceRO will display as editable for master // arrays are never editable // _pluginStarter neither $fillDT = array('field' => $data['name'], 'width' => '99%'); switch ($fieldType) { case CONS_TIPO_UPLOAD: // ############################################### FILE(s) $field_upload = $core->template->get("_upload_field"); $using = clone $field_upload; $emptyme = array(); $tobjTemp = $core->template->get("_thumb"); $FirstfileName = CONS_FMANAGER . $dimconfigMD[$data['name']]['location']; $path = explode("/", $FirstfileName); $fileName = array_pop($path); $path = implode("/", $path) . "/"; $hasFile = locateAnyFile($FirstfileName, $ext); if (!$hasFile) { $emptyme[] = "_hasFile"; if (isset($dimconfigMD[$data['name']][CONS_XML_THUMBNAILS])) { $hasImages = true; $fillDT['maxres'] = "max " . str_replace(",", "x", $dimconfigMD[$data['name']][CONS_XML_THUMBNAILS][0]); } } else { $fillDT['filesize'] = humanSize(filesize($FirstfileName)); $ext = strtolower($ext); $fillDT['download'] = CONS_INSTALL_ROOT . $FirstfileName . "?r=" . rand(0, 999); $fillDT['ico'] = filetypeIcon($ext); if (in_array($ext, array("jpg", "gif", "swf", "png", "jpeg"))) { $hasImages = true; $h = getimagesize($FirstfileName); $fillDT['width'] = $h[0];
function fillField(&$core, &$module, $name, &$field, &$data, &$p, $isSerialized = false, $basename = "") { $content = ""; // load l10n for datetimes if (!$p['isADD'] && $field[CONS_XML_TIPO] == CONS_TIPO_DATE && isset($data[$name])) { $data[$name] = fd($data[$name], $core->intlControl->getDate()); } else { if (!$p['isADD'] && $field[CONS_XML_TIPO] == CONS_TIPO_DATETIME && isset($data[$name])) { $data[$name] = fd($data[$name], "H:i:s " . $core->intlControl->getDate()); } } // format in language mode // pre-fill option arrays if (!$p['isADD'] && $field[CONS_XML_TIPO] == CONS_TIPO_OPTIONS && isset($data[$name])) { if (isset($data[$name])) { $l = strlen($data[$name]); for ($c = 0; $c < $l; $c++) { $data[$name . $c] = isset($data[$name . $c]) || $data[$name][$c] == "1"; } unset($l); } } // If we are adding, check default values if ($p['isADD']) { if (strpos($field[CONS_XML_SQL], "AUTO_INCREMENT") !== false) { return; } // do not put autoincrement keys on add if (isset($field[CONS_XML_DEFAULT]) && !isset($data[$name])) { if ($field[CONS_XML_TIPO] == CONS_TIPO_LINK && $field[CONS_XML_DEFAULT] == "%UID%" && defined("CONS_AUTH_USERMODULE") && $field[CONS_XML_MODULE] == CONS_AUTH_USERMODULE && $_SESSION[CONS_SESSION_ACCESS_LEVEL] > 0 && isset($_SESSION[CONS_SESSION_ACCESS_USER]['id'])) { $data[$name] = $_SESSION[CONS_SESSION_ACCESS_USER]['id']; } else { if ($field[CONS_XML_TIPO] == CONS_TIPO_DATE) { $data[$name] = fd($field[CONS_XML_DEFAULT], $core->intlControl->getDate()); } else { $data[$name] = $field[CONS_XML_DEFAULT]; } } } else { if (isset($field[CONS_XML_TIMESTAMP]) || isset($field[CONS_XML_UPDATESTAMP])) { if ($field[CONS_XML_TIPO] == CONS_TIPO_DATE) { $data[$name] = date($core->intlControl->getDate()); } else { $data[$name] = date("H:i:s " . $core->intlControl->getDate()); } } } } else { if (isset($field[CONS_XML_UPDATESTAMP])) { if ($field[CONS_XML_TIPO] == CONS_TIPO_DATE) { $data[$name] = date($core->intlControl->getDate()); } else { $data[$name] = date("H:i:s " . $core->intlControl->getDate()); } } } // ajax exceptions? if ($core->layout == 2 && $field[CONS_XML_TIPO] == CONS_TIPO_UPLOAD) { // ajax mode does not accept uploads return; } // have permission to see this field? if ($_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100 && isset($field[CONS_XML_RESTRICT]) && $field[CONS_XML_RESTRICT] > $_SESSION[CONS_SESSION_ACCESS_LEVEL]) { return; } else { // Does this field have a different interface handler? if so use it and continue to the next if (in_array($name, $p['cacheCustomFields'])) { // detect which plugin has the customHandler and use it. Use the first and leave, if there is more than one, ignore the conflict foreach ($module->plugins as $scriptname) { // if we didn't have the cache, this would run always, see? if (in_array($name, $core->loadedPlugins[$scriptname]->customFields)) { // ok, handle it (if it returns TRUE, ignore this handler) $content = $core->loadedPlugins[$scriptname]->field_interface($name, $p['isADD'], $data); if ($content === false) { return; } else { if ($content !== true) { break; // we will break this foreach plugin search, but continue normally the rest } } $content = ""; // if we didn't continue (use the field or ignore), proceed as if this field was normal, thus erase the custom content } } } // This field is read-only? if (in_array($name, $p['hideKeys']) || isset($field[CONS_XML_READONLY])) { if ($p['isADD']) { return; } else { if (!$p['isMultiple']) { $content = isset($data[$name]) ? $data[$name] : ' '; } else { return; } } } $fillDT = array('field' => $name, 'isADD' => $p['isADD'] ? "true" : "false", 'affreferer' => $module->name, 'affrefererkeys' => implode("_", $p['refererKeys']), 'width' => '99%', 'helper' => ''); if ($content == '') { // format according to type $helper = $core->langOut('helper_' . $module->name . "_" . $name); if ($helper != 'helper_' . $module->name . "_" . $name) { $fillDT['helper'] = $helper; } switch ($field[CONS_XML_TIPO]) { // for each fields ... case CONS_TIPO_UPLOAD: // ############################################### FILE(s) if ($p['isMultiple'] || $p['isMup']) { $content = false; continue; // continue will leave only the switch, since switch is considered a loop (??? WHY PHP, WHY ???) } $field_upload = $core->template->get("_upload_field"); $using = clone $field_upload; $emptyme = array(); if (!$p['isADD']) { $tobjTemp = $core->template->get("_thumb"); $path = CONS_FMANAGER . $module->name . "/"; $fileName = $name . "_"; foreach ($module->keys as $key) { $fileName .= $data[$key] . "_"; } $FirstfileName = $path . $fileName . "1"; $hasFile = locateAnyFile($FirstfileName, $ext); if (!$hasFile) { $emptyme[] = "_hasFile"; if (isset($module->fields[$name][CONS_XML_THUMBNAILS])) { $p['hasImages'] = true; $fillDT['maxres'] = "max " . str_replace(",", "x", $module->fields[$name][CONS_XML_THUMBNAILS][0]); } } else { $fillDT['filesize'] = humanSize(filesize($FirstfileName)); $ext = strtolower($ext); $fillDT['download'] = CONS_INSTALL_ROOT . $FirstfileName . "?r=" . rand(0, 9990); $fillDT['ico'] = filetypeIcon($ext); if (in_array($ext, array("jpg", "gif", "swf", "png", "jpeg"))) { $p['hasImages'] = true; $h = getimagesize($FirstfileName); $fillDT['width'] = $h[0]; $fillDT['height'] = $h[1]; $fillDT['dim'] = $h[0] . "x" . $h[1]; if ($h[0] < $p['maxWidth'] && $h[1] < $p['maxHeight']) { $emptyme[] = "_downloadable"; if ($ext != "swf") { $emptyme[] = "_swf"; } else { $emptyme[] = "_img"; } } else { $emptyme[] = "_presentable"; } if (isset($field[CONS_XML_THUMBNAILS])) { $thumbVersions = count($field[CONS_XML_THUMBNAILS]); if ($thumbVersions > 1) { $tObj = clone $tobjTemp; $tTemp = ""; for ($tv = 2; $tv <= $thumbVersions; $tv++) { $thumbFile = $path . "t/" . $fileName . $tv; locateFile($thumbFile, $ext); $h = getimagesize($thumbFile); $tTemp .= $tObj->techo(array('tdownload' => CONS_INSTALL_ROOT . $thumbFile)); } $using->assign("_thumb", $tTemp); } else { $emptyme[] = "_hasThumbs"; } } else { $emptyme[] = "_hasThumbs"; } } else { $emptyme[] = "_isImage"; $emptyme[] = "_presentable"; } } } else { $emptyme[] = "_hasFile"; } if (isset($field[CONS_XML_THUMBNAILS])) { $fillDT['maxres'] = "max " . str_replace(",", "x", $field[CONS_XML_THUMBNAILS][0]); } if (isset($field[CONS_XML_FILETYPES])) { $fillDT['exts'] = "(" . $field[CONS_XML_FILETYPES] . ")"; } $fillDT['maxsize'] = isset($field[CONS_XML_FILEMAXSIZE]) ? humanSize($field[CONS_XML_FILEMAXSIZE]) : ini_get('upload_max_filesize'); if (isset($field[CONS_XML_FILEMAXSIZE]) && $field[CONS_XML_FILEMAXSIZE] > $p['mfs']) { $p['mfs'] = $field[CONS_XML_FILEMAXSIZE]; } $content = $using->techo($fillDT, $emptyme); unset($emptyme); break; case CONS_TIPO_LINK: // ############################################### LINK TO ANOTHER MODULE $mod = $core->loaded($field[CONS_XML_MODULE]); if ($mod !== false) { $core->safety = false; // <-- in the select, we should always show every item $fillDT['rmodule'] = $field[CONS_XML_MODULE]; if ($mod->options[CONS_MODULE_PARENT]) { $field_sel = $core->template->get("_selecttree_field"); $using = clone $field_sel; $sql = $mod->get_base_sql(); if (isset($data[$name])) { $sql['SELECT'][] = "if (" . $mod->name . "." . $mod->keys[0] . "='" . $data[$name] . "',1,0) as selected"; } $sql['SELECT'][] = $mod->name . "." . $mod->title . " as treetitle"; $tree = $mod->getContents("", "treetitle", "", "\\", $sql); $using->getTreeTemplate("_sdirs", "_ssubdirs", $tree); } else { $field_sel = $core->template->get("_select_field"); $using = clone $field_sel; // checks if this field is/can be filtered by another, if can, leave empty on ADD $canBeFilteredBy = array(); if (isset($field[CONS_XML_FILTEREDBY])) { $canBeFilteredBy = $field[CONS_XML_FILTEREDBY]; // already a list of local fields $using->assign('helper', $core->langOut("filtered_by") . ": " . implode(",", $canBeFilteredBy)); $havePreqs = true; // either on add or edit, field that filter this could be present ... check them! for ($cbf = 0; $cbf < count($canBeFilteredBy); $cbf++) { if (!isset($data[$canBeFilteredBy[$cbf]]) || $data[$canBeFilteredBy[$cbf]] == '' || $data[$canBeFilteredBy[$cbf]] == '0') { $havePreqs = false; break; } } if (!$havePreqs) { // we can't fill it, so display the select_other_field message $using->assign("_optional", ""); $canBeFilteredBy_translated = array(); for ($cbf = 0; $cbf < count($canBeFilteredBy); $cbf++) { $canBeFilteredBy_translated[$cbf] = $core->langOut($canBeFilteredBy[$cbf]); } $using->assign("_options", "<option value=\"\">" . $core->langOut("select_other_field") . ": " . implode(", ", $canBeFilteredBy_translated) . "</option>"); } else { // we can fill this since all prerequisites are present! $sql = $mod->get_base_sql(); $sql['SELECT'] = array($mod->name . "." . $mod->keys[0] . " as ids", $mod->name . "." . $mod->title . " as title"); if (isset($data[$name])) { $sql['SELECT'][] = "if (" . $mod->name . "." . $mod->keys[0] . "='" . $data[$name] . "',1,0) as selected"; } // add filters foreach ($canBeFilteredBy as $filterfield) { // we know the data exists because this is an edit, but it could be empty if ($data[$filterfield] != '') { $remodeField = $mod->get_key_from($module->fields[$filterfield][CONS_XML_MODULE]); $sql['WHERE'][] = $mod->name . "." . $remodeField . "=\"" . $data[$filterfield] . "\""; } } if ($core->runContent($mod, $using, $sql, "_options") === false) { $using->assign("_options"); } } // add the corresponding data for the ajaxContextHandler $p['ajaxContextHandler'][$name] = $canBeFilteredBy; } else { $sql = $mod->get_base_sql(); # TODO: this probably won't work on multiple keys $sql['SELECT'] = array($mod->name . "." . $mod->keys[0] . " as ids", $mod->name . "." . $mod->title . " as title"); if (isset($data[$name])) { $sql['SELECT'][] = "if (" . $mod->name . "." . $mod->keys[0] . "='" . $data[$name] . "',1,0) as selected"; } //print_r($sql); //die(); if ($core->runContent($mod, $using, $sql, "_options") === false) { $using->assign("_options"); } } } $content = $using->techo($fillDT); $core->safety = true; // back to normal mode unset($using); } break; case CONS_TIPO_TEXT: // ############################################### TEXT (textarea/cke) $field_txt = $core->template->get("_textarea_field"); $using = clone $field_txt; $fillDT['value'] = isset($data[$name]) ? $data[$name] : ''; if (isset($field[CONS_XML_HTML])) { $fillDT['value'] = htmlspecialchars($fillDT['value']); } // ckedit will remove entities, so we add an extra layer! $useCKE = isset($field[CONS_XML_HTML]); # CKEdit $content = $using->techo($fillDT); $p['endScript'] .= $useCKE ? "var CKE{$name} = CKEDITOR.replace( '{$name}' , { language : '" . $_SESSION[CONS_SESSION_LANG] . "'" . (isset($module->fields[$name][CONS_XML_SIMPLEEDITFORCE]) ? ",toolbar : 'MiniToolbar'" : "") . "} );\n\tCKFinder.setupCKEditor( CKE{$name}, '/pages/_js/ckfinder/' ) ;\n" : ''; # CKEdit + CKFinder unset($using); break; case CONS_TIPO_ENUM: // ############################################### LIST OF ITEMS IN ENUM FORM preg_match("@ENUM \\(([^)]*)\\).*@", $field[CONS_XML_SQL], $regs); if ($p['isADD'] && isset($field[CONS_XML_DEFAULT]) && (!isset($data[$name]) || $data[$name] == "")) { $data[$name] = $module->fields[$name][CONS_XML_DEFAULT]; } $xtp = "<option value=\"{enum}\" {checked}>{enum_translated}</option>"; $tp = new CKTemplate($core->template); $tp->tbreak($xtp); $temp = isset($field[CONS_XML_MANDATORY]) ? '' : "<option value=''></option>"; $enums = explode(",", $regs[1]); foreach ($enums as $x) { $x = str_replace("'", "", $x); $db = array('enum' => $x, 'enum_translated' => $core->langOut($x), 'checked' => isset($data[$name]) && $data[$name] == $x ? ' selected="selected"' : ''); $temp .= $tp->techo($db); } $content = "<select " . ($p['isMultiple'] ? "onchange=\"\$('me_edit_" . $name . "').checked = true;\"" : "onchange=\"checkConditions();\"") . " id=\"{$name}\" name=\"{$name}\" >" . $temp . "</select>"; unset($temp); unset($enums); break; case CONS_TIPO_OPTIONS: // ############################################# CHECKBOX LIST $xtp = "<input type=\"checkbox\" onclick=\"checkopts('{field}');\" name=\"{name}\" id=\"{name}\" {checked}/><label for=\"{name}\">{translated}</label><br/>"; $tp = new CKTemplate($core->template); $tp->tbreak($xtp); $citem = 0; $temp = "<input type='hidden' name='{$name}' id='{$name}' value=\"" . (isset($data[$name]) ? $data[$name] : "") . "\"/>"; foreach ($field[CONS_XML_OPTIONS] as $opt) { $db = array('name' => $name . "_" . $citem, 'field' => $name, 'translated' => $core->langOut(str_replace("'", "", $opt)), 'checked' => isset($data[$name]) && strlen($data[$name]) >= $citem && $data[$name][$citem] == 1 ? ' checked="checked"' : ''); $temp .= $tp->techo($db); $citem++; } $content = $temp; unset($temp); break; case CONS_TIPO_DATE: // ############################################### DATE / DATETIME // ############################################### DATE / DATETIME case CONS_TIPO_DATETIME: // updatestamp & includestap already treated befpre switch if ($core->layout != 2) { $fillDT['calendar'] = "<img id='divcalendar_" . $name . "' onclick=\"calendarHandler.showCalendar('" . $name . "','divcalendar_" . $name . "',-80,-8);\" src=\"" . CONS_INSTALL_ROOT . CONS_PATH_PAGES . "_js/calendar/gifs/dyncalendar.gif\" style=\"width:16px;height:16px;position:relative;top:3px;left:2px\" alt=\"" . $core->langOut('calendar') . "\"/>"; } $fillDT['width'] = "120px"; $p['hasCalendar'] = true; case CONS_TIPO_VC: // ############################################### SIMPLE INPUT WITH HEAVY TYPESETTING // ############################################### SIMPLE INPUT WITH HEAVY TYPESETTING case CONS_TIPO_INT: case CONS_TIPO_FLOAT: $field_sel = $core->template->get("_normal_field"); $using = clone $field_sel; $fillDT['value'] = isset($data[$name]) ? $data[$name] : ''; $fillDT['type'] = "text"; if (isset($field[CONS_XML_META])) { if ($field[CONS_XML_META] == "masked") { $fillDT['type'] = "password"; } if ($field[CONS_XML_META] == "password") { $fillDT['type'] = "password"; if ($_SESSION[CONS_SESSION_ACCESS_LEVEL] != 100) { $data[$name] = ""; $fillDT['value'] = ""; } } } if ($field[CONS_XML_TIPO] == CONS_TIPO_INT) { if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_integer'); } $p['validators']['integer'][] = "'{$name}'"; } else { if ($field[CONS_XML_TIPO] == CONS_TIPO_FLOAT) { if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_float'); } $p['validators']['float'][] = "'{$name}'"; } else { if ($field[CONS_XML_TIPO] == CONS_TIPO_DATE) { $p['validators']['date'][] = "'{$name}'"; if ($fillDT['helper'] == '') { $fillDT['helper'] = '(' . $core->intlControl->getDate() . ')'; } } else { if ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME) { if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_time') . ' ' . $core->intlControl->getDate() . ')'; } $p['validators']['datetime'][] = "'{$name}'"; } } } } if (isset($field[CONS_XML_SPECIAL])) { switch ($field[CONS_XML_SPECIAL]) { case 'login': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_login'); } $p['validators']['login'][] = "'{$name}'"; break; case 'mail': if ($fillDT['helper'] == '') { $fillDT['helper'] = '(ex: login@servidor.com)'; } $p['validators']['mail'][] = "'{$name}'"; break; case 'number': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_integer'); } $p['validators']['integer'][] = "'{$name}'"; break; case 'float': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_float'); } $p['validators']['float'][] = "'{$name}'"; break; case 'cpf': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_cpf'); } $p['validators']['is_cpf'][] = "'{$name}'"; break; case 'cnpj': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_cnpj'); } $p['validators']['is_cnpj'][] = "'{$name}'"; break; case 'id': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_id'); } $p['validators']['is_id'][] = "'{$name}'"; break; case 'date': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->intlControl->getDate(); } $p['validators']['date'][] = "'{$name}'"; break; case 'datetime': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_time') . " " . $core->langOut('helper_followedby') . " " . $core->intlControl->getDate() . ')'; } $p['validators']['datetime'][] = "'{$name}'"; break; break; case 'onlinevideo': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_video'); } break; case 'time': if ($fillDT['helper'] == '') { $fillDT['helper'] = $core->langOut('helper_time'); } $p['validators']['time'][] = "'{$name}'"; break; default: if (strlen($field[CONS_XML_SPECIAL]) > 10 && substr($field[CONS_XML_SPECIAL], 0, 6) == "slider") { if (preg_match("@([0-9]*)\\,([0-9]*)@", $field[CONS_XML_SPECIAL], $ereg)) { unset($using); unset($field_sel); $field_sel = $core->template->get("_slider_field"); $using = clone $field_sel; $fillDT['minor'] = $ereg[1]; $fillDT['major'] = $ereg[2]; if (!is_numeric($fillDT['value'])) { $fillDT['value'] = $ereg[1]; } $p['hasSlider'] = true; if ($fillDT['helper'] == '') { $fillDT['helper'] = $ereg[1] . " - " . $ereg[2]; } } } break; } } $content = $using->techo($fillDT); break; case CONS_TIPO_ARRAY: # data is an array $p['hasSerializedArray'] = true; $p['serializedArrays'][] = '"' . $name . '"'; $p['endScript'] .= "CScontroler.fillData('{$name}'," . JSON_encode($field[CONS_XML_OPTIONS]) . "," . JSON_encode(isset($data[$name]) ? $data[$name] : '') . ");\n"; $field_ser = $core->template->get("_serializearray_field"); $using = clone $field_ser; $content = $using->techo($fillDT); unset($using); break; } # switch if (isset($field['conditional']) && strpos($field['conditional'], "=") !== false) { $temp = explode("=", $field['conditional']); $ltemp = trim(strtolower($temp[0])); $negation = strpos($ltemp, "!") !== false; if ($negation) { $ltemp = trim(str_replace("!", "", $ltemp)); } $rtemp = str_replace("'", "", trim($temp[1])); $p['condHandlers'][] = "\$('tableitem" . $name . "').style.display = \$('{$ltemp}').value " . ($negation ? "!=" : "==") . "'{$rtemp}' ? '' : 'none';"; } } # content not blank } # permission to see? if ($content === false) { return ''; } // if content is false, ignore alltogether // build a template object with this field and print it out $using = clone $p['objfield']; $outdata = array('field' => $content, 'title' => $isSerialized ? substr($name, strlen($basename) + 1) : $name, 'mandatory' => in_array($name, $module->keys) || isset($field[CONS_XML_MANDATORY]) && $field[CONS_XML_MANDATORY] ? "y" : "n"); if (!$p['isMultiple'] && (!$p['isMup'] || $name != $module->title) && $outdata['mandatory'] == 'y' && !in_array($name, $p['hideKeys']) && $field[CONS_XML_TIPO] != CONS_TIPO_UPLOAD && !isset($field[CONS_XML_READONLY])) { // EXCEPTION: a ignorenedit field CAN be blank during EDIT only if (!isset($field[CONS_XML_IGNORENEDIT]) || $p['isADD']) { $p['$validators']['mandatory'][] = "'{$name}'"; $p['$validators']['translation'][] = "'" . $core->langOut($name) . "'"; $p['$validators']['defaults'][] = isset($field[CONS_XML_DEFAULT]) ? "'" . $field[CONS_XML_DEFAULT] . "'" : "''"; } } $p['tempOutput'] .= $using->techo($outdata); unset($using); }