当前位置: 首页>>代码示例>>PHP>>正文


PHP Url::fromDocumentRoot方法代码示例

本文整理汇总了PHP中Cx\Core\Routing\Url::fromDocumentRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::fromDocumentRoot方法的具体用法?PHP Url::fromDocumentRoot怎么用?PHP Url::fromDocumentRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cx\Core\Routing\Url的用法示例。


在下文中一共展示了Url::fromDocumentRoot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendConfirmationMail

 /**
  * Send a confirmation e-mail with the order data
  *
  * Calls {@see Orders::getSubstitutionArray()}, which en route
  * creates User accounts for individual electronic Products by default.
  * Set $create_accounts to false when sending a copy.
  * @static
  * @param   integer   $order_id         The order ID
  * @param   boolean   $create_accounts  Create User accounts for electronic
  *                                      Products it true
  * @return  boolean                     The Customers' e-mail address
  *                                      on success, false otherwise
  * @access  private
  */
 static function sendConfirmationMail($order_id, $create_accounts = true)
 {
     $arrSubstitution = Orders::getSubstitutionArray($order_id, $create_accounts);
     $customer_id = $arrSubstitution['CUSTOMER_ID'];
     $objCustomer = Customer::getById($customer_id);
     if (!$objCustomer) {
         //die("Failed to get Customer for ID $customer_id");
         return false;
     }
     $arrSubstitution += $objCustomer->getSubstitutionArray() + self::getSubstitutionArray() + array('TIMESTAMP' => date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME, date_timestamp_get(date_create())), 'ROOT_URL' => \Cx\Core\Routing\Url::fromDocumentRoot()->toString());
     //DBG::log("sendConfirmationMail($order_id, $create_accounts): Subs: ".var_dump($arrSubstitution, true));
     if (empty($arrSubstitution)) {
         return false;
     }
     // Prepared template for order confirmation
     $arrMailTemplate = array('section' => 'Shop', 'key' => 'order_confirmation', 'lang_id' => $arrSubstitution['LANG_ID'], 'to' => $arrSubstitution['CUSTOMER_EMAIL'] . ',' . \Cx\Core\Setting\Controller\Setting::getValue('email_confirmation', 'Shop'), 'substitution' => &$arrSubstitution);
     //DBG::log("sendConfirmationMail($order_id, $create_accounts): Template: ".var_export($arrMailTemplate, true));
     //DBG::log("sendConfirmationMail($order_id, $create_accounts): Substitution: ".var_export($arrSubstitution, true));
     // NOTE: Creates some XML order file (for customizing)
     //        $template = file_get_contents(
     //            ASCMS_MODULE_PATH.'/Shop/View/Template/Backend/module_shop_export_orders.xml');
     //        \Cx\Core\MailTemplate\Controller\MailTemplate::substitute($template, $arrSubstitution, true);
     //        // Strip leftover comments from blocks: "<!---->" or "<!--  -->"
     //        $template = preg_replace('/<!--\s*-->/', '', $template);
     //        $file = new Cx\Lib\FileSystem\File(
     //            ASCMS_DOCUMENT_ROOT.'/orders/'.$order_id.'.xml');
     //        //$file->makeWritable(); // Fails on win32
     //        $file->write($template);
     ///
     if (!\Cx\Core\MailTemplate\Controller\MailTemplate::send($arrMailTemplate)) {
         return false;
     }
     return $arrSubstitution['CUSTOMER_EMAIL'];
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:48,代码来源:ShopLibrary.class.php

