本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::isFirstPartOfStr方法的具体用法?PHP GeneralUtility::isFirstPartOfStr怎么用?PHP GeneralUtility::isFirstPartOfStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::isFirstPartOfStr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialize all required repository and factory objects.
*
* @throws \RuntimeException
*/
protected function init()
{
$fileadminDirectory = rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') . '/';
/** @var $storageRepository \TYPO3\CMS\Core\Resource\StorageRepository */
$storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
$storages = $storageRepository->findAll();
foreach ($storages as $storage) {
$storageRecord = $storage->getStorageRecord();
$configuration = $storage->getConfiguration();
$isLocalDriver = $storageRecord['driver'] === 'Local';
$isOnFileadmin = !empty($configuration['basePath']) && \TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($configuration['basePath'], $fileadminDirectory);
if ($isLocalDriver && $isOnFileadmin) {
$this->storage = $storage;
break;
}
}
if (!isset($this->storage)) {
throw new \RuntimeException('Local default storage could not be initialized - might be due to missing sys_file* tables.');
}
$this->fileFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
//TYPO3 >= 6.2.0
if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 6002000) {
$this->fileIndexRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository');
} else {
//TYPO3 = 6.1
$this->fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
}
$this->targetDirectory = PATH_site . $fileadminDirectory . self::FOLDER_ContentUploads . '/';
}
示例2: prependDomain
/**
* Prepend current url if url is relative
*
* @param string $url given url
* @return string
*/
public static function prependDomain($url)
{
if (!GeneralUtility::isFirstPartOfStr($url, GeneralUtility::getIndpEnv('TYPO3_SITE_URL'))) {
$url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $url;
}
return $url;
}
示例3: renderForeignRecordHeaderControl_postProcess
/**
* Post-processing to define which control items to show. Possibly own icons can be added here.
*
* @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
* @param string $foreignTable The table (foreign_table) we create control-icons for
* @param array $childRecord The current record of that foreign_table
* @param array $childConfig TCA configuration of the current field of the child record
* @param boolean $isVirtual Defines whether the current records is only virtually shown and not physically part of the parent record
* @param array $controlItems (reference) Associative array with the currently available control items
*
* @return void
*/
public function renderForeignRecordHeaderControl_postProcess($parentUid, $foreignTable, array $childRecord, array $childConfig, $isVirtual, array &$controlItems)
{
if ($foreignTable != 'sys_file_reference') {
return;
}
if (!GeneralUtility::isFirstPartOfStr($childRecord['uid_local'], 'sys_file_')) {
return;
}
$parts = BackendUtility::splitTable_Uid($childRecord['uid_local']);
if (!isset($parts[1])) {
return;
}
$table = $childRecord['tablenames'];
$uid = $parentUid;
$arguments = GeneralUtility::_GET();
if ($this->isValidRecord($table, $uid) && isset($arguments['edit'])) {
$returnUrl = ['edit' => $arguments['edit'], 'returnUrl' => $arguments['returnUrl']];
if (GeneralUtility::compat_version('7.0')) {
$returnUrlGenerated = BackendUtility::getModuleUrl('record_edit', $returnUrl);
} else {
$returnUrlGenerated = 'alt_doc.php?' . ltrim(GeneralUtility::implodeArrayForUrl('', $returnUrl, '', true, true), '&') . BackendUtility::getUrlToken('editRecord');
}
$wizardArguments = ['P' => ['referenceUid' => $childRecord['uid'], 'returnUrl' => $returnUrlGenerated]];
$wizardUri = BackendUtility::getModuleUrl('focuspoint', $wizardArguments);
} else {
$wizardUri = 'javascript:alert(\'Please save the base record first, because open this wizard will not save the changes in the current form!\');';
}
/** @var WizardService $wizardService */
$wizardService = GeneralUtility::makeInstance('HDNET\\Focuspoint\\Service\\WizardService');
$this->arrayUnshiftAssoc($controlItems, 'focuspoint', $wizardService->getWizardButton($wizardUri));
}
示例4: fetchType
/**
* Type fetching method, based on the type that softRefParserObj returns
*
* @param array $value Reference properties
* @param string $type Current type
* @param string $key Validator hook name
* @return string fetched type
*/
public function fetchType($value, $type, $key)
{
if ($value['type'] === 'string' && GeneralUtility::isFirstPartOfStr(strtolower($value['tokenValue']), 'record:')) {
$type = 'linkhandler';
}
return $type;
}
示例5: createTag
/**
* Create a tag
*
* @param array $params
* @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj
* @return void
* @throws \Exception
*/
public function createTag(array $params, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
{
$request = GeneralUtility::_POST();
try {
// Check if a tag is submitted
if (!isset($request['item']) || empty($request['item'])) {
throw new \Exception('error_no-tag');
}
$itemUid = $request['uid'];
if ((int) $itemUid === 0 && (strlen($itemUid) == 16 && !GeneralUtility::isFirstPartOfStr($itemUid, 'NEW'))) {
throw new \Exception('error_no-uid');
}
$table = $request['table'];
if (empty($table)) {
throw new \Exception('error_no-table');
}
// Get tag uid
$newTagId = $this->getTagUid($request);
$ajaxObj->setContentFormat('javascript');
$ajaxObj->setContent('');
$response = array($newTagId, $request['item'], self::TAG, $table, 'tags', 'data[' . htmlspecialchars($table) . '][' . $itemUid . '][tags]', $itemUid);
$ajaxObj->setJavascriptCallbackWrap(implode('-', $response));
} catch (\Exception $e) {
$errorMsg = $GLOBALS['LANG']->sL(self::LLPATH . $e->getMessage());
$ajaxObj->setError($errorMsg);
}
}
示例6: fetchType
/**
* Type fetching method, based on the type that softRefParserObj returns
*
* @param array $value Reference properties
* @param string $type Current type
* @param string $key Validator hook name
* @return string fetched type
*/
public function fetchType($value, $type, $key)
{
if (GeneralUtility::isFirstPartOfStr(strtolower($value['tokenValue']), 'file:')) {
$type = 'file';
}
return $type;
}
示例7: addLabel
/**
* Add the label to a XML file
*
* @param string $extensionKey
* @param string $key
* @param string $default
*
* @return NULL
*/
public function addLabel($extensionKey, $key, $default)
{
// Excelude
if (!strlen($default)) {
return;
}
if (!strlen($key)) {
return;
}
if (!strlen($extensionKey)) {
return;
}
if (GeneralUtility::isFirstPartOfStr($key, 'LLL:')) {
return;
}
$absolutePath = $this->getAbsoluteFilename($extensionKey);
$content = GeneralUtility::getUrl($absolutePath);
if (strpos($content, ' index="' . $key . '"') !== false || trim($content) === '') {
return;
}
$replace = '<languageKey index="default" type="array">' . LF . TAB . TAB . TAB . '<label index="' . $key . '">' . $this->wrapCdata($default) . '</label>';
$content = str_replace('<languageKey index="default" type="array">', $replace, $content);
FileUtility::writeFileAndCreateFolder($absolutePath, $content);
$this->clearCache();
}
示例8: removeImageFileFromAlbumDirectory
/**
* Remove the file if it is located within its album path.
* That means, it does not remove files located in an other directory (like files imported by the directory importer)
*
* @param Tx_Yag_Domain_Model_Item $item
*/
public function removeImageFileFromAlbumDirectory(Tx_Yag_Domain_Model_Item $item)
{
$albumPath = $this->getOrigFileDirectoryPathForAlbum($item->getAlbum());
$imageFilePath = Tx_Yag_Domain_FileSystem_Div::makePathAbsolute($item->getSourceuri());
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($imageFilePath, $albumPath) && file_exists($imageFilePath)) {
unlink($imageFilePath);
}
}
示例9: renderColumnLabel
/**
* @param Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn $headerColumn
* @return string
*/
public function renderColumnLabel(Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn $headerColumn)
{
$label = $headerColumn->getLabel();
$label = Tx_PtExtlist_Utility_RenderValue::stdWrapIfPlainArray($label);
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($label, 'LLL:')) {
$label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label, '');
}
return $label;
}
示例10: md5HashIsUpdatedToTemporarySaltedString
/**
* @test
*/
public function md5HashIsUpdatedToTemporarySaltedString()
{
$isSet = null;
$originalPassword = '5f4dcc3b5aa765d61d8327deb882cf99';
$saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
$this->assertTrue($isSet);
$this->assertNotEquals($originalPassword, $saltedPassword);
$this->assertTrue(GeneralUtility::isFirstPartOfStr($saltedPassword, 'M$'));
}
示例11: tearDown
/**
* Tear down
*/
public function tearDown()
{
foreach ($this->testNodesToDelete as $node) {
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site . 'typo3temp/')) {
\TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($node, TRUE);
}
}
parent::tearDown();
}
示例12: main
/**
* Find lost files in uploads/ folder
* FIX METHOD: Simply delete the file...
*
* TODO: Add parameter to exclude filepath
* TODO: Add parameter to list more file names/patterns to ignore
* TODO: Add parameter to include RTEmagic images
*
* @return array
* @todo Define visibility
*/
public function main()
{
global $TYPO3_DB;
// Initialize result array:
$resultArray = array('message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'], 'headers' => array('managedFiles' => array('Files related to TYPO3 records and managed by TCEmain', 'These files you definitely want to keep.', 0), 'ignoredFiles' => array('Ignored files (index.html, .htaccess etc.)', 'These files are allowed in uploads/ folder', 0), 'RTEmagicFiles' => array('RTE magic images - those found (and ignored)', 'These files are also allowed in some uploads/ folders as RTEmagic images.', 0), 'lostFiles' => array('Lost files - those you can delete', 'You can delete these files!', 3), 'warnings' => array('Warnings picked up', '', 2)), 'managedFiles' => array(), 'ignoredFiles' => array(), 'RTEmagicFiles' => array(), 'lostFiles' => array(), 'warnings' => array());
// Get all files:
$fileArr = array();
$fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath($fileArr, PATH_site . 'uploads/');
$fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::removePrefixPathFromList($fileArr, PATH_site);
$excludePaths = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->cli_argValue('--excludePath', 0), TRUE);
// Traverse files and for each, look up if its found in the reference index.
foreach ($fileArr as $key => $value) {
$include = TRUE;
foreach ($excludePaths as $exclPath) {
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($value, $exclPath)) {
$include = FALSE;
}
}
$shortKey = \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5($value);
if ($include) {
// First, allow "index.html", ".htaccess" files since they are often used for good reasons
if (substr($value, -11) == '/index.html' || substr($value, -10) == '/.htaccess') {
unset($fileArr[$key]);
$resultArray['ignoredFiles'][$shortKey] = $value;
} else {
// Looking for a reference from a field which is NOT a soft reference (thus, only fields with a proper TCA/Flexform configuration)
$recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_string=' . $TYPO3_DB->fullQuoteStr($value, 'sys_refindex') . ' AND softref_key=' . $TYPO3_DB->fullQuoteStr('', 'sys_refindex'), '', 'sorting DESC');
// If found, unset entry:
if (count($recs)) {
unset($fileArr[$key]);
$resultArray['managedFiles'][$shortKey] = $value;
if (count($recs) > 1) {
$resultArray['warnings'][$shortKey] = 'Warning: File "' . $value . '" had ' . count($recs) . ' references from group-fields, should have only one!';
}
} else {
// When here it means the file was not found. So we test if it has a RTEmagic-image name and if so, we allow it:
if (preg_match('/^RTEmagic[P|C]_/', basename($value))) {
unset($fileArr[$key]);
$resultArray['RTEmagicFiles'][$shortKey] = $value;
} else {
// We conclude that the file is lost...:
unset($fileArr[$key]);
$resultArray['lostFiles'][$shortKey] = $value;
}
}
}
}
}
asort($resultArray['ignoredFiles']);
asort($resultArray['managedFiles']);
asort($resultArray['RTEmagicFiles']);
asort($resultArray['lostFiles']);
asort($resultArray['warnings']);
// $fileArr variable should now be empty with all contents transferred to the result array keys.
return $resultArray;
}
示例13: user_orderBy
/**
* Modifies the select box of orderBy-options as a category menu
* needs different ones then a news action
*
* @param array &$config configuration array
* @return void
*/
public function user_orderBy(array &$config)
{
$newItems = '';
// check if the record has been saved once
if (is_array($config['row']) && !empty($config['row']['pi_flexform'])) {
$flexformConfig = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($config['row']['pi_flexform']);
// check if there is a flexform configuration
if (isset($flexformConfig['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'])) {
$selectedActionList = $flexformConfig['data']['sDEF']['lDEF']['switchableControllerActions']['vDEF'];
// check for selected action
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($selectedActionList, 'Category')) {
$newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['moox_news']['orderByCategory'];
} elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($selectedActionList, 'Tag')) {
$this->removeNonValidOrderFields($config, 'tx_mooxnews_domain_model_tag');
$newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['moox_news']['orderByTag'];
} elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($selectedActionList, 'Target')) {
$this->removeNonValidOrderFields($config, 'tx_mooxnews_domain_model_target');
$newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['moox_news']['orderByTarget'];
} else {
$newItems = $GLOBALS['TYPO3_CONF_VARS']['EXT']['moox_news']['orderByNews'];
$orderByNews = true;
}
}
}
// if a override configuration is found
if (!empty($newItems)) {
// remove default configuration
$config['items'] = array();
// empty default line
array_push($config['items'], array('', ''));
$newItemArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $newItems, TRUE);
$languageKey = 'LLL:EXT:moox_news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.';
foreach ($newItemArray as $item) {
// label: if empty, key (=field) is used
$label = $GLOBALS['LANG']->sL($languageKey . $item, TRUE);
if (empty($label)) {
$label = htmlspecialchars($item);
}
array_push($config['items'], array($label, $item));
}
}
if ($orderByNews) {
foreach ($GLOBALS['TCA']['tx_mooxnews_domain_model_news']['columns'] as $fieldname => $field) {
$ll = 'LLL:EXT:' . $field['extkey'] . '/Resources/Private/Language/locallang_db.xml:';
if ($field['addToMooxNewsFrontendSorting']) {
$prefix = $ll . 'tx_' . str_replace("_", "", $field['extkey']) . '_domain_model_news';
$prefix = $GLOBALS['LANG']->sL($prefix, TRUE) . ": ";
$label = $GLOBALS['LANG']->sL($field['label'], TRUE);
array_push($config['items'], array($prefix . $label, \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToLowerCamelCase($fieldname)));
}
}
}
}
示例14: addOptions
/**
* Add options to FlexForm Selection - Options can be defined in TSConfig
*
* @param array $params
* @return void
*/
public function addOptions(&$params)
{
$this->initialize();
$tSconfig = BackendUtility::getPagesTSconfig($this->getPid());
$this->addCaptchaOption($params);
if (!empty($tSconfig['tx_femanager.']['flexForm.'][$params['config']['itemsProcFuncTab'] . '.']['addFieldOptions.'])) {
$options = $tSconfig['tx_femanager.']['flexForm.'][$params['config']['itemsProcFuncTab'] . '.']['addFieldOptions.'];
foreach ((array) $options as $value => $label) {
$params['items'][] = array(GeneralUtility::isFirstPartOfStr($label, 'LLL:') ? $this->languageService->sL($label) : $label, $value);
}
}
}
示例15: render_clickenlarge
/**
* Rendering the "data-htmlarea-clickenlarge" custom attribute, called from TypoScript
*
* @param string Content input. Not used, ignore.
* @param array TypoScript configuration
* @return string HTML output.
* @access private
* @todo Define visibility
*/
public function render_clickenlarge($content, $conf)
{
$clickenlarge = isset($this->cObj->parameters['data-htmlarea-clickenlarge']) ? $this->cObj->parameters['data-htmlarea-clickenlarge'] : 0;
if (!$clickenlarge) {
// Backward compatibility
$clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
}
$fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
$fileTable = $this->cObj->parameters['data-htmlarea-file-table'];
$fileUid = $this->cObj->parameters['data-htmlarea-file-uid'];
if ($fileUid) {
$fileObject = $fileFactory->getFileObject($fileUid);
$filePath = $fileObject->getForLocalProcessing(FALSE);
$file = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($filePath);
} else {
// Pre-FAL backward compatibility
$path = $this->cObj->parameters['src'];
$magicFolder = $fileFactory->getFolderObjectFromCombinedIdentifier($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']);
if ($magicFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
$magicFolderPath = $magicFolder->getPublicUrl();
$pathPre = $magicFolderPath . 'RTEmagicC_';
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($path, $pathPre)) {
// Find original file:
$pI = pathinfo(substr($path, strlen($pathPre)));
$filename = substr($pI['basename'], 0, -strlen('.' . $pI['extension']));
$file = $magicFolderPath . 'RTEmagicP_' . $filename;
} else {
$file = $this->cObj->parameters['src'];
}
}
}
// Unset clickenlarge custom attribute
unset($this->cObj->parameters['data-htmlarea-clickenlarge']);
// Backward compatibility
unset($this->cObj->parameters['clickenlarge']);
unset($this->cObj->parameters['allParams']);
$content = '<img ' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes($this->cObj->parameters, TRUE, TRUE) . ' />';
if ($clickenlarge && is_array($conf['imageLinkWrap.'])) {
$theImage = $file ? $GLOBALS['TSFE']->tmpl->getFileName($file) : '';
if ($theImage) {
$this->cObj->parameters['origFile'] = $theImage;
if ($this->cObj->parameters['title']) {
$conf['imageLinkWrap.']['title'] = $this->cObj->parameters['title'];
}
if ($this->cObj->parameters['alt']) {
$conf['imageLinkWrap.']['alt'] = $this->cObj->parameters['alt'];
}
$content = $this->cObj->imageLinkWrap($content, $theImage, $conf['imageLinkWrap.']);
$content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
}
}
return $content;
}