/**
  * Populate select options with page names (also add no page option)
  * @param string $content
  * @return string
  */
 public function edit($content)
 {
     $parent = BlockSelectOption::where('block_id', '=', $this->_block->id)->where('option', '=', 'parent')->first();
     $parentPageId = !empty($parent) ? $parent->value : 0;
     $this->_editViewData['selectOptions'] = [0 => '-- No Page Selected --'] + Page::get_page_list(['parent' => $parentPageId]);
     return String_::edit($content);
 }
Exemple #2
0
 /**
  * @param string $content
  * @return string
  */
 public function edit($content)
 {
     $this->_editViewData['placeHolder'] = [];
     if ($this->_editViewData['videoInfo'] = $this->_cache($content)) {
         $this->_editViewData['placeHolder'][$content] = $this->_editViewData['videoInfo']->snippet->title;
     }
     return parent::edit($content);
 }
Exemple #3
0
 /**
  * Save link in search text (without the target attribute)
  * @param null|string $content
  * @return null|string
  */
 public function generateSearchText($content)
 {
     $content = $this->_defaultData($content);
     $content['link'] = str_replace('internal://', '', $content['link'], $count);
     if ($count > 0) {
         $paths = Path::getById($content['link']);
         $content['link'] = $paths->exists ? $paths->name : '';
     }
     return parent::generateSearchText($content['link']);
 }
Exemple #4
0
 /**
  * Display select options, will fill in bg colour if hexadecimal
  * @param string $content
  * @return string
  */
 public function edit($content)
 {
     $this->_editViewData['selectOptions'] = [];
     $selectOptions = BlockSelectOption::where('block_id', '=', $this->_block->id)->get();
     foreach ($selectOptions as $selectOption) {
         $this->_editViewData['selectOptions'][$selectOption->value] = $selectOption->option;
     }
     if (preg_match('/^#[a-f0-9]{6}$/i', key($selectOptions))) {
         $this->_editViewData['class'] = 'select_colour';
     }
     return parent::edit($content);
 }
Exemple #5
0
 /**
  * Convert new lines to <br /> by default, also added length option which cuts string to a word nicely
  * @param string $content
  * @param array $options
  * @return string
  */
 public function display($content, $options = [])
 {
     $content = parent::display($content, $options);
     if (!empty($options['source'])) {
         return $content;
     }
     if (isset($options['meta']) && !isset($options['nl2br'])) {
         $options['nl2br'] = $options['meta'];
     }
     if (isset($options['nl2br']) && $options['nl2br'] || !isset($options['nl2br'])) {
         $content = nl2br($content);
     }
     if (!empty($options['length'])) {
         $content = StringHelper::cutString(strip_tags($content), $options['length']);
     }
     return $content;
 }
Exemple #6
0
 /**
  * Display form settings
  * Template selector should only should if custom template selected (otherwise deprecated)
  * @param string $postContent
  * @return string
  */
 public function edit($postContent)
 {
     $formData = $this->_defaultData($postContent);
     $formData->template = $formData->template == $this->_block->name ? 0 : $formData->template;
     $this->_editViewData['pageList'] = Page::get_page_list();
     $this->_editViewData['formTemplates'] = [0 => '-- Use view from template --'];
     $theme = Theme::find(config('coaster::frontend.theme'));
     if (!empty($theme)) {
         $forms = base_path('/resources/views/themes/' . $theme->theme . '/blocks/forms');
         if (is_dir($forms)) {
             foreach (scandir($forms) as $form) {
                 if (!is_dir($forms . DIRECTORY_SEPARATOR . $form)) {
                     $form_file = explode('.', $form);
                     if (!empty($form_file[0])) {
                         $this->_editViewData['formTemplates'][$form_file[0]] = $form_file[0] . (strpos(file_get_contents($forms . DIRECTORY_SEPARATOR . $form), 'captcha') ? ' (supports captcha)' : ' (does not support captcha)');
                     }
                 }
             }
         }
     }
     return parent::edit($formData);
 }
 /**
  * Add select option and price data to search
  * @param null|string $content
  * @return null|string
  */
 public function generateSearchText($content)
 {
     $content = $this->_defaultData($content);
     $searchText = $this->_generateSearchText($content->selected, $content->price);
     return parent::generateSearchText($searchText);
 }
 /**
  * Add text and colour data to search
  * @param null|string $content
  * @return null|string
  */
 public function generateSearchText($content)
 {
     $content = $this->_defaultData($content);
     $searchText = $this->_generateSearchText($content->text, $content->colour);
     return parent::generateSearchText($searchText);
 }
Exemple #9
0
 /**
  * Add image filename and image title data to search
  * @param null|string $content
  * @return null|string
  */
 public function generateSearchText($content)
 {
     $content = $this->_defaultData($content);
     $searchText = $this->_generateSearchText($content->title, basename($content->file));
     return parent::generateSearchText($searchText);
 }
 /**
  * Convert content to jQuery datetime picker format
  * @param string $content
  * @return string
  */
 public function edit($content)
 {
     $content = DateTimeHelper::mysqlToJQuery($content);
     return parent::edit($content);
 }
 /**
  * Get search text from repeater blocks
  * @param null|string $content
  * @return null|string
  */
 public function generateSearchText($content)
 {
     $searchText = '';
     $repeaterRows = PageBlockRepeaterData::loadRepeaterData($content, $this->_block->getVersionId());
     $repeaterBlocks = BlockRepeater::getRepeaterBlocks($this->_block->id);
     foreach ($repeaterRows as $rowId => $repeaterRow) {
         foreach ($repeaterBlocks as $blockId => $repeaterBlock) {
             if (($blockContent = array_key_exists($blockId, $repeaterRow) ? $repeaterRow[$blockId] : null) !== null) {
                 $block = Block::preloadClone($blockId)->setRepeaterData($this->_block->getRepeaterId(), $this->_block->getRepeaterRowId())->setPageId($this->_block->getPageId());
                 if ($block->exists && $block->search_weight > 0) {
                     $blockSearchText = $block->getTypeObject()->generateSearchText($blockContent);
                     $searchText .= $blockSearchText !== null ? $blockSearchText . "\n" : '';
                 }
             }
         }
     }
     return parent::generateSearchText($searchText);
 }
Exemple #12
0
 /**
  * @param string $content
  * @return string
  */
 public function edit($content)
 {
     return parent::edit($this->_defaultData($content));
 }