Ejemplo n.º 1
0
 /**
  *
  * Substitutes markers in a template. Usually, this is just a wrapper method
  * around the \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray method. However, this
  * method is only available from TYPO3 4.2.
  *
  * @param  String $template The template
  * @param  Array  $marker   The markers that are to be replaced
  * @return String           The template with replaced markers
  *
  */
 static function substituteMarkerArray($template, $marker)
 {
     if (TYPO3_branch === '4.1' || TYPO3_branch === '4.0') {
         return str_replace(array_keys($marker), array_values($marker), $template);
     } else {
         return HtmlParser::substituteMarkerArray($template, $marker);
     }
 }
 /**
  * Main function
  * The main function of this class. Loads language variables and
  * calls subsidiary functions.
  *
  * @author  Martin Helmich <*****@*****.**>
  * @version 2008-01-08
  * @return  string  The output of this script.
  */
 function main()
 {
     $this->debug('Starting message notification');
     $user_res = $this->databaseHandle->exec_SELECTquery('*', 'fe_users', 'tx_mmforum_pmnotifymode = 1 AND deleted=0 AND disable=0 AND starttime < ' . $GLOBALS['EXEC_TIME'] . ' AND (endtime = 0 OR endtime <= ' . $GLOBALS['EXEC_TIME'] . ')');
     $template = $this->loadTemplateFile('notifyPM');
     if ($this->conf['cron_htmlemail']) {
         $template = HtmlParser::getSubpart($template, '###NOTIFY_HTML###');
     } else {
         $template = HtmlParser::getSubpart($template, '###NOTIFY_PLAINTEXT###');
     }
     $itemTemplate = HtmlParser::getSubpart($template, '###NOTIFY_LISTITEM###');
     $content = '';
     while ($user_arr = $this->databaseHandle->sql_fetch_assoc($user_res)) {
         $pm_res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_pminbox', 'to_uid=' . $user_arr['uid'] . ' AND notified=0 AND mess_type=0');
         $pm_content = '';
         if ($this->databaseHandle->sql_num_rows($pm_res) == 0) {
             $this->debug('No new messages for user ' . $user_arr['username'] . '. Continue with next user.');
             continue;
         } else {
             $this->debug($this->databaseHandle->sql_num_rows($pm_res) . ' new messages for user ' . $user_arr['username'] . '. Creating email.');
         }
         while ($pm_arr = $this->databaseHandle->sql_fetch_assoc($pm_res)) {
             $link = sprintf($this->conf['cron_pm_readlink'], $pm_arr['uid']);
             $cache_link = $this->getCacheValue_remove('pm.urlCache.' . $pm_arr['uid']);
             if ($cache_link !== false) {
                 $link = $cache_link;
             }
             $pm_marker = array('###NOTIFY_SUBJECT###' => $pm_arr['subject'], '###NOTIFY_DATE###' => $this->formatDate($pm_arr['sendtime']), '###NOTIFY_SENDER###' => $this->getUsername($pm_arr['from_uid']), '###NOTIFY_LINK###' => $link, '###LLL_BY###' => $this->getLL('by'), '###LLL_ON###' => $this->getLL('on'));
             $pm_content .= HtmlParser::substituteMarkerArray($itemTemplate, $pm_marker);
         }
         $user_content = HtmlParser::substituteSubpart($template, '###NOTIFY_LISTITEM###', $pm_content);
         $user_marker = array('###NOTIFY_SUBJECT###' => sprintf($this->getLL('subject'), $this->databaseHandle->sql_num_rows($pm_res)), '###NOTIFY_TEXT###' => sprintf($this->getLL('text'), $this->conf['cron_sitetitle'], $this->databaseHandle->sql_num_rows($pm_res)), '###NOTIFY_ADDRESS###' => sprintf($this->getLL('address'), $user_arr[$this->conf['userNameField'] ? $this->conf['userNameField'] : 'username']), '###NOTIFY_LINK###' => $this->conf['cron_pm_link'], '###LABEL_NOTIFY_SUBJECT###' => $this->getLL('subject'), '###LABEL_NOTIFY_SENDER###' => $this->getLL('sender'), '###LABEL_NOTIFY_DATE###' => $this->getLL('date'));
         $user_content = HtmlParser::substituteMarkerArray($user_content, $user_marker);
         $subject = sprintf($this->getLL('mailSubject'), $this->conf['cron_sitetitle'], $this->databaseHandle->sql_num_rows($pm_res));
         $username = $user_arr['name'] ? $user_arr['name'] : $user_arr['username'];
         $recipient = '"' . $username . '" <' . $user_arr['email'] . '>';
         $contenttype = $this->conf['cron_htmlemail'] ? 'text/html' : 'text/plain';
         $header = "Content-Type: {$contenttype}; charset=utf-8\n";
         $header .= "From: " . $this->conf['cron_notifyPublishSender'] . "\n";
         $content .= "Try to send mail({$recipient}, {$subject}, ...)\n";
         if (!@mail($recipient, $subject, $user_content, $header)) {
             $this->debug('Could not send email to ' . $recipient, $this->DEBUG_ERROR);
         } else {
             $this->debug('Email to user ' . $user_arr['username'] . ' was successfully sent.');
         }
     }
     $updateArray = array('notified' => 1, 'tstamp' => $GLOBALS['EXEC_TIME']);
     $this->databaseHandle->exec_UPDATEquery('tx_mmforum_pminbox', 'notified=0', $updateArray);
     $this->content = $content;
 }
