1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-17 20:01:47 +02:00

Plugin builder will now read a legacy plugin.php and auto-generate a _sql.php file if not found (and the folder is writable)

This commit is contained in:
Cameron
2013-01-22 13:12:30 -08:00
parent 59d1afce62
commit a48a03a6f8

View File

@@ -1536,11 +1536,59 @@ class pluginBuilder
'keywords' => array('one','two'), 'keywords' => array('one','two'),
'category' => array('category'), 'category' => array('category'),
'copyright' => array('copyright'), 'copyright' => array('copyright'),
// 'languageFile' => array('type','path'),
// 'adminLinks' => array('url','description','icon','iconSmall','primary'), // 'adminLinks' => array('url','description','icon','iconSmall','primary'),
// 'sitelinks' => array('url','description','icon','iconSmall') // 'sitelinks' => array('url','description','icon','iconSmall')
); );
// Load old plugin.php file if it exists;
$legacyFile = e_PLUGIN.$this->pluginName."/plugin.php";
if(file_exists($legacyFile))
{
require_once($legacyFile);
$mes = e107::getMessage();
$mes->addInfo("Loading plugin.php file");
$defaults = array(
"main-name" => $eplug_name,
"author-name" => $eplug_author,
"author-url" => $eplug_url,
"description-description" => $eplug_description,
"summary-summary" => $eplug_description
);
if(count($eplug_tables) && !file_exists(e_PLUGIN.$this->pluginName."/".$this->pluginName."_sql.php"))
{
$cont = '';
foreach($eplug_tables as $tab)
{
if(strpos($tab,"INSERT INTO")!==FALSE)
{
continue;
}
$cont .= "\n".str_replace("\t"," ",$tab);
}
if(file_put_contents(e_PLUGIN.$this->pluginName."/".$this->pluginName."_sql.php",$cont))
{
$mes->addInfo($this->pluginName."_sql.php as been generated",'default',true);
$red = e107::getRedirect();
$red->redirect(e_REQUEST_URL,true);
// $red->redirect(e_SELF."?mode=create&newplugin=".$this->pluginName."&createFiles=1&step=2",true);
}
else
{
$msg = $this->pluginName."_sql.php is missing!<br />";
$msg .= "Please create <b>".$this->pluginName."_sql.php</b> in your plugin directory with the following content:<pre>".$cont."</pre>";
$mes->addWarning($msg);
}
}
}
$text = "<table class='table adminlist'>"; $text = "<table class='table adminlist'>";
foreach($data as $key=>$val) foreach($data as $key=>$val)
@@ -1552,7 +1600,7 @@ class pluginBuilder
$nm = $key.'-'.$type; $nm = $key.'-'.$type;
$name = "xml[$nm]"; $name = "xml[$nm]";
$size = (count($val)==1) ? 'span7' : 'span2'; $size = (count($val)==1) ? 'span7' : 'span2';
$text .= "<div class='{$size}'>".$this->xmlInput($name, $key."-". $type)."</div>"; $text .= "<div class='{$size}'>".$this->xmlInput($name, $key."-". $type, vartrue($defaults[$nm]))."</div>";
} }
$text .= "</div></td></tr>"; $text .= "</div></td></tr>";
@@ -1565,13 +1613,12 @@ class pluginBuilder
} }
function xmlInput($name, $info) function xmlInput($name, $info, $default='')
{ {
$frm = e107::getForm(); $frm = e107::getForm();
list($cat,$type) = explode("-",$info); list($cat,$type) = explode("-",$info);
$size = 30; $size = 30;
$default = '';
$help = ''; $help = '';
switch ($info) switch ($info)
@@ -1610,14 +1657,13 @@ class pluginBuilder
break; break;
case 'author-name': case 'author-name':
$default = USERNAME; $default = (vartrue($default)) ? $default : USERNAME;
$required = true; $required = true;
$help = "Author Name"; $help = "Author Name";
$pattern = "[A-Za-z \.0-9]*"; $pattern = "[A-Za-z \.0-9]*";
break; break;
case 'author-url': case 'author-url':
$default = '';
$required = true; $required = true;
$help = "Author Website Url"; $help = "Author Website Url";
// $pattern = "https?://.+"; // $pattern = "https?://.+";
@@ -1741,7 +1787,7 @@ $template = <<<TEMPLATE
</adminLinks> </adminLinks>
</e107Plugin> </e107Plugin>
TEMPLATE; TEMPLATE;
// TODO
/* /*
<siteLinks> <siteLinks>
<link url="{e_PLUGIN}_blank/_blank.php" perm="everyone">Blank</link> <link url="{e_PLUGIN}_blank/_blank.php" perm="everyone">Blank</link>