private function recursiveApplyTransformationToArray(array $input, Transformation $transformation)
 {
     $result = [];
     $attributes = isset($input['@attributes']) ? $input['@attributes'] : [];
     // Strip out the attributes.
     unset($input['@attributes']);
     // Run the input against the transformation test. If it passes, run
     // the actual transformation
     if ($transformation->test($input, $attributes) === true) {
         $input = $transformation->action($input, $attributes);
     }
     // Are we dealing with an associative array, or a sequential indexed array
     $isAssoc = array_is_assoc($input);
     // Iterate over each element in the array and decide if we need to move deeper
     foreach ($input as $key => $value) {
         $next = is_array($value) ? $this->recursiveApplyTransformationToArray($value, $transformation) : $value;
         // Preserve array indexes
         $isAssoc ? $result[$key] = $next : array_push($result, $value);
     }
     return $result;
 }
 /**
  * Build the transformation and output
  */
 public function execute()
 {
     if ($this->outputMode == self::OUTPUT_OFF) {
         return;
         //nothing to do
     }
     if ($this->outputMode == self::OUTPUT_XML_RAW) {
         if (!headers_sent()) {
             header("content-type: text/xml");
         }
         return $this->data;
     }
     $xml = $this->generateXML();
     $transformation = new Transformation($xml, $this->template);
     if ($this->outputMode == self::OUTPUT_XML) {
         if (!headers_sent()) {
             header("content-type: text/xml");
         }
         return $transformation->getXML();
     }
     return $transformation->execute($this->parameters);
 }
 /**
  * Factory method to create a new transformation based on a array containing
  * transformation parameters.
  *
  * The array format is:
  *
  * <code>
  * array(
  *   'query'      => 'Query string',
  *   'writer'     => 'WriterName',
  *   'source'     => 'source location',
  *   'artifact'   => 'path',
  *   'parameters' => array()
  * )
  * </code>
  *
  * The parameter array is optional.
  *
  * @param Transformer $transformer    Responsible transformer object.
  * @param mixed[]     $transformation Transformation array, see long
  *     description for the format.
  *
  * @throws \InvalidArgumentException
  *
  * @return Transformation
  */
 public static function createFromArray(Transformer $transformer, array $transformation)
 {
     // check if all required items are present
     if (!array_key_exists('query', $transformation) || !array_key_exists('writer', $transformation) || !array_key_exists('source', $transformation) || !array_key_exists('artifact', $transformation)) {
         throw new \InvalidArgumentException('Transformation array is missing elements, received: ' . var_export($transformation, true));
     }
     $transformation_obj = new Transformation($transformer, $transformation['query'], $transformation['writer'], $transformation['source'], $transformation['artifact']);
     if (isset($transformation['parameters']) && is_array($transformation['parameters'])) {
         $transformation_obj->setParameters($transformation['parameters']);
     }
     return $transformation_obj;
 }
Beispiel #4
0
 /**
  * Get the readable content for this exception
  */
 private function getContent()
 {
     $xslFile = APP_DIR . "view/" . Registry::get("PLAIN_TEXT_ERROR") . ".xsl";
     $transformation = new Transformation("<root><exceptions>" . $this->getXML() . "</exceptions></root>", $xslFile);
     return $transformation->execute();
 }
Beispiel #5
0
 function PiDigitStream()
 {
     $this->z = Transformation::Unity();
     $this->x = Transformation::Zero();
     $this->inverse = Transformation::Zero();
 }
Beispiel #6
0
 /**
  * Populates this template from an XML source.
  *
  * @param Transformer $transformer The transformer which is parent.
  * @param string      $xml         The XML definition for this template.
  *
  * @return void
  */
 public function populate(Transformer $transformer, $xml)
 {
     $xml = new \SimpleXMLElement($xml);
     $this->author = $xml->author;
     $this->version = $xml->version;
     $this->copyright = $xml->copyright;
     foreach ($xml->transformations->transformation as $transformation) {
         $transformation_obj = new Transformation($transformer, (string) $transformation['query'], (string) $transformation['writer'], (string) $transformation['source'], (string) $transformation['artifact']);
         // import generic parameters of the template
         if (isset($xml->parameters) && count($xml->parameters)) {
             $transformation_obj->importParameters($xml->parameters);
         }
         if (isset($transformation->parameters) && count($transformation->parameters)) {
             $transformation_obj->importParameters($transformation->parameters);
         }
         $this->transformations[] = $transformation_obj;
     }
 }
