Merge remote-tracking branch 'origin/master'

This commit is contained in:
Pootle server 2011-07-21 18:40:15 +02:00
commit 7f73cd6481
14 changed files with 233 additions and 208 deletions

View File

@ -53,6 +53,7 @@ phpMyAdmin - ChangeLog
- bug #3367993 [usability] Missing "Generate Password" button
- bug #3363221 [display] Missing Server Parameter on inline sql query
- bug #3367986 [navi] Drop field -> lost active table
- remove misleading comment on the "Rename database" interface
3.4.3.1 (2011-07-02)
- [security] Fixed possible session manipulation in swekey authentication, see PMASA-2011-5

View File

@ -404,17 +404,6 @@ if ($db != 'mysql') {
?>
</legend>
<input id="new_db_name" type="text" name="newname" size="30" class="textfield" value="" />
<?php
echo '(' . __('Command') . ': ';
/**
* @todo (see explanations above in a previous todo)
*/
//if (PMA_MYSQL_INT_VERSION >= XYYZZ) {
// echo 'RENAME DATABASE';
//} else {
echo 'INSERT INTO ... SELECT';
//}
echo ')'; ?>
</fieldset>
<fieldset class="tblFooters">
<input id="rename_db_input" type="submit" value="<?php echo __('Go'); ?>" />

View File

@ -2,7 +2,7 @@
/**
* Factory class that handles the creation of geometric objects.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
class PMA_GIS_Factory
{

View File

@ -2,7 +2,7 @@
/**
* Base class for all GIS data type classes.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
abstract class PMA_GIS_Geometry
{
@ -36,26 +36,27 @@ abstract class PMA_GIS_Geometry
*
* @param string $spatial GIS data object
* @param string $label Label for the GIS data object
* @param string $line_color Color for the GIS data object
* @param string $color Color for the GIS data object
* @param array $scale_data Array containing data related to scaling
* @param image $pdf TCPDF instance
*
* @return the modified TCPDF instance
*/
public abstract function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf);
public abstract function prepareRowAsPdf($spatial, $label, $color, $scale_data, $pdf);
/**
* Prepares the JavaScript related to a row in the GIS dataset to visualize it with OpenLayers.
* Prepares the JavaScript related to a row in the GIS dataset
* to visualize it with OpenLayers.
*
* @param string $spatial GIS data object
* @param int $srid Spatial reference ID
* @param string $label Label for the GIS data object
* @param string $point_color Color for the GIS data object
* @param array $scale_data Array containing data related to scaling
* @param string $spatial GIS data object
* @param int $srid Spatial reference ID
* @param string $label Label for the GIS data object
* @param string $color Color for the GIS data object
* @param array $scale_data Array containing data related to scaling
*
* @return the JavaScript related to a row in the GIS dataset
*/
public abstract function prepareRowAsOl($spatial, $srid, $label, $point_color, $scale_data);
public abstract function prepareRowAsOl($spatial, $srid, $label, $color, $scale_data);
/**
* Scales each row.
@ -77,9 +78,11 @@ abstract class PMA_GIS_Geometry
protected function getBoundsForOl($srid, $scale_data)
{
return 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat('
. $scale_data['minX'] . ', ' . $scale_data['minY'] . ').transform(new OpenLayers.Projection("EPSG:'
. $scale_data['minX'] . ', ' . $scale_data['minY']
. ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat('
. $scale_data['maxX'] . ', ' . $scale_data['maxY'] . ').transform(new OpenLayers.Projection("EPSG:'
. $scale_data['maxX'] . ', ' . $scale_data['maxY']
. ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()));';
}
@ -152,10 +155,53 @@ abstract class PMA_GIS_Geometry
$points_arr[] = $x;
$points_arr[] = $y;
}
unset($cordinate_arr);
}
return $points_arr;
}
/**
* Generates JavaScriipt for adding points for OpenLayers polygon.
*
* @param string $polygon points of a polygon in WKT form
* @param string $srid spatial reference id
*
* @return JavaScriipt for adding points for OpenLayers polygon
*/
protected function addPointsForOpenLayersPolygon($polygon, $srid)
{
$row = 'new OpenLayers.Geometry.Polygon(new Array(';
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
$points_arr = $this->extractPoints($polygon, null);
$row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point('
. $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= '))';
} else {
// Seperate outer and inner polygons
$parts = explode("),(", $polygon);
foreach ($parts as $ring) {
$points_arr = $this->extractPoints($ring, null);
$row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point('
. $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')), ';
}
$row = substr($row, 0, strlen($row) - 2);
}
$row .= ')), ';
return $row;
}
}
?>

