1<?php 2/* 3 * e107 website system 4 * 5 * Copyright (C) 2008-2009 e107 Inc (e107.org) 6 * Released under the terms and conditions of the 7 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) 8 * 9 */ 10 11require_once("../class2.php"); 12 13if (!getperms("1")) 14{ 15 e107::redirect('admin'); 16 exit; 17} 18 19e107::coreLan('theme', true); 20 21$e_sub_cat = 'theme_manage'; 22 23e107::css("inline"," 24.block-text h2.caption { text-align: right; margin-bottom: -30px; padding-right: 10px; } 25.hide { display: none } 26 27 28 29"); 30 31 32require_once(e_HANDLER."theme_handler.php"); 33$themec = new themeHandler; 34 35// print_a($_GET); 36 37$mode = varset($_GET['mode'],'main'); // (e_QUERY) ? e_QUERY :"main" ; 38 39 40if(!empty($_GET['action'])) 41{ 42 define('e_IFRAME',true); 43} 44 45if(!empty($_GET['action'])) 46{ 47 require_once("auth.php"); 48 switch ($_GET['action']) 49 { 50 case 'login': 51 $mp = $themec->getMarketplace(); 52 echo $mp->renderLoginForm(); 53 exit; 54 break; 55 56 /* 57 case 'download': 58 $string = base64_decode($_GET['src']); 59 parse_str($string, $p); 60 $mp = $themec->getMarketplace(); 61 $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); 62 // Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers) 63 echo "<pre>Connecting...\n"; flush(); 64 // download and flush 65 $mp->download($p['id'], $p['mode'], $p['type']); 66 echo "</pre>"; flush(); 67 exit; 68 break; 69 */ 70 71 case 'info': 72 if(!empty($_GET['src'])) 73 { 74 $string = base64_decode($_GET['src']); 75 parse_str($string,$p); 76 $themeInfo = e107::getSession()->get('thememanager/online/'.intval($p['id'])); 77 echo $themec->renderThemeInfo($themeInfo); 78 } 79 break; 80 81 case 'preview': 82 // Theme Info Ajax 83 $tm = (string) $_GET['id']; 84 $data = $themec->getThemeInfo($tm); 85 echo $themec->renderThemeInfo($data); 86 // exit; 87 break; 88 89 } 90/* 91 if(vartrue($_GET['src'])) // Process Theme Download. 92 { 93 $string = base64_decode($_GET['src']); 94 parse_str($string,$p); 95 96 if(vartrue($_GET['info'])) 97 { 98 echo $themec->renderThemeInfo($p); 99 // print_a($p); 100 exit; 101 } 102 103 $remotefile = $p['url']; 104 105 e107::getFile()->download($remotefile,'theme'); 106 exit; 107 108 } 109*/ 110 // Theme Info Ajax 111 // FIXME addd action=preview to the url, remove this block 112 if(!empty($_GET['id'])) 113 { 114 $tm = (string) $_GET['id']; 115 $data = $themec->getThemeInfo($tm); 116 echo $themec->renderThemeInfo($data); 117 } 118 119 require_once(e_ADMIN."footer.php"); 120 exit; 121 122} 123else 124{ 125 require_once("auth.php"); 126 127 /* 128 echo ' 129 130 <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true"> 131 <div class="modal-header"> 132 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 133 134 </div> 135 <div class="modal-body"> 136 <p>Loading…</p> 137 </div> 138 <div class="modal-footer"> 139 <a href="#" data-dismiss="modal" class="btn btn-primary">Close</a> 140 </div> 141 </div>'; 142 */ 143} 144 145 146 147 148 149 150 151if($mode == 'download' && !empty($_GET['src'])) 152{ 153 define('e_IFRAME', true); 154 $frm = e107::getForm(); 155 $mes = e107::getMessage(); 156 $string = base64_decode($_GET['src']); 157 parse_str($string, $data); 158 159 if(!empty($data['price'])) 160 { 161 e107::getRedirect()->go($data['url']); 162 return true; 163 } 164 165 if(deftrue('e_DEBUG_MARKETPLACE')) 166 { 167 echo "<b>DEBUG MODE ACTIVE (no downloading)</b><br />"; 168 echo '$_GET: '; 169 print_a($_GET); 170 171 echo 'base64 decoded and parsed as $data:'; 172 print_a($data); 173 return false; 174 } 175 176 177 $mp = $themec->getMarketplace(); 178 $mes->addSuccess(TPVLAN_85); 179 180 if($mp->download($data['id'], $data['mode'], 'theme')) // download and unzip theme. 181 { 182 // Auto install? 183 // $text = e107::getPlugin()->install($data['plugin_folder']); 184 // $mes->addInfo($text); 185 echo $mes->render('default', 'success'); 186 e107::getTheme()->clearCache(); 187 } 188 else 189 { 190 echo $mes->addError('Unable to continue')->render('default', 'error'); 191 } 192 193 echo $mes->render('default', 'debug'); 194 195} 196elseif(!empty($_POST['selectadmin'])) 197{ 198 $mode = "admin"; 199} 200 201if(!empty($_POST['upload'])) 202{ 203 $mode = "upload"; 204} 205elseif(!empty($_POST['selectmain']) || isset($_POST['setUploadTheme'])) 206{ 207 $mode = "main"; 208} 209 210if($mode == 'convert') 211{ 212 new theme_builder; 213} 214else 215{ 216 $themec -> showThemes($mode); 217} 218 219 220 221// <a data-toggle="modal" href="'.e_SELF.'" data-target="#myModal" class="btn" >Launch demo modal</a> 222 223 224 225 226require_once("footer.php"); 227 228function theme_adminmenu() 229{ 230 //global $mode; 231 232 $mode = varset($_GET['mode'],'main'); 233 234 // $e107 = &e107::getInstance(); 235 236 $var['main']['text'] = TPVLAN_33; 237 $var['main']['link'] = e_SELF; 238 239 $var['admin']['text'] = TPVLAN_34; 240 $var['admin']['link'] = e_SELF."?mode=admin"; 241 242 $var['choose']['text'] = TPVLAN_51; 243 $var['choose']['link'] = e_SELF."?mode=choose"; 244 245 $var['online']['text'] = TPVLAN_62; 246 $var['online']['link'] = e_SELF."?mode=online"; 247 248 $var['upload']['text'] = TPVLAN_38; 249 $var['upload']['link'] = e_SELF."?mode=upload"; 250 251 $var['convert']['text'] = ADLAN_CL_6; 252 $var['convert']['link'] = e_SELF."?mode=convert"; 253 254 // $selected = (e_QUERY) ? e_QUERY : "main"; 255 $icon = e107::getParser()->toIcon('e-themes-24'); 256 $caption = $icon."<span>".TPVLAN_26."</span>"; 257 258 259 e107::getNav()->admin($caption, $mode, $var); 260} 261 262class theme_builder 263{ 264 var $themeName = ""; 265 var $remove = array(); 266 267 function __construct() 268 { 269 270 $ns = e107::getRender(); 271 $tp = e107::getParser(); 272 273 e107::getMessage()->addDebug("Disable debug to save generated files. "); 274 275 276 $this->themeName = $tp->filter($_GET['newtheme'],'w'); 277 278 if(!empty($_GET['src'])) 279 { 280 $this->themeSrc = $tp->filter($_GET['src'],'w'); 281 $this->copyTheme(); 282 /* $src = $tp->filter($_GET['src'],'w'); 283 $name = $tp->filter($_GET['f']); 284 $title = $tp->filter($_GET['t']); 285 286 $this->copyTheme($src,$name,$title);*/ 287 288 } 289 290 291 292 if(vartrue($_GET['step']) == 3) 293 { 294 $this->step3(); 295 return; 296 } 297 298 if(vartrue($_GET['step']) == 2) 299 { 300 $this->step2(); 301 } 302 else 303 { 304 $ret = $this->step1(); 305 $ret2 = $this->copyThemeForm(); 306 307 $tabs = array( 308 0 => array('caption'=>$ret['caption'], 'text'=>$ret['text']), 309 1 => array('caption'=>$ret2['caption'], 'text'=>$ret2['text']), 310 311 ); 312 313 $ns->tablerender(ADLAN_140.SEP.ADLAN_CL_6,e107::getForm()->tabs($tabs)); 314 } 315 316 317 318 319 320 } 321 322 function step1() 323 { 324 325 $fl = e107::getFile(); 326 $frm = e107::getForm(); 327 $ns = e107::getRender(); 328 $mes = e107::getMessage(); 329 330 $plugFolders = $fl->get_dirs(e_THEME); 331 foreach($plugFolders as $dir) 332 { 333 if(file_exists(e_THEME.$dir."/theme.xml") || $dir == 'templates') 334 { 335 continue; 336 } 337 $newDir[$dir] = $dir; 338 } 339 340 $mes->addInfo(' '.TPVLAN_64.' <br /> 341 '.TPVLAN_65.' 342 <ul> 343 <li> '.TPVLAN_66.'</li> 344 <li> '.TPVLAN_67.'</li> 345 </ul> 346 '); 347 348 $text = $frm->open('createPlugin','get',e_SELF."?mode=convert"); 349 $text .= "<table class='table adminform'> 350 <colgroup> 351 <col class='col-label' /> 352 <col class='col-control' /> 353 </colgroup> 354 <tbody> 355 <tr> 356 <td> ".TPVLAN_68."</td> 357 <td>".$frm->select("newtheme",$newDir)."</td> 358 </tr>"; 359 360 /* 361 $text .= " 362 <tr> 363 <td>Create Files</td> 364 <td>".$frm->checkbox('createFiles',1,1)."</td> 365 </tr>"; 366 */ 367 368 $text .= "</tbody> 369 </table> 370 <div class='buttons-bar center'> 371 ".$frm->admin_button('step', 2,'other',LAN_GO)." 372 </div>"; 373 374 $text .= $frm->close(); 375 376 return array('caption'=>TPVLAN_88, 'text'=>$mes->render() . $text); 377 378 $ns->tablerender(TPVLAN_26.SEP.TPVLAN_88.SEP. TPVLAN_CONV_1, $mes->render() . $text); 379 380 } 381 382 function step2() 383 { 384 $ns = e107::getRender(); 385 $mes = e107::getMessage(); 386 $frm = e107::getForm(); 387 388 389 390 391 $data = array( 392 'main' => array('name','lang','version','date', 'compatibility'), 393 'author' => array('name','url'), 394 'summary' => array('summary'), 395 'description' => array('description'), 396 397 'keywords' => array('one','two'), 398 'category' => array('category'), 399 'livedemo' => array('livedemo'), 400 'copyright' => array('copyright'), 401 'stylesheets' => array('stylesheets') 402 // 'adminLinks' => array('url','description','icon','iconSmall','primary'), 403 // 'sitelinks' => array('url','description','icon','iconSmall') 404 ); 405 406 $legacyFile = e_THEME.$this->themeName."/theme.php"; 407 408 409 410 $newThemeXML = e_THEME.$this->themeName."/theme.xml"; 411 if(file_exists($newThemeXML)) 412 { 413 $info = e107::getTheme()->getThemeInfo($this->themeName); 414 415 e107::getDebug()->log($info); 416 417 if($this->themeSrc) // New theme copied from another 418 { 419 $defaults = array( 420 "main-name" => ucfirst($this->themeName), 421 'category-category' => vartrue($info['category']), 422 ); 423 } 424 else 425 { 426 $defaults = array( 427 "main-name" => vartrue($info['name']), 428 "main-date" => vartrue($info['date']), 429 "main-version" => vartrue($info['version']), 430 "author-name" => vartrue($info['author']), 431 "author-url" => vartrue($info['website']), 432 "description-description" => vartrue($info['description']), 433 "summary-summary" => vartrue($info['summary']), 434 'category-category' => vartrue($info['category']), 435 // "custompages" => vartrue($leg['CUSTOMPAGES']), 436 ); 437 } 438 439 if(!empty($info['keywords']['word'])) 440 { 441 $defaults['keywords-one'] = $info['keywords']['word'][0]; 442 $defaults['keywords-two'] = $info['keywords']['word'][1]; 443 } 444 445 } 446 elseif(file_exists($legacyFile)) 447 { 448 $legacyData = file_get_contents($legacyFile); 449 450 $regex = '/\$([\w]*)\s*=\s*("|\')([\w @.\/:<\>,\'\[\] !()]*)("|\');/im'; 451 preg_match_all($regex, $legacyData, $matches); 452 453 $leg = array(); 454 455 foreach($matches[1] as $i => $m) 456 { 457 $leg[$m] = strip_tags($matches[3][$i]); 458 if(substr($m,0,5) == 'theme' || $m == "CUSTOMPAGES") 459 { 460 $search[] = $matches[0][$i]; 461 } 462 } 463 464 $defaults = array( 465 "main-name" => vartrue($leg['themename']), 466 "author-name" => vartrue($leg['themeauthor']), 467 "author-url" => vartrue($leg['themewebsite']), 468 "description-description" => '', 469 "summary-summary" => vartrue($leg['themeinfo']), 470 "custompages" => vartrue($leg['CUSTOMPAGES']), 471 ); 472 473 $search[] = "Steve Dunstan"; 474 $search[] = "jalist@e107.org"; 475 476 $_SESSION['themebulder-remove'] = $search; 477 478 $mes->addInfo("Loading theme.php file"); 479 } 480 481 $text = $frm->open('newtheme-step3','post', e_SELF.'?mode=convert&src='.$this->themeSrc.'&newtheme='.$this->themeName.'&step=3'); 482 $text .= "<table class='table adminlist'>"; 483 foreach($data as $key=>$val) 484 { 485 $text.= "<tr><td>$key</td><td> 486 <div class='controls'>"; 487 foreach($val as $type) 488 { 489 $nm = $key.'-'.$type; 490 $name = "xml[$nm]"; 491 $size = (count($val)==1) ? 'col-md-7' : 'col-md-2'; 492 $text .= "<div class='{$size}'>".$this->xmlInput($name, $key."-". $type, vartrue($defaults[$nm]))."</div>"; 493 } 494 495 $text .= "</div></td></tr>"; 496 497 498 } 499 500 501 $text .= "</table>"; 502 $text .= " 503 <div class='buttons-bar center'>" 504 .$frm->hidden('newtheme', $this->themeName); 505 $text .= $frm->hidden('xml[custompages]', trim(vartrue($leg['CUSTOMPAGES']))) 506 .$frm->admin_button('step', 3,'other',LAN_GENERATE)." 507 </div>"; 508 509 $text .= $frm->close(); 510 511 // return array('caption'=>TPVLAN_88.SEP. TPVLAN_CONV_2, 'text'=>$mes->render() . $text); 512 513 $ns->tablerender(TPVLAN_26.SEP.ADLAN_CL_6.SEP. TPVLAN_CONV_2, $mes->render() . $text); 514 } 515 516 517 function step3() 518 { 519 $ns = e107::getRender(); 520 $mes = e107::getMessage(); 521 522 // print_a($_POST); 523 524 if(!empty($_POST['xml'])) 525 { 526 $xmlText = $this->createXml($_POST['xml']); 527 $ns->tablerender("theme.xml", $mes->render(). "<pre>".$xmlText."</pre>"); 528 } 529 530 531 $legacyFile = e_THEME.$this->themeName."/theme.php"; 532 if(file_exists($legacyFile) && empty($this->themeSrc)) 533 { 534 $legacyData = file_get_contents($legacyFile); 535 $legacyData = e107::getTheme()->upgradeThemeCode($legacyData); 536 537 $output = nl2br(htmlentities($legacyData)); 538 539 $ns->tablerender("theme.php (updated)", $output); 540 } 541 542 543 } 544 545 546 547 548 function createXml($data) 549 { 550 $ns = e107::getRender(); 551 $mes = e107::getMessage(); 552 $tp = e107::getParser(); 553 554 foreach($data as $key=>$val) 555 { 556 $key = strtoupper(str_replace("-","_",$key)); 557 $newArray[$key] = $val; 558 } 559 560 if(!empty($newArray['CUSTOMPAGES'])) 561 { 562 $newArray['CUSTOMPAGES'] = trim($newArray['CUSTOMPAGES']); 563 $LAYOUTS = "\n<layout name='custom' title='Custom'>\n"; 564 $LAYOUTS .= " <custompages>{CUSTOMPAGES}</custompages>\n"; 565 $LAYOUTS .= " </layout>"; 566 } 567 else 568 { 569 $LAYOUTS = ""; 570 } 571 572 if(!empty($newArray['STYLESHEETS_STYLESHEETS'])) 573 { 574 $STYLESHEETS = ''; 575 foreach($newArray['STYLESHEETS_STYLESHEETS'] as $val) 576 { 577 if(empty($val['file'])) 578 { 579 continue; 580 } 581 582 $STYLESHEETS .= "\t\t<css file=\"".$val['file']."\" name=\"".$val['name']."\" />\n"; 583 } 584 585 if(!empty($STYLESHEETS)) 586 { 587 $STYLESHEETS = "\n\t<stylesheets>\n".$STYLESHEETS."\t</stylesheets>"; 588 } 589 590 unset($newArray['STYLESHEETS_STYLESHEETS']); 591 } 592 else 593 { 594 $STYLESHEETS = ""; 595 } 596 597 $newArray['STYLESHEETS'] = $STYLESHEETS; 598 599 // print_a($newArray); 600 601 602$template = <<<TEMPLATE 603<?xml version="1.0" encoding="utf-8"?> 604<e107Theme name="{MAIN_NAME}" lan="{MAIN_LANG}" version="{MAIN_VERSION}" date="{MAIN_DATE}" compatibility="{MAIN_COMPATIBILITY}" livedemo="{LIVEDEMO_LIVEDEMO}"> 605 <author name="{AUTHOR_NAME}" url="{AUTHOR_URL}" /> 606 <summary lan="">{SUMMARY_SUMMARY}</summary> 607 <description lan="">{DESCRIPTION_DESCRIPTION}</description> 608 <category>{CATEGORY_CATEGORY}</category> 609 <keywords> 610 <word>{KEYWORDS_ONE}</word> 611 <word>{KEYWORDS_TWO}</word> 612 </keywords> 613 <copyright>{COPYRIGHT_COPYRIGHT}</copyright> 614 <screenshots> 615 <image>preview.jpg</image> 616 <image>fullpreview.jpg</image> 617 </screenshots>{STYLESHEETS} 618 <layouts> 619 <layout name='default' title='Default' default='true' />{LAYOUTS} 620 </layouts> 621</e107Theme> 622TEMPLATE; 623 624 625 $template = str_replace("{LAYOUTS}",$LAYOUTS, $template); 626 627 $result = e107::getParser()->simpleParse($template, $newArray); 628 $path = e_THEME.$this->themeName."/theme.xml"; 629 630 631 if(E107_DEBUG_LEVEL > 0) 632 { 633 $mes->addDebug("Debug Mode active - no file saved. "); 634 return htmlentities($result); 635 } 636 637 638 639 if(file_put_contents($path,$result)) 640 { 641 $mes->addSuccess("Saved: ".$path); 642 } 643 else 644 { 645 $mes->addError("Couldn't Save: ".$path); 646 } 647 648 649 650 return htmlentities($result); 651 652 653 } 654 655 656 657 function xmlInput($name, $info, $default='') 658 { 659 $frm = e107::getForm(); 660 list($cat,$type) = explode("-",$info); 661 662 $size = 30; 663 $help = ''; 664 $sizex = ''; 665 666 switch ($info) 667 { 668 669 case 'main-name': 670 $help = TPVLAN_CONV_3; 671 $required = true; 672 $pattern = "[A-Za-z 0-9]*"; 673 break; 674 675 case 'main-lang': 676 $help = TPVLAN_CONV_4; 677 $required = false; 678 $placeholder= "LAN equivalent"; 679 $pattern = "[A-Z0-9_]*"; 680 break; 681 682 case 'main-date': 683 $help = TPVLAN_CONV_6; 684 $required = true; 685 $default = (empty($default)) ? time() : strtotime($default); 686 break; 687 688 case 'main-version': 689 $default = '1.0'; 690 $required = true; 691 $help = TPVLAN_CONV_5; 692 $pattern = "^[\d]{1,2}\.[\d]{1,2}$"; 693 break; 694 695 case 'main-compatibility': 696 $default = '2.0'; 697 $required = true; 698 $help = TPVLAN_CONV_7; 699 $pattern = "^[\d]{1,2}\.[\d]{1,2}$"; 700 break; 701 702 case 'author-name': 703 $default = (vartrue($default)) ? $default : USERNAME; 704 $required = true; 705 $help = TPVLAN_CONV_8; 706 $pattern = "[A-Za-z \.0-9]*"; 707 break; 708 709 case 'author-url': 710 $required = true; 711 $help = TPVLAN_CONV_9; 712 // $pattern = "https?://.+"; 713 break; 714 715 case 'livedemo-livedemo': 716 $required = false; 717 $help = TPVLAN_CONV_16; 718 $placeholder= "http://demo-of-my-theme.com"; 719 // $pattern = "https?://.+"; 720 break; 721 722 //case 'main-installRequired': 723 // return "Installation required: ".$frm->radio_switch($name,'',LAN_YES, LAN_NO); 724 //break; 725 726 case 'summary-summary': 727 $help = TPVLAN_CONV_10; 728 $required = true; 729 $size = 200; 730 $placeholder= " "; 731 $pattern = "[A-Za-z,() \.0-9]*"; 732 break; 733 734 case 'keywords-one': 735 case 'keywords-two': 736 $help = TPVLAN_CONV_11; 737 $required = true; 738 $size = 20; 739 $placeholder= " "; 740 $pattern = '^[a-z]*$'; 741 break; 742 743 case 'description-description': 744 $help = TPVLAN_CONV_12; 745 $required = true; 746 $size = 100; 747 $placeholder = " "; 748 $pattern = "[A-Za-z \.0-9]*"; 749 break; 750 751 752 case 'category-category': 753 $help = TPVLAN_CONV_13; 754 $required = true; 755 $size = 20; 756 break; 757 758 default: 759 760 break; 761 } 762 763 $req = ($required == true) ? "&required=1" : ""; 764 $placeholder = (varset($placeholder)) ? $placeholder : $type; 765 $pat = ($pattern) ? "&pattern=".$pattern : ""; 766 $text = ''; 767 768 switch ($type) 769 { 770 771 case 'stylesheets': 772 $fl = e107::getFile(); 773 774 $fl->setMode('full'); 775 $stylesheets = $fl->get_files(e_THEME.$this->themeName."/", "\.css", null, 1); 776 foreach($stylesheets as $key=>$path) 777 { 778 $file = str_replace(e_THEME.$this->themeName."/",'',$path); 779 $text .= "<div class='row-fluid'>"; 780 $text .= "<div class='controls'>"; 781 $text .= "<div class='col-md-3'>".$frm->checkbox($name.'['.$key.'][file]',$file, false, array('label'=>$file))." 782 <div class='field-help'>".TPVLAN_CONV_14."</div></div>"; 783 $text .= "<div class='col-md-3'>".$frm->text($name.'['.$key.'][name]', $default, $size, 'placeholder='.$file . $req. $pat)." 784 <div class='field-help'>".TPVLAN_CONV_15."</div></div>"; 785 // $text .= "<div class='span2'>".$frm->checkbox('css['.$key.'][file]',$file, false, array('label'=>$file))."</div>"; 786 // $text .= "<div class='span2'>".$frm->text('css['.$key.'][name]', $default, $size, 'placeholder='.$placeholder . $req. $pat)."</div>"; 787 $text .= "</div>"; 788 $text .= "</div>"; 789 } 790 791 792 return $text; 793 break; 794 795 796 case 'date': 797 $text = $frm->datepicker($name, $default, 'format=yyyy-mm-dd'.$req.'&size=block-level'); 798 break; 799 800 case 'description': 801 $text = $frm->textarea($name,$default, 3, 100, $req.'&size=block-level'); // pattern not supported. 802 break; 803 804 805 case 'category': 806 807 $allowedCategories = array( 808 'generic', 'adult', 'blog', 'clan', 'children', 809 'corporate', 'forum', 'gaming', 'gallery', 'news', 810 'social', 'video', 'multimedia'); 811 812 sort($allowedCategories); 813 814 $text = $frm->select($name, $allowedCategories,$default,'useValues=1&required=1', true); 815 break; 816 817 818 default: 819 $text = $frm->text($name, $default, $size, 'placeholder='.$placeholder . $req. $pat.'&size=block-level'); 820 break; 821 } 822 823 824 $text .= ($help) ? "<span class='field-help'>".$help."</span>" : ""; 825 return $text; 826 827 } 828 829 830 831 832 833 function copyThemeForm() 834 { 835 836 $frm = e107::getForm(); 837 838 $list = e107::getTheme()->clearCache()->getThemeList(); // (e_THEME); 839 840 $folders = array_keys($list); 841 842 $text = $frm->open('copytheme','get','theme.php?mode=convert'); 843 $text .= "<table class='table adminform'> 844 <colgroup> 845 <col class='col-label' /> 846 <col class='col-control' /> 847 </colgroup> 848 <tr> 849 <td>".TPVLAN_91."</td> 850 <td>".$frm->select("src",$folders,'',array('useValues'=>1))."</td> 851 </tr> 852 853 <tr> 854 <td>".TPVLAN_92."</td> 855 <td>".$frm->text("newtheme",'',25, array('pattern'=>'[a-z_0-9]*', 'required'=>1))."</td> 856 </tr> 857 858 "; 859 860 /* 861 $text .= " 862 <tr> 863 <td>Create Files</td> 864 <td>".$frm->checkbox('createFiles',1,1)."</td> 865 </tr>"; 866 */ 867 868 $text .= " 869 </table> 870 <div class='buttons-bar center'> 871 ".$frm->admin_button('step', 2,'success', LAN_CREATE)." 872 </div>"; 873 874 875 876 877 $text .= $frm->close(); 878 879 880 // $text = "Create a new theme based on ".e->select('copytheme',$list); 881 882 883 return array('caption'=>LAN_CREATE, 'text'=>$text); 884 885 } 886 887 private function copyTheme() 888 { 889 if(empty($this->themeSrc) || empty($this->themeName) || is_dir(e_THEME.$this->themeName)) 890 { 891 return false; 892 } 893 894 if(e107::getFile()->copy(e_THEME.$this->themeSrc, e_THEME.$this->themeName)) 895 { 896 $newfiles = scandir(e_THEME.$this->themeName); 897 898 foreach($newfiles as $file) 899 { 900 if(is_dir(e_THEME.$this->themeName.'/'.$file) || $file === '.' || $file === '..') 901 { 902 continue; 903 } 904 905 if(strpos($file,"admin_") === 0) 906 { 907 unlink(e_THEME.$this->themeName.'/'.$file); 908 } 909 910 911 912 } 913 914 } 915 916 } 917 918 919 920 921} 922 923 924 925?> 926