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

Source for file config.inc.php

Documentation is available at config.inc.php

  1. <?php
  2. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. SVN Web Control
  4. Copyright ©2006 by sTEFANs
  5. Created on 26.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.  * This file contains interfaces that needs to be implemented for project configuration.
  26.  * 
  27.  * @package Swc
  28.  * @subpackage Inc
  29.  * @author Stefan Schraml
  30.  * @copyright Copyright ©2006 by sTEFANs
  31.  * @license http://opensource.org/licenses/lgpl-license.php GNU General Public License
  32.  * @version v1.1.0
  33.  * @since v1.0.0
  34.  */
  35.   
  36. /** 
  37.  * This interface defines a factory for SVN Web Control (SWC) configuration.
  38.  * There are two ways of applying configurations via Configuration Factory:
  39.  * 1. In the root folder of a project that should
  40.  *         be controlled via SWC is a frameset page. This
  41.  *         frameset page offers just on frame. The source url
  42.  *         of that frame points to swc/start.php and has a argument
  43.  *         that points to the SWC configuration file for that project.
  44.  *         This means the frame src could be swc/start.php?config=../conf.php.
  45.  *         The path of the config file must be relative to SWC directory
  46.  *         from SWCs point of view. The example above assumes that SWC is
  47.  *         located within root/swc directory. By the way, it is a good idea
  48.  *         to place the project also into a subdirectory of root, just keep
  49.  *         everything clean and separated.
  50.  *         Within this configuration file there must be function called
  51.  *         <b>GetSwcConfigFactory()</b> that returns the implementation
  52.  *         object of <b>SwcConfigFactory</b> and provides the config
  53.  *         for the project.
  54.  * 2. If a configuration factory is not provided as described above,
  55.  *         SWC takes the config factory instance proivded within
  56.  *         <b>.swc/config/std_config_factory.php</b>. This factory needs to be
  57.  *         implemented in a way, that it returns <b>Configuration</b>s for
  58.  *         all projects that should be controled by SWC.
  59.  * 
  60.  * Both scenarios described above has some advantages but also some disadvantages.
  61.  * It depends highly on the development rules and environment, which one
  62.  * to use. However, examples for both scenarios are provided together SWC.
  63.  * Have a look into the html root directory for scenario 1 and into swc/config
  64.  * for scenario 2.
  65.  * @package Swc
  66.  * @subpackage Inc
  67.  * @author Stefan Schraml
  68.  * @since v1.0.0
  69.  */
  70. interface SwcConfigFactory {
  71.     
  72.     /** 
  73.      * Returns an array of <b>SwcConfig</b> objects.
  74.      * These objects represents configured projects that
  75.      * are selectable within the project list, if more
  76.      * than one project is returned.
  77.      * @return array Array of configured projects.
  78.      * @see SwcConfig
  79.      * @since v1.0.0
  80.      */
  81.     public function GetSwcConfigs();
  82. }
  83.  
  84. /** 
  85.  * This interface defines a configuration that encapsulates several project settings
  86.  * needed by SVN Web Control. The main reason why a interface is chosen is to enable
  87.  * multiple instances of configuration. This interface must be implemented
  88.  * to configure projects.
  89.  * @package Swc
  90.  * @subpackage Inc
  91.  * @author Stefan Schraml
  92.  * @version v1.1.0
  93.  * @since v1.0.0
  94.  */
  95. interface SwcConfig {
  96.  
  97.     /** 
  98.      * Returns a user friendly name for the project.
  99.      * @return string User friendly project name.
  100.      * @since v1.0.0
  101.      */
  102.     public function GetProjectName();
  103.     
  104.     /** 
  105.      * Returns the relative URL of the Webpage under control.
  106.      * @return string URL of page to display in MainFrame.
  107.      * @since v1.0.0
  108.      */
  109.     public function GetMainFrame();
  110.     
  111.     /** 
  112.      * Returns the URL of the repository for the main frame.
  113.      * @return string URL of repository. Any protocol
  114.      *  (http://, svn://, etc.) is supported.
  115.      *  <br>
  116.      *  <b>Note:</b> <i>public function GetRepositoryRootDir</i> is deprecated
  117.      *  and removed from <i>SwcConfig</i> interface in SWC v1.1.0.
  118.      *  Please use <i>GetRepositoryRoot</i> instead.
  119.      * @since v1.0.0
  120.      */
  121.     public function GetRepositoryRoot();
  122.         
  123.     /** 
  124.      * Returns subdirectories which contains directories for tags.
  125.      * @return array or string (Array of) repository directory that contains tags.
  126.      * @since v1.0.0
  127.      */
  128.     public function GetTagDirs();
  129.     
  130.     /** 
  131.      * Returns the maximum depth of directories that should be considered
  132.      * as tag directory underneath <b>GetTagDirs()</b> hierarchy.
  133.      * E.g. if this is set to 2 than GetTagDirs()/dir1/dir2 is considered
  134.      * as tag directory while GetTagDirs()/dir1/dir2/dir3 is not.
  135.      * @return int Maximal path depth for tag directories.
  136.      * @since v1.0.0
  137.      */
  138.     public function GetMaxTagDirDepth();
  139.     
  140.     /** 
  141.      * Returns subdirectories which contains directories for branches.
  142.      * @return array or string (Array of) repository directory that contains branches.
  143.      * @since v1.0.0
  144.      */
  145.     public function GetBranchDirs();
  146.     
  147.     /** 
  148.      * Returns the maximum depth of directories that should be considered
  149.      * as branch directory underneath <b>GetBranchDirs()</b> hierarchy.
  150.      * E.g. if this is set to 2 than GetBranchDirs()/dir1/dir2 is considered
  151.      * as tag directory while GetBranchDirs()/dir1/dir2/dir3 is not.
  152.      * @return int Maximal path depth for branch directories.
  153.      * @since v1.0.0
  154.      */
  155.     public function GetMaxBranchDirDepth();
  156.     
  157.     /** 
  158.      * Returns subdirectoy which contains repository trunk.
  159.      * @return string Repository directory that contains main developement.
  160.      * @since v1.0.0
  161.      */
  162.     public function GetTrunkDir();
  163.         
  164.     /** 
  165.      * Returns the absolute path of the workspace directory in the local file system.
  166.      * @return string Absolute path of the workspace.
  167.      *  <br>
  168.      *  <b>Note:</b> <i>public function GetWebspaceRoot</i> is deprecated
  169.      *  and removed from <i>SwcConfig</i> interface in SWC v1.1.0.
  170.      *  Please use <i>GetWebspaceRootDir</i> instead.
  171.      * @since v1.0.0
  172.      */
  173.     public function GetWebspaceRootDir();
  174.     
  175.     /** 
  176.      * Returns the SVN user which should be used for repository access.
  177.      * @return string SVN user.
  178.      * @since v1.0.0
  179.      */
  180.     public function GetSvnUser();
  181.     
  182.     /** 
  183.      * Returns the password of the SVN user which should be used for repository access.
  184.      * @return string Password of SVN user.
  185.      * @since v1.0.0
  186.      */
  187.     public function GetSvnPassword();
  188.     
  189.     /** 
  190.      * Returns the URL of WebSVN view for this project or NULL if WebSVN is not available.
  191.      * @return string URL for WebSVN view for this project.
  192.      * @since v1.0.0
  193.      */
  194.     public function GetWebSvnUrl();
  195.     
  196.     /** 
  197.      * Returns true if SVN command bar may be shown, false otherwise.
  198.      * This setting overrides corresponding user setting in order to
  199.      * protect the system agaist malicious commands.
  200.      * @since v1.0.0
  201.      */
  202.     public function IsSvnCommandBarEnabled();
  203.     
  204.     /** 
  205.      * Returns the directory for packed (release) archives called
  206.      * spaceballs. Spaceballs archives are usually created for a dedicated revision.
  207.      * <i>Note</i> PHP needs write access granted on this directory.
  208.      * @return string Path for archive directory.
  209.      * @since v1.1.0
  210.      */
  211.     public function GetSpaceballDir();
  212.     
  213.     /** 
  214.      * Returns the HTTP URL for packed (release) archives. The
  215.      * URL should point to the directory returned by
  216.      * <i>GetSpaceballDir()</i>.
  217.      * @return string URL for spaceball directory.
  218.      * @since v1.1.0
  219.      */
  220.     public function GetSpaceballUrl();
  221. }
  222.  
  223. /**
  224.  * This interface contains any deprecated functions of interface <i>SwcConfig</i>
  225.  * and is introduced for documentation purposes only. <br>
  226.  * <b>Do not implement or extend this interface.</i>
  227.  *  
  228.  * @package Swc
  229.  * @subpackage Inc
  230.  * @author Stefan Schraml
  231.  * @since v1.1.0
  232.  */
  233. interface DeprecatedSwcConfig extends SwcConfig {
  234.     
  235.     /** 
  236.      * Returns the absolute path of the repository in the local file system.
  237.      * @deprecated v1.1.0 Use GetRepositroyRoot() instead to configure the repository root.
  238.      * @return string Absolute path of the repository.
  239.      * @see SwcConfig::GetRepositoryRoot
  240.      */
  241.     public function GetRepositoryRootDir();
  242.     
  243.     /** 
  244.      * Returns the URL for the workspace where the project
  245.      * is checked out. Used by SVN.
  246.      * @return string URL of Webspace.
  247.      * @deprecated v1.1.0 Use <i>GetWebspaceRootDir</i> instead to configure
  248.      *  webspace.
  249.      * @see SwcConfig::GetWebspaceRootDir
  250.      */
  251.     public function GetWebspaceRoot();
  252. }
  253.  
  254. /** 
  255.  * This abstract class provides default implementations of
  256.  * configuration methods that usually do not change. Deriving
  257.  * from this class instead of the the interface minimizes the
  258.  * number of methods that needs to be implemented.
  259.  * @package Swc
  260.  * @subpackage Inc
  261.  * @author Stefan Schraml
  262.  * @since v1.1.0
  263.  */
  264. abstract class SwcConfigAdapter implements SwcConfig {
  265.     
  266.     /** 
  267.      * Returns subdirectories which contains directories for tags.
  268.      * @return array or string (Array of) repository directory that contains tags.
  269.      * @since v1.1.0
  270.      */
  271.     public function GetTagDirs(){
  272.         return 'tags/';
  273.     }
  274.     
  275.     /** 
  276.      * Returns the maximum depth of directories that should be considered
  277.      * as tag directory underneath <b>GetTagDirs()</b> hierarchy.
  278.      * E.g. if this is set to 2 than GetTagDirs()/dir1/dir2 is considered
  279.      * as tag directory while GetTagDirs()/dir1/dir2/dir3 is not.
  280.      * @return int Maximal path depth for tag directories.
  281.      * @since v1.1.0
  282.      */
  283.     public function GetMaxTagDirDepth(){
  284.         return 1;
  285.     }
  286.     
  287.     /** 
  288.      * Returns subdirectories which contains directories for branches.
  289.      * @return array or string (Array of) repository directory that contains branches.
  290.      * @since v1.1.0
  291.      */
  292.     public function GetBranchDirs(){
  293.         return 'branches/';
  294.     }
  295.     
  296.     /** 
  297.      * Returns the maximum depth of directories that should be considered
  298.      * as branch directory underneath <b>GetBranchDirs()</b> hierarchy.
  299.      * E.g. if this is set to 2 than GetBranchDirs()/dir1/dir2 is considered
  300.      * as tag directory while GetBranchDirs()/dir1/dir2/dir3 is not.
  301.      * @return int Maximal path depth for branch directories.
  302.      * @since v1.1.0
  303.      */
  304.     public function GetMaxBranchDirDepth(){
  305.         return 1;
  306.     }
  307.     
  308.     /** 
  309.      * Returns subdirectoy which contains repository trunk.
  310.      * @return string Repository directory that contains main developement.
  311.      * @since v1.1.0
  312.      */
  313.     public function GetTrunkDir(){
  314.         return 'trunk/';
  315.     }
  316.     
  317.     /** 
  318.      * Returns the SVN user which should be used for repository access.
  319.      * @return string SVN user.
  320.      * @since v1.1.0
  321.      */
  322.     public function GetSvnUser(){
  323.         return 'swc_user';
  324.     }
  325.     
  326.     /** 
  327.      * Returns the password of the SVN user which should be used for repository access.
  328.      * @return string Password of SVN user.
  329.      * @since v1.1.0
  330.      */
  331.     public function GetSvnPassword(){
  332.         return 'swc_password';
  333.     }
  334.     
  335.     /** 
  336.      * Returns the URL of WebSVN view for this project or NULL if WebSVN is not available.
  337.      * @since v1.1.0
  338.      */
  339.     public function GetWebSvnUrl(){
  340.         return NULL;
  341.     }
  342.     
  343.     /** 
  344.      * Returns true if SVN command bar may be shown, false otherwise.
  345.      * This setting overrides corresponding user setting in order to
  346.      * protect the system agaist malicious commands.
  347.      * @since v1.1.0
  348.      */
  349.     public function IsSvnCommandBarEnabled(){
  350.         return true;
  351.     }
  352.     
  353.     /** 
  354.      * Returns the directory for packed (release) archives called
  355.      * spaceballs. Spaceballs archives are usually created for a dedicated revision.
  356.      * <i>Note</i> PHP needs write access granted on this directory.
  357.      * @return string Path for archive directory.
  358.      * @since v1.1.0
  359.      */
  360.     public function GetSpaceballDir({
  361.         $dir $this->GetWebspaceRootDir().'archives';
  362.         return $dir;
  363.     }
  364.     
  365.     /** 
  366.      * Returns the HTTP URL for packed (release) archives. The
  367.      * URL should point to the directory returned by
  368.      * <i>GetSpaceballDir()</i>. The default implementation
  369.      * tries to match the frist part of <i>GetMainFrame()</i>
  370.      * against the later part of <i>GetSpaceBallDir()</i>
  371.      * since usually the URL for the main frame contains the
  372.      * common root URL that also leads to the spaceball
  373.      * directory URL. If this implementation does not fit
  374.      * concrete requirments, this function must be overwritten
  375.      * within the concrete project configuration.
  376.      * @return string URL for spaceball directory.
  377.      * @since v1.1.0
  378.      */
  379.     public function GetSpaceballUrl(){
  380.         $dir $this->GetSpaceballDir();
  381.         $mf_url $this->GetMainFrame();
  382.         $dir_tmp str_replace('\\''/'$dir);
  383.         $sb_dir_tokens explode('/'$dir);
  384.         $mf_url_tokens explode('/'$mf_url);
  385.         $common array_intersect($sb_dir_tokens$mf_url_tokens);
  386.         $last array_pop($common);
  387.         $url '';
  388.         if ($last != NULL && $last != ''){    
  389.             $mf_keys array_keys($mf_url_tokens$last);
  390.             $mf_key array_pop($mf_keys);
  391.             $sb_keys array_keys($sb_dir_tokens$last);
  392.             $sb_key array_pop($sb_keys);
  393.             $i 0;
  394.             while ($i <= $mf_key){
  395.                 $url .= $mf_url_tokens[$i].'/';
  396.                 $i++;
  397.             }
  398.             $i $sb_key 1;
  399.             $cnt count($sb_dir_tokens);
  400.           while ($i $cnt){
  401.               $url .= $sb_dir_tokens[$i].'/';
  402.               $i++;
  403.           }
  404.         }
  405.         return $url;
  406.     }
  407. }
  408.  
  409. ?>

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