示例2: _createRSS

 function _createRSS()
 {
     global $_CONFIG, $objDatabase;
     $this->_arrSettings =& $this->_getSettings();
     $arrMedia = array();
     $objMedium = $objDatabase->Execute("\n            SELECT tblMedium.id,\n                   tblMedium.title,\n                   tblMedium.author,\n                   tblMedium.description,\n                   tblMedium.source,\n                   tblMedium.size,\n                   tblMedium.date_added,\n                   tblCategory.id AS categoryId,\n                   tblCategory.title AS categoryTitle\n            FROM " . DBPREFIX . "module_podcast_medium AS tblMedium\n            LEFT JOIN " . DBPREFIX . "module_podcast_rel_medium_category AS tblRel ON tblRel.medium_id=tblMedium.id\n            LEFT JOIN " . DBPREFIX . "module_podcast_category AS tblCategory ON tblCategory.id=tblRel.category_id\n            WHERE tblMedium.status=1\n            ORDER BY tblMedium.date_added DESC");
     if ($objMedium !== false) {
         while (!$objMedium->EOF) {
             if (!isset($arrMedia[$objMedium->fields['id']])) {
                 $arrMedia[$objMedium->fields['id']] = array('title' => $objMedium->fields['title'], 'author' => $objMedium->fields['author'], 'description' => $objMedium->fields['description'], 'source' => str_replace(array('%domain%', '%offset%'), array($_CONFIG['domainUrl'], \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath()), $objMedium->fields['source']), 'size' => $objMedium->fields['size'], 'date_added' => $objMedium->fields['date_added'], 'categories' => array());
             }
             if (!empty($objMedium->fields['id'])) {
                 $arrMedia[$objMedium->fields['id']]['categories'][$objMedium->fields['categoryId']] = $objMedium->fields['categoryTitle'];
             }
             $objMedium->MoveNext();
         }
     }
     $objRSSWriter = new \RSSWriter();
     $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
     $objRSSWriter->channelTitle = $this->_arrSettings['feed_title'];
     $objRSSWriter->channelLink = \Cx\Core\Routing\Url::fromModuleAndCmd('Podcast')->toString();
     $objRSSWriter->channelDescription = $this->_arrSettings['feed_description'];
     $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
     if (!empty($this->_arrSettings['feed_image'])) {
         $channelImageUrl = \Cx\Core\Routing\Url::fromDocumentRoot();
         $channelImageUrl->setMode('backend');
         $channelImageUrl->setPath(substr($this->_arrSettings['feed_image'], strlen(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath()) + 1));
         $objRSSWriter->channelImageUrl = $channelImageUrl;
         $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle;
         $objRSSWriter->channelImageLink = $objRSSWriter->channelLink;
     }
     $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
     // create podcast feed
     $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/podcast.xml';
     foreach ($arrMedia as $mediumId => $arrMedium) {
         $arrCategories = array();
         foreach ($arrMedium['categories'] as $categoryId => $categoryTitle) {
             array_push($arrCategories, array('domain' => htmlspecialchars(\Cx\Core\Routing\Url::fromModuleAndCmd('Podcast', '', '', array('cid' => $categoryId))->toString(), ENT_QUOTES, CONTREXX_CHARSET), 'title' => htmlspecialchars($categoryTitle, ENT_QUOTES, CONTREXX_CHARSET)));
         }
         $objRSSWriter->addItem(htmlspecialchars($arrMedium['title'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xhtml(\Cx\Core\Routing\Url::fromModuleAndCmd('Podcast', '', '', array('id' => $mediumId))->toString()), htmlspecialchars($arrMedium['description'], ENT_QUOTES, CONTREXX_CHARSET), htmlspecialchars($arrMedium['author'], ENT_QUOTES, CONTREXX_CHARSET), $arrCategories, '', array('url' => htmlspecialchars($arrMedium['source'], ENT_QUOTES, CONTREXX_CHARSET), 'length' => !empty($arrMedium['size']) ? $arrMedium['size'] : 'N/A', 'type' => 'application/x-video'), '', $arrMedium['date_added']);
     }
     $status = $objRSSWriter->write();
     if (count($objRSSWriter->arrErrorMsg) > 0) {
         $this->_strErrMessage .= implode('<br />', $objRSSWriter->arrErrorMsg);
     }
     if (count($objRSSWriter->arrWarningMsg) > 0) {
         $this->_strErrMessage .= implode('<br />', $objRSSWriter->arrWarningMsg);
     }
     return $status;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:50,代码来源:PodcastLib.class.php

示例3: displayInBrowser

 /**
  * displays newsletter contentn in browser
  *
  */
 public static function displayInBrowser()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     $id = !empty($_GET['id']) ? contrexx_input2raw($_GET['id']) : '';
     $email = !empty($_GET['email']) ? contrexx_input2raw($_GET['email']) : '';
     $code = !empty($_GET['code']) ? contrexx_input2raw($_GET['code']) : '';
     $unsubscribe = '';
     $profile = '';
     $date = '';
     $sex = '';
     $salutation = '';
     $title = '';
     $firstname = '';
     $lastname = '';
     $position = '';
     $company = '';
     $industry_sector = '';
     $address = '';
     $city = '';
     $zip = '';
     $country = '';
     $phoneOffice = '';
     $phoneMobile = '';
     $phonePrivate = '';
     $fax = '';
     $birthday = '';
     $website = '';
     if (!self::checkCode($id, $email, $code)) {
         // unable to verify user, therefore we will not load any user data to prevent leaking any privacy data
         $email = '';
         $code = '';
     }
     // Get newsletter content and template.
     $query = '
             SELECT `n`.`content`, `t`.`html`, `n`.`date_sent`
               FROM `' . DBPREFIX . 'module_newsletter` as `n`
         INNER JOIN `' . DBPREFIX . 'module_newsletter_template` as `t`
                 ON `n`.`template` = `t`.`id`
              WHERE `n`.`id` = "' . contrexx_raw2db($id) . '"
     ';
     $objResult = $objDatabase->Execute($query);
     if ($objResult->RecordCount()) {
         $html = $objResult->fields['html'];
         $content = $objResult->fields['content'];
         $date = date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date_sent']);
     } else {
         // newsletter not found > redirect to homepage
         \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromDocumentRoot());
         exit;
     }
     // Get user details.
     $query = '
         SELECT `id`, `email`, `uri`, `salutation`, `title`, `position`, `company`, `industry_sector`, `sex`,
                `lastname`, `firstname`, `address`, `zip`, `city`, `country_id`, 
                `phone_office`, `phone_mobile`, `phone_private`, `fax`, `birthday`
         FROM `' . DBPREFIX . 'module_newsletter_user`
         WHERE `email` = "' . contrexx_raw2db($email) . '"
     ';
     $objResult = $objDatabase->Execute($query);
     if ($objResult->RecordCount()) {
         // set recipient sex
         switch ($objResult->fields['sex']) {
             case 'm':
                 $gender = 'gender_male';
                 break;
             case 'f':
                 $gender = 'gender_female';
                 break;
             default:
                 $gender = 'gender_undefined';
                 break;
         }
         $objUser = \FWUser::getFWUserObject()->objUser;
         $userId = $objResult->fields['id'];
         $sex = $objUser->objAttribute->getById($gender)->getName();
         //$salutation     = contrexx_raw2xhtml($objUser->objAttribute->getById('title_'.$objResult->fields['salutation'])->getName());
         $objNewsletterLib = new NewsletterLib();
         $arrRecipientTitles = $objNewsletterLib->_getRecipientTitles();
         $salutation = $arrRecipientTitles[$objResult->fields['salutation']];
         $title = contrexx_raw2xhtml($objResult->fields['title']);
         $firstname = contrexx_raw2xhtml($objResult->fields['firstname']);
         $lastname = contrexx_raw2xhtml($objResult->fields['lastname']);
         $position = contrexx_raw2xhtml($objResult->fields['position']);
         $company = contrexx_raw2xhtml($objResult->fields['company']);
         $industry_sector = contrexx_raw2xhtml($objResult->fields['industry_sector']);
         $address = contrexx_raw2xhtml($objResult->fields['address']);
         $city = contrexx_raw2xhtml($objResult->fields['city']);
         $zip = contrexx_raw2xhtml($objResult->fields['zip']);
         // TODO: migrate to Country class
         $country = contrexx_raw2xhtml($objUser->objAttribute->getById('country_' . $objResult->fields['country_id'])->getName());
         $phoneOffice = contrexx_raw2xhtml($objResult->fields['phone_office']);
         $phoneMobile = contrexx_raw2xhtml($objResult->fields['phone_mobile']);
         $phonePrivate = contrexx_raw2xhtml($objResult->fields['phone_private']);
         $fax = contrexx_raw2xhtml($objResult->fields['fax']);
         $website = contrexx_raw2xhtml($objResult->fields['uri']);
         $birthday = contrexx_raw2xhtml($objResult->fields['birthday']);
//.........这里部分代码省略.........
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:101,代码来源:Newsletter.class.php

示例4: storeMessageComment

 /**
  * Validates the submitted comment data and writes it to the databse if valid.
  * Additionally, a notification is send out to the administration about the comment
  * by e-mail (only if the corresponding configuration option is set to do so).
  *
  * @param   integer News message ID for which the comment shall be stored
  * @param   string  Title of the news message for which the comment shall be stored.
  *                  The title will be used in the notification e-mail
  * @param   string  The poster's name of the comment
  * @param   string  The comment's title
  * @param   string  The comment's message text
  * @global    ADONewConnection
  * @global    array
  * @global    array
  * @global    array
  * @return  array   Returns an array of two elements. The first is either TRUE on success or FALSE on failure.
  *                  The second element contains an error message on failure.
  */
 private function storeMessageComment($newsMessageId, $newsMessageTitle, $name, $title, $message)
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG;
     if (!isset($_SESSION['news'])) {
         $_SESSION['news'] = array();
         $_SESSION['news']['comments'] = array();
     }
     // just comment
     if ($this->checkForCommentFlooding($newsMessageId)) {
         return array(false, sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_INTERVAL_MSG'], $this->arrSettings['news_comments_timeout']));
     }
     if (empty($title)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_TITLE']);
     }
     if (empty($message)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_MESSAGE']);
     }
     $date = time();
     $userId = 0;
     if (\FWUser::getFWUserObject()->objUser->login()) {
         $userId = \FWUser::getFWUserObject()->objUser->getId();
         $name = \FWUser::getParsedUserTitle($userId);
     } elseif ($this->arrSettings['news_comments_anonymous'] == '1') {
         // deny comment if the poster did not specify his name
         if (empty($name)) {
             return array(false, $_ARRAYLANG['TXT_NEWS_POSTER_NAME_MISSING']);
         }
         // check CAPTCHA for anonymous posters
         if (!\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
             return array(false, null);
         }
     } else {
         // Anonymous comments are not allowed
         return array(false, null);
     }
     $isActive = $this->arrSettings['news_comments_autoactivate'];
     $ipAddress = contrexx_input2raw($_SERVER['REMOTE_ADDR']);
     $objResult = $objDatabase->Execute("\n            INSERT INTO `" . DBPREFIX . "module_news_comments`\n                    SET `title` = '" . contrexx_raw2db($title) . "',\n                        `text` = '" . contrexx_raw2db($message) . "',\n                        `newsid` = '" . contrexx_raw2db($newsMessageId) . "',\n                        `date` = '" . contrexx_raw2db($date) . "',\n                        `poster_name` = '" . contrexx_raw2db($name) . "',\n                        `userid` = '" . contrexx_raw2db($userId) . "',\n                        `ip_address` = '" . contrexx_raw2db($ipAddress) . "',\n                        `is_active` = '" . contrexx_raw2db($isActive) . "'");
     if (!$objResult) {
         return array(false, $_ARRAYLANG['TXT_NEWS_COMMENT_SAVE_ERROR']);
     }
     /* Prevent comment flooding from same user:
        Either user is authenticated or had to validate a CAPTCHA.
        In either way, a Cloudrexx session had been initialized,
        therefore we are able to use the $_SESSION to log this comment */
     $_SESSION['news']['comments'][$newsMessageId] = $date;
     // Don't send a notification e-mail to the administrator
     if (!$this->arrSettings['news_comments_notification']) {
         return array(true, null);
     }
     // Send a notification e-mail to administrator
     if (!@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         \DBG::msg('Unable to send e-mail notification to admin');
         //DBG::stack();
         return array(true, null);
     }
     $objMail = new \phpmailer();
     if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
             $objMail->IsSMTP();
             $objMail->Host = $arrSmtp['hostname'];
             $objMail->Port = $arrSmtp['port'];
             $objMail->SMTPAuth = true;
             $objMail->Username = $arrSmtp['username'];
             $objMail->Password = $arrSmtp['password'];
         }
     }
     $objMail->CharSet = CONTREXX_CHARSET;
     $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
     $objMail->IsHTML(false);
     $objMail->Subject = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_SUBJECT'], $newsMessageTitle);
     $manageCommentsUrl = \Cx\Core\Routing\Url::fromDocumentRoot(array('cmd' => 'News', 'act' => 'comments', 'newsId' => $newsMessageId));
     $manageCommentsUrl->setPath(substr(\Cx\Core\Core\Controller\Cx::instanciate()->getBackendFolderName(), 1) . '/index.php');
     $manageCommentsUrl->setMode('backend');
     $manageCommentsUrl = $manageCommentsUrl->toString();
     $activateCommentTxt = $this->arrSettings['news_comments_autoactivate'] ? '' : sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_LINK'], $manageCommentsUrl);
     $objMail->Body = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_BODY'], $_CONFIG['domainUrl'], $newsMessageTitle, \FWUser::getParsedUserTitle($userId, $name), $title, nl2br($message), $activateCommentTxt);
     $objMail->AddAddress($_CONFIG['coreAdminEmail']);
     if (!$objMail->Send()) {
         \DBG::msg('Sending of notification e-mail failed');
         //DBG::stack();
     }
//.........这里部分代码省略.........
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:101,代码来源:News.class.php

示例5: prepareNewsletterLinksForSend

 protected static function prepareNewsletterLinksForSend($MailId, $MailHtmlContent, $UserId, $realUser)
 {
     global $objDatabase;
     $result = $MailHtmlContent;
     $matches = NULL;
     if (preg_match_all("/<a([^>]+)>(.*?)<\\/a>/is", $result, $matches)) {
         // get all links info
         $arrLinks = array();
         $objLinks = $objDatabase->Execute("\n                SELECT `id`, `title`, `url`\n                FROM " . DBPREFIX . "module_newsletter_email_link\n                WHERE `email_id`={$MailId}");
         if ($objLinks) {
             while (!$objLinks->EOF) {
                 $arrLinks[$objLinks->fields['id']] = array('title' => $objLinks->fields['title'], 'url' => $objLinks->fields['url']);
                 $objLinks->MoveNext();
             }
         }
         // replace links
         if (count($arrLinks) > 0) {
             $tagCount = count($matches[0]);
             $fullKey = 0;
             $attrKey = 1;
             $textKey = 2;
             $rmatches = NULL;
             for ($i = 0; $i < $tagCount; $i++) {
                 if (!preg_match("/newsletter_link_(\\d+)/i", $matches[$attrKey][$i], $rmatches)) {
                     continue;
                 }
                 $linkId = $rmatches[1];
                 $url = '';
                 if (preg_match("/href\\s*=\\s*(['\"])(.*?)\\1/i", $matches[$attrKey][$i], $rmatches)) {
                     $url = $rmatches[2];
                 }
                 // remove newsletter_link_N from rel attribute
                 $matches[$attrKey][$i] = preg_replace("/newsletter_link_" . $linkId . "/i", "", $matches[$attrKey][$i]);
                 // remove empty rel attribute
                 $matches[$attrKey][$i] = preg_replace("/\\s*rel=\\s*(['\"])\\s*\\1/i", "", $matches[$attrKey][$i]);
                 // remove left and right spaces
                 $matches[$attrKey][$i] = preg_replace("/([^=])\\s*\"/i", "\$1\"", $matches[$attrKey][$i]);
                 $matches[$attrKey][$i] = preg_replace("/=\"\\s*/i", "=\"", $matches[$attrKey][$i]);
                 // replace href attribute
                 if (isset($arrLinks[$linkId])) {
                     // TODO: use new URL-format
                     $arrParameters = array('section' => 'Newsletter', 'n' => $MailId, 'l' => $linkId, $realUser ? 'r' : 'm' => $UserId);
                     $newUrl = \Cx\Core\Routing\Url::fromDocumentRoot($arrParameters, null, null)->toString();
                     $matches[$attrKey][$i] = preg_replace("/href\\s*=\\s*(['\"]).*?\\1/i", "href=\"" . $newUrl . "\"", $matches[$attrKey][$i]);
                 }
                 $result = preg_replace("/" . preg_quote($matches[$fullKey][$i], '/') . "/is", "<a " . $matches[$attrKey][$i] . ">" . $matches[$textKey][$i] . "</a>", $result, 1);
             }
         }
     }
     return $result;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:51,代码来源:NewsletterLib.class.php

示例6: redirectPage

 /**
  * Redirect to content manager (open site)
  *
  * @param  integer  The page with this id will be shown in content manager.
  */
 protected function redirectPage($intPageId)
 {
     // This is not really a nice way to generate this URL!
     $baseUrl = \Cx\Core\Routing\Url::fromDocumentRoot();
     $baseUrl->setMode(\Cx\Core\Core\Controller\Cx::MODE_BACKEND);
     \Cx\Core\Csrf\Controller\Csrf::redirect($baseUrl . 'cadmin/ContentManager?page=' . $intPageId . '&tab=content');
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:12,代码来源:ContentWorkflow.class.php

示例7: fromApi

 /**
  * Returns the URL object for a command mode command accessed via HTTP(s)
  * @param string $command Command mode command name
  * @param array $arguments List of non-named arguments
  * @param array $parameters List of named parameters (key=>value style array)
  * @return \Cx\Core\Routing\Url Url object for the supplied command name
  */
 public static function fromApi($command, $arguments, $parameters = array())
 {
     $url = \Cx\Core\Routing\Url::fromDocumentRoot();
     $url->setMode('backend');
     $url->setPath('api/' . $command . '/' . implode('/', $arguments));
     $url->removeAllParams();
     $url->setParams($parameters);
     return $url;
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:16,代码来源:Url.class.php

示例8: createRSS

 /**
  * Create the RSS-Feed
  */
 function createRSS()
 {
     global $_CONFIG, $objDatabase, $_FRONTEND_LANGID;
     // languages
     $arrLanguages = \FWLanguage::getLanguageArray();
     if (intval($this->arrSettings['news_feed_status']) == 1) {
         if (count($arrLanguages > 0)) {
             $categoryDetails = $this->getCategoryLocale(null, array_keys($arrLanguages));
             foreach ($arrLanguages as $LangId => $arrLanguage) {
                 if ($arrLanguage['frontend'] == 1) {
                     $objRSSWriter = new \RSSWriter();
                     $query = "\n                            SELECT      tblNews.id,\n                                        tblNews.date,\n                                        tblNews.redirect,\n                                        tblNews.source,\n                                        tblNews.teaser_frames AS teaser_frames,\n                                        tblLocale.lang_id,\n                                        tblLocale.title,\n                                        tblLocale.text,\n                                        tblLocale.teaser_text\n                            FROM        " . DBPREFIX . "module_news AS tblNews\n                            INNER JOIN  " . DBPREFIX . "module_news_locale AS tblLocale ON tblLocale.news_id = tblNews.id\n                            WHERE       tblNews.status=1\n                                AND     tblLocale.is_active = 1\n                                AND     tblLocale.lang_id = " . $LangId . "\n                                AND     (tblNews.startdate <= '" . date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME) . "' OR tblNews.startdate = '0000-00-00 00:00:00')\n                                AND     (tblNews.enddate >= '" . date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME) . "' OR tblNews.enddate = '0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' ? " AND tblNews.frontend_access_id=0 " : '') . " ORDER BY tblNews.date DESC";
                     $arrNews = array();
                     if (($objResult = $objDatabase->SelectLimit($query, 20)) !== false && $objResult->RecordCount() > 0) {
                         while (!$objResult->EOF) {
                             if (empty($objRSSWriter->channelLastBuildDate)) {
                                 $objRSSWriter->channelLastBuildDate = date('r', $objResult->fields['date']);
                             }
                             $teaserText = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objResult->fields['teaser_text']);
                             $text = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objResult->fields['text']);
                             $redirect = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objResult->fields['redirect']);
                             \LinkGenerator::parseTemplate($teaserText, true);
                             \LinkGenerator::parseTemplate($text, true);
                             \LinkGenerator::parseTemplate($redirect, true);
                             $arrNews[$objResult->fields['id']] = array('date' => $objResult->fields['date'], 'title' => $objResult->fields['title'], 'text' => empty($redirect) ? (!empty($teaserText) ? nl2br($teaserText) . '<br /><br />' : '') . $text : (!empty($teaserText) ? nl2br($teaserText) : ''), 'redirect' => $redirect, 'source' => $objResult->fields['source'], 'teaser_frames' => explode(';', $objResult->fields['teaser_frames']), 'categoryIds' => $this->getNewsRelCategories($objResult->fields['id']));
                             $objResult->MoveNext();
                         }
                     } else {
                         continue;
                     }
                     $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
                     $objRSSWriter->channelTitle = contrexx_raw2xml($this->arrSettings['news_feed_title'][$LangId]);
                     $objRSSWriter->channelDescription = contrexx_raw2xml($this->arrSettings['news_feed_description'][$LangId]);
                     $objRSSWriter->channelLink = \Cx\Core\Routing\Url::fromModuleAndCmd('News', '', $LangId)->toString();
                     $objRSSWriter->channelLanguage = \FWLanguage::getLanguageParameter($LangId, 'lang');
                     $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
                     if (!empty($this->arrSettings['news_feed_image'])) {
                         $channelImageUrl = \Cx\Core\Routing\Url::fromDocumentRoot();
                         $channelImageUrl->setMode('backend');
                         $channelImageUrl->setPath(substr($this->arrSettings['news_feed_image'], strlen(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath()) + 1));
                         $objRSSWriter->channelImageUrl = $channelImageUrl;
                         $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle;
                         $objRSSWriter->channelImageLink = $objRSSWriter->channelLink;
                     }
                     $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
                     // create rss feed
                     $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml';
                     foreach ($arrNews as $newsId => $arrNewsItem) {
                         list($cmdDetail, $categories) = $this->getRssNewsLinks($LangId, $arrNewsItem['categoryIds'], $categoryDetails[$LangId]);
                         $itemUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('News', $cmdDetail, $LangId, array('newsid' => $newsId));
                         if (isset($arrNewsItem['teaser_frames'][0])) {
                             $itemUrl->setParam('teaserId', $arrNewsItem['teaser_frames'][0]);
                         }
                         $objRSSWriter->addItem(contrexx_raw2xml($arrNewsItem['title']), empty($arrNewsItem['redirect']) ? contrexx_raw2xml($itemUrl->toString()) : htmlspecialchars($arrNewsItem['redirect'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xml($arrNewsItem['text']), '', $categories, '', '', '', $arrNewsItem['date'], array('url' => htmlspecialchars($arrNewsItem['source'], ENT_QUOTES, CONTREXX_CHARSET), 'title' => contrexx_raw2xml($arrNewsItem['title'])));
                     }
                     $objRSSWriter->write();
                     // create headlines rss feed
                     $objRSSWriter->removeItems();
                     $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/news_headlines_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml';
                     foreach ($arrNews as $newsId => $arrNewsItem) {
                         list($cmdDetail, $categories) = $this->getRssNewsLinks($LangId, $arrNewsItem['categoryIds'], $categoryDetails[$LangId]);
                         $itemUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('News', $cmdDetail, $LangId, array('newsid' => $newsId));
                         if (isset($arrNewsItem['teaser_frames'][0])) {
                             $itemUrl->setParam('teaserId', $arrNewsItem['teaser_frames'][0]);
                         }
                         $objRSSWriter->addItem(contrexx_raw2xml($arrNewsItem['title']), contrexx_raw2xml($itemUrl->toString()), '', '', $categories, '', '', '', $arrNewsItem['date']);
                     }
                     $objRSSWriter->write();
                     $objRSSWriter->feedType = 'js';
                     $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.js';
                     $objRSSWriter->write();
                     if (count($objRSSWriter->arrErrorMsg) > 0) {
                         $this->strErrMessage .= implode('<br />', $objRSSWriter->arrErrorMsg);
                     }
                     if (count($objRSSWriter->arrWarningMsg) > 0) {
                         $this->strErrMessage .= implode('<br />', $objRSSWriter->arrWarningMsg);
                     }
                 }
             }
         }
     } else {
         if (count($arrLanguages > 0)) {
             foreach ($arrLanguages as $LangId => $arrLanguage) {
                 if ($arrLanguage['frontend'] == 1) {
                     @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml');
                     @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/news_headlines_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml');
                     @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.js');
                 }
             }
         }
     }
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:95,代码来源:NewsManager.class.php


注:本文中的Cx\Core\Routing\Url::fromDocumentRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。