예제 #1
0
 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();
 }
예제 #2
0
 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();
 }
예제 #3
0
 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);
 }
예제 #4
0
    /**
     * 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;
    }
 /**
  * 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);
 }
예제 #6
0
 /**
  * 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);
 }
 /**
  * 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;
 }
예제 #8
0
 /**
  * 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'] . '&amp;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();
 }
 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;
                     }
                     $objNews->MoveNext();
                 }
             }
         }
         $previewHTML = str_replace("[[content]]", $parsedNewsList, $this->GetTemplateSource($mailTemplate, 'html'));
         $this->_objTpl->setTemplate($previewHTML);
         return $this->_objTpl->get();
     } else {
         $selected = isset($_POST['SelectedNews']) ? $_POST['SelectedNews'] : '';
         $selectedNews = implode(",", $selected);
         $this->_pageTitle = $_ARRAYLANG['TXT_NEWSLETTER_NEWS_IMPORT_PREVIEW'];
         $this->_objTpl->loadTemplateFile('newsletter_news_preview.html');
         $this->_objTpl->setVariable(array('TXT_EMAIL_LAYOUT' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_EMAIL_LAYOUT'], 'TXT_IMPORT_LAYOUT' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_IMPORT_LAYOUT'], 'TXT_NEWS_PREVIEW' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_PREVIEW'], 'TXT_CREATE_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_CREATE_EMAIL'], 'NEWSLETTER_MAIL_TEMPLATE_MENU' => $this->_getTemplateMenu($mailTemplate, 'id="newsletter_mail_template" name="newsletter_mail_template" style="width:300px;" onchange="refreshIframe();"'), 'NEWSLETTER_IMPORT_TEMPLATE_MENU' => $this->_getTemplateMenu($importTemplate, 'id="newsletter_import_template" name="newsletter_import_template" style="width:300px;" onchange="refreshIframe();"', 'news'), 'NEWSLETTER_SELECTED_NEWS' => $selectedNews, 'NEWSLETTER_SELECTED_EMAIL_TEMPLATE' => $mailTemplate, 'NEWSLETTER_SELECTED_IMPORT_TEMPLATE' => $importTemplate));
     }
 }
예제 #10
0
 /**
  * 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"' : '');
         */
     }
 }
예제 #11
0
 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());
 }
예제 #12
0
 /**
  * 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 {
                 $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 {
             if ($this->absoluteUris && $this->domain) {
                 $data->setDomain($this->domain);
             }
             $this->placeholders[$placeholder] = $data->toString($this->absoluteUris);
         }
     }
     $this->fetchingDone = true;
 }
예제 #13
0
 /**
  * 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 . '}');
 }
예제 #14
0
 /**
  * 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());
 }
예제 #15
0
 /**
  * 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)));
 }
예제 #16
0
 /**
  * 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, '') . '&nbsp;' . 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');
 }
예제 #17
0
 /**
  * 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 {
                     $eventLink = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'detail', $contentLanguage, array('id' => $event->id, 'date' => $event->startDate->getTimestamp()))->toString();
                 }
                 $regLink = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'register', $contentLanguage, array('id' => $event->id, 'date' => $event->startDate->getTimestamp()))->toString();
                 $replaceContent = array($eventTitle, $eventStart, $eventEnd, $eventLink, $regLink, $userNick, $userFirstname, $userLastname, $domain, $date);
                 $mailTitle = str_replace($placeholder, $replaceContent, $mailTitle);
                 $mailContentText = str_replace($placeholder, $replaceContent, $mailContentText);
                 $mailContentHtml = str_replace($placeholder, $replaceContent, $mailContentHtml);
                 if (!empty($regId)) {
                     $mailTitle = str_replace($regSearch, $regReplace, $mailTitle);
                     $mailContentText = str_replace($regSearch, $regReplace, $mailContentText);
                     $mailContentHtml = str_replace($regSearch, $regReplace, $mailContentHtml);
                     $mailContentText = str_replace('[[REGISTRATION_DATA]]', $registrationDataText, $mailContentText);
                     $mailContentHtml = str_replace('[[REGISTRATION_DATA]]', $registrationDataHtml, $mailContentHtml);
                 }
                 /*echo "send to: ".$mailAdress."<br />";
                   echo "send title: ".$mailTitle."<br />";*/
                 $objMail->Subject = $mailTitle;
                 $objMail->Body = $mailContentHtml;
                 $objMail->AltBody = $mailContentText;
                 $objMail->AddAddress($mailAdress);
                 $objMail->Send();
                 $objMail->ClearAddresses();
             }
         }
     }
 }
