function get_list($gid)
 {
     $data = array('action' => 'list', 'name' => $this->name, 'role' => User::instance()->get_role());
     Event::run('steamcore.aclcheck', $data);
     // which model are we using? one passed through or the default?
     $model = steamcore::get_controls_model($this->gallery);
     $controller = URI::segment(1);
     $tdata = array();
     $page = Input::instance()->get('page', 0);
     $num = 18;
     $offset = 0;
     $limit = 18;
     if ($page) {
         $offset = $num * $page - $num;
     }
     $where = array();
     if (isset($gid) and is_numeric($gid)) {
         $where = array('galleries_id' => $gid);
     }
     // query the model
     $data['query'] = $model->where($where)->limit($limit, $offset)->find_all();
     $data['controller'] = $controller;
     $total = $model->count_last_query();
     $data['pagination'] = '';
     if ($total > $num) {
         $data['pagination'] = Pagination::factory(array('style' => 'digg', 'items_per_page' => $num, 'query_string' => 'page', 'total_items' => $total));
     }
     // merge any passed data and the data returned from the model
     $tdata = array_merge($tdata, $data);
     // return the result
     return $tdata;
 }
 /**
  * initialise this library
  *
  * @param array $params 
  * @return void
  * @author Andy Bennett
  */
 protected static function init()
 {
     if (isset(self::$setup)) {
         return;
     }
     $name = Kohana::instance()->uri->segment(1, Kohana::config('controls.default_controller'));
     self::$model = steamcore::get_controls_model($name);
 }
 public function setorder()
 {
     parse_str(Input::instance()->post('sorted'), $order);
     $c = Input::instance()->post('controller');
     foreach ($order['table-sort'] as $key => $value) {
         $m = steamcore::get_controls_model($c, $value);
         $m->order = $key + 1;
         if ($m->loaded) {
             $m->save();
         }
     }
     echo 1;
 }
 /**
  * edit plugins
  *
  * @return void
  * @author Andy Bennett
  */
 function edit()
 {
     $id = $this->input->post('form_id');
     $model = steamcore::get_controls_model('containers');
     // This includes deactivated plugins! They need to be filtered out
     $all_plugins = PluginManager::factory()->getPluginObjects();
     $res = $model->get_plugins($id);
     $container_plugins = array();
     foreach ($res as $row) {
         $container_plugins[$row->plugin_name]['column'] = $row->column;
         $container_plugins[$row->plugin_name]['order'] = $row->order;
         $container_plugins[$row->plugin_name]['template'] = $row->template;
     }
     $view = View::factory('containers_edit');
     $view->container = $model->get_db()->select_row('container', array('id' => $id));
     objectSort($all_plugins, 'column');
     $view->all_plugins = $all_plugins;
     $view->plugin_instances = $container_plugins;
     $copy = $view->render();
     $this->render($copy);
 }
 /**
  * Get data and display feed
  * 
  * @param string $description - For top of feed
  * @return void
  * @author Dan Chadwick
  */
 function index($description = null)
 {
     $model = steamcore::get_controls_model($this->uri->segment(2));
     $tbl = $model->table_name;
     //Set limit
     $limit = uri::segment(3, Kohana::config('rss.limit'));
     //Limit the number of feed items by adding a third segment to the url
     if ($limit == -1) {
         $limit = null;
     }
     /* Set filter
      *  Filters can be added to the rss string like so: ?filter_[filter_field_name]=[filter_value]
      */
     $get = Kohana::instance()->input->get();
     foreach ($get as $key => $filter_value) {
         if (strstr($key, 'filter_')) {
             $filter_column = substr($key, 7, strlen($key) - 7);
             $model->like($filter_column, $filter_value);
         }
     }
     $model->orderby(array('date_added' => 'desc'));
     $result = $model->find_all($limit);
     $v = Kohana::find_file('views', 'rss/' . $tbl) ? $tbl : 'feed-view';
     // You can use a new rss view (named after the table) for specific tables if differnet fields are to be displayed
     $p = new View('rss/' . $v);
     header('Content-type: application/rss+xml');
     $link = $tbl != 'pages' ? $tbl . '/' : '';
     $p->set('description', $description);
     $p->set('link_data', 'page/' . $link);
     $p->set('feed_data', $result);
     try {
         $p->render(TRUE);
     } catch (Exception $ex) {
         throw new Kohana_Exception('debug', 'Rss error');
     }
 }
 /**
  * listener for showing confirm delete page
  *
  * @return void
  * @author Andy Bennett
  */
 public static function event_item_confirm_delete()
 {
     try {
         $model = steamcore::get_controls_model(Event::$data['vals']['controller']);
         $t = $model->get_table();
         $db = $model->get_db();
         // show the confirm delete page
         $r = $db->select_row($t, array('id' => Event::$data['vals']['form_id']));
         Event::$data['title'] = $r->title;
         Event::$data['id'] = $r->id;
         View::factory('pages/confirm_delete', Event::$data);
     } catch (Exception $e) {
         Kohana::log('error', $e);
     }
 }
 /**
  * Confirm delete function
  *
  * @return void
  * @author Andy Bennett
  */
 public static function event_item_confirm_delete()
 {
     try {
         $id = Event::$data['vals']['form_id'];
         $user = steamcore::get_controls_model(Event::$data['vals']['controller'], $id);
         // show the confirm delete page
         if ($user->loaded) {
             $data = array('id' => $id, 'user' => $user, 'vals' => Event::$data['vals']);
             View::factory('pages/confirm_delete_user', $data)->render(true);
         }
     } catch (Exception $e) {
         Kohana::log('error', $e);
     }
 }
    /**
     * add a new page into the tree
     *
     * @return void
     * @author Andy Bennett
     */
    public function add()
    {
        $table = steamcore::get_controls_model('pages')->get_table();
        $data = array();
        $data['title'] = "New Page";
        $data['name'] = url::title($data['title']);
        $data["date_added"] = date('Y-m-d H:i:s');
        $data["date_modified"] = date('Y-m-d H:i:s');
        $data["container"] = 1;
        $data["copy"] = '<div class="editablecontent">
							<div class="editable" id="anonymous_element_14">
								Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore  magna aliquyam erat, sed diam voluptua. At vero eos et  accusam et justo duo dolores et ea rebum. Stet clita kasd  gubergren, no sea takimata sanctus est Lorem ipsum dolor  sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing  elitr, sed diam nonumy eirmod tempor invidunt ut labore  et dolore magna aliquyam erat, sed diam voluptua.
							</div>
						</div>';
        $db = new Database();
        $r = $db->insert($table, $data);
        $id = $r->insert_id();
        $db->where('id', $id)->update($table, array('name' => 'page-' . $id));
        echo $id;
    }
    /**
     * get meta tags
     *
     * @return string
     * @author Andy Bennett
     */
    function get_tags()
    {
        $curr_page = Kohana::instance()->uri->segment(2, 'home');
        $table = steamcore::get_controls_model('pages')->get_table();
        $db = Database::instance();
        $r = $db->select('meta_keywords, meta_description')->from($table)->where('name', $curr_page)->get();
        if ($r->count()) {
            return '<meta name="keywords" content="' . $r->current()->meta_keywords . '" />
				<meta name="description" content="' . $r->current()->meta_description . '" />';
        }
    }
 /**
  * get a list of templates
  *
  * @return array
  * @author Andy Bennett
  */
 function get_template_list()
 {
     return steamcore::get_controls_model('containers')->get_template_list();
 }