Beispiel #1
0
 /**
  * String multiplication.
  * this is repeated other times
  * @param sassNumber the number of times to repeat this
  * @return sassString the string result
  */
 public function op_times($other)
 {
     if (!$other instanceof SassNumber || !$other->isUnitless()) {
         throw new SassStringException('{what} must be a {type}', array('{what}' => Phamlp::t('sass', 'Value'), '{type}' => Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
     }
     $this->value = str_repeat($this->value, $other->value);
     return $this;
 }
Beispiel #2
0
 /**
  * Parse this node.
  * This raises an error.
  * @return array An empty array
  */
 public function parse($context)
 {
     if (!$this->warning || $this->root->parser->quiet === false) {
         set_error_handler(array($this, 'errorHandler'));
         trigger_error($this->warning ? $this->interpolate(Phamlp::t('sass', $this->message, $this->params), $context) : $this->evaluate(Phamlp::t('sass', $this->message, $this->params), $context)->toString());
         restore_error_handler();
     }
     return array();
 }
Beispiel #3
0
 /**
  * Takes the modulus (remainder) of this value divided by the value of other
  * 
  * @param
  *        	string value to divide by
  * @return mixed SassNumber if other is a SassNumber or
  *         SassColour if it is a SassColour
  */
 public function op_modulo($other)
 {
     if (!$other instanceof SassNumber || !$other->isUnitless()) {
         throw new SassNumberException('{what} must be a {type}', array('{what}' => Phamlp::t('sass', 'Number'), '{type}' => Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
     }
     $this->value %= $this->convert($other)->value;
     return $this;
 }
Beispiel #4
0
 /**
  * Asserts that the value of a literal is within the expected range 
  * @param SassLiteral the literal to test
  * @param float the minimum value
  * @param float the maximum value
  * @param string the units.
  * @throws SassScriptFunctionException if value is not the expected type
  */
 public static function assertInRange($literal, $min, $max, $units = '')
 {
     if ($literal->value < $min || $literal->value > $max) {
         throw new SassScriptFunctionException('{what} must be {inRange}', array('{what}' => $literal->typeOf, '{inRange}' => Phamlp::t('sass', 'between {min} and {max} inclusive', array('{min}' => $min . $units, '{max}' => $max . $units))), SassScriptParser::$context->node);
     }
 }
Beispiel #5
0
 /**
  * Colour bitwise Shift Right
  * @param sassNumber amount to shift right by
  * @return sassColour the colour result
  */
 public function op_shiftr($other)
 {
     if (!$other instanceof SassNumber || !$other->isUnitless()) {
         throw new SassColourException('{what} must be a {type}', array('{what}' => Phamlp::t('sass', 'Number'), '{type}' => Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
     }
     $this->red = $this->getRed() >> $other->value;
     $this->green = $this->getGreen() >> $other->value;
     $this->blue = $this->getBlue() >> $other->value;
     return $this;
 }
Beispiel #6
0
 /**
  * Phamlp Exception.
  * 
  * @param
  *        	string Category (haml|sass)
  * @param
  *        	string Exception message
  * @param
  *        	array parameters to be applied to the message using <code>strtr</code>.
  */
 public function __construct($category, $message, $params, $object)
 {
     parent::__construct(Phamlp::t($category, $message, $params) . (is_object($object) ? ": {$object->filename}::{$object->line}\nSource: {$object->source}" : ''));
 }
Beispiel #7
0
 /**
  * HamlParser constructor.
  * @param array options
  * @return HamlParser
  */
 public function __construct($options = array())
 {
     if (isset($options['language'])) {
         Phamlp::$language = $options['language'];
         unset($options['language']);
     }
     foreach ($options as $name => $value) {
         $this->{$name} = $value;
     }
     // foreach
     if ($this->ugly) {
         $this->style = 'compressed';
     }
     $this->format = strtolower($this->format);
     if (is_null($this->doctype) && !array_key_exists($this->format, $this->doctypes)) {
         throw new HamlException('Invalid {what} ({value}). Must be one of "{options}"', array('{what}' => 'format', '{value}' => $this->format, '{options}' => join(', ', array_keys($this->doctypes))), $this);
     }
     $this->showSource = $this->debug & HamlParser::DEBUG_SHOW_SOURCE;
     $this->showOutput = $this->debug & HamlParser::DEBUG_SHOW_OUTPUT;
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'HamlHelpers.php';
     if (isset($this->helperFile)) {
         require_once $this->helperFile;
         $this->helperClass = basename($this->helperFile, ".php");
         if (!is_subclass_of($this->helperClass, 'HamlHelpers')) {
             throw new HamlException('{what} must extend {base} class', array('{what}' => $this->helperClass, '{base}' => 'HamlHelpers'), $this);
         }
     }
 }
Beispiel #8
0
 /**
  * Constructor.
  * Sets parser options
  * @param array $options
  * @return SassParser
  */
 public function __construct($options = array())
 {
     if (!is_array($options)) {
         throw new SassException('{what} must be a {type}', array('{what}' => 'options', '{type}' => 'array'));
     }
     if (!empty($options['language'])) {
         Phamlp::$language = $options['language'];
     }
     if (!empty($options['extensions'])) {
         foreach ($options['extensions'] as $extension => $extOptions) {
             include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . $extension . DIRECTORY_SEPARATOR . 'config.php';
             $configClass = 'SassExtentions' . $extension . 'Config';
             $config = new $configClass();
             $config->config($extOptions);
             $lp = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . $extension . DIRECTORY_SEPARATOR . 'frameworks';
             $fp = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . $extension . DIRECTORY_SEPARATOR . 'functions';
             $options['load_paths'] = empty($options['load_paths']) ? array($lp) : array_merge($options['load_paths'], $lp);
             $options['function_paths'] = empty($options['function_paths']) ? array($fp) : array_merge($options['function_paths'], $fp);
         }
     }
     if (!empty($options['vendor_properties'])) {
         if ($options['vendor_properties'] === true) {
             $this->vendor_properties = $this->_vendorProperties;
         } elseif (is_array($options['vendor_properties'])) {
             $this->vendor_properties = array_merge($this->_vendorProperties, $options['vendor_properties']);
         }
     }
     unset($options['language'], $options['vendor_properties']);
     $defaultOptions = array('cache' => self::CACHE, 'cache_location' => dirname(__FILE__) . DIRECTORY_SEPARATOR . self::CACHE_LOCATION, 'css_location' => dirname(__FILE__) . DIRECTORY_SEPARATOR . self::CSS_LOCATION, 'debug_info' => false, 'filename' => array('dirname' => '', 'basename' => ''), 'function_paths' => array(), 'load_paths' => array(dirname(__FILE__) . DIRECTORY_SEPARATOR . self::TEMPLATE_LOCATION), 'line' => 1, 'line_numbers' => false, 'style' => SassRenderer::STYLE_NESTED, 'syntax' => SassFile::SASS);
     foreach (array_merge($defaultOptions, $options) as $name => $value) {
         if (property_exists($this, $name)) {
             $this->{$name} = $value;
         }
     }
 }