00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00033 class freesite_admin {
00034
00035
00036 var $data = array();
00037 var $check = array();
00038 var $fieldsArray=array();
00039 var $HIDDEN_FIELDS="";
00040 var $ALL_OK="";
00041 var $verificationOK="";
00042 var $verificationCode="";
00043 var $noDomainURL="";
00044
00045
00046 var $groupTemplate = "";
00047 var $groupGeneral = "";
00048 var $newsite_page = "";
00049 var $groupData=array();
00050 var $userData=array();
00051 var $user_uid = "";
00052 var $userGroup_uid = "";
00053
00054
00055
00056
00057 var $sysConfig = Array (
00058 "backendOnly" => 1,
00059 "emailHeader" => "From: TYPO3 Freesite Creator <>",
00060
00061
00062
00063
00064 "pid_templateArchive" => 0,
00065 "pid_dummyPagesArchive" => 0,
00066 "exclude_templateSelect" => 0,
00067 "exclude_dummyPages" => 0,
00068 "previewData" => 0,
00069 "emailVerification" => 1,
00070 "emailVerificationSubject" => "Freesite Verification Code",
00071 "emailVerificationMessage" => "This is the verification code from the automatic site-creation tool. Just enter this code into the code-field on the website.",
00072 "virtualDirRequired" => 0,
00073 "defaultLanguage" => "",
00074
00075 "defaultFormField_sitetitle" => "TITLE",
00076
00077
00078 "templateFile" => "",
00079 "templateFile_selectTemplate" => "",
00080 "templateFile_selectPages" => "",
00081 "inputFieldParams" => 'size=55',
00082 "notCorrectHTML" => '<BR><img src="../../../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 align=top> ',
00083 "msgBadUsername" => 'The username is too short or it exists allready. Please enter another one.',
00084 "msgBadPassword" => 'The password is too short.',
00085 "msgBadEmail" => 'This is not a valid email address.',
00086 "msgBadPath" => 'This directory is in use allready (or not allowed).',
00087 "msgBadDomain" => 'This domain-name is not valid.',
00088 "msgBadDomain_used" => 'The domain is allready used in TYPO3',
00089 "msgBadValue" => 'This field is required!',
00090 "msgEmailVerificationCode" => '<B>EMAIL Verification:</b><BR>A verification code has been send to <i>%s</i>. Read your mail and enter the code in this field in order to continue!<BR>',
00091 "label_Update" => 'Update information',
00092 "label_Return" => 'Make changes',
00093 "label_Preview" => 'Freeze information',
00094 "label_Create" => 'Create site!',
00095
00096 "templateFile_selectTemplate" => "",
00097 "templateFile_selectPages" => "",
00098 "templateSelect_noInfoLink" => 0,
00099
00100
00101
00102
00103
00104 "testingOnly" => 0,
00105 "pid_newsite" => 0,
00106 "uid_templateGroup" => 0,
00107 "uid_generalGroup" => 0,
00108
00109 "create_lockToDomain" => 1,
00110 "create_fileoper_perms_default" => 7,
00111 "createDomains" => 1,
00112 "createVirtualDirs" => 0,
00113 "createNewGroupDir" => 0,
00114 "createNewUserDir" => 0,
00115
00116 "templateFile_created" => "",
00117 "notify_email" => "",
00118 "notifyUser_email" => 1,
00119 "notifyUser_emailSubject" => 'TYPO3 Freesite Created',
00120 "notifyUser_emailMessage" => '
00121 The new TYPO3 site has been created for you!
00122
00123 The website is found at: ###WEBSITE_URL###
00124
00125 Username: ###USERNAME###
00126 Password: ###PASSWORD###
00127
00128 You enter the administration site at :
00129 ###LINK_URL###
00130
00131 Kind regards.
00132 '
00133 );
00134
00135 var $backPath = "";
00136 var $genTree_HTML = "";
00137
00138
00139
00143 function freesite_admin () {
00144 $this->backPath = $GLOBALS["BACK_PATH"];
00145
00146 $extConf = unserialize($GLOBALS["TYPO3_CONF_VARS"]["EXT"]["extConf"]["freesite"]);
00147 if (!is_array($extConf)) {
00148 t3lib_BEfunc::typo3PrintError ("Configuration Error","No configuration found written to localconf.php. Please go to the Extension Manager, click the title of the Freesite extension and configure this module with the form in the bottom of the page!",0);
00149 exit;
00150 }
00151
00152 $this->sysConfig = array_merge($this->sysConfig,$extConf);
00153 if (!$this->sysConfig["notify_email"]) $this->sysConfig["notify_email"] = $TYPO3_CONF_VARS["BE"]["warning_email_addr"];
00154
00155
00156
00157 if (TYPO3_OS=="WIN") {
00158 $this->sysConfig["createVirtualDirs"]==0;
00159 }
00160
00161
00162
00163
00164
00165 if ($this->sysConfig["backendOnly"]) {
00166 if (!$GLOBALS["BE_USER"]->user["uid"]) {
00167 t3lib_BEfunc::typo3PrintError ("Login-error","No user logged in! Sorry, I can't proceed then!",0);
00168 exit;
00169 }
00170 $GLOBALS["BE_USER"]->modAccess($GLOBALS["MCONF"],1);
00171 }
00172 }
00173
00174
00178 function genTree($theID, $depthData) {
00179
00180 $a=0;
00181
00182 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title,doktype,hidden,deleted', 'pages', 'pid='.intval($theID).' AND deleted=0', '', 'sorting');
00183 $c = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00184 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00185 $a++;
00186 $newID =$row[uid];
00187
00188 $this->genTree_HTML.="\n<DIV><NOBR>";
00189 $PM = "join";
00190 $LN = ($a==$c)?"blank":"line";
00191 $BTM = ($a==$c)?"bottom":"";
00192 $this->genTree_HTML.= $depthData.'<IMG src="'.$this->backPath.'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top"><IMG src="'.$this->backPath.'gfx/i/pages.gif" width="18" height="16" align="top">'.t3lib_div::fixed_lgd(strip_tags($row[title]),50).'</NOBR></DIV>';
00193 $this->genTree($newID,$this->genTree_HTML ? $depthData.'<IMG src="'.$this->backPath.'t3lib/gfx/ol/'.$LN.'.gif" width="18" height="16" align="top">' : '');
00194 }
00195 }
00196
00200 function doesExist($table,$field,$value) {
00201 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, $field.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($value, $table));
00202 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00203 return $row;
00204 }
00205 }
00206
00210 function getInputData($fieldName,$hsc=0) {
00211 $out = $this->data[$fieldName];
00212 if ($hsc) {
00213 $out=htmlspecialchars($out);
00214 }
00215 return $out;
00216 }
00217
00221 function isCorrect($fieldName) {
00222 if (isset($this->check[$fieldName])) {
00223 return $this->sysConfig["notCorrectHTML"].$this->check[$fieldName].'<BR>';
00224 }
00225 }
00226
00230 function cleanFileName($fileName) {
00231
00232 $theNewName = ereg_replace("[^\.[:alnum:]_-]","_",trim($fileName));
00233 return substr($theNewName,0,50);
00234 }
00235
00239 function rmSlash($string) {
00240 return ereg_replace("\/$","",$string);
00241 }
00242
00246 function rmDoubleSlash($string) {
00247 return str_replace("//","/",$string);
00248 }
00249
00250
00254 function getSubpart($content, $marker) {
00255 if ($marker && strstr($content,$marker)) {
00256 $start = strpos($content, $marker)+strlen($marker);
00257 $stop = @strpos($content, $marker, $start+1);
00258 $sub = substr($content, $start, $stop-$start);
00259
00260 $reg=Array();
00261 ereg("^[^<]*-->",$sub,$reg);
00262 $start+=strlen($reg[0]);
00263
00264 $reg=Array();
00265 ereg("<!--[^>]*$",$sub,$reg);
00266 $stop-=strlen($reg[0]);
00267
00268 return substr($content, $start, $stop-$start);
00269 }
00270 }
00271
00275 function substituteSubpart($content,$marker,$subpartContent,$recursive=1) {
00276
00277
00278
00279 $start = strpos($content, $marker);
00280 $stop = @strpos($content, $marker, $start+1)+strlen($marker);
00281 if ($start && $stop>$start) {
00282
00283 $before = substr($content, 0, $start);
00284 $reg=Array();
00285 ereg("<!--[^>]*$",$before,$reg);
00286 $start-=strlen($reg[0]);
00287 $before = substr($content, 0, $start);
00288
00289 $after = substr($content, $stop);
00290 $reg=Array();
00291 ereg("^[^<]*-->",$after,$reg);
00292 $stop+=strlen($reg[0]);
00293 $after = substr($content, $stop);
00294
00295 if (is_array($subpartContent)) {
00296 $substContent=$subpartContent[0].$this->getSubpart($content,$marker).$subpartContent[1];
00297 } else {
00298 $substContent=$subpartContent;
00299 }
00300
00301 if ($recursive && strpos($after, $marker)) {
00302 return $before.$substContent.$this->substituteSubpart($after,$marker,$subpartContent);
00303 } else {
00304 return $before.$substContent.$after;
00305 }
00306 } else {
00307 return $content;
00308 }
00309 }
00310
00314 function insertInDatabase($table,$data,$uid=0) {
00315 if ($table && is_array($data)) {
00316 unset($data["uid"]);
00317
00318 if (count($data)) {
00319 if ($this->sysConfig["testingOnly"]) {
00320 debug($table);
00321 debug($data);
00322
00323 if ($uid) {
00324 $query = $GLOBALS['TYPO3_DB']->UPDATEquery($table, 'uid='.intval($uid), $data);
00325 } else {
00326 $query = $GLOBALS['TYPO3_DB']->INSERTquery($table, $data);
00327 }
00328 debug($query,1);
00329
00330 return "99999";
00331 } else {
00332 if ($uid) {
00333 $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), $data);
00334 } else {
00335 $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $data);
00336 }
00337 $err = $GLOBALS['TYPO3_DB']->sql_error();
00338 if ($err) {
00339 debug($err,1);
00340 debug($table,1);
00341 debug($query,1);
00342
00343 exit;
00344 }
00345 return $GLOBALS['TYPO3_DB']->sql_insert_id();
00346 }
00347 }
00348 }
00349 die("The record could not be inserted or updated! ".$table);
00350 }
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00368 function main() {
00369
00370 $this->data = t3lib_div::_POST("data");
00371 $this->verifyData();
00372 $this->isReady();
00373
00374
00375
00376
00377 if (!$this->verificationOK) {
00378 $templateCode = $this->enteringData();
00379 } else {
00380 $templateCode = $this->creatingData();
00381 }
00382
00383 echo $templateCode;
00384
00385 if ($this->sysConfig["testingOnly"]) {
00386 echo "<HR>";
00387 debug("DATA:");
00388 debug($this->data);
00389 }
00390 }
00391
00395 function verifyData() {
00396
00397
00398
00399
00400
00401
00402 if (is_array($this->data)) {
00403 reset($this->data);
00404 while(list($k,$v)=each($this->data)) {
00405 $v=trim($v);
00406 $ok=0;
00407 switch($k) {
00408 case "FIELD_username":
00409 $v=strtolower($v);
00410 $v=$this->cleanFileName($v);
00411 $v=substr($v,0,20);
00412 if (strlen($v)<5 || $this->doesExist("be_users","username",$v)) {
00413 $this->check[$k]=$this->sysConfig["msgBadUsername"];
00414 }
00415 break;
00416 case "FIELD_email":
00417 if (!ereg("^[A-Za-z0-9\._-]*[@][A-Za-z0-9\._-]*[\.].[A-Za-z0-9]*$",$v)) {
00418 $this->check[$k]=$this->sysConfig["msgBadEmail"];
00419 }
00420 break;
00421 case "FIELD_password":
00422 if (strlen($v)<5) {
00423 $this->check[$k]=$this->sysConfig["msgBadPassword"];
00424 }
00425 break;
00426 case "FIELD_lang":
00427 if (!$v) {
00428 $v=$this->sysConfig["defaultLanguage"];
00429 }
00430 break;
00431 case "TEMPLATE":
00432 case "DUMMY_PAGES":
00433 $v=intval($v);
00434 $ok=1;
00435 break;
00436 case "FOLDER":
00437 $v=str_replace("å","aa",$v);
00438 $v=str_replace("Å","AA",$v);
00439 $v=strtr($v, "áéúíâêûôîæøÁÉÚÍÄËÜÖÏÆØ", "aeuiaeuoieoAEUIAEUOIEO");
00440
00441 $v=$this->cleanFileName($v);
00442 if ($v && (@file_exists(PATH_site.$v) || ereg("^typo|file|upload|media|t3lib|tslib",$v))) {
00443 $this->check[$k]=$this->sysConfig["msgBadPath"];
00444 }
00445 if (!$this->sysConfig["virtualDirRequired"]) {
00446 $ok=1;
00447 }
00448 break;
00449 case "DOMAIN":
00450 $v=strtolower($v);
00451 if ($v) {
00452 if (ereg("[^\.a-z0-9_-]",$v) || !strstr($v,".")) {
00453 $this->check[$k]=$this->sysConfig["msgBadDomain"];
00454 } else {
00455 if ($this->doesExist("sys_domain","domainName",$v)) {
00456 $this->check[$k]=$this->sysConfig["msgBadDomain_used"];
00457 }
00458 }
00459 }
00460 $ok=1;
00461 break;
00462 CASE "TITLE":
00463 $ok=1;
00464 break;
00465 default:
00466 break;
00467 }
00468 $this->data[$k]=$v;
00469 if (!$this->data[$k] && !$ok) {
00470 $this->check[$k]=$this->sysConfig["msgBadValue"];
00471 }
00472 }
00473 }
00474 }
00475
00479 function isReady() {
00480
00481
00482
00483
00484 $this->ALL_OK= (is_array($this->data) && !count($this->check));
00485
00486 $this->verificationOK="";
00487 if ($this->ALL_OK) {
00488 ksort($this->data);
00489 $this->verificationCode = strtoupper(substr(md5(serialize($this->data)),0,10));
00490
00491 $VERIFICATION_CODE = strtoupper(trim(t3lib_div::_POST("VERIFICATION_CODE")));
00492 if (t3lib_div::_POST("createButton")) {
00493 $this->verificationOK = ($VERIFICATION_CODE && !strcmp($VERIFICATION_CODE,$this->verificationCode));
00494 }
00495 }
00496 }
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00515 function enteringData() {
00516
00517
00518
00519 $templateFile= $this->sysConfig["templateFile"] ? PATH_site.$this->sysConfig["templateFile"] : "template.html";
00520 $templateCode = t3lib_div::getURL($templateFile);
00521 if (!$templateCode) die("No template file!! (".$templateFile.")");
00522
00523
00524 $this->fieldsArray["BACK_PATH"]=$this->backPath."../";
00525
00526
00527
00528
00529 $this->fieldsArray["TEMPLATE_VIEW"]="";
00530 if ($this->data["TEMPLATE"] && !$this->check["TEMPLATE"]) {
00531 $fN="tmplimages/".$this->data["TEMPLATE"];
00532 $file="";
00533 if (@is_file($fN.".gif")) {
00534 $file=$fN.".gif";
00535 } elseif (@is_file($fN.".jpg")) {
00536 $file=$fN.".jpg";
00537 }
00538 if (@is_file($file)) {
00539 $fI = @getimagesize($file);
00540 if (is_array($fI)) {
00541 $this->fieldsArray["TEMPLATE_VIEW"]='<BR><img src="'.$file.'" '.$fI[3].'><BR>';
00542 }
00543 }
00544 }
00545 $this->fieldsArray["DUMMY_PAGES_VIEW"]="";
00546 if ($this->data["DUMMY_PAGES"] && !$this->check["DUMMY_PAGES"]) {
00547 $this->genTree($this->data["DUMMY_PAGES"],"");
00548 $this->fieldsArray["DUMMY_PAGES_VIEW"]="<BR><BR>".$this->genTree_HTML."<BR>";
00549 }
00550
00551
00552
00553 if (!$this->ALL_OK || t3lib_div::_POST("updateButton")) {
00554
00555 $this->displayDataForms();
00556 } else {
00557
00558 $this->previewData();
00559 }
00560
00561
00562
00563
00564
00565
00566 $this->fieldsArray["UPDATE_CREATE"].=$this->HIDDEN_FIELDS;
00567 reset($this->fieldsArray);
00568 while(list($key,$content)=each($this->fieldsArray)) {
00569 $templateCode = str_replace("###".$key."###",$content,$templateCode);
00570 }
00571 return $templateCode;
00572 }
00573
00577 function displayDataForms() {
00578 global $TCA;
00579
00580
00581
00582 $languages=array();
00583 t3lib_div::loadTCA("be_users");
00584 if ($TCA["be_users"]["columns"]["lang"]) {
00585 reset($TCA["be_users"]["columns"]["lang"]["config"]["items"]);
00586 while(list(,$k)=each($TCA["be_users"]["columns"]["lang"]["config"]["items"])) {
00587 $theK = $k[1] ? $k[1] : "default";
00588 $languages[$theK]=$GLOBALS["LANG"]->sL($k[0]);
00589 }
00590 }
00591
00592
00593
00594
00595 $params=($this->sysConfig["inputFieldParams"] ? " ".$this->sysConfig["inputFieldParams"] : "") ;
00596
00597
00598
00599
00600 $this->fieldsArray["FIELD_realName"]='<input type="Text" name="data[FIELD_realName]" value="'.$this->getInputData("FIELD_realName",1).'"'.$params.'>'.$this->isCorrect("FIELD_realName");
00601 $this->fieldsArray["FIELD_email"]='<input type="Text" name="data[FIELD_email]" value="'.$this->getInputData("FIELD_email",1).'"'.$params.'>'.$this->isCorrect("FIELD_email");
00602 $this->fieldsArray["FIELD_username"]='<input type="Text" name="data[FIELD_username]" value="'.$this->getInputData("FIELD_username",1).'"'.$params.'>'.$this->isCorrect("FIELD_username");
00603 $this->fieldsArray["FIELD_password"]='<input type="Text" name="data[FIELD_password]" value="'.$this->getInputData("FIELD_password",1).'"'.$params.'>'.$this->isCorrect("FIELD_password");
00604
00605 $oTags="";
00606 reset($languages);
00607 $cmpValue = $this->getInputData("FIELD_lang") ? $this->getInputData("FIELD_lang") : $this->sysConfig["defaultLanguage"];
00608 while(list($key,$val)=each($languages)) {
00609 $oTags.='<option value="'.$key.'"'.($key==$cmpValue?' selected':'').'>'.$val.'</option>';
00610 }
00611 $this->fieldsArray["FIELD_lang"]='<select name="data[FIELD_lang]">'.$oTags.'</select>'.$this->isCorrect("FIELD_lang");
00612
00613
00614
00615
00616 $this->fieldsArray["TITLE"]='<input type="Text" name="data[TITLE]" value="'.$this->getInputData("TITLE",1).'"'.$params.'>'.$this->isCorrect("TITLE");
00617 $this->fieldsArray["FOLDER"]='<input type="Text" name="data[FOLDER]" value="'.$this->getInputData("FOLDER",1).'"'.$params.'>'.$this->isCorrect("FOLDER");
00618 $this->fieldsArray["DOMAIN"]='<input type="Text" name="data[DOMAIN]" value="'.$this->getInputData("DOMAIN",1).'"'.$params.'>'.$this->isCorrect("DOMAIN");
00619
00620
00621
00622
00623
00624 $pid = intval($this->sysConfig["pid_templateArchive"]);
00625 $oTags="";
00626 $firstUID=0;
00627 if ($pid) {
00628
00629 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($pid).' AND deleted=0 AND hidden=0 AND starttime=0 AND endtime=0', '', 'sorting');
00630 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00631 if (!$firstUID) $firstUID=$row[uid];
00632 $key=$row["uid"];
00633 $val=$row["title"];
00634 $oTags.='<option value="'.$key.'"'.($key==$this->getInputData("TEMPLATE")?' selected':'').'>'.$val.'</option>';
00635 }
00636
00637 $page_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid='.intval($pid).' AND deleted=0 AND hidden=0 AND starttime=0 AND endtime=0 AND fe_group=0', '', 'sorting');
00638 while($page_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($page_res)) {
00639
00640 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($page_row['uid']).' AND deleted=0 AND hidden=0 AND starttime=0 AND endtime=0', '', 'sorting');
00641 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00642 if (!$firstUID) $firstUID=$row[uid];
00643 $key=$row["uid"];
00644 $val=$page_row["title"]." / ".$row["title"];
00645 $oTags.='<option value="'.$key.'"'.($key==$this->getInputData("TEMPLATE")?' selected':'').'>'.$val.'</option>';
00646 }
00647 }
00648 $this->fieldsArray["TEMPLATE"]='<select name="data[TEMPLATE]">'.$oTags.'</select>'.$this->isCorrect("TEMPLATE");
00649 if ($this->sysConfig["exclude_templateSelect"]) {
00650 $this->fieldsArray["TEMPLATE"]="";
00651 $this->HIDDEN_FIELDS.='<input type="hidden" name="data[TEMPLATE]" value="'.$firstUID.'">';
00652 }
00653 } else {
00654 $this->fieldsArray["TEMPLATE"]="";
00655 }
00656
00657
00658
00659
00660 $pid = intval($this->sysConfig["pid_dummyPagesArchive"]);
00661 $oTags="";
00662 $firstUID=0;
00663 if ($pid) {
00664 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid='.intval($pid).' AND deleted=0 AND hidden=0 AND starttime=0 AND endtime=0 AND fe_group=0', '', 'sorting');
00665 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00666 if (!$firstUID) $firstUID=$row[uid];
00667 $key=$row["uid"];
00668 $val=$row["title"];
00669 $oTags.='<option value="'.$key.'"'.($key==$this->getInputData("DUMMY_PAGES")?' selected':'').'>'.$val.'</option>';
00670 }
00671 $this->fieldsArray["DUMMY_PAGES"]='<select name="data[DUMMY_PAGES]">'.$oTags.'</select>'.$this->isCorrect("DUMMY_PAGES");
00672 if ($this->sysConfig["exclude_dummyPages"]) {
00673 $this->fieldsArray["DUMMY_PAGES"]='';
00674 $this->HIDDEN_FIELDS.='<input type="Hidden" name="data[DUMMY_PAGES]" value="'.$firstUID.'">';
00675 }
00676 } else {
00677 $this->fieldsArray["DUMMY_PAGES"]='';
00678 }
00679
00680
00681
00682
00683 $this->fieldsArray["UPDATE_CREATE"]='<input type="Submit" name="updateButton" value="'.$this->sysConfig["label_Update"].'">';
00684 if ($this->ALL_OK) {
00685 if ($this->sysConfig["previewData"]) {
00686 $this->fieldsArray["UPDATE_CREATE"].=' <input type="Submit" name="previewButton" value="'.$this->sysConfig["label_Preview"].'">';
00687 } else {
00688 $this->fieldsArray["UPDATE_CREATE"].=' <input type="Submit" name="createButton" value="'.$this->sysConfig["label_Create"].'">';
00689 $this->HIDDEN_FIELDS.='<input type="Hidden" name="VERIFICATION_CODE" value="'.$this->verificationCode.'">'.chr(10);
00690 }
00691 }
00692 }
00693
00697 function previewData() {
00698 $fields=explode(",","FIELD_realName,FIELD_email,FIELD_username,FIELD_password,FIELD_lang,TITLE,FOLDER,DOMAIN,DUMMY_PAGES,TEMPLATE");
00699 while(list(,$v)=each($fields)) {
00700 switch($v) {
00701 case "DOMAIN":
00702 if ($this->data["FOLDER"] && !$this->data["DOMAIN"]) {
00703 $p=parse_url(t3lib_div::getIndpEnv("TYPO3_REQUEST_SCRIPT"));
00704 $dir=dirname($p["path"]);
00705 $path=dirname(dirname($dir));
00706 $this->fieldsArray[$v]="<b>".$path."</b>";
00707 } else {
00708 $this->fieldsArray[$v]="<b>".$this->data[$v]."</b>";
00709 }
00710 break;
00711 default:
00712 $this->fieldsArray[$v]="<b>".$this->data[$v]."</b>";
00713 break;
00714 }
00715 $this->HIDDEN_FIELDS.='<input type="Hidden" name="data['.$v.']" value="'.htmlspecialchars($this->data[$v]).'">'.chr(10);
00716 }
00717
00718
00719
00720
00721 if ($this->sysConfig["emailVerification"] && $this->sysConfig["previewData"]) {
00722 $this->fieldsArray["UPDATE_CREATE"]=sprintf($this->sysConfig["msgEmailVerificationCode"],$this->data["FIELD_email"]);
00723 $msg=$this->sysConfig["emailVerificationMessage"];
00724
00725
00726 mail ($this->data["FIELD_email"],
00727 $this->sysConfig["emailVerificationSubject"],
00728 $msg.chr(10).chr(10).$this->verificationCode,
00729 $this->sysConfig["emailHeader"]);
00730
00731 $this->fieldsArray["UPDATE_CREATE"].='<input type="Text" name="VERIFICATION_CODE" value=""><BR><BR>'.chr(10);
00732 } else {
00733 $this->HIDDEN_FIELDS.='<input type="Hidden" name="VERIFICATION_CODE" value="'.$this->verificationCode.'">'.chr(10);
00734 }
00735
00736 $this->fieldsArray["UPDATE_CREATE"].='<input type="Submit" name="updateButton" value="'.$this->sysConfig["label_Return"].'">';
00737 $this->fieldsArray["UPDATE_CREATE"].=' <input type="Submit" name="createButton" value="'.$this->sysConfig["label_Create"].'">';
00738 }
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749 function creatingData () {
00750
00751
00752
00753
00754 $this->groupTemplate = $this->doesExist("be_groups","uid",$this->sysConfig["uid_templateGroup"]);
00755 $this->groupGeneral = $this->doesExist("be_groups","uid",$this->sysConfig["uid_generalGroup"]);
00756 $this->newsite_page = $this->doesExist("pages","uid",$this->sysConfig["pid_newsite"]);
00757
00758
00759
00760
00761
00762
00763 $this->groupData=array();
00764 $this->groupData["pid"]=0;
00765 $this->groupData["tstamp"]=time();
00766 $this->groupData["hidden"]=0;
00767 $this->groupData["crdate"]=time();
00768 $this->groupData["cruser_id"]=0;
00769 $this->groupData["deleted"]=0;
00770
00771
00772
00773
00774 $this->groupData["title"]=$this->data["FIELD_username"];
00775 $this->groupData["description"]=
00776 "Sitetitle: ".$this->data["TITLE"].chr(10).
00777 "Name: ".$this->data["FIELD_realName"].chr(10).
00778 "Domain: ".$this->data["DOMAIN"].chr(10).
00779 "Folder: ".$this->data["FOLDER"].chr(10);
00780
00781
00782 $this->groupData["inc_access_lists"]= $this->groupTemplate["inc_access_lists"];
00783 $this->groupData["non_exclude_fields"]= $this->groupTemplate["non_exclude_fields"];
00784 $this->groupData["pagetypes_select"]= $this->groupTemplate["pagetypes_select"];
00785 $this->groupData["tables_select"]= $this->groupTemplate["tables_select"];
00786 $this->groupData["tables_modify"]= $this->groupTemplate["tables_modify"];
00787 $this->groupData["groupMods"]= $this->groupTemplate["groupMods"];
00788 $this->groupData["db_mountpoints"]= $this->groupTemplate["db_mountpoints"];
00789 $this->groupData["file_mountpoints"]= $this->groupTemplate["file_mountpoints"];
00790 $this->groupData["subgroup"]= $this->groupTemplate["subgroup"];
00791
00792
00793 if ($this->sysConfig["create_lockToDomain"]) {
00794 $this->groupData["lockToDomain"]=$this->data["DOMAIN"];
00795 } else {
00796 $this->groupData["lockToDomain"]="";
00797 }
00798
00799
00800
00801
00802
00803
00804
00805
00806 $this->userData=array();
00807 $this->userData["pid"]=0;
00808 $this->userData["tstamp"]=time();
00809 $this->userData["admin"]=0;
00810 $this->userData["disable"]=0;
00811 $this->userData["starttime"]=0;
00812 $this->userData["endtime"]=0;
00813 $this->userData["crdate"]=time();
00814 $this->userData["cruser_id"]=0;
00815 $this->userData["deleted"]=0;
00816
00817
00818 $this->userData["username"]=$this->data["FIELD_username"];
00819 $this->userData["password"]=md5($this->data["FIELD_password"]);
00820 $this->userData["email"]=$this->data["FIELD_email"];
00821 $this->userData["realName"]=$this->data["FIELD_realName"];
00822
00823 $this->data["FIELD_lang"] = $this->data["FIELD_lang"] ? $this->data["FIELD_lang"] : $this->sysConfig["defaultLanguage"];
00824 $this->userData["lang"]=$this->data["FIELD_lang"]=="default" ? "" : $this->data["FIELD_lang"];
00825
00826
00827 $this->userData["db_mountpoints"]="";
00828 $this->userData["file_mountpoints"]="";
00829 $this->userData["options"]=3;
00830
00831
00832 if ($this->sysConfig["create_lockToDomain"]) {
00833 $this->userData["lockToDomain"]=$this->data["DOMAIN"];
00834 } else {
00835 $this->userData["lockToDomain"]="";
00836 }
00837
00838
00839 $this->userData["uc"]="";
00840 $this->userData["userMods"]="";
00841 $this->userData["fileoper_perms"]=$this->sysConfig["create_fileoper_perms_default"];
00842
00843
00844
00845
00846 if (!$this->doesExist("be_users","username",$this->userData["username"])) {
00847 return $this->startCreate();
00848 } else {
00849
00850 die("Some error occurred! (the user did exist for some reason!)");
00851 }
00852
00853 }
00854
00858 function startCreate() {
00859 $this->setNoDomainUrl();
00860 $this->notifyAdmin();
00861 $this->addUserAndGroup();
00862 $this->createDirs();
00863
00864
00865
00866
00867 $new_BE_USER = t3lib_div::makeInstance("t3lib_beUserAuth");
00868 $new_BE_USER->OS = TYPO3_OS;
00869 if (!$this->sysConfig["testingOnly"]) {
00870 $new_BE_USER->setBeUserByUid($this->user_uid);
00871 $new_BE_USER->fetchGroupData();
00872 }
00873
00874
00875
00876
00877 if (($new_BE_USER->user["uid"] || $this->sysConfig["testingOnly"]) && is_array($this->newsite_page)) {
00878
00879 $dummyPage_row=$this->doesExist("pages","uid",$this->data["DUMMY_PAGES"]);
00880 if ($this->sysConfig["pid_dummyPagesArchive"] && is_array($dummyPage_row) && $this->sysConfig["pid_dummyPagesArchive"]==$dummyPage_row["pid"]) {
00881 $root_page_pid = $this->copyDummyPages($dummyPage_row["uid"],$new_BE_USER);
00882 if ($root_page_pid) {
00883 $this->setGroupMountPoint($root_page_pid);
00884 $this->setRootPageProperties($root_page_pid);
00885 $virtualDir = $this->createVirtualDir();
00886 $domainData = $this->createDomainRecord($root_page_pid,$virtualDir);
00887 $this->createTemplateRecord($root_page_pid,$this->getRootPageTitle());
00888 } else die ("No pages copied");
00889 } else die("no dummy page archive.");
00890 } else die ("new_BE_USER did not exist OR newsite_page didn't exist");
00891
00892 $out = $this->createdOutput($domainData);
00893 $this->sendNotifyEmailToUser();
00894 return $out;
00895 }
00896
00900 function setNoDomainUrl() {
00901 $p=parse_url(t3lib_div::getIndpEnv("TYPO3_REQUEST_SCRIPT"));
00902 $dir=dirname($p["path"]);
00903 $sitedirname = dirname(dirname(dirname(dirname($dir))));
00904 if (substr($sitedirname,-1)!="/") {
00905 $sitedirname.="/";
00906 }
00907 $this->noDomainURL=$this->rmDoubleSlash($p["host"].$sitedirname);
00908 }
00909
00913 function notifyAdmin() {
00914 $subject=$this->sysConfig["notifyUser_emailSubject"];
00915 if ($this->sysConfig["notify_email"]) {
00916 mail ($this->sysConfig["notify_email"],
00917 $subject." (admin-note)",
00918 "New site is created by ".$this->data["FIELD_realName"]." (".$this->data["FIELD_email"].") at http://".$this->noDomainURL.chr(10).chr(10).
00919 "Username: ".$this->userData["username"].chr(10).
00920 "Password: ".$this->data["FIELD_password"].chr(10),
00921 $this->sysConfig["emailHeader"]);
00922 }
00923 }
00924
00928 function addUserAndGroup() {
00929
00930 $this->testHeader("Add group");
00931 $this->userGroup_uid=$this->insertInDatabase("be_groups",$this->groupData);
00932
00933
00934
00935 $this->userData["usergroup"]=$this->userGroup_uid;
00936 if ($this->groupGeneral) {
00937 $this->userData["usergroup"].=",".$this->groupGeneral["uid"];
00938 }
00939 $this->testHeader("Add user");
00940 $this->user_uid = $this->insertInDatabase("be_users",$this->userData);
00941 }
00942
00946 function createDirs() {
00947 global $TYPO3_CONF_VARS;
00948
00949
00950
00951 if ($this->sysConfig["createNewUserDir"]
00952 && t3lib_div::isFirstPartOfStr($TYPO3_CONF_VARS["BE"]["userHomePath"],$TYPO3_CONF_VARS["BE"]["lockRootPath"])
00953 && @is_dir($TYPO3_CONF_VARS["BE"]["userHomePath"])) {
00954 $folder=$this->rmDoubleSlash($TYPO3_CONF_VARS["BE"]["userHomePath"]."/".$this->user_uid);
00955 if (!$this->sysConfig["testingOnly"]) {
00956 mkdir ($folder, 0700);
00957 mkdir ($folder."/_temp_", 0700);
00958 } else {
00959 debug("CREATE user home dir: ".$folder,1);
00960 }
00961 }
00962 if ($this->sysConfig["createNewGroupDir"]
00963 && t3lib_div::isFirstPartOfStr($TYPO3_CONF_VARS["BE"]["groupHomePath"],$TYPO3_CONF_VARS["BE"]["lockRootPath"])
00964 && @is_dir($TYPO3_CONF_VARS["BE"]["groupHomePath"])) {
00965 $folder=$this->rmDoubleSlash($TYPO3_CONF_VARS["BE"]["groupHomePath"]."/".$this->userGroup_uid);
00966 if (!$this->sysConfig["testingOnly"]) {
00967 mkdir ($folder, 0700);
00968 mkdir ($folder."/_temp_", 0700);
00969 } else {
00970 debug("CREATE group home dir: ".$folder,1);
00971 }
00972 }
00973 }
00974
00978 function createVirtualDir() {
00979 $virtualDir=0;
00980 $newFolder=PATH_site.$this->data["FOLDER"];
00981
00982 if (TYPO3_OS!="WIN" && $this->sysConfig["createVirtualDirs"] && $this->sysConfig["createDomains"] && $this->data["FOLDER"]) {
00983 if (!@file_exists($newFolder)) {
00984 if (!$this->sysConfig["testingOnly"]) {
00985 mkdir ($newFolder, 0700);
00986 $thelinks=explode(",","clear.gif,.htaccess,fileadmin,index.php,media,showpic.php,typo3,t3lib,tslib,typo3conf,typo3temp,uploads");
00987 while(list(,$target)=each($thelinks)) {
00988 $dest=$newFolder."/".$target;
00989 $target=PATH_site.$target;
00990 if (@file_exists($target)) {
00991 symlink ($target,$dest);
00992 }
00993 }
00994 } else {
00995 debug("CREATE VIRTUAL FOLDER: ".$newFolder,1);
00996 }
00997 $virtualDir=1;
00998 } else {
00999 die("This folder did exist allready! ".$newFolder);
01000 }
01001 }
01002 return $virtualDir;
01003 }
01004
01008 function copyDummyPages($src_uid,$new_BE_USER) {
01009 if (!$this->sysConfig["testingOnly"]) {
01010 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
01011 $tce->stripslashes_values=0;
01012 $tce->copyTree=2;
01013 $tce->neverHideAtCopy=1;
01014
01015
01016 $new_BE_USER->user["admin"]=1;
01017
01018
01019 $cmd=array();
01020 $cmd["pages"][$src_uid]["copy"]=$this->sysConfig["pid_newsite"];
01021 $tce->start(array(),$cmd,$new_BE_USER);
01022 $tce->process_cmdmap();
01023
01024
01025 unset($new_BE_USER);
01026
01027
01028 $root_page_pid = $tce->copyMappingArray["pages"][$src_uid];
01029 return $root_page_pid;
01030 } else {
01031 debug("COPY page structure: pid=".$src_uid,1);
01032 return 99999;
01033 }
01034 }
01035
01039 function setGroupMountPoint($root_page_pid) {
01040 $groupUpdate=array();
01041 if ($this->groupData["db_mountpoints"]) {
01042 $groupUpdate["db_mountpoints"] = $root_page_pid.",".$this->groupData["db_mountpoints"];
01043 } else {
01044 $groupUpdate["db_mountpoints"]=$root_page_pid;
01045 }
01046
01047 $this->testHeader("Group Update");
01048 $this->insertInDatabase("be_groups",$groupUpdate,$this->userGroup_uid);
01049 }
01050
01054 function setRootPageProperties($root_page_pid) {
01055 $pageData=array();
01056 $pageData["alias"]=$this->data["FIELD_username"];
01057 $pageData["title"]= $this->getRootPageTitle();
01058 $pageData["perms_userid"]=0;
01059
01060 $this->testHeader("page Data update");
01061 $this->insertInDatabase("pages",$pageData,$root_page_pid);
01062 }
01063
01067 function getRootPageTitle() {
01068 return $this->data["TITLE"]?$this->data["TITLE"]:($this->data["DOMAIN"]?$this->data["DOMAIN"]:($this->data["FOLDER"]?$this->data["FOLDER"]:$this->data["FIELD_username"]));
01069 }
01070
01074 function createDomainRecord($root_page_pid,$virtualDir) {
01075 if (($virtualDir || $this->data["DOMAIN"]) && $this->sysConfig["createDomains"]) {
01076 if (!$this->data["DOMAIN"]) {
01077 $path=$this->noDomainURL;
01078 } else {
01079 $path=$this->data["DOMAIN"]."/";
01080 }
01081 if ($virtualDir) {
01082 $path.=$this->data["FOLDER"];
01083 }
01084 $path = $this->rmSlash($path);
01085
01086 $domainData=array();
01087 $domainData["pid"]=$root_page_pid;
01088 $domainData["tstamp"]=time();
01089 $domainData["hidden"]=0;
01090 $domainData["domainName"]=$path;
01091 $domainData["redirectTo"]="";
01092
01093 if (!$this->doesExist("sys_domain","domainName",$path)) {
01094 $this->testHeader("sys_domain record");
01095 $this->insertInDatabase("sys_domain",$domainData);
01096 }
01097 }
01098 return $domainData;
01099 }
01100
01104 function createTemplateRecord($root_page_pid,$title) {
01105 if ($this->sysConfig["pid_templateArchive"]) {
01106
01107
01108
01109 $templateData=array();
01110
01111 $templateData["pid"]=$root_page_pid;
01112 $templateData["tstamp"]=time();
01113 $templateData["sorting"]=0;
01114 $templateData["crdate"]=time();
01115 $templateData["cruser_id"]=0;
01116 $templateData["deleted"]=0;
01117 $templateData["hidden"]=0;
01118 $templateData["starttime"]=0;
01119 $templateData["endtime"]=0;
01120
01121
01122 $templateData["root"]=1;
01123 $templateData["clear"]=3;
01124 $templateData["include_static"]="";
01125 $templateData["constants"]="";
01126 $templateData["config"]="";
01127 $templateData["resources"]="";
01128 $templateData["nextLevel"]="";
01129 $templateData["description"]="[AUTO-GENERATED TEMPLATE - ".date("d-m-Y")."]".chr(10);
01130
01131
01132 $templateData["title"]=$title;
01133 $templateData["sitetitle"]=$this->data[$this->sysConfig["defaultFormField_sitetitle"]];
01134 $templateData["basedOn"]=intval($this->data["TEMPLATE"]);
01135
01136 $this->testHeader("sys_template");
01137 $this->insertInDatabase("sys_template",$templateData);
01138 }
01139 }
01140
01144 function createdOutput($domainData) {
01145
01146 $templateFile= $this->sysConfig["templateFile_created"] ? PATH_site.$this->sysConfig["templateFile_created"] : "template_created.html";
01147 $templateCode = t3lib_div::getURL($templateFile);
01148 if (!$templateCode) die("No template file!! (".$templateFile.")");
01149
01150
01151
01152
01153 $this->fieldsArray["USERNAME"]=$this->userData["username"];
01154 $this->fieldsArray["PASSWORD"]=$this->data["FIELD_password"];
01155 $this->fieldsArray["WEBSITE_URL"]="http://".$this->rmSlash($domainData["domainName"]?$domainData["domainName"]:$this->noDomainURL)."/";
01156 $this->fieldsArray["ADMIN_URL"]=$this->fieldsArray["WEBSITE_URL"].TYPO3_mainDir;
01157 $this->fieldsArray["LINK_URL"]=$this->fieldsArray["ADMIN_URL"]."index.php?u=".rawurlencode($this->fieldsArray["USERNAME"])."&p=".rawurlencode($this->fieldsArray["PASSWORD"]);
01158 $this->fieldsArray["EMAIL"]=$this->data["FIELD_email"];
01159 if (!$domainData["domainName"]) {$this->fieldsArray["WEBSITE_URL"].='?'.$this->data["FIELD_username"];}
01160
01161 reset($this->fieldsArray);
01162 while(list($key,$content)=each($this->fieldsArray)) {
01163 $templateCode = str_replace("###".$key."###",$content,$templateCode);
01164 }
01165 return $templateCode;
01166 }
01167
01171 function sendNotifyEmailToUser() {
01172 $msg=$this->sysConfig["notifyUser_emailMessage"];
01173 $subject=$this->sysConfig["notifyUser_emailSubject"];
01174 reset($this->fieldsArray);
01175 while(list($key,$content)=each($this->fieldsArray)) {
01176 $msg = str_replace("###".$key."###",$content,$msg);
01177 }
01178 if ($this->sysConfig["notifyUser_email"]) {
01179 mail ($this->data["FIELD_email"],
01180 $subject,
01181 $msg,
01182 $this->sysConfig["emailHeader"]);
01183 }
01184 }
01185
01189 function testHeader($label) {
01190 if ($this->sysConfig["testingOnly"]) {
01191 echo '<HR>';
01192 debug($label,1);
01193 }
01194 }
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204 function getTemplateHTML($uid,$title,$template) {
01205 $fN="tmplimages/".$uid;
01206 $file="";
01207 if (@is_file($fN.".gif")) {
01208 $file=$fN.".gif";
01209 } elseif (@is_file($fN.".jpg")) {
01210 $file=$fN.".jpg";
01211 }
01212 if (@is_file($file)) {
01213 $fI = @getimagesize($file);
01214 if (is_array($fI)) {
01215 $image='<img src="'.$file.'" '.$fI[3].' border=0>';
01216 $image='<a href="#" onClick="select('.$uid.'); return false;">'.$image.'</a>';
01217 }
01218 }
01219
01220 $msg = $template;
01221 $msg = str_replace("###TITLE###",$title,$msg);
01222 $msg = str_replace("###IMAGE###",$image,$msg);
01223 return $msg;
01224 }
01225 function getPagesHTML($uid,$title,$template) {
01226 $admin = t3lib_div::makeInstance("freesite_admin");
01227 $admin->genTree($uid,"");
01228
01229 $pages=$admin->genTree_HTML;
01230 $title='<a href="#" onClick="select('.$uid.'); return false;">'.$title.'</a>';
01231
01232 $msg = $template;
01233 $msg = str_replace("###TITLE###",$title,$msg);
01234 $msg = str_replace("###PAGES###",$pages,$msg);
01235 return $msg;
01236 }
01237
01238
01239
01240
01241
01242
01243
01244
01245 function printSelect($theType) {
01246
01247 $theKey = "templateFile_".$theType;
01248 $templateFile= $this->sysConfig[$theKey] ? PATH_site.$this->sysConfig[$theKey] : "template_".$theType.".html";
01249 $templateCode = t3lib_div::getURL($templateFile);
01250 if (!$templateCode) die("No template file!! (".$templateFile.")");
01251
01252
01253 $itemPart = $this->getSubpart($templateCode, "###TEMPLATE_ITEM###");
01254 $out="";
01255
01256 switch($theType) {
01257 case "selectTemplate":
01258
01259 $infoUid = t3lib_div::_GP("infoUid");
01260 if ($infoUid && !$GLOBALS["TYPO3_CONF_VARS"]["BE"]["EXTERNAL"]["FREESITE"]["templateSelect_noInfoLink"]) {
01261
01262 $tRec = t3lib_BEfunc::getRecord("sys_template",$infoUid);
01263 if (is_array($tRec)) {
01264 $existTemplate = $this->initialize_editor($tRec["pid"],$tRec["uid"]);
01265 $out.="<HR><h3>Template Information:</h3>";
01266 $out.='<a href="index.php?script=template&infoUid='.$infoUid.'&allDetails=1">Show all categories</a><BR>';
01267 $out.=$this->displayExample("");
01268 }
01269
01270 } else {
01271 $pid = intval($this->sysConfig["pid_templateArchive"]);
01272 $oTags="";
01273 $firstUID=0;
01274 if ($pid) {
01275
01276 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($pid).' AND deleted=0 AND hidden=0 AND starttime=0 AND endtime=0', '', 'sorting');
01277 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01278 if (!$firstUID) $firstUID=$row[uid];
01279 $key=$row["uid"];
01280 $val=$row["title"];
01281 $out.=$this->getTemplateHTML($key,$val,$itemPart);
01282 }
01283
01284 $page_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid='.intval($pid).' AND deleted=0 AND hidden=0 AND starttime=0 AND endtime=0 AND fe_group=0', '', 'sorting');
01285 while($page_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($page_res)) {
01286
01287 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($page_row['uid']).' AND deleted=0 AND hidden=0 AND starttime=0 AND endtime=0', '', 'sorting');
01288 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01289 if (!$firstUID) $firstUID=$row[uid];
01290 $key=$row['uid'];
01291 $val=$page_row['title'].' / '.$row['title'];
01292 if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['EXTERNAL']['FREESITE']['templateSelect_noInfoLink']) {
01293 $out.='<a name="T'.$key.'"></a>';
01294 $out.='<a href="index.php?script=template&infoUid='.$key.'" target="template_infowindow"><img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/icon_note.gif" class="absmiddle" width=18 height=16 border=0></a>';
01295 }
01296 $out.=$this->getTemplateHTML($key,$val,$itemPart);
01297 }
01298 }
01299 }
01300 }
01301 break;
01302 case "selectPages":
01303
01304 $pid = intval($this->sysConfig["pid_dummyPagesArchive"]);
01305 $oTags="";
01306 $firstUID=0;
01307 if ($pid) {
01308 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid='.intval($pid).' AND deleted=0 AND hidden=0 AND starttime=0 AND endtime=0 AND fe_group=0', '', 'sorting');
01309 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01310 if (!$firstUID) $firstUID = $row[uid];
01311 $key = $row["uid"];
01312 $val = $row["title"];
01313 $out.= $this->getPagesHTML($key,$val,$itemPart);
01314 }
01315 }
01316 break;
01317 }
01318 echo $this->substituteSubpart($templateCode, "###TEMPLATE_ITEM###", $out);
01319 }
01320
01321
01322
01323 function displayExample($theOutput) {
01324 global $tmpl,$theConstants;
01325 $categories = $tmpl->ext_getCategoryLabelArray();
01326 $allDetails = t3lib_div::_GP("allDetails");
01327 if (is_array($categories)) {
01328
01329
01330 reset($categories);
01331 $tmpl->ext_localGfxPrefix=t3lib_extMgm::extPath("tstemplate_ceditor");
01332 $tmpl->ext_localWebGfxPrefix=$this->backPath.t3lib_extMgm::extRelPath("tstemplate_ceditor");
01333 while(list($category,$label)=each($categories)) {
01334 $tmpl->helpConfig=array();
01335 $tmpl->ext_getTSCE_config($category);
01336
01337 $detailFlag = $tmpl->helpConfig["imagetag"] || $tmpl->helpConfig["description"] || $tmpl->helpConfig["header"];
01338 if ($allDetails || $detailFlag) {
01339 $theOutput.="<HR>";
01340 $theOutput.="<h3>".$label.": ".$tmpl->helpConfig["header"]."</h3>";
01341 }
01342 if ($detailFlag) {
01343 $theOutput.='<div align="center">'.$tmpl->helpConfig["imagetag"].'</div><BR>'.
01344 ($tmpl->helpConfig["description"] ? implode(explode("//",$tmpl->helpConfig["description"]),"<BR>")."<BR>" : "").
01345 ($tmpl->helpConfig["bulletlist"] ? "<ul><li>".implode(explode("//",$tmpl->helpConfig["bulletlist"]),"<li>")."</ul>" : "<BR>");
01346 }
01347 if ($allDetails || $detailFlag) {
01348 $theOutput.=$this->getTemplateDetails($category);
01349 }
01350 }
01351 }
01352
01353 return $theOutput;
01354 }
01355 function getTemplateDetails($category) {
01356 global $tmpl,$theConstants;
01357
01358
01359 $subcat="";
01360 $subcat_name="";
01361 asort($tmpl->categories[$category]);
01362 while(list($name,$type)=each($tmpl->categories[$category])) {
01363 $params = $theConstants[$name];
01364 if (is_array($params)) {
01365 if ($subcat!=$params["subcat_name"]) {
01366 $subcat=$params["subcat_name"];
01367 $subcat_name = $params["subcat_name"] ? $tmpl->subCategories[$params["subcat_name"]][0] : "Others";
01368
01369 $out.='<tr><td colspan=3><img src=clear.gif height=10 width=1></td></tr>';
01370 $out.='<tr><td colspan=3 bgcolor="#cccccc"><strong>'.fw(strtoupper(htmlspecialchars($subcat_name))).'</strong></td></tr>';
01371 }
01372
01373 list($label)=explode("|",$params["label"]);
01374 $label_parts = explode(":",$label,2);
01375 if (count($label_parts)==2) {
01376 $head=trim($label_parts[0]);
01377 $body=trim($label_parts[1]);
01378 } else {
01379 $head=trim($label_parts[0]);
01380 $body="";
01381 }
01382 if (strlen($head)>35) {
01383 if (!$body) {$body=$head;}
01384 $head=t3lib_div::fixed_lgd($head,35);
01385 }
01386 $typeDat=$tmpl->ext_getTypeData($params["type"]);
01387
01388 $p_name = '<font color="#666666">['.$params["name"].']</font><BR>';
01389 $p_dlabel='<font color="#666666"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</font><BR>';
01390 $p_label = '<b>'.htmlspecialchars($head).'</b>';
01391 $p_descrip = $body ? htmlspecialchars($body)."<BR>" : "";
01392
01393
01394 $out.='<tr><td nowrap valign=top>'.fw($tmpl->helpConfig["constants"][$params["name"]].$p_label).'<BR><font color="#666666">'.fw(t3lib_div::fixed_lgd(htmlspecialchars($params["type"]),20)).'</font></td><td><img src=clear.gif width=10 height=1></td><td valign=top>'.fw($p_descrip).'</td></tr>';
01395
01396 }
01397 }
01398 $out='<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>';
01399 return $out;
01400 }
01401 function initialize_editor($pageId,$template_uid=0) {
01402
01403 global $tmpl,$tplRow,$theConstants;
01404
01405 $tmpl = t3lib_div::makeInstance("t3lib_tsparser_ext");
01406 $tmpl->tt_track = 0;
01407 $tmpl->init();
01408 $tmpl->fieldCompensation = (($GLOBALS["CLIENT"]["BROWSER"]=="net") ? "1" : "1.15");
01409
01410 $tplRow = $tmpl->ext_getFirstTemplate($pageId,$template_uid);
01411 if (is_array($tplRow)) {
01412
01413 $sys_page = t3lib_div::makeInstance("t3lib_pageSelect");
01414 $rootLine = $sys_page->getRootLine($pageId);
01415 $tmpl->runThroughTemplates($rootLine,$template_uid);
01416 $theConstants = $tmpl->generateConfig_constants();
01417 $tmpl->ext_categorizeEditableConstants($theConstants);
01418 $tmpl->ext_regObjectPositions($tplRow["constants"]);
01419 return 1;
01420 }
01421 }
01422 }
01423
01424
01425
01426 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/freesite/mod/class.freesite.php"]) {
01427 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/freesite/mod/class.freesite.php"]);
01428 }
01429
01430
01431 ?>