Esempio n. 1
0
    /**
     * Main function of the module. Write the content to $this->content
     * 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
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        $PATH_TYPO3 = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/';
        if ($BE_USER->user["admin"]) {
            // Draw the header.
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("template");
            $this->doc->backPath = $BACK_PATH;
            $this->pageRenderer = $this->doc->getPageRenderer();
            // Include Ext JS
            $this->pageRenderer->loadExtJS(true, true);
            $this->pageRenderer->enableExtJSQuickTips();
            $this->pageRenderer->enableExtJsDebug();
            $this->pageRenderer->addJsFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.js', 'text/javascript', FALSE, FALSE);
            $this->pageRenderer->addJsFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.NodeTree.js', 'text/javascript', FALSE, FALSE);
            //Add caretaker css
            $this->pageRenderer->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/css/tx.caretaker.nodetree.css', 'stylesheet', 'all', '', FALSE);
            // storage Pid
            $confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['caretaker']);
            $storagePid = (int) $confArray['storagePid'];
            $this->pageRenderer->addJsInlineCode('Caretaker_Nodetree', '
			Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
			Ext.ns("tx.caretaker");
			Ext.onReady(function() {
				tx.caretaker.view = new Ext.Viewport({
					layout: "fit",
					items: {
						id: "cartaker-tree",
						xtype: "caretaker-nodetree",
						autoScroll: true,
						dataUrl: TYPO3.settings.ajaxUrls[\'tx_caretaker::treeloader\'],
						addUrl: "' . $PATH_TYPO3 . 'alt_doc.php?edit[###NODE_TYPE###][' . $storagePid . ']=new",
						editUrl: "' . $PATH_TYPO3 . 'alt_doc.php?edit[tx_caretaker_###NODE_TYPE###][###NODE_UID###]=edit",
						hideUrl: "' . $PATH_TYPO3 . 'tce_db.php?&data[tx_caretaker_###NODE_TYPE###][###NODE_UID###][hidden]=1",
						unhideUrl: "' . $PATH_TYPO3 . 'tce_db.php?&data[tx_caretaker_###NODE_TYPE###][###NODE_UID###][hidden]=0"
					}
				});

				tx_caretaker_updateTreeById = function( id ){
					tx_caretaker_tree = Ext.getCmp("cartaker-tree");
					tx_caretaker_tree.reloadTreePartial( id );
				}
			});
			');
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->doc->form = '';
        } else {
            // If no access or if not admin
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate');
            $this->doc->backPath = $BACK_PATH;
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->content .= $this->doc->header($LANG->getLL("title"));
            $this->content .= $this->doc->spacer(5);
            $this->content .= $this->doc->spacer(10);
        }
    }
 /**
  * test enable ExtJsDebug
  */
 public function testEnableExtJsDebug()
 {
     $expectedRegExp = '#<script src="contrib/extjs/ext-all-debug\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
     $this->fixture->loadExtJS(TRUE, TRUE, 'jquery');
     $this->fixture->enableExtJsDebug();
     $out = $this->fixture->render();
     $this->assertRegExp($expectedRegExp, $out);
 }
 /**
  * Render start page with \TYPO3\CMS\Backend\Template\DocumentTemplate and pageTitle
  *
  * @param string $pageTitle title tag of the module. Not required by default, as BE modules are shown in a frame
  * @param bool $loadExtJs specifies whether to load ExtJS library. Defaults to FALSE
  * @param bool $loadExtJsTheme whether to load ExtJS "grey" theme. Defaults to FALSE
  * @param bool $enableExtJsDebug if TRUE, debug version of ExtJS is loaded. Use this for development only
  * @param bool $loadJQuery whether to load jQuery library. Defaults to FALSE
  * @param array $includeCssFiles List of custom CSS file to be loaded
  * @param array $includeJsFiles List of custom JavaScript file to be loaded
  * @param array $addJsInlineLabels Custom labels to add to JavaScript inline labels
  * @param array $includeRequireJsModules List of RequireJS modules to be loaded
  * @param string $jQueryNamespace Store the jQuery object in a specific namespace
  * @return void
  */
 public function render($pageTitle = '', $loadExtJs = false, $loadExtJsTheme = true, $enableExtJsDebug = false, $loadJQuery = false, $includeCssFiles = null, $includeJsFiles = null, $addJsInlineLabels = null, $includeRequireJsModules = null, $jQueryNamespace = null)
 {
     if ($pageTitle) {
         $this->pageRenderer->setTitle($pageTitle);
     }
     if ($loadExtJs) {
         $this->pageRenderer->loadExtJS(true, $loadExtJsTheme);
         if ($enableExtJsDebug) {
             $this->pageRenderer->enableExtJsDebug();
         }
     }
     if ($loadJQuery) {
         $jQueryNamespace = $jQueryNamespace ?: PageRenderer::JQUERY_NAMESPACE_DEFAULT;
         $this->pageRenderer->loadJquery(null, null, $jQueryNamespace);
     }
     // Include custom CSS and JS files
     if (is_array($includeCssFiles) && count($includeCssFiles) > 0) {
         foreach ($includeCssFiles as $addCssFile) {
             $this->pageRenderer->addCssFile($addCssFile);
         }
     }
     if (is_array($includeJsFiles) && count($includeJsFiles) > 0) {
         foreach ($includeJsFiles as $addJsFile) {
             $this->pageRenderer->addJsFile($addJsFile);
         }
     }
     if (is_array($includeRequireJsModules) && count($includeRequireJsModules) > 0) {
         foreach ($includeRequireJsModules as $addRequireJsFile) {
             $this->pageRenderer->loadRequireJsModule($addRequireJsFile);
         }
     }
     // Add inline language labels
     if (is_array($addJsInlineLabels) && count($addJsInlineLabels) > 0) {
         $extensionKey = $this->controllerContext->getRequest()->getControllerExtensionKey();
         foreach ($addJsInlineLabels as $key) {
             $label = LocalizationUtility::translate($key, $extensionKey);
             $this->pageRenderer->addInlineLanguageLabel($key, $label);
         }
     }
 }
