Example #1
0
 public static function install(LatteCompiler $compiler)
 {
     $me = new self($compiler);
     $me->addMacro('form', 'FormMacros::renderFormBegin($form = $_form = (is_object(%node.word) ? %node.word : $_control[%node.word]), %node.array)', 'FormMacros::renderFormEnd($_form)');
     $me->addMacro('label', array($me, 'macroLabel'), '?></label><?php');
     $me->addMacro('input', 'echo $_form[%node.word]->getControl()->addAttributes(%node.array)', NULL, array($me, 'macroAttrInput'));
     $me->addMacro('formContainer', '$_formStack[] = $_form; $formContainer = $_form = $_form[%node.word]', '$_form = array_pop($_formStack)');
 }
Example #2
0
 /**
  * Install table macros
  * @param \Nette\Latte\Compiler $compiler
  * @return \Nette\Latte\Macros\MacroSet|void
  */
 public static function install(Latte\Compiler $compiler)
 {
     $macros = new self($compiler);
     $macros->addMacro('table', '$table = $_table = $control = $_control = (is_object(%node.word) ? %node.word : $_control[%node.word]);' . 'Nette\\Latte\\Macros\\FormMacros::renderFormBegin($form = $_form = $table[\'filterForm\'], array());' . 'Drahak\\Tables\\TableMacros::renderTableBegin($table, %node.array);', 'Drahak\\Tables\\TableMacros::renderTableEnd($_table);' . 'Nette\\Latte\\Macros\\FormMacros::renderFormEnd($_form);');
     $macros->addMacro('th', array($macros, 'macroTableHeading'), '$_column->getLabelPrototype()->endTag();');
     $macros->addMacro('td', array($macros, 'macroTableCell'), '$_column->getCellPrototype()->endTag();');
     $macros->addMacro('tdControls', array($macros, 'macroControls'));
 }
 public static function install(Engine $latte, $dir)
 {
     $me = new self($latte->getCompiler());
     $me::$dir = $dir;
     $me->addMacro('component', NULL, [$me, 'macroComponentEnd']);
     $me->addMacro('child', NULL, [$me, 'macroChildEnd']);
     $me->addMacro('key', NULL, [$me, 'macroKeyEnd']);
 }
Example #4
0
	public static function install(NParser $parser)
	{
		$me = new self($parser);
		$me->addMacro('form',
			'NFormMacros::renderFormBegin($form = $_control[%node.word], %node.array)',
			'NFormMacros::renderFormEnd($form)');
		$me->addMacro('label', array($me, 'macroLabel'), '?></label><?php');
		$me->addMacro('input', 'echo $form[%node.word]->getControl()->addAttributes(%node.array)');
	}
Example #5
0
 public static function install(Compiler $compiler)
 {
     $me = new self($compiler);
     $me->addMacro('ifLocale', array($me, 'macroLocale'), '} unset($_localeParam);');
     $me->addMacro('version', array($me, 'macroVersion'));
     $me->addMacro('phref', NULL, NULL, function (MacroNode $node, PhpWriter $writer) use($me) {
         return ' ?> href="<?php ' . $me->macroLink($node, $writer) . ' ?>"<?php ';
     });
     return $me;
 }
Example #6
0
    /**
     * Install all macros
     *
     * @param NParser $parser
     */
    public static function install(NParser $parser)
    {
        $me = new self($parser);
        $me->addMacro('_', array($me, 'macroTranslate'), array($me, 'macroTranslate'));
        $me->addMacro('dynamicSidebar', 'dynamic_sidebar(%node.args);');
        $me->addMacro('widgetArea', 'dynamic_sidebar(%node.args);');
        $me->addMacro('isActiveSidebar', 'if(is_active_sidebar(%node.word)):', 'endif;');
        $me->addMacro('isNotActiveSidebar', 'if(!is_active_sidebar(%node.word)):', 'endif;');
        $me->addMacro('isActiveWidgetArea', 'if(is_active_sidebar(%node.word)):', 'endif;');
        $me->addMacro('isNotActiveWidgetArea', 'if(!is_active_sidebar(%node.word)):', 'endif;');
        $me->addMacro('head', 'if(is_singular() && get_option("thread_comments")){wp_enqueue_script("comment-reply");}wp_head();');
        $me->addMacro('footer', 'wp_footer();');
        $me->addMacro('mobileDetectionScript', " ?><script type='text/javascript'>var ua = navigator.userAgent; var meta = document.createElement('meta');if((ua.toLowerCase().indexOf('android') > -1 && ua.toLowerCase().indexOf('mobile')) || ((ua.match(/iPhone/i)) || (ua.match(/iPod/i)))){ meta.name = 'viewport';\tmeta.content = 'target-densitydpi=device-dpi, width=480'; }var m = document.getElementsByTagName('meta')[0]; m.parentNode.insertBefore(meta,m);</script> <?php ");
        $me->addMacro('menu', 'wp_nav_menu(%node.array);');
        $me->addMacro('title', 'echo WpLatteFunctions::getTitle()');
        $me->addMacro('editPostLink', 'edit_post_link(__("Edit", "ait"), "<span class=\\"edit-link\\">", "</span>", %node.word);');
        $me->addMacro('editCommentLink', 'WpLatteFunctions::editCommentLink(__("Edit", "ait"), %node.word, "<span class=\\"edit-link\\">", "</span>");');
        $me->addMacro('postContentPager', '
			$a = %node.array;
			if(empty($a)){
				wp_link_pages(array(
					"before" => "<div class=\\"page-link\\"><span>" . __("Pages:", "ait") . "</span>",
					"after" => "</div>"
				));
			}else{
				wp_link_pages(array(
					"before" => $a[1] . "<span>" . $a[0] . "</span>",
					"after" => $a[2]
				));
			}
			unset($a);
			');
        $me->addMacro('commentForm', 'comment_form(%node.array);');
        $me->addMacro('prevCommentsLink', 'previous_comments_link(%node.word)');
        $me->addMacro('nextCommentsLink', 'next_comments_link(%node.word)');
        $me->addMacro('prevPostsLink', 'previous_posts_link(%node.word)');
        $me->addMacro('nextPostsLink', 'next_posts_link(%node.word)');
        $me->addMacro('prevPostLink', 'previous_post_link("%link", %node.word)');
        $me->addMacro('nextPostLink', 'next_post_link("%link", %node.word)');
        $me->addMacro('commentTitle', '
				$a = %node.array;
				$a[0] = %escape($a[0]);
				printf(_n(
						"$a[2] &ldquo;%2\\$s&rdquo;",
						"%1\\$s $a[3] &ldquo;%2\\$s&rdquo;",
						$a[1],
						"ait"
					),
					number_format_i18n($a[1]),
					"<span>$a[0]</span>"
				);unset($a);');
        $me->addMacro('commentReplyLink', '
				$a = %node.array;
				comment_reply_link(array_merge(
					$a[1],
					array(
						"reply_text" => $a[0],
						"depth" => $a[2],
						"max_depth" => $a[1]["max_depth"]
					)
				), $a[3]); unset($a);');
        // oh my f*****g god, if there was $node->tokenizer->fetchArray(), so life would be better
        $me->addMacro('listComments', '
			$a = %node.array;
			$depth = 1;
			if(isset($a["begin"]))
				echo $a["begin"];
			else
				echo "<ol class=\\"commentlist\\">";

			if(isset($a["childrenClass"]))
				$children = " class=\\"$a[childrenClass]\\"";
			else
				$children = " class=\\"children\\"";

			$iterations = 0; foreach ($iterator = $_l->its[] = new NSmartCachingIterator($a["comments"]) as $comment):
				if ($comment->depth > $depth){
					echo "<ul{$children}>";
					$depth = $comment->depth;
				}elseif($comment->depth == $depth and !$iterator->isFirst()){
					echo "</li>";
				}elseif($comment->depth < $depth){
					echo "</li>";
					echo str_repeat("</ul></li>", $depth - $comment->depth);
					$depth = $comment->depth;
				}
			', '
			$iterations++; endforeach; array_pop($_l->its); $iterator = end($_l->its);
			echo "</li>";
			echo str_repeat("</ul></li>", $depth - 1);
			if(isset($a["end"]))
				echo $a["end"];
			else
				echo "</ol>";
			');
        $me->addMacro('less', 'echo WpLatteFunctions::lessify()');
        $me->addMacro('generatedCss', 'echo WpLatteFunctions::generatedCss()');
        $me->addMacro('breadcrumbs', 'echo WpLatteFunctions::breadcrumbs(%node.array)');
        $me->addMacro('linkTo', 'echo WpLatteFunctions::linkTo(%node.args)');
        $me->addMacro('lang', 'echo do_shortcode(%node.args)');
        $me->addMacro('cufon', "\n\t\t\t\$__cufon = %node.array; ?>\n\t\t\t<script id=\"ait-cufon-script\" src=\"<?php echo \$__cufon[2] ?>\"></script>\n\t\t\t<?php\n\t\t\t\$__tbCookie = @strstr(\$_COOKIE['aitThemeBox-' .THEME_CODE_NAME], 'Type\\\":\\\"google\\\"');\n\t\t\tif(\$__tbCookie === false and substr(\$__cufon[3], -3, 3) == '.js'): ?>\n\t\t\t<script id=\"ait-cufon-font-script\" src=\"<?php echo \$__cufon[3] ?>\"></script>\n\t\t\t<?php endif; ?>\n\n\t\t\t<script id=\"ait-cufon-font-replace\">\n\t\t\t\t<?php if(\$__cufon[5]): ?>\n\t\t\t\tvar isCookie = false;\n\t\t\t\ttry{\n\t\t\t\t\tvar type = Cookies.get('<?php echo \$__cufon[0] . ucfirst(\$__cufon[1]) . 'Type'?>');\n\t\t\t\t\tif(type == undefined || (type != undefined && type == 'cufon'))\n\t\t\t\t\t\tisCookie = true;\n\t\t\t\t}catch(e){\n\t\t\t\t\tisCookie = true;\n\t\t\t\t}\n\n\t\t\t\tif(isCookie != false){\n\t\t\t\t<?php endif; ?>\n\t\t\t\t\t<?php \$__font = WpLatteFunctions::getCssFontSelectors(\$__cufon[1]);?>\n\t\t\t\t\tCufon.now();\n\t\t\t\t\t<?php foreach(\$__font as \$selectors => \$values): ?>\n\t\t\t\t\tCufon.replace('<?php echo \$selectors ?>', {\n\t\t\t\t\t\tfontFamily: \"<?php echo \$__cufon[4]?>\".replace(/\\+/g, ' ')\n\t\t\t\t\t\t<?php if(isset(\$values['text-shadow'])): ?>, textShadow: '<?php echo \$values['text-shadow'] ?>'<?php endif; ?>\n\t\t\t\t\t\t<?php if(isset(\$values['hover'])): ?>, hover: {<?php if(isset(\$values['hover']['color'])): ?>color: '<?php echo \$values['hover']['color'] ?>'<?php endif; ?><?php if(isset(\$values['hover']['text-shadow'])): ?>,textShadow: '<?php echo \$values['hover']['text-shadow'] ?>'<?php endif; ?>}\n\t\t\t\t\t\t<?php endif; ?>\n\t\t\t\t\t});\n\t\t\t\t\t<?php endforeach; ?>\n\t\t\t\t<?php if(\$__cufon[5]): ?>}<?php endif; ?>\n\t\t\t</script><?php\n\t\t");
        $me->addMacro('dayLink', 'echo WpLatteFunctions::getDayLink(%node.args)');
        $me->addMacro('bodyClasses', "echo join(' ', get_body_class()) . ' ' . join(' ', %node.array)");
        $me->addMacro('willPaginate', 'if($GLOBALS["wp_query"]->max_num_pages > 1):', 'endif;');
        $me->addMacro('doShortcode', 'echo do_shortcode(%node.args)');
        $me->addMacro('paginateLinks', 'echo WpLatteFunctions::paginateLinks(%node.args)');
        $me->addMacro('stripTag', 'echo WpLatteFunctions::stripTag(%node.args);');
        $me->addMacro('getHeader', 'get_header(%node.word)');
        $me->addMacro('getFooter', 'get_footer(%node.word)');
        $me->addMacro('getSidebar', 'get_sidebar(%node.word)');
        $me->addMacro('timthumb', 'echo TIMTHUMB_URL . "?" . http_build_query(%node.array, "", "&amp;")');
        $me->addMacro('thumbnailResize', 'echo AitImageResizer::resize(%node.word, %node.array)');
        $me->addMacro('widget', 'the_widget(%node.word, %node.array)');
        $me->addMacro('googleAnalyticsCode', array($me, 'googleAnalyticsCodeMacro'));
        $me->addMacro('includePart', array($me, 'macroIncludePart'));
    }
Example #7
0
 /**
  * Register latte macros
  * @author Pavel Železný <*****@*****.**>
  * @param \Latte\Compiler $compiler
  * @return void
  */
 public static function install(Compiler $compiler)
 {
     $me = new self($compiler);
     $me->addMacro('button', array($me, 'macroButton'), array($me, 'macroButtonEnd'));
     $me->addMacro('caption', array($me, 'macroCaption'));
 }
Example #8
0
	public static function install(NLatteCompiler $compiler)
	{
		$me = new self($compiler);

		$me->addMacro('if', array($me, 'macroIf'), array($me, 'macroEndIf'));
		$me->addMacro('elseif', 'elseif (%node.args):');
		$me->addMacro('else', array($me, 'macroElse'));
		$me->addMacro('ifset', 'if (isset(%node.args)):', 'endif');
		$me->addMacro('elseifset', 'elseif (isset(%node.args)):');

		$me->addMacro('foreach', '', array($me, 'macroEndForeach'));
		$me->addMacro('for', 'for (%node.args):', 'endfor');
		$me->addMacro('while', 'while (%node.args):', 'endwhile');
		$me->addMacro('continueIf', 'if (%node.args) continue');
		$me->addMacro('breakIf', 'if (%node.args) break');
		$me->addMacro('first', 'if ($iterator->isFirst(%node.args)):', 'endif');
		$me->addMacro('last', 'if ($iterator->isLast(%node.args)):', 'endif');
		$me->addMacro('sep', 'if (!$iterator->isLast(%node.args)):', 'endif');

		$me->addMacro('var', array($me, 'macroVar'));
		$me->addMacro('assign', array($me, 'macroVar')); // deprecated
		$me->addMacro('default', array($me, 'macroVar'));
		$me->addMacro('dump', array($me, 'macroDump'));
		$me->addMacro('debugbreak', array($me, 'macroDebugbreak'));
		$me->addMacro('l', '?>{<?php');
		$me->addMacro('r', '?>}<?php');

		$me->addMacro('_', array($me, 'macroTranslate'), array($me, 'macroTranslate'));
		$me->addMacro('=', array($me, 'macroExpr'));
		$me->addMacro('?', array($me, 'macroExpr'));

		$me->addMacro('capture', array($me, 'macroCapture'), array($me, 'macroCaptureEnd'));
		$me->addMacro('include', array($me, 'macroInclude'));
		$me->addMacro('use', array($me, 'macroUse'));

		$me->addMacro('class', NULL, NULL, array($me, 'macroClass'));
		$me->addMacro('attr', array($me, 'macroOldAttr'), '', array($me, 'macroAttr'));
		$me->addMacro('href', NULL); // TODO: placeholder
	}
Example #9
0
    public static function install(LatteCompiler $compiler)
    {
        $me = new self($compiler);
        $me->addMacro('include', array($me, 'macroInclude'));
        $me->addMacro('includeblock', array($me, 'macroIncludeBlock'));
        $me->addMacro('extends', array($me, 'macroExtends'));
        $me->addMacro('layout', array($me, 'macroExtends'));
        $me->addMacro('block', array($me, 'macroBlock'), array($me, 'macroBlockEnd'));
        $me->addMacro('define', array($me, 'macroBlock'), array($me, 'macroBlockEnd'));
        $me->addMacro('snippet', array($me, 'macroBlock'), array($me, 'macroBlockEnd'));
        $me->addMacro('ifset', array($me, 'macroIfset'), 'endif');
        $me->addMacro('widget', array($me, 'macroControl'));
        // deprecated - use control
        $me->addMacro('control', array($me, 'macroControl'));
        $me->addMacro('href', NULL, NULL, create_function('MacroNode $node, PhpWriter $writer', 'extract(NCFix::$vars[' . NCFix::uses(array('me' => $me)) . '], EXTR_REFS);
			return \' ?> href="<?php \' . $me->macroLink($node, $writer) . \' ?>"<?php \';
		'));
        $me->addMacro('plink', array($me, 'macroLink'));
        $me->addMacro('link', array($me, 'macroLink'));
        $me->addMacro('ifCurrent', array($me, 'macroIfCurrent'), 'endif');
        // deprecated; use n:class="$presenter->linkCurrent ? ..."
        $me->addMacro('contentType', array($me, 'macroContentType'));
        $me->addMacro('status', array($me, 'macroStatus'));
    }
Example #10
0
 /**
  * @param Latte\Compiler $compiler
  */
 public static function install(Latte\Compiler $compiler)
 {
     $me = new self($compiler);
     $me->addMacro('assetWebPath', array($me, 'macroAssetWebPath'));
 }
 /**
  * @param Compiler $compiler
  * @param string $directory
  */
 public static function install(Compiler $compiler, $directory)
 {
     $me = new self($compiler);
     $me->directory = $directory;
     $me->addMacro('component', NULL, [$me, 'macroComponent']);
 }
Example #12
0
 /**
  * @param Engine $latte
  */
 public static function install(Engine $latte)
 {
     $me = new self($latte->getCompiler());
     $me->addMacro('wizard', array($me, 'wizardStart'), array($me, 'wizardEnd'));
     $me->addMacro('step', array($me, 'stepStart'), '}');
 }