/**
  * get a list of pages
  *
  * @return void
  * @author Andy Bennett
  */
 function get_pages_()
 {
     $name = 'application';
     $dbe = new Database_Expression('(SELECT pid FROM pages WHERE name="' . $name . '")');
     $root = ORM::factory('pages_position')->in('page_pid', $dbe)->find();
     $sitemap_string = $root->render_descendants($name, false)->render();
     $sitemap = simplexml_load_string($sitemap_string);
     $arr = array();
     $arr[] = steamcore::array_object(array('id' => 'home', 'title' => '/'));
     //get sections
     $xpc = $sitemap->xpath('/root/items/item');
     foreach ($xpc as $x) {
         $url = $x['url'];
         if (strpos($url, 'page') === false) {
             continue;
         }
         $arr[] = steamcore::array_object(array('id' => str_replace('/page/', '', $url), 'title' => (string) $x['url']));
     }
     //get sub-pages
     $xpc = $sitemap->xpath('/root/items/item/item');
     foreach ($xpc as $x) {
         $url = $x['url'];
         if (strpos($url, 'page') === false) {
             continue;
         }
         $arr[] = steamcore::array_object(array('id' => str_replace('/page/', '', $url), 'title' => (string) $x['url']));
     }
     return $arr;
 }
 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);
 }
 /**
  * set up the joins
  *
  * @param string $db 
  * @return void
  * @author Andy Bennett
  */
 function get_joins()
 {
     $t = parent::get_table();
     $joins = array();
     $joins[] = steamcore::array_object(array('table' => 'uploads AS u', 'on' => $t . '.upload = u.id'));
     #$joins[] = steamcore::array_object( array('table' => 'galleries AS s', 'on' => $t.'.gallery = s.id') );
     return $joins;
 }
 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;
 }
 /**
  * normalise the passed setup object (setting defaults, throwing errors on when required values are missing)
  *
  * @param string $setup 
  * @return void
  * @author Andy Bennett
  */
 public function normalise_setup($setup = false)
 {
     // throw exceptions if the correct parameters haven't been passed
     if (!is_object($setup)) {
         throw new Kohana_User_Exception('Form Setup Error', 'setup object required');
     }
     if (!isset($setup->form_name) || !is_string($setup->form_name)) {
         throw new Kohana_User_Exception('Form Setup Error', 'form_name string is required');
     }
     if (!isset($setup->model) || !is_object($setup->model)) {
         throw new Kohana_User_Exception('Form Setup Error', 'model object is required');
     }
     // setup
     $d = array('db' => true, 'update' => false, 'exit_point' => false, 'form_data' => array());
     $setup = steamcore::array_object($d, $setup);
     return $setup;
 }
 /**
  * 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);
 }
Example #8
0
 /**
  * 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');
     }
 }
 public function get_pages()
 {
     $arr = array();
     $arr[] = steamcore::array_object(array('id' => 'home', 'title' => '/'));
     // get sections
     $xpc = $this->sitemap->xpath('/root/items/item');
     foreach ($xpc as $x) {
         $url = $x['url'];
         if (strpos($url, 'page') === false) {
             continue;
         }
         $arr[] = steamcore::array_object(array('id' => str_replace('/page/', '', $url), 'title' => (string) $x['url']));
     }
     // get sub-pages
     $xpc = $xml->xpath('/root/items/item/item');
     foreach ($xpc as $x) {
         $url = $x['url'];
         if (strpos($url, 'page') === false) {
             continue;
         }
         $arr[] = steamcore::array_object(array('id' => str_replace('/page/', '', $url), 'title' => (string) $x['url']));
     }
     return $arr;
 }
 /**
  * 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);
     }
 }
Example #11
0
 /**
  * return list
  *
  * @param object $lc 
  * @return array
  * @author Andy Bennett
  */
 public function get_list()
 {
     $data = array('action' => 'list', 'name' => $this->name, 'role' => Steamauth::instance()->get_role());
     Event::run('steamcore.aclcheck', $data);
     $tdata = array();
     $limit = 10;
     $total = $this->model->get_total();
     // query the model
     $pagination = pagination_helper::get_pagination($limit, $total);
     $l = steamcore::array_object(array('limit' => $limit, 'offset' => $pagination->sql_offset()));
     $o = $this->get_order();
     $data['query'] = $this->model->get_list($w = null, $o, $l);
     $data['controller'] = Kohana::instance()->uri->segment(1);
     $data['pagination'] = $total <= $limit ? '' : $pagination->render();
     // pass the order direction
     // $data['od'] = (!isset($lc->query_config->order_dir) || $lc->query_config->order_dir == 'DESC')?'ASC':'DESC';
     // merge any passed data and the data returned from the model
     $tdata = array_merge($tdata, $data);
     // return the result
     return $tdata;
 }
 /**
  * get a list of templates
  *
  * @return array
  * @author Andy Bennett
  */
 function get_template_list()
 {
     return steamcore::get_controls_model('containers')->get_template_list();
 }
