Exemple #1
0
 /**
  * Decode non-scalar columns
  *
  * @param array $data
  * @return array
  */
 public function decode($data)
 {
     if (!empty($data['filter'])) {
         $data['value'] = $this->decodeValueColumn($data['value'], $data['filter']);
     }
     return parent::decode($data);
 }
Exemple #2
0
 /**
  * Build the content of the block for output
  *
  * @param BlockRow $blockRow
  * @param array $configs
  * @return array|string Variable array for module blocks
  *      and string content for custom blocks
  */
 public function buildBlock(BlockRow $blockRow, $configs = array())
 {
     $result = false;
     $block = $blockRow->toArray();
     $isCustom = $block['type'] ? true : false;
     // Merge run-time configs with system settings
     $options = isset($block['config']) ? $block['config'] : array();
     if (!empty($configs)) {
         $options = array_merge($options, $configs);
     }
     // Module-generated block, return array
     if (!empty($block['render'])) {
         // Load translations for corresponding module block
         Pi::service('i18n')->loadModule('block', $block['module']);
         /*
         // Merge run-time configs with system settings
         $options = isset($block['config']) ? $block['config'] : array();
         if (!empty($configs)) {
             $options = array_merge($options, $configs);
         }
         */
         // Render contents
         $result = call_user_func_array($block['render'], array($options, $block['module']));
         // Custom block, return string
     } elseif ($isCustom) {
         switch ($block['type']) {
             // list
             case 'list':
                 // carousel
             // carousel
             case 'carousel':
                 $items = empty($block['content']) ? false : json_decode($block['content'], true);
                 if ($items) {
                     $result = array('items' => $items, 'options' => $options);
                 }
                 break;
                 // compound tab
             // compound tab
             case 'tab':
                 $result = $this->transliterateTabs($block['content']);
                 break;
                 // static HTML
             // static HTML
             case 'html':
                 $result = Pi::service('markup')->render($block['content'], 'html');
                 $result = $this->transliterateGlobals($result);
                 break;
                 // static markdown
             // static markdown
             case 'markdown':
                 $result = Pi::service('markup')->render($block['content'], 'html', 'markdown');
                 $result = $this->transliterateGlobals($result);
                 break;
                 // static text
             // static text
             case 'text':
             default:
                 $result = Pi::service('markup')->render($block['content'], 'text');
                 $result = $this->transliterateGlobals($result);
                 break;
         }
     }
     return $result;
 }
Exemple #3
0
 /**
  * Delete a navigation
  *
  * @param NavigationRow $navigationRow
  * @param array $message
  * @return bool
  */
 protected function deleteNavigation(NavigationRow $navigationRow, &$message)
 {
     try {
         $navigationRow->delete();
     } catch (\Exception $e) {
         $message[] = $e->getMessage();
         return false;
     }
     $row = Pi::model('navigation_node')->find($navigationRow->name, 'navigation');
     if ($row) {
         $row->delete();
     }
     return true;
 }