Example #1
0
 public function &Index_getTopMessageMedia()
 {
     $list = TemplateInfo::getTemplateList();
     $data = $list['22'];
     $text = "";
     $file = $data['file'];
     $path = TemplateInfo::getTplDirectory() . $file;
     if (is_file($path) == true) {
         $text = file_get_contents($path);
     }
     $core =& $this->_core;
     $pairs = TemplateInfo::getIndexReplacePairs($core);
     $text = strtr($text, $pairs);
     return $text;
 }
	public static function render( $input, $args, $parser, $frame ) {
		// if this call is contained in a transcluded page or template,
		// or if the input is empty, display nothing
		if ( !$frame->title->equals( $parser->getTitle() ) || $input == '' )
			return;
	
		// TODO: Do processing here, like parse to an array
		$error_msg = null;

		// recreate the top-level <templateinfo> tag, with whatever
		// attributes it contained, because that was actually a tag-
		// function call, as opposed to a real XML tag
		$input = Xml::tags('templateinfo', $args, $input);

		// if 'type=' was specified, and it wasn't set to one of the
		// allowed values (currently just 'auto'),  don't validate -
		// just display the XML
		if (array_key_exists('type', $args) && $args['type'] != 'auto') {
			// Store XML in the page_props table - the Javascript
			// can figure out on its own whether or not to handle it
			$parser->getOutput()->setProperty( 'templateinfo', $input );
			// TODO - a hook should be called here, to allow other
			// XML handlers to parse and display this
			$text = Html::element('p', null, "The (unhandled) XML definition for this template is:") . "\n";
			$text .= Html::element('pre', null, $input);
			return $text;
		}

 		if ( $xml_object = TemplateInfo::validateXML( $input, $error_msg ) ) {
			// Store XML in the page_props table
			$parser->getOutput()->setProperty( 'templateinfo', $input );
			$text = TemplateInfo::parseTemplateInfo($xml_object);
		} else {
			// Store error message in the page_props table
			$parser->getOutput()->setProperty( 'templateinfo', $error_msg );
			$text = Html::element('p', null, "The (incorrect) XML definition for this template is:") . "\n";
			$text .= Html::element('pre', null, $input);
		}

		// return output
		return $text;
    	}
Example #3
0
 /**
  * @group default
  */
 public function testFromArray()
 {
     $data = ['name' => 'George', 'description' => 'My cuddly little TemplateInfo', 'usage' => 'I shall hug him and pet him and squeeze him...', 'see' => 'https://www.youtube.com/watch?v=ArNz8U7tgU4', 'license' => 'artistic'];
     $info = TemplateInfo::fromArray($data);
     $this->assertEquals('George', $info->getName());
     $this->assertEquals($data['description'], $info->getDescription());
     $this->assertEquals($data['usage'], $info->getUsage());
     $this->assertEquals($data['see'], $info->getSee());
     $this->assertEquals(['license' => 'artistic'], $info->getInfo());
     $this->assertTrue(isset($info->license));
     $this->assertEquals('artistic', $info->license);
 }
Example #4
0
 /**
  * Return the name of this Template. Equivalent to getInfo()->getName().
  * @return string|null
  * @see getInfo()
  */
 public function getName()
 {
     assert(null !== $this->info);
     return $this->info->getName();
 }