function render() { if (!$this->_application->isAdmin()) { if ($this->_content['result']) { org_glizy_helpers_Array::arrayMultisortByLabel($this->_content['result'], '__weight__'); } if (!$this->getAttribute('skipFormTag')) { parent::render_html_onStart(); } parent::render(); if (!$this->getAttribute('skipFormTag')) { parent::render_html_onEnd(); } } }
public function render_html_onEnd($value = '') { parent::render_html_onEnd(); $corePath = __Paths::get('CORE'); $jQueryPath = $corePath . 'classes/org/glizycms/js/jquery/'; $languageCode = $this->_application->getLanguage(); $language = $languageCode . '-' . strtoupper($languageCode); if ($this->getAttribute('newCode')) { $formEditPath = $corePath . 'classes/org/glizycms/js/formEdit2/'; $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($corePath . 'classes/org/glizycms/js/underscore/underscore-min.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEdit.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditStandard.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditCheckbox.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditRepeat.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditDate.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditDateTime.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.it.js')); $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'bootstrap-datetimepicker-master/css/datetimepicker.css')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditColorPicker.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-colorpicker/js/bootstrap-colorpicker.min.js')); $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'bootstrap-colorpicker/css/bootstrap-colorpicker.min.css')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditGUID.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditSelectFrom.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'select2/select2.min.js')); $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'select2/select2.css')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditTINYMCE.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditMediaPicker.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditFile.js')); //$this->addOutputCode( org_glizy_helpers_JS::linkJSfile( $jQueryPath.'fineuploader.jquery/jquery.fineuploader.js' ) ); //$this->addOutputCode( org_glizy_helpers_CSS::linkCSSfile( $jQueryPath.'fineuploader.jquery/fineuploader.css' ) ); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'jquery.validVal-packed.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditPermission.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditPhotoGalleryCategory.js')); // $this->addOutputCode( org_glizy_helpers_JS::linkJSfile( $formEditPath.'GlizyFormEditGoogleMaps.js' ) ); // $this->addOutputCode(org_glizy_helpers_JS::linkJSfile( 'http://maps.google.com/maps/api/js?sensor=false' )); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditCmsPagePicker.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditSelectPageType.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditUrl.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditModalPage.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($corePath . 'classes/org/glizycms/js/glizy-locale/' . $language . '.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.min.js')); $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.default.css')); $id = $this->getId(); $mediaPicker = $this->getMediaPickerUrl(); $AJAXAtion = $this->getAttribute('controllerName') ? $this->getAjaxUrl() : ''; $customValidation = $this->getAttribute('customValidation'); if ($customValidation) { $customValidation = 'customValidation: "' . $customValidation . '",'; } $tinyMceUrls = json_encode($this->getTinyMceUrls()); $jsCode = <<<EOD jQuery(function(){ if ( Glizy.tinyMCE_options ) { Glizy.tinyMCE_options.urls = {$tinyMceUrls}; } var myFormEdit = Glizy.oop.create("glizy.FormEdit", '{$id}', { AJAXAction: "{$AJAXAtion}", mediaPicker: {$mediaPicker}, formData: {$this->data}, {$customValidation} lang: GlizyLocale.FormEdit }); }); EOD; } else { $formEditPath = $corePath . 'classes/org/glizycms/js/formEdit/'; $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($corePath . 'classes/org/glizycms/js/underscore/underscore-min.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEdit.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditTINYMCE.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditFile.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditMediaPicker.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditGoogleMaps.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditGUID.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditColorPicker.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditValuesPreset.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditDate.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditDatetime.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.it.js')); $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'bootstrap-datetimepicker-master/css/datetimepicker.css')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'bootstrap-colorpicker/js/bootstrap-colorpicker.min.js')); $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'bootstrap-colorpicker/css/bootstrap-colorpicker.min.css')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($corePath . 'classes/org/glizycms/js/glizy-locale/' . $language . '.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'dropzone/dropzone.min.js')); $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'dropzone/css/basic2.css')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'jquery.validVal-packed.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditCmsPagePicker.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditSelectFrom.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'select2/select2.min.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.min.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditPermission.js')); $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'select2/select2.css')); $this->addOutputCode(org_glizy_helpers_CSS::linkCSSfile($jQueryPath . 'jquery.pnotify/jquery.pnotify.default.css')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditCheckbox.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile('http://maps.google.com/maps/api/js?sensor=false')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditSelectPageType.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditPhotoGalleryCategory.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($formEditPath . 'GlizyFormEditImageHotspot.js')); // $this->addOutputCode( org_glizy_helpers_JS::linkJSfile( $formEditPath.'GlizyFormEditTreeSelect.js' ) ); // $this->addOutputCode( org_glizy_helpers_JS::linkJSfile( $jQueryPath.'fancytree/jquery.fancytree-all.min.js' ) ); // $this->addOutputCode( org_glizy_helpers_CSS::linkCSSfile( $jQueryPath.'fancytree/skin-win7/ui.fancytree.min.css' ) ); $id = $this->getId(); $mediaPicker = $this->getMediaPickerUrl(); $AJAXAtion = $this->getAttribute('controllerName') ? $this->getAjaxUrl() : ''; $customValidation = $this->getAttribute('customValidation'); if ($customValidation) { $customValidation = 'customValidation: "' . $customValidation . '",'; } $tinyMceUrls = json_encode($this->getTinyMceUrls()); $jsCode = <<<EOD jQuery(function(){ if ( Glizy.tinyMCE_options ) { Glizy.tinyMCE_options.urls = {$tinyMceUrls}; } var ajaxUrl = "{$AJAXAtion}"; jQuery( "#{$id}" ).GlizyFormEdit({ AJAXAction: ajaxUrl ? ajaxUrl : Glizy.ajaxUrl, mediaPicker: {$mediaPicker}, formData: {$this->data}, {$customValidation} lang: GlizyLocale.FormEdit }); }); EOD; } $this->addOutputCode(org_glizy_helpers_JS::JScode($jsCode)); }
function render_html_onEnd() { if ($this->getAttribute('fieldset')) { $this->addOutputCode('</fieldset>'); } parent::render_html_onEnd(); if ($this->getAttribute('wrapDiv')) { $this->addOutputCode('</div>'); } }
function render_html_onStart() { parent::render_html_onStart(); $folderPath = __Paths::get('CORE') . 'classes/org/glizycms/js/visualsearch/'; $output = <<<EOD <script src="{$folderPath}dependencies.js" type="text/javascript"></script> <script src="{$folderPath}visualsearch.js" type="text/javascript"></script> <!--[if (!IE)|(gte IE 8)]><!--> <link href="{$folderPath}visualsearch-datauri.css" media="screen" rel="stylesheet" type="text/css" /> <!--<![endif]--> <!--[if lte IE 7]><!--> <link href="{$folderPath}visualsearch.css" media="screen" rel="stylesheet" type="text/css" /> <!--<![endif]--> EOD; $this->addOutputCode($output, 'head'); $id = $this->getId(); $query = ''; $callback = array(); $valuesMapping = array(); $valuesMappingRev = array(); $valueMatches = ''; foreach ($this->criteria as $v) { $callback[] = array('label' => $v->label, 'id' => $v->id); if ('facet' == $v->type) { $it = org_glizy_objectFactory::createModelIterator($this->getAttribute('model')); $it->where($v->id, '', '<>')->orderBy($v->id); $foundValues = array(); foreach ($it as $ar) { if (is_array($ar->{$v->id})) { foreach ($ar->{$v->id} as $value) { if (!in_array($value, $foundValues)) { $foundValues[] = $value; } } } else { if (!in_array($ar->{$v->id}, $foundValues)) { $foundValues[] = $ar->{$v->id}; } } } $valueMatches .= 'case "' . $v->label . '":callback(' . json_encode($foundValues) . ');break;'; } else { if ('static' == $v->type) { $foundValues = array(); $valuesMapping[$v->label] = array(); $values = json_decode($v->values); foreach ($values as $kk => $vv) { $label = __T($vv); $foundValues[] = $label; $valuesMapping[$v->label][$label] = $kk; $valuesMappingRev[$v->label][$kk] = $label; } $valueMatches .= 'case "' . $v->label . '":callback(' . json_encode($foundValues) . ');break;'; } else { if ('dictionary' == $v->type) { $dataProvider = $this->getComponentById($v->dataProvider); if (!is_null($dataProvider)) { $foundValues = array(); $valuesMapping[$v->label] = array(); $values = $dataProvider->getItems(); foreach ($values as $vv) { $foundValues[] = $vv['value']; $valuesMapping[$v->label][$vv['value']] = $vv['key']; $valuesMappingRev[$v->label][$vv['key']] = $vv['value']; } $valueMatches .= 'case "' . $v->label . '":callback(' . json_encode($foundValues) . ');break;'; } } } } } foreach ($this->filters as $item) { foreach ($item as $k => $v) { if (isset($valuesMappingRev[$k]) && isset($valuesMappingRev[$k][$v])) { $v = $valuesMappingRev[$k][$v]; } $query .= '"' . $k . '": "' . addslashes($v) . '" '; } } $callback = json_encode($callback); $valuesMapping = json_encode($valuesMapping); $output = <<<EOD <input name="{$id}_filters" id="{$id}_filters" type="hidden" value=""> <div id="{$id}_visualsearch"></div> <script type="text/javascript" charset="utf-8"> \$(document).ready(function() { var valuesMapping = {$valuesMapping}; var visualSearch = VS.init({ container : \$('#{$id}_visualsearch'), query : '{$query}', remainder: '', callbacks : { facetMatches : function(callback) { callback({$callback}) }, valueMatches : function(facet, searchTerm, callback) { switch (facet) { {$valueMatches} } } } }); \$('#{$id}').submit(function(){ var e = jQuery.Event("keydown"); e.which = 13 _.each(visualSearch.searchBox.inputViews, function(inputView, i) { inputView.box.trigger("focus"); inputView.box.trigger(e); }); var values = []; _.each(visualSearch.searchQuery.facets(), function(el, i){ _.each(el, function(el2, i2){ if (valuesMapping[i2]) { var temp = {}; temp[i2] = valuesMapping[i2][el2] values.push(temp); } else { values.push(el); } }); }); \$('#{$id}_filters').val(JSON.stringify(values)); return true; }) }); </script> EOD; $this->addOutputCode($output); }