/**
  * overload steam add function with different add listener
  *
  * @return void
  * @author Andy Bennett
  */
 public function add()
 {
     Event::clear('steamform_' . $this->setup['name'] . '_add.complete');
     Event::add('steamform_' . $this->setup['name'] . '_add.complete', array('Galleries_Controller', 'event_add_complete'));
     // We can't use parent here, as that wipes out the event we've set!
     Steam_Core::add();
 }
 public function __construct()
 {
     parent::__construct();
     // Create a custom 404 handler for this controller
     Event::clear('system.404', array('Kohana_404_Exception', 'trigger'));
     Event::add('system.404', array($this, 'error'));
     // Do we have anything cached?
     if (Kohana::config('userguide.cache')) {
         $this->cache = Cache::instance();
     }
     if (Router::$method === 'media') {
         // Do not template media files
         $this->auto_render = FALSE;
     }
     // Use customized Markdown parser
     define('MARKDOWN_PARSER_CLASS', 'Kodoc_Markdown');
     // Load Markdown support
     require Kohana::find_file('vendor', 'markdown', TRUE);
     // Set the base URL for links and images
     Kodoc_Markdown::$base_url = url::site('userguide') . '/';
     Kodoc_Markdown::$image_url = url::site('userguide/media') . '/';
     // Disable eAccelerator, it messes with	the ReflectionClass->getDocComments() calls
     ini_set('eaccelerator.enable', 0);
     // Bind the breadcrumb
     $this->template->bind('breadcrumb', $this->breadcrumb);
     // Add the breadcrumb
     $this->breadcrumb = array();
     $this->breadcrumb['userguide'] = 'User Guide';
     if ($this->package = URI::instance()->segment(3)) {
         $this->breadcrumb['userguide/guide/' . $this->package] = ucfirst($this->package);
     }
 }
示例#3
0
文件: php.php 项目: enormego/EightPHP
 /**
  * Disable Eight PHP error handling.
  *
  * @return  void
  */
 public static function disable()
 {
     if (Eight_Exception_PHP::$enabled) {
         restore_error_handler();
         Event::clear('system.shutdown', array('Eight_Exception_PHP', 'shutdown_handler'));
         Eight_Exception_PHP::$enabled = FALSE;
     }
 }
 /**
  * Disable Kohana PHP error handling.
  *
  * @return  void
  */
 public static function disable()
 {
     if (Kohana_PHP_Exception::$enabled) {
         restore_error_handler();
         Event::clear('system.shutdown', array('Kohana_PHP_Exception', 'shutdown_handler'));
         Kohana_PHP_Exception::$enabled = FALSE;
     }
 }
 function __construct()
 {
     parent::__construct();
     Event::clear('steamcore.item_confirm_delete');
     Event::add('steamcore.item_confirm_delete', array('auth_listeners', 'event_item_confirm_delete'));
     Event::clear('steamcore.item_deleted');
     Event::add('steamcore.item_deleted', array('auth_admin_listeners', 'event_item_deleted'));
     Event::clear('steamcore.item_view');
     Event::add('steamcore.item_view', array('auth_listeners', 'event_item_view'));
     Event::clear('steamcore_add.complete');
     Event::add('steamcore_add.complete', array('auth_admin_listeners', 'add_complete'));
     Event::clear('steamcore_edit.complete');
     Event::add('steamcore_edit.complete', array('auth_admin_listeners', 'edit_complete'));
 }
 /**
  * constructor
  *
  * @return void
  * @author Andy Bennett
  */
 function __construct()
 {
     parent::__construct();
     Event::add('gallery.show_list', array('gallery_listeners', 'gallery_list'));
     Event::add('gallery.save_titles_success', array('gallery_listeners', 'save_titles_success'));
     Event::add('gallery.upload_form', array('gallery_listeners', 'upload_form'));
     Event::add('gallery.post_upload_fail', array('gallery_listeners', 'post_upload_fail'));
     Event::add('gallery.post_upload_form', array('gallery_listeners', 'post_upload_form'));
     Event::clear('steamcore.item_view');
     Event::clear('steamcore.item_confirm_delete');
     Event::clear('xform_' . $this->name . '_edit.complete');
     Event::clear('xform_' . $this->name . '_edit.show_form');
     Event::add('steamcore.item_view', array('gallery_listeners', 'item_view_listener'));
     Event::add('steamcore.item_confirm_delete', array('gallery_listeners', 'item_confirm_delete_listener'));
     Event::add('xform_' . $this->name . '_edit.complete', array('gallery_listeners', 'edit_complete_listener'));
     Event::add('xform_' . $this->name . '_edit.show_form', array('gallery_listeners', 'edit_show_form_listener'));
     $this->set_gallery(URI::instance()->segment(1));
 }