Ejemplo n.º 3
0
    /**
     * Send an email notification to users in workspace
     *
     * @param array $stat Workspace access array from \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::checkWorkspace()
     * @param int $stageId New Stage number: 0 = editing, 1= just ready for review, 10 = ready for publication, -1 = rejected!
     * @param string $table Table name of element (or list of element names if $id is zero)
     * @param int $id Record uid of element (if zero, then $table is used as reference to element(s) alone)
     * @param string $comment User comment sent along with action
     * @param DataHandler $tcemainObj TCEmain object
     * @param array $notificationAlternativeRecipients List of recipients to notify instead of be_users selected by sys_workspace, list is generated by workspace extension module
     * @return void
     */
    protected function notifyStageChange(array $stat, $stageId, $table, $id, $comment, DataHandler $tcemainObj, array $notificationAlternativeRecipients = array())
    {
        $workspaceRec = BackendUtility::getRecord('sys_workspace', $stat['uid']);
        // So, if $id is not set, then $table is taken to be the complete element name!
        $elementName = $id ? $table . ':' . $id : $table;
        if (!is_array($workspaceRec)) {
            return;
        }
        // Get the new stage title from workspaces library, if workspaces extension is installed
        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces')) {
            $stageService = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\StagesService::class);
            $newStage = $stageService->getStageTitle((int) $stageId);
        } else {
            // @todo CONSTANTS SHOULD BE USED - tx_service_workspace_workspaces
            // @todo use localized labels
            // Compile label:
            switch ((int) $stageId) {
                case 1:
                    $newStage = 'Ready for review';
                    break;
                case 10:
                    $newStage = 'Ready for publishing';
                    break;
                case -1:
                    $newStage = 'Element was rejected!';
                    break;
                case 0:
                    $newStage = 'Rejected element was noticed and edited';
                    break;
                default:
                    $newStage = 'Unknown state change!?';
            }
        }
        if (count($notificationAlternativeRecipients) == 0) {
            // Compile list of recipients:
            $emails = array();
            switch ((int) $stat['stagechg_notification']) {
                case 1:
                    switch ((int) $stageId) {
                        case 1:
                            $emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']);
                            break;
                        case 10:
                            $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
                            break;
                        case -1:
                            // List of elements to reject:
                            $allElements = explode(',', $elementName);
                            // Traverse them, and find the history of each
                            foreach ($allElements as $elRef) {
                                list($eTable, $eUid) = explode(':', $elRef);
                                $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('log_data,tstamp,userid', 'sys_log', 'action=6 and details_nr=30
												AND tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($eTable, 'sys_log') . '
												AND recuid=' . (int) $eUid, '', 'uid DESC');
                                // Find all implicated since the last stage-raise from editing to review:
                                foreach ($rows as $dat) {
                                    $data = unserialize($dat['log_data']);
                                    $emails = $this->getEmailsForStageChangeNotification($dat['userid'], TRUE) + $emails;
                                    if ($data['stage'] == 1) {
                                        break;
                                    }
                                }
                            }
                            break;
                        case 0:
                            $emails = $this->getEmailsForStageChangeNotification($workspaceRec['members']);
                            break;
                        default:
                            $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
                    }
                    break;
                case 10:
                    $emails = $this->getEmailsForStageChangeNotification($workspaceRec['adminusers'], TRUE);
                    $emails = $this->getEmailsForStageChangeNotification($workspaceRec['reviewers']) + $emails;
                    $emails = $this->getEmailsForStageChangeNotification($workspaceRec['members']) + $emails;
                    break;
                default:
                    // Do nothing
            }
        } else {
            $emails = $notificationAlternativeRecipients;
        }
        // prepare and then send the emails
        if (count($emails)) {
            // Path to record is found:
            list($elementTable, $elementUid) = explode(':', $elementName);
            $elementUid = (int) $elementUid;
            $elementRecord = BackendUtility::getRecord($elementTable, $elementUid);
            $recordTitle = BackendUtility::getRecordTitle($elementTable, $elementRecord);
            if ($elementTable == 'pages') {
                $pageUid = $elementUid;
            } else {
                BackendUtility::fixVersioningPid($elementTable, $elementRecord);
                $pageUid = $elementUid = $elementRecord['pid'];
            }
            // fetch the TSconfig settings for the email
            // old way, options are TCEMAIN.notificationEmail_body/subject
            $TCEmainTSConfig = $tcemainObj->getTCEMAIN_TSconfig($pageUid);
            // new way, options are
            // pageTSconfig: tx_version.workspaces.stageNotificationEmail.subject
            // userTSconfig: page.tx_version.workspaces.stageNotificationEmail.subject
            $pageTsConfig = BackendUtility::getPagesTSconfig($pageUid);
            $emailConfig = $pageTsConfig['tx_version.']['workspaces.']['stageNotificationEmail.'];
            $markers = array('###RECORD_TITLE###' => $recordTitle, '###RECORD_PATH###' => BackendUtility::getRecordPath($elementUid, '', 20), '###SITE_NAME###' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], '###SITE_URL###' => GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, '###WORKSPACE_TITLE###' => $workspaceRec['title'], '###WORKSPACE_UID###' => $workspaceRec['uid'], '###ELEMENT_NAME###' => $elementName, '###NEXT_STAGE###' => $newStage, '###COMMENT###' => $comment, '###USER_REALNAME###' => $tcemainObj->BE_USER->user['realName'], '###USER_FULLNAME###' => $tcemainObj->BE_USER->user['realName'], '###USER_USERNAME###' => $tcemainObj->BE_USER->user['username']);
            // add marker for preview links if workspace extension is loaded
            if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces')) {
                $this->workspaceService = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class);
                // only generate the link if the marker is in the template - prevents database from getting to much entries
                if (GeneralUtility::isFirstPartOfStr($emailConfig['message'], 'LLL:')) {
                    $tempEmailMessage = $GLOBALS['LANG']->sL($emailConfig['message']);
                } else {
                    $tempEmailMessage = $emailConfig['message'];
                }
                if (strpos($tempEmailMessage, '###PREVIEW_LINK###') !== FALSE) {
                    $markers['###PREVIEW_LINK###'] = $this->workspaceService->generateWorkspacePreviewLink($elementUid);
                }
                unset($tempEmailMessage);
                $markers['###SPLITTED_PREVIEW_LINK###'] = $this->workspaceService->generateWorkspaceSplittedPreviewLink($elementUid, TRUE);
            }
            // Hook for preprocessing of the content for formmails:
            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/version/class.tx_version_tcemain.php']['notifyStageChange-postModifyMarkers'])) {
                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/version/class.tx_version_tcemain.php']['notifyStageChange-postModifyMarkers'] as $_classRef) {
                    $_procObj =& GeneralUtility::getUserObj($_classRef);
                    $markers = $_procObj->postModifyMarkers($markers, $this);
                }
            }
            // send an email to each individual user, to ensure the
            // multilanguage version of the email
            $emailRecipients = array();
            // an array of language objects that are needed
            // for emails with different languages
            $languageObjects = array($GLOBALS['LANG']->lang => $GLOBALS['LANG']);
            // loop through each recipient and send the email
            foreach ($emails as $recipientData) {
                // don't send an email twice
                if (isset($emailRecipients[$recipientData['email']])) {
                    continue;
                }
                $emailSubject = $emailConfig['subject'];
                $emailMessage = $emailConfig['message'];
                $emailRecipients[$recipientData['email']] = $recipientData['email'];
                // check if the email needs to be localized
                // in the users' language
                if (GeneralUtility::isFirstPartOfStr($emailSubject, 'LLL:') || GeneralUtility::isFirstPartOfStr($emailMessage, 'LLL:')) {
                    $recipientLanguage = $recipientData['lang'] ? $recipientData['lang'] : 'default';
                    if (!isset($languageObjects[$recipientLanguage])) {
                        // a LANG object in this language hasn't been
                        // instantiated yet, so this is done here
                        /** @var $languageObject \TYPO3\CMS\Lang\LanguageService */
                        $languageObject = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class);
                        $languageObject->init($recipientLanguage);
                        $languageObjects[$recipientLanguage] = $languageObject;
                    } else {
                        $languageObject = $languageObjects[$recipientLanguage];
                    }
                    if (GeneralUtility::isFirstPartOfStr($emailSubject, 'LLL:')) {
                        $emailSubject = $languageObject->sL($emailSubject);
                    }
                    if (GeneralUtility::isFirstPartOfStr($emailMessage, 'LLL:')) {
                        $emailMessage = $languageObject->sL($emailMessage);
                    }
                }
                $emailSubject = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($emailSubject, $markers, '', TRUE, TRUE);
                $emailMessage = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($emailMessage, $markers, '', TRUE, TRUE);
                // Send an email to the recipient
                /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
                $mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
                if (!empty($recipientData['realName'])) {
                    $recipient = array($recipientData['email'] => $recipientData['realName']);
                } else {
                    $recipient = $recipientData['email'];
                }
                $mail->setTo($recipient)->setSubject($emailSubject)->setFrom(\TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom())->setBody($emailMessage);
                $mail->send();
            }
            $emailRecipients = implode(',', $emailRecipients);
            $tcemainObj->newlog2('Notification email for stage change was sent to "' . $emailRecipients . '"', $table, $id);
        }
    }
