summaryrefslogtreecommitdiff
path: root/system/libraries/Controller.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-05-27 15:11:53 -0700
committerBharat Mediratta <bharat@menalto.com>2009-05-27 15:11:53 -0700
commit12fe58d997d2066dc362fd393a18b4e5da190513 (patch)
tree3ad8e5afb77829e1541ec96d86785760d65c04ac /system/libraries/Controller.php
parent00f47d4ddddcd1902db817018dd79ac01bcc8e82 (diff)
Rename 'kohana' to 'system' to conform to the Kohana filesystem layout. I'm comfortable with us not clearly drawing the distinction about the fact that it's Kohana.
Diffstat (limited to 'system/libraries/Controller.php')
-rw-r--r--system/libraries/Controller.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
new file mode 100644
index 00000000..d111f25e
--- /dev/null
+++ b/system/libraries/Controller.php
@@ -0,0 +1,78 @@
+<?php defined('SYSPATH') OR die('No direct access allowed.');
+/**
+ * Kohana Controller class. The controller class must be extended to work
+ * properly, so this class is defined as abstract.
+ *
+ * $Id: Controller.php 3979 2009-02-13 16:46:12Z zombor $
+ *
+ * @package Core
+ * @author Kohana Team
+ * @copyright (c) 2007-2008 Kohana Team
+ * @license http://kohanaphp.com/license.html
+ */
+abstract class Controller_Core {
+
+ // Allow all controllers to run in production by default
+ const ALLOW_PRODUCTION = TRUE;
+
+ /**
+ * Loads URI, and Input into this controller.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ if (Kohana::$instance == NULL)
+ {
+ // Set the instance to the first controller loaded
+ Kohana::$instance = $this;
+ }
+
+ // URI should always be available
+ $this->uri = URI::instance();
+
+ // Input should always be available
+ $this->input = Input::instance();
+ }
+
+ /**
+ * Handles methods that do not exist.
+ *
+ * @param string method name
+ * @param array arguments
+ * @return void
+ */
+ public function __call($method, $args)
+ {
+ // Default to showing a 404 page
+ Event::run('system.404');
+ }
+
+ /**
+ * Includes a View within the controller scope.
+ *
+ * @param string view filename
+ * @param array array of view variables
+ * @return string
+ */
+ public function _kohana_load_view($kohana_view_filename, $kohana_input_data)
+ {
+ if ($kohana_view_filename == '')
+ return;
+
+ // Buffering on
+ ob_start();
+
+ // Import the view variables to local namespace
+ extract($kohana_input_data, EXTR_SKIP);
+
+ // Views are straight HTML pages with embedded PHP, so importing them
+ // this way insures that $this can be accessed as if the user was in
+ // the controller, which gives the easiest access to libraries in views
+ include $kohana_view_filename;
+
+ // Fetch the output and close the buffer
+ return ob_get_clean();
+ }
+
+} // End Controller Class \ No newline at end of file