예제 #18
0
 /**
  * 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&amp;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']));
     }
 }
예제 #19
0
 /**
  * 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();
 }
예제 #20
0
 /**
  * @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;
     }
 }
예제 #21
0
 function getRecentNewsComments()
 {
     global $objDatabase;
     $this->_objTemplate->setTemplate($this->_pageContent, true, true);
     // abort if template block is missing
     if (!$this->_objTemplate->blockExists('news_comments')) {
         return;
     }
     // abort if commenting system is not active
     if (!$this->arrSettings['news_comments_activated']) {
         $this->_objTemplate->hideBlock('news_comments');
     } else {
         $_ARRAYLANG = \Env::get('init')->loadLanguageData('News');
         $commentsCount = (int) $this->arrSettings['recent_news_message_limit'];
         $query = "SELECT  `nComment`.`title`,\n                              `nComment`.`date`,\n                              `nComment`.`poster_name`,\n                              `nComment`.`userid`,\n                              `nComment`.`text`,\n                              `news`.`id`\n                        FROM  \n                              `" . DBPREFIX . "module_news_comments` AS nComment\n                        LEFT JOIN \n                              `" . DBPREFIX . "module_news` AS news\n                        ON\n                            `nComment`.newsid = `news`.id\n                        LEFT JOIN \n                              `" . DBPREFIX . "module_news_locale` AS nLocale\n                        ON\n                            `news`.id = `nLocale`.news_id AND `nLocale`.lang_id = " . FRONTEND_LANG_ID . "\n                        WHERE\n                            `news`.status = 1\n                        AND\n                            `news`.allow_comments = 1\n                        AND\n                            `nLocale`.is_active = 1\n                        AND\n                            `nComment`.`is_active` = '1'\n                        ORDER BY\n                              `date` DESC \n                        LIMIT 0, {$commentsCount}";
         $objResult = $objDatabase->Execute($query);
         // no comments for this message found
         if (!$objResult || $objResult->EOF) {
             if ($this->_objTemplate->blockExists('news_no_comment')) {
                 $this->_objTemplate->setVariable('TXT_NEWS_COMMENTS_NONE_EXISTING', $_ARRAYLANG['TXT_NEWS_COMMENTS_NONE_EXISTING']);
                 $this->_objTemplate->parse('news_no_comment');
             }
             $this->_objTemplate->hideBlock('news_comment_list');
             $this->_objTemplate->parse('news_comments');
             return $this->_objTemplate->get();
         }
         $i = 0;
         while (!$objResult->EOF) {
             self::parseUserAccountData($this->_objTemplate, $objResult->fields['userid'], $objResult->fields['poster_name'], 'news_comments_poster');
             $commentTitle = $objResult->fields['title'];
             $newsCategories = $this->getCategoriesByNewsId($objResult->fields['id']);
             $newsUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', array_keys($newsCategories)), FRONTEND_LANG_ID, array('newsid' => $objResult->fields['id']));
             $newsLink = self::parseLink($newsUrl, $commentTitle, contrexx_raw2xhtml($commentTitle));
             $this->_objTemplate->setVariable(array('NEWS_COMMENTS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_COMMENTS_TITLE' => contrexx_raw2xhtml($commentTitle), 'NEWS_COMMENTS_MESSAGE' => nl2br(contrexx_raw2xhtml($objResult->fields['text'])), 'NEWS_COMMENTS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_COMMENTS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_COMMENTS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_COMMENT_LINK' => $newsLink, 'NEWS_COMMENT_URL' => $newsUrl));
             $this->_objTemplate->parse('news_comment');
             $i++;
             $objResult->MoveNext();
         }
         $this->_objTemplate->parse('news_comment_list');
         $this->_objTemplate->hideBlock('news_no_comment');
     }
     return $this->_objTemplate->get();
 }
예제 #22
0
 /**
  * Searchs for an user with the given user id of the social media platform.
  * If there is no user, create one and directly log in.
  *
  * @param string $oauth_id the user id of the social media platform
  * @return bool
  * @throws OAuth_Exception
  */
 protected function getContrexxUser($oauth_id)
 {
     global $sessionObj;
     //\DBG::activate();
     $arrSettings = \User_Setting::getSettings();
     $provider = $this::OAUTH_PROVIDER;
     $FWUser = \FWUser::getFWUserObject();
     $objUser = $FWUser->objUser->getByNetwork($provider, $oauth_id);
     if (!$objUser) {
         // check whether the user is already logged in
         // if the user is logged in just add a new network to the user object
         if ($FWUser->objUser->login()) {
             $objUser = $FWUser->objUser;
             $this->addProviderToUserObject($provider, $oauth_id, $objUser);
             $objUser->getNetworks()->save();
             return true;
         }
         // create a new user with the default profile attributes
         $objUser = new \User();
         $objUser->setEmail($this->getEmail());
         $objUser->setAdminStatus(0);
         $objUser->setProfile(array('firstname' => array($this->getFirstname()), 'lastname' => array($this->getLastname())));
         $registrationRedirectNeeded = $arrSettings['sociallogin_show_signup']['status'];
         // if user_account_verification is true (1), then we need to do checkMandatoryCompliance(), because
         // the required fields must be set.
         if ($registrationRedirectNeeded == false && $arrSettings['user_account_verification']['value'] === 1) {
             $registrationRedirectNeeded = !$objUser->checkMandatoryCompliance();
         }
         $objUser->setActiveStatus(!$registrationRedirectNeeded);
         if ($registrationRedirectNeeded) {
             $objUser->setRestoreKey();
             $objUser->setRestoreKeyTime(intval($arrSettings['sociallogin_activation_timeout']['value']) * 60);
         }
         if (!empty($arrSettings['sociallogin_assign_to_groups']['value'])) {
             $groups = $arrSettings['sociallogin_assign_to_groups']['value'];
         } else {
             $groups = $arrSettings['assigne_to_groups']['value'];
         }
         $objUser->setGroups(explode(',', $groups));
         // if we can create the user without sign up page
         if (!$objUser->store()) {
             // if the email address already exists but not with the given oauth-provider
             throw new OAuth_Exception();
         }
         // add the social network to user
         $this->addProviderToUserObject($provider, $oauth_id, $objUser);
         $objUser->getNetworks()->save();
         // check whether there are empty mandatory fields or the setting to show sign up everytime
         if ($registrationRedirectNeeded) {
             // start session if no session is open
             if (!isset($sessionObj) || !is_object($sessionObj)) {
                 $sessionObj = \cmsSession::getInstance();
             }
             // write the user id to session so we can pre-fill the sign up form
             $_SESSION['user_id'] = $objUser->getId();
             // generate url for sign up page and redirect
             $signUpPageUri = \Cx\Core\Routing\Url::fromModuleAndCmd('Access', 'signup');
             \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . $signUpPageUri->__toString());
             exit;
         }
     }
     $FWUser->loginUser($objUser);
 }
