EXTMVC:
authorJochen Rau <j.rau@web.de>
Fri, 13 Mar 2009 11:41:51 +0000 (11:41 +0000)
committerJochen Rau <j.rau@web.de>
Fri, 13 Mar 2009 11:41:51 +0000 (11:41 +0000)
* improved marker based template engine
* added support for ViewHelper
* added RequestUri and BaseUri to the request
* added LinkHelper, ConvertHelper and others (not finished yet)

typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_AbstractHelper.php
typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_ConvertHelper.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_ForHelper.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_LinkHelper.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_TranslateHelper.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_URIHelper.php
typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_AbstractView.php
typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_TemplateView.php
typo3/sysext/extbase/Classes/Web/TX_EXTMVC_Web_Request.php
typo3/sysext/extbase/class.tx_extmvc_dispatcher.php

index 4247223..359e4e7 100644 (file)
@@ -20,6 +20,8 @@
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/View/Helper/TX_EXTMVC_View_Helper_HelperInterface.php');
+
 /**
  * An abstract View Helper
  *
diff --git a/typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_ConvertHelper.php b/typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_ConvertHelper.php
new file mode 100644 (file)
index 0000000..386e5a0
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/View/Helper/TX_EXTMVC_View_Helper_AbstractHelper.php');
+
+/**
+ * A For Helper
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_View_Helper_ConvertHelper extends TX_EXTMVC_View_Helper_AbstractHelper {
+
+       public function render($view, $content, $arguments) {
+               $value = $content;
+               $format = $arguments['format'];
+               if (!is_string($format)) ; // TODO Throw exception?
+               if ($value instanceof DateTime) {
+                       if ($format === NULL) {
+                               $value = $value->format('Y-m-d G:i'); // TODO Date time format from extension settings
+                       } else {
+                               $value = $value->format($format);
+                       }
+               } else {
+               }
+               return $value;
+       }
+       
+
+}
+
+?>
diff --git a/typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_ForHelper.php b/typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_ForHelper.php
new file mode 100644 (file)
index 0000000..6c52074
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/View/Helper/TX_EXTMVC_View_Helper_AbstractHelper.php');
+
+/**
+ * A For Helper
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_View_Helper_ForHelper extends TX_EXTMVC_View_Helper_AbstractHelper {
+
+       public function render($view, $content, $arguments, $templateSource, $variables) {
+               if (is_array($arguments['each'])) {
+                       foreach ($arguments['each'] as $singleElement) {
+                               $variables[TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($arguments['as'])] = $singleElement; // FIXME strtolower
+                               $newContent .= $view->renderTemplate($templateSource, $variables);
+                       }
+               }
+               return $newContent;
+       }
+
+}
+
+?>
diff --git a/typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_LinkHelper.php b/typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_LinkHelper.php
new file mode 100644 (file)
index 0000000..c3b43e8
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/View/Helper/TX_EXTMVC_View_Helper_AbstractHelper.php');
+
+/**
+ * A For Helper
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_View_Helper_LinkHelper extends TX_EXTMVC_View_Helper_AbstractHelper {
+
+       /**
+        * an instance of tslib_cObj
+        *
+        * @var tslib_cObj
+        */
+       protected $contentObject = null;
+
+       /**
+        * constructor for class tx_community_viewhelper_Link
+        */
+       public function __construct(array $arguments = array()) {
+               if (is_null($this->contentObject)) {
+                       $this->contentObject = t3lib_div::makeInstance('tslib_cObj');
+               }
+       }
+
+       public function render($view, $content, $arguments, $templateResource, $variables) {
+               $parameters = t3lib_div::_GET();
+               $prefixedExtensionKey = 'tx_' . $this->request->getControllerExtensionKey();
+               if (!empty($arguments['to'])) {
+                       $linkTo = $arguments['to'];
+                       $view->replaceReferencesWithValues($linkTo, $variables);
+                       unset($parameters['id']);
+               }
+               if (!empty($arguments['parameters'])) {
+                       $explodedParameters = explode(' ', $arguments['parameters']);
+                       $additionalParameters = array();
+                       foreach ($explodedParameters as $parameterString) {
+                               list($parameterKey, $parameterValue) = explode('=', trim($parameterString));
+                               $view->replaceReferencesWithValues($parameterValue, $variables);
+                               $additionalParameters[$prefixedExtensionKey] = array(trim($parameterKey) => $parameterValue);
+                               if (is_array($parameters[$prefixedExtensionKey])) {
+                                       $parameters[$prefixedExtensionKey] = array_merge($parameters[$prefixedExtensionKey], $additionalParameters[$prefixedExtensionKey]);
+                               } else {
+                                       $parameters[$prefixedExtensionKey] = $additionalParameters[$prefixedExtensionKey];
+                               }
+                       }
+               }
+               
+               $linkText = $view->renderTemplate($templateResource, $variables);
+
+               $parameters = is_array($parameters) ? t3lib_div::implodeArrayForUrl('', $parameters, '', 1) : '';
+
+               $link = $this->contentObject->typoLink(
+                       $linkText,
+                       array(
+                               'parameter' => $linkTo, // FIXME
+                               'additionalParams' => $parameters
+                       )
+               );
+               
+               return $link;
+       }
+                       
+}
+
+?>
diff --git a/typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_TranslateHelper.php b/typo3/sysext/extbase/Classes/View/Helper/TX_EXTMVC_View_Helper_TranslateHelper.php
new file mode 100644 (file)
index 0000000..b4dda7e
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/View/Helper/TX_EXTMVC_View_Helper_AbstractHelper.php');
+
+/**
+ * A For Helper
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_View_Helper_TranslateHelper extends TX_EXTMVC_View_Helper_AbstractHelper {
+
+       public function render($view, $content, $arguments, $templateResource, $variables) {
+               
+       }
+
+}
+
+?>
index 19cdf43..73add77 100644 (file)
@@ -56,8 +56,8 @@ class TX_EXTMVC_View_Helper_URIHelper extends TX_EXTMVC_View_Helper_AbstractHelp
         * @return string the HTML code for the generated link
         * @see UIRFor()
         */