View File

@ -2,7 +2,7 @@
/**
* Handles the visualization of GIS GEOMETRYCOLLECTION objects.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
{
@ -24,8 +24,8 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
public static function singleton()
{
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
$class = __CLASS__;
self::$_instance = new $class;
}
return self::$_instance;
@ -130,7 +130,7 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$type = substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
$image = $gis_obj->prepareRowAsPdf($sub_part, $label, $color, $scale_data, $pdf);
$pdf = $gis_obj->prepareRowAsPdf($sub_part, $label, $color, $scale_data, $pdf);
}
return $pdf;
}
@ -165,7 +165,8 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
}
/**
* Prepares JavaScript related to a row in the GIS dataset to visualize it with OpenLayers.
* Prepares JavaScript related to a row in the GIS dataset
* to visualize it with OpenLayers.
*
* @param string $spatial GIS GEOMETRYCOLLECTION object
* @param int $srid Spatial reference ID

View File

@ -2,7 +2,7 @@
/**
* Handles the visualization of GIS LINESTRING objects.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
class PMA_GIS_Linestring extends PMA_GIS_Geometry
{
@ -24,8 +24,8 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
public static function singleton()
{
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
$class = __CLASS__;
self::$_instance = new $class;
}
return self::$_instance;
@ -59,10 +59,10 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
{
// allocate colors
$r = hexdec(substr($line_color, 1, 2));
$g = hexdec(substr($line_color, 3, 2));
$b = hexdec(substr($line_color, 4, 2));
$color = imagecolorallocate($image, $r, $g, $b);
$red = hexdec(substr($line_color, 1, 2));
$green = hexdec(substr($line_color, 3, 2));
$blue = hexdec(substr($line_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = substr($spatial, 11, (strlen($spatial) - 12));
@ -94,10 +94,10 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
{
// allocate colors
$r = hexdec(substr($line_color, 1, 2));
$g = hexdec(substr($line_color, 3, 2));
$b = hexdec(substr($line_color, 4, 2));
$line = array('width' => 1.5, 'color' => array($r, $g, $b));
$red = hexdec(substr($line_color, 1, 2));
$green = hexdec(substr($line_color, 3, 2));
$blue = hexdec(substr($line_color, 4, 2));
$line = array('width' => 1.5, 'color' => array($red, $green, $blue));
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = substr($spatial, 11, (strlen($spatial) - 12));
@ -154,7 +154,8 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
}
/**
* Prepares JavaScript related to a row in the GIS dataset to visualize it with OpenLayers.
* Prepares JavaScript related to a row in the GIS dataset
* to visualize it with OpenLayers.
*
* @param string $spatial GIS LINESTRING object
* @param int $srid Spatial reference ID
@ -183,8 +184,9 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
$row = 'new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', '
. $point[1] . ')).transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')';

View File

@ -2,7 +2,7 @@
/**
* Handles the visualization of GIS MULTILINESTRING objects.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
{
@ -24,8 +24,8 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
public static function singleton()
{
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
$class = __CLASS__;
self::$_instance = new $class;
}
return self::$_instance;
@ -68,10 +68,10 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
{
// allocate colors
$r = hexdec(substr($line_color, 1, 2));
$g = hexdec(substr($line_color, 3, 2));
$b = hexdec(substr($line_color, 4, 2));
$color = imagecolorallocate($image, $r, $g, $b);
$red = hexdec(substr($line_color, 1, 2));
$green = hexdec(substr($line_color, 3, 2));
$blue = hexdec(substr($line_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
@ -108,10 +108,10 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
{
// allocate colors
$r = hexdec(substr($line_color, 1, 2));
$g = hexdec(substr($line_color, 3, 2));
$b = hexdec(substr($line_color, 4, 2));
$line = array('width' => 1.5, 'color' => array($r, $g, $b));
$red = hexdec(substr($line_color, 1, 2));
$green = hexdec(substr($line_color, 3, 2));
$blue = hexdec(substr($line_color, 4, 2));
$line = array('width' => 1.5, 'color' => array($red, $green, $blue));
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
@ -179,7 +179,8 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
}
/**
* Prepares JavaScript related to a row in the GIS dataset to visualize it with OpenLayers.
* Prepares JavaScript related to a row in the GIS dataset
* to visualize it with OpenLayers.
*
* @param string $spatial GIS MULTILINESTRING object
* @param int $srid Spatial reference ID
@ -213,8 +214,9 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
$points_arr = $this->extractPoints($linestring, null);
$row .= 'new OpenLayers.Geometry.LineString(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', '
. $point[1] . ')).transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')), ';

View File

@ -2,7 +2,7 @@
/**
* Handles the visualization of GIS MULTIPOINT objects.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
class PMA_GIS_Multipoint extends PMA_GIS_Geometry
{
@ -24,8 +24,8 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
public static function singleton()
{
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
$class = __CLASS__;
self::$_instance = new $class;
}
return self::$_instance;
@ -48,21 +48,21 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTIPOINT object
* @param string $label Label for the GIS MULTIPOINT object
* @param string $line_color Color for the GIS MULTIPOINT object
* @param array $scale_data Array containing data related to scaling
* @param image $image Image object
* @param string $spatial GIS MULTIPOINT object
* @param string $label Label for the GIS MULTIPOINT object
* @param string $point_color Color for the GIS MULTIPOINT object
* @param array $scale_data Array containing data related to scaling
* @param image $image Image object
*
* @return the modified image object
*/
public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
public function prepareRowAsPng($spatial, $label, $point_color, $scale_data, $image)
{
// allocate colors
$r = hexdec(substr($line_color, 1, 2));
$g = hexdec(substr($line_color, 3, 2));
$b = hexdec(substr($line_color, 4, 2));
$color = imagecolorallocate($image, $r, $g, $b);
$red = hexdec(substr($point_color, 1, 2));
$green = hexdec(substr($point_color, 3, 2));
$blue = hexdec(substr($point_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = substr($spatial, 11, (strlen($spatial) - 12));
@ -78,21 +78,21 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTIPOINT object
* @param string $label Label for the GIS MULTIPOINT object
* @param string $line_color Color for the GIS MULTIPOINT object
* @param array $scale_data Array containing data related to scaling
* @param image $pdf TCPDF instance
* @param string $spatial GIS MULTIPOINT object
* @param string $label Label for the GIS MULTIPOINT object
* @param string $point_color Color for the GIS MULTIPOINT object
* @param array $scale_data Array containing data related to scaling
* @param image $pdf TCPDF instance
*
* @return the modified TCPDF instance
*/
public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
public function prepareRowAsPdf($spatial, $label, $point_color, $scale_data, $pdf)
{
// allocate colors
$r = hexdec(substr($line_color, 1, 2));
$g = hexdec(substr($line_color, 3, 2));
$b = hexdec(substr($line_color, 4, 2));
$line = array('width' => 1.25, 'color' => array($r, $g, $b));
$red = hexdec(substr($point_color, 1, 2));
$green = hexdec(substr($point_color, 3, 2));
$blue = hexdec(substr($point_color, 4, 2));
$line = array('width' => 1.25, 'color' => array($red, $green, $blue));
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = substr($spatial, 11, (strlen($spatial) - 12));
@ -143,7 +143,8 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
}
/**
* Prepares JavaScript related to a row in the GIS dataset to visualize it with OpenLayers.
* Prepares JavaScript related to a row in the GIS dataset
* to visualize it with OpenLayers.
*
* @param string $spatial GIS MULTIPOINT object
* @param int $srid Spatial reference ID
@ -175,8 +176,9 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
$row = 'new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1]
. ')).transform(new OpenLayers.Projection("EPSG:' . $srid
. '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')';

View File

@ -2,7 +2,7 @@
/**
* Handles the visualization of GIS MULTIPOLYGON objects.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
{
@ -24,8 +24,8 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
public static function singleton()
{
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
$class = __CLASS__;
self::$_instance = new $class;
}
return self::$_instance;
@ -82,10 +82,10 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $fill_color, $scale_data, $image)
{
// allocate colors
$r = hexdec(substr($fill_color, 1, 2));
$g = hexdec(substr($fill_color, 3, 2));
$b = hexdec(substr($fill_color, 4, 2));
$color = imagecolorallocate($image, $r, $g, $b);
$red = hexdec(substr($fill_color, 1, 2));
$green = hexdec(substr($fill_color, 3, 2));
$blue = hexdec(substr($fill_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
@ -130,10 +130,10 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf)
{
// allocate colors
$r = hexdec(substr($fill_color, 1, 2));
$g = hexdec(substr($fill_color, 3, 2));
$b = hexdec(substr($fill_color, 4, 2));
$color = array($r, $g, $b);
$red = hexdec(substr($fill_color, 1, 2));
$green = hexdec(substr($fill_color, 3, 2));
$blue = hexdec(substr($fill_color, 4, 2));
$color = array($red, $green, $blue);
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
@ -154,7 +154,8 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
foreach ($inner as $inner_poly) {
$points_arr = array_merge(
$points_arr, $this->extractPoints($inner_poly, $scale_data, true)
$points_arr,
$this->extractPoints($inner_poly, $scale_data, true)
);
}
}
@ -223,7 +224,8 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
}
/**
* Prepares JavaScript related to a row in the GIS dataset to visualize it with OpenLayers.
* Prepares JavaScript related to a row in the GIS dataset
* to visualize it with OpenLayers.
*
* @param string $spatial GIS MULTIPOLYGON object
* @param int $srid Spatial reference ID
@ -257,33 +259,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
. 'new OpenLayers.Geometry.MultiPolygon(new Array(';
foreach ($polygons as $polygon) {
$row .= 'new OpenLayers.Geometry.Polygon(new Array(';
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
$points_arr = $this->extractPoints($polygon, null);
$row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= '))';
} else {
// Seperate outer and inner polygons
$parts = explode("),(", $polygon);
foreach ($parts as $ring) {
$points_arr = $this->extractPoints($ring, null);
$row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')), ';
}
$row = substr($row, 0, strlen($row) - 2);
}
$row .= ')), ';
$row .= $this->addPointsForOpenLayersPolygon($polygon, $srid);
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')), null, ' . json_encode($style_options) . '));';

View File

@ -2,7 +2,7 @@
/**
* Handles the visualization of GIS POINT objects.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
class PMA_GIS_Point extends PMA_GIS_Geometry
{
@ -24,8 +24,8 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
public static function singleton()
{
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
$class = __CLASS__;
self::$_instance = new $class;
}
return self::$_instance;
@ -48,21 +48,21 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS POINT object
* @param string $label Label for the GIS POINT object
* @param string $line_color Color for the GIS POINT object
* @param array $scale_data Array containing data related to scaling
* @param image $image Image object
* @param string $spatial GIS POINT object
* @param string $label Label for the GIS POINT object
* @param string $point_color Color for the GIS POINT object
* @param array $scale_data Array containing data related to scaling
* @param image $image Image object
*
* @return the modified image object
*/
public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
public function prepareRowAsPng($spatial, $label, $point_color, $scale_data, $image)
{
// allocate colors
$r = hexdec(substr($line_color, 1, 2));
$g = hexdec(substr($line_color, 3, 2));
$b = hexdec(substr($line_color, 4, 2));
$color = imagecolorallocate($image, $r, $g, $b);
$red = hexdec(substr($point_color, 1, 2));
$green = hexdec(substr($point_color, 3, 2));
$blue = hexdec(substr($point_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'POINT(' and trailing ')'
$point = substr($spatial, 6, (strlen($spatial) - 7));
@ -76,21 +76,21 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS POINT object
* @param string $label Label for the GIS POINT object
* @param string $line_color Color for the GIS POINT object
* @param array $scale_data Array containing data related to scaling
* @param image $pdf TCPDF instance
* @param string $spatial GIS POINT object
* @param string $label Label for the GIS POINT object
* @param string $point_color Color for the GIS POINT object
* @param array $scale_data Array containing data related to scaling
* @param image $pdf TCPDF instance
*
* @return the modified TCPDF instance
*/
public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
public function prepareRowAsPdf($spatial, $label, $point_color, $scale_data, $pdf)
{
// allocate colors
$r = hexdec(substr($line_color, 1, 2));
$g = hexdec(substr($line_color, 3, 2));
$b = hexdec(substr($line_color, 4, 2));
$line = array('width' => 1.25, 'color' => array($r, $g, $b));
$red = hexdec(substr($point_color, 1, 2));
$green = hexdec(substr($point_color, 3, 2));
$blue = hexdec(substr($point_color, 4, 2));
$line = array('width' => 1.25, 'color' => array($red, $green, $blue));
// Trim to remove leading 'POINT(' and trailing ')'
$point = substr($spatial, 6, (strlen($spatial) - 7));
@ -136,7 +136,8 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
}
/**
* Prepares JavaScript related to a row in the GIS dataset to visualize it with OpenLayers.
* Prepares JavaScript related to a row in the GIS dataset
* to visualize it with OpenLayers.
*
* @param string $spatial GIS POINT object
* @param int $srid Spatial reference ID
@ -167,9 +168,10 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
$points_arr = $this->extractPoints($point, null);
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(('
. 'new OpenLayers.Geometry.Point(' . $points_arr[0][0] . ', ' . $points_arr[0][1] . ')'
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject())),'
. ' null, ' . json_encode($style_options) . '));';
. 'new OpenLayers.Geometry.Point(' . $points_arr[0][0] . ', '
. $points_arr[0][1] . ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject())), null, '
. json_encode($style_options) . '));';
return $result;
}
}

View File

@ -2,7 +2,7 @@
/**
* Handles the visualization of GIS POLYGON objects.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
class PMA_GIS_Polygon extends PMA_GIS_Geometry
{
@ -24,8 +24,8 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
public static function singleton()
{
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c;
$class = __CLASS__;
self::$_instance = new $class;
}
return self::$_instance;
@ -77,10 +77,10 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $fill_color, $scale_data, $image)
{
// allocate colors
$r = hexdec(substr($fill_color, 1, 2));
$g = hexdec(substr($fill_color, 3, 2));
$b = hexdec(substr($fill_color, 4, 2));
$color = imagecolorallocate($image, $r, $g, $b);
$red = hexdec(substr($fill_color, 1, 2));
$green = hexdec(substr($fill_color, 3, 2));
$blue = hexdec(substr($fill_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
@ -122,10 +122,10 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf)
{
// allocate colors
$r = hexdec(substr($fill_color, 1, 2));
$g = hexdec(substr($fill_color, 3, 2));
$b = hexdec(substr($fill_color, 4, 2));
$color = array($r, $g, $b);
$red = hexdec(substr($fill_color, 1, 2));
$green = hexdec(substr($fill_color, 3, 2));
$blue = hexdec(substr($fill_color, 4, 2));
$color = array($red, $green, $blue);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
@ -206,7 +206,8 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
}
/**
* Prepares JavaScript related to a row in the GIS dataset to visualize it with OpenLayers.
* Prepares JavaScript related to a row in the GIS dataset
* to visualize it with OpenLayers.
*
* @param string $spatial GIS POLYGON object
* @param int $srid Spatial reference ID
@ -234,34 +235,9 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. 'new OpenLayers.Geometry.Polygon(new Array(';
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
$points_arr = $this->extractPoints($polygon, null);
$row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= '))';
} else {
// Seperate outer and inner polygons
$parts = explode("),(", $polygon);
foreach ($parts as $ring) {
$points_arr = $this->extractPoints($ring, null);
$row .= 'new OpenLayers.Geometry.LinearRing(new Array(';
foreach ($points_arr as $point) {
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject()), ';
}
$row = substr($row, 0, strlen($row) - 2);
$row .= ')), ';
}
$row = substr($row, 0, strlen($row) - 2);
}
$row .= ')), null, ' . json_encode($style_options) . '));';
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(';
$row .= $this->addPointsForOpenLayersPolygon($polygon, $srid);
$row .= 'null, ' . json_encode($style_options) . '));';
return $row;
}

View File

@ -2,7 +2,7 @@
/**
* Generates the JavaScripts needed to visualize GIS data.
*
* @package phpMyAdmin
* @package phpMyAdmin-GIS
*/
class PMA_GIS_Visualization
{
@ -74,6 +74,8 @@ class PMA_GIS_Visualization
/**
* All the variable initialization, options handling has to be done here.
*
* @return nothing
*/
protected function init()
{
@ -83,6 +85,8 @@ class PMA_GIS_Visualization
/**
* A function which handles passed parameters. Useful if desired
* chart needs to be a little bit different from the default one.
*
* @return nothing
*/
private function _handleOptions()
{
@ -121,6 +125,8 @@ class PMA_GIS_Visualization
* @param string $file_name file name
* @param string $type mime type
* @param string $ext extension of the file
*
* @return nothing
*/
private function _toFile($file_name, $type, $ext)
{
@ -179,6 +185,8 @@ class PMA_GIS_Visualization
* Saves as a SVG image to a file.
*
* @param string $file_name File name
*
* @return nothing
*/
public function toFileAsSvg($file_name)
{
@ -201,7 +209,10 @@ class PMA_GIS_Visualization
// fill the background
$bg = imagecolorallocate($image, 229, 229, 229);
imagefilledrectangle($image, 0, 0, $this->_settings['width'] - 1, $this->_settings['height'] - 1, $bg);
imagefilledrectangle(
$image, 0, 0, $this->_settings['width'] - 1,
$this->_settings['height'] - 1, $bg
);
$scale_data = $this->_scaleDataSet($this->_data);
$image = $this->_prepareDataSet($this->_data, 0, $scale_data, 'png', $image);
@ -234,6 +245,8 @@ class PMA_GIS_Visualization
* Saves as a PNG image to a file.
*
* @param string $file_name File name
*
* @return nothing
*/
public function toFileAsPng($file_name)
{
@ -260,6 +273,8 @@ class PMA_GIS_Visualization
* Saves as a PDF to a file.
*
* @param string $file_name File name
*
* @return nothing
*/
public function toFileAsPdf($file_name)
{

View File

@ -19,16 +19,20 @@ class PMA_getIcon_test extends PHPUnit_Framework_TestCase{
$GLOBALS['cfg']['PropertiesIconic'] = false;
$this->assertEquals('<span class="nowrap"></span>',
PMA_getIcon('b_comment.png') );
$this->assertEquals(
'<span class="nowrap"></span>',
PMA_getIcon('b_comment.png')
);
}
function testGetIconWithPropertiesIconic(){
$GLOBALS['cfg']['PropertiesIconic'] = true;
$this->assertEquals('<span class="nowrap"><img src="themes/dot.gif" title="" alt="" class="icon ic_b_comment" /></span>',
PMA_getIcon('b_comment.png') );
$this->assertEquals(
'<span class="nowrap"><img src="themes/dot.gif" title="" alt="" class="icon ic_b_comment" /></span>',
PMA_getIcon('b_comment.png')
);
}
function testGetIconAlternate(){
@ -36,9 +40,11 @@ class PMA_getIcon_test extends PHPUnit_Framework_TestCase{
$GLOBALS['cfg']['PropertiesIconic'] = true;
$alternate_text = 'alt_str';
$this->assertEquals('<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text
. '" class="icon ic_b_comment" /></span>',
PMA_getIcon('b_comment.png',$alternate_text) );
$this->assertEquals(
'<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text
. '" class="icon ic_b_comment" /></span>',
PMA_getIcon('b_comment.png', $alternate_text)
);
}
function testGetIconWithContainer(){
@ -46,9 +52,11 @@ class PMA_getIcon_test extends PHPUnit_Framework_TestCase{
$GLOBALS['cfg']['PropertiesIconic'] = true;
$alternate_text = 'alt_str';
$this->assertEquals('<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text
. '" class="icon ic_b_comment" /></span>',
PMA_getIcon('b_comment.png',$alternate_text, true) );
$this->assertEquals(
'<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text
. '" class="icon ic_b_comment" /></span>',
PMA_getIcon('b_comment.png', $alternate_text, true)
);
}
@ -57,9 +65,11 @@ class PMA_getIcon_test extends PHPUnit_Framework_TestCase{
$GLOBALS['cfg']['PropertiesIconic'] = true;
$alternate_text = 'alt_str';
$this->assertEquals('<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text
. '" class="icon ic_b_comment" /> ' . $alternate_text . '</span>',
PMA_getIcon('b_comment.png',$alternate_text, true, true) );
$this->assertEquals(
'<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text
. '" class="icon ic_b_comment" /> ' . $alternate_text . '</span>',
PMA_getIcon('b_comment.png', $alternate_text, true, true)
);
}
}

View File

@ -21,7 +21,9 @@ class PMA_showPHPDocu_test extends PHPUnit_Framework_TestCase
$target = "docu";
$lang = _pgettext('PHP documentation language', 'en');
$expected = '<a href="http://php.net/manual/' . $lang . '/' . $target . '" target="documentation"><img class="icon ic_b_help_s" src="themes/dot.gif" alt="' . __('Documentation') . '" title="' . __('Documentation') . '" /></a>';
$expected = '<a href="http://php.net/manual/' . $lang . '/' . $target
. '" target="documentation"><img class="icon ic_b_help_s" src="themes/dot.gif" alt="'
. __('Documentation') . '" title="' . __('Documentation') . '" /></a>';
$this->assertEquals($expected, PMA_showPHPDocu($target));
}
@ -32,7 +34,8 @@ class PMA_showPHPDocu_test extends PHPUnit_Framework_TestCase
$target = "docu";
$lang = _pgettext('PHP documentation language', 'en');
$expected = '[<a href="http://php.net/manual/' . $lang . '/' . $target . '" target="documentation">' . __('Documentation') . '</a>]';
$expected = '[<a href="http://php.net/manual/' . $lang . '/' . $target
. '" target="documentation">' . __('Documentation') . '</a>]';
$this->assertEquals($expected, PMA_showPHPDocu($target));
}