/**
  * @param array $arr1 First array
  * @param array $arr2 Second array
  * @return array Merged result.
  */
 public function array_merge(array $arr1, array $arr2)
 {
     /** @noinspection PhpDeprecationInspection PhpUndefinedClassInspection */
     return t3lib_div::array_merge($arr1, $arr2);
 }
	/**
	 * Search for a title in a certain PID
	 *
	 * @param	integer		Page id in which to search subpages matching title
	 * @param	string		Title to search for
	 * @return	array		First entry is uid, second entry is the row selected, including information about the page as a mount point.
	 * @access private
	 * @see searchTitle()
	 */
	function searchTitle_searchPid($searchPid, $title) {

		// List of "pages" fields to traverse for a "directory title" in the speaking URL (only from RootLine!!):
		$segTitleFieldList = $this->conf['segTitleFieldList'] ? $this->conf['segTitleFieldList'] : TX_REALURL_SEGTITLEFIELDLIST_DEFAULT;
		$selList = t3lib_div::uniqueList('uid,pid,doktype,mount_pid,mount_pid_ol,tx_realurl_exclude,' . $segTitleFieldList);
		$segTitleFieldArray = t3lib_div::trimExplode(',', $segTitleFieldList, 1);

		// page select object - used to analyse mount points.
		$sys_page = t3lib_div::makeInstance('t3lib_pageSelect');

		// Build an array with encoded values from the segTitleFieldArray of the subpages
		// First we find field values from the default language
		// Pages are selected in menu order and if duplicate titles are found the first takes precedence!
		$titles = array(); // array(title => uid);
		$exclude = array();
		$uidTrack = array();
		$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selList, 'pages',
						'pid=' . intval($searchPid) .
						' AND deleted=0 AND doktype!=255', '', 'sorting');
		while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))) {

			// Mount points:
			$mount_info = $sys_page->getMountPointInfo($row['uid'], $row);
			if (is_array($mount_info)) {
				// There is a valid mount point.
				if ($mount_info['overlay']) {
					// Overlay mode: Substitute WHOLE record:
					$result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selList, 'pages',
									'uid=' . intval($mount_info['mount_pid']) .
									' AND deleted=0 AND doktype!=255');
					$mp_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result2);
					if (is_array($mp_row)) {
						$row = $mp_row;
					}
					else {
						unset($row); // If the mount point could not be fetched, unset the row
					}
				}
				$row['_IS_MOUNTPOINT'] = $mount_info;
			}

			// Collect titles from selected row:
			if (is_array($row)) {
				if ($row['tx_realurl_exclude']) {
					// segment is excluded
					$exclude[] = $row;
				}
				// Process titles. Note that excluded segments are also searched
				// otherwise they will never be found
				$uidTrack[$row['uid']] = $row;
				foreach ($segTitleFieldArray as $fieldName) {
					if ($row[$fieldName]) {
						$encodedTitle = $this->encodeTitle($row[$fieldName]);
						if (!isset($titles[$fieldName][$encodedTitle])) {
							$titles[$fieldName][$encodedTitle] = $row['uid'];
						}
					}
				}
			}
		}
		$GLOBALS['TYPO3_DB']->sql_free_result($result);

		// We have to search the language overlay too, if: a) the language isn't the default (0), b) if it's not set (-1)
		$uidTrackKeys = array_keys($uidTrack);
		foreach ($uidTrackKeys as $l_id) {
			$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(TX_REALURL_SEGTITLEFIELDLIST_PLO,
					'pages_language_overlay', 'pid=' . intval($l_id) . ' AND deleted=0');
			while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))) {
				foreach ($segTitleFieldArray as $fieldName) {
					if ($row[$fieldName]) {
						$encodedTitle = $this->encodeTitle($row[$fieldName]);
						if (!isset($titles[$fieldName][$encodedTitle])) {
							$titles[$fieldName][$encodedTitle] = $l_id;
						}
					}
				}
			}
			$GLOBALS['TYPO3_DB']->sql_free_result($result);
		}

		// Merge titles:
		$segTitleFieldArray = array_reverse($segTitleFieldArray); // To observe the priority order...
		$allTitles = array();
		foreach ($segTitleFieldArray as $fieldName) {
			if (is_array($titles[$fieldName])) {
				$allTitles = t3lib_div::array_merge($allTitles, $titles[$fieldName]);
			}
		}

		// Return:
		$encodedTitle = $this->encodeTitle($title);
		if (isset($allTitles[$encodedTitle])) {
			return array($allTitles[$encodedTitle], $uidTrack[$allTitles[$encodedTitle]], false);
		}
		return array(false, false, $exclude);
	}
 /**
  * Overview About Sitemaps
  */
 public function indexAction()
 {
     $pages = $this->getBasePages();
     $providers = t3lib_div::trimExplode(',', $this->settings['provider'], TRUE);
     $nodes = array();
     foreach ($providers as $provider) {
         $provider = Tx_GoogleServices_Service_SitemapProvider::getProvider($provider);
         $providerNodes = $provider->getRecords(intval($this->settings['startpoint']), $pages, $this);
         $nodes = t3lib_div::array_merge($nodes, $providerNodes);
     }
     $this->prepareAndAssignNodes($nodes);
 }
示例#4
1
 /**
  * Adds items to the ->MOD_MENU array. Used for the function menu selector.
  *
  * @return    void
  */
 function menuConfig()
 {
     global $LANG;
     $this->MOD_MENU = array('users' => array('-1' => $LANG->getLL('loggedInUsers'), '0' => $LANG->getLL('notLoggedIn'), '' => '------------------------------'), 'mode' => array('-1' => $LANG->getLL('allTime'), '1' => $LANG->getLL('byTime')));
     foreach (t3lib_BEfunc::getRecordsByField('fe_users', 1, 1) as $user) {
         $this->MOD_MENU['users'][$user['uid']] = $user['username'];
     }
     parent::menuConfig();
     $set = t3lib_div::_GP('SET');
     if ($set['time']) {
         $dateFrom = strtotime($set['time']['from']);
         $dateTo = strtotime($set['time']['to']);
         $set['time']['from'] = $dateFrom > 0 ? date('d.m.Y', $dateFrom) : '';
         $set['time']['to'] = $dateTo > 0 ? date('d.m.Y', $dateTo) : '';
         $mergedSettings = t3lib_div::array_merge($this->MOD_SETTINGS, $set);
         $GLOBALS['BE_USER']->pushModuleData($this->MCONF['name'], $mergedSettings);
         $this->MOD_SETTINGS = $mergedSettings;
     }
 }
 /**
  * Actions for flex form element (move, delete)
  *
  * @param	array		&$valueArrayToRemoveFrom: by reference
  * @param	array		$deleteCMDS: ...	 *
  * @return	void
  */
 function _ACTION_FLEX_FORMdata(&$valueArray, $actionCMDs)
 {
     if (is_array($valueArray) && is_array($actionCMDs)) {
         foreach ($actionCMDs as $key => $value) {
             if ($key == '_ACTION') {
                 // First, check if there are "commands":
                 if (current($actionCMDs[$key]) !== "") {
                     asort($actionCMDs[$key]);
                     $newValueArray = array();
                     foreach ($actionCMDs[$key] as $idx => $order) {
                         if (substr($idx, 0, 3) == "ID-") {
                             $idx = $this->newIndexMap[$idx];
                         }
                         if ($order != "DELETE") {
                             // Just one reflection here: It is clear that when removing elements from a flexform, then we will get lost files unless we act on this delete operation by traversing and deleting files that were referred to.
                             $newValueArray[$idx] = $valueArray[$idx];
                         }
                         unset($valueArray[$idx]);
                     }
                     $valueArray = t3lib_div::array_merge($newValueArray, $valueArray);
                 }
             } elseif (is_array($actionCMDs[$key]) && isset($valueArray[$key])) {
                 $this->_ACTION_FLEX_FORMdata($valueArray[$key], $actionCMDs[$key]);
             }
         }
     }
 }
 /**
  * Ajax handler for the "suggest" feature in TCEforms.
  *
  * @param array $params The parameters from the AJAX call
  * @param TYPO3AJAX $ajaxObj The AJAX object representing the AJAX call
  * @return void
  */
 public function processAjaxRequest($params, &$ajaxObj)
 {
     // get parameters from $_GET/$_POST
     $search = t3lib_div::_GP('value');
     $table = t3lib_div::_GP('table');
     $field = t3lib_div::_GP('field');
     $uid = t3lib_div::_GP('uid');
     $pageId = t3lib_div::_GP('pid');
     t3lib_div::loadTCA($table);
     // If the $uid is numeric, we have an already existing element, so get the
     // TSconfig of the page itself or the element container (for non-page elements)
     // otherwise it's a new element, so use given id of parent page (i.e., don't modify it here)
     if (is_numeric($uid)) {
         if ($table == 'pages') {
             $pageId = $uid;
         } else {
             $row = t3lib_BEfunc::getRecord($table, $uid);
             $pageId = $row['pid'];
         }
     }
     $TSconfig = t3lib_BEfunc::getPagesTSconfig($pageId);
     $queryTables = array();
     $foreign_table_where = '';
     $wizardConfig = $GLOBALS['TCA'][$table]['columns'][$field]['config']['wizards']['suggest'];
     if (isset($GLOBALS['TCA'][$table]['columns'][$field]['config']['allowed'])) {
         $queryTables = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['allowed']);
     } elseif (isset($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table'])) {
         $queryTables = array($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table']);
         $foreign_table_where = $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table_where'];
         // strip ORDER BY clause
         $foreign_table_where = trim(preg_replace('/ORDER[[:space:]]+BY.*/i', '', $foreign_table_where));
     }
     $resultRows = array();
     // fetch the records for each query table. A query table is a table from which records are allowed to
     // be added to the TCEForm selector, originally fetched from the "allowed" config option in the TCA
     foreach ($queryTables as $queryTable) {
         t3lib_div::loadTCA($queryTable);
         // if the table does not exist, skip it
         if (!is_array($GLOBALS['TCA'][$queryTable]) || !count($GLOBALS['TCA'][$queryTable])) {
             continue;
         }
         $config = (array) $wizardConfig['default'];
         if (is_array($wizardConfig[$queryTable])) {
             $config = t3lib_div::array_merge_recursive_overrule($config, $wizardConfig[$queryTable]);
         }
         // merge the configurations of different "levels" to get the working configuration for this table and
         // field (i.e., go from the most general to the most special configuration)
         if (is_array($TSconfig['TCEFORM.']['suggest.']['default.'])) {
             $config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.']['suggest.']['default.']);
         }
         if (is_array($TSconfig['TCEFORM.']['suggest.'][$queryTable . '.'])) {
             $config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.']['suggest.'][$queryTable . '.']);
         }
         // use $table instead of $queryTable here because we overlay a config
         // for the input-field here, not for the queried table
         if (is_array($TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.']['default.'])) {
             $config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.']['default.']);
         }
         if (is_array($TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.'][$queryTable . '.'])) {
             $config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.'][$queryTable . '.']);
         }
         //process addWhere
         if (!isset($config['addWhere']) && $foreign_table_where) {
             $config['addWhere'] = $foreign_table_where;
         }
         if (isset($config['addWhere'])) {
             $config['addWhere'] = strtr(' ' . $config['addWhere'], array('###THIS_UID###' => intval($uid), '###CURRENT_PID###' => intval($pageId)));
         }
         // instantiate the class that should fetch the records for this $queryTable
         $receiverClassName = $config['receiverClass'];
         if (!class_exists($receiverClassName)) {
             $receiverClassName = 't3lib_TCEforms_Suggest_DefaultReceiver';
         }
         $receiverObj = t3lib_div::makeInstance($receiverClassName, $queryTable, $config);
         $params = array('value' => $search);
         $rows = $receiverObj->queryTable($params);
         if (empty($rows)) {
             continue;
         }
         $resultRows = t3lib_div::array_merge($resultRows, $rows);
         unset($rows);
     }
     $listItems = array();
     if (count($resultRows) > 0) {
         // traverse all found records and sort them
         $rowsSort = array();
         foreach ($resultRows as $key => $row) {
             $rowsSort[$key] = $row['text'];
         }
         asort($rowsSort);
         $rowsSort = array_keys($rowsSort);
         // Limit the number of items in the result list
         $maxItems = $config['maxItemsInResultList'] ? $config['maxItemsInResultList'] : 10;
         $maxItems = min(count($resultRows), $maxItems);
         // put together the selector entry
         for ($i = 0; $i < $maxItems; $i++) {
             $row = $resultRows[$rowsSort[$i]];
             $rowId = $row['table'] . '-' . $row['uid'] . '-' . $table . '-' . $uid . '-' . $field;
             $listItems[] = '<li' . ($row['class'] != '' ? ' class="' . $row['class'] . '"' : '') . ' id="' . $rowId . '" style="' . $row['style'] . '">' . $row['text'] . '</li>';
         }
     }
     if (count($listItems) > 0) {
         $list = implode('', $listItems);
     } else {
         $list = '<li class="suggest-noresults"><i>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.noRecordFound') . '</i></li>';
     }
     $list = '<ul class="' . $this->cssClass . '-resultlist">' . $list . '</ul>';
     $ajaxObj->addContent(0, $list);
 }
    /**
     * Send an email notification to users in workspace
     *
     * @param array $stat Workspace access array (from t3lib_userauthgroup::checkWorkspace())
     * @param integer $stageId New Stage number: 0 = editing, 1= just ready for review, 10 = ready for publication, -1 = rejected!
     * @param string $table Table name of element (or list of element names if $id is zero)
     * @param integer $id Record uid of element (if zero, then $table is used as reference to element(s) alone)
     * @param string $comment User comment sent along with action
     * @param t3lib_TCEmain $tcemainObj TCEmain object
     * @param string $notificationAlternativeRecipients Comma separated list of recipients to notificate instead of be_users selected by sys_workspace, list is generated by workspace extension module
     * @return void
     */
    protected function notifyStageChange(array $stat, $stageId, $table, $id, $comment, t3lib_TCEmain $tcemainObj, $notificationAlternativeRecipients = FALSE)
    {
        $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $stat['uid']);
        // So, if $id is not set, then $table is taken to be the complete element name!
        $elementName = $id ? $table . ':' . $id : $table;
        if (is_array($workspaceRec)) {
            // Get the new stage title from workspaces library, if workspaces extension is installed
            if (t3lib_extMgm::isLoaded('workspaces')) {
                $stageService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
                $newStage = $stageService->getStageTitle((int) $stageId);
            } else {
                // TODO: CONSTANTS SHOULD BE USED - tx_service_workspace_workspaces
                // TODO: use localized labels
                // Compile label:
                switch ((int) $stageId) {
                    case 1:
                        $newStage = 'Ready for review';
                        break;
                    case 10:
                        $newStage = 'Ready for publishing';
                        break;
                    case -1:
                        $newStage = 'Element was rejected!';
                        break;
                    case 0:
                        $newStage = 'Rejected element was noticed and edited';
                        break;
                    default:
                        $newStage = 'Unknown state change!?';
                        break;
                }
            }
            if ($notificationAlternativeRecipients == false) {
                // Compile list of recipients:
                $emails = array();
                switch ((int) $stat['stagechg_notification']) {
                    case 1:
                        switch ((int) $stageId) {
                            case 1:
                                $emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']);
                                break;
                            case 10:
                                $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
                                break;
                            case -1:
                                #								$emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']);
                                #								$emails = array_merge($emails,$this->getEmailsForStageChangeNotification($workspaceRec['members']));
                                // List of elements to reject:
                                $allElements = explode(',', $elementName);
                                // Traverse them, and find the history of each
                                foreach ($allElements as $elRef) {
                                    list($eTable, $eUid) = explode(':', $elRef);
                                    $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('log_data,tstamp,userid', 'sys_log', 'action=6 and details_nr=30
											AND tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($eTable, 'sys_log') . '
											AND recuid=' . intval($eUid), '', 'uid DESC');
                                    // Find all implicated since the last stage-raise from editing to review:
                                    foreach ($rows as $dat) {
                                        $data = unserialize($dat['log_data']);
                                        $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($dat['userid'], TRUE));
                                        if ($data['stage'] == 1) {
                                            break;
                                        }
                                    }
                                }
                                break;
                            case 0:
                                $emails = $this->getEmailsForStageChangeNotification($workspaceRec['members']);
                                break;
                            default:
                                $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
                                break;
                        }
                        break;
                    case 10:
                        $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
                        $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']));
                        $emails = t3lib_div::array_merge($emails, $this->getEmailsForStageChangeNotification($workspaceRec['members']));
                        break;
                }
            } else {
                $emails = array();
                foreach ($notificationAlternativeRecipients as $emailAddress) {
                    $emails[] = array('email' => $emailAddress);
                }
            }
            // prepare and then send the emails
            if (count($emails)) {
                // Path to record is found:
                list($elementTable, $elementUid) = explode(':', $elementName);
                $elementUid = intval($elementUid);
                $elementRecord = t3lib_BEfunc::getRecord($elementTable, $elementUid);
                $recordTitle = t3lib_BEfunc::getRecordTitle($elementTable, $elementRecord);
                if ($elementTable == 'pages') {
                    $pageUid = $elementUid;
                } else {
                    t3lib_BEfunc::fixVersioningPid($elementTable, $elementRecord);
                    $pageUid = $elementUid = $elementRecord['pid'];
                }
                // fetch the TSconfig settings for the email
                // old way, options are TCEMAIN.notificationEmail_body/subject
                $TCEmainTSConfig = $tcemainObj->getTCEMAIN_TSconfig($pageUid);
                // these options are deprecated since TYPO3 4.5, but are still
                // used in order to provide backwards compatibility
                $emailMessage = trim($TCEmainTSConfig['notificationEmail_body']);
                $emailSubject = trim($TCEmainTSConfig['notificationEmail_subject']);
                // new way, options are
                // pageTSconfig: tx_version.workspaces.stageNotificationEmail.subject
                // userTSconfig: page.tx_version.workspaces.stageNotificationEmail.subject
                $pageTsConfig = t3lib_BEfunc::getPagesTSconfig($pageUid);
                $emailConfig = $pageTsConfig['tx_version.']['workspaces.']['stageNotificationEmail.'];
                $markers = array('###RECORD_TITLE###' => $recordTitle, '###RECORD_PATH###' => t3lib_BEfunc::getRecordPath($elementUid, '', 20), '###SITE_NAME###' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], '###SITE_URL###' => t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, '###WORKSPACE_TITLE###' => $workspaceRec['title'], '###WORKSPACE_UID###' => $workspaceRec['uid'], '###ELEMENT_NAME###' => $elementName, '###NEXT_STAGE###' => $newStage, '###COMMENT###' => $comment, '###USER_REALNAME###' => $tcemainObj->BE_USER->user['realName'], '###USER_USERNAME###' => $tcemainObj->BE_USER->user['username']);
                // sending the emails the old way with sprintf(),
                // because it was set explicitly in TSconfig
                if ($emailMessage && $emailSubject) {
                    t3lib_div::deprecationLog('This TYPO3 installation uses Workspaces staging notification by setting the TSconfig options "TCEMAIN.notificationEmail_subject" / "TCEMAIN.notificationEmail_body". Please use the more flexible marker-based options tx_version.workspaces.stageNotificationEmail.message / tx_version.workspaces.stageNotificationEmail.subject');
                    $emailSubject = sprintf($emailSubject, $elementName);
                    $emailMessage = sprintf($emailMessage, $markers['###SITE_NAME###'], $markers['###SITE_URL###'], $markers['###WORKSPACE_TITLE###'], $markers['###WORKSPACE_UID###'], $markers['###ELEMENT_NAME###'], $markers['###NEXT_STAGE###'], $markers['###COMMENT###'], $markers['###USER_REALNAME###'], $markers['###USER_USERNAME###'], $markers['###RECORD_PATH###'], $markers['###RECORD_TITLE###']);
                    // filter out double email addresses
                    $emailRecipients = array();
                    foreach ($emails as $recip) {
                        $emailRecipients[$recip['email']] = $recip['email'];
                    }
                    $emailRecipients = implode(',', $emailRecipients);
                    // Send one email to everybody
                    t3lib_div::plainMailEncoded($emailRecipients, $emailSubject, $emailMessage);
                } else {
                    // send an email to each individual user, to ensure the
                    // multilanguage version of the email
                    $emailHeaders = $emailConfig['additionalHeaders'];
                    $emailRecipients = array();
                    // an array of language objects that are needed
                    // for emails with different languages
                    $languageObjects = array($GLOBALS['LANG']->lang => $GLOBALS['LANG']);
                    // loop through each recipient and send the email
                    foreach ($emails as $recipientData) {
                        // don't send an email twice
                        if (isset($emailRecipients[$recipientData['email']])) {
                            continue;
                        }
                        $emailSubject = $emailConfig['subject'];
                        $emailMessage = $emailConfig['message'];
                        $emailRecipients[$recipientData['email']] = $recipientData['email'];
                        // check if the email needs to be localized
                        // in the users' language
                        if (t3lib_div::isFirstPartOfStr($emailSubject, 'LLL:') || t3lib_div::isFirstPartOfStr($emailMessage, 'LLL:')) {
                            $recipientLanguage = $recipientData['lang'] ? $recipientData['lang'] : 'default';
                            if (!isset($languageObjects[$recipientLanguage])) {
                                // a LANG object in this language hasn't been
                                // instantiated yet, so this is done here
                                /** @var $languageObject language */
                                $languageObject = t3lib_div::makeInstance('language');
                                $languageObject->init($recipientLanguage);
                                $languageObjects[$recipientLanguage] = $languageObject;
                            } else {
                                $languageObject = $languageObjects[$recipientLanguage];
                            }
                            if (t3lib_div::isFirstPartOfStr($emailSubject, 'LLL:')) {
                                $emailSubject = $languageObject->sL($emailSubject);
                            }
                            if (t3lib_div::isFirstPartOfStr($emailMessage, 'LLL:')) {
                                $emailMessage = $languageObject->sL($emailMessage);
                            }
                        }
                        $emailSubject = t3lib_parseHtml::substituteMarkerArray($emailSubject, $markers, '', TRUE, TRUE);
                        $emailMessage = t3lib_parseHtml::substituteMarkerArray($emailMessage, $markers, '', TRUE, TRUE);
                        // Send an email to the recipient
                        t3lib_div::plainMailEncoded($recipientData['email'], $emailSubject, $emailMessage, $emailHeaders);
                    }
                    $emailRecipients = implode(',', $emailRecipients);
                }
                $tcemainObj->newlog2('Notification email for stage change was sent to "' . $emailRecipients . '"', $table, $id);
            }
        }
    }
 /**
  * Will select all fe_groups records that the current fe_user is member of - and which groups are also allowed in the current domain.
  * It also accumulates the TSconfig for the fe_user/fe_groups in ->TSdataArray
  *
  * @return	integer		Returns the number of usergroups for the frontend users (if the internal user record exists and the usergroup field contains a value)
  */
 function fetchGroupData()
 {
     $this->TSdataArray = array();
     $this->userTS = array();
     $this->userTSUpdated = 0;
     $this->groupData = array('title' => array(), 'uid' => array(), 'pid' => array());
     // Setting default configuration:
     $this->TSdataArray[] = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultUserTSconfig'];
     // get the info data for auth services
     $authInfo = $this->getAuthInfoArray();
     if ($this->writeDevLog) {
         if (is_array($this->user)) {
             t3lib_div::devLog('Get usergroups for user: ' . t3lib_div::arrayToLogString($this->user, array($this->userid_column, $this->username_column)), 'tslib_feUserAuth');
         } else {
             t3lib_div::devLog('Get usergroups for "anonymous" user', 'tslib_feUserAuth');
         }
     }
     $groupDataArr = array();
     // use 'auth' service to find the groups for the user
     $serviceChain = '';
     $subType = 'getGroups' . $this->loginType;
     while (is_object($serviceObj = t3lib_div::makeInstanceService('auth', $subType, $serviceChain))) {
         $serviceChain .= ',' . $serviceObj->getServiceKey();
         $serviceObj->initAuth($subType, array(), $authInfo, $this);
         $groupData = $serviceObj->getGroups($this->user, $groupDataArr);
         if (is_array($groupData) && count($groupData)) {
             $groupDataArr = t3lib_div::array_merge($groupDataArr, $groupData);
             // Keys in $groupData should be unique ids of the groups (like "uid") so this function will override groups.
         }
         unset($serviceObj);
     }
     if ($this->writeDevLog and $serviceChain) {
         t3lib_div::devLog($subType . ' auth services called: ' . $serviceChain, 'tslib_feUserAuth');
     }
     if ($this->writeDevLog and !count($groupDataArr)) {
         t3lib_div::devLog('No usergroups found by services', 'tslib_feUserAuth');
     }
     if ($this->writeDevLog and count($groupDataArr)) {
         t3lib_div::devLog(count($groupDataArr) . ' usergroup records found by services', 'tslib_feUserAuth');
     }
     // use 'auth' service to check the usergroups if they are really valid
     foreach ($groupDataArr as $groupData) {
         // by default a group is valid
         $validGroup = TRUE;
         $serviceChain = '';
         $subType = 'authGroups' . $this->loginType;
         while (is_object($serviceObj = t3lib_div::makeInstanceService('auth', $subType, $serviceChain))) {
             $serviceChain .= ',' . $serviceObj->getServiceKey();
             $serviceObj->initAuth($subType, array(), $authInfo, $this);
             if (!$serviceObj->authGroup($this->user, $groupData)) {
                 $validGroup = FALSE;
                 if ($this->writeDevLog) {
                     t3lib_div::devLog($subType . ' auth service did not auth group: ' . t3lib_div::arrayToLogString($groupData, 'uid,title'), 'tslib_feUserAuth', 2);
                 }
                 break;
             }
             unset($serviceObj);
         }
         unset($serviceObj);
         if ($validGroup) {
             $this->groupData['title'][$groupData['uid']] = $groupData['title'];
             $this->groupData['uid'][$groupData['uid']] = $groupData['uid'];
             $this->groupData['pid'][$groupData['uid']] = $groupData['pid'];
             $this->groupData['TSconfig'][$groupData['uid']] = $groupData['TSconfig'];
         }
     }
     if (count($this->groupData) && count($this->groupData['TSconfig'])) {
         // TSconfig: collect it in the order it was collected
         foreach ($this->groupData['TSconfig'] as $TSdata) {
             $this->TSdataArray[] = $TSdata;
         }
         $this->TSdataArray[] = $this->user['TSconfig'];
         // Sort information
         ksort($this->groupData['title']);
         ksort($this->groupData['uid']);
         ksort($this->groupData['pid']);
     }
     return count($this->groupData['uid']) ? count($this->groupData['uid']) : 0;
 }
		'), '199' => array('showitem' => 'doktype;;2;;1-1-1, hidden, title,
			--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.options,
				TSconfig;;6;nowrap;5-5-5, storage_pid;;7,
			--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.extended,
		'), '254' => array('showitem' => 'doktype;;2;;1-1-1, hidden, title;LLL:EXT:lang/locallang_general.xml:LGL.title,
			--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.files,
				media,
			--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.options,
				TSconfig;;6;nowrap;5-5-5, storage_pid;;7, module,
			--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.extended,
		'), '255' => array('showitem' => 'doktype;;2;;1-1-1, hidden, title,
			--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.extended,
		'));
