summaryrefslogtreecommitdiff
path: root/kohana/libraries/Controller.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-15 08:56:18 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-15 08:56:18 +0000
commit3b35e8b91ce94c292b46a296d034542ac5f0f6da (patch)
tree7a1444b5e16475b66300be105b8fc39e5117c881 /kohana/libraries/Controller.php
parent628058b4ed5aefb543ceb6ca9d3b87828c66bef1 (diff)
Refresh kohana from upstream svn trunk r3771.
During this process, remove a considerable number of files from kohana that we will not be needing in Gallery3, including the following files and directories: kohana/application kohana/example.htaccess kohana/index.php kohana/install.php kohana/kohana.png kohana/modules/archive kohana/modules/auth kohana/modules/flot kohana/modules/gmaps kohana/modules/kodoc kohana/modules/payment kohana/modules/smarty kohana/modules/unit_test/i18n kohana/modules/unit_test/tests/Example_Test.php kohana/modules/unit_test/tests/Valid_Test.php kohana/system/config/captcha.php kohana/system/controllers/captcha.php kohana/system/fonts kohana/system/i18n kohana/system/libraries/Calendar.php kohana/system/libraries/Calendar_Event.php kohana/system/libraries/Captcha.php kohana/system/libraries/Tagcloud.php kohana/system/vendor kohana/system/views/pagination kohana/system/views/kohana_calendar.php
Diffstat (limited to 'kohana/libraries/Controller.php')
-rw-r--r--kohana/libraries/Controller.php86
1 files changed, 86 insertions, 0 deletions
diff --git a/kohana/libraries/Controller.php b/kohana/libraries/Controller.php
new file mode 100644
index 00000000..5f946bde
--- /dev/null
+++ b/kohana/libraries/Controller.php
@@ -0,0 +1,86 @@
+<?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$
+ *
+ * @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);
+
+ try
+ {
+ // 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;
+ }
+ catch (Exception $e)
+ {
+ // Display the exception using its internal __toString method
+ echo $e;
+ }
+
+ // Fetch the output and close the buffer
+ return ob_get_clean();
+ }
+
+} // End Controller Class \ No newline at end of file