Skip to content
Browse files

Update examples to new API

  • Loading branch information...
1 parent 6a44d77 commit 7ec29271ad962a87f0198b9524bfb01e427ba09b @mrook mrook committed
Showing with 31 additions and 40 deletions.
  1. +8 −15 docs/examples/example1.php
  2. +23 −25 docs/examples/example_tree.php
View
23 docs/examples/example1.php
@@ -55,24 +55,19 @@
require_once 'VersionControl/SVN.php';
// Default options
-$base_url = 'svn://svn.killersoft.com/repos/VersionControl_SVN/trunk';
+$base_url = 'https://github.com/pear/VersionControl_SVN/trunk';
$base_add = isset($_GET['base_add']) ? '/'.$_GET['base_add'] : '';
$cmd = isset($_GET['cmd']) ? $_GET['cmd'] : 'list';
-$options = array(
- 'target' => $base_url.$base_add
-);
try {
// Create svn object with subcommands we'll want
- $svn = VersionControl_SVN::factory(array('list', 'cat'), $options);
+ $svn = VersionControl_SVN::factory(array('list', 'cat'));
// A quickie sample of browsing a Subversion repository
if ($cmd == 'cat') {
$file = $_GET['file'];
- $options['target'] = $base_url.$base_add.'/'.$file;
- $svn->cat->setOptions($options);
- $source = $svn->cat->run();
+ $source = $svn->cat->run(array($base_url.$base_add.'/'.$file));
if (substr($file, -4) == '.php') {
highlight_string($source);
} else {
@@ -80,14 +75,12 @@
}
} else {
- $list = $svn->list->run();
- $list_array = explode("\n", $list);
- foreach ($list_array as $item) {
- if (substr($item, -1) == '/') {
- $new_base = substr($item, 0, -1);
- echo "<a href=\"example1.php?cmd=list&base_add={$base_add}/{$new_base}\">$item</a><br />\n";
+ $list = $svn->list->run(array($base_url));
+ foreach ($list['list'][0]['entry'] as $item) {
+ if ($item['kind'] != 'file') {
+ echo "<a href=\"example1.php?cmd=list&base_add={$base_add}/{$item['name']}\">{$item['name']}</a><br />\n";
} else {
- echo "<a href=\"example1.php?cmd=cat&file={$item}&base_add={$base_add}\">$item</a><br />\n";
+ echo "<a href=\"example1.php?cmd=cat&file={$item['name']}&base_add={$base_add}\">{$item['name']}</a><br />\n";
}
}
}
View
48 docs/examples/example_tree.php
@@ -53,13 +53,12 @@
object for easy navigation.
*/
-error_reporting(E_ALL);
-ini_set('display_errors', 'on');
+error_reporting(E_ALL & ~E_DEPRECATED);
require_once 'VersionControl/SVN.php';
// Default options
-$base_url = 'https://www.killersoft.com/svn/packages/pear/VersionControl_SVN/trunk';
+$base_url = 'https://github.com/pear/VersionControl_SVN/trunk';
$base_add = '';
if (isset($_SERVER['PATH_INFO'])) {
$base_add = $_SERVER['PATH_INFO'];
@@ -98,28 +97,27 @@
'icon' => $foldericon));
$list = $svn->list->run($args, $switches);
- foreach ($list as $dir => $contents) {
- foreach ($list[$dir]['name'] as $i => $item) {
- if ($list[$dir]['type'][$i] == 'D') {
- $icon = $foldericon;
- $link = '';
- } else {
- $icon = $docicon;
- $link = $_SERVER['PHP_SELF']."/$dir/$item";
- // don't need the link for the .
- $link = str_replace('/.', '', $link);
- }
-
- if ($dir == '.') {
- // Adding to root level
- $obj = $item;
- $$obj =& $node1->addItem(new HTML_TreeNode(array('text' => $item, 'icon' => $icon, 'link' => $link)));
- } else {
- // Get parent item
- $parent = basename($dir);
- $obj = $item;
- $$obj =& $$parent->addItem(new HTML_TreeNode(array('text' => $item, 'icon' => $icon, 'link' => $link)));
- }
+ foreach ($list['list'][0]['entry'] as $item) {
+ $dir = dirname($item['name']);
+ if ($item['kind'] !== 'file') {
+ $icon = $foldericon;
+ $link = '';
+ } else {
+ $icon = $docicon;
+ $link = $_SERVER['PHP_SELF']."/" . $item['name'];
+ // don't need the link for the .
+ $link = str_replace('/.', '', $link);
+ }
+
+ if ($dir == '.') {
+ // Adding to root level
+ $obj = basename($item['name']);
+ $$obj = $node1->addItem(new HTML_TreeNode(array('text' => $item['name'], 'icon' => $icon, 'link' => $link)));
+ } else {
+ // Get parent item
+ $parent = basename($dir);
+ $obj = basename($item['name']);
+ $$obj = $$parent->addItem(new HTML_TreeNode(array('text' => $item['name'], 'icon' => $icon, 'link' => $link)));
}
}

0 comments on commit 7ec2927

Please sign in to comment.
Something went wrong with that request. Please try again.