public function parsePromoter($objPromoter, $index = null, array $arrPromoters = array())
 {
     $strTemplate = $this->cal_promoterTemplate ? $this->cal_promoterTemplate : 'cal_promoter_default';
     $objT = new \FrontendTemplate($strTemplate);
     $objT->setData($objPromoter->row());
     if ($objPromoter->room && ($objRoom = $objPromoter->getRelated('room')) !== null) {
         $objT->room = $objRoom;
     }
     $contact = new \stdClass();
     $hasContact = false;
     if ($objPromoter->website) {
         $objT->websiteUrl = \HeimrichHannot\Haste\Util\Url::addScheme($objPromoter->website);
     }
     foreach (static::$arrContact as $strField) {
         if (!$objT->{$strField}) {
             continue;
         }
         $hasContact = true;
         $contact->{$strField} = $objT->{$strField};
     }
     $objT->hasContact = $hasContact;
     $objT->contact = $contact;
     $objT->contactTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['contactTitle'];
     $objT->phoneTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['phoneTitle'];
     $objT->faxTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['faxTitle'];
     $objT->emailTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['emailTitle'];
     $objT->websiteTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['websiteTitle'];
     if (!empty($arrPromoters) && $index !== null) {
         $objT->cssClass = \HeimrichHannot\Haste\Util\Arrays::getListPositonCssClass($index, $arrPromoters);
     }
     return $objT->parse();
 }
 public static function sendConfirmationNotificationBe(\DataContainer $objDc)
 {
     if (($objSubmission = static::findByPk($objDc->id)) !== null) {
         static::sendConfirmationNotification($objSubmission->id);
         \Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['confirmationNotificationSent']);
         \Controller::redirect(Url::addQueryString('id=' . $objSubmission->pid, Url::removeQueryString(array('key'))));
     }
 }
 public static function getMemberContentLink($intId)
 {
     if (($objMemberContentArchive = MemberContentArchiveModel::findByPk($intId)) !== null) {
         if (($objTag = MemberContentArchiveTagModel::findByPk($objMemberContentArchive->tag)) !== null && $objTag->jumpTo) {
             if (($objMember = \MemberModel::findByPk($objMemberContentArchive->mid)) !== null) {
                 return Url::generateFrontendUrl($objTag->jumpTo) . '/' . General::getAliasIfAvailable($objMember);
             }
         }
     }
 }
 public function sendConfirmation($row, $href, $label, $title, $icon, $attributes)
 {
     if (($objSubmission = \HeimrichHannot\Submissions\SubmissionModel::findByPk($row['id'])) !== null) {
         if (($objSubmissionArchive = $objSubmission->getRelated('pid')) !== null && $objSubmissionArchive->nc_confirmation) {
             $href = $this->addToUrl($href);
             $href = \HeimrichHannot\Haste\Util\Url::addQueryString('id=' . $row['id'], $href);
             return '<a href="' . $href . '" title="' . specialchars($title) . '"' . $attributes . '>' . \Image::getHtml($icon, $label) . '</a> ';
         }
     }
 }
 public function replaceInsertTagsAbsolute($strTag)
 {
     $arrSplit = explode('::', $strTag);
     if ($arrSplit[0] == 'link_url_abs') {
         if (isset($arrSplit[1])) {
             return Url::generateAbsoluteUrl($arrSplit[1]);
         }
         return '';
     }
     return false;
 }
 /**
  * Generate a link to the relation submission form page
  *
  * @param \PageModel $objPage
  * @param \Model     $objEntity
  * @param array      $arrRelation
  *
  * @return string The url to the relation submission page
  */
 public function getRelationLink(\PageModel $objPage, \Model $objEntity, array $arrRelation)
 {
     $objPage = \PageModel::findWithDetails($objPage->id);
     $strParam = $arrRelation['request_parameter'] ?: $arrRelation['submissionField'];
     if (\Config::get('useAutoItem') && $arrRelation['useAutoItem']) {
         $varPath = !\Config::get('disableAlias') ? '/' : '/' . $strParam . '/';
         $varValue = !\Config::get('disableAlias') && $objEntity->alias ? $objEntity->alias : $objEntity->id;
         return \Controller::generateFrontendUrl($objPage->row(), $varPath . $varValue, $objPage->language, true);
     }
     $strQuery = $strParam . '=' . (!\Config::get('disableAlias') && $objEntity->alias ? $objEntity->alias : $objEntity->id);
     return Url::addQueryString($strQuery, \Controller::generateFrontendUrl($objPage->row(), null, $objPage->language, true));
 }
 protected function linkToPage($intPage)
 {
     $strUrl = ampersand($this->strUrl);
     if ($intPage <= 1 && !$this->blnForceParam) {
         if ($this->intRandomSeed) {
             $strUrl = Url::addQueryString(FormHybridList::PARAM_RANDOM . '=' . $this->intRandomSeed, $strUrl);
         }
         return $strUrl;
     } else {
         $strUrl = Url::addQueryString($this->strParameter . '=' . $intPage, $strUrl);
         if ($this->intRandomSeed) {
             $strUrl = Url::addQueryString(FormHybridList::PARAM_RANDOM . '=' . $this->intRandomSeed, $strUrl);
         }
         return $strUrl;
     }
 }
 public function isValidFile()
 {
     if ($this->mime == 'text/html') {
         return false;
     }
     $arrParts = Url::getParametersFromUri($this->url);
     if (!isset($arrParts['file'])) {
         return false;
     }
     if (!is_file(TL_ROOT . '/' . $arrParts['file'])) {
         return false;
     }
     if (!file_exists(TL_ROOT . '/' . $arrParts['file'])) {
         return false;
     }
     return true;
 }
 public function getYoutubeSrc()
 {
     if (!$this->init()) {
         return '';
     }
     $strUrl = $this->getConfigData('youtubePrivacy') ? static::$privacyEmbedSrc : static::$defaultEmbedSrc;
     $strUrl .= $this->youtube;
     $strUrl = \HeimrichHannot\Haste\Util\Url::addQueryString('rel=' . ($this->ytShowRelated ? 1 : 0), $strUrl);
     $strUrl = \HeimrichHannot\Haste\Util\Url::addQueryString('modestbranding=' . ($this->ytModestBranding ? 1 : 0), $strUrl);
     $strUrl = \HeimrichHannot\Haste\Util\Url::addQueryString('showinfo=' . ($this->ytShowInfo ? 1 : 0), $strUrl);
     if ($this->autoplay || $this->getConfigData('autoplay')) {
         $strUrl = \HeimrichHannot\Haste\Util\Url::addQueryString('autoplay=1', $strUrl);
     }
     return $strUrl;
 }
 protected function redirectAfterSubmission()
 {
     global $objPage;
     $blnRedirect = false;
     $strUrl = \Controller::generateFrontendUrl($objPage->row());
     if (($objTarget = \PageModel::findByPk($this->jumpTo)) !== null) {
         $blnRedirect = true;
         $strUrl = \Controller::generateFrontendUrl($objTarget->row(), null, null, true);
     }
     $arrPreserveParams = trimsplit(',', $this->jumpToPreserveParams);
     foreach ($arrPreserveParams as $strParam) {
         $varValue = \Input::get($strParam);
         if ($varValue === null) {
             continue;
         }
         switch ($strParam) {
             case 'token':
                 if ($this->deactivateTokens) {
                     break;
                 }
                 $strUrl = Url::addQueryString($strParam . '=' . \RequestToken::get(), $strUrl);
                 break;
             default:
                 $strUrl = Url::addQueryString($strParam . '=' . $varValue, $strUrl);
         }
     }
     if ($blnRedirect) {
         \HeimrichHannot\StatusMessages\StatusMessage::reset($this->objModule->id);
     }
     if ($this->async) {
         if ($blnRedirect) {
             $objResponse = new ResponseRedirect();
             $objResponse->setUrl($strUrl);
             $objResponse->output();
         }
         return;
     }
     if (!$blnRedirect) {
         if ($this->getReset()) {
             $this->reset(true);
         }
         return;
     }
     \Controller::redirect($strUrl);
 }
 /**
  * Get config value from transformed arrData and add logic to modify the value here
  * @param $strKey
  *
  * @return mixed|string
  */
 public function __get($strKey)
 {
     $varValue = $this->arrData[$strKey];
     switch ($strKey) {
         case 'strAction':
             if ($varValue && ($objActionPage = \PageModel::findWithDetails($varValue)) !== null) {
                 $varValue = \Controller::generateFrontendUrl($objActionPage->row(), null, null, true);
             } else {
                 $varValue = Url::removeQueryString(array('file'), \Environment::get('uri'));
                 // remove all query parameters within ajax request
                 if (Ajax::isRelated(Form::FORMHYBRID_NAME) !== false) {
                     $varValue = AjaxAction::removeAjaxParametersFromUrl($varValue);
                 }
             }
             // async form
             if ($this->async) {
                 $varValue = AjaxAction::generateUrl(Form::FORMHYBRID_NAME, 'asyncFormSubmit');
             }
             // add hash
             if ($this->addHashToAction) {
                 $varValue .= '#' . ($this->customHash ?: $this->strFormId);
             }
             break;
         case 'arrDefaultValues':
             $varValue = FormHelper::getAssocMultiColumnWizardList($varValue, 'field');
             break;
     }
     return $varValue;
 }
 protected function deleteItem($intId)
 {
     if (($objItem = General::getModelInstance($this->formHybridDataContainer, $intId)) !== null) {
         $objDc = new DC_Hybrid($this->formHybridDataContainer, $objItem, $objItem->id);
         $this->runBeforeDelete($objItem, $objDc);
         // remove previously created locks
         if (in_array('entity_lock', \ModuleLoader::getActive()) && $this->addEntityLock) {
             \HeimrichHannot\EntityLock\EntityLockModel::deleteLocks($this->formHybridDataContainer, $intId);
         }
         // call ondelete callbacks
         if (is_array($GLOBALS['TL_DCA'][$this->formHybridDataContainer]['config']['ondelete_callback'])) {
             foreach ($GLOBALS['TL_DCA'][$this->formHybridDataContainer]['config']['ondelete_callback'] as $callback) {
                 $this->import($callback[0]);
                 $this->{$callback}[0]->{$callback}[1]($objDc);
             }
         }
         $blnDeleted = $objItem->delete() > 0;
         if ($blnDeleted && $this->deleteNotification) {
             if (($objMessage = MessageModel::findPublishedById($this->formHybridSubmissionNotification)) !== null) {
                 $arrSubmissionData = SubmissionModel::prepareData($objItem, $this->formHybridDataContainer, $GLOBALS['TL_DCA'][$this->formHybridDataContainer], $objDc, $this->formHybridEditable);
                 $arrTokens = SubmissionModel::tokenizeData($arrSubmissionData);
                 if ($this->sendDeleteNotification($objMessage, $objItem, $arrSubmissionData, $arrTokens)) {
                     $objMessage->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
                 }
             }
         }
         $this->runAfterDelete($blnDeleted, $objItem, $objDc);
         if ($this->jumpToAfterDelete && ($strUrl = Url::getJumpToPageUrl($this->jumpToAfterDelete))) {
             \Controller::redirect($strUrl);
         }
         return $blnDeleted;
     }
     return false;
 }
 protected function getInfoAction(\File $objFile)
 {
     $strUrl = null;
     $strFileNameEncoded = utf8_convert_encoding($objFile->name, \Config::get('characterSet'));
     switch (TL_MODE) {
         case 'FE':
             $strHref = Url::getCurrentUrlWithoutParameters();
             $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFile->value);
             return 'window.open("' . $strHref . '", "_blank");';
             break;
         case 'BE':
             if (\Input::get('popup')) {
                 return null;
             } else {
                 $popupWidth = 664;
                 $popupHeight = 299;
                 $href = 'contao/popup.php?src=' . base64_encode($objFile->value);
                 return 'Backend.openModalIframe({"width":"' . $popupWidth . '","title":"' . str_replace("'", "\\'", specialchars($strFileNameEncoded, false, true)) . '","url":"' . $href . '","height":"' . $popupHeight . '"});return false';
             }
             break;
     }
     return $strUrl;
 }
 public function addItemColumns($objItem, &$arrItem)
 {
     parent::addItemColumns($objItem, $arrItem);
     global $objPage;
     // edit
     if ($this->addEditCol) {
         $arrItem['addEditCol'] = true;
         $strUrl = $this->addAjaxPagination ? Url::getCurrentUrlWithoutParameters() : Url::getUrl();
         if (($objPageJumpTo = \PageModel::findByPk($this->jumpToEdit)) !== null && $this->jumpToEdit != $objPage->id) {
             $strUrl = \Controller::generateFrontendUrl($objPageJumpTo->row(), null, null, true);
         }
         $arrItem['editUrl'] = Url::addQueryString($this->formHybridIdGetParameter . '=' . $objItem->id . (!$this->deactivateTokens ? '&token=' . \RequestToken::get() : ''), $strUrl);
     }
     // delete url
     if ($this->addDeleteCol) {
         $arrItem['addDeleteCol'] = true;
         $arrItem['deleteUrl'] = Url::addQueryString($this->formHybridIdGetParameter . '=' . $objItem->id . '&act=delete' . (!$this->deactivateTokens ? '&token=' . \RequestToken::get() : ''), $this->addAjaxPagination ? Url::getCurrentUrlWithoutParameters() : Url::getUrl());
     }
     // publish url
     if ($this->addPublishCol) {
         $arrItem['addPublishCol'] = true;
         $arrItem['publishUrl'] = Url::addQueryString($this->formHybridIdGetParameter . '=' . $objItem->id . '&act=publish' . (!$this->deactivateTokens ? '&token=' . \RequestToken::get() : ''), $this->addAjaxPagination ? Url::getCurrentUrlWithoutParameters() : Url::getUrl());
     }
 }
