public function __construct(&$params = array()) { // reccup le id du module si envoyé en param if (isset($_REQUEST->moduleId)) { if (isset($_SESSION["modules/" . $_REQUEST->moduleId . "/params"])) { $params = $_SESSION["modules/" . $_REQUEST->moduleId . "/params"]; } } $this->setParameters($params); $id = \Core\Request::getClassUri($this); $id = \Core\CString::sanitize($id); $this->id = $id . "-" . md5(serialize($params)); // Sotck une clé unique d'initialisation en session if (!isset($_SESSION["modules/" . $this->id()])) { $_SESSION["modules/" . $this->id()] = CString::rand(30); } $this->key = $_SESSION["modules/" . $this->id()]; $_SESSION["modules/" . $this->id() . "/params"] = $params; }
/** Translate a text */ public static function translateText($str) { global $PROJECT_TRANSLATION; $text = \Core\CString::sanitize($str); if (isset($PROJECT_TRANSLATION[$text])) { return $PROJECT_TRANSLATION[$text]; } else { if (!empty($PROJECT_TRANSLATION)) { \Core\FirePHP::fbLog("warn", "Translation error : " . $str); } } return $str; }
public function tableManagerBuildItem($randId, $field, $describe, $fieldPrefix = "") { $name = $field; $value = ""; if (isset($this->results[$field])) { $value = $this->results[$field]; } if (!empty($fieldPrefix)) { $value = ""; } if ($this->columns[$field]["updateIfNull"] === false) { $value = ""; } // TODO escape quote et accent !!! $value = htmlspecialchars($value); switch ($describe["type"]) { case "int": $type = "numberfield"; break; case "double": $type = "numberfield"; break; case "timestamp": case "datetime": $type = "datetime"; break; case "date": $type = "date"; break; case "time": $type = "time"; break; default: $type = "text"; break; } echo "<label for=\"field_{$name}" . $randId . "\">"; echo $fieldPrefix . " "; if (!empty($this->columns[$field]["alias"])) { echo $this->columns[$field]["alias"]; } else { echo $field; } if ($describe["notNull"]) { echo " *"; } echo "</label>"; // Suffixe name if (!empty($fieldPrefix)) { $name = $name . "____" . \Core\CString::sanitize($fieldPrefix); } // Max lenght for input $maxLength = ""; if ($describe["length"] > 0) { $maxLength = "maxlength=\"" . $describe["length"] . "\""; } // PK if ($describe["primaryKey"]) { // Si AI => id auto if ($describe["serial"]) { echo "<input type=\"text\" value=\"{$value}\" readonly=\"readonly\" placeholder=\"AUTO\" />"; } else { // si id non renseigné (new) id editable if ($value === "") { echo "<input type=\"text\" name=\"tablefield_{$name}\" value=\"{$value}\" {$maxLength} />"; } else { // si id renseigné id (update) non editable echo "<input type=\"text\" value=\"{$value}\" readonly=\"readonly\" />"; } } } else { // // Fk choix multiple // if (!empty($describe["foreignKey"])) { $sqlFk = "SELECT * FROM " . $this->db->quoteTable($describe["foreignKey"]["table"]); $resFk = $this->db->select($sqlFk); echo "<select\n id=\"field_{$name}" . $randId . "\"\n value=\"{$value}\"\n name=\"tablefield_{$name}\"\n class=\"{$type}\"\n type=\"{$type}\"\n attr-required=\"" . ($describe["notNull"] ? "required" : "") . "\"\n >"; echo "<option value=\"\"></option>"; foreach ($resFk as $r) { echo "<option\n value=\"" . $r[$describe["foreignKey"]["field"]] . "\"\n " . ($value == $r[$describe["foreignKey"]["field"]] ? "selected" : "") . "\n >"; echo implode(" - ", array_values($r)); echo "</option>"; } echo "</select>"; } elseif (!empty($describe["length"]) && (int) $describe["length"] > 255) { // // Text long // echo "<textarea\n id=\"field_{$name}" . $randId . "\"\n name=\"tablefield_{$name}\"\n class=\"{$type}\"\n type=\"{$type}\"\n attr-required=\"" . ($describe["notNull"] ? "required" : "") . "\"\n {$maxLength}\n >{$value}</textarea>"; } else { // // TODO bool... // echo "<input\n id=\"field_{$name}" . $randId . "\"\n value=\"{$value}\"\n name=\"tablefield_{$name}\"\n class=\"{$type}\"\n type=\"{$type}\"\n attr-required=\"" . ($describe["notNull"] ? "required" : "") . "\"\n {$maxLength}\n />"; } } // editor if (isset($this->columns[$field]["editor"]) && !empty($this->columns[$field]["editor"])) { $editor = strtolower($this->columns[$field]["editor"]); if ($editor == "tinymce") { echo "\n <script>\n \$(function() {\n \$('#field_{$name}" . $randId . "').attr('data-editor', 'tinymce');\n \$('#field_{$name}" . $randId . "').tinymce({});\n });\n </script>\n "; } } }