File indexing completed on 2025-05-04 05:29:03

0001 <?php 
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 
0023 ?>
0024 <style>
0025     #dialog-form form dl dl dd {
0026         margin: 0;
0027         padding: 0;
0028         margin-left: 10px;
0029     }
0030 
0031     #dialog-form form legend {
0032         margin: 0;
0033         padding: 0;
0034     }
0035 
0036     #dialog-form form dd {
0037         background-color: #d9d4d7;
0038     }
0039 
0040     #dialog-form form input {
0041         width: 95%;
0042     }
0043 
0044     #dialog-form form dl dd {
0045         padding-top: 3px;
0046         padding-bottom: 3px;
0047     }
0048 
0049     #dialog-form form dl dd fieldset dl dt#logo-label {
0050         display: none;
0051     }
0052 
0053     #dialog-form form dl dt#clientname-label {
0054         display: none;
0055     }
0056 
0057     #dialog-form form dl dd#clientname-element {
0058         display: none;
0059     }
0060 </style>
0061 <div class="messages">
0062     <?php foreach (Zend_Controller_Action_HelperBroker::getStaticHelper('flashMessenger')
0063                        ->getCurrentMessages() as $message) : ?>
0064         <p><?php echo $this->escape($message); ?></p>
0065     <?php endforeach; ?>
0066 </div>
0067 <div id="TableContainer"></div>
0068 <div id="dialog-form" title="Store Config"></div>
0069 
0070 
0071 <div id="dialog-cat-about" title="Create/Edit Store About Page">
0072     <form id="edit-cat-about" class="" action="/backend/store/saveabout" method="post">
0073         <input type="hidden" value="" id="text-cat-id" name="c"/>
0074         <textarea class="" id="text-cat-about" name="ca"></textarea>
0075     </form>
0076 </div>
0077 
0078 <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
0079 
0080 <script type="text/javascript">
0081     $(document).on('focusin', function(e) {
0082         if ($(e.target).closest(".mce-window, .moxman-window").length) {
0083             e.stopImmediatePropagation();
0084         }
0085     });
0086 
0087     tinymce.init({
0088         selector: "#text-cat-about",
0089         width: '100%',
0090         height: 400,
0091         autoresize_min_height: 400,
0092         autoresize_max_height: 600,
0093         menubar: false,
0094         plugins: [
0095             'autoresize advlist autolink lists link image charmap print preview anchor textcolor',
0096             'searchreplace visualblocks code fullscreen',
0097             'insertdatetime media table contextmenu paste code help wordcount'
0098         ],
0099         toolbar: 'insert | undo redo |  formatselect | bold italic backcolor  | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help',
0100         content_css: [
0101             '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
0102             '//www.tinymce.com/css/codepen.min.css']
0103     });
0104 
0105     $("#dialog-cat-about").dialog({
0106         autoOpen: false,
0107         height: 480,
0108         width: 640,
0109         modal: true,
0110         open: function (event, ui) {
0111             tinymce.get("text-cat-about").load();
0112         },
0113         buttons: {
0114             Cancel: function () {
0115                 $(this).dialog("close");
0116             },
0117             Save: function () {
0118                 tinymce.get("text-cat-about").save();
0119                 $('#edit-cat-about').submit();
0120                 $(this).dialog("close");
0121             }
0122         },
0123         close: function () {
0124         }
0125     });
0126 
0127     $('body').on("submit", '#edit-cat-about', function (event) {
0128         event.preventDefault();
0129         event.stopImmediatePropagation();
0130 
0131         jQuery.ajax({
0132             data: $(this).serialize(),
0133             url: this.action,
0134             type: this.method,
0135             error: function (jqXHR, textStatus, errorThrown) {
0136                 $(".alert-danger .alert-body").empty().html('<span class="error">Operation not possible.</span>');
0137                 $(".alert-danger").alert().fadeIn('slow');
0138                 return false;
0139             },
0140             success: function (data, textStatus, jqXHR) {
0141                 return false;
0142             }
0143         });
0144 
0145         return false;
0146     });
0147     
0148     $('body').on("click", 'a.create-about', function (event) {
0149         event.preventDefault();
0150         event.stopImmediatePropagation();
0151 
0152         var elementRecord = $(this).data("record");
0153 
0154         jQuery.ajax({
0155             data: {'c': elementRecord},
0156             url: '/backend/store/readabout/',
0157             type: 'post',
0158             error: function (jqXHR, textStatus, errorThrown) {
0159                 $(".alert-danger .alert-body").empty().html('<span class="error">Operation failed.</span>');
0160                 $(".alert-danger").alert().fadeIn('slow');
0161                 return false;
0162             },
0163             success: function (data, textStatus, jqXHR) {
0164 //                    $(".alert-success .alert-body").empty().html('<span class="success">Please find the category about page in : /httpdocs/partials/category-about/'+elementRecord+'.phtml .</span>');
0165 //                    $(".alert-success").alert().fadeIn('slow');
0166                 $('#text-cat-about').val(data.CatAbout);
0167                 $('#text-cat-id').val(data.c);
0168                 $('#dialog-cat-about').dialog('open');
0169                 return false;
0170             },
0171             complete: function (data, textStatus, errorThrown) {
0172                 return false;
0173             }
0174         });
0175 
0176         return false;
0177     });
0178         
0179     $("#dialog-form").dialog({
0180         autoOpen: false,
0181         //height: 350,
0182         width: 600,
0183         modal: true,
0184         buttons: {
0185             Close: function () {
0186                 $(this).dialog("close");
0187             },
0188             Save: function () {
0189                 $('#dialog-form form').submit();
0190                 $(this).dialog("close");
0191             }
0192         }
0193     });
0194 
0195 
0196     $(document).ready(function () {
0197         $('#TableContainer').jtable({
0198             jqueryuiTheme: true,
0199             paging: true,
0200             sorting: true,
0201             defaultSorting: 'order asc',
0202             title: 'Table of stores',
0203             actions: {
0204                 listAction: '/backend/store/list',
0205                 createAction: '/backend/store/create',
0206                 updateAction: function (postData) {
0207                     return $.Deferred(function ($dfd) {
0208                         $.ajax({
0209                             url: '/backend/store/update',
0210                             type: 'POST',
0211                             dataType: 'json',
0212                             data: postData,
0213                             success: function (data) {
0214                                 $dfd.resolve(data);
0215                                 $('#TableContainer').jtable('reload');
0216                             },
0217                             error: function () {
0218                                 $dfd.reject();
0219                             }
0220                         });
0221                     });
0222                 },
0223                 deleteAction: '/backend/store/delete'
0224             },
0225             fields: {
0226                 store_id: {
0227                     key: true,
0228                     create: false,
0229                     edit: false,
0230                     list: true,
0231                     title: 'Id',
0232                     width: '5%',
0233                 },
0234                 host: {
0235                     title: 'Hostname',
0236                     width: '10%',
0237                     list: true,
0238                     create: true,
0239                     inputTitle: 'hostname <small style="font-weight:normal; font-size: 0.7em">(45 chars)</small>'
0240                 },
0241                 mapping_id_name: {
0242                     title: 'Mapping Id',
0243                     width: '5%',
0244                     list: true,
0245                     create: true,
0246                     inputTitle: 'mapping id <small style="font-weight:normal; font-size: 0.7em">(45 chars) when set, should be unique</small>'
0247                 },
0248                 name: {
0249                     title: 'Store Displayname',
0250                     width: '10%',
0251                     list: true,
0252                     create: true,
0253                     inputTitle: 'Store Displayname <small style="font-weight:normal; font-size: 0.7em">(45 chars)</small>',
0254                     input: function (data) {
0255                         if (data.record) {
0256                             return '<input type="text" name="name" style="width:200px" value="' + data.record.name + '" pattern="[-a-zA-Z0-9_\.]+" /> <span class="small light">[-a-zA-Z0-9_.]</span>';
0257                         } else {
0258                             return '<input type="text" name="name" style="width:200px" pattern="[-a-zA-Z0-9_\.]+" /> <span class="small">[-a-zA-Z0-9_.]</span> ';
0259                         }
0260                     }
0261                 },
0262                 config_id_name: {
0263                     title: 'Config Id',
0264                     width: '10%',
0265                     list: true,
0266                     create: true,
0267                     inputTitle: '(config id) store id name <small style="font-weight:normal; font-size: 0.7em">(used as id for config and search) (45 chars)</small>',
0268                     input: function (data) {
0269                         if (data.record) {
0270                             return '<input type="text" name="config_id_name" style="width:200px" value="' + data.record.config_id_name + '" pattern="[-a-zA-Z0-9_]+" /> <span class="small">[-a-zA-Z0-9_]</span>';
0271                         } else {
0272                             return '<input type="text" name="config_id_name" style="width:200px" pattern="[-a-zA-Z0-9_]+" /> <span class="small">[-a-zA-Z0-9_]</span>';
0273                         }
0274                     }
0275                 },
0276                 order: {
0277                     title: 'Display Order',
0278                     width: '5%',
0279                     list: true,
0280                     create: true
0281                 },
0282                  is_show_home: {
0283                     title: 'Show a Startpage',  
0284                     inputTitle: 'Startpage or Explore as default <small style="font-weight:normal; font-size: 0.7em">(If \'yes\' the a Startpage will be shown instead of the Explore-List)</small>',
0285                     //type: 'checkbox',
0286                     create: true,
0287                     edit: true,
0288                     list:false,
0289                     //values: { 0: 'No', 1: 'Yes' },
0290                     type:'radiobutton',
0291                     options:{  
0292                        1:'yes',
0293                        0:'no'
0294                     },
0295                     defaultValue: 0
0296                 },
0297                 is_client: {
0298                     title: 'Is Client Config',
0299                     list: false,
0300                     //type: 'checkbox',
0301                     //values: { '0': 'No', '1': 'Yes' },
0302                     type:'radiobutton',
0303                     options:{  
0304                        1:'yes',
0305                        0:'no'
0306                     },
0307                     defaultValue: '0',
0308                     inputTitle: 'Is client <small style="font-weight:normal; font-size: 0.7em">(If \'yes\' then don\'t forget to set the <b>config id</b> to right store which config is used)</small>'
0309                 },
0310                 google_id: {
0311                     title: 'Google Id',
0312                     width: '5%'
0313                 },
0314                 tags_name: {
0315                     title: 'Tag-Filter Names',
0316                     type: 'textarea',
0317                     create: true,
0318                     edit: true,
0319                     width: '10%'
0320                 },                
0321                 tags_id: {
0322                     title: 'Tag-Filter IDs',
0323                     type: 'textarea',
0324                     create: true,
0325                     edit: true,
0326                     list:false,
0327                     width: '30%'
0328                 }
0329                 ,
0330                 tags_all: {
0331                     title: 'Tags Helper -> Click to Select',
0332                     create: false,
0333                     edit: true,
0334                     list: false,
0335                     options: function (data) {
0336                         data.clearCache();                        
0337                         return '/backend/store/tagsall';
0338                     }
0339                 },
0340                 groups_name: {
0341                     title: 'TagGroup-Filter Names',
0342                     type: 'textarea',
0343                     create: true,
0344                     edit: true,
0345                     width: '10%'
0346                 },                
0347                 groups_id: {
0348                     title: 'TagGroup-Filter IDs',
0349                     type: 'textarea',
0350                     create: true,
0351                     edit: true,
0352                     list:false,
0353                     width: '30%'
0354                 }
0355                 ,
0356                 groups_all: {
0357                     title: 'TagGroup Helper -> Click to Select',
0358                     create: false,
0359                     edit: true,
0360                     list: false,
0361                     options: function (data) {
0362                         data.clearCache();                        
0363                         return '/backend/store/alltaggroups';
0364                     }
0365                 },
0366                 cross_domain_login: {
0367                     title: 'Cross Domain Login',
0368                     list: false,
0369                     //type: 'checkbox',
0370                     //values: { '0': 'No', '1': 'Yes' },
0371                     type:'radiobutton',
0372                     options:{  
0373                        1:'yes',
0374                        0:'no'
0375                     },
0376                     defaultValue: '0'
0377                 },
0378                  is_show_title: {
0379                     title: 'Is Title Shown',                   
0380                     //type: 'checkbox',
0381                     create: true,
0382                     edit: true,
0383                     list:false,
0384                     //values: { 0: 'No', 1: 'Yes' },
0385                     type:'radiobutton',
0386                     options:{  
0387                        1:'yes',
0388                        0:'no'
0389                     },
0390                     defaultValue: 1
0391                 },
0392                  is_show_git_projects: {
0393                     title: 'Sidebar: Show Git-Project-List',                   
0394                     //type: 'checkbox',
0395                     create: true,
0396                     edit: true,
0397                     list:false,
0398                     //values: { 0: 'No', 1: 'Yes' },
0399                     type:'radiobutton',
0400                     options:{  
0401                        1:'yes',
0402                        0:'no'
0403                     },
0404                     defaultValue: 1
0405                 },
0406                  is_show_blog_news: {
0407                     title: 'Sidebar: Show Blog-News',                   
0408                     //type: 'checkbox',
0409                     create: true,
0410                     edit: true,
0411                     list:false,
0412                     //values: { 0: 'No', 1: 'Yes' },
0413                     type:'radiobutton',
0414                     options:{  
0415                        1:'yes',
0416                        0:'no'
0417                     },
0418                     defaultValue: 1
0419                 },
0420                  is_show_forum_news: {
0421                     title: 'Sidebar: Show Last Forums-Posts',                   
0422                     //type: 'checkbox',
0423                     create: true,
0424                     edit: true,
0425                     list:false,
0426                     //values: { 0: 'No', 1: 'Yes' },
0427                     type:'radiobutton',
0428                     options:{  
0429                        1:'yes',
0430                        0:'no'
0431                     },
0432                     defaultValue: 1
0433                 },
0434                  is_show_in_menu: {
0435                     width: '8%',
0436                     title: 'Show in Menu',                   
0437                     //type: 'checkbox',
0438                     create: true,
0439                     edit: true,
0440                     list:true,
0441                     //values: { 0: 'No', 1: 'Yes' },
0442                     type:'radiobutton',
0443                     options:{  
0444                        1:'1',
0445                        0:'0'
0446                     },
0447                     defaultValue: 1
0448                 },
0449                  is_show_real_domain_as_url: {
0450                     width: '8%',
0451                     title: 'Domain as URL',                   
0452                     //type: 'checkbox',
0453                     create: true,
0454                     edit: true,
0455                     list:true,
0456                     //values: { 0: 'No', 1: 'Yes' },
0457                     type:'radiobutton',
0458                     options:{  
0459                        1:'1',
0460                        0:'0'
0461                     },
0462                     defaultValue: 1
0463                 },
0464                 stay_in_context : {
0465                     title: 'Stay in Store Context with all links',                   
0466                     //type: 'checkbox',
0467                     create: true,
0468                     edit: true,
0469                     list:false,
0470                     //values: { 0: 'No', 1: 'Yes' },
0471                     type:'radiobutton',
0472                     options:{  
0473                        1:'yes',
0474                        0:'no'
0475                     },
0476                     defaultValue: 1
0477                 },  
0478                 browse_list_type_name: {
0479                     title: 'Browse-Type',
0480                     type: 'textarea',
0481                     create: false,
0482                     edit: false,
0483                     width: '8%'
0484                 }, 
0485                 browse_list_type: {
0486                     title: 'Browse-List-Type',
0487                     type: 'multiselectddl',
0488                     create: true,
0489                     edit: true,
0490                     list: false,
0491                     options: function (data) {
0492                         data.clearCache();                        
0493                         return '/backend/browselisttype/allbrowselisttypes';
0494                     }
0495                 },
0496 /*                initSearchIndex: {
0497                     title: '',
0498                     width: '1%',
0499                     sorting: false,
0500                     create: false,
0501                     edit: false,
0502                     list: true,
0503                     display: function (data) {
0504                         if (data.record) {
0505                             return '<button id="create_index" title="Init Search Index" class="jtable-command-button" style="width: 15px;height: 15px;background: url(/theme/flatui/img/todo/search.png);" rel="/backend/search/init/store_id/' + data.record.store_id + '/index_id/' + data.record.config_id_name + '"><span>init search</span></button>';
0506                         }
0507                     }
0508                 }, */
0509                 editConfig: {
0510                     title: '',
0511                     width: '1%',
0512                     sorting: false,
0513                     create: false,
0514                     edit: false,
0515                     list: true,
0516                     display: function (data) {
0517                         if (data.record) {
0518                             if (data.record.default == 1) {
0519                                 return '<a role="button" title="edit default template config" class="btn btn-primary btn-xs edit-config" style="color:white;"  data-record="' + data.record.config_id_name + '"><span>config</span></a>';
0520                             } else {
0521                                 if (data.record.is_client == 1) {
0522                                     return '<div title="config client. please edit source template." data-toggle="tooltip" data-placement="top" ><a role="button" class="btn btn-secondary btn-xs edit-config disabled" data-record="' + data.record.config_id_name + '"><span>config</span></a></div>';
0523                                 } else {
0524                                     return '<a role="button" title="edit template config" class="btn btn-info btn-xs edit-config" style="color:white;"  data-record="' + data.record.config_id_name + '"><span>config</span></a>';
0525                                 }
0526                             }
0527                         }
0528                     }
0529                 },
0530                 about: {
0531                     title: '',
0532                     width: '1%',
0533                     sorting: false,
0534                     create: false,
0535                     edit: false,
0536                     list: true,
0537                     display: function (data) {
0538                         if (data.record) {
0539                             return '<a title="create/edit about page" href="javascript:return false;" class="create-about" role="button" data-record=\'' + data.record.store_id + ' \'><span class="glyphicon glyphicon-open-file" aria-hidden="true"></span></a>';
0540                         }
0541                     }
0542                 }
0543             },
0544 
0545             //Initialize validation logic when a form is created
0546             formCreated: function (event, data) {
0547                 $('#jtable-edit-form').find('#Edit-tags_name').prop("disabled", true);
0548                 $('#jtable-edit-form').find('#Edit-tags_all').change(function () {
0549                     var str = "";
0550                     $( "select#Edit-tags_all option:selected" ).each(function() {
0551                       str = $( this ).val() ;
0552                     });
0553 
0554                     var t = $('#jtable-edit-form').find('#Edit-tags_id').val();
0555                     var tids ='';
0556                     if($.trim(t)){
0557                         tids = t+','+str;
0558                     }else{
0559                         tids = str;
0560                     }
0561                     
0562                      $('#jtable-edit-form').find('#Edit-tags_id').val(tids);
0563                 })
0564                 ;
0565                 
0566                 $('#jtable-edit-form').find('#Edit-groups_name').prop("disabled", true);
0567                 $('#jtable-edit-form').find('#Edit-groups_all').change(function () {
0568                     var str = "";
0569                     $( "select#Edit-groups_all option:selected" ).each(function() {
0570                       str = $( this ).val() ;
0571                     });
0572 
0573                     var t = $('#jtable-edit-form').find('#Edit-groups_id').val();
0574                     var tids ='';
0575                     if($.trim(t)){
0576                         tids = t+','+str;
0577                     }else{
0578                         tids = str;
0579                     }
0580                     
0581                      $('#jtable-edit-form').find('#Edit-groups_id').val(tids);
0582                 })
0583                 ;
0584                   
0585             }
0586         });
0587 
0588         $('#TableContainer').jtable('load');
0589     });
0590 
0591     $('body').on("click", 'button#create_index', function (event) {
0592         event.preventDefault();
0593         event.stopImmediatePropagation();
0594 
0595         var url_string = $(this).attr('rel');
0596 
0597         jQuery.ajax({
0598             url: url_string,
0599             type: 'get',
0600             error: function () {
0601                 alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>");
0602                 return false;
0603             },
0604             success: function (results) {
0605                 alert('Task to create search index was added successfully to the command queue.');
0606                 return false;
0607             }
0608         });
0609 
0610         return false;
0611     });
0612 
0613     $('body').on("click", 'a.edit-config', function (event) {
0614         event.preventDefault();
0615         event.stopImmediatePropagation();
0616 
0617         var elementRecord = $(this).data("record");
0618 
0619         jQuery.ajax({
0620             data: {'c': elementRecord},
0621             url: '/backend/store/loadstoreconfig/',
0622             type: 'post',
0623             error: function () {
0624                 alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>");
0625                 return false;
0626             },
0627             success: function (results) {
0628                 $('#dialog-form').empty().html(results.ViewRecord).dialog('open');
0629                 return false;
0630             }
0631         });
0632 
0633         return false;
0634     });
0635 
0636     $('body').on("submit", '#dialog-form form', function (event) {
0637         event.preventDefault();
0638         event.stopImmediatePropagation();
0639 
0640         jQuery.ajax({
0641             data: $(this).serialize(),
0642             url: '/backend/store/savestoreconfig',
0643             type: 'post',
0644             error: function (jqXHR, textStatus, errorThrown) {
0645                 alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>");
0646                 return false;
0647             },
0648             success: function (data, textStatus, jqXHR) {
0649                 return false;
0650             }
0651         });
0652 
0653         return false;
0654     });
0655 
0656     $('[data-toggle="popover"]').popover();
0657 </script>