VersionControl_SVN
[ class tree: VersionControl_SVN ] [ index: VersionControl_SVN ] [ all elements ]

Source for file example1.php

Documentation is available at example1.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 5                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2004, Clay Loveless                                    |
  7. // | All rights reserved.                                                 |
  8. // +----------------------------------------------------------------------+
  9. // | This LICENSE is in the BSD license style.                            |
  10. // | http://www.opensource.org/licenses/bsd-license.php                   |
  11. // |                                                                      |
  12. // | Redistribution and use in source and binary forms, with or without   |
  13. // | modification, are permitted provided that the following conditions   |
  14. // | are met:                                                             |
  15. // |                                                                      |
  16. // |  * Redistributions of source code must retain the above copyright    |
  17. // |    notice, this list of conditions and the following disclaimer.     |
  18. // |                                                                      |
  19. // |  * Redistributions in binary form must reproduce the above           |
  20. // |    copyright notice, this list of conditions and the following       |
  21. // |    disclaimer in the documentation and/or other materials provided   |
  22. // |    with the distribution.                                            |
  23. // |                                                                      |
  24. // |  * Neither the name of Clay Loveless nor the names of contributors   |
  25. // |    may be used to endorse or promote products derived from this      |
  26. // |    software without specific prior written permission.               |
  27. // |                                                                      |
  28. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
  29. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
  30. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
  31. // | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
  32. // | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,  |
  33. // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  34. // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;     |
  35. // | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER     |
  36. // | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT   |
  37. // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN    |
  38. // | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE      |
  39. // | POSSIBILITY OF SUCH DAMAGE.                                          |
  40. // +----------------------------------------------------------------------+
  41. // | Author: Clay Loveless <clay@killersoft.com>                          |
  42. // +----------------------------------------------------------------------+
  43. //
  44. // $Id: example1.php 286753 2009-08-03 19:37:03Z mrook $
  45. //
  46.  
  47. /*
  48.     In this example, we'll get a list of files in a repository, and
  49.     link to their contents.
  50. */
  51.  
  52. ini_set('display_errors''on');
  53.  
  54. require_once 'VersionControl/SVN.php';
  55.  
  56. // Setup our error stack
  57. $svnstack &PEAR_ErrorStack::singleton('VersionControl_SVN');
  58.  
  59. // Default options
  60. $base_url 'svn://svn.killersoft.com/repos/VersionControl_SVN/trunk';
  61. $base_add = isset($_GET['base_add']'/'.$_GET['base_add''';
  62. $cmd = isset($_GET['cmd']$_GET['cmd''list';
  63. $options = array(
  64.     'target'  => $base_url.$base_add
  65. );
  66.  
  67. // Create svn object with subcommands we'll want
  68. $svn VersionControl_SVN::factory(array('list''cat')$options);
  69.  
  70.  
  71. // A quickie sample of browsing a Subversion repository
  72. if ($cmd == 'cat'{
  73.     $file $_GET['file'];
  74.     $options['target'$base_url.$base_add.'/'.$file;
  75.     $svn->cat->setOptions($options);
  76.     $source $svn->cat->run();
  77.     if (substr($file-4== '.php'{
  78.         highlight_string($source);
  79.     else {
  80.         echo "<pre>$source</pre>\n";
  81.     }
  82.     
  83. else {
  84.     $list $svn->list->run();
  85.     $list_array explode("\n"$list);
  86.     foreach ($list_array as $item{
  87.         if (substr($item-1== '/'{
  88.             $new_base substr($item0-1);
  89.             echo "<a href=\"example1.php?cmd=list&base_add={$base_add}/{$new_base}\">$item</a><br />\n";
  90.         else {
  91.             echo "<a href=\"example1.php?cmd=cat&file={$item}&base_add={$base_add}\">$item</a><br />\n";
  92.         }
  93.     }
  94. }
  95.  
  96. // Check for errors
  97. if (count($errs $svnstack->getErrors())) 
  98.     echo "<pre>\n";
  99.     print_r($errs);
  100.     echo "</pre>\n";
  101. }
  102. ?>

Documentation generated on Mon, 11 Mar 2019 15:33:38 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.