diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index 1f6c3744c..22f8f0c78 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -2215,14 +2215,19 @@ class pluginBuilder } - if(vartrue($_POST['step']) == 3) + if(vartrue($_GET['step']) == 3) { $this->step3(); - - - return; + return null; } + + if(vartrue($_POST['step']) == 4) + { + $this->step4(); + return null; + } + if(vartrue($_GET['newplugin']) && $_GET['step']==2) { @@ -2231,7 +2236,7 @@ class pluginBuilder - return $this->step1(); + $this->step1(); } @@ -2259,7 +2264,7 @@ class pluginBuilder $info = EPL_ADLAN_102; $info .= ""; @@ -2323,9 +2328,31 @@ class pluginBuilder } + /** + * @param string $table + * @param string $file + */ + private function buildSQLFile($table, $file) + { + + $table = e107::getParser()->filter($table); + + e107::getDb()->gen("SHOW CREATE TABLE `#".$table."`"); + $data = e107::getDb()->fetch('num'); + + if(!empty($data[1])) + { + $createData = str_replace("`".MPREFIX, '`', $data[1]); + $createData .= ";"; + file_put_contents($file,$createData); + } + + } - function step2() + + + function step3() { require_once(e_HANDLER."db_verify_class.php"); @@ -2334,19 +2361,19 @@ class pluginBuilder $frm = e107::getForm(); $ns = e107::getRender(); $mes = e107::getMessage(); + $tp = e107::getParser(); - $newplug = $_GET['newplugin']; + $newplug = $tp->filter($_GET['newplugin']); $this->pluginName = $newplug; - - - - // $data = e107::getXml()->loadXMLfile(e_PLUGIN.'links_page/plugin.xml', 'advanced'); - // print_a($data); - // echo "
".var_export($data,true)."
"; - + $sqlFile = e_PLUGIN.$newplug."/".$newplug."_sql.php"; - + + if(!empty($_GET['build']) && !file_exists($sqlFile)) + { + $this->buildSQLFile($_GET['build'], $sqlFile); + } + $ret = array(); if(file_exists($sqlFile)) @@ -2356,9 +2383,8 @@ class pluginBuilder } else { - - // $ret = $this->buildTables(); - // $this->buildTable = true; + e107::getDebug()->log("SQL File Not Found"); + // $this->buildTable = true; } $text = $frm->open('newplugin-step3','post', e_SELF.'?mode=create&newplugin='.$newplug.'&createFiles='.$this->createFiles.'&step=3'); @@ -2372,20 +2398,13 @@ class pluginBuilder { foreach($ret['tables'] as $key=>$table) { - if($this->buildTable == true) - { - $label = "".$frm->checkbox('buildTable',1,false)." Build Table"; - } - else - { - $label = "Table: ".$table; - } - + $label = "Table: ".$table; $text .= "
  • ".$label."
  • "; $this->tableList[] = $table; } } + $text .= "
  • ".LAN_PREFS."
  • "; $text .= "
  • Addons
  • "; //TODO LAN @@ -2408,6 +2427,10 @@ class pluginBuilder $text .= ""; } } + + + + $text .= "
    \n"; $text .= $this->prefs(); $text .= "
    "; @@ -2429,7 +2452,7 @@ class pluginBuilder $text .= "
    ".$frm->hidden('newplugin', $this->pluginName)." - ".$frm->admin_button('step', 3,'other', LAN_GENERATE)." + ".$frm->admin_button('step', 4,'other', LAN_GENERATE)."
    "; $text .= $frm->close(); @@ -2444,29 +2467,74 @@ class pluginBuilder - private function buildTables() + private function step2() { - $template = "plugin_id int(10) unsigned NOT NULL auto_increment, - plugin_datestamp int(10) unsigned NOT NULL default '0', - plugin_name varchar(255) NOT NULL default '', - plugin_text text NOT NULL, - plugin_boolean tinyint(1) unsigned NOT NULL default '0', - plugin_author int(10) unsigned default NULL, - plugin_visibility int(4) NOT NULL default '0', - plugin_tags varchar(255) NOT NULL default '', - plugin_order int(6) unsigned NOT NULL default '0', - PRIMARY KEY (plugin_id)"; - $ret = array(); + $frm = e107::getForm(); - $ret['tables'] = array($this->pluginName); + $tables = e107::getDb()->tables(); - $ret['data'] = array(0=> str_replace("plugin", $this->pluginName, $template) ); - $ret['engine'] = array('0'=> 'InnoDB'); + $text = $frm->open('buildTab', 'get', e_REQUEST_SELF); - return $ret; + $text .= " + + + + + +

    ".ucfirst(LAN_OPTIONAL)."

    To generate your ".$this->pluginName."_sql.php table creation file, please select your sql table then click 'Refresh'"; + + $text .= $frm->select('build', $tables, null, array('useValues'=>1), "(".LAN_OPTIONAL.")"); + + + // $text .= "Refresh"; + // $text .= $frm->button('step', 3, 'submit', "Continue"); + unset($_GET['step']); + foreach($_GET as $k=>$v) + { + $text .= $frm->hidden($k,$v); + + } + // $text .= $frm->hidden("build_table_url", e_REQUEST_SELF.'?'.$qry, array('id'=>'build-table-url')); + + + $text .= "
      + ".$frm->button('step', 3, 'submit', LAN_CONTINUE)." +
    "; + + $text .= $frm->close(); + +/* + e107::js('footer-inline',' + + $(document).on("click", "#build-table-submit", function(e){ + + e.preventDefault(); + + $(this).addClass("disabled"); + + var url = $("#build-table-url").val(); + var sel = $("#build-table-tbl").val(); + + url = url + "&build=" + sel; + + window.location.href = url; + + return false; + }); + + + + + + ');*/ + $ns = e107::getRender(); + $ns->tablerender(ADLAN_98.SEP.EPL_ADLAN_114.SEP.EPL_ADLAN_115, $text); + + + return $text; } @@ -3470,7 +3538,7 @@ TEMPLATE; // ******************************** CODE GENERATION AREA ************************************************* - function step3() + function step4() { $pluginTitle = $_POST['xml']['main-name'] ; diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index adfcbc140..7df277edd 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -2454,6 +2454,18 @@ class e_form { $btype = 'submit'; if(strpos($action, 'action') === 0) $btype = 'button'; + + + if(isset($options['loading']) && ($options['loading'] == false)) + { + unset($options['loading']); + $include = ''; + } + else + { + $include = (deftrue("FONTAWESOME")) ? "data-loading-icon='fa-spinner' data-disable='true'" : ""; + } + $options = $this->format_options('admin_button', $name, $options); $options['class'] = vartrue($options['class']); @@ -2516,7 +2528,6 @@ class e_form break; } - $include = (deftrue("FONTAWESOME")) ? "data-loading-icon='fa-spinner' data-disable='true'" : ""; return " diff --git a/e107_languages/English/admin/lan_plugin.php b/e107_languages/English/admin/lan_plugin.php index 3ba8491be..4de9f03d3 100644 --- a/e107_languages/English/admin/lan_plugin.php +++ b/e107_languages/English/admin/lan_plugin.php @@ -119,8 +119,8 @@ define ('EPL_ADLAN_100',"click here to install some"); define ('EPL_ADLAN_101',"No plugins installed - [x]."); define ('EPL_ADLAN_102',"This Wizard will build an admin area for your plugin and generate a plugin.xml meta file. Before you start:"); define ('EPL_ADLAN_103',"Create a new writable folder in the [x] directory eg. [b]myplugin[/b]"); -define ('EPL_ADLAN_104',"If your plugin will use sql tables, create a new file in this folder and name it the same as the directory but with [b]_sql.php[/b] as a sufix eg. [b]myplugin_sql.php[/b]"); -define ('EPL_ADLAN_105',"Create your table in phpMyAdmin and paste an sql dump of it into your file and save. (see [i]e107_plugins/_blank/_blank_sql.php[/i] for an example)"); +// define ('EPL_ADLAN_104',"If your plugin will use sql tables, create a new file in this folder and name it the same as the directory but with [b]_sql.php[/b] as a sufix eg. [b]myplugin_sql.php[/b]"); +define ('EPL_ADLAN_105',"Create your table in phpMyAdmin in the same database as e107 and with the same table prefix."); define ('EPL_ADLAN_106',"Select your plugin's folder to begin."); define ('EPL_ADLAN_107',"Build an admin-area and xml file for:"); define ('EPL_ADLAN_108',"Check language files:");