예제 #23
0
파일: Counter.php 프로젝트: Niggu/cloudrexx
 /**
  * Count request
  *
  * @global   ADONewConnection
  * @see      _makeStatistics()
  */
 function _countRequest()
 {
     global $objDb;
     $page = \Env::get('em')->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findOneBy(array('id' => $this->pageId));
     if (!$page) {
         return;
     }
     $url = \Cx\Core\Routing\Url::fromPage($page);
     if ($page) {
         $objDb->Execute('
             UPDATE `' . DBPREFIX . 'stats_requests`
             SET `visits` = `visits`+1, `page` = "' . substr('/' . $url->getLangDir() . '/' . $url->getPath(), 0, 255) . '", `pageTitle` = "' . $page->getTitle() . '", `sid` = "' . $this->md5Id . '", `timestamp` = ' . $this->currentTime . '
             WHERE `pageId` = ' . $this->pageId . ' AND ((`sid` != "' . $this->md5Id . '") OR (`timestamp` <= ' . ($this->currentTime - $this->arrConfig['reload_block_time']['value']) . '))
         ');
         if ($objDb->Affected_Rows() == 0) {
             // this is allowed to fail if page was visited with same sid
             try {
                 $objDb->Execute('
                     INSERT INTO `' . DBPREFIX . 'stats_requests` (`sid`, `pageId`, `page`, `timestamp`, `visits`, `pageTitle`)
                     VALUES ("' . $this->md5Id . '", ' . $this->pageId . ', "' . substr('/' . $url->getLangDir() . '/' . $url->getPath(), 0, 255) . '", ' . $this->currentTime . ', 1, "' . $page->getTitle() . '")
                 ');
             } catch (\PDOException $e) {
             }
         }
     }
     $this->_makeStatistics(DBPREFIX . 'stats_requests_summary');
 }
예제 #24
0
 /**
  * Change the customers' password
  *
  * If no customer is logged in, redirects to the login page.
  * Returns true only after the password has been updated successfully.
  * @return  boolean             True on success, false otherwise
  */
 static function _changepass()
 {
     global $_ARRAYLANG;
     if (!self::$objCustomer) {
         \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'login') . '?redirect=' . base64_encode(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'changepass')));
     }
     if (isset($_POST['shopNewPassword'])) {
         if (empty($_POST['shopCurrentPassword'])) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_ENTER_CURRENT_PASSWORD']);
         }
         $password_old = contrexx_input2raw($_POST['shopCurrentPassword']);
         if (md5($password_old) != self::$objCustomer->password()) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_WRONG_CURRENT_PASSWORD']);
         }
         $password = contrexx_input2raw($_POST['shopNewPassword']);
         if (empty($password)) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_SPECIFY_NEW_PASSWORD']);
         }
         if (empty($_POST['shopConfirmPassword'])) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_PASSWORD_NOT_CONFIRMED']);
         }
         $password_confirm = contrexx_input2raw($_POST['shopConfirmPassword']);
         if ($password != $password_confirm) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_PASSWORD_NOT_CONFIRMED']);
         }
         if (strlen($password) < 6) {
             return \Message::error($_ARRAYLANG['TXT_PASSWORD_MIN_CHARS']);
         }
         if (!self::$objCustomer->password($password)) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_PASSWORD_INVALID']);
         }
         if (!self::$objCustomer->store()) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_PASSWORD_ERROR_UPDATING']);
         }
         return \Message::ok($_ARRAYLANG['TXT_SHOP_PASSWORD_CHANGED_SUCCESSFULLY']);
     }
     self::$objTemplate->setVariable(array('SHOP_PASSWORD_CURRENT' => $_ARRAYLANG['SHOP_PASSWORD_CURRENT'], 'SHOP_PASSWORD_NEW' => $_ARRAYLANG['SHOP_PASSWORD_NEW'], 'SHOP_PASSWORD_CONFIRM' => $_ARRAYLANG['SHOP_PASSWORD_CONFIRM'], 'SHOP_PASSWORD_CHANGE' => $_ARRAYLANG['SHOP_PASSWORD_CHANGE']));
     return false;
 }
