/** * inits the "old school" marker based templates (static or ajax) * * @return string */ public function initMarkerTemplate() { // init XAJAX? if ($this->conf['renderMethod'] != 'static') { $xajaxIsLoaded = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('xajax'); if (!$xajaxIsLoaded) { return '<span style="color: red;"><b>ke_search error:</b>"XAJAX" must be installed for this mode.</span>'; } else { $this->initXajax(); } } // Spinner Image if ($this->conf['spinnerImageFile']) { $spinnerSrc = $this->conf['spinnerImageFile']; } else { $spinnerSrc = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'res/img/spinner.gif'; } $this->spinnerImageFilters = '<img id="kesearch_spinner_filters" src="' . $spinnerSrc . '" alt="' . $this->pi_getLL('loading') . '" />'; $this->spinnerImageResults = '<img id="kesearch_spinner_results" src="' . $spinnerSrc . '" alt="' . $this->pi_getLL('loading') . '" />'; // get javascript onclick actions $this->initOnclickActions(); }
/** * 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 [type] ... */ function main() { global $LANG; $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->setModuleTemplate('mod_ttnews_admin.html'); $this->doc->docType = 'xhtml_trans'; if (!$this->doc->moduleTemplate) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('cannot set moduleTemplate', 'tt_news', 2, array('backpath' => $this->doc->backPath, 'filename from TBE_STYLES' => $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_ttnews_admin.html'], 'full path' => $this->doc->backPath . $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_ttnews_admin.html'])); $tfile = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('tt_news') . 'mod1/mod_ttnews_admin.html'; $this->doc->moduleTemplate = @file_get_contents(PATH_site . $tfile); } // Access check! // The page will show only if there is a valid page and if this page may be viewed by the user $access = is_array($this->pageinfo) ? 1 : 0; $this->markers['MOD_INFO'] = ''; if ($this->id && $access) { // JavaScript $this->doc->JScode = $this->doc->wrapScriptTags(' script_ended = 0; function jumpToUrl(URL) { // window.location.href = URL; } ' . ($this->singlePid ? ' function openFePreview(URL) { previewWin=window.open(URL,\'newTYPO3frontendWindow\'); previewWin.focus(); } ' : '') . $this->doc->redirectUrls()); $this->doc->postCode = $this->doc->wrapScriptTags(' script_ended = 1; '); $this->doc->inDocStylesArray['tt_news_mod1'] = ' #ttnewsadmin-tree { float:left; overflow-x: auto; overflow-y: auto; width: 253px; border-right: 1px solid #ccc; } #ttnews-cat-tree { margin-bottom: 15px; } #ttnewsadmin-list { padding: 0 10px 0 263px; } #togglesubcats { background:#ddd; padding: 2px; cursor: pointer; font-style:italic; } #newssubcats { background:#f8f9fa; padding: 2px; border:1px solid #ddd; } #resetcatselection { float:right; font-style:italic; } #ttnewsadmin-search { padding: 0; margin:0; } #ttnewsadmin-search input { margin: 0 3px; } span.hiddencat { color:#999; } span.list-cb { padding-right:15px;} table.typo3-dblist tr td.col-icon a { width: 18px; display: inline; } div.ttnewsadmin-pagination { padding: 5px 0; white-space: nowrap; } div.ttnewsadmin-pagination img, div.ttnewsadmin-pagination span.pageIndicator { margin-right: 6px; } div.ttnewsadmin-pagination img { vertical-align: bottom; padding-bottom: 2px; } #ttnewsadmin-tree .checkbox { display:inline; } #ttnews-cat-tree ul.tree { margin:16px 0 0 0; } '; // Render content: $this->moduleContent(); } else { // If no access or if ID == zero $this->displayOverview(); } $this->docHeaderButtons = $this->getHeaderButtons(); $this->markers['FUNC_MENU'] = ''; $this->markers['TREE'] = $this->treeContent; $this->markers['LIST'] = $this->listContent; $this->markers['CSH'] = $this->docHeaderButtons['csh']; $this->markers['LANG_MENU'] = $this->getLangMenu(); $this->markers['PAGE_SELECT'] = $this->getPageSelector(); // put it all together $this->content = $this->doc->startPage($LANG->getLL('title')); $this->content .= $this->doc->moduleBody($this->pageinfo, $this->docHeaderButtons, $this->markers); $this->content .= $this->doc->endPage(); $this->content = $this->doc->insertStylesAndJS($this->content); if (count($this->permsCache)) { $GLOBALS['BE_USER']->setAndSaveSessionData('permsCache', array($this->pidChash => $this->permsCache)); } }
/** * The main method of the PlugIn * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * @return The content that is displayed on the website */ function main($content, $conf) { if (TYPO3_VERSION_INTEGER >= 7000000) { $this->ms = TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds(); } else { $this->ms = t3lib_div::milliseconds(); } $this->conf = $conf; $this->pi_setPiVarDefaults(); $this->pi_loadLL(); $this->pi_USER_INT_obj = 1; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object! // initializes plugin configuration $this->init(); // init domReady action $this->initDomReadyAction(); // add header parts when in searchbox mode $this->addHeaderParts(); // init XAJAX? if ($this->conf['renderMethod'] != 'static') { if (TYPO3_VERSION_INTEGER < 6002000) { $xajaxIsLoaded = t3lib_extMgm::isLoaded('xajax'); } else { $xajaxIsLoaded = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('xajax'); } if (!$xajaxIsLoaded) { return '<span style="color: red;"><b>ke_search error:</b>"XAJAX" must be installed for this mode.</span>'; } else { $this->initXajax(); } } // Spinner Image if ($this->conf['spinnerImageFile']) { $spinnerSrc = $this->conf['spinnerImageFile']; } else { if (TYPO3_VERSION_INTEGER < 6002000) { $spinnerSrc = t3lib_extMgm::siteRelPath($this->extKey) . 'res/img/spinner.gif'; } else { $spinnerSrc = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'res/img/spinner.gif'; } } $this->spinnerImageFilters = '<img id="kesearch_spinner_filters" src="' . $spinnerSrc . '" alt="' . $this->pi_getLL('loading') . '" />'; $this->spinnerImageResults = '<img id="kesearch_spinner_results" src="' . $spinnerSrc . '" alt="' . $this->pi_getLL('loading') . '" />'; // get javascript onclick actions $this->initOnclickActions(); // hook for initials if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'] as $_classRef) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::getUserObj($_classRef); } $_procObj->addInitials($this); } } // get content $content = $this->getSearchboxContent(); $subpart = $this->cObj->getSubpart($content, '###SHOW_SPINNER###'); if ($this->conf['renderMethod'] == 'static') { $content = $this->cObj->substituteSubpart($content, '###SHOW_SPINNER###', ''); } else { $subpart = $this->cObj->substituteMarker($subpart, '###SPINNER###', $this->spinnerImageFilters); $content = $this->cObj->substituteSubpart($content, '###SHOW_SPINNER###', $subpart); } $content = $this->cObj->substituteMarker($content, '###LOADING###', $this->pi_getLL('loading')); // hook for additional searchbox markers if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['additionalSearchboxContent'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['additionalSearchboxContent'] as $_classRef) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::getUserObj($_classRef); } $_procObj->additionalSearchboxContent($content, $this); } } return $this->pi_wrapInBaseClass($content); }
/** * function includeJavascript */ public function addHeaderParts() { // build target URL if not result page unset($linkconf); $linkconf['parameter'] = $this->conf['resultPage']; $linkconf['additionalParams'] = ''; $linkconf['useCacheHash'] = false; $targetUrl = TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($this->cObj->typoLink_URL($linkconf)); $content = $this->cObj->getSubpart($this->templateCode, '###JS_SEARCH_ALL###'); if ($this->conf['renderMethod'] != 'static') { $content .= $this->cObj->getSubpart($this->templateCode, '###JS_SEARCH_NON_STATIC###'); } // include js for "ajax after page reload" mode if ($this->conf['renderMethod'] == 'ajax_after_reload') { $content .= $this->cObj->getSubpart($this->templateCode, '###JS_SEARCH_AJAX_RELOAD###'); } // loop through LL and fill $markerArray array_key_exists($this->LLkey, $this->LOCAL_LANG) ? $langKey = $this->LLkey : ($langKey = 'default'); foreach ($this->LOCAL_LANG[$langKey] as $key => $value) { $markerArray['###' . strtoupper($key) . '###'] = $value; } // define some additional markers $markerArray['###SITE_REL_PATH###'] = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey); $markerArray['###TARGET_URL###'] = $targetUrl; $markerArray['###PREFIX_ID###'] = $this->prefixId; $markerArray['###SEARCHBOX_DEFAULT_VALUE###'] = $this->pi_getLL('searchbox_default_value'); $markerArray['###DOMREADYACTION###'] = $this->onDomReady; $content = $this->cObj->substituteMarkerArray($content, $markerArray); // add JS to page header $GLOBALS['TSFE']->getPageRenderer()->addHeaderData($content); }
/** * The main method of the PlugIn * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * @return The content that is displayed on the website */ function main($content, $conf) { if (TYPO3_VERSION_INTEGER >= 7000000) { $this->ms = TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds(); } else { $this->ms = t3lib_div::milliseconds(); } $this->conf = $conf; $this->pi_setPiVarDefaults(); $this->pi_loadLL(); $this->pi_USER_INT_obj = 1; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object! // initializes plugin configuration $this->init(); if ($this->conf['resultPage'] != $GLOBALS['TSFE']->id) { $content = '<div id="textmessage">' . $this->pi_getLL('error_resultPage') . '</div>'; return $this->pi_wrapInBaseClass($content); } // init XAJAX? if ($this->conf['renderMethod'] != 'static') { if (TYPO3_VERSION_INTEGER < 6002000) { $xajaxIsLoaded = t3lib_extMgm::isLoaded('xajax'); } else { $xajaxIsLoaded = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('xajax'); } if (!$xajaxIsLoaded) { return; } else { $this->initXajax(); } } // Spinner Image if ($this->conf['spinnerImageFile']) { $spinnerSrc = $this->conf['spinnerImageFile']; } else { if (TYPO3_VERSION_INTEGER < 6002000) { $spinnerSrc = t3lib_extMgm::siteRelPath($this->extKey) . 'res/img/spinner.gif'; } else { $spinnerSrc = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'res/img/spinner.gif'; } } $this->spinnerImageFilters = '<img id="kesearch_spinner_filters" src="' . $spinnerSrc . '" alt="' . $this->pi_getLL('loading') . '" />'; $this->spinnerImageResults = '<img id="kesearch_spinner_results" src="' . $spinnerSrc . '" alt="' . $this->pi_getLL('loading') . '" />'; // get javascript onclick actions $this->initOnclickActions(); // hook for initials if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'] as $_classRef) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::getUserObj($_classRef); } $_procObj->addInitials($this); } } $content = $this->cObj->getSubpart($this->templateCode, '###RESULT_LIST###'); // hook: modifyResultList if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyResultList'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyResultList'] as $_classRef) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::getUserObj($_classRef); } $_procObj->modifyResultList($content, $this); } } // show text instead of results if no searchparams set and activated in ff if ($this->isEmptySearch && $this->conf['showTextInsteadOfResults']) { // Don't replace the following with substituteMarker // this is used to be valid against JavaScript calls $content = '<div id="textmessage">' . $this->pi_RTEcssText($this->conf['textForResults']) . '</div>'; $content .= '<div id="kesearch_results"></div>'; $content .= '<div id="kesearch_updating_results"></div>'; $content .= '<div id="kesearch_pagebrowser_top"></div>'; $content .= '<div id="kesearch_pagebrowser_bottom"></div>'; $content .= '<div id="kesearch_query_time"></div>'; return $content; } if ($this->conf['renderMethod'] == 'ajax_after_reload') { $content = $this->cObj->substituteMarker($content, '###MESSAGE###', ''); $content = $this->cObj->substituteMarker($content, '###QUERY_TIME###', ''); $content = $this->cObj->substituteMarker($content, '###PAGEBROWSER_TOP###', ''); $content = $this->cObj->substituteMarker($content, '###PAGEBROWSER_BOTTOM###', ''); $content = $this->cObj->substituteMarker($content, '###NUMBER_OF_RESULTS###', ''); $content = $this->cObj->substituteMarker($content, '###ORDERING###', ''); $content = $this->cObj->substituteMarker($content, '###SPINNER###', ''); $content = $this->cObj->substituteMarker($content, '###LOADING###', ''); return $this->pi_wrapInBaseClass($content); } $content = $this->cObj->substituteMarker($content, '###MESSAGE###', $this->getSearchResults()); $content = $this->cObj->substituteMarker($content, '###NUMBER_OF_RESULTS###', sprintf($this->pi_getLL('num_results'), $this->numberOfResults)); $content = $this->cObj->substituteMarker($content, '###ORDERING###', $this->renderOrdering()); $subpart = $this->cObj->getSubpart($content, '###SHOW_SPINNER###'); if ($this->conf['renderMethod'] == 'static') { $content = $this->cObj->substituteSubpart($content, '###SHOW_SPINNER###', ''); } else { $subpart = $this->cObj->substituteMarker($subpart, '###SPINNER###', $this->spinnerImageResults); $content = $this->cObj->substituteSubpart($content, '###SHOW_SPINNER###', $subpart); } $content = $this->cObj->substituteMarker($content, '###LOADING###', $this->pi_getLL('loading')); // process query time if ($this->conf['showQueryTime']) { if (TYPO3_VERSION_INTEGER >= 7000000) { $queryTime = TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $GLOBALS['TSFE']->register['ke_search_queryStartTime']; } else { $queryTime = t3lib_div::milliseconds() - $GLOBALS['TSFE']->register['ke_search_queryStartTime']; } $content = $this->cObj->substituteMarker($content, '###QUERY_TIME###', sprintf($this->pi_getLL('query_time'), $queryTime)); } else { $content = $this->cObj->substituteMarker($content, '###QUERY_TIME###', ''); } // render pagebrowser if ($GLOBALS['TSFE']->id == $this->conf['resultPage']) { if ($this->conf['pagebrowserOnTop'] || $this->conf['pagebrowserAtBottom']) { $pagebrowserContent = $this->renderPagebrowser(); } if ($this->conf['pagebrowserOnTop']) { $content = $this->cObj->substituteMarker($content, '###PAGEBROWSER_TOP###', $pagebrowserContent); } else { $content = $this->cObj->substituteMarker($content, '###PAGEBROWSER_TOP###', ''); } if ($this->conf['pagebrowserAtBottom']) { $content = $this->cObj->substituteMarker($content, '###PAGEBROWSER_BOTTOM###', $pagebrowserContent); } else { $content = $this->cObj->substituteMarker($content, '###PAGEBROWSER_BOTTOM###', ''); } } return $this->pi_wrapInBaseClass($content); }
/** * Displays a hirarchical menu from tt_news categories * * @return string html for the category menu */ function displayCatMenu() { $content = ''; $lConf = $this->conf['displayCatMenu.']; $mode = $lConf['mode'] ? $lConf['mode'] : 'tree'; $this->dontStartFromRootRecord = false; $this->initCatmenuEnv($lConf); switch ($mode) { case 'nestedWraps': $fields = '*'; $lConf = $this->conf['displayCatMenu.']; $addCatlistWhere = ''; if ($this->dontStartFromRootRecord) { $addCatlistWhere = 'tt_news_cat.uid IN (' . implode(',', $this->cleanedCategoryMounts) . ')'; } $res = $this->db->exec_SELECTquery($fields, 'tt_news_cat', ($this->dontStartFromRootRecord ? $addCatlistWhere : 'tt_news_cat.parent_category=0') . $this->SPaddWhere . $this->enableCatFields . $this->catlistWhere, '', 'tt_news_cat.' . $this->config['catOrderBy']); $cArr = array(); if (!$lConf['hideCatmenuHeader']) { $cArr[] = $this->local_cObj->stdWrap($this->pi_getLL('catmenuHeader', 'Select a category:'), $lConf['catmenuHeader_stdWrap.']); } while ($row = $this->db->sql_fetch_assoc($res)) { $cArr[] = $row; $subcats = $this->hObj->getSubCategoriesForMenu($row['uid'], $fields, $this->catlistWhere); if (count($subcats)) { $cArr[] = $subcats; } } $this->db->sql_free_result($res); $content = $this->getCatMenuContent($cArr, $lConf); break; case 'tree': case 'ajaxtree': $catTreeObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_ttnews_catmenu'); if ($mode == 'ajaxtree') { // todo use pagerenderer $this->tsfe->additionalHeaderData['tt_news_categorytree'] = ' ' . ($lConf['includePrototypeJS'] ? '<script type="text/javascript" src="' . TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('tt_news') . 'Resources/Public/JavaScript/compat/prototype/prototype.js"></script>' : '') . ' <script type="text/javascript" src="' . TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('tt_news') . 'Resources/Public/JavaScript/tt_news_catmenu.js"></script> '; } $catTreeObj->init($this); $catTreeObj->treeObj->FE_USER =& $this->tsfe->fe_user; $content = '<div id="ttnews-cat-tree">' . $catTreeObj->treeObj->getBrowsableTree() . '</div>'; break; default: // hook for user catmenu if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['userDisplayCatmenuHook'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['userDisplayCatmenuHook'] as $_classRef) { $_procObj =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); $content = $_procObj->userDisplayCatmenu($lConf, $this); } } break; } if ($this->debugTimes) { $this->hObj->getParsetime(__METHOD__); } return $this->local_cObj->stdWrap($content, $lConf['catmenu_stdWrap.']); }