作者:nahakiol
项目:cloudrex
function getHomeTopNews($catId = 0)
{
global $_CORELANG, $objDatabase;
$catId = intval($catId);
$i = 0;
$this->_objTemplate->setTemplate($this->_pageContent, true, true);
if ($this->_objTemplate->blockExists('newsrow')) {
$this->_objTemplate->setCurrentBlock('newsrow');
} else {
return null;
}
$newsLimit = intval($this->arrSettings['news_top_limit']);
if ($newsLimit > 50) {
//limit to a maximum of 50 news
$newsLimit = 50;
}
if ($newsLimit < 1) {
//do not get any news if 0 was specified as the limit.
$objResult = false;
} else {
//fetch news
$objResult = $objDatabase->SelectLimit("\n SELECT DISTINCT(tblN.id) AS id,\n tblN.`date`, \n tblN.teaser_image_path,\n tblN.teaser_image_thumbnail_path,\n tblN.redirect,\n tblN.publisher,\n tblN.publisher_id,\n tblN.author,\n tblN.author_id,\n tblL.title AS title, \n tblL.teaser_text\n FROM " . DBPREFIX . "module_news AS tblN\n INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id=tblN.id\n INNER JOIN " . DBPREFIX . "module_news_rel_categories AS tblC ON tblC.news_id=tblL.news_id\n WHERE tblN.status=1" . ($catId > 0 ? " AND tblC.category_id={$catId}" : '') . "\n AND tblN.teaser_only='0'\n AND tblL.lang_id=" . FRONTEND_LANG_ID . "\n AND (startdate<='" . date('Y-m-d H:i:s') . "' OR startdate='0000-00-00 00:00:00')\n AND (enddate>='" . date('Y-m-d H:i:s') . "' OR enddate='0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid=" . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '') . "ORDER BY\n (SELECT COUNT(*) FROM " . DBPREFIX . "module_news_stats_view WHERE news_id=tblN.id AND time>'" . date_format(date_sub(date_create('now'), date_interval_create_from_date_string(intval($this->arrSettings['news_top_days']) . ' day')), 'Y-m-d H:i:s') . "') DESC", $newsLimit);
}
if ($objResult !== false && $objResult->RecordCount()) {
while (!$objResult->EOF) {
$newsid = $objResult->fields['id'];
$newstitle = $objResult->fields['title'];
$author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']);
$publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']);
$newsCategories = $this->getCategoriesByNewsId($newsid);
$newsUrl = empty($objResult->fields['redirect']) ? \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), array($catId))), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $objResult->fields['redirect'];
$htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle));
list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
$this->_objTemplate->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher)));
if (!empty($image)) {
$this->_objTemplate->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage));
if ($this->_objTemplate->blockExists('news_image')) {
$this->_objTemplate->parse('news_image');
}
} else {
if ($this->_objTemplate->blockExists('news_image')) {
$this->_objTemplate->hideBlock('news_image');
}
}
self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail');
self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail');
$this->_objTemplate->parseCurrentBlock();
$i++;
$objResult->MoveNext();
}
} else {
$this->_objTemplate->hideBlock('newsrow');
}
$this->_objTemplate->setVariable("TXT_MORE_NEWS", $_CORELANG['TXT_MORE_NEWS']);
return $this->_objTemplate->get();
}
作者:nahakiol
项目:cloudrex
function getHomeHeadlines($catId = 0)
{
global $_CORELANG, $objDatabase, $_LANGID;
$i = 0;
$catId = intval($catId);
$this->_objTemplate->setTemplate($this->_pageContent, true, true);
$newsLimit = intval($this->arrSettings['news_headlines_limit']);
if ($newsLimit > 50) {
//limit to a maximum of 50 news
$newsLimit = 50;
}
if ($newsLimit < 1) {
//do not get any news if 0 was specified as the limit.
$objResult = false;
} else {
//fetch news
$objResult = $objDatabase->SelectLimit("\n SELECT DISTINCT(tblN.id) AS id,\n tblN.`date`, \n tblN.teaser_image_path,\n tblN.teaser_image_thumbnail_path,\n tblN.redirect,\n tblN.publisher,\n tblN.publisher_id,\n tblN.author,\n tblN.author_id,\n tblL.text NOT REGEXP '^(<br type=\"_moz\" />)?\$' AS newscontent,\n tblL.title AS title, \n tblL.teaser_text\n FROM " . DBPREFIX . "module_news AS tblN\n INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id=tblN.id\n INNER JOIN " . DBPREFIX . "module_news_rel_categories AS tblC ON tblC.news_id=tblL.news_id\n WHERE tblN.status=1" . ($catId > 0 ? " AND tblC.category_id={$catId}" : '') . "\n AND tblN.teaser_only='0'\n AND tblL.lang_id=" . $_LANGID . "\n AND tblL.is_active=1\n AND (startdate<='" . date('Y-m-d H:i:s') . "' OR startdate='0000-00-00 00:00:00')\n AND (enddate>='" . date('Y-m-d H:i:s') . "' OR enddate='0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid=" . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '') . "ORDER BY date DESC", $newsLimit);
}
if ($objResult !== false && $objResult->RecordCount() >= 0) {
while (!$objResult->EOF) {
$newsid = $objResult->fields['id'];
$newstitle = $objResult->fields['title'];
$newsCategories = $this->getCategoriesByNewsId($newsid);
$newsUrl = empty($objResult->fields['redirect']) ? empty($objResult->fields['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), array($catId))), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $objResult->fields['redirect'];
$htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle), 'headlineLink');
$htmlLinkTitle = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle));
// in case that the message is a stub, we shall just display the news title instead of a html-a-tag with no href target
if (empty($htmlLinkTitle)) {
$htmlLinkTitle = contrexx_raw2xhtml($newstitle);
}
list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
$author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']);
$publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']);
$this->_objTemplate->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_LINK_TITLE' => $htmlLinkTitle, 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'HEADLINE_ID' => $newsid, 'HEADLINE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'HEADLINE_TEXT' => nl2br($objResult->fields['teaser_text']), 'HEADLINE_LINK' => $htmlLinkTitle, 'HEADLINE_AUTHOR' => contrexx_raw2xhtml($author)));
if (!empty($image)) {
$this->_objTemplate->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage, 'HEADLINE_IMAGE_PATH' => contrexx_raw2xhtml($objResult->fields['teaser_image_path']), 'HEADLINE_THUMBNAIL_PATH' => contrexx_raw2xhtml($imageSource)));
if ($this->_objTemplate->blockExists('news_image')) {
$this->_objTemplate->parse('news_image');
}
} else {
if ($this->_objTemplate->blockExists('news_image')) {
$this->_objTemplate->hideBlock('news_image');
}
}
self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail');
self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail');
$this->_objTemplate->parse('headlines_row');
$i++;
$objResult->MoveNext();
}
} else {
$this->_objTemplate->hideBlock('headlines_row');
}
$this->_objTemplate->setVariable("TXT_MORE_NEWS", $_CORELANG['TXT_MORE_NEWS']);
return $this->_objTemplate->get();
}
作者:nahakiol
项目:cloudrex
public function testFileUrls()
{
$testResult = 'file://' . getcwd();
$url = Url::fromRequest();
$this->assertEquals($testResult, $url->toString());
$this->assertEquals(getcwd(), (string) $url);
$url = Url::fromMagic($testResult);
$this->assertEquals($testResult, $url->toString());
$this->assertEquals(getcwd(), (string) $url);
}
作者:Nigg
项目:cloudrex
/**
* Returns the PayPal form for initializing the payment process
* @param string $account_email The PayPal account e-mail address
* @param string $order_id The Order ID
* @param string $currency_code The Currency code
* @param string $amount The amount
* @param string $item_name The description used for the payment
* @return string The HTML code for the PayPal form
*/
static function getForm($account_email, $order_id, $currency_code, $amount, $item_name)
{
global $_ARRAYLANG;
//DBG::log("getForm($account_email, $order_id, $currency_code, $amount, $item_name): Entered");
$return = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success', FRONTEND_LANG_ID, array('handler' => 'paypal', 'result' => '1', 'order_id' => $order_id))->toString();
$cancel_return = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success', FRONTEND_LANG_ID, array('handler' => 'paypal', 'result' => '2', 'order_id' => $order_id))->toString();
$notify_url = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success', FRONTEND_LANG_ID, array('handler' => 'paypal', 'result' => '-1', 'order_id' => $order_id))->toString();
$retval = (\Cx\Core\Setting\Controller\Setting::getValue('paypal_active', 'Shop') ? '<script type="text/javascript">
// <![CDATA[
function go() { document.paypal.submit(); }
window.setTimeout("go()", 3000);
// ]]>
</script>
<form name="paypal" method="post"
action="https://www.paypal.com/ch/cgi-bin/webscr">
' : '<form name="paypal" method="post"
action="https://www.sandbox.paypal.com/ch/cgi-bin/webscr">
') . Html::getHidden('cmd', '_xclick') . Html::getHidden('business', $account_email) . Html::getHidden('item_name', $item_name) . Html::getHidden('currency_code', $currency_code) . Html::getHidden('amount', $amount) . Html::getHidden('custom', $order_id) . Html::getHidden('notify_url', $notify_url) . Html::getHidden('return', $return) . Html::getHidden('cancel_return', $cancel_return) . $_ARRAYLANG['TXT_PAYPAL_SUBMIT'] . '<br /><br />' . '<input type="submit" name="submitbutton" value="' . $_ARRAYLANG['TXT_PAYPAL_SUBMIT_BUTTON'] . "\" />\n</form>\n";
return $retval;
}
作者:nahakiol
项目:cloudrex
/**
* Parses a rudimentary system log backend page
* @param \Cx\Core\Html\Sigma $template Backend template for this page
* @param array $cmd Supplied CMD
*/
public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
{
$em = $this->cx->getDb()->getEntityManager();
$logRepo = $em->getRepository('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log');
// @todo: parse message if no entries (template block exists already)
$parseObject = $this->getNamespace() . '\\Model\\Entity\\Log';
// set default sorting
if (!isset($_GET['order'])) {
$_GET['order'] = 'timestamp/DESC';
}
// configure view
$viewGenerator = new \Cx\Core\Html\Controller\ViewGenerator($parseObject, array('functions' => array('delete' => 'true', 'paging' => true, 'sorting' => true, 'edit' => true), 'fields' => array('id' => array('showOverview' => false), 'timestamp' => array('readonly' => true), 'severity' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
return '<span class="' . contrexx_raw2xhtml(strtolower($data)) . '_background">' . contrexx_raw2xhtml($data) . '</span>';
})), 'message' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
$url = clone \Cx\Core\Routing\Url::fromRequest();
$url->setMode('backend');
$url->setParam('editid', $rows['id']);
return '<a href="' . $url . '">' . contrexx_raw2xhtml($data) . '</a>';
})), 'data' => array('readonly' => true, 'showOverview' => false, 'type' => 'text'), 'logger' => array('readonly' => true))));
$template->setVariable('ENTITY_VIEW', $viewGenerator);
}
作者:hbdskl
项目:LimeCM
/**
* Global search event listener
* Appends the News search results to the search object
*
* @param array $eventArgs
*/
private function SearchFindContent(array $eventArgs)
{
$search = current($eventArgs);
$term_db = contrexx_raw2db($search->getTerm());
$query = "SELECT id, text AS content, title, date, redirect,\n MATCH (text,title,teaser_text) AGAINST ('%{$term_db}%') AS score\n FROM " . DBPREFIX . "module_news AS tblN\n INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id = tblN.id\n WHERE ( text LIKE ('%{$term_db}%')\n OR title LIKE ('%{$term_db}%')\n OR teaser_text LIKE ('%{$term_db}%'))\n AND lang_id=" . FRONTEND_LANG_ID . "\n AND status=1\n AND is_active=1\n AND (startdate<='" . date('Y-m-d') . "' OR startdate='0000-00-00')\n AND (enddate>='" . date('Y-m-d') . "' OR enddate='0000-00-00')";
$pageUrl = function ($pageUri, $searchData) {
static $objNewsLib = null;
if (!$objNewsLib) {
$objNewsLib = new \Cx\Core_Modules\News\Controller\NewsLibrary();
}
if (empty($searchData['redirect'])) {
$newsId = $searchData['id'];
$newsCategories = $objNewsLib->getCategoriesByNewsId($newsId);
$objUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('News', $objNewsLib->findCmdById('details', array_keys($newsCategories)), FRONTEND_LANG_ID, array('newsid' => $newsId));
$pageUrlResult = $objUrl->toString();
} else {
$pageUrlResult = $searchData['redirect'];
}
return $pageUrlResult;
};
$result = new \Cx\Core_Modules\Listing\Model\Entity\DataSet($search->getResultArray($query, 'News', '', $pageUrl, $search->getTerm()));
$search->appendResult($result);
}
作者:nahakiol
项目:cloudrex
/**
* Returns the Event detail page link
*
* @param object $objEvent Event object
*
* @return string link for the detail page
*/
function _getDetailLink($objEvent)
{
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'detail');
$url->setParams(array('id' => $objEvent->id, 'date' => intval($objEvent->startDate)));
if ($objEvent->external) {
$url->setParam('external', 1);
}
return (string) $url;
}
作者:Nigg
项目:cloudrex
/**
* Get a single entry view
* @param int $id
* @return string
*/
function getDetail($id)
{
global $_LANGID;
if ($this->entryArray === false) {
$this->entryArray = $this->createEntryArray();
}
$entry = $this->entryArray[$id];
$title = $entry['translation'][$_LANGID]['subject'];
$content = $this->getIntroductionText($entry['translation'][$_LANGID]['content']);
$this->_objTpl->setTemplate($this->adjustTemplatePlaceholders($this->_arrSettings['data_template_entry']));
$translation = $entry['translation'][$_LANGID];
$image = $this->getThumbnailImage($id, $translation['image'], $translation['thumbnail'], $translation['thumbnail_type']);
$lang = $_LANGID;
$width = $this->_arrSettings['data_shadowbox_width'];
$height = $this->_arrSettings['data_shadowbox_height'];
if ($entry['mode'] == "normal") {
if ($this->_arrSettings['data_entry_action'] == "content") {
$cmd = $this->_arrSettings['data_target_cmd'];
$url = \Cx\Core\Routing\Url::fromModuleAndCmd('Data', $cmd, '', array('id' => $id));
} else {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd('Data', '', '', array('height' => $height, 'width' => $width, 'id' => $id, 'lang' => $lang));
}
} else {
$url = $entry['translation'][$_LANGID]['forward_url'] . '&id=' . $id;
}
$templateVars = array("TITLE" => $title, "IMAGE" => $image, "CONTENT" => $content, "HREF" => $url, "CLASS" => $this->_arrSettings['data_entry_action'] == "overlaybox" && $entry['mode'] == "normal" ? "rel=\"shadowbox;width=" . $width . ";height=" . $height . "\"" : "", "TXT_MORE" => $this->langVars['TXT_DATA_MORE']);
$this->_objTpl->setVariable($templateVars);
$this->_objTpl->parse("datalist_entry");
return $this->_objTpl->get();
}
作者:Cloudrex
项目:cloudrex
function _getNewsPreviewPage()
{
global $objDatabase, $_ARRAYLANG;
\JS::activate('cx');
$mailTemplate = isset($_POST['newsletter_mail_template']) ? intval($_POST['newsletter_mail_template']) : '1';
$importTemplate = isset($_POST['newsletter_import_template']) ? intval($_POST['newsletter_mail_template']) : '2';
if (isset($_GET['view']) && $_GET['view'] == 'iframe') {
$selectedNews = isset($_POST['selected']) ? contrexx_input2db($_POST['selected']) : '';
$mailTemplate = isset($_POST['emailtemplate']) ? intval($_POST['emailtemplate']) : '1';
$importTemplate = isset($_POST['importtemplate']) ? intval($_POST['importtemplate']) : '2';
$HTML_TemplateSource_Import = $this->_getBodyContent($this->_prepareNewsPreview($this->GetTemplateSource($importTemplate, 'html')));
$_REQUEST['standalone'] = true;
$this->_objTpl = new \Cx\Core\Html\Sigma();
\Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
$this->_objTpl->setTemplate($HTML_TemplateSource_Import);
$query = ' SELECT n.id AS newsid,
n.userid AS newsuid,
n.date AS newsdate,
n.teaser_image_path,
n.teaser_image_thumbnail_path,
n.redirect,
n.publisher,
n.publisher_id,
n.author,
n.author_id,
n.catid,
nl.title AS newstitle,
nl.text AS newscontent,
nl.teaser_text,
nc.name AS name
FROM ' . DBPREFIX . 'module_news AS n
INNER JOIN ' . DBPREFIX . 'module_news_locale AS nl ON nl.news_id = n.id
INNER JOIN ' . DBPREFIX . 'module_news_categories_locale AS nc ON nc.category_id=n.catid
WHERE status = 1
AND nl.is_active=1
AND nl.lang_id=' . FRONTEND_LANG_ID . '
AND nc.lang_id=' . FRONTEND_LANG_ID . '
AND n.id IN (' . $selectedNews . ')
ORDER BY nc.name ASC, n.date DESC';
$objNews = $objDatabase->Execute($query);
$objFWUser = \FWUser::getFWUserObject();
$current_category = '';
if ($this->_objTpl->blockExists('news_list')) {
if ($objNews !== false) {
while (!$objNews->EOF) {
$this->_objTpl->setVariable(array('NEWS_CATEGORY_NAME' => $objNews->fields['name']));
if ($current_category == $objNews->fields['catid']) {
$this->_objTpl->hideBlock("news_category");
}
$current_category = $objNews->fields['catid'];
$newsid = $objNews->fields['newsid'];
$newstitle = $objNews->fields['newstitle'];
$newsUrl = empty($objNews->fields['redirect']) ? empty($objNews->fields['newscontent']) ? '' : 'index.php?section=News&cmd=details&newsid=' . $newsid : $objNews->fields['redirect'];
$newstext = ltrim(strip_tags($objNews->fields['newscontent']));
$newsteasertext = ltrim(strip_tags($objNews->fields['teaser_text']));
$newslink = \Cx\Core\Routing\Url::fromModuleAndCmd('News', 'details', '', array('newsid' => $objNews->fields['newsid']));
if ($objNews->fields['newsuid'] && ($objUser = $objFWUser->objUser->getUser($objNews->fields['newsuid']))) {
$author = htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET);
} else {
$author = $_ARRAYLANG['TXT_ANONYMOUS'];
}
list($image, $htmlLinkImage, $imageSource) = \Cx\Core_Modules\News\Controller\NewsLibrary::parseImageThumbnail($objNews->fields['teaser_image_path'], $objNews->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
$this->_objTpl->setVariable(array('NEWS_CATEGORY_NAME' => $objNews->fields['name'], 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objNews->fields['newsdate']), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT_DATETIME, $objNews->fields['newsdate']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_URL' => $newslink, 'NEWS_TEASER_TEXT' => $newsteasertext, 'NEWS_TEXT' => $newstext, 'NEWS_AUTHOR' => $author));
$imageTemplateBlock = "news_image";
if (!empty($image)) {
$this->_objTpl->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage));
if ($this->_objTpl->blockExists($imageTemplateBlock)) {
$this->_objTpl->parse($imageTemplateBlock);
}
} else {
if ($this->_objTpl->blockExists($imageTemplateBlock)) {
$this->_objTpl->hideBlock($imageTemplateBlock);
}
}
$this->_objTpl->parse("news_list");
$objNews->MoveNext();
}
}
$parsedNewsList = $this->_objTpl->get();
} else {
if ($objNews !== false) {
$parsedNewsList = '';
while (!$objNews->EOF) {
$content = $this->_getBodyContent($this->GetTemplateSource($importTemplate, 'html'));
$newstext = ltrim(strip_tags($objNews->fields['newscontent']));
$newsteasertext = substr(ltrim(strip_tags($objNews->fields['teaser_text'])), 0, 100);
$newslink = \Cx\Core\Routing\Url::fromModuleAndCmd('News', 'detals', '', array('newsid' => $objNews->fields['newsid']));
if ($objNews->fields['newsuid'] && ($objUser = $objFWUser->objUser->getUser($objNews->fields['newsuid']))) {
$author = htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET);
} else {
$author = $_ARRAYLANG['TXT_ANONYMOUS'];
}
$search = array('[[NEWS_DATE]]', '[[NEWS_LONG_DATE]]', '[[NEWS_TITLE]]', '[[NEWS_URL]]', '[[NEWS_IMAGE_PATH]]', '[[NEWS_TEASER_TEXT]]', '[[NEWS_TEXT]]', '[[NEWS_AUTHOR]]', '[[NEWS_TYPE_NAME]]', '[[NEWS_CATEGORY_NAME]]');
$replace = array(date(ASCMS_DATE_FORMAT_DATE, $objNews->fields['newsdate']), date(ASCMS_DATE_FORMAT_DATETIME, $objNews->fields['newsdate']), $objNews->fields['newstitle'], $newslink, htmlentities($objNews->fields['teaser_image_thumbnail_path'], ENT_QUOTES, CONTREXX_CHARSET), $newsteasertext, $newstext, $author, $objNews->fields['typename'], $objNews->fields['name']);
$content = str_replace($search, $replace, $content);
if ($parsedNewsList != '') {
$parsedNewsList .= "<br/>" . $content;
} else {
$parsedNewsList = $content;
}
//.........这里部分代码省略.........
作者:Nigg
项目:cloudrex
/**
* Show the cameras
*
* @access private
* @global array
* @global array
* @global array
*/
function showCams()
{
global $_ARRAYLANG, $_CONFIG, $_CORELANG;
$this->_pageTitle = $_ARRAYLANG['TXT_SETTINGS'];
$this->_objTpl->loadTemplateFile('module_livecam_cams.html');
$amount = $this->arrSettings['amount_of_cams'];
$cams = $this->getCamSettings();
$this->_objTpl->setGlobalVariable(array('TXT_SETTINGS' => $_ARRAYLANG['TXT_SETTINGS'], 'TXT_CURRENT_IMAGE_URL' => $_ARRAYLANG['TXT_CURRENT_IMAGE_URL'], 'TXT_ARCHIVE_PATH' => $_ARRAYLANG['TXT_ARCHIVE_PATH'], 'TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_THUMBNAIL_PATH' => $_ARRAYLANG['TXT_THUMBNAIL_PATH'], 'TXT_SHADOWBOX_ACTIVE' => $_CORELANG['TXT_ACTIVATED'], 'TXT_SHADOWBOX_INACTIVE' => $_CORELANG['TXT_DEACTIVATED'], 'TXT_ACTIVATE_SHADOWBOX' => $_ARRAYLANG['TXT_ACTIVATE_SHADOWBOX'], 'TXT_ACTIVATE_SHADOWBOX_INFO' => $_ARRAYLANG['TXT_ACTIVATE_SHADOWBOX_INFO'], 'TXT_MAKE_A_FRONTEND_PAGE' => $_ARRAYLANG['TXT_MAKE_A_FRONTEND_PAGE'], 'TXT_CURRENT_IMAGE_MAX_SIZE' => $_ARRAYLANG['TXT_CURRENT_IMAGE_MAX_SIZE'], 'TXT_THUMBNAIL_MAX_SIZE' => $_ARRAYLANG['TXT_THUMBNAIL_MAX_SIZE'], 'TXT_CAM' => $_ARRAYLANG['TXT_CAM'], 'TXT_SUCCESS' => $_CORELANG['TXT_SETTINGS_UPDATED'], 'TXT_TO_MODULE' => $_ARRAYLANG['TXT_LIVECAM_TO_MODULE'], 'TXT_SHOWFROM' => $_ARRAYLANG['TXT_LIVECAM_SHOWFROM'], 'TXT_SHOWTILL' => $_ARRAYLANG['TXT_LIVECAM_SHOWTILL'], 'TXT_OCLOCK' => $_ARRAYLANG['TXT_LIVECAM_OCLOCK']));
for ($i = 1; $i <= $amount; $i++) {
if ($cams[$i]['shadowboxActivate'] == 1) {
$shadowboxActive = 'checked="checked"';
$shadowboxInctive = '';
} else {
$shadowboxActive = '';
$shadowboxInctive = 'checked="checked"';
}
try {
// fetch CMD specific livecam page
$camUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Livecam', $i, FRONTEND_LANG_ID, array(), '', false);
} catch (\Cx\Core\Routing\UrlException $e) {
// fetch generic livecam page
$camUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Livecam');
}
$this->_objTpl->setVariable(array('CAM_NUMBER' => $i, 'LIVECAM_CAM_URL' => $camUrl, 'CURRENT_IMAGE_URL' => $cams[$i]['currentImagePath'], 'ARCHIVE_PATH' => $cams[$i]['archivePath'], 'THUMBNAIL_PATH' => $cams[$i]['thumbnailPath'], 'SHADOWBOX_ACTIVE' => $shadowboxActive, 'SHADOWBOX_INACTIVE' => $shadowboxInctive, 'CURRENT_IMAGE_MAX_SIZE' => $cams[$i]['maxImageWidth'], 'THUMBNAIL_MAX_SIZE' => $cams[$i]['thumbMaxSize'], 'HOUR_FROM' => $this->getHourOptions($cams[$i]['showFrom']), 'MINUTE_FROM' => $this->getMinuteOptions($cams[$i]['showFrom']), 'HOUR_TILL' => $this->getHourOptions(!empty($cams[$i]['showTill']) ? $cams[$i]['showTill'] : mktime(23)), 'MINUTE_TILL' => $this->getMinuteOptions(!empty($cams[$i]['showTill']) ? $cams[$i]['showTill'] : mktime(0, 59))));
if (preg_match("/^https{0,1}:\\/\\//", $cams[$i]['currentImagePath'])) {
$filepath = $cams[$i]['currentImagePath'];
$this->_objTpl->setVariable("PATH", $filepath);
$this->_objTpl->parse("current_image");
} else {
$filepath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $cams[$i]['currentImagePath'];
if (\Cx\Lib\FileSystem\FileSystem::exists($filepath) && is_file($filepath)) {
$this->_objTpl->setVariable("PATH", $cams[$i]['currentImagePath']);
$this->_objTpl->parse("current_image");
} else {
$this->_objTpl->hideBlock("current_image");
}
}
$this->_objTpl->parse("cam");
/*
$this->_objTpl->setVariable('BLOCK_USE_BLOCK_SYSTEM', $_CONFIG['blockStatus'] == '1' ? 'checked="checked"' : '');
*/
}
}
作者:Nigg
项目:cloudrex
public function testTargetPathAndParams()
{
return false;
$this->insertFixtures();
$lang = 1;
$url = new Url('http://example.com/testpage1/testpage1_child/?foo=test');
$resolver = new Resolver($url, $lang, self::$em, '', $this->mockFallbackLanguages);
$resolver->resolve();
$this->assertEquals('testpage1/testpage1_child/', $url->getTargetPath());
$this->assertEquals('?foo=test', $url->getParams());
$this->assertEquals(true, $url->isRouted());
}
作者:Cloudrex
项目:cloudrex
/**
* Uses the given Entity Manager to retrieve all links for the placeholders
* @param EntityManager $em
*/
public function fetch($em)
{
if ($this->placeholders === null) {
throw new LinkGeneratorException('Seems like scan() was never called before calling fetch().');
}
$qb = $em->createQueryBuilder();
$qb->add('select', new Doctrine\ORM\Query\Expr\Select(array('p')));
$qb->add('from', new Doctrine\ORM\Query\Expr\From('Cx\\Core\\ContentManager\\Model\\Entity\\Page', 'p'));
//build a big or with all the node ids and pages
$arrExprs = null;
$fetchedPages = array();
$pIdx = 0;
foreach ($this->placeholders as $placeholder => $data) {
if ($data['type'] == 'id') {
# page is referenced by NODE-ID (i.e.: [[NODE_1]])
if (isset($fetchedPages[$data['nodeid']][$data['lang']])) {
continue;
}
$arrExprs[] = $qb->expr()->andx($qb->expr()->eq('p.node', $data['nodeid']), $qb->expr()->eq('p.lang', $data['lang']));
$fetchedPages[$data['nodeid']][$data['lang']] = true;
} else {
# page is referenced by module (i.e.: [[NODE_SHOP_CART]])
if (isset($fetchedPages[$data['module']][$data['cmd']][$data['lang']])) {
continue;
}
$arrExprs[] = $qb->expr()->andx($qb->expr()->eq('p.type', ':type'), $qb->expr()->eq('p.module', ':module_' . $pIdx), $qb->expr()->eq('p.cmd', ':cmd_' . $pIdx), $qb->expr()->eq('p.lang', $data['lang']));
$qb->setParameter('module_' . $pIdx, $data['module']);
$qb->setParameter('cmd_' . $pIdx, empty($data['cmd']) ? null : $data['cmd']);
$qb->setParameter('type', \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION);
$fetchedPages[$data['module']][$data['cmd']][$data['lang']] = true;
$pIdx++;
}
}
//fetch the nodes if there are any in the query
if ($arrExprs) {
foreach ($arrExprs as $expr) {
$qb->orWhere($expr);
}
$pages = $qb->getQuery()->getResult();
foreach ($pages as $page) {
// build placeholder's value -> URL
$url = \Cx\Core\Routing\Url::fromPage($page);
$placeholderByApp = '';
$placeholderById = \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX . $page->getNode()->getId();
$this->placeholders[$placeholderById . '_' . $page->getLang()] = $url;
if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
$module = $page->getModule();
$cmd = $page->getCmd();
$placeholderByApp = \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX;
$placeholderByApp .= strtoupper($module . (empty($cmd) ? '' : '_' . $cmd));
$this->placeholders[$placeholderByApp . '_' . $page->getLang()] = $url;
}
if ($page->getLang() == FRONTEND_LANG_ID) {
$this->placeholders[$placeholderById] = $url;
if (!empty($placeholderByApp)) {
$this->placeholders[$placeholderByApp] = $url;
}
}
}
}
// there might be some placeholders we were unable to resolve.
// try to resolve them by using the fallback-language-reverse-lookup
// methode provided by \Cx\Core\Routing\Url::fromModuleAndCmd().
foreach ($this->placeholders as $placeholder => $data) {
if (!$data instanceof \Cx\Core\Routing\Url) {
if (!empty($data['module'])) {
try {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['cmd'], $data['lang'], array(), '', false);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
} catch (\Cx\Core\Routing\UrlException $e) {
if ($data['lang'] && $data['cmd']) {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['cmd'] . '_' . $data['lang'], FRONTEND_LANG_ID);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
} else {
if ($data['lang'] && empty($data['cmd'])) {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['lang'], FRONTEND_LANG_ID);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
} else {
$url = \Cx\Core\Routing\Url::fromModuleAndCmd('Error', '', $data['lang']);
if ($this->absoluteUris && $this->domain) {
$url->setDomain($this->domain);
}
$this->placeholders[$placeholder] = $url->toString($this->absoluteUris);
}
}
}
} else {
//.........这里部分代码省略.........
作者:Cloudrex
项目:cloudrex
/**
* Appends a VG-style parameter to an Url object
*
* VG-style means:
* {<vgIncrementNumber>,(<key>=)<value>}(,...)
* @param \Cx\Core\Routing\Url $url Url object to apply params to
* @param int $vgId ID of the VG for the parameter
* @param string $name Parameter name
* @param string $value Parameter value
*/
protected static function appendVgParam($url, $vgId, $name, $value)
{
$params = $url->getParamArray();
$pre = '';
if (isset($params[$name])) {
$pre = $params[$name];
}
if (!empty($pre)) {
$pre .= ',';
}
$url->setParam($name, $pre . '{' . $vgId . ',' . $value . '}');
}
作者:Cloudrex
项目:cloudrex
/**
* Returns an array of values to be substituted
*
* Contains the following keys and values:
* 'SHOP_COMPANY' => The company name (from the settings)
* 'SHOP_HOMEPAGE' => The shop starting page URL
* Used primarily for all MailTemplates.
* Indexed by placeholder names.
* @return array The substitution array
*/
static function getSubstitutionArray()
{
return array('SHOP_COMPANY' => \Cx\Core\Setting\Controller\Setting::getValue('company', 'Shop'), 'SHOP_HOMEPAGE' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '', FRONTEND_LANG_ID)->toString());
}
作者:Nigg
项目:cloudrex
/**
* Performs the box view
*
* @return null
*/
function showThreeBoxes()
{
global $_ARRAYLANG;
$objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($this->startDate, $this->endDate, $this->categoryId, $this->searchTerm, true, $this->needAuth, true, 0, 'n', $this->sortDirection, true, $this->author);
$objEventManager->getEventList();
$this->_objTpl->setTemplate($this->pageContent);
if ($_REQUEST['cmd'] == 'boxes') {
$objEventManager->calendarBoxUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', 'boxes')->toString() . "?act=list";
$objEventManager->calendarBoxMonthNavUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', 'boxes')->toString();
} else {
$objEventManager->calendarBoxUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', '')->toString() . "?act=list";
$objEventManager->calendarBoxMonthNavUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', '')->toString();
}
if (empty($_GET['catid'])) {
$catid = 0;
} else {
$catid = $_GET['catid'];
}
if (isset($_GET['yearID']) && isset($_GET['monthID']) && isset($_GET['dayID'])) {
$day = $_GET['dayID'];
$month = $_GET['monthID'];
$year = $_GET['yearID'];
} elseif (isset($_GET['yearID']) && isset($_GET['monthID']) && !isset($_GET['dayID'])) {
$day = 0;
$month = $_GET['monthID'];
$year = $_GET['yearID'];
} elseif (isset($_GET['yearID']) && !isset($_GET['monthID']) && !isset($_GET['dayID'])) {
$day = 0;
$month = 0;
$year = $_GET['yearID'];
} else {
$day = date("d");
$month = date("m");
$year = date("Y");
}
$calendarbox = $objEventManager->getBoxes($this->boxCount, $year, $month, $day, $catid);
$objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true);
$objCategoryManager->getCategoryList();
$this->_objTpl->setVariable(array("TXT_{$this->moduleLangVar}_ALL_CAT" => $_ARRAYLANG['TXT_CALENDAR_ALL_CAT'], "{$this->moduleLangVar}_BOX" => $calendarbox, "{$this->moduleLangVar}_JAVA_SCRIPT" => $objEventManager->getCalendarBoxJS(), "{$this->moduleLangVar}_CATEGORIES" => $objCategoryManager->getCategoryDropdown($catid, 1)));
}
作者:nahakiol
项目:cloudrex
/**
* Show most viewed pages
*
* Show a list of the most viewed pages
*
* @access private
* @global array
* @see _initMostViewedPagesStatistics()
*/
function _showMostViewedPages()
{
global $_ARRAYLANG;
$i = 0;
$this->_objTpl->addBlockfile('STATS_REQUESTS_CONTENT', 'requests_block', 'module_stats_mvp.html');
$this->pageTitle = $_ARRAYLANG['TXT_MOST_POPULAR_PAGES'];
$this->_initMostViewedPages();
// set language variables
$this->_objTpl->setVariable(array('TXT_MOST_POPULAR_PAGES' => $_ARRAYLANG['TXT_MOST_POPULAR_PAGES'], 'TXT_PAGE' => $_ARRAYLANG['TXT_PAGE'], 'TXT_REQUESTS' => $_ARRAYLANG['TXT_REQUESTS'], 'TXT_LAST_REQUEST' => $_ARRAYLANG['TXT_LAST_REQUEST']));
if (count($this->arrMostViewedPages) > 0) {
foreach ($this->arrMostViewedPages as $stats) {
$page = \Env::get('em')->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findOneBy(array('id' => $stats['id']));
if ($page) {
$url = \Cx\Core\Routing\Url::fromPage($page);
$title = '<a href="' . $url . '" target="_blank">' . $page->getTitle() . '</a> (/' . $url->getLangDir() . '/' . $url->getPath() . ')';
} else {
$title = '<span>' . $stats['title'] . '</span> (' . $stats['page'] . ')';
}
$this->_objTpl->setVariable(array('STATS_REQUESTS_PAGE' => $title, 'STATS_REQUESTS_REQUESTS' => $this->_makePercentBar(300, 10, $stats['requests'] * 100 / $this->mostViewedPagesSum, 100, 1, '') . ' ' . round($stats['requests'] * 100 / $this->mostViewedPagesSum, 2) . '%' . ' (' . $stats['requests'] . ')', 'STATS_REQUESTS_LAST_REQUEST' => $stats['last_request'], 'STATS_REQUESTS_ROW_CLASS' => $i % 2 == 0 ? 'row2' : 'row1'));
$this->_objTpl->parse('stats_requests_mvp');
$this->_objTpl->hideBlock('stats_requests_nodata');
$i++;
}
} else {
$this->_objTpl->hideBlock('stats_requests');
$this->_objTpl->setVariable(array('TXT_NO_DATA_AVAILABLE' => $_ARRAYLANG['TXT_NO_DATA_AVAILABLE']));
}
$this->_objTpl->parse('requests_block');
}
作者:Nigg
项目:cloudrex
/**
* Initialize the mail functionality to the recipient
*
* @param \Cx\Modules\Calendar\Controller\CalendarEvent $event Event instance
* @param integer $actionId Mail action id
* @param integer $regId Registration id
* @param string $mailTemplate Mail template id
*/
function sendMail(CalendarEvent $event, $actionId, $regId = null, $mailTemplate = null)
{
global $objDatabase, $_ARRAYLANG, $_CONFIG;
$this->mailList = array();
// Loads the mail template which needs for this action
$this->loadMailList($actionId, $mailTemplate);
if (!empty($this->mailList)) {
$objRegistration = null;
if (!empty($regId)) {
$objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($event->registrationForm, $regId);
list($registrationDataText, $registrationDataHtml) = $this->getRegistrationData($objRegistration);
$query = 'SELECT `v`.`value`, `n`.`default`, `f`.`type`
FROM ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value AS `v`
INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_name AS `n`
ON `v`.`field_id` = `n`.`field_id`
INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field AS `f`
ON `v`.`field_id` = `f`.`id`
WHERE `v`.`reg_id` = ' . $regId . '
AND (
`f`.`type` = "salutation"
OR `f`.`type` = "firstname"
OR `f`.`type` = "lastname"
OR `f`.`type` = "mail"
)';
$objResult = $objDatabase->Execute($query);
$arrDefaults = array();
$arrValues = array();
if ($objResult !== false) {
while (!$objResult->EOF) {
if (!empty($objResult->fields['default'])) {
$arrDefaults[$objResult->fields['type']] = explode(',', $objResult->fields['default']);
}
$arrValues[$objResult->fields['type']] = $objResult->fields['value'];
$objResult->MoveNext();
}
}
$regSalutation = !empty($arrValues['salutation']) ? $arrDefaults['salutation'][$arrValues['salutation'] - 1] : '';
$regFirstname = !empty($arrValues['firstname']) ? $arrValues['firstname'] : '';
$regLastname = !empty($arrValues['lastname']) ? $arrValues['lastname'] : '';
$regMail = !empty($arrValues['mail']) ? $arrValues['mail'] : '';
$regType = $objRegistration->type == 1 ? $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] : $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'];
$regSearch = array('[[REGISTRATION_TYPE]]', '[[REGISTRATION_SALUTATION]]', '[[REGISTRATION_FIRSTNAME]]', '[[REGISTRATION_LASTNAME]]', '[[REGISTRATION_EMAIL]]');
$regReplace = array($regType, $regSalutation, $regFirstname, $regLastname, $regMail);
}
$domain = ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . "/";
$date = $this->format2userDateTime(new \DateTime());
$startDate = $event->startDate;
$endDate = $event->endDate;
$eventTitle = $event->title;
$eventStart = $event->all_day ? $this->format2userDate($startDate) : $this->formatDateTime2user($startDate, $this->getDateFormat() . ' (H:i:s)');
$eventEnd = $event->all_day ? $this->format2userDate($endDate) : $this->formatDateTime2user($endDate, $this->getDateFormat() . ' (H:i:s)');
$placeholder = array('[[TITLE]]', '[[START_DATE]]', '[[END_DATE]]', '[[LINK_EVENT]]', '[[LINK_REGISTRATION]]', '[[USERNAME]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[URL]]', '[[DATE]]');
$recipients = $this->getSendMailRecipients($actionId, $event, $regId, $objRegistration);
$objMail = new \phpmailer();
if ($_CONFIG['coreSmtpServer'] > 0) {
$arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']);
if ($arrSmtp !== 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']);
foreach ($recipients as $mailAdress => $langId) {
if (!empty($mailAdress)) {
$langId = $this->getSendMailLangId($actionId, $mailAdress, $langId);
if ($objUser = \FWUser::getFWUserObject()->objUser->getUsers($filter = array('email' => $mailAdress, 'is_active' => true))) {
$userNick = $objUser->getUsername();
$userFirstname = $objUser->getProfileAttribute('firstname');
$userLastname = $objUser->getProfileAttribute('lastname');
} else {
$userNick = $mailAdress;
if (!empty($regId) && $mailAdress == $regMail) {
$userFirstname = $regFirstname;
$userLastname = $regLastname;
} else {
$userFirstname = '';
$userLastname = '';
}
}
$mailTitle = $this->mailList[$langId]['mail']->title;
$mailContentText = !empty($this->mailList[$langId]['mail']->content_text) ? $this->mailList[$langId]['mail']->content_text : strip_tags($this->mailList[$langId]['mail']->content_html);
$mailContentHtml = !empty($this->mailList[$langId]['mail']->content_html) ? $this->mailList[$langId]['mail']->content_html : $this->mailList[$langId]['mail']->content_text;
// actual language of selected e-mail template
$contentLanguage = $this->mailList[$langId]['lang_id'];
if ($actionId == self::MAIL_NOTFY_NEW_APP && $event->arrSettings['confirmFrontendEvents'] == 1) {
$eventLink = $domain . "/cadmin/index.php?cmd={$this->moduleName}&act=modify_event&id={$event->id}&confirm=1";
} else {
//.........这里部分代码省略.........
作者:Nigg
项目:cloudrex
/**
* Gets the search results.
*
* @return mixed Parsed content.
*/
public function getSearchResults()
{
global $_ARRAYLANG;
$this->template->addBlockfile('ADMIN_CONTENT', 'search', 'Default.html');
if (!empty($this->term)) {
$pages = $this->getSearchedPages();
$countPages = $this->countSearchedPages();
usort($pages, array($this, 'sortPages'));
if ($countPages > 0) {
$parameter = '&cmd=Search' . (empty($this->term) ? '' : '&term=' . contrexx_raw2encodedUrl($this->term));
$paging = \Paging::get($parameter, '', $countPages, 0, true, null, 'pos');
$this->template->setVariable(array('TXT_SEARCH_RESULTS_COMMENT' => sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_COMMENT'], $this->term, $countPages), 'TXT_SEARCH_TITLE' => $_ARRAYLANG['TXT_NAVIGATION_TITLE'], 'TXT_SEARCH_CONTENT_TITLE' => $_ARRAYLANG['TXT_PAGETITLE'], 'TXT_SEARCH_SLUG' => $_ARRAYLANG['TXT_CORE_CM_SLUG'], 'TXT_SEARCH_LANG' => $_ARRAYLANG['TXT_LANGUAGE'], 'SEARCH_PAGING' => $paging));
foreach ($pages as $page) {
// used for alias pages, because they have no language
if ($page->getLang() == "") {
$languages = "";
foreach (\FWLanguage::getIdArray('frontend') as $langId) {
$languages[] = \FWLanguage::getLanguageCodeById($langId);
}
} else {
$languages = array(\FWLanguage::getLanguageCodeById($page->getLang()));
}
$aliasLanguages = implode(', ', $languages);
$originalPage = $page;
$link = 'index.php?cmd=ContentManager&page=' . $page->getId();
if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS) {
$pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
if ($originalPage->isTargetInternal()) {
// is internal target, get target page
$originalPage = $pageRepo->getTargetPage($page);
} else {
// is an external target, set the link to the external targets url
$originalPage = new \Cx\Core\ContentManager\Model\Entity\Page();
$originalPage->setTitle($page->getTarget());
$link = $page->getTarget();
}
}
$this->template->setVariable(array('SEARCH_RESULT_BACKEND_LINK' => $link, 'SEARCH_RESULT_TITLE' => $originalPage->getTitle(), 'SEARCH_RESULT_CONTENT_TITLE' => $originalPage->getContentTitle(), 'SEARCH_RESULT_SLUG' => substr($page->getPath(), 1), 'SEARCH_RESULT_LANG' => $aliasLanguages, 'SEARCH_RESULT_FRONTEND_LINK' => \Cx\Core\Routing\Url::fromPage($page)));
$this->template->parse('search_result_row');
}
} else {
$this->template->setVariable(array('TXT_SEARCH_NO_RESULTS' => sprintf($_ARRAYLANG['TXT_SEARCH_NO_RESULTS'], $this->term)));
}
} else {
$this->template->setVariable(array('TXT_SEARCH_NO_TERM' => $_ARRAYLANG['TXT_SEARCH_NO_TERM']));
}
}
作者:nahakiol
项目:cloudrex
/**
* Get a list of all news messages sorted by year and month.
*
* @access private
* @return string parsed content
*/
private function getArchive()
{
global $objDatabase, $_ARRAYLANG;
$categories = '';
$i = 0;
if ($categories = substr($_REQUEST['cmd'], 7)) {
$categories = $this->getCatIdsFromNestedSetArray($this->getNestedSetCategories(explode(',', $categories)));
}
$monthlyStats = $this->getMonthlyNewsStats($categories);
if (!empty($monthlyStats)) {
foreach ($monthlyStats as $key => $value) {
$this->_objTpl->setVariable(array('NEWS_ARCHIVE_MONTH_KEY' => $key, 'NEWS_ARCHIVE_MONTH_NAME' => $value['name'], 'NEWS_ARCHIVE_MONTH_COUNT' => count($value['news'])));
$this->_objTpl->parse('news_archive_months_list_item');
foreach ($value['news'] as $news) {
$newsid = $news['id'];
$newstitle = $news['newstitle'];
$newsCategories = $this->getCategoriesByNewsId($newsid);
$newsCommentActive = $news['commentactive'];
$newsUrl = empty($news['newsredirect']) ? empty($news['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), $categories)), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $news['newsredirect'];
$htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml('[' . $_ARRAYLANG['TXT_NEWS_MORE'] . '...]'));
list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($news['teaser_image_path'], $news['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
$author = \FWUser::getParsedUserTitle($news['author_id'], $news['author']);
$publisher = \FWUser::getParsedUserTitle($news['publisher_id'], $news['publisher']);
$objResult = $objDatabase->Execute('SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $newsid);
$this->_objTpl->setVariable(array('NEWS_ARCHIVE_ID' => $newsid, 'NEWS_ARCHIVE_CSS' => 'row' . ($i % 2 + 1), 'NEWS_ARCHIVE_TEASER' => nl2br($news['teaser_text']), 'NEWS_ARCHIVE_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_ARCHIVE_LONG_DATE' => date(ASCMS_DATE_FORMAT, $news['newsdate']), 'NEWS_ARCHIVE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $news['newsdate']), 'NEWS_ARCHIVE_TIME' => date(ASCMS_DATE_FORMAT_TIME, $news['newsdate']), 'NEWS_ARCHIVE_LINK_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_ARCHIVE_LINK' => $htmlLink, 'NEWS_ARCHIVE_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_ARCHIVE_CATEGORY' => stripslashes($news['name']), 'NEWS_ARCHIVE_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_ARCHIVE_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_ARCHIVE_COUNT_COMMENTS' => contrexx_raw2xhtml($objResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS'])));
if (!$newsCommentActive || !$this->arrSettings['news_comments_activated']) {
if ($this->_objTpl->blockExists('news_archive_comments_count')) {
$this->_objTpl->hideBlock('news_archive_comments_count');
}
}
if (!empty($image)) {
$this->_objTpl->setVariable(array('NEWS_ARCHIVE_IMAGE' => $image, 'NEWS_ARCHIVE_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_ARCHIVE_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_ARCHIVE_IMAGE_LINK' => $htmlLinkImage));
if ($this->_objTpl->blockExists('news_archive_image')) {
$this->_objTpl->parse('news_archive_image');
}
} elseif ($this->_objTpl->blockExists('news_archive_image')) {
$this->_objTpl->hideBlock('news_archive_image');
}
self::parseImageBlock($this->_objTpl, $news['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'archive_image_thumbnail');
self::parseImageBlock($this->_objTpl, $news['teaser_image_path'], $newstitle, $newsUrl, 'archive_image_detail');
$this->_objTpl->parse('news_archive_link');
$i++;
}
$this->_objTpl->setVariable(array('NEWS_ARCHIVE_MONTH_KEY' => $key, 'NEWS_ARCHIVE_MONTH_NAME' => $value['name']));
$this->_objTpl->parse('news_archive_month_list_item');
}
$this->_objTpl->parse('news_archive_months_list');
$this->_objTpl->parse('news_archive_month_list');
if ($this->_objTpl->blockExists('news_archive_status_message')) {
$this->_objTpl->hideBlock('news_archive_status_message');
}
} else {
$this->_objTpl->setVariable('TXT_NEWS_NO_NEWS_FOUND', $_ARRAYLANG['TXT_NEWS_NO_NEWS_FOUND']);
if ($this->_objTpl->blockExists('news_archive_status_message')) {
$this->_objTpl->parse('news_archive_status_message');
}
$this->_objTpl->hideblock('news_archive_months_list');
$this->_objTpl->hideBlock('news_archive_month_list');
}
return $this->_objTpl->get();
}
作者:Nigg
项目:cloudrex
/**
* @static
* @param integer $fileId
* @return string the download link
*/
public static function getDeleteLink($fileId)
{
global $objDatabase;
$objResult = $objDatabase->SelectLimit("SELECT `cmd`, `hash`, `check` FROM " . DBPREFIX . "module_filesharing WHERE `id` = " . intval($fileId), 1, 0);
if ($objResult !== false) {
$params = array('hash' => $objResult->fields['hash'], 'check' => $objResult->fields['check']);
try {
$objUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('FileSharing', $objResult->fields['cmd'], FRONTEND_LANG_ID, $params, '', false);
} catch (\Cx\Core\Routing\UrlException $e) {
$objUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('FileSharing', '', FRONTEND_LANG_ID, $params);
}
return $objUrl->toString();
} else {
return false;
}
}