/**
  * Constructor
  */
 function tx_kickstarter_wizard()
 {
     $this->modData = t3lib_div::_POST($this->varPrefix);
     $version = class_exists('t3lib_utility_VersionNumber') ? t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) : t3lib_div::int_from_ver(TYPO3_version);
     if ($version < 4006000) {
         $LOCAL_LANG = t3lib_div::readLLXMLfile(t3lib_extMgm::extPath('setup') . '/mod/locallang.xml', 'default');
         // Getting the available languages
         $theLanguages = t3lib_div::trimExplode('|', TYPO3_languages);
     } else {
         /** @var $xliffParser t3lib_l10n_parser_Xliff */
         $xliffParser = t3lib_div::makeInstance('t3lib_l10n_parser_Xliff');
         $LOCAL_LANG = $xliffParser->getParsedData(t3lib_extMgm::extPath('setup') . '/mod/locallang.xlf', 'default');
         /** @var $locales t3lib_l10n_Locales */
         $locales = t3lib_div::makeInstance('t3lib_l10n_Locales');
         // Getting the available languages
         $theLanguages = $locales->getLocales();
     }
     foreach ($theLanguages as $val) {
         if ($val !== 'default') {
             if ($version < 4006000) {
                 $localLabel = htmlspecialchars($LOCAL_LANG['default']['lang_' . $val]);
             } else {
                 $localLabel = htmlspecialchars($LOCAL_LANG['default']['lang_' . $val][0]['target']);
             }
             $this->languages[$val] = $localLabel;
         }
     }
     asort($this->languages);
     // init reserved words
     $resWords = t3lib_div::makeInstance('tx_kickstarter_reservedWords');
     $this->reservedWords = $resWords->getReservedWords();
 }
 /**
  * Sets up this testcase
  */
 public function setUp()
 {
     $this->getBackup = t3lib_div::_GET();
     $this->postBackup = t3lib_div::_POST();
     $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
     $GLOBALS['TYPO3_DB'] = $this->getMock('t3lib_DB', array());
     $this->backendConfigurationManager = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Configuration_BackendConfigurationManager'), array('dummy'));
 }
 /**
  * Sets up this testcase
  */
 public function setUp()
 {
     $this->getBackup = t3lib_div::_GET();
     $this->postBackup = t3lib_div::_POST();
     $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
     $GLOBALS['TYPO3_DB'] = $this->getMock('t3lib_DB', array());
     $this->extConfBackup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase'];
     $this->backendConfigurationManager = $this->getAccessibleMock('Tx_Extbase_Configuration_BackendConfigurationManager', array('getTypoScriptSetup'));
 }
 public static function getMergedGP()
 {
     $gp = array_merge(t3lib_div::_GET(), t3lib_div::_POST());
     $prefix = Tx_Formhandler_Globals::$formValuesPrefix;
     if ($prefix) {
         $gp = $gp[$prefix];
     }
     return $gp;
 }
 function auswertung()
 {
     $get = t3lib_div::_GET();
     $post = t3lib_div::_POST();
     $out = '<h1> Hier kommt eine Auswertung </h1>';
     $out .= '<h3>Get: ' . print_r($get, true) . '</h3>';
     $out .= '<h3>Post: ' . print_r($post, true) . '</h3>';
     return $out;
 }
 /**
  * Saves the sorting order of tasks in the backend user's uc
  *
  * @param	array		array of parameters from the AJAX interface, currently unused
  * @param	TYPO3AJAX	object of type TYPO3AJAX
  * @return	void
  */
 public function saveSortingState(array $params, TYPO3AJAX $ajaxObj)
 {
     $sort = array();
     $items = explode('&', t3lib_div::_POST('data'));
     foreach ($items as $item) {
         $sort[] = substr($item, 12);
     }
     $GLOBALS['BE_USER']->uc['taskcenter']['sorting'] = serialize($sort);
     $GLOBALS['BE_USER']->writeUC();
 }
 /**
  * Updates nested sets
  *
  * @return	string		HTML output
  */
 public function main()
 {
     if (t3lib_div::_POST('nssubmit') != '') {
         $this->updateOverridePaths();
         $content = 'Update finished successfully.';
     } else {
         $content = $this->prompt();
     }
     return $content;
 }
 /**
  * Updates nested sets
  *
  * @return	string		HTML output
  */
 public function main()
 {
     if (t3lib_div::_POST('nssubmit') != '') {
         $res = $this->adoptOldFilelist();
         $content = '<p>Update finished.<br/>' . 'Successfully adopted <b>' . $res['success'] . '</b> file(s).<br/>' . 'Failed for <b>' . $res['fail'] . '</b> file(s).</p>';
     } else {
         $content = $this->prompt();
     }
     return $content;
 }
 protected function loadGP()
 {
     $gp = array_merge(t3lib_div::_GET(), t3lib_div::_POST());
     if ($this->formValuesPrefix) {
         $gp = $gp[$this->formValuesPrefix];
     }
     if (!is_array($gp)) {
         $gp = array();
     }
     return $gp;
 }
Esempio n. 10
0
 /**
  * Set current query
  *
  * @param Tx_Youtubeapi_Domain_Model_Video $query The query
  * @return void
  */
 public function setQuery($settings)
 {
     $this->settings = $settings;
     $this->vars = t3lib_div::_GET('tx_youtubeapi_pi1');
     $this->postvars = t3lib_div::_POST('tx_youtubeapi_pi1');
     if ($this->postvars[search]) {
         $GLOBALS['TSFE']->fe_user->setKey("ses", "search", $this->postvars[search]);
         $this->settings['searchTerms'] = $GLOBALS["TSFE"]->fe_user->getKey("ses", "search");
     }
     if ($this->postvars[maxResults]) {
         $GLOBALS['TSFE']->fe_user->setKey("ses", "maxResults", $this->postvars[maxResults]);
     }
     $this->settings['maxResults'] = $GLOBALS["TSFE"]->fe_user->getKey("ses", "maxResults") ? $GLOBALS["TSFE"]->fe_user->getKey("ses", "maxResults") : $this->settings['maxResults'];
     $limit = $this->settings['maxResults'];
     if ($this->vars) {
         $page = (int) $this->vars[page];
         $start = $page * $limit + 1;
     } else {
         $start = 1;
     }
     $this->yt = new Zend_Gdata_YouTube();
     $this->query = $this->yt->newVideoQuery();
     $this->query->orderBy = $this->settings['orderBy'];
     $this->query->startIndex = $this->vars['start'] ? $this->vars['start'] : (int) $start;
     $this->query->maxResults = (int) $limit;
     print_r($this->settings['channel']);
     // Build search (flexform values will be overidden by searchoptions in FE)
     if ($this->postvars[type] == "") {
         $this->query->videoQuery = $this->postvars[search] ? $this->postvars[search] : $this->settings['searchTerm'];
     }
     // searching by keywords
     if ($this->settings['keywords'] || $this->postvars[type] == "keyword") {
         $keywords = $this->postvars[search] ? $this->postvars[search] : $this->settings['keywords'];
         $this->query->category = $this->_keyworded($keywords);
     }
     // searching by category
     if (($this->settings['category'] || $this->postvars[type] == "category") && !$this->settings['keywords']) {
         $category = $this->postvars[search] ? $this->postvars[search] : $this->settings['category'];
         $this->query->category = $this->_categorized($category);
     }
     // searching by category and keywords
     if (($this->settings['keywords'] || $this->postvars[type] == "keyword") && ($this->settings['category'] || $this->postvars[type] == "category")) {
         if ($this->settings['keywords'] && $this->postvars[type] == "category") {
             $keywords = $this->settings['keywords'];
             $category = $this->postvars[search];
         }
         if ($this->settings['category'] && $this->postvars[type] == "keyword") {
             $keywords = $this->postvars[search];
             $category = $this->settings['category'];
         }
         $this->query->category = $this->_categorized($category) . "/" . $this->_keyworded($keywords);
     }
 }
    public function main($parent, $pageId)
    {
        $this->post = t3lib_div::_POST();
        $this->get = t3lib_div::_GET();
        $erg = '<script src="../typo3conf/ext/he_portal/res/jquery/js/jquery-1.7.1b.min.js" type="text/javascript"></script>
						<script src="../typo3conf/ext/he_portal/res/jquery/js/portal.js" type="text/javascript"></script><br>
						<div class="aliasVerwaltung">
						<h1 class="heading">Alias Verwaltung</h1>
						<form method="post" action="">';
        $aliasListe = $this->post['aliasListe'];
        $aliasEingabe = $this->post['aliasEingabe'];
        $aliasSpeichern = $this->post['aliasSpeichern'];
        $filter = $this->post['filter'];
        $alias = $this->post['alias'];
        $url = $this->post['url'];
        $lang = $this->post['lang'];
        $uid = $this->post['uid'];
        $auswahl = '';
        if (empty($aliasListe) && empty($aliasEingabe) && empty($aliasSpeichern) && empty($abbrechen)) {
            $action = $this->get['action'];
            if ($action != '') {
                switch ($action) {
                    case 'edit':
                        $aliasUid = $this->get['aliasUid'];
                        if (!empty($aliasUid)) {
                            $auswahl = $this->aliasBearbeiten($aliasUid, $pageId);
                        }
                        break;
                }
            }
        } else {
            if ($aliasEingabe != '') {
                $auswahl = $this->aliasEingabe($alias, $url, $lang, $pageId);
            } else {
                if ($aliasSpeichern != '') {
                    $erg .= $this->aliasSpeichern($alias, $url, $lang, $uid);
                }
            }
        }
        if (empty($auswahl)) {
            $erg .= $this->aliasEingabe($alias, $url, $lang, $pageId);
            $erg .= $this->aliasListe($filter);
        } else {
            $erg .= $auswahl;
        }
        $erg .= '</div>';
        return $erg;
    }
 function change_title()
 {
     $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_indexedsearch.'];
     $sitename = $GLOBALS['TSFE']->tmpl->setup['sitetitle'];
     $orig_title = $GLOBALS['TSFE']->config['config']['pageTitleFirst'] ? $GLOBALS['TSFE']->page['title'] . ': ' . $sitename : $sitename . ': ' . $GLOBALS['TSFE']->page['title'];
     $params_search = t3lib_div::_POST('tx_indexedsearch') ? t3lib_div::_POST('tx_indexedsearch') : t3lib_div::_GET('tx_indexedsearch');
     if ($params_search['sword']) {
         $num_page = $params_search['pointer'] ? $params_search['pointer'] + 1 : '1';
         $page_title = $orig_title . ' - ' . $conf['pageTitleAdd'] . ' ' . $params_search['sword'] . ' - ' . $conf['pageTitlePage'] . ' ' . $num_page;
         return $page_title;
     } else {
         // original code from class.tslib_pagegen.php :
         $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle($GLOBALS['TSFE']->altPageTitle ? $GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title'], $GLOBALS['TSFE']->config['config']['noPageTitle'], $GLOBALS['TSFE']->config['config']['pageTitleFirst']);
         return $titleTagContent;
     }
 }
Esempio n. 13
0
 function getCacheID($cache_id = null)
 {
     // If caching is disabled in TYPO3 make sure it's disabled in Smarty as well
     if ($GLOBALS['TSFE']->no_cache || t3lib_div::_GP('no_cache')) {
         $this->caching = false;
         return;
         // Exit here
     }
     // If cHash is set, use it for the cache_id
     if (t3lib_div::_GP('cHash')) {
         return t3lib_div::_GP('cHash');
     }
     // Otherwise create a unique cache_id from POST/GET vars
     // TODO: Observe how well Smarty caching works in the context of TYPO3. Disabling caching is generally recommended...
     return $cache_id ? $cache_id : t3lib_div::shortMD5(serialize(array_merge(t3lib_div::_GET(), t3lib_div::_POST())));
 }
 public function main($parent, $pageId)
 {
     $this->post = t3lib_div::_POST();
     $this->get = t3lib_div::_GET();
     $erg = '<div class="qrCodes">';
     $erg .= '<h1 class="heading">QR-Codes</h1>';
     $filter = $this->post['filter'];
     $alias = $this->post['alias'];
     $url = $this->post['url'];
     $lang = $this->post['lang'];
     $uid = $this->post['uid'];
     $auswahl = $this->aliasListe($filter);
     $erg .= $auswahl;
     $erg .= '</div>';
     return $erg;
 }
 public function main($parent, $pageId)
 {
     $this->post = t3lib_div::_POST();
     $this->get = t3lib_div::_GET();
     $erg .= '<div class="portalFunktionen">';
     $erg .= '<h1>Portal Funktionen</h1>';
     $erg .= '<form name="alias" method="post" action="">';
     $gadgetsAktivieren = $this->post['gadgetsAktivieren'];
     $gadgetAuswahl = $this->post['gadgetAuswahl'];
     if (!empty($gadgetsAktivieren) || !empty($gadgetAuswahl)) {
         $erg .= $this->gadgetsAktivieren($gadgetAuswahl);
     }
     $erg .= '<input type="submit" name="gadgetsAktivieren" value="Gadgets für alle aktivieren"/>';
     $erg .= '</form>';
     $erg .= '</div>';
     return $erg;
 }
 public function formularAnzeigen()
 {
     $GLOBALS['TSFE']->additionalHeaderData['he_tools_css_1'] = '<link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/css/kms_form.css" rel="stylesheet" type="text/css" />';
     $username = $GLOBALS['TSFE']->fe_user->user['username'];
     $top = '';
     $middle = '';
     $bottom = '';
     $slqQuery = 'SELECT * FROM kms WHERE login="******"';
     $abfragePages = $this->sqlQuery($slqQuery);
     $data = $this->sqlFetchAssoc($abfragePages);
     $post = t3lib_div::_POST();
     $zustimmung = $post['zustimmung'];
     $anmelden = $post['anmelden'];
     $abbrechen = $post['abbrechen'];
     if (!empty($anmelden)) {
         if (empty($zustimmung)) {
             $error = '<h3 class="error">Sie müssen den Nutzungsrechten zustimmen!</h3>';
             $bottom = $this->gibAntragsFormular($error);
         } else {
             if (empty($data)) {
                 /* Neuer Antrag: E-Mail-Versand */
                 $top = $this->kmsEintragSpeichern($username);
             } else {
                 /* Vorhandener Antrag: kein E-Mail-Versand */
                 $top = 'Ihr KMS-Antrag wurde soeben gespeichert';
             }
             $bottom = $this->gibAnleitung();
         }
     } else {
         if (!empty($abbrechen)) {
             $bottom = $this->gubAbbrechenText();
         } else {
             if (!empty($data)) {
                 $top = $this->kmsEintragVorhanden($data['idate']);
                 $bottom = $this->gibAnleitung();
                 // Zum Testen
                 //$bottom = $this->gibAntragsFormular();
             } else {
                 $bottom = $this->gibAntragsFormular();
             }
         }
     }
     $out = '<div class="kms_form">' . $top . $bottom . '</div>';
     $this->disconnectDb();
     return $out;
 }
 /**
  * Constructor
  */
 function tx_kickstarter_wizard()
 {
     $this->modData = t3lib_div::_POST($this->varPrefix);
     // getting the available languages
     $theLanguages = t3lib_div::trimExplode('|', TYPO3_languages);
     $llFile = t3lib_extMgm::extPath('setup') . '/mod/locallang.xml';
     $LOCAL_LANG = t3lib_div::readLLXMLfile($llFile, 'default');
     foreach ($theLanguages as $val) {
         if ($val != 'default') {
             $localLabel = htmlspecialchars($LOCAL_LANG['default']['lang_' . $val]);
             $this->languages[$val] = $localLabel;
         }
     }
     asort($this->languages);
     // init reserved words
     $resWords = t3lib_div::makeInstance('tx_kickstarter_reservedWords');
     $this->reservedWords = $resWords->getReservedWords();
 }
 /**
  * Dispatches the incoming calls to methods about the ExtDirect API.
  *
  * @param aray $ajaxParams ajax parameters
  * @param TYPO3AJAX $ajaxObj typo3ajax instance
  * @return void
  */
 public function route($ajaxParams, TYPO3AJAX $ajaxObj)
 {
     try {
         $isForm = FALSE;
         $isUpload = FALSE;
         $rawPostData = file_get_contents('php://input');
         $postParameters = t3lib_div::_POST();
         $namespace = t3lib_div::_GET('namespace');
         if (!empty($postParameters['extAction'])) {
             $isForm = TRUE;
             $isUpload = $postParameters['extUpload'] === 'true';
             $request->action = $postParameters['extAction'];
             $request->method = $postParameters['extMethod'];
             $request->tid = $postParameters['extTID'];
             $request->data = array($_POST + $_FILES);
         } elseif (!empty($rawPostData)) {
             $request = json_decode($rawPostData);
         } else {
             throw new t3lib_error_Exception('ExtDirect: Missing Parameters!');
         }
         $response = NULL;
         if (is_array($request)) {
             $response = array();
             foreach ($request as $singleRequest) {
                 $response[] = $this->processRpc($singleRequest, $namespace);
             }
         } else {
             $response = $this->processRpc($request, $namespace);
         }
         if ($isForm && $isUpload) {
             $ajaxObj->setContentFormat('plain');
             $response = json_encode($response);
             $response = preg_replace('/&quot;/', '\\&quot;', $response);
             $response = array('<html><body><textarea>' . $response . '</textarea></body></html>');
         } else {
             $ajaxObj->setContentFormat('jsonbody');
         }
     } catch (t3lib_error_Exception $exception) {
         $response = array('type' => 'exception', 'message' => $exception->getMessage(), 'where' => $exception->getTraceAsString());
     }
     $ajaxObj->setContent($response);
 }
 /**
  * Builds a widget request object from the raw HTTP information
  *
  * @return Tx_Fluid_Core_Widget_WidgetRequest The widget request as an object
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function build()
 {
     $request = $this->objectManager->create('Tx_Fluid_Core_Widget_WidgetRequest');
     $request->setRequestURI(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'));
     $request->setBaseURI(t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
     $request->setMethod(isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : NULL);
     if (strtolower($_SERVER['REQUEST_METHOD']) === 'post') {
         $request->setArguments(t3lib_div::_POST());
     } else {
         $request->setArguments(t3lib_div::_GET());
     }
     $rawGetArguments = t3lib_div::_GET();
     // TODO: rename to @action, to be consistent with normal naming?
     if (isset($rawGetArguments['action'])) {
         $request->setControllerActionName($rawGetArguments['action']);
     }
     $widgetContext = $this->ajaxWidgetContextHolder->get($rawGetArguments['fluid-widget-id']);
     $request->setWidgetContext($widgetContext);
     return $request;
 }
Esempio n. 20
0
    public function main($id)
    {
        $post = t3lib_div::_POST();
        $suchen = $post[suchen];
        if ($suchen != '') {
            $uid = $post[uid];
            $tabelle = $post[tabelle];
            $erg .= $this->suchen($uid, $tabelle);
        }
        $erg .= '<div class="sys_logs">';
        $erg .= '<form name="sys_logs" method="post" action="">';
        $erg .= 'ID: <input type="text" name="uid" value="' . $id . '"/>';
        $erg .= ' Tabelle: <select name="tabelle">
						 <option value="pages" selected="selected">pages</option>
						 <option value="tt_content">tt_content</option>
						 </select><br/>';
        $erg .= '<input type="submit" name="suchen" value="Logeinträge suchen"/><br/><br/>';
        $erg .= '
				</form>
				</div>';
        return $erg;
    }
 function initializePositionSaving()
 {
     // Get stored tree structure:
     $this->stored = unserialize($this->BE_USER->uc['browseTrees'][$this->treeName]);
     // PM action
     // (If an plus/minus icon has been clicked, the PM GET var is sent and we must update the stored positions in the tree):
     $PM = explode('_', t3lib_div::_POST($this->treeName . '_pm'));
     // 0: mount key, 1: set/clear boolean, 2: item ID (cannot contain "_"), 3: treeName
     if (count($PM) == 4 && $PM[3] == $this->treeName) {
         if (isset($this->MOUNTS[$PM[0]])) {
             if ($PM[1]) {
                 // set
                 $this->stored[$PM[0]][$PM[2]] = 1;
                 $this->savePosition();
             } else {
                 // clear
                 unset($this->stored[$PM[0]][$PM[2]]);
                 $this->savePosition();
             }
         }
     }
 }
 /**
  * Create a tag
  *
  * @param array $params
  * @param TYPO3AJAX $ajaxObj
  * @return void
  * @throws Exception
  */
 public function createTag(array $params, TYPO3AJAX $ajaxObj)
 {
     $request = t3lib_div::_POST();
     try {
         // Check if a tag is submitted
         if (!isset($request['item']) || empty($request['item'])) {
             throw new Exception('error_no-tag');
         }
         $newsUid = $request['newsid'];
         if ((int) $newsUid === 0 && (strlen($newsUid) == 16 && !t3lib_div::isFirstPartOfStr($newsUid, 'NEW'))) {
             throw new Exception('error_no-newsid');
         }
         // Get tag uid
         $newTagId = $this->getTagUid($request);
         $ajaxObj->setContentFormat('javascript');
         $ajaxObj->setContent('');
         $response = array($newTagId, $request['item'], self::TAG, self::NEWS, 'tags', 'data[tx_news_domain_model_news][' . $newsUid . '][tags]', $newsUid);
         $ajaxObj->setJavascriptCallbackWrap(implode('-', $response));
     } catch (Exception $e) {
         $errorMsg = $GLOBALS['LANG']->sL(self::LLPATH . $e->getMessage());
         $ajaxObj->setError($errorMsg);
     }
 }
 /**
  * The main function in the class
  *
  * @return	string		HTML content
  */
 function main()
 {
     $output = 'Enter [table]:[uid]:[fieldlist (optional)] <input name="table_uid" value="' . htmlspecialchars(t3lib_div::_POST('table_uid')) . '" />';
     $output .= '<input type="submit" name="_" value="REFRESH" /><br/>';
     // Show record:
     if (t3lib_div::_POST('table_uid')) {
         list($table, $uid, $fieldName) = t3lib_div::trimExplode(':', t3lib_div::_POST('table_uid'), 1);
         if ($GLOBALS['TCA'][$table]) {
             $rec = t3lib_BEfunc::getRecordRaw($table, 'uid=' . intval($uid), $fieldName ? $fieldName : '*');
             if (count($rec)) {
                 $pidOfRecord = $rec['pid'];
                 $output .= '<input type="checkbox" name="show_path" value="1"' . (t3lib_div::_POST('show_path') ? ' checked="checked"' : '') . '/> Show path and rootline of record<br/>';
                 if (t3lib_div::_POST('show_path')) {
                     $output .= '<br/>Path of PID ' . $pidOfRecord . ': <em>' . t3lib_BEfunc::getRecordPath($pidOfRecord, '', 30) . '</em><br/>';
                     $output .= 'RL:' . Tx_Extdeveval_Compatibility::viewArray(t3lib_BEfunc::BEgetRootLine($pidOfRecord)) . '<br/>';
                     $output .= 'FLAGS:' . ($rec['deleted'] ? ' <b>DELETED</b>' : '') . ($rec['pid'] == -1 ? ' <b>OFFLINE VERSION of ' . $rec['t3ver_oid'] . '</b>' : '') . '<br/><hr/>';
                 }
                 if (t3lib_div::_POST('_EDIT')) {
                     $output .= '<hr/>Edit:<br/><br/>';
                     $output .= '<input type="submit" name="_SAVE" value="SAVE" /><br/>';
                     foreach ($rec as $field => $value) {
                         $output .= '<b>' . htmlspecialchars($field) . ':</b><br/>';
                         if (count(explode(chr(10), $value)) > 1) {
                             $output .= '<textarea name="record[' . $table . '][' . $uid . '][' . $field . ']" cols="100" rows="10">' . t3lib_div::formatForTextarea($value) . '</textarea><br/>';
                         } else {
                             $output .= '<input name="record[' . $table . '][' . $uid . '][' . $field . ']" value="' . htmlspecialchars($value) . '" size="100" /><br/>';
                         }
                     }
                 } elseif (t3lib_div::_POST('_SAVE')) {
                     $incomingData = t3lib_div::_POST('record');
                     $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($uid), $incomingData[$table][$uid]);
                     $output .= '<br/>Updated ' . $table . ':' . $uid . '...';
                     $this->updateRefIndex($table, $uid);
                 } else {
                     if (t3lib_div::_POST('_DELETE')) {
                         $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'uid=' . intval($uid));
                         $output .= '<br/>Deleted ' . $table . ':' . $uid . '...';
                         $this->updateRefIndex($table, $uid);
                     } else {
                         $output .= '<input type="submit" name="_EDIT" value="EDIT" />';
                         $output .= '<input type="submit" name="_DELETE" value="DELETE" onclick="return confirm(\'Are you sure you wish to delete?\');" />';
                         $output .= '<br/>' . md5(implode($rec));
                         $output .= Tx_Extdeveval_Compatibility::viewArray($rec);
                     }
                 }
             } else {
                 $output .= 'No record existed!';
             }
         }
     }
     return $output;
 }
