Exemplo n.º 1
0
 public function preRender($template_buffer, $template_name, &$data)
 {
     if ($this->template != 'setting/store_form.tpl') {
         return parent::preRender($template_buffer, $template_name, $data);
     }
     // add support for the Google site verification field
     $this->load->language('setting/store');
     $data['entry_google_site_verification'] = $this->language->get('entry_google_site_verification');
     if (isset($this->request->post['config_google_site_verification'])) {
         $data['config_google_site_verification'] = $this->request->post['config_google_site_verification'];
     } elseif (isset($store_info['config_google_site_verification'])) {
         $data['config_google_site_verification'] = $store_info['config_google_site_verification'];
     } else {
         $data['config_google_site_verification'] = '';
     }
     // add the Google site verification field to the template file
     $add = '            <div class="form-group">' . "\n";
     $add .= '              <label class="col-sm-2 control-label" for="input-google-site-verification"><?php echo $entry_google_site_verification; ?></label>' . "\n";
     $add .= '              <div class="col-sm-10">' . "\n";
     $add .= '                <input type="text" name="config_google_site_verification" value="<?php echo $config_google_site_verification; ?>" placeholder="<?php echo $entry_google_site_verification; ?>" id="input-google_site_verification" class="form-control" />' . "\n";
     $add .= '              </div>' . "\n";
     $add .= '            </div>' . "\n";
     $this->load->helper('modifier');
     $template_buffer = Modifier::modifyStringBuffer($template_buffer, '<textarea name="config_meta_description"', $add, 'after', 2);
     return parent::preRender($template_buffer, $template_name, $data);
 }
Exemplo n.º 2
0
		public static function getByCustomization($id)
		{
			global $db;
			//get customization from database
			$customizationSQL = "SELECT * FROM customizations WHERE customizationid=?";
			$values = array($id);
			$customization = $db->qwv($customizationSQL, $values);
			
			//get modifier from database
			$modifierSQL = "SELECT * FROM modifiers WHERE modifierid=?";
			$values = array($customization[0]['modifierid']);
			$modifier = $db->qwv($modifierSQL, $values);
			
			return Modifier::wrap($modifier);
		}
Exemplo n.º 3
0
 protected function preRender($templateBuffer)
 {
     if ($this->template != 'common/header.tpl') {
         return parent::preRender($templateBuffer);
     }
     if (!$this->user->isLogged() || !isset($this->request->get['token']) || !isset($this->session->data['token']) || $this->request->get['token'] != $this->session->data['token']) {
         return parent::preRender($templateBuffer);
     }
     // add the additional controller variables for the export menu
     $this->data['text_export'] = $this->language->get('text_export');
     $this->data['export'] = $this->url->link('tool/export', 'token=' . $this->session->data['token'], 'SSL');
     // add the export menus to the header
     $this->load->helper('modifier');
     $search = '<li><a href="<?php echo $backup; ?>"><?php echo $text_backup; ?></a></li>';
     $add = '          <li><a href="<?php echo $export; ?>"><?php echo $text_export; ?></a></li>' . "\n";
     $templateBuffer = Modifier::modifyStringBuffer($templateBuffer, $search, $add, 'after');
     return parent::preRender($templateBuffer);
 }
Exemplo n.º 4
0
		public function __get($var)
		{
			if( $var == 'order_item' )
			{
				return Order_Item::getByID($this->order_itemid);
			}
			elseif( $var == 'modifier' )
			{
				return Modifier::getByID($this->modifierid);
			}
			elseif( $var == 'ingredient' )
			{
				return Ingredient::getByID($this->ingredientid);
			}
			else
			{
				return $this->$var;
			}
		}
Exemplo n.º 5
0
 /** @inheritdoc */
 public static function calculateValue($modifierName, $modifierParams, $value, $params = array())
 {
     switch ($modifierName) {
         case 'replace':
             $default = Util::lavnn('default', $modifierParams, '');
             $fallback = Util::lavnn('fallback', $modifierParams, '');
             $value = Util::lavnn($fallback, $params, $default);
             break;
         case "checked":
             $value = $value == '1' ? 'checked' : '';
             break;
         case "fixbool":
             $value = (bool) $value;
             break;
         case 'round':
             $value = round($value, Util::lavnn('digits', $modifierParams, 0));
             break;
         case 'money':
             $value = round($value, 2);
             break;
         case 'date':
             $value = date('d.m.Y H:i:s', $value);
             break;
         case 'thousands':
             // @TODO make it configurable from locale. so far usable only for admin purposes
             $value = number_format($value, 0, '', '.');
             break;
         case 'checkboxvalue':
             $avalue = $value ? 'checked="checked"' : '';
             break;
         default:
             $value = parent::calculateValue($modifierName, $modifierParams, $value, $params);
             break;
     }
     return $value;
 }
Exemplo n.º 6
0
 public function testImportRecursive()
 {
     $this->fenom->compile('macro_recursive_import.tpl');
     $this->fenom->flush();
     $tpl = $this->fenom->getTemplate('macro_recursive.tpl');
     $this->assertSame("10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10", Modifier::strip($tpl->fetch(array()), true));
 }
 /**
  * Add modifier fields for this order, such as Shipping fields.
  * 
  * @param Array $fields Array of fields
  * @param OrderFormValidator $validator Checkout form validator
  * @param Order $order The current order
  */
 private function addModifierFields(&$fields, &$validator, $order)
 {
     foreach (Modifier::combined_form_fields($order) as $field) {
         if ($field->modifiesSubTotal()) {
             $fields['SubTotalModifiers'][] = $field;
         } else {
             $fields['Modifiers'][] = $field;
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Returns a string describing this <code>Field</code>.  The format is
  * the access modifiers for the field, if any, followed
  * by the field type, followed by a space, followed by
  * the fully-qualified name of the class declaring the field,
  * followed by a period, followed by the name of the field.
  * For example:
  * <pre>
  *    public static final int java.lang.Thread.MIN_PRIORITY
  *    private int java.io.FileDescriptor.fd
  * </pre>
  *
  * <p>The modifiers are placed in canonical order as specified by
  * "The Java Language Specification".  This is <tt>public</tt>,
  * <tt>protected</tt> or <tt>private</tt> first, and then other
  * modifiers in the following order: <tt>static</tt>, <tt>final</tt>,
  * <tt>transient</tt>, <tt>volatile</tt>.
  *
  * @return string
  */
 public function toString()
 {
     $mod = $this->getModifiers();
     return ($mod == 0 ? "" : Modifier::toString(mod) + " ") + $this->getTypeName($this->getType()) + " " + $this->getTypeName($this->getDeclaringClass()) + "." + $this->getName();
 }
Exemplo n.º 9
0
 /** @inheritdoc */
 public static function calculateValue($modifierName, $modifierParams, $value, $params = array())
 {
     switch ($modifierName) {
         case 'tag':
             return '{{' . $value . '}}';
             break;
         case "lowercase":
             $value = strtolower($value);
             break;
         case "uppercase":
             $value = strtoupper($value);
             break;
         case "trim":
             $value = trim($value);
             break;
         case "length":
             $value = strlen($value);
             break;
         case "wordcount":
             //$value = str_word_count($value, 0, '/[\p{C}\p{S}\p{Z}]+/'); // does not work with utf-8
             $value = str_replace("­", '', $value);
             // soft hyphen encoded in UTF-8
             $value = preg_match_all('~[\\p{L}\'\\-]+~u', $value);
             break;
         case "htmlentities":
             $value = htmlentities($value);
             break;
         case "zero":
             if ($value == '') {
                 $value = 0;
             }
             break;
         case "shortener":
             $wordCount = Util::lavnn('words', $modifierParams, 0);
             $charCount = Util::lavnn('chars', $modifierParams, 0);
             $value = TextUtil::shorten($value, $wordCount, $charCount);
             break;
         case "split":
             $delimiter = Util::lavnn('delimiter', $modifierParams, '');
             $value = explode(Processor::glueDecoder($delimiter), $value);
             break;
         case "if":
             if (!self::applyIf($modifierParams, $value, $params)) {
                 return '';
             }
             break;
         case "ifempty":
             $default = Util::lavnn('default', $modifierParams, '');
             $fallback = Util::lavnn('fallback', $modifierParams, '');
             if ($value != '') {
                 return $value;
             } elseif ($fallback != '') {
                 // @TODO fallback is now on top level of $params. make it findable in the tree
                 return Util::lavnn($fallback, $params, $default);
             } else {
                 return $default;
             }
             break;
         case "ifnotempty":
             if (is_null($value) || $value == '') {
                 return '';
             }
             break;
         case 'replace':
             $default = Util::lavnn('default', $modifierParams, '');
             $fallback = Util::lavnn('fallback', $modifierParams, '');
             $value = $fallback == '' ? $default : Util::lavnn($fallback, $params, $default);
             break;
         case "dbsafe":
             $value = TextUtil::dbsafe($value);
             break;
         case "jssafe":
             $value = TextUtil::jssafe($value);
             break;
         case "htmlsafe":
             $value = TextUtil::htmlsafe($value);
             break;
         case "urlencode":
             $value = urlencode($value);
             break;
         case "fixfloat":
             $value = floatval($value);
             break;
         case "fixint":
             $value = intval($value);
             break;
         case "fixbool":
             $value = (bool) $value;
             break;
         case 'rsstime':
             $value = date('D, d M Y H:i:s O', strtotime($value));
             break;
         case 'dbdate':
             // Convert date from current locale format to DB-suitable format
             if ($value != '') {
                 $value = DateTimeUtil::DateTimeToDB($value, Util::lavnn('time', $modifierParams, 'now'));
             }
             break;
         case 'date':
             // Convert database-formatted datetime into user favourite locale, without time
             if ($value != '') {
                 $utcDate = date_create_from_format('Y-m-d H:i:s', $value);
                 if (!$utcDate) {
                     $value = date($_SESSION['formats']['date_php'], strtotime($value));
                 } else {
                     $offset = Util::lavnn('timezoneOffset', $_SESSION, 0);
                     $localDate = $utcDate->modify("+{$offset} minutes");
                     // fixing the timezone offset can change the date
                     $value = $localDate->format($_SESSION['formats']['date_php']);
                 }
             }
             break;
         case 'time':
             // Convert database-formatted datetime into user favourite locale, without date
             if ($value != '') {
                 $utcDate = date_create_from_format('Y-m-d H:i:s', $value);
                 if (!$utcDate) {
                     $value = date($_SESSION['formats']['time_php'], strtotime($value));
                 } else {
                     $offset = Util::lavnn('timezoneOffset', $_SESSION, 0);
                     $localDate = $utcDate->modify("+{$offset} minutes");
                     $value = $localDate->format($_SESSION['formats']['time_php']);
                 }
             }
             break;
         case 'datetime':
             // Convert database-formatted datetime into user current locale, using time
             if ($value != '') {
                 $utcDate = date_create_from_format('Y-m-d H:i:s', $value);
                 if (!$utcDate) {
                     $value = date($_SESSION['formats']['datetime_php'], strtotime($value));
                 } else {
                     $offset = Util::lavnn('timezoneOffset', $_SESSION, 0);
                     $localDate = $utcDate->modify("+{$offset} minutes");
                     $value = $localDate->format($_SESSION['formats']['datetime_php']);
                 }
             }
             break;
         case 'timestamp':
             if ($value != '') {
                 $value = strtotime($value);
             }
             break;
         case "fixurl":
             $value = $value == '' ? '#' : (substr($value, 0, 4) != 'http' ? 'http://' : '') . $value;
             break;
         case "nohtml":
             $value = strip_tags($value);
             break;
         case "htmlcomment":
             $value = "<!--{$value}-->";
             break;
         case "dump":
             $value = print_r($value, 1);
             break;
         case 'unserialize':
             $value = $value == '' ? array() : json_decode($value, true);
             break;
         case 'loremipsum':
             $loremIpsum = array("Donec ullamcorper nulla non metus auctor fringilla.", "Vestibulum id ligula porta felis euismod semper.", "Praesent commodo cursus magna, vel scelerisque nisl consectetur.", "Fusce dapibus, tellus ac cursus commodo.");
             $value = $value == '' ? join(' ', $loremIpsum) : $value;
             break;
         case 'gravatar':
             $size = Util::lavnn('size', $modifierParams, 50);
             $email = md5(strtolower(trim($value)));
             $value = "http://www.gravatar.com/avatar/{$email}?s=" . $size;
             break;
         default:
             $value = parent::calculateValue($modifierName, $modifierParams, $value, $params);
             break;
     }
     return $value;
 }
Exemplo n.º 10
0
 /** @inheritdoc */
 public static function calculateValue($modifierName, $modifierParams, $value, $params = array())
 {
     switch ($modifierName) {
         case "ifnotempty":
         case "stopifempty":
             if (count($value) == 0) {
                 return "";
             }
             break;
         case "ifempty":
         case "stopifnotempty":
             $default = Util::lavnn('default', $modifierParams, '');
             if (count($value) != 0) {
                 return "";
             } elseif ($default != '') {
                 return $default;
             }
             break;
         case "length":
             $value = count($value);
             break;
         case "first":
             $value = $value[0];
             break;
         case "last":
             $value = $value[count($value)];
             break;
         case "field":
             $fieldName = Util::lavnn('name', $modifierParams, '');
             $value = Util::lavnn($fieldName, $value, '');
             break;
         case "buildquerystring":
             $value = '?' . http_build_query($value);
             break;
         case "cutcolumn":
             $columnName = Util::lavnn('column', $params, '');
             $output = array();
             foreach ($value as $row) {
                 $columnValue = Util::lavnn($columnName, $row, '');
                 if ($columnValue != '') {
                     $output[$columnValue] = $columnValue;
                 }
             }
             $value = $output;
             break;
         case "join":
             $glue = Util::lavnn('glue', $modifierParams, '');
             $value = join(Processor::glueDecoder($glue), $value);
             break;
         case "joincolumn":
             $fieldName = Util::lavnn('field', $modifierParams, '');
             $glue = Util::lavnn('glue', $modifierParams, '');
             $rowValues = array();
             foreach ($value as $row) {
                 $fieldValue = $row[$fieldName] or '';
                 if ($fieldValue != '') {
                     $rowValues[] = $row[$fieldName];
                 }
             }
             $value = join(Processor::glueDecoder($glue), $rowValues);
             break;
         case 'replace':
             $default = Util::lavnn('default', $modifierParams, '');
             $fallback = Util::lavnn('fallback', $modifierParams, '');
             $value = Util::lavnn($fallback, $params, $default);
             break;
         case "ksort":
             ksort($value);
             break;
         case "asort":
             asort($value);
             break;
         case "sort":
             sort($value);
             break;
         case "json":
             $value = json_encode($value);
             break;
         default:
             $value = parent::calculateValue($modifierName, $modifierParams, $value, $params);
             break;
     }
     return $value;
 }
Exemplo n.º 11
0
 /**
  * Returns the modifiers used in the section
  *
  * @return array
  */
 public function getModifiers()
 {
     $lastIndent = null;
     $modifiers = array();
     if ($modiferComment = $this->getModifiersComment()) {
         $modifierLines = explode("\n", $modiferComment);
         foreach ($modifierLines as $line) {
             if (empty($line)) {
                 continue;
             }
             preg_match('/^\\s*/', $line, $matches);
             $indent = strlen($matches[0]);
             if ($lastIndent && $indent > $lastIndent) {
                 $modifier = end($modifiers);
                 $modifier->setDescription($modifier->getDescription() + trim($line));
             } else {
                 $lineParts = explode(' - ', $line);
                 $name = trim(array_shift($lineParts));
                 $description = '';
                 if (!empty($lineParts)) {
                     $description = trim(implode(' - ', $lineParts));
                 }
                 $modifier = new Modifier($name, $description);
                 // If the CSS has a markup, pass it to the modifier for the example HTML
                 if ($markup = $this->getMarkup()) {
                     $modifier->setMarkup($markup);
                 }
                 $modifiers[] = $modifier;
             }
         }
     }
     return $modifiers;
 }
Exemplo n.º 12
0
 /** @inheritdoc */
 public static function calculateValue($modifierName, $modifierParams, $value, $params = array())
 {
     return parent::calculateValue($modifierName, $modifierParams, $value, $params);
 }
Exemplo n.º 13
0
 /**
  * Add a new set of modifiers to current modifiers. If modifiers has already been
  * added for specific field, they will be overwritten.
  * @param Modifier $modifier modifier to merge into current object
  * @return Modifier
  */
 public function mergeWith($modifier)
 {
     if (is_array($modifier)) {
         $modifier = new Modifier($modifier);
     }
     if (empty($modifier)) {
         return $this;
     }
     foreach ($modifier->getFields() as $fieldName => $rule) {
         $this->_fields[$fieldName] = $rule;
     }
     return $this;
 }