/**
  * Makes debug output
  * Prints $var in bold between two vertical lines
  * If not $var the word 'debug' is printed
  * If $var is an array, the array is printed by t3lib_div::print_array()
  * Wrapper method for TYPO3 debug methods
  *
  * @param	mixed		Variable to print
  * @param	string		The header.
  * @param	string		Group for the debug console
  * @return	void
  */
 public static function debug($var = '', $header = '', $group = 'Debug')
 {
     if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) {
         return \TYPO3\CMS\Core\Utility\DebugUtility::debug($var, $header, $group);
     } else {
         return t3lib_utility_Debug::debug($var, $header, $group);
     }
 }
Example #2
0
 /**
  * @param $parameters
  */
 protected function writeDebugMessage($parameters)
 {
     $message = isset($parameters['msg']) ? $parameters['msg'] : '';
     if (TYPO3_MODE == 'BE') {
         DebugUtility::debug($parameters, $parameters['extKey'], 'DevLog ext:solr: ' . $message);
     } else {
         echo $message . ':<br/>';
         DebuggerUtility::var_dump($parameters);
     }
 }
Example #3
0
function debug($variable = '', $name = '*variable*', $line = '*line*', $file = '*file*', $recursiveDepth = 3, $debugLevel = E_DEBUG)
{
    // If you wish to use the debug()-function, and it does not output something,
    // please edit the IP mask in TYPO3_CONF_VARS
    if (!\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
        return;
    }
    if (is_object($GLOBALS['error']) && @is_callable([$GLOBALS['error'], 'debug'])) {
        $GLOBALS['error']->debug($variable, $name, $line, $file, $recursiveDepth, $debugLevel);
    } else {
        $title = $name === '*variable*' ? '' : $name;
        $group = $line === '*line*' ? null : $line;
        \TYPO3\CMS\Core\Utility\DebugUtility::debug($variable, $title, $group);
    }
}
 /**
  * Writes a message to the deprecation log.
  *
  * @param string $msg Message (in English).
  * @return void
  */
 public static function deprecationLog($msg)
 {
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         return;
     }
     // Legacy values (no strict comparison, $log can be boolean, string or int)
     $log = $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'];
     if ($log === TRUE || $log == '1') {
         $log = array('file');
     } else {
         $log = self::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'], TRUE);
     }
     $date = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ': ');
     if (in_array('file', $log) !== FALSE) {
         // In case lock is acquired before autoloader was defined:
         if (class_exists('TYPO3\\CMS\\Core\\Locking\\Locker') === FALSE) {
             require_once ExtensionManagementUtility::extPath('core') . 'Classes/Locking/Locker.php';
         }
         // Write a longer message to the deprecation log
         $destination = self::getDeprecationLogFileName();
         $file = @fopen($destination, 'a');
         if ($file) {
             @fwrite($file, $date . $msg . LF);
             @fclose($file);
             self::fixPermissions($destination);
         }
     }
     if (in_array('devlog', $log) !== FALSE) {
         // Copy message also to the developer log
         self::devLog($msg, 'Core', self::SYSLOG_SEVERITY_WARNING);
     }
     // Do not use console in login screen
     if (in_array('console', $log) !== FALSE && isset($GLOBALS['BE_USER']->user['uid'])) {
         \TYPO3\CMS\Core\Utility\DebugUtility::debug($msg, $date, 'Deprecation Log');
     }
 }
Example #5
0
 /**
  * Debugging var with header and group.
  *
  * @param mixed $var Var
  * @param string $header Header
  * @param string $group Group
  *
  * @return void
  */
 protected function debug($var, $header, $group)
 {
     if ($this->debug) {
         \TYPO3\CMS\Core\Utility\DebugUtility::debug($var, $header, $group);
     }
 }
