]> dev.renevier.net Git - syp.git/commitdiff
small code cleanup (indentation, missing copyrights, etc)
authorarno <arenevier@fdn.fr>
Sat, 25 Jul 2009 17:22:53 +0000 (19:22 +0200)
committerarno <arenevier@fdn.fr>
Sun, 26 Jul 2009 15:39:10 +0000 (17:39 +0200)
api.php
inc/i10n/en/syp.php
inc/i10n/updatelang.php
inc/langutils.php
items.php
js/syp.js
logout.php
media/admin.css
news.php

diff --git a/api.php b/api.php
index 6ed26c9712435eec3dad280935df78b5c4023c65..50e8bfe3cfa2cc5cc1fad902cc24cde9757d03e8 100644 (file)
--- a/api.php
+++ b/api.php
@@ -116,6 +116,9 @@ function img_check_upload ($file) {
 }
 
 function delete_image_if_unused ($imgpath, $con) {
+    if (!isset ($imgpath) || (strlen ($imgpath) == 0)) {
+        return;
+    }
     if ($con->imgpath_exists ($imgpath)) {
         return false;
     }
index 55e66bbc186c83e0b23f2f822de05e7a53cfdfaa..4d965ea29a9ea746a6fbb0ff1cb953ed9ef4e8b3 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+/* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
+   license. */
+
     $translations['en'] = array(
         // your name
         "_translator_name" => "arno renevier",
index 04b12ec85359061de865d9f97b509f3686c41462..0d1498f73e1143c04d1f15823b217185c96bdcd5 100755 (executable)
@@ -1,13 +1,16 @@
 #!/usr/bin/php
 <?php
+/* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
+   license. */
 
 // only execute from command line
 if (!(isset ($argc)) || !(isset ($argv))) {
     exit (0);
 }
 
-$ROOTDIR="../../";
-$SCRIPTS=array("admin", "index", "wizard"); // scripts in rootdir we need to link to
+$ROOTDIR = "../../";
+// scripts in rootdir we need to link to
+$SCRIPTS = array ("admin", "index", "wizard");
 
 function usage() {
     global $argv;
@@ -47,11 +50,11 @@ function main($argv, $argc, $rootdir, $scripts) {
 }
 
 function escape_newline ($str, $tab) {
-    return str_replace("\n", "\\n\" .\n$tab$tab\"", $str);
+    return str_replace ("\n", "\\n\" .\n$tab$tab\"", $str);
 }
 function escape_slash ($str) {
-    $res = str_replace("\\", "\\\\", $str);
-    $res = str_replace("\"", "\\\"", $res);
+    $res = str_replace ("\\", "\\\\", $str);
+    $res = str_replace ("\"", "\\\"", $res);
     return $res;
 }
 
@@ -61,7 +64,7 @@ function escape_all ($str, $tab) {
     return $str;
 }
 
-function updatelang($lang, $rootdir, $scripts) {
+function updatelang ($lang, $rootdir, $scripts) {
     if (!preg_match ('/^[a-zA-Z]{2,3}(-[a-zA-Z]{2,3})?$/', $lang)) {
         warn ("$lang is not a valid lang format.\n");
         return false;
@@ -70,7 +73,7 @@ function updatelang($lang, $rootdir, $scripts) {
         warn ("en is reference language. It must be managed manually.\n");
         return false;
     }
-    
+
     if (!is_dir ($lang)) {
         if (!mkdir ($lang)) {
             error ("could not create $lang directory.\n");
@@ -90,7 +93,7 @@ function updatelang($lang, $rootdir, $scripts) {
     $tab = str_repeat (" ", 4);
 
     $tmpname = tempnam ("", "");
-    $output = fopen($tmpname, "w");
+    $output = fopen ($tmpname, "w");
 
     fwrite ($output, "<?php\n");
 
@@ -139,7 +142,7 @@ function updatelang($lang, $rootdir, $scripts) {
         error ("could not set permissions to $lang/sys.php");
         return false;
     }
-    
+
     foreach ($scripts as $script) {
         $link = $rootdir . "/"  . $script . "." . $lang . ".php";
         $target = $script . ".php";
index 5ac4a3766c0ed44b7b18d62dc8294db8d2b8401f..8a81b9c0f465a73f327e3c785259608011ec298e 100644 (file)
@@ -30,7 +30,7 @@ function parse_accept_language () {
             if (preg_match ('/^\s*([a-zA-Z-]+)\s*$/', $acc, $matches)) {
                 $possibilities [$matches [1]] = 1.0;
             }
-            if (preg_match ('/^\s*([a-zA-Z-]+)\s*;\s*q\s*=\s*([0-9\.]+)\s*$/', 
+            if (preg_match ('/^\s*([a-zA-Z-]+)\s*;\s*q\s*=\s*([0-9\.]+)\s*$/',
                             $acc, $matches)) {
                 $val = floatval ($matches [2]);
                 if ($val > 1.0) {
@@ -55,7 +55,7 @@ function other_languages ($current_lang) {
     if ($dotpos !== false) {
         $script = substr ($script, 0, $dotpos);
     }
-    
+
     global $translations;
     $links = Array ();
     foreach ($translations as $lang => $obj) {
index af0192f5ef61bdedd76a9c75876a4fbcd6cb5c61..2ce7c41bac98dcdb213c9cf14a421f7b1f4b38d2 100644 (file)
--- a/items.php
+++ b/items.php
@@ -8,7 +8,7 @@ require_once ("./inc/db/mysql.php");
 
 function main ($features) {
 
-    header("Cache-control: no-cache");
+    header ("Cache-control: no-cache");
 
     echo '<?xml version="1.0" encoding="UTF-8"?>
 <kml xmlns="http://www.opengis.net/kml/2.2">
index 032a6ac71e4264c29922c8e496f76a845cb9f272..8e32d8580d4d7e86d7b0f178cfa46f627d0c8e99 100644 (file)
--- a/js/syp.js
+++ b/js/syp.js
@@ -32,10 +32,10 @@ var SYP = {
     init: function() {
         this.map = new OpenLayers.Map("map", {
             controls:[
+                new OpenLayers.Control.SypAttribution(),
                 new OpenLayers.Control.Navigation(),
                 new OpenLayers.Control.PanZoom(),
-                new OpenLayers.Control.Permalink(),
-                new OpenLayers.Control.SypAttribution()
+                new OpenLayers.Control.Permalink()
             ],
             projection: new OpenLayers.Projection("EPSG:900913"),
             displayProjection: new OpenLayers.Projection("EPSG:4326")
@@ -140,7 +140,7 @@ var SYP = {
             this.map.events.unregister("movestart", this, this._unselect);
             return;
         }
-        popup = feature.popup;
+        var popup = feature.popup;
         if (popup.visible()) {
             popup.hide();
         }
index c2cd62c38e1972e1413469480c3be7a7634e6f09..9285e6a7ccb57ee9d7e97df673d4b2f740a63930 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+/* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
+   license. */
 
 require_once ("./inc/settings.php");
 
index fdef832fe5749fb39ed8666eb6070d86b4f19d56..04cdf4eff1c95b977784a1eda062289a8fcf01d3 100644 (file)
@@ -157,7 +157,3 @@ html>/**/body #img { /* hide from ie7 */
 #login_error {
     display: none;
 }
-
-/*
- * add feature
- */
index 615989f0fb3d00318808ecea45fe3487b02c2ae6..9bdefd18cc54da0821569ad5a97956d75804b080 100644 (file)
--- a/news.php
+++ b/news.php
@@ -22,8 +22,8 @@ function date3339 ($feature) {
     return $date;
 }
 
+// method from http://diveintomark.org/archives/2004/05/28/howto-atom-id#other
 function unique_id_from_feature ($feature) {
-    // method from http://diveintomark.org/archives/2004/05/28/howto-atom-id#other
     $date = date('Y-m-d', $feature->date);
     $res = sprintf("tag:%s,%s:%d", gethost(), $date, $feature->id);
     return $res;
@@ -36,9 +36,9 @@ function unique_id_from_site () {
 }
 
 function main ($features) {
-    print "<?xml version=\"1.0\" encoding=\"utf-8\"?>
+    printf ("<?xml version=\"1.0\" encoding=\"utf-8\"?>
 <feed xmlns=\"http://www.w3.org/2005/Atom\"
-      xmlns:georss=\"http://www.georss.org/georss\">\n";
+      xmlns:georss=\"http://www.georss.org/georss\">\n");
 
     printf("  <link rel=\"alternate\" type=\"text/html\" href=\"%s\"/>\n",
             full_url_from_path (""));
@@ -60,10 +60,10 @@ function main ($features) {
         printf("   </author>\n");
     }
 
-    print "\n";
+    printf ("\n");
 
     foreach ($features as $feature) {
-        print ("    <entry>\n");
+        printf ("    <entry>\n");
 
         if ($feature->title) {
             $title = htmlspecialchars ($feature->title, ENT_QUOTES);
@@ -88,7 +88,7 @@ function main ($features) {
         }
 
         if (strlen ($contentHTML) != 0) {
-            printf("       <content type=\"html\">
+            printf ("       <content type=\"html\">
                 %s
        </content>\n", htmlspecialchars ($contentHTML));
         }
@@ -98,7 +98,7 @@ function main ($features) {
 
         printf("    </entry>\n\n");
     }
-    print '</feed>';
+    printf ("</feed>");
 }
 
 try {