/** * Create a generic table showing the lines of the table * * */ private function table($attributs = array()) { // Create an HTML table object $tableau = new Zmax_HTML_Table(2, $attributs); $tableau->setAfficheEntete(1, false); $tableau->setLegende($this->title); // Create the headers foreach ($this->info['cols'] as $name) { if (!isset($this->auto_increment_key[$name]) and !isset($this->hide_from_table[$name])) { $tableau->ajoutEntete(2, $name, $this->headers[$name]); } } // A form to select sub-contents of the table if ($this->show_table_form) { $form = new Zmax_HTML_Form("post", $this->url, false, "table_form", "table_form"); // Create a first row with select fields foreach ($this->info['cols'] as $name) { if (!isset($this->auto_increment_key[$name]) and !isset($this->hide_from_table[$name])) { // Define the HTML form field name $form_field_name = $this->getTblFormFieldName($name); // Get the default value if it exists $form_field_name = $this->getTblFormFieldName($name); if (isset($this->table_form_values[$form_field_name])) { $default = $this->table_form_values[$form_field_name]; } else { $default = ""; } // Create an input field, based on the field type if (!isset($this->form_fields_type[$name])) { // A text field, for full text search $form_field = $form->champTexte("", $form_field_name, $default, 20, 20); // Add in the where clause $safe_def = $this->db->prepareString($default); $this->where_clause .= " AND {$name} LIKE '%{$safe_def}%'"; } else { if ($this->form_fields_type[$name] == self::SELECT_FIELD or $this->form_fields_type[$name] == self::RADIO_FIELD) { $the_list = array_merge(array(self::ALL_INDEX => $this->texts->zmax->all), $this->form_fields[$name]); $form_field = $form->champListe("", $form_field_name, $default, 1, $the_list); // Add in the where clause if ($default != self::ALL_INDEX) { $this->where_clause .= " AND {$name} = '{$default}'"; } // echo "$name is a select field<br/>"; } else { if ($this->form_fields_type[$name] == self::CHECKBOX_FIELD) { $form_field = $form->champCheckBox("", $form_field_name, "", $this->form_fields[$name], self::NB_ROWS_CHECKBOX); } else { if ($this->form_fields_type[$name] == self::BOOLEAN_FIELD) { $form_field = $form->champRadio("", $form_field_name, "", $this->form_fields[$name]); } } } } // Put the field in the table $tableau->ajoutValeur(0, $name, $form->getChamp($form_field)); } } $form_field = $form->champValider($this->texts->form->submit, "submit"); $tableau->ajoutValeur(0, "Action", $form->getChamp($form_field)); unset($form); } // End of the creation of the table form // Show the values of the many-to-many associations foreach ($this->add_form_fields as $remote_field_name => $link) { if (!isset($this->hide_from_table[$remote_field_name])) { $tableau->ajoutEntete(2, $remote_field_name, $this->headers[$remote_field_name]); } } // Scan the table // echo "Where clause = " . $this->where_clause . "<br/>"; if (!empty($this->order_by_clause)) { $this->table_object->select()->order($this->order_by_clause); } if (empty($this->where_clause)) { $objs = $this->table_object->fetchAll(); } else { $objs = $this->table_object->fetchAll($this->where_clause); } $i = 0; foreach ($objs as $obj) { $row = $obj->toArray(); // Easier to manipulate as an array $i++; // Create the cells foreach ($this->info['cols'] as $name) { $meta = $this->info['metadata'][$name]; // What is this for? // if(substr($name,-8)=="_archive"){$val_archive = $row[$name];} if (!isset($this->auto_increment_key[$name]) and !isset($this->hide_from_table[$name])) { if ($meta['DATA_TYPE'] == "time") { // Show only hour and minutes $time = explode(":", $row[$name]); $row[$name] = $time[0] . ":" . $time[1]; } if (isset($this->form_fields[$name][$row[$name]])) { // The value is referred to by the foreign key $ligne[$nom] $label = $this->form_fields[$name][$row[$name]]; } else { // Attention: traitement des balises HTML avant affichage if (!is_array($row[$name])) { $label = htmlSpecialChars($row[$name]); } else { echo "Non string {$name}? " . $row[$name] . "<br/>"; } } $tableau->ajoutValeur($i, $name, $label); } } // Show the values of the many-to-many associations foreach ($this->add_form_fields as $remote_field_name => $remote_descr) { // Get teh name of the remote table and the remote field $bridge_table = $remote_descr['bridge_table']; $remote_table = $remote_descr['remote_table']; if (!isset($this->hide_from_table[$remote_field_name])) { // Follow the many-to-many link $remotes = $obj->findManyToManyRowset($remote_table, $bridge_table); $comma = $r_val = ""; foreach ($remotes as $remote) { $rem_arr = $remote->toArray(); $r_val .= $comma . $rem_arr[$remote_field_name]; $comma = ", "; } $tableau->ajoutValeur($i, $remote_field_name, $r_val); } } // Add links in the table $modLink = $archLink = $delLink = ""; if ($this->show_btn_modify) { // Show the modification URL $urlMod = $this->keyAccess($row) . "&" . self::ZMAX_EDIT_ACTION . "=" . self::DB_EDIT; // Attention: traitement des balises HTML avant affichage $urlMod = $urlMod . $this->form_table_query; $modLink = "<a href='{$this->url}{$urlMod}'>{$this->texts->form->modify}</a>"; } // Show the deletion URL if ($this->show_btn_delete) { // url de destruction $urlDel = $this->keyAccess($row) . "&" . self::ZMAX_EDIT_ACTION . "=" . self::DB_DELETE; // Attention: traitement des balises HTML avant affichage $urlDel = $urlDel; $msg_suppression = $this->texts->are_you_sure; $url = $this->url . "/" . $urlDel . $this->form_table_query; $jscript = "onClick=\"if (confirm('" . $msg_suppression . "')) " . "{window.location = '" . $url . "';} else alert ('" . $this->texts->form->canceled . "');\" "; $delLink = "<a {$jscript} href='#'>{$this->texts->form->delete}</a>"; } // modification de la classe pour mettre toutes les actions dans la meme colonne by JF (webnet) 17/08/2007 $outLink = $modLink; if ($modLink != "") { $outLink .= "<br />\n"; } $outLink .= $archLink; if ($archLink != "") { $outLink .= "<br />\n"; } $outLink .= $delLink; $tableau->ajoutValeur($i, "Action", $outLink); } // If a form is associated to the table: create // the form, then put the table in it, then return if ($this->show_table_form) { $form = new Zmax_HTML_Form("post", $this->url, false, "table_form", "table_form"); $form->champCache("show_table_form", 1); $form->ajoutTexte($tableau->tableauHTML()); return $form->formulaireHTML(); } else { // Return the string that contains the HTML table return $tableau->tableauHTML(); } }
/** * Static method that returns a login form * */ public static function loginForm($req_controller, $req_action, $request) { // Get the current action URL (use the config to obtain the base URL) // Get the utilitary objects from the registry $registry = Zend_registry::getInstance(); $zmax_context = $registry->get("zmax_context"); $module_name = $request->getModuleName(); if (!empty($module_name)) { $module = $request->getModuleName() . "/"; } else { $module = ""; } $url = $zmax_context->config->app->base_url . "/" . $module . $request->getControllerName() . "/" . $request->getActionName() . "?1=1"; // The form always refers to the current controller // and to the current action $current_action = $request->getActionName(); $form = new Zmax_HTML_Form($url); $form->champCache("zmax_req_controller", $req_controller); $form->champCache("zmax_req_action", $req_action); $form->debutTable(); $form->champTexte($zmax_context->texts->zmax->login, "zmax_login", "", 20); $form->champMotDePasse($zmax_context->texts->zmax->password, "zmax_password", "", 20); $form->champValider($zmax_context->texts->zmax->submit, "submit_login"); $form->finTable(); return $form->fin(); }