示例#1
0
文件: DocBlock.php 项目: sakshika/ATM
 public function appendElement(GenericElement $element)
 {
     $name = $element->getAnnotationName();
     if (isset($this->elements[$name])) {
         if (!is_array($this->elements[$name])) {
             $this->elements[$name] = array($this->elements[$name]);
         }
         $this->elements[$name][] = $element;
         return;
     }
     $this->elements[$name] = $element;
 }
示例#2
0
 public function getIndexingFragment($pm_content, $pa_options)
 {
     if (is_array($pm_content)) {
         $pm_content = serialize($pm_content);
     }
     return parent::getIndexingFragment((int) $pm_content, $pa_options);
 }
示例#3
0
 public function asDom(\TheSeer\fDOM\fDOMDocument $ctx)
 {
     $node = parent::asDom($ctx);
     $type = $node->getAttribute('type');
     if (strpos($type, '[]')) {
         $type = mb_substr($type, 0, -2);
         $node->setAttribute('type', 'array');
         $node->setAttribute('of', $type);
     }
     if (!in_array($type, $this->types)) {
         if (!$node->hasAttribute('of')) {
             $node->setAttribute('type', 'object');
         } else {
             $node->setAttribute('of', 'object');
         }
         $parts = explode('\\', $type);
         $local = array_pop($parts);
         $namespace = join('\\', $parts);
         $class = $node->appendElementNS(self::XMLNS, 'type');
         $class->setAttribute('full', $type);
         $class->setAttribute('namespace', $namespace);
         $class->setAttribute('name', $local);
     }
     return $node;
 }
示例#4
0
 public function getIndexingFragment($pm_content, $pa_options)
 {
     if (is_array($pm_content)) {
         $pm_content = serialize($pm_content);
     }
     if ($pm_content == '') {
         return parent::getIndexingFragment($pm_content, $pa_options);
     }
     $va_return = array();
     $o_geocode_parser = new \GeocodeAttributeValue();
     $va_return[$this->getTableName() . '/' . $this->getElementCode() . '_text'] = $pm_content;
     //@see https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-geo-shape-type.html
     if ($va_coords = $o_geocode_parser->parseValue($pm_content, array())) {
         // Features and points within features are delimited by : and ; respectively. We have to break those apart first.
         if (isset($va_coords['value_longtext2']) && $va_coords['value_longtext2']) {
             $va_points = preg_split("[\\:\\;]", $va_coords['value_longtext2']);
             // fun fact: ElasticSearch expects GeoJSON -- which has pairs of longitude, latitude.
             // google maps and others usually return latitude, longitude, which is also what we store
             if (sizeof($va_points) == 1) {
                 $va_tmp = explode(',', $va_points[0]);
                 $va_return[$this->getTableName() . '/' . $this->getElementCode()] = array('type' => 'point', 'coordinates' => array((double) $va_tmp[1], (double) $va_tmp[0]));
             } elseif (sizeof($va_points) > 1) {
                 // @todo might want to index as multipolygon to break apart features?
                 $va_coordinates_for_es = array();
                 foreach ($va_points as $vs_point) {
                     $va_tmp = explode(',', $vs_point);
                     $va_coordinates_for_es[] = array((double) $va_tmp[1], (double) $va_tmp[0]);
                 }
                 $va_return[$this->getTableName() . '/' . $this->getElementCode()] = array('type' => 'polygon', 'coordinates' => $va_coordinates_for_es);
             }
         }
     }
     return $va_return;
 }
 /**
  * Load data from Request form fields.
  *
  * @todo fp> check that we are not creating a loop!
  *
  * @return boolean true if loaded data seems valid.
  */
 function load_from_request()
 {
     parent::load_from_Request();
     if (param($this->dbprefix . 'parent_ID', 'integer', -1) !== -1) {
         $this->set_from_Request('parent_ID');
     }
     return !param_errors_detected();
 }
示例#6
0
 public function getIndexingFragment($pm_content, $pa_options)
 {
     if (is_array($pm_content)) {
         $pm_content = serialize($pm_content);
     }
     if ($pm_content == '') {
         return parent::getIndexingFragment($pm_content, $pa_options);
     }
     // we index lengths as float in meters --that way we can do range searches etc.
     try {
         $o_parsed_length = caParseLengthDimension($pm_content);
         return parent::getIndexingFragment((double) $o_parsed_length->convertTo('METER', 6, 'en_US'), $pa_options);
     } catch (\Exception $e) {
         return array();
     }
 }
示例#7
0
 public function getIndexingFragment($pm_content, $pa_options)
 {
     if (is_array($pm_content)) {
         $pm_content = serialize($pm_content);
     }
     if ($pm_content == '') {
         return parent::getIndexingFragment($pm_content, $pa_options);
     }
     // we index currencys as float number and the 3-char currency code in a separate text field
     $o_curr = new \CurrencyAttributeValue();
     $va_parsed_currency = $o_curr->parseValue($pm_content, array());
     if (is_array($va_parsed_currency) && isset($va_parsed_currency['value_decimal1'])) {
         return array($this->getTableName() . '/' . $this->getElementCode() => $va_parsed_currency['value_decimal1'], $this->getTableName() . '/' . $this->getElementCode() . '_currency' => $va_parsed_currency['value_longtext1']);
     } else {
         return parent::getIndexingFragment($pm_content, $pa_options);
     }
 }
    /**
     * Insert object into DB based on previously recorded changes
     */
    function dbinsert()
    {
        global $DB;
        $DB->begin();
        if ($max_order = $DB->get_var('SELECT MAX(' . $this->dbprefix . 'order)
																			FROM ' . $this->dbtablename)) {
            // The new element order must be the lastest
            $max_order++;
        } else {
            // There are no elements in the database yet, so his order is set to 1.
            $max_order = 1;
        }
        // Set Object order:
        $this->set('order', $max_order);
        parent::dbinsert();
        $DB->commit();
    }
示例#9
0
 public function __construct($ps_table_name, $ps_element_code)
 {
     parent::__construct($ps_table_name, $ps_element_code);
 }