function createTableFirstPagePic64($array_link) { $ind = 0; $row_table = null; $table = new Table(10, 10); for ($i = 0; $i < sizeof($array_link); $i++) { if ($array_link[$i]->getUserHaveRights()) { if ($ind % 5 == 0) { if ($row_table != null) { $table->addRow($row_table); } $row_width = 20; if (sizeof($array_link) < 5) { $row_width = 100 / sizeof($array_link); } $row_table = new RowTable(RowTable::ALIGN_CENTER, $row_width . "%"); } $row_table->add($array_link[$i]); $ind++; } } if ($row_table != null) { $table->addRow($row_table); } return $table; }
/** * Method createRender * @access private * @param boolean $first_time [default value: true] * @since 1.1.11 */ private function createRender($first_time = true) { $this->table_main = new Table(); $this->table_main->setClass($this->table_style); $this->table_main->setWidth($this->table_width); if ($first_time) { $this->form = new Form($this->page_object); $this->error_obj = new Object(); $this->error_obj->setId("wsp_auth_IdErrorMsg"); $this->login = new TextBox($this->form, "wsp_auth_login"); $this->login_validation = new LiveValidation(); $this->login->setLiveValidation($this->login_validation->addValidatePresence()->setFieldName($this->login_label)); $this->login->setFocus()->setStripTags()->setWidth($this->input_width); $this->password = new Password($this->form, "wsp_auth_passwd"); $this->passwd_validation = new LiveValidation(); $this->password->setLiveValidation($this->passwd_validation->addValidatePresence()->setFieldName($this->password_label)); $this->password->setStripTags()->setWidth($this->input_width); $this->connect_button = new Button($this->form, "wsp_auth_connect", "", $this->button_label); $this->hdnReferer = new Hidden($this->form, "wsp_auth_referer"); } if ($this->encrypt && extension_loaded('openssl')) { $this->form->setEncryptObject(new EncryptDataWspObject("wsp-authentication")); } else { $this->form->disableEncryptObject(); } if ($this->button_class != '') { $this->connect_button->setClass($this->button_class); } if ($this->ajax_wait_message != "") { $this->connect_button->setAjaxWaitMessage($this->ajax_wait_message); } if ($this->disable_ajax_wait_message) { $this->connect_button->disableAjaxWaitMessage(); } $this->connect_button->assignEnterKey()->onClick($this->connect_method); $this->connect_button->setAjaxEvent($this->is_ajax_event); if ($this->style == Authentication::STYLE_2_LINES) { $this->table_main->addRow($this->error_obj)->setColspan(2)->setAlign(RowTable::ALIGN_CENTER); $this->table_main->addRowColumns($this->login_label . ": ", $this->login)->setColumnWidth(2, "100%")->setNowrap(); $this->table_main->addRowColumns($this->password_label . ": ", $this->password)->setNowrap(); for ($i = 0; $i < sizeof($this->custom_field_array); $i++) { $this->table_main->addRowColumns($this->custom_label_array[$i] . ": ", $this->custom_field_array[$i])->setNowrap(); } $this->table_main->addRow(); $this->table_main->addRow($this->connect_button)->setColspan(2); } else { if ($this->style == Authentication::STYLE_2_LINES_NO_TEXT) { $this->table_main->addRow($this->error_obj)->setAlign(RowTable::ALIGN_CENTER); $this->table_main->addRowColumns($this->login->setFocus())->setColumnWidth(2, "100%")->setNowrap(); $this->table_main->addRowColumns($this->password)->setNowrap(); for ($i = 0; $i < sizeof($this->custom_field_array); $i++) { $this->table_main->addRowColumns($this->custom_field_array[$i])->setNowrap(); } $this->table_main->addRow(); $this->table_main->addRow($this->connect_button); } else { if ($this->style == Authentication::STYLE_1_LINE) { $this->table_main->addRow($this->error_obj)->setColspan(5)->setAlign(RowTable::ALIGN_CENTER); $row = new RowTable(); $row->add(new Object($this->login_label, ": ", $this->login->setFocus()))->add(" ")->add(new Object($this->password_label, ": ", $this->password))->add(" "); for ($i = 0; $i < sizeof($this->custom_field_array); $i++) { $row->add(new Object($this->custom_label_array[$i], ": "))->add($this->custom_field_array[$i])->add(" "); } $row->add($this->connect_button)->setNowrap(); $this->table_main->addRow($row); } else { if ($this->style == Authentication::STYLE_1_LINE_NO_TEXT) { $this->table_main->addRow($this->error_obj)->setColspan(3)->setAlign(RowTable::ALIGN_CENTER); $row = new RowTable(); $row->add($this->login->setFocus())->add(" ")->add($this->password)->add(" "); for ($i = 0; $i < sizeof($this->custom_field_array); $i++) { $row->add($this->custom_field_array[$i])->add(" "); } $row->add($this->connect_button)->setNowrap(); $this->table_main->addRow($row); } } } } if (isset($_GET['referer'])) { $this->hdnReferer->setValue(trim($_GET['referer'])); } $this->form->setContent(new Object($this->table_main, $this->hdnReferer)); $this->render = $this->form; }
/** * Method addRowLoadFromSqlDataView * @access private * @param mixed $row * @param mixed $list_attribute * @param mixed $list_attribute_type * @param mixed $key_attributes * @param mixed $ind * @param boolean $is_delete_action [default value: false] * @param double $line_nb [default value: 0] * @return boolean * @since 1.1.6 */ private function addRowLoadFromSqlDataView($row, $list_attribute, $list_attribute_type, $key_attributes, $ind, $is_delete_action = false, $line_nb = null) { if ($this->from_sql_data_view_delete) { // create delete button if not already exists $bnt_del_id = $this->id . "_btndel__ind_" . $ind; $delete_pic = $this->getPage()->getObjectId($bnt_del_id); if ($delete_pic == null) { $delete_pic = new Picture("img/wsp-admin/delete_16.png", 16, 16, 0, Picture::ALIGN_ABSMIDDLE); $delete_pic->setId($bnt_del_id); $delete_pic->onClickJs("if (!confirm('" . __(TABLE_CONFIME_DEL_ROW) . "')) { return false; }"); $delete_pic->onClick($this->getPage(), "onChangeTableFromSqlDataView")->setAjaxEvent()->disableAjaxWaitMessage(); } } // create row $row_table = new RowTable(); $row_table->setId($this->id . "_row_" . $ind); for ($i = 0; $i < sizeof($list_attribute); $i++) { // get field properties if (is_array($this->from_sql_data_view_properties[$list_attribute[$i]])) { $attribute_properties = $this->from_sql_data_view_properties[$list_attribute[$i]]; } else { $attribute_properties = array(); } // get property display if (isset($attribute_properties["display"]) && $attribute_properties["display"] == false) { continue; } // get property update $is_update_ok = true; if (isset($attribute_properties["update"]) && $attribute_properties["update"] == false) { $is_update_ok = false; } if ($this->from_sql_data_view_update && !in_array($list_attribute[$i], $key_attributes) && $is_update_ok) { $row_value = $row->getValue($list_attribute[$i]); if (gettype($row_value) == "object" && method_exists($row_value, "render")) { $row_value = $row_value->render(); } $edit_pic = new Picture("wsp/img/edit_16x16.png", 16, 16); $row_obj = new Object($edit_pic, trim($row_value) == "" ? " " : utf8encode($row_value)); $row_obj->setId($this->id . "_" . $list_attribute[$i] . "_obj_" . $ind)->setStyle("cursor:pointer;border:1px solid gray;"); $input_obj = $this->createDbAttributeObject($row, $list_attribute, $list_attribute_type, $i, $ind, $key_attributes); if (get_class($input_obj) == "ComboBox") { // Get foreign key value $row_obj->emptyObject(); $value = $input_obj->getText(); $row_obj->add($edit_pic, trim($value) == "" ? " " : $value); } else { if (get_class($input_obj) == "Calendar") { $row_obj->emptyObject(); $value = $input_obj->getValueStr(); $row_obj->add($edit_pic, trim($value) == "" ? " " : $value); $row_table->setNowrap(); } } $row_obj_input = new Object($input_obj); $row_obj_input->setId($this->id . "_" . $list_attribute[$i] . "_input_obj_" . $ind); $cancel_pic = new Picture("wsp/img/cancel_12x12.png", 12, 12); $cancel_pic->setId($this->id . "_img_" . $ind . "_cancel_" . $list_attribute[$i]); $cancel_pic->onClickJs("\$('#" . $row_obj->getId() . "').css('display', 'inline');\$('#" . $row_obj_input->getId() . "').hide();" . ($this->from_sql_data_view_add_button != null ? "\$('#" . $this->from_sql_data_view_add_button->getId() . "').button({ disabled: false });" : "")); $cancel_pic_obj = new Object($cancel_pic); $row_obj_input->add($cancel_pic_obj->forceSpanTag()->setStyle("position:absolute;")); if (!$this->getPage()->isAjaxPage() || $is_delete_action || $this->from_sql_data_view_reload_pic != null && $this->from_sql_data_view_reload_pic->isClicked() || $this->from_sql_data_view_add_button != null && $this->from_sql_data_view_add_button->isClicked()) { $this->getPage()->addObject(new JavaScript("\$(document).ready(function() { \$('#" . $row_obj_input->getId() . "').hide(); });")); } $row_obj->onClickJs("\$('#" . $row_obj->getId() . "').hide();\$('#" . $row_obj_input->getId() . "').show();" . ($this->from_sql_data_view_add_button != null ? "\$('#" . $this->from_sql_data_view_add_button->getId() . "').button({ disabled: true });" : "")); $row_table->add(new Object($row_obj, $row_obj_input)); // get properties align if (isset($attribute_properties["align"])) { $row_table->setColumnAlign($i + 1, $attribute_properties["align"]); } } else { $value = $row->getValue($list_attribute[$i]); if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj'])) { $input_obj_tmp = $this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj']; $input_obj_tmp->setValue($value); $value = $input_obj_tmp->getText(); } if (get_class($value) == "DateTime") { $value = $value->format("Y-m-d"); } $row_table->add(utf8encode($value)); } } if ($this->from_sql_data_view_delete) { $row_table->add($delete_pic); } else { if ($this->from_sql_data_view_insert) { $row_table->add(); } } if ($is_table_defined_style) { $row_table->setBorderPredefinedStyle($this->class); } if ($this->is_advance_table) { if (isset($line_nb) && $line_nb !== null) { $row_table->setRowClass($line_nb % 2 == 0 ? "odd" : "even"); } else { if (is_numeric($ind)) { $row_table->setRowClass($ind % 2 == 0 ? "odd" : "even"); } else { $row_table->setRowClass("even"); } } } $this->addRow($row_table); }
/** * Method render * @access public * @param boolean $ajax_render [default value: false] * @return mixed * @since 1.1.9 */ public function render($ajax_render = false) { $gallery_table = new Table(); $gallery_table->setId("PhotoGalleryTable" . rand(0, 999999))->activatePagination(); $header = new RowTable(); for ($i = 0; $i < $this->nb_col; $i++) { $header->add(); } $gallery_table->addRow($header->setHeaderClass(0)); $ind = 0; $last_ind = -1; $gallery_row = null; $files = scandir($this->path, 1); for ($i = 0; $i < sizeof($files); $i++) { $file = $files[$i]; if ($file != "." && $file != "..") { $getExt = explode(".", $file); $countExt = count($getExt); $fExt = $countExt - 1; $myExt = $getExt[$fExt]; if ((is_dir($this->path . $file) || $this->in_arrayi($myExt, $this->picture_ext)) && $file != $this->thumbnail_folder) { if ($ind != $last_ind && $ind % $this->nb_col == 0) { if ($gallery_row != null) { $gallery_table->addRow($gallery_row); } $gallery_row = new RowTable(); $gallery_row->setWidth("25%"); $last_ind = $ind; } if (is_dir($this->path . $file)) { if ($this->subfolder) { $folder_pic = new Picture($this->folder_pic, 128, 128, 0, Picture::ALIGN_ABSMIDDLE, $file); $url = $this->getPage()->getCurrentURL(); if (($pos = find($url, "gallery_event=")) > 0) { $pos2 = find($url, "&", 0, $pos); if ($pos2 == 0) { $url = substr($url, 0, $pos - 1); } else { $url1 = substr($url, 0, $pos - 1); $url2 = substr($url, $pos2, strlen($url)); $url = $url1 . $url2; } } if (find($url, "?") > 0) { $url = $url . "&"; } else { $url = $url . "?"; } $url = $url . "gallery_event=" . urlencode(str_replace($this->original_path, "", $this->path . $file)); $folder_link = new Link($url, Link::TARGET_NONE, new Object($folder_pic, "<br/>", $file)); $gallery_row->add($folder_link); $ind++; } } else { if ($this->in_arrayi($myExt, $this->picture_ext)) { $pic_file = str_replace(str_replace("\\", "/", realpath(SITE_DIRECTORY)) . "/", "", str_replace("\\", "/", realpath($this->path)) . "/" . $file); $pic_file_lower_ext = str_replace("." . $myExt, strtolower("." . $myExt), $pic_file); if ($pic_file_lower_ext != $pic_file) { $path_file_lower_ext = str_replace($pic_file, $pic_file_lower_ext, str_replace("\\", "/", realpath(SITE_DIRECTORY . "/" . $pic_file))); if (!rename(realpath(SITE_DIRECTORY . "/" . $pic_file), $path_file_lower_ext)) { $pic_file_lower_ext = $pic_file; } } $pic_name = str_replace("." . $myExt, "", $file); $pic_thumbnail = $pic_file_lower_ext; if (trim($this->thumbnail_folder) != "") { if (in_array(strtolower($myExt), array("jpg", "jpeg", "gif", "png"))) { if (!is_dir(realpath($this->path) . "/" . $this->thumbnail_folder)) { mkdir(realpath($this->path) . "/" . $this->thumbnail_folder); } $pic_thumbnail_path = realpath($this->path . "/" . $this->thumbnail_folder) . "/" . str_replace("." . $myExt, strtolower("." . $myExt), $file); $pic_thumbnail = str_replace(str_replace("\\", "/", realpath(SITE_DIRECTORY)) . "/", "", str_replace("\\", "/", realpath($this->path . "/" . $this->thumbnail_folder)) . "/" . str_replace("." . $myExt, strtolower("." . $myExt), $file)); if (strtolower($myExt) == "gif") { // convert to jpg $pic_thumbnail_path = str_replace(".gif", ".jpg", $pic_thumbnail_path); $pic_thumbnail = str_replace(".gif", ".jpg", $pic_thumbnail); } if (!file_exists($pic_thumbnail_path)) { if (strtolower($myExt) == "jpg" || strtolower($myExt) == "jpeg") { jpegReductionFixe($pic_file_lower_ext, $pic_thumbnail_path, 128, 128); } else { if (strtolower($myExt) == "png") { pngReductionFixe($pic_file_lower_ext, $pic_thumbnail_path, 128, 128); } else { $tmp_file = realpath($this->path . "/" . $this->thumbnail_folder) . "/temp.jpg"; gif2jpeg($pic_file_lower_ext, $tmp_file); jpegReductionFixe($tmp_file, $pic_thumbnail_path, 128, 128); unlink($tmp_file); } } } } } $pic = new Picture($pic_thumbnail, 128, 128, 0, Picture::ALIGN_ABSMIDDLE, $pic_name); $pic->addLightbox("Lightbox" . $gallery_table->getId(), $pic_file_lower_ext, "\$(window).width()-(\$(window).width()*0.2)", "\$(window).height()-(\$(window).height()*0.2)"); $gallery_row->add(new Object($pic, "<br/>", $pic_name)); $ind++; } } } } } if ($gallery_row != null) { while ($ind % $this->nb_col != 0) { $gallery_row->add(); $ind++; } $gallery_table->addRow($gallery_row); } return $gallery_table->render($ajax_render); }
/** * Method loadFromSqlDataView * @access public * @param mixed $sql * @param mixed $properties [default value: array(] * @return mixed * @since 1.2.0 */ public function loadFromSqlDataView($sql, $properties = array(), $hide_empty_fields = false) { if (gettype($sql) != "object" || get_class($sql) != "SqlDataView") { throw new NewException(get_class($this) . "->loadFromSqlDataView() error: \$sql is not SqlDataView object", 0, getDebugBacktrace(1)); } if ($insert || $update || $delete) { if ($sql->isQueryWithJoin()) { throw new NewException(get_class($this) . "->loadFromSqlDataView() error: you need use SqlDataView object without JOIN if you want to use insert update or delete.", 0, getDebugBacktrace(1)); } } if (!is_array($properties)) { throw new NewException(get_class($this) . "->loadFromSqlDataView() error: \$properties need to be an array", 0, getDebugBacktrace(1)); } $list_attribute = $sql->getListAttributeArray(); // Add properties to apply on all fields if (isset($properties[ModelViewMapper::PROPERTIES_ALL]) && is_array($properties[ModelViewMapper::PROPERTIES_ALL])) { $apply_all_array = $properties[ModelViewMapper::PROPERTIES_ALL]; foreach ($apply_all_array as $property_name => $property_value) { for ($i = 0; $i < sizeof($list_attribute); $i++) { $property[$property_name] = $property_value; if (isset($properties[$list_attribute[$i]])) { $properties[$list_attribute[$i]] = array_merge($properties[$list_attribute[$i]], $property); } else { $properties[$list_attribute[$i]] = $property; } } } } // check foreign keys $db_table_foreign_keys = $sql->getDbTableObject()->getDbTableForeignKeys(); foreach ($db_table_foreign_keys as $fk_attribute => $value) { if (isset($properties[$fk_attribute])) { $fk_property = $properties[$fk_attribute]; if (isset($fk_property["fk_attribute"])) { // create combobox $cmb = new ComboBox($this); // get foreign key data $query = "select distinct " . $value["column"] . " as id, " . $fk_property["fk_attribute"] . " as value from " . $value["table"]; if (isset($fk_property["fk_where"])) { $query .= " where " . $fk_property["fk_where"]; } if (isset($fk_property["fk_orderby"])) { $query .= " order by " . $fk_property["fk_orderby"]; } $stmt = DataBase::getInstance()->prepareStatement($query); $row = DataBase::getInstance()->stmtBindAssoc($stmt, $row); while ($stmt->fetch()) { $cmb->addItem(utf8encode($row['id']), utf8encode($row['value'])); } // add combo box in properties $value['cmb_obj'] = $cmb; $properties[$fk_attribute] = array_merge($properties[$fk_attribute], $value); } } } $this->from_sql_data_view_properties = $properties; $key_attributes = $sql->getPrimaryKeysAttributes(); // check if all the fields of sql object are in the SQL attributes $list_attribute_change = false; $auto_hide_field_from = -1; $all_list_attributes = $sql->getDbTableObject()->getDbTableAttributes(); for ($i = 0; $i < sizeof($all_list_attributes); $i++) { if (!in_array($all_list_attributes[$i], $list_attribute)) { $tmp_list_attribute = $sql->getCustomFields(); $tmp_list_attribute .= ", `" . $sql->getDbTableObject()->getDbTableName() . "`.`" . $all_list_attributes[$i] . "`"; $sql->setCustomFields($tmp_list_attribute); if ($auto_hide_field_from == -1) { $auto_hide_field_from = sizeof($list_attribute); } } } if ($auto_hide_field_from != -1) { $list_attribute = $sql->getListAttributeArray(); for ($i = $auto_hide_field_from; $i < sizeof($list_attribute); $i++) { $properties[$list_attribute[$i]]["display"] = false; } } $list_attribute_type = $sql->getListAttributeTypeArray(); $auto_increment_id = $sql->getDbTableObject()->getDbTableAutoIncrement(); $this->from_sql_data_view_properties = $properties; $it = $sql->retrieve(); if ($it->getRowsNum() > 1) { throw new NewException(get_class($this) . "->loadFromSqlDataView() error: the query return more than 1 result. Form object can only modify 1 " . get_class($sql->getDbTableObject()) . ".", 0, getDebugBacktrace(1)); } $this->table_from_sql_data_view = new Table(); $this->table_from_sql_data_view->setDefaultAlign(RowTable::ALIGN_LEFT); $this->table_from_sql_data_view->setDefaultValign(RowTable::VALIGN_CENTER); // Generate form data $this->sql_data_view_object = $sql; $this->data_row_iterator_object = $it; if ($it->hasNext()) { $row = $it->next(); $this->data_row_object = $row; } else { $temp_it = clone $it; $row = $temp_it->insert(); for ($i = 0; $i < sizeof($list_attribute); $i++) { $row->setValue($list_attribute[$i], ""); } } for ($i = 0; $i < sizeof($list_attribute); $i++) { // get field properties if (is_array($this->from_sql_data_view_properties[$list_attribute[$i]])) { $attribute_properties = $this->from_sql_data_view_properties[$list_attribute[$i]]; } else { $attribute_properties = array(); } // get property display if (isset($attribute_properties["display"]) && $attribute_properties["display"] == false) { continue; } // get property update $is_update_ok = true; if (isset($attribute_properties["update"]) && $attribute_properties["update"] == false) { $is_update_ok = false; } $row_table = new RowTable(); if (isset($attribute_properties["title"])) { $row_table->add($attribute_properties["title"] . ": "); } else { $row_table->add($list_attribute[$i] . ": "); } $row_table->add(" "); if ($list_attribute[$i] != $auto_increment_id && $is_update_ok) { $row_value = $row->getValue($list_attribute[$i]); if (gettype($row_value) == "object" && method_exists($row_value, "render")) { $row_value = $row_value->render(); } $input_obj = $this->createDbAttributeObject($row, $list_attribute, $list_attribute_type, $i, $key_attributes); $row_table->add($input_obj); // get properties align if (isset($attribute_properties["align"])) { $row_table->setColumnAlign($i + 1, $attribute_properties["align"]); } } else { $value = $row->getValue($list_attribute[$i]); if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj'])) { $input_obj_tmp = $this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj']; $input_obj_tmp->setValue($value); $value = $input_obj_tmp->getText(); } if (get_class($value) == "DateTime") { $value = $value->format("Y-m-d"); } $row_table->add(utf8encode($value)); } if ($hide_empty_fields && $value == '') { // Do not add the empty field } else { $this->table_from_sql_data_view->addRow($row_table); } if (isset($attribute_properties["row_id"]) && $attribute_properties["row_id"] != "") { $row_table->setId($attribute_properties["row_id"]); } else { $row_table->setId($i); } } return $it; }