Documentation TYPO3 par Ameos

class.tx_kickstarter_section_cm.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 ***************************************************************/
00033 require_once(t3lib_extMgm::extPath("kickstarter")."class.tx_kickstarter_sectionbase.php");
00034  
00035 class tx_kickstarter_section_cm extends tx_kickstarter_sectionbase {
00036         var $sectionID = 'cm';
00037 
00041         function render_wizard() {
00042                 $lines=array();
00043 
00044                 $action = explode(":",$this->wizard->modData["wizAction"]);
00045                 if ($action[0]=="edit") {
00046                         $this->regNewEntry($this->sectionID,$action[1]);
00047                         $lines = $this->catHeaderLines($lines,$this->sectionID,$this->wizard->options[$this->sectionID],"&nbsp;",$action[1]);
00048                         $piConf = $this->wizard->wizArray[$this->sectionID][$action[1]];
00049                         $ffPrefix='['.$this->sectionID.']['.$action[1].']';
00050 
00051                                 // Enter title of the module function
00052                         $subContent="<strong>Title of the ClickMenu element:</strong><BR>".
00053                                 $this->renderStringBox_lang("title",$ffPrefix,$piConf);
00054                         $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00055 
00056                                 // Position
00057                         $optValues = array(
00058                                 "bottom" => "Insert in bottom",
00059                                 "top" => "Insert in top",
00060                                 "before_delete" => "Insert before the 'Delete' item",
00061                         );
00062                         $subContent="<strong>Options</strong><BR>".
00063                                 $this->renderSelectBox($ffPrefix."[options]",$piConf["options"],$optValues);
00064                         $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00065 
00066                                 // Admin only
00067                         $subContent =$this->resImg("cm.png");
00068                         $subContent.= $this->renderCheckBox($ffPrefix."[second_level]",$piConf["second_level"])."Activate a second-level menu.<BR>";
00069                         $subContent.= $this->renderCheckBox($ffPrefix."[only_page]",$piConf["only_page"])."Add only if the click menu is on a 'Page' (example)<BR>";
00070                         $subContent.= $this->renderCheckBox($ffPrefix."[only_if_edit]",$piConf["only_if_edit"])."Only active if item is editable.<BR>";
00071                         $subContent.= $this->renderCheckBox($ffPrefix."[remove_view]",$piConf["remove_view"])."Remove 'Show' element (example)<BR>";
00072                         $lines[]='<tr'.$this->bgCol(3).'><td>'.$this->fw($subContent).'</td></tr>';
00073                 }
00074 
00075 
00076                 $this->process_hook('render_wizard', $lines);
00077 
00078                 $content = '<table border=0 cellpadding=2 cellspacing=2>'.implode("",$lines).'</table>';
00079                 return $content;
00080         }
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00092         function render_extPart($k,$config,$extKey) {
00093                 $WOP = '[' . $this->sectionID . '][' . $k .']';
00094                 $cN = $this->returnName($extKey,'class', $this->sectionID . $k);
00095                 $filename = 'class.'.$cN.'.php';
00096                 $pathSuffix = $this->sectionID . $k .'/';
00097 
00098                         // This will make sure our item is inserted in the clickmenu!
00099                 $this->wizard->ext_tables[]=$this->sPS('
00100                         '.$this->WOPcomment('WOP:'.$WOP.':').'
00101                         if (TYPO3_MODE=="BE")   {
00102                                 $GLOBALS["TBE_MODULES_EXT"]["xMOD_alt_clickmenu"]["extendCMclasses"][]=array(
00103                                         "name" => "'.$cN.'",
00104                                         "path" => t3lib_extMgm::extPath($_EXTKEY)."'.$filename.'"
00105                                 );
00106                         }
00107                 ');
00108                         // Add title to the locallang file.
00109                 $this->addLocalConf($this->wizard->ext_locallang,$config,"title","cm",$k);
00110 
00111                         // Add icon
00112                 $this->addFileToFileArray($pathSuffix."cm_icon.gif",t3lib_div::getUrl(t3lib_extMgm::extPath("kickstarter")."res/notfound_module.gif"));
00113 
00114                         //      Building class:
00115                 $content = "";
00116                 $content.=$this->sPS('
00117                                 // Adds the regular item:
00118                         $LL = $this->includeLL();
00119 
00120                                 // Repeat this (below) for as many items you want to add!
00121                                 // Remember to add entries in the localconf.php file for additional titles.
00122                         $url = t3lib_extMgm::extRelPath("'.$extKey.'")."'.$pathSuffix.'index.php?id=".$uid;
00123                         $localItems[] = $backRef->linkItem(
00124                                 $GLOBALS["LANG"]->getLLL("cm'.$k.'_title",$LL),
00125                                 $backRef->excludeIcon(\'<img src="\'.t3lib_extMgm::extRelPath("'.$extKey.'").\''.$pathSuffix.'cm_icon.gif" width="15" height="12" border=0 align=top>\'),
00126                                 $backRef->urlRefForCM($url),
00127                                 1       // Disables the item in the top-bar. Set this to zero if you with the item to appear in the top bar!
00128                         );
00129                 ');
00130                 if ($config["second_level"])    {
00131                         $secondContent = $content;
00132                         $secondContent.=chr(10).'$menuItems=array_merge($menuItems,$localItems);';
00133 
00134                         $content = "";
00135                         $content.=$this->sPS('
00136                                 $LL = $this->includeLL();
00137 
00138                                 $localItems[]="spacer";
00139                                 $localItems["moreoptions_'.$cN.'"]=$backRef->linkItem(
00140                                         $GLOBALS["LANG"]->getLLL("cm'.$k.'_title_activate",$LL),
00141                                         $backRef->excludeIcon(\'<img src="\'.t3lib_extMgm::extRelPath("'.$extKey.'").\''.$pathSuffix.'cm_icon_activate.gif" width="15" height="12" border=0 align=top>\'),
00142                                         "top.loadTopMenu(\'".t3lib_div::linkThisScript()."&cmLevel=1&subname=moreoptions_'.$cN.'\');return false;",
00143                                         0,
00144                                         1
00145                                 );
00146                         ');
00147 
00148                                 // Add activate title to the locallang file.
00149                         $this->addLocalConf($this->wizard->ext_locallang,array("title_activate"=>"...Second level ->"),"title_activate","cm",$k,0,1);
00150                                 // Add activate icon
00151                         $this->addFileToFileArray($pathSuffix."cm_icon_activate.gif",t3lib_div::getUrl(t3lib_extMgm::extPath("kickstarter")."res/notfound_module.gif"));
00152                 }
00153 
00154                 if ($config["only_page"])       $content=$this->sPS('
00155                                 // Returns directly, because the clicked item was not from the pages table '.$this->WOPcomment('(WOP:'.$WOP.'[only_page])').'
00156                         if ($table!="pages")    return $menuItems;
00157                 ').$content;
00158 
00159                 $content.=$this->sPS('
00160                         '.$this->WOPcomment('(WOP:'.$WOP.'[options] BEGIN) Inserts the item at the chosen location').'
00161                 ');
00162                 if ($config["options"]=="top")  {       // In top:
00163                         $content.=$this->sPS('
00164                                 $menuItems=array_merge($localItems,$menuItems);
00165                         ');
00166                 } elseif ($config["options"]=="before_delete")  {       // Just before "Delete" and its preceding divider line:
00167                         $content.=$this->sPS('
00168                                         // Find position of "delete" element:
00169                                 reset($menuItems);
00170                                 $c=0;
00171                                 while(list($k)=each($menuItems))        {
00172                                         $c++;
00173                                         if (!strcmp($k,"delete"))       break;
00174                                 }
00175                                         // .. subtract two (delete item + divider line)
00176                                 $c-=2;
00177                                         // ... and insert the items just before the delete element.
00178                                 array_splice(
00179                                         $menuItems,
00180                                         $c,
00181                                         0,
00182                                         $localItems
00183                                 );
00184                         ');
00185                 } else  {       // In bottom (default):
00186                         $content.=$this->sPS('
00187                                 // Simply merges the two arrays together and returns ...
00188                                 $menuItems=array_merge($menuItems,$localItems);
00189                         ');
00190                 }
00191                 $content.=$this->sPS('
00192                         '.$this->WOPcomment('(WOP:'.$WOP.'[options] END)').'
00193                 ');
00194 
00195                 if ($config["only_if_edit"])    $content=$this->wrapBody('
00196                         if ($backRef->editOK)   {
00197                         ',$content,'
00198                         }
00199                 ');
00200 
00201 
00202                 if ($config["remove_view"])     $content.=$this->sPS('
00203                                 // Removes the view-item from clickmenu  '.$this->WOPcomment('(WOP:'.$WOP.'[remove_view])').'
00204                         unset($menuItems["view"]);
00205                 ');
00206 
00207                 $content=$this->wrapBody('
00208                         if (!$backRef->cmLevel) {
00209                         ',$content,'
00210                         }
00211                 ');
00212 
00213                 if ($config["second_level"])    {
00214                         $content.=$this->wrapBody('
00215                                 else {
00216                                 ',$secondContent,'
00217                                 }
00218                         ');
00219                 }
00220 
00221 
00222 
00223 
00224                         // Now wrap the function body around this:
00225                 $content=$this->wrapBody('
00226                         function main(&$backRef,$menuItems,$table,$uid) {
00227                                 global $BE_USER,$TCA,$LANG;
00228 
00229                                 $localItems = Array();
00230                                 ',$content,'
00231                                 return $menuItems;
00232                         }
00233                 ');
00234                         // Add include locallanguage function:
00235                 $content.=$this->addLLFunc($extKey);
00236 
00237                         // Now wrap the function body around this:
00238                 $content=$this->wrapBody('
00239                         class '.$cN.' {
00240                                 ',$content,'
00241                         }
00242                 ');
00243 
00244 
00245 #               $this->printPre($content);
00246 
00247                 $this->addFileToFileArray($filename,$this->PHPclassFile($extKey,$filename,$content,"Addition of an item to the clickmenu"));
00248 
00249 
00250                 $cN = $this->returnName($extKey,"class","cm".$k);
00251                 $this->writeStandardBE_xMod($extKey,$config,$pathSuffix,$cN,$k,"cm");
00252 
00253         }
00254 
00255 }
00256 
00257 
00258 // Include ux_class extension?
00259 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/kickstarter/sections/class.tx_kickstarter_section_cm.php']) {
00260         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/kickstarter/sections/class.tx_kickstarter_section_cm.php']);
00261 }
00262 
00263 
00264 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6