Esempio n. 4
0
    /**
     * Main function of the module. Write the content to $this->content
     * 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
     *
     * @return void
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        $PATH_TYPO3 = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/';
        if ($BE_USER->user["admin"]) {
            // find node
            $node_repository = tx_caretaker_NodeRepository::getInstance();
            $node = $node_repository->id2node($this->node_id, true);
            if (!$node) {
                $node = $node_repository->getRootNode();
            }
            // Draw the header.
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
            $this->doc->backPath = $BACK_PATH;
            $this->pageRenderer = $this->doc->getPageRenderer();
            // Include Ext JS
            $this->pageRenderer->loadExtJS();
            $this->pageRenderer->addJsFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.js');
            $panels = array();
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['caretaker']['extJsBackendPanels'] as $extJsBackendPanel) {
                // register JS
                foreach ($extJsBackendPanel['jsIncludes'] as $jsInclude) {
                    $filename = $BACK_PATH . '../' . str_replace(PATH_site, '', \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($jsInclude));
                    $this->pageRenderer->addJsFile($filename);
                }
                // register CSS
                foreach ($extJsBackendPanel['cssIncludes'] as $cssInclude) {
                    $filename = $BACK_PATH . '../' . str_replace(PATH_site, '', \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($cssInclude));
                    $this->pageRenderer->addCssFile($filename);
                }
                // add ExtJs Panel
                $panels[$extJsBackendPanel['id']] = $extJsBackendPanel['xtype'];
            }
            $this->pageRenderer->addJsFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.NodeToolbar.js');
            // Enable debug mode for Ext JS
            $this->pageRenderer->enableExtJsDebug();
            // storage Pid
            $confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['caretaker']);
            $storagePid = (int) $confArray['storagePid'];
            //Add caretaker css
            $this->pageRenderer->addCssFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/css/tx.caretaker.overview.css');
            $pluginItems = array();
            foreach ($panels as $id => $xtype) {
                $pluginItems[] = '{ id: "' . $id . '", xtype: "' . $xtype . '" , back_path: back_path , node_id: node_id }';
            }
            $this->pageRenderer->addJsInlineCode('Caretaker_Overview', '
				Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
				Ext.namespace("tx","tx.caretaker");

				Ext.onReady( function() {

					var back_path   = "' . $this->doc->backPath . '";
					var back_url    = "' . urlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')) . '";
					var path_typo3  = "' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/";
					var	add_url     = "' . $PATH_TYPO3 . 'alt_doc.php?edit[###NODE_TYPE###][' . $storagePid . ']=new";
					var node_id     = "' . $node->getCaretakerNodeId() . '";
					var node_type   = "' . strtolower($node->getType()) . '";
					var node_hidden = "' . $node->getHidden() . '";
					var node_uid    = "' . $node->getUid() . '";
					var node_title  = "' . htmlspecialchars($node->getTitle() ? $node->getTitle() : '[no title]') . '( ' . ($node->getTypeDescription() ? htmlspecialchars($node->getTypeDescription()) : $node->getType()) . ' )" ;
					var node_state  = "' . $node->getTestResult()->getState() . '" ;
					var node_state_info  = "' . $node->getTestResult()->getStateInfo() . '" ;

					tx.caretaker.view = new Ext.Viewport({
						layout: "fit",
						items: {
								xtype    : "panel",
								id       : "node",
								autoScroll: true,
								title    : node_title,
								iconCls  : "icon-caretaker-type-" + node_type,
								tbar     : {
									xtype: "caretaker-nodetoolbar",
									back_path: back_path,
									path_typo3: path_typo3,
									back_url: back_url,
									add_url :add_url,
									node_id: node_id,
									node_type: node_type,
									node_uid: node_uid,
									node_hidden: node_hidden,
									node_state: node_state,
									node_state_info: node_state_info
								},
								items    : [
									{
										xtype    : "panel",
										padding  : "10",
										layout   : "fit",
										id       : "caretaker-panels",
										items    : [
											' . implode(chr(10) . ',', $pluginItems) . chr(10) . '
										]
									}
								],
						}
					 });
				});
			');
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->doc->form = '';
        } else {
            // If no access or if not admin
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate');
            $this->doc->backPath = $BACK_PATH;
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->content .= $this->doc->header($LANG->getLL("title"));
            $this->content .= $this->doc->spacer(5);
            $this->content .= $this->doc->spacer(10);
        }
    }