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 $LANG->includeLLFile('EXT:recycler/mod1/locallang.xml');
00026 $BE_USER->modAccess($MCONF, 1);
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class tx_recycler_module1 extends t3lib_SCbase {
00037
00038
00039
00040 public $doc;
00041
00042 protected $relativePath;
00043 protected $pageRecord = array();
00044 protected $isAccessibleForCurrentUser = false;
00045
00046 protected $allowDelete = false;
00047 protected $recordsPageLimit = 50;
00048
00049
00050
00051
00052
00053
00054 public function initialize() {
00055 parent::init();
00056 $this->doc = t3lib_div::makeInstance('template');
00057 $this->doc->setModuleTemplate(t3lib_extMgm::extPath('recycler') . 'mod1/mod_template.html');
00058 $this->doc->backPath = $GLOBALS['BACK_PATH'];
00059
00060 $this->relativePath = t3lib_extMgm::extRelPath('recycler');
00061 $this->pageRecord = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
00062 $this->isAccessibleForCurrentUser = (
00063 $this->id && is_array($this->pageRecord) || !$this->id && $this->isCurrentUserAdmin()
00064 );
00065
00066
00067 if ($GLOBALS['BE_USER']->workspace !== 0) {
00068 $this->isAccessibleForCurrentUser = false;
00069 }
00070
00071
00072 $modTS = $GLOBALS['BE_USER']->getTSConfig('mod.recycler');
00073 if ($this->isCurrentUserAdmin()) {
00074 $this->allowDelete = true;
00075 } else {
00076 $this->allowDelete = ($modTS['properties']['allowDelete'] == '1');
00077 }
00078 if (isset($modTS['properties']['recordsPageLimit']) && intval($modTS['properties']['recordsPageLimit']) > 0) {
00079 $this->recordsPageLimit = intval($modTS['properties']['recordsPageLimit']);
00080 }
00081 }
00082
00083
00084
00085
00086
00087
00088 public function render() {
00089 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00090
00091 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $GLOBALS['LANG']->getLL('description'));
00092 if ($this->isAccessibleForCurrentUser) {
00093 $this->loadHeaderData();
00094
00095 $this->content .= '<div id="recyclerContent"></div>';
00096 } else {
00097
00098 $this->content .= $this->doc->spacer(10);
00099 }
00100 }
00101
00102
00103
00104
00105
00106
00107 public function flush() {
00108 $content = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
00109 $content.= $this->doc->moduleBody(
00110 $this->pageRecord,
00111 $this->getDocHeaderButtons(),
00112 $this->getTemplateMarkers()
00113 );
00114 $content.= $this->doc->endPage();
00115
00116 $this->content = null;
00117 $this->doc = null;
00118
00119 echo $content;
00120 }
00121
00122
00123
00124
00125
00126
00127 protected function isCurrentUserAdmin() {
00128 return (bool)$GLOBALS['BE_USER']->user['admin'];
00129 }
00130
00131
00132
00133
00134
00135
00136 protected function loadHeaderData() {
00137
00138 $this->loadStylesheet($this->relativePath . 'res/css/customExtJs.css');
00139
00140 $this->doc->getPageRenderer()->loadExtJS();
00141
00142 $this->doc->JScode.= t3lib_div::wrapJS('
00143 Ext.namespace("Recycler");
00144 Recycler.statics = ' . json_encode($this->getJavaScriptConfiguration()) . ';
00145 Recycler.lang = ' . json_encode($this->getJavaScriptLabels()) . ';'
00146 );
00147
00148 $this->loadJavaScript($this->relativePath . 'res/js/ext_expander.js');
00149 $this->loadJavaScript($this->relativePath . 'res/js/search_field.js');
00150 $this->loadJavaScript($this->relativePath . 'res/js/t3_recycler.js');
00151 }
00152
00153
00154
00155
00156
00157
00158
00159 protected function loadStylesheet($fileName) {
00160 $fileName = t3lib_div::resolveBackPath($this->doc->backPath . $fileName);
00161 $this->doc->JScode .= TAB . '<link rel="stylesheet" type="text/css" href="' . t3lib_div::createVersionNumberedFilename($fileName) . '" />' . LF;
00162 }
00163
00164
00165
00166
00167
00168
00169
00170 protected function loadJavaScript($fileName) {
00171 $fileName = t3lib_div::resolveBackPath($this->doc->backPath . $fileName);
00172 $this->doc->JScode .= TAB . '<script language="javascript" type="text/javascript" src="' . t3lib_div::createVersionNumberedFilename($fileName) . '"></script>' . LF;
00173 }
00174
00175
00176
00177
00178
00179
00180 protected function getJavaScriptConfiguration() {
00181 $configuration = array(
00182 'pagingSize' => $this->recordsPageLimit,
00183 'showDepthMenu' => 1,
00184 'startUid' => $this->id,
00185 'tableDefault' => 'pages',
00186 'renderTo' => 'recyclerContent',
00187 'isSSL' => t3lib_div::getIndpEnv('TYPO3_SSL'),
00188 'ajaxController' => $this->doc->backPath . 'ajax.php?ajaxID=tx_recycler::controller',
00189 'deleteDisable' => $this->allowDelete ? 0 : 1,
00190 'depthSelection' => $this->getDataFromSession('depthSelection', 0),
00191 'tableSelection' => $this->getDataFromSession('tableSelection', 'pages'),
00192 );
00193 return $configuration;
00194 }
00195
00196
00197
00198
00199
00200
00201 protected function getJavaScriptLabels() {
00202 $coreLabels = array(
00203 'title' => $GLOBALS['LANG']->getLL('title'),
00204 'path' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.path'),
00205 'table' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.table'),
00206 'depth' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_perm.xml:Depth'),
00207 'depth_0' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_0'),
00208 'depth_1' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_1'),
00209 'depth_2' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_2'),
00210 'depth_3' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_3'),
00211 'depth_4' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_4'),
00212 'depth_infi' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_infi'),
00213 );
00214
00215 $extensionLabels = $this->getJavaScriptLabelsFromLocallang('js.', 'label_');
00216 $javaScriptLabels = array_merge($coreLabels, $extensionLabels);
00217
00218
00219 if ($GLOBALS['LANG']->charSet !== 'utf-8') {
00220 $GLOBALS['LANG']->csConvObj->convArray($javaScriptLabels, $GLOBALS['LANG']->charSet, 'utf-8');
00221 }
00222
00223 return $javaScriptLabels;
00224 }
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 protected function getJavaScriptLabelsFromLocallang($selectionPrefix = 'js.', $stripFromSelectionName = '') {
00235 $extraction = array();
00236 $labels = array_merge(
00237 (array)$GLOBALS['LOCAL_LANG']['default'],
00238 (array)$GLOBALS['LOCAL_LANG'][$GLOBALS['LANG']->lang]
00239 );
00240
00241 $labelPattern = '#^' . preg_quote($selectionPrefix, '#') . '(' . preg_quote($stripFromSelectionName, '#') . ')?#';
00242
00243 foreach ($labels as $label => $value) {
00244 if (strpos($label, $selectionPrefix) === 0) {
00245 $key = preg_replace($labelPattern, '', $label);
00246 $extraction[$key] = $value;
00247 }
00248 }
00249 return $extraction;
00250 }
00251
00252
00253
00254
00255
00256
00257 protected function getDocHeaderButtons() {
00258 $buttons = array(
00259 'csh' => t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']),
00260 'shortcut' => $this->getShortcutButton(),
00261 'save' => ''
00262 );
00263
00264
00265 $buttons['save'] = '';
00266
00267 return $buttons;
00268 }
00269
00270
00271
00272
00273
00274
00275 protected function getShortcutButton() {
00276 $result = '';
00277 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00278 $result = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
00279 }
00280 return $result;
00281 }
00282
00283
00284
00285
00286
00287
00288 protected function getTemplateMarkers() {
00289 $markers = array(
00290 'FUNC_MENU' => $this->getFunctionMenu(),
00291 'CONTENT' => $this->content,
00292 'TITLE' => $GLOBALS['LANG']->getLL('title'),
00293 );
00294 return $markers;
00295 }
00296
00297
00298
00299
00300
00301
00302 protected function getFunctionMenu() {
00303 return t3lib_BEfunc::getFuncMenu(
00304 0,
00305 'SET[function]',
00306 $this->MOD_SETTINGS['function'],
00307 $this->MOD_MENU['function']
00308 );
00309 }
00310
00311
00312
00313
00314
00315
00316
00317
00318 protected function getDataFromSession($identifier, $default = NULL) {
00319 $sessionData =& $GLOBALS['BE_USER']->uc['tx_recycler'];
00320 if (isset($sessionData[$identifier]) && $sessionData[$identifier]) {
00321 $data = $sessionData[$identifier];
00322 } else {
00323 $data = $default;
00324 }
00325 return $data;
00326 }
00327 }
00328
00329
00330
00331 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/recycler/mod1/index.php']) {
00332 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/recycler/mod1/index.php']);
00333 }
00334
00335
00336
00337
00338 $SOBE = t3lib_div::makeInstance('tx_recycler_module1');
00339 $SOBE->initialize();
00340
00341
00342 foreach($SOBE->include_once as $INC_FILE) {
00343 include_once($INC_FILE);
00344 }
00345
00346 $SOBE->render();
00347 $SOBE->flush();
00348 ?>