Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class view
- {
- protected $view_name;
- protected $view_items;
- protected $view_path;
- protected $data;
- //Set the view directory
- public function set_view($directory)
- {
- $this->view_name = $directory;
- $this->view_path = dirname(__FILE__) . "/views/" . $directory;
- $this->view_items = scandir($this->view_path);
- }
- //Add data to view data
- public function add_data($name = null, $data)
- {
- $this->data[$name] = $data;
- return true;
- }
- //Remove data by selected key name or key data
- public function remove_data($key_name = null, $key_data = null)
- {
- $new_data = array();
- foreach($this->data as $key => $data)
- {
- if($data != $key_data && $key != $key_name)
- $new_data[$key] = $data;
- }
- $this->data = $new_data;
- return true;
- }
- public function clear_data()
- {
- $this->data = null;
- return true;
- }
- //Include the view item selected, requires view item name and data
- public function loadSelected($name, $suffix = null)
- {
- if($suffix == null)
- include($this->view_path . "/" . $name . ".php");
- else
- include($this->view_path . "/" . $name . $prefix);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment