/**
  * Implements the abstract transformation function of the BaseDocumentController class.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 02.20.2008<br />
  * Version 0.2, 05.01.2008 (language is now published to the java script code)<br />
  * Version 0.3, 18.09.2008 (Introduced datadir attribute to be able to operate the module in more than one application)<br />
  */
 public function transformContent()
 {
     // get current data dir or trigger error
     $dataDir = $this->getDocument()->getAttribute('datadir');
     if ($dataDir === null) {
         throw new InvalidArgumentException('[NewsPagerController::transformContent()] Tag ' . 'attribute "datadir" was not present in the &lt;core:importdesign /&gt; tag ' . 'definition! Please specify a news content directory!');
     }
     // load default news page
     /* @var $provider NewsPagerProvider */
     $provider = $this->getServiceObject(NewsPagerProvider::class);
     $newsItem = $provider->getNewsByPage($dataDir, 1);
     // fill place holders
     $this->setPlaceHolder('NewsLanguage', $this->getLanguage());
     $this->setPlaceHolder('NewsCount', $newsItem->getNewsCount());
     $this->setPlaceHolder('Headline', $newsItem->getHeadline());
     $this->setPlaceHolder('SubHeadline', $newsItem->getSubHeadline());
     $this->setPlaceHolder('Content', $newsItem->getContent());
     // set news service base url
     $url = LinkGenerator::generateActionUrl(Url::fromCurrent(), 'APF\\modules\\newspager\\biz', 'Pager');
     $this->setPlaceHolder('ActionUrl', $url);
     $this->setPlaceHolder('DataDir', base64_encode($dataDir));
     if ($this->getLanguage() == 'de') {
         $this->setPlaceHolder('ErrorMsg', 'Es ist ein Fehler beim Aufrufen der News aufgetreten! Bitte versuchen Sie es später wieder.');
     } else {
         $this->setPlaceHolder('ErrorMsg', 'Requesting the next news page failed! Please try again later.');
     }
 }
Example #2
0
 /**
  * Generates the tag's output.
  *
  * @return string The desired media url
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 29.10.2008<br />
  * Version 0.2, 01.11.2008<br />
  * Version 0.3, 05.11.2008 (Changed action base url generation)<br />
  * Version 0.4, 07.11.2008 (Refactored the url generation due to some addressing bugs)<br />
  * Version 0.5, 20.06.2010 (Adapted parameter order to support old rewrite rules that do file extension matching for routing exceptions)<br />
  * Version 0.6, 09.04.2011 (Refactored to use release 1.14's new link generation concept)<br />
  */
 public function transform()
 {
     // generate action url using the APF's new link generation mechanism since 1.14
     return LinkGenerator::generateActionUrl(Url::fromCurrent(), 'APF\\tools\\media', 'streamMedia', ['namespace' => str_replace('\\', '_', $this->getRequiredAttribute('namespace')), 'extension' => $this->getAttribute('extension'), 'filebody' => $this->getAttribute('filebody')]);
 }
Example #3
0
 public function transform()
 {
     $params = ['logout' => 'true'];
     return LinkGenerator::generateActionUrl(Url::fromCurrent(), 'APF\\modules\\usermanagement\\biz', 'logout', $params);
 }
Example #4
0
 protected function buildPackageLink($url, $name)
 {
     // Generate url if not given
     $url = $url === null ? Url::fromCurrent(true) : Url::fromString($url);
     return LinkGenerator::generateActionUrl($url, 'APF\\extensions\\htmlheader', 'JsCss', ['package' => $name . '.' . $this->getTypeIndicator()]);
 }
Example #5
0
 /**
  * Generate and return HTML code of the captcha tag.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 20.06.2008<br />
  * Version 0.2, 05.11.2008 (Changed action base url generation)<br />
  * Version 0.3, 07.11.2008 (Fixed the action URL generation. See class MediaInclusionTag for more details.)<br />
  * Version 0.4, 19.12.2009 (Added attribute to be able to disable the inline styles to have clean markup)<br />
  * Version 0.5, 04.01.2010 (Added clearonformerror attribute)<br />
  * Version 0.6, 04.01.2010 (Added the image_id attribute)<br />
  */
 public function transform()
 {
     // check, if the inline style should be disabled
     $disableInlineStyle = $this->getAttribute('disable_inline');
     $disableInlineStyle = $disableInlineStyle === 'true' ? true : false;
     // create desired media url
     $captchaUrl = LinkGenerator::generateActionUrl(Url::fromCurrent(), 'APF\\modules\\captcha\\biz', 'showCaptcha', ['name' => $this->textFieldName]);
     // initialize captcha source
     $captchaCode = '<div class="captcha"><img src="' . $captchaUrl . '" alt="CAPTCHA" ';
     if ($disableInlineStyle === false) {
         $captchaCode .= 'style="float:left;" ';
     }
     // add class and style attributes if desired
     $imgClass = $this->getAttribute('image_class');
     if ($imgClass !== null) {
         $captchaCode .= 'class="' . $imgClass . '" ';
     }
     $imgStyle = $this->getAttribute('image_style');
     if ($imgStyle !== null) {
         $captchaCode .= 'style="' . $imgStyle . '" ';
     }
     $imgId = $this->getAttribute('image_id');
     if ($imgId !== null) {
         $captchaCode .= 'id="' . $imgId . '" ';
     }
     // clear field on form errors
     $cleanOnError = $this->getAttribute('clearonformerror');
     if ($cleanOnError === 'true') {
         /* @var $parent HtmlFormTag */
         $parent = $this->getParentObject();
         if (!$parent->isValid()) {
             $this->textField->setAttribute('value', '');
         }
     }
     // concatenate the html code and return it
     if ($disableInlineStyle === true) {
         return $captchaCode . '/><div>' . $this->textField->transform() . '</div></div>';
     } else {
         return $captchaCode . '/><div style="line-height: 40px; float: left; margin-left: 20px;">' . $this->textField->transform() . '</div><div style="clear: left;"></div></div>';
     }
 }
 /**
  * Creates the upload link.
  *
  * @return string
  *
  * @author Werner Liemberger <*****@*****.**>
  * @version 1.0, 14.3.2011<br>
  */
 public function link()
 {
     $scheme = LinkGenerator::cloneLinkScheme();
     $scheme->setEncodeAmpersands(false);
     $link = LinkGenerator::generateActionUrl(Url::fromCurrent(), 'APF\\tools\\form\\multifileupload', 'multifileupload', ['formname' => $this->formName, 'name' => $this->name], $scheme);
     return $link;
 }
