User: ejonker Date: 11-1-2015 Time: 18:54
Пример #1
0
 /**
  * 
  * @param Context $context
  */
 public function handle(Context $context)
 {
     $string = new StringExpr();
     $string->handle($context);
     $this->key = $string->getResult();
     $nameSeparator = new StructuralChar(array(":"));
     $nameSeparator->handle($context);
     $value = new Value();
     $value->handle($context);
     $this->value = $value->getResult();
 }
Пример #2
0
 /**
  * Set Contains comparison.
  *
  * @param Value $value Value object to compare against
  *
  * @return boolean
  */
 public function setContains(Value $value)
 {
     if (is_array($value->getValue())) {
         foreach ($this->value as $val) {
             if ($val instanceof Set && $val == $value->getSet()) {
                 return true;
             }
         }
         return false;
     }
     return in_array($value->getValue(), $this->value);
 }
Пример #3
0
 private function processSquareBracket($token)
 {
     $parser = new Value($this->baseData, $this->autoLookup);
     if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) {
         $this->callTransphpormFunctions($token);
     } else {
         if ($this->last !== null) {
             $this->data->traverse($this->last);
         }
         $this->last = $parser->parseTokens($token['value'], null)[0];
     }
 }
Пример #4
0
 /**
  * 
  * @param Context $context
  * @throws DecodeException
  */
 public function handle(Context $context)
 {
     $ws = WS::getInstance();
     $ws->handle($context);
     $value = new Value();
     $value->handle($context);
     $ws->handle($context);
     if ($context->hasNext()) {
         $current = $context->current();
         $context->throwException("Unexpected character('{$current}')");
     }
     $this->result = $value->getResult();
 }
Пример #5
0
 function __construct($method, $args)
 {
     $this->method = $method;
     $this->args = $args;
     $this->xml = '<?xml version="1.0" encoding="utf-8" ?><methodCall><methodName>' . $this->method . '</methodName><params>';
     foreach ($this->args as $arg) {
         $this->xml .= '<param><value>';
         $v = new Value($arg);
         $this->xml .= $v->getXml();
         $this->xml .= '</value></param>' . LF;
     }
     $this->xml .= '</params></methodCall>';
 }
Пример #6
0
 function parse($value)
 {
     if ($value == 'inherit') {
         return CSS_PROPERTY_INHERIT;
     }
     $value = trim(strtolower($value));
     switch (strtolower($value)) {
         case "xx-small":
             return Value::fromData(BASE_FONT_SIZE_PT * 3 / 5, UNIT_PT);
         case "x-small":
             return Value::fromData(BASE_FONT_SIZE_PT * 3 / 4, UNIT_PT);
         case "small":
             return Value::fromData(BASE_FONT_SIZE_PT * 8 / 9, UNIT_PT);
         case "medium":
             return Value::fromData(BASE_FONT_SIZE_PT, UNIT_PT);
         case "large":
             return Value::fromData(BASE_FONT_SIZE_PT * 6 / 5, UNIT_PT);
         case "x-large":
             return Value::fromData(BASE_FONT_SIZE_PT * 3 / 2, UNIT_PT);
         case "xx-large":
             return Value::fromData(BASE_FONT_SIZE_PT * 2 / 1, UNIT_PT);
     }
     switch (strtolower($value)) {
         case "larger":
             return Value::fromData(1.2, UNIT_EM);
         case "smaller":
             return Value::fromData(0.83, UNIT_EM);
             // 0.83 = 1/1.2
     }
     if (preg_match("/(\\d+\\.?\\d*)%/i", $value, $matches)) {
         return Value::fromData($matches[1] / 100, UNIT_EM);
     }
     return Value::fromString($value);
 }
function units2pt($value, $font_size = null)
{
    $unit = Value::unit_from_string($value);
    switch ($unit) {
        case UNIT_PT:
            return pt2pt((double) $value);
        case UNIT_PX:
            return px2pt((double) $value);
        case UNIT_MM:
            return pt2pt(mm2pt((double) $value));
        case UNIT_CM:
            return pt2pt(mm2pt((double) $value * 10));
        case UNIT_EM:
            return em2pt((double) $value, $font_size);
        case UNIT_EX:
            return ex2pt((double) $value, $font_size);
        case UNIT_IN:
            return pt2pt((double) $value * 72);
            // points used by CSS 2.1 are equal to 1/72nd of an inch.
        // points used by CSS 2.1 are equal to 1/72nd of an inch.
        case UNIT_PC:
            return pt2pt((double) $value * 12);
            // 1 pica equals to 12 points.
        // 1 pica equals to 12 points.
        default:
            global $g_config;
            if ($g_config['mode'] === 'quirks') {
                return px2pt((double) $value);
            } else {
                return 0;
            }
    }
}
Пример #8
0
 /**
  * Get the properties of the object.
  * 
  * @return  array of key-value pairs.
  * 
  * @since  __DEPLOY_VERSION__
  */
 public function getProperties()
 {
     $properties = parent::getProperties();
     // Unset the properties we don't want to expose.
     unset($properties['raisedon']);
     return $properties;
 }
 function parse($value)
 {
     if ($value == 'inherit') {
         return CSS_PROPERTY_INHERIT;
     }
     return Value::fromString($value);
 }
 function BoxNoteCall(&$content, &$pipeline)
 {
     $this->GenericInlineBox();
     $this->_note_content =& $content;
     $this->copy_style($content);
     $this->put_height_constraint(new HCConstraint(null, null, null));
     /**
      * Prepare ::note-call box
      */
     $this->_note_call_box = InlineBox::create_from_text(CSSListStyleType::format_number(LST_DECIMAL, 99), WHITESPACE_NORMAL, $pipeline);
     $this->_note_call_box->copy_style($content);
     $this->_note_call_box->content[0]->copy_style($content);
     $font = $this->_note_call_box->content[0]->getCSSProperty(CSS_FONT);
     $font = $font->copy();
     $font->size->scale(0.75);
     $this->_note_call_box->content[0]->setCSSProperty(CSS_FONT, $font);
     $this->_note_call_box->content[0]->setCSSProperty(CSS_VERTICAL_ALIGN, VA_SUPER);
     $this->_note_call_box->content[0]->setCSSProperty(CSS_LINE_HEIGHT, CSS::getDefaultValue(CSS_LINE_HEIGHT));
     /**
      * Prepare ::marker box
      */
     $this->_note_marker_box = InlineBox::create_from_text(CSSListStyleType::format_number(LST_DECIMAL, 99), WHITESPACE_NORMAL, $pipeline);
     $this->_note_marker_box->copy_style($content);
     $this->_note_marker_box->content[0]->copy_style($content);
     $font = $this->_note_marker_box->content[0]->getCSSProperty(CSS_FONT);
     $font = $font->copy();
     $font->size->scale(0.5);
     $this->_note_marker_box->content[0]->setCSSProperty(CSS_FONT, $font);
     $margin = $this->_note_marker_box->content[0]->getCSSProperty(CSS_MARGIN);
     $margin = $margin->copy();
     $margin->right = Value::fromData(FOOTNOTE_MARKER_MARGIN, UNIT_PT);
     $this->_note_marker_box->content[0]->setCSSProperty(CSS_MARGIN, $margin);
     $this->_note_marker_box->content[0]->setCSSProperty(CSS_VERTICAL_ALIGN, VA_SUPER);
     $this->_note_marker_box->content[0]->setCSSProperty(CSS_LINE_HEIGHT, CSS::getDefaultValue(CSS_LINE_HEIGHT));
 }
Пример #11
0
 /**
  * @see DataPermissionInterface::__construct()
  * @param string type
  * @param integer $id
  */
 function __construct($type, $id)
 {
     if (is_numeric($id) and $type) {
         $this->type = $type;
         switch ($type) {
             case "file":
                 $this->id = $id;
                 $this->object = File::get_instance($id);
                 break;
             case "value":
                 $this->id = $id;
                 $this->object = Value::get_instance($id);
                 break;
             case "parameter":
                 $this->id = $id;
                 $this->object = Parameter::get_instance($id);
                 break;
             case "folder":
                 $this->id = $id;
                 $this->object = Folder::get_instance($id);
                 break;
         }
         $this->automatic = $this->object->get_automatic();
         $this->permission = $this->object->get_permission();
         $this->owner_id = $this->object->get_owner_id();
         $this->owner_group_id = $this->object->get_owner_group_id();
     } else {
         $this->id = null;
         $this->object = null;
     }
 }
