Example #1
0
                 foreach ($filteredBy as $fname) {
                 	if (!in_array($fname,$refererModule->keys) && count($keys)>0) {
                 		$_REQUEST[$key] = array_shift($keys); // if fowarder off
                 		$str .= "&".$key."=".$_REQUEST[$key];
                 	}
                 }
                 */
                 $core->headerControl->internalFoward($str);
                 $core->action = "edit";
                 // if internalFoward is disabled
                 $pa_dealt = true;
             }
         case 4:
             // public
             $url = new CKTemplate($core->template);
             $url->tbreak($module->options[CONS_MODULE_PUBLIC]);
             $url = $url->techo($_POST);
             $url = CONS_INSTALL_ROOT . $url;
             $core->headerControl->internalFoward($url);
             list($core->context, $core->action, $core->original_action, $ext) = extractUri("", $url);
             $core->context_str = implode("/", $core->context);
             $pa_dealt = true;
             break;
     }
     if (!$pa_dealt) {
         $core->action = "list";
         $_REQUEST = array('module' => $_REQUEST['module']);
         // prevents filtering the list in the event of non-foward mode
         $core->headerControl->internalFoward("list.html?module=" . $_REQUEST['module']);
     }
 } else {
Example #2
0
 function runAction($action, $data, $silent = false, $mfo = false, $startedAt = "")
 {
     # mfo is "Mandatory Fields Ok", which removes the need to check them
     # returns TRUE or FALSE
     # check for auto_increment during insert on $parent->lastReturnCode
     if (is_object($action)) {
         $this->parent->errorControl->raise(126);
     }
     $this->parent->lastReturnCode = 0;
     unset($this->parent->storage['lastactiondata']);
     if (is_numeric($data)) {
         if ($action == CONS_ACTION_DELETE) {
             $id = $data;
             $data = array();
             $data[$this->keys[0]] = $id;
         } else {
             if (!$silent) {
                 $this->parent->errorControl->raise(187, $data, $this->name);
             }
             return false;
         }
     }
     if (count($this->plugins) > 0 && ($action == CONS_ACTION_UPDATE || $action == CONS_ACTION_INCLUDE || $action == CONS_ACTION_DELETE)) {
         foreach ($this->plugins as $pname) {
             if (!$this->parent->loadedPlugins[$pname]->edit_parse($action, $data)) {
                 if (!$silent) {
                     $this->parent->errorControl->raise(168, $pname, $this->name);
                 }
                 return false;
             }
         }
     }
     if (!$mfo) {
         $missing = $this->check_mandatory($data, $action);
         # returns a list of mandatory fields missing or invalid
         if (count($missing) > 0) {
             $this->parent->errorState = true;
             if (!$silent) {
                 $this->parent->errorControl->raise(127, implode(",", $missing), $this->name);
             }
             return false;
         }
     }
     $EnumPrunecache = array();
     switch ($action) {
         case CONS_ACTION_UPDATE:
             ###################################################### UPDATE ############################################
             $wS = "";
             # whereStruct
             $kA = array();
             # keyArray
             $haveAllKeys = $this->getKeys($wS, $kA, $data);
             // is it ok not to have all keys?
             # security
             if ($this->parent->safety && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100) {
                 $Owner = $this->parent->authControl->checkOwner($this, $kA);
                 // array with isOwner and isSameGroup
                 $this->parent->lockPermissions();
                 # Load permissions to this, in case something changed
                 if (!$this->parent->authControl->checkPermission($this, CONS_ACTION_UPDATE, $Owner, $data)) {
                     $this->parent->errorControl->raise(151, '', $this->name);
                     return false;
                 }
             }
             $this->parent->notifyEvent($this, CONS_ACTION_UPDATE, $data, $startedAt, true);
             # early notify
             $sql = "UPDATE " . $this->dbname . " SET ";
             $output = "";
             $outfield = false;
             foreach ($this->fields as $name => $field) {
                 if ($this->parent->safety && isset($field[CONS_XML_RESTRICT]) && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < $field[CONS_XML_RESTRICT] && !isset($field[CONS_XML_UPDATESTAMP])) {
                     # safety is on and this is a restricted field, while the user trying to change it does not have enough level
                     if (isset($data[$name])) {
                         $this->parent->errorControl->raise(145, $name, $this->name);
                     }
                     continue;
                 }
                 if ($name != $this->keys[0] && strpos($field[CONS_XML_SQL], "AUTO_INCREMENT") === false) {
                     # cannot change main key or auto_increment ones
                     $outfield = $this->sqlParameter(false, $data, $name, $field, $EnumPrunecache, false, $kA, $wS);
                     if ($outfield !== false) {
                         $output .= $name . "=" . $outfield . ",";
                     }
                 }
                 # if (not key)
             }
             #foreach
             unset($outfield);
             if ($output != "") {
                 # removes end ,
                 $output = substr($output, 0, strlen($output) - 1);
                 $sql .= $output . " WHERE " . $wS;
                 if (!$this->parent->dbo->simpleQuery($sql, $this->parent->debugmode)) {
                     $this->parent->errorState = true;
                     $lastError = $this->parent->dbo->log[count($this->parent->dbo->log) - 1];
                     if (strpos(strtolower($lastError), "duplicate") === false) {
                         if (!$silent) {
                             $this->parent->errorControl->raise(136, "", $this->name);
                         }
                     } else {
                         if (!$silent) {
                             $this->parent->errorControl->raise(137, "", $this->name);
                         }
                     }
                     return false;
                 } else {
                     $this->parent->notifyEvent($this, CONS_ACTION_UPDATE, $data, $startedAt);
                     # later notify
                     $this->parent->storage['lastactiondata'] =& $data;
                 }
             } else {
                 $this->parent->errorState = true;
                 if (!$silent) {
                     $this->parent->errorControl->raise(138, "", $this->name);
                 }
                 return false;
             }
             if (count($EnumPrunecache) != 0) {
                 $this->autoPrune($EnumPrunecache, $data);
             }
             return true;
             break;
         case CONS_ACTION_INCLUDE:
             ###################################################### INCLUDE ############################################
             if ($this->parent->safety) {
                 # checkPermission has this test but this is faster
                 if ($this->parent->safety && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100) {
                     $this->parent->lockPermissions();
                     if (!$this->parent->authControl->checkPermission($this, CONS_ACTION_INCLUDE, array(true, true, true, 0))) {
                         $this->parent->errorControl->raise(150, '', $this->name);
                         return false;
                         # cannot create even OWNED items
                     }
                 }
                 # can create items
             }
             # if this module have multiple key fields, there is no auto_increment IF there is an id (id created automatically w/o AI)
             if (count($this->keys) > 1 && $this->keys[0] == "id") {
                 $wheres = array();
                 foreach ($this->keys as $field) {
                     if ($field != "") {
                         if (!isset($data[$field])) {
                             # we need this parent data to create the id, but it's missing!
                             $this->parent->errorState = true;
                             if (!$silent) {
                                 $this->parent->errorControl->raise(139, $field, $this->name);
                             }
                             return false;
                         }
                         array_push($wheres, $field . "=\"" . $data[$field] . "\"");
                     }
                 }
                 # foreach
                 $sql = "SELECT MAX(id) FROM " . $this->dbname . (count($wheres) != 0 ? " WHERE " . implode(" AND ", $wheres) : "");
                 $id = $this->parent->dbo->fetch($sql, $this->parent->debugmode);
                 if (!$id) {
                     # suposes it was empty
                     $id = 1;
                 } else {
                     $id++;
                 }
                 $sql = "INSERT INTO " . $this->dbname . " SET id='{$id}',";
                 $data['id'] = $id;
             } else {
                 $id = false;
                 $sql = "INSERT INTO " . $this->dbname . " SET ";
             }
             $output = "";
             $hasAuto = "";
             $outfield = false;
             foreach ($this->fields as $name => $field) {
                 if ($this->parent->safety && isset($field[CONS_XML_RESTRICT]) && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < $field[CONS_XML_RESTRICT]) {
                     # safety is on and this is a restricted field, while the user trying to add it does not have enough level
                     # however while ADDING a field that is mandatory, if it has no default you can add
                     if (!isset($field[CONS_XML_MANDATORY]) || isset($field[CONS_XML_DEFAULT])) {
                         if (isset($data[$name])) {
                             $this->parent->errorControl->raise(145, $name, $this->name, 'not mandatory or default on add');
                         }
                         unset($data[$name]);
                     }
                 }
                 if (strpos(strtolower($field[CONS_XML_SQL]), "auto_increment") === false && !($this->keys[0] == "id" && $name == $this->keys[0] && count($this->keys) > 1)) {
                     # cannot change auto_increment or main key fields
                     $outfield = $this->sqlParameter(true, $data, $name, $field, $EnumPrunecache);
                     if ($outfield !== false) {
                         $output .= $name . "=" . $outfield . ",";
                     }
                     if ((!$outfield || !isset($data[$name]) || $data[$name] == '') && isset($field[CONS_XML_AUTOFILL]) && !isset($field[CONS_XML_DEFAULT])) {
                         if (isset($data[$field[CONS_XML_AUTOFILL]])) {
                             $data[$name] = $data[$field[CONS_XML_AUTOFILL]];
                             // if the autofill field is HTML and this is NOT, remove HTML
                             if ($field[CONS_XML_TIPO] == CONS_TIPO_TEXT && !isset($field[CONS_XML_HTML])) {
                                 if (isset($this->fields[$field[CONS_XML_AUTOFILL]][CONS_XML_HTML])) {
                                     $data[$name] = preg_replace("/(<)([^<>]*)(>)/", "", $data[$name]);
                                 }
                             }
                             $output .= $name . "=\"" . $data[$name] . "\",";
                         }
                     }
                 } else {
                     # if (not AutoIncrement)
                     $hasAuto = $name;
                 }
             }
             #foreach
             $id = 0;
             unset($outfield);
             if ($output != "") {
                 # removes end ,
                 $output = substr($output, 0, strlen($output) - 1);
                 $sql .= $output;
                 if (!$this->parent->dbo->simpleQuery($sql, $this->parent->debugmode)) {
                     $this->parent->errorState = true;
                     $lastError = $this->parent->dbo->log[count($this->parent->dbo->log) - 1];
                     if (strpos(strtolower($lastError), "duplicate") === false) {
                         if (!$silent) {
                             $this->parent->errorControl->raise(140, $lastError, $this->name);
                         }
                     } else {
                         if (!$silent) {
                             $this->parent->errorControl->raise(141, $lastError, $this->name);
                         }
                     }
                     return false;
                 } else {
                     # post processing ...
                     if ($this->keys[0] == "id") {
                         $id = $this->parent->dbo->insert_id();
                         if ($hasAuto != "") {
                             $data[$hasAuto] = $id;
                         } else {
                             $data['id'] = $id;
                         }
                     }
                     # check for uploads and urla
                     $wS = "";
                     $kA = array();
                     $this->getKeys($wS, $kA, $data);
                     foreach ($this->fields as $name => $field) {
                         if ($field[CONS_XML_TIPO] == CONS_TIPO_SERIALIZED) {
                             foreach ($field[CONS_XML_SERIALIZEDMODEL] as $exname => $exfield) {
                                 #--- serialized uploads
                                 if ($exfield[CONS_XML_TIPO] == CONS_TIPO_UPLOAD) {
                                     $upOk = $this->prepareUpload($name . "_" . $exname, $kA, $data);
                                     if ($upOk != 4 && $upOk != 0) {
                                         // 4 = nothing sent, 0 = sent and ok
                                         # not mandatory but failed, warn about it but do not abort
                                         if (!$silent) {
                                             $this->parent->errorControl->raise(200 + $upOk, $upOk, $this->name, $name . '_' . $exname);
                                         }
                                         //$this->deleteUploads($kA,$name."_".$exname,'',$name); // delete possible partial thumbnail process
                                         # so far, serialized uploads have no flag
                                         //} else if ($upOk == 0) {
                                         //	$this->parent->dbo->simpleQuery("UPDATE ".$this->dbname." SET $name='y' WHERE $wS");
                                     }
                                 }
                             }
                         }
                         if ($field[CONS_XML_TIPO] == CONS_TIPO_UPLOAD) {
                             #--- normal uploads
                             $upOk = $this->prepareUpload($name, $kA, $data);
                             if ($upOk != 0 && isset($field[CONS_XML_MANDATORY])) {
                                 # failed or didn't send upload but it's mandatory
                                 $this->parent->errorState = true;
                                 if (!$silent) {
                                     $this->parent->errorControl->raise(200 + $upOk, $upOk, $this->name, $name);
                                 }
                                 # must remove inserted data!
                                 $this->parent->dbo->simpleQuery("DELETE FROM " . $this->dbname . " WHERE " . $wS, $this->parent->debugmode);
                                 $this->deleteUploads($kA);
                                 return false;
                             } else {
                                 if ($upOk != 4 && $upOk != 0) {
                                     // 4 = nothing sent, 0 = sent and ok
                                     # not mandatory but failed, warn about it but do not abort
                                     if (!$silent) {
                                         $this->parent->errorControl->raise(200 + $upOk, $upOk, $this->name, $name);
                                     }
                                     $this->deleteUploads($kA, $name);
                                     // delete possible partial thumbnail process
                                 } else {
                                     if ($upOk == 0) {
                                         $this->parent->dbo->simpleQuery("UPDATE " . $this->dbname . " SET {$name}='y' WHERE {$wS}");
                                     }
                                 }
                             }
                         } else {
                             if ($field[CONS_XML_TIPO] == CONS_TIPO_VC && isset($field[CONS_XML_SPECIAL]) && $field[CONS_XML_SPECIAL] == "urla" && (!isset($data[$name]) || $data[$name] == '')) {
                                 # EMPTY special VC urla might require the data to be fully processed to create the proper result, so we do it after the include
                                 $source = isset($field[CONS_XML_SOURCE]) ? $field[CONS_XML_SOURCE] : "{" . $this->title . "}";
                                 $tp = new CKTemplate($this->parent->template);
                                 $tp->tbreak($source);
                                 $urla = removeSimbols($tp->techo($data), true, false);
                                 if ($urla != '') {
                                     $this->parent->dbo->simpleQuery("UPDATE " . $this->dbname . " SET {$name}=\"{$urla}\" WHERE {$wS}");
                                     $data[$name] = $urla;
                                 }
                                 unset($tp);
                             }
                         }
                     }
                     $this->parent->lastReturnCode = $id;
                     $this->parent->notifyEvent($this, CONS_ACTION_INCLUDE, $data, $startedAt, false);
                     # later notify (there is no early notify for an include)
                     $this->parent->lastReturnCode = $id;
                     // notifyEvent could have changed/consumed lastReturnCode
                     $this->parent->storage['lastactiondata'] =& $data;
                 }
             } else {
                 # null insert? error
                 $this->parent->errorState = true;
                 if (!$silent) {
                     $this->parent->errorControl->raise(142, "", $this->name);
                 }
                 return false;
             }
             if (count($EnumPrunecache) != 0) {
                 $this->autoPrune($EnumPrunecache, $data);
             }
             return true;
             break;
         case CONS_ACTION_DELETE:
             ###################################################### DELETE ############################################
             $wS = "";
             $kA = array();
             $haveallKeys = $this->getKeys($wS, $kA, $data);
             # security
             $Owner = $this->parent->authControl->checkOwner($this, $kA);
             // array with isOwner and isSameGroup
             if ($this->parent->safety && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100) {
                 $this->parent->lockPermissions($this, $data, $Owner);
                 if (!$this->parent->authControl->checkPermission($this, CONS_ACTION_DELETE, $Owner, $data)) {
                     $this->parent->errorControl->raise(149, '', $this->name);
                     return false;
                 }
             }
             $this->parent->notifyEvent($this, CONS_ACTION_DELETE, $data, $startedAt, true);
             # early notify
             if ($this->parent->dbo->simpleQuery("DELETE FROM " . $this->dbname . " WHERE " . $wS, $this->parent->debugmode)) {
                 $this->deleteUploads($kA);
                 $this->parent->notifyEvent($this, CONS_ACTION_DELETE, $data, $startedAt, false);
                 # later notify
                 return true;
             } else {
                 $this->parent->errorState = true;
                 if (!$silent) {
                     $this->parent->errorControl->raise(143, "", $this->name);
                 }
                 return false;
             }
             break;
     }
     # switch
 }
Example #3
0
            if ($haveListADD) {
                $outputAdd .= $lineAddObj->techo($rowData);
            }
        }
        $outputLine .= $lineObj->techo($rowData);
    }
}
// foreach field to display
// end creation of listing templates
############################ FINALIZE TEMPLATE #####################
// prepare real output
if (!$notitle) {
    $core->template->assign("_top_row", $output);
}
$lineObj = new CKTemplate($core->template);
$lineObj->tbreak($outputLine);
$core->template->assign("_row", $lineObj);
if ($haveListADD && !$notitle) {
    $core->template->assign("_rowla", $outputAdd);
    $core->template->assign("colspan", $usedColumns + ($core->layout == 0 ? 3 : 2));
    $core->template->assign("lafields", implode("','", $laFields));
} else {
    $core->template->assign("_la");
}
############################ FILL SEARCH FORMS  #####################
// prepare template parameters for runContent
$core->templateParams['callbackModule'] =& $module;
$core->templateParams['forcepost'] = "frmbase|haveinfo=1";
# not really needed to change the haveinfo but TC requires a field to change
$core->templateParams['noOutputParse'] = !$imageDetected;
# faster (won't treat images nor toggles)
Example #4
0
 function log($die = true)
 {
     function appendErrors(&$core, &$output, &$template, $data)
     {
         foreach ($data as $line) {
             $line = explode("|", $line);
             # date|id_client|uri|errCode|module|parameters|extended parameters|log[|...]
             $thisData = array();
             $thisData['date'] = array_shift($line);
             $thisData['id_client'] = array_shift($line);
             $thisData['uri'] = array_shift($line);
             $thisData['errCode'] = array_shift($line);
             $thisData['module'] = array_shift($line);
             $thisData['parameters'] = array_shift($line);
             $thisData['extended'] = array_shift($line);
             $thisData['log'] = implode("|", $line);
             if (is_numeric($thisData['errCode']) && isset($core->errorControl->ERRORS[$thisData['errCode']])) {
                 $errorLevel = $core->errorControl->ERRORS[$thisData['errCode']];
                 $thisData['level'] = $errorLevel < 10 ? 0 : ($errorLevel < 20 ? 1 : 2);
                 $output .= $template->techo($thisData);
             }
         }
     }
     $outputTemplate = "<div style='line-height:25px;border-bottom:1px solid #999999;margin-bottom:3px;'>{date} {id_client}: <span style='color:red'>{errCode} ({_t}e{errCode}{/t})</span> [{module}] {parameters} (<strong>{extended}</strong>) @ {uri}</div>";
     $template = new CKTemplate($this->parent->template);
     $template->tbreak($outputTemplate);
     $this->parent->close(false);
     $temp = "";
     // 1 day ago
     $previousDay = datecalc(date("Y-m-d"), 0, 0, -1);
     $previousDay = str_replace("-", "", $previousDay);
     if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log")) {
         appendErrors($this->parent, $temp, $template, explode("\n", cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log")));
     }
     # Today
     $previousDay = date("Ymd");
     if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log")) {
         appendErrors($this->parent, $temp, $template, explode("\n", cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log")));
     }
     if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log")) {
         $temp .= nl2br(cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log"));
     }
     echo "Log files are located at " . CONS_PATH_LOGS . $_SESSION['CODE'] . "/<br/><br/>";
     echo $temp;
     echo "<br/><hr>";
     # httpd log?
     if (CONS_HTTPD_ERRFILE != '') {
         $httpderrlog = str_replace("{Y}", date("Y"), CONS_HTTPD_ERRFILE);
         $httpderrlog = str_replace("{m}", date("m"), $httpderrlog);
         $httpderrlog = str_replace("{d}", date("d"), $httpderrlog);
         if (is_file(CONS_HTTPD_ERRDIR . $httpderrlog)) {
             echo "<div style='font-color:red;margin-top:5px'>HTTPD errors detected on {$httpderrlog} log file:</div><br/><pre>";
             echo cReadFile(CONS_HTTPD_ERRDIR . $httpderrlog);
             echo "</pre>";
         }
     }
     if ($die) {
         $this->parent->close(true);
         die;
     }
 }
Example #5
0
                    $module->generateBackup();
                    if ($this->nearTimeLimit()) {
                        break;
                    }
                }
            }
        }
        if (CONS_CRONDBBACKUP_MAIL != '' && !$this->nearTimeLimit()) {
            $bfile = CONS_PATH_BACKUP . $_SESSION['CODE'] . "/backup.zip";
            if (is_file($bfile)) {
                @unlink($bfile);
            }
            $files = listFiles(CONS_PATH_BACKUP . $_SESSION['CODE'] . "/", '/.*\\.sql/');
            if (count($files) == 0) {
                return;
            }
            $zip = new ZipArchive();
            $zip->open($bfile, ZipArchive::CREATE);
            foreach ($files as $file) {
                $zip->addFile(CONS_PATH_BACKUP . $_SESSION['CODE'] . "/" . $file, $file);
            }
            $zip->close();
            unset($zip);
            $mail = "BACKUP PERFORMED AT " . date("Y-m-d H:i:s");
            $tmail = new CKTemplate();
            $tmail->tbreak($mail);
            sendmail(CONS_CRONDBBACKUP_MAIL, "backup " . $_SESSION['CODE'], $tmail, CONS_MASTERMAIL, '', true, $bfile);
        }
    }
    $this->dimconfig['_cronH'] = date("H");
}
Example #6
0
     $content = $using->techo($fillDT);
     $endScript .= $useCKE ? "var CKE" . $data['name'] . " = CKEDITOR.replace( '" . $data['name'] . "' , { language : '" . $_SESSION[CONS_SESSION_LANG] . "'} );\n\tCKFinder.setupCKEditor( CKE" . $data['name'] . ", '/pages/_js/ckfinder/' ) ;\n" : '';
     # CKEdit + CKFinder
     break;
 case CONS_TIPO_ENUM:
     // ############################################### LIST OF ITEMS IN ENUM FORM
     preg_match("@ENUM \\(([^)]*)\\).*@", $dimconfigMD[$data['name']][CONS_XML_SQL], $regs);
     if (isset($dimconfigMD[$data['name']][CONS_XML_DEFAULT]) && $data['value'] == "") {
         $data['value'] = $dimconfigMD[$data['name']][CONS_XML_DEFAULT];
     }
     if ($data['name'] == 'bi_adm_skin') {
         $regs = array(1 => CONS_ADM_ACTIVESKINS);
     }
     $xtp = "<option value=\"{enum}\" {checked}>{enum_translated}</option>";
     $tp = new CKTemplate($core->template);
     $tp->tbreak($xtp);
     $temp = isset($dimconfigMD[$data['name']][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' => $data['value'] == $x ? ' selected="selected"' : '');
         $temp .= $tp->techo($db);
     }
     $content = "<select id=\"" . $data['name'] . "\" name=\"" . $data['name'] . "\" >" . $temp . "</select>";
     break;
 case CONS_TIPO_DATE:
     // ############################################### DATE / DATETIME
 // ############################################### DATE / DATETIME
 case CONS_TIPO_DATETIME:
     $fillDT['calendar'] = "<img id='divcalendar_" . $data['name'] . "' onclick=\"calendarHandler.showCalendar('" . $data['name'] . "','divcalendar_" . $data['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";
Example #7
0
            // next page
            $line = 1;
        }
    }
    $offset--;
}
// print
// prepare templates
$aPage = clone $core->template->get("_page");
$core->template->assign("fontsize", $lData['fontsize']);
$aPage->assign("fontsize", $lData['fontsize']);
$aPage->assign("fullwidth", $lData['pfl'] + $lData['sw'] * $lData['cols'] + $lData['ol'] * ($lData['cols'] - 1) + 2);
$aPage->assign("fullheight", $lData['pft'] + $lData['sh'] * $lData['rows'] + $lData['ot'] * ($lData['rows'] - 1) + 2);
$aLabel = clone $core->template->get("_etiqueta");
$content = new CKTemplate();
$content->tbreak(nl2br($lData['content']));
$output = "";
$pageOutput = "";
// get labels
$basesql = $module->get_base_sql("", "", 1);
foreach ($theKeys as $ids) {
    if ($ids != "" && preg_match('/' . $ereg_pattern . '/', $ids, $regs)) {
        // valid multiple keys (checkboxes)
        $sql = $basesql;
        for ($pos = 0; $pos < $keyscount; $pos++) {
            // build WHERE based on keys
            $sql['WHERE'][] = $module->name . "." . $keys[$pos] . "=\"" . $regs[$pos + 1] . "\"";
        }
        if ($core->dbo->query($sql, $r, $n) && $n > 0) {
            // get data
            $data = $core->dbo->fetch_assoc($r);
Example #8
0
        // fill up title, metas etc
        if (isset($param['title'])) {
            $mytemplate = new CKTemplate($this->template);
            $mytemplate->tbreak($param['title']);
            $this->template->constants['PAGE_TITLE'] = $mytemplate->techo($result);
            $this->storage['LOCKTITLE'] = true;
            unset($mytemplate);
        }
        if (isset($param['metadesc'])) {
            $mytemplate = new CKTemplate($this->template);
            $mytemplate->tbreak($param['metadesc']);
            $this->template->constants['METADESC'] = $mytemplate->techo($result);
            $this->storage['LOCKDESC'] = true;
            unset($mytemplate);
        }
        if (isset($param['metakeys'])) {
            $mytemplate = new CKTemplate($this->template);
            $mytemplate->tbreak($param['metakeys']);
            $this->template->constants['METAKEYS'] = $mytemplate->techo($result);
            $this->storage['LOCKKEYS'] = true;
            unset($mytemplate);
        }
        return true;
    } else {
        unset($this->storage['friendlyurldata']);
        // just in case
        unset($this->storage['friendlyurlmodule']);
        // jic
    }
}
return false;
Example #9
0
foreach ($modules as $mod) {
    $module = $this->loaded($mod);
    if (!$module) {
        continue;
    }
    $sql = $module->get_base_sql('', '', $itemsPerModule);
    $hasCategory = $hasCategory || isset($category[$rssId]) && $category[$rssId] != "";
    $this->dbo->query($sql, $r, $n);
    $dateField = "";
    foreach ($module->fields as $fname => &$field) {
        if ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME && isset($field[CONS_XML_TIMESTAMP])) {
            $dateField = $fname;
        }
    }
    $ppage = new CKTemplate($this->template);
    $ppage->tbreak($ilt[$rssId]);
    for ($c = 0; $c < $n; $c++) {
        $dados = $this->dbo->fetch_assoc($r);
        $rssItem = array("title" => $dados[$it[$rssId]], "description" => $dados[$idesc[$rssId]], "date" => $dateField != "" ? gmdate("D, d M Y H:i:s", tomktime($dados[$dateField])) . " GMT" : $NOWdate, "link" => $ppage->techo($dados));
        if (!isset($category[$rssId]) || $category[$rssId] != "") {
            if ($hasCategory) {
                $rssItem['category'] = $dados[$category[$rssId]];
            }
        }
        $mylist[] = $rssItem;
    }
    $rssId++;
}
function datesort($a, $b)
{
    return datecompare($a['date'], $b['date']) ? 1 : -1;
Example #10
0
                $this->errorControl->raise(183, $name);
                $innerFile = "";
            }
        }
    }
    if ($innerFile != "") {
        if ($file != "") {
            $mail->assignFile("CONTENT", $innerFile);
        } else {
            $mail->fetch($innerFile);
        }
        # no template, but we have a file
    }
} else {
    if ($file == "") {
        $mail->tbreak("{CONTENT} ");
        # no template nor file
        if (is_file(CONS_PATH_SETTINGS . "defaults/automail.html")) {
            $smh = new CKTemplate($this->template);
            $smh->fetch(CONS_PATH_SETTINGS . "defaults/automail.html");
            $objField = $smh->get("_field");
            $temp = "";
            foreach ($_POST as $name => $data) {
                if ($name != "haveinfo") {
                    $temp .= $objField->techo(array('name' => $name, 'content' => nl2br($data)));
                }
            }
            $smh->assign("_field", $temp);
            $template = $smh->techo();
            unset($smh);
            unset($objField);
Example #11
0
    $limit = isset($mod['limit']) ? $mod['limit'] : 15;
    $where = isset($mod['where']) ? $mod['where'] : '';
    $order = isset($mod['order']) ? $mod['order'] : '';
    $sql = $module->get_base_sql($where, $order, $limit);
    $this->dbo->query($sql, $r, $n);
    $dateField = isset($mod['date']) ? $mod['date'] : '';
    if ($dateField == '') {
        foreach ($module->fields as $fname => &$field) {
            if (($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME || $field[CONS_XML_TIPO] == CONS_TIPO_DATE) && isset($field[CONS_XML_TIMESTAMP])) {
                $dateField = $fname;
            }
        }
    }
    if ($link != '') {
        $ppage = new CKTemplate($this->template);
        $ppage->tbreak($link);
    }
    for ($c = 0; $c < $n; $c++) {
        $dados = $this->dbo->fetch_assoc($r);
        $resultData = array("module" => $mod['module'], "title" => $dados[$title], "description" => $dados[$desc], "date" => $dateField != "" ? $dados[$dateField] : date("Y-m-d H:i:s"), "link" => $link != '' ? $ppage->techo($dados) : '', "id" => $dados[$module->keys[0]]);
        // TODO: does not support multiple keys
        $mylist[] = $resultData;
    }
    $c++;
}
if (!$groupPerModule) {
    function datesort($a, $b)
    {
        return datecompare($a['date'], $b['date']) ? 1 : -1;
    }
    uksort($mylist, "datesort");
Example #12
0
        foreach ($_GET as $gname => $gitem) {
            if (substr($gname, 0, 3) == "la_") {
                $newlist[substr($gname, 3)] = $gitem;
            } else {
                $newlist[$gname] = $gitem;
            }
        }
        $where = $sm->getRemoteKeys($module, $newlist);
    }
    foreach ($where as $whereItem) {
        $sql['WHERE'][] = $whereItem;
    }
}
// prepare template
$tp = new CKTemplate($this->template);
$tp->tbreak("<select id=\"{$container}\" name=\"{$container}\" {extras}>" . ($allowEmpty ? "<option value=''></option>" : "") . "{_options}<option {selected|selected} value=\"{id}\">{title}</option>{/options}</select>");
$extras = "";
if ($aoc) {
    $extras .= "onChange=\"selectChange();\" ";
}
if ($className != "") {
    $extras .= "class=\"{$className}\" ";
}
if ($widthValue != "") {
    $extras .= "style=\"width:{$widthValue}\" ";
}
$tp->assign("extras", $extras);
// fill select
$this->safety = false;
// <-- show all fields we can list
$total = $module->runContent($tp, $sql, "_options", false, false, false);
Example #13
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);
}