Example #1
0
 public function zone_fork($disposition_id, $disposition, $url, $theme, $page, $zone)
 {
     $url = str_replace(url(), '', $url);
     if (!$url || preg_match('#^index(?:\\.|/)#', $url)) {
         $url = '/';
     }
     if (extension($url) == 'html') {
         $url = substr($url, 0, -5) . '/*';
     }
     $url = explode('/', $url);
     if (!empty($url[0]) && ($module = $this->load->module($url[0])) && !empty($module->routes) && ($method = $module->get_method(array_slice($url, 1, -1), TRUE))) {
         $url = array($url[0], $method, '*');
     }
     $url = implode('/', $url);
     if ($page == '*' || !$this->db->select('1')->from('nf_dispositions')->where('page', $url)->row()) {
         foreach ($disposition as &$rows) {
             foreach ($rows->cols as &$col) {
                 foreach ($col->widgets as &$w) {
                     $widget = $this->db->select('widget', 'type', 'title', 'settings')->from('nf_widgets')->where('widget_id', $w->widget_id)->row();
                     $w->widget_id = $this->db->insert('nf_widgets', array('widget' => $widget['widget'], 'type' => $widget['type'], 'title' => $widget['title'], 'settings' => $widget['settings']));
                 }
             }
         }
         return Zone::display($this->db->insert('nf_dispositions', array('theme' => $theme, 'page' => $url, 'zone' => $zone, 'disposition' => serialize($disposition))), $disposition, $url, $zone, TRUE);
     } else {
         $this->model()->delete_disposition($disposition);
         $this->db->where('disposition_id', $disposition_id)->delete('nf_dispositions');
         $disposition = $this->db->select('disposition_id', 'disposition')->from('nf_dispositions')->where('theme', $theme)->where('page', '*')->where('zone', $zone)->row();
         return Zone::display($disposition['disposition_id'], unserialize($disposition['disposition']), '*', $zone, TRUE);
     }
 }
Example #2
0
 public function display_zone($zone_id)
 {
     static $dispositions;
     if (is_null($dispositions)) {
         $this->db->select('zone', 'disposition_id', 'disposition', 'page')->from('nf_dispositions')->where('theme', $this->load->theme->name)->order_by('page DESC');
         $pages = array('page', '*', 'OR');
         if ($this->config->segments_url[0] == 'index') {
             $pages[] = 'page';
             $pages[] = '/';
             $pages[] = 'OR';
         } else {
             for ($i = count($segments = $this->load->module->segments); $i > 0; $i--) {
                 $pages[] = 'page';
                 $pages[] = implode('/', array_slice($segments, 0, $i)) . '/*';
                 $pages[] = 'OR';
             }
         }
         call_user_func_array(array($this->db, 'where'), $pages);
         foreach ($this->db->get() as $disposition) {
             if (!isset($dispositions[$zone = $disposition['zone']])) {
                 unset($disposition['zone']);
                 $dispositions[$zone] = $disposition;
             }
         }
     }
     if (!empty($dispositions[$zone_id])) {
         $disposition = $dispositions[$zone_id];
         return Zone::display($disposition['disposition_id'], unserialize($disposition['disposition']), $disposition['page'], $zone_id);
     }
     return '';
 }