Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • BaseOperation
  • CacheManager
  • CatalogsCacheManager
  • ClearOperation
  • Collection
  • ConfigOperation
  • ConfigsCacheManager
  • DisableOperation
  • EditorOperation
  • EnableOperation
  • Hooks
  • ManageBlock
  • Module
  • ModulesCacheManager
  • StatOperation

Interfaces

  • CacheManagerInterface

Exceptions

  • CacheNotDefined
  1 <?php
  2 
  3 /*
  4  * This file is part of the Icybee package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 namespace Icybee\Modules\Cache;
 13 
 14 use ICanBoogie\I18n;
 15 
 16 class Module extends \Icybee\Module
 17 {
 18     static public function get_files_stat($path, $pattern=null)
 19     {
 20         $root = \ICanBoogie\DOCUMENT_ROOT;
 21 
 22         if (!file_exists($path))
 23         {
 24             $path = $root . $path;
 25         }
 26 
 27         if (!file_exists($path))
 28         {
 29             mkdir($path, 0705, true);
 30 
 31             if (!file_exists($path))
 32             {
 33                 return array
 34                 (
 35                     0, '<span class="warning">Impossible de créer le dossier&nbsp: <em>' . \ICanBoogie\strip_root($path) . '</em></span>'
 36                 );
 37             }
 38         }
 39 
 40         if (!is_writable($path))
 41         {
 42             return array
 43             (
 44                 0, '<span class="warning">Dossier vérouillé en écriture&nbsp: <em>' . \ICanBoogie\strip_root($path) . '</em></span>'
 45             );
 46         }
 47 
 48         $n = 0;
 49         $size = 0;
 50         $iterator = new \DirectoryIterator($path);
 51 
 52         if ($pattern)
 53         {
 54             $iterator = new \RegexIterator($iterator, $pattern);
 55         }
 56 
 57         foreach ($iterator as $file)
 58         {
 59             $filename = $file->getFilename();
 60 
 61             if ($filename{0} == '.')
 62             {
 63                 continue;
 64             }
 65 
 66             ++$n;
 67             $size += $file->getSize();
 68         }
 69 
 70         return array
 71         (
 72             $n, I18n\t(':count files<br /><span class="small">:size</span>', array(':count' => $n, 'size' => \ICanBoogie\I18n\format_size($size)))
 73         );
 74     }
 75 
 76     static public function get_vars_stat($regex)
 77     {
 78         global $core;
 79 
 80         $n = 0;
 81         $size = 0;
 82 
 83         foreach ($core->vars->matching($regex) as $pathname => $fileinfo)
 84         {
 85             ++$n;
 86             $size += $fileinfo->getSize();
 87         }
 88 
 89         return array
 90         (
 91             $n, I18n\t(':count files<br /><span class="small">:size</span>', array(':count' => $n, 'size' => \ICanBoogie\I18n\format_size($size)))
 92         );
 93     }
 94 
 95     /**
 96      * Deletes files in a directory according to a RegEx pattern.
 97      *
 98      * @param string $path Path to the directory where the files shoud be deleted.
 99      * @param string|null $pattern RegEx pattern to delete matching files, or null to delete all
100      * files.
101      */
102     static public function clear_files($path, $pattern=null)
103     {
104         $root = \ICanBoogie\DOCUMENT_ROOT;
105 
106         if (strpos($path, $root) !== 0)
107         {
108             $path = $root . $path;
109         }
110 
111         if (!is_dir($path))
112         {
113             return false;
114         }
115 
116         $n = 0;
117         $dh = opendir($path);
118 
119         while (($file = readdir($dh)) !== false)
120         {
121             if ($file{0} == '.' || ($pattern && !preg_match($pattern, $file)))
122             {
123                 continue;
124             }
125 
126             $n++;
127             unlink($path . '/' . $file);
128         }
129 
130         return $n;
131     }
132 }
Autodoc API documentation generated by ApiGen 2.8.0