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 getAjaxRender
  * @access public
  * @return string javascript code to update initial html of object Box (call with AJAX)
  * @since 1.0.35
  */
 public function getAjaxRender()
 {
     $html = "";
     if ($this->object_change && !$this->is_new_object_after_init) {
         // Extract JavaScript from HTML
         $array_ajax_render = extract_javascript($this->render(true));
         for ($i = 1; $i < sizeof($array_ajax_render); $i++) {
             new JavaScript($array_ajax_render[$i], true);
         }
         $html .= "\$('#wsp_box_" . $this->id . "').innerHTML = \"" . str_replace('"', '\\"', str_replace("\n", "", str_replace("\r", "", $array_ajax_render[0]))) . "\";\n";
     }
     return $html;
 }
Beispiel #3
0
 /**
  * Method render
  * @access public
  * @param boolean $ajax_render [default value: false]
  * @return mixed
  * @since 1.2.7
  */
 public function render($ajax_render = false)
 {
     $map_div = "<div id=\"" . $this->id . "\" style=\"width:" . $this->width . "px;height:" . $this->height . "px\"></div>";
     $html = $map_div;
     $html .= $this->getJavascriptTagOpen();
     $html .= "\tif ('function' == typeof(L.map)) {\n";
     $html .= "\tvar map_" . $this->id . " = null;\n";
     $html .= "\tvar geocoder_" . $this->id . " = null;\n\t\t\tvar TimerIDArray_" . $this->id . " = new Array();\n\t\t\tvar TimerIDCount_" . $this->id . " = 0;\n\t\t\t\n\t\t\tif (arrayLoadedMap == null) {\n\t\t\t\tvar arrayLoadedMap = new Array();\n\t\t\t}\n\t\t\t\t\t\n\t\t\tvar arrayMarkerLocation_" . $this->id . " = null;\n\t\t\tinitArrays_" . $this->id . " = function() {\n\t\t\t\tarrayMarkerLocation_" . $this->id . " = new Array();\n\t\t\t};\n";
     $html .= "\tinitIcon = function(img) {\n\t\t\t\tvar mapIcon = L.icon({\n\t\t\t\t\ticonUrl: img,\n\t\t\t\t\ticonRetinaUrl: img,\n\t\t\t\t\ticonSize: [32, 32],\n\t\t\t\t\ticonAnchor: [15, 32],\n\t\t\t\t\tpopupAnchor: [0, -33],\n\t\t\t\t\tshadowUrl: '',\n\t\t\t\t\tshadowRetinaUrl: '',\n\t\t\t\t\tshadowSize: [40, 63],\n\t\t\t\t\tshadowAnchor: [15, 62]\n\t\t\t\t});\n\t\t\t\treturn mapIcon;\n\t\t\t};\n";
     for ($i = 0; $i < sizeof($this->location_icon); $i++) {
         $html .= "\tvar icon_" . $this->id . "_" . $i . " = \"" . $this->location_icon[$i] . "\";\n";
     }
     $html .= "\tvar icon_" . $this->id . "_default = \"" . $this->getPage()->getCDNServerURL() . "wsp/img/leaflet/marker-icon-32.png\";\n";
     $html .= "\tL.Icon.Default.imagePath = \"" . $this->getPage()->getCDNServerURL() . "wsp/img/leaflet\";\n";
     $html .= "\$(document).ready(function() {\n";
     $html .= "\tinitializeMap_" . $this->id . " = function(center_latitude, center_longitude, zoom) {\n";
     if ($this->geosearch_tool == MapLeafLet::GEOSEARCH_GOOGLE) {
         $html .= "\t\tvar geoprovider = new L.GeoSearch.Provider.Google;\n";
     } else {
         if ($this->geosearch_tool == MapLeafLet::GEOSEARCH_BING) {
             $html .= "\t\tvar geoprovider = new L.GeoSearch.Provider.Bing;\n";
         } else {
             if ($this->geosearch_tool == MapLeafLet::GEOSEARCH_ESRI) {
                 $html .= "\t\tvar geoprovider = new L.GeoSearch.Provider.Esri;\n";
             } else {
                 if ($this->geosearch_tool == MapLeafLet::GEOSEARCH_NOKIA) {
                     $html .= "\t\tvar geoprovider = new L.GeoSearch.Provider.Nokia;\n";
                 } else {
                     $html .= "\t\tvar geoprovider = new L.GeoSearch.Provider.OpenStreetMap;\n";
                 }
             }
         }
     }
     $html .= "\t\tinitArrays_" . $this->id . "();\n\t\t\t\tif (map_" . $this->id . " != null) { var parent=\$('#" . $this->id . "').parent(); \$('#" . $this->id . "').remove(); \$('" . addslashes($map_div) . "').prependTo(parent); };\n\t\t\t\tmap_" . $this->id . " = L.map(\"" . $this->id . "\").setView((center_latitude==null&&center_longitude==null?[" . $this->default_latitude . ", " . $this->default_longitude . "]:new L.LatLng(center_latitude, center_longitude)), (zoom==null?" . $this->zoom . ":zoom));\n";
     for ($i = 0; $i < sizeof($this->tile_layer); $i++) {
         $html .= "\t\tvar tileLayer_" . $this->id . "_" . $i . " = L.tileLayer('" . $this->tile_layer[$i] . "', {\n                        attribution: '" . addslashes($this->tile_layer_attribution[$i]) . "'\n";
         if ($this->max_zoom != -1) {
             $html .= "\t\t, maxZoom: " . $this->max_zoom . "\n";
         }
         if ($this->min_zoom != -1) {
             $html .= "\t\t, minZoom: " . $this->min_zoom . "\n";
         }
         $html .= "\t\t})";
         if ($this->tile_layer_display[$i] !== false) {
             $html .= ".addTo(map_" . $this->id . ")";
         }
         $html .= ";\n";
     }
     $ctrl_radio_html = "";
     $ctrl_check_html = "";
     for ($i = 0; $i < sizeof($this->tile_layer_control_name); $i++) {
         if (trim($this->tile_layer_control_name[$i]) != "") {
             if ($this->tile_layer_control_type[$i] == MapLeafLet::TILE_LAYER_CTRL_RADIO) {
                 if ($ctrl_radio_html == "") {
                     $ctrl_radio_html .= "\t\tvar radioLayers_" . $this->id . " = {\n";
                 } else {
                     $ctrl_radio_html .= "\t\t,";
                 }
                 $ctrl_radio_html .= "\"" . $this->tile_layer_control_name[$i] . "\" : tileLayer_" . $this->id . "_" . $i;
             } else {
                 if ($ctrl_check_html == "") {
                     $ctrl_check_html .= "\t\tvar checkLayers_" . $this->id . " = {\n";
                 } else {
                     $ctrl_check_html .= "\t\t,";
                 }
                 $ctrl_check_html .= "\"" . $this->tile_layer_control_name[$i] . "\" : tileLayer_" . $this->id . "_" . $i;
             }
         }
     }
     if ($ctrl_radio_html != "" || $ctrl_check_html != "") {
         if ($ctrl_radio_html != "") {
             $html .= $ctrl_radio_html;
             $html .= "\t\t};\n";
         }
         if ($ctrl_check_html != "") {
             $html .= $ctrl_check_html;
             $html .= "\t\t};\n";
         }
         $html .= "\t\tL.control.layers(";
         $html .= ($ctrl_radio_html != "" ? "radioLayers_" . $this->id : "null") . ", ";
         $html .= $ctrl_check_html != "" ? "checkLayers_" . $this->id : "null";
         $html .= ").addTo(map_" . $this->id . ");\n";
     }
     $html .= "\t\tgeocoder_" . $this->id . " = new L.Control.GeoSearch({\n\t\t\t\t\tprovider: geoprovider\n\t\t\t\t});\n";
     if ($this->display_searchbar) {
         $html .= "\t\tgeocoder_" . $this->id . ".addTo(map_" . $this->id . ");\n";
     }
     if ($this->geosearch_tool != MapLeafLet::GEOSEARCH_GOOGLE) {
         $html .= "\t\tloadMap_" . $this->id . "();\n";
     }
     $html .= "\tarrayLoadedMap[arrayLoadedMap.length] = '" . $this->id . "';\n";
     for ($i = 0; $i < sizeof($this->legend); $i++) {
         $html .= "\tvar legend" . $i . " = L.control({position: '" . $this->legend_position[$i] . "'});\n";
         $html .= "\tlegend" . $i . ".onAdd = function(map_" . $this->id . ") {\n";
         if (gettype($this->legend[$i]) == "object" && method_exists($this->legend[$i], "render")) {
             $content = $this->legend[$i]->render();
         } else {
             $content = $this->legend[$i];
         }
         // Extract JavaScript from HTML
         include_once dirname(__FILE__) . "/../../../../includes/utils_ajax.inc.php";
         $array_ajax_render = extract_javascript($content);
         for ($j = 1; $j < sizeof($array_ajax_render); $j++) {
             new JavaScript($array_ajax_render[$j], true);
         }
         $html .= "\t\tvar div = L.DomUtil.create('div');\n";
         $html .= "\t\tdiv.innerHTML = \"" . str_replace("\n", "", str_replace("\r", "", addslashes($array_ajax_render[0]))) . "\";\n";
         $html .= "\t\treturn div;\n";
         $html .= "\t};\n";
         $html .= "\tlegend" . $i . ".addTo(map_" . $this->id . ");\n";
     }
     $html .= "};\n";
     $html .= "\tloadMap_" . $this->id . " = function() {\n";
     $html .= "\t\tloadAllMarkers_" . $this->id . "();\n\t\t\t\tloadAllAddressMarkers_" . $this->id . "();\n\t\t\t};\n";
     $html .= "\tloadAllLoadedMaps = function() {\n\t\t\t\tfor (i=0; i < arrayLoadedMap.length; i++) {\n\t\t\t\t\teval('loadMap_'+arrayLoadedMap[i]+'()');\n\t\t\t\t}\n\t\t\t};\n";
     $html .= "\tloadAllMarkers_" . $this->id . " = function() {\n";
     $is_already_center = false;
     for ($i = sizeof($this->marker_latitude) - 1; $i >= 0; $i--) {
         $icon = "icon_" . $this->id . "_default";
         if ($this->marker_icon_id[$i] != -1) {
             $icon = "icon_" . $this->id . "_" . $this->marker_icon_id[$i];
         }
         $is_center = "false";
         if (!$is_already_center && $this->marker_is_center[$i]) {
             $is_center = "true";
             $is_already_center = true;
         }
         $html .= "\t\taddMarker_" . $this->id . "(" . $i . ", " . $this->marker_latitude[$i] . ", " . $this->marker_longitude[$i] . ", '" . addslashes($this->marker_text[$i]) . "', " . $icon . ", " . $is_center . ", '" . addslashes($this->marker_link[$i]) . "');\n";
     }
     $html .= "\t};\n";
     $html .= "\tloadAllAddressMarkers_" . $this->id . " = function() {\n\t\t\t\tclearAllTimeout_" . $this->id . "();\n";
     $is_already_center = false;
     for ($i = sizeof($this->location) - 1; $i >= 0; $i--) {
         $icon = "icon_" . $this->id . "_default";
         if ($this->location_icon_id[$i] != -1) {
             $icon = "icon_" . $this->id . "_" . $this->location_icon_id[$i];
         }
         $is_center = "false";
         if (!$is_already_center && $this->location_is_center[$i]) {
             $is_center = "true";
             $is_already_center = true;
         }
         $html .= "\t\tshowMarker_" . $this->id . "(" . $i . ", '" . addslashes($this->location[$i]) . "', '" . addslashes($this->location_text[$i]) . "', " . $icon . ", " . $is_center . ", '" . addslashes($this->marker_link[$i]) . "');\n";
     }
     $html .= "\t};\n";
     $html .= "showMarker_" . $this->id . " = function(ind, address, text, icon, is_center, marker_link) {\n\t\t\t\t\tif (arrayMarkerLocation_" . $this->id . "[ind] == null) {\n\t\t\t\t\t\tTimerIDArray_" . $this->id . "[TimerIDCount_" . $this->id . "++] = setTimeout(\"markLocation_" . $this->id . "(\" + ind + \", '\" + addslashes(address) + \"', '\" + addslashes(text) + \"', '\" + icon + \"', \" + is_center + \", '\" + marker_link + \"')\", ind*200);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdisplayMarker_" . $this->id . "(ind, text, (marker_link!=''?true:false));\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tclearAllTimeout_" . $this->id . " = function() {\n\t\t\t\t\tfor (i=0; i < TimerIDCount_" . $this->id . "; i++) {\n\t    \t\t\t\tclearTimeout(TimerIDArray_" . $this->id . "[i]);\n\t\t\t\t\t}\n\t\t\t\t\tTimerIDArray_" . $this->id . " = new Array();\n\t\t\t\t\tTimerIDCount_" . $this->id . " = 0;\n\t\t\t\t};\n";
     $html .= "\tmarkLocation_" . $this->id . " = function(ind, address, text, icon, is_center, marker_link) {\n\t\t\t\t    geocoder_" . $this->id . ".geosearch(address, function(response) {\n\t\t\t    \t\tif (response != null) {\n\t\t\t\t    \t\taddMarker_" . $this->id . "(ind, response['Y'], response['X'], text, icon, is_center, marker_link);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t};\n";
     $html .= "\taddMarker_" . $this->id . " = function(ind, latitude, longitude, text, icon, is_center, marker_link) {\n\t\t\t\t    var marker = L.marker([latitude, longitude]);\n\t\t\t\t\tif (marker_link != '') {\n\t\t\t\t\t\tmarker.on('click', function() { window.location = marker_link; }).on('mouseover', function(e){ marker.openPopup(); });\n\t\t\t\t\t}\n\t\t\t\t\tif (icon != '') {\n\t\t\t\t\t\tvar mapIcon = initIcon(icon);\n\t\t\t\t\t\tmarker.setIcon(mapIcon);\n\t\t\t\t\t}\n\t\t    \t\tarrayMarkerLocation_" . $this->id . "[ind]=marker;\n\t\t    \t\tdisplayMarker_" . $this->id . "(ind, text, (marker_link!=''?true:false));\n\t\t    \t\tif (is_center == true) {\n\t\t    \t\t\tmap_" . $this->id . ".setView([latitude, longitude], " . $this->zoom . ");\n\t\t\t\t\t}\n\t\t\t\t};\n";
     $html .= "\tdisplayMarker_" . $this->id . " = function(ind, text, is_marker_link) {\n\t\t\t\t    if (text == null || text == '') {\n\t\t\t\t\t\tarrayMarkerLocation_" . $this->id . "[ind].addTo(map_" . $this->id . ");\n\t\t\t\t\t} else if (is_marker_link) {\n\t\t\t\t\t\tarrayMarkerLocation_" . $this->id . "[ind].addTo(map_" . $this->id . ").bindPopup(text);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tarrayMarkerLocation_" . $this->id . "[ind].addTo(map_" . $this->id . ").bindPopup(text).openPopup();\n\t\t\t\t\t}\n\t\t\t\t};\n";
     if ($this->init_onload) {
         $html .= "\tinitializeMap_" . $this->id . "();\n";
     }
     $html .= "});\n";
     if (DEBUG) {
         $html .= "\t} else {\n";
         $html .= "\t\talert(\"" . __(INCLUDE_OBJECT_TO_MAIN_PAGE, get_class($this), get_class($this)) . "\");\n";
         $html .= "\t}\n";
     } else {
         $html .= "\t}\n";
     }
     $html .= $this->getJavascriptTagClose();
     $this->object_change = false;
     return $html;
 }
Beispiel #4
0
 /**
  * Method getAjaxRender
  * @access public
  * @return string javascript code to update initial html of object Button (call with AJAX)
  * @since 1.0.36
  */
 public function getAjaxRender()
 {
     $this->automaticAjaxEvent();
     $html = "";
     if ($this->object_change && !$this->is_new_object_after_init) {
         if ($this->is_ajax_event) {
             new JavaScript($this->getAjaxEventFunctionRender(), true);
         }
         // Extract JavaScript from HTML
         $array_ajax_render = extract_javascript($this->render(true));
         for ($i = 1; $i < sizeof($array_ajax_render); $i++) {
             new JavaScript($array_ajax_render[$i], true);
         }
         $html .= "\$('#wsp_button_" . $this->id . "').html(\"" . str_replace("\n", "", str_replace("\r", "", addslashes($array_ajax_render[0]))) . "\");\n";
     }
     return $html;
 }
Beispiel #5
0
 /**
  * Method getAjaxRender
  * @access public
  * @return string javascript code to update initial html of object Object (call with AJAX)
  * @since 1.0.36
  */
 public function getAjaxRender()
 {
     $this->automaticAjaxEvent();
     $html = "";
     if ($this->object_change && !$this->is_new_object_after_init) {
         if ($this->id == "") {
             throw new NewException("Error Object: You must specified an id (setId())", 0, getDebugBacktrace(1));
         }
         $content = "";
         for ($i = 0; $i < sizeof($this->objects); $i++) {
             if ($this->objects_after_init[$i] === true) {
                 if ($i != 0) {
                     $html .= " ";
                 }
                 if (gettype($this->objects[$i]) == "object" && method_exists($this->objects[$i], "render")) {
                     $content .= $this->objects[$i]->render();
                 } else {
                     $content .= $this->objects[$i];
                 }
             }
         }
         // Extract JavaScript from HTML
         $array_ajax_render = extract_javascript($content);
         for ($i = 1; $i < sizeof($array_ajax_render); $i++) {
             new JavaScript($array_ajax_render[$i], true);
         }
         // Add current object javascript
         $js = $this->generateObjectJavascript(true);
         if ($js != "") {
             $this->getPage()->addObject(new JavaScript($js), false, true);
         }
         if ($this->object_is_cleared) {
             $html .= "\$('#" . $this->getId() . "').html(\"\");\n";
         }
         $html .= "\$('#" . $this->getId() . "').append(\"" . str_replace("\n", "", str_replace("\r", "", addslashes($array_ajax_render[0]))) . "\");\n";
         $html .= "\$('#" . $this->getId() . "').attr('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 . ";";
             }
         }
         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;";
         } else {
             $html .= "display:" . ($this->force_span_tag ? "inline" : "block") . ";";
         }
         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->droppable || $this->sortable) {
             $html .= "min-width: 24px;width: expression(this.scrollWidth < 26 ? '26px' : 'auto');";
         }
         if ($this->style != "") {
             $html .= $this->style;
         }
         $html .= "\");\n";
         if ($this->draggable || $this->droppable || $this->sortable || $this->class != "") {
             $html .= "\$('#" . $this->getId() . "').attr('class', '";
             $class_exists = false;
             if ($this->draggable) {
                 $html .= "draggable";
                 $class_exists = true;
             }
             if ($this->droppable) {
                 if ($class_exists) {
                     $html .= " ";
                 }
                 $html .= "droppable";
                 $class_exists = true;
             }
             if ($this->sortable) {
                 if ($class_exists) {
                     $html .= " ";
                 }
                 $html .= "sortable";
                 $class_exists = true;
             }
             if ($this->class != "") {
                 if ($class_exists) {
                     $html .= " ";
                 }
                 $html .= $this->class;
                 $class_exists = true;
             }
             $html .= "');\n";
         }
         $this->object_change = false;
     }
     return $html;
 }