<?php

defined('SYSPATH') or die('No direct script access.');
$config['steamauth'] = new stdClass();
$config['steamauth']->identity_column = 'identity';
$config['steamauth']->credential_column = 'credential';
$config['steamauth']->tables = array('primary' => steamcore::array_object(array('table' => 'users', 'key' => 'id')), 'secondary' => array());
$config['steamauth']->registration_enabled = TRUE;
$config['steamauth']->home_action = '';
$config['steamauth']->activation_method = 'user';
// credential SETTINGS
$config['steamauth']->user_credential_min = 6;
//min credential length
$config['steamauth']->user_credential_max = 16;
//max credential length
$config['steamauth']->use_country = TRUE;
$config['steamauth']->change_credential_email = 'change_credential_email';
$config['steamauth']->activation_email = 'activation_email';
//The location of the activation email
$config['steamauth']->forgotten_credential_email = 'forgotten_credential_email';
// The location of the forgotten password email
$config['steamauth']->forgotten_credential_reset_email = 'forgotten_credential_reset_email';
//The location of the forgotten password reset email
$config['steamauth']->forgotten_identity_email = 'forgotten_identity_email';
// The location of the forgotten password email
$config['steamauth']->user_activation_email = 'user_activation_email';
//The location of the activation email
$config['steamauth']->moderator_activation_email = 'moderator_activation_email';
//The location of the activation email
 /**
  * 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);
     }
 }
Example #15
0
    /**
     * 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;
    }
 /**
  * show the user their profile for editing
  *
  * @return void
  * @author Andy Bennett
  */
 public function profile()
 {
     if (!$this->model->test_logged_in()) {
         throw new Exception('invalid user');
     }
     $id = $this->model->get_user_data()->id;
     $setup = steamcore::array_object(array('update' => $id, 'form_name' => 'auth_profile', 'model' => $this->model));
     // try running the form, throw exception on error (shouldn't happen)
     try {
         steamform_helper::run_form($setup);
     } catch (Exception $e) {
         throw new Kohana_User_Exception('SteamCore Edit Error', $e->getMessage());
     }
 }
