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

Source for file example_tree.php

Documentation is available at example_tree.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: example_tree.php 286753 2009-08-03 19:37:03Z mrook $
  45. //
  46.  
  47. /*
  48.     This is a more complex example, that also illustrates the use of 
  49.     HTML_TreeMenu.
  50.     
  51.     In this example, we'll get a recusive list of files in a repository.
  52.     We will then loop through the files and build a dynamic HTML_TreeMenu
  53.     object for easy navigation.
  54. */
  55.  
  56. ini_set('display_errors''on');
  57.  
  58. require_once 'VersionControl/SVN.php';
  59.  
  60. // Setup our error stack
  61. $svnstack &PEAR_ErrorStack::singleton('VersionControl_SVN');
  62.  
  63. // Default options
  64. $base_url 'https://www.killersoft.com/svn/packages/pear/VersionControl_SVN/trunk';
  65. $base_add '';
  66. if (isset($_SERVER['PATH_INFO'])) {
  67.     $base_add $_SERVER['PATH_INFO'];
  68. }
  69.  
  70. $cmd '';
  71. $cmd = isset($_GET['cmd']$_GET['cmd''list';
  72.  
  73. $options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_ASSOC);
  74. $switches = array('R' => true);
  75. $args = array("{$base_url}{$base_add}");
  76.  
  77. // Create svn object with subcommands we'll want
  78. $svn VersionControl_SVN::factory(array('list''cat')$options);
  79.  
  80. // A quickie sample of browsing a Subversion repository
  81. if ($base_add != ''{
  82.     $source $svn->cat->run($args);
  83.     if (substr($base_add-4== '.php'{
  84.         highlight_string($source);
  85.     else {
  86.         echo '<pre>'.htmlentities($sourceENT_NOQUOTES)."</pre>\n";
  87.     }
  88.     
  89. else {
  90.  
  91.     // TreeMenu setup
  92.     require_once 'HTML/TreeMenu.php';
  93.     // Change icons to appropriate names
  94.     // See HTML_TreeMenu docs for more details.
  95.     $foldericon 'aquafolder.gif';
  96.     $docicon 'bbedit_doc.gif';
  97.     $menu = new HTML_TreeMenu();
  98.     $node1 = new HTML_TreeNode(array('text' => 'VersionControl_SVN',
  99.                                      'icon' => $foldericon));
  100.     
  101.     $list $svn->list->run($args$switches);
  102.     foreach ($list as $dir => $contents{
  103.         foreach ($list[$dir]['name'as $i => $item{
  104.             if ($list[$dir]['type'][$i== 'D'{
  105.                 $icon $foldericon;
  106.                 $link '';
  107.             else {
  108.                 $icon $docicon;
  109.                 $link $_SERVER['PHP_SELF']."/$dir/$item";
  110.                 // don't need the link for the .
  111.                 $link str_replace('/.'''$link);
  112.             }
  113.  
  114.             if ($dir == '.'{
  115.                 // Adding to root level
  116.                 $obj $item;
  117.                 $$obj =$node1->addItem(new HTML_TreeNode(array('text' => $item'icon' => $icon'link' => $link)));
  118.             else {
  119.                 // Get parent item
  120.                 $parent basename($dir);
  121.                 $obj $item;
  122.                 $$obj =$$parent->addItem(new HTML_TreeNode(array('text' => $item'icon' => $icon'link' => $link)));
  123.             }
  124.         }
  125.     }
  126.  
  127.     $menu->addItem($node1);
  128.     
  129.     // Create presentation class
  130.     $treeMenu &new HTML_TreeMenu_DHTML($menuarray('images' => 'images',
  131.                                                     'defaultClass' => 'treeMenuDefault'));
  132.     
  133.     ?>
  134. <html>
  135. <head>
  136.     <title>VersionControl_SVN Source Listing</title>
  137.     <script language="javascript" type="text/javascript" src="TreeMenu.js"></script>
  138.     <style type="text/css">
  139.     body, td, th {
  140.         font-family: verdana,arial,helvetica,sans-serif;
  141.         font-size: 80%;
  142.     }
  143.     .squeeze { line-height: 96%; font-size: xx-small; font-family:Verdana,Geneva,Arial; color: #999999; }
  144.     </style>
  145. </head>
  146. <body>
  147. <h3>VersionControl_SVN Source Listing</h3>
  148. <?php
  149. $treeMenu->printMenu();
  150. ?>
  151.  
  152. <p>
  153. <span class="squeeze">
  154. Source listing driven by <a href="http://pear.php.net/package/HTML_TreeMenu">HTML_TreeMenu</a> and <a href="VersionControl_SVN_docs/index.html">VersionControl_SVN</a>
  155. </span>
  156. </p>
  157.  
  158. <?php
  159. // Check for errors
  160. if (count($errs $svnstack->getErrors())) 
  161.     echo "<pre>\n";
  162.     print_r($errs);
  163.     echo "</pre>\n";
  164. }
  165. ?>
  166.  
  167. </body>
  168. </html>
  169. <?php
  170. }
  171. ?>

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