Example #7
0
 /**
  * Tests link generation with multiple mapped actions.
  */
 public function testMultipleMappedActions()
 {
     $standardScheme = new MultipleMappedActionsTestableStandardLinkScheme();
     $rewriteScheme = new MultipleMappedActionsTestableRewriteLinkScheme();
     // provokes test for naming collision!
     $fooMapping = new ActionUrlMapping('foo', 'VENDOR\\foo', 'say-foo');
     $standardScheme->addActionMapping($fooMapping);
     $rewriteScheme->addActionMapping($fooMapping);
     $fooAction = new TestFrontControllerAction();
     $fooAction->setActionName('say-foo');
     $fooAction->setActionNamespace('VENDOR\\foo');
     $fooAction->setKeepInUrl(true);
     $standardScheme->addAction($fooAction);
     $rewriteScheme->addAction($fooAction);
     // provokes test for naming collision!
     $barMapping = new ActionUrlMapping('bar', 'VENDOR\\bar', 'say-bar');
     $standardScheme->addActionMapping($barMapping);
     $rewriteScheme->addActionMapping($barMapping);
     $barAction = new TestFrontControllerAction();
     $barAction->setActionName('say-bar');
     $barAction->setActionNamespace('VENDOR\\bar');
     $barAction->setKeepInUrl(true);
     $standardScheme->addAction($barAction);
     $rewriteScheme->addAction($barAction);
     // simple normal URL containing mapped actions - w/o params
     $url = new Url(null, null, null, '/categories');
     $link = LinkGenerator::generateUrl($url, $standardScheme);
     $this->assertEquals('/categories?foo&amp;bar', $link);
     // simple rewrite URL containing mapped actions - w/o params
     $url = new Url(null, null, null, null);
     $link = LinkGenerator::generateUrl($url, $rewriteScheme);
     $this->assertEquals('/~/foo/~/bar', $link);
     // normal action URL containing mapped actions - w/o params
     $url = new Url(null, null, null, '/categories');
     $link = LinkGenerator::generateActionUrl($url, 'VENDOR\\baz', 'say-baz', [], $standardScheme);
     $this->assertEquals('/categories?VENDOR_baz-action:say-baz&amp;foo&amp;bar', $link);
     // rewrite action URL containing mapped actions - w/o params
     $url = new Url(null, null, null, null);
     $link = LinkGenerator::generateActionUrl($url, 'VENDOR\\baz', 'say-baz', [], $rewriteScheme);
     $this->assertEquals('/~/VENDOR_baz-action/say-baz/~/foo/~/bar', $link);
     // simple normal URL containing mapped actions - w/ params
     $url = new Url(null, null, null, '/categories', ['one' => '1', 'two' => '2']);
     $link = LinkGenerator::generateUrl($url, $standardScheme);
     $this->assertEquals('/categories?one=1&amp;two=2&amp;foo&amp;bar', $link);
     // simple rewrite URL containing mapped actions - w/ params
     $url = new Url(null, null, null, null, ['one' => '1', 'two' => '2']);
     $link = LinkGenerator::generateUrl($url, $rewriteScheme);
     $this->assertEquals('/one/1/two/2/~/foo/~/bar', $link);
     // normal action URL containing mapped actions - w/ params
     $url = new Url(null, null, null, '/categories', ['one' => '1', 'two' => '2']);
     $link = LinkGenerator::generateActionUrl($url, 'VENDOR\\baz', 'say-baz', [], $standardScheme);
     $this->assertEquals('/categories?one=1&amp;two=2&amp;VENDOR_baz-action:say-baz&amp;foo&amp;bar', $link);
     // rewrite action URL containing mapped actions - w/ params
     $url = new Url(null, null, null, null, ['one' => '1', 'two' => '2']);
     $link = LinkGenerator::generateActionUrl($url, 'VENDOR\\baz', 'say-baz', [], $rewriteScheme);
     $this->assertEquals('/one/1/two/2/~/VENDOR_baz-action/say-baz/~/foo/~/bar', $link);
 }
Example #8
0
 /**
  * Builds a Link for the JsCssInclusion FC-action
  *
  * @param string $url Optional url.
  * @param string $namespace Namespace of file
  * @param string $filename Name of file
  * @param bool $fcaction Optional. Create link for FC-Action.
  * @param string $type Filetype
  *
  * @return string elements' link.
  */
 protected function buildFrontcontrollerLink($url, $namespace, $filename, $fcaction, $type)
 {
     if ($fcaction === null) {
         $fcaction = true;
     }
     if ($fcaction) {
         $UrlObj = $url === null ? Url::fromCurrent(true) : Url::fromString($url);
         return LinkGenerator::generateActionUrl($UrlObj, 'APF\\extensions\\htmlheader', 'JsCss', ['path' => str_replace('\\', '_', $namespace), 'type' => $type, 'file' => $filename]);
     } else {
         $namespace = str_replace('\\', '/', $namespace);
         $url .= substr($url, -1, 1) !== '/' ? '/' : '';
         return $url . $namespace . '/' . $filename . '.' . $type;
     }
 }