/**
  * This function converts version range strings (like '4.2.0-4.4.99') to an array
  * (like array('4.2.0', '4.4.99'). It also forces each version part to be between
  * 0 and 999
  *
  * @param string $versionsString
  * @return array
  */
 public static function convertVersionsStringToVersionNumbers($versionsString)
 {
     $versions = GeneralUtility::trimExplode('-', $versionsString);
     $versionsCount = count($versions);
     for ($i = 0; $i < $versionsCount; $i++) {
         $cleanedVersion = GeneralUtility::trimExplode('.', $versions[$i]);
         $cleanedVersionCount = count($cleanedVersion);
         for ($j = 0; $j < $cleanedVersionCount; $j++) {
             $cleanedVersion[$j] = MathUtility::forceIntegerInRange($cleanedVersion[$j], 0, 999);
         }
         $cleanedVersionString = implode('.', $cleanedVersion);
         if (static::convertVersionNumberToInteger($cleanedVersionString) === 0) {
             $cleanedVersionString = '';
         }
         $versions[$i] = $cleanedVersionString;
     }
     return $versions;
 }
 /**
  * Returns REQUIRED_EXTENSIONS constant set by package manager as array.
  *
  * @return array List of required extensions
  * @deprecated since 6,2, will be removed two versions later.
  */
 public static function getRequiredExtensionListArray()
 {
     GeneralUtility::logDeprecatedFunction();
     return GeneralUtility::trimExplode(',', REQUIRED_EXTENSIONS);
 }
Exemplo n.º 3
0
 /**
  * Sets the search paths from different sources, internal
  *
  * @return array Array of absolute paths (keys and values are equal)
  */
 protected static function getPathsInternal()
 {
     $pathsArr = array();
     $sysPathArr = array();
     // Image magick paths first
     // im_path_lzw take precedence over im_path
     if ($imPath = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] ? $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] : $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']) {
         $imPath = self::fixPath($imPath);
         $pathsArr[$imPath] = $imPath;
     }
     // Add configured paths
     if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['binPath']) {
         $sysPath = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['binPath'], 1);
         foreach ($sysPath as $val) {
             $val = self::fixPath($val);
             $sysPathArr[$val] = $val;
         }
     }
     // Add path from environment
     // TODO: how does this work for WIN
     if ($GLOBALS['_SERVER']['PATH']) {
         $sep = TYPO3_OS == 'WIN' ? ';' : ':';
         $envPath = GeneralUtility::trimExplode($sep, $GLOBALS['_SERVER']['PATH'], 1);
         foreach ($envPath as $val) {
             $val = self::fixPath($val);
             $sysPathArr[$val] = $val;
         }
     }
     // Set common paths for Unix (only)
     if (TYPO3_OS !== 'WIN') {
         $sysPathArr = array_merge($sysPathArr, array('/usr/bin/' => '/usr/bin/', '/usr/local/bin/' => '/usr/local/bin/'));
     }
     $pathsArr = array_merge($pathsArr, $sysPathArr);
     return $pathsArr;
 }
Exemplo n.º 4
0
 /**
  * Filters an array to reduce its elements to match the condition.
  * The values in $keepItems can be optionally evaluated by a custom callback function.
  *
  * Example (arguments used to call this function):
  * $array = array(
  * array('aa' => array('first', 'second'),
  * array('bb' => array('third', 'fourth'),
  * array('cc' => array('fifth', 'sixth'),
  * );
  * $keepItems = array('third');
  * $getValueFunc = function($value) { return $value[0]; }
  *
  * Returns:
  * array(
  * array('bb' => array('third', 'fourth'),
  * )
  *
  * @param array $array The initial array to be filtered/reduced
  * @param mixed $keepItems The items which are allowed/kept in the array - accepts array or csv string
  * @param string $getValueFunc (optional) Callback function used to get the value to keep
  * @return array The filtered/reduced array with the kept items
  */
 public static function keepItemsInArray(array $array, $keepItems, $getValueFunc = null)
 {
     if ($array) {
         // Convert strings to arrays:
         if (is_string($keepItems)) {
             $keepItems = GeneralUtility::trimExplode(',', $keepItems);
         }
         // Check if valueFunc can be executed:
         if (!is_callable($getValueFunc)) {
             $getValueFunc = null;
         }
         // Do the filtering:
         if (is_array($keepItems) && !empty($keepItems)) {
             foreach ($array as $key => $value) {
                 // Get the value to compare by using the callback function:
                 $keepValue = isset($getValueFunc) ? call_user_func($getValueFunc, $value) : $value;
                 if (!in_array($keepValue, $keepItems)) {
                     unset($array[$key]);
                 }
             }
         }
     }
     return $array;
 }
Exemplo n.º 5
0
 public function enhanceEventQuery(&$select, &$table, &$where, &$groupBy, &$orderBy)
 {
     $select .= ', tx_cal_event_category_mm.uid_foreign AS category_uid ';
     $table .= ' LEFT JOIN tx_cal_event_category_mm ON tx_cal_event_category_mm.uid_local = tx_cal_event.uid';
     $where .= $this->getCategorySearchString($this->conf['pidList'], true);
     $groupBy = 'tx_cal_event.uid';
     if ($this->conf['view.']['joinCategoryByAnd']) {
         $categoryArray = GeneralUtility::trimExplode(',', $this->conf['category'], 1);
         $groupBy .= ', tx_cal_event_category_mm.uid_foreign HAVING count(*) =' . count($categoryArray);
     }
     $orderBy .= ', tx_cal_event.uid,tx_cal_event_category_mm.sorting';
     if ($this->conf['view.'][$this->conf['view'] . '.']['event.']['additionalCategoryWhere']) {
         $where .= ' ' . $this->cObj->cObjGetSingle($this->conf['view.'][$this->conf['view'] . '.']['event.']['additionalCategoryWhere'], $this->conf['view.'][$this->conf['view'] . '.']['event.']['additionalCategoryWhere.']);
     }
 }
Exemplo n.º 6
0
 /**
  * Explodes the input string into words.
  * This is done by splitting first by lines, then by space char. Each word will be in stored as a value in an array. Lines will be indicated by two subsequent empty values.
  *
  * @param string $str The string input
  * @return array Array with words.
  * @access private
  */
 public function explodeStringIntoWords($str)
 {
     $strArr = GeneralUtility::trimExplode(LF, $str);
     $outArray = array();
     foreach ($strArr as $lineOfWords) {
         $allWords = GeneralUtility::trimExplode(' ', $lineOfWords, TRUE);
         $outArray[] = $allWords;
         $outArray[] = array('');
         $outArray[] = array('');
     }
     return call_user_func_array('array_merge', $outArray);
 }
 /**
  * Fixes the SQL mode by unsetting NO_BACKSLASH_ESCAPES if found.
  *
  * @return void
  */
 private function setSqlMode()
 {
     $resource = $this->sql_query('SELECT @@SESSION.sql_mode;');
     if ($resource) {
         $result = $resource->fetch_row();
         if (isset($result[0]) && $result[0] && strpos($result[0], 'NO_BACKSLASH_ESCAPES') !== FALSE) {
             $modes = array_diff(GeneralUtility::trimExplode(',', $result[0]), array('NO_BACKSLASH_ESCAPES'));
             $query = 'SET sql_mode=\'' . $this->db->real_escape_string(implode(',', $modes)) . '\';';
             $this->sql_query($query);
             GeneralUtility::sysLog('NO_BACKSLASH_ESCAPES could not be removed from SQL mode: ' . $this->sql_error(), 'rn_base', GeneralUtility::SYSLOG_SEVERITY_ERROR);
         }
     }
 }
 /**
  * Update be_groups with tx_mooxnews_categorymounts set
  *
  * @param string $table
  * @param array $oldNewCategoryUidMapping
  */
 protected function updateCategoryPermissionFields($table, array $oldNewCategoryUidMapping)
 {
     $updatedRecords = 0;
     $rows = $this->databaseConnection->exec_SELECTgetRows('uid, category_perms, tx_mooxnews_categorymounts', $table, "tx_mooxnews_categorymounts != ''");
     foreach ($rows as $row) {
         $oldUids = GeneralUtility::trimExplode(',', $row['tx_mooxnews_categorymounts']);
         $newUids = $row['category_perms'] ? GeneralUtility::trimExplode(',', $row['category_perms']) : array();
         foreach ($oldUids as $oldUid) {
             if (!empty($oldNewCategoryUidMapping[$oldUid])) {
                 $newUids[] = $oldNewCategoryUidMapping[$oldUid];
             }
         }
         $newCategoryPerms = implode(',', array_unique($newUids));
         if ($newCategoryPerms !== $row['category_perms']) {
             $this->databaseConnection->exec_UPDATEquery($table, 'uid=' . $row['uid'], array('category_perms' => $newCategoryPerms));
             $updatedRecords++;
         }
     }
     $message = 'Updated ' . $updatedRecords . ' "' . $table . '" records';
     $status = FlashMessage::INFO;
     $title = '';
     $this->messageArray[] = array($status, $title, $message);
 }