Changeset 455
- Timestamp:
- 09/01/2007 12:19:19 AM (15 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 removed
- 7 modified
-
modules/user_guide/controllers/user_guide.php (modified) (4 diffs)
-
modules/user_guide/views/user_guide/css/layout.php (modified) (2 diffs)
-
modules/user_guide/views/user_guide/css/spinner.gif (added)
-
modules/user_guide/views/user_guide/js/effects.php (modified) (4 diffs)
-
system/core/Kohana.php (modified) (7 diffs)
-
system/i18n/en/Core.php (deleted)
-
system/i18n/en/Exceptions.php (added)
-
system/libraries/Controller.php (modified) (1 diff)
-
system/libraries/View.php (modified) (3 diffs)
-
system/views/kohana_holiday.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/user_guide/controllers/user_guide.php
r450 r455 72 72 public function _tags() 73 73 { 74 Kohana::$output = preg_replace_callback('!<(benchmark|event|file|definition)>.+?</[^>]+>!', array($this, '_tag_update'), Kohana::$output);74 self::$output = preg_replace_callback('!<(benchmark|event|file|definition)>.+?</[^>]+>!', array($this, '_tag_update'), self::$output); 75 75 } 76 76 … … 99 99 header('Content-type: text/javascript'); 100 100 101 $this->_media('js', preg_replace('/\.js$/ ', '', $filename));101 $this->_media('js', preg_replace('/\.js$/D', '', $filename)); 102 102 } 103 103 … … 106 106 header('Content-type: text/css'); 107 107 108 $this->_media('css', preg_replace('/\.css$/ ', '', $filename));108 $this->_media('css', preg_replace('/\.css$/D', '', $filename)); 109 109 } 110 110 … … 118 118 $this->load->view('user_guide/'.$type.'/'.$filename)->render(TRUE); 119 119 } 120 catch ( file_not_found$exception)120 catch (Kohana_Exception $exception) 121 121 { 122 122 print '/* script not found */'; -
trunk/modules/user_guide/views/user_guide/css/layout.php
r452 r455 9 9 Default Styles 10 10 */ 11 body { background: # 111; color: #111; font-size: 82%; line-height: 140%; font-family: "Lucida Grande", Arial, Verdana, sans-serif; }11 body { background: #f7fbf1; color: #111; font-size: 82%; line-height: 140%; font-family: "Lucida Grande", Arial, Verdana, sans-serif; } 12 12 a { color: #449; text-decoration: none; } 13 13 h1 { border-bottom: solid 1px #999; font-size: 2.5em; text-align: center; color: #b43f11; } … … 22 22 Template Styles 23 23 */ 24 #container { position: relative; width: 70%; min-width: 30em; max-width: 60em; margin: 0 auto; }25 #menu { position: absolute; right: -10.1em; width: 10em; padding: 0.2em 0; }24 #container { position: relative; margin: 0 12em 2em 1em; border: solid 0 #e7f5d7; border-width: 0 0.2em 0.3em 0.2em; } 25 #menu { position: fixed; top: 0; right: 1.5em; width: 10em; padding: 0.2em 0; } 26 26 #menu ul { margin: 0 0.2em; list-style: none; color: #b43f11; } 27 #menu li ul { padding: 0.1em 0; margin-right: 0; font-size: 0.8em; color: #444; }27 #menu li.first { font-size: 1.4em; padding-top: 0.2em; } 28 28 #menu li.active li.lite { color: #b43f11; } 29 #menu li ul a { color: #666; }30 #menu ul a:hover { text-decoration: underline; color: #45721d; }31 #menu li .first { font-size: 1.2em; }29 #menu li ul { padding: 0.1em 0; margin-right: 0; font-size: 0.7em; color: #444; } 30 #menu li ul a { color: #333; } 31 #menu li ul a:hover { font-weight: bold; color: #2f4f14; } 32 32 #menu li span { cursor: pointer; } 33 #body , #footer { padding: 0 0.5em; background: #eee; }33 #body { padding: 0.3em 1em; background: #fff; } 34 34 #body ol, #body ul { margin: 1em; margin-left: 2.5em; } 35 35 #body ol { list-style: decimal; } 36 36 #body ul { list-style: circle; } 37 37 #body li { padding: 0.1em 0; } 38 #loading { position: absolute; top: 0; right: 0; z-index: 9999; padding: 0.5em 2em; background: #fff; border: solid 0 #aaa; border-width: 0 0 1px 1px; text-align: center; text-transform: uppercase; font-size: 0.7em; } 38 #footer { padding: 0 1em; background: #fff; line-height: 2em; } 39 #loading { position: absolute; top: 0; right: 0; z-index: 9999; width: 32px; height: 32px; background: transparent url(spinner.gif) center center no-repeat; } 39 40 #loading span { color: #400; } 40 41 /* -
trunk/modules/user_guide/views/user_guide/js/effects.php
r452 r455 1 1 // $Id$ 2 2 $(document).ready(function(){ 3 // Menu opacity hover effect, much fancy pants! 4 $('#menu').css('opacity', 0.75).hover(function(){ 5 $(this).fadeTo(100, 0.9); 6 }, function(){ 7 $(this).fadeTo(300, 0.7) 8 }); 3 9 // Append the AJAX loader 4 $('#container').append('<div id="loading"><span>…loading</span></div>'); 5 // To prevent extra querying 6 Kohana.loading = $('#loading').hide().css('opacity', 0.85); 7 // Make the menu sticky 8 $(window).scroll(function(){ 9 $('#menu').css('top', $(window).scrollTop()); 10 }); 11 // Apply menu effects 12 $('#menu li.first li') 13 .hide() // Hide these li's 14 .parent() // Parent ul 15 .parent() // Parent li 16 .click(function(){ 17 // Hover affects the ul > li inside of this li 18 var curr = $('#menu li.active'); 19 var self = $(this); 20 // Clicks to the same element will do nothing 21 if (self.is('.active') == false) 22 { 23 // Hide the current elements 24 curr.removeClass('active') 25 .find('ul > li') 26 .stack('animate', {height: 'hide', width: 'hide'}, 100); 27 // Show the new elements 28 self.addClass('active') 29 .find('ul > li') 30 .stack('animate', {height: 'show', width: 'show'}, 100); 31 } 10 $('#container').append('<div id="loading"> </div>'); 11 // To prevent extra querying, add the loading element to Kohana after hiding it 12 Kohana.loading = $('#loading').hide(); 13 // Apply menu sliding effect 14 $('#menu li.first').click(function(){ 15 // Define the current menu and the clicked menu 16 var curr = $('#menu li.active'); 17 var self = $(this); 18 // Clicks to the same menu will do nothing 19 if (self.is('.active') == false) 20 { 21 // Hide the current elements 22 curr.removeClass('active') 23 .find('ul') 24 .slideUp(250); 25 // Show the new elements 26 self.addClass('active') 27 .find('ul') 28 .slideDown(250); 32 29 } 33 ). 34 // Find links in the menu 35 find('a') 36 .click(function(){ 30 }) 31 // Find and hide the sub menus that are not in the active menu 32 .not('.active').find('ul').hide(); 33 // Add AJAX functionality to the menu links 34 $('#menu a').click(function(){ 37 35 // Show loading 38 36 Kohana.toggleLoading(true); 39 37 // Fetch the current link 40 38 var link = $(this); 41 // Make AJAX request 39 // Make AJAX request, using ?ajax=true 42 40 $.get(link.attr('href'), {ajax: 'true'}, function(data) { 43 // Add the "lite"class to the current link44 $('#menu li.activeli.lite').removeClass('lite');41 // Add the hilight class to the current link 42 $('#menu ul li.lite').removeClass('lite'); 45 43 link.parent().addClass('lite'); 46 44 // Load new AJAX content … … 51 49 return false; 52 50 }); 53 // Show the active menu54 $('#menu li.active ul > li')55 .stack('animate', {height: 'show', width: 'show'}, 100);56 51 }); 57 52 // Special Kohana functions … … 62 57 // If we are waiting for an animation, retry in 5ms 63 58 if (Kohana.waiting == true) { 64 setTimeout('Kohana.toggleLoading('+on+')', 100);59 setTimeout('Kohana.toggleLoading('+on+')', 20); 65 60 return false; 66 61 } … … 68 63 Kohana.waiting = true; 69 64 if (on == true) { // Show loading 70 this.loading.slideDown(2 00, function() {65 this.loading.slideDown(250, function() { 71 66 Kohana.waiting = false; 72 67 }); 73 68 } else { // Hide loading 74 this.loading.slideUp(2 00, function() {69 this.loading.slideUp(250, function() { 75 70 Kohana.waiting = false; 76 71 }); -
trunk/system/core/Kohana.php
r448 r455 27 27 class Kohana { 28 28 29 public static $buffer_level = 0; // Ouput buffering level 30 public static $error_types = array(); // Human readable error types 31 public static $registry = array(); // Library registery 32 33 public static $output = ''; 34 35 private static $instance = FALSE; // Controller instance 29 // The singleton instance of the controller 30 private static $instance = NULL; 31 32 // Human readable error types, for PHP errors 33 private static $error_types = array(); 34 35 // Error strings that will be displayed by unhandled exceptions 36 private static $error_strings = array(); 37 38 // Library registery, to prevent multiple loads of libraries 39 private static $libraries = array(); 40 41 // Ouput buffering level 42 private static $buffer_level = 0; 43 44 // The final output that will displayed by Kohana 45 // This variable is protected, so that the controller can overload it 46 protected static $output = ''; 36 47 37 48 /** … … 46 57 public function __construct() 47 58 { 48 if (self::$instance == FALSE) 49 { 50 self::$instance = $this; 51 } 52 else 53 { 54 trigger_error('<em>“There can be only one [instance of Kohana]!“</em>', E_USER_ERROR); 55 } 59 if (is_object(self::$instance)) 60 throw new Exception('there_can_be_only_one'); 61 62 self::$instance = $this; 56 63 } 57 64 … … 79 86 { 80 87 static $run; 88 81 89 // This function can only be run once 82 90 if ($run === TRUE) return; … … 256 264 public static function exception_handler($exception) 257 265 { 266 258 267 /** 259 268 * @todo This needs to choose a i18n message based on the type of exception + message … … 339 348 public static function load_class($class) 340 349 { 341 if (isset(self::$ registry[$class]))342 { 343 return self::$ registry[$class];350 if (isset(self::$libraries[$class])) 351 { 352 return self::$libraries[$class]; 344 353 } 345 354 346 355 if ($class == 'Controller') 347 356 { 348 self::$ registry[$class] = TRUE;357 self::$libraries[$class] = TRUE; 349 358 } 350 359 else 351 360 { 352 self::$ registry[$class] = new $class();353 } 354 355 return self::$ registry[$class];361 self::$libraries[$class] = new $class(); 362 } 363 364 return self::$libraries[$class]; 356 365 } 357 366 … … 365 374 * @return mixed 366 375 */ 367 public static function find_file($directory, $filename, $required = FALSE )376 public static function find_file($directory, $filename, $required = FALSE, $ext = FALSE) 368 377 { 369 378 static $found = array(); 370 379 371 380 $search = $directory.DIRECTORY_SEPARATOR.$filename; 372 373 if (isset($found[$search])) 374 return $found[$search]; 375 376 $paths = Config::include_paths(); 381 $hash = md5($search); 382 383 if (isset($found[$hash])) 384 return $found[$hash]; 377 385 378 386 if ($directory == 'config' OR $directory == 'i18n') 379 387 { 388 $fnd = array(); 389 380 390 // Search from SYSPATH up 381 $paths = array_reverse($paths);382 383 // Create a braced list for glob384 $paths = '{'.implode(',', $paths).'}';385 386 // Find all matching files, without sorting387 if ( ($files = glob($paths.$search.EXT, GLOB_BRACE + GLOB_NOSORT)) != FALSE)388 {389 return $found[$search] = $files; 390 }391 foreach(array_reverse(Config::include_paths()) as $path) 392 { 393 if (is_file($path.$search.EXT)) $fnd[] = $path.$search.EXT; 394 } 395 396 // If required and nothing was found, throw an exception 397 if ($required == TRUE AND $fnd === array()) 398 throw new Kohana_Exception('resource_not_found', $directory, $filename); 399 400 return $found[$hash] = $fnd; 391 401 } 392 402 else 393 403 { 404 // Users can define their own extensions, .css, etc 405 $ext = ($ext == FALSE) ? EXT : ''; 406 394 407 // Find the file and return it's filename 395 foreach ( $pathsas $path)396 { 397 if (is_file($path.$search. EXT))408 foreach (Config::include_paths() as $path) 409 { 410 if (is_file($path.$search.$ext)) 398 411 { 399 return $found[$ search] = $path.$search.EXT;412 return $found[$hash] = $path.$search.$ext; 400 413 } 401 414 } 402 } 403 404 // If the function gets this far in execution, it means that no file 405 // was located. If the file was flagged as required, return an error. 406 ($required === TRUE) and trigger_error 407 ( 408 'Unable to locate the requested file, <tt>'.$filename.EXT.'</tt>', 409 E_USER_ERROR 410 ); 411 412 // File is not required, return FALSE 413 return FALSE; 415 416 // If the file is required, throw an exception 417 if ($required == TRUE) 418 throw new Kohana_Exception('resource_not_found', $directory, $filename); 419 420 return $found[$hash] = FALSE; 421 } 422 } 423 424 public static function lang($type = FALSE, $name = TRUE) 425 { 426 static $found = array(); 427 428 // Throw an exception if the type is not specified 429 if ($type == FALSE) 430 throw new Kohana_Exception('A language message type must be used when calling <code>Kohan::lang()</code>.'); 431 432 if ( ! isset($found[$type])) 433 { 434 // Messages from this file 435 $messages = array(); 436 437 // The name of the file to search for 438 $filename = Config::item('core.locale').DIRECTORY_SEPARATOR.ucfirst($type); 439 440 // Loop through the files and include each one, so SYSPATH files 441 // can be overloaded by more localized files 442 foreach(array_reverse(self::find_file('i18n', $filename)) as $filename) 443 { 444 include $filename; 445 446 // Merge in configuration 447 if (isset($lang) AND is_array($lang)) 448 { 449 $messages = array_merge($messages, $lang); 450 } 451 } 452 453 // Cache the type 454 $found[$type] = $messages; 455 } 456 457 // Return something 458 if ($name === TRUE) 459 { 460 return $found[$type]; 461 } 462 elseif ($found[$type] == FALSE OR ! isset($found[$type][$name])) 463 { 464 return FALSE; 465 } 466 else 467 { 468 return $found[$type][$name]; 469 } 414 470 } 415 471 … … 460 516 461 517 } // End Kohana class 518 519 class Kohana_Exception extends Exception { 520 521 protected $message = 'Unknown Exception: '; 522 523 protected $file = ''; 524 protected $line = 0; 525 protected $code = 0; 526 527 528 function __construct($error) 529 { 530 // Fetch the error message 531 $message = Kohana::lang('exceptions', $error); 532 533 // Handle error messages that are not set 534 if ($message == '') 535 { 536 $this->message .= $error; 537 } 538 else 539 { 540 // Add in the args if necessary, removing the $error arg 541 if (count($args = array_slice(func_get_args(), 1)) > 0) 542 { 543 $this->message = vsprintf($message, $args); 544 } 545 else 546 { 547 $this->message = $message; 548 } 549 } 550 } 551 552 public function __toString() 553 { 554 return $this->message; 555 } 556 557 } // End Kohana Exception Class -
trunk/system/libraries/Controller.php
r450 r455 22 22 public function kohana_include_view($kohana_view_filename, $kohana_input_data) 23 23 { 24 if ($kohana_view_filename == '') return; 25 24 26 // Buffering on 25 27 ob_start(); -
trunk/system/libraries/View.php
r447 r455 33 33 class View_Core { 34 34 35 private $kohana_view_filename; 36 private $kohana_renderer = ''; 35 private $kohana_filename = FALSE; 36 private $kohana_renderer = FALSE; 37 private $kohana_filetype = FALSE; 38 private $kohana_protected = FALSE; 37 39 private $data = array(); 38 40 39 41 public function __construct($name, $data = NULL) 40 42 { 41 $this->kohana_view_filename = Kohana::find_file('views', $name, TRUE); 43 if (preg_match('/\.(gif|jpg|png|swf)$/Di', $name, $type)) 44 { 45 $type = $type[1]; 46 $this->kohana_filename = Kohana::find_file('views', $name, TRUE, $type); 47 $this->kohana_filetype = image_type_to_mime_type(exif_imagetype($this->kohana_filename)); 48 } 49 else 50 { 51 $this->kohana_filename = Kohana::find_file('views', $name, TRUE); 52 } 42 53 43 54 // Preload data … … 59 70 public function __set($name, $value) 60 71 { 61 if ($name == 'kohana_view_filename' AND $this->kohana_view_filename == FALSE) 72 $protected = array('kohana_filename', 'kohana_renderer', 'kohana_filetype'); 73 74 if (in_array($name, $protected) AND $this->$name === FALSE) 62 75 { 63 $this-> kohana_view_filename = $value;76 $this->$name = $value; 64 77 } 65 78 else … … 84 97 public function render($print = FALSE, $callback = FALSE) 85 98 { 86 $output = Kohana::instance()->kohana_include_view($this->kohana_view_filename, $this->data); 99 if ($this->kohana_filetype == FALSE) 100 { 101 $output = Kohana::instance()->kohana_include_view($this->kohana_filename, $this->data); 87 102 88 if ($callback != FALSE)89 {90 $output = Kohana::callback($callback, $output);91 }103 if ($callback != FALSE) 104 { 105 $output = Kohana::callback($callback, $output); 106 } 92 107 93 if ($print == TRUE) 94 { 95 print $output; 108 if ($print == TRUE) 109 { 110 111 print $output; 112 } 113 else 114 { 115 return $output; 116 } 96 117 } 97 118 else 98 119 { 99 return $output; 120 header('Content-type: '.$this->kohana_filetype); 121 122 if ($print == TRUE) 123 { 124 fpassthru(($file = fopen($this->kohana_filename, 'rb'))); 125 fclose($file); 126 } 127 else 128 { 129 return file_get_contents($this->kohana_filename); 130 } 100 131 } 101 132 } -
trunk/system/views/kohana_holiday.php
r447 r455 1 <?php 2 header('Content-type: image/gif'); 3 exit(base64_decode('R0lGODlhoACAAPcAAAEAAAoBAAwJCBMBABcLCBsDARsTESMEASgJBCkTCywaFDcJAzkUCDofIzYkGTcsJ0QBAEcLBUwBAEcYCE8ZFFQBAFoFAlYaBk0pFVkkClkpFE83KmcIAGwRBXgWAWYeIGYqCW4wD2g3F3okBHY6Fmw3J2M/QFdDNmxCHHpDGWlGKHdIJnJOMnpXNn9gO1RIRHFYSXpjUnRoZokNG4YZAIsbAJgXAIYlA4skAY01FpcoAZsxAY83KKUaAKYoAKsjAKc0A6k6E7cpALU6Ars0AKIgKoZIGJRPHI5NLopWKIVbN5ZZJ4djOpxiKphmN51wPrtCA7BIGq1TL7hiHKVqNq5tMapzOYxXR41tTIhqVo9wU5ZrR5l0SY51aZZ7Z61SSah3R6Z7VrJxS6p6acUsAMY3AMs8AtY6AtMrK8cxQsdFA8tDAc1WFNdIAttTBMhaKdpkFtFwMeVIAOtLAONUAuVZCuxUAOxbAvBOAfFXAPJcAe1lBex0E/JkAfNrA/NtCvR0A/V7BPN4C+R6KMxgWsp2SLaAPJyDapqEd6CDX6iEWriFTLeIV6aJZ6WLdquTeLaQaraYeNqINu6DG/eHB/SHFfqXCfaXFe+SLvu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