Example #6
0
 /**
  * Writes a message to the deprecation log.
  *
  * @param string $msg Message (in English).
  * @return void
  */
 public static function deprecationLog($msg)
 {
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         return;
     }
     // Legacy values (no strict comparison, $log can be boolean, string or int)
     $log = $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'];
     if ($log === true || $log == '1') {
         $log = ['file'];
     } else {
         $log = self::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'], true);
     }
     $date = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ': ');
     if (in_array('file', $log) !== false) {
         // Write a longer message to the deprecation log
         $destination = static::getDeprecationLogFileName();
         $file = @fopen($destination, 'a');
         if ($file) {
             @fwrite($file, $date . $msg . LF);
             @fclose($file);
             self::fixPermissions($destination);
         }
     }
     if (in_array('devlog', $log) !== false) {
         // Copy message also to the developer log
         self::devLog($msg, 'Core', self::SYSLOG_SEVERITY_WARNING);
     }
     // Do not use console in login screen
     if (in_array('console', $log) !== false && isset($GLOBALS['BE_USER']->user['uid'])) {
         DebugUtility::debug($msg, $date, 'Deprecation Log');
     }
 }
 /**
  * Explain select queries
  * If $this->explainOutput is set, SELECT queries will be explained here. Only queries with more than one possible result row will be displayed.
  * The output is either printed as raw HTML output or embedded into the TS admin panel (checkbox must be enabled!)
  *
  * @todo Feature is not DBAL-compliant
  *
  * @param string $query SQL query
  * @param string $from_table Table(s) from which to select. This is what comes right after "FROM ...". Required value.
  * @param int $row_count Number of resulting rows
  * @return bool TRUE if explain was run, FALSE otherwise
  */
 protected function explain($query, $from_table, $row_count)
 {
     $debugAllowedForIp = GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
     if ((int) $this->explainOutput == 1 || (int) $this->explainOutput == 2 && $debugAllowedForIp) {
         // Raw HTML output
         $explainMode = 1;
     } elseif ((int) $this->explainOutput == 3 && is_object($GLOBALS['TT'])) {
         // Embed the output into the TS admin panel
         $explainMode = 2;
     } else {
         return false;
     }
     $error = $this->sql_error();
     $trail = \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail();
     $explain_tables = array();
     $explain_output = array();
     $res = $this->sql_query('EXPLAIN ' . $query, $this->link);
     if (is_a($res, '\\mysqli_result')) {
         while ($tempRow = $this->sql_fetch_assoc($res)) {
             $explain_output[] = $tempRow;
             $explain_tables[] = $tempRow['table'];
         }
         $this->sql_free_result($res);
     }
     $indices_output = array();
     // Notice: Rows are skipped if there is only one result, or if no conditions are set
     if ($explain_output[0]['rows'] > 1 || GeneralUtility::inList('ALL', $explain_output[0]['type'])) {
         // Only enable output if it's really useful
         $debug = true;
         foreach ($explain_tables as $table) {
             $tableRes = $this->sql_query('SHOW TABLE STATUS LIKE \'' . $table . '\'');
             $isTable = $this->sql_num_rows($tableRes);
             if ($isTable) {
                 $res = $this->sql_query('SHOW INDEX FROM ' . $table, $this->link);
                 if (is_a($res, '\\mysqli_result')) {
                     while ($tempRow = $this->sql_fetch_assoc($res)) {
                         $indices_output[] = $tempRow;
                     }
                     $this->sql_free_result($res);
                 }
             }
             $this->sql_free_result($tableRes);
         }
     } else {
         $debug = false;
     }
     if ($debug) {
         if ($explainMode) {
             $data = array();
             $data['query'] = $query;
             $data['trail'] = $trail;
             $data['row_count'] = $row_count;
             if ($error) {
                 $data['error'] = $error;
             }
             if (!empty($explain_output)) {
                 $data['explain'] = $explain_output;
             }
             if (!empty($indices_output)) {
                 $data['indices'] = $indices_output;
             }
             if ($explainMode == 1) {
                 \TYPO3\CMS\Core\Utility\DebugUtility::debug($data, 'Tables: ' . $from_table, 'DB SQL EXPLAIN');
             } elseif ($explainMode == 2) {
                 $GLOBALS['TT']->setTSselectQuery($data);
             }
         }
         return true;
     }
     return false;
 }
Example #8
0
 /**
  * Writes a message to the deprecation log.
  *
  * @param string $msg Message (in English).
  * @return void
  */
 public static function deprecationLog($msg)
 {
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         return;
     }
     $log = $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'];
     $date = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ': ');
     // Legacy values (no strict comparison, $log can be boolean, string or int)
     if ($log === TRUE || $log == '1') {
         $log = 'file';
     }
     if (stripos($log, 'file') !== FALSE) {
         // In case lock is acquired before autoloader was defined:
         if (class_exists('TYPO3\\CMS\\Core\\Locking\\Locker') === FALSE) {
             require_once PATH_t3lib . 'class.t3lib_lock.php';
         }
         // Write a longer message to the deprecation log
         $destination = self::getDeprecationLogFileName();
         $lockObject = self::makeInstance('TYPO3\\CMS\\Core\\Locking\\Locker', $destination, $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']);
         /** @var \TYPO3\CMS\Core\Locking\Locker $lockObject */
         $lockObject->setEnableLogging(FALSE);
         $lockObject->acquire();
         $file = @fopen($destination, 'a');
         if ($file) {
             @fwrite($file, $date . $msg . LF);
             @fclose($file);
             self::fixPermissions($destination);
         }
         $lockObject->release();
     }
     if (stripos($log, 'devlog') !== FALSE) {
         // Copy message also to the developer log
         self::devLog($msg, 'Core', self::SYSLOG_SEVERITY_WARNING);
     }
     // Do not use console in login screen
     if (stripos($log, 'console') !== FALSE && isset($GLOBALS['BE_USER']->user['uid'])) {
         \TYPO3\CMS\Core\Utility\DebugUtility::debug($msg, $date, 'Deprecation Log');
     }
 }
Example #9
0
    /**
     * Calling function that checks system, IM, GD, dirs, database
     * and lets you alter localconf.php
     *
     * This method is called from init.php to start the Install Tool.
     *
     * @return void
     * @todo Define visibility
     */
    public function init()
    {
        // Must be called after inclusion of init.php (or from init.php)
        if (!defined('PATH_typo3')) {
            die;
        }
        if (!$this->passwordOK) {
            die;
        }
        // Setting stuff...
        $this->check_mail();
        $this->setupGeneral();
        $this->generateConfigForm();
        if (count($this->messages)) {
            \TYPO3\CMS\Core\Utility\DebugUtility::debug($this->messages);
        }
        if ($this->step) {
            $this->output($this->outputWrapper($this->stepOutput()));
        } else {
            // Menu...
            switch ($this->INSTALL['type']) {
                case 'images':
                    $this->checkIM = 1;
                    $this->checkTheConfig();
                    $this->silent = 0;
                    $this->checkTheImageProcessing();
                    break;
                case 'database':
                    $this->checkTheConfig();
                    $this->silent = 0;
                    $this->checkTheDatabase();
                    break;
                case 'update':
                    $this->checkDatabase();
                    $this->silent = 0;
                    $this->updateWizard();
                    break;
                case 'config':
                    $this->silent = 0;
                    $this->checkIM = 1;
                    $this->message('About configuration', 'How to configure TYPO3', $this->generallyAboutConfiguration());
                    $isPhpCgi = PHP_SAPI == 'fpm-fcgi' || PHP_SAPI == 'cgi' || PHP_SAPI == 'isapi' || PHP_SAPI == 'cgi-fcgi';
                    $this->message('System Information', 'Your system has the following configuration', '
							<dl id="systemInformation">
								<dt>OS detected:</dt>
								<dd>' . (TYPO3_OS == 'WIN' ? 'WIN' : 'UNIX') . '</dd>
								<dt>CGI detected:</dt>
								<dd>' . ($isPhpCgi ? 'YES' : 'NO') . '</dd>
								<dt>PATH_thisScript:</dt>
								<dd>' . PATH_thisScript . '</dd>
							</dl>
						');
                    $this->checkTheConfig();
                    $ext = 'Write configuration';
                    if ($this->fatalError) {
                        if ($this->config_array['no_database'] || !$this->config_array['mysqlConnect']) {
                            $this->message($ext, 'Database not configured yet!', '
								<p>
									You need to specify database username,
									password and host as one of the first things.
									<br />
									Next you\'ll have to select a database to
									use with TYPO3.
								</p>
								<p>
									Use the form below.
								</p>
							', 2);
                        } else {
                            $this->message($ext, 'Fatal error encountered!', '
								<p>
									Somewhere above a fatal configuration
									problem is encountered.
									Please make sure that you\'ve fixed this
									error before you submit the configuration.
									TYPO3 will not run if this problem is not
									fixed!
									<br />
									You should also check all warnings that may
									appear.
								</p>
							', 2);
                        }
                    } elseif ($this->mode == '123') {
                        if (!$this->fatalError) {
                            $this->message($ext, 'Basic configuration completed', '
								<p>
									You have no fatal errors in your basic
									configuration.
									You may have warnings though. Please pay
									attention to them!
									However you may continue and install the
									database.
								</p>
								<p>
									<strong>
										<span style="color:#f00;">Step 2: </span>
									</strong>
									<a href="' . $this->scriptSelf . '?TYPO3_INSTALL[type]=database' . ($this->mode ? '&mode=' . rawurlencode($this->mode) : '') . '">Click here to install the database.</a>
								</p>
							', -1, 1);
                        }
                    }
                    $this->message($ext, 'Very Important: Changing Image Processing settings', '
						<p>
							When you change the settings for Image Processing
							you <em>must</em> take into account
							that <em>old images</em> may still be in typo3temp/
							folder and prevent new files from being generated!
							<br />
							This is especially important to know, if you\'re
							trying to set up image processing for the very first
							time.
							<br />
							The problem is solved by <a href="' . htmlspecialchars($this->setScriptName('cleanup')) . '">clearing the typo3temp/ folder</a>.
							Also make sure to clear the cache_pages table.
						</p>
					', 1, 1);
                    $this->message($ext, 'Very Important: Changing Encryption Key setting', '
						<p>
							When you change the setting for the Encryption Key
							you <em>must</em> take into account that a change to
							this value might invalidate temporary information,
							URLs etc.
							<br />
							The problem is solved by <a href="' . htmlspecialchars($this->setScriptName('cleanup')) . '">clearing the typo3temp/ folder</a>.
							Also make sure to clear the cache_pages table.
						</p>
					', 1, 1);
                    $this->message($ext, 'Update configuration', '
						<p>
							This form updates the configuration with the
							suggested values you see below. The values are based
							on the analysis above.
							<br />
							You can change the values in case you have
							alternatives to the suggested defaults.
							<br />
							By this final step you will configure TYPO3 for
							immediate use provided that you have no fatal errors
							left above.
						</p>' . $this->setupGeneral('get_form') . '
					', 0, 1);
                    $this->output($this->outputWrapper($this->printAll()));
                    break;
                case 'extConfig':
                    $this->silent = 0;
                    $this->generateConfigForm('get_form');
                    // Get the template file
                    $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'InitExtConfig.html');
                    // Get the template part from the file
                    $template = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($templateFile, '###TEMPLATE###');
                    // Define the markers content
                    $markers = array('action' => $this->action, 'content' => $this->printAll(), 'write' => 'Write configuration', 'notice' => 'NOTICE:', 'explanation' => '
							By clicking this button, the configuration is updated
							with new values for the parameters listed above!
						');
                    // Fill the markers in the template
                    $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($template, $markers, '###|###', TRUE, FALSE);
                    // Send content to the page wrapper function
                    $this->output($this->outputWrapper($content));
                    break;
                case 'cleanup':
                    $this->checkTheConfig();
                    $this->silent = 0;
                    $this->cleanupManager();
                    break;
                case 'phpinfo':
                    $this->silent = 0;
                    $this->phpinformation();
                    break;
                case 'typo3conf_edit':
                    $this->silent = 0;
                    $this->typo3conf_edit();
                    break;
                case 'logout':
                    $enableInstallToolFile = PATH_site . 'typo3conf/ENABLE_INSTALL_TOOL';
                    if (is_file($enableInstallToolFile) && trim(file_get_contents($enableInstallToolFile)) !== 'KEEP_FILE') {
                        unlink(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                    }
                    $this->formProtection->clean();
                    $this->session->destroySession();
                    \TYPO3\CMS\Core\Utility\HttpUtility::redirect($this->scriptSelf);
                    break;
                case 'about':
                default:
                    $this->silent = 0;
                    $this->message('About', 'Warning - very important!', $this->securityRisk() . $this->alterPasswordForm(), 2);
                    $this->message('About', 'Using this script', '
						<p>
							Installing TYPO3 has always been a hot topic on the
							mailing list and forums. Therefore we\'ve developed
							this tool which will help you through configuration
							and testing.
							<br />
							There are three primary steps for you to take:
						</p>
						<p>
							<strong>1: Basic Configuration</strong>
							<br />
							In this step your PHP-configuration is checked. If
							there are any settings that will prevent TYPO3 from
							running correctly you\'ll get warnings and errors
							with a description of the problem.
							<br />
							You\'ll have to enter a database username, password
							and hostname. Then you can choose to create a new
							database or select an existing one.
							<br />
							Finally the image processing settings are entered
							and verified and you can choose to let the script
							update the configuration with the suggested settings.
						</p>
						<p>
							<strong>2: Database Analyser</strong>
							<br />
							In this step you can either install a new database
							or update the database from any previous TYPO3
							version.
							<br />
							You can also get an overview of extra/missing
							fields/tables in the database compared to a raw
							sql-file.
							<br />
							The database is also verified against your
							\'tables.php\' configuration ($TCA) and you can
							even see suggestions to entries in $TCA or new
							fields in the database.
						</p>
						<p>
							<strong>3: Upgrade Wizard</strong>
							<br />
							Here you will find update methods taking care of
							changes to the TYPO3 core which are not backwards
							compatible.
							<br />
							It is recommended to run this wizard after every
							update to make sure everything will still work
							flawlessly.
						</p>
						<p>
							<strong>4: Image Processing</strong>
							<br />
							This step is a visual guide to verify your
							configuration of the image processing software.
							<br />
							You\'ll be presented to a list of images that should
							all match in pairs. If some irregularity appears,
							you\'ll get a warning. Thus you\'re able to track an
							error before you\'ll discover it on your website.
						</p>
						<p>
							<strong>5: All Configuration</strong>
							<br />
							This gives you access to any of the configuration
							options in the TYPO3_CONF_VARS array. Every option
							is also presented with a comment explaining what it
							does.
						</p>
						<p>
							<strong>6: Cleanup</strong>
							<br />
							Here you can clean up the temporary files in typo3temp/
							folder and the tables used for caching of data in
							your database.
						</p>
					');
                    $this->message('About', 'Why is this script stand-alone?', '
						<p>
							You would think that this script should rather be a
							module in the backend and access-controlled to only
							admin-users from the database. But that\'s not how
							it works.
							<br />
							The reason is, that this script must not be
							depending on the success of the configuration of
							TYPO3 and whether or not there is a working database
							behind. Therefore the script is invoked from the
							backend init.php file, which allows access if the
							constant \'TYPO3_enterInstallScript\' has been
							defined and is not FALSE. That is and should be the
							case <em>only</em> when calling the script
							\'typo3/install/index.php\' - this script!
						</p>
					');
                    $headCode = 'Header legend';
                    $this->message($headCode, 'Notice!', '
						<p>
							Indicates that something is important to be aware
							of.
							<br />
							This does <em>not</em> indicate an error.
						</p>
					', 1);
                    $this->message($headCode, 'Just information', '
						<p>
							This is a simple message with some information about
							something.
						</p>
					');
                    $this->message($headCode, 'Check was successful', '
						<p>
							Indicates that something was checked and returned an
							expected result.
						</p>
					', -1);
                    $this->message($headCode, 'Warning!', '
						<p>
							Indicates that something may very well cause trouble
							and you should definitely look into it before
							proceeding.
							<br />
							This indicates a <em>potential</em> error.
						</p>
					', 2);
                    $this->message($headCode, 'Error!', '
						<p>
							Indicates that something is definitely wrong and
							that TYPO3 will most likely not perform as expected
							if this problem is not solved.
							<br />
							This indicates an actual error.
						</p>
					', 3);
                    $this->output($this->outputWrapper($this->printAll()));
                    break;
            }
        }
    }
 /**
  * store collected data of defined indexers to db
  * @param integer $storagePid
  * @param string $title
  * @param string $type
  * @param integer $targetPid
  * @param string $content
  * @param string $tags
  * @param string $params
  * @param string $abstract
  * @param integer $language
  * @param integer $starttime
  * @param integer $endtime
  * @param string $fe_group
  * @param boolean $debugOnly
  * @param array $additionalFields
  * @return boolean|integer
  */
 public function storeInIndex($storagePid, $title, $type, $targetPid, $content, $tags = '', $params = '', $abstract = '', $language = 0, $starttime = 0, $endtime = 0, $fe_group = '', $debugOnly = false, $additionalFields = array())
 {
     // if there are errors found in current record return false and break processing
     if (!$this->checkIfRecordHasErrorsBeforeIndexing($storagePid, $title, $type, $targetPid)) {
         return false;
     }
     // optionally add tag set in the indexer configuration
     if (!empty($this->indexerConfig['filteroption']) && (substr($type, 0, 4) != 'file' || substr($type, 0, 4) == 'file' && $this->indexerConfig['index_use_page_tags_for_files'] || $this->indexerConfig['type'] == 'file')) {
         $indexerTag = $this->getTag($this->indexerConfig['filteroption']);
         $tagChar = $this->extConf['prePostTagChar'];
         if ($tags) {
             $tags .= ',' . $tagChar . $indexerTag . $tagChar;
         } else {
             $tags = $tagChar . $indexerTag . $tagChar;
         }
         $tags = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($tags);
     }
     $table = 'tx_kesearch_index';
     $fieldValues = $this->createFieldValuesForIndexing($storagePid, $title, $type, $targetPid, $content, $tags, $params, $abstract, $language, $starttime, $endtime, $fe_group, $additionalFields);
     // check if record already exists
     if (substr($type, 0, 4) == 'file') {
         $recordExists = $this->checkIfFileWasIndexed($fieldValues['type'], $fieldValues['hash']);
     } else {
         $recordExists = $this->checkIfRecordWasIndexed($fieldValues['orig_uid'], $fieldValues['pid'], $fieldValues['type'], $fieldValues['language']);
     }
     if ($recordExists) {
         // update existing record
         $where = 'uid=' . intval($this->currentRow['uid']);
         unset($fieldValues['crdate']);
         if ($debugOnly) {
             // do not process - just debug query
             \TYPO3\CMS\Core\Utility\DebugUtility::debug($GLOBALS['TYPO3_DB']->UPDATEquery($table, $where, $fieldValues), 1);
         } else {
             // process storing of index record and return uid
             $this->updateRecordInIndex($fieldValues);
             return true;
         }
     } else {
         // insert new record
         if ($debugOnly) {
             // do not process - just debug query
             \TYPO3\CMS\Core\Utility\DebugUtility::debug($GLOBALS['TYPO3_DB']->INSERTquery($table, $fieldValues, false));
         } else {
             // process storing of index record and return uid
             $this->insertRecordIntoIndex($fieldValues);
             return $GLOBALS['TYPO3_DB']->sql_insert_id();
         }
     }
 }
Example #11
0
 /**
  * Template rendering for subdatas and principal datas
  *
  * @param array   $templateMarkers
  * @param string  $templateSection
  * @param boolean $debug
  * @return string HTML code
  */
 public function renderAllTemplate($templateMarkers, $templateSection, $debug = false)
 {
     // Check if the template is loaded
     if (!$this->templateContent) {
         return false;
     }
     // Check argument
     if (!is_array($templateMarkers)) {
         return false;
     }
     if ($debug === true) {
         \TYPO3\CMS\Core\Utility\DebugUtility::debug($templateMarkers, 'Markers for ' . $templateSection);
     }
     $content = '';
     if (is_array($templateMarkers[0])) {
         foreach ($templateMarkers as $markers) {
             $content .= $this->renderAllTemplate($markers, $templateSection, $debug);
         }
     } else {
         $content = $this->renderSingle($templateMarkers, $templateSection);
     }
     return $this->cleanTemplate($content);
 }
Example #12
0
 /**
  * Init Method for initialising the navigation.
  *
  * @param string $content Content passed to method
  * @param array $conf Typoscript Array
  *
  * @return array array for the menurendering of TYPO3
  */
 public function init($content, array $conf)
 {
     $this->mConf = $this->processConf($conf);
     if ($this->mConf['useRootlineInformationToUrl']) {
         $this->useRootlineInformationToUrl = $this->mConf['useRootlineInformationToUrl'];
     }
     $this->choosenCat = $this->mConf['category'];
     $this->nodeArrayAdditionalFields = GeneralUtility::trimExplode(',', $this->mConf['additionalFields'], 0);
     $this->pid = $this->mConf['overridePid'] ? $this->mConf['overridePid'] : $this->getFrontendController()->id;
     $this->gpVars = GeneralUtility::_GPmerged($this->prefixId);
     \CommerceTeam\Commerce\Utility\GeneralUtility::initializeFeUserBasket();
     $this->gpVars['basketHashValue'] = $this->getBasket()->getBasketHashValue();
     $this->pageRootline = $this->getFrontendController()->rootLine;
     $this->menuType = $this->mConf['1'];
     $this->entryLevel = (int) $this->mConf['entryLevel'];
     if ((int) $this->mConf['noAct'] > 0) {
         $this->noAct = true;
     }
     if ((int) $this->mConf['maxLevel'] > 0) {
         $this->maxLevel = (int) $this->mConf['maxLevel'];
     }
     /*
      * Detect if a user is logged in and if he or she has usergroups
      * as we have to take in accout, that different usergroups may have different
      * rights on the commerce tree, so consider this whe calculation the cache hash.
      */
     $usergroups = '';
     if (is_array($this->getFrontendUser()->user)) {
         $usergroups = $this->getFrontendUser()->user['usergroup'];
     }
     $this->cat = $this->getRootCategory();
     // Define a default
     $this->choosenCat = $this->mConf['category'];
     $this->showUid = $this->gpVars['showUid'] ? $this->gpVars['showUid'] : 0;
     $this->mDepth = $this->gpVars['mDepth'] ? $this->gpVars['mDepth'] : 0;
     $this->path = $this->gpVars['path'] ? $this->gpVars['path'] : 0;
     $this->expandAll = $this->mConf['expandAll'] ? $this->mConf['expandAll'] : 0;
     $menuErrorName = array();
     if (!($this->cat > 0)) {
         $menuErrorName[] = 'No category defined in TypoScript: lib.tx_commerce.navigation.special.category';
     }
     if (!($this->pid > 0)) {
         $menuErrorName[] = 'No OveridePID defined in TypoScript: lib.tx_commerce.navigation.special.overridePid';
     }
     if (!empty($menuErrorName)) {
         foreach ($menuErrorName as $oneError) {
             \TYPO3\CMS\Core\Utility\DebugUtility::debug($this->mConf, $oneError);
         }
         return $this->makeErrorMenu(5);
     }
     /*
      * Unique Hash for this usergroup and page to display the navigation
      */
     $hash = md5('tx_commerce_navigation:' . implode('-', $this->mConf) . ':' . $usergroups . ':' . $this->getFrontendController()->linkVars . ':' . GeneralUtility::getIndpEnv('HTTP_HOST'));
     /*
      * Render Menue Array and store in cache, if possible
      */
     if ($this->getFrontendController()->no_cache) {
         // Build directly and don't sore, if no_cache=1'
         $this->mTree = $this->makeArrayPostRender($this->pid, 'tx_commerce_categories', 'tx_commerce_categories_parent_category_mm', 'tx_commerce_products', 'tx_commerce_products_categories_mm', $this->cat, 1, 0, $this->maxLevel);
         /*
          * Sorting Options, there is only one type 'alphabetiDesc' :)
          * the others must to program
          *
          * @todo: implement sortType: alphabetiAsc, byUid, bySorting
          */
         if ($this->mConf['sortAllitems.']['type'] == 'alphabetiDesc') {
             $this->sortAllMenuArray($this->mTree, 'alphabetiDesc');
         }
     } else {
         $cachedMatrix = $this->getHash($hash);
         if (!empty($cachedMatrix)) {
             // User the cached version
             $this->mTree = $cachedMatrix;
         } else {
             // no cache present buld data and stor it in cache
             $this->mTree = $this->makeArrayPostRender($this->pid, 'tx_commerce_categories', 'tx_commerce_categories_parent_category_mm', 'tx_commerce_products', 'tx_commerce_products_categories_mm', $this->cat, 1, 0, $this->maxLevel);
             /*
              * Sorting Options, there is only one type 'alphabetiDesc' :)
              * the others must to program
              *
              * @todo: implement sortType: alphabetiAsc, byUid, bySorting
              */
             if ($this->mConf['sortAllitems.']['type'] == 'alphabetiDesc') {
                 $this->sortAllMenuArray($this->mTree, 'alphabetiDesc');
             }
             $this->storeHash($hash, $this->mTree);
         }
     }
     /*
      * Finish menue array rendering, now postprocessing
      * with current status of menue
      */
     $keys = array_keys($this->mTree);
     /*
      * Detect rootline, necessary
      */
     if ($this->noAct === true) {
         $this->pathParents = array();
         $this->mDepth = 0;
     } elseif ($this->gpVars['catUid']) {
         $this->choosenCat = $this->gpVars['catUid'];
     } elseif ($this->gpVars['showUid']) {
         /*
          * If a product is shown, we have to detect the parent category as well
          * even if wo haven't walked thrue the categories
          */
         /**
          * Product.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Product $product
          */
         $product = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Product', $this->gpVars['showUid']);
         $product->loadData();
         $this->choosenCat = $product->getMasterparentCategory();
     }
     if ($this->gpVars['path']) {
         $this->path = $this->gpVars['path'];
         $this->pathParents = explode(',', $this->path);
     } elseif (is_numeric($this->choosenCat) && $this->choosenCat > 0) {
         /**
          * Build the path by or own.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Category $category
          */
         $category = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Category', $this->choosenCat);
         $category->loadData();
         // Get the right path with custom method
         $aPath = $this->getRootLine($this->mTree, $this->choosenCat, $this->expandAll);
         if (!$aPath) {
             /*
              * If the methode getRootLine fail, we take the path direct from the DB.
              */
             $tmpArray = $category->getParentCategoriesUidlist();
             $this->fixPathParents($tmpArray, $this->cat);
         } else {
             $tmpArray = $aPath;
         }
         /*
          * Strip the Staring point and the value 0
          */
         if (!is_array($tmpArray)) {
             $tmpArray = array();
         }
         foreach ((array) $tmpArray as $value) {
             if ($value != $this->cat && $value > 0) {
                 $this->pathParents[] = $value;
             }
         }
         if ($this->mConf['groupOptions.']['onOptions'] == 1 && $this->getFrontendUser()->user['usergroup'] != '') {
             $this->fixPathParents($this->pathParents, $keys[0]);
         }
         $this->pathParents = array_reverse($this->pathParents);
         if (!$this->gpVars['mDepth']) {
             $this->mDepth = count($this->pathParents);
             if ($this->gpVars['manufacturer']) {
                 ++$this->mDepth;
             }
         }
     } else {
         /*
          * If no Category is choosen by the user, so you just render the default menue
          * no rootline for the categories is needed and the depth is 0
          */
         $this->pathParents = array();
         $this->mDepth = 0;
     }
     /*
      * If we do have an entry level,
      * we strip away the number of array levels of the entry level value
      */
     if ($this->entryLevel > 0) {
         $newParentes = array_reverse($this->pathParents);
         /**
          * Foreach entry level detect the array for this level and remove
          * it from $this->mTree.
          */
         for ($i = 0; $i < $this->entryLevel; ++$i) {
             $this->mTree = $this->mTree[$newParentes[$i]]['--subLevel--'];
             /*
              * Reduce elementes in pathParents and decrese menue depth
              */
             array_pop($this->pathParents);
             --$this->mDepth;
         }
     }
     if ($this->pathParents) {
         $this->processArrayPostRender($this->mTree, $this->pathParents, $this->mDepth);
     }
     // never ever tough this piece of crap its needed to return an array
     return $this->mTree;
 }
Example #13
0
 function hasPeriodChanged($old, $new, $reverse = false, $debug = false)
 {
     if ($debug) {
         \TYPO3\CMS\Core\Utility\DebugUtility::debug(array($old, $new, $reverse));
     }
     if ($reverse) {
         return intval($new) < intval($old);
     } else {
         return intval($new) > intval($old);
     }
 }
Example #14
0
 /**
  * Replaces a file with file in local file system.
  *
  * @param string $fileIdentifier
  * @param string $localFilePath
  * @return bool TRUE if the operation succeeded
  */
 public function replaceFile($fileIdentifier, $localFilePath)
 {
     DebugUtility::debug(__FUNCTION__, 'Method');
     $this->cache->flush();
 }
 /**
  * @param string $parseFuncTSPath path to TypoScript parseFunc setup.
  * @return the parsed string.
  * @author Bastian Waidelich <*****@*****.**>
  * @author Niels Pardon <*****@*****.**>
  */
 public function render($parseFuncTSPath = 'lib.parseFunc_RTE')
 {
     if (TYPO3_MODE === 'BE') {
         $this->simulateFrontendEnvironment();
     }
     $value = $this->renderChildren();
     $value = $this->htmlSubstr($value, 0, 200, true, '...');
     \TYPO3\CMS\Core\Utility\DebugUtility::debug($value, 'value');
     $content = $this->contentObject->parseFunc($value, array(), '< ' . $parseFuncTSPath);
     if (TYPO3_MODE === 'BE') {
         $this->resetFrontendEnvironment();
     }
     return $content;
 }