Ejemplo n.º 4
0
 /**
  * Render the page but not the JavaScript and CSS Files
  *
  * @param string $substituteHash The hash that is used for the placehoder markers
  * @access private
  * @return string Content of rendered section
  */
 public function renderPageWithUncachedObjects($substituteHash)
 {
     $this->prepareRendering();
     $markerArray = $this->getPreparedMarkerArrayForPageWithUncachedObjects($substituteHash);
     $template = $this->getTemplateForPart(self::PART_COMPLETE);
     return trim(\TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($template, $markerArray, '###|###'));
 }
Ejemplo n.º 5
0
 /**
  * Builds the checkboxes out of the hooks array
  *
  * @param array $brokenLinkOverView Array of broken links information
  * @param string $prefix
  * @return string code content
  */
 protected function getCheckOptions(array $brokenLinkOverView, $prefix = '')
 {
     $markerArray = array();
     if (!empty($prefix)) {
         $additionalAttr = ' class="' . $prefix . '"';
     } else {
         $additionalAttr = ' class="refresh"';
     }
     $checkOptionsTemplate = HtmlParser::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
     $hookSectionTemplate = HtmlParser::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
     $markerArray['statistics_header'] = $this->doc->sectionHeader($this->getLanguageService()->getLL('report.statistics.header'));
     $markerArray['total_count_label'] = BackendUtility::wrapInHelp('linkvalidator', 'checkboxes', $this->getLanguageService()->getLL('overviews.nbtotal'));
     $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount'] ?: '0';
     $linktypes = GeneralUtility::trimExplode(',', $this->modTS['linktypes'], TRUE);
     $hookSectionContent = '';
     if (is_array($linktypes)) {
         if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $type => $value) {
                 if (in_array($type, $linktypes)) {
                     $hookSectionMarker = array('count' => $brokenLinkOverView[$type] ?: '0');
                     $translation = $this->getLanguageService()->getLL('hooks.' . $type) ?: $type;
                     $hookSectionMarker['option'] = '<input type="checkbox"' . $additionalAttr . ' id="' . $prefix . 'SET_' . $type . '" name="' . $prefix . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') . '/>' . '<label for="' . $prefix . 'SET_' . $type . '">' . htmlspecialchars($translation) . '</label>';
                     $hookSectionContent .= HtmlParser::substituteMarkerArray($hookSectionTemplate, $hookSectionMarker, '###|###', TRUE, TRUE);
                 }
             }
         }
     }
     $checkOptionsTemplate = HtmlParser::substituteSubpart($checkOptionsTemplate, '###HOOK_SECTION###', $hookSectionContent);
     return HtmlParser::substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE);
 }
