当前位置: 首页>>代码示例>>PHP>>正文


PHP eZTemplate::templatesUsageStatistics方法代码示例

本文整理汇总了PHP中eZTemplate::templatesUsageStatistics方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplate::templatesUsageStatistics方法的具体用法?PHP eZTemplate::templatesUsageStatistics怎么用?PHP eZTemplate::templatesUsageStatistics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZTemplate的用法示例。


在下文中一共展示了eZTemplate::templatesUsageStatistics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateStatistics

 static function generateStatistics($as_html = true)
 {
     $stats = '';
     if (!eZTemplate::isTemplatesUsageStatisticsEnabled()) {
         return $stats;
     }
     if ($as_html) {
         $stats .= "<h3>Templates used to render the page:</h3>";
         $stats .= "<table id='templateusage' class='debug_resource_usage' title='List of used templates'>" . "<tr><th title='Usage count of this particular template'>Usage</th>" . "<th>Requested template</th>" . "<th>Template</th>" . "<th>Template loaded</th>" . "<th>Edit</th>" . "<th>Override</th></tr>";
     } else {
         $formatString = "%-40s%-40s%-40s\n";
         $stats .= "Templates usage statistics\n";
         $stats .= sprintf($formatString, 'Templates', 'Requested template', 'Template loaded');
     }
     if ($as_html) {
         $iconSizeX = 16;
         $iconSizeY = 16;
         $templateViewFunction = 'visual/templateview';
         eZURI::transformURI($templateViewFunction);
         $templateEditFunction = 'visual/templateedit';
         eZURI::transformURI($templateEditFunction);
         $templateOverrideFunction = 'visual/templatecreate';
         eZURI::transformURI($templateOverrideFunction);
         $std_base = eZTemplateDesignResource::designSetting('standard');
         $wwwDir = htmlspecialchars(eZSys::wwwDir(), ENT_COMPAT, 'UTF-8');
         $editIconFile = "{$wwwDir}/design/{$std_base}/images/edit.gif";
         $overrideIconFile = "{$wwwDir}/design/{$std_base}/images/override-template.gif";
         $tdClass = 'used_templates_stats1';
         $j = 0;
         $currentSiteAccess = $GLOBALS['eZCurrentAccess']['name'];
     }
     $templatesUsageStatistics = eZTemplate::templatesUsageStatistics();
     $alreadyListedTemplate = $templateCounts = array();
     //Generate usage count for each unique template first.
     foreach ($templatesUsageStatistics as $templateInfo) {
         $actualTemplateName = $templateInfo['actual-template-name'];
         if (!array_key_exists($actualTemplateName, $templateCounts)) {
             $templateCounts[$actualTemplateName] = 1;
         } else {
             ++$templateCounts[$actualTemplateName];
         }
     }
     //Then create the actual listing
     foreach ($templatesUsageStatistics as $templateInfo) {
         $actualTemplateName = $templateInfo['actual-template-name'];
         $requestedTemplateName = $templateInfo['requested-template-name'];
         $templateFileName = $templateInfo['template-filename'];
         if (!in_array($actualTemplateName, $alreadyListedTemplate)) {
             $alreadyListedTemplate[] = $actualTemplateName;
             if ($as_html) {
                 $requestedTemplateViewURI = $templateViewFunction . '/' . $requestedTemplateName;
                 $actualTemplateViewURI = $templateViewFunction . '/' . $actualTemplateName;
                 $templateEditURI = $templateEditFunction . '/' . $templateFileName;
                 $templateOverrideURI = $templateOverrideFunction . '/' . $actualTemplateName;
                 $actualTemplateNameOutput = $actualTemplateName == $requestedTemplateName ? "<em>&lt;No override&gt;</em>" : $actualTemplateName;
                 $stats .= "<tr class='data'><td>{$templateCounts[$actualTemplateName]}</td>" . "<td><a href=\"{$requestedTemplateViewURI}\">{$requestedTemplateName}</a></td>" . "<td>{$actualTemplateNameOutput}</td>" . "<td>{$templateFileName}</td>" . "<td><a href=\"{$templateEditURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$editIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Edit template\" title=\"Edit template\" /></a></td>" . "<td><a href=\"{$templateOverrideURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$overrideIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Override template\" title=\"Override template\" /></a></td></tr>";
                 $j++;
             } else {
                 $stats .= sprintf($formatString, $requestedTemplateName, $actualTemplateName, $templateFileName);
             }
         }
     }
     $totalTemplatesCount = count($templatesUsageStatistics);
     $totalUniqueTemplatesCopunt = count(array_keys($alreadyListedTemplate));
     if ($as_html) {
         $stats .= "<tr><td colspan=\"6\"><b>&nbsp;Number of times templates used: {$totalTemplatesCount}<br />&nbsp;Number of unique templates used: {$totalUniqueTemplatesCopunt}</b></td></tr>";
         $stats .= "</table>";
     } else {
         $stats .= "\nTotal templates count: " . $totalTemplatesCount . "\n" . "Total unique templates count: " . $totalUniqueTemplatesCopunt . "\n";
     }
     return $stats;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:72,代码来源:eztemplatesstatisticsreporter.php

示例2: generateStatistics

 static function generateStatistics($as_html = true)
 {
     $statStartTime = microtime(true);
     $stats = '';
     if (!eZTemplate::isTemplatesUsageStatisticsEnabled()) {
         return $stats;
     }
     if ($as_html) {
         $stats .= "<h2>Templates used to render the page:</h2>";
         $stats .= "<table id='templateusage' summary='List of used templates' style='border: 1px dashed black;' cellspacing='0'>" . "<tr><th>Usage count</th>" . "<th>Requested template</th>" . "<th>Template</th>" . "<th>Template loaded</th>" . "<th>Edit</th>" . "<th>Override</th></tr>";
     } else {
         $formatString = "%-40s%-40s%-40s\n";
         $stats .= "Templates usage statistics\n";
         $stats .= sprintf($formatString, 'Templates', 'Requested template', 'Template loaded');
     }
     if ($as_html) {
         $iconSizeX = 16;
         $iconSizeY = 16;
         $templateViewFunction = 'visual/templateview';
         eZURI::transformURI($templateViewFunction);
         $templateEditFunction = 'visual/templateedit';
         eZURI::transformURI($templateEditFunction);
         $templateOverrideFunction = 'visual/templatecreate';
         eZURI::transformURI($templateOverrideFunction);
         $std_base = eZTemplateDesignResource::designSetting('standard');
         $wwwDir = eZSys::wwwDir();
         $editIconFile = "{$wwwDir}/design/{$std_base}/images/edit.gif";
         $overrideIconFile = "{$wwwDir}/design/{$std_base}/images/override-template.gif";
         $tdClass = 'used_templates_stats1';
         $j = 0;
         $currentSiteAccess = $GLOBALS['eZCurrentAccess']['name'];
     }
     $templatesUsageStatistics = eZTemplate::templatesUsageStatistics();
     $alreadyListedTemplate = $templateCounts = array();
     //Generate usage count for each unique template first.
     foreach ($templatesUsageStatistics as $templateInfo) {
         $actualTemplateName = $templateInfo['actual-template-name'];
         if (!array_key_exists($actualTemplateName, $templateCounts)) {
             $templateCounts[$actualTemplateName] = 1;
         } else {
             ++$templateCounts[$actualTemplateName];
         }
     }
     //Then create the actual listing
     foreach ($templatesUsageStatistics as $templateInfo) {
         $actualTemplateName = $templateInfo['actual-template-name'];
         $requestedTemplateName = $templateInfo['requested-template-name'];
         $templateFileName = $templateInfo['template-filename'];
         if (!in_array($actualTemplateName, $alreadyListedTemplate)) {
             $alreadyListedTemplate[] = $actualTemplateName;
             if ($as_html) {
                 $tdClass = $j % 2 == 0 ? 'used_templates_stats1' : 'used_templates_stats2';
                 $requestedTemplateViewURI = $templateViewFunction . '/' . $requestedTemplateName;
                 $actualTemplateViewURI = $templateViewFunction . '/' . $actualTemplateName;
                 $templateEditURI = $templateEditFunction . '/' . $templateFileName;
                 $templateOverrideURI = $templateOverrideFunction . '/' . $actualTemplateName;
                 $actualTemplateNameOutput = $actualTemplateName == $requestedTemplateName ? "<span style=\"font-style: italic;\">&lt;No override&gt;</span>" : $actualTemplateName;
                 $stats .= "<tr><td class=\"{$tdClass}\" style=\"text-align: center;\">{$templateCounts[$actualTemplateName]}</td>" . "<td class=\"{$tdClass}\"><a href=\"{$requestedTemplateViewURI}\">{$requestedTemplateName}</a></td>" . "<td class=\"{$tdClass}\">{$actualTemplateNameOutput}</td>" . "<td class=\"{$tdClass}\">{$templateFileName}</td>" . "<td class=\"{$tdClass}\" align=\"center\"><a href=\"{$templateEditURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$editIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Edit template\" title=\"Edit template\" /></a></td>" . "<td class=\"{$tdClass}\" align=\"center\"><a href=\"{$templateOverrideURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$overrideIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Override template\" title=\"Override template\" /></a></td></tr>";
                 $j++;
             } else {
                 $stats .= sprintf($formatString, $requestedTemplateName, $actualTemplateName, $templateFileName);
             }
         }
     }
     $totalTemplatesCount = count($templatesUsageStatistics);
     $totalUniqueTemplatesCopunt = count(array_keys($alreadyListedTemplate));
     $statEndTime = microtime(true);
     $timeUsage = number_format($statEndTime - $statStartTime, 4);
     if ($as_html) {
         $stats .= "<tr><td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td></tr>";
         $stats .= "<tr><td colspan=\"2\" style=\"text-align: left;\"><b>&nbsp;Number of times templates used: {$totalTemplatesCount}<br />&nbsp;Number of unique templates used: {$totalUniqueTemplatesCopunt}</b></td></tr>";
         $stats .= "<tr><td colspan=\"2\" style=\"text-align: left;\"><b>&nbsp;Time used to render template usage: {$timeUsage} secs</b></td></tr>";
         $stats .= "</table>";
     } else {
         $stats .= "\nTotal templates count: " . $totalTemplatesCount . "\n" . "Total unique templates count: " . $totalUniqueTemplatesCopunt . "\n";
     }
     return $stats;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:78,代码来源:eztemplatesstatisticsreporter.php


注:本文中的eZTemplate::templatesUsageStatistics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。