Пример #12
0
 public function __construct($node, $parent)
 {
     parent::__construct($node, $parent);
     self::$possible_attributes = array_merge(parent::$possible_attributes, self::$possible_attributes);
     self::$required_attributes = array_merge(parent::$required_attributes, self::$required_attributes);
     self::$possible_children = array_merge(parent::$possible_children, self::$possible_children);
     self::$required_children = array_merge(parent::$required_children, self::$required_children);
 }
Пример #13
0
 /**
  * Check for equality of this event against another event.
  * 
  * This overrides the generic equality test because we want to
  * include the requestedon timestamp too.
  * 
  * @param   Value  $other  Another value object to compare with this one.
  * 
  * @return  boolean
  * 
  * @since  __DEPLOY_VERSION__
  */
 public function equals(Value $other)
 {
     // Must have occurred at the same time.
     if ($this->requestedon != $other->requestedon) {
         return false;
     }
     return parent::equals($other);
 }
Пример #14
0
 public function __construct($aComponents = array(), $sSeparator = ',', $iLineNo = 0)
 {
     parent::__construct($iLineNo);
     if (!is_array($aComponents)) {
         $aComponents = array($aComponents);
     }
     $this->aComponents = $aComponents;
     $this->sSeparator = $sSeparator;
 }
 function parse($value)
 {
     $value = trim($value);
     if ($value === 'inherit') {
         return CSS_PROPERTY_INHERIT;
     }
     if ($value === 'normal') {
         return $this->_default_value;
     }
     return Value::fromString($value);
 }
Пример #16
0
 /**
  * A widget containing text (essentially just a div or span with text)
  * @param string $text The text to display
  * @param boolean $inline Determines if the widget should be span(true) or div(false)
  * @param string $id The HTML #id of the element
  * @param string $class The HTML .class of element
  * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended)
  **/
 public function __construct($text = EMPTYSTRING, $inline = false, $id = null, $class = null, $args = null)
 {
     HtmlAttributes::Assure($args);
     if (Value::SetAndNotNull($id)) {
         $args->Add('id', $id);
     }
     if (Value::SetAndNotNull($class)) {
         $args->Add('class', $class);
     }
     $tag = $inline ? 'span' : 'div';
     parent::__construct($tag, $args, $text);
 }
 function parse_value($value)
 {
     switch (strtolower($value)) {
         case 'thin':
             return Value::fromString('1px');
         case 'medium':
             return Value::fromString('3px');
         case 'thick':
             return Value::fromString('5px');
         default:
             return Value::fromString($value);
     }
 }
Пример #18
0
 /**
  * 
  * @param Context $context
  */
 public function handle(Context $context)
 {
     $beginArray = new StructuralChar(array("["));
     $beginArray->handle($context);
     if ($context->current() === "]") {
         $endArray = new StructuralChar(array("]"));
         $endArray->handle($context);
         $this->result = array();
         return;
     }
     $result = array();
     while (true) {
         $value = new Value();
         $value->handle($context);
         $result[] = $value->getResult();
         $struct = new StructuralChar(array(",", "]"));
         $struct->handle($context);
         if ($struct->getResult() === "]") {
             $this->result = $result;
             break;
         }
     }
 }
Пример #19
0
 function init($data)
 {
     $len = strlen($data);
     $is_percentage = false;
     if ($len > 0) {
         $is_percentage = $data[$len - 1] === '%';
     }
     $value = new MarginSideValue();
     $value->_units = Value::fromString($data);
     $value->value = $data;
     $value->percentage = $is_percentage ? (int) $data : null;
     $value->auto = $data === 'auto';
     return $value;
 }
 /**
  * @return array
  */
 public function getParameters()
 {
     $params = [];
     if (is_array($v = $this->value->getValue()) && $this->value->getOperator() === 'BETWEEN') {
         foreach ($v as $index => $value) {
             $params[$this->value->getParameterKey($index)] = $value;
         }
     } elseif ($this->value->getOperator() === 'IS') {
         // conitnue...
     } elseif ($this->value->getOperator() === 'INSTANCE OF') {
         // conitnue...
     } else {
         $params[$this->value->getParameterKey()] = $this->value->getValue();
     }
     return $params;
 }
Пример #21
0
 public function __tostring()
 {
     $result = EMPTYSTRING;
     if (Value::SetAndNotNull($this->_list) && is_array($this->_list)) {
         ksort($this->_list);
         foreach ($this->_list as $key => $val) {
             if (strstr(BOOLEANPARAMETERS, '|' . $key . '|') && $val == true) {
                 $result .= RTK_SINGLESPACE . $key;
             } else {
                 $result .= RTK_SINGLESPACE . $key . '="' . $val . '"';
             }
         }
     }
     return $result;
 }
 /**
  * Optimization: width/color fields of this class
  * never modified partially, so we could use one shared object 
  * as a default value
  */
 function EdgePDF()
 {
     static $default_width = null;
     if (is_null($default_width)) {
         $default_width =& Value::fromData(0, UNIT_PT);
     }
     static $default_color = null;
     if (is_null($default_color)) {
         $default_color =& new Color(array(0, 0, 0), true);
     }
     $this->width =& $default_width;
     $this->color =& $default_color;
     $this->style = BS_NONE;
     $this->_isDefaultColor = true;
 }
Пример #23
0
 public function html_display($result)
 {
     $result = parent::html_display($result);
     if (Value::get(get_class($this) . '_commented', true) && Component::isActive('Comment')) {
         if ($result instanceof DBObject) {
             $comments = Comment::getComments($result->getMeta('table'), $result->getMeta('id'));
             Backend::addContent(Render::renderFile('comments.tpl.php', array('comment_list' => $comments)));
             if (Permission::check('create', 'comment')) {
                 $values = array('foreign_table' => $result->getMeta('table'), 'foreign_id' => $result->getMeta('id'));
                 Backend::addContent(Render::renderFile('comment.add.tpl.php', $values));
             }
         }
     }
     return $result;
 }
Пример #24
0
 /**
  * @param Node|array $data
  * @return static
  */
 public function set($data)
 {
     if (!$this->fullNode($data)) {
         $items = [];
         foreach ($data as $n => $i) {
             if ($this->fullNode($i)) {
                 $items[] = Operator::bin(Identifier::node($n), '=', $i);
             } else {
                 $items[] = Operator::bin(Identifier::node($n), '=', Value::node($i));
             }
         }
         $data = Enum::expr($items);
     }
     $this->data = $data;
     return $this;
 }
Пример #25
0
 /**
  * @param integer $value_id
  * @param integer $type_id
  * @param integer $folder_id
  * @param array $value_obj_content_array
  */
 function __construct($value_id = null, $type_id = null, $folder_id = null, $value_obj_content_array = null)
 {
     if ($value_id) {
         $value_obj = Value::get_instance($value_id);
         if (is_array($value_obj_content_array)) {
             $value_obj->set_content_array($value_obj_content_array);
         }
         $this->shape_array = $value_obj->get_value_shape();
         $this->content_array = $value_obj->get_value_content(false);
     } elseif ($type_id) {
         $value_obj = Value::get_instance(null);
         if (is_array($value_obj_content_array)) {
             $value_obj->set_content_array($value_obj_content_array);
         }
         $this->shape_array = $value_obj->get_value_shape($type_id, $folder_id);
         $this->content_array = $value_obj->get_value_content(false, $type_id, $folder_id);
     }
 }
 function &_fromString($value, &$class_object)
 {
     if ($value == 'inherit') {
         $dummy = CSS_PROPERTY_INHERIT;
         return $dummy;
     }
     if ($value == 'auto' || $value == '') {
         $class_object->init(null, VALUE_AUTO);
         return $class_object;
     }
     $strlen = strlen($value);
     if ($value[$strlen - 1] == '%') {
         $class_object->init((double) $value, VALUE_PERCENTAGE);
         return $class_object;
     }
     $class_object->init(Value::fromString($value), VALUE_NORMAL);
     return $class_object;
 }