Ejemplo n.º 6
0
 /**
  * Returns HTML-code, which is a visual representation of a multidimensional array
  * Returns FALSE if $array_in is not an array
  *
  * @param mixed $incomingValue Array to view
  * @return string HTML output
  * @todo Define visibility
  */
 public function viewArray($incomingValue)
 {
     // Get the template file
     $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'ViewArray.html');
     if (is_array($incomingValue) && !empty($incomingValue)) {
         // Get the template part from the file
         $content = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($templateFile, '###TEMPLATE###');
         // Get the subpart for a single item
         $itemSubpart = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($content, '###ITEM###');
         foreach ($incomingValue as $key => $value) {
             if (is_array($value)) {
                 $description = $this->viewArray($value);
             } elseif (is_object($value)) {
                 $description = get_class($value);
                 if (method_exists($value, '__toString')) {
                     $description .= ': ' . (string) $value;
                 }
             } else {
                 if (gettype($value) == 'object') {
                     $description = 'Unknown object';
                 } else {
                     $description = htmlspecialchars((string) $value);
                 }
             }
             // Define the markers content
             $itemMarkers = array('key' => htmlspecialchars((string) $key), 'description' => !empty($description) ? $description : '&nbsp;');
             // Fill the markers in the subpart
             $items[] = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($itemSubpart, $itemMarkers, '###|###', TRUE, FALSE);
         }
         // Substitute the subpart for single item
         $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($content, '###ITEM###', implode(LF, $items));
     }
     return $content;
 }
Ejemplo n.º 7
0
 /**
  * Generates the css files
  *
  * @return void
  */
 protected function generateCSS()
 {
     $cssData = '';
     if ($this->includeTimestampInCSS) {
         $timestamp = '?' . time();
     } else {
         $timestamp = '';
     }
     $spritePathForCSS = $this->resolveSpritePath();
     $markerArray = array('###NAMESPACE###' => $this->nameSpace, '###DEFAULTWIDTH###' => $this->defaultWidth, '###DEFAULTHEIGHT###' => $this->defaultHeight, '###SPRITENAME###' => '', '###SPRITEURL###' => $spritePathForCSS ? $spritePathForCSS . '/' : '');
     $markerArray['###SPRITEURL###'] .= $this->spriteName . '.png' . $timestamp;
     foreach ($this->spriteBases as $base) {
         $markerArray['###SPRITENAME###'] = $base;
         $cssData .= \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($this->templateSprite, $markerArray);
     }
     foreach ($this->iconsData as $key => $data) {
         $temp = $data['iconNameParts'];
         array_shift($temp);
         $cssName = implode('-', $temp);
         $markerArrayIcons = array('###NAMESPACE###' => $this->nameSpace, '###ICONNAME###' => $cssName, '###LEFT###' => $data['left'], '###TOP###' => $data['top'], '###SIZE_INFO###' => '');
         if ($data['height'] != $this->defaultHeight) {
             $markerArrayIcons['###SIZE_INFO###'] .= TAB . 'height: ' . $data['height'] . 'px;' . LF;
         }
         if ($data['width'] != $this->defaultWidth) {
             $markerArrayIcons['###SIZE_INFO###'] .= TAB . 'width: ' . $data['width'] . 'px;' . LF;
         }
         $cssData .= \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($this->templateIcon, $markerArrayIcons);
     }
     \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_site . $this->cssFolder . $this->spriteName . '.css', $cssData);
 }
