本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::isValidUrl方法的具体用法?PHP GeneralUtility::isValidUrl怎么用?PHP GeneralUtility::isValidUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::isValidUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isInLocalDomain
/**
* Determines whether the URL matches a domain
* in the sys_domain databse table.
*
* @param string $url Absolute URL which needs to be checked
* @return boolean Whether the URL is considered to be local
*/
protected function isInLocalDomain($url)
{
$result = FALSE;
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($url)) {
$parsedUrl = parse_url($url);
if ($parsedUrl['scheme'] === 'http' || $parsedUrl['scheme'] === 'https') {
$host = $parsedUrl['host'];
// Removes the last path segment and slash sequences like /// (if given):
$path = preg_replace('#/+[^/]*$#', '', $parsedUrl['path']);
$cObj = new ContentObjectRenderer();
$localDomains = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName', 'sys_domain', '1=1' . $cObj->enableFields('sys_domain'));
if (is_array($localDomains)) {
foreach ($localDomains as $localDomain) {
// strip trailing slashes (if given)
$domainName = rtrim($localDomain['domainName'], '/');
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($host . $path . '/', $domainName . '/')) {
$result = TRUE;
break;
}
}
}
}
}
return $result;
}
示例2: unserialize
/**
* @param $status
* @param $table
* @param $id
* @param $fieldArray
* @param $self
*/
function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$self)
{
if ($table == 'tx_html5videoplayer_domain_model_video') {
$data = $fieldArray;
if ($status == 'update') {
$data = array_merge($GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tx_html5videoplayer_domain_model_video', 'uid=' . (int) $id), $data);
}
$vimeoUrl = $data['vimeo'];
if (($status == 'update' || $status == 'new') && $vimeoUrl != '' && GeneralUtility::isValidUrl($vimeoUrl)) {
if (preg_match('/https?:\\/\\/(?:www\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)?|groups\\/([^\\/]*)\\/videos\\/|album\\/(\\d+)\\/video\\/|)(\\d+)(?:$|\\/|\\?)/i', $vimeoUrl, $matches)) {
$videoId = $matches[3];
$videoData = unserialize(GeneralUtility::getUrl('http://vimeo.com/api/v2/video/' . $videoId . '.php'));
if (is_array($videoData)) {
// We're only interested in index zero.
$videoData = $videoData[0];
if (!isset($data['title']) || trim($data['title']) == '') {
$fieldArray['title'] = $videoData['title'];
}
if (!isset($data['description']) || trim($data['description']) == '') {
$fieldArray['description'] = $videoData['description'];
}
if (!isset($data['posterimage']) || trim($data['posterimage']) == '') {
$resourceFactory = ResourceFactory::getInstance();
$folder = $resourceFactory->retrieveFileOrFolderObject($this->getUploadFolder());
$thumbnailData = GeneralUtility::getUrl($videoData['thumbnail_large']);
$file = $folder->createFile(basename($videoData['thumbnail_large']) . '.jpg');
$file->setContents($thumbnailData);
$fieldArray['posterimage'] = 'file:' . $file->getUid();
}
}
}
}
}
}
示例3: getGoogleSitemapToolUrl
/**
* Generate Google tool url for sitemap submit
*/
protected function getGoogleSitemapToolUrl()
{
$url = $this->toolUrl . urlencode($this->xmlSiteUrl);
if (!GeneralUtility::isValidUrl($url)) {
return null;
}
return $url;
}
示例4: validateVariables
/**
* Validate required variables
*
* @param string $defaultDomain
* @throws \TYPO3\CMS\Core\Exception
* @return boolean
*/
protected function validateVariables($defaultDomain)
{
if (empty($defaultDomain)) {
throw new \TYPO3\CMS\Core\Exception('No default domain configured');
} elseif (GeneralUtility::isValidUrl($defaultDomain) === false) {
throw new \TYPO3\CMS\Core\Exception('Default domain invalid');
}
return true;
}
示例5: getUrl
/**
* Get url
*
* @param bool $relativeToCurrentScript Determines whether the URL returned should be relative to the current script, in case it is relative at all.
* @return string
*/
public function getUrl($relativeToCurrentScript = false)
{
$url = $this->url;
if ($relativeToCurrentScript && !GeneralUtility::isValidUrl($url)) {
$absolutePathToContainingFolder = PathUtility::dirname(PATH_site . $url);
$pathPart = PathUtility::getRelativePathTo($absolutePathToContainingFolder);
$filePart = substr(PATH_site . $url, strlen($absolutePathToContainingFolder) + 1);
$url = $pathPart . $filePart;
}
return $url;
}
示例6: check
/**
* Validates that a specified field has valid url syntax.
*
* @param array &$check The TypoScript settings for this error check
* @param string $name The field name
* @param array &$gp The current GET/POST parameters
* @return string The error string
*/
public function check()
{
$checkFailed = '';
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
$valid = \TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($this->gp[$this->formFieldName]);
if (!$valid) {
$checkFailed = $this->getCheckFailed();
}
}
return $checkFailed;
}
示例7: isValid
/**
* Returns TRUE, if the given property ($propertyValue) is a valid URL / URI.
*
* If at least one error occurred, the result is FALSE.
*
* @param mixed $value The value that should be validated
*
* @return boolean TRUE if the value is valid, FALSE if an error occured
*/
public function isValid($value)
{
if (empty($value)) {
return TRUE;
}
if (GeneralUtility::isValidUrl($value) === FALSE) {
$this->addError('The given subject was not a valid URL.', 1392679659);
return FALSE;
}
return TRUE;
}
示例8: validateAdditionalFields
/**
* Validates the additional fields' values
*
* @param array $submittedData An array containing the data submitted by the add/edit task form
* @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module
* @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
*/
public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
{
$validInput = TRUE;
$urlsToCrawl = GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'UrlsToCrawl'], TRUE);
foreach ($urlsToCrawl as $url) {
if (!GeneralUtility::isValidUrl($url)) {
$validInput = FALSE;
break;
}
}
if (empty($submittedData[$this->fieldPrefix . 'UrlsToCrawl']) || !$validInput) {
$message = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:minicrawler/locallang.xml:scheduler.error.urlNotValid'));
$schedulerModule->addMessage($message, FlashMessage::ERROR);
$validInput = FALSE;
}
return $validInput;
}
示例9: handleConfiguration
/**
* Modify the given times via the configuration
*
* @param array $times
* @param Configuration $configuration
*
* @return void
*/
public function handleConfiguration(array &$times, Configuration $configuration)
{
$url = $configuration->getExternalIcsUrl();
if (!GeneralUtility::isValidUrl($url)) {
HelperUtility::createFlashMessage('Configuration with invalid ICS URL: ' . $url, 'Index ICS URL', FlashMessage::ERROR);
return;
}
$events = $this->icsReaderService->toArray($url);
foreach ($events as $event) {
/** @var $event ICalEvent */
$startTime = DateTimeUtility::getDaySecondsOfDateTime($event->getStart());
$endTime = DateTimeUtility::getDaySecondsOfDateTime($event->getEnd());
if ($endTime === self::DAY_END) {
$endTime = 0;
}
$entry = ['pid' => 0, 'start_date' => $event->getStart(), 'end_date' => $event->getEnd() ?: $event->getStart(), 'start_time' => $startTime, 'end_time' => $endTime, 'all_day' => $endTime === 0];
$times[] = $entry;
}
}
示例10: determineBaseUrl
/**
* Determines the base URL for this driver, from the configuration or
* the TypoScript frontend object
*
* @return void
*/
protected function determineBaseUrl()
{
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($this->absoluteBasePath, PATH_site)) {
// use site-relative URLs
// TODO add unit test
$this->baseUri = substr($this->absoluteBasePath, strlen(PATH_site));
} elseif (isset($this->configuration['baseUri']) && \TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($this->configuration['baseUri'])) {
$this->baseUri = rtrim($this->configuration['baseUri'], '/') . '/';
} else {
}
}
示例11: determineBaseUrl
/**
* Determines the base URL for this driver, from the configuration or
* the TypoScript frontend object
*
* @return void
*/
protected function determineBaseUrl()
{
// only calculate baseURI if the storage does not enforce jumpUrl Script
if ($this->hasCapability(ResourceStorage::CAPABILITY_PUBLIC)) {
if (GeneralUtility::isFirstPartOfStr($this->absoluteBasePath, PATH_site)) {
// use site-relative URLs
$temporaryBaseUri = rtrim(PathUtility::stripPathSitePrefix($this->absoluteBasePath), '/');
if ($temporaryBaseUri !== '') {
$uriParts = explode('/', $temporaryBaseUri);
$uriParts = array_map('rawurlencode', $uriParts);
$temporaryBaseUri = implode('/', $uriParts) . '/';
}
$this->baseUri = $temporaryBaseUri;
} elseif (isset($this->configuration['baseUri']) && GeneralUtility::isValidUrl($this->configuration['baseUri'])) {
$this->baseUri = rtrim($this->configuration['baseUri'], '/') . '/';
}
}
}
示例12: processPhysical
/**
* Processes a physical unit for the Solr index
*
* @access protected
*
* @param tx_dlf_document &$doc: The METS document
* @param integer $page: The page number
* @param array $physicalUnit: Array of the physical unit to process
*
* @return integer 0 on success or 1 on failure
*/
protected static function processPhysical(tx_dlf_document &$doc, $page, array $physicalUnit)
{
$errors = 0;
// Read extension configuration.
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
if (!empty($physicalUnit['files'][$extConf['fileGrpFulltext']])) {
$file = $doc->getFileLocation($physicalUnit['files'][$extConf['fileGrpFulltext']]);
// Load XML file.
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($file) || version_compare(phpversion(), '5.3.3', '<')) {
// Set user-agent to identify self when fetching XML data.
if (!empty($extConf['useragent'])) {
@ini_set('user_agent', $extConf['useragent']);
}
// Turn off libxml's error logging.
$libxmlErrors = libxml_use_internal_errors(TRUE);
// disable entity loading
$previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
// Load XML from file.
$xml = simplexml_load_string(file_get_contents($file));
// reset entity loader setting
libxml_disable_entity_loader($previousValueOfEntityLoader);
// Reset libxml's error logging.
libxml_use_internal_errors($libxmlErrors);
if ($xml === FALSE) {
return 1;
}
} else {
return 1;
}
// Load class.
if (!class_exists('Apache_Solr_Document')) {
require_once \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:' . self::$extKey . '/lib/SolrPhpClient/Apache/Solr/Document.php');
}
// Create new Solr document.
$solrDoc = new Apache_Solr_Document();
// Create unique identifier from document's UID and unit's XML ID.
$solrDoc->setField('id', $doc->uid . $physicalUnit['id']);
$solrDoc->setField('uid', $doc->uid);
$solrDoc->setField('pid', $doc->pid);
$solrDoc->setField('page', $page);
if (!empty($physicalUnit['files'][$extConf['fileGrpThumbs']])) {
$solrDoc->setField('thumbnail', $doc->getFileLocation($physicalUnit['files'][$extConf['fileGrpThumbs']]));
}
$solrDoc->setField('partof', $doc->parentId);
$solrDoc->setField('root', $doc->rootId);
$solrDoc->setField('sid', $physicalUnit['id']);
$solrDoc->setField('toplevel', FALSE);
$solrDoc->setField('type', $physicalUnit['type'], self::$fields['fieldboost']['type']);
$solrDoc->setField('fulltext', tx_dlf_alto::getRawText($xml));
try {
self::$solr->service->addDocument($solrDoc);
} catch (Exception $e) {
if (!defined('TYPO3_cliMode')) {
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', tx_dlf_helper::getLL('flash.solrException', TRUE) . '<br />' . htmlspecialchars($e->getMessage()), tx_dlf_helper::getLL('flash.error', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, TRUE);
tx_dlf_helper::addMessage($message);
}
return 1;
}
}
return $errors;
}
示例13: load
/**
* Load XML file from URL
*
* @access protected
*
* @param string $location: The URL of the file to load
*
* @return boolean TRUE on success or FALSE on failure
*/
protected function load($location)
{
// Load XML file.
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($location) || version_compare(phpversion(), '5.3.3', '<')) {
// Load extension configuration
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']);
// Set user-agent to identify self when fetching XML data.
if (!empty($extConf['useragent'])) {
@ini_set('user_agent', $extConf['useragent']);
}
// Turn off libxml's error logging.
$libxmlErrors = libxml_use_internal_errors(TRUE);
// Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
$previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
// Load XML from file.
$xml = simplexml_load_string(file_get_contents($location));
// reset entity loader setting
libxml_disable_entity_loader($previousValueOfEntityLoader);
// Reset libxml's error logging.
libxml_use_internal_errors($libxmlErrors);
// Set some basic properties.
if ($xml !== FALSE) {
$this->xml = $xml;
return TRUE;
} else {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load(' . $location . ')] Could not load XML file from "' . $location . '"', self::$extKey, SYSLOG_SEVERITY_ERROR);
}
}
} else {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load(' . $location . ')] Invalid file location "' . $location . '" for document loading', self::$extKey, SYSLOG_SEVERITY_ERROR);
}
}
return FALSE;
}
示例14: preprocessImages
/**
* @param array $files
* @param boolean $onlyProperties
* @throws Exception
* @return array|NULL
*/
public function preprocessImages($files, $onlyProperties = FALSE)
{
if (TRUE === empty($files)) {
return NULL;
}
if ('BE' === TYPO3_MODE) {
$this->simulateFrontendEnvironment();
}
$setup = array('width' => $this->arguments['width'], 'height' => $this->arguments['height'], 'minW' => $this->arguments['minWidth'], 'minH' => $this->arguments['minHeight'], 'maxW' => $this->arguments['maxWidth'], 'maxH' => $this->arguments['maxHeight'], 'treatIdAsReference' => FALSE);
$images = array();
foreach ($files as $file) {
$imageInfo = $this->contentObject->getImgResource($file->getUid(), $setup);
$GLOBALS['TSFE']->lastImageInfo = $imageInfo;
if (FALSE === is_array($imageInfo)) {
throw new Exception('Could not get image resource for "' . htmlspecialchars($file->getCombinedIdentifier()) . '".', 1253191060);
}
if ((double) substr(TYPO3_version, 0, 3) < 7.1) {
$imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);
} else {
$imageInfo[3] = GraphicalFunctions::pngToGifByImagemagick($imageInfo[3]);
}
$imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);
$GLOBALS['TSFE']->imagesOnPage[] = $imageInfo[3];
if (TRUE === GeneralUtility::isValidUrl($imageInfo[3])) {
$imageSource = $imageInfo[3];
} else {
$imageSource = $GLOBALS['TSFE']->absRefPrefix . GeneralUtility::rawUrlEncodeFP($imageInfo[3]);
}
if (TRUE === $onlyProperties) {
$file = ResourceUtility::getFileArray($file);
}
$images[] = array('info' => $imageInfo, 'source' => $imageSource, 'file' => $file);
}
if ('BE' === TYPO3_MODE) {
$this->resetFrontendEnvironment();
}
return $images;
}
示例15: getPublicUrlReturnsValidUrlContainingSpecialCharacters
/**
* @test
* @dataProvider getPublicUrlReturnsValidUrlContainingSpecialCharacters_dataProvider
*/
public function getPublicUrlReturnsValidUrlContainingSpecialCharacters($fileIdentifier)
{
$baseUri = 'http://example.org/foobar/' . uniqid();
$fixture = $this->createDriverFixture(array('baseUri' => $baseUri));
$publicUrl = $fixture->getPublicUrl($fileIdentifier);
$this->assertTrue(GeneralUtility::isValidUrl($publicUrl), 'getPublicUrl did not return a valid URL:' . $publicUrl);
}