/**
  * Do multi-page navigation.  Displays the prev, next and page options.
  * @param $page the page currently viewed
  * @param $pages the maximum number of pages
  * @param $url the url to refer to with the page number inserted
  * @param $max_width the number of pages to make available at any one time (default = 20)
  */
 function printPages($page, $pages, $url, $max_width = 20)
 {
     Console::logSpeed('Time taken to get to line ' . __LINE__);
     global $lang;
     $window = 8;
     if ($page < 0 || $page > $pages) {
         return;
     }
     if ($pages < 0) {
         return;
     }
     if ($max_width <= 0) {
         return;
     }
     if ($pages > 1) {
         //echo "<center><p>\n";
         if ($page != 1) {
             $temp = str_replace('%s', 1 - 1, $url);
             echo "<a class=\"pagenav\" href=\"{$temp}\">{$this->lang['strfirst']}</a>\n";
             $temp = str_replace('%s', $page - 1 - 1, $url);
             echo "<a class=\"pagenav\" href=\"{$temp}\">{$this->lang['strprev']}</a>\n";
         }
         if ($page <= $window) {
             $min_page = 1;
             $max_page = min(2 * $window, $pages);
         } elseif ($page > $window && $pages >= $page + $window) {
             $min_page = $page - $window + 1;
             $max_page = $page + $window;
         } else {
             $min_page = $page - (2 * $window - ($pages - $page)) + 1;
             $max_page = $pages;
         }
         // Make sure min_page is always at least 1
         // and max_page is never greater than $pages
         $min_page = max($min_page, 1);
         $max_page = min($max_page, $pages);
         for ($i = $min_page; $i <= $max_page; $i++) {
             $temp = str_replace('%s', $i - 1, $url);
             if ($i != $page) {
                 echo "<a class=\"pagenav\" href=\"{$temp}\">{$i}</a>\n";
             } else {
                 echo "{$i}\n";
             }
         }
         if ($page != $pages) {
             $temp = str_replace('%s', $page + 1 - 1, $url);
             echo "<a class=\"pagenav\" href=\"{$temp}\">{$this->lang['strnext']}</a>\n";
             $temp = str_replace('%s', $pages - 1, $url);
             echo "<a class=\"pagenav\" href=\"{$temp}\">{$this->lang['strlast']}</a>\n";
         }
     }
 }