Beispiel #7
0
 public static function set_coord_krass()
 {
     global $db;
     //geeignete Anzahl der Abfrage wählen, damit die Berechnungen in unter 30 sekunden erfolgen können, zwischen 400 und 600 ist ein guter wert
     $result5Pegel = $db->qry(" SELECT pegelnummer,Rechtswert_GK,Hochwert_GK,lat,lon,streifenzone,ellipsoid,daten_fehler,pnp FROM " . TABLE_PEGEL2 . " WHERE `lat` = '' AND `lon` = '' AND `Rechtswert_GK` != '0.00' AND `Hochwert_GK` != '0.00' AND `ellipsoid` = 'Krassovski' ORDER BY `pegelnummer` DESC LIMIT 0, 450 ");
     if ($result5Pegel) {
         //echo 'erfolg verbindung und auswahl';
         //ins logfile schreiben
         $msg = "erfolg verbindung und auswahl";
         Log::write(LOG_OTHER, $msg);
     } else {
         echo 'fehler verbindung und auswahl';
         //ins logfile schreiben
         $msg = "fehler verbindung und auswahl";
         Log::write(LOG_OTHER, $msg);
     }
     for ($i = 0; $i < mysql_num_rows($result5Pegel); $i++) {
         while ($row5Pegel = mysql_fetch_array($result5Pegel)) {
             $pegelnummer = $row5Pegel["pegelnummer"];
             $rw = $row5Pegel["Rechtswert_GK"];
             $hw = $row5Pegel["Hochwert_GK"];
             $streifen = $row5Pegel["streifenzone"];
             $pnp = $row5Pegel["pnp"];
             //jetzt wird am leerzeichen getrennt und in ein arry geschrieben
             $avar = explode(" ", $streifen);
             //transformation mit formel
             $bvar = Transformation::GK_geo_krass($hw, $rw, $avar[1]);
             //echo '<br><br>l und b<br>';
             //var_dump($bvar);
             $cvar = Transformation::geo_krass_kart($bvar[0], $bvar[1], $pnp);
             //echo '<br><br>kart<br>';
             //var_dump($cvar);
             $dvar = Transformation::rotation_translation_krass_wgs84($cvar[0], $cvar[1], $cvar[2]);
             //echo '<br><br>nach rot und trans<br>';
             //var_dump($dvar);
             $evar = Transformation::kart_wgs84_geo($dvar[0], $dvar[1], $dvar[2]);
             //echo '<br><br>nach umwandlung<br>';
             //var_dump($evar);
             //wichtig ist php hat nur einen return wert dieser ist hier ein array also passend setzten
             $lat = $evar[0];
             $lon = $evar[1];
             $result = $db->qry(" UPDATE " . TABLE_PEGEL2 . " SET \n\tpegelnummer='{$pegelnummer}',\n\tlat='{$lat}',\n\tlon='{$lon}'\n\tWHERE pegelnummer='{$pegelnummer}' ");
             if ($result) {
                 //echo '<br><br>';
                 //echo 'erfolg update koordinaten';
                 //ins logfile schreiben
                 $msg = "erfolg update der koordinaten von pegelnummer '. {$pegelnummer} .'";
                 Log::write(LOG_OTHER, $msg);
             } else {
                 echo 'fehler bitte in sql.log nachsehen';
             }
         }
     }
 }
Beispiel #8
0
 /**
  * Transforms an array into XML.
  *
  * @param array|string ...$args Objects to transform.
  *
  * @return string
  */
 public static function xml(...$args)
 {
     return static::transform($args, Transformation::getDefault('xml'));
 }