Ejemplo n.º 8
0
 /**
  * Fill the button lists with the defined HTML
  *
  * @param array $buttons HTML for all buttons
  * @return array Containing HTML for both buttonlists
  */
 protected function getDocHeaderButtons($buttons)
 {
     $markers = array();
     // Fill buttons for left and right float
     $floats = array('left', 'right');
     foreach ($floats as $key) {
         // Get the template for each float
         $buttonTemplate = HtmlParser::getSubpart($this->moduleTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
         // Fill the button markers in this float
         $buttonTemplate = HtmlParser::substituteMarkerArray($buttonTemplate, $buttons, '###|###', TRUE);
         // getting the wrap for each group
         $buttonWrap = HtmlParser::getSubpart($this->moduleTemplate, '###BUTTON_GROUP_WRAP###');
         // looping through the groups (max 6) and remove the empty groups
         for ($groupNumber = 1; $groupNumber < 6; $groupNumber++) {
             $buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###';
             $buttonGroup = HtmlParser::getSubpart($buttonTemplate, $buttonMarker);
             if (trim($buttonGroup)) {
                 if ($buttonWrap) {
                     $buttonGroup = HtmlParser::substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
                 }
                 $buttonTemplate = HtmlParser::substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
             }
         }
         // Replace the marker with the template and remove all line breaks (for IE compat)
         $markers['BUTTONLIST_' . strtoupper($key)] = str_replace(LF, '', $buttonTemplate);
     }
     // Hook for manipulating docHeaderButtons
     if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'])) {
         $params = array('buttons' => $buttons, 'markers' => &$markers, 'pObj' => &$this);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'] as $funcRef) {
             GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
     return $markers;
 }
Ejemplo n.º 9
0
 /**
  * Traverses the input $markContentArray array and for each key the marker
  * by the same name (possibly wrapped and in upper case) will be
  * substituted with the keys value in the array.
  *
  * This is very useful if you have a data-record to substitute in some
  * content. In particular when you use the $wrap and $uppercase values to
  * pre-process the markers. Eg. a key name like "myfield" could effectively
  * be represented by the marker "###MYFIELD###" if the wrap value
  * was "###|###" and the $uppercase boolean TRUE.
  *
  * @param string $content The content stream, typically HTML template content.
  * @param array $markContentArray The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content.
  * @param string $wrap A wrap value - [part 1] | [part 2] - for the markers before substitution
  * @param bool $uppercase If set, all marker string substitution is done with upper-case markers.
  * @param bool $deleteUnused If set, all unused marker are deleted.
  * @return string The processed output stream
  * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE()
  */
 public function substituteMarkerArray($content, array $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE)
 {
     return HtmlParser::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
 }
Ejemplo n.º 10
0
 /**
  * Replace the marker with recipient data and then send it
  *
  * @param	string		$content: the HTML or plaintext part
  * @param	array		$recipRow: Recipient's data array
  * @param	array		$markers: existing markers that are mail-specific, not user-specific
  * @return	integer		which kind of email is sent, 1 = HTML, 2 = plain, 3 = both
  */
 function replaceMailMarkers($content, $recipRow, $markers)
 {
     //replace %23%23%23 with ###, since typolink generated link with urlencode
     $content = str_replace('%23%23%23', '###', $content);
     $rowFieldsArray = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['defaultRecipFields']);
     if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['addRecipFields']) {
         $rowFieldsArray = array_merge($rowFieldsArray, GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['addRecipFields']));
     }
     foreach ($rowFieldsArray as $substField) {
         $subst = $GLOBALS['LANG']->csConvObj->conv($recipRow[$substField], $GLOBALS['LANG']->charSet, $this->charset);
         $markers['###USER_' . $substField . '###'] = $subst;
     }
     // uppercase fields with uppercased values
     $uppercaseFieldsArray = array('name', 'firstname');
     foreach ($uppercaseFieldsArray as $substField) {
         $subst = $GLOBALS['LANG']->csConvObj->conv($recipRow[$substField], $GLOBALS['LANG']->charSet, $this->charset);
         $markers['###USER_' . strtoupper($substField) . '###'] = strtoupper($subst);
     }
     // Hook allows to manipulate the markers to add salutation etc.
     if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/direct_mail']['res/scripts/class.dmailer.php']['mailMarkersHook'])) {
         $mailMarkersHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/direct_mail']['res/scripts/class.dmailer.php']['mailMarkersHook'];
         if (is_array($mailMarkersHook)) {
             $hookParameters = array('row' => &$recipRow, 'markers' => &$markers);
             $hookReference =& $this;
             foreach ($mailMarkersHook as $hookFunction) {
                 GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookReference);
             }
         }
     }
     return HtmlParser::substituteMarkerArray($content, $markers);
 }
