Beispiel #1
0
 function testRunatAsHasMorePriority()
 {
     $parent = $this->_createParentTag();
     $info = new WactTagInfo('my_tag', 'blah');
     $info->setRunat('client');
     $info->setRunatAs('WactRuntimeComponentHTMLTag');
     $this->dictionary->registerWactTagInfo($info, $file = 'whatever');
     $tag = 'my_tag';
     $attrs = array();
     $this->assertEqual($this->dictionary->findTagInfo($tag, $attrs, FALSE, $parent), $info);
 }
Beispiel #2
0
 function findTagInfo($tag, $attrs, $isEmpty, $current_node)
 {
     $tag = strtolower($tag);
     if (isset($attrs['wact:id'])) {
         $attrs['runat'] = 'server';
     }
     // Does the tag have the runat attribute? If so it might be a component
     if (isset($attrs['runat'])) {
         if (strtolower($attrs['runat']) == 'server') {
             if (isset($this->info[$tag])) {
                 return $this->info[$tag];
             } else {
                 // we are a generic tag.  We run at the server, but have no
                 // specific WactTagInfo record in the dictionary.
                 if (!$isEmpty) {
                     $generic = new WactTagInfo($tag, 'WactGenericContainerHTMLTag');
                     $generic->File = 'limb/wact/src/compiler/tag_node/WactGenericContainerHTMLTag.class.php';
                 } else {
                     $generic = new WactTagInfo($tag, 'WactGenericHTMLTag');
                     $generic->File = 'limb/wact/src/compiler/tag_node/WactGenericHTMLTag.class.php';
                     $generic->setForbidEndTag();
                 }
                 $generic->setRunat('client');
                 return $generic;
             }
         }
     } else {
         if (isset($this->info[$tag])) {
             $WactTagInfo = $this->info[$tag];
             if ($WactTagInfo->getRunat() == 'server') {
                 return $WactTagInfo;
             }
             // Check if tag allowed to inherit runat attribute from parent
             if ($runat_as = $WactTagInfo->getRunatAs()) {
                 if ($parent = $current_node->findSelfOrParentByClass($runat_as)) {
                     if ($parent->getBoolAttribute('children_reuse_runat', TRUE)) {
                         return $WactTagInfo;
                     }
                 }
             }
         }
     }
     return NULL;
 }
Beispiel #3
0
 function preParse()
 {
     foreach ($this->tag_info->getRequiredConstantAttributes() as $attr_name) {
         $value = $this->getAttribute($attr_name);
         if (empty($value)) {
             $this->raiseRequiredAttributeError($attr_name);
         }
     }
     foreach ($this->tag_info->getRequiredAttributes() as $attr_name) {
         if (!$this->hasAttribute($attr_name)) {
             $this->raiseRequiredAttributeError($attr_name);
         }
     }
     if ($this->tag_info->isRestrictSelfNesting() && ($parent = $this->findParentByClass(get_class($this)))) {
         $this->raiseCompilerError('Tag cannot be nested within the same tag', array('same_tag_file' => $parent->getTemplateFile(), 'same_tag_line' => $parent->getTemplateLine()));
     }
     if (($parent_class = $this->tag_info->getParentTagClass()) && !($parent = $this->findParentByClass($parent_class))) {
         $this->raiseCompilerError('Tag must be enclosed by a proper parent tag', array('required_parent_tag_class' => $parent_class));
     }
     return parent::preParse();
 }
Beispiel #4
0
 function testEndTagIsPlainSinceRunAtClientButPopExpectedPlainTagReturnMatchToWactTag()
 {
     $tag = 'test';
     $info = new WactTagInfo($tag, 'test');
     $info->setRunat('client');
     $this->tag_dictionary->setReturnReference('getWactTagInfo', $info);
     $location = new WactSourceLocation('my_file', 10);
     $this->tree_builder->expectOnce('popExpectedPlainTag', array($tag, $location));
     $this->tree_builder->setReturnValue('popExpectedPlainTag', WACT_EXPECTED_WACT_TAG);
     $this->tree_builder->expectOnce('popNode');
     $this->state->endTag($tag, $location);
 }
Beispiel #5
0
 function testRestrictSelfNesting()
 {
     $tag_info = new WactTagInfo('CompilerTag', 'whatever');
     $tag_info->setRestrictSelfNesting(true);
     $component = new WactCompilerTag(new WactSourceLocation('my_file', 13), 'whatever', $tag_info);
     $parent = new WactCompilerTag(new WactSourceLocation('my_file', 10), 'whatEver', $tag_info);
     $component->parent = $parent;
     try {
         $component->preParse();
         $this->assertTrue(false);
     } catch (WactException $e) {
         $this->assertWantedPattern('/Tag cannot be nested within the same tag/', $e->getMessage());
         $this->assertEqual($e->getParam('same_tag_file'), 'my_file');
         $this->assertEqual($e->getParam('same_tag_line'), 10);
     }
 }