Beispiel #1
0
 /**
  * Method getAjaxRender
  * @access public
  * @return string javascript code to update initial html of object Table (call with AJAX)
  * @since 1.0.93
  */
 public function getAjaxRender()
 {
     $html = "";
     if ($this->object_change && !$this->is_new_object_after_init) {
         if ($this->ajax_refresh_all_table) {
             // refresh all table
             if ($this->is_advance_table || is_browser_ie() && get_browser_ie_version() < 8) {
                 $html .= "var my_parent_node = \$('#" . $this->id . "').parent();";
             } else {
                 $html .= "var my_parent_node = \$('#" . $this->id . "');";
             }
             $html .= "my_parent_node.empty();";
             $array_ajax_render = extract_javascript($this->render(false));
             for ($j = 1; $j < sizeof($array_ajax_render); $j++) {
                 new JavaScript($array_ajax_render[$j], true);
             }
             if (trim($array_ajax_render[0]) != "") {
                 $html .= "my_parent_node.append('" . str_replace("\n", "", str_replace("\r", "", addslashes($array_ajax_render[0]))) . "');";
             }
         } else {
             for ($i = 0; $i < sizeof($this->rows); $i++) {
                 if ($this->rows[$i]->isNew()) {
                     $array_ajax_render = extract_javascript($this->rows[$i]->render(false));
                     for ($j = 1; $j < sizeof($array_ajax_render); $j++) {
                         new JavaScript($array_ajax_render[$j], true);
                     }
                     $html .= "\$('#" . $this->id . "').append('" . str_replace("\n", "", str_replace("\r", "", addslashes($array_ajax_render[0]))) . "');";
                 } else {
                     if ($this->rows[$i]->isDeleted()) {
                         $html .= "\$('#wsp_rowtable_" . $this->rows[$i]->getId() . "').remove();";
                     }
                 }
             }
         }
     }
     if ($html != "" && $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));
     }
     return $html;
 }
Beispiel #2
0
 /**
  * Method enableThirdPartyCookiesFilter
  * @access public
  * @param string $disabled_services_rgb [default value: 48,48,48]
  * @param string $color_text [default value: white]
  * @param string $position [default value: bottom]
  * @param boolean $adblocker [default value: true]
  * @param boolean $cookieslist [default value: true]
  * @return Page
  * @since 1.2.13
  */
 public function enableThirdPartyCookiesFilter($disabled_services_rgb = '48,48,48', $color_text = 'white', $position = 'bottom', $adblocker = true, $cookieslist = true)
 {
     if ($this->cookies_accept_message) {
         throw new NewException("The cookies accept message is already activated. You cannot used the third party cookies filter feature.", 0, getDebugBacktrace(1));
     }
     $this->third_party_cookies_filter = true;
     $this->third_party_cookies_filter_position = $position;
     $this->third_party_cookies_filter_adblocker = $adblocker;
     $this->third_party_cookies_filter_cookieslist = $cookieslist;
     if (!$this->isAjaxPage() && !$this->isAjaxLoadPage()) {
         JavaScriptInclude::getInstance()->add("wsp/js/tarteaucitron/tarteaucitron.js");
         if ($disabled_services_rgb != "" && $disabled_services_rgb != "48,48,48") {
             $is_ie8 = false;
             if (is_browser_ie() && get_browser_ie_version() < 9) {
                 $is_ie8 = true;
             }
             $this->addObject(new JavaScript("var rgb = '" . $disabled_services_rgb . "';var colorText = '" . $color_text . "';\nvar customTheme = document.createElement('style'),\ncssRule = '#tarteaucitron #tarteaucitronServices .tarteaucitronMainLine .tarteaucitronName a, #tarteaucitron #tarteaucitronServices .tarteaucitronTitle a {color: ' + colorText + ' !important}#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronCookiesListMain:hover, #tarteaucitron #tarteaucitronServices .tarteaucitronLine:hover {background: " . ($is_ie8 ? "rgb" : "rgba") . "(' + rgb + '" . ($is_ie8 ? "" : ", 0.20") . ") !important;}#tarteaucitron #tarteaucitronServices .tarteaucitronHidden, #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronHidden {background: " . ($is_ie8 ? "rgb" : "rgba") . "(' + rgb + '" . ($is_ie8 ? "" : ", 0.07") . ") !important}#tarteaucitron .tarteaucitronBorder, #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronCookiesListMain, #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList, #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronHidden, #tarteaucitron #tarteaucitronServices .tarteaucitronMainLine {border-color:rgb(' + rgb + ') !important}#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronCookiesListMain, #tarteaucitron #tarteaucitronServices .tarteaucitronLine {background: " . ($is_ie8 ? "rgb" : "rgba") . "(' + rgb + '" . ($is_ie8 ? "" : ", 0.1") . ") !important}#tarteaucitron #tarteaucitronServices .tarteaucitronMainLine .tarteaucitronName b, #tarteaucitronAlertBig #tarteaucitronDisclaimerAlert b, #tarteaucitronAlertSmall #tarteaucitronCookiesNumber, #tarteaucitronAlertSmall #tarteaucitronManager, #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesTitle b, #tarteaucitron #tarteaucitronInfo a {color:' + colorText + ' !important}#tarteaucitron #tarteaucitronServices .tarteaucitronMainLine, #tarteaucitronAlertBig, #tarteaucitronAlertBig #tarteaucitronDisclaimerAlert, #tarteaucitronAlertSmall, .tac_activate, .tac_activate .tac_float, .tac_activate .tac_float b, #tarteaucitron #tarteaucitronClosePanel, #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronClosePanelCookie, #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesTitle, #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesTitle:hover, #tarteaucitron #tarteaucitronInfo, #tarteaucitron #tarteaucitronServices .tarteaucitronDetails, #tarteaucitron #tarteaucitronServices .tarteaucitronTitle, #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronTitle, #tarteaucitron #tarteaucitronServices .tarteaucitronMainLine:hover {background: rgb(' + rgb + ') !important;color:' + colorText + ' !important}#tarteaucitronAlertBig #tarteaucitronCloseAlert {color: rgb(' + rgb + ') !important;background:' + colorText + ' !important}';\ncustomTheme.type = 'text/css';\nif (customTheme.styleSheet) {\n    customTheme.styleSheet.cssText = cssRule;\n} else {\n    customTheme.appendChild(document.createTextNode(cssRule));\n}\ndocument.getElementsByTagName('body')[0].appendChild(customTheme)"), true);
         }
     }
     return $this;
 }
