CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.2
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbAclSchema
  • DbConfigTask
  • DboAdodb
  • DboDb2
  • DboFirebird
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOdbc
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • DboSybase
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • Flay
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • i18nSchema
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JsHelper
  • JsHelperObject
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginTask
  • ProjectTask
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • SessionsSchema
  • Set
  • Shell
  • String
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • __enclose
  • make_clean_css
  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • write_css_cache
  1: <?php
  2: /* SVN FILE: $Id$ */
  3: /**
  4:  * Short description for file.
  5:  *
  6:  * Long description for file
  7:  *
  8:  * PHP versions 4 and 5
  9:  *
 10:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 11:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 12:  *
 13:  * Licensed under The MIT License
 14:  * Redistributions of files must retain the above copyright notice.
 15:  *
 16:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 17:  * @link          http://cakephp.org CakePHP(tm) Project
 18:  * @package       cake
 19:  * @subpackage    cake.app.webroot
 20:  * @since         CakePHP(tm) v 0.2.9
 21:  * @version       $Revision$
 22:  * @modifiedby    $LastChangedBy$
 23:  * @lastmodified  $Date$
 24:  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 25:  */
 26: if (!defined('CAKE_CORE_INCLUDE_PATH')) {
 27:     header('HTTP/1.1 404 Not Found');
 28:     exit('File Not Found');
 29: }
 30: /**
 31:  * Enter description here...
 32:  */
 33: if (!class_exists('File')) {
 34:     uses('file');
 35: }
 36: /**
 37:  * Enter description here...
 38:  *
 39:  * @param unknown_type $path
 40:  * @param unknown_type $name
 41:  * @return unknown
 42:  */
 43:     function make_clean_css($path, $name) {
 44:         App::import('Vendor', 'csspp' . DS . 'csspp');
 45:         $data = file_get_contents($path);
 46:         $csspp = new csspp();
 47:         $output = $csspp->compress($data);
 48:         $ratio = 100 - (round(strlen($output) / strlen($data), 3) * 100);
 49:         $output = " /* file: $name, ratio: $ratio% */ " . $output;
 50:         return $output;
 51:     }
 52: /**
 53:  * Enter description here...
 54:  *
 55:  * @param unknown_type $path
 56:  * @param unknown_type $content
 57:  * @return unknown
 58:  */
 59:     function write_css_cache($path, $content) {
 60:         if (!is_dir(dirname($path))) {
 61:             mkdir(dirname($path));
 62:         }
 63:         $cache = new File($path);
 64:         return $cache->write($content);
 65:     }
 66: 
 67:     if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) {
 68:         exit('Wrong file name.');
 69:     }
 70: 
 71:     $filename = 'css/' . $regs[1];
 72:     $filepath = CSS . $regs[1];
 73:     $cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]);
 74: 
 75:     if (!file_exists($filepath)) {
 76:         exit('Wrong file name.');
 77:     }
 78: 
 79:     if (file_exists($cachepath)) {
 80:         $templateModified = filemtime($filepath);
 81:         $cacheModified = filemtime($cachepath);
 82: 
 83:         if ($templateModified > $cacheModified) {
 84:             $output = make_clean_css($filepath, $filename);
 85:             write_css_cache($cachepath, $output);
 86:         } else {
 87:             $output = file_get_contents($cachepath);
 88:         }
 89:     } else {
 90:         $output = make_clean_css($filepath, $filename);
 91:         write_css_cache($cachepath, $output);
 92:         $templateModified = time();
 93:     }
 94: 
 95:     header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT');
 96:     header("Content-Type: text/css");
 97:     header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
 98:     header("Cache-Control: max-age=86400, must-revalidate"); // HTTP/1.1
 99:     header("Pragma: cache");        // HTTP/1.0
100:     print $output;
101: ?>
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs