示例#1
0
文件: UIMacros.php 项目: krecek/nrsn
	public static function renderSnippets(NControl $control, stdClass $local, array $params)
	{
		$control->snippetMode = FALSE;
		$payload = $control->getPresenter()->getPayload();
		if (isset($local->blocks)) {
			foreach ($local->blocks as $name => $function) {
				if ($name[0] !== '_' || !$control->isControlInvalid(substr($name, 1))) {
					continue;
				}
				ob_start();
				$function = reset($function);
				$snippets = $function($local, $params);
				$payload->snippets[$id = $control->getSnippetId(substr($name, 1))] = ob_get_clean();
				if ($snippets) {
					$payload->snippets += $snippets;
					unset($payload->snippets[$id]);
				}
			}
		}
		$control->snippetMode = TRUE;
		if ($control instanceof IRenderable) {
			$queue = array($control);
			do {
				foreach (array_shift($queue)->getComponents() as $child) {
					if ($child instanceof IRenderable) {
						if ($child->isControlInvalid()) {
							$child->snippetMode = TRUE;
							$child->render();
							$child->snippetMode = FALSE;
						}
					} elseif ($child instanceof IComponentContainer) {
						$queue[] = $child;
					}
				}
			} while ($queue);
		}
	}
示例#2
0
文件: loader.php 项目: GE3/GE3
 static function create(NControl $control, $name = NULL, $tag = 'div')
 {
     if (self::$outputAllowed) {
         $obj = new self();
         $obj->tag = trim($tag, '<>');
         if ($obj->tag) {
             echo '<', $obj->tag, ' id="', $control->getSnippetId($name), '">';
         }
         return $obj;
     } elseif ($control->isControlInvalid($name)) {
         $obj = new self();
         $obj->id = $control->getSnippetId($name);
         $obj->payload = $control->getPresenter()->getPayload();
         ob_start();
         $obj->level = ob_get_level();
         self::$outputAllowed = TRUE;
         return $obj;
     } else {
         return FALSE;
     }
 }