Beispiel #3
0
 private function changeStyleSheetProperty($css_file_name, $array_properties, $property, $value, $display_rule_error = true)
 {
     for ($i = 0; $i < sizeof($array_properties); $i++) {
         if (is_browser_ie() && get_browser_ie_version() < 9) {
             $array_sub_properties = split(',', $array_properties[$i]);
         } else {
             $array_sub_properties = array($array_properties[$i]);
         }
         for ($j = 0; $j < sizeof($array_sub_properties); $j++) {
             $this->addObject(new JavaScript("changeStyleSheetProperty('" . $css_file_name . "', '" . $array_sub_properties[$j] . "', '" . $property . "', '" . addslashes($value) . "', " . ($display_rule_error ? "true" : "false") . ");"));
         }
     }
 }
Beispiel #4
0
 /**
  * Method getStyle
  * @access public
  * @return mixed
  * @since 1.2.13
  */
 public function getStyle()
 {
     $html = "";
     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 . ";";
         }
     }
     if ($this->font_size != "") {
         if (is_integer($this->font_size)) {
             $html .= "font-size:" . $this->font_size . "pt;";
         } else {
             $html .= "font-size:" . $this->font_size . ";";
         }
     }
     if ($this->font_family != "") {
         $html .= "font-family:" . $this->font_family . ";";
     }
     if ($this->font_weight != "") {
         $html .= "font-weight:" . $this->font_weight . ";";
     }
     if ($this->border != "") {
         $html .= "border:";
         if (is_integer($this->border)) {
             $html .= $this->border . "px";
         } else {
             $html .= $this->border;
         }
         $html .= " " . $this->border_style . " " . $this->border_color . ";";
     }
     if ($this->hide_object) {
         $html .= "display:none;";
     }
     if ($this->min_height != "") {
         $html .= "min-height: " . $this->min_height . "px;height: expression(this.scrollHeight < " . $this->min_height . " ? '" . $this->min_height . "px' : 'auto');";
     } else {
         if ($this->droppable || $this->sortable) {
             $html .= "min-height: 24px;height: expression(this.scrollHeight < 22 ? '24px' : 'auto');";
         }
     }
     if ($this->max_height != "") {
         $html .= "max-height: " . $this->max_height . "px;overflow:auto;" . (is_browser_ie() ? "overflow-x:scroll;" : "") . "height: expression(this.scrollHeight > " . $this->max_height . " ? '" . $this->max_height . "px' : 'auto');";
     }
     if ($this->droppable || $this->sortable) {
         $html .= "min-width: 24px;width: expression(this.scrollWidth < 26 ? '26px' : 'auto');";
     }
     if ($this->style != "") {
         $html .= $this->style;
     }
     return $html;
 }
