Example #1
0
    public function testObjectModelWithToArraySetsViewVariables()
    {
        $model = new Zend_View_Helper_PartialTest_Aggregate();

        $view = new Zend_View(array(
            'scriptPath' => $this->basePath . '/default/views/scripts'
        ));
        $this->helper->setView($view);
        $return = $this->helper->partial('partialVars.phtml', $model);

        foreach ($model->toArray() as $key => $value) {
            $string = sprintf('%s: %s', $key, $value);
            $this->assertContains($string, $return);
        }
    }
Example #2
0
 public function partial($origname = null, $module = null, $model = null)
 {
     if (0 == func_num_args()) {
         return $this;
     }
     $resource = ZFE_Environment::getResource('Multilanguage');
     if (null !== $resource) {
         $paths = $this->view->getScriptPaths();
         // Use the view's language if set, otherwise the resource's language
         $lang = isset($this->view->language) ? $this->view->language : $resource->getLanguage();
         $default = $resource->getDefault();
         // To support multiple extensions, gather the extensions in an array
         // This supports e.g. .ajax.phtml and .html.phtml, etc.
         $ext_array = array();
         $name = $origname;
         while (($x = pathinfo($name, PATHINFO_EXTENSION)) != "") {
             array_unshift($ext_array, $x);
             $name = pathinfo($name, PATHINFO_FILENAME);
         }
         $ext = implode(".", $ext_array);
         $name = substr_replace($origname, "-" . $lang, strrpos($origname, $ext) - 1, 0);
         $exists = array_reduce($paths, function ($ret, $path) use($name) {
             return $ret || file_exists($path . $name);
         }, false);
         if (!$exists && $lang !== $default) {
             $name = substr_replace($origname, "-" . $default, strrpos($origname, $ext) - 1, 0);
             $exists = array_reduce($paths, function ($ret, $path) use($name) {
                 return $ret || file_exists($path . $name);
             }, false);
         }
         if (!$exists) {
             $name = $origname;
         }
     } else {
         $name = $origname;
     }
     return parent::partial($name, $module, $model);
 }
Example #3
0
 /**
  * @group ZF-2716
  */
 public function testActionWithPartialsUseOfViewRendererReturnsToOriginatingViewState()
 {
     require_once 'Zend/View/Helper/Partial.php';
     $partial = new Zend_View_Helper_Partial();
     $this->view->setScriptPath(dirname(__FILE__) . '/_files/modules/default/views/scripts/');
     $partial->setView($this->view);
     Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view = $this->view;
     $partial->partial('partialActionCall.phtml');
     $this->assertSame($this->view, Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view);
 }
Example #4
0
 public function testSetObjectKeyImplementsFluentInterface()
 {
     $test = $this->helper->setObjectKey('foo');
     $this->assertSame($this->helper, $test);
 }