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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 $LANG->includeLLFile('EXT:taskcenter/task/locallang.xml');
00037
00038
00039 $BE_USER->modAccess($MCONF, 1);
00040
00041
00042
00043
00044
00045 class SC_mod_user_task_index extends t3lib_SCbase {
00046
00047 protected $pageinfo;
00048
00049
00050
00051
00052
00053
00054 public function __construct() {
00055 parent::init();
00056
00057
00058 $this->doc = t3lib_div::makeInstance('template');
00059 $this->doc->setModuleTemplate(
00060 t3lib_extMgm::extPath('taskcenter') . 'res/mod_template.html'
00061 );
00062 $this->doc->backPath = $GLOBALS['BACK_PATH'];
00063 $this->doc->getPageRenderer()->loadScriptaculous('effects,dragdrop');
00064 $this->doc->addStyleSheet(
00065 'tx_taskcenter',
00066 '../' . t3lib_extMgm::siteRelPath('taskcenter') . 'res/mod_styles.css'
00067 );
00068 }
00069
00070
00071
00072
00073
00074
00075 public function menuConfig() {
00076 $this->MOD_MENU = array('mode' => array());
00077
00078 $this->MOD_MENU['mode']['information'] = $GLOBALS['LANG']->sL('LLL:EXT:taskcenter/locallang.xml:task_overview');
00079 $this->MOD_MENU['mode']['tasks'] = 'Tasks';
00080
00081 parent::menuConfig();
00082 }
00083
00084
00085
00086
00087
00088
00089
00090 public function main() {
00091 $docHeaderButtons = $this->getButtons();
00092 $markers = array();
00093
00094 $this->doc->JScodeArray[] = '
00095 script_ended = 0;
00096 function jumpToUrl(URL) {
00097 document.location = URL;
00098 }
00099
00100 Event.observe(document, "dom:loaded", function(){
00101 var changeEffect;
00102 Sortable.create("task-list", { handles:$$("#task-list .drag"), tag: "li", ghosting:false, overlap:"vertical", constraint:false,
00103 onChange: function(item) {
00104 var list = Sortable.options(item).element;
00105
00106 $$("#task-list a").each(function(link) {
00107 link.writeAttribute("onclick","return false;");
00108 });
00109
00110 },
00111
00112 onUpdate: function(list) {
00113 new Ajax.Request("ajax.php", {
00114 method: "post",
00115 parameters: { ajaxID :"Taskcenter::saveSortingState", data: Sortable.serialize(list)}
00116 });
00117
00118 Event.observe(window,"mouseup",function(){
00119 $$("#task-list a").each(function(link) {
00120 link.writeAttribute("onclick","");
00121 });
00122 });
00123
00124 }
00125 });
00126
00127 $$("#taskcenter-menu .down").invoke("observe", "click", function(event){
00128 var item = Event.element(event);
00129 var itemParent = item.up();
00130 item = item.next("div").next("div").next("div").next("div");
00131
00132 if (itemParent.hasClassName("expanded")) {
00133 itemParent.removeClassName("expanded").addClassName("collapsed");
00134 Effect.BlindUp(item, {duration : 0.5});
00135 state = 1;
00136 } else {
00137 itemParent.removeClassName("collapsed").addClassName("expanded");
00138 Effect.BlindDown(item, {duration : 0.5});
00139 state = 0;
00140 }
00141 new Ajax.Request("ajax.php", {
00142 parameters : "ajaxID=Taskcenter::saveCollapseState&item=" + itemParent.id + "&state=" + state
00143 });
00144 });
00145 });
00146 ';
00147 $this->doc->postCode='
00148 <script language="javascript" type="text/javascript">
00149 script_ended = 1;
00150 if (top.fsMod) {
00151 top.fsMod.recentIds["web"] = 0;
00152 }
00153 </script>
00154 ';
00155
00156
00157 $mode = (string)$this->MOD_SETTINGS['mode'];
00158 if ($mode == 'information') {
00159 $this->renderInformationContent();
00160 } else {
00161 $this->renderModuleContent();
00162 }
00163
00164
00165 $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu(
00166 0,
00167 'SET[mode]',
00168 $this->MOD_SETTINGS['mode'],
00169 $this->MOD_MENU['mode']
00170 );
00171 $markers['CONTENT'] = $this->content;
00172
00173
00174 $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
00175 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00176 $this->content .= $this->doc->endPage();
00177 $this->content = $this->doc->insertStylesAndJS($this->content);
00178 }
00179
00180
00181
00182
00183
00184
00185 public function printContent() {
00186 echo $this->content;
00187 }
00188
00189
00190
00191
00192
00193
00194 protected function renderModuleContent() {
00195 $title = $content = $actionContent = '';
00196 $chosenTask = (string)$this->MOD_SETTINGS['function'];
00197
00198
00199 if (empty($chosenTask) || $chosenTask == 'index') {
00200 $chosenTask = 'taskcenter.tasks';
00201 }
00202
00203
00204 list($extKey, $taskClass) = explode('.', $chosenTask, 2);
00205 $title = $GLOBALS['LANG']->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter'][$extKey][$taskClass]['title']);
00206
00207 if (class_exists($taskClass)) {
00208 $taskInstance = t3lib_div::makeInstance($taskClass, $this);
00209
00210 if ($taskInstance instanceof tx_taskcenter_Task) {
00211
00212 if ($this->checkAccess($extKey, $taskClass)) {
00213 $actionContent .= $taskInstance->getTask();
00214 } else {
00215 $flashMessage = t3lib_div::makeInstance(
00216 't3lib_FlashMessage',
00217 $GLOBALS['LANG']->getLL('error-access', TRUE),
00218 $GLOBALS['LANG']->getLL('error_header'),
00219 t3lib_FlashMessage::ERROR
00220 );
00221 $actionContent .= $flashMessage->render();
00222 }
00223 } else {
00224
00225 $flashMessage = t3lib_div::makeInstance(
00226 't3lib_FlashMessage',
00227 sprintf($GLOBALS['LANG']->getLL('error_no-instance', TRUE), $taskClass, 'tx_taskcenter_Task'),
00228 $GLOBALS['LANG']->getLL('error_header'),
00229 t3lib_FlashMessage::ERROR
00230 );
00231 $actionContent .= $flashMessage->render();
00232 }
00233 } else {
00234 $flashMessage = t3lib_div::makeInstance(
00235 't3lib_FlashMessage',
00236 $GLOBALS['LANG']->sL('LLL:EXT:taskcenter/task/locallang_mod.xml:mlang_labels_tabdescr'),
00237 $GLOBALS['LANG']->sL('LLL:EXT:taskcenter/task/locallang_mod.xml:mlang_tabs_tab'),
00238 t3lib_FlashMessage::INFO
00239 );
00240 $actionContent .= $flashMessage->render();
00241 }
00242
00243 $content = '<div id="taskcenter-main">
00244 <div id="taskcenter-menu">' . $this->indexAction() . '</div>
00245 <div id="taskcenter-item" class="' . $extKey . '-' . $taskClass . '">' .
00246 $actionContent . '
00247 </div>
00248 </div>';
00249
00250 $this->content .= $content;
00251 }
00252
00253
00254
00255
00256
00257
00258 protected function renderInformationContent() {
00259 $content = $this->description (
00260 $GLOBALS['LANG']->getLL('mlang_tabs_tab'),
00261 $GLOBALS['LANG']->sL('LLL:EXT:taskcenter/task/locallang_mod.xml:mlang_labels_tabdescr')
00262 );
00263
00264 $content .= $GLOBALS['LANG']->getLL('taskcenter-about');
00265
00266 if ($GLOBALS['BE_USER']->isAdmin()) {
00267 $content .= '<br /><br />' . $this->description (
00268 $GLOBALS['LANG']->getLL('taskcenter-adminheader'),
00269 $GLOBALS['LANG']->getLL('taskcenter-admin')
00270 );
00271 }
00272
00273 $this->content .= $content;
00274 }
00275
00276
00277
00278
00279
00280
00281
00282
00283 public function description($title, $description='') {
00284 if (!empty($description)) {
00285 $description = '<p class="description">' . nl2br(htmlspecialchars($description)) . '</p><br />';
00286 }
00287 $content = $this->doc->section($title, $description, FALSE, TRUE);
00288
00289 return $content;
00290 }
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307 public function renderListMenu($items, $mainMenu = FALSE) {
00308 $content = $section = '';
00309 $count = 0;
00310
00311
00312 if ($mainMenu) {
00313 $userSorting = unserialize($GLOBALS['BE_USER']->uc['taskcenter']['sorting']);
00314 if (is_array($userSorting)) {
00315 $newSorting = array();
00316 foreach($userSorting as $item) {
00317 if(isset($items[$item])) {
00318 $newSorting[] = $items[$item];
00319 unset($items[$item]);
00320 }
00321 }
00322 $items = $newSorting + $items;
00323 }
00324 }
00325
00326 if (is_array($items) && count($items) > 0) {
00327 foreach($items as $item) {
00328 $title = htmlspecialchars($item['title']);
00329
00330 $icon = $additionalClass = $collapsedStyle = '';
00331
00332 if (!empty($item['icon'])) {
00333 if (strpos($item['icon'], '<img ') === FALSE) {
00334 $absIconPath = t3lib_div::getFileAbsFilename($item['icon']);
00335
00336 if (file_exists($absIconPath)) {
00337 $icon = $GLOBALS['BACK_PATH'] . '../' . str_replace(PATH_site, '', $absIconPath);
00338 $icon = '<img src="' . $icon . '" title="' . $title . '" alt="' . $title . '" />';
00339 }
00340 if (@is_file($icon)) {
00341 $icon = '<img' . t3lib_iconworks::skinImg($GLOBALS['BACK_PATH'], $icon, 'width="16" height="16"') . ' title="' . $title . '" alt="' . $title . '" />';
00342 }
00343 } else {
00344 $icon = $item['icon'];
00345 }
00346 }
00347
00348
00349 $description = (!empty($item['descriptionHtml'])) ? $item['descriptionHtml'] : '<p>' . nl2br(htmlspecialchars($item['description'])) . '</p>';
00350
00351 $id = $this->getUniqueKey($item['uid']);
00352
00353
00354 if ($mainMenu && isset($GLOBALS['BE_USER']->uc['taskcenter']['states'][$id]) && $GLOBALS['BE_USER']->uc['taskcenter']['states'][$id]) {
00355 $collapsedStyle = 'style="display:none"';
00356 $additionalClass = 'collapsed';
00357 } else {
00358 $additionalClass = 'expanded';
00359 }
00360
00361
00362 if ($count == 0) {
00363 $additionalClass .= ' first-item';
00364 } elseif ($count + 1 === count($items)) {
00365 $additionalClass .= ' last-item';
00366 }
00367
00368
00369 $active = ((string) $this->MOD_SETTINGS['function'] == $item['uid']) ? ' active-task' : '';
00370
00371
00372 if ($mainMenu) {
00373 $dragIcon = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/move.gif', 'width="16" height="16" hspace="2"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.move', 1) . '" alt="" />';
00374 $section = '<div class="down"> </div>
00375 <div class="drag">' . $dragIcon . '</div>';
00376 $backgroundClass = 't3-row-header ';
00377 }
00378
00379 $content .= '<li class="' . $additionalClass . $active . '" id="el_' .$id . '">
00380 ' . $section . '
00381 <div class="image">' . $icon . '</div>
00382 <div class="' . $backgroundClass . 'link"><a href="' . $item['link'] . '">' . $title . '</a></div>
00383 <div class="content " ' . $collapsedStyle . '>' . $description . '</div>
00384 </li>';
00385
00386 $count++;
00387 }
00388
00389 $navigationId = ($mainMenu) ? 'id="task-list"' : '';
00390
00391 $content = '<ul ' . $navigationId . ' class="task-list">' . $content . '</ul>';
00392
00393 }
00394
00395 return $content;
00396 }
00397
00398
00399
00400
00401
00402
00403 protected function indexAction() {
00404 $content = '';
00405 $tasks = array();
00406 $icon = t3lib_extMgm::extRelPath('taskcenter') . 'task/task.gif';
00407
00408
00409 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter']) && count($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter']) > 0) {
00410 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter'] as $extKey => $extensionReports) {
00411 foreach ($extensionReports as $taskClass => $task) {
00412 if (!$this->checkAccess($extKey, $taskClass)) {
00413 continue;
00414 }
00415 $link = 'mod.php?M=user_task&SET[function]=' . $extKey . '.' . $taskClass;
00416 $taskTitle = $GLOBALS['LANG']->sL($task['title']);
00417 $taskDescriptionHtml = '';
00418
00419
00420 if (!empty($task['icon'])) {
00421 $icon = t3lib_div::getFileAbsFilename($task['icon']);
00422 }
00423
00424 if (class_exists($taskClass)) {
00425 $taskInstance = t3lib_div::makeInstance($taskClass, $this);
00426 if ($taskInstance instanceof tx_taskcenter_Task) {
00427 $taskDescriptionHtml = $taskInstance->getOverview();
00428 }
00429 }
00430
00431
00432 $uniqueKey = $this->getUniqueKey($extKey . '.' . $taskClass);
00433 $tasks[$uniqueKey] = array(
00434 'title' => $taskTitle,
00435 'descriptionHtml' => $taskDescriptionHtml,
00436 'description' => $GLOBALS['LANG']->sL($task['description']),
00437 'icon' => $icon,
00438 'link' => $link,
00439 'uid' => $extKey . '.' . $taskClass
00440 );
00441 }
00442 }
00443
00444 $content .= $this->renderListMenu($tasks, TRUE);
00445 } else {
00446 $flashMessage = t3lib_div::makeInstance(
00447 't3lib_FlashMessage',
00448 $GLOBALS['LANG']->getLL('no-tasks', TRUE),
00449 '',
00450 t3lib_FlashMessage::INFO
00451 );
00452 $this->content .= $flashMessage->render();
00453 }
00454
00455 return $content;
00456 }
00457
00458
00459
00460
00461
00462
00463
00464 protected function getButtons() {
00465 $buttons = array(
00466 'csh' => t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']),
00467 'shortcut' => '',
00468 'open_new_window' => $this->openInNewWindow()
00469 );
00470
00471
00472 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00473 $buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
00474 }
00475
00476 return $buttons;
00477 }
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489 protected function checkAccess($extKey, $taskClass) {
00490
00491 $tsConfig = $GLOBALS['BE_USER']->getTSConfig('taskcenter.' . $extKey . '.' . $taskClass);
00492 if (isset($tsConfig['value']) && intval($tsConfig['value']) == 0) {
00493 return FALSE;
00494 }
00495
00496
00497 if ($GLOBALS['BE_USER']->isAdmin()) {
00498 return TRUE;
00499 }
00500
00501
00502 if (intval($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter'][$extKey][$taskClass]['admin']) == 1) {
00503 return FALSE;
00504 }
00505
00506 return TRUE;
00507 }
00508
00509
00510
00511
00512
00513
00514
00515
00516 public function urlInIframe($url, $max=0) {
00517 $this->doc->JScodeArray[] =
00518 'function resizeIframe(frame,max) {
00519 var parent = $("typo3-docbody");
00520 var parentHeight = $(parent).getHeight() - 0;
00521 var parentWidth = $(parent).getWidth() - $("taskcenter-menu").getWidth() - 50;
00522 $("list_frame").setStyle({height: parentHeight+"px", width: parentWidth+"px"});
00523
00524 }
00525
00526 var version = parseFloat(navigator.appVersion.split(";")[1].strip().split(" ")[1]);
00527 if (!(Prototype.Browser.IE && version == 6)) {
00528 Event.observe(window, "resize", resizeIframe, false);
00529 }';
00530
00531 return '<iframe onload="resizeIframe(this,' . $max . ');" scrolling="auto" width="100%" src="' . $url . '" name="list_frame" id="list_frame" frameborder="no" style="margin-top:-51px;border: none;"></iframe>';
00532 }
00533
00534
00535
00536
00537
00538
00539
00540
00541 protected function getUniqueKey($string) {
00542 $search = array('.', '_');
00543 $replace = array('-', '');
00544
00545 return str_replace($search, $replace, $string);
00546 }
00547
00548
00549
00550
00551
00552
00553 protected function openInNewWindow() {
00554 $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT');
00555 $onClick = "devlogWin=window.open('" . $url . "','taskcenter','width=790,status=0,menubar=1,resizable=1,location=0,scrollbars=1,toolbar=0');return false;";
00556 $content = '<a href="#" onclick="' . htmlspecialchars($onClick).'">' .
00557 '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/open_in_new_window.gif', 'width="19" height="14"') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.openInNewWindow', 1) . '" class="absmiddle" alt="" />' .
00558 '</a>';
00559 return $content;
00560 }
00561
00562
00563 }
00564
00565
00566 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/taskcenter/task/index.php']) {
00567 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/taskcenter/task/index.php']);
00568 }
00569
00570
00571
00572
00573 $SOBE = t3lib_div::makeInstance('SC_mod_user_task_index');
00574
00575 foreach($SOBE->include_once as $INC_FILE) {
00576 include_once($INC_FILE);
00577 }
00578
00579 $SOBE->main();
00580 $SOBE->printContent();
00581
00582 ?>