コード例 #1
0
 /**
  * Provides hook for decorators, so that they can overwrite css
  * and other definitions.
  * 
  * @param bool $skipUpdateInit Set to true to skip the parents updateInit extension
  * 
  * @return void
  *
  * @author Sascha Koehler <*****@*****.**>, Sebastian Diel <*****@*****.**>
  * @since 14.03.2013
  */
 public function init($skipUpdateInit = false)
 {
     parent::init(true);
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery.datepicker.js');
     Requirements::javascript('silvercart/admin/javascript/jquery-ui/date-range-picker/js/date.js');
     Requirements::javascript('silvercart/admin/javascript/jquery-ui/date-range-picker/js/daterangepicker.jQuery.js');
     Requirements::css('silvercart/admin/javascript/jquery-ui/date-range-picker/css/ui.daterangepicker.css');
     Requirements::customScript(sprintf("\n            (function(\$) {\n                \$(document).ready(function() { \n                    //Date picker\n                    \$('#Form_SearchForm_q_Created').daterangepicker({\n                        arrows: false,\n                        dateFormat: 'dd.mm.yy',\n                        presetRanges: [\n                            {text: '%s', dateStart: 'today', dateEnd: 'today' },\n                            {text: '%s', dateStart: 'today-7days', dateEnd: 'today' },\n                            {text: '%s', dateStart: function(){ return Date.parse('today').moveToFirstDayOfMonth();  }, dateEnd: 'today' },\n                            {text: '%s', dateStart: function(){ var x= Date.parse('today'); x.setMonth(0); x.setDate(1); return x; }, dateEnd: 'today' },\n                            {text: '%s', dateStart: function(){ return Date.parse('1 month ago').moveToFirstDayOfMonth();  }, dateEnd: function(){ return Date.parse('1 month ago').moveToLastDayOfMonth();  } }\n                        ],\n                        presets: {\n                            specificDate: '%s',\n                            allDatesBefore: '%s',\n                            allDatesAfter: '%s',\n                            dateRange: '%s'\n                        },\n                        rangeStartTitle: '%s',\n                        rangeEndTitle: '%s',\n                        nextLinkText: '%s',\n                        prevLinkText: '%s'\n                    });\n                });\n            })(jQuery);", _t('SilvercartDateRangePicker.TODAY'), _t('SilvercartDateRangePicker.LAST_7_DAYS'), _t('SilvercartDateRangePicker.THIS_MONTH'), _t('SilvercartDateRangePicker.THIS_YEAR'), _t('SilvercartDateRangePicker.LAST_MONTH'), _t('SilvercartDateRangePicker.DATE'), _t('SilvercartDateRangePicker.ALL_BEFORE'), _t('SilvercartDateRangePicker.ALL_AFTER'), _t('SilvercartDateRangePicker.PERIOD'), _t('SilvercartDateRangePicker.START_DATE'), _t('SilvercartDateRangePicker.END_DATE'), _t('SilvercartDateRangePicker.NEXT'), _t('SilvercartDateRangePicker.PREVIOUS')));
     $this->extend('updateInit');
 }
コード例 #2
0
 /**
  * Provides hook for decorators, so that they can overwrite css
  * and other definitions.
  * 
  * @param bool $skipUpdateInit Set to true to skip the parents updateInit extension
  * 
  * @return void
  *
  * @author Sascha Koehler <*****@*****.**>, Roland Lehmann <*****@*****.**>, Sebastian Diel <*****@*****.**>
  * @since 14.03.2013
  */
 public function init($skipUpdateInit = false)
 {
     /*
      * we tweeked the backend behavior so that when you press the button 'add' on the
      * tab files the file object will be created. This was neccessary because we
      * want to use the fileiframefield without saving. If this created file
      * is not saved by the user it must be deleted because it is an empty entry.
      */
     $request = $this->getRequest();
     $postVars = $request->postVars();
     if (array_key_exists('update', $postVars)) {
         $productID = $postVars['update'];
         $currentProduct = DataObject::get_by_id('SilvercartProduct', $productID);
         if ($currentProduct) {
             if ($currentProduct->SilvercartFiles()) {
                 foreach ($currentProduct->SilvercartFiles() as $file) {
                     if ($file->isEmptyObject()) {
                         $file->delete();
                     }
                 }
             }
             if ($currentProduct->SilvercartImages()) {
                 foreach ($currentProduct->SilvercartImages() as $image) {
                     if ($image->isEmptyObject()) {
                         $image->delete();
                     }
                 }
             }
         }
     }
     parent::init($skipUpdateInit);
 }