Beispiel #1
0
 public function __construct()
 {
     // call parent constructor
     parent::__construct();
     // register events
     $this->app->event->dispatcher->connect('element:afterdisplay', array($this, 'afterDisplay'));
 }
Beispiel #2
0
 public function getRenderedValues($params = array(), $mode = false, $opts = array())
 {
     // create a unique hash for this element position
     $hash = md5(serialize(array($opts, $this->getType()->getApplication()->getGroup(), $this->getType()->id, $params->get('element') . $params->get('_layout'), $params->get('_position') . $params->get('_index'))));
     if (!array_key_exists($hash, $this->_rendered_values)) {
         // init vars
         $result = parent::getRenderedValues($params, $mode, $opts);
         if (empty($result)) {
             return null;
         }
         // if no results abort
         // truncate
         if ($max_length = $params->find('specific._max_car', 0)) {
             $tr_mode = $params->find('specific._max_car_mode', 1);
             $tr_suffix = $params->find('specific._max_car_suffix', '...');
             // group all text & truncate
             if (isset($max_length) && $max_length > 0 && count($result['result']) > 1 && $tr_mode == 1) {
                 $result_len = 0;
                 for ($i = 0; $i < count($result['result']); $i++) {
                     switch (preg_replace('/\\..+/', '', $mode)) {
                         // WK Slideset // WK Accordion
                         case 'slideset':
                         case 'accordion':
                             $text = $result['result'][$i]['content'];
                             $result_len += strlen(strip_tags($text));
                             if ($result_len > $max_length) {
                                 $truncate_len = $i > 1 ? $result_len - $max_length : $max_length;
                                 $result['result'][$i]['content'] = $this->app->zlstring->truncate($text, $truncate_len, $tr_suffix);
                                 $result['result'] = array_slice($result['result'], 0, $i + 1);
                                 // remove the rest
                                 $result['report']['limited'] = true;
                                 break;
                             } else {
                                 $result['result'][$i]['content'] = $text;
                             }
                             break;
                         default:
                             $text = $result['result'][$i];
                             $result_len += strlen(strip_tags($text));
                             if ($result_len > $max_length) {
                                 $truncate_len = $i > 1 ? $result_len - $max_length : $max_length;
                                 $result['result'][$i] = $this->app->zlstring->truncate($text, $truncate_len, $tr_suffix);
                                 $result['result'] = array_slice($result['result'], 0, $i + 1);
                                 // remove the rest
                                 $result['report']['limited'] = true;
                                 break;
                             } else {
                                 $result['result'][$i] = $text;
                             }
                             break;
                     }
                 }
             } else {
                 if (isset($max_length) && $max_length > 0 && $tr_mode == 2) {
                     $limited_once = false;
                     for ($i = 0; $i < count($result['result']); $i++) {
                         switch (preg_replace('/\\..+/', '', $mode)) {
                             // WK Slideset // WK Accordion
                             case 'slideset':
                             case 'accordion':
                                 if (strlen($result['result'][$i]['content']) > $max_length) {
                                     $result['result'][$i]['content'] = $this->app->zlstring->truncate($result['result'][$i]['content'], $max_length, $tr_suffix);
                                     $limited_once == true;
                                 }
                                 break;
                             default:
                                 if (strlen($result['result'][$i]) > $max_length) {
                                     $result['result'][$i] = $this->app->zlstring->truncate($result['result'][$i], $max_length, $tr_suffix);
                                     $limited_once == true;
                                 }
                                 break;
                         }
                     }
                     $result['report']['limited'] = $limited_once ? $result['report']['limited'] : true;
                 }
             }
         }
         $this->_rendered_values[$hash] = $result;
     }
     return $this->_rendered_values[$hash];
 }
Beispiel #3
0
 public function loadAssets()
 {
     parent::loadAssets();
     // load ZLUX assets
     $this->app->zlfw->zlux->loadMainAssets();
     // load the FilesPro js
     $this->app->document->addScript('elements:filespro/filespro.js');
 }
Beispiel #4
0
 public function bindData($data = array())
 {
     parent::bindData($data);
     foreach ($this as $self) {
         $value = $this->get('value', '');
         if (!empty($value)) {
             $tzoffset = $this->app->date->getOffset();
             $date = $this->app->date->create($value, $tzoffset);
             $value = $date->toSQL();
             $this->set('value', $value);
         }
         $valueend = $this->get('valueend', '');
         if (!empty($valueend)) {
             $tzoffset = $this->app->date->getOffset();
             $date = $this->app->date->create($valueend, $tzoffset);
             $valueend = $date->toSQL();
             $this->set('valueend', $valueend);
         }
     }
     // necesary for submission
     $this->rewind();
 }
Beispiel #5
0
 public function loadAssets()
 {
     parent::loadAssets();
     // ZLUX
     $this->app->zlfw->zlux->loadMainAssets(true);
     // element assets
     $this->app->document->addScript('zlfw:assets/js/accounting.min.js');
     $this->app->document->addScript('elements:repeatablepro/repeatablepro.js');
     $this->app->document->addStylesheet('elements:variations/assets/css/style.css');
     $this->app->document->addScript('elements:pricepro/assets/js/price.js');
     $this->app->document->addScript('elements:variations/assets/js/script.js');
     return $this;
 }
Beispiel #6
0
 protected function _renderRepeatable($function, $params = array())
 {
     if ($this->config->find('specific._editor') == 'joomlaeditor') {
         $params = $this->app->data->create($params);
         $this->rewind();
         return $this->config->get('repeatable') ? $this->renderLayout($this->getLayout('edit/edit_yoo.php'), compact('params')) : $this->_addEditor(0, $this->get('value', $this->config->get('default')), $params->get('trusted_mode', false));
     } else {
         return parent::_renderRepeatable($function, $params);
     }
 }
Beispiel #7
0
 public function getConfigForm()
 {
     $form = parent::getConfigForm();
     $form->addElementPath($this->app->path->path('zoocart:fields'));
     return $form;
 }
Beispiel #8
0
 public function loadAssets()
 {
     parent::loadAssets();
     $this->app->zlfw->zlux->loadMainAssets(true);
     $this->app->document->addScript('zlfw:assets/js/accounting.min.js');
     $this->app->document->addScript('elements:measurespro/measurespro.js');
     return $this;
 }