Esempio n. 24
0
	/**
	 * Main function, drawing marked up XML.
	 *
	 * @return	void
	 */
	function main()	{
		global $LANG,$BACK_PATH;

			// Check admin: If this is changed some day to other than admin users we HAVE to check if there is read access to the record being selected!
		if (!$GLOBALS['BE_USER']->isAdmin())	die('no access.');

		$this->returnUrl =  t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));

			// Draw the header.
		$this->doc = t3lib_div::makeInstance('template');
		$this->doc->docType = 'xhtml_trans';
		$this->doc->backPath = $BACK_PATH;
		$this->doc->setModuleTemplate('EXT:templavoila/resources/templates/cm2_default.html');
		$this->doc->bodyTagId = 'typo3-mod-php';
		$this->doc->divClass = '';

			// XML code:
		$this->viewTable = t3lib_div::_GP('viewRec');

		$record = t3lib_BEfunc::getRecordWSOL($this->viewTable['table'], $this->viewTable['uid']);	// Selecting record based on table/uid since adding the field might impose a SQL-injection problem; at least the field name would have to be checked first.
		if (is_array($record))	{

				// Set current XML data:
			$currentXML = $record[$this->viewTable['field_flex']];

				// Clean up XML:
			$cleanXML = '';
			if ($GLOBALS['BE_USER']->isAdmin())	{
				if ('tx_templavoila_flex' == $this->viewTable['field_flex'])	{
					$flexObj = t3lib_div::makeInstance('t3lib_flexformtools');
					if ($record['tx_templavoila_flex'])	{
						$cleanXML = $flexObj->cleanFlexFormXML($this->viewTable['table'],'tx_templavoila_flex',$record);

							// If the clean-button was pressed, save right away:
						if (t3lib_div::_POST('_CLEAN_XML'))	{
							$dataArr = array();
							$dataArr[$this->viewTable['table']][$this->viewTable['uid']]['tx_templavoila_flex'] = $cleanXML;

								// Init TCEmain object and store:
							$tce = t3lib_div::makeInstance('t3lib_TCEmain');
							$tce->stripslashes_values=0;
							$tce->start($dataArr,array());
							$tce->process_datamap();

								// Re-fetch record:
							$record = t3lib_BEfunc::getRecordWSOL($this->viewTable['table'], $this->viewTable['uid']);
							$currentXML = $record[$this->viewTable['field_flex']];
						}
					}
				}
			}

			if (md5($currentXML)!=md5($cleanXML))	{
					// Create diff-result:
				$t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
				$diffres = $t3lib_diff_Obj->makeDiffDisplay($currentXML,$cleanXML);

			$flashMessage = t3lib_div::makeInstance(
				't3lib_FlashMessage',
				$LANG->getLL('needsCleaning',1),
				'',
				t3lib_FlashMessage::INFO
			);
			$xmlContentMarkedUp = $flashMessage->render();

			$xmlContentMarkedUp .= '<table border="0">
					<tr class="bgColor5 tableheader">
						<td>'.$LANG->getLL('current',1).'</td>
					</tr>
					<tr>
						<td>'.$this->markUpXML($currentXML).'<br/><br/></td>
					</tr>
					<tr class="bgColor5 tableheader">
						<td>'.$LANG->getLL('clean',1).'</td>
					</tr>
					<tr>
						<td>'.$this->markUpXML($cleanXML).'</td>
					</tr>
					<tr class="bgColor5 tableheader">
						<td>'.$LANG->getLL('diff',1).'</td>
					</tr>
					<tr>
						<td>'.$diffres.'
						<br/><br/><br/>

						<form action="'.t3lib_div::getIndpEnv('REQUEST_URI').'" method="post">
							<input type="submit" value="'.$LANG->getLL('cleanUp',1).'" name="_CLEAN_XML" />
						</form>

						</td>
					</tr>
				</table>

				';
			} else {
				$xmlContentMarkedUp = '';
				if ($cleanXML)	{
					$flashMessage = t3lib_div::makeInstance(
						't3lib_FlashMessage',
						$LANG->getLL('XMLclean',1),
						'',
						t3lib_FlashMessage::OK
					);
					$xmlContentMarkedUp = $flashMessage->render();
				}
				$xmlContentMarkedUp.= $this->markUpXML($currentXML);
			}

			$this->content.=$this->doc->section('',$xmlContentMarkedUp,0,1);
		}

			// Add spacer:
		$this->content.=$this->doc->spacer(10);

		$docHeaderButtons = $this->getDocHeaderButtons();
		$docContent = array(
			'CSH' => $docHeaderButtons['csh'],
			'CONTENT' => $this->content
		);

		$content  = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
		$content .= $this->doc->moduleBody(
			array(),
			$docHeaderButtons,
			$docContent
		);
		$content .= $this->doc->endPage();

			// Replace content with templated content
		$this->content = $content;
	}
   /**
    * Main method of your PlugIn
    *
    * @param    string    $content: The content of the PlugIn
    * @param    array    $conf: The PlugIn Configuration
    * @return    string    The content that should be displayed on the website
    */
   function main($content, $conf)
   {
       $this->conf = $conf;
       $this->pi_setPiVarDefaults();
       $this->pi_initPIflexForm();
       // Init FlexForm configuration for plugin
       $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!
       $thePID = 0;
       // PID of the sysfolder with questions
       $resPID = 0;
       // PID of the sysfolder with results
       $nextPID = 0;
       // PID for forms
       $finalPID = 0;
       // PID for the final page
       $listPID = 0;
       // PID for highscore or poll result
       $startPID = 0;
       // PID of the startpage
       $uid = 0;
       // quiz taker UID?!
       //$firsttime = 0;            // start time of the quiz
       $elapseTime = 0;
       // intval($this->conf['quizTimeMinutes'])*60;            // Verflossene Zeit in Sekunden
       $joker1 = 0;
       // Joker used?
       $joker2 = 0;
       $joker3 = 0;
       $startPage = false;
       // start page which asks only for user data?
       $questionPage = false;
       // question page?
       $answerPage = false;
       // answer page?
       $finalPage = false;
       // final page reached?
       $noQuestions = false;
       // no more questions?
       $secondVisit = false;
       // quiz already solved?
       $sendMail = false;
       // email should be send?
       $error = false;
       // was there an error?
       $nextCat = '';
       // global next category
       $catArray = array();
       // array with category names
       $oldLoaded = false;
       // old data loaded
       // global $TSFE;
       $this->lang = intval($GLOBALS['TSFE']->config['config']['sys_language_uid']);
       $this->copyFlex();
       // copy Felxform-Variables to this->conf
       $this->tableAnswers = $this->conf['tableAnswers'] == 'tx_myquizpoll_voting' ? 'tx_myquizpoll_voting' : 'tx_myquizpoll_result';
       if ($this->conf['enableCaptcha'] && t3lib_extMgm::isLoaded('sr_freecap')) {
           // load Captcha: Anti-Spam-Tool ??? only if enabled (16.10.2009)
           require_once t3lib_extMgm::extPath('sr_freecap') . 'pi2/class.tx_srfreecap_pi2.php';
           $this->freeCap = t3lib_div::makeInstance('tx_srfreecap_pi2');
       }
       // TODO: Rekursiv-Flag berücksichtigen!
       if (!($this->cObj->data['pages'] == '')) {
           // PID (eine oder mehrere)
           $thePID = $this->cObj->data['pages'];
       } elseif (!($this->conf['sysPID'] == '')) {
           $thePID = preg_replace('/[^0-9,]/', '', $this->conf['sysPID']);
       } else {
           $thePID = $GLOBALS["TSFE"]->id;
       }
       $resPID = $this->conf['resultsPID'] ? intval($this->conf['resultsPID']) : $thePID;
       $resPIDs = preg_replace('/[^0-9,]/', '', $resPID);
       // für den Highscore werden ggf. alle PIDs gebraucht
       if (strstr($resPID, ',')) {
           // wenn mehrere Ordner ausgewählt, nimm den ersten
           $tmp = explode(",", $resPID);
           $resPID = intval(trim($tmp[0]));
       }
       $nextPID = $this->conf['nextPID'] ? intval($this->conf['nextPID']) : $GLOBALS['TSFE']->id;
       $finalPID = $this->conf['finalPID'] ? intval($this->conf['finalPID']) : $GLOBALS['TSFE']->id;
       // oder $nextPID;
       $listPID = $this->conf['listPID'] ? intval($this->conf['listPID']) : $GLOBALS['TSFE']->id;
       // oder $finalPID;
       $startPID = intval($this->conf['startPID']);
       if ($this->conf['answerChoiceMax']) {
           // antworten pro fragen
           $this->answerChoiceMax = intval($this->conf['answerChoiceMax']);
       }
       if (!$this->conf['myVars.']['separator']) {
           // separator bei den myVars
           $this->conf['myVars.']['separator'] = ',';
       }
       mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
       // Seed random number generator
       //$this->local_cObj = t3lib_div::makeInstance("tslib_cObj");    // Local cObj
       // Get post parameters: Submited Quiz-data
       if ($this->conf['CMD'] == 'archive') {
           $this->conf['ignoreSubmit'] = true;
       }
       // submits in diesen Fällen igonieren
       $quizData = array();
       if (is_array(t3lib_div::_GP($this->prefixId)) && !$this->conf['ignoreSubmit']) {
           if (is_array(t3lib_div::_POST($this->prefixId))) {
               $quizData = t3lib_div::_POST($this->prefixId);
           } else {
               $quizData = t3lib_div::_GET($this->prefixId);
           }
           //$quizData = t3lib_div::slashArray(t3lib_div::GPvar($this->prefixId),"strip"); // deprecated
           if ($quizData['cmd'] == '') {
               $quizData['cmd'] = $this->conf['CMD'];
           } elseif ($quizData['cmd'] == 'allanswers') {
               // or $quizData['cmd']=='score' or $quizData['cmd']=='list'
               $quizData['cmd'] = '';
               // for security reasons we want that users can´t see everything
           }
       } else {
           $quizData['cmd'] = $this->conf['CMD'];
           // get the CMD from the backend
       }
       if ($quizData["name"]) {
           $quizData["name"] = htmlspecialchars($quizData["name"]);
       }
       if ($quizData["email"]) {
           $quizData["email"] = htmlspecialchars($quizData["email"]);
       }
       if ($quizData["homepage"]) {
           $quizData["homepage"] = htmlspecialchars($quizData["homepage"]);
       }
       // Zurück navigieren?
       $back = intval($quizData["back"]);
       $back_hit = intval($quizData["back-hit"]);
       if ($back_hit) {
           $quizData['cmd'] = '';
       }
       $seite = 0;
       if ($this->tableAnswers == 'tx_myquizpoll_voting') {
           $this->conf['allowBack'] = 0;
       }
       // Load template
       $tempPath = $this->initTemplate();
       // Marker values
       $statisticsArray = array();
       $markerArray = array();
       $subpartArray = array();
       $wrappedSubpartArray = array();
       $markerArrayP = array();
       $markerArrayQ = array();
       $markerArrayP["###REF_HIGHSCORE###"] = '';
       $markerArrayP["###REF_HIGHSCORE_URL###"] = '';
       $markerArrayP["###REF_POLLRESULT_URL###"] = '';
       $markerArrayP["###REF_QUIZ_ANALYSIS###"] = '';
       $markerArrayP["###REF_NO_MORE###"] = '';
       $markerArrayP["###REF_ERRORS###"] = '';
       $markerArrayP["###REF_RES_ERRORS###"] = '';
       $markerArrayP["###REF_JOKERS###"] = '';
       $markerArrayP["###REF_QUESTIONS###"] = '';
       $markerArrayP["###REF_QRESULT###"] = '';
       $markerArrayP["###REF_INTRODUCTION###"] = '';
       $markerArrayP["###REF_QPOINTS###"] = '';
       $markerArrayP["###REF_SKIPPED###"] = '';
       $markerArrayP["###REF_NEXT###"] = '';
       $markerArrayP["###REF_POLLRESULT###"] = '';
       $markerArrayP["###SUBMIT_JSC###"] = '';
       $markerArrayP["###PREFIX###"] = $this->prefixId;
       $markerArrayP["###FORM_URL###"] = $this->pi_getPageLink($nextPID);
       $markerArrayP["###NO_NEGATIVE###"] = intval($this->conf['noNegativePoints']);
       $markerArrayP["###REMOTE_IP###"] = intval($this->conf['remoteIP']);
       $markerArrayP["###BLOCK_IP###"] = $this->conf['blockIP'];
       $markerArrayQ["###PREFIX###"] = $this->prefixId;
       $markerArray["###PREFIX###"] = $this->prefixId;
       $markerArray["###FORM_URL###"] = $markerArrayP["###FORM_URL###"];
       $markerArrayP["###VAR_RESPID###"] = $resPID;
       $markerArrayP["###VAR_LANG###"] = $this->lang;
       $markerArrayP["###VAR_NOW###"] = $markerArray["###VAR_NOW###"] = time() + 1;
       // kleiner Zeitvorsprung (Seite muss ja geladen werden)
       $markerArray["###NAME###"] = $this->pi_getLL('name', 'name');
       $markerArray["###EMAIL###"] = $this->pi_getLL('email', 'email');
       $markerArray["###HOMEPAGE###"] = $this->pi_getLL('homepage', 'homepage');
       $markerArray["###GO_ON###"] = $this->pi_getLL('go_on', 'go_on');
       $markerArray["###SUBMIT###"] = $this->pi_getLL('submit', 'submit');
       $markerArray["###RESET###"] = $this->pi_getLL('reset', 'reset');
       $markerArray["###GO_BACK###"] = $this->pi_getLL('back', 'back');
       $markerArray["###CORRECT_ANSWERS###"] = $this->pi_getLL('correct_answers', 'correct_answers');
       $markerArray["###EXPLANATION###"] = $this->pi_getLL('listFieldHeader_explanation', 'listFieldHeader_explanation');
       //$markerArray["###VAR_ADDRESS_UID###"] = $quizData["address_uid"] = 0;
       $markerArray["###VAR_CATEGORY###"] = '';
       $markerArray["###VAR_NEXT_CATEGORY###"] = '';
       $markerArray["###VAR_TOTAL_POINTS###"] = '';
       $markerArray["###VAR_QUESTIONS_CORRECT###"] = '';
       $markerArray["###VAR_QUESTIONS_FALSE###"] = '';
       $markerArray["###VAR_QUESTIONS_ANSWERED###"] = 0;
       //if ($this->conf['enforceSelection']) {
       $markerArrayP["###QUESTION###"] = $this->pi_getLL('listFieldHeader_name', 'listFieldHeader_name');
       $markerArrayP["###MISSING_ANSWER###"] = $this->pi_getLL('missing_answer', 'missing_answer');
       //}
       if ($this->conf['pageTimeSeconds'] || $this->conf['quizTimeMinutes']) {
           $markerArray["###TIME_UP1###"] = $this->pi_getLL('time_up1', 'time_up1');
           $markerArray["###LIMIT1A###"] = $this->pi_getLL('limit1a', 'limit1a');
           $markerArray["###LIMIT1B###"] = $this->pi_getLL('limit1b', 'limit1b');
           $markerArray["###TIME_UP2###"] = $this->pi_getLL('time_up2', 'time_up2');
           $markerArray["###LIMIT2A###"] = $this->pi_getLL('limit2a', 'limit2a');
           $markerArray["###LIMIT2B###"] = $this->pi_getLL('limit2b', 'limit2b');
           $markerArray["###SECONDS###"] = $this->pi_getLL('seconds', 'seconds');
           $markerArray["###MINUTES###"] = $this->pi_getLL('minutes', 'minutes');
       }
       // Link to the Highscore list
       $urlParameters = array("tx_myquizpoll_pi1[cmd]" => "score", "tx_myquizpoll_pi1[qtuid]" => intval($quizData['qtuid']), "no_cache" => "1");
       $markerArray["###HIGHSCORE_URL###"] = $this->pi_linkToPage($this->pi_getLL('highscore_url', 'highscore_url'), $listPID, $target = '', $urlParameters);
       // Jokers and Details
       if ($this->conf['useJokers'] && $this->conf['pageQuestions'] == 1 || $this->conf['showDetailAnswers']) {
           /*
            *  Instantiate the xajax object and configure it
            */
           require_once t3lib_extMgm::extPath('xajax') . 'class.tx_xajax.php';
           // Include xaJax
           $this->xajax = t3lib_div::makeInstance('tx_xajax');
           // Make the instance
           # $this->xajax->setRequestURI('xxx');         // nothing to set, we send to the same URI
           # $this->xajax->decodeUTF8InputOn(); // Decode form vars from utf8 ???
           # $this->xajax->setCharEncoding('utf-8'); // Encode of the response to utf-8 ???
           $this->xajax->setWrapperPrefix($this->prefixId);
           // To prevent conflicts, prepend the extension prefix
           $this->xajax->statusMessagesOff();
           // messages in the status bar?
           $this->xajax->debugOff();
           // Turn only on during testing
           if ($this->conf['useJokers']) {
               $this->xajax->registerFunction(array('getAjaxData', &$this, 'getAjaxData'));
           }
           // Register the names of the PHP functions you want to be able to call through xajax - $xajax->registerFunction(array('functionNameInJavascript', &$object, 'methodName'));
           if ($this->conf['showDetailAnswers']) {
               $this->xajax->registerFunction(array('getAjaxDetails', &$this, 'getAjaxDetails'));
           }
           $this->xajax->processRequests();
           // If this is an xajax request, call our registered function, send output and exit
           $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId . '_2'] = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('xajax'));
           // Else create javascript and add it to the header output
           $markerArrayJ = array();
           $markerArrayJ["###PREFIX###"] = $this->prefixId;
           $markerArrayJ["###USE_JOKERS###"] = $this->pi_getLL('use_jokers', 'use_jokers');
           $markerArrayJ["###ANSWER_JOKER###"] = $this->pi_getLL('answer_joker', 'answer_joker');
       }
       // Init
       $no_rights = 0;
       // second entry of the quiz taker or not logged in if requiered?
       $captchaError = false;
       // wrong Captcha?
       //        $leftQuestions = 0;        // no. of questions to be shown
       $whereAnswered = '';
       // questions that have been allready answered (UIDs)
       $whereSkipped = '';
       // questions that have been skipped (UIDs)
       $content = '';
       // content to be shown
       $this->helperObj = t3lib_div::makeInstance('tx_myquizpoll_helper', $thePID, $this->lang, $this->answerChoiceMax, $this->tableQuestions, $this->tableAnswers, $this->tableRelation, $this->conf);
       // enable dev logging if set
       if (TYPO3_DLOG || $this->conf['debug']) {
           $this->helperObj->writeDevLog = TRUE;
           t3lib_div::devLog('UID: ' . $this->cObj->data['uid'] . '; language: ' . $this->lang . '; use cookies: ' . $this->conf['useCookiesInDays'] . '; use ip-check: ' . $this->conf['doubleEntryCheck'] . '; path to template: ' . $tempPath, $this->extKey, 0);
       }
       // set some session-variables
       if (!$this->conf['isPoll'] && $quizData['cmd'] == '' && !$quizData['qtuid']) {
           $this->helperObj->setQuestionsVars();
       }
       // what to display?
       switch ($quizData['cmd']) {
           case 'archive':
               if ($this->conf['isPoll']) {
                   /* Display only a list of old polls	*/
                   return $this->pi_wrapInBaseClass($this->showPollArchive($listPID, $thePID, $resPID));
               }
           case 'list':
               if (is_numeric($quizData['qid'])) {
                   /* Display an old poll	*/
                   return $this->pi_wrapInBaseClass($this->showPollResult('', $quizData, $thePID, $resPID));
               }
               // Andere Fälle später entscheiden
       }
       // get the startPID of a solved quiz
       if (!$startPID) {
           $startPID = $this->helperObj->getStartUid($quizData['qtuid']);
       }
       $quiz_name = $this->conf['quizName'];
       if (!$quiz_name) {
           $quiz_name = $this->helperObj->getPageTitle($startPID);
       }
       $markerArrayP["###QUIZ_NAME###"] = $markerArray["###QUIZ_NAME###"] = $quiz_name;
       //if ($this->conf['startCategory']) {        // Kategorie-Namen zwischenspeichern
       $res6 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,name,celement,pagetime', $this->tableCategory, 'pid IN (' . $thePID . ')');
       $catCount = $GLOBALS['TYPO3_DB']->sql_num_rows($res6);
       if ($catCount > 0) {
           while ($row6 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res6)) {
               $catUID = $row6['uid'];
               $this->catArray[$catUID] = array();
               $this->catArray[$catUID]['name'] = $row6['name'];
               $this->catArray[$catUID]['celement'] = $row6['celement'];
               $this->catArray[$catUID]['pagetime'] = $row6['pagetime'];
           }
           if ($this->helperObj->writeDevLog) {
               t3lib_div::devLog($catCount . ' categories found.', $this->extKey, 0);
           }
       }
       $GLOBALS['TYPO3_DB']->sql_free_result($res6);
       //}
       // check, if logged in
       if ($this->conf['loggedInCheck'] && ($quizData['cmd'] != 'score' && $quizData['cmd'] != 'list') && !$GLOBALS['TSFE']->loginUser) {
           $no_rights = 1;
           // noname user is (b)locked now
           $markerArray["###NOT_LOGGEDIN###"] = $this->pi_getLL('not_loggedin', 'not_loggedin');
           $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_NOT_LOGGEDIN###");
           $content .= $this->cObj->substituteMarkerArray($template, $markerArray);
           // Sonderfall !!!
           if ($this->helperObj->writeDevLog) {
               t3lib_div::devLog('Loggin check failes!', $this->extKey, 0);
           }
       }
       $quiz_taker_ip_address = preg_replace('/[^0-9\\.]/', '', $this->helperObj->getRealIpAddr());
       // Ignore all sumbits and old data?
       if (!$this->conf['ignoreSubmit']) {
           // check for second entry ( based on the ip-address )
           if ($this->conf['doubleEntryCheck'] && ($quizData['cmd'] != 'score' && $quizData['cmd'] != 'list') && !$quizData['qtuid'] && $no_rights == 0) {
               $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp, uid', $this->tableAnswers, 'pid=' . $resPID . " AND ip='" . $quiz_taker_ip_address . "' AND sys_language_uid=" . $this->lang, '', 'tstamp DESC', '1');
               $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
               if ($rows > 0) {
                   // DB entry found for current user?
                   $fetchedRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5);
                   $dateOld = $fetchedRow['tstamp'];
                   if ($this->helperObj->writeDevLog) {
                       t3lib_div::devLog('Entry found for IP ' . $quiz_taker_ip_address . ': ' . $fetchedRow['uid'], $this->extKey, 0);
                   }
                   $period = intval($this->conf['doubleEntryCheck']);
                   // seconds
                   if ($period < 10000) {
                       $period *= 60 * 60 * 24;
                   }
                   // days
                   //if ($period==1) $period = 50000;        // approx. a half day is the quiz blocked for the same ip-address
                   if (time() - $dateOld < $period) {
                       if ($this->conf['doubleCheckMode'] || $this->conf['secondPollMode']) {
                           $quizData['qtuid'] = intval($fetchedRow['uid']);
                           $quizData['cmd'] = 'next';
                           $quizData['secondVisit'] = 1;
                           $secondVisit = true;
                           if ($this->helperObj->writeDevLog) {
                               t3lib_div::devLog('IP-check: cmd to next changed, because doubleCheckMode=' . $this->conf['doubleCheckMode'] . ', secondPollMode=' . $this->conf['secondPollMode'], $this->extKey, 0);
                           }
                       } else {
                           $no_rights = 1;
                           // user is (b)locked now
                           $markerArray["###DOUBLE_ENTRY###"] = $this->pi_getLL('double_entry', 'double_entry');
                           $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_DOUBLE_ENTRY###");
                           $content .= $this->cObj->substituteMarkerArray($template, $markerArray);
                           // Sonderfall !!!
                           if ($this->helperObj->writeDevLog) {
                               t3lib_div::devLog('User is blocked (ip-check), because doubleCheckMode=' . $this->conf['doubleCheckMode'] . ', secondPollMode=' . $this->conf['secondPollMode'], $this->extKey, 0);
                           }
                       }
                   }
                   $GLOBALS['TYPO3_DB']->sql_free_result($res5);
                   //$oldLoaded = true;
               }
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('IP check for qtuid=' . $quizData['qtuid'], $this->extKey, 0);
               }
           }
           // check for second entry ( based on the fe_users-id )
           if ($this->conf['loggedInMode'] && ($quizData['cmd'] != 'score' && $quizData['cmd'] != 'list') && !$quizData['qtuid'] && $GLOBALS['TSFE']->loginUser && $this->tableAnswers == 'tx_myquizpoll_result' && $no_rights == 0) {
               $fe_uid = intval($GLOBALS['TSFE']->fe_user->user['uid']);
               $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid, tstamp', $this->tableAnswers, 'pid=' . $resPID . " AND fe_uid={$fe_uid} AND sys_language_uid=" . $this->lang, '', 'tstamp DESC', '1');
               $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
               if ($rows > 0) {
                   // DB entry found for current user?
                   $fetchedRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5);
                   if ($this->conf['doubleCheckMode'] || $this->conf['secondPollMode']) {
                       $quizData['qtuid'] = intval($fetchedRow['uid']);
                       $quizData['cmd'] = 'next';
                       $secondVisit = true;
                   } else {
                       $no_rights = 1;
                       // user is (b)locked now
                       $markerArray["###DOUBLE_ENTRY###"] = $this->pi_getLL('double_entry', 'double_entry');
                       $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_DOUBLE_ENTRY###");
                       $content .= $this->cObj->substituteMarkerArray($template, $markerArray);
                       // Sonderfall !!!
                   }
                   $GLOBALS['TYPO3_DB']->sql_free_result($res5);
                   //$oldLoaded = true;
               }
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('fe_users check for qtuid=' . $quizData['qtuid'], $this->extKey, 0);
               }
           }
           // check if the captcha is OK
           if (($quizData['cmd'] == 'submit' && $this->helperObj->getAskAtQ($quizData['qtuid']) || $quizData["fromStart"] && $this->conf['userData.']['askAtStart'] || $quizData["fromFinal"] && $this->conf['userData.']['askAtFinal']) && is_object($this->freeCap) && $this->conf['enableCaptcha'] && !$this->freeCap->checkWord($quizData['captcha_response']) && $no_rights == 0) {
               if ($quizData["fromStart"] && $startPID != $GLOBALS["TSFE"]->id) {
                   // Weiterleitung zurueck zur Extra-Startseite
                   $this->redirectUrl($startPID, array($this->prefixId . '[name]' => $quizData["name"], $this->prefixId . '[email]' => $quizData["email"], $this->prefixId . '[homepage]' => $quizData["homepage"], $this->prefixId . '[captchaError]' => '1'));
                   break;
                   // hier kommt man eh nie hin...
               }
               if ($quizData["fromFinal"] && $finalPID != $GLOBALS["TSFE"]->id) {
                   // Weiterleitung zurueck zur Extra-Endseite
                   $this->redirectUrl($finalPID, array($this->prefixId . '[qtuid]' => intval($quizData["qtuid"]), $this->prefixId . '[cmd]' => 'next', $this->prefixId . '[name]' => $quizData["name"], $this->prefixId . '[email]' => $quizData["email"], $this->prefixId . '[homepage]' => $quizData["homepage"], $this->prefixId . '[captchaError]' => '1'));
                   break;
                   // hier kommt man eh nie hin...
               }
               $quizData['cmd'] = $quizData["fromStart"] ? '' : 'next';
               // "nochmal" simulieren
               //$quizData['qtuid'] = '';        // wieso wohl???
               $markerArray["###CAPTCHA_NOT_OK###"] = $this->pi_getLL('captcha_not_ok', 'captcha_not_ok');
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_CAPTCHA_NOT_OK###");
               $markerArrayP["###REF_ERRORS###"] .= $this->cObj->substituteMarkerArray($template, $markerArray);
               // instead of $content
               //if ($quizData["fromStart"])
               $quizData["fromStart"] = 0;
               // nichts wurde getan simulieren
               $quizData["fromFinal"] = 0;
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('captcha check 1 not ok.', $this->extKey, 0);
               }
               $error = true;
               $captchaError = true;
           } else {
               if ($quizData["captchaError"]) {
                   $markerArray["###CAPTCHA_NOT_OK###"] = $this->pi_getLL('captcha_not_ok', 'captcha_not_ok');
                   $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_CAPTCHA_NOT_OK###");
                   $markerArrayP["###REF_ERRORS###"] .= $this->cObj->substituteMarkerArray($template, $markerArray);
                   // instead of $content
                   if ($this->helperObj->writeDevLog) {
                       t3lib_div::devLog('captcha check 2 not ok.', $this->extKey, 0);
                   }
                   $error = true;
                   $captchaError = true;
               }
           }
           // check if used IP is blocked
           if ($quizData['cmd'] == 'submit' && $this->conf['blockIP']) {
               $ips = explode(',', $this->conf['blockIP']);
               foreach ($ips as $aip) {
                   $len = strlen(trim($aip));
                   if (substr($quiz_taker_ip_address, 0, $len) == trim($aip)) {
                       //$markerArray["###IP_BLOCKED###"] = $this->pi_getLL('ip_blocked','ip_blocked');
                       //$template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_IP_BLOCKED###");
                       $markerArrayP["###REF_ERRORS###"] .= 'Your IP is blocked!';
                       //$this->cObj->substituteMarkerArray($template, $markerArray);
                       if ($this->helperObj->writeDevLog) {
                           t3lib_div::devLog('IP ' . $quiz_taker_ip_address . ' blocked!', $this->extKey, 0);
                       }
                       $error = true;
                       $no_rights = 1;
                   }
               }
           }
           // read quiz takers old data
           $answeredQuestions = '';
           // prev. answered Question(s)
           $skipped = '';
           $cids = '';
           $fids = '';
           if (($this->conf['useCookiesInDays'] && !$quizData['qtuid'] || $quizData['cmd'] == 'next' || $quizData['cmd'] == 'submit' && !$this->conf['isPoll'] && ($this->conf['dontShowPoints'] != 1 || $this->conf['quizTimeMinutes'])) && $no_rights == 0) {
               $cookieRead = false;
               if (!$quizData['qtuid'] && $this->conf['useCookiesInDays']) {
                   // !($quizData['cmd']  == 'next' || $quizData['cmd']  == 'submit')) warum das nur? auskommentiert am 27.12.2009
                   $cookieName = $this->getCookieMode($resPID, $thePID);
                   if ($this->conf['allowCookieReset'] && $quizData["resetcookie"]) {
                       setcookie($cookieName, "", time() - 3600);
                       if ($this->helperObj->writeDevLog) {
                           t3lib_div::devLog('Cookie reseted: ' . $cookieName, $this->extKey, 0);
                       }
                   } else {
                       if ($this->conf['useCookiesInDays']) {
                           $quizData['qtuid'] = intval($_COOKIE[$cookieName]);
                           // read quiz taker UID from a cookie
                           if ($quizData['qtuid']) {
                               $cookieRead = true;
                           }
                           if ($this->helperObj->writeDevLog) {
                               t3lib_div::devLog('Cookie read: ' . $cookieName . '=' . $quizData['qtuid'], $this->extKey, 0);
                           }
                           // oder? $HTTP_COOKIE_VARS["myquizpoll".$resPID];    oder?  $GLOBALS["TSFE"]->fe_user->getKey("ses","myquizpoll".$resPID);
                       }
                   }
               }
               if ($quizData['qtuid'] && $this->tableAnswers == 'tx_myquizpoll_result') {
                   // load solved questions and quiz takers name, email, homepage, old points and last time
                   $uid = intval($quizData['qtuid']);
                   $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('name, email, homepage, qids,sids,cids,fids, p_or_a, p_max, percent, o_max, o_percent, firsttime, joker1,joker2,joker3, lastcat,nextcat', $this->tableAnswers, 'uid=' . $uid . ' AND sys_language_uid=' . $this->lang);
                   //.' '.$this->cObj->enableFields($this->tableAnswers), auskommentiert am 7.11.10
                   $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
                   if ($rows > 0) {
                       // DB entry found for current user?
                       $fetchedRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5);
                       $answeredQuestions = $fetchedRow['qids'];
                       if (!$this->conf["isPoll"]) {
                           $skipped = $fetchedRow['sids'];
                           $joker1 = $fetchedRow['joker1'];
                           $joker2 = $fetchedRow['joker2'];
                           $joker3 = $fetchedRow['joker3'];
                           $firsttime = intval($fetchedRow['firsttime']);
                           $this->helperObj->setFirstTime($uid, $firsttime);
                           if ($answeredQuestions) {
                               // 2.9.10: beantwortete poll-frage muss man auch speichern???
                               if ($fetchedRow['nextcat']) {
                                   $nextCat = $fetchedRow['nextcat'];
                                   if ($this->conf['startCategory']) {
                                       $this->conf['startCategory'] = $nextCat;
                                   }
                                   // kategorie der naechsten frage...
                               }
                               if ($quizData['cmd'] != 'submit') {
                                   // namen nicht ueberschreiben
                                   $whereAnswered = ' AND uid NOT IN (' . preg_replace('/[^0-9,]/', '', $answeredQuestions) . ')';
                                   // exclude answered questions next time
                                   if (!($quizData["name"] || $quizData["email"] || $quizData["homepage"])) {
                                       $quizData["name"] = $fetchedRow['name'];
                                       // abgesendete daten nicht mit default-werten ueberschreiben!
                                       $quizData["email"] = $fetchedRow['email'];
                                       $quizData["homepage"] = $fetchedRow['homepage'];
                                   }
                                   //$markerArray["###VAR_ADDRESS_UID###"] = $quizData["address_uid"] = $fetchedRow['address_uid'];
                               }
                               $markerArray["###VAR_TOTAL_POINTS###"] = intval($fetchedRow['p_or_a']);
                               // save total points for the case there are no more questions
                               $markerArray["###VAR_TMAX_POINTS###"] = intval($fetchedRow['p_max']);
                               $markerArray["###VAR_TMISSING_POINTS###"] = intval($fetchedRow['p_max']) - intval($fetchedRow['p_or_a']);
                               $markerArray["###VAR_PERCENT###"] = intval($fetchedRow['percent']);
                               $markerArray["###VAR_OMAX_POINTS###"] = intval($fetchedRow['o_max']);
                               $markerArray["###VAR_OVERALL_PERCENT###"] = intval($fetchedRow['o_percent']);
                               $markerArray["###VAR_QUESTIONS_ANSWERED###"] = $fetchedRow['qids'] ? substr_count($fetchedRow['qids'], ',') + 1 : 0;
                               if ($fetchedRow['cids'] || $fetchedRow['fids']) {
                                   // if weglassen?
                                   $markerArray["###VAR_QUESTIONS_CORRECT###"] = $fetchedRow['cids'] ? substr_count($fetchedRow['cids'], ',') + 1 : 0;
                                   $markerArray["###VAR_QUESTIONS_FALSE###"] = $fetchedRow['fids'] ? substr_count($fetchedRow['fids'], ',') + 1 : 0;
                               }
                               $markerArray["###VAR_CATEGORY###"] = $this->catArray[$row['lastcat']]['name'];
                               $markerArray["###VAR_NEXT_CATEGORY###"] = $this->catArray[$row['nextcat']]['name'];
                               $elapseTime = time() - $firsttime;
                           }
                           if ($skipped && $quizData['cmd'] != 'submit') {
                               $whereSkipped = ' AND uid NOT IN (' . preg_replace('/[^0-9,]/', '', $skipped) . ')';
                               // exclude skipped questions next time
                           }
                       }
                       if ($cookieRead) {
                           $secondVisit = true;
                       }
                       // es wurde erfolgreich ein cookie gelesen
                   }
                   $GLOBALS['TYPO3_DB']->sql_free_result($res5);
               } else {
                   if ($quizData['qtuid']) {
                       // load solved poll question from voting-table
                       $uid = intval($quizData['qtuid']);
                       $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('question_id', $this->tableAnswers, 'uid=' . $uid . ' AND sys_language_uid=' . $this->lang);
                       if ($GLOBALS['TYPO3_DB']->sql_num_rows($res5) > 0) {
                           $fetchedRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5);
                           $answeredQuestions = $fetchedRow['question_id'];
                           if ($cookieRead) {
                               $secondVisit = true;
                           }
                       }
                       $GLOBALS['TYPO3_DB']->sql_free_result($res5);
                   } else {
                       if ($this->conf['quizTimeMinutes'] && $quizData["time"]) {
                           $elapseTime = time() - intval($quizData["time"]);
                           // before saving data
                       }
                   }
               }
               if ($quizData['qtuid'] && $this->conf["isPoll"] && $this->conf["secondPollMode"] == 1) {
                   $quizData['cmd'] = 'list';
                   if ($this->helperObj->writeDevLog) {
                       t3lib_div::devLog("changing to list mode", $this->extKey, 0);
                   }
               }
               if ($quizData['qtuid']) {
                   $oldLoaded = true;
               }
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog("Old data loaded with uid {$uid}: {$answeredQuestions} / {$whereAnswered} / {$whereSkipped}", $this->extKey, 0);
               }
           }
       }
       $markerArrayP["###QTUID###"] = intval($quizData['qtuid']);
       // check, if quiz is cancled
       if ($this->conf['quizTimeMinutes'] && intval($this->conf['quizTimeMinutes']) * 60 - $elapseTime <= 0) {
           // oder $quizData['cancel'] == 1 ) {
           $markerArray["###REACHED1###"] = $this->pi_getLL('reached1', 'reached1');
           $markerArray["###REACHED2###"] = $this->pi_getLL('reached2', 'reached2');
           $markerArray["###SO_FAR_REACHED1###"] = $this->pi_getLL('so_far_reached1', 'so_far_reached1');
           $markerArray["###SO_FAR_REACHED2###"] = $this->pi_getLL('so_far_reached2', 'so_far_reached2');
           $markerArray["###QUIZ_END###"] = $this->pi_getLL('quiz_end', 'quiz_end');
           $markerArray["###RESTART_QUIZ###"] = $this->pi_linkToPage($this->pi_getLL('restart_quiz', 'restart_quiz'), $startPID, $target = '', array());
           $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_END###");
           $content .= $this->cObj->substituteMarkerArray($template, $markerArray);
           // sonderfall !!!
           if ($this->conf['finalWhenCancel']) {
               $noQuestions = true;
           } else {
               if ($this->conf['highscore.']['showAtFinal']) {
                   $quizData['cmd'] = 'score';
                   // show highscore
               } else {
                   $quizData['cmd'] = 'exit';
                   // display no more questions
               }
               $no_rights = 1;
               // cancel all
           }
           if ($this->helperObj->writeDevLog) {
               t3lib_div::devLog("cancel check: {$no_rights}/" . $quizData['cmd'], $this->extKey, 0);
           }
       }
       // show only a start page?
       if ($this->conf['userData.']['askAtStart'] && !$quizData['qtuid'] && !$quizData['cmd'] && !$quizData["fromStart"]) {
           // show only "ask for user data"?
           $startPage = true;
           $quizData['cmd'] = 'start';
       }
       // next page is a page with questions...
       if ($quizData['cmd'] == 'next') {
           $quizData['cmd'] = '';
       }
       if ($quizData['cmd'] == 'submit' && !$this->conf['ignoreSubmit'] && $no_rights == 0) {
           /* ***************************************************** */
           /*
            * Display result page: answers and points
            */
           if (!$this->conf["isPoll"]) {
               // neu seit 20.2.2011
               // Check quiz taker name and email
               if (trim($quizData["name"]) == "") {
                   $quizData["name"] = $this->pi_getLL('no_name', 'no_name');
               }
               if (!t3lib_div::validEmail(trim($quizData["email"]))) {
                   $quizData["email"] = $this->pi_getLL('no_email', 'no_email');
               }
               // Avoid bad characters in database request
               $quiz_taker_name = $GLOBALS['TYPO3_DB']->quoteStr($quizData['name'], $this->tableAnswers);
               $quiz_taker_email = $GLOBALS['TYPO3_DB']->quoteStr($quizData['email'], $this->tableAnswers);
               $quiz_taker_homepage = $GLOBALS['TYPO3_DB']->quoteStr($quizData['homepage'], $this->tableAnswers);
               $markerArray["###REAL_NAME###"] = $quiz_taker_name;
               $markerArray["###REAL_EMAIL###"] = $quiz_taker_email;
               $markerArray["###REAL_HOMEPAGE###"] = $quiz_taker_homepage;
               $markerArray["###RESULT_FOR###"] = $this->pi_getLL('result_for', 'result_for');
               if ($quiz_taker_email == $this->pi_getLL('no_email', 'no_email')) {
                   $quiz_taker_email = '';
               }
               if ($quiz_taker_homepage == $this->pi_getLL('no_homepage', 'no_homepage')) {
                   $quiz_taker_homepage = '';
               }
           }
           $markerArray["###THANK_YOU###"] = $this->pi_getLL('thank_you', 'thank_you');
           if (!$this->conf['isPoll']) {
               $markerArray["###RES_QUESTION_POINTS###"] = $this->pi_getLL('result_question_points', 'result_question_points');
               $markerArray["###VAR_QUESTIONS###"] = $this->helperObj->getQuestionsNo();
               if ($whereAnswered) {
                   $markerArray["###VAR_QUESTION###"] = $this->helperObj->getQuestionNo($whereAnswered);
               } else {
                   $markerArray["###VAR_QUESTION###"] = $this->helperObj->getQuestionNo('-');
               }
           }
           // Begin HTML output
           $template_qr = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QRESULT###");
           // full template
           if (!$this->conf["isPoll"]) {
               // neu seit 20.2.2011
               $template_answer = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QR_CORR###");
               $template_okok = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QR_CORR_ANSW###");
               $template_oknot = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QR_CORR_NOTANSW###");
               $template_notok = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QR_NOTCORR_ANSW###");
               $template_notnot = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QR_NOTCORR_NOTANSW###");
               $template_qr_points = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QR_POINTS###");
               $template_expl = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_EXPLANATION###");
           }
           $template_delimiter = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_DELIMITER###");
           $template_image_begin = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUESTION_IMAGE_BEGIN###");
           $template_image_end = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUESTION_IMAGE_END###");
           // Get the answers from the user
           $answerArray = array();
           $questionNumber = 1;
           $lastUIDs = '';
           $whereUIDs = '';
           $whereCat = '';
           if ($this->conf['onlyCategories']) {
               $whereCat = " AND category IN (" . preg_replace('/[^0-9,]/', '', $this->conf['onlyCategories']) . ")";
           }
           while ($quizData['uid' . $questionNumber]) {
               $answerArray[$questionNumber] = $quizData['uid' . $questionNumber];
               $lastUIDs .= ',' . intval($quizData['uid' . $questionNumber]);
               $questionNumber++;
           }
           $maxQuestions = $questionNumber - 1;
           if ($lastUIDs) {
               $whereUIDs = ' AND uid IN (' . substr($lastUIDs, 1) . ')';
               //}    // kgb: geaendert am 6.9.2010
               // Get questions from the database
               $questionsArray = array();
               $tempNumber = 0;
               $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->tableQuestions, 'pid IN (' . $thePID . ')' . $whereUIDs . $whereCat . ' AND sys_language_uid=' . $this->lang . ' ' . $this->cObj->enableFields($this->tableQuestions));
               $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
               if ($rows > 0) {
                   while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5)) {
                       $tempNumber = $row['uid'];
                       // save the uid for each question
                       $questionsArray[$tempNumber] = $row;
                       // save each question
                   }
               }
               $GLOBALS['TYPO3_DB']->sql_free_result($res5);
           }
           $points = 0;
           // points from the user (quiz taker)
           $maxPoints = 0;
           // maximum points reachable per page
           $maxTotal = 0;
           // maximum total points reachable
           $percent = 0;
           // 100 * reached points / total points
           $overallMaximum = 0;
           // overall points of all questions
           $overallPercent = 0;
           // overall percent
           $questionUID = 0;
           // uid of a question
           $answered = '';
           // uids of answered questions
           $skipped = '';
           // uids of skipped questions
           $correctAnsw = '';
           // uids of correct answered question
           $falseAnsw = '';
           // uids of false answered question
           $skippedCount = 0;
           // no. of skipped questions at this page
           $imgTSConfig = array();
           // image values
           if (is_array($this->conf['jokers.'])) {
               $halvePoints = $this->conf['jokers.']['halvePoints'];
           } else {
               $halvePoints = 0;
           }
           // Old questions and answers
           for ($questionNumber = 1; $questionNumber < $maxQuestions + 1; $questionNumber++) {
               $questionUID = intval($answerArray[$questionNumber]);
               $row = $questionsArray[$questionUID];
               $markerArray["###VAR_QUESTION_NUMBER###"] = $questionNumber;
               if ($this->conf['isPoll']) {
                   // link to the result page
                   $urlParameters = array("tx_myquizpoll_pi1[cmd]" => "list", "tx_myquizpoll_pi1[qid]" => $questionUID, "no_cache" => "1");
                   $markerArray["###POLLRESULT_URL###"] = $this->pi_linkToPage($this->pi_getLL('poll_url', 'poll_url'), $listPID, $target = '', $urlParameters);
               } else {
                   if ($quizData['answer' . $questionNumber] == -1) {
                       $skipped .= ',' . $questionUID;
                       $skippedCount++;
                       continue;
                   }
               }
               //$answerPointsBool = false;
               $answered .= ',' . $questionUID;
               // nach unten geschoben...
               $questionPoints = 0;
               $maxQuestionPoints = 0;
               $markerArray["###VAR_QUESTION###"]++;
               $nextCat = '';
               $lastCat = $row['category'];
               if ($this->catArray[$lastCat]) {
                   $markerArray["###VAR_CATEGORY###"] = $this->catArray[$lastCat]['name'];
               }
               // Output the result/explanations
               if (!($this->conf['dontShowCorrectAnswers'] && $this->conf['dontShowPoints'] == 1) || $this->conf['startCategory'] || $this->conf['advancedStatistics'] || $this->conf['showAllCorrectAnswers'] || $this->conf['isPoll']) {
                   if ($row['image']) {
                       // && (substr_count($template_qr, 'REF_QUESTION_IMAGE_BEGIN')>0)) {
                       $markerArray["###VAR_QUESTION_IMAGE###"] = $this->helperObj->getImage($row['image'], $row["alt_text"]);
                       $markerArray["###REF_QUESTION_IMAGE_BEGIN###"] = $this->cObj->substituteMarkerArray($template_image_begin, $markerArray);
                       $markerArray["###REF_QUESTION_IMAGE_END###"] = $template_image_end;
                   } else {
                       $markerArray["###REF_QUESTION_IMAGE_BEGIN###"] = '';
                       $markerArray["###REF_QUESTION_IMAGE_END###"] = '';
                   }
                   $markerArray["###TITLE_HIDE###"] = $row['title_hide'] ? '-hide' : '';
                   $markerArray["###VAR_QUESTION_TITLE###"] = $row['title'];
                   $markerArray["###VAR_QUESTION_NAME###"] = $this->formatStr($row['name']);
                   // $this->pi_RTEcssText($row['name']);
                   $markerArray["###VAR_ANSWER_POINTS###"] = '';
                   $markerArray["###REF_QR_ANSWER_ALL###"] = '';
                   $markerArray["###REF_QR_ANSWER_CORR###"] = '';
                   $markerArray["###REF_QR_ANSWER_CORR_ANSW###"] = '';
                   $markerArray["###REF_QR_ANSWER_CORR_NOTANSW###"] = '';
                   $markerArray["###REF_QR_ANSWER_NOTCORR_ANSW###"] = '';
                   $markerArray["###REF_QR_ANSWER_NOTCORR_NOTANSW###"] = '';
                   $markerArray["###REF_QR_POINTS###"] = '';
                   $markerArray["###VAR_QUESTION_ANSWER###"] = '';
                   $markerArray["###REF_QR_EXPLANATION###"] = '';
                   $markerArray["###REF_DELIMITER###"] = '';
                   $markerArray["###P1###"] = '';
                   $markerArray["###P2###"] = '';
                   if ($this->conf['dontShowPoints']) {
                       $markerArray["###NO_POINTS###"] = '';
                   } else {
                       $markerArray["###NO_POINTS###"] = '0';
                   }
                   if (!$this->conf['isPoll']) {
                       if (!$this->conf['dontShowPoints'] && $row['qtype'] < 5) {
                           $markerArray["###P1###"] = $this->pi_getLL('p1', 'p1');
                           $markerArray["###P2###"] = $this->pi_getLL('p2', 'p2');
                       }
                       /*    if ($this->conf['noNegativePoints']<3) {        // 20.01.10: wenn alle antworten richtig sein muessen, antwort-punkte ignorieren!
                                 for ($currentValue=1; $currentValue <= $this->answerChoiceMax; $currentValue++) {
                                     if (intval($row['points'.$currentValue])>0 ) {
                                         $answerPointsBool = true;
                                         break;        // Punkte bei Antworten gefunden...
                                     }
                                 }
                             }  am 21.01.10 auskommentiert! */
                   } else {
                       $points = $quizData['answer' . $questionNumber];
                       // points = SELECTED ANSWER !!!
                       $markerArray["###VAR_USER_ANSWER###"] = $row['answer' . $points];
                       if ($points > 0 && $row['category' . $points]) {
                           // NEU && $this->conf['startCategory']
                           $nextCat = $row['category' . $points];
                           // next category from an answer
                       }
                       break;
                       // mehr braucht man nicht bei Umfragen !!!
                   }
                   // myVars for questions
                   $markerArray = array_merge($markerArray, $this->helperObj->setQuestionVars($questionNumber));
                   $allAnswersOK = true;
                   // alle Antworten richtig beantwortet?
                   //$correctBool = false;    // gibt es ueberhaupt korrekte antworten?
                   $realCorrectBool = false;
                   // wurden ueberhaupt korrekte Antworten markiert?
                   $withAnswer = $this->conf['noAnswer'];
                   // gab es eine Antwort vom Benutzer?
                   $lastSelected = 0;
                   for ($answerNumber = 1; $answerNumber < $this->answerChoiceMax + 1; $answerNumber++) {
                       if ($row['answer' . $answerNumber] || $row['answer' . $answerNumber] === '0' || in_array($row['qtype'], $this->textType)) {
                           // was a answer set in the backend?
                           $selected = 0;
                           // was the answer selected by the quiz taker?
                           $tempAnswer = '';
                           // text for answer $answerNumber
                           // myVars for answers
                           $markerArray = array_merge($markerArray, $this->helperObj->setAnswerVars($answerNumber, $row['qtype']));
                           //if ( !$this->conf['isPoll'] ) {    // show correct answers. Bug fixed: dontShowCorrectAnswers doesnt matter here
                           if (!$this->conf['dontShowCorrectAnswers']) {
                               $markerArray["###VAR_QUESTION_ANSWER###"] = $row['answer' . $answerNumber];
                           }
                           $thisCat = $row['category' . $answerNumber];
                           if ($this->catArray[$thisCat]) {
                               $markerArray['###VAR_QA_CATEGORY###'] = $this->catArray[$thisCat]['name'];
                           }
                           if ($row['correct' . $answerNumber]) {
                               // es gibt richtige Antworten
                               $realCorrectBool = true;
                           }
                           $answerPoints = 0;
                           // answer points from the DB
                           if (!$this->conf['dontShowPoints']) {
                               //if ($answerPointsBool) {         // hier interessiert es nicht, ob eine Antwort als korrekt markiert wurde!
                               if ($this->conf['noNegativePoints'] < 3) {
                                   // das ganze Verhalten am 21.01.10 geaendert...
                                   $answerPoints = intval($row['points' . $answerNumber]);
                               }
                               if ($answerPoints > 0) {
                                   $row['correct' . $answerNumber] = true;
                                   // ACHTUNG: falls Punkte zu einer Antwort gesetzt sind, dann wird die Antwort als RICHTIG bewertet!
                               } else {
                                   $answerPoints = intval($row['points']);
                               }
                               if ($row['correct' . $answerNumber] || $row['qtype'] == 3) {
                                   if (($row['qtype'] == 0 || $row['qtype'] == 4) && $this->conf['noNegativePoints'] < 3) {
                                       // KGB, 20.01.10: weg: !$answerPointsBool || $row['qtype'] >= 3, neu: $this->conf['noNegativePoints']<3
                                       $maxQuestionPoints += $answerPoints;
                                   } else {
                                       if ($answerPoints > $maxQuestionPoints) {
                                           $maxQuestionPoints = $answerPoints;
                                       }
                                   }
                                   // bei punkten pro antwort ODER wenn nicht addiert werden soll
                               }
                               if ($row['qtype'] < 5) {
                                   $markerArray["###VAR_ANSWER_POINTS###"] = $answerPoints;
                               }
                           }
                           if ($quizData['answer' . $questionNumber . '_' . $answerNumber]) {
                               // !='') {    // type 0 und 4
                               $selected = $answerNumber;
                           } else {
                               if (($row['qtype'] > 0 && $row['qtype'] < 3 || $row['qtype'] == 7) && $quizData['answer' . $questionNumber] == $answerNumber) {
                                   $selected = $answerNumber;
                               } else {
                                   if ($row['qtype'] == 3 && $quizData['answer' . $questionNumber] != '' || $row['qtype'] == 5) {
                                       // type 3 und 5
                                       $selected = $answerNumber;
                                       // sollte 1 sein
                                   }
                               }
                           }
                           //}
                           $wrongText = 0;
                           // wrong text input?
                           /*                            if ($this->conf['isPoll']) {    // wurde aus der Schleife genommen!
                                                           $points=$quizData['answer'.$questionNumber];                        // points = SELECTED ANSWER !!!
                                                           $markerArray["###VAR_USER_ANSWER###"] .= $row['answer'.$points];
                                                       } else */
                           if ($row['qtype'] == 5 && !$this->conf['dontShowCorrectAnswers']) {
                               $markerArray["###VAR_QUESTION_ANSWER###"] = nl2br(htmlspecialchars($quizData['answer' . $questionNumber]));
                               $tempAnswer = $this->cObj->substituteMarkerArray($template_okok, $markerArray);
                               $markerArray["###REF_QR_ANSWER_CORR_ANSW###"] .= $tempAnswer;
                               // welches template soll man hier wohl nehmen?
                               if ($quizData['answer' . $questionNumber] || $quizData['answer' . $questionNumber] === 0) {
                                   $withAnswer = true;
                               }
                               if ($this->helperObj->writeDevLog) {
                                   t3lib_div::devLog($questionUID . '-' . $answerNumber . '=CORR_ANSW5->', $this->extKey, 0);
                               }
                           } else {
                               if ($selected > 0 && ($row['qtype'] == 3 && strtolower($row['answer' . $answerNumber]) == strtolower($quizData['answer' . $questionNumber]) || $row['qtype'] != 3 && $row['correct' . $answerNumber])) {
                                   // korrekte Antwort
                                   $questionPoints = $questionPoints + $answerPoints;
                                   // $row['points']; geaendert am 16.9.2009
                                   if (!$this->conf['dontShowCorrectAnswers']) {
                                       $tempAnswer = $this->cObj->substituteMarkerArray($template_okok, $markerArray);
                                       $markerArray["###REF_QR_ANSWER_CORR_ANSW###"] .= $tempAnswer;
                                   }
                                   //$correctBool = true;
                                   $withAnswer = true;
                                   if ($this->helperObj->writeDevLog) {
                                       t3lib_div::devLog($questionUID . '-' . $answerNumber . '=CORR_ANSW->' . $questionPoints, $this->extKey, 0);
                                   }
                               } else {
                                   if ($selected > 0) {
                                       // falsche Antwort
                                       $allAnswersOK = false;
                                       if ($this->conf['noNegativePoints'] != 2) {
                                           $questionPoints = $questionPoints - $answerPoints;
                                       }
                                       // $row['points']; geaendert am 16.9.2009
                                       if (!$this->conf['dontShowCorrectAnswers']) {
                                           // { added 8.8.09
                                           if ($row['qtype'] == 3) {
                                               // since 0.1.8: falsche und richtige antwort ausgeben
                                               $tempAnswer = $this->cObj->substituteMarkerArray($template_oknot, $markerArray);
                                               $markerArray["###REF_QR_ANSWER_CORR_NOTANSW###"] .= $tempAnswer;
                                               $markerArray["###VAR_QUESTION_ANSWER###"] = htmlspecialchars($quizData['answer' . $questionNumber]);
                                           }
                                           $tempAnswer2 = $this->cObj->substituteMarkerArray($template_notok, $markerArray);
                                           $markerArray["###REF_QR_ANSWER_NOTCORR_ANSW###"] .= $tempAnswer2;
                                           $tempAnswer .= $tempAnswer2;
                                           // hier gibt es 2 antworten !!!
                                       }
                                       if ($row['qtype'] == 3 && ($row['answer1'] || $row['answer1'] === '0')) {
                                           $wrongText = 1;
                                       }
                                       // for statistics: a2 statt a1 bei falscher antwort
                                       $withAnswer = true;
                                       if ($this->helperObj->writeDevLog) {
                                           t3lib_div::devLog($questionUID . '-' . $answerNumber . '=NOTCORR_ANSW->' . $questionPoints, $this->extKey, 0);
                                       }
                                   } else {
                                       if ($row['correct' . $answerNumber]) {
                                           // nicht beantwortet, waere aber richtig gewesen
                                           $allAnswersOK = false;
                                           if (!$this->conf['dontShowCorrectAnswers']) {
                                               // hierhin verschoben am 24.1.10
                                               $tempAnswer = $this->cObj->substituteMarkerArray($template_oknot, $markerArray);
                                               $markerArray["###REF_QR_ANSWER_CORR_NOTANSW###"] .= $tempAnswer;
                                           }
                                           if ($row['qtype'] == 3 && ($row['answer1'] || $row['answer1'] === '0')) {
                                               $wrongText = 1;
                                               // for statistics: a2 statt a1 bei falscher antwort
                                               $selected = 2;
                                               // statistics: no answer = false answer !
                                           }
                                           //$correctBool = true;
                                           if ($this->helperObj->writeDevLog) {
                                               t3lib_div::devLog($questionUID . '-' . $answerNumber . '=CORR_NOTANSW->', $this->extKey, 0);
                                           }
                                       } else {
                                           if (!$this->conf['dontShowCorrectAnswers']) {
                                               $tempAnswer = $this->cObj->substituteMarkerArray($template_notnot, $markerArray);
                                               $markerArray["###REF_QR_ANSWER_NOTCORR_NOTANSW###"] .= $tempAnswer;
                                               if ($this->helperObj->writeDevLog) {
                                                   t3lib_div::devLog($questionUID . '-' . $answerNumber . '=NOTCORR_NOTANSW->', $this->extKey, 0);
                                               }
                                           }
                                       }
                                   }
                               }
                           }
                           if (!$this->conf['dontShowCorrectAnswers']) {
                               // !$this->conf['isPoll'] &&
                               $markerArray["###REF_QR_ANSWER_ALL###"] .= $tempAnswer;
                               // all answers in correct order
                               if ($row['correct' . $answerNumber] || $row['qtype'] == 3 || $row['qtype'] == 5) {
                                   // all correct answers
                                   $markerArray["###REF_QR_ANSWER_CORR###"] .= $this->cObj->substituteMarkerArray($template_answer, $markerArray);
                               }
                           }
                           if ($this->conf['advancedStatistics'] && $withAnswer) {
                               // for more statistics  && !$this->conf['isPoll']
                               $statisticsArray[$questionUID]['a' . ($answerNumber + $wrongText)] = $selected > 0 ? 1 : 0;
                               if (($row['qtype'] == 3 || $row['qtype'] == 5) && ($quizData['answer' . $questionNumber] || $quizData['answer' . $questionNumber] === '0')) {
                                   $statisticsArray[$questionUID]['text'] = $GLOBALS['TYPO3_DB']->quoteStr($quizData['answer' . $questionNumber], $this->tableRelation);
                               } else {
                                   $statisticsArray[$questionUID]['text'] = '';
                               }
                           }
                           if ($selected > 0 && $row['category' . $selected]) {
                               // && $this->conf['startCategory']
                               $nextCat = $row['category' . $selected];
                               // next category from an answer
                           }
                           if ($selected > 0) {
                               $lastSelected = $selected;
                           }
                       }
                       if (in_array($row['qtype'], $this->textType)) {
                           break 1;
                       }
                       // nur erste Antwort ist hier moeglich
                   }
                   if ($catCount > 0) {
                       // $this->conf['startCategory']
                       if (!$nextCat) {
                           $nextCat = $row['category_next'];
                       }
                       // next category of this question
                       if ($this->conf['advancedStatistics'] && $withAnswer) {
                           $statisticsArray[$questionUID]['nextCat'] = $nextCat;
                       }
                   }
                   if (!$this->conf['dontShowPoints']) {
                       // Bug fixed: dontShowCorrectAnswers doesnt matter here  && !$this->conf['isPoll']
                       if ($questionPoints < 0 && $this->conf['noNegativePoints']) {
                           $questionPoints = 0;
                       }
                       // keine neg. Punkte
                       if ($questionPoints > 0 && $this->conf['noNegativePoints'] == 3) {
                           if (!$allAnswersOK) {
                               $questionPoints = 0;
                           } else {
                               $questionPoints = $answerPoints;
                           }
                           // KGB, 19.01.10: nur maximale Punkte vergeben, nicht pro Antwort
                       }
                       if ($this->conf['noNegativePoints'] == 4) {
                           // Punkte nur, wenn alles OK war
                           if ($allAnswersOK) {
                               $questionPoints = 0;
                           } else {
                               $questionPoints = $answerPoints;
                           }
                       }
                       if ($questionPoints > 0 && $halvePoints && ($quizData["joker1"] || $quizData["joker2"] || $quizData["joker3"])) {
                           $questionPoints = intval($questionPoints / 2);
                       }
                       // halbe Punkte nach Joker-Benutzung
                       $points += $questionPoints;
                       $maxPoints += $maxQuestionPoints;
                       if ($this->conf['advancedStatistics'] && $withAnswer) {
                           $statisticsArray[$questionUID]['points'] = $questionPoints;
                       }
                   } else {
                       if ($this->conf['advancedStatistics'] && $withAnswer) {
                           $statisticsArray[$questionUID]['points'] = 0;
                       }
                       /*    if ($this->conf['dontShowPoints']==2){    // TODO: eine unausgereifte Idee
                                 $cat = ($allAnswersOK) ? $nextCat : $row['category'];
                                 $points=intval('/,|\./', '', $this->catArray[$cat]['name']);    // katgorie in punkte umwandeln
                             } */
                   }
                   // 20.4.10: $correctBool ersetzt durch:
                   if ($realCorrectBool && $withAnswer) {
                       // falls es richtige antworten gibt, merken welche man richtig/falsch beantwortet hat
                       if ($allAnswersOK) {
                           $correctAnsw .= ',' . $questionUID;
                           if ($this->helperObj->writeDevLog) {
                               t3lib_div::devLog($questionUID . ' correct.', $this->extKey, 0);
                           }
                       } else {
                           $falseAnsw .= ',' . $questionUID;
                           if ($this->helperObj->writeDevLog) {
                               t3lib_div::devLog($questionUID . ' not correct.', $this->extKey, 0);
                           }
                       }
                   } else {
                       if ($this->helperObj->writeDevLog) {
                           t3lib_div::devLog($questionUID . ' not counted.', $this->extKey, 0);
                       }
                   }
                   if (!$this->conf['dontShowCorrectAnswers']) {
                       //  && !$this->conf['isPoll']
                       if (!$this->conf['dontShowPoints'] && $row['qtype'] < 5) {
                           $markerArray["###VAR_QUESTION_POINTS###"] = $questionPoints;
                           $markerArray["###VAR_MAX_QUESTION_POINTS###"] = $maxQuestionPoints;
                           $markerArray["###REF_QR_POINTS###"] = $this->cObj->substituteMarkerArray($template_qr_points, $markerArray);
                       } else {
                           $markerArray["###VAR_QUESTION_POINTS###"] = '';
                           $markerArray["###VAR_MAX_QUESTION_POINTS###"] = '';
                       }
                       if ($row['explanation'] != '' || $row['explanation1'] != '' || $row['explanation2'] != '') {
                           // Explanation
                           $markerArray["###VAR_EXPLANATION###"] = '';
                           if ($row['explanation1'] != '') {
                               // Nur wenn das addon myquizpoll_expl2 installiert ist
                               $markerArray["###VAR_EXPLANATION###"] = $lastSelected && $row['explanation' . $lastSelected] ? $this->formatStr($row['explanation' . $lastSelected]) : $this->formatStr($row['explanation']);
                           } else {
                               if ($row['explanation2'] != '') {
                                   // Nur wenn das addon myquizpoll_expl installiert ist
                                   $markerArray["###VAR_EXPLANATION###"] = $allAnswersOK ? $this->formatStr($row['explanation']) : $this->formatStr($row['explanation2']);
                               } else {
                                   $markerArray["###VAR_EXPLANATION###"] = $this->formatStr($row['explanation']);
                               }
                           }
                           if ($markerArray["###VAR_EXPLANATION###"]) {
                               $markerArray["###REF_QR_EXPLANATION###"] = $this->cObj->substituteMarkerArray($template_expl, $markerArray);
                           } else {
                               $markerArray["###REF_QR_EXPLANATION###"] = '';
                           }
                       }
                       $markerArray["###REF_DELIMITER###"] = $this->cObj->substituteMarkerArray($template_delimiter, $markerArray);
                   }
               }
               if (!$this->conf['dontShowCorrectAnswers']) {
                   // bug fixed: points dont even matter  && !$this->conf['isPoll']
                   $markerArrayP["###REF_QRESULT###"] .= $this->cObj->substituteMarkerArray($template_qr, $markerArray);
               }
           }
           // hier wurde mal REF_INTRODUCTION befüllt
           if ($answered) {
               $answered = substr($answered, 1);
           }
           // now answered questions (UIDs)
           if ($skipped) {
               $skipped = substr($skipped, 1);
           }
           // now skipped questions (UIDs)
           if ($correctAnsw) {
               $correctAnsw = substr($correctAnsw, 1);
           }
           if ($falseAnsw) {
               $falseAnsw = substr($falseAnsw, 1);
           }
           $doUpdate = 0;
           // insert or update?
           $pointsTotal = $points;
           // total points, reached
           $maxTotal = $maxPoints;
           // total points, maximum
           $markerArray["###VAR_NEXT_CATEGORY###"] = $this->catArray[$nextCat]['name'];
           //if ($this->conf['pageQuestions'] > 0 && !$this->conf['isPoll']) {    // more questions aviable? // auskommentiert am 27.12.2009, denn der Cheat-Test muss immer kommen!
           if (!$this->conf['showAnswersSeparate']) {
               $quizData['cmd'] = '';
           }
           // show more/next questions!
           // Seek for old answered questions
           if ($quizData['qtuid'] && !$this->conf['isPoll']) {
               $uid = intval($quizData['qtuid']);
               $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('qids,cids,fids,sids, p_or_a, p_max, joker1,joker2,joker3', $this->tableAnswers, 'uid=' . $uid . ' AND sys_language_uid=' . $this->lang);
               //.' '.$this->cObj->enableFields($this->tableAnswers), auskommentiert am 7.11.10
               $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
               if ($rows > 0) {
                   // DB entry found for current user?
                   $fetchedRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5);
                   $answeredOld = $fetchedRow['qids'];
                   $correctOld = $fetchedRow['cids'];
                   $falseOld = $fetchedRow['fids'];
                   $skippedOld = $fetchedRow['sids'];
                   $pointsOld = $fetchedRow['p_or_a'];
                   $maxPointsOld = $fetchedRow['p_max'];
                   $joker1 = $fetchedRow['joker1'];
                   $joker2 = $fetchedRow['joker2'];
                   $joker3 = $fetchedRow['joker3'];
                   if ($correctOld && $correctAnsw) {
                       $correctAnsw = $correctOld . ',' . $correctAnsw;
                   } else {
                       if ($correctOld) {
                           $correctAnsw = $correctOld;
                       }
                   }
                   if ($falseOld && $falseAnsw) {
                       $falseAnsw = $falseOld . ',' . $falseAnsw;
                   } else {
                       if ($falseOld) {
                           $falseAnsw = $falseOld;
                       }
                   }
                   if (!$answered) {
                       // all questions skipped  # Fall 1: bisher nur geskipped
                       $answered = $answeredOld;
                       // all answered questions
                       if ($skippedOld && $skipped) {
                           $skipped = $skippedOld . ',' . $skipped;
                       } else {
                           if ($skippedOld) {
                               $skipped = $skippedOld;
                           }
                       }
                       $pointsTotal = $pointsOld;
                       // total points
                       $maxTotal = $maxPointsOld;
                       //if ($answeredOld) $doUpdate=1;
                       $doUpdate = 3;
                       if ($this->helperObj->writeDevLog) {
                           t3lib_div::devLog("do=3, points={$pointsTotal}, max={$maxTotal}", $this->extKey, 0);
                       }
                   } else {
                       if (stristr(',' . $answeredOld . ',', ',' . $answered . ',')) {
                           // Fall 2: somebody tries to cheat!
                           $answered = $answeredOld;
                           // all answered questions
                           $skipped = $skippedOld;
                           // all skipped questions
                           $pointsTotal = $pointsOld;
                           // total points
                           $maxTotal = $maxPointsOld;
                           if ($back > 0) {
                               $doUpdate = 1;
                               // back-seite: update mit alten daten
                           } else {
                               $doUpdate = 2;
                               $error = true;
                               $markerArray["###CHEATING###"] = $this->pi_getLL('cheating', 'cheating');
                               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_CHEATING###");
                               $markerArrayP["###REF_RES_ERRORS###"] .= $this->cObj->substituteMarkerArray($template, $markerArray);
                               if ($this->helperObj->writeDevLog) {
                                   t3lib_div::devLog("Cheating error!", $this->extKey, 0);
                               }
                               /*$tempTime = $this->helperObj->getPageTime($quizData['qtuid']);
                                 if ($tempTime) {
                                     $markerArrayP["###VAR_NOW###"] = $markerArray["###VAR_NOW###"] = $tempTime;
                                 }*/
                           }
                           if ($this->helperObj->writeDevLog) {
                               t3lib_div::devLog("do=2, points={$pointsTotal}, max={$maxTotal}", $this->extKey, 0);
                           }
                       } else {
                           if ($answeredOld) {
                               // Fall 3: man hat schon was beantwortet
                               $answered = $answeredOld . ',' . $answered;
                               // all answered questions
                               if ($skippedOld && $skipped) {
                                   $skipped = $skippedOld . ',' . $skipped;
                               } else {
                                   if ($skippedOld) {
                                       $skipped = $skippedOld;
                                   }
                               }
                               $pointsTotal = $points + $pointsOld;
                               // total points
                               //$maxTotal = $maxPoints;
                               if ($maxPointsOld > 0) {
                                   $maxTotal += $maxPointsOld;
                               }
                               $doUpdate = 1;
                               if ($this->helperObj->writeDevLog) {
                                   t3lib_div::devLog("do=1, points={$pointsTotal}, max={$maxTotal}", $this->extKey, 0);
                               }
                           } else {
                               if ($skippedOld) {
                                   // Fall 4: skipped, dann beantwortet
                                   if ($skippedOld && $skipped) {
                                       $skipped = $skippedOld . ',' . $skipped;
                                   } else {
                                       $skipped = $skippedOld;
                                   }
                                   $pointsTotal = $points;
                                   // total points
                                   $doUpdate = 1;
                               }
                           }
                       }
                   }
               }
           }
           $whereAnswered = '';
           if ($answered) {
               $whereAnswered = ' AND uid NOT IN (' . preg_replace('/[^0-9,]/', '', $answered) . ')';
           }
           // exclude answered questions next time
           $whereSkipped = '';
           if ($skipped) {
               $whereSkipped = ' AND uid NOT IN (' . preg_replace('/[^0-9,]/', '', $skipped) . ')';
           }
           // exclude skipped questions next time
           if ($skippedCount > 0) {
               $markerArray["###VAR_NO###"] = $skippedCount;
               $markerArray["###SKIPPED###"] = $this->pi_getLL('skipped', 'skipped');
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_SKIPPED###");
               $markerArrayP["###REF_SKIPPED###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
               // instead $content
           }
           //} else
           if (!$this->conf['pageQuestions']) {
               if ($this->conf['highscore.']['showAtFinal']) {
                   $quizData['cmd'] = 'score';
               } else {
                   $quizData['cmd'] = 'nix';
               }
               // keine neuen Fragen...
           } else {
               if ($this->conf['isPoll'] && !$nextCat) {
                   $quizData['cmd'] = 'list';
               }
           }
           $markerArray["###VAR_QUESTIONS_ANSWERED###"] = $answered ? substr_count($answered, ',') + 1 : 0;
           if ($falseAnsw || $correctAnsw) {
               $markerArray["###VAR_QUESTIONS_CORRECT###"] = $correctAnsw ? substr_count($correctAnsw, ',') + 1 : 0;
               $markerArray["###VAR_QUESTIONS_FALSE###"] = $falseAnsw ? substr_count($falseAnsw, ',') + 1 : 0;
           }
           if ($this->conf['dontShowPoints'] != 1 && !$this->conf['isPoll']) {
               // Total points yet. && !$this->conf['dontShowCorrectAnswers'] ??
               $markerArray["###RESULT_POINTS###"] = $this->pi_getLL('result_points', 'result_points');
               $markerArray["###TOTAL_POINTS###"] = $this->pi_getLL('total_points', 'total_points');
               $markerArray["###SO_FAR_REACHED1###"] = $this->pi_getLL('so_far_reached1', 'so_far_reached1');
               $markerArray["###SO_FAR_REACHED2###"] = $this->pi_getLL('so_far_reached2', 'so_far_reached2');
               $markerArray["###VAR_RESULT_POINTS###"] = $points;
               $markerArray["###VAR_MAX_POINTS###"] = $maxPoints;
               $markerArray["###VAR_MISSING_POINTS###"] = $maxPoints - $points;
               $markerArray["###VAR_TOTAL_POINTS###"] = $pointsTotal;
               $markerArray["###VAR_TMAX_POINTS###"] = $maxTotal;
               $markerArray["###VAR_TMISSING_POINTS###"] = $maxTotal - $pointsTotal;
               if ($maxTotal > 0) {
                   $percent = intval(round(100 * $pointsTotal / $maxTotal));
               }
               $markerArray["###VAR_PERCENT###"] = $percent;
               $overallMaximum = $markerArray["###VAR_OMAX_POINTS###"];
               if ($overallMaximum) {
                   $overallPercent = 100 * $pointsTotal / $overallMaximum;
                   $markerArray["###VAR_OVERALL_PERCENT###"] = intval(round($overallPercent));
                   //$markerArray["###VAR_OMAX_POINTS###"] = $overallMaximum;
               }
               if ($doUpdate == 0) {
                   $overallMaximum = $this->helperObj->getQuestionsMaxPoints();
                   // maximum points of all questions
                   if ($overallMaximum > 0) {
                       $overallPercent = 100 * $markerArray["###VAR_TOTAL_POINTS###"] / $overallMaximum;
                   }
                   $markerArray["###VAR_OVERALL_PERCENT###"] = intval(round($overallPercent));
                   $markerArray["###VAR_OMAX_POINTS###"] = $overallMaximum;
                   $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_RESULT_POINTS###");
               } else {
                   $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_RESULT_POINTS_TOTAL###");
               }
               $markerArrayP["###REF_QPOINTS###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
               // instead $content
           }
           if ($this->conf['startCategory'] && $nextCat) {
               //  && $this->conf['pageQuestions']==1
               $this->conf['startCategory'] = $nextCat;
               // kategorie der naechsten frage
           }
           // myVars for page
           $markerArrayP = array_merge($markerArrayP, $this->helperObj->setPageVars());
           if ($points == '') {
               $points = 0;
           }
           if ($pointsTotal == '') {
               $pointsTotal = 0;
           }
           $hidden = intval($quizData["hidden"]);
           if ($doUpdate == 0 && ($points > 0 || !$this->conf['isPoll'])) {
               // Insert new results into database
               $timestamp = time();
               $firsttime = intval($quizData["time"]);
               $insert = array('pid' => $resPID, 'tstamp' => $timestamp, 'crdate' => $timestamp, 'hidden' => $hidden, 'ip' => $quiz_taker_ip_address, 'sys_language_uid' => $this->lang);
               if (!$this->conf['isPoll']) {
                   $insert['joker1'] = $joker1 = intval($quizData["joker1"]);
                   $insert['joker2'] = $joker2 = intval($quizData["joker2"]);
                   $insert['joker3'] = $joker3 = intval($quizData["joker3"]);
                   $insert['name'] = $quiz_taker_name;
                   $insert['email'] = $quiz_taker_email;
                   $insert['homepage'] = $quiz_taker_homepage;
                   $insert['p_max'] = $maxPoints;
                   $insert['percent'] = $percent;
                   $insert['o_max'] = $overallMaximum;
                   $insert['o_percent'] = $overallPercent;
                   $insert['cids'] = $correctAnsw;
                   $insert['fids'] = $falseAnsw;
                   $insert['sids'] = $skipped;
                   // Hook for tt_address
                   if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['setAdrHook']) && $this->conf['userData.']['tt_address_pid']) {
                       foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['setAdrHook'] as $_classRef) {
                           $_procObj =& t3lib_div::getUserObj($_classRef);
                           $markerArray["###VAR_ADDRESS_UID###"] = $quizData["address_uid"] = intval($_procObj->setAdr($quizData, $this->conf['userData.']['tt_address_pid'], $this->conf['userData.']['tt_address_groups']));
                       }
                       $insert['address_uid'] = $quizData["address_uid"];
                   }
               }
               if ($this->tableAnswers == 'tx_myquizpoll_result') {
                   $insert['p_or_a'] = $points;
                   $insert['qids'] = $answered;
                   $insert['firsttime'] = $firsttime;
                   $insert['lasttime'] = $timestamp;
                   $insert['lastcat'] = $lastCat;
                   $insert['nextcat'] = $nextCat;
                   $insert['fe_uid'] = intval($GLOBALS['TSFE']->fe_user->user['uid']);
                   $insert['start_uid'] = intval($quizData["start_uid"]);
               } else {
                   $insert['answer_no'] = $points;
                   $insert['question_id'] = $answered;
               }
               $success = $GLOBALS['TYPO3_DB']->exec_INSERTquery($this->tableAnswers, $insert);
               if ($success) {
                   $quizData['qtuid'] = $GLOBALS['TYPO3_DB']->sql_insert_id();
                   if ($this->tableAnswers == 'tx_myquizpoll_result') {
                       $this->helperObj->setStartUid($quizData['qtuid'], intval($quizData["start_uid"]));
                   }
                   if ($this->conf['useCookiesInDays']) {
                       // save quiz takers UID as cookie?
                       $cookieName = $this->getCookieMode($resPID, $thePID);
                       //if (!($this->conf['isPoll'] && $_COOKIE[$cookieName])) {    // bein Umfragen Cookie nicht ueberschreiben...
                       if (intval($this->conf['useCookiesInDays']) == -1) {
                           $periode = 0;
                       } else {
                           $periode = time() + 3600 * 24 * intval($this->conf['useCookiesInDays']);
                       }
                       setcookie($cookieName, $quizData['qtuid'], $periode);
                       /* cookie for x days */
                       if ($this->helperObj->writeDevLog) {
                           t3lib_div::devLog('Storing Cookie: ' . $cookieName . '=' . $quizData['qtuid'] . ', period=' . $periode, $this->extKey, 0);
                       }
                       //}
                   }
                   $this->helperObj->setFirstTime($quizData['qtuid'], $firsttime);
               } else {
                   $content .= "<p>MySQL Insert-Error for table " . $this->tableAnswers . " :-(</p>";
               }
           } else {
               if ($doUpdate == 1) {
                   // update current user entry
                   $uid = intval($quizData['qtuid']);
                   $timestamp = time();
                   $update = array('tstamp' => $timestamp, 'hidden' => $hidden, 'name' => $quiz_taker_name, 'email' => $quiz_taker_email, 'homepage' => $quiz_taker_homepage, 'p_or_a' => $pointsTotal, 'p_max' => $maxTotal, 'percent' => $percent, 'o_percent' => $overallPercent, 'qids' => $answered, 'cids' => $correctAnsw, 'fids' => $falseAnsw, 'sids' => $skipped, 'lastcat' => $lastCat, 'nextcat' => $nextCat, 'lasttime' => $timestamp);
                   $success = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->tableAnswers, 'uid=' . $uid . ' AND sys_language_uid=' . $this->lang, $update);
                   if (!$success) {
                       $content .= "<p>MySQL Update-Error :-(</p>";
                   }
               } else {
                   if ($doUpdate == 3) {
                       // update current skipped entry (only skipped questions?!?!)
                       $uid = intval($quizData['qtuid']);
                       $timestamp = time();
                       $update = array('tstamp' => $timestamp, 'hidden' => $hidden, 'sids' => $skipped, 'lasttime' => $timestamp);
                       $success = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->tableAnswers, 'uid=' . $uid . ' AND sys_language_uid=' . $this->lang, $update);
                       if (!$success) {
                           $content .= "<p>MySQL Update-Error :-(</p>";
                       }
                   }
               }
           }
           $markerArray["###QTUID###"] = intval($quizData["qtuid"]);
           if ($this->conf['isPoll']) {
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_POLL_SUBMITED###");
               // Output thank you
               $markerArray['###QUESTION_NAME###'] = $this->pi_getLL('poll_question', 'poll_question');
               $markerArray['###USER_ANSWER###'] = $this->pi_getLL('poll_answer', 'poll_answer');
               $markerArrayP["###REF_INTRODUCTION###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
               // instead $content
           } else {
               if ($this->conf['userData.']['showAtAnswer']) {
                   $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_USER_SUBMITED###");
                   // Output the user name
                   $markerArrayP["###REF_INTRODUCTION###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
                   // instead $content
               }
           }
           if ($this->conf['advancedStatistics'] && $doUpdate < 2) {
               // write advanced Statistics to database
               $uid = intval($quizData['qtuid']);
               $timestamp = time();
               $firsttime = $this->helperObj->getFirstTime($uid);
               if ($this->conf['requireSession']) {
                   $where_time = ' AND crdate=' . $firsttime;
               } else {
                   $where_time = '';
               }
               if (is_array($statisticsArray)) {
                   foreach ($statisticsArray as $type => $element) {
                       // delete old entry in back-mode
                       if ($back > 0) {
                           $GLOBALS['TYPO3_DB']->exec_DELETEquery($this->tableRelation, "pid={$resPID} AND user_id={$uid} AND question_id={$type} {$where_time} AND sys_language_uid=" . $this->lang);
                       }
                       $insert = array('pid' => $resPID, 'tstamp' => $timestamp, 'crdate' => $firsttime, 'hidden' => $hidden, 'user_id' => $uid, 'question_id' => $type, 'textinput' => $element['text'], 'points' => $element['points'] ? $element['points'] : 0, 'nextcat' => $element['nextCat'] ? $element['nextCat'] : 0, 'sys_language_uid' => $this->lang);
                       //$array2=array();
                       for ($answerNumber = 1; $answerNumber < $this->answerChoiceMax + 1; $answerNumber++) {
                           $insert['checked' . $answerNumber] = $element['a' . $answerNumber] ? 1 : 0;
                       }
                       //$insert = array_merge($array1, $array2);
                       $GLOBALS['TYPO3_DB']->exec_INSERTquery($this->tableRelation, $insert);
                   }
               }
           }
           if (!$this->conf['pageQuestions'] && !$this->conf['isPoll']) {
               $finalPage = true;
           }
           $answerPage = true;
           if ($back) {
               $back--;
           }
       }
       if ($this->conf['finishedMinPercent'] && $this->conf['pageQuestions'] > 0 && $markerArray["###VAR_TOTAL_POINTS###"] !== '' && (!$this->conf['showAnswersSeparate'] || !$quizData['cmd']) && $no_rights == 0) {
           /* ***************************************************** */
           /*
            * Display positive cancel page: quiz taker has reached finishedMinPercent percent???
            */
           if ($markerArray["###VAR_OMAX_POINTS###"]) {
               $myPercent = 100 * $markerArray["###VAR_TOTAL_POINTS###"] / $markerArray["###VAR_OMAX_POINTS###"];
           } else {
               $myPercent = 0;
           }
           $uidP = 0;
           $finishedMinPercent = $this->conf['finishedMinPercent'];
           if (strpos($finishedMinPercent, ':') !== false) {
               list($finishedMinPercent, $uidP) = explode(":", $finishedMinPercent);
           }
           if (intval($finishedMinPercent) <= $myPercent) {
               // do we have enough points???
               if ($uidP) {
                   // redirect to a URL with that UID?
                   $this->redirectUrl($uidP, array());
               }
               $markerArray["###REACHED1###"] = $this->pi_getLL('reached1', 'reached1');
               $markerArray["###REACHED2###"] = $this->pi_getLL('reached2', 'reached2');
               $markerArray["###SO_FAR_REACHED1###"] = $this->pi_getLL('so_far_reached1', 'so_far_reached1');
               $markerArray["###SO_FAR_REACHED2###"] = $this->pi_getLL('so_far_reached2', 'so_far_reached2');
               //$markerArray["###VAR_OVERALL_PERCENT###"] = intval($myPercent);
               //$markerArray["###VAR_OMAX_POINTS###"] = $overallMaximum;
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_FINISHEDMINPERCENT###");
               if ($template == '') {
                   // if it is not in the template
                   $template = $this->cObj->getSubpart($this->origTemplateCode, "###TEMPLATE_QUIZ_FINISHEDMINPERCENT###");
               }
               $content .= $this->cObj->substituteMarkerArray($template, $markerArray);
               // sonderfall !!!!!!!!!
               $answerPage = false;
               if ($this->conf['highscore.']['showAtFinal']) {
                   $quizData['cmd'] = 'score';
                   // show highscore
               } else {
                   $quizData['cmd'] = 'exit';
                   // display no more questions
               }
           }
       }
       if ($this->conf['cancelWhenWrong'] && $this->conf['pageQuestions'] > 0 && $markerArray["###VAR_TOTAL_POINTS###"] !== '' && (!$this->conf['showAnswersSeparate'] || !$quizData['cmd']) && $no_rights == 0) {
           /* ***************************************************** */
           /*
            * Display negative cancel page: quiz taker has given a wrong answer???
            */
           if ($markerArray["###VAR_TOTAL_POINTS###"] < $markerArray["###VAR_TMAX_POINTS###"]) {
               $markerArray["###REACHED1###"] = $this->pi_getLL('reached1', 'reached1');
               $markerArray["###REACHED2###"] = $this->pi_getLL('reached2', 'reached2');
               $markerArray["###SO_FAR_REACHED1###"] = $this->pi_getLL('so_far_reached1', 'so_far_reached1');
               $markerArray["###SO_FAR_REACHED2###"] = $this->pi_getLL('so_far_reached2', 'so_far_reached2');
               $markerArray["###QUIZ_END###"] = $this->pi_getLL('quiz_end', 'quiz_end');
               $markerArray["###RESTART_QUIZ###"] = $this->pi_linkToPage($this->pi_getLL('restart_quiz', 'restart_quiz'), $startPID, $target = '', array());
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_END###");
               if ($template == '') {
                   // if it is not in the template
                   $template = $this->cObj->getSubpart($this->origTemplateCode, "###TEMPLATE_QUIZ_END###");
               }
               $content .= $this->cObj->substituteMarkerArray($template, $markerArray);
               // sonderfall !!!
               $answerPage = false;
               // show no answers
               if ($this->conf['finalWhenCancel']) {
                   $noQuestions = true;
               } else {
                   if ($this->conf['highscore.']['showAtFinal']) {
                       $quizData['cmd'] = 'score';
                       // show highscore
                   } else {
                       $quizData['cmd'] = 'exit';
                       // display no more questions
                   }
                   $no_rights = 1;
                   // cancel all
               }
           }
       }
       // Pre-fill quiz taker name and email if FE user logged in
       if ($GLOBALS['TSFE']->loginUser) {
           if (!$quizData["name"]) {
               $field = $this->conf['fe_usersName'];
               if (!$field) {
                   $field = 'name';
               }
               $quizData["name"] = $GLOBALS['TSFE']->fe_user->user[$field];
           }
           if (!$quizData["email"]) {
               $quizData["email"] = $GLOBALS['TSFE']->fe_user->user['email'];
           }
           if (!$quizData["homepage"]) {
               $quizData["homepage"] = $GLOBALS['TSFE']->fe_user->user['www'];
           }
       }
       if ($quizData["name"]) {
           $markerArray["###DEFAULT_NAME###"] = htmlspecialchars($quizData["name"]);
       } else {
           $markerArray["###DEFAULT_NAME###"] = $this->pi_getLL('no_name', 'no_name');
       }
       if ($quizData["email"]) {
           $markerArray["###DEFAULT_EMAIL###"] = htmlspecialchars($quizData["email"]);
       } else {
           $markerArray["###DEFAULT_EMAIL###"] = $this->pi_getLL('no_email', 'no_email');
       }
       if ($quizData["homepage"]) {
           $markerArray["###DEFAULT_HOMEPAGE###"] = htmlspecialchars($quizData["homepage"]);
       } else {
           $markerArray["###DEFAULT_HOMEPAGE###"] = $this->pi_getLL('no_homepage', 'no_homepage');
       }
       $markerArray["###HIDE_ME###"] = $this->pi_getLL('hide_me', 'hide_me');
       $markerArray["###VISIBILITY###"] = $this->pi_getLL('visibility', 'visibility');
       // TODO: warum nur?
       // UID loeschen bei Umfragen
       if ($this->conf['isPoll']) {
           $quizData['qtuid'] = '';
       }
       if ($this->helperObj->writeDevLog) {
           t3lib_div::devLog('Next cmd: ' . $quizData['cmd'] . ', answer-page: ' . $answerPage . ', final-page: ' . $finalPage, $this->extKey, 0);
       }
       if ($quizData['cmd'] == '' && $no_rights == 0) {
           /* ***************************************************** */
           /*
            * Display initial page: questions and quiz taker name fields
            */
           $oldRelData = array();
           if ($this->conf['allowBack'] && $this->conf['pageQuestions'] && $quizData['qtuid'] && $back > 0) {
               $where = '';
               $where_rel = '';
               $where_time = '';
               $uid = intval($quizData['qtuid']);
               if ($this->conf['requireSession']) {
                   $where_time = ' AND firsttime=' . $this->helperObj->getFirstTime($uid);
               }
               $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('name,email,homepage,qids', $this->tableAnswers, "uid={$uid} {$where_time} AND sys_language_uid=" . $this->lang);
               //.' '.$this->cObj->enableFields($this->tableAnswers));
               $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
               if ($rows > 0) {
                   $fetchedRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5);
                   $qids = explode(',', $fetchedRow['qids']);
                   $bisher = count($qids);
                   $seiten = round($bisher / $this->conf['pageQuestions']);
                   $seite = $seiten - $back + 1;
                   for ($k = 0; $k < $bisher; $k++) {
                       if (ceil(($k + 1) / $this->conf['pageQuestions']) == $seite) {
                           $where .= $qids[$k] . ',';
                       }
                   }
                   if ($where) {
                       $where = ' AND uid IN (' . preg_replace('/[^0-9,]/', '', rtrim($where, ',')) . ')';
                       $where_rel = ' AND user_id IN (' . preg_replace('/[^0-9,]/', '', rtrim($where, ',')) . ')';
                   }
                   $quizData["name"] = $fetchedRow['name'];
                   $quizData["email"] = $fetchedRow['email'];
                   $quizData["homepage"] = $fetchedRow['homepage'];
                   if ($quizData["name"]) {
                       $markerArray["###DEFAULT_NAME###"] = htmlspecialchars($quizData["name"]);
                   } else {
                       $markerArray["###DEFAULT_NAME###"] = $this->pi_getLL('no_name', 'no_name');
                   }
                   if ($quizData["email"]) {
                       $markerArray["###DEFAULT_EMAIL###"] = htmlspecialchars($quizData["email"]);
                   } else {
                       $markerArray["###DEFAULT_EMAIL###"] = $this->pi_getLL('no_email', 'no_email');
                   }
                   if ($quizData["homepage"]) {
                       $markerArray["###DEFAULT_HOMEPAGE###"] = htmlspecialchars($quizData["homepage"]);
                   } else {
                       $markerArray["###DEFAULT_HOMEPAGE###"] = $this->pi_getLL('no_homepage', 'no_homepage');
                   }
               }
               $GLOBALS['TYPO3_DB']->sql_free_result($res5);
               $sortBy = $this->getSortBy();
               $questionsArray = array();
               $questionNumber = 0;
               if ($where) {
                   $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->tableQuestions, 'pid IN (' . $thePID . ')' . $where . ' AND sys_language_uid=' . $this->lang . ' ' . $this->cObj->enableFields($this->tableQuestions), '', $sortBy);
                   $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
                   if ($this->helperObj->writeDevLog) {
                       t3lib_div::devLog($rows . ' rows selected with: pid IN (' . $thePID . ')' . $where . ' AND sys_language_uid=' . $this->lang, $this->extKey, 0);
                   }
                   if ($rows > 0) {
                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5)) {
                           $questionNumber++;
                           $questionsArray[$questionNumber] = $row;
                       }
                   }
                   $GLOBALS['TYPO3_DB']->sql_free_result($res5);
               }
               $numOfQuestions = $questionNumber;
               $maxQuestions = $numOfQuestions;
               // bisherige Antworten noch holen
               if ($where_rel) {
                   if ($this->conf['requireSession']) {
                       $where_time = ' AND crdate=' . $this->helperObj->getFirstTime($uid);
                   }
                   $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->tableRelation, "pid={$resPID} AND user_id={$uid} {$where_time} AND sys_language_uid=" . $this->lang);
                   $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
                   if ($rows > 0) {
                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5)) {
                           $temp_qid = $row['question_id'];
                           $oldRelData[$temp_qid] = array();
                           $oldRelData[$temp_qid]['textinput'] = $row['textinput'];
                           for ($j = 1; $j <= $this->answerChoiceMax; $j++) {
                               $oldRelData[$temp_qid]['checked' . $j] = $row['checked' . $j];
                           }
                       }
                   }
                   $GLOBALS['TYPO3_DB']->sql_free_result($res5);
               }
               //print_r($oldRelData);
           } elseif (!$noQuestions) {
               // Order questions by & and limit to
               $limitTo = '';
               $whereCat = '';
               $sortBy = $this->getSortBy();
               // Limit questions?
               if ($this->conf['pageQuestions'] > 0 && $this->conf['sortBy'] != 'random') {
                   $limitTo = preg_replace('/[^0-9,]/', '', $this->conf['pageQuestions']);
               }
               // category
               if ($this->conf['startCategory']) {
                   $whereCat = " AND category=" . intval($this->conf['startCategory']);
               } else {
                   if ($this->conf['onlyCategories']) {
                       $whereCat = " AND category IN (" . preg_replace('/[^0-9,]/', '', $this->conf['onlyCategories']) . ")";
                   }
               }
               // Get questions from the database
               $questionsArray = array();
               $questionNumber = 0;
               $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->tableQuestions, 'pid IN (' . $thePID . ')' . $whereCat . $whereAnswered . $whereSkipped . ' AND sys_language_uid=' . $this->lang . ' ' . $this->cObj->enableFields($this->tableQuestions), '', $sortBy, $limitTo);
               $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
               if (!$rows && $whereSkipped) {
                   // now ignore the skipped questions
                   $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->tableQuestions, 'pid IN (' . $thePID . ')' . $whereCat . $whereAnswered . ' AND sys_language_uid=' . $this->lang . ' ' . $this->cObj->enableFields($this->tableQuestions), '', $sortBy, $limitTo);
                   $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
               }
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog($rows . ' rows selected with: pid IN (' . $thePID . ')' . $whereCat . $whereAnswered . ' AND sys_language_uid=' . $this->lang, $this->extKey, 0);
               }
               if ($rows > 0) {
                   while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5)) {
                       $questionNumber++;
                       $questionsArray[$questionNumber] = $row;
                   }
               }
               $numOfQuestions = $questionNumber;
               // real questions
               $maxQuestions = $this->conf['pageQuestions'];
               // should be questions
               if ($this->conf['isPoll']) {
                   $maxQuestions = 1;
                   // only max. 1 poll-question
               } else {
                   if (!$maxQuestions) {
                       $maxQuestions = $numOfQuestions;
                   } else {
                       if ($numOfQuestions < $maxQuestions) {
                           $maxQuestions = $numOfQuestions;
                           // no. of maximum question = no. of questions in the DB
                       }
                   }
               }
               if ($numOfQuestions > 0 and $this->conf['sortBy'] == 'random') {
                   // any questions out there???    Random questions???
                   $randomQuestionsArray = array();
                   $questionNumber = 0;
                   $versuche = 0;
                   // Not very fast random method
                   while ($questionNumber < $maxQuestions) {
                       // alle Fragen durchgehen
                       $random = mt_rand(1, $numOfQuestions);
                       $randomQuestionsArray[$questionNumber + 1] = $questionsArray[$random];
                       // eine Frage uebernehmen
                       $duplicate = 0;
                       for ($i = 1; $i < $questionNumber + 1; $i++) {
                           if ($randomQuestionsArray[$questionNumber + 1]['uid'] == $randomQuestionsArray[$i]['uid']) {
                               $duplicate = 1;
                               // doch nicht uebernehmen
                           }
                           if (!$duplicate && $this->conf['randomCategories'] && $versuche < 5 * $maxQuestions && $randomQuestionsArray[$questionNumber + 1]['category'] == $randomQuestionsArray[$i]['category']) {
                               $duplicate = 1;
                               // doch nicht uebernehmen
                           }
                       }
                       if (!$duplicate) {
                           $questionNumber++;
                       }
                       $versuche++;
                   }
                   // rearange questions Array
                   for ($questionNumber = 1; $questionNumber < $maxQuestions + 1; $questionNumber++) {
                       $questionsArray[$questionNumber] = $randomQuestionsArray[$questionNumber];
                   }
               }
               if ($this->conf['finishAfterQuestions']) {
                   // finish after X questions?
                   $numOfQuestions = intval($this->conf['finishAfterQuestions']) - $this->helperObj->getQuestionNo($whereAnswered);
                   if ($numOfQuestions < $maxQuestions) {
                       $maxQuestions = $numOfQuestions;
                       // no. of maximum question = no. of questions in the DB
                   }
               }
           } else {
               $numOfQuestions = 0;
           }
           if ($numOfQuestions > 0) {
               // any questions out there???
               // Start des Output
               $lastUID = 0;
               // remember the last question ID
               $pageTimeCat = 0;
               // time per page from a category
               $questTillNow = 0;
               // no. of questions answered till now
               $imgTSConfig = array();
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUESTION###");
               $template_image_begin = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUESTION_IMAGE_BEGIN###");
               $template_image_end = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUESTION_IMAGE_END###");
               $template_answer = $this->cObj->getSubpart($template, "###TEMPLATE_QUESTION_ANSWER###");
               $template_delimiter = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_DELIMITER###");
               if (!$this->conf['isPoll']) {
                   $markerArray["###VAR_QUESTIONS###"] = $this->helperObj->getQuestionsNo();
                   if ($back && $seite) {
                       $markerArray["###VAR_QUESTION###"] = $questTillNow = ($seite - 1) * $this->conf['pageQuestions'];
                   } else {
                       $markerArray["###VAR_QUESTION###"] = $questTillNow = $this->helperObj->getQuestionNo($whereAnswered);
                   }
               }
               // Questions and answers
               for ($questionNumber = 1; $questionNumber < $maxQuestions + 1; $questionNumber++) {
                   $row = $questionsArray[$questionNumber];
                   $quid = $row['uid'];
                   $markerArray["###VAR_QUESTION_NUMBER###"] = $questionNumber;
                   $answerPointsBool = false;
                   // gibt es punkte bei einzelnen antworten?
                   $markerArray["###VAR_QUESTION###"]++;
                   if ($row['image']) {
                       $markerArray["###VAR_QUESTION_IMAGE###"] = $this->helperObj->getImage($row['image'], $row["alt_text"]);
                       $markerArray["###REF_QUESTION_IMAGE_BEGIN###"] = $this->cObj->substituteMarkerArray($template_image_begin, $markerArray);
                       $markerArray["###REF_QUESTION_IMAGE_END###"] = $template_image_end;
                   } else {
                       $markerArray["###REF_QUESTION_IMAGE_BEGIN###"] = '';
                       $markerArray["###REF_QUESTION_IMAGE_END###"] = '';
                   }
                   $markerArray["###VAR_QUESTION_TYPE###"] = $row['qtype'];
                   $markerArray["###TITLE_HIDE###"] = $row['title_hide'] ? '-hide' : '';
                   $markerArray["###VAR_QUESTION_TITLE###"] = $row['title'];
                   $markerArray["###VAR_QUESTION_NAME###"] = $this->formatStr($row['name']);
                   //$this->formatStr($this->local_cObj->stdWrap($row['name'],$this->conf["general_stdWrap."])); //$this->pi_RTEcssText($row['name']);
                   if (!$this->conf['dontShowPoints'] && !$this->conf['isPoll'] && $row['qtype'] < 5) {
                       $markerArray["###VAR_QUESTION_POINTS###"] = 0;
                       if ($markerArray["###VAR_TOTAL_POINTS###"]) {
                           $markerArray["###VAR_NEXT_POINTS###"] = $markerArray["###VAR_TOTAL_POINTS###"];
                       } else {
                           $markerArray["###VAR_NEXT_POINTS###"] = 0;
                       }
                       for ($currentValue = 1; $currentValue <= $this->answerChoiceMax; $currentValue++) {
                           if (intval($row['points' . $currentValue]) > 0) {
                               $answerPointsBool = true;
                               break;
                           }
                       }
                       if ($answerPointsBool) {
                           $markerArray["###VAR_ANSWER_POINTS###"] = $this->pi_getLL('different_number_of', 'different_number_of');
                       } else {
                           if (($row['qtype'] == 0 || $row['qtype'] == 4) && $this->conf['noNegativePoints'] < 3) {
                               $markerArray["###VAR_ANSWER_POINTS###"] = $this->pi_getLL('each', 'each') . ' ' . $row['points'];
                           } else {
                               $markerArray["###VAR_ANSWER_POINTS###"] = $row['points'];
                           }
                       }
                       $markerArray["###P1###"] = $this->pi_getLL('p1', 'p1');
                       $markerArray["###P2###"] = $this->pi_getLL('p2', 'p2');
                   } else {
                       $markerArray["###VAR_ANSWER_POINTS###"] = '';
                       $markerArray["###VAR_QUESTION_POINTS###"] = '';
                       $markerArray["###VAR_NEXT_POINTS###"] = '';
                       $markerArray["###P1###"] = '';
                       $markerArray["###P2###"] = '';
                   }
                   $markerArray["###REF_QUESTION_ANSWER###"] = '';
                   if ($row['qtype'] == 2) {
                       $input_id = $this->conf['myVars.']['answers.']['input_id'] ? ' id="answer' . $questionNumber . '"' : '';
                       if ($markerArrayQ["###MY_INPUT_LABEL###"] == 5) {
                           $input_id .= ' class="form-control"';
                       }
                       $markerArrayQ["###VAR_QUESTION_ANSWER###"] = '<select name="tx_myquizpoll_pi1[answer' . $questionNumber . ']" ###MY_SELECT###' . $input_id . '>' . "\n";
                       //  class="'.$this->prefixId.'-answer"
                   }
                   // my Variables of questions
                   $markerArray["###MY_SELECT###"] = '';
                   $markerArray = array_merge($markerArray, $this->helperObj->setQuestionVars($questionNumber));
                   // Jokers
                   if ($this->conf['useJokers'] && $this->conf['pageQuestions'] == 1) {
                       $temp_uid = intval($quizData['qtuid']);
                       $markerArrayJ["###JAVASCRIPT###"] = '';
                       $markerArrayJ["###JOKER_50###"] = $this->pi_getLL('joker_50', 'joker_50');
                       $markerArrayJ["###JOKER_AUDIENCE###"] = $this->pi_getLL('joker_audience', 'joker_audience');
                       $markerArrayJ["###JOKER_PHONE###"] = $this->pi_getLL('joker_phone', 'joker_phone');
                       if (is_array($this->conf['jokers.'])) {
                           $unlimited = $this->conf['jokers.']['unlimited'];
                       } else {
                           $unlimited = 0;
                       }
                       if ($joker1 && !$unlimited) {
                           $markerArrayJ["###JOKER_50_LINK###"] = '';
                           $markerArrayJ["###JAVASCRIPT###"] .= "document.getElementById('" . $this->prefixId . "-joker_50').style.display = 'none';\n";
                       } else {
                           $markerArrayJ["###JOKER_50_LINK###"] = $this->prefixId . 'getAjaxData(' . $quid . ',' . $temp_uid . ',1,\'joker_50\');';
                       }
                       if ($joker2 && !$unlimited) {
                           $markerArrayJ["###JOKER_AUDIENCE_LINK###"] = '';
                           $markerArrayJ["###JAVASCRIPT###"] .= "document.getElementById('" . $this->prefixId . "-joker_audience').style.display = 'none';\n";
                       } else {
                           $markerArrayJ["###JOKER_AUDIENCE_LINK###"] = $this->prefixId . 'getAjaxData(' . $quid . ',' . $temp_uid . ',2,\'joker_audience\');';
                       }
                       if ($joker3 && !$unlimited) {
                           $markerArrayJ["###JOKER_PHONE_LINK###"] = '';
                           $markerArrayJ["###JAVASCRIPT###"] .= "document.getElementById('" . $this->prefixId . "-joker_phone').style.display = 'none';\n";
                       } else {
                           $markerArrayJ["###JOKER_PHONE_LINK###"] = $this->prefixId . 'getAjaxData(' . $quid . ',' . $temp_uid . ',3,\'joker_phone\');';
                       }
                       $template_jokers = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_JOKERS###");
                       $markerArrayP["###REF_JOKERS###"] = $this->cObj->substituteMarkerArray($template_jokers, $markerArrayJ);
                   }
                   // Daten zur aktuellen und nächsten Kategorie
                   $thisCat = $row['category'];
                   if ($this->catArray[$thisCat]) {
                       $markerArray["###VAR_CATEGORY###"] = $this->catArray[$thisCat]['name'];
                       $pageTimeCat = $this->catArray[$thisCat]['pagetime'];
                   }
                   $thisCat = $row['category_next'];
                   if ($this->catArray[$thisCat]) {
                       $markerArray["###VAR_NEXT_CATEGORY###"] = $this->catArray[$thisCat]['name'];
                   }
                   // Display answers
                   $answers = 0;
                   $radmonArray = array();
                   for ($answerNumber = 1; $answerNumber <= $this->answerChoiceMax; $answerNumber++) {
                       $text_type = in_array($row['qtype'], $this->textType);
                       // Answers in random order?
                       if ($this->conf['mixAnswers'] && !$text_type) {
                           $currentValue = 0;
                           $leer = 0;
                           while ($currentValue == 0 && $leer < 33) {
                               $random = mt_rand(1, $this->answerChoiceMax);
                               if (($row['answer' . $random] || $row['answer' . $random] === '0') && !in_array($random, $radmonArray)) {
                                   $radmonArray[] = $random;
                                   $currentValue = $random;
                               } else {
                                   $leer++;
                               }
                           }
                       } else {
                           $currentValue = $answerNumber;
                       }
                       if (!$text_type && ($row['answer' . $currentValue] || $row['answer' . $currentValue] === '0') || $text_type && $answerNumber == 1) {
                           $answers++;
                           $input_id = '';
                           $input_label1 = '';
                           $input_label2 = '';
                           // my Variables for answers
                           $markerArrayQ["###MY_OPTION###"] = '';
                           $markerArrayQ["###MY_INPUT_RADIO###"] = '';
                           $markerArrayQ["###MY_INPUT_CHECKBOX###"] = '';
                           $markerArrayQ["###MY_INPUT_TEXT###"] = '';
                           $markerArrayQ["###MY_INPUT_AREA###"] = '';
                           $markerArrayQ["###MY_INPUT_WRAP###"] = '';
                           $markerArrayQ = array_merge($markerArrayQ, $this->helperObj->setAnswerVars($answerNumber, $row['qtype']));
                           $markerArrayQ["###VAR_QA_NR###"] = $currentValue;
                           if ($row['qtype'] < 3 || $row['qtype'] == 4 || $row['qtype'] == 7) {
                               //$answer_choice = $this->formatStr($row['answer'.$currentValue]);    // Problem: <tt> geht hier verloren!
                               $answer_choice = $this->conf['general_stdWrap.']['notForAnswers'] ? $row['answer' . $currentValue] : $this->formatStr($row['answer' . $currentValue]);
                               if ($row['qtype'] != 2 && !(strpos($markerArrayQ["###MY_INPUT_WRAP###"], '|') === false)) {
                                   $answer_choice = str_replace('|', $answer_choice, $markerArrayQ["###MY_INPUT_WRAP###"]);
                               }
                           }
                           // Questtion type
                           if ($row['qtype'] == 1) {
                               // radio-button
                               if ($markerArrayQ["###MY_INPUT_ID###"]) {
                                   $input_id = 'id="answer' . $questionNumber . '_' . $answerNumber . '"';
                               }
                               if ($markerArrayQ["###MY_INPUT_LABEL###"]) {
                                   if ($markerArrayQ["###MY_INPUT_LABEL###"] == 3) {
                                       $class_label = ' class="radio"';
                                   } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 4) {
                                       $class_label = ' class="radio inline"';
                                   } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 6) {
                                       $class_label = ' class="radio-inline"';
                                   } else {
                                       $class_label = '';
                                   }
                                   if ($markerArrayQ["###MY_INPUT_LABEL###"] == 5) {
                                       $label_wrap1 = '<div class="radio">';
                                       $label_wrap2 = '</div>';
                                   } else {
                                       $label_wrap1 = '';
                                       $label_wrap2 = '';
                                   }
                                   $input_label1 = $label_wrap1 . '<label for="answer' . $questionNumber . '_' . $answerNumber . '"' . $class_label . '>';
                                   $input_label2 = '</label>' . $label_wrap2;
                               }
                               $answer_content = '<input type="radio" name="tx_myquizpoll_pi1[answer' . $questionNumber . ']" value="' . $currentValue . '" ' . $input_id . ' ###MY_INPUT_RADIO###';
                               if (is_array($oldRelData[$quid]) && $oldRelData[$quid]['checked' . $currentValue]) {
                                   $answer_content .= ' checked="checked"';
                               } elseif ($captchaError && $quizData['answer' . $questionNumber] == $currentValue) {
                                   $answer_content .= ' checked="checked"';
                               }
                               $answer_content .= ' /> ';
                           } else {
                               if ($row['qtype'] == 2) {
                                   // select-box
                                   $answer_content = '<option value="' . $currentValue . '" ###MY_OPTION###';
                                   if (is_array($oldRelData[$quid]) && $oldRelData[$quid]['checked' . $currentValue]) {
                                       $answer_content .= ' selected="selected"';
                                   } elseif ($captchaError && $quizData['answer' . $questionNumber] == $currentValue) {
                                       $answer_content .= ' selected="selected"';
                                   }
                                   $answer_content .= '> ';
                               } else {
                                   if ($row['qtype'] == 3) {
                                       // input-text
                                       if ($markerArrayQ["###MY_INPUT_ID###"]) {
                                           $input_id = 'id="answer' . $questionNumber . '"';
                                       }
                                       if ($markerArrayQ["###MY_INPUT_LABEL###"] == 5) {
                                           $input_id .= ' class="form-control"';
                                       }
                                       if (is_array($oldRelData[$quid])) {
                                           $value = $oldRelData[$quid]['textinput'];
                                       } else {
                                           if ($captchaError) {
                                               $value = $quizData['answer' . $questionNumber];
                                           } else {
                                               if ($row['answer2'] || $row['answer2'] === '0') {
                                                   $value = $row['answer2'];
                                               } else {
                                                   $value = '';
                                               }
                                           }
                                       }
                                       $answer_content = '<input type="text" name="tx_myquizpoll_pi1[answer' . $questionNumber . ']" value="' . $value . '" ' . $input_id . ' ###MY_INPUT_TEXT### /> ';
                                   } else {
                                       if ($row['qtype'] == 4) {
                                           // ja/nein
                                           $answer_content = $answer_choice;
                                           if ($markerArrayQ["###MY_INPUT_ID###"]) {
                                               $input_id = 'id="answer' . $questionNumber . '_' . $answerNumber . '_1"';
                                           }
                                           if ($markerArrayQ["###MY_INPUT_LABEL###"]) {
                                               if ($markerArrayQ["###MY_INPUT_LABEL###"] == 3) {
                                                   $class_label = ' class="radio"';
                                               } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 4) {
                                                   $class_label = ' class="radio inline"';
                                               } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 6) {
                                                   $class_label = ' class="radio-inline"';
                                               } else {
                                                   $class_label = '';
                                               }
                                               if ($markerArrayQ["###MY_INPUT_LABEL###"] == 5) {
                                                   $label_wrap1 = '<div class="radio">';
                                                   $label_wrap2 = '</div>';
                                               } else {
                                                   $label_wrap1 = '';
                                                   $label_wrap2 = '';
                                               }
                                               $input_label1 = $label_wrap1 . '<label for="answer' . $questionNumber . '_' . $answerNumber . '_1"' . $class_label . '>';
                                               $input_label2 = '</label>' . $label_wrap2;
                                           }
                                           $answer_content .= ' <span class="' . $this->prefixId . '-yesno"><span class="' . $this->prefixId . '-yes">';
                                           if ($markerArrayQ["###MY_INPUT_LABEL###"] > 1) {
                                               $answer_content .= $input_label1;
                                           }
                                           $answer_content .= '<input type="radio" name="tx_myquizpoll_pi1[answer' . $questionNumber . '_' . $currentValue . ']" ' . $input_id . ' value="' . $currentValue . '" ###MY_INPUT_RADIO###';
                                           if (is_array($oldRelData[$quid]) && $oldRelData[$quid]['checked' . $currentValue]) {
                                               $answer_content .= ' checked="checked"';
                                           } elseif ($captchaError && $quizData['answer' . $questionNumber . '_' . $currentValue] == $currentValue) {
                                               $answer_content .= ' checked="checked"';
                                           }
                                           $answer_content .= ' /> ';
                                           if ($markerArrayQ["###MY_INPUT_LABEL###"] == 1) {
                                               $answer_content .= $input_label1;
                                           }
                                           $answer_content .= $this->pi_getLL('yes', 'yes') . $input_label2 . '</span>';
                                           if ($markerArrayQ["###MY_INPUT_ID###"]) {
                                               $input_id = 'id="answer' . $questionNumber . '_' . $answerNumber . '_0"';
                                           }
                                           if ($markerArrayQ["###MY_INPUT_LABEL###"]) {
                                               if ($markerArrayQ["###MY_INPUT_LABEL###"] == 3) {
                                                   $class_label = ' class="radio"';
                                               } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 4) {
                                                   $class_label = ' class="radio inline"';
                                               } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 6) {
                                                   $class_label = ' class="radio-inline"';
                                               } else {
                                                   $class_label = '';
                                               }
                                               if ($markerArrayQ["###MY_INPUT_LABEL###"] == 5) {
                                                   $label_wrap1 = '<div class="radio">';
                                                   $label_wrap2 = '</div>';
                                               } else {
                                                   $label_wrap1 = '';
                                                   $label_wrap2 = '';
                                               }
                                               $input_label1 = $label_wrap1 . '<label for="answer' . $questionNumber . '_' . $answerNumber . '_0"' . $class_label . '>';
                                               $input_label2 = '</label>' . $label_wrap2;
                                           }
                                           $answer_content .= ' <span class="' . $this->prefixId . '-no">';
                                           if ($markerArrayQ["###MY_INPUT_LABEL###"] > 1) {
                                               $answer_content .= $input_label1;
                                           }
                                           $answer_content .= '<input type="radio" name="tx_myquizpoll_pi1[answer' . $questionNumber . '_' . $currentValue . ']" ' . $input_id . ' value="0" ###MY_INPUT_RADIO###';
                                           if (is_array($oldRelData[$quid]) && !$oldRelData[$quid]['checked' . $currentValue]) {
                                               $answer_content .= ' checked="checked"';
                                           } elseif ($captchaError && $quizData['answer' . $questionNumber . '_' . $currentValue] == 0) {
                                               $answer_content .= ' checked="checked"';
                                           }
                                           $answer_content .= ' /> ';
                                           if ($markerArrayQ["###MY_INPUT_LABEL###"] == 1) {
                                               $answer_content .= $input_label1;
                                           }
                                           $answer_content .= $this->pi_getLL('no', 'no') . $input_label2 . '</span></span>';
                                       } else {
                                           if ($row['qtype'] == 5) {
                                               // textarea
                                               if ($markerArrayQ["###MY_INPUT_ID###"]) {
                                                   $input_id = 'id="answer' . $questionNumber . '"';
                                               }
                                               if ($markerArrayQ["###MY_INPUT_LABEL###"] == 5) {
                                                   $input_id .= ' class="form-control"';
                                               }
                                               if (is_array($oldRelData[$quid])) {
                                                   $value = str_replace('\\r\\n', "\r\n", $oldRelData[$quid]['textinput']);
                                               } else {
                                                   if ($captchaError) {
                                                       $value = $quizData['answer' . $questionNumber];
                                                   } else {
                                                       if ($row['answer2'] || $row['answer2'] === '0') {
                                                           $value = $row['answer2'];
                                                       } else {
                                                           $value = '';
                                                       }
                                                   }
                                               }
                                               $answer_content = '<textarea name="tx_myquizpoll_pi1[answer' . $questionNumber . ']" ' . $input_id . ' ###MY_INPUT_AREA###>' . $value . '</textarea> ';
                                           } else {
                                               if ($row['qtype'] == 7) {
                                                   // star-rating
                                                   if ($markerArrayQ["###MY_INPUT_ID###"]) {
                                                       $input_id = 'id="answer' . $questionNumber . '_' . $answerNumber . '"';
                                                   }
                                                   if ($markerArrayQ["###MY_INPUT_LABEL###"]) {
                                                       $input_label1 = '<label for="answer' . $questionNumber . '_' . $answerNumber . '">';
                                                       $input_label2 = '</label>';
                                                   }
                                                   $answer_content = '<input type="radio" class="star" name="tx_myquizpoll_pi1[answer' . $questionNumber . ']" value="' . $currentValue . '" ' . $input_id;
                                                   if (is_array($oldRelData[$quid]) && $oldRelData[$quid]['checked' . $currentValue]) {
                                                       $answer_content .= ' checked="checked"';
                                                   } elseif ($captchaError && $quizData['answer' . $questionNumber] == $currentValue) {
                                                       $answer_content .= ' checked="checked"';
                                                   }
                                                   $answer_content .= ' title="' . $answer_choice . '" /> ';
                                               } else {
                                                   // checkbox
                                                   if ($markerArrayQ["###MY_INPUT_ID###"]) {
                                                       $input_id = 'id="answer' . $questionNumber . '_' . $answerNumber . '"';
                                                   }
                                                   if ($markerArrayQ["###MY_INPUT_LABEL###"]) {
                                                       if ($markerArrayQ["###MY_INPUT_LABEL###"] == 3) {
                                                           $class_label = ' class="checkbox"';
                                                       } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 4) {
                                                           $class_label = ' class="checkbox inline"';
                                                       } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 6) {
                                                           $class_label = ' class="checkbox-inline"';
                                                       } else {
                                                           $class_label = '';
                                                       }
                                                       if ($markerArrayQ["###MY_INPUT_LABEL###"] == 5) {
                                                           $label_wrap1 = '<div class="checkbox">';
                                                           $label_wrap2 = '</div>';
                                                       } else {
                                                           $label_wrap1 = '';
                                                           $label_wrap2 = '';
                                                       }
                                                       $input_label1 = $label_wrap1 . '<label for="answer' . $questionNumber . '_' . $answerNumber . '"' . $class_label . '>';
                                                       $input_label2 = '</label>' . $label_wrap2;
                                                   }
                                                   $answer_content = '<input type="checkbox" name="tx_myquizpoll_pi1[answer' . $questionNumber . '_' . $currentValue . ']" value="' . $currentValue . '" ' . $input_id . ' ###MY_INPUT_CHECKBOX###';
                                                   if (is_array($oldRelData[$quid]) && $oldRelData[$quid]['checked' . $currentValue]) {
                                                       $answer_content .= ' checked="checked"';
                                                   } elseif ($captchaError && $quizData['answer' . $questionNumber . '_' . $currentValue] == $currentValue) {
                                                       $answer_content .= ' checked="checked"';
                                                   }
                                                   $answer_content .= ' /> ';
                                               }
                                           }
                                       }
                                   }
                               }
                           }
                           if (!$this->conf['dontShowPoints'] && !$this->conf['isPoll'] && $row['qtype'] < 5) {
                               $tmpPoints = 0;
                               if ($this->conf['noNegativePoints'] < 3 && $answerPointsBool) {
                                   $tmpPoints = intval($row['points' . $currentValue]);
                               }
                               if ($tmpPoints > 0) {
                                   $row['correct' . $currentValue] = true;
                               } else {
                                   $tmpPoints = intval($row['points']);
                               }
                               if ($row['correct' . $currentValue] || $row['qtype'] == 3) {
                                   if (($row['qtype'] == 0 || $row['qtype'] == 4) && $this->conf['noNegativePoints'] < 3) {
                                       $markerArray["###VAR_QUESTION_POINTS###"] += $tmpPoints;
                                       // points for each answer
                                   } else {
                                       if ($tmpPoints > $markerArray["###VAR_QUESTION_POINTS###"]) {
                                           $markerArray["###VAR_QUESTION_POINTS###"] = $tmpPoints;
                                           // points for each answer
                                       }
                                   }
                               }
                           }
                           $thisCat = $row['category' . $currentValue];
                           if ($this->catArray[$thisCat]) {
                               $markerArrayQ['###VAR_QA_CATEGORY###'] = $this->catArray[$thisCat]['name'];
                           }
                           if ($row['qtype'] < 3) {
                               if ($markerArrayQ["###MY_INPUT_LABEL###"] > 1) {
                                   $answer_content = $input_label1 . $answer_content . $answer_choice . $input_label2;
                               } else {
                                   $answer_content .= $input_label1 . $answer_choice . $input_label2;
                               }
                           }
                           if ($row['qtype'] == 2) {
                               $answer_content .= "</option>\n";
                               $markerArrayQ["###VAR_QUESTION_ANSWER###"] .= $this->cObj->substituteMarkerArray($answer_content, $markerArrayQ);
                           } else {
                               $markerArrayQ['###VAR_QUESTION_ANSWER###'] = $this->cObj->substituteMarkerArray($answer_content, $markerArrayQ);
                               $markerArray["###REF_QUESTION_ANSWER###"] .= $this->cObj->substituteMarkerArray($template_answer, $markerArrayQ);
                           }
                       }
                   }
                   if (!$this->conf['dontShowPoints'] && !$this->conf['isPoll'] && $row['qtype'] < 5) {
                       $markerArray["###VAR_NEXT_POINTS###"] += $markerArray["###VAR_QUESTION_POINTS###"];
                   }
                   $markerArray["###VAR_QUESTION_ANSWERS###"] = $answers;
                   if ($this->conf['allowSkipping']) {
                       // skip answers
                       $markerArrayQ["###VAR_QA_NR###"] = -1;
                       // Questtion type
                       if ($row['qtype'] == 1) {
                           if ($markerArrayQ["###MY_INPUT_ID###"]) {
                               $input_id = ' id="answer' . $questionNumber . '_x"';
                           }
                           if ($markerArrayQ["###MY_INPUT_LABEL###"]) {
                               if ($markerArrayQ["###MY_INPUT_LABEL###"] == 3) {
                                   $class_label = ' class="radio"';
                               } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 4) {
                                   $class_label = ' class="radio inline"';
                               } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 6) {
                                   $class_label = ' class="radio-inline"';
                               } else {
                                   $class_label = '';
                               }
                               if ($markerArrayQ["###MY_INPUT_LABEL###"] == 5) {
                                   $label_wrap1 = '<div class="radio">';
                                   $label_wrap2 = '</div>';
                               } else {
                                   $label_wrap1 = '';
                                   $label_wrap2 = '';
                               }
                               $input_label1 = $label_wrap1 . '<label for="answer' . $questionNumber . '_x"' . $class_label . '>';
                               $input_label2 = '</label>' . $label_wrap2;
                           }
                           $answer_content = '<input type="radio" name="tx_myquizpoll_pi1[answer' . $questionNumber . ']" value="-1"' . $input_id . ' /> ';
                           if ($markerArrayQ["###MY_INPUT_LABEL###"] > 1) {
                               $answer_content = $input_label1 . $answer_content . $this->pi_getLL('skip', 'skip') . $input_label2;
                           } else {
                               $answer_content .= $input_label1 . $this->pi_getLL('skip', 'skip') . $input_label2;
                           }
                       } else {
                           if ($row['qtype'] == 2) {
                               $answer_content = '<option value="-1"> ' . $this->pi_getLL('skip', 'skip') . '</option>';
                           } else {
                               if ($row['qtype'] < 6) {
                                   if ($markerArrayQ["###MY_INPUT_ID###"]) {
                                       $input_id = ' id="answer' . $questionNumber . '_x"';
                                   }
                                   if ($markerArrayQ["###MY_INPUT_LABEL###"]) {
                                       if ($markerArrayQ["###MY_INPUT_LABEL###"] == 3) {
                                           $class_label = ' class="checkbox"';
                                       } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 4) {
                                           $class_label = ' class="checkbox inline"';
                                       } elseif ($markerArrayQ["###MY_INPUT_LABEL###"] == 6) {
                                           $class_label = ' class="checkbox-inline"';
                                       } else {
                                           $class_label = '';
                                       }
                                       if ($markerArrayQ["###MY_INPUT_LABEL###"] == 5) {
                                           $label_wrap1 = '<div class="checkbox">';
                                           $label_wrap2 = '</div>';
                                       } else {
                                           $label_wrap1 = '';
                                           $label_wrap2 = '';
                                       }
                                       $input_label1 = $label_wrap1 . '<label for="answer' . $questionNumber . '_x"' . $class_label . '>';
                                       $input_label2 = '</label>' . $label_wrap2;
                                   }
                                   $answer_content = '<input type="checkbox" name="tx_myquizpoll_pi1[answer' . $questionNumber . ']" value="-1"' . $input_id . ' /> ';
                                   if ($markerArrayQ["###MY_INPUT_LABEL###"] > 1) {
                                       $answer_content = $input_label1 . $answer_content . $this->pi_getLL('skip', 'skip') . $input_label2;
                                   } else {
                                       $answer_content .= $input_label1 . $this->pi_getLL('skip', 'skip') . $input_label2;
                                   }
                               }
                           }
                       }
                       $markerArrayQ['###VAR_QA_CATEGORY###'] = '';
                       if ($row['qtype'] == 2) {
                           $markerArrayQ['###VAR_QUESTION_ANSWER###'] .= $answer_content;
                       } else {
                           $markerArrayQ['###VAR_QUESTION_ANSWER###'] = $answer_content;
                           $markerArray["###REF_QUESTION_ANSWER###"] .= $this->cObj->substituteMarkerArray($template_answer, $markerArrayQ);
                       }
                   }
                   if ($row['qtype'] == 2) {
                       $markerArrayQ["###VAR_QUESTION_ANSWER###"] .= "</select>\n";
                       $markerArray["###REF_QUESTION_ANSWER###"] .= $this->cObj->substituteMarkerArray($template_answer, $markerArrayQ);
                   }
                   if (($this->helperObj->getAskAtQ($quizData['qtuid']) || $questionNumber < $maxQuestions) && !$this->conf['isPoll']) {
                       $markerArray["###REF_DELIMITER###"] = $this->cObj->substituteMarkerArray($template_delimiter, $markerArray);
                   } else {
                       $markerArray["###REF_DELIMITER###"] = '';
                   }
                   if ($this->conf['enforceSelection']) {
                       // 25.1.10: antwort erzwingen?
                       $this->helperObj->addEnforceJsc($questionNumber, $answers, $row['qtype']);
                   }
                   //$this->subpart = $template;
                   $template2 = $this->cObj->substituteSubpart($template, '###TEMPLATE_QUESTION_ANSWER###', $markerArray["###REF_QUESTION_ANSWER###"], 0);
                   $markerArrayP["###REF_QUESTIONS###"] .= $this->cObj->substituteMarkerArray($template2, $markerArray);
                   // statt $content .= since 0.1.8
                   $markerArrayP["###REF_QUESTIONS###"] .= '<input type="hidden" name="tx_myquizpoll_pi1[uid' . $questionNumber . ']" value="' . $quid . '" class="input_hidden" />';
                   if ($this->conf['isPoll']) {
                       // link to the result page
                       $urlParameters = array("tx_myquizpoll_pi1[cmd]" => "list", "tx_myquizpoll_pi1[qid]" => $quid, "no_cache" => "1");
                       $markerArray["###POLLRESULT_URL###"] = $this->pi_linkToPage($this->pi_getLL('poll_url', 'poll_url'), $listPID, $target = '', $urlParameters);
                   }
                   $lastUID = $quid;
               }
               $markerArrayP["###REF_SUBMIT_FIELDS###"] = '';
               $markerArrayP["###HIDDENFIELDS###"] = '';
               $markerArrayP["###VAR_QID###"] = $lastUID;
               // last question uid, added on 23.1.2011
               if ($this->conf['isPoll']) {
                   $markerArrayP["###VAR_FID###"] = '';
                   $markerArrayP["###POLLRESULT###"] = $this->pi_getLL('poll_url', 'poll_url');
                   $markerArrayP["###NUM_VOTES###"] = $this->pi_getLL('num_votes', 'num_votes');
                   if ($this->conf['rating.']['parameter']) {
                       // rating
                       $markerArrayP["###VAR_FID###"] = $this->helperObj->getForeignId();
                       // a foreign uid, added on 23.1.2011
                   }
               }
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('last question: ' . $lastUID, $this->extKey, 0);
               }
               // back-button
               if ($this->conf['allowBack'] && $this->conf['pageQuestions'] && $quizData['qtuid']) {
                   $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="' . $this->prefixId . '[back]" value="' . $back . '" />';
                   $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="' . $this->prefixId . '[back-hit]" value="0" />';
                   $markerArray['###BACK_STYLE###'] = $seite == 1 ? ' style="display:none;"' : '';
               } else {
                   $markerArray['###BACK_STYLE###'] = ' style="display:none;"';
               }
               // Submit/User-Data Template
               if ($this->helperObj->getAskAtQ($quizData['qtuid']) && !$this->conf['isPoll']) {
                   $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_USER_TO_SUBMIT###");
                   if (is_object($this->freeCap) && $this->conf['enableCaptcha']) {
                       $markerArray = array_merge($markerArray, $this->freeCap->makeCaptcha());
                   } else {
                       $subpartArray['###CAPTCHA_INSERT###'] = '';
                   }
                   $markerArrayP["###REF_SUBMIT_FIELDS###"] = $this->cObj->substituteMarkerArrayCached($template, $markerArray, $subpartArray, $wrappedSubpartArray);
               } else {
                   if (!($answeredQuestions == $lastUID && $this->conf["isPoll"])) {
                       $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_SUBMIT###");
                       $markerArrayP["###REF_SUBMIT_FIELDS###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
                       $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="name" value="' . $markerArray["###DEFAULT_NAME###"] . '" /> ';
                       // fürs Template?
                       $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="' . $this->prefixId . '[name]" value="' . htmlspecialchars($quizData["name"]) . '" />';
                       $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="' . $this->prefixId . '[email]" value="' . htmlspecialchars($quizData["email"]) . '" />';
                       $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="' . $this->prefixId . '[homepage]" value="' . htmlspecialchars($quizData["homepage"]) . '" />';
                   } else {
                       $markerArray["###NO_SUBMIT###"] = $this->pi_getLL('no_submit', 'no_submit');
                       $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_NO_SUBMIT###");
                       $markerArrayP["###REF_SUBMIT_FIELDS###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
                       // new in 0.1.8
                   }
               }
               if (!$this->conf['isPoll']) {
                   // when is Poll, do not update result-table
                   $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="' . $this->prefixId . '[qtuid]" value="' . intval($quizData["qtuid"]) . '" />';
               }
               if ($this->conf['hideByDefault']) {
                   $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="' . $this->prefixId . '[hidden]" value="1" />';
               }
               if (!$quizData['qtuid']) {
                   $markerArrayP["###HIDDENFIELDS###"] .= '
 <input type="hidden" name="' . $this->prefixId . '[start_uid]" value="' . $GLOBALS['TSFE']->id . '" />
 <input type="hidden" name="' . $this->prefixId . '[time]" value="' . time() . '" />';
               }
               $markerArrayP["###HIDDENFIELDS###"] .= '
 <input type="hidden" name="' . $this->prefixId . '[cmd]" value="submit" />';
               //  <input type="hidden" name="no_cache" value="1" />		KGB: auskommentiert am 30.5.2015
               if ($this->conf['useJokers'] && $this->conf['pageQuestions'] == 1) {
                   $markerArrayP["###HIDDENFIELDS###"] .= '
 <input type="hidden" name="' . $this->prefixId . '[joker1]" value="0" />
 <input type="hidden" name="' . $this->prefixId . '[joker2]" value="0" />
 <input type="hidden" name="' . $this->prefixId . '[joker3]" value="0" />';
               }
               $markerArrayP["###MAX_PAGES###"] = $this->helperObj->getMaxPages();
               $markerArrayP["###PAGE###"] = $this->helperObj->getPage($questTillNow);
               $markerArrayP["###FE_USER_UID###"] = intval($GLOBALS['TSFE']->fe_user->user['uid']);
               $markerArrayP["###SUBMIT_JSC###"] = $this->helperObj->getSubmitJsc();
               $questionPage = true;
           } else {
               // final page: no more questions left, if pageQuestions > 0
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('0 questions found. Entering final page...', $this->extKey, 0);
               }
               // if ($oldLoaded) $secondVisit = true;	// Keine Email schicken, wenn alle Fragen schon beantwortet wurden: NE, so einfach ist das nicht :-(
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_NO_MORE###");
               $markerArray["###NO_MORE###"] = $this->pi_getLL('no_more', 'no_more');
               $markerArray['###YOUR_EVALUATION###'] = $this->pi_getLL('your_evaluation', 'your_evaluation');
               $markerArray['###REACHED1###'] = $this->pi_getLL('reached1', 'reached1');
               $markerArray['###REACHED2###'] = $this->pi_getLL('reached2', 'reached2');
               $markerArray['###POINTS###'] = $this->pi_getLL('points', 'points');
               /*    if ($this->conf['startPID'])        // wir sind nicht auf der Startseite, also parent holen...
                         $restart_id = $this->conf['startPID']; // $GLOBALS['TSFE']->page['pid'];
                     else 
                         $restart_id = $GLOBALS['TSFE']->id;    */
               $markerArray["###RESTART_QUIZ###"] = $this->pi_linkToPage($this->pi_getLL('restart_quiz', 'restart_quiz'), $startPID, $target = '', array());
               if ($this->conf['allowCookieReset']) {
                   $markerArray["###RESET_COOKIE###"] = $this->pi_linkToPage($this->pi_getLL('reset_cookie', 'reset_cookie'), $startPID, $target = '', array($this->prefixId . '[resetcookie]' => 1));
               } else {
                   $markerArray["###RESET_COOKIE###"] = '';
               }
               $questions = '';
               if ($this->conf['showAllCorrectAnswers'] && !$this->conf['isPoll']) {
                   // show all answers...
                   /*if ($this->conf['finishAfterQuestions'])
                         $fragen = intval($this->conf['finishAfterQuestions']);
                     else
                         $fragen = $this->helperObj->getQuestionsNo();*/
                   $questions = $this->showAllAnswers($quizData, $thePID, $resPID, false, 0);
                   // 24.01.10: 0 statt $fragen
               }
               $subpart = $template;
               $template = $this->cObj->substituteSubpart($subpart, '###QUIZ_ANSWERS###', $questions);
               $markerArrayP["###REF_NO_MORE###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
               $markerArrayP["###RESTART_QUIZ###"] = $markerArray["###RESTART_QUIZ###"];
               $markerArrayP["###RESET_COOKIE###"] = $markerArray["###RESET_COOKIE###"];
               if ($this->conf['highscore.']['showAtFinal']) {
                   $quizData['cmd'] = 'score';
               }
               $finalPage = true;
           }
           // myVars for page
           $markerArrayP = array_merge($markerArrayP, $this->helperObj->setPageVars());
       } else {
           if ($this->conf['showAnswersSeparate'] && $quizData['cmd'] == 'submit' && !$this->conf['isPoll'] && $no_rights == 0) {
               /* ***************************************************** */
               /*
                * Display only a next button
                */
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_NEXT###");
               $markerArray["###HIDDENFIELDS###"] = '';
               // back-button
               if ($this->conf['allowBack'] && $this->conf['pageQuestions'] && $quizData['qtuid']) {
                   $markerArray['###BACK_STYLE###'] = '';
                   $markerArray["###HIDDENFIELDS###"] .= '<input type="hidden" name="' . $this->prefixId . '[back]" value="' . $back . '" />
   <input type="hidden" name="' . $this->prefixId . '[back-hit]" value="0" />';
               } else {
                   $markerArray['###BACK_STYLE###'] = ' style="display:none;"';
               }
               if ($template == '') {
                   // if it is not in the template
                   $template = $this->cObj->getSubpart($this->origTemplateCode, "###TEMPLATE_NEXT###");
               }
               $markerArrayP["###REF_NEXT###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
               // instead $content
           }
       }
       /** Redirect to the final page? **/
       if ($finalPage && $quizData['cmd'] != 'exit' && $this->conf['finalPID'] && $finalPID != intval($GLOBALS["TSFE"]->id)) {
           $this->redirectUrl($finalPID, array($this->prefixId . '[qtuid]' => intval($quizData["qtuid"]), $this->prefixId . '[cmd]' => 'next'));
           break;
           // unnoetig...
       }
       /** Poll result? **/
       if ($answerPage && $this->conf['isPoll']) {
           $quizData['cmd'] = 'list';
       }
       // Make a page-layout
       if ($quizData['cmd'] == 'allanswers' && !$this->conf['isPoll']) {
           /* ***************************************************** */
           /*
            * Display all questions and correct answers
            */
           if ($this->helperObj->writeDevLog) {
               t3lib_div::devLog("show answers of: {$thePID},{$resPID}", $this->extKey, 0);
           }
           $content .= $this->showAllAnswers($quizData, $thePID, $resPID, false, 0);
           // 24.01.10: 0 statt $this->helperObj->getQuestionsNo()
       }
       if ($quizData['cmd'] == 'score' && !$this->conf['isPoll']) {
           /* ***************************************************** */
           /*
            * Display highscore page: top 10 table
            */
           if ($quizData["setUserData"] && $quizData['qtuid'] && $quizData["name"]) {
               // ggf. erst Benutzerdaten in der DB setzen...
               $uid = intval($quizData['qtuid']);
               $firsttime = $this->helperObj->getFirstTime($uid);
               if ($firsttime == intval($quizData["setUserData"])) {
                   // Security test bestanden?
                   // update current user entry
                   $timestamp = time();
                   // Avoid bad characters in database request
                   $quiz_taker_name = $GLOBALS['TYPO3_DB']->quoteStr($quizData["name"], $this->tableAnswers);
                   $quiz_taker_email = $GLOBALS['TYPO3_DB']->quoteStr($quizData["email"], $this->tableAnswers);
                   $quiz_taker_homepage = $GLOBALS['TYPO3_DB']->quoteStr($quizData["homepage"], $this->tableAnswers);
                   $hidden = intval($quizData["hidden"]);
                   $update = array('tstamp' => $timestamp, 'name' => $quiz_taker_name, 'email' => $quiz_taker_email, 'homepage' => $quiz_taker_homepage, 'hidden' => $hidden);
                   // Hook for tt_address
                   if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['setAdrHook']) && $this->conf['userData.']['tt_address_pid']) {
                       foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['setAdrHook'] as $_classRef) {
                           $_procObj =& t3lib_div::getUserObj($_classRef);
                           $update['address_uid'] = intval($_procObj->setAdr($quizData, $this->conf['userData.']['tt_address_pid'], $this->conf['userData.']['tt_address_groups']));
                       }
                   }
                   $success = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->tableAnswers, 'uid=' . $uid . ' AND sys_language_uid=' . $this->lang, $update);
                   if (!$success) {
                       $content .= "<p>MySQL Update-Error :-(</p>";
                   }
               }
               if ($this->conf['email.']['send_admin'] == 2 || $this->conf['email.']['send_user'] == 2) {
                   $sendMail = true;
               }
           }
           if ($finalPage) {
               $markerArrayP["###REF_HIGHSCORE###"] = $this->showHighscoreList($quizData, $resPIDs, $listPID);
           } else {
               $content .= $this->showHighscoreList($quizData, $resPIDs, $listPID);
           }
       } else {
           if ($quizData['cmd'] == 'list' && $this->conf['isPoll']) {
               /* ***************************************************** */
               /*
                * Display poll result
                */
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('Poll result: searching question in ' . $thePID . ' and results in ' . $resPID, $this->extKey, 0);
               }
               if ($answerPage) {
                   $markerArrayP["###REF_POLLRESULT###"] = $this->showPollResult($answered, $quizData, $thePID, $resPID);
               } else {
                   $content .= $this->showPollResult($answered, $quizData, $thePID, $resPID);
               }
           }
       }
       if (!$this->conf['isPoll'] && $quizData['cmd'] != 'score') {
           // show highscore link?
           $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_HIGHSCORE_URL###");
           $markerArrayP["###REF_HIGHSCORE_URL###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
       }
       if ($this->conf['isPoll'] && $quizData['cmd'] != 'list') {
           // show poll result link?
           $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_POLLRESULT_URL###");
           $markerArrayP["###REF_POLLRESULT_URL###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
       }
       /** Layout for the start page **/
       if ($startPage) {
           $markerArrayP["###REF_PAGE_LIMIT###"] = '';
           $markerArrayP["###REF_QUIZ_LIMIT###"] = '';
           $markerArrayP["###HIDDENFIELDS###"] = '<input type="hidden" name="' . $this->prefixId . '[fromStart]" value="1" />';
           $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_USER_TO_SUBMIT###");
           $markerArray['###BACK_STYLE###'] = ' style="display:none;"';
           if (is_object($this->freeCap) && $this->conf['enableCaptcha']) {
               $markerArray = array_merge($markerArray, $this->freeCap->makeCaptcha());
           } else {
               $subpartArray['###CAPTCHA_INSERT###'] = '';
           }
           $markerArrayP["###REF_SUBMIT_FIELDS###"] = $this->cObj->substituteMarkerArrayCached($template, $markerArray, $subpartArray, $wrappedSubpartArray);
           $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUESTION_PAGE###");
           if ($template == '') {
               // if it is not in the template
               $template = $this->cObj->getSubpart($this->origTemplateCode, "###TEMPLATE_QUESTION_PAGE###");
           }
           $content .= $this->cObj->substituteMarkerArray($template, $markerArrayP);
       }
       /** Layout for a result page **/
       if ($answerPage && $quizData['cmd'] != 'exit') {
           if ($this->conf['quizTimeMinutes']) {
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_TIME_LIMIT###");
               if (!$quizData['qtuid']) {
                   $markerArray["###VAR_SECS###"] = intval($this->conf['quizTimeMinutes']) * 60;
                   $markerArray["###VAR_MIN###"] = $this->conf['quizTimeMinutes'];
               } else {
                   $markerArray["###VAR_SECS###"] = intval($this->conf['quizTimeMinutes']) * 60 - $elapseTime;
                   $markerArray["###VAR_MIN###"] = round($markerArray["###VAR_SECS###"] / 60);
               }
               $markerArrayP["###REF_QUIZ_LIMIT###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
           } else {
               $markerArrayP["###REF_QUIZ_LIMIT###"] = '';
           }
           if ($this->helperObj->writeDevLog) {
               t3lib_div::devLog('Displaying result-page...', $this->extKey, 0);
           }
           $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_RESULT_PAGE###");
           if ($template == '') {
               // if it is not in the (old custom) template
               $template = $this->cObj->getSubpart($this->origTemplateCode, "###TEMPLATE_RESULT_PAGE###");
           }
           $content .= $this->cObj->substituteMarkerArray($template, $markerArrayP);
           if ($this->conf['isPoll'] && $this->conf['email.']['send_admin']) {
               $sendMail = true;
           }
       }
       /** Layout for a questions page **/
       if ($questionPage && $quizData['cmd'] != 'exit') {
           if ($this->conf['pageTimeSeconds']) {
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_PAGE_TIME_LIMIT###");
               $markerArray["###VAR_SECS###"] = $pageTimeCat ? $pageTimeCat : $this->conf['pageTimeSeconds'];
               $markerArrayP["###REF_PAGE_LIMIT###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
           } else {
               $markerArrayP["###REF_PAGE_LIMIT###"] = '';
           }
           if ($this->conf['quizTimeMinutes']) {
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_TIME_LIMIT###");
               if (!$quizData['qtuid']) {
                   $markerArray["###VAR_SECS###"] = intval($this->conf['quizTimeMinutes']) * 60;
                   $markerArray["###VAR_MIN###"] = $this->conf['quizTimeMinutes'];
               } else {
                   $markerArray["###VAR_SECS###"] = intval($this->conf['quizTimeMinutes']) * 60 - $elapseTime;
                   $markerArray["###VAR_MIN###"] = round($markerArray["###VAR_SECS###"] / 60);
               }
               $markerArrayP["###REF_QUIZ_LIMIT###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
           } else {
               $markerArrayP["###REF_QUIZ_LIMIT###"] = '';
           }
           $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUESTION_PAGE###");
           if ($template == '') {
               // if it is not in the template
               $template = $this->cObj->getSubpart($this->origTemplateCode, "###TEMPLATE_QUESTION_PAGE###");
           }
           $content .= $this->cObj->substituteMarkerArray($template, $markerArrayP);
       }
       /** Layout for the last/final page **/
       $uidP = 0;
       // page UID
       $uidC = 0;
       // content UID
       if ($finalPage && $quizData['cmd'] != 'exit') {
           // nicht noetig: && !$this->conf['isPoll']) {
           if (($this->conf['showAnalysis'] || $this->conf['showEvaluation']) && !$this->conf['dontShowPoints']) {
               // Analysis depends on points
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('Displaying Analysis: ' . $this->conf['showAnalysis'] . ' or Evaluation: ' . $this->conf['showEvaluation'], $this->extKey, 0);
               }
               if (!$markerArray["###VAR_TMAX_POINTS###"]) {
                   $this->helperObj->setQuestionsVars();
                   $markerArray["###VAR_TMAX_POINTS###"] = $this->helperObj->getQuestionsMaxPoints();
                   // omax und tmax sollten hier gleich sein
                   if (!$markerArray["###VAR_TMAX_POINTS###"]) {
                       $markerArray["###VAR_TMAX_POINTS###"] = 100000;
                   }
                   // notfalls halt irgendein wert
               }
               $points = $markerArray["###VAR_TOTAL_POINTS###"];
               $percent = 100 * $points / $markerArray["###VAR_TMAX_POINTS###"];
               // genauerer wert...
               $markerArray["###VAR_PERCENT###"] = intval($percent);
               $markerArray["###REACHED1###"] = $this->pi_getLL('reached1', 'reached1');
               $markerArray["###REACHED2###"] = $this->pi_getLL('reached2', 'reached2');
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('Total points=' . $markerArray["###VAR_TOTAL_POINTS###"] . ' tmax points=' . $markerArray["###VAR_TMAX_POINTS###"] . ' percent=' . $markerArray["###VAR_PERCENT###"], $this->extKey, 0);
               }
               if ($this->conf['showAnalysis']) {
                   $dataArray = explode(',', $this->conf['showAnalysis']);
               } else {
                   $dataArray = explode(',', $this->conf['showEvaluation']);
               }
               $templateNo = '';
               $p = 0;
               while ($p < count($dataArray)) {
                   $templateNo = $dataArray[$p];
                   if (strpos($templateNo, ':') !== false) {
                       if ($this->conf['showAnalysis']) {
                           list($templateNo, $uidP) = explode(":", $templateNo);
                       } else {
                           list($templateNo, $uidC) = explode(":", $templateNo);
                       }
                   }
                   if ($this->conf['showAnalysis']) {
                       if ($percent <= floatval($templateNo)) {
                           // wann abbrechen?
                           //    if ($uidP) ...    // redirect to a URL with that UID  -> weiter nach unten verschoben (nach email Versendung!!)
                           break;
                       }
                   } else {
                       if ($points <= floatval($templateNo)) {
                           // wann abbrechen?
                           break;
                       }
                   }
                   $p++;
               }
               if (!($uidP || $uidC)) {
                   $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_ANALYSIS_{$templateNo}###");
                   $markerArrayP["###REF_QUIZ_ANALYSIS###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
               } else {
                   if ($uidC) {
                       $confC = array('tables' => 'tt_content', 'source' => $uidC, 'dontCheckPid' => 1);
                       $markerArrayP["###REF_QUIZ_ANALYSIS###"] = $this->cObj->RECORDS($confC);
                   }
               }
           } else {
               if ($this->conf['showCategoryElement']) {
                   $showCategoryElement = intval($this->conf['showCategoryElement']);
                   if ($this->helperObj->writeDevLog) {
                       t3lib_div::devLog('Displaying category element: ' . $showCategoryElement . ' nextcat: ' . $nextCat, $this->extKey, 0);
                   }
                   if ($showCategoryElement == 1 && $nextCat > 0 && $this->catArray[$nextCat]['celement']) {
                       $uidC = $this->catArray[$nextCat]['celement'];
                       $confC = array('tables' => 'tt_content', 'source' => $uidC, 'dontCheckPid' => 1);
                       $markerArrayP["###REF_QUIZ_ANALYSIS###"] = $this->cObj->RECORDS($confC);
                       // last category element
                   } else {
                       if ($showCategoryElement > 1 && $this->conf['advancedStatistics']) {
                           $tmpCat = '';
                           $usedCatArray = array();
                           $catCount = 0;
                           $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('DISTINCT nextcat, COUNT(nextcat) anzahl', $this->tableRelation, 'nextcat>0 AND user_id=' . intval($quizData['qtuid']) . ' AND sys_language_uid=' . $this->lang, 'nextcat', 'anzahl DESC', '');
                           $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
                           if ($rows > 0) {
                               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5)) {
                                   $tmpCat = $row['nextcat'];
                                   if ($catCount == 0) {
                                       $firstCount = $row['anzahl'];
                                   }
                                   if ($tmpCat && $this->catArray[$tmpCat]['celement'] && ($showCategoryElement == 4 || $showCategoryElement == 3 && $firstCount == $row['anzahl'] || $catCount == 0)) {
                                       $usedCatArray[$tmpCat] = $row['anzahl'];
                                   }
                                   $catCount += $row['anzahl'];
                               }
                           }
                           if (count($usedCatArray) > 0) {
                               $markerArrayC = array();
                               $markerArrayC['###PREFIX###'] = $markerArrayP['###PREFIX###'];
                               $markerArrayC['###ANSWERS###'] = $this->pi_getLL('answers', 'answers');
                               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_CATEGORY_ELEMENT###");
                               foreach ($usedCatArray as $key => $value) {
                                   $uidC = $this->catArray[$key]['celement'];
                                   $confC = array('tables' => 'tt_content', 'source' => $uidC, 'dontCheckPid' => 1);
                                   $markerArrayC['###CATEGORY###'] = $this->catArray[$key]['name'];
                                   $markerArrayC['###CONTENT###'] = $this->cObj->RECORDS($confC);
                                   // most category element
                                   $markerArrayC['###VAR_COUNT###'] = $value;
                                   $markerArrayC['###VAR_PERCENT###'] = round(100 * $value / $catCount);
                                   $markerArrayP["###REF_QUIZ_ANALYSIS###"] .= $this->cObj->substituteMarkerArray($template, $markerArrayC);
                               }
                           }
                           $GLOBALS['TYPO3_DB']->sql_free_result($res5);
                       }
                   }
               }
           }
           if (!$uidP) {
               // no redirect
               $markerArrayP["###FORM_URL###"] = $this->pi_getPageLink($listPID);
               // zur endgueltig letzten seite wechseln
               $markerArrayP["###REF_SUBMIT_FIELDS###"] = '';
               $markerArrayP["###HIDDENFIELDS###"] = '';
               $markerArrayP["###FE_USER_UID###"] = intval($GLOBALS['TSFE']->fe_user->user['uid']);
               if ($this->conf['userData.']['showAtFinal']) {
                   $quiz_taker_name = $GLOBALS['TYPO3_DB']->quoteStr($quizData["name"], $this->tableAnswers);
                   $quiz_taker_email = $GLOBALS['TYPO3_DB']->quoteStr($quizData["email"], $this->tableAnswers);
                   $quiz_taker_homepage = $GLOBALS['TYPO3_DB']->quoteStr($quizData["homepage"], $this->tableAnswers);
                   $markerArray["###REAL_NAME###"] = $quiz_taker_name;
                   $markerArray["###REAL_EMAIL###"] = $quiz_taker_email;
                   $markerArray["###REAL_HOMEPAGE###"] = $quiz_taker_homepage;
                   $markerArray["###RESULT_FOR###"] = $this->pi_getLL('result_for', 'result_for');
                   $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_USER_SUBMITED###");
                   // Output the user name
                   $markerArrayP["###REF_INTRODUCTION###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
               }
               // User-Data Template
               if ($this->conf['userData.']['askAtFinal'] && $quizData['qtuid']) {
                   $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_USER_TO_SUBMIT###");
                   $markerArray['###BACK_STYLE###'] = ' style="display:none;"';
                   if (is_object($this->freeCap) && $this->conf['enableCaptcha']) {
                       $markerArray = array_merge($markerArray, $this->freeCap->makeCaptcha());
                   } else {
                       $subpartArray['###CAPTCHA_INSERT###'] = '';
                   }
                   $firsttime = $this->helperObj->getFirstTime($quizData['qtuid']);
                   $markerArrayP["###REF_SUBMIT_FIELDS###"] = $this->cObj->substituteMarkerArrayCached($template, $markerArray, $subpartArray, $wrappedSubpartArray);
                   $markerArrayP["###HIDDENFIELDS###"] = "\n" . '  <input type="hidden" name="' . $this->prefixId . '[qtuid]" value="' . intval($quizData["qtuid"]) . '" />' . "\n";
                   $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="' . $this->prefixId . '[setUserData]" value="' . $firsttime . '" />' . "\n";
                   $markerArrayP["###HIDDENFIELDS###"] .= '  <input type="hidden" name="' . $this->prefixId . '[fromFinal]" value="1" />';
               }
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_FINAL_PAGE###");
               if ($template == '') {
                   // if it is not in the template
                   $template = $this->cObj->getSubpart($this->origTemplateCode, "###TEMPLATE_QUIZ_FINAL_PAGE###");
               }
               $content .= $this->cObj->substituteMarkerArray($template, $markerArrayP);
           }
           if ($this->conf['email.']['send_admin'] == 1 || $this->conf['email.']['send_user'] == 1) {
               $sendMail = true;
           }
       }
       /** Send an/two email(s)? **/
       if ($sendMail && !$error && !$secondVisit) {
           if ($this->helperObj->writeDevLog) {
               t3lib_div::devLog('Entering "send emails"...', $this->extKey, 0);
           }
           $markerArrayP["###EMAIL_TAKEN###"] = $this->pi_getLL('email_taken', 'email_taken');
           if (!$markerArrayP["###REF_INTRODUCTION###"] && !$this->conf['isPoll']) {
               if (!$markerArray["###RESULT_FOR###"]) {
                   $markerArray["###REAL_NAME###"] = htmlspecialchars($quizData['name']);
                   $markerArray["###REAL_EMAIL###"] = htmlspecialchars($quizData['email']);
                   $markerArray["###REAL_HOMEPAGE###"] = htmlspecialchars($quizData['homepage']);
                   $markerArray["###RESULT_FOR###"] = $this->pi_getLL('result_for', 'result_for');
               }
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_QUIZ_USER_SUBMITED###");
               // Output the user name
               $markerArrayP["###REF_INTRODUCTION###"] = $this->cObj->substituteMarkerArray($template, $markerArray);
           }
           if ($this->conf['showAllCorrectAnswers'] && !$this->conf['isPoll']) {
               // show all answers...
               $quizData['sendEmailNow'] = true;
               // noetig um zu wissen, welches Template genommen werden soll
               $markerArrayP["###REF_EMAIL_ALLANSWERS###"] = $this->showAllAnswers($quizData, $thePID, $resPID, true, 0);
           } else {
               $markerArrayP["###REF_EMAIL_ALLANSWERS###"] = '';
           }
           if ($this->conf['email.']['send_admin'] && t3lib_div::validEmail($this->conf['email.']['admin_mail']) && $this->conf['email.']['admin_subject']) {
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('Sending email to admin: ' . $this->conf['email.']['admin_mail'], $this->extKey, 0);
               }
               $markerArrayP["###SUBJECT###"] = $this->conf['email.']['admin_subject'];
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_ADMIN_EMAIL###");
               if ($template == '') {
                   // if it is not in the template
                   $template = $this->cObj->getSubpart($this->origTemplateCode, "###TEMPLATE_ADMIN_EMAIL###");
               }
               $mailcontent = $this->cObj->substituteMarkerArray($template, $markerArrayP);
               $this->helperObj->sendEmail($mailcontent, '', $this->conf['email.']['admin_mail'], $this->conf['email.']['admin_name'], $this->conf['email.']['admin_subject']);
           }
           if ($this->conf['email.']['send_user'] && t3lib_div::validEmail($quizData["email"]) && $this->conf['email.']['user_subject']) {
               if ($this->helperObj->writeDevLog) {
                   t3lib_div::devLog('Sending email to user: '******'email.']['user_subject'];
               $template = $this->cObj->getSubpart($this->templateCode, "###TEMPLATE_USER_EMAIL###");
               if ($template == '') {
                   // if it is not in the template
                   $template = $this->cObj->getSubpart($this->origTemplateCode, "###TEMPLATE_USER_EMAIL###");
               }
               $mailcontent = $this->cObj->substituteMarkerArray($template, $markerArrayP);
               $this->helperObj->sendEmail($mailcontent, '', $quizData["email"], $quizData["name"], $this->conf['email.']['user_subject']);
           }
       }
       /** Delete user result at the end of the quiz? **/
       if ($finalPage && $this->conf['deleteResults']) {
           // 60*60*24 = 86400 = 1 tag
           $loesche = '';
           $counter = 0;
           $where = 'pid=' . $resPID;
           $where .= ' AND (crdate<' . (time() - 86400) . ' OR uid=' . intval($quizData['qtuid']) . ')';
           if ($this->conf['deleteResults'] == 2) {
               $where .= ' AND fe_uid=0';
           }
           if ($this->conf['deleteResults'] == 3) {
               $where .= " AND name='" . $GLOBALS['TYPO3_DB']->quoteStr($this->pi_getLL('no_name', 'no_name'), $this->tableAnswers) . "'";
           }
           $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $this->tableAnswers, $where, '', 'crdate DESC', '255');
           if ($GLOBALS['TYPO3_DB']->sql_num_rows($res5) > 0) {
               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5)) {
                   $loesche .= ', ' . $row['uid'];
                   $counter++;
               }
               $loesche = substr($loesche, 1);
           }
           $GLOBALS['TYPO3_DB']->sql_free_result($res5);
           if ($this->conf['deleteDouble'] && $counter < 250) {
               // mehrfache eintraege eines users zu einem quiz loeschen
               $where2 = '';
               $fe_uid = intval($GLOBALS['TSFE']->fe_user->user['uid']);
               if ($this->conf['deleteResults'] == 2 && $fe_uid > 0) {
                   $where2 = ' AND fe_uid=' . $fe_uid;
               } else {
                   if ($this->conf['deleteResults'] == 3 && $quizData["name"] != $this->pi_getLL('no_name', 'no_name') && $quizData["name"]) {
                       $where2 = " AND name='" . $GLOBALS['TYPO3_DB']->quoteStr($quizData["name"], $this->tableAnswers) . "'";
                   }
               }
               if ($where2) {
                   $start_uid = $this->helperObj->getStartUid($quizData['qtuid']);
                   $res5 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid, o_percent, crdate', $this->tableAnswers, 'pid=' . $resPID . ' AND sys_language_uid=' . $this->lang . ' AND start_uid=' . $start_uid . $where2, '', 'o_percent DESC, crdate DESC', '200');
                   $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($res5);
                   if ($rows > 0) {
                       $counter = 0;
                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res5)) {
                           $counter++;
                           if ($counter > 1) {
                               $loesche .= $loesche ? ',' . $row['uid'] : $row['uid'];
                           }
                       }
                   }
                   $GLOBALS['TYPO3_DB']->sql_free_result($res5);
               }
           }
           if ($this->helperObj->writeDevLog) {
               t3lib_div::devLog('Deleting result data with: ' . $where . $where2 . ' => ' . $loesche, $this->extKey, 0);
           }
           if ($loesche) {
               $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery($this->tableRelation, 'user_id IN (' . preg_replace('/[^0-9,]/', '', $loesche) . ')');
               $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery($this->tableAnswers, 'uid IN (' . preg_replace('/[^0-9,]/', '', $loesche) . ')');
           }
       }
       /** Redirect at the end of the quiz? **/
       if ($finalPage && $uidP) {
           // redirect to a URL with that UID
           $this->redirectUrl($uidP, array($this->prefixId . '[name]' => $quizData["name"], $this->prefixId . '[email]' => $quizData["email"], $this->prefixId . '[homepage]' => $quizData["homepage"]));
       }
       if ($this->helperObj->writeDevLog) {
           t3lib_div::devLog('return the content to the Typo3 core', $this->extKey, 0);
       }
       return $this->pi_wrapInBaseClass($content);
   }
    /**
     * [Describe function...]
     *
     * @param	[type]		$row: ...
     * @param	[type]		$conf: ...
     * @param	[type]		$table: ...
     * @return	[type]		...
     */
    function resultRowDisplay($row, $conf, $table)
    {
        static $even = FALSE;
        $tce = t3lib_div::makeInstance('t3lib_TCEmain');
        $SET = $GLOBALS['SOBE']->MOD_SETTINGS;
        $out = '<tr class="bgColor' . ($even ? '6' : '4') . '">';
        $even = !$even;
        foreach ($row as $fN => $fV) {
            if (t3lib_div::inList($SET['queryFields'], $fN) || !$SET['queryFields'] && $fN != 'pid' && $fN != 'deleted') {
                if ($SET['search_result_labels']) {
                    $fVnew = $this->getProcessedValueExtra($table, $fN, $fV, $conf, '<br />');
                } else {
                    $fVnew = htmlspecialchars($fV);
                }
                $out .= '<td>' . $fVnew . '</td>';
            }
        }
        $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
        $out .= '<td nowrap>';
        if (!$row['deleted']) {
            $out .= '<a href="#" onClick="top.launchView(\'' . $table . '\',' . $row['uid'] . ',\'' . $GLOBALS['BACK_PATH'] . '\');return false;">' . t3lib_iconWorks::getSpriteIcon('status-dialog-information') . '</a>';
            $out .= '<a href="#" onClick="' . t3lib_BEfunc::editOnClick($params, $GLOBALS['BACK_PATH'], t3lib_div::getIndpEnv('REQUEST_URI') . t3lib_div::implodeArrayForUrl('SET', (array) t3lib_div::_POST('SET'))) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
        } else {
            $out .= '<a href="' . t3lib_div::linkThisUrl($GLOBALS['BACK_PATH'] . 'tce_db.php', array('cmd[' . $table . '][' . $row['uid'] . '][undelete]' => '1', 'redirect' => t3lib_div::linkThisScript(array()))) . t3lib_BEfunc::getUrlToken('tceAction') . '">';
            $out .= t3lib_iconWorks::getSpriteIcon('actions-edit-restore', array('title' => 'undelete only')) . '</a>';
            $out .= '<a href="' . t3lib_div::linkThisUrl($GLOBALS['BACK_PATH'] . 'tce_db.php', array('cmd[' . $table . '][' . $row['uid'] . '][undelete]' => '1', 'redirect' => t3lib_div::linkThisUrl('alt_doc.php', array('edit[' . $table . '][' . $row['uid'] . ']' => 'edit', 'returnUrl' => t3lib_div::linkThisScript(array()))))) . t3lib_BEfunc::getUrlToken('tceAction') . '">';
            $out .= t3lib_iconWorks::getSpriteIcon('actions-edit-restore-edit', array('title' => 'undelete and edit')) . '</a>';
        }
        $_params = array($table => $row);
        if (is_array($this->hookArray['additionalButtons'])) {
            foreach ($this->hookArray['additionalButtons'] as $_funcRef) {
                $out .= t3lib_div::callUserFunction($_funcRef, $_params, $this);
            }
        }
        $out .= '</td>
		</tr>
		';
        return $out;
    }
    function main($content, $conf)
    {
        $this->Bol = new BlumenbachOnline();
        $this->conf = $conf;
        $this->pi_setPiVarDefaults();
        $this->pi_loadLL();
        $this->fe_user = $this->Bol->fe_userdata;
        @session_start();
        $submitbutton = "";
        //		include_once("./bolonline.main.conf.php");
        /* Spezialfelder und Felder an/aus */
        include_once "bolonline.main.conf.php";
        $content .= $jscript_special_inputfields;
        //javascript fuer Spezialfelder
        //		if($this->Bol->debug) $content .= "<xmp>".print_r($_REQUEST, 1)."</xmp>";
        //		$GLOBALS['TYPO3_DB']->sql_free_result($res);
        #$content = $this->Bol->showAll($this->piVars['limit']);
        //		$content .= $this->Bol->show($_POST['id']);
        $_SESSION['todo'] = $_REQUEST["todo"] != "" ? $_REQUEST["todo"] : $_SESSION['todo'];
        $_SESSION['update_id'] = $_REQUEST["kerndaten_id"][0] != "" ? $_REQUEST["kerndaten_id"][0] : $_SESSION['update_id'];
        $_SESSION['hauptkategorie_id'] = $_REQUEST['hauptkategorie_id'] != "" ? $_REQUEST['hauptkategorie_id'] : $_SESSION['hauptkategorie_id'];
        $_SESSION['hauptkategorie_update_id'] = $_REQUEST['hauptkategorie_update_id'] != "" ? $_REQUEST['hauptkategorie_update_id'] : $_SESSION['hauptkategorie_update_id'];
        ######## XAJAX-Initialisieren:
        //require('/var/www/produktion.blumenbach.de/typo3conf/ext/bolonline/pi1/fileupload.ajax.server.php');
        require t3lib_extMgm::extPath('xajax') . 'class.tx_xajax.php';
        $xajax = t3lib_div::makeInstance('tx_xajax');
        $xajax->errorHandlerOn();
        $xajax->outputEntitiesOn();
        $xajax->cleanBufferOn();
        //wichtig!
        $xajax->setTimeout(500);
        //disabled
        $xajax->setLogFile("/var/www/produktion.blumenbach.de/typo3conf/ext/bolonline/test_ajax.log");
        $xajax->decodeUTF8InputOn();
        // for input
        $xajax->setCharEncoding('utf-8');
        //for output
        $xajax->statusMessagesOn();
        $xajax->debugOff();
        $xajax->registerExternalFunction('setUploadFields', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/fileupload.ajax.incl.php');
        $xajax->registerExternalFunction('setNoAssignedUploadFields', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/fileupload.ajax.incl.php');
        $xajax->registerExternalFunction('delImage', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/fileupload.ajax.incl.php');
        $xajax->registerExternalFunction('setFields', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/fileupload.ajax.incl.php');
        $xajax->registerExternalFunction('getDBDumpfile', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/datensicherung.php');
        $xajax->registerExternalFunction('getAccociationIDs', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/associations.pulldown.ajax.incl.php');
        $xajax->registerExternalFunction('setAccociationIDs', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/associations.pulldown.ajax.incl.php');
        $xajax->registerExternalFunction('getGettyData', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/gettySearch.ajax.incl.php');
        $xajax->registerExternalFunction('putGettyValues', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/gettySearch.ajax.incl.php');
        $xajax->registerExternalFunction('getGNDData', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/gndSearch.ajax.incl.php');
        $xajax->registerExternalFunction('putGNDValues', t3lib_extMgm::siteRelPath('bolonline') . '/pi1/gndSearch.ajax.incl.php');
        /*-------------- under development.... ---------------------*/
        //        $bis = rand(11,2999);
        //        echo $bis;
        //        for($i=0;$i<$bis;$i++) {
        //            echo chr(rand(0,150))." ";
        //        }
        //        die();
        /*------------ //under development.... ---------------------*/
        //print_r($_POST);
        $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = $xajax->getJavascript(t3lib_extMgm::siteRelPath('xajax'));
        $xajax->processRequests();
        $content .= '<table style="width:100%;border: 1px solid black">';
        if ($_SESSION['todo'] == "update" && isset($_SESSION['update_id'])) {
            require_once "hauptkategorie.changer.incl.php";
        }
        //###### Backup-Link: ############################################################################################
        include_once "db_backup.php";
        $content .= '<tr><td colspan="2"><div style="padding:5px;" id="db_backuplink" onClick="xajax_getDBDumpfile()">o <u>Hier klicken um eine Datensicherungsdatei zu erzeugen...</u></div></td></tr>';
        ##################################################################################################################
        $content .= '<tr><td colspan="2" style="background-color:lightgrey;height:1px;padding:1px"></td></tr>';
        //		$content .= 'Mediafiles: <xmp style="color:green">'.print_r($_FILES,1	).'</xmp>';
        // ################################# Datensatz editieren #################################
        $content .= '<tr><td style="width:50%">';
        $content .= '<form name="todo" action="' . $this->pi_getPageLink($GLOBALS['TSFE']->id) . '" method="POST">';
        $content .= '<select style="background-color:#fcfbc4;width:100%;padding:2px" name="todo" onChange="document.todo.submit()">
						<option value="">bitte wählen</option>
				   		<option style="color:blue" value="insert"' . ($_SESSION['todo'] == "insert" ? " selected" : "") . '>neuer Datensatz</option>
					<option style="color:red" value="update"' . ($_SESSION['todo'] == "update" ? " selected" : "") . '>bestehenden Datensatz editieren</option>
					</select>';
        $content .= '</form></td>';
        //print_r($_POST);
        if ($_SESSION['todo'] == 'update') {
            $content .= '<td style="width:50%"><form name="update" action="' . $this->pi_getPageLink($GLOBALS['TSFE']->id) . '" method="POST">';
            $content .= '<input type="hidden" name="todo" value="update">';
            $content .= '<select style="background-color:#fda92a;width:100%;padding:2px" name="kerndaten_id[]" onChange="document.update.submit()">
																		<option value="">bitte wählen</option>';
            /****** Hauptkategorie-Zuordnung aendern: *******************/
            $datensatz_ids = array();
            $datensatz_ids = $this->Bol->getUpdateTeaser($_SESSION['hauptkategorie_id']);
            //			$content .= $this->Bol->dump($datensatz_ids);
            foreach ($datensatz_ids as $id => $value) {
                $zugeordnete_kategorie = $this->Bol->getMainCategories($id);
                $content .= '<option value="' . $id . '"' . ($_SESSION['update_id'] == $id ? " selected" : "") . '>' . substr($value, 0, 250) . ' ->' . $zugeordnete_kategorie[0]['kategorie'] . '</option>';
            }
            $content .= '</select>';
            $content .= '</form></td></tr>';
        }
        // ################################# Ende Datensatz editieren #################################
        $content .= '<tr><td colspan="2" style="background-color:lightgrey;height:1px;padding:1px"></td></tr>';
        if ($_SESSION['todo'] == "update" && isset($_SESSION['update_id'])) {
            require "hauptkategorie.updater.incl.php";
        }
        /*--------- Funktion fuer Multiple Select der Tabellenzuordnung gelb ------*/
        $content .= '<script language="JavaScript">
                        function getMultiple(ob) {
                                var arSelected = "";
                                var counter = 0;
                                while (ob.selectedIndex != -1) {
                                if (counter==0) arSelected+= ob.options[ob.selectedIndex].value;
                                else arSelected+="|"+ob.options[ob.selectedIndex].value;
                                        ob.options[ob.selectedIndex].selected = false;
                                        counter++;
                                } // You can use the arSelected array for further processing.

                        return arSelected;
                        }
                      </script>';
        /*-------- /Funktion fuer Multiple Select der Tabellenzuordnung gelb ------*/
        $content .= '<tr><td colspan="2" style="background-color:lightgrey;height:1px;padding:1px"></td></tr>';
        $content .= '<tr><td colspan="2" style="height:10px"></td></tr>';
        //$content .= '<form action="' . $this->pi_getPageLink($GLOBALS['TSFE']->id) . '" method="POST" id="stammdaten" name="stammdaten">';
        //$content .= '<tr><td><br /><br />'.$this->setUploadFields().'</td></tr>';
        //		print_r($this->Bol->getTableColumns());
        $content .= '<tr><td colspan="2">';
        #if($_POST['todo']!=0){
        switch ($_SESSION['todo']) {
            case "insert":
                $submitbutton = htmlspecialchars($this->pi_getLL('submit_button_label'));
                $submit_label = htmlspecialchars($this->pi_getLL('submit_label_new'));
                //		$content .=  'insert';
                //				$content .= $this->Bol->show();
                $content .= '<form name="neueintrag" method="POST">';
                $this->Bol->tablename = 'tx_bolonline_Kerndaten';
                $this->Bol->getTableColumns();
                $blockbez = '<br /><b style="color:green">Block: ' . $this->Bol->tablename . '</b><br />';
                $content .= $blockbez;
                $content .= $this->Bol->show(0) . '<br /><br /><br />';
                $kerndaten_id = $this->Bol->insert(t3lib_div::_POST());
                // da $this->Bol->tablename = 'tx_bolonline_Kerndaten' ist die hier zurückgegebene id die kerndaten_id!
                $this->Bol->tablename = 'tx_bolonline_PartI';
                $this->Bol->getTableColumns();
                $blockbez = '<br /><b style="color:red">Block: ' . $this->Bol->tablename . '</b><br />';
                $content .= $blockbez;
                $content .= $this->Bol->show(0) . '<br /><br /><br />';
                $this->Bol->insert(t3lib_div::_POST(), $kerndaten_id);
                $this->Bol->tablename = 'tx_bolonline_PartII';
                $this->Bol->getTableColumns();
                $blockbez = '<br /><b style="color:blue">Block: ' . $this->Bol->tablename . '</b><br />';
                $content .= $blockbez;
                $content .= $this->Bol->show(0) . '<br /><br /><br />';
                $this->Bol->insert(t3lib_div::_POST(), $kerndaten_id);
                $this->Bol->tablename = 'tx_bolonline_PartIII';
                $this->Bol->getTableColumns();
                $blockbez = '<br /><b style="color:yellow">Block: ' . $this->Bol->tablename . '</b><br />';
                $content .= $blockbez;
                $content .= $this->Bol->show(0) . '<br /><br /><br />';
                $this->Bol->insert(t3lib_div::_POST(), $kerndaten_id);
                $this->Bol->tablename = 'tx_bolonline_PartIV';
                $this->Bol->getTableColumns();
                // Blockbezeichner aus Sprachdatei holen:
                $__blockbez = parent::pi_getLL($this->tablename . '.d');
                $blockbez = '<br /><b style="color:orange">' . $__blockbez . '</b><br />';
                $content .= $blockbez;
                $content .= $this->Bol->show(0) . '<br /><br /><br />';
                $this->Bol->insert(t3lib_div::_POST(), $kerndaten_id);
                $content .= '<input type="submit" value="' . $submit_label . '"></form>';
                //				echo 'UPDATE-ID:'.$kerndaten_id;
                if ($kerndaten_id > 0) {
                    $_SESSION['todo'] = "update";
                    $_SESSION['update_id'] = $kerndaten_id;
                    $text = "/intern/bol_db/?no_cache=1&kerndaten_id=" . $kerndaten_id;
                    $link = $text;
                    //					$link = $text . $this->pi_getPageLink($GLOBALS['TSFE']->$kerndaten_id, '');
                    //					echo 'WEITERLEITUNG nach: '.$link;
                    @header("Location: " . $link);
                }
                break;
            case "update":
                $submitbutton = htmlspecialchars($this->pi_getLL('update_button_label'));
                $submit_label = htmlspecialchars($this->pi_getLL('submit_label_update'));
                if ($_SESSION['update_id'] > 0) {
                    //					$this->Bol->tablename = 'tx_bolonline_Kerndaten';
                    //					$this->Bol->getTableColumns();
                    //					echo $this->Bol->update(t3lib_div :: _POST(), $_SESSION['update_id']);
                    //					$blockbez = '<br /><b>Block: ' . $this->Bol->tablename . '</b><br />';
                    //					$content .= $blockbez;
                    //					$content .= $this->Bol->show($_SESSION['update_id']);
                    // File-Upload-Felder:
                    //					$content .= '<script language="JavaScript">xajax_setUploadFields(1,"_kerndaten")</script>';
                    $content .= '<style type="text/css">' . "\n";
                    $content .= '#partcontentdiv_kerndaten {
                                        border: 2px solid green;
                                        padding: 5px;
                                }
                                #partcontentdiv_partI {
                                        border: 2px solid red;
                                        padding: 5px;
                                }
                        #partcontentdiv_partII {
                                        border: 2px solid blue;
                                        padding: 5px;
                                }
                        #partcontentdiv_partIII {
                                        border: 2px solid yellow;
                                        padding: 5px;
                                }
                        #partcontentdiv_partIV {
                                        border: 2px solid orange;
                                        padding: 5px;
                                }
                                .blockbez_tx_bolonline_Kerndaten { color: green }
                                .blockbez_tx_bolonline_PartI { color: red; }
                                .blockbez_tx_bolonline_PartII { color: blue; }
                                .blockbez_tx_bolonline_PartIII { color: yellow; }
                                .blockbez_tx_bolonline_PartIV { color: orange; }
										
										
                                ' . "\n";
                    $content .= '</style>' . "\n";
                    // alle anderen Felder:
                    $content .= '<script language="JavaScript">xajax_setFields("tx_bolonline_Kerndaten","kerndaten",1,0,0)</script>';
                    $content .= '<script language="JavaScript">xajax_setFields("tx_bolonline_PartI","partI",1,1)</script>';
                    $content .= '<script language="JavaScript">xajax_setFields("tx_bolonline_PartII","partII",1,1)</script>';
                    $content .= '<script language="JavaScript">xajax_setFields("tx_bolonline_PartIII","partIII",1,1)</script>';
                    $content .= '<script language="JavaScript">xajax_setFields("tx_bolonline_PartIV","partIV",1,1)</script>';
                    $content .= '<div id="partcontentdiv_kerndaten" style="width:700px;"><h1>Kerndaten</h1></div><br /><br />';
                    $content .= '<div id="partcontentdiv_partII" style="width:700px;"><h1>PartII-FELDER</h1></div><br /><br />';
                    $content .= '<div id="partcontentdiv_partI" style="width:700px;"><h1>PartI-FELDER</h1></div><br /><br />';
                    $content .= '<div id="partcontentdiv_partIII" style="width:700px;"><h1>PartIII-FELDER</h1></div><br /><br />';
                    $content .= '<div id="partcontentdiv_partIV" style="width:700px;"><h1>PartIV-FELDER</h1></div><br /><br />';
                    //					if ($_SESSION['todo'] != 'delete' && $_SESSION['todo'] != '') {
                    //						$content .= '</td></tr><tr><td>
                    //						<br><br>
                    //						<h3>' . $submit_label . '</h3><br>
                    //						<input type="submit" name="' . $this->prefixId . '[submit_button]" value="' . $submitbutton . '">
                    //						</form>
                    //						<br />
                    //						<!--<p>You can click here to ' . $this->pi_linkToPage('get to this page again', $GLOBALS['TSFE']->id) . '</p>-->
                    //							';
                    //					}
                    $this->Bol->tablename = 'tx_bolonline_Kerndaten';
                    $this->Bol->getTableColumns();
                    //					$this->Bol->update(t3lib_div :: _POST(), $_SESSION['update_id']);
                    $this->Bol->update(t3lib_div::_POST(), $_SESSION['update_id']);
                    /*
                    					$this->Bol->tablename = 'tx_bolonline_Kerndaten';
                    					$this->Bol->getTableColumns();
                    					$this->Bol->update(t3lib_div :: _POST(), $_SESSION['update_id']);
                    					$blockbez = '<br /><b>Block: '.$this->Bol->tablename.'</b><br />';
                    					$content .= $blockbez;
                    					$content .= $this->Bol->show($_SESSION['update_id']);
                    */
                    $this->Bol->tablename = 'tx_bolonline_PartI';
                    $this->Bol->getTableColumns();
                    $this->Bol->update(t3lib_div::_POST(), $_SESSION['update_id']);
                    /*
                    					$blockbez = '<br /><b>Block: '.$this->Bol->tablename.'</b><br />';
                    					$content .= $blockbez;
                    					$content .= $this->Bol->show($_SESSION['update_id']);
                    */
                    $this->Bol->tablename = 'tx_bolonline_PartII';
                    $this->Bol->getTableColumns();
                    $this->Bol->update(t3lib_div::_POST(), $_SESSION['update_id']);
                    //					$content .= '<script language="JavaScript">xajax_setFields("tx_bolonline_PartII","partII",1)</script>';
                    /*
                    					$blockbez = '<br /><b>Block: '.$this->Bol->tablename.'</b><br />';
                    					$content .= $blockbez;
                    					$content .= $this->Bol->show($_SESSION['update_id']);
                    */
                    $this->Bol->tablename = 'tx_bolonline_PartIII';
                    $this->Bol->getTableColumns();
                    $this->Bol->update(t3lib_div::_POST(), $_SESSION['update_id']);
                    /*
                    					$blockbez = '<br /><b>Block: '.$this->Bol->tablename.'</b><br />';
                    					$content .= $blockbez;
                    					$content .= $this->Bol->show($_SESSION['update_id']);
                    */
                    $this->Bol->tablename = 'tx_bolonline_PartIV';
                    $this->Bol->getTableColumns();
                    $this->Bol->update(t3lib_div::_POST(), $_SESSION['update_id']);
                    #$content .= '<script language="JavaScript">xajax_setFields("tx_bolonline_PartIV","partIV",1)</script>';
                    /*
                    					$blockbez = '<br /><b>Block: '.$this->Bol->tablename.'</b><br />';
                    					$content .= $blockbez;
                    					$content .= $this->Bol->show($_SESSION['update_id']);
                    */
                }
                break;
            case "delete":
                $deleted = $this->Bol->delete($_REQUEST['id'], $_REQUEST['tablename']);
                if ($deleted) {
                    $content .= 'Der Datensatz Nr. ' . $_REQUEST['id'] . 'aus Tabelle ' . $_REQUEST['tablename'] . ' wurde gelöscht!';
                } else {
                    $content .= "<div style='color:red'>something went wrong, couldǹt delete!</div>";
                }
                break;
            default:
                //				$content .= $this->Bol->show($_GET['id']);
                //				$content .= "Bitte Aktion wählen!";
                break;
        }
        $content .= '</td></tr></table>';
        return $this->pi_wrapInBaseClass($content);
    }
 /**
  * check if the t3editor should be disabled (by a POST value)
  */
 protected function checkEditorIsDisabled()
 {
     $editorIsDisabled = t3lib_div::_POST('t3editor_disableEditor');
     if (!empty($editorIsDisabled)) {
         $editorIsDisabled = $editorIsDisabled == 'true';
     } else {
         $editorIsDisabled = $GLOBALS['BE_USER']->uc['disableT3Editor'];
     }
     if ($GLOBALS['BE_USER']->uc['disableT3Editor'] != $editorIsDisabled) {
         $GLOBALS['BE_USER']->uc['disableT3Editor'] = $editorIsDisabled;
         $GLOBALS['BE_USER']->writeUC();
     }
 }
    public function personenSuche(&$parent)
    {
        $GLOBALS['TSFE']->additionalHeaderData['he_tools_css_1'] = '
		<link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/personensuche.css" rel="stylesheet" type="text/css" />
		<script src="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/js/delay.js" type="text/javascript"></script>
		';
        $username = $GLOBALS['TSFE']->fe_user->user['username'];
        $gadgetId = tx_he_portal_lib_gadgets::gibGadgetId($GLOBALS['TSFE']->id);
        $out = $this->initGadget($parent->cObj, $username, $gadgetId);
        $gadgetEinstellungen = tx_he_portal_lib_gadgets::gadgetEinstellungenLaden($gadgetId, $username);
        $mitEnterAbsenden = tx_he_portal_lib_gadgets::gibGadgetEinstellungenWert($gadgetEinstellungen, 'modus');
        $minBuchstaben = tx_he_portal_lib_gadgets::gibGadgetEinstellungenWert($gadgetEinstellungen, 'anz_zeichen');
        if ($mitEnterAbsenden == 'on') {
            $minBuchstaben = 99;
        }
        $out = $this->initGadget($parent->cObj);
        $url = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'index.php?id=' . $GLOBALS['TSFE']->id;
        $post = t3lib_div::_POST();
        if (isset($post['eingabe'])) {
            $eingabe = $post['eingabe'];
        } else {
            $eingabe = '';
        }
        if (isset($post['bereich'])) {
            $bereich = $post['bereich'];
        } else {
            $bereich = '';
        }
        if (isset($post['rolle'])) {
            $rolle = $post['rolle'];
        } else {
            $rolle = '';
        }
        if ($minBuchstaben == 99) {
            $hinweis = 'Bitte betätigen Sie Ihre Eingabe mit ENTER';
        } else {
            $hinweis = 'Bitte geben Sie mindestens ' . $minBuchstaben . ' Zeichen ein, um die Suche zu starten.';
        }
        if (!empty($eingabe) || !empty($bereich) || !empty($rolle)) {
            $postErgebnis = '<div id="personenliste">' . $this->personenSucheDaten($eingabe, $bereich, $rolle) . '</div>';
        } else {
            $postErgebnis = '<div id="personenliste">' . $hinweis . '</div>';
        }
        $bereichsListe = '';
        $bereichsGruppen = array('Alle' => 'Alle', 'AN' => 'Angewandte Naturwissenschaft', 'BW' => 'Betriebswirtschaft', 'FZ' => 'Fahrzeugtechnik', 'GL' => 'Grundlagen', 'GS' => 'Graduate School', 'GU' => 'Gebäude Energie Umwelt', 'IT' => 'Informationstechnik', 'MB' => 'Maschinenbau', 'ME' => 'Mechatronik', 'SP' => 'Soziale Arbeit, Gesundheit und Soziales', 'WI' => 'Wirtschaftsingenieurwesen', 'AUSLBEZ' => 'Akademisches Auslandsamt', 'DZ' => 'Didaktikzentrum', 'FINA' => 'Finanzabteilung', 'GUP' => 'Grundsatz und Planungsabteilung', 'IFS' => 'Institut für Fremdsprachen', 'OEFFENTLICHKEITSARBEIT' => 'Öffentlichkeitsarbeit (RÖM)', 'PERSABT' => 'Personalabteilung', 'PERSONALRAT' => 'Personalrat', 'RZ' => 'Rechenzentrum', 'REKTORAT' => 'Rektorat', 'STUDA' => 'Studentische  Abteilung', 'TECHNABT' => 'Technische Abteilung');
        foreach ($bereichsGruppen as $kuerzel => $name) {
            $usergroup = tx_he_personen_util::gibBenutzergruppe($kuerzel);
            $bereichsListe .= '<option value="' . $usergroup . '">' . $name . '</option>
												';
        }
        $gruppenListe = '';
        $funktionsGruppen = array('Alle' => 'Alle', 'AUSZUBILDENDE' => 'Auszubildende', 'DEKANAT' => 'Dekanat', 'LB' => 'Lehrbeauftragte', 'LEITUNG' => 'Leitung', 'HE-MITARBEITER' => 'Mitarbeiter', 'PROFESSOR' => 'Professoren', 'SEKRETARIAT' => 'Sekretariat');
        foreach ($funktionsGruppen as $kuerzel => $name) {
            $usergroup = tx_he_personen_util::gibBenutzergruppe($kuerzel);
            $gruppenListe .= '<option value="' . $usergroup . '">' . $name . '</option>
												';
        }
        $out .= self::getJsAnimationCode();
        $out .= '
	<style>
	#personenliste {
		width: 100%;
	}
	</style>
	<div class="personensuche">
	<form id="suchform" action="' . $url . '" method="POST">
		<div class="filter name">
			<label for="eingabe">Nachname: </label>
			<input id="eingabe" name="eingabe" title="' . $hinweis . '" size="30" />
		</div>
		<div class="filter bereich">
			<label for="bereich">Bereich: </label>
			<select id="bereich" name="bereich">
			' . $bereichsListe . '
			</select>
		</div>
		<div class="filter rolle">
			<label for="rolle">Rolle: </label>
			<select id="rolle" name="rolle">
			' . $gruppenListe . '
			</select>
		</div>
		<div class="reset">
			</br><input id="reset" type="reset" title="Eingaben zurücksetzen" value="X" />
		</div>
		<input id="absenden" type="submit" value="Absenden" />
	</form>
	<div id="namenListe">' . $postErgebnis . '</div>
	</div>
		
		<script>
		$.fn.clearForm = function() {
		  return this.each(function() {
		    var type = this.type, tag = this.tagName.toLowerCase();
		    if (tag == "form")
		      return $(":input",this).clearForm();
		    if (type == "text" || type == "password" || tag == "textarea")
		      this.value = "";
		    else if (type == "checkbox" || type == "radio")
		      this.checked = false;
		    else if (tag == "select")
		      this.selectedIndex = 0;
		  });
		};
		function executeAjax(url){
      var result=""
      $.ajax({
        url: url,
        async: false,
        beforeSend : function(){
          processingAnimation("start","bitte warten");
        },
        success: function(data, request) {
          processingAnimation("stop");
          result = data;
        }
      });
      return result;
    }

		function absenden() {
			var eingabe = encodeURI($("#eingabe").val());
			var eingabeClean = $("#eingabe").val();
			var bereich = encodeURI($("#bereich").val());
			var rolle = encodeURI($("#rolle").val());
			if (eingabeClean.length>=' . $minBuchstaben . ' || bereich!="0" || rolle!="0") {
				processingAnimation("start","bitte warten");
				$("#personenliste").detach();
//				$("<div id=\'personenliste\'></div>").appendTo($("#namenListe"));
				var erg = executeAjax("index.php?eID=he_tools&action=personensuche&eingabe=" + eingabe + "&bereich=" + bereich + "&rolle=" + rolle + "&minChars=' . $minBuchstaben . '");
        if (erg=="") {
					$("<div id=\'personenliste\' class=\\"rot\\"><br/>Bitte aktualisieren Sie das Browserfenster (z.B. mit der Taste F5)!<br/></div>").appendTo($("#namenListe"));
				} else {
					$("<div id=\'personenliste\'>" + erg + "</div>").appendTo($("#namenListe"));
				}
/*
				$("#personenliste").load("index.php?eID=he_tools&action=personensuche&eingabe=" + eingabe + "&bereich=" + bereich + "&rolle=" + rolle, function() {
					processingAnimation("stop");
				});
*/
		} else {
				$("#personenliste").detach();
				if (eingabeClean.length>0) {
					$("<div id=\\"personenliste\\">Bitte geben Sie mindestens ' . $minBuchstaben . ' Buchstaben ein.</div>").appendTo($("#namenListe"));
				}
			}
		}
		$("#absenden").remove();';
        if ($minBuchstaben < 99) {
            $out .= '
			 		$("#eingabe").bindWithDelay("keyup",function(event) {
			 			absenden();
			 		});';
        }
        $out .= '
						 $("#bereich").change(function(event) {
								absenden();
						 });
						 $("#rolle").change(function(event) {
								absenden();
						 });
						 $("#reset").click(function(event) {
						 		$("#suchform").clearForm()
 						 		absenden();
						 });
						 </script>
		';
        return $out;
    }
Esempio n. 30
0
    /**
     * Generate the main settings formular:
     *
     * @return	void
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TBE_MODULES;
        // file creation / delete
        if ($this->isAdmin) {
            if ($this->installToolFileKeep) {
                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileHasKeep'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::WARNING);
                $this->content .= $flashMessage->render();
            }
            if (t3lib_div::_POST('deleteInstallToolEnableFile')) {
                unlink(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                $this->setInstallToolFileExists();
                if ($this->getInstallToolFileExists()) {
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileDelete_failed'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::ERROR);
                } else {
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileDelete_ok'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::OK);
                }
                $this->content .= $flashMessage->render();
            }
            if (t3lib_div::_POST('createInstallToolEnableFile')) {
                touch(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                t3lib_div::fixPermissions(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                $this->setInstallToolFileExists();
                if ($this->getInstallToolFileExists()) {
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileCreate_ok'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::OK);
                } else {
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileCreate_failed'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::ERROR);
                }
                $this->content .= $flashMessage->render();
            }
        }
        if ($this->languageUpdate) {
            $this->doc->JScodeArray['languageUpdate'] .= '
				if (top.refreshMenu) {
					top.refreshMenu();
				} else {
					top.TYPO3ModuleMenu.refreshMenu();
				}
			';
        }
        if ($this->pagetreeNeedsRefresh) {
            t3lib_BEfunc::setUpdateSignal('updatePageTree');
        }
        // Start page:
        $this->doc->loadJavascriptLib('md5.js');
        // use a wrapper div
        $this->content .= '<div id="user-setup-wrapper">';
        // Load available backend modules
        $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
        $this->loadModules->observeWorkspaces = true;
        $this->loadModules->load($TBE_MODULES);
        $this->content .= $this->doc->header($LANG->getLL('UserSettings') . ' - ' . $BE_USER->user['realName'] . ' [' . $BE_USER->user['username'] . ']');
        // show if setup was saved
        if ($this->setupIsUpdated && !$this->tempDataIsCleared && !$this->settingsAreResetToDefault) {
            $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('setupWasUpdated'), $LANG->getLL('UserSettings'));
            $this->content .= $flashMessage->render();
        }
        // Show if temporary data was cleared
        if ($this->tempDataIsCleared) {
            $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('tempDataClearedFlashMessage'), $LANG->getLL('tempDataCleared'));
            $this->content .= $flashMessage->render();
        }
        // Show if temporary data was cleared
        if ($this->settingsAreResetToDefault) {
            $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('settingsAreReset'), $LANG->getLL('resetConfiguration'));
            $this->content .= $flashMessage->render();
        }
        // If password is updated, output whether it failed or was OK.
        if ($this->passwordIsSubmitted) {
            if ($this->passwordIsUpdated) {
                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('newPassword_ok'), $LANG->getLL('newPassword'));
            } else {
                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('newPassword_failed'), $LANG->getLL('newPassword'), t3lib_FlashMessage::ERROR);
            }
            $this->content .= $flashMessage->render();
        }
        // render the menu items
        $menuItems = $this->renderUserSetup();
        $this->content .= $this->doc->spacer(20) . $this->doc->getDynTabMenu($menuItems, 'user-setup', FALSE, FALSE, 0, 1, FALSE, 1, $this->dividers2tabs);
        $formToken = $this->formProtection->generateToken('BE user setup', 'edit');
        // Submit and reset buttons
        $this->content .= $this->doc->spacer(20);
        $this->content .= $this->doc->section('', t3lib_BEfunc::cshItem('_MOD_user_setup', 'reset', $BACK_PATH) . '
			<input type="hidden" name="simUser" value="' . $this->simUser . '" />
			<input type="hidden" name="formToken" value="' . $formToken . '" />
			<input type="submit" name="data[save]" value="' . $LANG->getLL('save') . '" />
			<input type="button" value="' . $LANG->getLL('resetConfiguration') . '" onclick="if(confirm(\'' . $LANG->getLL('setToStandardQuestion') . '\')) {document.getElementById(\'setValuesToDefault\').value=1;this.form.submit();}" />
			<input type="button" value="' . $LANG->getLL('clearSessionVars') . '"  onclick="if(confirm(\'' . $LANG->getLL('clearSessionVarsQuestion') . '\')){document.getElementById(\'clearSessionVars\').value=1;this.form.submit();}" />
			<input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" />
			<input type="hidden" name="data[clearSessionVars]" value="0" id="clearSessionVars" />');
        // Notice
        $this->content .= $this->doc->spacer(30);
        $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('activateChanges'), '', t3lib_FlashMessage::INFO);
        $this->content .= $flashMessage->render();
        // end of wrapper div
        $this->content .= '</div>';
        // Setting up the buttons and markers for docheader
        $docHeaderButtons = $this->getButtons();
        $markers['CSH'] = $docHeaderButtons['csh'];
        $markers['CONTENT'] = $this->content;
        // Build the <body> for the module
        $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        // Renders the module page
        $this->content = $this->doc->render($LANG->getLL('UserSettings'), $this->content);
    }