Exemple #2
0
	public function sampleSpeedComparison() {
		Console::logSpeed('Time taken to get to line '.__LINE__);
		Console::logSpeed('Time taken to get to line '.__LINE__);
		Console::logSpeed('Time taken to get to line '.__LINE__);
		Console::logSpeed('Time taken to get to line '.__LINE__);
		Console::logSpeed('Time taken to get to line '.__LINE__);
		Console::logSpeed('Time taken to get to line '.__LINE__);
	}
 public static function profile($that = '', $function = '', $line = '', $msg = '')
 {
     if (defined('OWA_PROFILER')) {
         if (OWA_PROFILER === true) {
             static $profiler;
             if (!class_exists('PhpQuickProfiler')) {
                 require_once OWA_INCLUDE_DIR . 'pqp/classes/PhpQuickProfiler.php';
             }
             if (empty($profiler)) {
                 $profiler = new PhpQuickProfiler(PhpQuickProfiler::getMicroTime(), OWA_INCLUDE_DIR . 'pqp/');
             }
             $class = get_class($that);
             Console::logSpeed($class . "::{$function} - Line: {$line} - Msg: {$msg}");
             Console::logMemory($that, $class . "::{$function} - Line: {$line}");
             return $profiler;
         }
     }
 }
 function PKPApplication()
 {
     // Configure error reporting
     // FIXME: Error logging needs to be suppressed for strict
     // and deprecation errors in PHP5 as long as we support PHP 4.
     // This is primarily for static method warnings and warnings
     // about use of ... =& new ... Static class members cannot be
     // declared in PHP4 and ... =& new ... is deprecated since PHP 5.
     $errorReportingLevel = E_ALL;
     if (defined('E_STRICT')) {
         $errorReportingLevel &= ~E_STRICT;
     }
     if (defined('E_DEPRECATED')) {
         $errorReportingLevel &= ~E_DEPRECATED;
     }
     @error_reporting($errorReportingLevel);
     // Instantiate the profiler
     import('lib.pkp.classes.core.PKPProfiler');
     $pkpProfiler = new PKPProfiler();
     // Begin debug logging
     Console::logMemory('', 'PKPApplication::construct');
     Console::logSpeed('PKPApplication::construct');
     // Seed random number generator
     mt_srand((double) microtime() * 1000000);
     import('lib.pkp.classes.core.Core');
     import('lib.pkp.classes.core.String');
     import('lib.pkp.classes.core.Registry');
     import('lib.pkp.classes.config.Config');
     if (Config::getVar('debug', 'display_errors')) {
         // Try to switch off normal error display when error display
         // is being managed by OJS.
         @ini_set('display_errors', false);
     }
     if (Config::getVar('debug', 'deprecation_warnings')) {
         // Switch deprecation warnings back on. This can only be done
         // after declaring the Config class as we need access to the
         // configuration and we cannot declare the Config class before
         // we've switched of deprecation warnings as its declaration
         // causes warnings itself.
         // FIXME: When we drop PHP4 support and can declare static methods
         // as such then we can also include E_STRICT/E_DEPRECATED here as
         // nearly all strict/deprecated warnings concern PHP4 support.
         @error_reporting($errorReportingLevel);
     }
     Registry::set('application', $this);
     import('lib.pkp.classes.db.DAORegistry');
     import('lib.pkp.classes.db.XMLDAO');
     import('lib.pkp.classes.cache.CacheManager');
     import('classes.security.Validation');
     import('lib.pkp.classes.session.SessionManager');
     import('classes.template.TemplateManager');
     import('lib.pkp.classes.plugins.PluginRegistry');
     import('lib.pkp.classes.plugins.HookRegistry');
     import('classes.i18n.AppLocale');
     String::init();
     set_error_handler(array($this, 'errorHandler'));
     $microTime = Core::microtime();
     Registry::set('system.debug.startTime', $microTime);
     $notes = array();
     Registry::set('system.debug.notes', $notes);
     Registry::set('system.debug.profiler', $pkpProfiler);
     if (Config::getVar('general', 'installed')) {
         // Initialize database connection
         $conn =& DBConnection::getInstance();
         if (!$conn->isConnected()) {
             if (Config::getVar('database', 'debug')) {
                 $dbconn =& $conn->getDBConn();
                 fatalError('Database connection failed: ' . $dbconn->errorMsg());
             } else {
                 fatalError('Database connection failed!');
             }
         }
     }
 }
 static function pqp_post_controller()
 {
     Console::logMemory(FALSE, 'CI POST CONTROLLER');
     Console::logSpeed('CI POST CONTROLLER');
 }
 function wpdt_end()
 {
     if (!is_admin() && current_user_can("level_10") && get_option('wpdt_quick_profiler')) {
         Console::logSpeed('Concluding!');
         $this->profiler->display($this->db);
         remove_action('init', array(&$this, 'wpdt_init'));
         remove_action('wp_footer', array(&$this, 'wpdt_end'));
         foreach ($this->filter_list as $filter) {
             if (get_option('wpdt_' . $filter) == 'checked') {
                 remove_filter($filter, 'wpdt_' . $filter);
             }
         }
     }
 }
Exemple #7
0
 /**
  * Add in any Benchmark Results to the PQP Profiler
  *
  * @return void
  * @author Dan Morin
  **/
 static function pqp_benchmark_results()
 {
     $CI = get_instance();
     $profile = array();
     foreach ($CI->benchmark->marker as $key => $val) {
         // We match the "end" marker so that the list ends
         // up in the order that it was defined
         if (preg_match("/(.+?)_end/i", $key, $match)) {
             if (isset($CI->benchmark->marker[$match[1] . '_end']) and isset($CI->benchmark->marker[$match[1] . '_start'])) {
                 $profile[$match[1]] = $CI->benchmark->elapsed_time($match[1] . '_start', $key);
             }
         }
     }
     foreach ($profile as $key => $val) {
         $key = ucwords(str_replace(array('_', '-'), ' ', $key));
         Console::log($key . ': ' . $val);
         Console::logSpeed($key . ': ' . $val);
     }
     Console::log('GET: ' . print_r($_GET, TRUE));
     Console::log('POST: ' . print_r($_POST, TRUE));
 }
 public static function speed($name)
 {
     if (isset(self::$profiler)) {
         Console::logSpeed($name);
     }
 }
Exemple #9
0
<?php

/**
 * Events - all standard Events are defined here.
 *
 * @author Virgil-Adrian Teaca - virgil@giulianaeassociati.com
 * @version 3.0
 */
/** Define Events. */
// Add a Listener Closure to the Event 'nova.framework.booting'.
Event::listen('nova.framework.booting', function () {
    Console::logSpeed("Nova Framework booting");
});
// Add a Listener Closure to the Event 'router.matched'.
Event::listen('router.matched', function ($route, $request) {
    // Share the Views the current URI.
    View::share('currentUri', $request->path());
    // Share the Views the Backend's base URI.
    $segments = $request->segments();
    if (!empty($segments)) {
        // Make the path equal with the first part if it exists, i.e. 'admin'
        $baseUri = array_shift($segments) . '/';
        // Add to path the next part, if it exists, defaulting to 'dashboard'.
        $baseUri .= !empty($segments) ? array_shift($segments) : 'dashboard';
    } else {
        $baseUri = '';
    }
    View::share('baseUri', $baseUri);
});