Пример #27
0
 private function processSquareBracket($token)
 {
     $parser = new Value($this->baseData, $this->autoLookup);
     if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) {
         $this->callTransphpormFunctions($token);
     } else {
         if ($this->last !== null) {
             $this->data->traverse($this->last);
         } else {
             $lastResult = $this->result->pop();
             if ($lastResult) {
                 $this->data = new ValueData($lastResult);
             }
         }
         $this->last = $parser->parseTokens($token['value'], null)[0];
         if (!is_bool($this->last)) {
             $this->traversing = true;
         }
     }
 }
Пример #28
0
 /**
  * Add a text input field to the form
  * @param string $name The HTML name (and #id) of the input field
  * @param string $title The text written next to the input field
  * @param string $value The predefined value in the input field
  * @param integer $size How many rows the input field should span
  * @param HtmlElement $container (optional) The "container" to add it to
  **/
 public function AddTextField($name, $title, $value = null, $size = null, $container = null)
 {
     $args = new HtmlAttributes();
     $args->Add('name', $name);
     $args->Add('id', $name);
     $line = new HtmlElement('div', array('class' => 'formline'));
     $line->AddChild(new HtmlElement('label', array('for' => $name), $title));
     $group = new HtmlElement('div', array('class' => 'formgroup'));
     if ($size == null || intval($size) <= 0) {
         $args->Add('type', 'text');
         if (Value::SetAndNotNull($value)) {
             $args->Add('value', $value);
         }
         $group->AddChild(new HtmlElement('input', $args));
     } else {
         $args->Add('rows', $size);
         $group->AddChild(new HtmlElement('textarea', $args, $value));
     }
     $line->AddChild($group);
     $this->AddToContainer($line, $container);
 }
Пример #29
0
 function doInherit(&$state)
 {
     if ($state->get_propertyDefaultFlag(CSS_FONT_SIZE)) {
         $this->size = Value::fromData(1, UNIT_EM);
     }
     if ($this->style === CSS_PROPERTY_INHERIT) {
         $this->style = $state->getInheritedProperty(CSS_FONT_STYLE);
     }
     if ($this->weight === CSS_PROPERTY_INHERIT) {
         $this->weight = $state->getInheritedProperty(CSS_FONT_WEIGHT);
     }
     if ($this->size === CSS_PROPERTY_INHERIT) {
         $size = $state->getInheritedProperty(CSS_FONT_SIZE);
         $this->size = $size->copy();
     }
     if ($this->family === CSS_PROPERTY_INHERIT) {
         $this->family = $state->getInheritedProperty(CSS_FONT_FAMILY);
     }
     if ($this->line_height === CSS_PROPERTY_INHERIT) {
         $this->line_height = $state->getInheritedProperty(CSS_LINE_HEIGHT);
     }
 }
Пример #30
0
 public static function Insert($message, $recipe, $id = EMPTYSTRING)
 {
     $result = false;
     if (Site::HasHttps() && Login::IsLoggedIn()) {
         if (Value::SetAndNotEmpty($message) && Value::SetAndNotNull($recipe)) {
             $path = 'R=' . $recipe;
             if ($id != EMPTYSTRING) {
                 if ($stmt = Database::GetLink()->prepare('SELECT `comment_path` FROM `Comment` WHERE `comment_path` LIKE ?;')) {
                     $stmt->bindParam(1, $path, PDO::PARAM_STR, 255);
                     $stmt->execute();
                     $stmt->bindColumn(1, $result);
                     $stmt->fetch();
                     $stmt->closeCursor();
                     if ($result != null && _string::StartsWith($result, $path)) {
                         $path = $result . '>' . $id;
                     } else {
                         $path = null;
                     }
                 }
             }
             if ($path != null) {
                 $userid = Login::GetId();
                 $timestamp = time();
                 if ($stmt = Database::GetLink()->prepare('INSERT INTO `Comment` (`user_id`, `comment_path`, `comment_contents`, `sent_at`) VALUES (?, ?, ?, ?);')) {
                     $stmt->bindParam(1, $userid, PDO::PARAM_INT);
                     $stmt->bindParam(2, $path, PDO::PARAM_STR, 255);
                     $stmt->bindParam(3, $message, PDO::PARAM_STR, 255);
                     $stmt->bindParam(4, $timestamp, PDO::PARAM_INT);
                     $stmt->execute();
                     $stmt->closeCursor();
                 }
             }
         }
     }
     return $result;
 }