Наследование: extends Drinkable
Пример #1
0
 /**
  * Constructor
  *
  * @param string $markup
  * @param array $tokens
  * @param LiquidFileSystem $file_system
  * @return AssignLiquidTag
  */
 public function __construct($markup, &$tokens, &$file_system)
 {
     $syntax_regexp = new LiquidRegexp('/(\\w+)\\s*=\\s*(' . LIQUID_QUOTED_FRAGMENT . '+)/');
     $filter_seperator_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPARATOR . '\\s*(.*)/');
     $filter_split_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPARATOR . '/');
     $filter_name_regexp = new LiquidRegexp('/\\s*(\\w+)/');
     $filter_argument_regexp = new LiquidRegexp('/(?:' . LIQUID_FILTER_ARGUMENT_SEPARATOR . '|' . LIQUID_ARGUMENT_SEPARATOR . ')\\s*(' . LIQUID_QUOTED_FRAGMENT . ')/');
     $this->filters = array();
     if ($filter_seperator_regexp->match($markup)) {
         $filters = $filter_split_regexp->split($filter_seperator_regexp->matches[1]);
         foreach ($filters as $filter) {
             $filter_name_regexp->match($filter);
             $filtername = $filter_name_regexp->matches[1];
             $filter_argument_regexp->match_all($filter);
             $matches = Liquid::array_flatten($filter_argument_regexp->matches[1]);
             array_push($this->filters, array($filtername, $matches));
         }
     }
     if ($syntax_regexp->match($markup)) {
         $this->_to = $syntax_regexp->matches[1];
         $this->_from = $syntax_regexp->matches[2];
     } else {
         throw new LiquidException("Syntax Error in 'assign' - Valid syntax: assign [var] = [source]");
     }
 }
 /**
  * Constructor
  *
  * @param string $markup
  * @return LiquidVariable
  */
 public function __construct($markup)
 {
     $this->markup = $markup;
     $quoted_fragment_regexp = new LiquidRegexp('/\\s*(' . LIQUID_QUOTED_FRAGMENT . ')/');
     $filter_seperator_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPARATOR . '\\s*(.*)/');
     $filter_split_regexp = new LiquidRegexp('/' . LIQUID_FILTER_SEPARATOR . '/');
     $filter_name_regexp = new LiquidRegexp('/\\s*(\\w+)/');
     $filter_argument_regexp = new LiquidRegexp('/(?:' . LIQUID_FILTER_ARGUMENT_SEPARATOR . '|' . LIQUID_ARGUMENT_SEPARATOR . ')\\s*(' . LIQUID_QUOTED_FRAGMENT . ')/');
     $quoted_fragment_regexp->match($markup);
     //$this->_name = $quoted_fragment_regexp->matches[1];
     $this->_name = isset($quoted_fragment_regexp->matches[1]) ? $quoted_fragment_regexp->matches[1] : null;
     // harry
     if ($filter_seperator_regexp->match($markup)) {
         $filters = $filter_split_regexp->split($filter_seperator_regexp->matches[1]);
         foreach ($filters as $filter) {
             $filter_name_regexp->match($filter);
             $filtername = $filter_name_regexp->matches[1];
             $filter_argument_regexp->match_all($filter);
             //$matches = array_flatten($filter_argument_regexp->matches[1]);
             $matches = Liquid::array_flatten($filter_argument_regexp->matches[1]);
             $this->filters[] = array($filtername, $matches);
         }
     } else {
         $this->filters = array();
     }
 }
Пример #3
0
 protected function setUp()
 {
     parent::setUp();
     $defaultConfig = array('HAS_PROPERTY_METHOD' => 'field_exists', 'GET_PROPERTY_METHOD' => 'get', 'FILTER_SEPARATOR' => '\\|', 'ARGUMENT_SEPARATOR' => ',', 'FILTER_ARGUMENT_SEPARATOR' => ':', 'VARIABLE_ATTRIBUTE_SEPARATOR' => '.', 'INCLUDE_ALLOW_EXT' => false, 'INCLUDE_SUFFIX' => 'liquid', 'INCLUDE_PREFIX' => '_', 'TAG_START' => '{%', 'TAG_END' => '%}', 'VARIABLE_START' => '{{', 'VARIABLE_END' => '}}', 'ALLOWED_VARIABLE_CHARS' => '[a-zA-Z_.-]', 'QUOTED_STRING' => '"[^":]*"|\'[^\':]*\'');
     foreach ($defaultConfig as $configKey => $configValue) {
         Liquid::set($configKey, $configValue);
     }
 }
Пример #4
0
 public function testArrayFlattenNestedArray()
 {
     $object = new \stdClass();
     // Method does not maintain keys.
     $original = array('one' => 'one_value', 42 => array('one_value', array('two_value', 10)), $object);
     $expected = array('one_value', 'one_value', 'two_value', 10, $object);
     $this->assertEquals($expected, Liquid::arrayFlatten($original));
 }
 public function testReadTemplateFile()
 {
     Liquid::set('INCLUDE_PREFIX', '');
     Liquid::set('INCLUDE_SUFFIX', 'tpl');
     $root = dirname(__FILE__) . DIRECTORY_SEPARATOR . self::TEMPLATES_DIR . DIRECTORY_SEPARATOR;
     $fileSystem = new LocalFileSystem($root);
     $this->assertEquals('test content', trim($fileSystem->readTemplateFile('mypartial')));
 }
Пример #6
0
 /**
  * Extracts tag attributes from a markup string.
  *
  * @param string $markup
  */
 protected function extractAttributes($markup)
 {
     $this->attributes = array();
     $attributeRegexp = new Regexp(Liquid::get('TAG_ATTRIBUTES'));
     $matches = $attributeRegexp->scan($markup);
     foreach ($matches as $match) {
         $this->attributes[$match[0]] = $match[1];
     }
 }
Пример #7
0
 /**
  * Resolves a given path to a full template file path, making sure it's valid
  *
  * @param string $templatePath
  *
  * @throws LiquidException
  * @return string
  */
 public function fullPath($templatePath)
 {
     $nameRegex = Liquid::get('INCLUDE_ALLOW_EXT') ? new Regexp('/^[^.\\/][a-zA-Z0-9_\\.\\/]+$/') : new Regexp('/^[^.\\/][a-zA-Z0-9_\\/]+$/');
     if (!$nameRegex->match($templatePath)) {
         throw new LiquidException("Illegal template name '{$templatePath}'");
     }
     if (strpos($templatePath, '/') !== false) {
         $fullPath = Liquid::get('INCLUDE_ALLOW_EXT') ? $this->root . dirname($templatePath) . '/' . basename($templatePath) : $this->root . dirname($templatePath) . '/' . Liquid::get('INCLUDE_PREFIX') . basename($templatePath) . '.' . Liquid::get('INCLUDE_SUFFIX');
     } else {
         $fullPath = Liquid::get('INCLUDE_ALLOW_EXT') ? $this->root . $templatePath : $this->root . Liquid::get('INCLUDE_PREFIX') . $templatePath . '.' . Liquid::get('INCLUDE_SUFFIX');
     }
     $rootRegex = new Regexp('/' . preg_quote(realpath($this->root), '/') . '/');
     if (!$rootRegex->match(realpath($fullPath))) {
         throw new LiquidException("Illegal template path '" . realpath($fullPath) . "'");
     }
     return $fullPath;
 }
Пример #8
0
 /**
  * Parses the given tokens
  *
  * @param array $tokens
  */
 public function parse(&$tokens)
 {
     $startRegexp = new LiquidRegexp('/^' . LIQUID_TAG_START . '/');
     $tagRegexp = new LiquidRegexp('/^' . LIQUID_TAG_START . '\\s*(\\w+)\\s*(.*)?' . LIQUID_TAG_END . '$/');
     $variableStartRegexp = new LiquidRegexp('/^' . LIQUID_VARIABLE_START . '/');
     $this->_nodelist = array();
     if (!is_array($tokens)) {
         return;
     }
     $tags = LiquidTemplate::getTags();
     while (count($tokens)) {
         $token = array_shift($tokens);
         if ($startRegexp->match($token)) {
             if ($tagRegexp->match($token)) {
                 // if we found the proper block delimitor just end parsing here and let the outer block proceed
                 if ($tagRegexp->matches[1] == $this->blockDelimiter()) {
                     return $this->endTag();
                 }
                 if (array_key_exists($tagRegexp->matches[1], $tags)) {
                     $tag_name = $tags[$tagRegexp->matches[1]];
                 } else {
                     $tag_name = 'LiquidTag' . ucwords($tagRegexp->matches[1]);
                     // search for a defined class of the right name, instead of searching in an array
                     $tag_name = Liquid::classExists($tag_name) === true ? $tag_name : null;
                 }
                 if (class_exists($tag_name)) {
                     $this->_nodelist[] = new $tag_name($tagRegexp->matches[2], $tokens, $this->_fileSystem);
                     if ($tagRegexp->matches[1] == 'extends') {
                         return true;
                     }
                 } else {
                     $this->unknownTag($tagRegexp->matches[1], $tagRegexp->matches[2], $tokens);
                 }
             } else {
                 throw new LiquidException("Tag {$token} was not properly terminated");
                 // harry
             }
         } elseif ($variableStartRegexp->match($token)) {
             $this->_nodelist[] = $this->_createVariable($token);
         } elseif ($token != '') {
             $this->_nodelist[] = $token;
         }
     }
     $this->assertMissingDelimitation();
 }
Пример #9
0
 /**
  * Constructor
  *
  * @param string $markup
  */
 public function __construct($markup)
 {
     $this->markup = $markup;
     $quotedFragmentRegexp = new Regexp('/\\s*(' . Liquid::get('QUOTED_FRAGMENT') . ')/');
     $filterSeperatorRegexp = new Regexp('/' . Liquid::get('FILTER_SEPARATOR') . '\\s*(.*)/');
     $filterSplitRegexp = new Regexp('/' . Liquid::get('FILTER_SEPARATOR') . '/');
     $filterNameRegexp = new Regexp('/\\s*(\\w+)/');
     $filterArgumentRegexp = new Regexp('/(?:' . Liquid::get('FILTER_ARGUMENT_SEPARATOR') . '|' . Liquid::get('ARGUMENT_SEPARATOR') . ')\\s*(' . Liquid::get('QUOTED_FRAGMENT_FILTER_ARGUMENT') . ')/');
     $quotedFragmentRegexp->match($markup);
     $this->name = isset($quotedFragmentRegexp->matches[1]) ? $quotedFragmentRegexp->matches[1] : null;
     if ($filterSeperatorRegexp->match($markup)) {
         $filters = $filterSplitRegexp->split($filterSeperatorRegexp->matches[1]);
         foreach ($filters as $filter) {
             $filterNameRegexp->match($filter);
             $filtername = $filterNameRegexp->matches[1];
             $filterArgumentRegexp->matchAll($filter);
             $matches = Liquid::arrayFlatten($filterArgumentRegexp->matches[1]);
             $this->filters[] = array($filtername, $matches);
         }
     } else {
         $this->filters = array();
     }
 }
Пример #10
0
<?php

/*
 * Copyright(c) 2009 limitlink,Inc. All Rights Reserved.
 * http://limitlink.jp/
 * 文字コード UTF-8
 */
require_once '../application/loader.php';
$view->script('postcode.js');
$view->heading('顧客情報編集');
$hash['folder'] = array('&nbsp;') + $hash['folder'];
$liquid = new Liquid();
?>
<div class="contentcontrol">
	<h1>顧客情報編集</h1>
	<table class="customertype" cellspacing="0"><tr>
		<td><a href="index.php">個人</a></td>
		<td><a class="current" href="company.php">法人</a></td>
	</tr></table>
	<div class="clearer"></div>
</div>
<ul class="operate">
	<li><a href="company.php<?php 
echo $view->positive(array('folder' => $hash['data']['folder_id']));
?>
">一覧に戻る</a></li>
	<li><a href="companyadd.php?id=<?php 
echo $hash['data']['id'];
?>
">複製</a></li>
	<li><a href="companydelete.php?id=<?php 
Пример #11
0
/*
 * Copyright(c) 2009 limitlink,Inc. All Rights Reserved.
 * http://limitlink.jp/
 * 文字コード UTF-8
 */
require_once '../application/loader.php';
$view->heading('履歴');
$pagination = new Pagination(array('parent' => $_GET['parent']));
$current[intval($hash['parent']['customer_type'])] = ' class="current"';
if ($hash['parent']['customer_type'] == 1) {
    $location = array('company.php', 'companyview.php');
} else {
    $location = array('index.php', 'view.php');
}
$liquid = new Liquid();
?>
<div class="contentcontrol">
	<h1>履歴</h1>
	<table class="customertype" cellspacing="0"><tr>
		<td><a<?php 
echo $current[0];
?>
 href="index.php">個人</a></td>
	</tr></table>
	<div class="clearer"></div>
</div>
<ul class="operate">
	<li><a href="../customer/<?php 
echo $location[0];
echo $view->positive(array('folder' => $hash['parent']['folder_id']));
Пример #12
0
 * http://limitlink.jp/
 * 文字コード UTF-8
 */
require_once '../application/loader.php';
$view->heading('履歴');
$pagination = new Pagination(array('type' => $_GET['type'], 'folder' => $_GET['folder']));
$current[intval($_GET['type'])] = ' class="current"';
if ($_GET['type'] == 1) {
    $caption = '会社名';
} else {
    $caption = '名前';
}
if (count($hash['list']) <= 0) {
    $attribute = ' onclick="alert(\'出力するデータがありません。\');return false;"';
}
$liquid = new Liquid();
?>
<div class="contentcontrol">
	<h1>履歴<?php 
echo $view->caption($hash['folder']);
?>
</h1>
	<table class="customertype" cellspacing="0"><tr>
		<td><a<?php 
echo $current[0];
?>
 href="index.php">個人</a></td>
		<td><a<?php 
echo $current[1];
?>
 href="index.php?type=1">法人</a></td>
Пример #13
0
 /**
  * Resolved the namespaced queries gracefully.
  *
  * @param string $key
  *
  * @throws LiquidException
  * @return mixed
  */
 private function variable($key)
 {
     // Support [0] style array indicies
     if (preg_match("|\\[[0-9]+\\]|", $key)) {
         $key = preg_replace("|\\[([0-9]+)\\]|", ".\$1", $key);
     }
     $parts = explode(Liquid::get('VARIABLE_ATTRIBUTE_SEPARATOR'), $key);
     $object = $this->fetch(array_shift($parts));
     if (is_object($object)) {
         if (!method_exists($object, 'toLiquid')) {
             throw new LiquidException("Method 'toLiquid' not exists!");
         }
         $object = $object->toLiquid();
     }
     if ($object === null) {
         return null;
     }
     while (count($parts) > 0) {
         if ($object instanceof Drop) {
             $object->setContext($this);
         }
         $nextPartName = array_shift($parts);
         if (is_array($object)) {
             // if the last part of the context variable is .size we just return the count
             if ($nextPartName == 'size' && count($parts) == 0 && !array_key_exists('size', $object)) {
                 return count($object);
             }
             if (array_key_exists($nextPartName, $object)) {
                 $object = $object[$nextPartName];
             } else {
                 return null;
             }
         } elseif (is_object($object)) {
             if ($object instanceof Drop) {
                 // if the object is a drop, make sure it supports the given method
                 if (!$object->hasKey($nextPartName)) {
                     return null;
                 }
                 $object = $object->invokeDrop($nextPartName);
             } elseif (method_exists($object, Liquid::get('HAS_PROPERTY_METHOD'))) {
                 if (!call_user_func(array($object, Liquid::get('HAS_PROPERTY_METHOD')), $nextPartName)) {
                     return null;
                 }
                 call_user_func(array($object, Liquid::get('GET_PROPERTY_METHOD')), $nextPartName);
             } else {
                 // if it's just a regular object, attempt to access a property
                 if (!property_exists($object, $nextPartName)) {
                     return null;
                 }
                 $object = $object->{$nextPartName};
             }
         }
         if (is_object($object) && method_exists($object, 'toLiquid')) {
             $object = $object->toLiquid();
         }
     }
     return $object;
 }
Пример #14
0
 public function __construct($meta = 0)
 {
     Liquid::__construct(self::STILL_WATER, $meta, "Still Water");
     $this->hardness = 500;
 }
Пример #15
0
<?php

/*
 * Copyright(c) 2009 limitlink,Inc. All Rights Reserved.
 * http://limitlink.jp/
 * 文字コード UTF-8
 */
require_once '../application/loader.php';
$view->script('customer.js');
$view->heading('履歴設定');
$liquid = new Liquid();
if ($_GET['folder'] <= 0 || count($hash['item']) > 0 || count($hash['default']) <= 0) {
    $display[1] = ' style="display:none;"';
    $operator = '標準設定';
} else {
    $display[0] = ' style="display:none;"';
    $operator = '項目の変更';
}
if (!is_array($hash['item']) || count($hash['item']) <= 0) {
    for ($i = 0; $i < 5; $i++) {
        $hash['item'][] = array('item_display' => 1);
    }
}
?>
<h1>履歴設定<?php 
echo $view->caption($hash['folder'], array(0 => 'トップ / 標準設定'));
?>
</h1>
<ul class="operate">
	<li><a href="index.php<?php 
echo $view->parameter(array('folder' => $_GET['folder']));
Пример #16
0
<?php

/*
 * Copyright(c) 2009 limitlink,Inc. All Rights Reserved.
 * http://limitlink.jp/
 * 文字コード UTF-8
 */
require_once '../application/loader.php';
$view->heading('履歴削除');
$current[intval($hash['parent']['customer_type'])] = ' class="current"';
$liquid = new Liquid();
?>
<div class="contentcontrol">
	<h1>履歴削除</h1>
	<table class="customertype" cellspacing="0"><tr>
		<td><a<?php 
echo $current[0];
?>
 href="index.php">個人</a></td>
		<td><a<?php 
echo $current[1];
?>
 href="index.php?type=1">法人</a></td>
	</tr></table>
	<div class="clearer"></div>
</div>
<ul class="operate">
	<li><a href="customer.php<?php 
echo $view->parameter(array('parent' => $hash['parent']['id']));
?>
">履歴一覧に戻る</a></li>
Пример #17
0
 /**
  * Create a variable for the given token
  *
  * @param string $token
  *
  * @throws \Liquid\LiquidException
  * @return Variable
  */
 private function createVariable($token)
 {
     $variableRegexp = new Regexp('/^' . Liquid::get('VARIABLE_START') . '(.*)' . Liquid::get('VARIABLE_END') . '$/');
     if ($variableRegexp->match($token)) {
         return new Variable($variableRegexp->matches[1]);
     }
     throw new LiquidException("Variable {$token} was not properly terminated");
 }
Пример #18
0
 /**
  * Tokenizes the given source string
  *
  * @param string $source
  *
  * @return array
  */
 public static function tokenize($source)
 {
     return empty($source) ? array() : preg_split(Liquid::get('TOKENIZATION_REGEXP'), $source, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
 }
Пример #19
0
 protected function setup()
 {
     parent::setUp();
     $this->regexp = new Regexp('/' . Liquid::get('QUOTED_FRAGMENT') . '/');
 }