public function veranstaltungBuchen(&$piBase, $pid, $eventId, $eventDateId)
    {
        $GLOBALS['TSFE']->additionalHeaderData['hetools'] .= '
				<link rel="stylesheet" type="text/css" href="' . t3lib_extMgm::siteRelPath('fe_management') . 'res/femanagement.css"/>
				<link rel="stylesheet" type="text/css" href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/technolino.css"/>
				';
        /** @var  $terminModel tx_femanagement_model_events */
        $terminModel = t3lib_div::makeInstance('tx_femanagement_model_events', $piBase, $pid);
        $eventData = $terminModel->getEventData($eventId);
        $out = '<h1>' . $eventData['title'] . '</h1>' . '<h2>Thema: ' . $eventData['subtitle'] . '</h2>';
        $out .= '<form class="technolino" method="POST" action="">';
        $out .= $this->getInputField('organization', 'Name Ihrer Einrichtung');
        $out .= $this->getInputField('first_name', 'Vorname');
        $out .= $this->getInputField('last_name', 'Nachname');
        $out .= $this->getInputField('street', 'Straße/Hausnummer');
        $out .= $this->getInputField('zip', 'Plz');
        $out .= $this->getInputField('city', 'Ort');
        $out .= $this->getInputField('email', 'E-Mail-Adresse');
        $out .= $this->getInputField('phone', 'Tel.');
        $out .= $this->getTextareaField('remarks', 'Bemerkungen', false);
        $out .= '<div id="buttons" class="field">
        <input type="submit" name="anmelden" value="Verbindlich anmelden" />
         </div>';
        $out .= '</form>';
        return $out;
    }
 /**
  * Hooks to the felogin extension to provide additional code for FE login
  *
  * @return	array	0 => onSubmit function, 1 => extra fields and required files
  */
 public function loginFormHook()
 {
     $result = array(0 => '', 1 => '');
     if ($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel'] == 'rsa') {
         $backend = tx_rsaauth_backendfactory::getBackend();
         if ($backend) {
             $result[0] = 'tx_rsaauth_feencrypt(this);';
             $javascriptPath = t3lib_extMgm::siteRelPath('rsaauth') . 'resources/';
             $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js');
             foreach ($files as $file) {
                 $result[1] .= '<script type="text/javascript" src="' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
             }
             // Generate a new key pair
             $keyPair = $backend->createNewKeyPair();
             // Save private key
             $storage = tx_rsaauth_storagefactory::getStorage();
             /* @var $storage tx_rsaauth_abstract_storage */
             $storage->put($keyPair->getPrivateKey());
             // Add RSA hidden fields
             $result[1] .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />';
             $result[1] .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />';
         }
     }
     return $result;
 }
 /**
  * Renders entry for one page of the current document.
  *
  * @access	protected
  *
  * @param	integer		$number: The page to render
  * @param	string		$template: Parsed template subpart
  *
  * @return	string		The rendered entry ready for output
  */
 protected function getEntry($number, $template)
 {
     // Set current page if applicable.
     if (!empty($this->piVars['page']) && $this->piVars['page'] == $number) {
         $markerArray['###STATE###'] = 'cur';
     } else {
         $markerArray['###STATE###'] = 'no';
     }
     // Set page number.
     $markerArray['###NUMBER###'] = $number;
     // Set pagination.
     $markerArray['###PAGINATION###'] = $this->doc->physicalPagesInfo[$this->doc->physicalPages[$number]]['label'];
     // Get thumbnail or placeholder.
     if (!empty($this->doc->physicalPagesInfo[$this->doc->physicalPages[$number]]['files'][$this->conf['fileGrpThumbs']])) {
         $thumbnailFile = $this->doc->getFileLocation($this->doc->physicalPagesInfo[$this->doc->physicalPages[$number]]['files'][$this->conf['fileGrpThumbs']]);
     } elseif (!empty($this->conf['placeholder'])) {
         $thumbnailFile = $GLOBALS['TSFE']->tmpl->getFileName($this->conf['placeholder']);
     } else {
         $thumbnailFile = t3lib_extMgm::siteRelPath($this->extKey) . 'plugins/pagegrid/placeholder.jpg';
     }
     $thumbnail = '<img alt="' . $markerArray['###PAGINATION###'] . '" src="' . $thumbnailFile . '" />';
     // Get new plugin variables for typolink.
     $piVars = $this->piVars;
     // Unset no longer needed plugin variables.
     // unset($piVars['pagegrid']) is for DFG Viewer compatibility!
     unset($piVars['pointer'], $piVars['DATA'], $piVars['pagegrid']);
     $piVars['page'] = $number;
     $linkConf = array('useCacheHash' => 1, 'parameter' => $this->conf['targetPid'], 'additionalParams' => t3lib_div::implodeArrayForUrl($this->prefixId, $piVars, '', TRUE, FALSE), 'title' => $markerArray['###PAGINATION###']);
     $markerArray['###THUMBNAIL###'] = $this->cObj->typoLink($thumbnail, $linkConf);
     return $this->cObj->substituteMarkerArray($template, $markerArray);
 }
 public function getMapCore($backpath = '')
 {
     $path = ($backpath ? $backpath : $GLOBALS['TSFE']->absRefPrefix) . t3lib_extMgm::siteRelPath('ods_osm') . 'res/';
     $path = $this->config['local_js'] ? $path . 'OpenLayers3/' : 'http://ol3js.org/en/master/';
     $GLOBALS['TSFE']->getPageRenderer()->addCssFile($path . 'css/ol.css');
     $this->scripts = array($path . 'build/ol.js');
 }
    /**
     * action list
     *
     * @return void
     */
    public function listAction()
    {
        $formPage = $this->settings['formPage'];
        $this->response->addAdditionalHeaderData('
			<link rel="stylesheet" type="text/css" href="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/Css/jhe_supportform.css"></link>
			<script src="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/JavaScript/jhe_supportform.js?1468835123" type="text/javascript"></script>
		');
        $this->view->assign('formpage', $formPage);
    }
 /**
  * Sets the value of captcha markers
  */
 public function addGlobalMarkers(&$markerArray, $markerObject)
 {
     $cmdKey = $markerObject->controlData->getCmdKey();
     if (t3lib_extMgm::isLoaded('captcha') && $markerObject->conf[$cmdKey . '.']['evalValues.']['captcha_response'] == 'captcha') {
         $markerArray['###CAPTCHA_IMAGE###'] = '<img src="' . t3lib_extMgm::siteRelPath('captcha') . 'captcha/captcha.php" alt="" />';
     } else {
         $markerArray['###CAPTCHA_IMAGE###'] = '';
     }
 }
Beispiel #7
0
 /**
  * Initializes the Module
  *
  * @return	void
  */
 public function __construct()
 {
     parent::init();
     // initialize document
     $this->doc = t3lib_div::makeInstance('template');
     $this->doc->setModuleTemplate(t3lib_extMgm::extPath('reports') . 'mod/mod_template.html');
     $this->doc->backPath = $GLOBALS['BACK_PATH'];
     $this->doc->addStyleSheet('tx_reports', '../' . t3lib_extMgm::siteRelPath('reports') . 'mod/mod_styles.css');
 }
Beispiel #8
0
 /**
  * Initializes the Module
  *
  * @return	void
  */
 public function __construct()
 {
     parent::init();
     // initialize document
     $this->doc = t3lib_div::makeInstance('template');
     $this->doc->setModuleTemplate(t3lib_extMgm::extPath('taskcenter') . 'res/mod_template.html');
     $this->doc->backPath = $GLOBALS['BACK_PATH'];
     $this->doc->getPageRenderer()->loadScriptaculous('effects,dragdrop');
     $this->doc->addStyleSheet('tx_taskcenter', '../' . t3lib_extMgm::siteRelPath('taskcenter') . 'res/mod_styles.css');
 }
 /**
  * Provides form code for the superchallenged authentication.
  *
  * @param	array	$params	Parameters to the script
  * @param	SC_index	$pObj	Calling object
  * @return	string	The code for the login form
  */
 public function getLoginScripts(array $params, SC_index &$pObj)
 {
     $content = '';
     if ($pObj->loginSecurityLevel == 'rsa') {
         $javascriptPath = t3lib_extMgm::siteRelPath('rsaauth') . 'resources/';
         $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js');
         $content = '';
         foreach ($files as $file) {
             $content .= '<script type="text/javascript" src="' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
         }
     }
     return $content;
 }
 /**
  * Adds the JS files necessary for search suggestions
  *
  * @access	protected
  *
  * @return	void
  */
 protected function addAutocompleteJS()
 {
     // Check if there are any metadata to suggest.
     $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_metadata.*', 'tx_dlf_metadata', 'tx_dlf_metadata.autocomplete=1 AND tx_dlf_metadata.pid=' . intval($this->conf['pages']) . tx_dlf_helper::whereClause('tx_dlf_metadata'), '', '', '1');
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
         // Add javascript to page header.
         if (tx_dlf_helper::loadJQuery()) {
             $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId . '_search_suggest'] = '<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath($this->extKey) . 'plugins/search/tx_dlf_search_suggest.js"></script>';
         }
     } else {
         if (TYPO3_DLOG) {
             t3lib_div::devLog('[tx_dlf_search->addAutocompleteJS()] No metadata fields configured for search suggestions', $this->extKey, SYSLOG_SEVERITY_WARNING);
         }
     }
 }
 private function init($conf)
 {
     $this->conf = $conf;
     $this->pi_setPiVarDefaults();
     $this->pi_loadLL();
     $this->pi_initPIflexForm();
     // Init FlexForm configuration for plugin
     // Get the logged in user id or return false
     $this->config['userid'] = $GLOBALS['TSFE']->loginUser ? $GLOBALS['TSFE']->fe_user->user['uid'] : false;
     // Getting the pid list via the flexform
     $pidList = $this->cObj->data['pages'];
     $this->conf['pidList'] = $pidList ? $pidList : $GLOBALS['TSFE']->id;
     // Template code
     $this->config['templateFile'] = $this->cObj->fileResource($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'templateFile', 'sDEF') ? $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'templateFile', 'sDEF') : t3lib_extMgm::siteRelPath($this->extKey) . 'res/template.html');
 }
    public function renderZeitschriftenListe()
    {
        $GLOBALS['TSFE']->additionalHeaderData[$this->extKey . 'he_tools_css_1'] = '<link href="' . t3lib_extMgm::siteRelPath($this->extKey) . 'res/zeitschriften.css" rel="stylesheet" type="text/css" />';
        $zeitschriftenListe = array();
        $this->gibZeitschriftenListe($zeitschriftenListe);
        $out .= '<a name="top"></name>';
        $out .= $this->renderBuchstabenLinks($zeitschriftenListe);
        $out .= '<table class="tab100 zeitschriften">
		<tbody>
		';
        foreach ($zeitschriftenListe as $buchstabe => $liste) {
            $out .= $this->renderBuchstabenBlock($buchstabe, $liste);
        }
        $out .= '</table>';
        return $out;
    }
    public function render($parent)
    {
        $GLOBALS['TSFE']->additionalHeaderData[$this->extKey . 'he_tools_css_1'] = '<link href="' . t3lib_extMgm::siteRelPath($this->extKey) . 'res/hochschule_a_z.css" rel="stylesheet" type="text/css" />';
        $zeitschriftenListe = array();
        $this->gibArtikel($zeitschriftenListe);
        $out .= '<a name="top"></name>';
        $out .= $this->renderBuchstabenLinks($zeitschriftenListe);
        $out = '';
        $username = $GLOBALS['TSFE']->fe_user->user['username'];
        $gadgetId = tx_he_portal_lib_gadgets::gibGadgetId($GLOBALS['TSFE']->id);
        if (tx_he_portal_lib_gadgets::gadgetHilfeTextAnzeigen($gadgetId, $username)) {
            $hilfeId = tx_he_portal_lib_gadgets::gibGadgetHilfeUid($gadgetId);
            $config = array('tables' => 'tt_content', 'source' => $hilfeId);
            $out .= $parent->cObj->RECORDS($config);
        }
        $out .= '
	<div class="a_bis_z_suche">
		<div style="margin: 10px 0;">
		Bitte geben Sie einen Suchbegriff ein.</div>
	<form action="" method="POST">
		<input class="such_box" type="text" id="eingabe" name="eingabe" size="40" />
		<input id="absenden" type="submit" value="Absenden" />
	</form>
	<div id="namenListe" style="margin-top:2em; font-family:Arial">
	</div>
	
	</div>
		
		<script>
		$("#absenden").css({"display": "none"});
		$("#eingabe").keyup(function(event) {
			var eingabe = encodeURI($("#eingabe").val());
			if (eingabe.length>0) {
				$("#ergebnisliste").detach();
				$("<div id=\\"ergebnisliste\\"></div>").appendTo($("#namenListe"));
//				$("#ergebnisliste").load("index.php?id=94212&mode=AZ&eingabe=" + eingabe);
				$("#ergebnisliste").load("index.php?eID=he_tools&action=a_bis_z_suche&val=" + eingabe);
			} else {
				$("#ergebnisliste").detach();
			}
			
		});
		</script>
		';
        return $out;
    }
 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;
 }
    /**
     * action list
     *
     * @return void
     */
    public function listAction()
    {
        $this->response->addAdditionalHeaderData('
			<link rel="stylesheet" type="text/css" href="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/Css/jhe_supportform.css?1468915302"></link>
			<script src="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/JavaScript/jhe_supportform.js?1468915302" type="text/javascript"></script>
		');
        if ($this->request->getArguments() && array_key_exists('supportFormTopic', $this->request->getArguments())) {
            $supportFormTopic = $this->request->getArgument('supportFormTopic');
        } else {
            if ($_GET['form'] != '') {
                $supportFormTopic = $_GET['form'];
            } else {
                $supportFormTopic = 'error';
            }
        }
        switch ($supportFormTopic) {
            case 'sapSupportAnfrage':
            case 'sapNeuesStartkennwort':
            case 'sapBenutzerentsperren':
            case 'sapBenutzerAnlegen':
            case 'sapBenutzerloeschen':
            case 'itSupportAnfrage':
            case 'itVpnZugang':
            case 'isisSupportAnfrage':
            case 'isisStartkennwort':
            case 'preysSupportAnfrage':
            case 'presysDebitorAktivieren':
            case 'presysPasswort':
            case 'presysTestzugang':
            case 'teampointSupportAnfrage':
                $supportFormTopicPassedToView = $supportFormTopic;
                $errorMessage = '';
                break;
            case 'error':
            default:
                $supportFormTopicPassedToView = 'error';
                $errorMessage = 'Ihrer Anfrage konnte kein Formular zugeordnet werden. Bitte gehen Sie zurück zur letzten TeamPoint-Seite und versuchen Sie es nochmals.<br />Sollte des Problem immer noch bestehen, wenden Sie sich bitte an <a href="mailto:technik@teampoint.info">technik@teampoint.info</a>.';
                break;
        }
        $this->view->assign('topic', $supportFormTopicPassedToView);
        if ($errorMessage) {
            $this->view->assign('error', $errorMessage);
        }
        $this->view->assign('fe_user', $GLOBALS['TSFE']->fe_user->user);
    }
 function makeCaptcha()
 {
     $this->tslib_pibase();
     //Make sure that labels in locallang.php may be overridden
     $this->conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->prefixId . '.'];
     $this->pi_loadLL();
     $this->pi_USER_INT_obj = 1;
     // Disable caching
     $this->confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rggooglemap']);
     $GLOBALS['TSFE']->additionalHeaderData['b121211'] = '<script src="http://maps.google.com/maps?file=api&amp;v=2.61&amp;key=' . $this->confArr['googleKey'] . '" type="text/javascript"></script>';
     $GLOBALS['TSFE']->additionalHeaderData['b121212'] = '<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath('rggooglemap') . 'res/rggm_load.js"></script>';
     $L = t3lib_div::_GP('L');
     $markerArray = array();
     $markerArray['###MAP###'] = '<div style="height:350px;width:400px" id="mapLoad"></div>';
     $markerArray['###' . strtoupper($this->extKey) . '_NOTICE###'] = $this->pi_getLL('notice') . ' ' . $this->pi_getLL('explain');
     $markerArray['###' . strtoupper($this->extKey) . '_CANT_READ###'] = '<span ' . $this->pi_classParam('cant-read') . '>' . $this->pi_getLL('cant_read1');
     $markerArray['###' . strtoupper($this->extKey) . '_CANT_READ###'] .= ' <a href="#" onclick="this.blur();newFreeCap();return false;">' . $this->pi_getLL('click_here') . '</a>';
     $markerArray['###' . strtoupper($this->extKey) . '_CANT_READ###'] .= $this->pi_getLL('cant_read2') . '</span>';
     return $markerArray;
 }
    /**
     * action index
     *
     * @return void
     */
    public function indexAction()
    {
        if ($this->settings['countTo'] == 'date') {
            $todayDate = new DateTime(date('Y-m-d', time()));
            $targetDate = new DateTime(date('Y-m-d', $this->settings['targetdate']));
            $interval = $todayDate->diff($targetDate);
            $this->settings['daysToTargetDate'] = $interval->format('%a');
        } else {
            if ($this->settings['countTo'] == 'datetime') {
                //integrate jquery.countdown and other necessary modules
                $GLOBALS['TSFE']->additionalHeaderData['tx_jhecountdownce'] = '
				<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/JavaScript/jquery.countdown.min.js"></script>
				<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/JavaScript/moment-with-locales.js"></script>
				<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/JavaScript/lodash.js"></script>
				<link rel="stylesheet" type="text/css" href="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/Css/jhe_countdownce.css" media="all">
			';
            }
        }
        $this->settings['targetDateString'] = date('c', $this->settings['targetdatetime']);
        $this->view->assign(settings, $this->settings);
    }
    /**
     * action index
     *
     * @return void
     */
    public function indexAction()
    {
        $arrGreetingsUnexploded = explode(',', $this->settings['greetings']['value']);
        $strLang = '';
        foreach ($arrGreetingsUnexploded as $greeting) {
            $arrGreeting = explode('|', $greeting);
            if ($arrGreeting[0] && $arrGreeting[1]) {
                $arrGreetingsForSettings[] = array('lang' => trim($arrGreeting[0]), 'text' => trim($arrGreeting[1]));
                $strLang .= trim($arrGreeting[0] . ',');
            }
        }
        $this->settings['greetings'] = $arrGreetingsForSettings;
        $this->settings['languages'] = $strLang;
        //integrate jquery.countdown and other necessary modules
        $GLOBALS['TSFE']->additionalHeaderData['tx_jhenewyearsheader'] = '
			<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/JavaScript/fireworks.js"></script>
			<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/JavaScript/newyearsheader.js"></script>
			<link rel="stylesheet" type="text/css" href="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/Css/newyearsheader.css" media="screen" />
			<link rel="stylesheet" type="text/css" href="' . t3lib_extMgm::siteRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/Css/fireworks.css" media="screen" />
		';
        $this->view->assign(settings, $this->settings);
    }
    public function main()
    {
        $get = t3lib_div::_GET();
        $post = t3lib_div::_POST();
        if (isset($post['anmelden']) || isset(${$post}['absenden'])) {
            $anmeldeDatenOk = $this->pruefeAnmeldeDaten($post);
            if (!$anmeldeDatenOk) {
                $out = $this->gibFehlermeldung($post);
            } else {
                $out = '<h1>Anmeldung ok</h1>';
            }
        } else {
            $out = '<h1>gleich geht es weiter</h1>';
        }
        $GLOBALS['TSFE']->additionalHeaderData['he_tools_css_1'] = '
		<link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/css/einfuehrung_anmeldungen.css" rel="stylesheet" type="text/css" />
		<link href="/typo3/sysext/t3skin/stylesheets/sprites/t3skin.css" rel="stylesheet" type="text/css" />
		<link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/css/jquery.ui.core.css" rel="stylesheet" type="text/css" />
		<link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/css/jquery.ui.base.css" rel="stylesheet" type="text/css" />
		<link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/css/jquery.ui.theme.css" rel="stylesheet" type="text/css" />
		<link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/css/jquery.ui.datepicker.css" rel="stylesheet" type="text/css" />
		';
        return $out;
    }
 /**
  * Plugin Main Method
  *
  * @param	string	$content: The content of the PlugIn
  * @param	array		$conf: The PlugIn Configuration
  * @return	The content that should be displayed on the website
  */
 public function main($content, $conf)
 {
     /*{{{*/
     $this->pi_setPiVarDefaults();
     $this->pi_loadLL();
     // path to this extension
     $this->extPath = t3lib_extMgm::siteRelPath($this->extKey);
     // create instance of the extension library
     $this->lib = t3lib_div::makeInstance('tx_ketroubletickets_lib');
     // 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!
     $this->pi_USER_INT_obj = 1;
     // get the pidList and the recursive flag from the content object
     // if this plugin has been inserted into a content column (and has not
     // been included via typoscript)
     if (strstr($this->cObj->currentRecord, 'tt_content')) {
         $conf['pidList'] = $this->cObj->data['pages'] ? $this->cObj->data['pages'] : $conf['pidList'];
         $conf['recursive'] = $this->cObj->data['recursive'] ? $this->cObj->data['recursive'] : $conf['recursive'];
     }
     // make the configurationen class-wide available
     $this->conf = $conf;
     // a local content object (with clear configuration)
     $lcObj = t3lib_div::makeInstance('tslib_cObj');
     // start with empty content
     $content = '';
     // get the template
     $templateFile = $this->conf['templateFile'] ? $this->conf['templateFile'] : $this->extPath . 'res/template/ke_troubletickets_pi2.tmpl.htm';
     $this->templateCode = $lcObj->fileResource($templateFile);
     if (!$this->templateCode) {
         return '<p class="error">' . $this->pi_getLL('error_no_template') . '</p>';
     }
     // General permission check: This plugin only makes sense if a user is logged in
     if (!$GLOBALS['TSFE']->loginUser) {
         return $this->pi_wrapInBaseClass($this->pi_getLL('error_not_logged_in', 'Please log in.'));
     }
     /******************************************
      * Actions
      *****************************************/
     // show single view if searchword is ticket UID
     if ($this->isValidTicketUid($this->piVars['sword'])) {
         $this->piVars['showUid'] = intval($this->piVars['sword']);
         $this->piVars['sword'] = '';
         // get ticket data
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid,category', $this->tablename, 'uid=' . $this->piVars['showUid'] . $lcObj->enableFields($this->tablename));
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
             $ticket = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
         }
         // get the category data
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('singleviewpage', $this->categoryTablename, 'uid="' . $ticket['category'] . '" ' . $lcObj->enableFields($this->categoryTablename));
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
             $categoryData = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
         }
         // find out the singleview pid
         // the singleviewpage must be set in the category
         // If the category of the current ticket contains a single view page,
         // use that. Otherwise use the current page.
         if (is_array($categoryData) && !empty($categoryData['singleviewpage'])) {
             $singleViewPage = $categoryData['singleviewpage'];
             // render the link
             $linkToTicketURL = $this->pi_getPageLink($singleViewPage, '_blank', array('tx_ketroubletickets_pi1[showUid]' => $ticket['uid']));
             // do the redirect
             header('Location:' . t3lib_div::locationHeaderUrl($linkToTicketURL));
         } else {
             $content .= '<p class="error">' . $this->pi_getLL('error_no_singleviewpage') . '</p>';
         }
     }
     if ($this->piVars['sword']) {
         $content .= '<p class="error">' . $this->pi_getLL('error_not_found') . '</p>';
     }
     $content .= $this->renderForm();
     return $this->pi_wrapInBaseClass($content);
 }
    public function ajaxContentForm($app, $data)
    {
        $GLOBALS['TSFE']->additionalHeaderData['he_tools_css_1'] = '<link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/data_view.css" rel="stylesheet" type="text/css" />';
        //$GLOBALS['TSFE']->additionalHeaderData['he_tools_css_1'] = '<link href="' . t3lib_extMgm::siteRelPath('he_tools') . 'res/' . $cssDatei . '" rel="stylesheet" type="text/css" />';
        $daten = $this->ajaxContentFormGetListData($app, $data);
        $filter = $this->getFilter($app, $data);
        $out = '<div class="filter">' . $filter . '</div>';
        $out .= '
		<div class="a_bis_z_suche ' . $app . '">
	<form action="" method="post" onSubmit="return false;">
	<div class="azSelector azSelector-list-1">
	<ul class="azSelector azSelector-list-1">';
        $link = 'index.php?id=' . $GLOBALS['TSFE']->id . '&azTab=alle';
        $out .= '<li class="tab-alle selected">
		<a onclick="javascript:charClick(\'alle\');return false;" href="' . $link . '" title="Alle Einträge" target="_self">
		<span>Alle</span></a></li>';
        $azListe = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'PQ', 'R', 'S', 'T', 'U', 'V', 'W', 'XYZ');
        foreach ($azListe as $eintrag) {
            $link = 'index.php?id=' . $GLOBALS['TSFE']->id . '&azTab=' . $eintrag;
            $out .= '<li class="tab-' . $eintrag . '">';
            $searchFields = explode(',', $daten['searchFields']);
            $buchstabeVorhanden = FALSE;
            foreach ($daten['data'] as $entry) {
                foreach ($searchFields as $field) {
                    if (strtoupper($entry[$field][0]) == $eintrag) {
                        $buchstabeVorhanden = TRUE;
                    }
                }
            }
            if ($buchstabeVorhanden) {
                $out .= '<a onclick="javascript:charClick(\'' . $eintrag . '\');return false;" href="' . $link . '" title="' . $eintrag . '" target="_self">
								<span>' . $eintrag . '</span></a>';
            } else {
                $out .= '<span class="disable">' . $eintrag . '</span>';
            }
            $out .= '</li>';
        }
        $out .= '</ul>
		</div>
		<div style="margin: 10px 0;">
		Bitte geben Sie einen Suchbegriff ein.</div>
		<input class="such_box" type="text" id="eingabe" name="eingabe" size="40" />
		<input id="absenden" type="submit" value="Absenden" />
		</form>
		<div id="namenListe">
		<div id="ergebnisliste">
		';
        $userName = $GLOBALS['TSFE']->fe_user->user['username'];
        $out .= $this->ajaxContentFormRenderListData($app, $daten['data']);
        $out .= '</div>
		</div>
		</div>
		';
        $out .= $this->getJs($app, $data['pid']);
        return $out;
    }
    /**
     * Displays a hirarchical menu from tt_news categories
     *
     * @return	string		html for the category menu
     */
    function displayCatMenu()
    {
        $content = '';
        $lConf = $this->conf['displayCatMenu.'];
        $mode = $lConf['mode'] ? $lConf['mode'] : 'tree';
        $this->dontStartFromRootRecord = false;
        $this->initCatmenuEnv($lConf);
        switch ($mode) {
            case 'nestedWraps':
                $fields = '*';
                $lConf = $this->conf['displayCatMenu.'];
                $addCatlistWhere = '';
                if ($this->dontStartFromRootRecord) {
                    $addCatlistWhere = 'tt_news_cat.uid IN (' . implode(',', $this->cleanedCategoryMounts) . ')';
                }
                $res = $this->db->exec_SELECTquery($fields, 'tt_news_cat', ($this->dontStartFromRootRecord ? $addCatlistWhere : 'tt_news_cat.parent_category=0') . $this->SPaddWhere . $this->enableCatFields . $this->catlistWhere, '', 'tt_news_cat.' . $this->config['catOrderBy']);
                $cArr = array();
                if (!$lConf['hideCatmenuHeader']) {
                    $cArr[] = $this->local_cObj->stdWrap($this->pi_getLL('catmenuHeader', 'Select a category:'), $lConf['catmenuHeader_stdWrap.']);
                }
                while ($row = $this->db->sql_fetch_assoc($res)) {
                    $cArr[] = $row;
                    $subcats = $this->hObj->getSubCategoriesForMenu($row['uid'], $fields, $this->catlistWhere);
                    if (count($subcats)) {
                        $cArr[] = $subcats;
                    }
                }
                $this->db->sql_free_result($res);
                $content = $this->getCatMenuContent($cArr, $lConf);
                break;
            case 'tree':
            case 'ajaxtree':
                $catTreeObj = t3lib_div::makeInstance('tx_ttnews_catmenu');
                if ($mode == 'ajaxtree') {
                    // todo use pagerenderer
                    $this->tsfe->additionalHeaderData['tt_news_categorytree'] = '
						' . ($lConf['includePrototypeJS'] ? '<script type="text/javascript" src="typo3/contrib/prototype/prototype.js"></script>' : '') . '
						<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath('tt_news') . 'js/tt_news_catmenu.js"></script>
					';
                }
                $catTreeObj->init($this);
                $catTreeObj->treeObj->FE_USER =& $this->tsfe->fe_user;
                $content = '<div id="ttnews-cat-tree">' . $catTreeObj->treeObj->getBrowsableTree() . '</div>';
                break;
            default:
                // hook for user catmenu
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['userDisplayCatmenuHook'])) {
                    foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['userDisplayCatmenuHook'] as $_classRef) {
                        $_procObj =& t3lib_div::getUserObj($_classRef);
                        $content = $_procObj->userDisplayCatmenu($lConf, $this);
                    }
                }
                break;
        }
        if ($this->debugTimes) {
            $this->hObj->getParsetime(__METHOD__);
        }
        return $this->local_cObj->stdWrap($content, $lConf['catmenu_stdWrap.']);
    }
