Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 05:46 pm EDT

Geeklog Forums

Wamp to Github


Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
I'm creating and testing plugins for Geeklog CMS with WAMP. As files for a plugin are store in 3 directories (plugins, public_html, admin) I wrote a function to copy all new or modified files and folders to a unique folder. And from this folder I can push to Github.

Customize this code for your needs and put it in your system/lib-custom.php file

Text Formatted Code

// Geeklog CMS - Copy plugins to external folder if files are new

global $_PLUGINS;

// List of plugins you want to copy
$github_plugins = array('test','captcha');

foreach ($_PLUGINS as $plugin) {

    if (!in_array($plugin, $github_plugins)) continue;
   
    //Sources in plugins folder
    $src = $_CONF['path'] . 'plugins/' . $plugin;
    //Customize your destination
    $dst = "c:/plugins/$plugin";
    CUSTOM_recurse_copy($src, $dst);
   
    //Sources in public_html folder
    $src = $_CONF['path_html'] . $plugin;
    //Customize your destination
    $dst = "c:/plugins/$plugin/public_html";
    CUSTOM_recurse_copy($src, $dst);
   
    //Sources in admin folder
    $src = $_CONF['path_html'] . 'admin/plugins/' . $plugin;
    //Customize your destination
    $dst = "c:/plugins/$plugin/admin";
    CUSTOM_recurse_copy($src, $dst);

}

function CUSTOM_recurse_copy($src,$dst) {
   
    //Uncomment this line if you do not need to copy files
    //return;  
   
    global $_CONF;
   
    if (is_dir($src)) {
        $dir = opendir($src);
        if (!is_dir($dst)) mkdir($dst);
        while(false !== ( $file = readdir($dir)) ) {
            if (( $file != '.' ) && ( $file != '..' )) {
                if ( is_dir($src . '/' . $file) ) {
                    CUSTOM_recurse_copy( $src . '/' . $file, $dst . '/' . $file);
                }
                else {
                    //Check if source is newer
                    if ( file_exists($dst . '/' . $file) ) {
                        if ( filemtime($dst . '/' . $file) < filemtime($src . '/' . $file) ) copy($src . '/' . $file, $dst . '/' . $file);                             
                    } else {
                        copy($src . '/' . $file, $dst . '/' . $file);
                    }
                }
            }
        }
        closedir($dir);
    }
}

I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1468
Location:Canada
A good idea. It has always been a bit of a pain to remember which files have changed.
One of the Geeklog Core Developers.
 Quote

All times are EDT. The time is now 05:46 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content