Ejemplo n.º 11
0
 /**
  * Creates HTML output for a palette
  *
  * @param array $palArr The palette array to print
  * @return string HTML output
  * @todo Define visibility
  */
 public function printPalette($palArr)
 {
     $fieldAttributes = $labelAttributes = '';
     // Init color/class attributes:
     if ($this->colorScheme[2]) {
         $labelAttributes .= ' bgcolor="' . $this->colorScheme[2] . '"';
     }
     if ($this->classScheme[2]) {
         $labelAttributes .= ' class="t3-form-palette-field-label ' . $this->classScheme[2] . '"';
     } else {
         $labelAttributes .= ' class="t3-form-palette-field-label"';
     }
     if ($this->colorScheme[4]) {
         $fieldAttributes .= ' style="color: ' . $this->colorScheme[4] . '"';
     }
     if ($this->classScheme[4]) {
         $fieldAttributes .= ' class="t3-form-palette-field ' . $this->classScheme[4] . '"';
     }
     $row = 0;
     $iRow = array();
     $lastLineWasLinebreak = FALSE;
     // Traverse palette fields and render them into containers:
     foreach ($palArr as $content) {
         if ($content['NAME'] === '--linebreak--') {
             if (!$lastLineWasLinebreak) {
                 $row++;
                 $lastLineWasLinebreak = TRUE;
             }
         } else {
             $lastLineWasLinebreak = FALSE;
             $paletteMarkers = array('###CONTENT_TABLE###' => $content['TABLE'], '###CONTENT_ID###' => $content['ID'], '###CONTENT_FIELD###' => $content['FIELD'], '###CONTENT_NAME###' => $content['NAME'], '###CONTENT_ITEM###' => $content['ITEM'], '###CONTENT_ITEM_NULLVALUE###' => $content['ITEM_NULLVALUE'], '###CONTENT_ITEM_DISABLED###' => $content['ITEM_DISABLED'], '###ATTRIBUTES_LABEL###' => $labelAttributes, '###ATTRIBUTES_FIELD###' => $fieldAttributes);
             $iRow[$row][] = HtmlParser::substituteMarkerArray($this->paletteFieldTemplate, $paletteMarkers, FALSE, TRUE);
         }
     }
     // Final wrapping into the fieldset:
     $out = '<fieldset class="t3-form-palette-fieldset">';
     for ($i = 0; $i <= $row; $i++) {
         if (isset($iRow[$i])) {
             $out .= implode('', $iRow[$i]);
             $out .= $i < $row ? '<br />' : '';
         }
     }
     $out .= '</fieldset>';
     return $out;
 }
Ejemplo n.º 12
0
 /**
  * Renders the loop for a given loop name.
  *
  * @param string $loopName Key from $this->loops to render
  */
 protected function renderLoop($loopName)
 {
     $loopContent = '';
     $loopTemplate = $this->getSubpart('LOOP:' . $loopName);
     $loopContentMarker = 'loop_content:' . $loopName;
     $loopSingleItem = $this->getSubpart($loopContentMarker, $loopTemplate);
     if (empty($loopSingleItem)) {
         // backwards compatible fallback for unnamed loops
         $loopContentMarker = 'loop_content';
         $loopSingleItem = $this->getSubpart($loopContentMarker, $loopTemplate);
     }
     $loopMarker = strtoupper($this->loops[$loopName]['marker']);
     $loopVariables = $this->loops[$loopName]['data'];
     $foundMarkers = $this->getMarkersFromTemplate($loopSingleItem, $loopMarker . '\\.');
     $loopCount = count($loopVariables);
     if (count($foundMarkers)) {
         $iterationCount = 0;
         foreach ($loopVariables as $value) {
             // escape content and title
             if (isset($value['content'])) {
                 $value['content'] = $this->escapeResultContent($value['content']);
             }
             if (isset($value['title'])) {
                 $value['title'] = htmlspecialchars($value['title'], NULL, NULL, FALSE);
             }
             $resolvedMarkers = $this->resolveVariableMarkers($foundMarkers, $value);
             $resolvedMarkers['LOOP_CURRENT_ITERATION_COUNT'] = ++$iterationCount;
             // pass the whole object / array / variable as is (serialized though)
             $resolvedMarkers[$loopMarker] = serialize($value);
             $currentIterationContent = HtmlParser::substituteMarkerArray($loopSingleItem, $resolvedMarkers, '###|###');
             $inLoopMarkers = $this->getMarkersFromTemplate($currentIterationContent, 'LOOP:', FALSE);
             $inLoopMarkers = $this->filterProtectedLoops($inLoopMarkers);
             $currentIterationContent = $this->processInLoopMarkers($currentIterationContent, $loopName, $inLoopMarkers, $value);
             $currentIterationContent = $this->processConditions($currentIterationContent);
             $loopContent .= $currentIterationContent;
         }
     }
     $loopContent = HtmlParser::substituteSubpart($loopTemplate, '###' . strtoupper($loopContentMarker) . '###', $loopContent);
     $loopContent = HtmlParser::substituteMarkerArray($loopContent, array('LOOP_ELEMENT_COUNT' => $loopCount), '###|###');
     $this->workOnSubpart = HtmlParser::substituteSubpart($this->workOnSubpart, '###LOOP:' . strtoupper($loopName) . '###', $loopContent);
 }
 /**
  * Generates the notification email content.
  * This function generates the content of the notification email that is to
  * be sent. The result of this function is stored into the attribute $this->postqueueMail.
  *
  * @author  Martin Helmich <*****@*****.**>
  * @version 2008-06-22
  * @return  void
  */
 function generateOutput()
 {
     $template = $this->loadTemplateFile('notifyPublish');
     if ($this->conf['cron_htmlemail']) {
         $template = HtmlParser::getSubpart($template, '###PNOTIFY_HTML###');
     } else {
         $template = HtmlParser::getSubpart($template, '###PNOTIFY_PLAINTEXT###');
     }
     $itemTemplate = HtmlParser::getSubpart($template, '###PNOTIFY_LISTITEM###');
     $marker = array('###PNOTIFY_SUBJECT###' => sprintf($this->getLL('subject'), count($this->postqueueItems)), '###PNOTIFY_TEXT###' => sprintf($this->getLL('text'), $this->conf['cron_sitetitle'], count($this->postqueueItems)), '###PNOTIFY_LINK###' => $this->conf['cron_postqueue_link'], '###LABEL_PNOTIFY_TOPICTITLE###' => $this->getLL('topictitle'), '###LABEL_PNOTIFY_TOPICDATE###' => $this->getLL('topicdate'), '###LABEL_PNOTIFY_TOPICAUTHOR###' => $this->getLL('topicauthor'), '###LABEL_PNOTIFY_TOPICFORUM###' => $this->getLL('topicforum'));
     $template = HtmlParser::substituteMarkerArray($template, $marker);
     $itemContent = '';
     foreach ($this->postqueueItems as $postqueueItem) {
         $itemMarker = array('###PNOTIFY_TOPICTITLE###' => $this->getTopicTitle($postqueueItem), '###PNOTIFY_TOPICAUTHOR###' => $this->getTopicAuthor($postqueueItem['post_user']), '###PNOTIFY_TOPICDATE###' => date('d. m. Y, H:i', $postqueueItem['post_time']), '###PNOTIFY_TOPICFORUM###' => $this->getTopicForum($postqueueItem));
         $itemContent .= HtmlParser::substituteMarkerArray($itemTemplate, $itemMarker);
     }
     $template = HtmlParser::substituteSubpart($template, '###PNOTIFY_LISTITEM###', $itemContent);
     $this->postqueueMail = $template;
 }