예제 #25
0
 /**
  * Writes RSS feed containing the latest N messages of each category the feed-directory. This is done for every language seperately.
  *
  * @global  array
  * @global  array
  * @global  FWLanguage
  */
 function writeCategoryRSS()
 {
     global $_CONFIG, $_ARRAYLANG;
     if (intval($this->_arrSettings['blog_rss_activated'])) {
         $arrCategories = $this->createCategoryArray();
         //Iterate over all languages
         foreach ($this->_arrLanguages as $intLanguageId => $arrLanguageValues) {
             $arrEntries = $this->createEntryArray($intLanguageId);
             //If there exist entries in this language go on, otherwise skip
             if (count($arrEntries) > 0) {
                 //Iterate over all categories
                 foreach ($arrCategories as $intCategoryId => $arrCategoryTranslation) {
                     //If the category is activated in this language, find assigned messages
                     if ($arrCategoryTranslation[$intLanguageId]['is_active']) {
                         $intNumberOfMessages = 0;
                         //Counts found messages for this category
                         $objRSSWriter = new \RSSWriter();
                         $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
                         $objRSSWriter->channelTitle = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_BLOG_LIB_RSS_MESSAGES_TITLE'];
                         $objRSSWriter->channelLink = \Cx\Core\Routing\Url::fromModuleAndCmd('Blog', '', $intLanguageId)->toString();
                         $objRSSWriter->channelDescription = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_BLOG_LIB_RSS_MESSAGES_TITLE'] . ' (' . $arrCategoryTranslation[$intLanguageId]['name'] . ')';
                         $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
                         //Function doesn't exist
                         //$objRSSWriter->channelLanguage = \FWLanguage::getLanguageParameter($intLanguageId, 'lang');
                         $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
                         //Find assigned messages
                         $entryUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Blog', 'details', $intLanguageId);
                         foreach ($arrEntries as $intEntryId => $arrEntryValues) {
                             if ($this->categoryMatches($intCategoryId, $arrEntryValues['categories'][$intLanguageId])) {
                                 //Message is in category, add to feed
                                 $entryUrl->setParam('id', $intEntryId);
                                 $objRSSWriter->addItem(html_entity_decode($arrEntryValues['subject'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xhtml($entryUrl->toString()), htmlspecialchars($arrEntryValues['translation'][$intLanguageId]['content'], ENT_QUOTES, CONTREXX_CHARSET), htmlspecialchars($arrEntryValues['user_name'], ENT_QUOTES, CONTREXX_CHARSET), '', '', '', '', $arrEntryValues['time_created_ts'], '');
                                 $intNumberOfMessages++;
                                 //Check for message-limit
                                 if ($intNumberOfMessages >= intval($this->_arrSettings['blog_rss_messages'])) {
                                     break;
                                 }
                             }
                         }
                         $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/blog_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml';
                         $objRSSWriter->write();
                         \Cx\Lib\FileSystem\FileSystem::makeWritable(\Env::get('cx')->getWebsiteFeedPath() . '/blog_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml');
                     }
                 }
             }
         }
     }
 }
예제 #26
0
 /**
  * Wrapper for \Cx\Core\Routing\Url::fromApi()
  * This ensures correct param order
  * @param string $adapterName (Json)Data adapter name
  * @param string $adapterMethod (Json)Data method name
  * @param array $params (optional) params for (Json)Data method call
  * @return \Cx\Core\Routing\Url URL for (Json)Data call
  */
 protected function getUrlFromApi($adapterName, $adapterMethod, $params)
 {
     if (isset($_GET['preview'])) {
         $params['theme'] = intval($_GET['preview']);
     }
     $url = \Cx\Core\Routing\Url::fromApi('Data', array('Plain', $adapterName, $adapterMethod), $params);
     // make sure params are in correct order:
     $correctIndexOrder = array('page', 'lang', 'user', 'theme', 'country', 'currency');
     $params = $url->getParamArray();
     uksort($params, function ($a, $b) use($correctIndexOrder) {
         return array_search($a, $correctIndexOrder) - array_search($b, $correctIndexOrder);
     });
     $url->setParams($params);
     $url->setParam('EOU', '');
     return $url;
 }
예제 #27
0
 /**
  * Show one category
  * @param unknown_type $id
  */
 function showCategory($id)
 {
     global $_ARRAYLANG;
     $arrEntries = $this->createEntryArray($this->_intLanguageId);
     $this->createSettingsArray();
     foreach ($arrEntries as $key => $value) {
         if ($value['active']) {
             // check date
             if ($value['release_time'] != 0) {
                 if ($value['release_time'] > time()) {
                     // too old
                     continue;
                 }
                 // if it is not endless (0), check if 'now' is past the given date
                 if ($value['release_time_end'] != 0 && time() > $value['release_time_end']) {
                     continue;
                 }
             }
             if ($this->categoryMatches($id, $value['categories'][$this->_intLanguageId])) {
                 $this->_objTpl->setVariable(array("ENTRY_TITLE" => $value['translation'][$this->_intLanguageId]['subject'], "ENTRY_CONTENT" => $this->getIntroductionText($value['translation'][$this->_intLanguageId]['content']), "ENTRY_ID" => $key, "ENTRY_HREF" => \Cx\Core\Routing\Url::fromModuleAndCmd('Data', $this->curCmd, '', array('id' => $key)), "TXT_MORE" => $_ARRAYLANG['TXT_DATA_MORE'], "CMD" => $this->curCmd));
                 $this->_objTpl->parse("entry");
             }
         }
     }
     $this->_objTpl->parse("showDataCategory");
 }
예제 #28
0
 /**
  * Redirect
  *
  * This function redirects the client. This is done by issuing
  * a "Location" header and exiting if wanted.  If you set $rfc2616 to true
  * HTTP will output a hypertext note with the location of the redirect.
  *
  * @static
  * @access  public
  * @return  mixed   Returns true on succes (or exits) or false if headers
  *                  have already been sent.
  * @param   string  $url URL where the redirect should go to.
  * @param   bool    $exit Whether to exit immediately after redirection.
  * @param   bool    $rfc2616 Wheter to output a hypertext note where we're
  *                  redirecting to (Redirecting to <a href="...">...</a>.)
  */
 public static function redirect($url, $exit = true, $rfc2616 = false)
 {
     if (headers_sent()) {
         return false;
     }
     $url = \Cx\Core\Routing\Url::fromMagic($url);
     $url = $url->toString();
     // use absolute url
     self::header('Location: ' . $url);
     if ($rfc2616 && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
         printf('Redirecting to: <a href="%s">%s</a>.', $url, $url);
     }
     if ($exit) {
         exit;
     }
     return true;
 }
 /**
  * Searches the content and returns an array that is built as needed by the search module.
  *
  * @param string $searchTerm
  *
  * @return array
  */
 public function searchResultsForSearchModule($searchTerm)
 {
     $em = \Env::get('cx')->getDb()->getEntityManager();
     $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
     // only list results in case the associated page of the module is active
     $page = $pageRepo->findOneBy(array('module' => 'MediaDir', 'lang' => FRONTEND_LANG_ID, 'type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION));
     //If page is not exists or page is inactive then return empty result
     if (!$page || !$page->isActive()) {
         return array();
     }
     //get the config site values
     \Cx\Core\Setting\Controller\Setting::init('Config', 'site', 'Yaml');
     $coreListProtectedPages = \Cx\Core\Setting\Controller\Setting::getValue('coreListProtectedPages', 'Config');
     $searchVisibleContentOnly = \Cx\Core\Setting\Controller\Setting::getValue('searchVisibleContentOnly', 'Config');
     //get the config otherConfigurations value
     \Cx\Core\Setting\Controller\Setting::init('Config', 'otherConfigurations', 'Yaml');
     $searchDescriptionLength = \Cx\Core\Setting\Controller\Setting::getValue('searchDescriptionLength', 'Config');
     $hasPageAccess = true;
     $isNotVisible = $searchVisibleContentOnly == 'on' && !$page->isVisible();
     if ($coreListProtectedPages == 'off' && $page->isFrontendProtected()) {
         $hasPageAccess = \Permission::checkAccess($page->getFrontendAccessId(), 'dynamic', true);
     }
     //If the page is invisible and frontend access is denied then return empty result
     if ($isNotVisible || !$hasPageAccess) {
         return array();
     }
     //get the media directory entry by the search term
     $entries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($this->moduleName);
     $entries->getEntries(null, null, null, $searchTerm);
     //if no entries found then return empty result
     if (empty($entries->arrEntries)) {
         return array();
     }
     $results = array();
     $formEntries = array();
     $defaultEntries = null;
     $objForm = new \Cx\Modules\MediaDir\Controller\MediaDirectoryForm(null, $this->moduleName);
     $numOfEntries = intval($entries->arrSettings['settingsPagingNumEntries']);
     foreach ($entries->arrEntries as $entry) {
         $pageUrlResult = null;
         $entryForm = $objForm->arrForms[$entry['entryFormId']];
         //Get the entry's link url
         //check the entry's form detail view exists if not,
         //check the entry's form overview exists if not,
         //check the default overview exists if not, dont show the corresponding entry in entry
         switch (true) {
             case $entries->checkPageCmd('detail' . $entry['entryFormId']):
                 $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, 'detail' . $entry['entryFormId'], FRONTEND_LANG_ID, array('eid' => $entry['entryId']));
                 break;
             case $pageCmdExists = $entries->checkPageCmd($entryForm['formCmd']):
             case $entries->checkPageCmd(''):
                 if ($pageCmdExists && !isset($formEntries[$entryForm['formCmd']])) {
                     $formEntries[$entryForm['formCmd']] = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName);
                     $formEntries[$entryForm['formCmd']]->getEntries(null, null, null, null, null, null, 1, null, 'n', null, null, $entryForm['formId']);
                 }
                 if (!$pageCmdExists && !isset($defaultEntries)) {
                     $defaultEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName);
                     $defaultEntries->getEntries();
                 }
                 //get entry's form overview / default page paging position
                 $entriesPerPage = $numOfEntries;
                 if ($pageCmdExists) {
                     $entriesPerPage = !empty($entryForm['formEntriesPerPage']) ? $entryForm['formEntriesPerPage'] : $numOfEntries;
                 }
                 $pageCmd = $pageCmdExists ? $entryForm['formCmd'] : '';
                 $entryKeys = $pageCmdExists ? array_keys($formEntries[$entryForm['formCmd']]->arrEntries) : array_keys($defaultEntries->arrEntries);
                 $entryPos = array_search($entry['entryId'], $entryKeys);
                 $position = floor($entryPos / $entriesPerPage);
                 $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, $pageCmd, FRONTEND_LANG_ID, array('pos' => $position * $entriesPerPage));
                 break;
             default:
                 break;
         }
         //If page url is empty then dont show it in the result
         if (!$pageUrlResult) {
             continue;
         }
         //Get the search results title and content from the form context field 'title' and 'content'
         $title = current($entry['entryFields']);
         $content = '';
         $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName);
         $inputFields = $objInputfields->getInputfields();
         foreach ($inputFields as $arrInputfield) {
             $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : '';
             if (!in_array($contextType, array('title', 'content'))) {
                 continue;
             }
             $strType = isset($arrInputfield['type_name']) ? $arrInputfield['type_name'] : '';
             $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType);
             try {
                 $objInputfield = safeNew($strInputfieldClass, $this->moduleName);
                 $arrTranslationStatus = contrexx_input2int($arrInputfield['type_multi_lang']) == 1 ? $entry['entryTranslationStatus'] : null;
                 $arrInputfieldContent = $objInputfield->getContent($entry['entryId'], $arrInputfield, $arrTranslationStatus);
                 if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) {
                     $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[(BLOCK_[A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']);
                     \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage());
                 }
             } catch (\Exception $e) {
                 \DBG::log($e->getMessage());
                 continue;
             }
             $inputFieldValue = $arrInputfieldContent[$this->moduleConstVar . '_INPUTFIELD_VALUE'];
             if (empty($inputFieldValue)) {
                 continue;
             }
             if ($contextType == 'title') {
                 $title = $inputFieldValue;
             } elseif ($contextType == 'content') {
                 $content = \Cx\Core_Modules\Search\Controller\Search::shortenSearchContent($inputFieldValue, $searchDescriptionLength);
             }
         }
         $results[] = array('Score' => 100, 'Title' => html_entity_decode(contrexx_strip_tags($title), ENT_QUOTES, CONTREXX_CHARSET), 'Content' => $content, 'Link' => $pageUrlResult->toString());
     }
     return $results;
 }
