From ffef82fe76022424b5fef27d48cb715a35b93d79 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Tue, 3 Jun 2014 09:10:55 +0100 Subject: [PATCH] GitHub manager to add, edit/remove and choose Establish local and remote paths plus get settings file contents If we're choosing a path pair, get the number and the 2 chosen paths (local and remote). Paths are not valid until checked if exist. Prior to that, a mkdir is attempted if it doesn't with error reporting if that doesn't happen. If valid, set the new root path and reload the file manager Adding and editing of local and remote array paths on postback also handled Page displays form & table so you can manage repo pairs along with providing usage info --- lib/github-manager.php | 245 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 lib/github-manager.php diff --git a/lib/github-manager.php b/lib/github-manager.php new file mode 100644 index 0000000..76abeb3 --- /dev/null +++ b/lib/github-manager.php @@ -0,0 +1,245 @@ +top.ICEcoder.message('Sorry, cannot create folder at\\n".$chosenLocal."');"; + } + } + + if (is_dir($docRoot.$chosenLocal)) { + $pathValid = true; + } + + if ($pathValid) { + + // New setting for the root path + $settingsNew = '"root" => "'.$chosenLocal.'",'.PHP_EOL; + + // Identify the bit to replace + $repPosStart = strpos($settingsContents,'"root"'); + $repPosEnd = strpos($settingsContents,'"checkUpdates"'); + + // Compile our new settings + $settingsContents = substr($settingsContents,0,$repPosStart).$settingsNew.substr($settingsContents,$repPosEnd,strlen($settingsContents)); + + // Now update the config file + if (is_writeable($settingsFile)) { + $fh = fopen($settingsFile, 'w'); + fwrite($fh, $settingsContents); + fclose($fh); + // Hide this popup and reload file manager + echo ""; + } else { + echo ""; + } + + } + + } + + // ====== + // ADDING + // ====== + + if ($_GET['action']=="add") { + + // Start creating a new chunk for the github paths + $settingsNew = '"githubLocalPaths" => array('; + + // Add the new one + if ($_POST['githubLocalPathNEW'] != "" && $_POST['githubRemotePathNEW'] != "") { + $settingsNew .= '"'.$_POST['githubLocalPathNEW'].'",'; + } + + // Then set all the old local paths + for ($i=0; $iwindow.location='github-manager.php?updatedGithubPaths&csrf='+top.ICEcoder.csrf;"; + die('saving github paths...'); + } else { + echo ""; + } + } +} +?> + + + + +ICEcoder <?php echo $ICEcoder["versionNo"];?> GitHub manager + + + + + + + +

github paths

+ +
+ 0) { + ?> +
+

Choose existing path


+ +
+ + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + echo ''; + echo ''; + echo ''; + ?> +
Local pathRemote GitHub path
Choose
Set local and remote path to blanks to remove
Update
+ "> +
+
+ + +
+

Add new path


+ +
+ + + + + + + + + + + + +
Local pathRemote GitHub path
Add
+ "> +
+
+ +

Usage Info:

+ +

Enter relative local paths (eg /server/myfiles) and absolute GitHub paths (eg https://github.com/user/repo or https://github.com/user/repo/tree/branch for branches), as per the examples. With this done you have established the source paths at both locations, as a pair.

+

You can then choose a path pair and this then becomes your new root path in ICEcoder.

+

The file manager then displays a new GitHub icon, which you can click on to perform and show a diff check between the 2 sources. These diffs can then be committed and pushed to the remote path at GitHub or cloned to your local path, to sync your files.

+

If you want to set another root path, this can be done in the Help > Settings screen.

+ +
+ + + +