Example #17
0
 /**
  * return a list of the groups
  *
  * @return array
  * @author Andy Bennett
  */
 public function get_groups()
 {
     $new = array();
     $roles = Kohana::config('acl.roles');
     foreach ($roles as $role => $val) {
         if ($role == 'superadmin') {
             continue;
         }
         if ($role == 'guest') {
             continue;
         }
         $new[] = steamcore::array_object(array('id' => $role, 'title' => $role));
     }
     return $new;
 }
 /**
  * get the list of gallery items
  *
  * @param int $gid 
  * @return array
  * @author Andy Bennett
  */
 function get_list($gid)
 {
     $data = array('action' => 'list', 'name' => $this->name, 'role' => Steamauth::instance()->get_role());
     Event::run('steamcore.aclcheck', $data);
     // which model are we using? one passed through or the default?
     $model = $this->model;
     $controller = Kohana::instance()->uri->segment(1);
     $tdata = array();
     $limit = 10;
     $where = null;
     if ($this->uri->segment(3)) {
         $where = array('gallery' => $gid);
     }
     // query the model
     $pagination = pagination_helper::get_pagination($limit, $model->get_total($where));
     $l = steamcore::array_object(array('limit' => $limit, 'offset' => $pagination->sql_offset()));
     $data['query'] = $model->get_list($where, $order = null, $limit = $l);
     $data['controller'] = $controller;
     $data['pagination'] = $pagination->render();
     // pass the order direction
     // $data['od'] = (!isset($lc->query_config->order_dir) || $lc->query_config->order_dir == 'DESC')?'ASC':'DESC';
     // merge any passed data and the data returned from the model
     $tdata = array_merge($tdata, $data);
     // return the result
     return $tdata;
 }
 /**
  * build and run an XML form
  *
  * @param object $setup 
  * @return void
  * @author Andy Bennett
  */
 public static function run_form($setup = false)
 {
     try {
         $setup = SteamForm::normalise_setup($setup);
         $form = SteamForm::factory($setup);
         // does the form data validate
         $form->test_form();
         // get the data submitted from the form
         $fc = steamcore::array_object(array('form' => $form->return_form()));
         // run the validated event
         Event::run('steamform_' . $setup->form_name . '.validated', $fc);
         if ($setup->exit_point === 'validated') {
             return;
         }
         // do the uploading
         foreach ($_FILES as $file => $file_data) {
             if ($file_data['error'] > 0) {
                 unset($_POST[$file]);
             } else {
                 // insert the upload into the uploads database
                 $_POST[$file] = $setup->model->insert_upload(upload::get_upload_data($file, $file_data));
             }
         }
         // run the uploaded event
         Event::run('steamform_' . $setup->form_name . '.uploaded', $fc);
         if ($setup->exit_point === 'uploaded') {
             return;
         }
         // if this is an update, get the current values, and pass them into the form
         if ($setup->update !== false) {
             $id = isset($setup->id) ? $setup->id : Kohana::instance()->input->post('form_id');
             if (!$id || !preg_match('/^[0-9]+$/', $id)) {
                 throw new Exception("No ID supplied");
             }
             $fc->id = $id;
             // prepare the data for inserting
             $setup->model->prep_update_formdata($fc);
             Event::run('steamform_' . $setup->form_name . '.update_prepped', $fc);
             if ($setup->exit_point === 'prepped') {
                 return $fc;
             }
             if ($setup->db) {
                 // insert the data into the database
                 $r = $setup->model->update_formdata($fc);
                 // run the updated event
                 Event::run('steamform_' . $setup->form_name . '.updated', $r);
             }
         } else {
             // prepare the data for inserting
             $setup->model->prep_insert_formdata($fc);
             Event::run('steamform_' . $setup->form_name . '.insert_prepped', $fc);
             if ($setup->exit_point === 'prepped') {
                 return $fc;
             }
             if ($setup->db) {
                 // insert the data into the database
                 $r = $setup->model->insert_formdata($fc);
                 // run the inserted event
                 Event::run('steamform_' . $setup->form_name . '.inserted', $r);
             }
         }
         if ($setup->exit_point === 'inserted') {
             return;
         }
         if ($setup->exit_point === 'updated') {
             return;
         }
         // if there is a notify item in the form, run the notify event
         if (isset($fc->form->notify)) {
             Event::run('steamform.notify', steamcore::array_object(array('data' => $fc, 'notify' => $fc->form->notify)));
         }
         Event::run('audit.cache', steamcore::array_object(array('action' => $setup->update ? 'edit' : 'add', 'id' => $r, 'data' => $fc->data)));
         // run the inserted event
         Event::run('steamform_' . $setup->form_name . '.complete', steamcore::array_object(array('id' => $r, 'data' => $fc->data)));
     } catch (Exception $e) {
         // if this is an update, get the current values, and pass them into the form
         if ($setup->update !== false) {
             $current = steamform_helper::return_current_values($setup->model, $setup->update, $form);
             $form->set_form_data('current', $current);
         }
         if ($e->getCode() != -1) {
             Kohana::log('error', $e->getMessage());
             $form->set_form_data('error', $e->getMessage());
         }
         // generate the html and throw it
         $f = $form->render();
         // run the show_form event
         Event::run('steamform_' . $setup->form_name . '.show_form', $f);
     }
 }
    /**
     * 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 . '" />';
        }
    }
 /**
  * join the tables as appropriate
  *
  * @param object $lc 
  * @return object
  * @author Andy Bennett
  */
 public function get_joins()
 {
     // get the primary table from the config file
     $p = $this->conf->tables['primary'];
     $joins = array();
     // set the secondary
     if (isset($this->conf->tables['secondary']) && is_array($this->conf->tables['secondary'])) {
         foreach ($this->conf->tables['secondary'] as $t) {
             $t->type = isset($t->type) ? $t->type : 'left';
             $joins[] = steamcore::array_object(array('table' => $t->table, 'on' => $t->table . '.' . $t->key . '=' . $p->table . '.' . $p->key, 'type' => 'left'));
         }
     }
     return $joins;
 }