Added ApcCacheSource to the CacheListPage
authorRouL <roul@codingcorner.info>
Sat, 16 Jul 2011 17:44:31 +0000 (19:44 +0200)
committerRouL <roul@codingcorner.info>
Sat, 16 Jul 2011 17:53:55 +0000 (19:53 +0200)
wcfsetup/install/files/acp/templates/cacheList.tpl
wcfsetup/install/files/lib/acp/page/CacheListPage.class.php

index 9722809832543d9acf838fb7aaa609cffd75f911..bf0342c6f3719f45e192b36d86738a054133c5db 100644 (file)
@@ -1,90 +1,94 @@
-{include file='header'}\r
-\r
-<div class="mainHeadline">\r
-       <img src="{@RELATIVE_WCF_DIR}icon/cacheL.png" alt="" />\r
-       <div class="headlineContainer">\r
-               <h2>{lang}wcf.acp.cache.list{/lang}</h2>\r
-       </div>\r
-</div>\r
-\r
-{if $cleared}\r
-       <p class="success">{lang}wcf.acp.cache.clear.success{/lang}</p> \r
-{/if}\r
-\r
-<fieldset>\r
-       <legend>{lang}wcf.acp.cache.data{/lang}</legend>\r
-       \r
-       <div class="formElement">\r
-               <p class="formFieldLabel">{lang}wcf.acp.cache.data.source{/lang}</p>\r
-               <p class="formField">{$cacheData.source}</p>\r
-       </div>\r
-       {if $cacheData.version}\r
-               <div class="formElement">\r
-                       <p class="formFieldLabel">{lang}wcf.acp.cache.data.version{/lang}</p>\r
-                       <p class="formField">{$cacheData.version}</p>\r
-               </div>\r
-       {/if}\r
-       <div class="formElement">\r
-               <p class="formFieldLabel">{lang}wcf.acp.cache.data.size{/lang}</p>\r
-               <p class="formField">{@$cacheData.size|filesize}</p>\r
-       </div>\r
-       <div class="formElement">\r
-               <p class="formFieldLabel">{lang}wcf.acp.cache.data.files{/lang}</p>\r
-               <p class="formField">{#$cacheData.files}</p>\r
-       </div>\r
-       \r
-       {if $additionalFields|isset}{@$additionalFields}{/if}\r
-</fieldset>\r
-\r
-<div class="contentHeader">\r
-       <div class="largeButtons">\r
-               <ul>\r
-                       <li><a onclick="return confirm('{lang}wcf.acp.cache.clear.sure{/lang}')" href="index.php?action=CacheClear{@SID_ARG_2ND}"><img src="{@RELATIVE_WCF_DIR}icon/deleteM.png" alt="" /> <span>{lang}wcf.acp.cache.button.clear{/lang}</span></a></li>\r
-                       {if $additionalLargeButtons|isset}{@$additionalLargeButtons}{/if}\r
-               </ul>\r
-       </div>\r
-</div>\r
-\r
-{foreach from=$caches key=cache item=files}\r
-       {if $files|count}\r
-               <div class="border titleBarPanel">\r
-                       <div class="containerHead">\r
-                               <div class="containerIcon">\r
-                                       <a onclick="openList('{$cache}')"><img src="{@RELATIVE_WCF_DIR}icon/minusS.png" id="{$cache}Image" alt="" /></a>\r
-                               </div>\r
-                               <div class="containerContent">\r
-                                       <h3>{$cache} ({#$files|count})</h3>\r
-                               </div>\r
-                       </div>\r
-               </div>\r
-               <div class="border borderMarginRemove" id="{$cache}">\r
-                       <table class="tableList">\r
-                               <thead>\r
-                                       <tr class="tableHead">\r
-                                               <th><div><span class="emptyHead">{lang}wcf.acp.cache.list.name{/lang}</span></div></th>\r
-                                               <th><div><span class="emptyHead">{lang}wcf.acp.cache.list.size{/lang}</span></div></th>\r
-                                               <th><div><span class="emptyHead">{lang}wcf.acp.cache.list.mtime{/lang}</span></div></th>\r
-                                               <th><div><span class="emptyHead">{lang}wcf.acp.cache.list.perm{/lang}</span></div></th>\r
-                                       </tr>\r
-                               </thead>\r
-                               <tbody>\r
-                               {foreach from=$files item=file}\r
-                                       <tr class="{cycle values="container-1,container-2"}">\r
-                                               <td class="columnText">{$file.filename}</td>\r
-                                               <td class="columnNumbers">{@$file.filesize|filesize}</td>\r
-                                               <td class="columnDate">{if $file.mtime > 1}{@$file.mtime|time}{/if}</td>\r
-                                               <td class="columnNumbers"{if !$file.writable} style="color: #c00"{/if}>{@$file.perm}</td>\r
-                                       </tr>\r
-                               {/foreach}\r
-                               </tbody>\r
-                       </table>\r
-               </div>\r
-               <script type="text/javascript">\r
-                       //<![CDATA[\r
-                       initList('{$cache}', 0);\r
-                       //]]>\r
-               </script>\r
-       {/if}\r
-{/foreach}\r
-\r
-{include file='footer'}\r
+{include file='header'}
+
+<div class="mainHeadline">
+       <img src="{@RELATIVE_WCF_DIR}icon/cacheL.png" alt="" />
+       <div class="headlineContainer">
+               <h2>{lang}wcf.acp.cache.list{/lang}</h2>
+       </div>
+</div>
+
+{if $cleared}
+       <p class="success">{lang}wcf.acp.cache.clear.success{/lang}</p> 
+{/if}
+
+<fieldset>
+       <legend>{lang}wcf.acp.cache.data{/lang}</legend>
+       
+       <div class="formElement">
+               <p class="formFieldLabel">{lang}wcf.acp.cache.data.source{/lang}</p>
+               <p class="formField">{$cacheData.source}</p>
+       </div>
+       {if $cacheData.version}
+               <div class="formElement">
+                       <p class="formFieldLabel">{lang}wcf.acp.cache.data.version{/lang}</p>
+                       <p class="formField">{$cacheData.version}</p>
+               </div>
+       {/if}
+       <div class="formElement">
+               <p class="formFieldLabel">{lang}wcf.acp.cache.data.size{/lang}</p>
+               <p class="formField">{@$cacheData.size|filesize}</p>
+       </div>
+       <div class="formElement">
+               <p class="formFieldLabel">{lang}wcf.acp.cache.data.files{/lang}</p>
+               <p class="formField">{#$cacheData.files}</p>
+       </div>
+       
+       {if $additionalFields|isset}{@$additionalFields}{/if}
+</fieldset>
+
+<div class="contentHeader">
+       <div class="largeButtons">
+               <ul>
+                       <li><a onclick="return confirm('{lang}wcf.acp.cache.clear.sure{/lang}')" href="index.php?action=CacheClear{@SID_ARG_2ND}"><img src="{@RELATIVE_WCF_DIR}icon/deleteM.png" alt="" /> <span>{lang}wcf.acp.cache.button.clear{/lang}</span></a></li>
+                       {if $additionalLargeButtons|isset}{@$additionalLargeButtons}{/if}
+               </ul>
+       </div>
+</div>
+
+{foreach from=$caches key=cache item=files}
+       {if $files|count}
+               <div class="border titleBarPanel">
+                       <div class="containerHead">
+                               <div class="containerIcon">
+                                       <a onclick="openList('{$cache}')"><img src="{@RELATIVE_WCF_DIR}icon/minusS.png" id="{$cache}Image" alt="" /></a>
+                               </div>
+                               <div class="containerContent">
+                                       <h3>{$cache} ({#$files|count})</h3>
+                               </div>
+                       </div>
+               </div>
+               <div class="border borderMarginRemove" id="{$cache}">
+                       <table class="tableList">
+                               <thead>
+                                       <tr class="tableHead">
+                                               <th><div><span class="emptyHead">{lang}wcf.acp.cache.list.name{/lang}</span></div></th>
+                                               <th><div><span class="emptyHead">{lang}wcf.acp.cache.list.size{/lang}</span></div></th>
+                                               <th><div><span class="emptyHead">{lang}wcf.acp.cache.list.mtime{/lang}</span></div></th>
+                                               {if $files.0.perm|isset}
+                                                       <th><div><span class="emptyHead">{lang}wcf.acp.cache.list.perm{/lang}</span></div></th>
+                                               {/if}
+                                       </tr>
+                               </thead>
+                               <tbody>
+                               {foreach from=$files item=file}
+                                       <tr class="{cycle values="container-1,container-2"}">
+                                               <td class="columnText">{$file.filename}</td>
+                                               <td class="columnNumbers">{@$file.filesize|filesize}</td>
+                                               <td class="columnDate">{if $file.mtime > 1}{@$file.mtime|time}{/if}</td>
+                                               {if $file.perm|isset}
+                                                       <td class="columnNumbers"{if !$file.writable} style="color: #c00"{/if}>{@$file.perm}</td>
+                                               {/if}
+                                       </tr>
+                               {/foreach}
+                               </tbody>
+                       </table>
+               </div>
+               <script type="text/javascript">
+                       //<![CDATA[
+                       initList('{$cache}', 0);
+                       //]]>
+               </script>
+       {/if}
+{/foreach}
+
+{include file='footer'}
index 07c9f59894f22fcaa92262978fca64a85ba075b0..333b3ad508929f50805041901fd8c6a78da41ebb 100755 (executable)
@@ -114,6 +114,50 @@ class CacheListPage extends AbstractPage {
                        $this->cacheData['files'] = $stats['curr_items'];
                        $this->cacheData['size'] = $stats['bytes'];
                }
+               // apc
+               else if ($this->cacheData['source'] == 'wcf\system\cache\source\ApcCacheSource') {
+                       // set version
+                       $this->cacheData['version'] = phpversion('apc');
+                       
+                       $conditions = new PreparedStatementConditionBuilder();
+                       $conditions->add("packageID IN (?)", array(PackageDependencyHandler::getDependencies()));
+                       $conditions->add("standalone = ?", array(1));
+                       
+                       // get package dirs
+                       $sql = "SELECT  packageDir, packageName, instanceNo
+                               FROM    wcf".WCF_N."_package
+                               ".$conditions;
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute($conditions->getParameters());
+                       $pattern = array();
+                       $packageNames = array();
+                       while ($row = $statement->fetchArray()) {
+                               $packagePath = FileUtil::getRealPath(WCF_DIR.$row['packageDir']).'cache/';
+                               $packageNames[$packagePath] = $row['packageName'].' #'.$row['instanceNo'];
+                       }
+                       
+                       $apcinfo = apc_cache_info('user');
+                       $cacheList = $apcinfo['cache_list'];
+                       foreach ($cacheList as $cache) {
+                               $cachePath = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(dirname($cache['info'])));
+                               if (isset($packageNames[$cachePath])) {
+                                       // Use the pacakgeName + the instance number, because pathes could confuse the administrator.
+                                       // He could think this is a file cache. If instanceName would be unique, we could use it instead.
+                                       $packageName = $packageNames[$cachePath];
+                                       if (!isset($this->caches[$packageName])) $this->caches[$packageName] = array();
+                                       
+                                       // get additional cache information
+                                       $this->caches[$packageName][] = array(
+                                               'filename' => basename($cache['info'], '.php'),
+                                               'filesize' => $cache['mem_size'],
+                                               'mtime' => $cache['mtime'],
+                                       );
+                                       
+                                       $this->cacheData['files']++;
+                                       $this->cacheData['size'] += $cache['mem_size'];
+                               }
+                       }
+               }
        }
        
        /**