getMarketplace(); echo $mp->renderLoginForm(); exit; break; /* case 'download': $string = base64_decode($_GET['src']); parse_str($string, $p); $mp = $themec->getMarketplace(); $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); // Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers) echo "
Connecting...\n"; flush();
			// download and flush
			$mp->download($p['id'], $p['mode'], $p['type']);
			echo "
"; flush(); exit; break; */ case 'info': if(!empty($_GET['src'])) { $string = base64_decode($_GET['src']); parse_str($string,$p); $themeInfo = e107::getSession()->get('thememanager/online/'.intval($p['id'])); echo $themec->renderThemeInfo($themeInfo); } break; case 'preview': // Theme Info Ajax $tm = (string) $_GET['id']; $data = $themec->getThemeInfo($tm); echo $themec->renderThemeInfo($data); // exit; break; } /* if(vartrue($_GET['src'])) // Process Theme Download. { $string = base64_decode($_GET['src']); parse_str($string,$p); if(vartrue($_GET['info'])) { echo $themec->renderThemeInfo($p); // print_a($p); exit; } $remotefile = $p['url']; e107::getFile()->download($remotefile,'theme'); exit; } */ // Theme Info Ajax // FIXME addd action=preview to the url, remove this block if(!empty($_GET['id'])) { $tm = (string) $_GET['id']; $data = $themec->getThemeInfo($tm); echo $themec->renderThemeInfo($data); } require_once(e_ADMIN."footer.php"); exit; } else { require_once("auth.php"); /* echo ' '; */ } if($mode == 'download' && !empty($_GET['src'])) { define('e_IFRAME', true); $frm = e107::getForm(); $mes = e107::getMessage(); $string = base64_decode($_GET['src']); parse_str($string, $data); if(!empty($data['price'])) { e107::getRedirect()->go($data['url']); return true; } if(deftrue('e_DEBUG_MARKETPLACE')) { echo "DEBUG MODE ACTIVE (no downloading)
"; echo '$_GET: '; print_a($_GET); echo 'base64 decoded and parsed as $data:'; print_a($data); return false; } $mp = $themec->getMarketplace(); $mes->addSuccess(TPVLAN_85); if($mp->download($data['id'], $data['mode'], 'theme')) // download and unzip theme. { // Auto install? // $text = e107::getPlugin()->install($data['plugin_folder']); // $mes->addInfo($text); echo $mes->render('default', 'success'); e107::getTheme()->clearCache(); } else { echo $mes->addError('Unable to continue')->render('default', 'error'); } echo $mes->render('default', 'debug'); } elseif(!empty($_POST['selectadmin'])) { $mode = "admin"; } if(!empty($_POST['upload'])) { $mode = "upload"; } elseif(!empty($_POST['selectmain']) || isset($_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'] = TPVLAN_62; $var['online']['link'] = e_SELF."?mode=online"; $var['upload']['text'] = TPVLAN_38; $var['upload']['link'] = e_SELF."?mode=upload"; $var['convert']['text'] = ADLAN_CL_6; $var['convert']['link'] = e_SELF."?mode=convert"; // $selected = (e_QUERY) ? e_QUERY : "main"; $icon = e107::getParser()->toIcon('e-themes-24'); $caption = $icon."".TPVLAN_26.""; e107::getNav()->admin($caption, $mode, $var); } class theme_builder { var $themeName = ""; var $remove = array(); function __construct() { $ns = e107::getRender(); $tp = e107::getParser(); e107::getMessage()->addDebug("Disable debug to save generated files. "); $this->themeName = $tp->filter($_GET['newtheme'],'w'); if(!empty($_GET['src'])) { $this->themeSrc = $tp->filter($_GET['src'],'w'); $this->copyTheme(); /* $src = $tp->filter($_GET['src'],'w'); $name = $tp->filter($_GET['f']); $title = $tp->filter($_GET['t']); $this->copyTheme($src,$name,$title);*/ } if(vartrue($_GET['step']) == 3) { $this->step3(); return; } if(vartrue($_GET['step']) == 2) { $this->step2(); } else { $ret = $this->step1(); $ret2 = $this->copyThemeForm(); $tabs = array( 0 => array('caption'=>$ret['caption'], 'text'=>$ret['text']), 1 => array('caption'=>$ret2['caption'], 'text'=>$ret2['text']), ); $ns->tablerender(ADLAN_140.SEP.ADLAN_CL_6,e107::getForm()->tabs($tabs)); } } 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(' '.TPVLAN_64.'
'.TPVLAN_65.' '); $text = $frm->open('createPlugin','get',e_SELF."?mode=convert"); $text .= ""; /* $text .= " "; */ $text .= "
".TPVLAN_68." ".$frm->select("newtheme",$newDir)."
Create Files ".$frm->checkbox('createFiles',1,1)."
".$frm->admin_button('step', 2,'other',LAN_GO)."
"; $text .= $frm->close(); return array('caption'=>TPVLAN_88, 'text'=>$mes->render() . $text); $ns->tablerender(TPVLAN_26.SEP.TPVLAN_88.SEP. TPVLAN_CONV_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'), 'livedemo' => array('livedemo'), 'copyright' => array('copyright'), 'stylesheets' => array('stylesheets') // 'adminLinks' => array('url','description','icon','iconSmall','primary'), // 'sitelinks' => array('url','description','icon','iconSmall') ); $legacyFile = e_THEME.$this->themeName."/theme.php"; $newThemeXML = e_THEME.$this->themeName."/theme.xml"; if(file_exists($newThemeXML)) { $info = e107::getTheme()->getThemeInfo($this->themeName); e107::getDebug()->log($info); if($this->themeSrc) // New theme copied from another { $defaults = array( "main-name" => ucfirst($this->themeName), 'category-category' => vartrue($info['category']), ); } else { $defaults = array( "main-name" => vartrue($info['name']), "main-date" => vartrue($info['date']), "main-version" => vartrue($info['version']), "author-name" => vartrue($info['author']), "author-url" => vartrue($info['website']), "description-description" => vartrue($info['description']), "summary-summary" => vartrue($info['summary']), 'category-category' => vartrue($info['category']), // "custompages" => vartrue($leg['CUSTOMPAGES']), ); } if(!empty($info['keywords']['word'])) { $defaults['keywords-one'] = $info['keywords']['word'][0]; $defaults['keywords-two'] = $info['keywords']['word'][1]; } } elseif(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&src='.$this->themeSrc.'&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) ? 'col-md-7' : 'col-md-2'; $text .= "
".$this->xmlInput($name, $key."-". $type, vartrue($defaults[$nm]))."
"; } $text .= "
"; $text .= "
" .$frm->hidden('newtheme', $this->themeName); $text .= $frm->hidden('xml[custompages]', trim(vartrue($leg['CUSTOMPAGES']))) .$frm->admin_button('step', 3,'other',LAN_GENERATE)."
"; $text .= $frm->close(); // return array('caption'=>TPVLAN_88.SEP. TPVLAN_CONV_2, 'text'=>$mes->render() . $text); $ns->tablerender(TPVLAN_26.SEP.ADLAN_CL_6.SEP. TPVLAN_CONV_2, $mes->render() . $text); } function step3() { $ns = e107::getRender(); $mes = e107::getMessage(); // print_a($_POST); if(!empty($_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) && empty($this->themeSrc)) { $legacyData = file_get_contents($legacyFile); $legacyData = e107::getTheme()->upgradeThemeCode($legacyData); $output = nl2br(htmlentities($legacyData)); $ns->tablerender("theme.php (updated)", $output); } } 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(!empty($newArray['CUSTOMPAGES'])) { $newArray['CUSTOMPAGES'] = trim($newArray['CUSTOMPAGES']); $LAYOUTS = "\n\n"; $LAYOUTS .= " {CUSTOMPAGES}\n"; $LAYOUTS .= " "; } else { $LAYOUTS = ""; } if(!empty($newArray['STYLESHEETS_STYLESHEETS'])) { $STYLESHEETS = ''; foreach($newArray['STYLESHEETS_STYLESHEETS'] as $val) { if(empty($val['file'])) { continue; } $STYLESHEETS .= "\t\t\n"; } if(!empty($STYLESHEETS)) { $STYLESHEETS = "\n\t\n".$STYLESHEETS."\t"; } unset($newArray['STYLESHEETS_STYLESHEETS']); } else { $STYLESHEETS = ""; } $newArray['STYLESHEETS'] = $STYLESHEETS; // print_a($newArray); $template = <<