예제 #30
0
 /**
  * Parsing the News tags.
  *
  * @global type $_ARRAYLANG
  * @param type $objTpl
  * @param type $newsId
  */
 public function parseNewsTags($objTpl = null, $newsId = null, $block = 'newsTagList')
 {
     global $_ARRAYLANG;
     if (!empty($newsId)) {
         $newsTagDetails = $this->getNewsTags($newsId);
         $newsTags = $newsTagDetails['tagList'];
     }
     $tags = $this->getTags(array_keys($newsTags));
     if (empty($tags)) {
         if ($objTpl->blockExists('noTags')) {
             $objTpl->setVariable('TXT_NEWS_NO_TAGS_FOUND', $_ARRAYLANG['TXT_NEWS_NO_TAGS_FOUND']);
             $objTpl->showBlock('noTags');
         }
         return;
     }
     $tagCount = count($tags);
     $currentTagCount = 0;
     if ($objTpl->blockExists($block) && !empty($tags)) {
         foreach ($tags as $tag) {
             ++$currentTagCount;
             $newsLink = \Cx\Core\Routing\Url::fromModuleAndCmd('news', '', FRONTEND_LANG_ID, array('tag' => urlencode($tag)));
             $objTpl->setVariable(array('NEWS_TAG_NAME' => $tag, 'NEWS_TAG_LINK' => '<a class="tags" href="' . $newsLink . '">' . ucfirst($tag) . '</a>' . ($currentTagCount < $tagCount ? ',' : '')));
             $objTpl->parse($block);
         }
         if ($objTpl->blockExists('tagsBlock')) {
             $objTpl->touchBlock('tagsBlock');
         }
     }
 }