1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

Git updates for plugins and themes when available.

This commit is contained in:
Cameron
2016-06-02 19:20:58 -07:00
parent 0109e91271
commit 6ef0868077
5 changed files with 103 additions and 25 deletions

View File

@@ -23,6 +23,8 @@ $e_sub_cat = 'plug_manage';
define('PLUGIN_SHOW_REFRESH', FALSE);
define('PLUGIN_SCAN_INTERVAL', !empty($_SERVER['E_DEV']) ? 0 : 360);
define("ADMIN_GITSYNC_ICON", $tp->toGlyph('fa-refresh', array('size'=>'2x', 'fw'=>1)));
global $user_pref;
@@ -151,7 +153,7 @@ class pluginmanager_form extends e_form
$text .= EPL_NOINSTALL_1.str_replace("..", "", e_PLUGIN.$this->plug['plugin_path'])."/ ".EPL_DIRECTORY;
if($this->plug['plugin_installflag'] == false)
{
e107::getDb()->db_Delete('plugin', "plugin_installflag=0 AND (plugin_path='{$this->plug['plugin_path']}' OR plugin_path='{$this->plug['plugin_path']}/' ) ");
e107::getDb()->delete('plugin', "plugin_installflag=0 AND (plugin_path='{$this->plug['plugin_path']}' OR plugin_path='{$this->plug['plugin_path']}/' ) ");
}
}
}
@@ -164,9 +166,13 @@ class pluginmanager_form extends e_form
if ($this->plug['plugin_installflag'] && e_DEBUG == true)
{
$text .= "<a class='btn btn-default' href='".e_SELF."?repair.".$this->plug['plugin_id']."' title='".'Repair plugin settings'."'> ".ADMIN_REPAIRPLUGIN_ICON."</a>";
$text .= "<a class='btn btn-default' href='".e_SELF."?repair.".$this->plug['plugin_id']."' title='Repair plugin settings'> ".ADMIN_REPAIRPLUGIN_ICON."</a>";
}
if($this->plug['plugin_installflag'] && is_dir($_path.".git"))
{
$text .= "<a class='plugin-manager btn btn-default' href='".e_SELF."?pull.".$this->plug['plugin_id']."' title='Sync with Git Repo'> ".ADMIN_GITSYNC_ICON."</a>";
}
$text .="</div> ";
@@ -246,8 +252,9 @@ class pluginManager{
global $user_pref,$admin_log;
$tmp = explode('.', e_QUERY);
$this -> action = ($tmp[0]) ? $tmp[0] : "installed";
$this -> id = varset($tmp[1]) ? intval($tmp[1]) : "";
$this -> id = !empty($tmp[1]) ? intval($tmp[1]) : "";
$this -> titlearray = array('installed'=>EPL_ADLAN_22,'avail'=>EPL_ADLAN_23, 'upload'=>EPL_ADLAN_38);
if(isset($_GET['mode']))
@@ -334,6 +341,25 @@ class pluginManager{
}
if($this->action == 'pull' && !empty($this->id))
{
$info = e107::getPlugin()->getInfo($this->id);
if(!empty($info['plugin_path']))
{
$return = e107::getFile()->gitPull($info['plugin_path'], 'plugin');
e107::getMessage()->addSuccess($return);
$this->action = 'refresh';
}
else
{
$this->action = 'avail';
}
}
if($this->action == 'avail' || $this->action == 'installed') // Plugin Check is done during upgrade_routine.
{
$this -> pluginCheck();
@@ -345,12 +371,16 @@ class pluginManager{
$this -> pluginCheck(true); // forced
}
if($this->action == "repair")
{
$this -> pluginRepair();
$this->action = 'refresh';
}
if($this->action == "refresh")
{
$this -> pluginCheck(true); // forced

View File

@@ -41,25 +41,8 @@ class _system_cron
if(is_dir(e_BASE.".git")) // Check it's a Git Repo
{
$return = $fl->gitPull();
$gitPath = defset('e_GIT','git'); // addo to e107_config.php to
// Change Dir.
$cmd = 'cd '.e_ROOT;
$mes->addDebug($cmd);
$text = `$cmd 2>&1`;
// Remove any local changes.
$cmd = $gitPath.' reset --hard';
$mes->addDebug($cmd);
$text .= `$cmd 2>&1`;
// Run Pull request
$cmd = $gitPath.' pull';
$mes->addDebug($cmd);
$text .= `$cmd 2>&1`;
$return = print_a($text,true);
$mes->addSuccess($return);
if(unlink(e_BASE."install.php"))

View File

@@ -1245,6 +1245,54 @@ class e_file
}
public function gitPull($folder='', $type=null)
{
$gitPath = defset('e_GIT','git'); // addo to e107_config.php to
$mes = e107::getMessage();
// Change Dir.
switch($type)
{
case "plugin":
$dir = realpath(e_PLUGIN.basename($folder));
break;
case "theme":
$dir = realpath(e_THEME.basename($folder));
break;
default:
$dir = e_ROOT;
}
$cmd = 'cd '.$dir;
// return $cmd;
$mes->addDebug($cmd);
$mes->addDebug($cmd);
$text = `$cmd 2>&1`;
// Remove any local changes.
$cmd = $gitPath.' reset --hard';
$mes->addDebug($cmd);
$text .= `$cmd 2>&1`;
// Run Pull request
$cmd = $gitPath.' pull';
$mes->addDebug($cmd);
$text .= `$cmd 2>&1`;
return print_a($text,true);
}
/**
* Returns true is the URL is valid and false if it is not.
* @param $url

View File

@@ -159,6 +159,12 @@ class themeHandler
}
if(!empty($_POST['git_pull']))
{
$return = e107::getFile()->gitPull($_POST['curTheme'], 'theme');
$mes->addSuccess($return);
}
if(isset($_POST['installplugin']))
{
$key = key($_POST['installplugin']);
@@ -1217,7 +1223,7 @@ class themeHandler
<tr>
<td><b>".TPVLAN_11."</b></td>
<td>".$theme['version']."</td>
<td class='well center middle' rowspan='7' style='text-align:center; vertical-align:middle;width:25%'>".$thumbnail."</td>
<td class='well center middle' rowspan='9' style='text-align:center; vertical-align:middle;width:25%'>".$thumbnail."</td>
</tr>";
$text .= "<tr><td style='vertical-align:top; width:25%'><b>".LAN_AUTHOR."</b>:</td><td style='vertical-align:top'>".$author."</td></tr>";
@@ -1235,6 +1241,14 @@ class themeHandler
$text .= ($theme['csscompliant']) ? " &amp; CSS ".$theme['csscompliant'] : "";
$text .= "</td></tr>";
if(is_dir(e_THEME.$this->id."/.git"))
{
$text .= "<tr><td><b>Developer</b></td>
<td >".$this->frm->admin_button('git_pull', 1, 'primary', $tp->toGlyph('fa-refresh'). "Git Sync")."</td></tr>";
}
// site theme..
if($mode == 1)
{
@@ -1377,6 +1391,9 @@ class themeHandler
</tr>";
}
$itext .= "</table></td></tr>";
}

View File

@@ -1260,7 +1260,7 @@ li.rssRow > div {
.fborder .forumheader3 { padding: 8px; line-height: 1.42857143; vertical-align: top; border-top: 1px solid #0a0a0a; }
.plugin-manager .fa-refresh { padding-top: 4px }
/*