/** * Constructor JavaScript * @param string $code_javascript * @param boolean $add_js_to_page [default value: false] */ function __construct($code_javascript, $add_js_to_page = false) { parent::__construct(); if (!isset($code_javascript)) { throw new NewException("1 argument for " . get_class($this) . "::__construct() is mandatory", 0, getDebugBacktrace(1)); } $this->code_javascript = $code_javascript; $this->is_javascript_object = true; if ($add_js_to_page) { $page_object = Page::getInstance($_GET['p']); if (gettype($code_javascript) != "object") { // search in javascript if begin by $(document).ready( // then put javascript to the end (for AJAX because doc is already loaded) $tmp_code_javascript = trim(str_replace("\t", "", $code_javascript)); $pos_doc_ready = find($tmp_code_javascript, "\$(document).ready(", 1); $pos_jquery_ready = find($tmp_code_javascript, "jQuery(document).ready(", 1); if ($pos_doc_ready >= 18 && $pos_doc_ready <= 30 || $pos_jquery_ready >= 23 && $pos_jquery_ready <= 35) { // 30|35: beacause of tag //<![CDATA[ $page_object->addObject($this, false, true); } else { $page_object->addObject($this); } } else { $page_object->addObject($this); } } }
/** * Constructor Hidden * @param mixed $page_or_form_object * @param string $name * @param string $id * @param string $value */ function __construct($page_or_form_object, $name = '', $id = '', $value = '') { parent::__construct(); if (!isset($page_or_form_object) || gettype($page_or_form_object) != "object" || !is_subclass_of($page_or_form_object, "Page") && get_class($page_or_form_object) != "Form") { throw new NewException("Argument page_or_form_object for " . get_class($this) . "::__construct() error", 0, getDebugBacktrace(1)); } if (is_subclass_of($page_or_form_object, "Page")) { $this->class_name = get_class($page_or_form_object); $this->page_object = $page_or_form_object; $this->form_object = null; } else { $this->page_object = $page_or_form_object->getPageObject(); $this->class_name = get_class($this->page_object) . "_" . $page_or_form_object->getName(); $this->form_object = $page_or_form_object; } if ($name == "") { $name = $this->page_object->createObjectName($this); $this->name = $name; } else { $exist_object = $this->page_object->existsObjectName($name); $this->name = $name; if ($exist_object != false) { throw new NewException("Tag name \"" . $name . "\" for object " . get_class($this) . " already use for other object " . get_class($exist_object), 0, getDebugBacktrace(1)); } $this->page_object->addEventObject($this, $this->form_object); } if ($id == "") { $this->id = $name; } else { $this->id = $id; } $this->value = $value; $this->default_value = $value; }
function decryptMessage($crypttext, $priv_key, $passphrase = 'passphrase') { $crypttext = base64_decode($crypttext); $res = openssl_pkey_get_private($priv_key, $passphrase); if ($res != false) { if (openssl_private_decrypt($crypttext, $text, $res)) { return $text; } else { $error = ""; while ($msg = openssl_error_string()) { $error .= $msg . "<br />\n"; } $error = __(DECRYPT_ERROR) . (DEBUG && $error != "" ? " : " . $error : ""); throw new NewException($error, 0, false); } } else { $error = ""; while ($msg = openssl_error_string()) { $error .= $msg . "<br />\n"; } $error = "Error parsing private key" . ($error != "" ? " : " . $error : ""); throw new NewException($error, 0, getDebugBacktrace(1)); } return ""; }
/** * Constructor DataRowIterator * @param mixed $db_table_object */ function __construct($db_table_object) { if (!isset($db_table_object)) { throw new NewException("1 argument for " . get_class($this) . "::__construct() is mandatory", 0, getDebugBacktrace(1)); } $this->db_table_object = $db_table_object; $this->rows_num = 0; }
/** * Constructor Url * @param mixed $url */ function __construct($url) { parent::__construct(); if (!isset($url)) { throw new NewException("1 argument for " . get_class($this) . "::__construct() is mandatory", 0, getDebugBacktrace(1)); } $this->url = $url; }
/** * Constructor Criteo * @param mixed $criteo_zone_id * @param string $width * @param string $height */ function __construct($criteo_zone_id, $width = '', $height = '') { parent::__construct(); if (!isset($criteo_zone_id)) { throw new NewException("1 argument for " . get_class($this) . "::__construct() is mandatory", 0, getDebugBacktrace(1)); } $this->criteo_zone_id = $criteo_zone_id; $this->width = $width; $this->height = $height; }
/** * Constructor DockMenuItem * @param mixed $img * @param mixed $value * @param string $link */ function __construct($img, $value, $link = '') { parent::__construct(); if (!isset($img) && !isset($value)) { throw new NewException("2 arguments for " . get_class($this) . "::__construct() are mandatory", 0, getDebugBacktrace(1)); } $this->img = $img; $this->value = $value; $this->link = $link; }
/** * Constructor VideoYoutube * @param mixed $youtube_video_key * @param integer $width * @param integer $height */ function __construct($youtube_video_key, $width, $height) { parent::__construct(); if (!isset($youtube_video_key) && !isset($width) && !isset($height)) { throw new NewException("3 arguments for " . get_class($this) . "::__construct() are mandatory", 0, getDebugBacktrace(1)); } $this->youtube_video_key = $youtube_video_key; $this->width = $width; $this->height = $height; }
/** * Method setMenuItems * @access public * @param mixed $menu_items_object * @return MenuItem * @since 1.0.35 */ public function setMenuItems($menu_items_object) { if (get_class($menu_items_object) != "MenuItems") { throw new NewException("Error MenuItem->setMenuItems(): {$menu_items_object} is not a MenuItems object", 0, getDebugBacktrace(1)); } $this->menu_items = $menu_items_object; if ($GLOBALS['__PAGE_IS_INIT__']) { $this->object_change = true; } return $this; }
/** * Constructor Adsense * @param mixed $google_ad_client * @param mixed $google_ad_slot * @param mixed $google_ad_width * @param mixed $google_ad_height */ function __construct($google_ad_client, $google_ad_slot, $google_ad_width, $google_ad_height) { parent::__construct(); if (!isset($google_ad_client) && !isset($google_ad_slot) && !isset($google_ad_width) && !isset($google_ad_height)) { throw new NewException("4 arguments for " . get_class($this) . "::__construct() are mandatory", 0, getDebugBacktrace(1)); } $this->google_ad_client = $google_ad_client; $this->google_ad_slot = $google_ad_slot; $this->google_ad_width = $google_ad_width; $this->google_ad_height = $google_ad_height; }
/** * Constructor Font * @param object $content_object * @param string $font_size * @param string $font_family * @param string $font_weight */ function __construct($content_object, $font_size = '', $font_family = '', $font_weight = '') { parent::__construct(); if (!isset($content_object)) { throw new NewException("1 argument for " . get_class($this) . "::__construct() is mandatory", 0, getDebugBacktrace(1)); } $this->content_object = $content_object; $this->font_size = $font_size; $this->font_family = $font_family; $this->font_weight = $font_weight; }
/** * Method askUserToSharePosition * @access public * @param boolean $refresh_page [default value: false] * @param string $js_onsuccess * @return GeoLocalisation * @since 1.0.98 */ public function askUserToSharePosition($refresh_page = false, $js_onsuccess = '') { $GLOBALS['__GEOLOC_ASK_USER_SHARE_POSITION__'] = true; if (gettype($js_onsuccess) != "string" && get_class($js_onsuccess) != "JavaScript") { throw new NewException(get_class($this) . "->askUserToSharePosition(): \$js_onsuccess must be a string or JavaScript object.", 0, getDebugBacktrace(1)); } if (get_class($js_onsuccess) == "JavaScript") { $js_onsuccess = $js_onsuccess->render(); } $_SESSION['geolocalisation_user_share_js'] = $js_onsuccess . ($refresh_page ? "refreshPage();" : ""); return $this; }
/** * Constructor SwfObject * @param string $id * @param string $swf_file * @param integer $width * @param integer $height * @param string $optional_text */ function __construct($id, $swf_file, $width, $height, $optional_text = '') { parent::__construct(); if (!isset($id) || !isset($swf_file) || !isset($width) || !isset($height)) { throw new NewException("4 arguments for " . get_class($this) . "::__construct() are mandatory", 0, getDebugBacktrace(1)); } $this->id = $id; $this->swf_file = $swf_file; $this->width = $width; $this->height = $height; $this->text = $optional_text; $this->addJavaScript(BASE_URL . "wsp/js/swfobject.js", "", true); }
/** * Method _open * @access static * @return mixed * @since 1.1.0 */ private static function _open() { $file = "wsp/wsp_banned_visitors"; $mode = 'a+'; $option_perms = 0666 & ~umask(); $mask = 0666 & ~$option_perms; $old_mask = umask($mask); $result = fopen($file, $mode); umask($old_mask); if (!$result) { throw new NewException("The WSP framework needs to create the file " . $file . ". Please give write rights on the folder or create manually the file (with write rights).", 0, getDebugBacktrace(1)); } return $result; }
/** * Constructor PaypalBuyCheck * @param mixed $amount * @param mixed $business_paypal_account */ function __construct($amount, $business_paypal_account) { if (!isset($amount) || !isset($business_paypal_account)) { throw new NewException("2 arguments for " . get_class($this) . "::__construct() are mandatories", 0, getDebugBacktrace(1)); } if (!is_numeric($amount)) { throw new NewException(get_class($this) . " error: \$amount need to be numeric.", 0, getDebugBacktrace(1)); } $this->amount = $amount; $this->business_paypal_account = $business_paypal_account; if (!extension_loaded("curl")) { throw new NewException("PaypalBuyCheck: You need to install PHP lib CURL.", 0, getDebugBacktrace(1)); } }
/** * Constructor ContactForm * @param Page $page_object * @param string $send_method * @param string $table_style */ function __construct($page_object, $send_method, $table_style = '') { parent::__construct(); if (!isset($page_object) || !isset($send_method)) { throw new NewException("2 arguments for " . get_class($this) . "::__construct() are mandatory", 0, getDebugBacktrace(1)); } if (gettype($page_object) != "object" || !is_subclass_of($page_object, "Page")) { throw new NewException("Argument page_object for " . get_class($this) . "::__construct() error", 0, getDebugBacktrace(1)); } $this->page_object = $page_object; $this->mail_to = SMTP_MAIL; $this->mail_to_name = SMTP_NAME; $table_main = new Table(); $table_main->setClass($table_style); $form = new Form($this->page_object); $name = new TextBox($form, "contact_name"); $name_validation = new LiveValidation(); $name->setLiveValidation($name_validation->addValidatePresence()->setFieldName(__(CONTACTFORM_NAME))); $table_main->addRowColumns(__(CONTACTFORM_NAME) . ": ", $name->setFocus())->setColumnWidth(2, "100%"); $email = new TextBox($form, "contact_email"); $email_validation = new LiveValidation(); $email->setLiveValidation($email_validation->addValidateEmail()->addValidatePresence()->setFieldName(__(CONTACTFORM_EMAIL))); $table_main->addRowColumns(__(CONTACTFORM_EMAIL) . ": ", $email); $subject = new TextBox($form, "contact_subject"); $subject_validation = new LiveValidation(); $subject->setLiveValidation($subject_validation->addValidatePresence()->setFieldName(__(CONTACTFORM_SUBJECT))); $table_main->addRowColumns(__(CONTACTFORM_SUBJECT) . ": ", $subject); $table_main->addRow(); $editor = new Editor($form, "contact_message"); $editor_validation = new LiveValidation(); $editor->setLiveValidation($editor_validation->addValidatePresence()->setFieldName(__(CONTACTFORM_MESSAGE))); $editor->setToolbar(Editor::TOOLBAR_SIMPLE); $table_main->addRow(new Object(__(CONTACTFORM_MESSAGE) . ": ", "<br/>", $editor))->setColspan(3)->setAlign(RowTable::ALIGN_LEFT); $table_main->addRow(); $this->captcha = new Captcha($form, "contact_captcha"); $table_main->addRow($this->captcha)->setColspan(3); $table_main->addRow(); $this->send_button = new Button($form, "contact_send", "", __(CONTACTFORM_SEND)); $this->send_button->assignEnterKey()->onClick($send_method)->setAjaxEvent(); $table_main->addRow($this->send_button)->setColspan(3); $table_main->addRow(); $form->setContent($table_main); $this->render = $form; }
/** * Constructor PhotoGallery * @param mixed $path * @param string $picture_ext [default value: jpg,jpeg,png,gif] * @param string $folder_pic [default value: wsp/img/folder_image_128x128.png] */ function __construct($path, $picture_ext = 'jpg,jpeg,png,gif', $folder_pic = 'wsp/img/folder_image_128x128.png') { parent::__construct(); if (!isset($path)) { throw new NewException("1 argument for " . get_class($this) . "::__construct() is mandatory", 0, getDebugBacktrace(1)); } $this->original_path = $path; if (isset($_GET['gallery_event'])) { $path = $path . $_GET['gallery_event']; } if (!is_dir($path)) { throw new NewException("Unable to find the path " . $path, 0, getDebugBacktrace(1)); } $this->path = $path; $this->picture_ext = explode(',', $picture_ext); $this->folder_pic = $folder_pic; $this->addCss(BASE_URL . "wsp/css/jquery.lightbox-0.5.css", "", true); $this->addCss(BASE_URL . "wsp/css/jquery.dataTables.css", "", true); $this->addJavaScript(BASE_URL . "wsp/js/jquery.lightbox-0.5.min.js", "", true); $this->addJavaScript(BASE_URL . "wsp/js/jquery.dataTables.min.js", "", true); }
/** * Method setAjaxWaitMessage * @access public * @param mixed $message_or_object * @return Authentication * @since 1.2.1 */ public function setAjaxWaitMessage($message_or_object) { if (gettype($message_or_object) == "object") { if (get_class($message_or_object) != "Object") { throw new NewException("Error " . get_class($this) . "->setAjaxWaitMessage(): \$message_or_object must be an Object and not " . get_class($message_or_object) . ".", 0, getDebugBacktrace(1)); } $message_or_object->hide(); } $this->ajax_wait_message = $message_or_object; $this->createRender(false); return $this; }
/** * Method add * @access public * @param string $js_url * @param string $conditional_comment * @param boolean $combine [default value: false] * @param string $js_script * @param boolean $async [default value: false] * @since 1.0.59 */ public function add($js_url, $conditional_comment = '', $combine = false, $js_script = '', $async = false) { if (!in_array($js_url, $this->js_scripts)) { $this->js_scripts[] = $js_url; $this->conditional_comment[] = $conditional_comment; $this->combine[] = $combine; if ($GLOBALS['__AJAX_PAGE__'] == true && $GLOBALS['__AJAX_LOAD_PAGE__'] == false && $GLOBALS['__PAGE_IS_INIT__'] == true) { $this->is_for_ajax[] = true; } else { $this->is_for_ajax[] = false; } if ($combine && $js_script != "") { throw new NewException(get_class($this) . "->add() error: you can't add script with combine mode", 0, getDebugBacktrace(1)); } $this->script[] = $js_script; $this->is_async[] = $async; } }
/** * Method getAjaxRender * @access public * @return string javascript code to update initial html of object RowTable (call with AJAX) * @since 1.0.85 */ public function getAjaxRender() { $html = ""; if ($this->object_change && !$this->is_new_object_after_init) { if ($this->id == "") { throw new NewException(get_class($this) . "->getAjaxRender() error: To update this object with Ajax event you must define an id (" . get_class($this) . "->setId())", 0, getDebugBacktrace(1)); } $html .= "\$('#wsp_rowtable_" . $this->id . "').html(\"" . str_replace("\n", "", str_replace("\r", "", addslashes($this->render(true)))) . "\");\n"; } return $html; }
/** * Method displayJavascriptTag * @access public * @return WebSitePhpObject * @since 1.0.35 */ public function displayJavascriptTag() { if (!$this->is_javascript_object) { throw new NewException("displayJavascriptTag Error : You display JavaScript tag only for Javascript object", 0, getDebugBacktrace(1)); } $this->display_javascript_tag = true; return $this; }
/** * Method setContextMenuOnTreeViewItem * @access public * @param ContextMenu $context_menu_object * @param TreeViewItem|TreeViewFolder|TreeViewFile|TreeView $treeview_item_object * @return TreeView * @since 1.0.35 */ public function setContextMenuOnTreeViewItem($context_menu_object, $treeview_item_object) { if (get_class($context_menu_object) != "ContextMenu") { throw new NewException("Error TreeView->setContextMenuOnTreeViewItem(): {$context_menu_object} is not a ContextMenu object", 0, getDebugBacktrace(1)); } if (get_class($treeview_item_object) != "TreeViewItem" && get_class($treeview_item_object) != "TreeViewFolder" && get_class($treeview_item_object) != "TreeViewFile" && get_class($treeview_item_object) != "TreeView") { throw new NewException("Error TreeView->setContextMenuOnTreeViewItem(): {$treeview_item_object} is not a TreeViewItem object", 0, getDebugBacktrace(1)); } if ($treeview_item_object->getParentTreeViewItem() == null) { throw new NewException("Error TreeView->setContextMenuOnTreeViewItem(): you must associate object " . get_class($treeview_item_object) . " to an other TreeViewItem before setting the ContextMenu", 0, getDebugBacktrace(1)); } $this->generateTreeViewIds(); $this->context_menu_item[$treeview_item_object->getId()] = $context_menu_object; return $this; }
/** * Method rounded * @access public * @return ToolTip * @since 1.1.0 */ public function rounded() { if (preg_match("/^(jtools|tipped)\$/", $this->style)) { throw new NewException("Error " . get_class($this) . ": The style \"" . $this->style . "\" is already rounded.", 0, getDebugBacktrace(1)); } $this->add_css = true; $this->rounded = true; return $this; }
/** * Method onDragEndJs * @access public * @param string|JavaScript $js_function * @return DraggableEvent * @since 1.0.35 */ public function onDragEndJs($js_function) { if (gettype($js_function) != "string" && get_class($js_function) != "JavaScript" && !is_subclass_of($js_function, "JavaScript")) { throw new NewException(get_class($this) . "->onDragEndJs(): \$js_function must be a string or JavaScript object.", 0, getDebugBacktrace(1)); } if (get_class($js_function) == "JavaScript" || is_subclass_of($js_function, "JavaScript")) { $js_function = $js_function->render(); } $this->ondragend = trim($js_function); if ($GLOBALS['__PAGE_IS_INIT__']) { $wsp_object = $this->getPage()->getObjectId($this->draggable_id); if ($wsp_object != null) { $wsp_object->forceAjaxRender(); } } return $this; }
/** * Method halt * @access public * @param string $message all occurred errors as array * @since 1.0.59 */ public function halt($message) { if ($this->debug) { throw new NewException($message . " (filename: " . $this->name . ")", 0, getDebugBacktrace(1)); } }
/** * Method render * @access public * @param boolean $ajax_render [default value: false] * @return string html code of object Box * @since 1.0.35 */ public function render($ajax_render = false) { $html = ""; if ($this->browser_ie_version != false && $this->browser_ie_version <= 7) { $this->shadow = false; } if ($this->force_box_with_picture) { $this->shadow = true; } if (!$ajax_render) { $html .= "<div id=\"wsp_box_" . $this->id . "\" class=\"\">\n"; } $html .= "<div id=\"drag_box_" . $this->id . "\" align=\"left\" class=\""; if ($this->move) { $html .= "draggable"; } $html .= "\""; if ($this->width != "" || $this->height != "") { $html .= " style=\""; if ($this->width != "") { if (is_integer($this->width)) { $html .= "width:" . $this->width . "px;"; } else { $html .= "width:" . $this->width . ";"; } } if ($this->height != "") { if (is_integer($this->height)) { $html .= "height:" . $this->height . "px;"; } else { $html .= "height:" . $this->height . ";"; } } $html .= "\""; } $html .= ">\n"; if (!$this->force_box_with_picture) { if (!$this->css3) { if ($this->browser_ie_version != false && $this->browser_ie_version <= 7) { // do nothing } else { $angle_class = "AngleRond" . ucfirst($this->style_header); $shadow_class = ""; $html .= "<div style=\"height:5px;"; if ($this->shadow) { $shadow_class = "Ombre"; $html .= "position: relative; top: -5px;"; } $html .= "\">\n"; $html .= "\t<b class=\"" . $angle_class . " pix1" . ucfirst($this->style_header) . $shadow_class . ($this->box_gradient ? " pix1Gradient" : "") . "\"></b>\n"; $html .= "\t<b class=\"" . $angle_class . " pix2" . $shadow_class . ($this->box_gradient ? " pix2Gradient" : "") . "\"></b>\n"; $html .= "\t<b class=\"" . $angle_class . " pix3" . $shadow_class . ($this->box_gradient ? " pix3Gradient" : "") . "\"></b>\n"; $html .= "\t<b class=\"" . $angle_class . " pix4" . $shadow_class . ($this->box_gradient ? " pix4Gradient" : "") . "\"></b>\n"; $html .= "\t<b class=\"" . $angle_class . " pix5" . $shadow_class . ($this->box_gradient ? " pix5Gradient" : "") . "\"></b>\n"; $html .= "</div>\n"; } if ($this->shadow) { $html .= "\t<div class=\"ombre" . ucfirst($this->style_header) . "\">\n"; } $html .= "\t\t<div"; if ($this->shadow) { $html .= " class=\"boiteTxt\""; } $html .= " >\n"; } $html .= "\t\t\t<table class=\"table_" . $this->style_header . "_angle BoxOverFlowHidden"; if ($this->css3) { $html .= " Css3RadiusBox" . $this->style_header; if ($this->shadow) { $html .= " Css3ShadowBox" . $this->style_header; } } $html .= "\" cellpadding=\"0\" cellspacing=\"0\""; if ($this->height != "") { $html .= " height=\"" . $this->height . "\""; } $html .= " style=\"table-layout:fixed;" . ($this->browser_ie_version != false && $this->browser_ie_version <= 7 ? "border-top:1px solid " . $this->box_border_color . ";" : "") . "\">\n"; $html .= "\t\t\t\t<tr>\n"; $html .= "\t\t\t\t\t<td class=\"header_" . $this->style_header . "_bckg header_" . $this->style_header . "_bckg_a"; if ($this->css3) { $html .= " Css3RadiusBoxTitle" . $this->style_header; if ($this->box_gradient) { $html .= " Css3GradientBoxTitle" . $this->style_header; } } $html .= "\""; if (!$this->css3) { $html .= " style=\"padding: " . ($this->browser_ie_version != false ? $this->browser_ie_version != false && $this->browser_ie_version <= 7 ? 4 : 0 : 2) . "px 0px 4px 5px;\""; } $html .= ">"; if ($this->icon_48_pixels != "") { $html .= "<table cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"width:48px;\"><span style=\"position:absolute;margin-top:-24px;margin-left:-2px;\">"; $html .= "<img src=\"" . $this->icon_48_pixels . "\" height=\"48\" width=\"48\""; if ($this->icon_48_pixels_text != "") { $html .= " title=\"" . str_replace("\"", " ", $this->icon_48_pixels_text) . "\" alt=\"" . str_replace("\"", " ", $this->icon_48_pixels_text) . "\""; } $html .= "></span></td><td>"; } if ($this->icon_16_pixels != "") { $html .= "<img src=\"" . $this->icon_16_pixels . "\" height=\"16\" width=\"16\" style=\"vertical-align: middle;\""; if ($this->icon_16_pixels_text != "") { $html .= " title=\"" . str_replace("\"", " ", $this->icon_16_pixels_text) . "\" alt=\"" . str_replace("\"", " ", $this->icon_16_pixels_text) . "\""; } $html .= "> "; } if ($this->tagH != "") { $html .= "<" . $this->tagH . " style=\"font-weight:bold;\">"; } if ($this->link != "") { $html .= "<a href=\"" . $this->link . "\">"; } if (gettype($this->title) != "object") { $html .= $this->title; } else { if (gettype($this->title) == "object" && method_exists($this->title, "render")) { $html .= $this->title->render(); } else { $html .= $this->title; } } if ($this->link != "") { $html .= "</a>"; } if ($this->tagH != "") { $html .= "</" . $this->tagH . ">"; } if ($this->icon_48_pixels != "") { $html .= "</td></tr></table>"; } $html .= "</td>\n"; $html .= "\t\t\t\t</tr>\n"; $html .= "\t\t\t\t<tr id=\"" . $this->id . "\">\n"; $html .= "\t\t\t\t\t<td class=\"table_" . $this->style_content . "_bckg\" width=\"9999\" valign=\"" . $this->valign . "\" style=\"height:100%;padding:4px;border-top:1px solid " . $this->box_border_color . ";\">\n"; $html .= "\t\t\t\t\t\t<div "; if ($this->align == Box::ALIGN_JUSTIFY) { $html .= "style=\"text-align:justify;\" "; } else { $html .= "align=\"" . $this->align . "\" "; } $html .= ">\n"; if ($this->content != null) { if (gettype($this->content) == "object" && method_exists($this->content, "render")) { $html_content = $this->content->render($ajax_render); } else { $html_content = $this->content; } /*if (find($html_content, "<a href=") > 0) { $html .= " ".str_replace("<a href=\"", "<a class=\"box_style_".$this->style_content."\" href=\"", str_replace("<a href='", "<a class='box_style_".$this->style_content."' href='", $html_content))."\n"; $html .= $this->getJavascriptTagOpen(); $html .= "$('.box_style_".$this->style_content."').each(function() { if ($(this).parent().hasClass('ui-state-default') || (!$(this).parent().hasClass('ui-state-default') && $(this).parent().parent().hasClass('ui-state-default'))) { $(this).removeClass('box_style_".$this->style_content."'); } });\n"; $html .= $this->getJavascriptTagClose(); } else {*/ $html .= "\t\t\t\t\t\t" . $html_content . "\n"; //} } $html .= "\t\t\t\t\t\t</div>\n"; $html .= "\t\t\t\t\t</td>\n"; $html .= "\t\t\t\t</tr>\n"; $html .= "\t\t\t</table>\n"; if (!$this->css3) { $html .= "\t\t</div>\n"; if ($this->shadow) { $html .= "\t</div>\n"; } } } else { $html .= "\t\t<div id=\"left" . ucfirst($this->style_header) . "\">\n"; $html .= "\t\t\t<div id=\"right" . ucfirst($this->style_header) . "\" style=\"padding-bottom:" . ($this->browser_ie_version <= 7 ? 5 : 3) . "px;"; if ($this->height != "") { $html .= "height:100%;"; } $html .= "\">\n"; $html .= "\t\t\t\t<div id=\"top" . ucfirst($this->style_header) . "\">\n"; $html .= "\t\t\t\t\t<div style=\"height:30px;\"></div>\n"; $html .= "\t\t\t\t</div>\n"; $html .= "\t\t\t\t<div class=\"header_" . $this->style_header . "_bckg header_" . $this->style_header . "_bckg_a\" style=\"background:none;padding-bottom:3px;position:relative;top:-20px;height:0px;\">"; if ($this->icon_48_pixels != "") { $html .= "<img src=\"" . $this->icon_48_pixels . "\" height=\"48\" width=\"48\" style=\"position:absolute;top:-16px;left:-4px;\""; if ($this->icon_48_pixels_text != "") { $html .= " title=\"" . str_replace("\"", " ", $this->icon_48_pixels_text) . "\" alt=\"" . str_replace("\"", " ", $this->icon_48_pixels_text) . "\""; } $html .= "><span style=\"width:40px;display:block;float:left;height:1px;\"> </span>"; } if ($this->icon_16_pixels != "") { $html .= "<img src=\"" . $this->icon_16_pixels . "\" height=\"16\" width=\"16\" style=\"vertical-align: middle;\""; if ($this->icon_16_pixels_text != "") { $html .= " title=\"" . str_replace("\"", " ", $this->icon_16_pixels_text) . "\" alt=\"" . str_replace("\"", " ", $this->icon_16_pixels_text) . "\""; } $html .= "> "; } if ($this->tagH != "") { $html .= "<" . $this->tagH . " style=\"font-weight:bold;\">"; } if ($this->link != "") { $html .= "<a href=\"" . $this->link . "\">"; } if (gettype($this->title) != "object") { $html .= $this->title; } else { if (gettype($this->title) == "object" && method_exists($this->title, "render")) { $html .= $this->title->render(); } else { $html .= $this->title; } } if ($this->link != "") { $html .= "</a>"; } if ($this->tagH != "") { $html .= "</" . $this->tagH . ">"; } $html .= "\t\t\t\t</div>\n"; $html .= "\t\t\t\t<div style=\"clear:both;margin-left:" . ($this->browser_ie_version != false && $this->browser_ie_version > 7 ? -9 : -7) . "px;\">\n"; $html .= "\t\t\t\t<div id=\"wsp_box_content_" . $this->id . "\" class=\"table_" . $this->style_content . "_bckg\" style=\"padding-left:0px;border:1px solid " . $this->box_border_color . ";"; $html .= "display:table-cell;"; if (is_integer($this->width)) { $html .= "width:" . ($this->width - 12) . "px;"; } else { throw new NewException("width attribute in " . get_class($this) . " must be an integer", 0, getDebugBacktrace(1)); } if ($this->valign == Box::VALIGN_CENTER) { $html .= "vertical-align:middle;"; } else { $html .= "vertical-align:" . $this->valign . ";"; } if ($this->height != "") { if (is_integer($this->height)) { $html .= "height:" . ($this->height - 20) . "px;"; } else { $html .= "height:" . $this->height . ";"; } } $html .= "\">\n"; if ($this->height != "" && is_integer($this->height) && $this->valign == RoundBox::VALIGN_CENTER) { $html .= "<div style=\"display:table;height:100%;#position:relative;width:100%;\" class=\"BoxOverFlowHidden\">\n"; $html .= "\t<div style=\"#position:absolute;#top:50%;display:table-cell;vertical-align:middle;width:100%;\">\n"; $html .= "\t\t<div style=\"#position:relative;#top:-50%;\">\n"; } $html .= "\t\t\t\t\t<div"; if ($this->align == Box::ALIGN_JUSTIFY) { $html .= " style=\"width:98%;text-align:justify;"; } else { $html .= " align=\"" . $this->align . "\" style=\"width:98%;"; } $html .= "margin:5px;padding-right:5px;\">\n"; if ($this->content != null) { if (gettype($this->content) == "object" && method_exists($this->content, "render")) { $html_content = $this->content->render($ajax_render); } else { $html_content = $this->content; } /*if (find($html_content, "<a href=") > 0) { $html .= " ".str_replace("<a href=\"", "<a class=\"box_style_".$this->style_content."\" href=\"", str_replace("<a href='", "<a class='box_style_".$this->style_content."' href='", $html_content))."\n"; $html .= $this->getJavascriptTagOpen(); $html .= "$('.box_style_".$this->style_content."').each(function() { if ($(this).parent().hasClass('ui-state-default') || (!$(this).parent().hasClass('ui-state-default') && $(this).parent().parent().hasClass('ui-state-default'))) { $(this).removeClass('box_style_".$this->style_content."'); } });\n"; $html .= $this->getJavascriptTagClose(); } else {*/ $html .= "\t\t\t\t\t\t" . $html_content . "\n"; //} } $html .= "\t\t\t\t</div>\n"; if ($this->height != "" && is_integer($this->height) && $this->valign == RoundBox::VALIGN_CENTER) { $html .= "\t\t</div>\n"; $html .= "\t</div>\n"; $html .= "</div>\n"; } $html .= "\t\t\t\t</div>\n"; $html .= "\t\t\t\t</div>\n"; $html .= "\t\t\t</div>\n"; $html .= "\t\t</div>\n"; } $html .= "</div>\n"; if (!$ajax_render) { $html .= "</div>\n"; } $html .= "<br/>\n"; if ($this->move) { $html .= $this->getJavascriptTagOpen(); $html .= "\$(\"#wsp_box_" . $this->id . "\").draggable({opacity: 0.8, scroll: true"; if ($this->move_revert) { $html .= ", revert: true"; } $html .= "});\n"; if ($this->resizable) { $html .= "\$(\"#drag_box_" . $this->id . "\").resizable();\n"; $html .= "\$(\"#drag_box_" . $this->id . "\").find('.ui-resizable-e').remove();\n"; $html .= "\$(\"#drag_box_" . $this->id . "\").find('.ui-resizable-s').remove();\n"; $html .= "\$(\"#drag_box_" . $this->id . "\").find('.ui-resizable-se').remove();\n"; } $html .= $this->getJavascriptTagClose(); } $this->object_change = false; return $html; }
/** * Method getAjaxRender * @access public * @return string javascript code to update initial html of object TreeViewItem (call with AJAX) * @since 1.0.35 */ public function getAjaxRender() { $html = ""; if ($this->object_change && !$this->is_new_object_after_init) { $treeview_object = $this->getTreeViewObject(); $treeview_object->generateTreeViewIds(); $old_value = $this->old_value; $old_value_id = $this->old_value; if (gettype($this->old_value) == "object") { if (in_array(get_class($this->old_value), $this->array_object_ok)) { if (get_class($this->old_value) == "Button") { $this->old_value->forceSpanTag(); } $old_value = $this->old_value->render($ajax_render); $old_value_id = $this->old_value->getValue(); } else { throw new NewException("Error TreeViewItem: value need to be a string, " . implode(", ", $array_object_ok), 0, getDebugBacktrace(1)); } } $value = $this->value; $value_id = $this->value; if (gettype($this->value) == "object") { if (in_array(get_class($this->value), $this->array_object_ok)) { if (get_class($this->value) == "Button") { $this->value->forceSpanTag(); } $value = $this->value->render($ajax_render); $value_id = $this->value->getValue(); } else { throw new NewException("Error TreeViewItem: value need to be a string, " . implode(", ", $array_object_ok), 0, getDebugBacktrace(1)); } } $id = $this->getId(); if ($old_value_id != $value_id) { $tmp_node_id = substr($id, strlen($id) - strlen($value_id), strlen($id)); $id = str_replace($tmp_node_id, strtolower(str_replace(" ", "_", str_replace("-", "_", url_rewrite_format($old_value_id)))), $id); } $html .= "\$('#" . $id . "_id').parent(\"span\").parent(\"li\").removeClass(\"closed\")"; if ($this->is_close) { $html .= ".addClass(\"closed\")"; } $html .= ";"; if ($value != $old_value) { $html .= "\$('#" . $id . "_id').html(\" " . str_replace("\n", "", str_replace("\r", "", str_replace('"', '\\"', addslashes($value)))) . "\");"; $html .= "\$('#" . $id . "_id').attr(\"id\", \"" . $this->getId() . "_id\");"; $html .= "\$('#" . $id . "').attr(\"id\", \"" . $this->getId() . "\");"; $html .= $this->generateHtmlChangeSubItemId($this, strlen($this->getId()), $id); } } return $html; }
/** * Method setField * @access public * @param mixed $attribute_name * @param mixed $field * @return boolean * @since 1.2.1 */ public function setField($attribute_name, $field) { if (!in_array(get_class($field), $this->objects_ok_array)) { throw new NewException(get_class($this) . "->setField() error: field need to be " . implode(", ", $this->objects_ok_array) . ".", 0, getDebugBacktrace(1)); } if (in_array(get_class($this->fields_array[$attribute_name]), $this->objects_ok_array)) { $this->fields_array[$attribute_name] = $field; return true; } return false; }
/** * Method getObjectEventValidationRender * @access protected * @param string $on_event * @param string $callback * @param string $params * @param boolean $abort_last_request [default value: false] * @return string * @since 1.0.35 */ protected function getObjectEventValidationRender($on_event, $callback, $params = '', $abort_last_request = false) { if ($callback != "" && $this->form_object == null && (isset($_GET['dialogbox_level']) || isset($_GET['tabs_object_id']))) { if (get_class($this) == "Button" && $this->is_link || get_class($this) == "Picture" || get_class($this) == "SortableEvent" || get_class($this) == "ContextMenuEvent" || get_class($this) == "DroppableEvent" || get_class($this) == "UploadFile") { // it's ok for these cases } else { throw new NewException("Object " . get_class($this) . " must link to a Form Object when he have a callback method in a DialogBox or a Tabs", 0, getDebugBacktrace(1)); } } $html = ""; if ($this->on_form_is_changed_js != "" && $this->form_object != null && get_class($this->form_object) == "Form") { $obj_id = $this->getId(); if (get_class($this) == "ComboBox" || get_class($this) == "SelectList") { $obj_id = $this->getEventObjectName(); } $html .= "if (\$('#" . $this->form_object->getId() . "_WspFormChange').val() != ';" . $obj_id . ";') { "; if ($this->on_form_is_changed_revert) { $html .= "revertLastFormChangeObjectToDefaultValue('" . get_class($this) . "', '" . $obj_id . "', '" . $this->form_object->getId() . "');"; } $html .= $this->on_form_is_changed_js . " }\n"; } if ($on_event != "" || $callback != "") { // force Editor copy to Hidden $js_force_editor_copy = ""; $event_object_name = "Editor"; if ($this->form_object != null) { $event_object_name .= "_" . $this->form_object->getName(); } $eventObject = $this->page_object->getEventObjects($event_object_name); for ($i = 0; $i < sizeof($eventObject); $i++) { $object = $eventObject[$i]; $js_force_editor_copy .= "copyEditorContent_" . $object->getName() . "ToHidden();"; } if (get_class($this) == "Object") { $html .= "stopEventPropagation(event);\n"; } $html = $html . $js_force_editor_copy; // object encryption $encrypt_html = ""; for ($i = 0; $i < sizeof($_SESSION['websitephp_register_object']); $i++) { $object = $_SESSION['websitephp_register_object'][$i]; if (get_class($object) != "Form" && method_exists($object, "isEncrypted") && $object->isEncrypted()) { $tmp_object = $object; if (get_class($tmp_object) == "Editor") { $object = $this->page_object->getObjectId($tmp_object->getHiddenId()); } if ($this->is_ajax_event) { $encrypt_html .= "encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . "[encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . ".length] = new Array();\n"; $encrypt_html .= "encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . "[encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . ".length-1][0] = '" . $object->getId() . "';\n"; $encrypt_html .= "encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . "[encryptedObjectValueArray" . get_class($this) . "_" . $this->getEventObjectName() . ".length-1][1] = \$('#" . $object->getId() . "').val();\n"; } if (get_class($tmp_object) == "Editor") { $encrypt_html .= $this->encryptObjectData($object, '', $tmp_object); } else { $encrypt_html .= $this->encryptObjectData($object); } $encrypt_html .= "\$('#" . $object->getName() . "').val(encrypt_data);\n"; } } if ($callback != "") { $html .= "ResetCallbackObjectValue();\n\$('#Callback_" . $this->getEventObjectName() . "').val('" . $callback . "(" . $params; if ($this->callback_args != "") { if ($params != "") { $html .= ","; } $html .= $this->callback_args; } $html .= ")');\n"; } if ($this->is_ajax_event && $callback != "" || $this->form_object != null && $callback != "" || $callback != "") { $html .= "if (\$('#Callback_" . $this->getEventObjectName() . "').val() == '') { return false; }\n"; } if ($on_event != "" || $this->is_ajax_event) { if ($on_event != "") { $html .= str_replace("\"", "\\\"", $on_event); if ($on_event[strlen($on_event) - 1] != ";") { $html .= ";"; } $html .= "\n"; } if ($callback != "") { if ($this->is_ajax_event) { $html .= $encrypt_html; $html .= "callAjax" . get_class($this) . "_" . $this->getEventObjectName() . "_event(\$('#Callback_" . $this->getEventObjectName() . "').val(), " . ($abort_last_request ? "true" : "false") . ");\n"; } else { if ($this->form_object != null) { $html .= $encrypt_html; $html .= "\$('#" . $this->form_object->getId() . "').submit();\n"; } else { $html .= "location.href='" . $this->generateCurrentUrlWithCallback() . "';\n"; } } } } else { if ($this->form_object != null) { $html .= $encrypt_html; $html .= "\$('#" . $this->form_object->getId() . "').submit();\n"; } else { if ($callback != "") { $html .= "location.href='" . $this->getPage()->getBaseURL() . "/" . $this->generateCurrentUrlWithCallback() . "';\n"; } } } } return $html; }
/** * Method render * @access public * @param boolean $ajax_render [default value: false] * @return string html code of object LiveValidation * @since 1.0.35 */ public function render($ajax_render = false) { if (!isset($this->object)) { throw new NewException("1 argument for " . get_class($this) . "::__construct() is mandatory", 0, getDebugBacktrace(1)); } if (get_class($this->object) == "Form") { return; } $html = $this->getJavascriptTagOpen(); if (get_class($this->object) == "Editor") { $id = $this->object->getHiddenId(); } else { $id = $this->object->getId(); } $html .= "\tLV_" . $id . " = new LiveValidation('" . $id . "'"; if ($this->onlyOnSubmit) { $html .= ", {onlyOnSubmit: true}"; } $html .= ");\n"; $html .= "\tLV_" . $id . $this->validate_js . ";\n"; if ($this->valid_init) { $html .= "\tLV_" . $id . ".validate();\n"; } if (method_exists($this->object, "getFormObject")) { $form_object = $this->object->getFormObject(); if ($form_object != null) { // search all button of the form $event_object_name = "Button_" . $form_object->getName(); $eventObject = $form_object->getPageObject()->getEventObjects($event_object_name); for ($i = 0; $i < sizeof($eventObject); $i++) { if (find($eventObject[$i]->getOnClickJs(), "/*LV_condition_zone*/", 0, 0) > 0) { $eventObject[$i]->onClickJs(str_replace("/*LV_validate_zone*/", "LV_" . $id . ".validate();/*LV_validate_zone*/", $eventObject[$i]->getOnClickJs())); $eventObject[$i]->onClickJs(str_replace("/*LV_condition_zone*/", "&&LiveValidationForm_" . $form_object->getName() . "_" . $id . "()/*LV_condition_zone*/", $eventObject[$i]->getOnClickJs())); } else { $html .= "\tlv_error_alert_id = '';\n\tlv_error_alert_field_name = '';\n\tlv_error_alert_msg = '';\n\tLV_ErrorAlert_" . $form_object->getName() . " = function() { "; $error_dialogbox_msg = new DialogBox(__(ERROR), __(LIVE_VALIDATION_FORMULAR_ERROR_MSG)); $error_dialogbox_msg->activateCloseButton("\$('#'+lv_error_alert_id).focus();"); $error_dialogbox_field = new DialogBox(__(ERROR), __(LIVE_VALIDATION_FORMULAR_FIELD_ERROR)); $error_dialogbox_field->activateCloseButton("\$('#'+lv_error_alert_id).focus();"); if (DEBUG) { $error_dialogbox = new DialogBox(__(ERROR), __(LIVE_VALIDATION_FORMULAR_ERROR_DEBUG)); } else { $error_dialogbox = new DialogBox(__(ERROR), __(LIVE_VALIDATION_FORMULAR_ERROR)); } $error_dialogbox->activateCloseButton(); $html .= "\tif (lv_error_alert_msg != '') {\n"; $html .= "\t\t" . $error_dialogbox_msg->render() . "\n"; $html .= "\t} else if (lv_error_alert_field_name != '') {\n"; $html .= "\t\t" . $error_dialogbox_field->render(); $html .= "\t} else {\n"; $html .= "\t\t" . $error_dialogbox->render() . "\n"; $html .= "\t}\n"; $html .= " };\n"; $eventObject[$i]->onClickJs("LV_" . $id . ".validate();/*LV_validate_zone*/if(LiveValidationForm_" . $form_object->getName() . "_" . $id . "()/*LV_condition_zone*/){" . $eventObject[$i]->getOnClickJs() . "}else{LV_ErrorAlert_" . $form_object->getName() . "();return false;}"); } } $html .= "\tLiveValidationForm_" . $form_object->getName() . "_" . $id . " = function() {\n"; $html .= "\t\tif (\$('#" . $id . "').attr('disabled')) {\n"; $html .= "\t\t\treturn true;\n"; $html .= "\t\t} else {\n"; $html .= "\t\t\tvar valid=(LV_" . $id . ".message!='Thankyou!'||LV_" . $id . ".message==null)?false:true;\n"; $html .= "\t\t\tif (valid) return true;\n"; $html .= "\t\t\tlv_error_alert_id = '" . $id . "';\n"; if ($this->field_name != "") { $html .= "\t\t\tlv_error_alert_field_name = '" . addslashes($this->field_name) . "';\n"; } else { $html .= "\t\t\tlv_error_alert_field_name = '';\n"; } if ($this->alert_msg != "") { $html .= "\t\t\tlv_error_alert_msg = '" . addslashes($this->alert_msg) . "';\n"; } else { $html .= "\t\t\tlv_error_alert_msg = '';\n"; } $html .= "\t\t\treturn false;\n"; $html .= "\t\t}\n"; $html .= "\t};\n"; } else { throw new NewException("To use LineValidation for object " . get_class($this->object) . " you must add him in a form (form object is null).", 0, getDebugBacktrace(1)); } } else { throw new NewException("LineValidation error: method getFormObject is missing for object " . get_class($this->object) . ".", 0, getDebugBacktrace(1)); } $html .= $this->getJavascriptTagClose(); $this->object_change = false; return $html; }