<commit_before><?php defined('SYSPATH') OR die('No direct script access.');
/**
 * Admin Controller Class for control logging
 *
 * ### System Requirements
 *
 * - PHP 5.3 or higher
 * - Gleez CMS 0.9.26 or higher
 * - MondoDB 2.4 or higher
 * - PHP-extension MongoDB 1.4.0 or higher
 *
 * @package    Mango\Controller\Admin
 * @author     <NAME>
 * @version    0.2.1
 * @copyright  (c) 2011-2013 Gleez Technologies
 * @license    http://gleezcms.org/license  Gleez CMS License
 */

class Controller_Admin_Log extends Controller_Admin {

	/**
	 * Current logs collection
	 * @var Mango_Collection
	 */
	private $collection;

	/**
	 * The before() method is called before controller action
	 *
	 * @uses  ACL::required
	 * @uses  Config::get
	 * @uses  Mango::instance
	 * @uses  Mango::__get
	 */
	public function before()
	{
		ACL::required('view logs');

		$this->collection = Config::get('mango-reader.collections.logs', 'Logs');
		$this->collection = Mango::instance()->{$this->collection};

		parent::before();
	}

	/**
	 * The after() method is called after controller action
	 *
	 * @uses  Route::get
	 * @uses  Route::uri
	 */
	public function after()
	{
		// Tabs
		$this->_tabs =  array(
			array('link' => Route::get('admin/log')->uri(array('action' =>'stat')), 'text' => __('Statistics')),
			array('link' => Route::get('admin/log')->uri(array('action' =>'list')), 'text' => __('List')),
		);

		parent::after();
	}

	/**
	 * Show Log statistics
	 *
	 * @uses  Mango_Collection::getStats
	 */
	public function action_stat()
	{
		$this->title = __('System Log Statistics');

		$view = View::factory('admin/log/stat')
			->set('stats', $this->collection->getStats());

		$this->response->body($view);
	}

	/**
	 * Shows list of events
	 *
	 * @uses  Config::get
	 * @uses  Route::get
	 * @uses  Mango::instance
	 * @uses  Mango_Collection::count
	 * @uses  Mango_Collection::reset
	 * @uses  Mango_Collection::skip
	 * @uses  Mango_Collection::sortDesc
	 * @uses  Mango_Collection::limit<commit_msg>Fixed issue: Do not display the stats tab if collection not exists<commit_after><?php defined('SYSPATH') OR die('No direct script access.');
/**
 * Admin Controller Class for control logging
 *
 * ### System Requirements
 *
 * - PHP 5.3 or higher
 * - Gleez CMS 0.9.26 or higher
 * - MondoDB 2.4 or higher
 * - PHP-extension MongoDB 1.4.0 or higher
 *
 * @package    Mango\Controller\Admin
 * @author     Gleez Team
 * @version    0.2.1
 * @copyright  (c) 2011-2013 Gleez Technologies
 * @license    http://gleezcms.org/license  Gleez CMS License
 */

class Controller_Admin_Log extends Controller_Admin {

	/**
	 * Current logs collection
	 * @var \Mango_Collection
	 */
	private $collection;

	/**
	 * Collection name
	 * @var string
	 */
	private $collection_name;

	/**
	 * The before() method is called before controller action
	 *
	 * @uses  ACL::required
	 * @uses  Config::get
	 * @uses  Mango::instance
	 * @uses  Mango::__get
	 */
	public function before()
	{
		ACL::required('view logs');

		$this->collection_name = Config::get('mango-reader.collections.logs', 'logs');
		$this->collection = Mango::instance()->{$this->collection_name};

		parent::before();
	}

	/**
	 * The after() method is called after controller action
	 *
	 * @uses  Route::get
	 * @uses  Route::uri
	 */
	public function after()
	{
		$exists = Mango::instance()->exists($this->collection_name);

		// Tabs
		$this->_tabs =  array(
			array('link' => Route::get('admin/log')->uri(array('action' =>'list')), 'text' => __('List')),
			$exists ? array('link' => Route::get('admin/log')->uri(array('action' =>'stat')), 'text' => __('Statistics')) : NULL
		);

		parent::after();
	}

	/**
	 * Show Log statistics
	 *
	 * @uses  Mango_Collection::getStats
	 */
	public function action_stat()
	{
		$this->title = __('System Log Statistics');

		$view = View::factory('admin/log/stat')
			->set('stats', $this->collection->getStats());

		$this->response->body($view);
	}

	/**
	 * Shows list of events
	 *
	 * @uses  Config::get
	 * @uses  Route::get
	 * @uses  Mango::instance
	 * @uses  Mango_Collection::count
	 * @uses  Mango_Collection::reset
	 * @uses  Mango_Collection::skip
	 * @uses  Mango_Collection::sortDesc
	 * @uses  Mango_Collection::limit
{'fraction_non_alphanumeric': 0.1721698113207547, 'fraction_numerical': 0.010377358490566037, 'mean_word_length': 3.5749730312837107, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '103933', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1359, 'n_words': 327}