示例#7
0
 /**
  * Disables the profiler for this page only.
  * Best used when profiler is autoloaded.
  *
  * @return  void
  */
 public function disable()
 {
     // Removes itself from the event queue
     Event::clear('system.display', array($this, 'render'));
 }
示例#8
0
 public function status($step = 0)
 {
     $this->template = "";
     $this->auto_render = FALSE;
     $url = $this->release->download;
     $working_dir = Kohana::config('upload.relative_directory') . "/upgrade/";
     $zip_file = Kohana::config('upload.relative_directory') . "/upgrade/ushahidi.zip";
     if ($step == 0) {
         $this->upgrade->logger("Downloading latest version of ushahidi...");
         echo json_encode(array("status" => "success", "message" => Kohana::lang('upgrade.download')));
     }
     if ($step == 1) {
         // Create the Directory if it doesn't exist
         if (!file_exists(DOCROOT . "media/uploads/upgrade")) {
             mkdir(DOCROOT . "media/uploads/upgrade");
             chmod(DOCROOT . "media/uploads/upgrade", 0777);
             $this->upgrade->logger("Creating Directory - " . DOCROOT . "media/uploads/upgrade");
         }
         $latest_ushahidi = $this->upgrade->download_ushahidi($url);
         //download was successful
         if ($this->upgrade->success) {
             $this->upgrade->write_to_file($latest_ushahidi, $zip_file);
             $this->upgrade->logger("Successfully Downloaded. Unpacking " . $zip_file);
             echo json_encode(array("status" => "success", "message" => Kohana::lang('upgrade.successfully_downloaded')));
         } else {
             $this->upgrade->logger("** Failed downloading.\n\n");
             echo json_encode(array("status" => "error", "message" => Kohana::lang('upgrade.failed_downloading')));
         }
     }
     if ($step == 2) {
         //extract compressed file
         $this->upgrade->unzip_ushahidi($zip_file, $working_dir);
         //extraction was successful
         if ($this->upgrade->success) {
             $this->upgrade->logger("Successfully Unpacked. Copying files...");
             echo json_encode(array("status" => "success", "message" => Kohana::lang('upgrade.successfully_unpacked')));
         } else {
             $this->upgrade->logger("** Failed unpacking.\n\n");
             echo json_encode(array("status" => "error", "message" => Kohana::lang('upgrade.failed_unpacking')));
         }
     }
     if ($step == 3) {
         //copy files
         $this->upgrade->ftp_recursively($working_dir . "ushahidi/", DOCROOT);
         $this->upgrade->remove_old($working_dir . 'ushahidi/upgrader_removed_files.txt', DOCROOT);
         // Clear out caches before new request
         Cache::instance()->delete_all();
         Kohana::cache_save('configuration', NULL, Kohana::config('core.internal_cache'));
         Kohana::cache_save('language', NULL, Kohana::config('core.internal_cache'));
         Kohana::cache_save('find_file_paths', NULL, Kohana::config('core.internal_cache'));
         Event::clear('system.shutdown', array('Kohana', 'internal_cache_save'));
         //copying was successful
         if ($this->upgrade->success) {
             $this->upgrade->logger("Successfully Copied. Upgrading Database...");
             echo json_encode(array("status" => "success", "message" => Kohana::lang('upgrade.successfully_copied')));
         } else {
             $this->upgrade->logger("** Failed copying files.\n\n");
             echo json_encode(array("status" => "error", "message" => Kohana::lang('upgrade.failed_copying')));
         }
     }
     // Database BACKUP + UPGRADE
     if ($step == 4) {
         // backup database.
         // is gzip enabled ?
         $gzip = Kohana::config('config.output_compression');
         $error = $this->_do_db_backup($gzip);
         if (empty($error)) {
             if (file_exists(DOCROOT . "sql/")) {
                 $this->_process_db_upgrade(DOCROOT . "sql/");
             }
             $this->upgrade->logger("Database backup and upgrade successful.");
             echo json_encode(array("status" => "success", "message" => Kohana::lang('upgrade.backup_success')));
         } else {
             $this->upgrade->logger("** Failed backing up database.\n\n");
             echo json_encode(array("status" => "error", "message" => Kohana::lang('upgrade.backup_failed')));
         }
     }
     // Database UPGRADE ONLY
     if ($step == 5) {
         if (file_exists(DOCROOT . "sql/")) {
             //upgrade tables
             $this->_process_db_upgrade(DOCROOT . "sql/");
             $this->upgrade->logger("Database upgrade successful.");
             echo json_encode(array("status" => "success", "message" => Kohana::lang('upgrade.dbupgrade_success')));
         } else {
             $this->upgrade->logger("Database upgrade successful.");
             echo json_encode(array("status" => "success", "message" => Kohana::lang('upgrade.dbupgrade_success')));
         }
     }
     // Delete downloaded files
     if ($step == 6) {
         $this->upgrade->logger("Deleting downloaded files...");
         echo json_encode(array("status" => "success", "message" => Kohana::lang('upgrade.deleting_files')));
     }
     if ($step == 7) {
         $this->upgrade->remove_recursively($working_dir);
         $this->upgrade->logger("UPGRADE SUCCESSFUL");
         echo json_encode(array("status" => "success", "message" => Kohana::lang('upgrade.upgrade_success', array(url::site("admin/upgrade/logfile?f=" . $this->session->get('upgrade_session') . ".txt")))));
         $this->session->delete('upgrade_session');
     }
 }
 /**
  * set up the form; do replacements, set up validation
  *
  * @return void
  * @author Andy Bennett
  */
 public function setup_form()
 {
     // set up an empty array to hold the row objects
     $this->rows = array();
     if (isset($this->form->append_data)) {
         foreach ($this->form->append_data as $n) {
             foreach ($n as $k => $v) {
                 Display::instance()->append_data($k, $v);
             }
         }
     }
     if (!isset($this->form->steamform_js) or $this->form->steamform_js == 'true') {
         // Display::instance()->add_javascript('/cache/js/steamform');
         Display::instance()->add_javascript('/steamform/index/steamform');
     }
     /*
     	<events>
     		<event>
     			<clear>true</clear>
     			<event>steamform_home_stories_edit.complete</event>
     			<class>adminform_helpers</class>
     			<method>event_home_stories_edit_complete</method>
     		</event>
     	</events>
     */
     if (isset($this->form->events)) {
         foreach ($this->form->events->event as $e) {
             if (!isset($e->class) or !isset($e->method) or !isset($e->event)) {
                 continue;
             }
             $c = (string) $e->class;
             $m = (string) $e->method;
             $ev = (string) $e->event;
             if (isset($e->clear) and (string) $e->clear == 'true') {
                 Event::clear($ev);
             }
             Event::add($ev, array($c, $m));
         }
     }
     // iterate through the form pages
     foreach ($this->form->pages->page as $page) {
         // set a temporary array to hold the row objects
         $temp_row = array();
         $n_row = 0;
         // iterate through the page rows
         foreach ($page->rows->row as $row) {
             // get the name of the row, and the post name
             $name = (string) $row->name;
             $fname = 'form_' . $name;
             // fix any dates
             steamform_helper::fix_dates($this->post, $row, $fname);
             // create an instance of the form row object
             $temp_row[] = new SteamFormRow($this, $row, $n_row);
             if ($row->type == 'colour') {
                 Display::instance()->append_data('jsfiles', '/cache/js/colour_picker');
             }
             if (isset($row->rules)) {
                 foreach ($row->rules->rule as $rule) {
                     $this->post->add_rules($fname, (string) $rule);
                 }
             }
             if (isset($row->filters)) {
                 foreach ($row->filters->filter as $filter) {
                     $this->post->pre_filter((string) $filter, $fname);
                 }
             }
             if (isset($row->callbacks)) {
                 foreach ($row->callbacks->callback as $callback) {
                     $this->post->add_callbacks($fname, array((string) $callback['class'], (string) $callback));
                 }
             }
             $n_row++;
         }
         $this->rows[] = $temp_row;
     }
 }