// Merging palette settings:
// t3lib_div::array_merge() MUST be used - otherwise the keys will be re-numbered!
$TCA['pages']['palettes'] = t3lib_div::array_merge($TCA['pages']['palettes'], array('1' => array('showitem' => 'starttime, endtime, extendToSubpages'), '2' => array('showitem' => 'layout, lastUpdated, newUntil, no_search'), '3' => array('showitem' => 'alias, target, no_cache, cache_timeout'), '5' => array('showitem' => 'author, author_email', 'canNotCollapse' => 1)));
// if the compat version is less than 4.2, pagetype 2 ("Advanced")
// and pagetype 5 ("Not in menu") are added to TCA.
if (!t3lib_div::compat_version('4.2')) {
    // Merging in CMS doktypes
    array_splice($TCA['pages']['columns']['doktype']['config']['items'], 2, 0, array(array('LLL:EXT:cms/locallang_tca.xml:pages.doktype.I.0', '2', 'i/pages.gif'), array('LLL:EXT:cms/locallang_tca.xml:pages.doktype.I.3', '5', 'i/pages_notinmenu.gif')));
    // setting the doktype 1 ("Standard") to show less fields
    $TCA['pages']['types'][1] = array('showitem' => 'doktype;;2;;1-1-1, hidden, nav_hide, title;;3;;2-2-2, subtitle,
				--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.access,
					starttime, endtime, fe_group, extendToSubpages,
				--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.options,
					TSconfig;;6;nowrap;4-4-4, storage_pid;;7, l18n_cfg,
				--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.extended,
		');
    // adding doktype 2 ("Advanced")
    $TCA['pages']['types'][2] = array('showitem' => 'doktype;;2;;1-1-1, hidden, nav_hide, title;;3;;2-2-2, subtitle, nav_title,
 /**
  * main method which controls the data flow and outputs the addresses
  *
  * @param	string	$content: content string, empty
  * @param	array	$conf: configuration array with TS configuration
  * @return	string	the processed addresses
  */
 function main($content, $conf)
 {
     $this->init($conf);
     $content = '';
     $singleSelection = $this->getSingleRecords();
     $groupSelection = $this->getRecordsFromGroups();
     // merge both arrays so that we do not have any duplicates
     $addresses = t3lib_div::array_merge($singleSelection, $groupSelection);
     $templateCode = $this->getTemplate();
     // apply sorting
     if ($this->conf['sortByColumn'] === 'singleSelection' && count($groupSelection) === 0) {
         // we want to sort by single selection and only have single record selection
         $sortedAdressesUid = explode(',', $this->conf['singleSelection']);
         $sortedAddresses = array();
         foreach ($sortedAdressesUid as $uid) {
             $sortedAddresses[] = $addresses[$uid];
         }
         $addresses = $sortedAddresses;
     } else {
         // if sortByColumn was set to singleSelection, but we don't have a single selection, switch to default column "name"
         if ($this->conf['sortByColumn'] === 'singleSelection') {
             $this->conf['sortByColumn'] = 'name';
         }
         // sorting the addresses by any other field
         $sortBy = array();
         foreach ($addresses as $k => $v) {
             $sortBy[$k] = $this->normalizeSortingString($v[$this->conf['sortByColumn']]);
         }
         array_multisort($sortBy, $this->conf['sortOrder'], $addresses);
     }
     // limit output to max listMaxItems addresses
     if ((int) $this->conf['listMaxItems'] > 0) {
         $addresses = array_slice($addresses, 0, (int) $this->conf['listMaxItems']);
     }
     // output
     foreach ($addresses as $address) {
         if (!empty($address)) {
             $markerArray = $this->getItemMarkerArray($address);
             $subpartArray = $this->getSubpartArray($templateCode, $markerArray, $address);
             $addressContent = $this->cObj->substituteMarkerArrayCached($templateCode, $markerArray, $subpartArray);
             $wrap = $this->conf['templates.'][$this->conf['templateName'] . '.']['wrap'];
             $content .= $this->cObj->wrap($addressContent, $wrap);
             $content .= chr(10) . chr(10);
         }
     }
     $templateAllWrap = $this->conf['templates.'][$this->conf['templateName'] . '.']['allWrap'];
     $content = $this->cObj->wrap($content, $templateAllWrap);
     $overallWrap = $this->conf['wrap'];
     $content = $this->cObj->wrap($content, $overallWrap);
     return $this->pi_wrapInBaseClass($content);
 }
 /**
  * Return the CloudCarousel for chgallery (Experimental)
  * 
  * @param $content
  * @param $conf
  */
 function getCloudCarousel($content, $conf)
 {
     require_once t3lib_extMgm::extPath('imagecarousel') . 'pi2/class.tx_imagecarousel_pi2.php';
     $obj = t3lib_div::makeInstance('tx_imagecarousel_pi2');
     if ($conf['contentKey']) {
         $obj->setContentKey($conf['contentKey']);
     } else {
         $obj->setContentKey($obj->extKey . '_' . $this->cObj->data['uid']);
     }
     $obj->conf = t3lib_div::array_merge($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_imagecarousel_pi2.'], $conf);
     $obj->cObj = $this->cObj;
     $obj->type = 'chgallery';
     $return_string = $obj->parseTemplate('', true);
     return $content;
 }
 /**
  * add localized page records to a cache/globalArray
  * This is much faster than requesting the DB for each tt_content-record
  *
  * @param array $pageRow
  * @return void
  */
 public function addLocalizedPagesToCache($pageRow)
 {
     // create entry in cachedPageRecods for default language
     $this->cachedPageRecords[0][$pageRow['uid']] = $pageRow;
     // create entry in cachedPageRecods for additional languages, skip default language 0
     foreach ($this->sysLanguages as $sysLang) {
         if ($sysLang[1] > 0) {
             if (TYPO3_VERSION_INTEGER >= 7000000) {
                 list($pageOverlay) = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $pageRow['uid'], 'AND sys_language_uid=' . intval($sysLang[1]));
             } else {
                 list($pageOverlay) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $pageRow['uid'], 'AND sys_language_uid=' . intval($sysLang[1]));
             }
             if ($pageOverlay) {
                 if (TYPO3_VERSION_INTEGER >= 7000000) {
                     $this->cachedPageRecords[$sysLang[1]][$pageRow['uid']] = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge($pageRow, $pageOverlay);
                 } else {
                     $this->cachedPageRecords[$sysLang[1]][$pageRow['uid']] = t3lib_div::array_merge($pageRow, $pageOverlay);
                 }
             }
         }
     }
 }
示例#13
0
 /**
  * Adds items to the ->MOD_MENU array. Used for the function menu selector.
  *
  * @return	void
  */
 function menuConfig()
 {
     // Load the list of values that can be used as filters (filters are used only when all entries are being displayed)
     $this->getLogFilters();
     $this->MOD_MENU = array('function' => array('showlog' => $GLOBALS['LANG']->getLL('showlog'), 'cleanup' => $GLOBALS['LANG']->getLL('cleanup')), 'logrun' => array('1000' => $GLOBALS['LANG']->getLL('latest_run'), '25' => $GLOBALS['LANG']->getLL('latest_25'), '50' => $GLOBALS['LANG']->getLL('latest_50'), '100' => $GLOBALS['LANG']->getLL('latest_100'), '-1' => $GLOBALS['LANG']->getLL('all_entries')), 'autorefresh' => 0, 'page' => 0, 'expandAllExtraData' => 0, 'sword' => '');
     $this->MOD_MENU['logrun'] = t3lib_div::array_merge($this->recentRuns, $this->MOD_MENU['logrun']);
     // If the clear button has been clicked, empty all filters
     if (!empty($this->setVars['clear'])) {
         $this->selectedFilters = array();
         $GLOBALS['BE_USER']->pushModuleData('selectedFilters', $this->selectedFilters);
     } else {
         if (isset($this->setVars['filters'])) {
             $storedData = $GLOBALS['BE_USER']->getModuleData('selectedFilters');
             if (isset($storedData)) {
                 $this->selectedFilters = array_merge($storedData, $this->setVars['filters']);
             } else {
                 $this->selectedFilters = $this->setVars['filters'];
             }
             $GLOBALS['BE_USER']->pushModuleData('selectedFilters', $this->selectedFilters);
         } else {
             $this->selectedFilters = $GLOBALS['BE_USER']->getModuleData('selectedFilters');
         }
     }
     parent::menuConfig();
 }
 /**
  * get meta information from a file using the metaExtract service
  *
  * @param	string		file with absolut path
  * @param	array		file meta information which should be extended
  * @return	array		file meta information
  * @todo what about using services in a chain?
  */
 function getFileMetaInfo($pathname, $meta)
 {
     global $TYPO3_CONF_VARS;
     $TX_DAM = $GLOBALS['T3_VAR']['ext']['dam'];
     $conf = array();
     $conf['wantedCharset'] = $this->getWantedCharset();
     if (is_file($pathname) && is_readable($pathname)) {
         $fileType = $meta['fields']['file_type'];
         if ($this->setup['useInternalMediaTypeList']) {
             // get media type from file type
             $meta['fields']['media_type'] = $TX_DAM['file2mediaCode'][$fileType];
             //  or from mime type
             $meta['fields']['media_type'] = $meta['fields']['media_type'] ? $meta['fields']['media_type'] : tx_dam::convert_mediaType($meta['fields']['file_mime_type']);
         } else {
             $meta['fields']['media_type'] = tx_dam::convert_mediaType($meta['fields']['file_mime_type']);
         }
         $mediaType = tx_dam::convert_mediaType($meta['fields']['media_type']);
         // find a service for that file type
         if (!is_object($serviceObj = t3lib_div::makeInstanceService('metaExtract', $fileType))) {
             // find a global service for that media type
             $serviceObj = t3lib_div::makeInstanceService('metaExtract', $mediaType . ':*');
         }
         if (is_object($serviceObj)) {
             $serviceObj->setInputFile($pathname, $fileType);
             $conf['meta'] = $meta;
             if ($serviceObj->process('', '', $conf) > 0 and is_array($svmeta = $serviceObj->getOutput())) {
                 $meta = t3lib_div::array_merge_recursive_overrule($meta, $svmeta);
             }
             $serviceObj->__destruct();
             unset($serviceObj);
         }
         // make simple image size detection if not yet done
         if ($meta['fields']['media_type'] == TXDAM_mtype_image and intval($meta['fields']['hpixels']) == 0) {
             $imgsize = $this->getImageDimensions($pathname, $meta);
             $meta = t3lib_div::array_merge_recursive_overrule($meta, $imgsize);
         }
         $metaExtractServices = array();
         $extraServiceTypes = array();
         if (!isset($meta['fields']['meta']['EXIF']) and !$meta['exif_done']) {
             $metaExtractServices[TXDAM_mtype_image][] = 'image:exif';
         }
         if (!isset($meta['fields']['meta']['IPTC']) and !$meta['iptc_done'] and (!isset($meta['fields']['meta']['XMP']) and !$meta['xmp_done'])) {
             $metaExtractServices[TXDAM_mtype_image][] = 'image:iptc';
         }
         if ($extraServiceTypes) {
             $metaExtractServices[TXDAM_mtype_image] = t3lib_div::array_merge($metaExtractServices[TXDAM_mtype_image], implode(', ', $extraServiceTypes));
         }
         // TODO should be possible to register other services too?!
         // read exif, iptc data
         if (is_array($metaExtractServices[$meta['fields']['media_type']])) {
             foreach ($metaExtractServices[$meta['fields']['media_type']] as $subType) {
                 if ($serviceObj = t3lib_div::makeInstanceService('metaExtract', $subType)) {
                     $serviceObj->setInputFile($pathname, $fileType);
                     $conf['meta'] = $meta;
                     if ($serviceObj->process('', '', $conf) > 0 and is_array($svmeta = $serviceObj->getOutput())) {
                         $meta = t3lib_div::array_merge_recursive_overrule($meta, $svmeta);
                     }
                     $serviceObj->__destruct();
                     unset($serviceObj);
                 }
             }
         }
         // convert extra meta data to xml
         if (is_array($meta['fields']['meta'])) {
             // content in array is expected as utf-8 because of xml functions
             $meta['fields']['meta'] = $this->array2xml($meta['fields']['meta']);
         }
         // If no title then the file-name is set as title. This will raise the hits considerably if the search matches the document name.
         if ($meta['fields']['title'] == '') {
             $meta['fields']['title'] = $this->makeTitleFromFilename($meta['fields']['file_name']);
         }
         $meta['fields']['keywords'] = $this->listBeautify($meta['fields']['keywords']);
     }
     if ($this->writeDevLog) {
         t3lib_div::devLog('getFileMetaInfo()', 'tx_dam_indexing', 0, $meta);
     }
     return $meta;
 }