Beispiel #23
0
    function makeMap($addresses)
    {
        $script_url1 = t3lib_extMgm::siteRelPath($this->extKey) . 'scripts/OpenLayers/OpenLayers.js';
        $script_url2 = t3lib_extMgm::siteRelPath($this->extKey) . 'scripts/OpenLayers/OpenStreetMap.js';
        $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = '<script type="text/javascript" src="' . $script_url1 . '" language="JavaScript"></script><script type="text/javascript" src="' . $script_url2 . '" language="JavaScript"></script>';
        $iconUrl = "typo3conf/ext/3px_osmap/res/" . $this->conf['iconFile'];
        $zoom = $this->conf['zoom'] ? $this->conf['zoom'] : 10;
        $zoom = $this->lConf['zoom'] ? $this->lConf['zoom'] : $zoom;
        $mapWidth = $this->conf['mapWidth'] ? $this->conf['mapWidth'] : 600;
        $mapWidth = $this->lConf['mapWidth'] ? $this->lConf['mapWidth'] : $mapWidth;
        $mapHeight = $this->conf['mapHeight'] ? $this->conf['mapHeight'] : 400;
        $mapHeight = $this->lConf['mapHeight'] ? $this->lConf['mapHeight'] : $mapWidth;
        $map = '
    <div id="tx_3pxosmap_pi1_map" style="width:' . $mapWidth . 'px; height:' . $mapWidth . 'px;">
    <script type="text/javascript">
        function Lon2Merc(lon) {
          return 20037508.34*lon/180;
        }
        function Lat2Merc(lat) {
          var PI = 3.14159265358979323846;
          lat = Math.log(Math.tan((90 + lat)*PI/360))/(PI/180);
          return 20037508.34*lat/180;
        }
        var currentPopup;
        var zoom = ' . $zoom . ';

        // layers            
        var mapnik_layer = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
        var tah_layer = new OpenLayers.Layer.OSM.Osmarender("Osmarender");
        var cyclemap_layer = new OpenLayers.Layer.OSM.CycleMap("CycleMap");

        // icon
        var size = new OpenLayers.Size(' . $this->conf['iconWidth'] . ',' . $this->conf['iconHeight'] . ');
        var offset = new OpenLayers.Pixel(-((size.w/2)-0), -(size.h-0));
        var offset = 0;
        var icon = new OpenLayers.Icon("' . $iconUrl . '",size,offset);
        icon.setOpacity(0.8);
      ';
        $min_lat = -90;
        $max_lat = 90;
        $min_lon = -180;
        $max_lon = 180;
        foreach ($addresses as $address) {
            $address_description = $address['address'];
            if ($address['address'] && $address['city']) {
                $address_description .= ', ';
            }
            $address_description .= $address['zip'] . ' ' . $address['city'];
            $map_entries .= '
            DrawAddressEntry(' . $address['lon'] . ',' . $address['lat'] . ',"' . $address['uid'] . '","' . $address['name'] . '","' . $address_description . '");
        ';
            if ($max_lat > $address['lat']) {
                $max_lat = $address['lat'];
            }
            if ($min_lat < $address['lat']) {
                $min_lat = $address['lat'];
            }
            if ($max_lon > $address['lon']) {
                $max_lon = $address['lon'];
            }
            if ($min_lon < $address['lon']) {
                $min_lon = $address['lon'];
            }
        }
        $map .= '
      
          // bounds
          var p_min = new OpenLayers.Geometry.Point(' . $min_lon . ', ' . $min_lat . ');
          p_min.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); 

          var p_max = new OpenLayers.Geometry.Point(' . $max_lon . ', ' . $max_lat . ');
          p_max.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); 

          var bounds = new OpenLayers.Bounds();
          bounds.extend(p_min);
          bounds.extend(p_max);
          bounds.toBBOX(); 

          // map      
          var map = new OpenLayers.Map("tx_3pxosmap_pi1_map", {
            controls: [
              new OpenLayers.Control.KeyboardDefaults(),
              new OpenLayers.Control.MouseDefaults(),
              new OpenLayers.Control.LayerSwitcher(),
              new OpenLayers.Control.PanZoomBar()],
              maxExtent: bounds,
              numZoomLevels: 18,
              maxResolution: 156543,
              units: "meters",
              projection: "EPSG:41001"} );
              
              
          map.addLayers([mapnik_layer, tah_layer, cyclemap_layer]);
            
          var markers = new OpenLayers.Layer.Markers( "map" );
          map.addLayer(markers);
            
          var markerClick = function (evt) {
              if (this.popup == null) {
                  this.popup = this.createPopup(true);
                  this.popup.setOpacity(0.8);
                  map.addPopup(this.popup);
                  this.popup.show();
              } else {
                  this.popup.toggle();
              }
              currentPopup = this.popup;
              OpenLayers.Event.stop(evt);
          };
                        
          function DrawAddressEntry(lon,lat,uid,name,description) {
            var coords =  new OpenLayers.LonLat(Lon2Merc(lon),Lat2Merc(lat));
            var feature = new OpenLayers.Feature(uid,coords);
            feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, { minSize: new OpenLayers.Size(150, 100) });
            feature.data.popupContentHTML = "<div><strong>" + name + "</strong><br />" + description + "</div>";
            var marker = new OpenLayers.Marker(coords,icon.clone());
            marker.feature = feature;
            markers.addMarker(marker);
            marker.events.register("click", feature, markerClick);
          
          }
          // draw all entries
          ' . $map_entries . '
  
          // extent & zoom to zoomlevel
          map.zoomToExtent(bounds)
          // get current zoom 
          var current_zoom = map.getZoom();
          // avoid that predefined zoom it to large to show all entries
          if ( zoom > current_zoom ) {
              zoom = current_zoom;
          }
          map.zoomTo(zoom);

      </script>
      </div>
      <div id="tx_3pxosmap_pi1_credits">karte von <a href="http://www.openstreetmap.org/">openstreetmap</a>, anzeige mit <a href="http://www.openlayers.org/">openlayers</a></div>
      
    
    ';
        return $map;
    }
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
if (!defined('PATH_txdam')) {
    define('PATH_txdam', t3lib_extMgm::extPath('dam'));
}
if (!defined('PATH_txdam_rel')) {
    define('PATH_txdam_rel', t3lib_extMgm::extRelPath('dam'));
}
if (!defined('PATH_txdam_siteRel')) {
    define('PATH_txdam_siteRel', t3lib_extMgm::siteRelPath('dam'));
}
// that's the base API
require_once PATH_txdam . 'lib/class.tx_dam.php';
// include basic image stuff because it's used so often
require_once PATH_txdam . 'lib/class.tx_dam_image.php';
// get extension setup
$TYPO3_CONF_VARS['EXTCONF']['dam']['setup'] = unserialize($_EXTCONF);
if ($TYPO3_CONF_VARS['EXTCONF']['dam']['setup']['tsconfig'] === 'default') {
    t3lib_extMgm::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:dam/tsconfig/default.txt">');
} elseif ($TYPO3_CONF_VARS['EXTCONF']['dam']['setup']['tsconfig'] === 'minimal') {
    t3lib_extMgm::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:dam/tsconfig/minimal.txt">');
} elseif ($TYPO3_CONF_VARS['EXTCONF']['dam']['setup']['tsconfig'] === 'example') {
    t3lib_extMgm::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:dam/tsconfig/example.txt">');
}
// set some config values from extension setup
tx_dam::config_setValue('setup.devel', $TYPO3_CONF_VARS['EXTCONF']['dam']['setup']['devel']);
// register default icons
tx_dam::register_fileIconPath(PATH_txdam . 'i/18/', 'FE');
 /**
  * initial all the values for the RTE
  * 
  * @param	array		config to use
  * @param	array		rteId (a counter)
  * @return	array		initiated config
  */
 function init($config, $rteId = 1, $PA = array())
 {
     global $LANG, $BE_USER;
     if (TYPO3_branch == 4.1 && !t3lib_extMgm::isLoaded('tinymce_rte_patch41')) {
         die('for TYPO3 4.1 you need to install the extension tinymce_rte_patch41');
     }
     // get the language (also checks if lib is called from FE or BE, which might of use later.)
     if (TYPO3_MODE == 'FE') {
         $LANG = t3lib_div::makeInstance('language');
         $LANG->init($GLOBALS['TSFE']->tmpl->setup['config.']['language']);
         $LANG->includeLLFile('typo3conf/ext/tinymce_rte/mod1/locallang_browse_links.xml');
     } else {
         $LANG = $GLOBALS['LANG'];
     }
     $this->language = $LANG->lang;
     // language conversion from TLD to iso631
     if (is_array($LANG->csConvObj->isoArray) && array_key_exists($this->language, $LANG->csConvObj->isoArray)) {
         $this->language = $LANG->csConvObj->isoArray[$this->language];
     }
     // check if TinyMCE language file exists
     $langpath = t3lib_extmgm::isLoaded($config['languagesExtension']) ? t3lib_extMgm::siteRelPath($config['languagesExtension']) : t3lib_extMgm::siteRelPath('tinymce_rte') . 'res/';
     if (!is_file(PATH_site . $langpath . 'tiny_mce/langs/' . $this->language . '.js')) {
         $this->language = 'en';
     }
     $config['init.']['language'] = $this->language;
     $config['init.']['document_base_url'] = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
     $config['init.']['elements'] = 'RTEarea' . $rteId;
     // resolve EXT pathes for these values
     $config['init.']['spellchecker_rpc_url'] = $this->getPath($config['init.']['spellchecker_rpc_url']) . '?pageId=' . $this->currentPage;
     $config['tiny_mcePath'] = $this->getPath($config['tiny_mcePath']);
     $config['tiny_mceGzipPath'] = $this->getPath($config['tiny_mceGzipPath']);
     // defines if you want to force UTF8 on every config entry
     $this->forceUTF8 = $config['forceUTF8'] ? true : false;
     if (is_array($BE_USER->userTS['RTE.'])) {
         $config = $this->array_merge_recursive_override($config, $BE_USER->userTS['RTE.']['default.']);
     }
     return $config;
 }
   /**
    * 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);
   }
Beispiel #27
0
 /**
  * Get wizard array for FCEs
  *
  * @param array $wizardElements
  * @return array $returnElements
  */
 function wizard_renderFCEs($wizardElements)
 {
     if (!is_array($wizardElements)) {
         $wizardElements = array();
     }
     $returnElements = array();
     // Flexible content elements:
     $positionPid = $this->id;
     $storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid);
     $toRepo = t3lib_div::makeInstance('tx_templavoila_templateRepository');
     $toList = $toRepo->getTemplatesByStoragePidAndScope($storageFolderPID, tx_templavoila_datastructure::SCOPE_FCE);
     foreach ($toList as $toObj) {
         if ($toObj->isPermittedForUser()) {
             $tmpFilename = $toObj->getIcon();
             $returnElements['fce.']['elements.']['fce_' . $toObj->getKey() . '.'] = array('icon' => @is_file(PATH_site . substr($tmpFilename, 3)) ? $tmpFilename : '../' . t3lib_extMgm::siteRelPath('templavoila') . 'res1/default_previewicon.gif', 'description' => $toObj->getDescription() ? htmlspecialchars($toObj->getDescription()) : $GLOBALS['LANG']->getLL('template_nodescriptionavailable'), 'title' => $toObj->getLabel(), 'params' => $this->getDsDefaultValues($toObj));
         }
     }
     return $returnElements;
 }
    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);
    }
 /**
  * Builds a collection list
  *
  * @access	protected
  *
  * @return	string		The list of collections ready to output
  */
 protected function showCollectionList()
 {
     $additionalWhere = '';
     $orderBy = 'tx_dlf_collections.label';
     // Handle collections set by configuration.
     if ($this->conf['collections']) {
         if (count(explode(',', $this->conf['collections'])) == 1 && empty($this->conf['dont_show_single'])) {
             $this->showSingleCollection(intval(trim($this->conf['collections'], ' ,')));
         }
         $additionalWhere .= ' AND tx_dlf_collections.uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']) . ')';
         $orderBy = 'FIELD(tx_dlf_collections.uid, ' . $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']) . ')';
     }
     // Should user-defined collections be shown?
     if (empty($this->conf['show_userdefined'])) {
         $additionalWhere .= ' AND tx_dlf_collections.fe_cruser_id=0';
     } elseif ($this->conf['show_userdefined'] > 0) {
         if (!empty($GLOBALS['TSFE']->fe_user->user['uid'])) {
             $additionalWhere .= ' AND tx_dlf_collections.fe_cruser_id=' . intval($GLOBALS['TSFE']->fe_user->user['uid']);
         } else {
             $additionalWhere .= ' AND NOT tx_dlf_collections.fe_cruser_id=0';
         }
     }
     // Get collections.
     $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_collections.uid AS uid,tx_dlf_collections.label AS label,tx_dlf_collections.thumbnail AS thumbnail,tx_dlf_collections.description AS description,tx_dlf_collections.priority AS priority,COUNT(tx_dlf_documents.uid) AS titles', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_documents.partof=0 AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . $additionalWhere . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_collections.uid', $orderBy, '');
     $count = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
     $content = '';
     if ($count == 1 && empty($this->conf['dont_show_single'])) {
         $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
         $this->showSingleCollection(intval($resArray['uid']));
     } elseif ($count > 0) {
         // Get number of volumes per collection.
         $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_collections.uid AS uid,COUNT(tx_dlf_documents.uid) AS volumes', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0' . tx_dlf_helper::whereClause('tx_dlf_documents') . ') AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . $additionalWhere . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_collections.uid', '', '');
         $volumes = array();
         while ($resArrayVolumes = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resultVolumes)) {
             $volumes[$resArrayVolumes['uid']] = $resArrayVolumes['volumes'];
         }
         // Process results.
         while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
             // Generate random but unique array key taking priority into account.
             do {
                 $_key = $resArray['priority'] * 1000 + mt_rand(0, 1000);
             } while (!empty($markerArray[$_key]));
             // Merge plugin variables with new set of values.
             $additionalParams = array('collection' => $resArray['uid']);
             if (is_array($this->piVars)) {
                 $piVars = $this->piVars;
                 unset($piVars['DATA']);
                 $additionalParams = tx_dlf_helper::array_merge_recursive_overrule($piVars, $additionalParams);
             }
             // Build typolink configuration array.
             $conf = array('useCacheHash' => 1, 'parameter' => $GLOBALS['TSFE']->id, 'additionalParams' => t3lib_div::implodeArrayForUrl($this->prefixId, $additionalParams, '', TRUE, FALSE));
             // Link collection's title to list view.
             $markerArray[$_key]['###TITLE###'] = $this->cObj->typoLink(htmlspecialchars($resArray['label']), $conf);
             // Add feed link if applicable.
             if (!empty($this->conf['targetFeed'])) {
                 $img = '<img src="' . t3lib_extMgm::siteRelPath($this->extKey) . 'res/icons/txdlffeeds.png" alt="' . $this->pi_getLL('feedAlt', '', TRUE) . '" title="' . $this->pi_getLL('feedTitle', '', TRUE) . '" />';
                 $markerArray[$_key]['###FEED###'] = $this->pi_linkTP($img, array($this->prefixId => array('collection' => $resArray['uid'])), FALSE, $this->conf['targetFeed']);
             } else {
                 $markerArray[$_key]['###FEED###'] = '';
             }
             // Add thumbnail.
             if (!empty($resArray['thumbnail'])) {
                 $markerArray[$_key]['###THUMBNAIL###'] = '<img alt="" title="' . htmlspecialchars($resArray['label']) . '" src="' . $resArray['thumbnail'] . '" />';
             } else {
                 $markerArray[$_key]['###THUMBNAIL###'] = '';
             }
             // Add description.
             $markerArray[$_key]['###DESCRIPTION###'] = $this->pi_RTEcssText($resArray['description']);
             // Build statistic's output.
             $labelTitles = $this->pi_getLL($resArray['titles'] > 1 ? 'titles' : 'title', '', FALSE);
             $markerArray[$_key]['###COUNT_TITLES###'] = htmlspecialchars($resArray['titles'] . $labelTitles);
             $labelVolumes = $this->pi_getLL($volumes[$resArray['uid']] > 1 ? 'volumes' : 'volume', '', FALSE);
             $markerArray[$_key]['###COUNT_VOLUMES###'] = htmlspecialchars($volumes[$resArray['uid']] . $labelVolumes);
         }
         // Randomize sorting?
         if (!empty($this->conf['randomize'])) {
             ksort($markerArray, SORT_NUMERIC);
             // Don't cache the output.
             $this->setCache(FALSE);
         }
         $entry = $this->cObj->getSubpart($this->template, '###ENTRY###');
         foreach ($markerArray as $marker) {
             $content .= $this->cObj->substituteMarkerArray($entry, $marker);
         }
         // Hook for getting custom collection hierarchies/subentries (requested by SBB).
         foreach ($this->hookObjects as $hookObj) {
             if (method_exists($hookObj, 'showCollectionList_getCustomCollectionList')) {
                 $hookObj->showCollectionList_getCustomCollectionList($this, $this->conf['templateFile'], $content, $markerArray);
             }
         }
         return $this->cObj->substituteSubpart($this->template, '###ENTRY###', $content, TRUE);
     }
     return $content;
 }
 /**
  * Calculates the path to the TYPO3 directory from the current directory
  *
  * @return string
  */
 protected function getBackPath()
 {
     $extPath = t3lib_extMgm::siteRelPath('openid');
     $segmentCount = count(explode('/', $extPath));
     $path = str_pad('', $segmentCount * 3, '../') . TYPO3_mainDir;
     return $path;
 }