示例#10
0
<?php

defined('SYSPATH') or die('No direct access allowed.');
if (class_exists('PHPUnit_Util_Filter')) {
    // Hand control of errors and exceptions to PHPUnit
    if (defined('Kohana::VERSION')) {
        Kohana_Exception::disable();
        Kohana_PHP_Exception::disable();
    } else {
        restore_exception_handler();
        restore_error_handler();
    }
    Event::clear('system.ready');
    Event::clear('system.routing');
    Event::clear('system.execute');
}
 /**
  * add event listener for shutdown event
  *
  * @return void
  * @author Andy Bennett
  */
 public function index()
 {
     Event::clear('system.shutdown');
     Event::add('system.shutdown', array('Webcache_Controller', 'shutdown'));
 }
 function set_listeners()
 {
     parent::set_listeners();
     Event::clear('steamcore.list_view');
     Event::add('steamcore.list_view', array('steam_ordered_listeners', 'list_view_listener'));
 }
示例#13
0
     * This is what makes it possible for Basset routes to be adjusted prior to them being displayed.
     */
    $handler = Bundle::handles(URI::current());
    Route::filter("{$handler}::before", function () {
        Config::set('session.driver', '');
        return Basset::compiled();
    });
    /**
     * After the Basset route is run we'll adjust the response object setting the appropriate content
     * type for the assets.
     */
    Route::filter("{$handler}::after", function ($response) {
        $types = array('less' => 'text/css', 'sass' => 'text/css', 'scss' => 'text/css', 'css' => 'text/css', 'js' => 'text/javascript');
        $extension = File::extension(Request::uri());
        if (array_key_exists($extension, $types)) {
            $response->header('Content-Type', $types[$extension]);
        }
        // To prevent any further output being added to any Basset routes we'll clear any events listening
        // for the laravel.done event.
        Event::clear('laravel.done');
    });
}
/**
 * If the current URI is not being handled by Basset then all registered Basset routes will be
 * compiled once Laravel has finished doing its thing.
 */