Ejemplo n.º 14
0
 /**
  * Make login news - renders the HTML content for a list of news shown under
  * the login form. News data is added through sys_news records
  *
  * @return string HTML content
  * @credits Idea by Jan-Hendrik Heuing
  * @todo Define visibility
  */
 public function makeLoginNews()
 {
     $newsContent = '';
     $systemNews = $this->getSystemNews();
     // Traverse news array IF there are records in it:
     if (is_array($systemNews) && count($systemNews) && !GeneralUtility::_GP('loginRefresh')) {
         /** @var $htmlParser \TYPO3\CMS\Core\Html\RteHtmlParser */
         $htmlParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\RteHtmlParser');
         $htmlParser->procOptions['dontHSC_rte'] = TRUE;
         // Get the main news template, and replace the subpart after looped through
         $newsContent = HtmlParser::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_NEWS###');
         $newsItemTemplate = HtmlParser::getSubpart($newsContent, '###NEWS_ITEM###');
         $newsItem = '';
         $count = 1;
         foreach ($systemNews as $newsItemData) {
             $additionalClass = '';
             if ($count == 1) {
                 $additionalClass = ' first-item';
             } elseif ($count == count($systemNews)) {
                 $additionalClass = ' last-item';
             }
             $newsItemContent = $htmlParser->TS_transform_rte($htmlParser->TS_links_rte($newsItemData['content']));
             $newsItemMarker = array('###HEADER###' => htmlspecialchars($newsItemData['header']), '###DATE###' => htmlspecialchars($newsItemData['date']), '###CONTENT###' => $newsItemContent, '###CLASS###' => $additionalClass);
             $count++;
             $newsItem .= HtmlParser::substituteMarkerArray($newsItemTemplate, $newsItemMarker);
         }
         $title = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] : $GLOBALS['LANG']->getLL('newsheadline');
         $newsContent = HtmlParser::substituteMarker($newsContent, '###NEWS_HEADLINE###', htmlspecialchars($title));
         $newsContent = HtmlParser::substituteSubpart($newsContent, '###NEWS_ITEM###', $newsItem);
     }
     return $newsContent;
 }
 /**
  * Renders the message.
  *
  * @return string The message as HTML.
  */
 public function render()
 {
     $markers = array_merge($this->getDefaultMarkers(), $this->markers);
     $content = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($this->htmlTemplate);
     $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($content, $markers, '', FALSE, TRUE);
     return $content;
 }
