本文整理汇总了PHP中t3lib_div::testInt方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::testInt方法的具体用法?PHP t3lib_div::testInt怎么用?PHP t3lib_div::testInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::testInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*/
public function __construct()
{
// we check for existance of our targetDirectory
if (!is_dir(PATH_site . $this->targetDirectory)) {
t3lib_div::mkdir(PATH_site . $this->targetDirectory);
}
// if enabled, we check whether we should auto-create the .htaccess file
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['generateApacheHtaccess']) {
// check whether .htaccess exists
$htaccessPath = PATH_site . $this->targetDirectory . '.htaccess';
if (!file_exists($htaccessPath)) {
t3lib_div::writeFile($htaccessPath, $this->htaccessTemplate);
}
}
// decide whether we should create gzipped versions or not
$compressionLevel = $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['compressionLevel'];
// we need zlib for gzencode()
if (extension_loaded('zlib') && $compressionLevel) {
$this->createGzipped = TRUE;
// $compressionLevel can also be TRUE
if (t3lib_div::testInt($compressionLevel)) {
$this->gzipCompressionLevel = intval($compressionLevel);
}
}
}
示例2: put
/**
* Adds a key to the storage or removes existing key
*
* @param string $key The key
* @return void
* @see tx_rsaauth_abstract_storage::put()
*/
public function put($key)
{
if ($key == null) {
// Remove existing key
list($keyId) = $_SESSION['tx_rsaauth_key'];
if (t3lib_div::testInt($keyId)) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_rsaauth_keys', 'uid=' . $keyId);
unset($_SESSION['tx_rsaauth_key']);
}
} else {
// Add key
// Get split point. First part is always smaller than the second
// because it goes to the file system
$keyLength = strlen($key);
$splitPoint = rand(intval($keyLength / 10), intval($keyLength / 2));
// Get key parts
$keyPart1 = substr($key, 0, $splitPoint);
$keyPart2 = substr($key, $splitPoint);
// Store part of the key in the database
//
// Notice: we may not use TCEmain below to insert key part into the
// table because TCEmain requires a valid BE user!
$time = $GLOBALS['EXEC_TIME'];
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_rsaauth_keys', array('pid' => 0, 'crdate' => $time, 'key_value' => $keyPart2));
$keyId = $GLOBALS['TYPO3_DB']->sql_insert_id();
// Store another part in session
$_SESSION['tx_rsaauth_key'] = array($keyId, $keyPart1);
}
// Remove expired keys (more than 30 minutes old)
$GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_rsaauth_keys', 'crdate<' . ($GLOBALS['EXEC_TIME'] - 30 * 60));
}
示例3: isInteger
/**
* Wrapper for t3lib_div::testInt and \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($var)
* @param mixed $var
* @return boolean
*/
public static function isInteger($var)
{
if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) {
$isInteger = \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($var);
} elseif (tx_rnbase_util_TYPO3::isTYPO46OrHigher()) {
$isInteger = t3lib_utility_Math::canBeInterpretedAsInteger($var);
} else {
$isInteger = t3lib_div::testInt($var);
}
return $isInteger;
}
示例4: testInt
public static function testInt($var)
{
$result = FALSE;
$callingClassName = '\\TYPO3\\CMS\\Core\\Utility\\MathUtility';
if (class_exists($callingClassName) && method_exists($callingClassName, 'canBeInterpretedAsInteger')) {
$result = call_user_func($callingClassName . '::canBeInterpretedAsInteger', $var);
} else {
if (class_exists('t3lib_utility_Math') && method_exists('t3lib_utility_Math', 'canBeInterpretedAsInteger')) {
$result = t3lib_utility_Math::canBeInterpretedAsInteger($var);
} else {
if (class_exists('t3lib_div') && method_exists('t3lib_div', 'testInt')) {
$result = t3lib_div::testInt($var);
}
}
}
return $result;
}
示例5: __construct
/**
* Constructor
*/
public function __construct()
{
// we check for existance of our targetDirectory
if (!is_dir(PATH_site . $this->targetDirectory)) {
t3lib_div::mkdir(PATH_site . $this->targetDirectory);
}
// decide whether we should create gzipped versions or not
$compressionLevel = $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['compressionLevel'];
// we need zlib for gzencode()
if (extension_loaded('zlib') && $compressionLevel) {
$this->createGzipped = TRUE;
// $compressionLevel can also be TRUE
if (t3lib_div::testInt($compressionLevel)) {
$this->gzipCompressionLevel = $compressionLevel;
}
}
}
示例6: transform_rte
/**
* Transformation handler: 'txdam_media' / direction: "rte"
* Processing linked images from database content going into the RTE.
* Processing includes converting the src attribute to an absolute URL.
*
* @param string Content input
* @return string Content output
*/
function transform_rte($value, &$pObj)
{
// Split content by the TYPO3 pseudo tag "<media>":
$blockSplit = $pObj->splitIntoBlock('media', $value, 1);
foreach ($blockSplit as $k => $v) {
$error = '';
if ($k % 2) {
// block:
$tagCode = t3lib_div::unQuoteFilenames(trim(substr($pObj->getFirstTag($v), 0, -1)), true);
$link_param = $tagCode[1];
$href = '';
$useDAMColumn = FALSE;
// Checking if the id-parameter is int and get meta data
if (t3lib_div::testInt($link_param)) {
$meta = tx_dam::meta_getDataByUid($link_param);
}
if (is_array($meta)) {
$href = tx_dam::file_url($meta);
if (!$tagCode[4]) {
require_once PATH_txdam . 'lib/class.tx_dam_guifunc.php';
$displayItems = '';
if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], 'usedamcolumn') && $pObj->thisConfig['buttons.']['link.']['media.']['properties.']['title.']['useDAMColumn']) {
$displayItems = $pObj->thisConfig['buttons.']['link.']['media.']['properties.']['title.']['useDAMColumn.']['displayItems'] ? $pObj->thisConfig['buttons.']['link.']['media.']['properties.']['title.']['useDAMColumn.']['displayItems'] : '';
$useDAMColumn = TRUE;
}
$tagCode[4] = tx_dam_guiFunc::meta_compileHoverText($meta, $displayItems, ', ');
}
} else {
$href = $link_param;
$error = 'No media file found: ' . $link_param;
}
// Setting the A-tag:
$bTag = '<a href="' . htmlspecialchars($href) . '" txdam="' . htmlspecialchars($link_param) . '"' . ($tagCode[2] && $tagCode[2] != '-' ? ' target="' . htmlspecialchars($tagCode[2]) . '"' : '') . ($tagCode[3] && $tagCode[3] != '-' ? ' class="' . htmlspecialchars($tagCode[3]) . '"' : '') . ($tagCode[4] ? ' title="' . htmlspecialchars($tagCode[4]) . '"' : '') . ($useDAMColumn ? ' usedamcolumn="true"' : '') . ($error ? ' rteerror="' . htmlspecialchars($error) . '" style="background-color: yellow; border:2px red solid; color: black;"' : '') . '>';
$eTag = '</a>';
$blockSplit[$k] = $bTag . $this->transform_rte($pObj->removeFirstAndLastTag($blockSplit[$k]), $pObj) . $eTag;
}
}
$value = implode('', $blockSplit);
return $value;
}
示例7: processContentUpdates
/**
* Processes page and content changes in regard to RealURL caches.
*
* @param string $status
* @param string $tableName
* @param int $recordId
* @param array $databaseData
* @return void
* @todo Handle changes to tx_realurl_exclude recursively
*/
protected function processContentUpdates($status, $tableName, $recordId, array $databaseData)
{
if ($status == 'update' && t3lib_div::testInt($recordId)) {
list($pageId, $languageId) = $this->getPageData($tableName, $recordId);
$this->fetchRealURLConfiguration($pageId);
if ($this->shouldFixCaches($tableName, $databaseData)) {
if (isset($databaseData['alias'])) {
$this->expirePathCacheForAllLanguages($pageId);
} else {
$this->expirePathCache($pageId, $languageId);
}
$this->clearOtherCaches($pageId);
}
}
}
示例8: isOnSymmetricSide
/**
* Checks, if we're looking from the "other" side, the symmetric side, to a symmetric relation.
*
* @param string $parentUid: The uid of the parent record
* @param array $parentConf: The TCA configuration of the parent field embedding the child records
* @param array $childRec: The record row of the child record
* @return boolean Returns true if looking from the symmetric ("other") side to the relation.
*/
function isOnSymmetricSide($parentUid, $parentConf, $childRec)
{
return t3lib_div::testInt($childRec['uid']) && $parentConf['symmetric_field'] && $parentUid == $childRec[$parentConf['symmetric_field']] ? true : false;
}
示例9: pagePathtoID
//.........这里部分代码省略.........
// any items from path parts, we need to check if they are defined as postSetVars or
// fixedPostVars on this page. This does not guarantie 100% success. For example,
// if path to page is /hello/world/how/are/you and hello/world found in cache and
// there is a postVar 'how' on this page, the check below will not work. But it is still
// better than nothing.
if ($row && $postVar) {
$postVars = $this->pObj->getPostVarSetConfig($row['pid'], 'postVarSets');
if (!is_array($postVars) || !isset($postVars[$postVar])) {
// Check fixed
$postVars = $this->pObj->getPostVarSetConfig($row['pid'], 'fixedPostVars');
if (!is_array($postVars) || !isset($postVars[$postVar])) {
// Not a postVar, so page most likely in not in cache. Clear row.
// TODO It would be great to update cache in this case but usually TYPO3 is not
// complitely initialized at this place. So we do not do it...
$row = false;
}
}
}
// Process row if found:
if ($row) { // We found it in the cache
// Check for expiration. We can get one of three:
// 1. expire = 0
// 2. expire <= time()
// 3. expire > time()
// 1 is permanent, we do not process it. 2 is expired, we look for permanent or non-expired
// (in this order!) entry for the same page od and redirect to corresponding path. 3 - same as
// 1 but means that entry is going to expire eventually, nothing to do for us yet.
if ($row['expire'] > 0) {
if ($this->pObj->enableDevLog) {
t3lib_div::devLog('pagePathToId found row', 'realurl', 0, $row);
}
// 'expire' in the query is only for logging
// Using pathq2 index!
list($newEntry) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pagepath,expire', 'tx_realurl_pathcache',
'page_id=' . intval($row['page_id']) . '
AND language_id=' . intval($row['language_id']) . '
AND (expire=0 OR expire>' . $row['expire'] . ')', '', 'expire', '1');
if ($this->pObj->enableDevLog) {
t3lib_div::devLog('pagePathToId searched for new entry', 'realurl', 0, $newEntry);
}
// Redirect to new path immediately if it is found
if ($newEntry) {
// Replace path-segments with new ones:
$originalDirs = $this->pObj->dirParts; // All original
$cp_pathParts = $pathParts;
// Popping of pages of original dirs (as many as are remaining in $pathParts)
for ($a = 0; $a < count($pathParts); $a++) {
array_pop($originalDirs); // Finding all preVars here
}
for ($a = 0; $a < count($copy_pathParts); $a++) {
array_shift($cp_pathParts); // Finding all postVars here
}
$newPathSegments = explode('/', $newEntry['pagepath']); // Split new pagepath into segments.
$newUrlSegments = array_merge($originalDirs, $newPathSegments, $cp_pathParts); // Merge those segments.
$newUrlSegments[] = $this->pObj->filePart; // Add any filename as well
$redirectUrl = implode('/', $newUrlSegments); // Create redirect URL:
if ($this->pObj->extConf['fileName']['defaultToHTMLsuffixOnPrev'] && strlen($redirectUrl) > 1) {
if (substr($redirectUrl, -1, 1) == '/') {
$redirectUrl = substr($redirectUrl, 0, -1);
}
if (!t3lib_div::testInt($this->pObj->extConf['fileName']['defaultToHTMLsuffixOnPrev'])) {
$redirectUrl .= $this->pObj->extConf['fileName']['defaultToHTMLsuffixOnPrev'];
}
else {
$redirectUrl .= '.html';
}
}
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . t3lib_div::locationHeaderUrl($redirectUrl));
exit();
}
$this->pObj->disableDecodeCache = true; // Do not cache this!
}
// Unshift the number of segments that must have defined the page:
$cc = count($copy_pathParts);
for ($a = 0; $a < $cc; $a++) {
array_shift($pathParts);
}
// Assume we can use this info at first
$id = $row['page_id'];
$GET_VARS = $row['mpvar'] ? array('MP' => $row['mpvar']) : '';
}
else {
// Find it
list($info, $GET_VARS) = $this->findIDByURL($pathParts);
// Setting id:
$id = ($info['id'] ? $info['id'] : 0);
}
// Return found ID:
return array($id, $GET_VARS);
}
示例10: linkData
/**
* The mother of all functions creating links/URLs etc in a TypoScript environment.
* See the references below.
* Basically this function takes care of issues such as type,id,alias and Mount Points, URL rewriting (through hooks), M5/B6 encoded parameters etc.
* It is important to pass all links created through this function since this is the guarantee that globally configured settings for link creating are observed and that your applications will conform to the various/many configuration options in TypoScript Templates regarding this.
*
* @param array The page record of the page to which we are creating a link. Needed due to fields like uid, alias, target, no_cache, title and sectionIndex_uid.
* @param string Default target string to use IF not $page['target'] is set.
* @param boolean If set, then the "&no_cache=1" parameter is included in the URL.
* @param string Alternative script name if you don't want to use $GLOBALS['TSFE']->config['mainScript'] (normally set to "index.php")
* @param array Array with overriding values for the $page array.
* @param string Additional URL parameters to set in the URL. Syntax is "&foo=bar&foo2=bar2" etc. Also used internally to add parameters if needed.
* @param string If you set this value to something else than a blank string, then the typeNumber used in the link will be forced to this value. Normally the typeNum is based on the target set OR on $GLOBALS['TSFE']->config['config']['forceTypeValue'] if found.
* @param string The target Doamin, if any was detected in typolink
* @return array Contains keys like "totalURL", "url", "sectionIndex", "linkVars", "no_cache", "type", "target" of which "totalURL" is normally the value you would use while the other keys contains various parts that was used to construct "totalURL"
* @see tslib_frameset::frameParams(), tslib_cObj::typoLink(), tslib_cObj::SEARCHRESULT(), TSpagegen::pagegenInit(), tslib_menu::link()
*/
function linkData($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '', $targetDomain = '')
{
global $TYPO3_CONF_VARS;
$LD = array();
// Overriding some fields in the page record and still preserves the values by adding them as parameters. Little strange function.
if (is_array($overrideArray)) {
foreach ($overrideArray as $theKey => $theNewVal) {
$addParams .= '&real_' . $theKey . '=' . rawurlencode($page[$theKey]);
$page[$theKey] = $theNewVal;
}
}
// Adding Mount Points, "&MP=", parameter for the current page if any is set:
if (!strstr($addParams, '&MP=')) {
if (trim($GLOBALS['TSFE']->MP_defaults[$page['uid']])) {
// Looking for hardcoded defaults:
$addParams .= '&MP=' . rawurlencode(trim($GLOBALS['TSFE']->MP_defaults[$page['uid']]));
} elseif ($GLOBALS['TSFE']->config['config']['MP_mapRootPoints']) {
// Else look in automatically created map:
$m = $this->getFromMPmap($page['uid']);
if ($m) {
$addParams .= '&MP=' . rawurlencode($m);
}
}
}
// Setting ID/alias:
if (!$script) {
$script = $GLOBALS['TSFE']->config['mainScript'];
}
if ($page['alias']) {
$LD['url'] = $script . '?id=' . rawurlencode($page['alias']);
} else {
$LD['url'] = $script . '?id=' . $page['uid'];
}
// Setting target
$LD['target'] = trim($page['target']) ? trim($page['target']) : $oTarget;
// typeNum
$typeNum = $this->setup[$LD['target'] . '.']['typeNum'];
if (!t3lib_div::testInt($typeOverride) && intval($GLOBALS['TSFE']->config['config']['forceTypeValue'])) {
$typeOverride = intval($GLOBALS['TSFE']->config['config']['forceTypeValue']);
}
if (strcmp($typeOverride, '')) {
$typeNum = $typeOverride;
}
// Override...
if ($typeNum) {
$LD['type'] = '&type=' . intval($typeNum);
} else {
$LD['type'] = '';
}
$LD['orig_type'] = $LD['type'];
// Preserving the type number.
// noCache
$LD['no_cache'] = trim($page['no_cache']) || $no_cache ? '&no_cache=1' : '';
// linkVars
if ($GLOBALS['TSFE']->config['config']['uniqueLinkVars']) {
if ($addParams) {
$LD['linkVars'] = t3lib_div::implodeArrayForUrl('', t3lib_div::explodeUrl2Array($GLOBALS['TSFE']->linkVars . $addParams));
} else {
$LD['linkVars'] = $GLOBALS['TSFE']->linkVars;
}
} else {
$LD['linkVars'] = $GLOBALS['TSFE']->linkVars . $addParams;
}
// Add absRefPrefix if exists.
$LD['url'] = $GLOBALS['TSFE']->absRefPrefix . $LD['url'];
// If the special key 'sectionIndex_uid' (added 'manually' in tslib/menu.php to the page-record) is set, then the link jumps directly to a section on the page.
$LD['sectionIndex'] = $page['sectionIndex_uid'] ? '#c' . $page['sectionIndex_uid'] : '';
// Compile the normal total url
$LD['totalURL'] = $this->removeQueryString($LD['url'] . $LD['type'] . $LD['no_cache'] . $LD['linkVars'] . $GLOBALS['TSFE']->getMethodUrlIdToken) . $LD['sectionIndex'];
// Call post processing function for link rendering:
if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc'])) {
$_params = array('LD' => &$LD, 'args' => array('page' => $page, 'oTarget' => $oTarget, 'no_cache' => $no_cache, 'script' => $script, 'overrideArray' => $overrideArray, 'addParams' => $addParams, 'typeOverride' => $typeOverride, 'targetDomain' => $targetDomain), 'typeNum' => $typeNum);
foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc'] as $_funcRef) {
t3lib_div::callUserFunction($_funcRef, $_params, $this);
}
}
// Return the LD-array
return $LD;
}
示例11: main
/**
* Main function
* Makes a header-location redirect to an edit form IF POSSIBLE from the passed data - otherwise the window will just close.
*
* @return void
*/
function main()
{
global $TCA;
if ($this->doClose) {
$this->closeWindow();
} else {
// Initialize:
$table = $this->P['table'];
$field = $this->P['field'];
t3lib_div::loadTCA($table);
$config = $TCA[$table]['columns'][$field]['config'];
$fTable = $this->P['currentValue'] < 0 ? $config['neg_foreign_table'] : $config['foreign_table'];
// Detecting the various allowed field type setups and acting accordingly.
if (is_array($config) && $config['type'] == 'select' && !$config['MM'] && $config['maxitems'] <= 1 && t3lib_div::testInt($this->P['currentValue']) && $this->P['currentValue'] && $fTable) {
// SINGLE value:
$redirectUrl = 'alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . '&edit[' . $fTable . '][' . $this->P['currentValue'] . ']=edit';
t3lib_utility_Http::redirect($redirectUrl);
} elseif (is_array($config) && $this->P['currentSelectedValues'] && ($config['type'] == 'select' && $config['foreign_table'] || $config['type'] == 'group' && $config['internal_type'] == 'db')) {
// MULTIPLE VALUES:
// Init settings:
$allowedTables = $config['type'] == 'group' ? $config['allowed'] : $config['foreign_table'] . ',' . $config['neg_foreign_table'];
$prependName = 1;
$params = '';
// Selecting selected values into an array:
$dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
$dbAnalysis->start($this->P['currentSelectedValues'], $allowedTables);
$value = $dbAnalysis->getValueArray($prependName);
// Traverse that array and make parameters for alt_doc.php:
foreach ($value as $rec) {
$recTableUidParts = t3lib_div::revExplode('_', $rec, 2);
$params .= '&edit[' . $recTableUidParts[0] . '][' . $recTableUidParts[1] . ']=edit';
}
// Redirect to alt_doc.php:
t3lib_utility_Http::redirect('alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . $params);
} else {
$this->closeWindow();
}
}
}
示例12: TS_links_rte
function TS_links_rte($value)
{
$value = $this->TS_AtagToAbs($value);
// Split content by the TYPO3 pseudo tag "<link>":
$blockSplit = $this->splitIntoBlock('link', $value, 1);
foreach ($blockSplit as $k => $v) {
$error = '';
if ($k % 2) {
// block:
$tagCode = t3lib_div::unQuoteFilenames(trim(substr($this->getFirstTag($v), 0, -1)), true);
$link_param = $tagCode[1];
$href = '';
$siteUrl = $this->siteUrl();
// Parsing the typolink data. This parsing is roughly done like in tslib_content->typolink()
if (strstr($link_param, '@')) {
// mailadr
$href = 'mailto:' . preg_replace('/^mailto:/i', '', $link_param);
} elseif (substr($link_param, 0, 1) == '#') {
// check if anchor
$href = $siteUrl . $link_param;
} else {
$fileChar = intval(strpos($link_param, '/'));
$urlChar = intval(strpos($link_param, '.'));
// Detects if a file is found in site-root OR is a simulateStaticDocument.
list($rootFileDat) = explode('?', $link_param);
$rFD_fI = pathinfo($rootFileDat);
if (trim($rootFileDat) && !strstr($link_param, '/') && (@is_file(PATH_site . $rootFileDat) || t3lib_div::inList('php,html,htm', strtolower($rFD_fI['extension'])))) {
$href = $siteUrl . $link_param;
} elseif ($urlChar && (strstr($link_param, '//') || !$fileChar || $urlChar < $fileChar)) {
// url (external): If doubleSlash or if a '.' comes before a '/'.
if (!preg_match('/^[a-z]*:\\/\\//', trim(strtolower($link_param)))) {
$scheme = 'http://';
} else {
$scheme = '';
}
$href = $scheme . $link_param;
} elseif ($fileChar) {
// file (internal)
$href = $siteUrl . $link_param;
} else {
// integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to tables.php!!)
// Splitting the parameter by ',' and if the array counts more than 1 element it's a id/type/parameters triplet
$pairParts = t3lib_div::trimExplode(',', $link_param, TRUE);
$idPart = $pairParts[0];
$link_params_parts = explode('#', $idPart);
$idPart = trim($link_params_parts[0]);
$sectionMark = trim($link_params_parts[1]);
if (!strcmp($idPart, '')) {
$idPart = $this->recPid;
}
// If no id or alias is given, set it to class record pid
// Checking if the id-parameter is an alias.
if (!t3lib_div::testInt($idPart)) {
list($idPartR) = t3lib_BEfunc::getRecordsByField('pages', 'alias', $idPart);
$idPart = intval($idPartR['uid']);
}
$page = t3lib_BEfunc::getRecord('pages', $idPart);
if (is_array($page)) {
// Page must exist...
// XCLASS changed from $href = $siteUrl .'?id=' . $idPart . ($pairParts[2] ? $pairParts[2] : '') . ($sectionMark ? '#' . $sectionMark : '');
$href = $idPart . ($pairParts[2] ? $pairParts[2] : '') . ($sectionMark ? '#' . $sectionMark : '');
// linkHandler - allowing links to start with registerd linkHandler e.g.. "record:"
} elseif (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typolinkLinkHandler'][array_shift(explode(':', $link_param))])) {
$href = $link_param;
} else {
#$href = '';
$href = $siteUrl . '?id=' . $link_param;
$error = 'No page found: ' . $idPart;
}
}
}
// Setting the A-tag:
$bTag = '<a href="' . htmlspecialchars($href) . '"' . ($tagCode[2] && $tagCode[2] != '-' ? ' target="' . htmlspecialchars($tagCode[2]) . '"' : '') . ($tagCode[3] && $tagCode[3] != '-' ? ' class="' . htmlspecialchars($tagCode[3]) . '"' : '') . ($tagCode[4] ? ' title="' . htmlspecialchars($tagCode[4]) . '"' : '') . ($error ? ' rteerror="' . htmlspecialchars($error) . '" style="background-color: yellow; border:2px red solid; color: black;"' : '') . '>';
$eTag = '</a>';
$blockSplit[$k] = $bTag . $this->TS_links_rte($this->removeFirstAndLastTag($blockSplit[$k])) . $eTag;
}
}
// Return content:
return implode('', $blockSplit);
}
示例13: parseCurUrl
/**
* For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
*
* @param string HREF value tp analyse
* @param string The URL of the current website (frontend)
* @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
*/
function parseCurUrl($href, $siteUrl)
{
$href = trim($href);
if ($href) {
$info = array();
// Default is "url":
$info['value'] = $href;
$info['act'] = 'url';
$specialParts = explode('#_SPECIAL', $href);
if (count($specialParts) == 2) {
// Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
$info['value'] = '#_SPECIAL' . $specialParts[1];
$info['act'] = 'spec';
} elseif (t3lib_div::isFirstPartOfStr($href, $siteUrl)) {
// If URL is on the current frontend website:
$rel = substr($href, strlen($siteUrl));
if (file_exists(PATH_site . rawurldecode($rel))) {
// URL is a file, which exists:
$info['value'] = rawurldecode($rel);
if (@is_dir(PATH_site . $info['value'])) {
$info['act'] = 'folder';
} else {
$info['act'] = 'file';
}
} else {
// URL is a page (id parameter)
$uP = parse_url($rel);
if (!trim($uP['path'])) {
$pp = preg_split('/^id=/', $uP['query']);
$pp[1] = preg_replace('/&id=[^&]*/', '', $pp[1]);
$parameters = explode('&', $pp[1]);
$id = array_shift($parameters);
if ($id) {
// Checking if the id-parameter is an alias.
if (!t3lib_div::testInt($id)) {
list($idPartR) = t3lib_BEfunc::getRecordsByField('pages', 'alias', $id);
$id = intval($idPartR['uid']);
}
$pageRow = t3lib_BEfunc::getRecordWSOL('pages', $id);
$titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
$info['value'] = $GLOBALS['LANG']->getLL('page', 1) . " '" . htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'], $titleLen)) . "' (ID:" . $id . ($uP['fragment'] ? ', #' . $uP['fragment'] : '') . ')';
$info['pageid'] = $id;
$info['cElement'] = $uP['fragment'];
$info['act'] = 'page';
$info['query'] = $parameters[0] ? '&' . implode('&', $parameters) : '';
}
}
}
} else {
// Email link:
if (strtolower(substr($href, 0, 7)) == 'mailto:') {
$info['value'] = trim(substr($href, 7));
$info['act'] = 'mail';
}
}
$info['info'] = $info['value'];
} else {
// NO value inputted:
$info = array();
$info['info'] = $GLOBALS['LANG']->getLL('none');
$info['value'] = '';
$info['act'] = 'page';
}
// let the hook have a look
foreach ($this->hookObjects as $hookObject) {
$info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
}
return $info;
}
示例14: processSoftReferences_substTokens
/**
* Substition of softreference tokens
*
* @param string Content of field with soft reference tokens in.
* @param array Soft reference configurations
* @param string Table for which the processing occurs
* @param string UID of record from table
* @return string The input content with tokens substituted according to entries in softRefCfgs
*/
function processSoftReferences_substTokens($tokenizedContent, $softRefCfgs, $table, $uid)
{
// traverse each softref type for this field:
foreach ($softRefCfgs as $cfg) {
// Get token ID:
$tokenID = $cfg['subst']['tokenID'];
// Default is current token value:
$insertValue = $cfg['subst']['tokenValue'];
// Based on mode:
switch ((string) $this->softrefCfg[$tokenID]['mode']) {
case 'exclude':
// Exclude is a simple passthrough of the value
break;
case 'editable':
// Editable always picks up the value from this input array:
$insertValue = $this->softrefInputValues[$tokenID];
break;
default:
// Mapping IDs/creating files: Based on type, look up new value:
switch ((string) $cfg['subst']['type']) {
case 'db':
default:
// Trying to map database element if found in the mapID array:
list($tempTable, $tempUid) = explode(':', $cfg['subst']['recordRef']);
if (isset($this->import_mapId[$tempTable][$tempUid])) {
$insertValue = t3lib_BEfunc::wsMapId($tempTable, $this->import_mapId[$tempTable][$tempUid]);
// Look if reference is to a page and the original token value was NOT an integer - then we assume is was an alias and try to look up the new one!
if ($tempTable === 'pages' && !t3lib_div::testInt($cfg['subst']['tokenValue'])) {
$recWithUniqueValue = t3lib_BEfunc::getRecord($tempTable, $insertValue, 'alias');
if ($recWithUniqueValue['alias']) {
$insertValue = $recWithUniqueValue['alias'];
}
}
}
break;
break;
case 'file':
// Create / Overwrite file:
$insertValue = $this->processSoftReferences_saveFile($cfg['subst']['relFileName'], $cfg, $table, $uid);
break;
}
break;
}
// Finally, swap the soft reference token in tokenized content with the insert value:
$tokenizedContent = str_replace('{softref:' . $tokenID . '}', $insertValue, $tokenizedContent);
}
return $tokenizedContent;
}
示例15: typoLink
/**
* Implements the "typolink" property of stdWrap (and others)
* Basically the input string, $linktext, is (typically) wrapped in a <a>-tag linking to some page, email address, file or URL based on a parameter defined by the configuration array $conf.
* This function is best used from internal functions as is. There are some API functions defined after this function which is more suited for general usage in external applications.
* Generally the concept "typolink" should be used in your own applications as an API for making links to pages with parameters and more. The reason for this is that you will then automatically make links compatible with all the centralized functions for URL simulation and manipulation of parameters into hashes and more.
* For many more details on the parameters and how they are intepreted, please see the link to TSref below.
*
* @param string $linktxt The string (text) to link
* @param array $conf TypoScript configuration (see link below)
* @param tslib_cObj $cObj
* @return string A link-wrapped string.
* @see stdWrap(), tslib_pibase::pi_linkTP()
* @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=321&cHash=59bd727a5e
*/
function typoLink($linktxt, $conf, $cObj = NULL)
{
$finalTagParts = array();
// If called from media link handler, use the reference of the passed cObj
if (!is_object($this->cObj)) {
$this->cObj = $cObj;
}
$link_param = trim($this->cObj->stdWrap($conf['parameter'], $conf['parameter.']));
$initP = '?id=' . $GLOBALS['TSFE']->id . '&type=' . $GLOBALS['TSFE']->type;
$this->cObj->lastTypoLinkUrl = '';
$this->cObj->lastTypoLinkTarget = '';
if ($link_param) {
$link_paramA = t3lib_div::unQuoteFilenames($link_param, TRUE);
$link_param = trim($link_paramA[0]);
// Link parameter value
$linkClass = trim($link_paramA[2]);
// Link class
if ($linkClass === '-') {
$linkClass = '';
}
// The '-' character means 'no class'. Necessary in order to specify a title as fourth parameter without setting the target or class!
$forceTarget = trim($link_paramA[1]);
// Target value
$forceTitle = trim($link_paramA[3]);
// Title value
if ($forceTarget === '-') {
$forceTarget = '';
}
// The '-' character means 'no target'. Necessary in order to specify a class as third parameter without setting the target!
// Check, if the target is coded as a JS open window link:
$JSwindowParts = array();
$JSwindowParams = '';
$onClick = '';
if ($forceTarget && preg_match('/^([0-9]+)x([0-9]+)(:(.*)|.*)$/', $forceTarget, $JSwindowParts)) {
// Take all pre-configured and inserted parameters and compile parameter list, including width+height:
$JSwindow_tempParamsArr = t3lib_div::trimExplode(',', strtolower($conf['JSwindow_params'] . ',' . $JSwindowParts[4]), TRUE);
$JSwindow_paramsArr = array();
foreach ($JSwindow_tempParamsArr as $JSv) {
list($JSp, $JSv) = explode('=', $JSv);
$JSwindow_paramsArr[$JSp] = $JSp . '=' . $JSv;
}
// Add width/height:
$JSwindow_paramsArr['width'] = 'width=' . $JSwindowParts[1];
$JSwindow_paramsArr['height'] = 'height=' . $JSwindowParts[2];
// Imploding into string:
$JSwindowParams = implode(',', $JSwindow_paramsArr);
$forceTarget = '';
// Resetting the target since we will use onClick.
}
// Internal target:
$target = isset($conf['target']) ? $conf['target'] : $GLOBALS['TSFE']->intTarget;
if ($conf['target.']) {
$target = $this->cObj->stdWrap($target, $conf['target.']);
}
// Checking if the id-parameter is an alias.
if (version_compare(TYPO3_version, '4.6.0', '>=')) {
$isInteger = t3lib_utility_Math::canBeInterpretedAsInteger($link_param);
} else {
$isInteger = t3lib_div::testInt($link_param);
}
if (!$isInteger) {
$GLOBALS['TT']->setTSlogMessage("tx_dam_tsfemediatag->typolink(): File id '" . $link_param . "' is not an integer, so '" . $linktxt . "' was not linked.", 1);
return $linktxt;
}
if (!is_object($media = tx_dam::media_getByUid($link_param))) {
$GLOBALS['TT']->setTSlogMessage("tx_dam_tsfemediatag->typolink(): File id '" . $link_param . "' was not found, so '" . $linktxt . "' was not linked.", 1);
return $linktxt;
}
if (!$media->isAvailable) {
$GLOBALS['TT']->setTSlogMessage("tx_dam_tsfemediatag->typolink(): File '" . $media->getPathForSite() . "' (" . $link_param . ") did not exist, so '" . $linktxt . "' was not linked.", 1);
return $linktxt;
}
$meta = $media->getMetaArray();
if (is_array($this->conf['procFields.'])) {
foreach ($this->conf['procFields.'] as $field => $fieldConf) {
if (substr($field, -1, 1) === '.') {
$fN = substr($field, 0, -1);
} else {
$fN = $field;
$fieldConf = array();
}
$meta[$fN] = $media->getContent($fN, $fieldConf);
}
}
$this->addMetaToData($meta);
// Title tag
//.........这里部分代码省略.........