示例#1
0
 /**
  * Renders Lorem Ipsum paragraphs. If $lipsum is provided it
  * will be used as source text. If not provided as an argument
  * or as inline argument, $lipsum is fetched from TypoScript settings.
  *
  * @param string $lipsum String of paragraphs file path or EXT:myext/path/to/file
  * @return string
  */
 public function render($lipsum = NULL)
 {
     if (strlen($lipsum) === 0) {
         $this->getDefaultLoremIpsum();
     }
     if (strlen($lipsum) < 255 && !preg_match('/[^a-z0-9_\\./]/i', $lipsum)) {
         // argument is most likely a file reference.
         $sourceFile = t3lib_div::getFileAbsFileName($lipsum);
         if (file_exists($sourceFile) === TRUE) {
             $lipsum = file_get_contents($sourceFile);
         } else {
             t3lib_div::sysLog('Vhs LipsumViewHelper was asked to load Lorem Ipsum from a file which does not exist. ' . 'The file was: ' . $sourceFile, 'Vhs');
             $lipsum = $this->getDefaultLoremIpsum();
         }
     }
     $lipsum = preg_replace('/[\\r\\n]{1,}/i', "\n", $lipsum);
     $paragraphs = explode("\n", $lipsum);
     $paragraphs = array_slice($paragraphs, 0, intval($settings['paragraphs']));
     foreach ($paragraphs as $index => $paragraph) {
         $length = $settings['wordsPerParagraph'] + rand(0 - intval($settings['skew']), intval($settings['skew']));
         $words = explode(' ', $paragraph);
         $paragraphs[$index] = implode(' ', array_slice($words, 0, $length));
     }
     $lipsum = implode("\n", $paragraphs);
     if ((bool) $settings['html'] === TRUE) {
         $lipsum = $this->contentObject->parseFunc($lipsum, array(), '< ' . $settings['parseFuncTSPath']);
     }
     return $lipsum;
 }
 /**
  * Returns array of system languages
  * @param	integer		page id (only used to get TSconfig configuration setting flag and label for default language)
  * @param	string		Backpath for flags
  * @return	array
  */
 function getSystemLanguages($page_id = 0, $backPath = '')
 {
     global $TCA, $LANG;
     // Icons and language titles:
     t3lib_div::loadTCA('sys_language');
     $flagAbsPath = t3lib_div::getFileAbsFileName($TCA['sys_language']['columns']['flag']['config']['fileFolder']);
     $flagIconPath = $backPath . '../' . substr($flagAbsPath, strlen(PATH_site));
     $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($page_id, 'mod.SHARED');
     $languageIconTitles = array();
     // Set default:
     $languageIconTitles[0] = array('uid' => 0, 'title' => strlen($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $LANG->getLL('defaultLanguage') . ')' : $LANG->getLL('defaultLanguage'), 'ISOcode' => 'DEF', 'flagIcon' => strlen($modSharedTSconfig['properties']['defaultLanguageFlag']) && @is_file($flagAbsPath . $modSharedTSconfig['properties']['defaultLanguageFlag']) ? $flagIconPath . $modSharedTSconfig['properties']['defaultLanguageFlag'] : null);
     // Set "All" language:
     $languageIconTitles[-1] = array('uid' => -1, 'title' => $LANG->getLL('multipleLanguages'), 'ISOcode' => 'DEF', 'flagIcon' => $flagIconPath . 'multi-language.gif');
     // Find all system languages:
     $sys_languages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_language', '');
     foreach ($sys_languages as $row) {
         $languageIconTitles[$row['uid']] = $row;
         if ($row['static_lang_isocode'] && t3lib_extMgm::isLoaded('static_info_tables')) {
             $staticLangRow = t3lib_BEfunc::getRecord('static_languages', $row['static_lang_isocode'], 'lg_iso_2');
             if ($staticLangRow['lg_iso_2']) {
                 $languageIconTitles[$row['uid']]['ISOcode'] = $staticLangRow['lg_iso_2'];
             }
         }
         if (strlen($row['flag'])) {
             $languageIconTitles[$row['uid']]['flagIcon'] = @is_file($flagAbsPath . $row['flag']) ? $flagIconPath . $row['flag'] : '';
         }
     }
     return $languageIconTitles;
 }
示例#3
0
 public function main()
 {
     $out = '';
     $conf = $this->getModule()->getConfigurations();
     $file = t3lib_div::getFileAbsFileName($conf->get($this->getConfId() . 'template'));
     $templateCode = t3lib_div::getURL($file);
     if (!$templateCode) {
         return $conf->getLL('msg_template_not_found') . '<br />File: \'' . $file . '\'<br />ConfId: \'' . $this->getConfId() . 'template\'';
     }
     $subpart = '###' . strtoupper($this->getFuncId()) . '###';
     $template = tx_rnbase_util_Templates::getSubpart($templateCode, $subpart);
     if (!$template) {
         return $conf->getLL('msg_subpart_not_found') . ': ' . $subpart;
     }
     $start = microtime(TRUE);
     $memStart = memory_get_usage();
     $out .= $this->getContent($template, $conf, $conf->getFormatter(), $this->getModule()->getFormTool());
     if (tx_rnbase_util_BaseMarker::containsMarker($out, 'MOD_')) {
         $markerArr = array();
         $memEnd = memory_get_usage();
         $markerArr['###MOD_PARSETIME###'] = microtime(TRUE) - $start;
         $markerArr['###MOD_MEMUSED###'] = $memEnd - $memStart;
         $markerArr['###MOD_MEMSTART###'] = $memStart;
         $markerArr['###MOD_MEMEND###'] = $memEnd;
         $out = tx_rnbase_util_Templates::substituteMarkerArrayCached($out, $markerArr);
     }
     return $out;
 }
 /**
  * Lädt ein COnfigurations Objekt nach mit der TS aus der Extension
  * Dabei wird alles geholt was in "plugin.tx_$extKey", "lib.$extKey." und
  * "lib.links." liegt
  *
  * @param string $extKey Extension, deren TS Config geladen werden soll
  * @param string $extKeyTS Extension, deren Konfig innerhalb der
  *     TS Config geladen werden soll.
  *     Es kann also zb. das TS von mklib geladen werden aber darin die konfig für
  *     das plugin von mkxyz
  * @param string $sStaticPath pfad zum TS
  * @param array $aConfig zusätzliche Konfig, die die default  überschreibt
  * @param boolean $resolveReferences sollen referenzen die in lib.
  *     und plugin.tx_$extKeyTS stehen aufgelöst werden?
  * @param boolean $forceTsfePreparation
  * @return tx_rnbase_configurations
  */
 public static function loadConfig4BE($extKey, $extKeyTs = null, $sStaticPath = '', $aConfig = array(), $resolveReferences = false, $forceTsfePreparation = false)
 {
     $extKeyTs = is_null($extKeyTs) ? $extKey : $extKeyTs;
     if (!$sStaticPath) {
         $sStaticPath = '/static/ts/setup.txt';
     }
     if (file_exists(t3lib_div::getFileAbsFileName('EXT:' . $extKey . $sStaticPath))) {
         t3lib_extMgm::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $extKey . $sStaticPath . '">');
     }
     tx_rnbase::load('tx_rnbase_configurations');
     tx_rnbase::load('tx_rnbase_util_Misc');
     $tsfePreparationOptions = array();
     if ($forceTsfePreparation) {
         $tsfePreparationOptions['force'] = true;
     }
     // Ist bei Aufruf aus BE notwendig! (@TODO: sicher???)
     tx_rnbase_util_Misc::prepareTSFE($tsfePreparationOptions);
     $GLOBALS['TSFE']->config = array();
     $cObj = t3lib_div::makeInstance('tslib_cObj');
     $pageTsConfig = self::getPagesTSconfig(0);
     $tempConfig = $pageTsConfig['plugin.']['tx_' . $extKeyTs . '.'];
     $tempConfig['lib.'][$extKeyTs . '.'] = $pageTsConfig['lib.'][$extKeyTs . '.'];
     $tempConfig['lib.']['links.'] = $pageTsConfig['lib.']['links.'];
     if ($resolveReferences) {
         $GLOBALS['TSFE']->tmpl->setup['lib.'][$extKeyTs . '.'] = $tempConfig['lib.'][$extKeyTs . '.'];
         $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_' . $extKeyTs . '.'] = $pageTsConfig['plugin.']['tx_' . $extKeyTs . '.'];
     }
     $pageTsConfig = $tempConfig;
     $qualifier = $pageTsConfig['qualifier'] ? $pageTsConfig['qualifier'] : $extKeyTs;
     // möglichkeit die default konfig zu überschreiben
     $pageTsConfig = t3lib_div::array_merge_recursive_overrule($pageTsConfig, $aConfig);
     $configurations = new tx_rnbase_configurations();
     $configurations->init($pageTsConfig, $cObj, $extKeyTs, $qualifier);
     return $configurations;
 }
 /**
  * Factory method which creates the specified cache along with the specified kind of backend.
  * After creating the cache, it will be registered at the cache manager.
  *
  * @param string $cacheIdentifier The name / identifier of the cache to create
  * @param string $cacheName Name of the cache frontend
  * @param string $backendName Name of the cache backend
  * @param array $backendOptions (optional) Array of backend options
  * @return t3lib_cache_frontend_Frontend The created cache frontend
  * @author Robert Lemke <*****@*****.**>
  */
 public function create($cacheIdentifier, $cacheName, $backendName, array $backendOptions = array())
 {
     // loading the cache backend file and class
     list($backendFile, $backendClassReference) = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackends'][$backendName]);
     $backendRequireFile = t3lib_div::getFileAbsFileName($backendFile);
     if ($backendRequireFile) {
         t3lib_div::requireOnce($backendRequireFile);
     }
     $backend = t3lib_div::makeInstance($backendClassReference, $backendOptions);
     if (!$backend instanceof t3lib_cache_backend_Backend) {
         throw new t3lib_cache_exception_InvalidCache('"' . $backendName . '" is not a valid cache backend.', 1216304301);
     }
     // loading the cache frontend file and class
     list($cacheFile, $cacheClassReference) = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheFrontends'][$cacheName]);
     $cacheRequireFile = t3lib_div::getFileAbsFileName($cacheFile);
     if ($cacheRequireFile) {
         t3lib_div::requireOnce($cacheRequireFile);
     }
     $cache = t3lib_div::makeInstance($cacheClassReference, $cacheIdentifier, $backend);
     if (!$cache instanceof t3lib_cache_frontend_Frontend) {
         throw new t3lib_cache_exception_InvalidCache('"' . $cacheName . '" is not a valid cache.', 1216304300);
     }
     $this->cacheManager->registerCache($cache);
     return $cache;
 }
 /**
  * The main method of the PlugIn
  *
  * @param	string		$content: The PlugIn content
  * @param	array		$conf: The PlugIn configuration
  * @return	The content that is displayed on the website
  */
 function main($content, $conf)
 {
     $this->conf = $conf;
     $this->bootstrap();
     $yahooapi = new yahooApiResolver();
     $yahooapi->setUnit($this->conf["unit"]);
     $yahooapi->setTimeout($this->conf["timeout"]);
     $yahooapi->setLocationCode($this->conf["location"]);
     //Configure API Cache
     $yahooapi->setCacheTime($this->conf["cacheTime"]);
     $yahooapi->setCachePath(t3lib_div::getFileAbsFileName("uploads/tx_adicoweather"));
     $yahooapi->setCacheName("apicache_" . substr($this->conf["crc"], 0, 10) . ".json");
     //Enable/Disable API Cache
     $yahooapi->enableCache($this->conf["enableCache"]);
     $api_result = $yahooapi->getWeatherData();
     if (!$api_result) {
         $result = $this->renderWeather(array(), false);
     } else {
         $result = $this->renderWeather($this->buildMarkerArray($api_result), true);
     }
     if ($conf['removeWrapInBaseClass'] == 1) {
         return $result;
     } else {
         return $this->pi_wrapInBaseClass($result);
     }
 }
 /**
  * 
  * @return string
  */
 public function indexAction()
 {
     try {
         $options = $this->widgetConfiguration['options'];
         $apiKey = $this->widgetConfiguration['apiKey'];
         if (!empty($this->widgetConfiguration['templatePathAndName'])) {
             $this->view->setTemplatePathAndFilename(t3lib_div::getFileAbsFileName($this->widgetConfiguration['templatePathAndName']));
         }
         $flickr = new Tx_T3orgFlickrfeed_Utility_Flickr($apiKey);
         if ($this->widgetConfiguration['type'] == 1 || $this->widgetConfiguration['type'] === 'tag') {
             // tagSearch
             $this->view->assign('result', $flickr->tagSearch($this->widgetConfiguration['tags'], $options));
             if (is_array($this->widgetConfiguration['tags']) || $this->widgetConfiguration['tags'] instanceof Traversable) {
                 $tags = $this->widgetConfiguration['tags'];
             } else {
                 $tags = t3lib_div::trimExplode(',', $this->widgetConfiguration['tags'], true);
             }
             $this->view->assign('tags', $tags);
         } elseif ($this->widgetConfiguration['type'] == 2 || $this->widgetConfiguration['type'] === 'user') {
             // people.getPublicPhotos
             $this->view->assign('result', $flickr->userSearch($this->widgetConfiguration['user_id'], $options));
         } else {
             $this->view->assign('result', $flickr->groupPoolGetPhotos($this->widgetConfiguration['group_id'], $options));
         }
     } catch (Exception $e) {
         t3lib_div::sysLog($e->getMessage(), $this->request->getControllerExtensionKey(), LOG_ERR);
         $this->view->assign('error', $e->getMessage());
     }
 }
 /**
  * Method to render the view.
  *
  * @return string html content
  */
 public function render()
 {
     ob_start();
     $this->template = t3lib_div::getFileAbsFileName($this->template);
     include $this->template;
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
 protected function initializeView(Tx_Extbase_MVC_View_ViewInterface $view)
 {
     if (array_key_exists('templatePath', $this->settings) && !empty($this->settings['templatePath'])) {
         $rootPath = t3lib_div::getFileAbsFileName($this->settings['templatePath']);
         $this->view->setTemplateRootPath($rootPath . '/Templates');
         $this->view->setPartialRootPath($rootPath . '/Partials');
         $this->view->setLayoutRootPath($rootPath . '/Layout');
     }
 }
 function processOutput()
 {
     if ($GLOBALS['TSFE']->type != $GLOBALS['pdf_generator2_parameters']['typeNum']) {
         parent::processOutput();
     } else {
         $_params = array('pObj' => &$this);
         require_once t3lib_div::getFileAbsFileName('EXT:pdf_generator2/class.tx_pdfgenerator2.php');
         t3lib_div::callUserFunction("tx_pdfgenerator2->tslib_fe_processOutput", $_params, $this);
     }
 }
 /**
  * Initialize the action and get correct configuration
  *
  * @return void
  */
 public function initializeAction()
 {
     $this->objects = $this->widgetConfiguration['objects'];
     $this->configuration = t3lib_div::array_merge_recursive_overrule($this->configuration, (array) $this->widgetConfiguration['configuration'], TRUE);
     $this->numberOfPages = (int) ceil(count($this->objects) / (int) $this->configuration['itemsPerPage']);
     $this->pagesBefore = (int) $this->configuration['pagesBefore'];
     $this->pagesAfter = (int) $this->configuration['pagesAfter'];
     $this->lessPages = (bool) $this->configuration['lessPages'];
     $this->forcedNumberOfLinks = (int) $this->configuration['forcedNumberOfLinks'];
     $this->templatePath = t3lib_div::getFileAbsFileName($this->configuration['templatePath']);
 }
示例#12
0
 /**
  * Translates an array of paths or single path into absolute paths/path
  *
  * @param mixed $path
  * @return mixed
  */
 public function translatePath($path)
 {
     if (is_array($path) == FALSE) {
         return t3lib_div::getFileAbsFileName($path);
     } else {
         foreach ($path as $key => $subPath) {
             $path[$key] = self::translatePath($subPath);
         }
     }
     return $path;
 }
 function _getPathReload()
 {
     if (($sPath = $this->_navConf("/reloadpic/")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($sPath)) {
             $sPath = $this->callRunneable($sPath);
         }
         if (t3lib_div::isFirstPartOfStr($sPath, "EXT:")) {
             $sPath = t3lib_div::getIndpEnv("TYPO3_SITE_URL") . str_replace(t3lib_div::getIndpEnv("TYPO3_DOCUMENT_ROOT"), "", t3lib_div::getFileAbsFileName($sPath));
         }
     }
     return $sPath;
 }
 /**
  *
  * @param string $lang
  * @return string
  */
 public static function getFlagIconFileForLanguage($flagName)
 {
     $flag = null;
     if (!strlen($flagName)) {
         $flagName = 'unknown';
     }
     // same dirty trick as for #17286 in Core
     if (is_file(t3lib_div::getFileAbsFileName('EXT:t3skin/images/flags/' . $flagName . '.png', FALSE))) {
         // resolving extpath on its own because otherwise this might not return a relative path
         $flag = $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('t3skin') . '/images/flags/' . $flagName . '.png';
     }
     return $flag;
 }
示例#15
0
 /**
  * Render method
  *
  * @return string
  */
 public function render()
 {
     $file = t3lib_div::getFileAbsFileName($this->arguments['file']);
     $directory = $this->arguments['directory'];
     $evaluation = FALSE;
     if (isset($this->arguments['file'])) {
         $evaluation = (file_exists($file) || file_exists(PATH_site . $file)) && is_file($file);
     } elseif (isset($this->arguments['directory'])) {
         $evaluation = is_dir($directory) || is_dir(PATH_site . $directory);
     }
     if ($evaluation !== FALSE) {
         return $this->renderThenChild();
     }
     return $this->renderElseChild();
 }
示例#16
0
 /**
  * Render the PHP template, translate and return the output as string
  *
  * The ".php" suffix is added in this function.
  * Call this function after the $pathToTemplates is set.
  * The return value is the rendered result of the template, followed by translation.
  * It is typically a (x)html string, but can be used for any other text based format.
  *
  * @param	string		name of template file without the ".php" suffix
  * @param	tx_rnbase_configurations	configuration instance
  * @return	string		typically an (x)html string
  */
 function render($view, $configurations)
 {
     $link = $configurations->createLink();
     // Die ViewData bereitstellen
     $viewData =& $configurations->getViewData();
     $formatter = tx_rnbase::makeInstance('tx_rnbase_util_FormatUtil', $configurations);
     //t3lib_div::debug($formatter);
     $path = $this->getTemplate($view);
     // Für den PHP Include benötigen wir den absoluten Pfad
     $path = t3lib_div::getFileAbsFileName($path);
     ob_start();
     include $path;
     $out = ob_get_clean();
     return $out;
 }
 /**
  * Render the URI to the resource. The filename is used from child content.
  *
  * @param string $path The path and filename of the resource (relative to Public resource directory of the extension).
  * @param string $extensionName Target extension name. If not set, the current extension name will be used
  * @param boolean $absolute If set, an absolute URI is rendered
  * @return string The URI to the resource
  * @api
  */
 public function render($path, $extensionName = NULL, $absolute = FALSE)
 {
     if ($extensionName === NULL) {
         $extensionName = $this->controllerContext->getRequest()->getControllerExtensionName();
     }
     $uri = 'EXT:' . t3lib_div::camelCaseToLowerCaseUnderscored($extensionName) . '/Resources/Public/' . $path;
     $uri = t3lib_div::getFileAbsFileName($uri);
     $uri = substr($uri, strlen(PATH_site));
     if (TYPO3_MODE === 'BE' && $absolute === FALSE) {
         $uri = '../' . $uri;
     }
     if ($absolute === TRUE) {
         $uri = $this->controllerContext->getRequest()->getBaseURI() . $uri;
     }
     return $uri;
 }
 /**
  * @return boolean
  */
 public function execute()
 {
     t3lib_div::devLog('[tx_scheduler_ImportMember]: execute', 't3o_membership', 0);
     $membershipRecords = $this->getDatabaseConnection()->exec_SELECTgetRows('uid, name', 'tx_t3omembership_domain_model_membership', 'NOT hidden AND NOT deleted');
     foreach ($membershipRecords as $membershipRecord) {
         $this->memberships[$membershipRecord['name']] = (int) $membershipRecord['uid'];
     }
     // does the import file exist?
     $importFile = $this->getImportFile();
     if (!t3lib_div::isAbsPath($importFile)) {
         $importFile = t3lib_div::getFileAbsFileName($importFile);
     }
     if (!file_exists($importFile)) {
         t3lib_div::devLog('[tx_scheduler_ImportMember]: no importfile - given value: ' . $importFile, 't3o_membership', 0);
         return false;
     }
     $this->initializeHookObjects();
     $fileData = file($importFile);
     array_shift($fileData);
     foreach ($fileData as $key => $line) {
         $line = iconv('ISO-8859-15', 'UTF-8', $line);
         /** @noinspection PhpParamsInspection */
         $fields = t3lib_div::trimExplode("\t", $line);
         $membershipUid = $this->getMembershipUid($fields[12]);
         // Skip records with unknown membership types.
         if (empty($membershipUid)) {
             continue;
         }
         $subscriptionNo = (int) $fields[14];
         $endDate = $this->getMemberEndDate($fields[15]);
         // If the user has cancelled his membership "Gekündigt", we set the endtime enable field.
         $endTime = !empty($fields[17]) ? $endDate : 0;
         $hidden = false;
         if ($endTime > 0 && $endTime < time()) {
             $hidden = true;
         }
         $member = array('name' => $fields[6], 'subscription_no' => $subscriptionNo, 'external_id' => (int) $fields[0], 'address' => $fields[7] !== '' ? $fields[7] : $fields[8], 'zip' => $fields[10], 'city' => $fields[11], 'country' => $fields[13], 'end_date' => $endDate, 'endtime' => $endTime, 'hidden' => $hidden, 'starttime' => 0, 'membership' => $membershipUid, 'pid' => $this->getMembershipStoragePid(), 'crdate' => time(), 'tstamp' => time(), 'invoice_email' => $fields[84], 'email' => $fields[79], 'url' => $fields[80], 'firstname' => $fields[82], 'lastname' => $fields[83]);
         $memberUid = $this->createOrUpdateMember($subscriptionNo, $member);
         foreach ($this->hookObjects as $hookObject) {
             if (method_exists($hookObject, 'postUpdateMemberData')) {
                 $hookObject->postUpdateMemberData($memberUid, $member);
             }
         }
     }
     return true;
 }
 /**
  * prepare path, resolve relative path and resolve EXT: path
  *
  * @param $path absolute or relative path or EXT:foobar/
  * @return string/bool false if path is invalid, else the absolute path
  */
 protected function getPath($path)
 {
     // getFileAbsFileName can't handle directory path with trailing / correctly
     if (substr($path, -1) === '/') {
         $path = substr($path, 0, -1);
     }
     // FIXME remove this hacky part
     // skip path checks for CLI mode
     if (defined('TYPO3_cliMode')) {
         return $path;
     }
     $path = t3lib_div::getFileAbsFileName($path);
     if (t3lib_div::isAllowedAbsPath($path)) {
         return $path;
     } else {
         return false;
     }
 }
 /**
  * Get defined Skin for drupdown
  * @return array
  */
 function getSkins($config, $item)
 {
     $confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['imagecarousel']);
     if (!is_dir(t3lib_div::getFileAbsFileName($confArr['skinFolder']))) {
         // if the defined folder does not exist, define the default folder
         $confArr['skinFolder'] = "EXT:imagecarousel/res/skins/";
     }
     $items = t3lib_div::get_dirs(t3lib_div::getFileAbsFileName($confArr['skinFolder']));
     if (count($items) > 0) {
         $optionList = array();
         foreach ($items as $key => $item) {
             $item = trim($item);
             if (!preg_match('/^\\./', $item)) {
                 $optionList[] = array($item, $item);
             }
         }
         $config['items'] = array_merge($config['items'], $optionList);
     }
     return $config;
 }
 /**
  * Manipulating the input array, $params, adding new selectorbox items.
  * 
  * @param	array	array of select field options (reference)
  * @param	object	parent object (reference)
  * @return	void
  */
 function main(&$params, &$pObj)
 {
     // get the current page ID
     $thePageId = $params['row']['pid'];
     $template = t3lib_div::makeInstance('t3lib_tsparser_ext');
     // do not log time-performance information
     $template->tt_track = 0;
     $template->init();
     $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
     $rootLine = $sys_page->getRootLine($thePageId);
     // generate the constants/config + hierarchy info for the template.
     $template->runThroughTemplates($rootLine);
     $template->generateConfig();
     // get value for the path containing the template files
     $readPath = t3lib_div::getFileAbsFileName($template->setup['plugin.']['tx_ttaddress_pi1.']['templatePath']);
     // if that direcotry is valid and is a directory then select files in it
     if (@is_dir($readPath)) {
         $template_files = t3lib_div::getFilesInDir($readPath, 'tmpl,html,htm', 1, 1);
         $parseHTML = t3lib_div::makeInstance('t3lib_parseHTML');
         foreach ($template_files as $htmlFilePath) {
             // reset vars
             $selectorBoxItem_title = '';
             $selectorBoxItem_icon = '';
             // read template content
             $content = t3lib_div::getUrl($htmlFilePath);
             // ... and extract content of the title-tags
             $parts = $parseHTML->splitIntoBlock('title', $content);
             $titleTagContent = $parseHTML->removeFirstAndLastTag($parts[1]);
             // set the item label
             $selectorBoxItem_title = trim($titleTagContent . ' (' . basename($htmlFilePath) . ')');
             // try to look up an image icon for the template
             $fI = t3lib_div::split_fileref($htmlFilePath);
             $testImageFilename = $readPath . $fI['filebody'] . '.gif';
             if (@is_file($testImageFilename)) {
                 $selectorBoxItem_icon = '../' . substr($testImageFilename, strlen(PATH_site));
             }
             // finally add the new item
             $params['items'][] = array($selectorBoxItem_title, basename($htmlFilePath), $selectorBoxItem_icon);
         }
     }
 }
 /**
  * Gets a list of all files in a directory recursively and removes
  * old ones.
  *
  * @throws RuntimeException If folders are not found or files can not be deleted
  * @param string $directory Path to the directory
  * @param integer $timestamp Timestamp of the last file modification
  * @return boolean TRUE if success
  */
 protected function cleanUpDirectory($directory, $timestamp)
 {
     $fullPathToDirectory = t3lib_div::getFileAbsFileName($directory);
     // Check if given directory exists
     if (!@is_dir($fullPathToDirectory)) {
         throw new RuntimeException('Given directory "' . $fullPathToDirectory . '" does not exist', 1323272107);
     }
     // Find all files in the directory
     $directoryContent = new DirectoryIterator($fullPathToDirectory);
     /** @var $fileObject SplFileInfo */
     $fileObject = NULL;
     foreach ($directoryContent as $fileObject) {
         // Remove files that are older than given timestamp and don't match the exclude pattern
         if ($fileObject->isFile() && !preg_match('/' . $this->excludePattern . '/i', $fileObject->getFilename()) && $fileObject->getCTime() < $timestamp) {
             if (!@unlink($fileObject->getRealPath())) {
                 throw new RuntimeException('Could not remove file "' . $fileObject->getRealPath() . '"', 1323272115);
             }
         }
     }
     return TRUE;
 }
	/**
	 *
	 * @param string $lang
	 * @return string
	 */
	public static function getFlagIconFileForLanguage($flagName) {

		$flag = null;
		if (!strlen($flagName)) {
			$flagName = 'unknown';
		}
		if (tx_templavoila_div::convertVersionNumberToInteger(TYPO3_version) < 4005000) {
			$flagAbsPath = t3lib_div::getFileAbsFileName($GLOBALS['TCA']['sys_language']['columns']['flag']['config']['fileFolder']);
			$flagIconPath = $GLOBALS['BACK_PATH'] . '../' . substr($flagAbsPath, strlen(PATH_site));
			if (is_file($flagAbsPath . $flagName)) {
				$flag = $flagIconPath . $flagName;
			}
		} else {
				// same dirty trick as for #17286 in Core
			if(is_file(t3lib_div::getFileAbsFileName('EXT:t3skin/images/flags/'. $flagName . '.png', FALSE))) {
				   // resolving extpath on its own because otherwise this might not return a relative path
				$flag = $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('t3skin') . '/images/flags/' . $flagName . '.png';
			}
		}
		return $flag;
	}
 /**
  * If it is an URL, nothing to do, if it is a file, check if path is allowed and prepend current url
  *
  * @param string $url
  * @return string
  * @throws UnexpectedValueException
  */
 public static function getCorrectUrl($url)
 {
     if (empty($url)) {
         throw new UnexpectedValueException('An empty url is given');
     }
     $url = self::getFalFilename($url);
     // check URL
     $urlInfo = parse_url($url);
     // means: it is no external url
     if (!isset($urlInfo['scheme'])) {
         // resolve paths like ../
         $url = t3lib_div::resolveBackPath($url);
         // absolute path is used to check path
         $absoluteUrl = t3lib_div::getFileAbsFileName($url);
         if (!t3lib_div::isAllowedAbsPath($absoluteUrl)) {
             throw new UnexpectedValueException('The path "' . $url . '" is not allowed.');
         }
         // append current domain
         $url = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $url;
     }
     return $url;
 }
 /**
  * @see Classes/MVC/Controller/Tx_Extbase_MVC_Controller_ActionController::initializeView()
  */
 protected function initializeView($view)
 {
     /* set the template and partial path
      * 
      * this was added due to a bug. If the default action (dispatcher) was called, it created
      * Tx_CzSimpleCal_View_EventIndex_Dispatch but did not set the templateRoot (only the
      * discarded Template view had it). So we do it here.
      */
     if ($view instanceof Tx_Fluid_View_TemplateViewInterface) {
         $extbaseFrameworkConfiguration = Tx_Extbase_Dispatcher::getExtbaseFrameworkConfiguration();
         if (isset($extbaseFrameworkConfiguration['view']['templateRootPath']) && strlen($extbaseFrameworkConfiguration['view']['templateRootPath']) > 0) {
             $view->setTemplateRootPath(t3lib_div::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']));
         }
         if (isset($extbaseFrameworkConfiguration['view']['layoutRootPath']) && strlen($extbaseFrameworkConfiguration['view']['layoutRootPath']) > 0) {
             $view->setLayoutRootPath(t3lib_div::getFileAbsFileName($extbaseFrameworkConfiguration['view']['layoutRootPath']));
         }
         if (isset($extbaseFrameworkConfiguration['view']['partialRootPath']) && strlen($extbaseFrameworkConfiguration['view']['partialRootPath']) > 0) {
             $view->setPartialRootPath(t3lib_div::getFileAbsFileName($extbaseFrameworkConfiguration['view']['partialRootPath']));
         }
     }
     $view->assign('actionSettings', $this->actionSettings);
 }
 /**
  * Translate a given string in the current language
  *
  * @param string $string
  * @return string
  */
 static function locallizeString($locallangString)
 {
     // handler whole LLL String
     if (strpos($locallangString, 'LLL:') !== 0) {
         $result = $locallangString;
     } else {
         switch (TYPO3_MODE) {
             case 'FE':
                 // FE
                 if ($GLOBALS['TSFE']) {
                     $lcObj = t3lib_div::makeInstance('tslib_cObj');
                     $result = $lcObj->TEXT(array('data' => $locallangString));
                 } else {
                     $LANG = t3lib_div::makeInstance('language');
                     $LANG->init($language_key);
                     $result = $LANG->getLLL($locallang_key, t3lib_div::readLLfile(t3lib_div::getFileAbsFileName($locallang_file), $LANG->lang, $LANG->charSet));
                 }
                 break;
             case 'BE':
                 $locallangParts = explode(':', $locallangString);
                 array_shift($locallangParts);
                 $locallang_key = array_pop($locallangParts);
                 $locallang_file = implode(':', $locallangParts);
                 $language_key = $GLOBALS['BE_USER']->uc['lang'];
                 $LANG = t3lib_div::makeInstance('language');
                 $LANG->init($language_key);
                 $result = $LANG->getLLL($locallang_key, t3lib_div::readLLfile(t3lib_div::getFileAbsFileName($locallang_file), $LANG->lang, $LANG->charSet));
                 break;
             default:
                 $result = $locallangString;
                 break;
         }
     }
     /// recursive call for {LLL:} parts
     $result = preg_replace_callback('/{(LLL:EXT:[^ ]+?:[^ ]+?)}/', 'tx_caretaker_LocallizationHelper::locallizeSubstring', $result);
     return $result;
 }
示例#27
0
 /**
  * builds the XML header (array of markers to substitute)
  *
  * @return	array		the filled XML header markers
  */
 function getXmlHeader()
 {
     $lConf = $this->conf['displayXML.'];
     $markerArray = array();
     $markerArray['###SITE_TITLE###'] = $lConf['xmlTitle'];
     $markerArray['###SITE_LINK###'] = $this->config['siteUrl'];
     $markerArray['###SITE_DESCRIPTION###'] = $lConf['xmlDesc'];
     if (!empty($markerArray['###SITE_DESCRIPTION###'])) {
         if ($lConf['xmlFormat'] == 'atom03') {
             $markerArray['###SITE_DESCRIPTION###'] = '<tagline>' . $markerArray['###SITE_DESCRIPTION###'] . '</tagline>';
         } elseif ($lConf['xmlFormat'] == 'atom1') {
             $markerArray['###SITE_DESCRIPTION###'] = '<subtitle>' . $markerArray['###SITE_DESCRIPTION###'] . '</subtitle>';
         }
     }
     $markerArray['###SITE_LANG###'] = $lConf['xmlLang'];
     if ($lConf['xmlFormat'] == 'rss2') {
         $markerArray['###SITE_LANG###'] = '<language>' . $markerArray['###SITE_LANG###'] . '</language>';
     } elseif ($lConf['xmlFormat'] == 'atom03') {
         $markerArray['###SITE_LANG###'] = ' xml:lang="' . $markerArray['###SITE_LANG###'] . '"';
     }
     if (empty($lConf['xmlLang'])) {
         $markerArray['###SITE_LANG###'] = '';
     }
     $imgFile = t3lib_div::getFileAbsFileName($this->cObj->stdWrap($lConf['xmlIcon'], $lConf['xmlIcon.']));
     $imgSize = is_file($imgFile) ? getimagesize($imgFile) : '';
     $markerArray['###IMG_W###'] = $imgSize[0];
     $markerArray['###IMG_H###'] = $imgSize[1];
     $relImgFile = str_replace(PATH_site, '', $imgFile);
     $markerArray['###IMG###'] = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $relImgFile;
     $markerArray['###NEWS_WEBMASTER###'] = $lConf['xmlWebMaster'];
     $markerArray['###NEWS_MANAGINGEDITOR###'] = $lConf['xmlManagingEditor'];
     $selectConf = array();
     $selectConf['pidInList'] = $this->pid_list;
     // select only normal news (type=0) for the RSS feed. You can override this with other types with the TS-var 'xmlNewsTypes'
     $selectConf['selectFields'] = 'max(datetime) as maxval';
     $res = $this->exec_getQuery('tt_news', $selectConf);
     $row = $this->db->sql_fetch_assoc($res);
     // optional tags
     if ($lConf['xmlLastBuildDate']) {
         $markerArray['###NEWS_LASTBUILD###'] = '<lastBuildDate>' . date('D, d M Y H:i:s O', $row['maxval']) . '</lastBuildDate>';
     } else {
         $markerArray['###NEWS_LASTBUILD###'] = '';
     }
     if ($lConf['xmlFormat'] == 'atom03' || $lConf['xmlFormat'] == 'atom1') {
         $markerArray['###NEWS_LASTBUILD###'] = $this->hObj->getW3cDate($row['maxval']);
     }
     if ($lConf['xmlWebMaster']) {
         $markerArray['###NEWS_WEBMASTER###'] = '<webMaster>' . $lConf['xmlWebMaster'] . '</webMaster>';
     } else {
         $markerArray['###NEWS_WEBMASTER###'] = '';
     }
     if ($lConf['xmlManagingEditor']) {
         $markerArray['###NEWS_MANAGINGEDITOR###'] = '<managingEditor>' . $lConf['xmlManagingEditor'] . '</managingEditor>';
     } else {
         $markerArray['###NEWS_MANAGINGEDITOR###'] = '';
     }
     if ($lConf['xmlCopyright']) {
         if ($lConf['xmlFormat'] == 'atom1') {
             $markerArray['###NEWS_COPYRIGHT###'] = '<rights>' . $lConf['xmlCopyright'] . '</rights>';
         } else {
             $markerArray['###NEWS_COPYRIGHT###'] = '<copyright>' . $lConf['xmlCopyright'] . '</copyright>';
         }
     } else {
         $markerArray['###NEWS_COPYRIGHT###'] = '';
     }
     $charset = $this->tsfe->metaCharset ? $this->tsfe->metaCharset : 'iso-8859-1';
     if ($lConf['xmlDeclaration']) {
         $markerArray['###XML_DECLARATION###'] = trim($lConf['xmlDeclaration']);
     } else {
         $markerArray['###XML_DECLARATION###'] = '<?xml version="1.0" encoding="' . $charset . '"?>';
     }
     // promoting TYPO3 in atom feeds, supress the subversion
     $version = explode('.', $GLOBALS['TYPO3_VERSION'] ? $GLOBALS['TYPO3_VERSION'] : $GLOBALS['TYPO_VERSION']);
     unset($version[2]);
     $markerArray['###TYPO3_VERSION###'] = implode($version, '.');
     return $markerArray;
 }
 /**
  * get the template code, prepared for javascript (no line breaks, quoted in slinge quotes)
  *
  * @return	string	the template code, prepared to use in javascript
  */
 protected function getPreparedTemplate()
 {
     $T3Editor_template = t3lib_div::getURL(t3lib_div::getFileAbsFileName('EXT:t3editor/res/templates/t3editor.html'));
     $T3Editor_template = addslashes($T3Editor_template);
     $T3Editor_template = str_replace(LF, "' + '", $T3Editor_template);
     return '\'' . $T3Editor_template . '\'';
 }
示例#29
0
 /**
  * Gets all available XML or ZIP files from the FTP server
  *
  * @throws Exception
  * @return array List of files, as local paths
  */
 protected function getFilesFromFtp()
 {
     $files = array();
     // First try connecting and logging in
     $connection = ftp_connect($this->extensionConfiguration['ftp_server']);
     if ($connection === FALSE) {
         throw new Exception('Could not connect to FTP server', 1322489458);
     } else {
         if (@ftp_login($connection, $this->extensionConfiguration['ftp_server_username'], $this->extensionConfiguration['ftp_server_password'])) {
             ftp_pasv($connection, TRUE);
             // If a path was defined, change directory to this path
             if (!empty($this->extensionConfiguration['ftp_server_downpath'])) {
                 $result = ftp_chdir($connection, $this->extensionConfiguration['ftp_server_downpath']);
                 if ($result === FALSE) {
                     throw new Exception('Could not change to directory: ' . $this->extensionConfiguration['ftp_server_downpath'], 1322489723);
                 }
             }
             // Get list of files to download from current directory
             $filesToDownload = ftp_nlist($connection, '');
             // If there are any files, loop on them
             if ($filesToDownload != FALSE) {
                 // Check that download directory exists
                 $downloadFolder = 'uploads/tx_l10nmgr/jobs/in/';
                 $downloadPath = PATH_site . $downloadFolder;
                 if (!is_dir(t3lib_div::getFileAbsFileName($downloadPath))) {
                     t3lib_div::mkdir_deep(PATH_site, $downloadFolder);
                 }
                 foreach ($filesToDownload as $aFile) {
                     // Ignore current directory and reference to upper level
                     if ($aFile != '.' && $aFile != '..') {
                         $fileInformation = pathinfo($aFile);
                         // Download only XML or ZIP files
                         if ($fileInformation['extension'] == 'xml' || $fileInformation['extension'] == 'zip') {
                             $savePath = $downloadPath . $aFile;
                             // Get each file and save them to temporary directory
                             $result = ftp_get($connection, $savePath, $aFile, FTP_BINARY);
                             if ($result) {
                                 // If the file is XML, list it for usage as is
                                 if ($fileInformation['extension'] == 'xml') {
                                     $files[] = $savePath;
                                 } else {
                                     /** @var $unzip tx_l10nmgr_zip */
                                     $unzip = t3lib_div::makeInstance('tx_l10nmgr_zip');
                                     $unzipResource = $unzip->extractFile($savePath);
                                     // Process extracted files if file type = xml => IMPORT
                                     $archiveFiles = $this->checkFileType($unzipResource['fileArr'], 'xml');
                                     $files = array_merge($files, $archiveFiles);
                                     // Store the temporary directory's path for later clean up
                                     $this->directoryToCleanUp = $unzipResource['tempDir'];
                                 }
                                 // Remove the file from the FTP server
                                 $result = ftp_delete($connection, $aFile);
                                 // If deleting failed, register error message
                                 // (don't throw exception as this does not need to interrupt the process)
                                 if (!$result) {
                                     $this->errors[] = 'Could not remove file ' . $aFile . 'from FTP server';
                                 }
                                 // If getting the file failed, register error message
                                 // (don't throw exception as this does not need to interrupt the process)
                             } else {
                                 $this->errors[] = 'Problem getting file ' . $aFile . 'from server or saving it locally';
                             }
                         }
                     }
                 }
             }
         } else {
             ftp_close($connection);
             throw new Exception('Could not log into to FTP server', 1322489527);
         }
     }
     return $files;
 }
示例#30
0
 protected function handleUpload($albumName)
 {
     $count = (int) $_POST['tx-picasa-pi2-uploader_count'];
     $pictures = array();
     for ($i = 0; $i < $count; $i++) {
         $prefix = 'tx-picasa-pi2-uploader_' . $i . '_';
         if ($_POST[$prefix . 'status'] === 'done') {
             $pictures[] = $picture = 'typo3temp/tx_picasa/tmp/' . $_POST[$prefix . 'tmpname'];
             $this->_client->postPhotoToAlbum($_POST[$prefix . 'name'], t3lib_div::getFileAbsFileName($picture), $albumName);
         }
     }
     $this->showUploadedPictures($albumName, $pictures);
 }