renderThemeInfo($p); // print_a($p); exit; } $remotefile = $p['url']; e107::getFile()->download($remotefile,'theme'); exit; } // Theme Info Ajax $tm = (string) $_GET['id']; $data = $themec->getThemeInfo($tm); echo $themec->renderThemeInfo($data); exit; } else { require_once("auth.php"); /* echo ' '; */ } $mode = varset($_GET['mode'],'main'); // (e_QUERY) ? e_QUERY :"main" ; if(vartrue($_POST['selectadmin'])) { $mode = "admin"; } if(vartrue($_POST['upload'])) { $mode = "choose"; } if(vartrue($_POST['selectmain']) || varset($_POST['setUploadTheme'])) { $mode = "main"; } if($mode == 'convert') { new theme_builder; } else { $themec -> showThemes($mode); } // Launch demo modal require_once("footer.php"); function theme_adminmenu() { //global $mode; $mode = varset($_GET['mode'],'main'); // $e107 = &e107::getInstance(); $var['main']['text'] = TPVLAN_33; $var['main']['link'] = e_SELF; $var['admin']['text'] = TPVLAN_34; $var['admin']['link'] = e_SELF."?mode=admin"; $var['choose']['text'] = TPVLAN_51; $var['choose']['link'] = e_SELF."?mode=choose"; $var['online']['text'] = "Find Themes"; $var['online']['link'] = e_SELF."?mode=online"; $var['upload']['text'] = TPVLAN_38; $var['upload']['link'] = e_SELF."?mode=upload"; $var['convert']['text'] = "Convert"; $var['convert']['link'] = e_SELF."?mode=convert"; // $selected = (e_QUERY) ? e_QUERY : "main"; e107::getNav()->admin(TPVLAN_26, $mode, $var); } class theme_builder { var $themeName = ""; var $remove = array(); function __construct() { $this->themeName = $_GET['newtheme']; if(vartrue($_GET['step']) == 3) { $this->step3(); return; } if(vartrue($_GET['step']) == 2) { $this->step2(); } else { $this->step1(); } } function step1() { $fl = e107::getFile(); $frm = e107::getForm(); $ns = e107::getRender(); $mes = e107::getMessage(); $plugFolders = $fl->get_dirs(e_THEME); foreach($plugFolders as $dir) { if(file_exists(e_THEME.$dir."/theme.xml") || $dir == 'templates') { continue; } $newDir[$dir] = $dir; } $mes->addInfo("This Wizard will build a theme.xml meta file for your theme.
Before you start: "); $text = $frm->open('createPlugin','get',e_SELF."?mode=convert"); $text .= ""; /* $text .= " "; */ $text .= "
Select your theme's folder ".$frm->selectbox("newtheme",$newDir)."
Create Files ".$frm->checkbox('createFiles',1,1)."
".$frm->admin_button('step', 2,'other','Go')."
"; $text .= $frm->close(); $ns->tablerender(TPVLAN_26.SEP."Converter".SEP."Step 1", $mes->render() . $text); } function step2() { $ns = e107::getRender(); $mes = e107::getMessage(); $frm = e107::getForm(); $data = array( 'main' => array('name','lang','version','date', 'compatibility'), 'author' => array('name','url'), 'summary' => array('summary'), 'description' => array('description'), 'keywords' => array('one','two'), 'category' => array('category'), 'copyright' => array('copyright') // 'adminLinks' => array('url','description','icon','iconSmall','primary'), // 'sitelinks' => array('url','description','icon','iconSmall') ); $legacyFile = e_THEME.$this->themeName."/theme.php"; if(file_exists($legacyFile)) { $legacyData = file_get_contents($legacyFile); $regex = '/\$([\w]*)\s*=\s*("|\')([\w @.\/:<\>,\'\[\] !()]*)("|\');/im'; preg_match_all($regex, $legacyData, $matches); $leg = array(); foreach($matches[1] as $i => $m) { $leg[$m] = strip_tags($matches[3][$i]); if(substr($m,0,5) == 'theme' || $m == "CUSTOMPAGES") { $search[] = $matches[0][$i]; } } $defaults = array( "main-name" => vartrue($leg['themename']), "author-name" => vartrue($leg['themeauthor']), "author-url" => vartrue($leg['themewebsite']), "description-description" => '', "summary-summary" => vartrue($leg['themeinfo']), "custompages" => vartrue($leg['CUSTOMPAGES']), ); $search[] = "Steve Dunstan"; $search[] = "jalist@e107.org"; $_SESSION['themebulder-remove'] = $search; $mes->addInfo("Loading theme.php file"); } $text = $frm->open('newtheme-step3','post', e_SELF.'?mode=convert&newtheme='.$this->themeName.'&step=3'); $text .= ""; foreach($data as $key=>$val) { $text.= ""; } $text .= "
$key
"; foreach($val as $type) { $nm = $key.'-'.$type; $name = "xml[$nm]"; $size = (count($val)==1) ? 'span7' : 'span2'; $text .= "
".$this->xmlInput($name, $key."-". $type, vartrue($defaults[$nm]))."
"; } $text .= "
"; $text .= "
" .$frm->hidden('newtheme', $this->themeName) .$frm->hidden('xml[custompages]', trim(vartrue($leg['CUSTOMPAGES']))) .$frm->admin_button('step', 3,'other','Generate')."
"; $text .= $frm->close(); $ns->tablerender(TPVLAN_26.SEP."Converter".SEP."Step 2", $mes->render() . $text); } function step3() { $ns = e107::getRender(); $mes = e107::getMessage(); // print_a($_POST); if($_POST['xml']) { $xmlText = $this->createXml($_POST['xml']); } $ns->tablerender("theme.xml", $mes->render(). "
".$xmlText."
"); $legacyFile = e_THEME.$this->themeName."/theme.php"; if(file_exists($legacyFile)) { $legacyData = file_get_contents($legacyFile); } $legacyData = $this->cleanUp($legacyData); $output = nl2br(htmlentities($legacyData)); // $legacyData = str_replace("\n\n\n","\n",$legacyData); $ns->tablerender("theme.php (updated)", $output); } function cleanUp($text) { $search = array(); $replace = array(); $search[0] = '$HEADER '; $replace[0] = '$HEADER["default"] '; $search[1] = '$FOOTER '; $replace[1] = '$FOOTER["default"] '; // Early 0.6 and 0.7 Themes $search[2] = '$CUSTOMHEADER '; $replace[2] = '$HEADER["custom"] '; $search[3] = '$CUSTOMFOOTER '; $replace[3] = '$FOOTER["custom"] '; //TODO Handle v1.x style themes. eg. $CUSTOMHEADER['something']; $text = str_replace($_SESSION['themebulder-remove'],"",$text); $text = str_replace($search, $replace, $text); return $text; } function createXml($data) { $ns = e107::getRender(); $mes = e107::getMessage(); $tp = e107::getParser(); foreach($data as $key=>$val) { $key = strtoupper(str_replace("-","_",$key)); $newArray[$key] = $val; } if(vartrue($newArray['CUSTOMPAGES'])) { $newArray['CUSTOMPAGES'] = trim($newArray['CUSTOMPAGES']); $LAYOUTS = "\n"; $LAYOUTS .= " {CUSTOMPAGES}\n"; $LAYOUTS .= " "; } else { $LAYOUTS = ""; } $template = <<