Beispiel #6
0
 /**
  * Method render
  * @access public
  * @param boolean $ajax_render [default value: false]
  * @return string html code of object Editor
  * @since 1.0.36
  */
 public function render($ajax_render = false)
 {
     $html = "";
     if ($this->class_name != "") {
         if (!$ajax_render) {
             $html .= "<div id=\"wsp_editor_" . $this->name . "\">\n";
         }
         $html .= "<textarea name=\"" . $this->getEventObjectName() . "\" id=\"" . $this->name . "\"";
         $html .= " style=\"height:";
         if ($this->height != "") {
             $html .= $this->height;
         } else {
             $html .= "100";
         }
         $html .= "px;width:";
         if ($this->width != "") {
             $html .= $this->width . "px";
         } else {
             $html .= "98%";
         }
         $html .= ";\">";
         if ($this->form_object != null) {
             $hidden_text = new TextBox($this->form_object, "hidden_" . $this->name);
         } else {
             $hidden_text = new TextBox($this->page_object, "hidden_" . $this->name);
         }
         $html .= $this->getValue() . "</textarea>\n";
         $hidden_text->setStyle("display:none;")->forceEmpty();
         $html .= $hidden_text->render() . "\n";
         if (!$ajax_render) {
             $html .= "</div>\n";
             $html .= $this->getJavascriptTagOpen();
             $html .= $this->getCreateEditorJs();
             $html .= $this->getJavascriptTagClose();
             if ($this->live_validation != null) {
                 $html .= $this->live_validation->render();
             }
         } else {
             // For Ajax render: Extract JavaScript from HTML
             $array_ajax_render = extract_javascript($this->live_validation->render());
             for ($i = 1; $i < sizeof($array_ajax_render); $i++) {
                 new JavaScript($array_ajax_render[$i], true);
             }
         }
     }
     $this->object_change = false;
     return $html;
 }
