/**
  * Inits the class 'language'
  *
  * @param string    Fieldname in the _LOCAL_LANG array or the locallang.xml
  * @return  void
  */
 public function initLang()
 {
     require_once PATH_typo3 . 'sysext/lang/lang.php';
     $this->pObj->lang = t3lib_div::makeInstance('language');
     $this->pObj->lang->init($GLOBALS['TSFE']->lang);
     if ($this->pObj->b_drs_all) {
         t3lib_div::devlog('[INFO/ALL] Init a language object.', $this->pObj->extKey, 0);
         t3lib_div::devlog('[INFO/ALL] Value of $GLOBALS[TSFE]->lang :' . $GLOBALS['TSFE']->lang, $this->pObj->extKey, 0);
     }
 }
 /**
  * cover all cases:
  * 1. extend TYPO3 class like fe_users (no mapping table needed)
  *
  * @param Tx_ExtensionBuilder_Domain_Model_DomainObject $domainObject
  */
 private function validateMapping(Tx_ExtensionBuilder_Domain_Model_DomainObject $domainObject)
 {
     $parentClass = $domainObject->getParentClass();
     $tableName = $domainObject->getMapToTable();
     $extensionPrefix = 'Tx_' . t3lib_div::underscoredToUpperCamelCase($domainObject->getExtension()->getExtensionKey()) . '_Domain_Model_';
     if (!empty($parentClass)) {
         $classConfiguration = $this->configurationManager->getExtbaseClassConfiguration($parentClass);
         t3lib_div::devlog('class settings ' . $parentClass, 'extension_builder', 0, $classConfiguration);
         if (!isset($classConfiguration['tableName'])) {
             if (!$tableName) {
                 $this->validationResult['errors'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('Mapping configuration error in domain object ' . $domainObject->getName() . ': The mapping table could not be detected from Extbase Configuration. Please enter a table name', self::ERROR_MAPPING_NO_TABLE);
             }
         } else {
             // get the table name from the parent class configuration
             $tableName = $classConfiguration['tableName'];
         }
         if (!class_exists($parentClass, TRUE)) {
             $this->validationResult['errors'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('Mapping configuration error in domain object ' . $domainObject->getName() . ': the parent class ' . $parentClass . 'seems not to exist ', self::ERROR_MAPPING_NO_PARENTCLASS);
         }
     }
     if ($tableName) {
         if (strpos($extensionPrefix, $tableName) !== FALSE) {
             // the domainObject extends a class of the same extension
             if (!$parentClass) {
                 $this->validationResult['errors'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('Mapping configuration error in domain object ' . $domainObject->getName() . ': you have to define a parent class if you map to a table of another domain object of the same extension ', self::ERROR_MAPPING_NO_PARENTCLASS);
             }
         }
         if (!isset($GLOBALS['TCA'][$tableName])) {
             $this->validationResult['errors'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('There is no entry for table "' . $tableName . '" of ' . $domainObject->getName() . ' in TCA. For technical reasons you can only extend tables with TCA configuration.', self::ERROR_MAPPING_NO_TCA);
         }
     }
     if (isset($GLOBALS['TCA'][$tableName]['ctrl']['type'])) {
         $dataTypeRes = $GLOBALS['TYPO3_DB']->sql_query('DESCRIBE ' . $tableName);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dataTypeRes)) {
             if ($row['Field'] == $GLOBALS['TCA'][$tableName]['ctrl']['type']) {
                 if (strpos($row['Type'], 'int') !== FALSE) {
                     $this->validationResult['warnings'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('The configured type field for table "' . $tableName . '" is of type ' . $row['Type'] . '<br />This means the type field can not be used for defining the record type. <br />You have to configure the mappings yourself if you want to map to this<br /> table or extend the correlated class', self::ERROR_MAPPING_WRONG_TYPEFIELD_CONFIGURATION);
                 }
             }
         }
     }
 }
 public function sendEmail($from, $to, $subject, $bodyHtml, $bodyPlain = '')
 {
     $mail = t3lib_div::makeInstance('t3lib_mail_Message');
     if (empty($bodyPlain)) {
         $bodyPlain = preg_replace('/(<br>|<br \\/>|<br\\/>)\\s*/i', PHP_EOL, $bodyHtml);
         $bodyPlain = strip_tags($this->bodyPlain);
     }
     $mail->setFrom($from);
     $mail->setTo($to);
     $mail->setSubject($subject);
     $htmlComplete = $this->initHtml() . $bodyHtml . $this->exitHtml();
     $mail->setBody($htmlComplete, 'text/html');
     $mail->addPart($bodyPlain, 'text/plain');
     $erg = $mail->send();
     if (!$erg) {
         $failedRecipients = $this->mail->getFailedRecipients();
         t3lib_div::devlog('E-Mail-Versand fehlgeschlagen!', 'kms_formular', 0, $failedRecipients);
     }
     return $erg;
 }
 /**
  * prompt_drs(): Prompt to the drs the value if the given sheet.field
  *
  * @param string    $sheet:     label of the sheet
  * @param string    $field:     label of the field
  * @param string    $value:     value of the field
  * @return  void
  * @version 0.0.1
  * @since 0.0.1
  */
 public function prompt_drs($sheet, $field, $value)
 {
     if ($this->pObj->b_drs_flexform) {
         t3lib_div::devlog('[INFO/FLEXFORM] ' . $sheet . '.' . $field . ': \'' . $value . '\'', $this->pObj->extKey, 0);
     }
 }
 /**
  *
  * @param $relationJsonConfiguration
  * @return Tx_ExtensionBuilder_Domain_Model_DomainObject_Relation_AbstractRelation
  */
 public static function buildRelation($relationJsonConfiguration)
 {
     $relationSchemaClassName = 'Tx_ExtensionBuilder_Domain_Model_DomainObject_Relation_' . ucfirst($relationJsonConfiguration['relationType']) . 'Relation';
     if (!class_exists($relationSchemaClassName)) {
         t3lib_div::devlog('Relation misconfiguration', 'extension_builder', 2, $relationJsonConfiguration);
         throw new Exception('Relation of type ' . $relationSchemaClassName . ' not found (configured in "' . $relationJsonConfiguration['relationName'] . '")');
     }
     $relation = new $relationSchemaClassName();
     $relation->setName($relationJsonConfiguration['relationName']);
     //$relation->setInlineEditing((bool)$relationJsonConfiguration['inlineEditing']);
     $relation->setLazyLoading((bool) $relationJsonConfiguration['lazyLoading']);
     $relation->setExcludeField($relationJsonConfiguration['propertyIsExcludeField']);
     $relation->setDescription($relationJsonConfiguration['relationDescription']);
     $relation->setUniqueIdentifier($relationJsonConfiguration['uid']);
     return $relation;
 }
示例#6
0
 /**
  * merge existing locallang (either in xlf or locallang.xml) with the required/configured new labels
  *
  * TODO: this method works currently only for 'default' language
  * @static
  * @param string $locallangFile
  * @param string $newXmlString
  * @param string fileFormat (xml or xlf
  * @return string merged label in XML format
  */
 public static function mergeLocallangXlf($locallangFile, $newXmlString, $fileFormat)
 {
     if (!file_exists($locallangFile)) {
         throw new Exception('File not found: ' . $locallangFile);
     }
     if (pathinfo($locallangFile, PATHINFO_EXTENSION) == 'xlf') {
         $existingXml = simplexml_load_file($locallangFile, 'SimpleXmlElement', LIBXML_NOWARNING);
         $existingLabelArr = self::flattenLocallangArray(self::parseXliff($existingXml), 'xlf');
     } else {
         $existingLabelArr = self::flattenLocallangArray(t3lib_div::xml2array(t3lib_div::getUrl($locallangFile)), 'xml');
     }
     if ($fileFormat == 'xlf') {
         $newXml = simplexml_load_string($newXmlString, 'SimpleXmlElement', LIBXML_NOWARNING);
         $newLabelArr = self::flattenLocallangArray(self::parseXliff($newXml), 'xlf');
     } else {
         $newLabelArr = self::flattenLocallangArray(t3lib_div::xml2array($newXmlString), 'xml');
     }
     t3lib_div::devlog('mergeLocallang', 'extension_builder', 0, array('new' => $newLabelArr, 'existing' => $existingLabelArr));
     if (is_array($existingLabelArr)) {
         $mergedLabelArr = t3lib_div::array_merge_recursive_overrule($newLabelArr, $existingLabelArr);
     } else {
         $mergedLabelArr = $newLabelArr;
     }
     t3lib_div::devlog('mergeLocallang', 'extension_builder', 0, $mergedLabelArr);
     return $mergedLabelArr;
 }
 /**
  *
  * @param string $extensionKey
  * @return array settings
  */
 public function getExtensionSettings($extensionKey)
 {
     $settings = array();
     $settingsFile = $this->getSettingsFile($extensionKey);
     if (file_exists($settingsFile)) {
         $yamlParser = new Tx_ExtensionBuilder_Utility_SpycYAMLParser();
         $settings = $yamlParser->YAMLLoadString(file_get_contents($settingsFile));
     } else {
         t3lib_div::devlog('No settings found: ' . $settingsFile, 'extension_builder', 2);
     }
     return $settings;
 }
 /**
  *
  * @param Tx_ExtensionBuilder_Domain_Model_Extension $extension
  * @param string $backupDir
  *
  * @return void
  */
 static function backupExtension($extension, $backupDir)
 {
     if (empty($backupDir)) {
         throw new Exception('Please define a backup directory in extension configuration!');
     } else {
         if (!t3lib_div::validPathStr($backupDir)) {
             throw new Exception('Backup directory is not a valid path: ' . $backupDir);
         } else {
             if (t3lib_div::isAbsPath($backupDir)) {
                 if (!t3lib_div::isAllowedAbsPath($backupDir)) {
                     throw new Exception('Backup directory is not an allowed absolute path: ' . $backupDir);
                 }
             } else {
                 $backupDir = PATH_site . $backupDir;
             }
         }
     }
     if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
         $backupDir .= '/';
     }
     if (!is_dir($backupDir)) {
         throw new Exception('Backup directory does not exist: ' . $backupDir);
     } else {
         if (!is_writable($backupDir)) {
             throw new Exception('Backup directory is not writable: ' . $backupDir);
         }
     }
     $backupDir .= $extension->getExtensionKey();
     // create a subdirectory for this extension
     if (!is_dir($backupDir)) {
         t3lib_div::mkdir($backupDir);
     }
     if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
         $backupDir .= '/';
     }
     $backupDir .= date('Y-m-d-') . time();
     if (!is_dir($backupDir)) {
         t3lib_div::mkdir($backupDir);
     }
     $extensionDir = substr($extension->getExtensionDir(), 0, strlen($extension->getExtensionDir()) - 1);
     try {
         self::recurse_copy($extensionDir, $backupDir);
     } catch (Exception $e) {
         throw new Exception('Code generation aborted:' . $e->getMessage());
     }
     t3lib_div::devlog('Backup created in ' . $backupDir, 'extension_builder', 0);
 }
 /**
  * wrapper for t3lib_div::writeFile
  * checks for overwrite settings
  *
  * @param string $targetFile the path and filename of the targetFile (relative to extension dir)
  * @param string $fileContents
  */
 protected function writeFile($targetFile, $fileContents)
 {
     if ($this->roundTripEnabled) {
         $overWriteMode = Tx_ExtensionBuilder_Service_RoundTrip::getOverWriteSettingForPath($targetFile, $this->extension);
         if ($overWriteMode == -1) {
             return;
             // skip file creation
         }
         if ($overWriteMode == 1 && strpos($targetFile, 'Classes') === FALSE) {
             // classes are merged by the class builder
             $fileExtension = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
             if ($fileExtension == 'html') {
                 //TODO: We need some kind of protocol to be displayed after code generation
                 t3lib_div::devlog('File ' . basename($targetFile) . ' was not written. Template files can\'t be merged!', 'extension_builder', 1);
                 return;
             } elseif (in_array($fileExtension, $this->filesSupportingSplitToken)) {
                 $fileContents = $this->insertSplitToken($targetFile, $fileContents);
             }
         } else {
             if (file_exists($targetFile) && $overWriteMode == 2) {
                 // keep the existing file
                 return;
             }
         }
     }
     if (empty($fileContents)) {
         t3lib_div::devLog('No file content! File ' . $targetFile . ' had no content', 'extension_builder', 0, $this->settings);
     }
     $success = t3lib_div::writeFile($targetFile, $fileContents);
     if (!$success) {
         throw new Exception('File ' . $targetFile . ' could not be created!');
     }
 }
 /**
  * @param Tx_ExtensionBuilder_Domain_Model_Extension $extension
  * @param array $propertyConfiguration
  * @return void
  */
 protected function setExtensionProperties(&$extension, $propertyConfiguration)
 {
     // name
     $extension->setName(trim($propertyConfiguration['name']));
     // description
     $extension->setDescription($propertyConfiguration['description']);
     // extensionKey
     $extension->setExtensionKey(trim($propertyConfiguration['extensionKey']));
     if ($propertyConfiguration['emConf']['disableVersioning']) {
         $extension->setSupportVersioning(FALSE);
     }
     // various extension properties
     $extension->setVersion($propertyConfiguration['emConf']['version']);
     if (!empty($propertyConfiguration['emConf']['dependsOn'])) {
         $dependencies = array();
         $lines = t3lib_div::trimExplode("\n", $propertyConfiguration['emConf']['dependsOn']);
         foreach ($lines as $line) {
             if (strpos($line, '=>')) {
                 list($extensionKey, $version) = t3lib_div::trimExplode('=>', $line);
                 $dependencies[$extensionKey] = $version;
             }
         }
         $extension->setDependencies($dependencies);
     }
     if (!empty($propertyConfiguration['emConf']['targetVersion'])) {
         $extension->setTargetVersion(floatval($propertyConfiguration['emConf']['targetVersion']));
     }
     if (!empty($propertyConfiguration['emConf']['custom_category'])) {
         $category = $propertyConfiguration['emConf']['custom_category'];
     } else {
         $category = $propertyConfiguration['emConf']['category'];
     }
     $extension->setCategory($category);
     $extension->setShy($propertyConfiguration['emConf']['shy']);
     $extension->setPriority($propertyConfiguration['emConf']['priority']);
     // state
     $state = 0;
     switch ($propertyConfiguration['emConf']['state']) {
         case 'alpha':
             $state = Tx_ExtensionBuilder_Domain_Model_Extension::STATE_ALPHA;
             break;
         case 'beta':
             $state = Tx_ExtensionBuilder_Domain_Model_Extension::STATE_BETA;
             break;
         case 'stable':
             $state = Tx_ExtensionBuilder_Domain_Model_Extension::STATE_STABLE;
             break;
         case 'experimental':
             $state = Tx_ExtensionBuilder_Domain_Model_Extension::STATE_EXPERIMENTAL;
             break;
         case 'test':
             $state = Tx_ExtensionBuilder_Domain_Model_Extension::STATE_TEST;
             break;
     }
     $extension->setState($state);
     if (!empty($propertyConfiguration['originalExtensionKey'])) {
         // handle renaming of extensions
         // original extensionKey
         $extension->setOriginalExtensionKey($propertyConfiguration['originalExtensionKey']);
         t3lib_div::devlog('Extension setOriginalExtensionKey:' . $extension->getOriginalExtensionKey(), 'extbase', 0, $propertyConfiguration);
     }
     if (!empty($propertyConfiguration['originalExtensionKey']) && $extension->getOriginalExtensionKey() != $extension->getExtensionKey()) {
         $settings = $this->configurationManager->getExtensionSettings($extension->getOriginalExtensionKey());
         // if an extension was renamed, a new extension dir is created and we
         // have to copy the old settings file to the new extension dir
         copy($this->configurationManager->getSettingsFile($extension->getOriginalExtensionKey()), $this->configurationManager->getSettingsFile($extension->getExtensionKey()));
     } else {
         $settings = $this->configurationManager->getExtensionSettings($extension->getExtensionKey());
     }
     if (!empty($settings)) {
         $extension->setSettings($settings);
         t3lib_div::devlog('Extension settings:' . $extension->getExtensionKey(), 'extbase', 0, $extension->getSettings());
     }
 }
 /**
  * Generate the code files according to the transferred JSON configuration
  *
  * @throws Exception
  * @return array (status => message)
  */
 protected function rpcAction_save()
 {
     try {
         $extensionBuildConfiguration = $this->configurationManager->getConfigurationFromModeler();
         t3lib_div::devlog('Modeler Configuration', 'extension_builder', 0, $extensionBuildConfiguration);
         $validationConfigurationResult = $this->extensionValidator->validateConfigurationFormat($extensionBuildConfiguration);
         if (!empty($validationConfigurationResult['warnings'])) {
             $confirmationRequired = $this->handleValidationWarnings($validationConfigurationResult['warnings']);
             if (!empty($confirmationRequired)) {
                 return $confirmationRequired;
             }
         }
         $extension = $this->extensionSchemaBuilder->build($extensionBuildConfiguration);
     } catch (Exception $e) {
         throw $e;
     }
     // Validate the extension
     $validationResult = $this->extensionValidator->isValid($extension);
     if (!empty($validationResult['errors'])) {
         $errorMessage = '';
         foreach ($validationResult['errors'] as $exception) {
             $errorMessage .= '<br />' . $exception->getMessage();
         }
         throw new Exception($errorMessage);
     }
     if (!empty($validationResult['warnings'])) {
         $confirmationRequired = $this->handleValidationWarnings($validationResult['warnings']);
         if (!empty($confirmationRequired)) {
             return $confirmationRequired;
         }
     }
     $extensionDirectory = $extension->getExtensionDir();
     if (!is_dir($extensionDirectory)) {
         t3lib_div::mkdir($extensionDirectory);
     } else {
         if ($this->settings['extConf']['backupExtension'] == 1) {
             try {
                 Tx_ExtensionBuilder_Service_RoundTrip::backupExtension($extension, $this->settings['extConf']['backupDir']);
             } catch (Exception $e) {
                 throw $e;
             }
         }
         $extensionSettings = $this->configurationManager->getExtensionSettings($extension->getExtensionKey());
         if ($this->settings['extConf']['enableRoundtrip'] == 1) {
             if (empty($extensionSettings)) {
                 // no config file in an existing extension!
                 // this would result in a total overwrite so we create one and give a warning
                 $this->configurationManager->createInitialSettingsFile($extension, $this->settings['codeTemplateRootPath']);
                 return array('warning' => "<span class='error'>Roundtrip is enabled but no configuration file was found.</span><br />This might happen if you use the extension builder the first time for this extension. <br />A settings file was generated in <br /><b>typo3conf/ext/" . $extension->getExtensionKey() . "/Configuration/ExtensionBuilder/settings.yaml.</b><br />Configure the overwrite settings, then save again.");
             }
             try {
                 Tx_ExtensionBuilder_Service_RoundTrip::prepareExtensionForRoundtrip($extension);
             } catch (Exception $e) {
                 throw $e;
             }
         }
     }
     try {
         $this->codeGenerator->build($extension);
         $this->extensionInstallationStatus->setExtension($extension);
         $message = '<p>The Extension was saved</p>' . $this->extensionInstallationStatus->getStatusMessage();
         if ($extension->getNeedsUploadFolder()) {
             $message .= '<br />Notice: File upload is not yet implemented.';
         }
         $result = array('success' => $message);
     } catch (Exception $e) {
         throw $e;
     }
     $this->extensionRepository->saveExtensionConfiguration($extension);
     return $result;
 }
 /**
  * Write a simple model class for a non aggregate root domain object with one to one relation
  *
  * @test
  */
 function writeModelClassWithZeroToOneRelation()
 {
     $modelName = 'ModelCgt3';
     $relatedModelName = 'relatedModel';
     $propertyName = 'relName';
     $domainObject = $this->buildDomainObject($modelName);
     $relatedDomainObject = $this->buildDomainObject($relatedModelName);
     $relation = new Tx_ExtensionBuilder_Domain_Model_DomainObject_Relation_ZeroToOneRelation($propertyName);
     $relation->setForeignModel($relatedDomainObject);
     $domainObject->addProperty($relation);
     $classFileContent = $this->codeGenerator->generateDomainObjectCode($domainObject, TRUE);
     $modelClassDir = 'Classes/Domain/Model/';
     $result = t3lib_div::mkdir_deep($this->extension->getExtensionDir(), $modelClassDir);
     $absModelClassDir = $this->extension->getExtensionDir() . $modelClassDir;
     $this->assertTrue(is_dir($absModelClassDir), 'Directory ' . $absModelClassDir . ' was not created');
     $modelClassPath = $absModelClassDir . $domainObject->getName() . '.php';
     t3lib_div::devlog('Class Content', 'extension_builder', 0, array('c' => $classFileContent));
     t3lib_div::writeFile($modelClassPath, $classFileContent);
     $this->assertFileExists($modelClassPath, 'File was not generated: ' . $modelClassPath);
     $className = $domainObject->getClassName();
     include $modelClassPath;
     $this->assertTrue(class_exists($className), 'Class was not generated:' . $className);
     $reflection = new Tx_ExtensionBuilder_Reflection_ClassReflection($className);
     $this->assertTrue($reflection->hasMethod('get' . ucfirst($propertyName)), 'Getter was not generated');
     $this->assertTrue($reflection->hasMethod('set' . ucfirst($propertyName)), 'Setter was not generated');
     $setterMethod = $reflection->getMethod('set' . ucfirst($propertyName));
     $this->assertTrue($setterMethod->isTaggedWith('param'), 'No param tag set for setter method');
     $paramTagValues = $setterMethod->getTagValues('param');
     $this->assertTrue(strpos($paramTagValues[0], $relatedDomainObject->getClassName()) === 0, 'Wrong param tag:' . $paramTagValues[0]);
     $parameters = $setterMethod->getParameters();
     $this->assertTrue(count($parameters) == 1, 'Wrong parameter count in setter method');
     $parameter = current($parameters);
     $this->assertTrue($parameter->getName() == $propertyName, 'Wrong parameter name in setter method');
     $this->assertTrue($parameter->getTypeHint() == $relatedDomainObject->getClassName(), 'Wrong type hint for setter parameter:' . $parameter->getTypeHint());
 }
 /**
  *
  * @param string $filePath
  * @param Array $variables
  */
 protected function renderTemplate($filePath, $variables)
 {
     if (!isset($variables['settings']['codeTemplateRootPath'])) {
         t3lib_div::devlog('Render: ' . $filePath, 'builder', 2, $variables);
         throw new Exception('No template root path configured: ' . $filePath);
     }
     if (!file_exists($variables['settings']['codeTemplateRootPath'] . $filePath)) {
         t3lib_div::devlog('No template file found: ' . $variables['settings']['codeTemplateRootPath'] . $filePath, 'extension_builder', 2, $variables);
         throw new Exception('No template file found: ' . $variables['settings']['codeTemplateRootPath'] . $filePath);
     }
     $parsedTemplate = $this->templateParser->parse(file_get_contents($variables['settings']['codeTemplateRootPath'] . $filePath));
     return $parsedTemplate->render($this->buildRenderingContext($variables));
 }
    public function sendeBuchungsUeberblick($anrede, $email)
    {
        $mail = t3lib_div::makeInstance('t3lib_mail_Message');
        $sender = $this->conf['veranstaltungen.']['email.']['sender'];
        $subject = $this->conf['veranstaltungen.']['email.']['subject'];
        $footer = $this->conf['veranstaltungen.']['email.']['footer.']['value'];
        $titleVeranstaltung = $this->conf['veranstaltungen.']['veranstaltungs_titel'];
        $username = $GLOBALS['TSFE']->fe_user->user['username'];
        $userTermine = $this->userTermine($username);
        $bodyHtml = '<p>' . $anrede . '</p>';
        if (count($userTermine) == 0) {
            $bodyHtml .= '<p>Aktuell sind keine Veranstaltungen für Sie gebucht</p>';
        } else {
            $bodyHtml .= '<p>Aktuell sind folgende Veranstaltungen für Sie gebucht:</p>
										<table>
										';
            foreach ($userTermine as $termin) {
                $this->gibTerminDetails($termin, $titel, $ort, $raum, $datum, $uhrzeit);
                $bodyHtml .= '<tr class="title"><th colspan="2">' . $titleVeranstaltung . ': ' . $titel . '</th></tr>
								<tr><td class="right">Datum:</td><td>' . $datum . '</td></tr>
								<tr><td class="right">Zeit:</td><td>' . $uhrzeit . '</td></tr>
								<tr><td class="right">Ort:</td><td>' . $ort . '</td></tr>
								<tr><td class="right">Raum:</td><td>' . $raum . '</td></tr>
				';
            }
            $bodyHtml .= '</table>
									';
        }
        $bodyHtml .= '<p>' . $footer . '</p>';
        $bodyPlain = strip_tags($bodyHtml);
        $mail->setFrom($sender);
        $mail->setTo($email);
        $mail->setSubject($subject);
        $htmlComplete = $this->initHtml($subject) . $bodyHtml . $this->exitHtml();
        $mail->setBody($htmlComplete, 'text/html');
        $mail->addPart($bodyPlain, 'text/plain');
        $erg = $mail->send();
        if (!$erg) {
            $failedRecipients = $mail->getFailedRecipients();
            t3lib_div::devlog('E-Mail-Versand fehlgeschlagen!', 'fe_managment', 0, $failedRecipients);
        }
        return $erg;
    }
 /**
  * This method generates the repository class object, which is passed to the template
  * it keeps all methods and properties including user modified method bodies and comments
  * needed to create a repository class file
  *
  * @param Tx_ExtensionBuilder_Domain_Model_DomainObject $domainObject
  * @param boolean $mergeWithExistingClass
  *
  * @return Tx_ExtensionBuilder_Domain_Model_Class_Class
  */
 public function generateRepositoryClassObject($domainObject, $mergeWithExistingClass)
 {
     t3lib_div::devlog('------------------------------------- generateRepositoryClassObject(' . $domainObject->getName() . ') ---------------------------------', 'extension_builder', 1);
     $this->classObject = NULL;
     $className = $domainObject->getDomainRepositoryClassName();
     if ($mergeWithExistingClass) {
         try {
             $this->classObject = $this->roundTripService->getRepositoryClass($domainObject);
         } catch (Exception $e) {
             t3lib_div::devLog('Class ' . $className . ' could not be imported: ' . $e->getMessage(), 'extension_builder');
         }
     }
     if ($this->classObject == NULL) {
         $this->classObject = new Tx_ExtensionBuilder_Domain_Model_Class_Class($className);
         if (isset($this->settings['Repository']['parentClass'])) {
             $parentClass = $this->settings['Repository']['parentClass'];
         } else {
             $parentClass = 'Tx_Extbase_Persistence_Repository';
         }
         $this->classObject->setParentClass($parentClass);
     }
     return $this->classObject;
 }
 /**
  * Adds one (or multiple) properties found in a source code line to the classObject
  *
  * @param array $propertyMatches as returned from preg_match_all
  */
 protected function addProperty(array $propertyMatches, $startLine = NULL)
 {
     $properties = array_combine($propertyMatches['name'], $propertyMatches['value']);
     $isFirstProperty = TRUE;
     foreach ($properties as $propertyName => $propertyValue) {
         try {
             // the property has to exist in the classReflection
             $reflectionProperty = $this->classReflection->getProperty($propertyName);
             if ($reflectionProperty) {
                 $classProperty = new Tx_ExtensionBuilder_Domain_Model_Class_Property($propertyName);
                 $classProperty->mapToReflectionProperty($reflectionProperty);
                 // get the default value from regex matches
                 if (!empty($propertyValue)) {
                     if (strlen($classProperty->getVarType()) < 1) {
                         // try to detect the varType from default value
                         if (strpos($propertyValue, 'array') > -1) {
                             $varType = 'array';
                         } else {
                             eval('$varType = gettype(' . $propertyValue . ');');
                         }
                         if (!empty($varType) && $varType != 'NULL') {
                             $classProperty->setVarType($varType);
                         }
                     }
                     $classProperty->setValue(trim($propertyValue));
                     $classProperty->setDefault(TRUE);
                 }
                 if ($isFirstProperty) {
                     // only the first property will get the preceding block assigned
                     $precedingBlock = $this->concatLinesFromArray($this->lines, $this->lastMatchedLineNumber, $startLine, FALSE);
                     $classProperty->setPrecedingBlock($precedingBlock);
                     $isFirstProperty = FALSE;
                 }
                 $this->classObject->addProperty($classProperty);
                 $this->lastMatchedLineNumber = $this->lineCount;
             } else {
                 throw new Tx_ExtensionBuilder_Exception_ParseError(' Property ' . $propertyName . ' does not exist. Parsed from line ' . $this->lineCount . 'in ' . $this->classReflection->getFileName());
             }
         } catch (ReflectionException $e) {
             // ReflectionClass throws an exception if a property was not found
             t3lib_div::devlog('Exception in line : ' . $e->getMessage() . 'Property ' . $propertyName . ' found in line ' . $this->lineCount, 'extension_builder');
         }
     }
 }
 /**
  * zzFfValue: Returns the value of the given flexform field
  *
  * @param	[type]		$$sheet: ...
  * @param	[type]		$field: ...
  * @param	[type]		$drs: ...
  * @return	mixed		$value  : Value from the flexform field
  * @version 2.0.0
  * @since   2.0.0
  */
 public function zzFfValue($sheet, $field, $drs = true)
 {
     $pi_flexform = $this->row['pi_flexform'];
     $value = $this->pObj->pi_getFFvalue($pi_flexform, $field, $sheet, 'lDEF', 'vDEF');
     // RETURN : Don't prompt to DRS
     if (!$drs) {
         return $value;
     }
     // RETURN : Don't prompt to DRS
     // RETURN : DRS is disabled
     if (!$this->pObj->b_drs_flexform) {
         return $value;
     }
     // RETURN : DRS is disabled
     // DRS
     $prompt = $sheet . '.' . $field . ': "' . $value . '"';
     t3lib_div::devlog('[INFO/FLEXFORM] ' . $prompt, $this->pObj->extKey, 0);
     // DRS
     return $value;
 }
示例#18
0
 /**
  * Read URL for single queue entry
  *
  * @param	integer		Queue entry id
  * @param	boolean		If set, will process even if exec_time has been set!
  * @return	int
  */
 function readUrl($queueId, $force = FALSE)
 {
     $ret = 0;
     if ($this->debugMode) {
         t3lib_div::devlog('crawler-readurl start ' . microtime(true), __FUNCTION__);
     }
     // Get entry:
     list($queueRec) = $this->db->exec_SELECTgetRows('*', 'tx_crawler_queue', 'qid=' . intval($queueId) . ($force ? '' : ' AND exec_time=0 AND process_scheduled > 0'));
     if (is_array($queueRec)) {
         // Set exec_time to lock record:
         $field_array = array('exec_time' => $this->getCurrentTime());
         if (isset($this->processID)) {
             //if mulitprocessing is used we need to store the id of the process which has handled this entry
             $field_array['process_id_completed'] = $this->processID;
         }
         $this->db->exec_UPDATEquery('tx_crawler_queue', 'qid=' . intval($queueId), $field_array);
         $result = $this->readUrl_exec($queueRec);
         $resultData = unserialize($result['content']);
         //atm there's no need to point to specific pollable extensions
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pollSuccess'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pollSuccess'] as $pollable) {
                 // only check the success value if the instruction is runnig
                 // it is important to name the pollSuccess key same as the procInstructions key
                 if (is_array($resultData['parameters']['procInstructions']) && in_array($pollable, $resultData['parameters']['procInstructions'])) {
                     if (!empty($resultData['success'][$pollable]) && $resultData['success'][$pollable]) {
                         $ret |= self::CLI_STATUS_POLLABLE_PROCESSED;
                     }
                 }
             }
         }
         // Set result in log which also denotes the end of the processing of this entry.
         $field_array = array('result_data' => serialize($result));
         $this->db->exec_UPDATEquery('tx_crawler_queue', 'qid=' . intval($queueId), $field_array);
     }
     if ($this->debugMode) {
         t3lib_div::devlog('crawler-readurl stop ' . microtime(true), __FUNCTION__);
     }
     return $ret;
 }
 /**
  * Set the booleans for Warnings, Errors and DRS - Development Reporting System
  *
  * @return  void
  * @version 1.2.2
  * @since 0.0.2
  */
 private function init_drs()
 {
     //////////////////////////////////////////////////////////////////////
     //
     // Prepaire the developer contact prompt
     $this->developer_contact = 'company: ' . $this->str_developer_company . '<br />' . 'name: ' . $this->str_developer_name . '<br />' . 'mail: <a href="mailto:' . $this->str_developer_mail . '" title="Send a mail">' . $this->str_developer_mail . '</a><br />' . 'web: <a href="' . $this->str_developer_web . '" title="Website" target="_blank">' . $this->str_developer_web . '</a><br />' . 'phone: ' . $this->str_developer_phone . '<br />' . 'languages: ' . $this->str_developer_lang . '<br /><br />' . 'TYPO3 Repository:<br /><a href="' . $this->str_developer_typo3ext . '" title="' . $this->extKey . ' online" target="_blank">' . $this->str_developer_typo3ext . '</a>';
     // Prepaire the developer contact prompt
     //////////////////////////////////////////////////////////////////////
     //
     // Set the DRS mode
     if ($this->arr_extConf['drs_mode'] == 'All') {
         $this->b_drs_all = true;
         $this->b_drs_error = true;
         $this->b_drs_warn = true;
         $this->b_drs_info = true;
         $this->b_drs_flexform = true;
         $this->b_drs_marker = true;
         $this->b_drs_perform = true;
         $this->b_drs_typolink = true;
         $this->b_drs_security = true;
         $this->b_drs_typoscript = true;
         t3lib_div::devlog('[INFO/DRS] DRS - Development Reporting System:<br />' . $this->arr_extConf['drs_mode'], $this->extKey, 0);
     }
     if ($this->arr_extConf['drs_mode'] == 'Errors and Warnings') {
         $this->b_drs_error = true;
         $this->b_drs_warn = true;
         t3lib_div::devlog('[INFO/DRS] DRS - Development Reporting System:<br />' . $this->arr_extConf['drs_mode'], $this->extKey, 0);
     }
     if ($this->arr_extConf['drs_mode'] == 'Flexform') {
         $this->b_drs_error = true;
         $this->b_drs_warn = true;
         $this->b_drs_info = true;
         $this->b_drs_flexform = true;
         $this->b_drs_perform = true;
         $this->b_drs_typoscript = true;
         t3lib_div::devlog('[INFO/DRS] DRS - Development Reporting System:<br />' . $this->arr_extConf['drs_mode'], $this->extKey, 0);
     }
     if ($this->arr_extConf['drs_mode'] == 'Marker') {
         $this->b_drs_error = true;
         $this->b_drs_warn = true;
         $this->b_drs_info = true;
         $this->b_drs_marker = true;
         t3lib_div::devlog('[INFO/DRS] DRS - Development Reporting System:<br />' . $this->arr_extConf['drs_mode'], $this->extKey, 0);
     }
     if ($this->arr_extConf['drs_mode'] == 'Performance') {
         $this->b_drs_perform = true;
         t3lib_div::devlog('[INFO/DRS] DRS - Development Reporting System:<br />' . $this->arr_extConf['drs_mode'], $this->extKey, 0);
     }
     if ($this->arr_extConf['drs_mode'] == 'TypoLink') {
         $this->b_drs_error = true;
         $this->b_drs_warn = true;
         $this->b_drs_info = true;
         $this->b_drs_marker = true;
         $this->b_drs_typolink = true;
         t3lib_div::devlog('[INFO/DRS] DRS - Development Reporting System:<br />' . $this->arr_extConf['drs_mode'], $this->extKey, 0);
     }
     if ($this->arr_extConf['drs_mode'] == 'Security') {
         $this->b_drs_error = true;
         $this->b_drs_warn = true;
         $this->b_drs_info = true;
         $this->b_drs_security = true;
         t3lib_div::devlog('[INFO/DRS] DRS - Development Reporting System:<br />' . $this->arr_extConf['drs_mode'], $this->extKey, 0);
     }
     // Set the DRS mode
 }
 /**
  * access( ): The method checks, if current user is logged on the TYPO3 backend
  *            and if user is an administrator.
  *            If it is, the method defines the constant PDFCONTROLLER_ACCESS
  *
  * @return  void
  * @version 1.0.2
  * @since   1.0.2
  */
 private function access()
 {
     // RETURN no session because cookie is missing
     if (!isset($_COOKIE['be_typo_user'])) {
         if ($this->b_drs_security) {
             $prompt = 'No cookie with element be_typo_user.';
             t3lib_div::devlog('[INFO/SECURITY] ' . $prompt, $this->extKey, 0);
             $prompt = 'User doesn\'t get access.';
             t3lib_div::devlog('[OK/SECURITY] ' . $prompt, $this->extKey, -1);
         }
         return;
     }
     // RETURN no session because cookie is missing
     // RETURN no session because cookie element is empty
     if (empty($_COOKIE["be_typo_user"])) {
         if ($this->b_drs_security) {
             $prompt = 'Cookie element be_typo_user is empty.';
             t3lib_div::devlog('[INFO/SECURITY] ' . $prompt, $this->extKey, 0);
             $prompt = 'User doesn\'t get access.';
             t3lib_div::devlog('[OK/SECURITY] ' . $prompt, $this->extKey, -1);
         }
         return;
     }
     // RETURN no session because cookie element is empty
     // Get backend user id
     $select_fields = 'ses_userid';
     $from_table = 'be_sessions';
     // 120223, bjensen-
     //$where_clause   = 'ses_id = \'' . $GLOBALS['TYPO3_DB']->fullQuoteStr( $_COOKIE["be_typo_user"] ) . '\'';
     // 120223, bjensen+
     $where_clause = 'ses_id = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($_COOKIE["be_typo_user"], $from_table);
     $groupBy = '';
     $orderBy = '';
     $limit = '';
     $query = $GLOBALS['TYPO3_DB']->SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit);
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit);
     // 120223, dwildt+
     $error = $GLOBALS['TYPO3_DB']->sql_error();
     if ($error) {
         $prompt = '
               <h1>SQL ERROR</h1>
               <h2>TYPO3 PDF Controller</h2>
               <p>SQL error message: ' . $error . '</p>
               <p>SQL query: ' . $query . '</p>
               <p>Please post the error in the
                 <a href="http://typo3-pdfcontroller.de/">
                   TYPO3 PDF Controller forum</a>
               </p>
             ';
         die($prompt);
     }
     // 120223, dwildt+
     $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
     // Get backend user id
     // RETURN user isn't logged on the backend
     if (!is_array($row)) {
         if ($this->b_drs_security) {
             $prompt = 'Row is empty. User isn\'t logged on the backend';
             t3lib_div::devlog('[WARN/SECURITY] ' . $prompt, $this->extKey, 2);
             $prompt = 'Query: ' . $query;
             t3lib_div::devlog('[INFO/SECURITY] ' . $prompt, $this->extKey, 0);
             $prompt = 'User doesn\'t get access.';
             t3lib_div::devlog('[OK/SECURITY] ' . $prompt, $this->extKey, -1);
         }
         return;
     }
     // RETURN user isn't logged on the backend
     // RETURN ses_userid is empty
     if (empty($row['ses_userid'])) {
         if ($this->b_drs_security) {
             $prompt = 'Undefined error: field ses_userid of current row is empty.';
             t3lib_div::devlog('[ERROR/SECURITY] ' . $prompt, $this->extKey, 3);
             $prompt = 'Query: ' . $query;
             t3lib_div::devlog('[INFO/SECURITY] ' . $prompt, $this->extKey, 0);
             $prompt = 'User doesn\'t get access.';
             t3lib_div::devlog('[OK/SECURITY] ' . $prompt, $this->extKey, -1);
         }
         return;
     }
     // RETURN ses_userid is empty
     // Get backend user
     $select_fields = 'username, realName, admin';
     $from_table = 'be_users';
     $where_clause = 'uid = ' . (int) $row['ses_userid'];
     $groupBy = '';
     $orderBy = '';
     $limit = '';
     $query = $GLOBALS['TYPO3_DB']->SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit);
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit);
     $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
     // Get backend user id
     // RETURN row is empty
     if (!is_array($row)) {
         if ($this->b_drs_security) {
             $prompt = 'Undefined error: row is empty.';
             t3lib_div::devlog('[ERROR/SECURITY] ' . $prompt, $this->extKey, 3);
             $prompt = 'Query: ' . $query;
             t3lib_div::devlog('[INFO/SECURITY] ' . $prompt, $this->extKey, 0);
             $prompt = 'User doesn\'t get access.';
             t3lib_div::devlog('[OK/SECURITY] ' . $prompt, $this->extKey, -1);
         }
         return;
     }
     // RETURN row is empty
     // RETURN be_user isn't admin
     if (!($row['admin'] == 1)) {
         if ($this->b_drs_security) {
             $prompt = 'User ' . $row['realname'] . ' (' . $row['username'] . ') hasn\'t administrator access!';
             t3lib_div::devlog('[INFO/SECURITY] ' . $prompt, $this->extKey, 0);
             $prompt = 'User doesn\'t get access.';
             t3lib_div::devlog('[OK/SECURITY] ' . $prompt, $this->extKey, -1);
         }
         return;
     }
     // RETURN be_user isn't admin
     // DRS - Devleopment Reporting System
     if ($this->b_drs_security) {
         $prompt = 'User ' . $row['realName'] . ' (' . $row['username'] . ') has administrator access!';
         t3lib_div::devlog('[OK/SECURITY] ' . $prompt, $this->extKey, -1);
     }
     // DRS - Devleopment Reporting System
     // SUCCESS: PDFCONTROLLER_ACCESS will defined
     define('PDFCONTROLLER_ACCESS', true);
     return;
 }