if (!starts_with(URI::current(), Bundle::option('basset', 'handles'))) {
    Event::listen('laravel.done', function () {
        Basset::compile();
    });
}
示例#14
0
 /**
  * add form events
  *
  * @return void
  * @author Andy Bennett
  */
 private function form_events()
 {
     /*
     	<events>
     		<event>
     			<clear>true</clear>
     			<event>xform_home_stories_edit.complete</event>
     			<class>adminform_helpers</class>
     			<method>event_home_stories_edit_complete</method>
     		</event>
     	</events>
     */
     if (isset($this->form->events)) {
         foreach ($this->form->events->event as $e) {
             if (!isset($e->class) or !isset($e->method) or !isset($e->event)) {
                 continue;
             }
             $c = (string) $e->class;
             $m = (string) $e->method;
             $ev = (string) $e->event;
             if (isset($e->clear) and (string) $e->clear == 'true') {
                 Event::clear($ev);
             }
             Event::add($ev, array($c, $m));
         }
     }
 }
示例#15
0
<?php

/*
 * replace the stock kohana 404 event with our custom per-site one.
 */
function custom_404()
{
    # this automatically dies to a page or 404
    new Marketing_Controller('nonsense');
}
Event::clear('system.404');
Event::add('system.404', 'custom_404');
/* end */
示例#16
0
* 	http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 
* @copyright 2009 Steamshift Development LLP <*****@*****.**>
* @package Steam
* @subpackage Core
* @category Hook
* @author Andy Bennett
* @version 2.0.3
*/
Event::clear('system.404', array('Kohana', 'show_404'));
Event::add('system.403', 'error_403');
Event::add('system.404', 'error_404');
function error_403()
{
    if (Kohana::$instance == NULL) {
        Kohana::$instance = new Errors_Controller();
    }
    Kohana::log('error', 'Error 403 (steam.core.hooks): ' . URI::instance()->string());
    throw new Kohana_403_Exception(null, 'common/error_403');
}
function error_404()
{
    if (Kohana::$instance == NULL) {
        Kohana::$instance = new Errors_Controller();
    }
 /**
  * edit a user
  *
  * @return void
  * @author Andy Bennett
  */
 public function edit()
 {
     Event::clear('steamform_auth_admin_edit.complete');
     Event::add('steamform_auth_admin_edit.complete', array('auth_admin_events', 'edit_complete'));
     parent::edit();
 }