-       public function linkTo($label, $actionName, $arguments = array(), $controllerName = NULL, $extensionKey = NULL, $subextensionKey = NULL, $options = array()) {
-               $link = '<a href="' . $this->URIFor($actionName, $arguments, $controllerName, $extensionKey, $subextensionKey, $options) . '">' . htmlspecialchars($label) . '</a>';
+       public function linkTo($label, $actionName, $arguments = array(), $controllerName = NULL, $extensionKey = NULL) {
+               $link = '<a href="' . $this->URIFor($actionName, $arguments, $controllerName, $extensionKey) . '">' . htmlspecialchars($label) . '</a>';
                return $link;
        }
 
@@ -68,21 +68,14 @@ class TX_EXTMVC_View_Helper_URIHelper extends TX_EXTMVC_View_Helper_AbstractHelp
         * @param array $arguments Additional arguments
         * @param string $controllerName Name of the target controller. If not set, current controller is used
         * @param string $extensionKey Name of the target extension. If not set, current extension is used
-        * @param string $subextensionKey Name of the target subextension. If not set, current subextension is used
         * @param array $options Further options
         * @return string the HTML code for the generated link
         */
-       public function URIFor($actionName, $arguments = array(), $controllerName = NULL, $extensionKey = NULL, $subextensionKey = NULL, $options = array()) {
+       public function URIFor($actionName, $arguments = array(), $controllerName = NULL, $extensionKey = NULL) {
                $routeValues = $arguments;
                $routeValues['@action'] = $actionName;
                $routeValues['@controller'] = ($controllerName === NULL) ? $this->request->getControllerName() : $controllerName;
                $routeValues['@extension'] = ($extensionKey === NULL) ? $this->request->getControllerExtensionKey() : $extensionKey;
-               $currentSubextensionKey = $this->request->getControllerSubextensionKey();
-               if ($subextensionKey === NULL && strlen($currentSubextensionKey)) {
-                       $routeValues['@subextension'] = $currentSubextensionKey;
-               } else if (strlen($subextensionKey)) {
-                       $routeValues['@subextension'] = $subextensionKey;
-               }
 
                $URIString = $this->router->resolve($routeValues);
                return $URIString;
index 2e85526..906aa82 100755 (executable)
@@ -116,7 +116,7 @@ abstract class TX_EXTMVC_View_AbstractView implements TX_EXTMVC_View_ViewInterfa
         */
        public function getViewHelper($viewHelperClassName) {
                if (!isset($this->viewHelpers[$viewHelperClassName])) {
-                       $viewHelper = $this->objectManager->getObject($viewHelperClassName);
+                       $viewHelper = t3lib_div::makeInstance($viewHelperClassName);
                        if (!$viewHelper instanceof TX_EXTMVC_View_Helper_HelperInterface) {
                                throw new TX_EXTMVC_Exception_InvalidViewHelper('View Helpers must implement interface "TX_EXTMVC_View_Helper_HelperInterface"', 1222895456);
                        }
index 8bc0f0c..422b513 100644 (file)
@@ -23,6 +23,7 @@ declare(ENCODING = 'utf-8');
 
 require_once(PATH_t3lib . 'class.t3lib_parsehtml.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Utility/TX_EXTMVC_Utility_Strings.php');
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/View/Helper/TX_EXTMVC_View_Helper_ForHelper.php');
 
 /**
  * A basic Template View
@@ -42,8 +43,8 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
        const SCAN_PATTERN_SUBPARTS = '/<!--\s*###(?P<SubpartName>[^#]*)###.*?-->(?P<SubpartTemplateSource>.*?)<!--\s*###(?P=SubpartName)###.*?-->/sm';
        const SCAN_PATTERN_MARKER = '/###(?P<MarkerName>.*?)###/sm';
 
-       const SPLIT_PATTERN_MARKER = '/^(?:(?P<ViewHelperName>[a-zA-Z0-9_]+):)?(?P<ContextVariable>(?:\s*[a-zA-Z0-9_]+)(?=(\s|$)))?(?P<ObjectAndProperty>(?:\s*[a-zA-Z0-9_]+\.(?:[a-zA-Z0-9_]+)(?=(\s|$))))?(?P<Attributes>(?:\s*[a-zA-Z0-9_]+=(?:"(?:[^"])*"|\'(?:[^\'])*\'|[a-zA-Z0-9_\.]+)\s*)*)\s*$/';
-       const SPLIT_PATTERN_ARGUMENTS = '/(?P<ArgumentKey>[a-zA-Z][a-zA-Z0-9_]*)=(?:(?:"(?P<ValueDoubleQuoted>[^"\s]+)")|(?:\'(?P<ValueSingleQuoted>[^\'\s]+)\')|(?:(?P<ValueUnquoted>[^"\'\s]*)))/';
+       const SPLIT_PATTERN_MARKER = '/^(?:(?P<ViewHelperName>[a-zA-Z0-9_]+):)?(?P<ContextVariable>(?:\s*[a-zA-Z0-9_]+)(?=(\s|$)))?(?P<ObjectAndProperty>(?:\s*[a-zA-Z0-9_]+\.(?:[a-zA-Z0-9_]+)(?=(\s|$))))?(?P<Attributes>(?:\s*[a-zA-Z0-9_]+=(?:"(?:[^"])*"|\'(?:[^\'])*\'|\{(?:[^\{])*\}|[a-zA-Z0-9_\.]+)\s*)*)\s*$/';
+       const SPLIT_PATTERN_ARGUMENTS = '/(?P<ArgumentKey>[a-zA-Z][a-zA-Z0-9_]*)=(?:(?:"(?P<ValueDoubleQuoted>[^"]+)")|(?:\'(?P<ValueSingleQuoted>[^\']+)\')|(?:\{(?P<ValueObject>[^\'\s]+)\})|(?:(?P<ValueUnquoted>[^"\'\s]*)))/';
 
        /**
         * File pattern for resolving the template file
@@ -179,7 +180,7 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
                }
                // TODO exception if a template was not defined
                $content = $this->renderTemplate($templateSource, $this->contextVariables);
-               // $this->removeUnfilledMarkers($content);
+               $this->removeUnfilledMarkers($content);
                return $content;
        }
 
@@ -189,7 +190,7 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
         * @param string $templateSource The template source
         * @return void
         */
-       protected function renderTemplate($templateSource, $variables) {
+       public function renderTemplate($templateSource, $variables) {
                $subpartArray = array();
                $subparts = $this->getSubparts($templateSource);
                foreach ($subparts as $subpartMarker => $subpartSource) {
@@ -233,44 +234,26 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
                        }
                }
                
-               if ($viewHelperName === 'Convert') {                    
-                       if (!empty($arguments['format'])) {
-                               $format = $arguments['format'];
-                       } else {
-                               $format = NULL;
-                       }
-               }
-               
-               if ($viewHelperName === 'For') {                
-                       if (is_array($arguments['each'])) {
-                               foreach ($arguments['each'] as $singleElement) {
-                                       $variables[TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($arguments['as'])] = $singleElement; // FIXME strtolower
-                                       $content .= $this->renderTemplate($templateSource, $variables);
-                               }
-                       }
+               if (!empty($viewHelperName)) {
+                       $viewHelperClassName = 'TX_EXTMVC_View_Helper_' . $viewHelperName . 'Helper';
+                       $viewHelper = $this->getViewHelper($viewHelperClassName);
+                       $content = $viewHelper->render($this, $content, $arguments, $templateSource, $variables);
                }
-               return $this->convertValue($content, $format);
+               return $content;
        }
        
        protected function getArguments($attributes, $variables) {
-               preg_match_all(self::SPLIT_PATTERN_ARGUMENTS, $attributes, $explodedAttributes, PREG_SET_ORDER);
+               preg_match_all(self::SPLIT_PATTERN_ARGUMENTS, $attributes, $explodedAttributes, PREG_SET_ORDER);                
                $arguments = array();
                foreach ($explodedAttributes as $explodedAttribute) {
                        if (!empty($explodedAttribute['ValueDoubleQuoted'])) {
                                 $argumentValue = $explodedAttribute['ValueDoubleQuoted'];
                        } elseif (!empty($explodedAttribute['ValueSingleQuoted'])) {
                                $argumentValue = $explodedAttribute['ValueSingleQuoted'];
+                       } elseif (!empty($explodedAttribute['ValueObject'])) {                          
+                               $argumentValue = $this->getValueForVariableAndKey($explodedAttribute['ValueObject'], $variables);
                        } elseif (!empty($explodedAttribute['ValueUnquoted'])) {
-                               $explodedValue = explode('.', $explodedAttribute['ValueUnquoted']);
-                               if (count($explodedValue) > 1) {                                                                                        
-                                       $possibleMethodName = 'get' . TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($explodedValue[1]);
-                                       $argumentValueObject = $variables[TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($explodedValue[0])];
-                                       if (method_exists($argumentValueObject, $possibleMethodName)) {
-                                               $argumentValue = $argumentValueObject->$possibleMethodName();
-                                       }
-                               } else {
-                                       $argumentValue = $variables[$explodedValue[0]];
-                               }
+                               $argumentValue = $this->getValueForVariableAndKey($explodedAttribute['ValueUnquoted'], $variables);
                        } else {
                                $argumentValue = NULL;
                        }
@@ -278,7 +261,43 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
                }
                return $arguments;
        }
+       
+       public function replaceReferencesWithValues(&$theString, $variables) {
+               preg_match_all('/(?:\{([^\s]*?)\})?/', $theString, $matches, PREG_SET_ORDER);
+               foreach ($matches as $match) {
+                       if (count($match) > 1) {
+                               $reference = $match[0];
+                               $value = $this->getValueForVariableAndKey($match[1], $variables);
+                       }
+                       $theString = str_replace($reference, $value, $theString);
+               }
+       }
                
+       public function getValueForVariableAndKey($variableAndKey, $variables) {
+               $explodedVariableAndKey = explode('.', $variableAndKey);
+               $variable = $variables[TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($explodedVariableAndKey[0])];
+               if (!empty($variable)) {
+                       if (count($explodedVariableAndKey) > 1) {
+                               $key = $explodedVariableAndKey[1];
+                               if (is_object($variable)) {
+                                       $possibleMethodName = 'get' . TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($key);
+                                       if (method_exists($variable, $possibleMethodName)) {
+                                               $value = $variable->$possibleMethodName();
+                                       }
+                               } elseif (is_array($variable)) {
+                                       $value = $variable[TX_EXTMVC_Utility_Strings::underscoredToLowerCamelCase($key)];
+                               }
+                       } else {
+                               if (is_object($variable)) {
+                                       $value = $variable->__toString();
+                               } else {
+                                       $value = $variable;
+                               }
+                       }
+               }
+               return $value;
+       }
+
        protected function getSubpartArray($templateSource) {
                $subpartArray = array();
                if (count($subparts) > 0) {
@@ -311,39 +330,7 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
                }
                return $markers;
        }
-       
-       /**
-        * Resolve a view helper.
-        *
-        * @param string $namespaceIdentifier Namespace identifier for the view helper.
-        * @param string $methodIdentifier Method identifier, might be hierarchical like "link.url"
-        * @return array An Array where the first argument is the object to call the method on, and the second argument is the method name
-        */
-       protected function resolveViewHelperClassName($viewHelperName) {
-               $className = '';
-               $className = ucfirst($explodedViewHelperName[0]);
-               $className .= 'ViewHelper';
-
-               $name =  'TX_Blogexample_View_' . $className;
-
-               return $name;
-       }
-
-
-       
-       protected function convertValue($value, $format = NULL) {
-               if (!is_string($format)) ; // TODO Throw exception?
-               if ($value instanceof DateTime) {
-                       if ($format === NULL) {
-                               $value = $value->format('Y-m-d G:i'); // TODO Date time format from extension settings
-                       } else {
-                               $value = $value->format($format);
-                       }
-               } else {
-               }
-               return $value;
-       }
-               
+                       
        protected function removeUnfilledMarkers(&$content) {
                // TODO remove also comments
                $content = preg_replace('/###.*###|<!--[^>]*###.*###[^<]*-->(.*)/msU', '', $content);
@@ -358,6 +345,7 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
         */
        public function assign($key, $value) {
                $this->contextVariables[$key] = $value;
+               return $this;
        }
 }
 ?>
\ No newline at end of file
index 0d310b5..cb3976a 100755 (executable)
@@ -41,17 +41,12 @@ class TX_EXTMVC_Web_Request extends TX_EXTMVC_Request {
        protected $method = 'GET';
 
        /**
-        * @var F3_FLOW3_Utility_Environment
-        */
-       protected $environment;
-
-       /**
-        * @var F3_FLOW3_Property_DataType_URI The request URI
+        * @var string
         */
        protected $requestURI;
 
        /**
-        * @var F3_FLOW3_Property_DataType_URI The base URI for this request - ie. the host and path leading to the index.php
+        * @var string The base URI for this request - ie. the host and path leading to the index.php
         */
        protected $baseURI;
 
@@ -70,7 +65,7 @@ class TX_EXTMVC_Web_Request extends TX_EXTMVC_Request {
        /**
         * Returns the name of the request method
         *
-        * @return string Name of the request method - one of the F3_FLOW3_Utility_Environment::REQUEST_METHOD_* constants
+        * @return string Name of the request method
         */
        public function getMethod() {
                return $this->method;
@@ -83,8 +78,7 @@ class TX_EXTMVC_Web_Request extends TX_EXTMVC_Request {
         * @return void
         */
        public function setRequestURI($requestURI) {
-               $this->requestURI = clone $requestURI;
-               $this->baseURI = $this->detectBaseURI($requestURI);
+               $this->requestURI = $requestURI;
        }
 
        /**
@@ -103,7 +97,7 @@ class TX_EXTMVC_Web_Request extends TX_EXTMVC_Request {
         * @return void
         */
        public function setBaseURI($baseURI) {
-               $this->baseURI = clone $baseURI;
+               $this->baseURI = $baseURI;
        }
 
        /**
@@ -114,22 +108,5 @@ class TX_EXTMVC_Web_Request extends TX_EXTMVC_Request {
        public function getBaseURI() {
                return $this->baseURI;
        }
-
-       /**
-        * Tries to detect the base URI of this request and returns it.
-        *
-        * @param string $requestURI URI of this web request
-        * @return string The detected base URI
-        */
-       protected function detectBaseURI($requestURI) {
-               $baseURI = clone $requestURI;
-               $baseURI->setQuery(NULL);
-               $baseURI->setFragment(NULL);
-
-               $requestPathSegments = explode('/', $this->environment->getScriptRequestPathAndName());
-               array_pop($requestPathSegments);
-               $baseURI->setPath(implode('/', $requestPathSegments) . '/');
-               return $baseURI;
-       }
 }
 ?>
\ No newline at end of file
index aead1f9..446acbf 100644 (file)
@@ -79,10 +79,12 @@ class TX_EXTMVC_Dispatcher {
         * @param array|NULL $configuration The TS configuration array
         * @return String $content The processed content
         */
-       public function dispatch($content, $configuration) {            
+       public function dispatch($content, $configuration) {                            
                // TODO Add an AJAX dispatcher
                // debug($configuration);
                $request = t3lib_div::makeInstance('TX_EXTMVC_Web_Request');
+               $request->setRequestURI(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'));
+               $request->setBaseURI(t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
                $request->setControllerExtensionKey(strtolower($configuration['extension']));
                $request->setControllerName($configuration['controller']);
                $request->setControllerActionName($configuration['action']);