Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
 /**
  * Get colour option to select with text box
  * @param string $content
  * @return string
  */
 public function edit($content)
 {
     $this->_editViewData['selectOptions'] = ['none' => 'No Colour'];
     $selectOptions = BlockSelectOption::where('block_id', '=', $this->_block->id)->get();
     foreach ($selectOptions as $selectOption) {
         $this->_editViewData['selectOptions'][$selectOption->value] = $selectOption->option;
     }
     $this->_editViewData['selectClass'] = 'select_colour';
     return parent::edit($this->_defaultData($content));
 }
Exemplo n.º 3
0
 /**
  * Edit selectwprice data view
  * @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($this->_defaultData($content));
 }
 /**
  * Allow custom options to be added (comma separated)
  * @param array $postContent
  * @return static
  */
 public function submit($postContent)
 {
     $postContent['select'] = !empty($postContent['select']) ? $postContent['select'] : [];
     if ($postContent['custom']) {
         $newOptions = explode(',', $postContent['custom']);
         $optionsArr = [];
         $options = BlockSelectOption::where('block_id', '=', $this->_block->id)->get();
         if (!$options->isEmpty()) {
             foreach ($options as $option) {
                 $optionsArr[$option->value] = $option->option;
             }
         }
         foreach ($newOptions as $newOption) {
             $newOption = trim($newOption);
             if ($newOption && empty($optionsArr[$newOption])) {
                 $optionsArr[$newOption] = $newOption;
             }
         }
         BlockSelectOption::import($this->_block->id, $optionsArr);
         $postContent['select'] = array_merge($postContent['select'], $newOptions);
     }
     return $this->save(!empty($postContent['select']) ? serialize($postContent['select']) : '');
 }
 public function getSelects($blockId = null, $import = 0)
 {
     if ($blockId) {
         $block = Block::where('type', 'LIKE', '%select%')->where('type', 'NOT LIKE', '%selectpage%')->where('id', '=', $blockId)->first();
     }
     if (!empty($block)) {
         if ($import) {
             $import = ['fa-4.6' => 'Font Awesome Class List 4.6.1'];
             $this->layoutData['content'] = View::make('coaster::pages.themes.selects', ['block' => $block, 'import' => $import]);
         } else {
             $options = BlockSelectOption::where('block_id', '=', $blockId)->get();
             $options = $options->isEmpty() ? [] : $options;
             $this->layoutData['content'] = View::make('coaster::pages.themes.selects', ['block' => $block, 'options' => $options]);
         }
     } else {
         $selectBlocks = [];
         $blocks = Block::where('type', 'LIKE', '%select%')->where('type', 'NOT LIKE', '%selectpage%')->get();
         if (!$blocks->isEmpty()) {
             foreach ($blocks as $block) {
                 $selectBlocks[$block->id] = $block->name;
             }
         }
         $this->layoutData['content'] = View::make('coaster::pages.themes.selects', ['blocks' => $selectBlocks]);
     }
 }