Esempio n. 15
0
 /**
  * @dataProvider addSchemeProvider
  * @test
  */
 public function testAddScheme($strUrl, $strScheme, $expectedResult)
 {
     $this->assertSame($expectedResult, Url::addScheme($strUrl, $strScheme));
 }
 protected function generateResetFilterField()
 {
     $arrData = array('inputType' => 'explanation', 'eval' => array('text' => '<div class="form-group reset-filter"><a class="btn btn-default" href="' . Url::getCurrentUrlWithoutParameters() . '"><span>' . $GLOBALS['TL_LANG']['formhybrid_list'][FORMHYBRID_LIST_BUTTON_RESET_FILTER][0] . '</span></a></div>'));
     $this->arrFields[FORMHYBRID_LIST_BUTTON_RESET_FILTER] = $this->generateField(FORMHYBRID_LIST_BUTTON_RESET_FILTER, $arrData);
 }
 public function generate(array $arrOptions = array())
 {
     $this->arrOptions = array_merge($this->arrOptions, $arrOptions);
     $arrData = $this->getData($this->arrOptions);
     if (!$arrOptions['dlh_googlemap_nocss']) {
         \delahaye\googlemaps\Googlemap::CssInjection();
     }
     $this->arrOptions['staticMap'] = $this->generateStatic($this->arrOptions);
     $objTemplate = new \FrontendTemplate($this->arrOptions['dlh_googlemap_template']);
     if (!isset($GLOBALS['TL_JAVASCRIPT']['googlemaps'])) {
         $strUrl = '//maps.google.com/maps/api/js';
         $strUrl = Url::addQueryString('language=' . $this->arrOptions['language'], $strUrl);
         global $objPage;
         if (($objRootPage = \PageModel::findPublishedById($objPage->rootId)) !== null && $objRootPage->dlh_googlemaps_apikey) {
             $strUrl = Url::addQueryString('key=' . $objRootPage->dlh_googlemaps_apikey, $strUrl);
         }
         $GLOBALS['TL_JAVASCRIPT']['googlemaps'] = $strUrl;
     }
     $objTemplate->map = $arrData;
     $objTemplate->tabs = $arrData['dlh_googlemap_tabs'];
     $objTemplate->labels = $GLOBALS['TL_LANG']['dlh_googlemaps']['labels'];
     return $objTemplate->parse();
 }
 public function addShareColumn($objItem, &$arrItem)
 {
     global $objPage;
     if (($objPageJumpTo = \PageModel::findByPk($this->jumpToShare)) !== null || ($objPageJumpTo = $objPage)) {
         $strShareUrl = \Environment::get('url') . '/' . \Controller::generateFrontendUrl($objPageJumpTo->row());
         $strUrl = Url::addQueryString('act=share', Url::getCurrentUrlWithoutParameters());
         $strUrl = Url::addQueryString('url=' . urlencode($strShareUrl), $strUrl);
         $strUrl = Url::addQueryString($this->formHybridIdGetParameter . '=' . $objItem->id, $strUrl);
         $arrItem['shareUrl'] = $strUrl;
     }
 }