Beispiel #5
0
 /**
  * Method render
  * @access public
  * @param boolean $ajax_render [default value: false]
  * @return string html code of object UploadFile
  * @since 1.2.3
  */
 public function render($ajax_render = false)
 {
     $html = "";
     // check if the UploadFile is linked to a Form with Ajax button
     if ($this->form_object != null) {
         $array_form_object = $this->form_object->getFormObjects();
         for ($i = 0; $i < sizeof($array_form_object); $i++) {
             if (get_class($array_form_object[$i]) == "Button") {
                 if ($array_form_object[$i]->isAjaxEvent()) {
                     throw new NewException(get_class($this) . " error: You cannot use ajax event on a Button if you include " . get_class($this) . " in a Form object.", 0, getDebugBacktrace(1));
                     break;
                 }
             }
         }
     }
     // check if the UploadFile is used in AjaxLoadPage (Tabs, DialogBox)
     if ($this->getPage()->isAjaxLoadPage()) {
         // In this case UploadFile need to be sublit with ajax event
         if (!$this->is_ajax_event) {
             throw new NewException(get_class($this) . " error: You need to use " . get_class($this) . " with ajax event (" . get_class($this) . "->setAjaxEvent()) when loaded in AjaxLoadPage (Tabs, DialogBox).", 0, getDebugBacktrace(1));
         }
         if ($this->form_object != null) {
             throw new NewException(get_class($this) . " error: You cannot use " . get_class($this) . " in a Form object when loaded in AjaxLoadPage (Tabs, DialogBox).", 0, getDebugBacktrace(1));
         }
     }
     if (sizeof($this->callback_onchange_params) > 0) {
         $args = $this->callback_onchange_params;
         $str_function = array_shift($args);
         $this->callback_onchange = $this->loadCallbackMethod($str_function, $args);
     }
     if ($this->callback_onchange != "") {
         $html .= "<input type='hidden' id='Callback_" . $this->getEventObjectName() . "' name='Callback_" . $this->getEventObjectName() . "' value=''/>\n";
     }
     if ($this->is_ajax_event) {
         $html .= $this->getJavascriptTagOpen();
         $html .= $this->getAjaxEventFunctionRender();
         $html .= $this->getJavascriptTagClose();
     }
     if ($this->button_value == "") {
         if ($this->is_multiple) {
             $this->button_value = __(WSP_BTN_UPLOAD_FILES);
         } else {
             $this->button_value = __(WSP_BTN_UPLOAD_FILE);
         }
     }
     // Generate HTML
     if ($this->object_drop_zone == null || is_browser_ie() && get_browser_ie_version() <= 9) {
         if ($this->select_file_icon == "" || gettype($this->select_file_icon) != "object" || get_class($this->select_file_icon) != "Picture") {
             if (!is_browser_ie()) {
                 $html .= "<span class=\"UploadFile\">";
                 $html .= "<input type=\"text\" id=\"UploadFile_Path_" . $this->id . "\" disabled/>";
                 $html .= "<label id=\"UploadFile_Button_" . $this->id . "\" class=\"button";
                 if ($this->class != "") {
                     $html .= " " . $this->class;
                 }
                 $html .= "\"";
                 if ($this->tooltip != "") {
                     $html .= " title=\"" . $this->tooltip . "\"";
                 }
                 $html .= ">" . $this->button_value . "</label><input type='file' name='" . $this->getEventObjectName() . ($this->is_multiple ? "[]" : "") . "' id='" . $this->id . "' class='UploadFileInput'";
                 if ($this->is_multiple) {
                     $html .= " multiple";
                 }
                 $html .= "/>";
                 $html .= "</span>";
             } else {
                 $html .= "<input type='file' name='" . $this->getEventObjectName() . ($this->is_multiple ? "[]" : "") . "' id='" . $this->id . "'";
                 if ($this->is_multiple) {
                     $html .= " multiple";
                 }
                 if ($this->width != "") {
                     $html .= " style=\"width:";
                     if (is_integer($this->width)) {
                         $html .= $this->width . "px";
                     } else {
                         $html .= $this->width;
                     }
                     $html .= ";\"";
                 }
                 if ($this->class != "") {
                     $html .= " class='" . $this->class . "'";
                 }
                 if ($this->tooltip != "") {
                     $html .= " title='" . $this->tooltip . "'";
                 }
                 $html .= "/>";
             }
         } else {
             $html .= "<input type='file' name='" . $this->getEventObjectName() . ($this->is_multiple ? "[]" : "") . "' id='" . $this->id . "'";
             if ($this->is_multiple) {
                 $html .= " multiple";
             }
             $html .= " style='display:none;'/>";
             $html .= $this->select_file_icon->render($ajax_render);
         }
         $html .= $this->getJavascriptTagOpen();
         if (!is_browser_ie() && $this->select_file_icon == "") {
             $html .= "\$('#UploadFile_Button_" . $this->id . "').click(function(event){\n";
             $html .= "\t\$('#" . $this->id . "').click();\n";
             $html .= "});\n";
             if ($this->width != "") {
                 $html .= "\$('#UploadFile_Path_" . $this->id . "').css('width', (";
                 if (is_integer($this->width)) {
                     $html .= $this->width;
                 } else {
                     $html .= trim(str_replace("px", "", $this->width));
                 }
                 $html .= " - myReplace(\$('#UploadFile_Button_" . $this->id . "').css('width'), 'px', '')) + 'px');\n";
             }
         }
         $html .= "\$('#" . $this->id . "').change(function(){\n";
         if (!is_browser_ie()) {
             $html .= "\tvar current_file = myReplaceAll(\$(this).val(), '\\\\', '/').split('/');\n";
             $html .= "\tcurrent_file = current_file[current_file.length-1];\n";
             $html .= "\t\$('#UploadFile_Path_" . $this->id . "').val(current_file);\n";
         }
         if ($this->onchange != "" || $this->callback_onchange != "") {
             $html .= "\t" . str_replace("\n", "", $this->getObjectEventValidationRender($this->onchange, $this->callback_onchange)) . "\n";
         }
         $html .= "});";
         $html .= $this->getJavascriptTagClose();
     } else {
         $html .= $this->object_drop_zone->render($ajax_render);
         $html .= "<input type='file' name='" . $this->getEventObjectName() . ($this->is_multiple ? "[]" : "") . "' id='" . $this->id . "' style='display:none;'/>";
         $html .= $this->getJavascriptTagOpen();
         $html .= "\$(document).on('dragenter', '#" . $this->object_drop_zone->getId() . "', function() {\n                \$(this).css('border', '" . $this->drop_zone_over_style . "');\n                return false;\n            });\n\n            \$(document).on('dragover', '#" . $this->object_drop_zone->getId() . "', function(e){\n                e.preventDefault();\n                e.stopPropagation();\n                \$(this).css('border', '" . $this->drop_zone_over_style . "');\n                return false;\n            });\n\n            \$(document).on('dragleave', '#" . $this->object_drop_zone->getId() . "', function(e) {\n                e.preventDefault();\n                e.stopPropagation();\n";
         if ($this->object_drop_zone->getStyle() != "") {
             $html .= "\$(this).attr('style', '" . $this->object_drop_zone->getStyle() . "');\n";
         }
         $html .= "return false;\n            });\n            \$(document).on('drop', '#" . $this->object_drop_zone->getId() . "', function(e) {\n                if(e.originalEvent.dataTransfer){\n                   if(e.originalEvent.dataTransfer.files.length) {\n                       e.preventDefault();\n                       e.stopPropagation();\n";
         $html .= "document.getElementById('" . $this->id . "').files = e.originalEvent.dataTransfer.files;\n";
         $html .= str_replace("\n", "", $this->getObjectEventValidationRender($this->onchange, $this->callback_onchange)) . "\n";
         $html .= "}\n                }\n";
         if ($this->object_drop_zone->getStyle() != "") {
             $html .= "\$(this).attr('style', '" . $this->object_drop_zone->getStyle() . "');\n";
         }
         $html .= "return false;\n            });";
         $html .= $this->getJavascriptTagClose();
     }
     $this->object_change = false;
     return $html;
 }