本文整理汇总了PHP中t3lib_div类的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div类的具体用法?PHP t3lib_div怎么用?PHP t3lib_div使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了t3lib_div类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renders <f:then> child if BE user is allowed to edit given table, otherwise renders <f:else> child.
*
* @param string $table Name of the table
* @return string the rendered string
* @api
*/
public function render($table)
{
if ($GLOBALS['BE_USER']->isAdmin() || t3lib_div::inList($GLOBALS['BE_USER']->groupData['tables_modify'], $table)) {
return $this->renderThenChild();
}
return $this->renderElseChild();
}
示例2: __construct
/**
* constructor
*
* @param Tx_CzSimpleCal_Domain_Repository_EventRepository $eventRepository
* @param Tx_CzSimpleCal_Domain_Repository_EventIndexRepository $eventIndexRepository
* @param Tx_Extbase_Persistence_ManagerInterface $persistenceManager
*/
public function __construct(Tx_CzSimpleCal_Domain_Repository_EventRepository $eventRepository, Tx_CzSimpleCal_Domain_Repository_EventIndexRepository $eventIndexRepository, Tx_Extbase_Persistence_ManagerInterface $persistenceManager)
{
t3lib_div::makeInstance('Tx_Extbase_Dispatcher');
$this->eventRepository = $eventRepository;
$this->eventIndexRepository = $eventIndexRepository;
$this->persistenceManager = $persistenceManager;
}
示例3: main
/**
* Processing of clickmenu items
*
* @param object Reference to parent
* @param array Menu items array to modify
* @param string Table name
* @param integer Uid of the record
* @return array Menu item array, returned after modification
* @todo Skinning for icons...
*/
function main(&$backRef, $menuItems, $table, $uid)
{
global $BE_USER, $TCA;
$localItems = array();
if ($backRef->cmLevel && t3lib_div::_GP('subname') == 'moreoptions' || $table === 'pages' && $uid == 0) {
// Show import/export on second level menu OR root level.
$LL = $this->includeLL();
$modUrl = $backRef->backPath . t3lib_extMgm::extRelPath('impexp') . 'app/index.php';
$url = $modUrl . '?tx_impexp[action]=export&id=' . ($table == 'pages' ? $uid : $backRef->rec['pid']);
if ($table == 'pages') {
$url .= '&tx_impexp[pagetree][id]=' . $uid;
$url .= '&tx_impexp[pagetree][levels]=0';
$url .= '&tx_impexp[pagetree][tables][]=_ALL';
} else {
$url .= '&tx_impexp[record][]=' . rawurlencode($table . ':' . $uid);
$url .= '&tx_impexp[external_ref][tables][]=_ALL';
}
$localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('export', $LL)), $backRef->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-export-t3d')), $backRef->urlRefForCM($url), 1);
if ($table == 'pages') {
$url = $modUrl . '?id=' . $uid . '&table=' . $table . '&tx_impexp[action]=import';
$localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('import', $LL)), $backRef->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-import-t3d')), $backRef->urlRefForCM($url), 1);
}
}
return array_merge($menuItems, $localItems);
}
示例4: autoPublishWorkspaces
/**
* This method is called by the Scheduler task that triggers
* the autopublication process
* It searches for workspaces whose publication date is in the past
* and publishes them
*
* @return void
*/
public function autoPublishWorkspaces()
{
global $TYPO3_CONF_VARS;
// Temporarily set admin rights
// FIXME: once workspaces are cleaned up a better solution should be implemented
$currentAdminStatus = $GLOBALS['BE_USER']->user['admin'];
$GLOBALS['BE_USER']->user['admin'] = 1;
// Select all workspaces that needs to be published / unpublished:
$workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,swap_modes,publish_time,unpublish_time', 'sys_workspace', 'pid=0
AND
((publish_time!=0 AND publish_time<=' . intval($GLOBALS['EXEC_TIME']) . ')
OR (publish_time=0 AND unpublish_time!=0 AND unpublish_time<=' . intval($GLOBALS['EXEC_TIME']) . '))' . t3lib_BEfunc::deleteClause('sys_workspace'));
$workspaceService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
foreach ($workspaces as $rec) {
// First, clear start/end time so it doesn't get select once again:
$fieldArray = $rec['publish_time'] != 0 ? array('publish_time' => 0) : array('unpublish_time' => 0);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_workspace', 'uid=' . intval($rec['uid']), $fieldArray);
// Get CMD array:
$cmd = $workspaceService->getCmdArrayForPublishWS($rec['uid'], $rec['swap_modes'] == 1);
// $rec['swap_modes']==1 means that auto-publishing will swap versions, not just publish and empty the workspace.
// Execute CMD array:
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = 0;
$tce->start(array(), $cmd);
$tce->process_cmdmap();
}
// Restore admin status
$GLOBALS['BE_USER']->user['admin'] = $currentAdminStatus;
}
示例5: __construct
/**
* constructor for class Tx_Solr_ViewHelper_Date
*/
public function __construct(array $arguments = array())
{
if (is_null($this->dateFormat) || is_null($this->contentObject)) {
$this->dateFormat = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['general.']['dateFormat.'];
$this->contentObject = t3lib_div::makeInstance('tslib_cObj');
}
}
示例6: getResultReturnsAllResults
/**
* @test
*/
public function getResultReturnsAllResults()
{
$request = t3lib_div::makeInstance('Tx_Solr_IndexQueue_PageIndexerResponse');
$request->addActionResult('action1', 'result1');
$request->addActionResult('action2', 'result2');
$this->assertEquals(array('action1' => 'result1', 'action2' => 'result2'), $request->getActionResult());
}
示例7: _render
function _render($conf)
{
require_once PATH_formidable . "api/class.tx_ameosformidable.php";
$this->oForm = t3lib_div::makeInstance("tx_ameosformidable");
$this->oForm->initFromTs($this, $conf);
return $this->oForm->render();
}
示例8: isIpInRange
/**
* Check if the remote IP is the allowed range.
* Supports IPv4 and IPv6.
*
* @param string $strIp remote IP address
* @param boolean $bIpv4 If the IP is IPv4 (if not, it's IPv6)
* @param string $strRange Defined range. Comma-separated list of IPs.
* * supported for parts of the address.
*
* @return boolean True if the IP is in the range
*/
protected function isIpInRange($strIp, $bIpv4, $strRange)
{
if ($bIpv4) {
return t3lib_div::cmpIPv4($strIp, $strRange);
}
return t3lib_div::cmpIPv6($strIp, $strRange);
}
示例9: render_clickenlarge
/**
* Rendering the "clickenlarge" custom attribute, called from TypoScript
*
* @param string Content input. Not used, ignore.
* @param array TypoScript configuration
* @return string HTML output.
* @access private
*/
function render_clickenlarge($content, $conf)
{
$clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
$path = $this->cObj->parameters['src'];
$pathPre = $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] . 'RTEmagicC_';
if (t3lib_div::isFirstPartOfStr($path, $pathPre)) {
// Find original file:
$pI = pathinfo(substr($path, strlen($pathPre)));
$filename = substr($pI['basename'], 0, -strlen('.' . $pI['extension']));
$file = $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] . 'RTEmagicP_' . $filename;
} else {
$file = $this->cObj->parameters['src'];
}
unset($this->cObj->parameters['clickenlarge']);
unset($this->cObj->parameters['allParams']);
$content = '<img ' . t3lib_div::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;
}
示例10: getAllowedActions
public function getAllowedActions($config)
{
$pid = $config['row']['pid'];
$tsConfig = t3lib_befunc::getPagesTSconfig($pid);
$flexConfig =& $tsConfig['options.']['cz_simple_cal_pi1.']['flexform.'];
if (empty($flexConfig) || !isset($flexConfig['allowedActions.'])) {
return;
}
$allowedActions = array();
if (isset($flexConfig['allowedActions'])) {
$enabled = array();
foreach (t3lib_div::trimExplode(',', $flexConfig['allowedActions'], true) as $i) {
$enabled[$i . '.'] = '';
}
$allowedActions = array_intersect_key($flexConfig['allowedActions.'], $enabled);
} else {
$allowedActions = $flexConfig['allowedActions.'];
}
foreach ($allowedActions as $name => $action) {
$name = rtrim($name, '.');
$label = $GLOBALS['LANG']->sL($action['label']);
if (empty($label)) {
$label = $name;
}
$config['items'][$name] = array($label, $name);
}
}
示例11: process
/**
* Logs the given values.
*
* @return void
*/
public function process()
{
//set params
$table = "tx_formhandler_log";
$fields['ip'] = t3lib_div::getIndpEnv('REMOTE_ADDR');
if (isset($this->settings['disableIPlog']) && intval($this->settings['disableIPlog']) == 1) {
$fields['ip'] = NULL;
}
$fields['tstamp'] = time();
$fields['crdate'] = time();
$fields['pid'] = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'pid');
if (!$fields['pid']) {
$fields['pid'] = $GLOBALS['TSFE']->id;
}
ksort($this->gp);
$keys = array_keys($this->gp);
$serialized = serialize($this->gp);
$hash = md5(serialize($keys));
$fields['params'] = $serialized;
$fields['key_hash'] = $hash;
if (intval($this->settings['markAsSpam']) == 1) {
$fields['is_spam'] = 1;
}
//query the database
$res = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $fields);
$insertedUID = $GLOBALS['TYPO3_DB']->sql_insert_id();
$sessionValues = array('inserted_uid' => $insertedUID, 'inserted_tstamp' => $fields['tstamp'], 'key_hash' => $hash);
Tx_Formhandler_Globals::$session->setMultiple($sessionValues);
if (!$this->settings['nodebug']) {
Tx_Formhandler_StaticFuncs::debugMessage('logging', array($table, implode(',', $fields)));
if (strlen($GLOBALS['TYPO3_DB']->sql_error()) > 0) {
Tx_Formhandler_StaticFuncs::debugMessage('error', array($GLOBALS['TYPO3_DB']->sql_error()), 3);
}
}
}
示例12: render
/**
* Render the facebook like viewhelper
*
* @return string
*/
public function render()
{
$code = '';
$url = !empty($this->arguments['href']) ? $this->arguments['href'] : t3lib_div::getIndpEnv('TYPO3_REQUEST_URL');
// absolute urls are needed
$this->tag->addAttribute('href', Tx_News_Utility_Url::prependDomain($url));
$this->tag->forceClosingTag(TRUE);
// -1 means no JS
if ($this->arguments['javaScript'] != '-1') {
if (empty($this->arguments['javaScript'])) {
$tsSettings = $this->pluginSettingsService->getSettings();
$locale = !empty($tsSettings['facebookLocale']) ? $tsSettings['facebookLocale'] : 'en_US';
$code = '<script src="http://connect.facebook.net/' . $locale . '/all.js#xfbml=1"></script>';
// Social interaction Google Analytics
if ($this->pluginSettingsService->getByPath('analytics.social.facebookLike') == 1) {
$code .= t3lib_div::wrapJS("\n\t\t\t\t\t\tFB.Event.subscribe('edge.create', function(targetUrl) {\n\t\t\t\t\t\t \t_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tFB.Event.subscribe('edge.remove', function(targetUrl) {\n\t\t\t\t\t\t _gaq.push(['_trackSocial', 'facebook', 'unlike', targetUrl]);\n\t\t\t\t\t\t});\n\t\t\t\t\t");
}
} else {
$code = '<script src="' . htmlspecialchars($this->arguments['javaScript']) . '"></script>';
}
}
// seems as if a div with id fb-root is needed this is just a dirty
// workaround to make things work again Perhaps we should
// use the iframe variation.
$code .= '<div id="fb-root"></div>' . $this->tag->render();
return $code;
}
示例13: getDevMode
public static function getDevMode()
{
if (self::$devMode === null) {
self::$devMode = t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
}
return self::$devMode;
}
示例14: setCache
/**
* Initializes the identifier prefix when setting the cache.
*
* @param t3lib_cache_frontend_Frontend $cache The frontend for this backend
* @return void
* @author Robert Lemke <robert@typo3.org>
*/
public function setCache(t3lib_cache_frontend_Frontend $cache)
{
parent::setCache($cache);
$processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default');
$pathHash = t3lib_div::shortMD5(PATH_site . $processUser['name'], 12);
$this->identifierPrefix = 'TYPO3_' . $pathHash;
}
示例15: generateExtensionFromVersion1Configuration
/**
* This test creates an extension based on a JSON file, generated
* with version 1.0 of the ExtensionBuilder and compares all
* generated files with the originally created ones
* This test should help, to find compatibility breaking changes
*
* @test
*/
function generateExtensionFromVersion1Configuration()
{
$this->configurationManager = $this->getMock($this->buildAccessibleProxy('Tx_ExtensionBuilder_Configuration_ConfigurationManager'), array('dummy'));
$this->extensionSchemaBuilder = $this->objectManager->get('Tx_ExtensionBuilder_Service_ExtensionSchemaBuilder');
$testExtensionDir = PATH_typo3conf . 'ext/extension_builder/Tests/Examples/TestExtensions/test_extension_v1/';
$jsonFile = $testExtensionDir . Tx_ExtensionBuilder_Configuration_ConfigurationManager::EXTENSION_BUILDER_SETTINGS_FILE;
if (file_exists($jsonFile)) {
// compatibility adaptions for configurations from older versions
$extensionConfigurationJSON = json_decode(file_get_contents($jsonFile), TRUE);
$extensionConfigurationJSON = $this->configurationManager->fixExtensionBuilderJSON($extensionConfigurationJSON);
} else {
$this->fail('JSON file not found');
}
$this->extension = $this->extensionSchemaBuilder->build($extensionConfigurationJSON);
$this->codeGenerator->setSettings(array('codeTemplateRootPath' => PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/', 'extConf' => array('enableRoundtrip' => '0')));
$newExtensionDir = vfsStream::url('testDir') . '/';
$this->extension->setExtensionDir($newExtensionDir . 'test_extension/');
$this->codeGenerator->build($this->extension);
$referenceFiles = t3lib_div::getAllFilesAndFoldersInPath(array(), $testExtensionDir);
foreach ($referenceFiles as $referenceFile) {
$createdFile = str_replace($testExtensionDir, $this->extension->getExtensionDir(), $referenceFile);
if (!in_array(basename($createdFile), array('ExtensionBuilder.json'))) {
// json file is generated by controller
$referenceFileContent = str_replace(array('2011-08-11', '###YEAR###'), array(date('Y-m-d'), date('Y')), file_get_contents($referenceFile));
//t3lib_div::writeFile(PATH_site.'fileadmin/'.basename($createdFile), file_get_contents($createdFile));
$this->assertFileExists($createdFile, 'File ' . $createdFile . ' was not created!');
$this->assertEquals(t3lib_div::trimExplode("\n", $referenceFileContent, TRUE), t3lib_div::trimExplode("\n", file_get_contents($createdFile), TRUE), 'File ' . $createdFile . ' was not equal to original file.');
}
}
}