[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/common/ -> eztemplatesstatisticsreporter.php (source)

   1  <?php
   2  //
   3  // Definition of eZTemplatesStatisticsReporter class
   4  //
   5  // Created on: <18-Feb-2005 17:21:17 dl>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file eztemplatesstatisticsreporter.php
  30  */
  31  
  32  /*!
  33    \class eZTemplatesStatisticsReporter eztemplatesstatisticsreporter.php
  34    \brief Generates statistics of tempate usage.
  35  
  36  */
  37  
  38  include_once ( 'kernel/common/eztemplatedesignresource.php' );
  39  include_once ( 'lib/eztemplate/classes/eztemplate.php' );
  40  include_once ( 'lib/ezutils/classes/ezsys.php' );
  41  
  42  class eZTemplatesStatisticsReporter
  43  {
  44      function eZTemplatesStatisticsReporter()
  45      {
  46      }
  47  
  48      /*!
  49       static
  50      */
  51      function &generateStatistics( $as_html = true )
  52      {
  53          $stats = '';
  54  
  55          if ( !eZTemplate::isTemplatesUsageStatisticsEnabled() )
  56              return $stats;
  57  
  58          if ( $as_html )
  59          {
  60              $stats .= "<h2>Templates used to render the page:</h2>";
  61              $stats .= ( "<table style='border: 1px dashed black;' cellspacing='0'>" .
  62                     "<tr><th>&nbsp;Template</th>" .
  63                     "<th>&nbsp;Requested template</th>" .
  64                     "<th>&nbsp;Template loaded</th>" .
  65                     "<th>&nbsp;Edit</th>" .
  66                     "<th>&nbsp;Override</th></tr>" );
  67          }
  68          else
  69          {
  70              $formatString = "%-40s%-40s%-40s\n";
  71              $stats .= "Templates usage statistics\n";
  72              $stats .= sprintf( $formatString, 'Templates', 'Requested template', 'Template loaded' );
  73          }
  74  
  75          if ( $as_html )
  76          {
  77              $iconSizeX = 16;
  78              $iconSizeY = 16;
  79              $templateViewFunction = 'visual/templateview/';
  80              $templateEditFunction = 'visual/templateedit/';
  81              $templateOverrideFunction = 'visual/templatecreate/';
  82  
  83              $std_base = eZTemplateDesignResource::designSetting( 'standard' );
  84              $wwwDir = eZSys::wwwDir();
  85              $editIconFile = "$wwwDir/design/$std_base/images/edit.gif";
  86              $overrideIconFile = "$wwwDir/design/$std_base/images/override-template.gif";
  87  
  88              $tdClass = 'used_templates_stats1';
  89              $j = 0;
  90  
  91              $currentSiteAccess = $GLOBALS['eZCurrentAccess']['name'];
  92          }
  93  
  94          $templatesUsageStatistics =& eZTemplate::templatesUsageStatistics();
  95          foreach( $templatesUsageStatistics as $templateInfo )
  96          {
  97              $actualTemplateName =& $templateInfo['actual-template-name'];
  98              $requestedTemplateName =& $templateInfo['requested-template-name'];
  99              $templateFileName =& $templateInfo['template-filename'];
 100  
 101              if ( $as_html )
 102              {
 103                  $tdClass = ( $j % 2 == 0 ) ? 'used_templates_stats1' : 'used_templates_stats2';
 104  
 105                  $requestedTemplateViewURI = $templateViewFunction . $requestedTemplateName;
 106                  $actualTemplateViewURI = $templateViewFunction . $actualTemplateName;
 107  
 108                  $templateEditURI = $templateEditFunction . $templateFileName;
 109                  $templateOverrideURI = $templateOverrideFunction . $actualTemplateName;
 110  
 111                  $stats .= ( "<tr><td class=\"$tdClass\"><a href=\"$actualTemplateViewURI\">&nbsp;$actualTemplateName</a></td>" .
 112                         "<td class=\"$tdClass\"><a href=\"$requestedTemplateViewURI\">&nbsp;$requestedTemplateName</a></td>" .
 113                         "<td class=\"$tdClass\">&nbsp;$templateFileName</td>" .
 114                         "<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>".
 115                         "<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>" );
 116  
 117                  $j++;
 118              }
 119              else
 120              {
 121                  $stats .= sprintf( $formatString, $actualTemplateName, $requestedTemplateName, $templateFileName );
 122              }
 123          }
 124  
 125          $totalTemplatesCount = count( $templatesUsageStatistics );
 126  
 127          if ( $as_html )
 128          {
 129              $stats .= ( "<tr><td class=\"$tdClass\">&nbsp;</td>" .
 130                     "<td class=\"$tdClass\">&nbsp;</td>" .
 131                     "<td class=\"$tdClass\">&nbsp;</td>".
 132                     "<td class=\"$tdClass\">&nbsp;</td>".
 133                     "<td class=\"$tdClass\">&nbsp;</td></tr>" );
 134              $stats .= "<tr><td><b>&nbsp;Total templates count: $totalTemplatesCount</b></td></tr>";
 135              $stats .= "</table>";
 136          }
 137          else
 138          {
 139              $stats .= "\nTotal templates count: " . $totalTemplatesCount . "\n";
 140          }
 141  
 142          return $stats;
 143      }
 144  }
 145  
 146  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7