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$
  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. // Default options
  57. $base_url 'https://github.com/pear/VersionControl_SVN/trunk';
  58. $base_add = isset($_GET['base_add']'/'.$_GET['base_add''';
  59. $cmd = isset($_GET['cmd']$_GET['cmd''list';
  60.  
  61. try {
  62.     // Create svn object with subcommands we'll want
  63.     $svn VersionControl_SVN::factory(array('list''cat'));
  64.  
  65.  
  66.     // A quickie sample of browsing a Subversion repository
  67.     if ($cmd == 'cat'{
  68.         $file $_GET['file'];
  69.         $source $svn->cat->run(array($base_url.$base_add.'/'.$file));
  70.         if (substr($file-4== '.php'{
  71.             highlight_string($source);
  72.         else {
  73.             echo "<pre>$source</pre>\n";
  74.         }
  75.  
  76.     else {
  77.         $list $svn->list->run(array($base_url));
  78.         foreach ($list['list'][0]['entry'as $item{
  79.             if ($item['kind'!= 'file'{
  80.                 echo "<a href=\"example1.php?cmd=list&base_add={$base_add}/{$item['name']}\">{$item['name']}</a><br />\n";
  81.             else {
  82.                 echo "<a href=\"example1.php?cmd=cat&file={$item['name']}&base_add={$base_add}\">{$item['name']}</a><br />\n";
  83.             }
  84.         }
  85.     }
  86. catch (VersionControl_SVN_Exception $e{
  87.     echo "<pre>\n";
  88.     print_r($e->getMessage());
  89.     echo "</pre>\n";
  90. }
  91. ?>

Documentation generated on Sat, 09 Feb 2013 12:30:10 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.