protected function compile()
	{
		/** @var PageModel $objPage */
		global $objPage;

		$arrJumpTo = array();
		$arrNewsletter = array();

		$strRequest = ampersand(Environment::get('request'), true);
		$objNewsletter = NewsletterModel::findSentByPids($this->nl_channels);

		if ($objNewsletter !== null)
		{
			while ($objNewsletter->next())
			{
				/** @var NewsletterChannelModel $objTarget */
				if (!($objTarget = $objNewsletter->getRelated('pid')) instanceof NewsletterChannelModel)
				{
					continue;
				}

				$jumpTo = (int) $objTarget->jumpTo;

				// A jumpTo page is not mandatory for newsletter channels (see #6521) but required for the list module
				if ($jumpTo < 1)
				{
					throw new \Exception("Newsletter channels without redirect page cannot be used in a newsletter list");
				}

				$strUrl = $strRequest;

				if (!isset($arrJumpTo[$objTarget->jumpTo]))
				{
					if (($objJumpTo = $objTarget->getRelated('jumpTo')) instanceof PageModel)
					{
						/** @var PageModel $objJumpTo */
						$arrJumpTo[$objTarget->jumpTo] = $objJumpTo->getFrontendUrl(Config::get('useAutoItem') ? '/%s' : '/items/%s');
					}
					else
					{
						$arrJumpTo[$objTarget->jumpTo] = $strUrl;
					}
				}

				$strUrl = $arrJumpTo[$objTarget->jumpTo];
				$strAlias = $objNewsletter->alias ?: $objNewsletter->id;

				$arrNewsletter[] = array
				(
					'subject' => $objNewsletter->subject,
					'title' => StringUtil::stripInsertTags($objNewsletter->subject),
					'href' => sprintf(preg_replace('/%(?!s)/', '%%', $strUrl), $strAlias),
					'date' => Date::parse($objPage->dateFormat, $objNewsletter->date),
					'datim' => Date::parse($objPage->datimFormat, $objNewsletter->date),
					'time' => Date::parse($objPage->timeFormat, $objNewsletter->date),
					'channel' => $objNewsletter->pid
				);
			}
		}

		$this->Template->newsletters = $arrNewsletter;
	}
protected function compile()
	{
		
		global $objPage;

		$arrJumpTo = array();
		$arrNewsletter = array();

		$strRequest = ampersand(Environment::get('request'), true);
		$objNewsletter = NewsletterModel::findSentByPids($this->nl_channels);

		if ($objNewsletter !== null)
		{
			while ($objNewsletter->next())
			{
				
				if (!($objTarget = $objNewsletter->getRelated('pid')) instanceof NewsletterChannelModel)
				{
					continue;
				}

				$jumpTo = (int) $objTarget->jumpTo;

				
				if ($jumpTo < 1)
				{
					throw new \Exception("Newsletter channels without redirect page cannot be used in a newsletter list");
				}

				$strUrl = $strRequest;

				if (!isset($arrJumpTo[$objTarget->jumpTo]))
				{
					if (($objJumpTo = $objTarget->getRelated('jumpTo')) instanceof PageModel)
					{
						
						$arrJumpTo[$objTarget->jumpTo] = $objJumpTo->getFrontendUrl(Config::get('useAutoItem') ? '/%s' : '/items/%s');
					}
					else
					{
						$arrJumpTo[$objTarget->jumpTo] = $strUrl;
					}
				}

				$strUrl = $arrJumpTo[$objTarget->jumpTo];
				$strAlias = $objNewsletter->alias ?: $objNewsletter->id;

				$arrNewsletter[] = array
				(
					'subject' => $objNewsletter->subject,
					'title' => StringUtil::stripInsertTags($objNewsletter->subject),
					'href' => sprintf(preg_replace('/%(?!s)/', '%%', $strUrl), $strAlias),
					'date' => Date::parse($objPage->dateFormat, $objNewsletter->date),
					'datim' => Date::parse($objPage->datimFormat, $objNewsletter->date),
					'time' => Date::parse($objPage->timeFormat, $objNewsletter->date),
					'channel' => $objNewsletter->pid
				);
			}
		}

		$this->Template->newsletters = $arrNewsletter;
	}
protected function compile ( ) { /** @var PageModel $objPage */ global $ objPage ; $ arrJumpTo = array ( ) ; $ arrNewsletter = array ( ) ; $ strRequest = ampersand ( Environment :: get ( 'request' ) , true ) ; $ objNewsletter = NewsletterModel :: findSentByPids ( $ this -> nl_channels ) ; if ( $ objNewsletter !== null ) { while ( $ objNewsletter -> next ( ) ) { /** @var NewsletterChannelModel $objTarget */ if ( ! ( $ objTarget = $ objNewsletter -> getRelated ( 'pid' ) ) instanceof NewsletterChannelModel ) { continue ; } $ jumpTo = ( int ) $ objTarget -> jumpTo ; // A jumpTo page is not mandatory for newsletter channels (see #6521) but required for the list module if ( $ jumpTo < 1 ) { throw new \ Exception ( "Newsletter channels without redirect page cannot be used in a newsletter list" ) ; } $ strUrl = $ strRequest ; if ( ! isset ( $ arrJumpTo [ $ objTarget -> jumpTo ] ) ) { if ( ( $ objJumpTo = $ objTarget -> getRelated ( 'jumpTo' ) ) instanceof PageModel ) { /** @var PageModel $objJumpTo */ $ arrJumpTo [ $ objTarget -> jumpTo ] = $ objJumpTo -> getFrontendUrl ( Config :: get ( 'useAutoItem' ) ? '/%s' : '/items/%s' ) ; } else { $ arrJumpTo [ $ objTarget -> jumpTo ] = $ strUrl ; } } $ strUrl = $ arrJumpTo [ $ objTarget -> jumpTo ] ; $ strAlias = $ objNewsletter -> alias ? : $ objNewsletter -> id ; $ arrNewsletter [ ] = array ( 'subject' => $ objNewsletter -> subject , 'title' => StringUtil :: stripInsertTags ( $ objNewsletter -> subject ) , 'href' => sprintf ( preg_replace ( '/%(?!s)/' , '%%' , $ strUrl ) , $ strAlias ) , 'date' => Date :: parse ( $ objPage -> dateFormat , $ objNewsletter -> date ) , 'datim' => Date :: parse ( $ objPage -> datimFormat , $ objNewsletter -> date ) , 'time' => Date :: parse ( $ objPage -> timeFormat , $ objNewsletter -> date ) , 'channel' => $ objNewsletter -> pid ) ; } } $ this -> Template -> newsletters = $ arrNewsletter ; }
Generate the module
Generate the module