Source for file CMS3_PackageVerifier.php

Documentation is available at CMS3_PackageVerifier.php

  1. <?php     
  2. //              (F)
  3. // CMS3 - A Three Content Management System.
  4. // Copyright (C) 2007  Jop... (Jonas F. Jensen).
  5. // 
  6. // This program is free software; you can redistribute it and/or
  7. // modify it under the terms of the GNU General Public License
  8. // as published by the Free Software Foundation; either version 2
  9. // of the License, or (at your option) any later version.
  10. // 
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with this program; if not, write to the Free Software
  18. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  19.  
  20. /**
  21. *This file defines CMS3_PackageVerifier
  22. *
  23. @package    PackageVerifier
  24. @author    Jonas F. Jensen <jopsen@gmail.com>
  25. @copyright    2007 Jonas F. Jensen.
  26. @license    http://www.gnu.org/licenses/gpl.txt
  27. */
  28.  
  29. /*
  30. *PackageVerifier provides a frontend for verifying packages (installed plugins).
  31. */
  32. class CMS3_PackageVerifier extends CMS3_System_Plugin implements ISystemCallbackIConfigure //TODO: Perhaps implement IProvidesHelp
  33. {
  34.  
  35.     //ISystemCallback implementation
  36.     //used for ajax save...
  37.  
  38.     
  39.     /**
  40.      * Handles a callback from ajax application.
  41.      *
  42.      * @param string data Data attached to this callback
  43.      * @return 
  44.      * @access public
  45.      */
  46.     public function SystemCallback$data ){
  47.         if($data == "Verify"){
  48.             $Res $this->Owner->GetPlugin("PackageManager")->VerifyPlugin($_POST["SelectedPackage"]);
  49.             print $Res $this->Formatsha1sumResult($Res"<b style=\"color: Red;\">Package has been modified, the master signature of package is NOT valid.</b>";
  50.         }else{
  51.             //Nothing smart to do, just return a soft 404
  52.             print "Error: 404, data not found.";
  53.         }
  54.     }
  55.  
  56.     /**
  57.     *Add HTML formatting to the output from sha1sum
  58.     */
  59.     protected function Formatsha1sumResult($Result)
  60.     {
  61.         $ArrRes explode("\n",$Result);
  62.         $FRes "";
  63.         foreach($ArrRes as $Res)
  64.         {
  65.             if(substr($Res,-4== ": OK")
  66.                 $FRes .= "<div>" $Res "</div>";
  67.             elseif(substr($Res,-8== ": FAILED")
  68.                 $FRes .= "<div style=\"background-color: Red\">" $Res "</div>";
  69.             else
  70.                 $FRes .= "<div style=\"background-color: Yellow\">" $Res "</div>";
  71.         }
  72.         return $FRes;
  73.     }
  74.  
  75.     //IConfigure implementation
  76.  
  77.     
  78.     /**
  79.     * Gets an absolute address of an icon for this plugin
  80.     */
  81.     public function GetControlCenterIcon(){
  82.         return $this->Owner->GetCMS3URL("bin/" $this->GetPluginID("/config.png";
  83.     }
  84.  
  85.     /**
  86.     * Gets menu entry string
  87.     */
  88.     public function GetControlCenterMenuEntry(){
  89.         //TODO: i18n
  90.         return "Verify package";
  91.     }
  92.  
  93.     /**
  94.      * Gets a dojo based ajax guide for configuration of the plugin.
  95.      *
  96.      * @param IEmbedmentOutputHandler OutputHandler
  97.      * @return IEmbedmentOutputHandler 
  98.      * @access public
  99.      */
  100.     public function &Configure($Identifier null&$EmbedmentOutputHandler ){
  101.         //Load templates from files
  102.         $Head file_get_contents($this->Owner->GetCMS3Path("data/" $this->GetPluginID("/ConfigHead.htm");
  103.         $Body file_get_contents($this->Owner->GetCMS3Path("data/" $this->GetPluginID("/ConfigBody.htm");
  104.  
  105.             //Generate content
  106.         foreach($this->Owner->GetPlugin("PackageManager")->ListPlugins(as $Plugin//Note: we're getting it from PackageManager, since not all plugins are removable
  107.         {
  108.             $Options .= "<option value='" $Plugin "' >" $Plugin "</option>\n";
  109.         }
  110.         $Body str_replace("CMS3URL",$this->Owner->GetCMS3URL(,$Body);
  111.         $Body str_replace("OPTIONS",$Options ,$Body);
  112.  
  113.         //Parse the output
  114.         $EmbedmentOutputHandler->ExtentHeader($Head);
  115.         $EmbedmentOutputHandler->SetBody($Body);
  116.         return $EmbedmentOutputHandler;
  117.     }
  118.  
  119.  
  120.         //Implementation of IPlugin
  121.  
  122.     
  123.     /**
  124.      * Gets the pluginID of the plugin.
  125.      *
  126.      * @return string 
  127.      * @access public
  128.      */
  129.     public function GetPluginID)
  130.     {
  131.         return "PackageVerifier";
  132.     }
  133.  
  134.  
  135. }
  136.  
  137.  
  138. ?>

Documentation generated on Mon, 30 Apr 2007 01:59:06 +0200 by phpDocumentor 1.3.1