Beispiel #7
0
 /**
  * Method render
  * @access public
  * @param boolean $ajax_render [default value: false]
  * @return string html code of object DialogBox
  * @since 1.0.35
  */
 public function render($ajax_render = false)
 {
     $html = "";
     $html_content = "";
     $js_display_from_url = "";
     if (gettype($this->content) == "object" && method_exists($this->content, "render")) {
         $html_content = $this->content->render();
         // Extract JavaScript from HTML
         include_once dirname(__FILE__) . "/../../includes/utils_ajax.inc.php";
         $array_extract_js = extract_javascript($html_content);
         for ($i = 1; $i < sizeof($array_extract_js); $i++) {
             if ($this->display_from_url) {
                 $js_display_from_url .= str_replace("//<![CDATA[", "", str_replace("//]]>", "", str_replace("\"", "'", str_replace("\r", "", str_replace("\n", "", $array_extract_js[$i]))))) . " ";
             } else {
                 new JavaScript("\$(document).ready( function() {" . $array_extract_js[$i] . " } );", true);
             }
         }
         $html_content = $array_extract_js[0];
     } else {
         $html_content = $this->content;
     }
     if (get_class($this->content) != "Url") {
         $tmp_html_content = "<div align=\\'" . $this->align . "\\'";
         if ($this->style != "") {
             $tmp_html_content .= " style=\\'" . $this->style . "\\'";
         }
         $tmp_html_content .= ">" . str_replace("\"", "\\\"", str_replace("'", "\\'", str_replace("\r", "", str_replace("\n", "", $html_content)))) . "</div>";
         $html_content = $tmp_html_content;
     } else {
         if (find($html_content, "?", 0, 0) > 0) {
             $html_content .= "&dialogbox_level=" . ($this->dialogbox_indice == "" ? 1 : $this->dialogbox_indice);
         } else {
             $html_content .= "?dialogbox_level=" . ($this->dialogbox_indice == "" ? 1 : $this->dialogbox_indice);
         }
     }
     if ($this->display_from_url) {
         $html .= "javascript:";
     } else {
         $html .= "jQuery(document).ready(function(){ ";
     }
     $html .= "var create_div = true;";
     if ($this->one_instance) {
         if (!$this->close_if_instance_exists) {
             $html .= "if (typeof(wspDialogBox" . $this->dialogbox_indice . ") !== 'undefined') { if (wspDialogBox" . $this->dialogbox_indice . ".dialog('widget').css('display') == 'block') { ";
             if (get_class($this->content) == "Url") {
                 $html .= "create_div = false;";
             } else {
                 $html .= "wspDialogBox" . $this->dialogbox_indice . ".dialog('widget').find('.ui-widget-content').html('" . $html_content . "');";
                 $html .= "return false;";
             }
             $html .= " } } ";
         } else {
             $html .= $this->close()->render();
         }
     }
     $html .= "if (create_div) {";
     $html .= "wspDialogBox" . $this->dialogbox_indice . " = \$('";
     $html_div = "<div style=\\'display:hidden;z-index:99999" . $this->dialogbox_indice . ";\\'>";
     if (get_class($this->content) != "Url") {
         $html_div .= $html_content;
     } else {
         $html_div .= "<div align=\\'center\\'><img src=\\'" . $this->getPage()->getCDNServerURL() . "wsp/img/loading.gif\\' width=\\'32\\' height=\\'32\\' /></div>";
     }
     if ($this->display_from_url && $GLOBALS['__AJAX_PAGE__'] && !$GLOBALS['__AJAX_LOAD_PAGE__']) {
         $html_div = str_replace("\\'", "\\\\'", $html_div);
     }
     $html .= $html_div;
     $html .= "</div>').appendTo('body');";
     $html .= " } ";
     if ($this->display_from_url && $js_display_from_url != "") {
         $html .= $js_display_from_url;
     }
     $html .= "wspDialogBox" . $this->dialogbox_indice;
     if ($this->delay > 0) {
         $html .= ".delay(" . $this->delay . ").queue(function( nxt ) { \$(this)";
     }
     $html .= ".dialog({ title: '" . addslashes(str_replace("\r", "", str_replace("\n", "", $this->title))) . "'";
     $html .= ", close: function() { wspDialogBox" . $this->dialogbox_indice . ".dialog('widget').find('.ui-dialog-content').html(''); wspDialogBox" . $this->dialogbox_indice . ".dialog('widget').remove(); }";
     if ($this->desactivate) {
         $html .= ", modal: true, closeOnEscape: false";
     } else {
         $html .= ", modal: false, closeOnEscape: true";
     }
     if ($this->close_button) {
         $html .= ", buttons: { '" . addslashes(__(CLOSE)) . "': function() { \$(this).dialog('close');" . $this->close_button_js . " } }";
     }
     $html .= "});";
     if (!is_browser_ie_6()) {
         $html .= "if (create_div) {";
         if ($this->width != "") {
             $html .= "wspDialogBox" . $this->dialogbox_indice . ".dialog('option', 'width', " . $this->width . ");";
         } else {
             $html .= "wspDialogBox" . $this->dialogbox_indice . ".dialog('option', 'minWidth', 350);";
         }
         if ($this->height != "") {
             $html .= "wspDialogBox" . $this->dialogbox_indice . ".dialog('option', 'height', " . $this->height . ");";
         }
         if ($this->position != "") {
             if (find($this->position, "[", 0, 0) > 0) {
                 $html .= "wspDialogBox" . $this->dialogbox_indice . ".dialog('option', 'position', " . $this->position . ");";
             } else {
                 $html .= "wspDialogBox" . $this->dialogbox_indice . ".dialog('option', 'position', '" . $this->position . "');";
             }
         } else {
             if ($this->position_x > -1 || $this->position_y > -1) {
                 $html .= "wspDialogBox" . $this->dialogbox_indice . ".dialog('option', 'position', [" . $this->position_x . "," . $this->position_y . "]);";
             }
         }
         $html .= "}";
     }
     if ($this->desactivate) {
         $html .= "wspDialogBox" . $this->dialogbox_indice . ".dialog('widget').find('.ui-dialog-titlebar-close').hide();";
     }
     $html .= "setTimeout('LoadPngPicture();', 1);";
     if (get_class($this->content) == "Url") {
         $html .= "wspDialogBox" . $this->dialogbox_indice;
         if ($this->load_url_delay > 0) {
             $html .= ".delay(" . $this->load_url_delay . ").queue(function( nxt ) { \$(this)";
         }
         $html .= ".load('" . $html_content . "', {}, ";
         $html .= "function (response, status, xhr) {";
         $html .= "if (status == 'error' && response != '') { wspDialogBox" . $this->dialogbox_indice . " = \$('<div style=\\'display:hidden;z-index:99999" . $this->dialogbox_indice . ";\\'><table><tr><td><img src=\\'" . $this->getPage()->getCDNServerURL() . "wsp/img/warning.png\\' height=\\'24\\' width=\\'24\\' border=\\'0\\' align=\\'absmidlle\\'/></td><td><b>Error</b></td></tr></table>' + response + '</div>').appendTo('body'); }";
         $html .= "});";
         if ($this->load_url_delay > 0) {
             $html .= "});";
         }
     }
     if (!$this->display_from_url) {
         $html .= "});";
         if ($this->delay > 0) {
             $html .= "});";
         }
     } else {
         if ($this->delay > 0) {
             $html .= "});";
         }
         $html .= "return false;";
     }
     $this->object_change = false;
     return $html;
 }