Ejemplo n.º 16
0
 /**
  * Build the mail content
  *
  * @param integer $curPage Id of the current page
  * @param string $pageList List of pages id
  * @param array $markerArray Array of markers
  * @param array $oldBrokenLink Marker array with the number of link found
  * @return string Content of the mail
  */
 protected function buildMail($curPage, $pageList, array $markerArray, array $oldBrokenLink)
 {
     $pageSectionHtml = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($this->templateMail, '###PAGE_SECTION###');
     // Hook
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['buildMailMarkers'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['buildMailMarkers'] as $userFunc) {
             $params = array('curPage' => $curPage, 'pageList' => $pageList, 'markerArray' => $markerArray, 'oldBrokenLink' => $oldBrokenLink, 'pObj' => &$this);
             $newMarkers = GeneralUtility::callUserFunction($userFunc, $params, $this);
             if (is_array($newMarkers)) {
                 $markerArray = GeneralUtility::array_merge($markerArray, $newMarkers);
             }
             unset($params);
         }
     }
     if (is_array($markerArray)) {
         foreach ($markerArray as $markerKey => $markerValue) {
             if (empty($oldBrokenLink[$markerKey])) {
                 $oldBrokenLink[$markerKey] = 0;
             }
             if ($markerValue != $oldBrokenLink[$markerKey]) {
                 $this->isDifferentToLastRun = TRUE;
             }
             $markerArray[$markerKey . '_old'] = $oldBrokenLink[$markerKey];
         }
     }
     $markerArray['title'] = BackendUtility::getRecordTitle('pages', BackendUtility::getRecord('pages', $curPage));
     $content = '';
     if ($markerArray['brokenlinkCount'] > 0) {
         $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($pageSectionHtml, $markerArray, '###|###', TRUE, TRUE);
     }
     return $content;
 }
 /**
  * Generates the notification email content.
  * This function generates the content of the notification email that is to
  * be sent. The result of this function is stored into the attribute $this->postalertMail.
  *
  * @author  Martin Helmich <*****@*****.**>
  * @version 2008-06-22
  * @return  void
  */
 function generateOutput()
 {
     $template = $this->loadTemplateFile('notifyReported');
     if ($this->conf['cron_htmlemail']) {
         $template = HtmlParser::getSubpart($template, '###PNOTIFY_HTML###');
     } else {
         $template = HtmlParser::getSubpart($template, '###PNOTIFY_PLAINTEXT###');
     }
     $itemTemplate = HtmlParser::getSubpart($template, '###PNOTIFY_LISTITEM###');
     $marker = array('###PNOTIFY_SUBJECT###' => sprintf($this->getLL('subject'), count($this->postalertItems)), '###PNOTIFY_TEXT###' => sprintf($this->getLL('text'), $this->conf['cron_sitetitle'], count($this->postalertItems)), '###PNOTIFY_LINK###' => $this->conf['cron_alertqueue_link'], '###LABEL_PNOTIFY_TOPICTITLE###' => $this->getLL('topictitle'), '###LABEL_PNOTIFY_REPORTDATE###' => $this->getLL('reportdate'), '###LABEL_PNOTIFY_TOPICAUTHOR###' => $this->getLL('topicauthor'), '###LABEL_PNOTIFY_TOPICFORUM###' => $this->getLL('topicforum'), '###LABEL_PNOTIFY_TOPICREPORTER###' => $this->getLL('postreporter'), '###LABEL_PNOTIFY_ALERTTEXT###' => $this->getLL('alerttext'), '###LABEL_PNOTIFY_POSTCONTENT###' => $this->getLL('reportedcontent'));
     $template = HtmlParser::substituteMarkerArray($template, $marker);
     $itemContent = '';
     foreach ($this->postalertItems as $postalertItem) {
         $itemMarker = array('###PNOTIFY_TOPICTITLE###' => $this->getTopicTitle($postalertItem['topic_id']), '###PNOTIFY_TOPICAUTHOR###' => $this->getPostAuthor($postalertItem['post_id']), '###PNOTIFY_TOPICREPORTER###' => $this->getUsername($postalertItem['cruser_id']), '###PNOTIFY_REPORTDATE###' => date('d. m. Y, H:i', $postalertItem['crdate']), '###PNOTIFY_TOPICFORUM###' => $this->getTopicForum($postalertItem['topic_id']), '###PNOTIFY_POSTCONTENT###' => $this->getPostContent($postalertItem['post_id']), '###PNOTIFY_ALERTTEXT###' => stripslashes($postalertItem['alert_text']), '###LABEL_PNOTIFY_ALERTTEXT###' => $this->getLL('alerttext'), '###LABEL_PNOTIFY_POSTCONTENT###' => $this->getLL('reportedcontent'));
         $itemContent .= HtmlParser::substituteMarkerArray($itemTemplate, $itemMarker);
     }
     $template = HtmlParser::substituteSubpart($template, '###PNOTIFY_LISTITEM###', $itemContent);
     $this->postalertMail = $template;
 }
Ejemplo n.º 18
0
    /**
     * Exit the script with a message that the install tool is locked.
     *
     * @return void
     */
    protected static function dieWithLockedInstallToolMessage()
    {
        require_once PATH_site . 't3lib/class.t3lib_parsehtml.php';
        // Define the stylesheet
        $stylesheet = '<link rel="stylesheet" type="text/css" href="' . '../stylesheets/install/install.css" />';
        $javascript = '<script type="text/javascript" src="' . '../contrib/prototype/prototype.js"></script>';
        $javascript .= '<script type="text/javascript" src="' . '../sysext/install/Resources/Public/Javascript/install.js"></script>';
        // Get the template file
        $template = @file_get_contents(PATH_site . 'typo3/templates/install.html');
        // Define the markers content
        $markers = array('styleSheet' => $stylesheet, 'javascript' => $javascript, 'title' => 'The Install Tool is locked', 'content' => '
				<p>
					To enable the Install Tool, the file ENABLE_INSTALL_TOOL must be created.
				</p>
				<ul>
					<li>
						In the typo3conf/ folder, create a file named ENABLE_INSTALL_TOOL. The file name is
						case sensitive, but the file itself can simply be an empty file.
					</li>
					<li class="t3-install-locked-user-settings">
						Alternatively, in the Backend, go to <a href="javascript:top.goToModule(\'tools_install\',1);">Admin tools &gt; Install</a>
						and let TYPO3 create this file for you.<br />
						You are recommended to log out from the Install Tool after finishing your work.
						The file will then automatically be deleted.
					</li>
				</ul>
				<p>
					For security reasons, it is highly recommended that you either rename or delete the file after the operation is finished.
				</p>
				<p>
					As an additional security measure, if the file is older than one hour, TYPO3 will automatically delete it. The file must be writable by the web server user.
				</p>
			');
        // Fill the markers
        $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($template, $markers, '###|###', 1, 1);
        // Output the warning message and exit
        header('Content-Type: text/html; charset=utf-8');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
        echo $content;
        die;
    }