sTEFANs Subversion Web Contol (SWC)
Inc
[ class tree: Swc ] [ index: Swc ] [ all elements ]

Source for file svn_executor.inc.php

Documentation is available at svn_executor.inc.php

  1. <?php
  2. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. SVN Web Control
  4. Copyright ©2006 by sTEFANs
  5. Created on 25.02.2006
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330,
  20. Boston, MA 02111-1307, USA.
  21. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. */
  23.  
  24. /**
  25.  * Implements the execution of SVN commands.
  26.  * The commands should be executed before any webpage is opened in order
  27.  * to have the results ready within all pages.
  28.  * 
  29.  * @package Swc
  30.  * @subpackage Inc
  31.  * @author Stefan Schraml
  32.  * @copyright Copyright ©2006 by sTEFANs
  33.  * @license http://opensource.org/licenses/lgpl-license.php GNU General Public License
  34.  * @version v1.1.0
  35.  * @since v1.0.0
  36.  */
  37.  
  38. /** Common defines */
  39. require_once('var.inc.php');
  40. /** Utility functions */
  41. require_once('utils.inc.php');
  42. /** SVN command library */
  43. require_once('svn_lib.inc.php');
  44.  
  45. /** 
  46.  * Executed SVN commands according to $_SESSION[IDX_ACTION].
  47.  * Stores all execution results within $_SESSION[IDX_EXEC_RES]
  48.  * array.
  49.  * @param array $results A result array that should be appended by the
  50.  *  result of the command execution. A new array is returned if this
  51.  *  parameter is set to NULL.
  52.  * @return array Array containing results of command excution.
  53.  * 
  54.  * @since v1.0.0
  55.  */
  56. function &SvnExecute(&$results NULL){
  57.     if ($results == NULL){
  58.         $results array();
  59.     }
  60.     
  61. //PrintDebugArray($_SESSION, 'Svn Executor: SESSION');
  62.     $config GetSelectedConfig();
  63.     if ($config == NULL){
  64.         return $results;
  65.     }
  66.     if(isset($_SESSION[IDX_ACTION])){
  67.         switch ($_SESSION[IDX_ACTION]){
  68.             case ACTION_LIST_REPOSITORY:
  69.                 $result ListRepository($config);
  70.                 $result[IDX_TITLET(TK_RESULT_TITLE_REP_LIST);                    
  71.                 $results[$result;
  72.                 break;
  73.             case ACTION_STATUS:
  74.                 $result GetWebspaceStatus($config);
  75.                 $result[IDX_TITLET(TK_RESULT_TITLE_WS_STATUS);                    
  76.                 $results[$result;
  77.                 break;
  78.             case ACTION_LOG:
  79.                 $result GetWebspaceLog($config);
  80.                 $result[IDX_TITLET(TK_RESULT_TITLE_WS_LOG);                    
  81.                 $results[$result;
  82.                 break;
  83.             case ACTION_INFO:
  84.                 $result GetWebspaceInfo($configfalse);
  85.                 $result[IDX_TITLET(TK_RESULT_TITLE_WS_INFO);                    
  86.                 $results[$result;
  87.                 break;
  88.             case ACTION_UPDATE:
  89.                 $result UpdateWebspace($config);
  90.                 $result[IDX_TITLET(TK_RESULT_TITLE_WS_UPDATE);                    
  91.                 $results[$result;
  92.                 break;
  93.             case ACTION_CLEANUP:
  94.                 $result CleanupWebspace($config);
  95.                 $result[IDX_TITLET(TK_RESULT_TITLE_WS_CLEANUP);                    
  96.                 $results[$result;
  97.                 break;
  98.             case ACTION_SWITCH:
  99.                 $path NULL;
  100.                 if (isset($_SESSION[IDX_SWITCH_PATH])){
  101.                     $path $_SESSION[IDX_SWITCH_PATH];
  102.                 }
  103.                 $result SwitchWebspace($config$path);
  104.                 $result[IDX_TITLET(TK_RESULT_TITLE_WS_SWITCH);                    
  105.                 $results[$result;
  106.                 break;            
  107.             case ACTION_CHECKOUT:
  108.                 $result CheckoutWebspace($config);
  109.                 $result[IDX_TITLET(TK_RESULT_TITLE_WS_CHECKOUT);                    
  110.                 $results[$result;
  111.                 break;        
  112.             case ACTION_SVN_HELP:
  113.                 $result[IDX_TITLET(TK_RESULT_SVN_HELP_TITLE);
  114.                 $result[IDX_STDOUTarray(
  115.                     T(TK_RESULT_SVN_HELP_HEADER),
  116.                     T(TK_RESULT_SVN_HELP_REP_SHORT),
  117.                     T(TK_RESULT_SVN_HELP_REP_LONG),
  118.                     T(TK_RESULT_SVN_HELP_WS_SHORT),
  119.                     T(TK_RESULT_SVN_HELP_WS_LONG));                
  120.                 $results[$result;
  121.                 $result GetSvnLookHelp();
  122.                 $result[IDX_TITLET(TK_RESULT_TITLE_SVNLOOK_HELP);                    
  123.                 $results[$result;
  124.                 $result GetSvnHelp();
  125.                 $result[IDX_TITLET(TK_RESULT_TITLE_SVN_HELP);                    
  126.                 $results[$result;
  127.                 $result GetSvnAdminHelp();
  128.                 $result[IDX_TITLET(TK_RESULT_TITLE_SVNADMIN_HELP);                    
  129.                 $results[$result;
  130.                 $result GetSvnVersionHelp();
  131.                 $result[IDX_TITLET(TK_RESULT_TITLE_SVNADMIN_HELP);                    
  132.                 $results[$result;
  133.                 break;        
  134.             case ACTION_SVN_CMD:
  135.                 $result array();
  136.                 $result[IDX_TITLET(TK_RESULT_ERROR_CMD_NOT_EXEC);
  137.                 $result[IDX_ERROUTarray(T(TK_RESULT_ERROR_NO_CMD));
  138.                 if(isset($_SESSION[IDX_ACTION_COMMAND]&& $_SESSION[IDX_ACTION_COMMAND!= ''){
  139.                     $cmd $_SESSION[IDX_ACTION_COMMAND];
  140.                     $cmd str_replace('%repository%'$config->GetRepositoryRoot()$cmd);
  141.                     $cmd str_replace('%webspace%'$config->GetWebspaceRootDir()$cmd);
  142.                     $cmd str_replace('%rep%'$config->GetRepositoryRoot()$cmd);
  143.                     $cmd str_replace('%ws%'$config->GetWebspaceRootDir()$cmd);
  144.                     $result[IDX_ERROUTarray(T(TK_RESULT_ERROR_NO_SVN_CMD__CMD$cmd));
  145.                     $rc stripos($cmd'svn');
  146.                     if ($rc !== false && $rc == 0){
  147.                         $result ExecSvnCmd($cmd);
  148.                         $result[IDX_TITLET(TK_RESULT_CMD_EXEC);
  149.                     }
  150.                 }                    
  151.                 $results[$result;
  152.                 break;
  153.         }
  154.     }
  155.     return $results;
  156. ?>

Documentation generated on Fri, 03 Nov 2006 18:45:00 +0100 by phpDocumentor 1.3.0RC6
for sTEFANs POWERED BY eBC.bz