Documentation TYPO3 par Ameos

class.tx_kickstarter_section_module.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2001-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00031 require_once(t3lib_extMgm::extPath("kickstarter")."class.tx_kickstarter_sectionbase.php");
00032  
00033 class tx_kickstarter_section_module extends tx_kickstarter_sectionbase {
00034   var $sectionID = 'module';
00038         function render_wizard() {
00039                 $lines=array();
00040 
00041                 $action = explode(":",$this->wizard->modData["wizAction"]);
00042                 if ($action[0]=="edit") {
00043                         $this->regNewEntry($this->sectionID,$action[1]);
00044                         $lines = $this->catHeaderLines($lines,$this->sectionID,$this->wizard->options[$this->sectionID],"&nbsp;",$action[1]);
00045                         $piConf = $this->wizard->wizArray[$this->sectionID][$action[1]];
00046                         $ffPrefix='['.$this->sectionID.']['.$action[1].']';
00047 
00048                                 // Enter title of the module
00049                         $subContent="<strong>Enter a title for the module:</strong><BR>".
00050                                 $this->renderStringBox_lang("title",$ffPrefix,$piConf);
00051                         $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00052 
00053                                 // Description
00054                         $subContent="<strong>Enter a description:</strong><BR>".
00055                                 $this->renderStringBox_lang("description",$ffPrefix,$piConf);
00056                         $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00057 
00058                                 // Description
00059                         $subContent="<strong>Enter a tab label (shorter description):</strong><BR>".
00060                                 $this->renderStringBox_lang("tablabel",$ffPrefix,$piConf);
00061                         $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00062 
00063                                 // Position
00064                         $optValues = array(
00065                                 "web" => "Sub in Web-module",
00066                                 "file" => "Sub in File-module",
00067                                 "user" => "Sub in User-module",
00068                                 "tools" => "Sub in Tools-module",
00069                                 "help" => "Sub in Help-module",
00070                                 "_MAIN" => "New main module"
00071                         );
00072                         $subContent="<strong>Sub- or main module?</strong><BR>".
00073                                 $this->renderSelectBox($ffPrefix."[position]",$piConf["position"],$optValues).
00074                                 $this->resImg("module.png");
00075                         $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00076 
00077                                 // Sub-position
00078                         $optValues = array(
00079                                 "0" => "Bottom (default)",
00080                                 "top" => "Top",
00081                                 "web_after_page" => "If in Web-module, after Web>Page",
00082                                 "web_before_info" => "If in Web-module, before Web>Info",
00083                         );
00084                         $subContent="<strong>Position in module menu?</strong><BR>".
00085                                 $this->renderSelectBox($ffPrefix."[subpos]",$piConf["subpos"],$optValues);
00086                         $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00087 
00088                                 // Admin only
00089                         $subContent = $this->renderCheckBox($ffPrefix."[admin_only]",$piConf["admin_only"])."Admin-only access!<BR>";
00090                         $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00091 
00092                                 // Options
00093                         $subContent = $this->renderCheckBox($ffPrefix."[interface]",$piConf["interface"])."Allow other extensions to interface with function menu<BR>";
00094 #                       $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00095                 }
00096 
00097                 /* HOOK: Place a hook here, so additional output can be integrated */
00098                 if(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['kickstarter']['add_cat_module'])) {
00099                   foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['kickstarter']['add_cat_module'] as $_funcRef) {
00100                     $lines = t3lib_div::callUserFunction($_funcRef, $lines, $this);
00101                   }
00102                 }
00103 
00104                 $content = '<table border=0 cellpadding=2 cellspacing=2>'.implode("",$lines).'</table>';
00105                 return $content;
00106         }
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00118         function render_extPart($k,$config,$extKey) {
00119                 $WOP="[module][".$k."]";
00120                 $mN = ($config["position"]!="_MAIN"?$config["position"]."_":"").$this->returnName($extKey,"module","M".$k);
00121                 $cN = $this->returnName($extKey,"class","module".$k);
00122                 $pathSuffix = "mod".$k."/";
00123 
00124                         // Insert module:
00125                 switch($config["subpos"])       {
00126                         case "top":
00127                                 $subPos="top";
00128                         break;
00129                         case "web_after_page":
00130                                 $subPos="after:layout";
00131                         break;
00132                         case "web_before_info":
00133                                 $subPos="before:info";
00134                         break;
00135                 }
00136                 $this->wizard->ext_tables[]=$this->sPS('
00137                         '.$this->WOPcomment('WOP:'.$WOP).'
00138                         if (TYPO3_MODE=="BE")   {
00139                                         '.$this->WOPcomment('1. and 2. parameter is WOP:'.$WOP.'[position] , 3. parameter is WOP:'.$WOP.'[subpos]').'
00140                                 t3lib_extMgm::addModule("'.
00141                                         ($config["position"]!="_MAIN"?$config["position"]:$this->returnName($extKey,"module","M".$k)).
00142                                         '","'.
00143                                         ($config["position"]!="_MAIN"?$this->returnName($extKey,"module","M".$k):"").
00144                                         '","'.
00145                                         $subPos.
00146                                         '",t3lib_extMgm::extPath($_EXTKEY)."'.$pathSuffix.'");
00147                         }
00148                 ');
00149 
00150                         // Make conf.php file:
00151                 $content = $this->sPS('
00152                                 // DO NOT REMOVE OR CHANGE THESE 3 LINES:
00153                         define("TYPO3_MOD_PATH", "ext/'.$extKey.'/'.$pathSuffix.'");
00154                         $BACK_PATH="../../../";
00155                         $MCONF["name"]="'.$mN.'";
00156 
00157                                 '.$this->WOPcomment('WOP:'.$WOP.'[admin_only]: If the flag was set the value is "admin", otherwise "user,group"').'
00158                         $MCONF["access"]="'.($config["admin_only"]?"admin":"user,group").'";
00159                         $MCONF["script"]="index.php";
00160 
00161                         $MLANG["default"]["tabs_images"]["tab"] = "moduleicon.gif";
00162                         $MLANG["default"]["ll_ref"]="LLL:EXT:'.$extKey.'/'.$pathSuffix.'locallang_mod.php";
00163                 ');
00164                 $this->wizard->EM_CONF_presets["module"][]=ereg_replace("\/$","",$pathSuffix);
00165 
00166 
00167                 $ll=array();
00168                 $this->addLocalConf($ll,$config,"title","module",$k,1,0,"mlang_tabs_tab");
00169                 $this->addLocalConf($ll,$config,"description","module",$k,1,0,"mlang_labels_tabdescr");
00170                 $this->addLocalConf($ll,$config,"tablabel","module",$k,1,0,"mlang_labels_tablabel");
00171                 $this->addLocalLangFile($ll,$pathSuffix."locallang_mod.php",'Language labels for module "'.$mN.'" - header, description');
00172 
00173 //                      $MLANG["default"]["tabs"]["tab"] = "'.addslashes($config["title"]).'";  '.$this->WOPcomment('WOP:'.$WOP.'[title]').'
00174 //                      $MLANG["default"]["labels"]["tabdescr"] = "'.addslashes($config["description"]).'";     '.$this->WOPcomment('WOP:'.$WOP.'[description]').'
00175 //                      $MLANG["default"]["labels"]["tablabel"] = "'.addslashes($config["tablabel"]).'";        '.$this->WOPcomment('WOP:'.$WOP.'[tablabel]').'
00176 
00177 /*
00178                 if (count($this->selectedLanguages))    {
00179                         reset($this->selectedLanguages);
00180                         while(list($lk,$lv)=each($this->selectedLanguages))     {
00181                                 if ($lv)        {
00182                                         $content.= $this->sPS('
00183                                                         // '.$this->languages[$lk].' language:
00184                                                 $MLANG["'.$lk.'"]["tabs"]["tab"] = "'.addslashes($config["title_".$lk]).'";     '.$this->WOPcomment('WOP:'.$WOP.'[title_'.$lk.']').'
00185                                                 $MLANG["'.$lk.'"]["labels"]["tabdescr"] = "'.addslashes($config["description_".$lk]).'";        '.$this->WOPcomment('WOP:'.$WOP.'[description_'.$lk.']').'
00186                                                 $MLANG["'.$lk.'"]["labels"]["tablabel"] = "'.addslashes($config["tablabel_".$lk]).'";   '.$this->WOPcomment('WOP:'.$WOP.'[tablabel_'.$lk.']').'
00187                                         ');
00188                                 }
00189                         }
00190                 }
00191 */
00192                 $content=$this->wrapBody('
00193                         <?php
00194                         ',$content,'
00195                         ?>
00196                 ',0);
00197 
00198                 $this->addFileToFileArray($pathSuffix."conf.php",trim($content));
00199 
00200                         // Add title to local lang file
00201                 $ll=array();
00202                 $this->addLocalConf($ll,$config,"title","module",$k,1);
00203                 $this->addLocalConf($ll,array("function1"=>"Function #1"),"function1","module",$k,1,1);
00204                 $this->addLocalConf($ll,array("function2"=>"Function #2"),"function2","module",$k,1,1);
00205                 $this->addLocalConf($ll,array("function3"=>"Function #3"),"function3","module",$k,1,1);
00206                 $this->addLocalLangFile($ll,$pathSuffix."locallang.php",'Language labels for module "'.$mN.'"');
00207 
00208                         // Add clear.gif
00209                 $this->addFileToFileArray($pathSuffix."clear.gif",t3lib_div::getUrl(t3lib_extMgm::extPath("kickstarter")."res/clear.gif"));
00210 
00211                         // Add clear.gif
00212                 $this->addFileToFileArray($pathSuffix."moduleicon.gif",t3lib_div::getUrl(t3lib_extMgm::extPath("kickstarter")."res/notfound_module.gif"));
00213 
00214 
00215                         // Make module index.php file:
00216                 $indexContent = $this->sPS('
00217                                 // DEFAULT initialization of a module [BEGIN]
00218                         unset($MCONF);
00219                         require ("conf.php");
00220                         require ($BACK_PATH."init.php");
00221                         require ($BACK_PATH."template.php");
00222                         $LANG->includeLLFile("EXT:'.$extKey.'/'.$pathSuffix.'locallang.php");
00223                         #include ("locallang.php");
00224                         require_once (PATH_t3lib."class.t3lib_scbase.php");
00225                         $BE_USER->modAccess($MCONF,1);  // This checks permissions and exits if the users has no permission for entry.
00226                                 // DEFAULT initialization of a module [END]
00227                 ');
00228 
00229                 $indexContent.= $this->sPS('
00230                         class '.$cN.' extends t3lib_SCbase {
00231                                 var $pageinfo;
00232 
00236                                 function init() {
00237                                         global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00238 
00239                                         parent::init();
00240 
00241                                         /*
00242                                         if (t3lib_div::_GP("clear_all_cache"))  {
00243                                                 $this->include_once[]=PATH_t3lib."class.t3lib_tcemain.php";
00244                                         }
00245                                         */
00246                                 }
00247 
00251                                 function menuConfig()   {
00252                                         global $LANG;
00253                                         $this->MOD_MENU = Array (
00254                                                 "function" => Array (
00255                                                         "1" => $LANG->getLL("function1"),
00256                                                         "2" => $LANG->getLL("function2"),
00257                                                         "3" => $LANG->getLL("function3"),
00258                                                 )
00259                                         );
00260                                         parent::menuConfig();
00261                                 }
00262 
00263                                         // If you chose "web" as main module, you will need to consider the $this->id parameter which will contain the uid-number of the page clicked in the page tree
00267                                 function main() {
00268                                         global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00269 
00270                                         // Access check!
00271                                         // The page will show only if there is a valid page and if this page may be viewed by the user
00272                                         $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00273                                         $access = is_array($this->pageinfo) ? 1 : 0;
00274 
00275                                         if (($this->id && $access) || ($BE_USER->user["admin"] && !$this->id))  {
00276 
00277                                                         // Draw the header.
00278                                                 $this->doc = t3lib_div::makeInstance("mediumDoc");
00279                                                 $this->doc->backPath = $BACK_PATH;
00280                                                 $this->doc->form=\'<form action="" method="POST">\';
00281 
00282                                                         // JavaScript
00283                                                 $this->doc->JScode = \'
00284                                                         <script language="javascript" type="text/javascript">
00285                                                                 script_ended = 0;
00286                                                                 function jumpToUrl(URL) {
00287                                                                         document.location = URL;
00288                                                                 }
00289                                                         </script>
00290                                                 \';
00291                                                 $this->doc->postCode=\'
00292                                                         <script language="javascript" type="text/javascript">
00293                                                                 script_ended = 1;
00294                                                                 if (top.fsMod) top.fsMod.recentIds["web"] = \'.intval($this->id).\';
00295                                                         </script>
00296                                                 \';
00297 
00298                                                 $headerSection = $this->doc->getHeader("pages",$this->pageinfo,$this->pageinfo["_thePath"])."<br>".$LANG->sL("LLL:EXT:lang/locallang_core.php:labels.path").": ".t3lib_div::fixed_lgd_pre($this->pageinfo["_thePath"],50);
00299 
00300                                                 $this->content.=$this->doc->startPage($LANG->getLL("title"));
00301                                                 $this->content.=$this->doc->header($LANG->getLL("title"));
00302                                                 $this->content.=$this->doc->spacer(5);
00303                                                 $this->content.=$this->doc->section("",$this->doc->funcMenu($headerSection,t3lib_BEfunc::getFuncMenu($this->id,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"])));
00304                                                 $this->content.=$this->doc->divider(5);
00305 
00306 
00307                                                 // Render content:
00308                                                 $this->moduleContent();
00309 
00310 
00311                                                 // ShortCut
00312                                                 if ($BE_USER->mayMakeShortcut())        {
00313                                                         $this->content.=$this->doc->spacer(20).$this->doc->section("",$this->doc->makeShortcutIcon("id",implode(",",array_keys($this->MOD_MENU)),$this->MCONF["name"]));
00314                                                 }
00315 
00316                                                 $this->content.=$this->doc->spacer(10);
00317                                         } else {
00318                                                         // If no access or if ID == zero
00319 
00320                                                 $this->doc = t3lib_div::makeInstance("mediumDoc");
00321                                                 $this->doc->backPath = $BACK_PATH;
00322 
00323                                                 $this->content.=$this->doc->startPage($LANG->getLL("title"));
00324                                                 $this->content.=$this->doc->header($LANG->getLL("title"));
00325                                                 $this->content.=$this->doc->spacer(5);
00326                                                 $this->content.=$this->doc->spacer(10);
00327                                         }
00328                                 }
00329 
00333                                 function printContent() {
00334 
00335                                         $this->content.=$this->doc->endPage();
00336                                         echo $this->content;
00337                                 }
00338 
00342                                 function moduleContent()        {
00343                                         switch((string)$this->MOD_SETTINGS["function"]) {
00344                                                 case 1:
00345                                                         $content="<div align=center><strong>Hello World!</strong></div><BR>
00346                                                                 The \'Kickstarter\' has made this module automatically, it contains a default framework for a backend module but apart from it does nothing useful until you open the script \'".substr(t3lib_extMgm::extPath("'.$extKey.'"),strlen(PATH_site))."'.$pathSuffix.'index.php\' and edit it!
00347                                                                 <HR>
00348                                                                 <BR>This is the GET/POST vars sent to the script:<BR>".
00349                                                                 "GET:".t3lib_div::view_array($_GET)."<BR>".
00350                                                                 "POST:".t3lib_div::view_array($_POST)."<BR>".
00351                                                                 "";
00352                                                         $this->content.=$this->doc->section("Message #1:",$content,0,1);
00353                                                 break;
00354                                                 case 2:
00355                                                         $content="<div align=center><strong>Menu item #2...</strong></div>";
00356                                                         $this->content.=$this->doc->section("Message #2:",$content,0,1);
00357                                                 break;
00358                                                 case 3:
00359                                                         $content="<div align=center><strong>Menu item #3...</strong></div>";
00360                                                         $this->content.=$this->doc->section("Message #3:",$content,0,1);
00361                                                 break;
00362                                         }
00363                                 }
00364                         }
00365                 ');
00366 
00367                 $SOBE_extras["firstLevel"]=0;
00368                 $SOBE_extras["include"]=1;
00369                 $this->addFileToFileArray($pathSuffix."index.php",$this->PHPclassFile($extKey,$pathSuffix."index.php",$indexContent,"Module '".$config["title"]."' for the '".$extKey."' extension.",$cN,$SOBE_extras));
00370 
00371         }
00372 
00373 }
00374 
00375 
00376 // Include ux_class extension?
00377 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/kickstarter/sections/class.tx_kickstarter_section_module.php']) {
00378         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/kickstarter/sections/class.tx_kickstarter_section_module.php']);
00379 }
00380 
00381 
00382 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6