]> dev.renevier.net Git - syj.git/commitdiff
version 0.1 v0.1
authorarno <arno@renevier.net>
Tue, 27 Jul 2010 11:29:16 +0000 (13:29 +0200)
committerarno <arno@renevier.net>
Tue, 27 Jul 2010 11:29:16 +0000 (13:29 +0200)
126 files changed:
.gitignore [new file with mode: 0644]
.gitmodules [new file with mode: 0644]
COPYING.TXT [new file with mode: 0644]
application/Bootstrap.php [new file with mode: 0644]
application/configs/application.ini [new file with mode: 0644]
application/configs/session.ini [new file with mode: 0644]
application/controllers/AccountController.php [new file with mode: 0644]
application/controllers/ContactController.php [new file with mode: 0644]
application/controllers/CronController.php [new file with mode: 0644]
application/controllers/ErrorController.php [new file with mode: 0644]
application/controllers/GeomController.php [new file with mode: 0644]
application/controllers/IdxController.php [new file with mode: 0644]
application/controllers/LoginController.php [new file with mode: 0644]
application/controllers/NewpwdController.php [new file with mode: 0644]
application/controllers/PathController.php [new file with mode: 0644]
application/controllers/PendingController.php [new file with mode: 0644]
application/controllers/TermsofuseController.php [new file with mode: 0644]
application/controllers/UserController.php [new file with mode: 0644]
application/controllers/helpers/SyjApi.php [new file with mode: 0644]
application/controllers/helpers/SyjGeoip.php [new file with mode: 0644]
application/controllers/helpers/SyjPostData.php [new file with mode: 0644]
application/controllers/plugins/SyjLocale.php [new file with mode: 0644]
application/exception/Forbidden.php [new file with mode: 0644]
application/exception/InvalidEmail.php [new file with mode: 0644]
application/exception/NotFound.php [new file with mode: 0644]
application/exception/Request.php [new file with mode: 0644]
application/forms/Account.php [new file with mode: 0644]
application/forms/Contact.php [new file with mode: 0644]
application/forms/Geom.php [new file with mode: 0644]
application/forms/Login.php [new file with mode: 0644]
application/forms/Newpwd.php [new file with mode: 0644]
application/forms/Pending.php [new file with mode: 0644]
application/forms/Pending/ResetPassword.php [new file with mode: 0644]
application/forms/Pending/ValidateCreation.php [new file with mode: 0644]
application/forms/TableAbstract.php [new file with mode: 0644]
application/forms/User.php [new file with mode: 0644]
application/forms/decorator/TableDescription.php [new file with mode: 0644]
application/languages/lang_en.po [new file with mode: 0644]
application/languages/lang_fr.po [new file with mode: 0644]
application/layouts/scripts/footer.phtml [new file with mode: 0644]
application/layouts/scripts/header.phtml [new file with mode: 0644]
application/layouts/scripts/layout.phtml [new file with mode: 0644]
application/models/Generic.php [new file with mode: 0644]
application/models/Path.php [new file with mode: 0644]
application/models/PathMapper.php [new file with mode: 0644]
application/models/Pending.php [new file with mode: 0644]
application/models/Pending/ResetPassword.php [new file with mode: 0644]
application/models/Pending/ValidateCreation.php [new file with mode: 0644]
application/models/PendingMapper.php [new file with mode: 0644]
application/models/User.php [new file with mode: 0644]
application/models/UserMapper.php [new file with mode: 0644]
application/validate/EmailAddress.php [new file with mode: 0644]
application/views/helpers/AddParamToUrl.php [new file with mode: 0644]
application/views/helpers/Anchor.php [new file with mode: 0644]
application/views/helpers/FooterLink.php [new file with mode: 0644]
application/views/helpers/HeadBase.php [new file with mode: 0644]
application/views/helpers/LocaleShort.php [new file with mode: 0644]
application/views/helpers/LocaleSwitcher.php [new file with mode: 0644]
application/views/helpers/LoggedUser.php [new file with mode: 0644]
application/views/helpers/LogoutLink.php [new file with mode: 0644]
application/views/helpers/Returnto.php [new file with mode: 0644]
application/views/scripts/account/index.phtml [new file with mode: 0644]
application/views/scripts/account/success.phtml [new file with mode: 0644]
application/views/scripts/contact/index.phtml [new file with mode: 0644]
application/views/scripts/contact/success.phtml [new file with mode: 0644]
application/views/scripts/error/error.phtml [new file with mode: 0644]
application/views/scripts/idx/index.phtml [new file with mode: 0644]
application/views/scripts/login/login.phtml [new file with mode: 0644]
application/views/scripts/newpwd/index.phtml [new file with mode: 0644]
application/views/scripts/newpwd/success.phtml [new file with mode: 0644]
application/views/scripts/pending/creation_cancel.phtml [new file with mode: 0644]
application/views/scripts/pending/creation_validate.phtml [new file with mode: 0644]
application/views/scripts/pending/index.phtml [new file with mode: 0644]
application/views/scripts/pending/password_cancel.phtml [new file with mode: 0644]
application/views/scripts/pending/password_validate.phtml [new file with mode: 0644]
application/views/scripts/termsofuse/index.phtml [new file with mode: 0644]
generated/.placeholder [new file with mode: 0644]
library/Zend [new submodule]
library/gisconverter [new submodule]
library/gisconverter.php [new symlink]
library/phptojs.php [new file with mode: 0644]
library/pwdgen.php [new file with mode: 0644]
public/css/account.css [new file with mode: 0644]
public/css/contact.css [new file with mode: 0644]
public/css/error.css [new file with mode: 0644]
public/css/generic.css [new file with mode: 0644]
public/css/login.css [new file with mode: 0644]
public/css/newpwd.css [new file with mode: 0644]
public/css/openlayers [new symlink]
public/css/pending.css [new file with mode: 0644]
public/css/syj.css [new file with mode: 0644]
public/css/termsofuse.css [new file with mode: 0644]
public/icons/close.png [new symlink]
public/icons/delete.png [new file with mode: 0644]
public/index.php [new file with mode: 0644]
public/js/ModifiablePath.js [new symlink]
public/js/OpenLayers.js [new symlink]
public/js/account.js [new file with mode: 0644]
public/js/ajaxize.js [new file with mode: 0644]
public/js/closebtn.js [new file with mode: 0644]
public/js/contact.js [new file with mode: 0644]
public/js/deck.js [new file with mode: 0644]
public/js/forms.js [new file with mode: 0644]
public/js/img [new symlink]
public/js/lib [new symlink]
public/js/login.js [new file with mode: 0644]
public/js/message.js [new file with mode: 0644]
public/js/newpwd.js [new file with mode: 0644]
public/js/prototype.js [new symlink]
public/js/simplebox.js [new symlink]
public/js/syj.js [new file with mode: 0644]
public/js/termsofuse.js [new file with mode: 0644]
public/js/theme [new symlink]
public/modifiablepath [new submodule]
public/openlayers [new submodule]
public/prototype [new submodule]
public/simplebox [new submodule]
scripts/crontab.syj [new file with mode: 0644]
scripts/data.postgres.sql [new file with mode: 0644]
scripts/db_auth.sh [new file with mode: 0755]
scripts/reset.postgres.sh [new file with mode: 0755]
scripts/schema.postgres.sql [new file with mode: 0644]
scripts/trailingspaces.sh [new file with mode: 0755]
scripts/updategeoip.sh [new file with mode: 0755]
scripts/updategeonames.sh [new file with mode: 0755]
scripts/updatepo.sh [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..ae9a1ce
--- /dev/null
@@ -0,0 +1,4 @@
+application/languages/*.mo
+application/languages/*.po~
+scripts/jslint.js
+generated/mails.txt
diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..d0bc733
--- /dev/null
@@ -0,0 +1,18 @@
+[submodule "public/openlayers"]
+       path = public/openlayers
+       url = http://github.com/ccnmtl/openlayers.git
+[submodule "public/modifiablepath"]
+       path = public/modifiablepath
+       url = git://github.com/arenevier/ModifiablePath.git
+[submodule "library/gisconverter"]
+       path = library/gisconverter
+       url = git://github.com/arenevier/gisconverter.php
+[submodule "public/prototype"]
+       path = public/prototype
+       url = /var/www/syj/public/prototype
+[submodule "library/Zend"]
+       path = library/Zend
+       url = /var/www/syj/library/Zend
+[submodule "public/simplebox"]
+       path = public/simplebox
+       url = /var/www/syj/public/simplebox
diff --git a/COPYING.TXT b/COPYING.TXT
new file mode 100644 (file)
index 0000000..754dd92
--- /dev/null
@@ -0,0 +1,673 @@
+- Show Your Journey is available under the Affero General Public License
+  Version 3, and redistributed under the conditions of this license. A copy of
+  modified AGPL license is included in this file.
+
+- delete.png comes form FamFamFam Silk Icons. Author is Mark James. It is
+  licensed under a Creative Commons Attribution 2.5 License. See
+  http://www.famfamfam.com/lab/icons/silk/ for more informations.
+
+
+
+===============================================================================
+
+                    GNU AFFERO GENERAL PUBLIC LICENSE
+                       Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+  A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate.  Many developers of free software are heartened and
+encouraged by the resulting cooperation.  However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+  The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community.  It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server.  Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+  An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals.  This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU Affero General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Remote Network Interaction; Use with the GNU General Public License.
+
+  Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software.  This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time.  Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source.  For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code.  There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+<http://www.gnu.org/licenses/>.
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
new file mode 100644 (file)
index 0000000..08816c0
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
+    protected static $libns = array('gisconverter', 'phptojs', 'pwdgen');
+
+    public function _bootstrap($resource = null) {
+        $autoloader = Zend_Loader_Autoloader::getInstance();
+        foreach (self::$libns as $namespace) {
+            $autoloader->pushAutoloader(array($this, 'syj_autoload'), array($namespace, 'Syj_'));
+        }
+
+        parent::_bootstrap($resource);
+    }
+
+    public function run()
+    {
+        $sessionConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/session.ini', APPLICATION_ENV);
+        Zend_Session::setOptions($sessionConfig->toArray());
+        Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer')->initView(APPLICATION_PATH . '/views/', 'Syj_View');
+
+        parent::run();
+    }
+
+    static public function syj_autoload($class) {
+        foreach (self::$libns as $namespace) {
+            if (strpos ($class, $namespace) === 0) {
+                include_once ($namespace . ".php");
+                return;
+            }
+        }
+
+        if (strpos ($class, "Syj_") === 0) {
+            $segments = explode ('_', $class);
+
+            if (count($segments) < 3) {
+                return;
+            }
+
+            $dirpath = implode('/', array_map('strtolower', array_slice($segments, 1, -1)));
+            $filename = APPLICATION_PATH . '/' . ($dirpath ? $dirpath . '/' : '') . end($segments) . '.php';
+            if (Zend_Loader::isReadable($filename)) {
+                include_once $filename;
+            }
+        }
+    }
+
+}
+
diff --git a/application/configs/application.ini b/application/configs/application.ini
new file mode 100644 (file)
index 0000000..290fa8c
--- /dev/null
@@ -0,0 +1,100 @@
+; This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+; and is published under the AGPL license. */
+[production]
+phpSettings.display_startup_errors = 0
+phpSettings.display_errors = 0
+phpSettings.error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
+includePaths.library = APPLICATION_PATH "/../library"
+bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
+bootstrap.class = "Bootstrap"
+appnamespace = "Syj"
+; needed to send mails from cron
+resources.frontController.params.rooturl="http://osm-syj.crans.org/"
+resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
+resources.frontController.params.displayExceptions = 0
+resources.frontController.params.webmasterEmail = "arno@renevier.net"
+resources.frontController.params.emailSavingPath = APPLICATION_PATH "/../generated/mails.txt"
+; default geolocation
+resources.frontController.defaultloc.minlon = -160.0
+resources.frontController.defaultloc.maxlon = 160.0
+resources.frontController.defaultloc.minlat = -70.0
+resources.frontController.defaultloc.maxlat = 70.0
+resources.frontController.actionhelperpaths.Syj_Controller_Action_Helper  = APPLICATION_PATH "/controllers/helpers"
+resources.frontController.plugins.locale = "Syj_Controllers_Plugins_SyjLocale"
+resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
+resources.db.adapter = "Pdo_Pgsql"
+; i18n
+resources.translate.adapter = gettext
+resources.translate.data = APPLICATION_PATH "/languages"
+resources.translate.scan = filename
+resources.translate.disableNotices = true
+;
+; routes
+;
+
+; geom/
+resources.router.routes.geom.route = "geom/:idx"
+resources.router.routes.geom.defaults.controller = "geom"
+resources.router.routes.geom.defaults.action = "index"
+; idx/
+resources.router.routes.idx.route = "idx/:url"
+resources.router.routes.idx.defaults.controller = "idx"
+resources.router.routes.idx.defaults.action = "index"
+; "/" url works the same way as "idx/"
+resources.router.routes.root.type = "Zend_Controller_Router_Route_Static"
+resources.router.routes.root.route = "/"
+resources.router.routes.root.defaults.controller = "idx"
+; login/
+resources.router.routes.login.route = "login/"
+resources.router.routes.login.defaults.controller = "login"
+resources.router.routes.login.defaults.action = "login"
+; user/
+resources.router.routes.user.route = "user/"
+resources.router.routes.user.defaults.controller = "user"
+resources.router.routes.user.defaults.action = "user"
+; logout/
+resources.router.routes.logout.route = "logout/"
+resources.router.routes.logout.defaults.controller = "login"
+resources.router.routes.logout.defaults.action = "logout"
+; account/
+resources.router.routes.account.route = "account/"
+resources.router.routes.account.defaults.controller = "account"
+resources.router.routes.account.defaults.action = "index"
+; contact/
+resources.router.routes.contact.route = "contact/"
+resources.router.routes.contact.defaults.controller = "contact"
+resources.router.routes.contact.defaults.action = "index"
+; pending/
+resources.router.routes.pending.route = "pending/:idx"
+resources.router.routes.pending.defaults.controller = "pending"
+resources.router.routes.pending.defaults.action = "index"
+; termsofuse/
+resources.router.routes.termsofuse.route = "termsofuse/"
+resources.router.routes.termsofuse.defaults.controller = "termsofuse"
+resources.router.routes.termsofuse.defaults.action = "index"
+; cron/
+resources.router.routes.cron.route = "cron/"
+resources.router.routes.cron.defaults.controller = "cron"
+resources.router.routes.cron.defaults.action = "index"
+; newpwd/
+resources.router.routes.newpwd.route = "newpwd/"
+resources.router.routes.newpwd.defaults.controller = "newpwd"
+resources.router.routes.newpwd.defaults.action = "index"
+
+; database
+resources.db.params.username = "syj"
+resources.db.params.password = ""
+resources.db.params.dbname = "syj"
+
+[development : production]
+phpSettings.display_startup_errors = 1
+phpSettings.error_reporting = E_ALL | E_STRICT
+phpSettings.display_errors = 1
+; needed to send mails from cron
+resources.frontController.params.rooturl="http://localhost/syj/"
+resources.frontController.params.displayExceptions = 1
+resources.db.params.username = "syj"
+resources.db.params.password = ""
+resources.db.params.dbname = "syj"
+resources.db.params.profiler.enabled = true
+resources.db.params.profiler.class = Zend_Db_Profiler_Firebug
diff --git a/application/configs/session.ini b/application/configs/session.ini
new file mode 100644 (file)
index 0000000..08df068
--- /dev/null
@@ -0,0 +1,10 @@
+; This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+; and is published under the AGPL license. */
+[production]
+name = syj_session
+use_cookies = on
+use_trans_sid = off
+use_only_cookies = on
+cookie_httponly = on
+
+[development:production]
diff --git a/application/controllers/AccountController.php b/application/controllers/AccountController.php
new file mode 100644 (file)
index 0000000..97f9fbc
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class AccountController extends Zend_Controller_Action
+{
+
+    public function init() {
+        $this->view->headScript()->appendFile('js/prototype.js');
+        $this->view->headScript()->appendFile('js/forms.js');
+        $this->view->headScript()->appendFile('js/account.js');
+        $this->view->headLink()->appendStylesheet('css/generic.css');
+        $this->view->headLink()->appendStylesheet('css/account.css');
+        $this->view->headTitle($this->view->translate("my account"));
+    }
+
+    public function indexAction() {
+        $user = $this->view->loggedUser();
+        $request = $this->getRequest();
+
+        if ($user === null) {
+            $encodeduri = implode('/', array_map('urlencode', explode('/', $request->getRequestUri())));
+            $loginurl = $this->view->addParamToUrl($this->view->baseUrl() . '/' . 'login', 'redirect', $encodeduri);
+            $translator = Zend_Registry::get('Zend_Translate');
+            $lang = Zend_Controller_Front::getInstance()->getRequest()->getQuery('lang');
+            if ($lang) {
+                $adapter = $translator->getAdapter();
+                if ($adapter->isAvailable($lang)) {
+                    $loginurl = $this->view->addParamToUrl($loginurl, 'lang', $lang);
+                }
+            }
+            $this->_helper->Redirector->gotoURL($loginurl, array('prependBase' => false));
+        }
+
+        $form = new Syj_Form_Account(array('name' => 'accountform'));
+        $formData = $request->getPost();
+
+        $valid = false;
+        if (!empty($formData) and $form->isValid($formData)) {
+            $valid = true;
+            if ($user->password != sha1($formData['account_password_current'])) {
+                $valid = false;
+                $form->account_password_current->addError(__("Wrong password"));
+            }
+            $user->email = $formData['account_email'];
+            $user->password = sha1($formData['account_password']);
+            $userMapper = new Syj_Model_UserMapper();
+
+            try {
+                $userMapper->save ($user);
+            } catch(Zend_Db_Statement_Exception $e) {
+                if ($e->getCode() == 23505) { // 23505: Unique violation throw new Syj_Exception_Request();
+                    $message = $e->getMessage();
+                    if (strpos($message, 'users_email_key') !== false) {
+                        $valid = false;
+                        $form->account_email->addError(__("an user is already registered with this email"));
+                    } else {
+                        throw $e;
+                    }
+                } else {
+                    throw $e;
+                }
+            }
+        }
+
+        if ($valid) {
+            $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/success.:suffix');
+            return;
+        }
+
+        if (empty($formData)) {
+            $form->account_email->setValue($user->email);
+        } else {
+            $form->account_email->setValue($formData['account_email']);
+        }
+
+        $this->_jsLocaleStrings();
+        $this->view->form = $form;
+    }
+
+    protected function _jsLocaleStrings() {
+        $this->view->jslocales = array(
+            'notEmptyField' => __("Value is required and can't be empty"),
+            'passwordNoMatchWarn' => __("Password do not match"),
+            'passwordLenghtWarn' => array(__("At least %d characters"), 6),
+            'nochangeWarn' => __("You have made no change"),
+            );
+    }
+}
diff --git a/application/controllers/ContactController.php b/application/controllers/ContactController.php
new file mode 100644 (file)
index 0000000..0b71c32
--- /dev/null
@@ -0,0 +1,125 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class ContactController extends Zend_Controller_Action
+{
+
+    public function init() {
+        $this->view->headScript()->appendFile('js/prototype.js');
+        $this->view->headScript()->appendFile('js/forms.js');
+        $this->view->headScript()->appendFile('js/contact.js');
+        $this->view->headLink()->appendStylesheet('css/generic.css');
+        $this->view->headLink()->appendStylesheet('css/contact.css');
+        $this->view->headTitle($this->view->translate("contact form"));
+    }
+
+    protected function saveToFile(array $data) {
+        $savePath = Zend_Controller_Front::getInstance()->getParam('emailSavingPath');
+        if (!$savePath) {
+            return;
+        }
+        $saveDir = dirname($savePath);
+        if (is_file($saveDir) and !is_dir($saveDir)) {
+            throw new Zend_Exception();
+        }
+        if (!is_dir($saveDir)) {
+            if (@mkdir($saveDir, 0640, true) === false) {
+                throw new Zend_Exception();
+            }
+        }
+        $handle = @fopen($savePath, 'a');
+        if ($handle === false) {
+            throw new Zend_Exception();
+        }
+        fwrite($handle, "------\n");
+        fwrite($handle, "mail sent by " . $data['contact_email'] . "\n");
+        fwrite($handle, "on " . date('r') . "\n");
+        fwrite($handle, "subject: " . $data['contact_subject'] . "\n");
+        fwrite($handle, "\n");
+        fwrite($handle, $data['contact_content']);
+        fwrite($handle, "\n");
+        fwrite($handle, "\n");
+        fclose($handle);
+    }
+
+    protected function sendMail(array $data) {
+        try {
+            $this->saveToFile($data);
+        } catch(Zend_Exception $e) {
+            return false;
+        }
+        $to = Zend_Controller_Front::getInstance()->getParam('webmasterEmail');
+        $subject = "[SYJ] " . $data["contact_subject"];
+        $content = $data["contact_content"];
+        $from = $data["contact_email"];
+
+        $mail = new Zend_Mail('utf-8');
+        $mail->addTo($to)
+             ->setSubject($subject)
+             ->setBodyText($content)
+             ->setFrom($from);
+
+        try {
+            $mail->send();
+        } catch(Exception $e) {
+            return false;
+        }
+        return true;
+    }
+
+    public function indexAction() {
+        $form = new Syj_Form_Contact(array('name' => 'contactform'));
+
+        $request = $this->getRequest();
+        $formData = $request->getPost();
+
+        if (!empty($formData) and $form->isValid($formData)) {
+            if ($this->sendMail($form->getValues())) {
+                $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/success.:suffix');
+                return;
+            } else {
+                $this->view->sendError = true;
+            }
+        }
+
+        if (empty($formData)) {
+            $user = $this->view->loggedUser();
+            if ($user) {
+                $form->contact_email->setValue($user->email)
+                                    ->setAttrib('readonly', 'true');
+            }
+
+            $subject = $request->getQuery('subject');
+            if (isset($subject)) {
+                foreach ($form->contact_subject->getValidators() as $key => $validator) {
+                    if (!$validator->isValid($subject)) {
+                        $subject = null;
+                        break;
+                    }
+                }
+            }
+            $form->contact_subject->setValue($subject);
+
+            $content = $request->getQuery('content');
+            if (isset($content)) {
+                foreach ($form->contact_content->getValidators() as $key => $validator) {
+                    if (!$validator->isValid($content)) {
+                        $content = null;
+                        break;
+                    }
+                }
+            }
+            $form->contact_content->setValue(isset($content) ? $content : $this->view->translate("Hi,"));
+        }
+
+        $this->_jsLocaleStrings();
+        $this->view->form = $form;
+    }
+
+    protected function _jsLocaleStrings() {
+        $this->view->jslocales = array(
+            'notEmptyField' => __("Value is required and can't be empty"),
+            'invalidMail' => __("Invalid email"));
+    }
+}
diff --git a/application/controllers/CronController.php b/application/controllers/CronController.php
new file mode 100644 (file)
index 0000000..e8ab6ec
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class CronController extends Zend_Controller_Action
+{
+    public function init() {
+        $ip = $this->getRequest()->getClientIp(true);
+        if ($ip !== '127.0.0.1' and $ip !== '::1') {
+            throw new Syj_Exception_Forbidden();
+        }
+    }
+    public function indexAction() {
+        $mapper = new Syj_Model_PendingMapper();
+        foreach ($mapper->fetchAll() as $pending) {
+            $pending->notify();
+        }
+        $this->_helper->SyjApi->setCode(200);
+    }
+}
diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php
new file mode 100644 (file)
index 0000000..db283ab
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class ErrorController extends Zend_Controller_Action
+{
+    protected function httpError($code) {
+        $this->getResponse()->setHttpResponseCode($code);
+        $this->view->message = Zend_Http_Response::responseCodeAsText($code);
+    }
+
+    public function init() {
+        $this->view->jslocales = null;
+        $this->view->headScript()->exchangeArray(array());
+        $this->view->headLink()->exchangeArray(array());
+        $this->view->headTitle()->exchangeArray(array());
+        $this->view->headStyle()->exchangeArray(array());
+
+        $this->view->headLink()->appendStylesheet('css/generic.css');
+        $this->view->headLink()->appendStylesheet('css/error.css');
+    }
+
+    public function errorAction() {
+        $error = $this->_getParam('error_handler');
+
+        $error_code = 500; // default value: Internal Server Error
+        switch ($error->type) {
+            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
+            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
+            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
+                $error_code = 404; // Not Found
+                break;
+            default:
+                if ($error->exception instanceof Syj_Exception_Request) {
+                    $error_code = 400; // Bad Request
+                } else if ($error->exception instanceof Syj_Exception_Forbidden) {
+                    $error_code = 403; // Forbidden
+                } else if ($error->exception instanceof Syj_Exception_NotFound) {
+                    $error_code = $error->exception->getCode();
+                }
+                break;
+        }
+        $this->httpError($error_code);
+
+        // Log exception, if logger available
+        if ($log = $this->getLog()) {
+            $log->crit($this->view->message, $error->exception);
+        }
+
+        if ($error_code != 404 and $error_code != 410 and $error->request->isXmlHttpRequest()) {
+            return $this->_helper->json(array('message' => $error->exception->getMessage()));
+        }
+
+        // conditionally display exceptions
+        if ($this->getInvokeArg('displayExceptions') == true) {
+            $this->view->exception = $error->exception;
+        }
+
+        $this->view->request   = $error->request;
+        $this->view->isServerError = ($error_code >= 500 and $error_code < 600);
+        $this->view->headTitle($this->view->translate("Oups, something went wrong"));
+    }
+
+    public function getLog() {
+        $bootstrap = $this->getInvokeArg('bootstrap');
+        if (!$bootstrap->hasPluginResource('Log')) {
+            return false;
+        }
+        $log = $bootstrap->getResource('Log');
+        return $log;
+    }
+
+}
diff --git a/application/controllers/GeomController.php b/application/controllers/GeomController.php
new file mode 100644 (file)
index 0000000..38d5ce7
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class GeomController extends Zend_Controller_Action
+{
+
+    public function indexAction() {
+        $request = $this->getRequest();
+        $response = $this->getResponse();
+
+        $idx = $request->idx;
+        $pathMapper = new Syj_Model_PathMapper();
+        $path = new Syj_Model_Path();
+
+        $api = $this->_helper->SyjApi;
+
+        if (!$pathMapper->find($idx, $path)) {
+            if ($pathMapper->hasexisted($idx)) {
+                $api->setCode(410);
+            } else {
+                $api->setCode(404);
+            }
+            return;
+        }
+
+        $api->setCheckIfNoneMatch(true)->setBody(json_encode(
+            array('owner' => (string)$path->owner->pseudo, 'geom' => (string)$path->geom)
+        ));
+    }
+}
diff --git a/application/controllers/IdxController.php b/application/controllers/IdxController.php
new file mode 100644 (file)
index 0000000..589c71b
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class IdxController extends Zend_Controller_Action
+{
+
+    public function init() {
+        $this->view->headScript()->appendFile('js/OpenLayers.js');
+        $this->view->headScript()->appendFile('js/ModifiablePath.js');
+        $this->view->headScript()->appendFile('js/prototype.js');
+        $this->view->headScript()->appendFile('js/simplebox.js');
+        $this->view->headScript()->appendFile('js/closebtn.js');
+        $this->view->headScript()->appendFile('js/deck.js');
+        $this->view->headScript()->appendFile('js/ajaxize.js');
+        $this->view->headScript()->appendFile('js/message.js');
+        $this->view->headScript()->appendFile('js/syj.js');
+        $this->view->headLink()->appendStylesheet('css/openlayers/style.css');
+        $this->view->headLink()->appendStylesheet('css/generic.css');
+        $this->view->headLink()->appendStylesheet('css/syj.css');
+    }
+
+    public function indexAction() {
+        $url = $this->getRequest()->getUserParam('url');
+
+        $geomform = new Syj_Form_Geom(array('name' => 'geomform', 'action' => 'path'));
+        $loginform = new Syj_Form_Login(array('name' => 'loginform', 'action' => 'login'));
+        $userform = new Syj_Form_User(array('name' => 'userform', 'action' => 'user'));
+        $newpwdform = new Syj_Form_Newpwd(array('name' => 'newpwdform', 'action' => 'newpwd'));
+
+        if (isset($url)) {
+            $pathMapper = new Syj_Model_PathMapper();
+            $path = new Syj_Model_Path();
+            if (!$pathMapper->findByUrl($url, $path)) {
+                if (is_numeric($url) and $pathMapper->hasexisted($url)) {
+                    throw new Syj_Exception_NotFound('Gone', 410);
+                } else {
+                    throw new Syj_Exception_NotFound('Not Found', 404);
+                }
+            }
+            $title = $path->displayTitle;
+            $this->view->path = $path;
+            $geomform->geom_title->setValue($path->title);
+            $geomform->geom_data->setValue((string)$path->geom);
+            $geomform->geom_id->setValue((string)$path->id);
+            $loginform->login_geom_id->setValue((string)$path->id);
+        } else {
+            $extent = new phptojs\JsObject('gMaxExtent', $this->_helper->syjGeoip($this->getRequest()->getClientIp(true)));
+            $this->view->headScript()->prependScript((string) $extent);
+            $title = "Show your journey";
+        }
+
+        $this->_jsLoggedInfo(isset($url) ? $path: null);
+        $this->_jsLocaleStrings();
+        $this->view->headTitle($title);
+        $this->view->geomform = $geomform;
+        $this->view->loginform = $loginform;
+        $this->view->userform = $userform;
+        $this->view->newpwdform = $newpwdform;
+    }
+
+    protected function _jsLoggedInfo(Syj_Model_Path $path = null) {
+        $loggedinfo = new phptojs\JsObject('gLoggedInfo', array('connections' => 0));
+
+        $sessionStorage = Zend_Auth::getInstance()->getStorage();
+        $sessionData = $sessionStorage->read();
+
+        if ($sessionStorage->isEmpty()) {
+            $loggedinfo->logged = false;
+        } else {
+            $userMapper = new Syj_Model_UserMapper();
+            $obj = new Syj_Model_User();
+            if ($userMapper->find($sessionData['user'], $obj)) {
+                $loggedinfo->logged = true;
+            } else {
+                // non existent user
+                Zend_Session::start();
+                Zend_Session::destroy();
+                $loggedinfo->logged = false;
+            }
+        }
+
+        if (isset($path)) {
+            if ($path->owner->id == $sessionData['user']) {
+                $loggedinfo->isowner = true;
+            } else {
+                $loggedinfo->isowner = false;
+            }
+            $loggedinfo->ownername = $this->view->escape((string)$path->owner->pseudo);
+        } else {
+            $loggedinfo->isowner = true;
+        }
+
+        $this->view->headScript()->prependScript((string) $loggedinfo);
+    }
+
+    protected function _jsLocaleStrings() {
+        $this->view->jslocales = array(
+            'saveSuccess' => __("save took place successfully"),
+            'requestError' => __("server did not understood request. That's probably caused by a bug in SYJ"),
+            'UnreferencedError' => __("path did not exist in the server. May be it has been already deleted"),
+            'uniquePathError' => __("similar path seems to already exist. Please do not create two exactly identical paths"),
+            'notReachedError' => __("server could not be reached"),
+            'serverError' => __("there was a server error"),
+            'unknownError' => __("there was an unknown error"),
+            'userEmptyWarn' => __("you must enter a login name"),
+            'loginSuccess' => __("Login correct"),
+            'loginFailure' => __("Wrong login/password"),
+            'loginNeeded' => __("You need to login before retrying to save"),
+            'cookiesNeeded' => __("You need to have cookies enabled to login to SYJ"),
+            'passwordEmptyWarn' => __("you must enter a password"),
+            'passwordNoMatchWarn' => __("Password do not match"),
+            'acceptTermsofuseWarn' => __("You must accept terms of use"),
+            'emailEmptyWarn' => __("you must enter an email"),
+            'emailInvalidWarn' => __("invalid email"),
+            'invalidPseudo' => __("pseudo must only contain letters, digits, dots or underscores"),
+            'uniqueUserError' => __("unavailable pseudo"),
+            'uniqueEmailError' => __("an user is already registered with this email"),
+            'userSuccess' => __("Account created"),
+            'newpwdSuccess' => __("A link to reset your password has been emailed to you"),
+            'canResubmit' => __("Now, you can retry to save"),
+            'routeBy' => __("route by"),
+            'osmAttribution' => __("Map by <a href='http://openstreetmap.org/'>OpenStreetMap</a>")
+            );
+    }
+
+}
diff --git a/application/controllers/LoginController.php b/application/controllers/LoginController.php
new file mode 100644 (file)
index 0000000..96d485a
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class LoginController extends Zend_Controller_Action
+{
+    public function init() {
+        $this->view->headTitle($this->view->translate("login"));
+        $this->view->headScript()->appendFile('js/prototype.js');
+        $this->view->headScript()->appendFile('js/forms.js');
+        $this->view->headScript()->appendFile('js/login.js');
+        $this->view->headLink()->appendStylesheet('css/generic.css');
+        $this->view->headLink()->appendStylesheet('css/login.css');
+    }
+
+    public function loginAction() {
+        $form = new Syj_Form_Login(array('name' => 'loginform'));
+        $request = $this->getRequest();
+        $formData = $request->getPost();
+        $this->view->form = $form;
+        $httprequest = $request->isXmlHttpRequest();
+
+        if (!$httprequest) {
+            $this->_jsLocaleStrings();
+        }
+
+        if (empty ($formData) or !$form->isValid($formData)) {
+            if ($httprequest) {
+                throw new Syj_Exception_Request();
+            } else {
+                return;
+            }
+        }
+
+        /* form has been filled */
+
+        $adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
+        $authAdapter = new Zend_Auth_Adapter_DbTable($adapter, 'users', 'pseudo', 'password');
+        $authAdapter->setIdentity($formData['login_user'])
+                ->setCredential(sha1($formData['login_password']));
+
+        $auth = Zend_Auth::getInstance();
+        $result = $auth->authenticate($authAdapter);
+        if (!$result->isValid()) {
+            if ($httprequest) {
+                throw new Syj_Exception_Forbidden();
+            } else {
+                $form->addError('Wrong login/password');
+                return;
+            }
+        }
+
+        $userid = $authAdapter->getResultRowObject('id')->id;
+        $auth->getStorage()->write(array('user' => $userid));
+        Zend_Session::rememberMe(); // zend default expiration delay is 2 weeks. Ok, use that value
+
+
+        if ($httprequest) {
+            $api = $this->_helper->SyjApi->setCode(200);
+
+            $login_geom_id = $formData['login_geom_id'];
+            if ($login_geom_id) {
+                $path = new Syj_Model_Path();
+                $pathMapper = new Syj_Model_PathMapper();
+                if (!$pathMapper->find((int)$login_geom_id, $path)) {
+                    throw new Syj_Exception_Request();
+                }
+                if ($path->owner->id === $userid) {
+                    $api->setBody("1"); // owner of displayed geometry
+                } else {
+                    $api->setBody("0");
+                }
+            } else {
+                $api->setBody("1"); // no geometry displayed: owner of the (future) geometry
+            }
+        } else {
+            $this->redirect();
+        }
+    }
+
+    public function logoutAction() {
+        Zend_Session::start();
+        Zend_Session::destroy();
+        $this->redirect();
+    }
+
+    protected function redirect($target = null) {
+        if (!isset($target)) {
+            $target = $this->getRequest()->getQuery('redirect');
+        }
+
+        if (!isset($target)) {
+            $target = $this->view->baseUrl();
+        }
+        if (!$target) {
+            $target = '/';
+        }
+
+        $this->_helper->Redirector->gotoURL($target, array('prependBase' => false));
+    }
+
+    protected function _jsLocaleStrings() {
+        $this->view->jslocales = array(
+            'userEmptyWarn' => __("you must enter a login name"));
+    }
+}
diff --git a/application/controllers/NewpwdController.php b/application/controllers/NewpwdController.php
new file mode 100644 (file)
index 0000000..2dc2724
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class NewpwdController extends Zend_Controller_Action
+{
+
+    public function init() {
+        $this->view->headScript()->appendFile('js/prototype.js');
+        $this->view->headScript()->appendFile('js/newpwd.js');
+        $this->view->headLink()->appendStylesheet('css/generic.css');
+        $this->view->headLink()->appendStylesheet('css/newpwd.css');
+    }
+
+    public function indexAction() {
+        $form = new Syj_Form_Newpwd(array('name' => 'newpwdform'));
+        $request = $this->getRequest();
+        $formData = $request->getPost();
+        $this->view->form = $form;
+        $httprequest = $request->isXmlHttpRequest();
+
+        if (!$httprequest) {
+            $this->_jsLocaleStrings();
+        }
+
+        if (empty($formData)) {
+            $loggeduser = $this->view->loggedUser();
+            if ($loggeduser) {
+                $form->newpwd_email->setValue($loggeduser->email)
+                                    ->setAttrib('readonly', 'true');
+            }
+        }
+
+        if (empty ($formData) or !$form->isValid($formData)) {
+            if ($httprequest) {
+                throw new Syj_Exception_Request();
+            } else {
+                return;
+            }
+        }
+
+        /* form has been filled */
+        $userMapper = new Syj_Model_UserMapper();
+        $user = new Syj_Model_User();
+        if ($userMapper->findByEmail($formData['newpwd_email'], $user)) {
+            // if no user exist with posted email, pretend everything went correct
+            $loggeduser = isset($loggeduser) ? $loggeduser: $this->view->loggedUser();
+            if ($loggeduser and ($loggeduser != $user)) {
+                throw new Syj_Exception_Request();
+            }
+            $pending = new Syj_Model_Pending_ResetPassword();
+            $pending->setUser($user);
+            if (!$pending->notify()) {
+                throw new Zend_Exception();
+            }
+        }
+
+        if ($httprequest) {
+            $api = $this->_helper->SyjApi->setCode(200);
+        } else {
+            $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/success.:suffix');
+        }
+
+    }
+
+    protected function _jsLocaleStrings() {
+        $this->view->jslocales = array(
+            'notEmptyField' => __("Value is required and can't be empty"),
+            );
+    }
+}
diff --git a/application/controllers/PathController.php b/application/controllers/PathController.php
new file mode 100644 (file)
index 0000000..bd4d339
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class PathController extends Zend_Controller_Action
+{
+    public function indexAction() {
+        $formData = $this->_helper->SyjPostData->getPostData('Syj_Form_Geom');
+
+        $sessionStorage = Zend_Auth::getInstance()->getStorage();
+        if ($sessionStorage->isEmpty()) {
+            throw new Syj_Exception_Forbidden();
+        }
+        $sessionData = $sessionStorage->read();
+
+        $user = new Syj_Model_User();
+        $userMapper = new Syj_Model_UserMapper();
+        if (!$userMapper->find($sessionData['user'], $user)) {
+            // we could also throw a forbidden exception, but client session
+            // should not contain reference to a non existent user. So, it's considered a bug.
+            throw new Syj_Exception_Forbidden();
+        }
+
+        $decoder = new gisconverter\WKT();
+
+        try {
+            $geom = $decoder->geomFromText($formData["geom_data"]);
+        } catch (gisconverter\CustomException $e) {
+            throw new Syj_Exception_Request();
+        }
+
+        if ($geom::name != "LineString") {
+            throw new Syj_Exception_Request();
+        }
+
+        $path = new Syj_Model_Path();
+        $pathMapper = new Syj_Model_PathMapper();
+        if (isset ($formData["geom_id"]) and $formData["geom_id"]) {
+            if (!$pathMapper->find($formData["geom_id"], $path)) {
+                throw new Syj_Exception_Request("unreferenced");
+            }
+        }
+        $path->geom = $geom;
+        if ($path->getId()) {
+            if ($path->owner->id != $user->id) {
+                throw new Syj_Exception_Forbidden();
+            }
+        } else {
+            $path->owner = $user;
+        }
+        if (isset($formData["geom_title"])) {
+            $path->title = $formData["geom_title"];
+        }
+        try {
+            $pathMapper->save ($path);
+        } catch(Zend_Db_Statement_Exception $e) {
+            if ($e->getCode() == 23505) { // 23505: Unique violation throw new Syj_Exception_Request();
+                $message = $e->getMessage();
+                if (strpos($message, 'paths_geom_key') !== false) {
+                    throw new Syj_Exception_Request("uniquepath");
+                } else {
+                    throw $e;
+                }
+            } else {
+                throw $e;
+            }
+        }
+
+        $this->_helper->SyjApi->setBody($path->id);
+    }
+}
diff --git a/application/controllers/PendingController.php b/application/controllers/PendingController.php
new file mode 100644 (file)
index 0000000..025f6c9
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class PendingController extends Zend_Controller_Action
+{
+
+    public function init() {
+        $this->view->headLink()->appendStylesheet('css/generic.css');
+        $this->view->headLink()->appendStylesheet('css/pending.css');
+    }
+
+    public function indexAction() {
+        $request = $this->getRequest();
+        $response = $this->getResponse();
+        $hash = $request->idx;
+
+        $pendingMapper = new Syj_Model_PendingMapper();
+        $pending = $pendingMapper->fetchByHash($hash);
+        if (!isset($pending)) {
+            throw new Syj_Exception_NotFound('Not Found', 404);
+        }
+
+        $formData = $request->getPost();
+
+        switch ($pending->action) {
+            case 'validate_creation':
+            if (array_key_exists('pending_validate', $formData)) {
+                    if (!$pending->run()) {
+                        throw new Syj_Exception();
+                    }
+                    $title = $this->view->translate("account validated");
+                    $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_validate.:suffix');
+
+                } else if (array_key_exists('pending_cancel', $formData)) {
+                    if (!$pending->cancel()) {
+                        throw new Syj_Exception();
+                    }
+                    $title = $this->view->translate("account deleted");
+                    $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_cancel.:suffix');
+                } else {
+                    $this->view->form = new Syj_Form_Pending_ValidateCreation($pending, array('name' => 'pendingform'));
+                    $title = $this->view->translate('account creation validation');
+                }
+            break;
+            case 'reset_password':
+                if (array_key_exists('pending_validate', $formData)) {
+                    if (!$pending->run()) {
+                        throw new Syj_Exception();
+                    }
+                    $this->view->newpwd = $pending->newpwd;
+
+                    $title = $this->view->translate("password changed");
+                    $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_validate.:suffix');
+
+                    // logout
+                    Zend_Session::start();
+                    Zend_Session::destroy();
+
+                } else if (array_key_exists('pending_cancel', $formData)) {
+                    if (!$pending->cancel()) {
+                        throw new Syj_Exception();
+                    }
+                    $title = $this->view->translate("request canceled");
+                    $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_cancel.:suffix');
+                } else {
+                    $this->view->form = new Syj_Form_Pending_ResetPassword($pending, array('name' => 'pendingform'));
+                    $title = $this->view->translate('password reset validation');
+                }
+            break;
+            default:
+                throw new Syj_Exception_Request();
+            break;
+        }
+
+        $this->view->headTitle($title);
+    }
+
+}
diff --git a/application/controllers/TermsofuseController.php b/application/controllers/TermsofuseController.php
new file mode 100644 (file)
index 0000000..e1b8838
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class TermsofuseController extends Zend_Controller_Action
+{
+    public function indexAction() {
+        $this->view->headLink()->appendStylesheet('css/generic.css');
+        $this->view->headLink()->appendStylesheet('css/termsofuse.css');
+        $this->view->headScript()->appendFile('js/prototype.js');
+        $this->view->headScript()->appendFile('js/termsofuse.js');
+        $this->view->headTitle($this->view->translate("terms of use"));
+    }
+}
diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php
new file mode 100644 (file)
index 0000000..2bb3fe9
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class UserController extends Zend_Controller_Action
+{
+
+    public function userAction() {
+        $formData = $this->_helper->SyjPostData->getPostData('Syj_Form_User');
+
+        // XXX: we validate email server side *only* so we don't want to
+        // validate in SyjPostData. Then, we validate email outside Syj_Form_User
+        $emailValidator = new Syj_Validate_EmailAddress();
+        if (!$emailValidator->isValid($formData['user_email'])) {
+            throw new Syj_Exception_InvalidEmail();
+        }
+
+        $user = new Syj_Model_User();
+        $user->pseudo = $formData["user_pseudo"];
+        $user->password = sha1($formData["user_password"]);
+        $user->email = $formData["user_email"];
+        $user->creationAddr = $this->getRequest()->getClientIp(true);
+
+        if (Zend_Registry::isRegistered('Zend_Translate')) {
+            $translator = Zend_Registry::get('Zend_Translate');
+            $adapter = $translator->getAdapter();
+            $locale = new Zend_Locale($adapter->getLocale());
+            $user->lang = $locale->getLanguage();
+        }
+
+        $userMapper = new Syj_Model_UserMapper();
+
+        try {
+            $userMapper->save ($user);
+        } catch(Zend_Db_Statement_Exception $e) {
+            if ($e->getCode() == 23505) { // 23505: Unique violation throw new Syj_Exception_Request();
+                $message = $e->getMessage();
+                if (strpos($message, 'users_pseudo_key') !== false) {
+                    throw new Syj_Exception_Request("uniquepseudo");
+                } else if (strpos($message, 'users_email_key') !== false) {
+                    throw new Syj_Exception_Request("uniqueemail");
+                } else {
+                    throw $e;
+                }
+            } else {
+                throw $e;
+            }
+        }
+
+        $auth = Zend_Auth::getInstance();
+        $auth->getStorage()->write(array('user' => $user->id));
+        Zend_Session::rememberMe(); // zend default expiration delay is 2 weeks. Ok, use that value
+        $this->_helper->SyjApi->setCode(200);
+    }
+}
diff --git a/application/controllers/helpers/SyjApi.php b/application/controllers/helpers/SyjApi.php
new file mode 100644 (file)
index 0000000..86ea00e
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Controller_Action_Helper_SyjApi extends Zend_Controller_Action_Helper_Abstract
+{
+    protected $_contentType = 'text/plain';
+    protected $_checkIfNoneMatch = false;
+    protected $_body = '';
+    protected $_code = 200;
+
+    public function init() {
+        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
+        $viewRenderer->setNoRender();
+        $layout = Zend_Layout::getMvcInstance();
+        if (null !== $layout) {
+            $layout->disableLayout();
+        }
+    }
+
+    public function setContentType($contentType) {
+        $this->_contentType = (string)$contentType;
+        return $this;
+    }
+
+    public function getContentType() {
+        $this->_contentType = $contentType;
+    }
+
+    public function setBody($body) {
+        $this->_body = (string)$body;
+        return $this;
+    }
+
+    public function getBody() {
+        return $body;
+    }
+
+    public function setCode($code) {
+        $this->_code = (int)$code;
+        return $this;
+    }
+
+    public function getCode() {
+        return $this->_code;
+    }
+
+    public function setCheckIfNoneMatch($check) {
+        $this->_checkIfNoneMatch = (boolean)$check;
+        return $this;
+    }
+
+    public function getCheckIfNoneMatch() {
+        return $this->_checkIfNoneMatch;
+    }
+
+    public function postDispatch() {
+        $response = $this->getResponse();
+
+        $response->setHeader('Content-Type', $this->_contentType)
+                 ->setHeader('Content-Length', strlen($this->_body));
+
+        if ($this->_checkIfNoneMatch) {
+            $request = $this->getRequest();
+
+            $etag = md5 ($this->_body);
+            if ($request->getServer("HTTP_IF_NONE_MATCH") == $etag) {
+                $response->setHttpResponseCode(304);
+                return;
+            }
+
+            // no-cache is needed otherwise IE does not try to get new version.
+            $response->setHeader ('Cache-control', 'no-cache, must-revalidate');
+            $response->setHeader ('Etag', $etag);
+        }
+
+        $response->setHttpResponseCode($this->_code)
+                 ->setBody($this->_body);
+    }
+}
+?>
diff --git a/application/controllers/helpers/SyjGeoip.php b/application/controllers/helpers/SyjGeoip.php
new file mode 100644 (file)
index 0000000..5d5dd12
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Controller_Action_Helper_SyjGeoip extends Zend_Controller_Action_Helper_Abstract
+{
+
+    public function direct ($ip) {
+        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
+        $select = $db->select(null)->from('geoip', null)->where('geoip.begin_ip <= inet_to_bigint(?)', (string)$ip)
+                                  ->where('geoip.end_ip >= inet_to_bigint(?)', (string)$ip)
+                                  ->limit(1)
+                                  ->join('geonames', 'geonames.country = geoip.country', array(
+                                  'geonames.minlon', 'geonames.minlat', 'geonames.maxlon', 'geonames.maxlat'
+                                  ));
+        try {
+            $stmt = $db->query($select);
+            $row = $db->query($select)->fetch();
+        } catch (Exception $e) {
+            $row = null;
+        }
+        if (!$row) {
+            $row = Zend_Controller_Front::getInstance()->getParam('defaultloc');
+        }
+        return array_map(function($elem) { return (float)$elem;},$row);
+    }
+}
diff --git a/application/controllers/helpers/SyjPostData.php b/application/controllers/helpers/SyjPostData.php
new file mode 100644 (file)
index 0000000..3f18222
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Controller_Action_Helper_SyjPostData extends Zend_Controller_Action_Helper_Abstract
+{
+
+    public function getPostData($form) {
+        if (is_string($form) and class_exists($form)) {
+            $form = new $form;
+        }
+        if (!$form instanceof Zend_Form) {
+            throw new Zend_Exception();
+        }
+
+        if (!$this->getRequest()->isPost()) {
+            throw new Syj_Exception_Request();
+        }
+        $data = $this->getRequest()->getPost();
+        if (!$form->isValid($data)) {
+            throw new Syj_Exception_Request();
+        }
+
+        return $data;
+    }
+
+}
diff --git a/application/controllers/plugins/SyjLocale.php b/application/controllers/plugins/SyjLocale.php
new file mode 100644 (file)
index 0000000..19af8ec
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Controllers_Plugins_SyjLocale extends Zend_Controller_Plugin_Abstract
+{
+
+    public function preDispatch(Zend_Controller_Request_Abstract $request) {
+        $lang = $request->getQuery('lang');
+        if (is_null($lang)) {
+            return;
+        }
+
+        if (!Zend_Registry::isRegistered('Zend_Translate')) {
+            return;
+        }
+
+        $translator = Zend_Registry::get('Zend_Translate');
+        $adapter = $translator->getAdapter();
+        if (!$adapter->isAvailable($lang)) {
+            return;
+        }
+
+        $adapter->setLocale($lang);
+    }
+
+}
diff --git a/application/exception/Forbidden.php b/application/exception/Forbidden.php
new file mode 100644 (file)
index 0000000..1718f2b
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Exception_Forbidden extends Zend_Exception
+{
+}
diff --git a/application/exception/InvalidEmail.php b/application/exception/InvalidEmail.php
new file mode 100644 (file)
index 0000000..3f18da4
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Exception_InvalidEmail extends Syj_Exception_Request
+{
+     protected $_message = 'invalidemail';
+
+     // Redefine the exception so message isn't optional
+     public function __construct($msg = '', $code = 0, Exception $previous = null) {
+        parent::__construct($msg ?: $this->_message, $code, $previous);
+     }
+
+}
diff --git a/application/exception/NotFound.php b/application/exception/NotFound.php
new file mode 100644 (file)
index 0000000..b769770
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Exception_NotFound extends Zend_Exception
+{
+}
diff --git a/application/exception/Request.php b/application/exception/Request.php
new file mode 100644 (file)
index 0000000..0099ce7
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Exception_Request extends Zend_Exception
+{
+}
diff --git a/application/forms/Account.php b/application/forms/Account.php
new file mode 100644 (file)
index 0000000..d8103df
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Form_Account extends Zend_Form
+{
+    protected $_decorators = array(
+                            'FormElements' => array('decorator' => 'FormElements', 'options' => null),
+                            'Form' => array('decorator' => 'Form', 'options' => array()));
+
+    protected $_elementDecorators = array(
+                                'ViewHelper',
+                                'Errors' => array('decorator' => 'Errors', 'options' => array('class' => 'error')),
+                                array(array('lbreak1' => 'HtmlTag'), array('tag' => 'br', 'openOnly' => true)),
+                                'Label',
+                                array(array('lbreak2' => 'HtmlTag'), array('tag' => 'br', 'placement' => 'APPEND', 'openOnly' => true)),
+                                );
+
+    public function init() {
+        $formErrors = $this->getView()->getHelper('FormErrors');
+        $formErrors->setElementStart("<div%s>")
+                   ->setElementEnd("</div>")
+                   ->setElementSeparator("<br>");
+
+        $validator = new Syj_Validate_EmailAddress();
+        $email = array('Text', 'account_email', array(
+            'label' => __("email"),
+            'validators' => array($validator),
+            'maxlength' => '320',
+            'required' => true));
+
+        $passValidator = new Zend_Validate_StringLength(6);
+        $passValidator->setMessage(vsprintf($this->getTranslator()->translate("At least %d characters"), 6));
+        $pass = array('Password', 'account_password', array(
+            'label' => __("password"),
+            'required' => true,
+            'validators' => array($passValidator)));
+
+        $identicalValidator = new Zend_Validate_Identical('account_password');
+        $identicalValidator->setMessage(__("Password do not match"));
+        $pass_confirm = array('Password', 'account_password_confirm', array(
+                'label' => __("confirm password"),
+                'validators' => array($identicalValidator),
+                'required' => true
+        ));
+
+        $pass_current = array('Password', 'account_password_current', array(
+                'label' => __("current password")));
+
+        $submit = array('Submit', 'account_submit', array('label' => __("modify my informations")));
+
+        $this->addElements(array($email, $pass, $pass_confirm, $pass_current, $submit));
+        $this->account_submit->setDecorators(array('ViewHelper'));
+
+        // fieldset around form
+        $this->addDisplayGroup(array_keys($this->_elements), 'main',
+            array('decorators' => array('FormElements',
+                                 array('fieldset'))));
+
+    }
+}
diff --git a/application/forms/Contact.php b/application/forms/Contact.php
new file mode 100644 (file)
index 0000000..aed73e3
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Form_Contact extends Zend_Form
+{
+
+    protected $_decorators = array(
+                            'FormElements' => array('decorator' => 'FormElements', 'options' => null),
+                            'Form' => array('decorator' => 'Form', 'options' => array()));
+
+    protected $_elementDecorators = array(
+                                'ViewHelper',
+                                'Errors' => array('decorator' => 'Errors', 'options' => array('class' => 'error')),
+                                array(array('lbreak1' => 'HtmlTag'), array('tag' => 'br', 'openOnly' => true)),
+                                'Label',
+                                array(array('lbreak2' => 'HtmlTag'), array('tag' => 'br', 'placement' => 'APPEND', 'openOnly' => true)),
+                                );
+
+    public function init() {
+        $formErrors = $this->getView()->getHelper('FormErrors');
+        $formErrors->setElementStart("<div%s>")
+                   ->setElementEnd("</div>")
+                   ->setElementSeparator("<br>");
+
+        // required needs following string to be translated
+        __("Value is required and can't be empty");
+
+        // we are less strict than Zend_Validate_Email because we want a user
+        // with a strange email to be able to still contact us with the form
+        $emailValidator = new Zend_Validate_Regex('/^[A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}$/i');
+        $emailValidator->setMessage(__("Invalid email"), $emailValidator::NOT_MATCH);
+        $email = array('Text', 'contact_email', array(
+             'required' => 'true',
+             'validators' => array($emailValidator),
+            'label' => __("Email:")));
+
+        $maxSubjLength = 80;
+        $subjectValidator = new Zend_Validate_StringLength(0, $maxSubjLength);
+        $subjectValidator->setMessage(__("Subject must be %max% characters long or less",$subjectValidator::TOO_LONG));
+        $subject = array('Text', 'contact_subject', array(
+             'required' => 'true',
+             'maxlength' => $maxSubjLength,
+             'validators' => array($subjectValidator),
+            'label' => __("Subject:")));
+
+        $contentFilter = new Zend_Filter_PregReplace('/\r\n/', "\n");
+        $content = array('Textarea', 'contact_content', array(
+            'label' => __("Message:"),
+            'cols' => 40,
+            'filters' => array($contentFilter),
+            'required' => 'true',
+            'rows' => 10));
+
+        $submit = array('Submit', 'contact_submit', array(
+            'label' => __("Send"),
+            'decorators' => array('ViewHelper')));
+
+        $this->addElements(array($email, $subject, $content, $submit));
+
+        // fieldset around form
+        $this->addDisplayGroup(array_keys($this->_elements), 'main',
+            array('decorators' => array('FormElements',
+                                 array('fieldset', array('legend' => __("Send a message")))
+        )));
+    }
+
+}
diff --git a/application/forms/Geom.php b/application/forms/Geom.php
new file mode 100644 (file)
index 0000000..751d798
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Form_Geom extends Zend_Form
+{
+    protected $_elementDecorators = array( 'ViewHelper', 'Errors',);
+
+    protected $_decorators = array(
+                            'FormElements' => array('decorator' => 'FormElements', 'options' => null),
+                            'Form' => array('decorator' => 'Form', 'options' => null)
+                            );
+
+    public function init() {
+        $id = array('Hidden', 'geom_id');
+        $data = array('Hidden', 'geom_data', array('required' => true));
+
+        $title = array('Text', 'geom_title', array(
+            'label' => __("optional title for this journey"),
+            'attribs' => array('maxlength' => '40', 'size' => '20'),
+            'validators' => array(new Zend_Validate_StringLength(0, 40))
+            ));
+        $submit = array('Submit', 'geom_submit', array('label' => __("save")));
+
+        $this->addElements(array($id, $data, $title, $submit));
+
+        // fieldset around title
+        //$this->addDisplayGroup(array('geom_title'), 'metadata', array('decorators' => array('FormElements', 'Fieldset')));
+
+        $this->geom_title->addDecorator('HtmlTag', array('tag' => 'br', 'openOnly' => true))->
+            addDecorator('label');
+        $this->geom_submit->addDecorator('HtmlTag', array('tag' => 'br', 'openOnly' => true));
+
+    }
+}
diff --git a/application/forms/Login.php b/application/forms/Login.php
new file mode 100644 (file)
index 0000000..b42f8ba
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Form_Login extends Syj_Form_TableAbstract
+{
+
+    public function init() {
+        $user = array('Text', 'login_user', array( 'label' => __("user"), 'required' => true));
+        $pass = array('Password', 'login_password', array( 'label' => __("password")));
+
+
+        $this->setMainElements(array($user, $pass))
+             ->addElement('Hidden', 'login_geom_id', array( 'decorators' => array('ViewHelper')));
+
+        $currentUri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
+        if (strpos($currentUri, '?') !== false) {
+            $currentUri = strstr($currentUri, '?', true);
+        }
+        $href = $this->getView()->addParamToUrl('newpwd', 'redirect', $currentUri, true);
+
+        $anchor = $this->getView()->Anchor($href,
+                                    $this->getTranslator()->translate("I forgot my password"),
+                                    array('id' => 'newpwd_control_anchor'));
+
+        $this->addElement('Submit', 'login_submit', array('label' => __("login"), 'description' => $anchor));
+        $decorator = $this->login_submit->getDecorator('Description');
+        $decorator->setOption('escape', false);
+    }
+
+}
diff --git a/application/forms/Newpwd.php b/application/forms/Newpwd.php
new file mode 100644 (file)
index 0000000..3acb1cc
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Form_Newpwd extends Syj_Form_TableAbstract
+{
+    protected $_elementDecorators = array(
+                          'ViewHelper',
+                          array(array('td' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 100%' )),
+                          array('label', array('tag' => 'td')),
+                          array(array('tr' => 'HtmlTag'), array('tag' => 'tr')),
+                          array('TableDescription'),
+                          'Errors' => array('decorator' => 'Errors', 'options' => array('class' => 'error')),
+                          );
+
+    protected $_decorators = array(
+                            'FormElements' => array('decorator' => 'FormElements', 'options' => null),
+                            'Form' => array('decorator' => 'Form', 'options' => null),
+                            );
+
+
+    public function init() {
+        $formErrors = $this->getView()->getHelper('FormErrors');
+        $formErrors->setElementStart("<div%s>")
+                   ->setElementEnd("</div>")
+                   ->setElementSeparator("<br>");
+
+        $user = array('Text', 'newpwd_email', array( 'label' => __("email"),
+                                                     'required' => true,
+                                                     'maxlength' => 320
+                                                     ));
+        $this->setMainElements(array($user));
+        $this->addElement('Submit', 'newpwd_submit', array('label' => __("reset my password")));
+    }
+}
+
diff --git a/application/forms/Pending.php b/application/forms/Pending.php
new file mode 100644 (file)
index 0000000..0336a8a
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+abstract class Syj_Form_Pending extends Zend_Form
+{
+    protected $_pending = null;
+
+    protected $_elementDecorators = array(
+                          array('Description', array('tag' => '', 'escape' => false)),
+                          array(array('br' => 'HtmlTag'), array('tag' => 'br', 'placement' => 'APPEND', 'openOnly' => true)),
+                          'ViewHelper',
+                          array(array('p' => 'HtmlTag'), array('tag' => 'p', 'class' => 'desc')),
+                          );
+
+    protected $_decorators = array(
+                            'FormElements' => array('decorator' => 'FormElements', 'options' => null),
+                            'Form' => array('decorator' => 'Form', 'options' => array('class' => 'center'))
+                            );
+
+    public function __construct(Syj_Model_Pending $pending, $options = null) {
+        $this->_pending = $pending;
+        parent::__construct($options);
+    }
+
+    public function init() {
+        $activate = array('Submit', 'pending_validate', $this->getActivateOptions());
+        $cancel = array('Submit', 'pending_cancel', $this->getCancelOptions());
+        $this->addElements(array($activate, $cancel));
+    }
+
+    abstract protected function getActivateOptions();
+
+    abstract protected function getCancelOptions();
+
+}
diff --git a/application/forms/Pending/ResetPassword.php b/application/forms/Pending/ResetPassword.php
new file mode 100644 (file)
index 0000000..91b0a73
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Form_Pending_ResetPassword extends Syj_Form_Pending
+{
+    protected function getActivateOptions() {
+        $user = $this->_pending->user;
+
+        $translator = $this->getTranslator();
+        $activatetext = $translator->translate("Hi %s. Someone, probably you, has asked to reset password for your account. To get a new password, validate with following button.");
+        $pseudo = htmlspecialchars($user->pseudo);
+        $activatetext = vsprintf ($activatetext, array($pseudo));
+
+        return array(
+                'label' => __("reset my password"),
+                'description' => $activatetext);
+
+    }
+
+    protected function getCancelOptions() {
+        return array(
+                'label' => __("cancel request"),
+                'description' => __("To cancel this request, press following button. Your password will not change.")
+                );
+    }
+}
diff --git a/application/forms/Pending/ValidateCreation.php b/application/forms/Pending/ValidateCreation.php
new file mode 100644 (file)
index 0000000..6746f6d
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Form_Pending_ValidateCreation extends Syj_Form_Pending
+{
+   protected function getActivateOptions() {
+        $user = $this->_pending->user;
+
+        $translator = $this->getTranslator();
+        $activatetext = $translator->translate("Someone, probably you, has registered an account %s with email address %s on syj. To confirm this account creation, validate with following button.");
+        $pseudo = '<strong>' . htmlspecialchars('"' . $user->pseudo . '"') . '</strong>';
+        $email = '<strong>' . htmlspecialchars('"' . $user->email . '"') . '</strong>';
+        $activatetext = vsprintf ($activatetext, array($pseudo, $email));
+
+        return array(
+                'label' => __("save"),
+                'description' => $activatetext);
+    }
+
+    protected function getCancelOptions() {
+        return array(
+                'label' => __("delete"),
+                'description' => __("To cancel account creation, press following button. The account and all its data will be deleted.")
+                );
+    }
+}
diff --git a/application/forms/TableAbstract.php b/application/forms/TableAbstract.php
new file mode 100644 (file)
index 0000000..3f51c1d
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+abstract class Syj_Form_TableAbstract extends Zend_Form
+{
+    protected $_elementDecorators = array(
+                          'ViewHelper',
+                          array(array('td' => 'HtmlTag'), array('tag' => 'td', 'style' => 'width: 100%' )),
+                          array('label', array('tag' => 'td')),
+                          array(array('tr' => 'HtmlTag'), array('tag' => 'tr')),
+                          array('TableDescription'));
+
+    protected $_decorators = array(
+                            'FormErrors' => array('decorator' => 'FormErrors', 'options' => null),
+                            'FormElements' => array('decorator' => 'FormElements', 'options' => null),
+                            'Form' => array('decorator' => 'Form', 'options' => null),
+                            );
+
+    protected $_displaygroupDecorators = array(
+                'FormElements',
+                array('HtmlTag', array('tag' => 'table')));
+
+    protected $_defaultClassName = "form-table-elem";
+
+    public function __construct($options = null) {
+        $this->addPrefixPath('Syj_Form_Decorator', APPLICATION_PATH . '/forms/decorator/', 'decorator');
+        parent::__construct($options);
+    }
+
+    protected function setMainElements(array $elements) {
+        $this->setElements($elements);
+        $this->addDisplayGroup(array_map(function ($elem) { return $elem[1]; }, $elements), 'data');
+        $this->setDisplayGroupDecorators($this->_displaygroupDecorators);
+
+        return $this;
+    }
+
+    public function addElement($element, $name = null, $options = null)
+    {
+        $res = parent::addElement($element, $name, $options);
+        if ($element instanceof Zend_Form_Element) {
+            $name = $element->getName();
+        }
+        $element = $this->_elements[$name];
+        if ($element instanceof Zend_Form_Element_Text or $element instanceof Zend_Form_Element_Password) {
+            if ($this->getAttrib('class') === null) {
+                $element->setAttrib('class', $this->_defaultClassName);
+            }
+        } else if ($element instanceof Zend_Form_Element_Submit) {
+            $element->setDecorators(array(
+                        'ViewHelper',
+                        array('Description', array('tag' => '')),
+                        array('HtmlTag', array('tag' => 'p', 'class' => 'center')),
+                        ));
+        }
+        return $res;
+    }
+}
diff --git a/application/forms/User.php b/application/forms/User.php
new file mode 100644 (file)
index 0000000..b74258a
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Form_User extends Syj_Form_TableAbstract
+{
+    public function init() {
+        $translator = $this->getTranslator();
+
+        $name = array('Text', 'user_pseudo', array(
+            'label' => __("user name"),
+            'attribs' => array('maxlength' => '20'),
+            'validators' => array(new Zend_Validate_StringLength(0, 20),
+                                 new Zend_Validate_Regex('/^[a-zA-Z0-9_\.]+$/')),
+            'required' => true
+        ));
+
+        $desc = $translator->translate("At least %d characters");
+        $desc = vsprintf($desc, 6);
+        $pass = array('Password', 'user_password', array(
+            'label' => __("password"),
+            'required' => true,
+            'description' => $desc,
+            'validators' => array(new Zend_Validate_StringLength(6))
+        ));
+
+        $pass_confirm = array('Password', 'user_password_confirm', array(
+                'label' => __("confirm password"),
+                'validators' => array(new Zend_Validate_Identical('user_password')),
+                'required' => true
+        ));
+
+        $email = array('Text', 'user_email', array(
+            'label' => __("email"),
+            'description' => __("After creating your account, you will receive a confirmation email. You have 7 days to confirm otherwise, your account and your routes will all be deleted."),
+            'required' => true
+            ));
+
+        $this->setMainElements(array($name, $pass, $pass_confirm, $email));
+
+        $anchor = $this->getView()->Anchor("termsofuse", $translator->translate("terms of use"), array('id' => 'user_termsofuse_anchor'));
+        $text = $translator->translate("I've read and accepted %s");
+        $text = vsprintf($text, $anchor);
+        $this->addElement('Checkbox', 'user_accept', array("label" => $text,
+                            'decorators' => array(
+                                  'ViewHelper',
+                                  'label',
+                                  array('HtmlTag', array('tag' => 'div'))),
+                            'validators' => array(new Zend_Validate_Identical('1'))));
+
+        $decorator = $this->user_accept->getDecorator('Zend_Form_Decorator_Label');
+        $decorator->setOption('escape', false);
+
+        $this->addElement('Submit', 'user_submit', array('label' => __("create account")));
+    }
+}
diff --git a/application/forms/decorator/TableDescription.php b/application/forms/decorator/TableDescription.php
new file mode 100644 (file)
index 0000000..d7ee7f8
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+require_once 'Zend/Form/Decorator/Description.php';
+require_once 'Zend/Form/Decorator/HtmlTag.php';
+
+/*
+ * wraps description content in a <td> tag then in a <tr> tag
+ */
+class Syj_Form_Decorator_TableDescription extends Zend_Form_Decorator_Description
+{
+
+    public function getClass()
+    {
+        $class = $this->getOption('class');
+        if (null === $class) {
+            $class = 'message';
+            $this->setOption('class', $class);
+        }
+
+        return $class;
+    }
+
+    public function render($content)
+    {
+        $element = $this->getElement();
+        $view    = $element->getView();
+        if (null === $view) {
+            return $content;
+        }
+
+        $description = $element->getDescription();
+        $description = trim($description);
+
+        if (!empty($description) && (null !== ($translator = $element->getTranslator()))) {
+            $description = $translator->translate($description);
+        }
+
+        if (empty($description)) {
+            return $content;
+        }
+
+        $separator = $this->getSeparator();
+        $placement = $this->getPlacement();
+        $class     = $this->getClass();
+        $escape    = $this->getEscape();
+
+        $options   = $this->getOptions();
+
+        if ($escape) {
+            $description = $view->escape($description);
+        }
+
+        $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'div',
+                            'id'  => $this->getElement()->getName() . '-desc',
+                            'class' => $class));
+        $description = $decorator->render($description);
+        $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'td'));
+        $description = $decorator->render($description);
+        $description = '<td>&nbsp;</td>' . $description;
+        $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'tr'));
+        $description = $decorator->render($description);
+
+        switch ($placement) {
+            case self::PREPEND:
+                return $description . $separator . $content;
+            case self::APPEND:
+            default:
+                return $content . $separator . $description;
+        }
+    }
+
+}
diff --git a/application/languages/lang_en.po b/application/languages/lang_en.po
new file mode 100644 (file)
index 0000000..9b8ff7b
--- /dev/null
@@ -0,0 +1,603 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: syj\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-07-23 10:53+0200\n"
+"PO-Revision-Date: \n"
+"Last-Translator: arno <arno@renevier.net>\n"
+"Language-Team: arno <arno@renevier.net>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: English\n"
+"X-Poedit-Country: UNITED STATES\n"
+"X-Poedit-SourceCharset: utf-8\n"
+"X-Poedit-KeywordsList: translate;__\n"
+"X-Poedit-Basepath: application\n"
+"X-Poedit-Bookmarks: 5,-1,-1,-1,-1,-1,-1,-1,-1,-1\n"
+"X-Poedit-SearchPath-0: application\n"
+
+#: application/views/scripts/error/error.phtml:1
+msgid "An error occurred"
+msgstr "An error occurred"
+
+#: application/views/scripts/error/error.phtml:23
+msgid "Please try again later"
+msgstr "Please try again later"
+
+#: application/views/scripts/error/error.phtml:25
+#: application/views/scripts/pending/password_cancel.phtml:15
+#: application/views/scripts/pending/creation_validate.phtml:15
+#: application/views/scripts/pending/creation_cancel.phtml:15
+#: application/views/helpers/Returnto.php:23
+#: application/views/helpers/Returnto.php:31
+msgid "go to main page"
+msgstr "go to main page"
+
+#: application/views/scripts/contact/index.phtml:7
+#, php-format
+msgid "There was an unkwown message when sending the message. Please try again later, or send a mail directly to <a href=\"mailto:%s\">%s</a>"
+msgstr "There was an unkwown message when sending the message. Please try again later, or send a mail directly to <a href=\"mailto:%s\">%s</a>"
+
+#: application/views/scripts/contact/success.phtml:4
+msgid "Email was send successfully"
+msgstr "Email was send successfully"
+
+#: application/views/scripts/idx/index.phtml:8
+msgid "SYJ needs javascript. Please activate scripts in your browser."
+msgstr "SYJ needs javascript. Please activate scripts in your browser."
+
+#: application/views/scripts/idx/index.phtml:14
+#: application/controllers/LoginController.php:8
+#: application/layouts/scripts/footer.phtml:61
+#: application/forms/Login.php:26
+msgid "login"
+msgstr "login"
+
+#: application/views/scripts/idx/index.phtml:17
+#: application/views/scripts/idx/index.phtml:69
+msgid "create an account"
+msgstr "create an account"
+
+#: application/views/scripts/idx/index.phtml:30
+msgid "Welcome on Syj."
+msgstr "Welcome on Syj."
+
+#: application/views/scripts/idx/index.phtml:32
+msgid "To create a journey, just click on the map to add points to your route. You can zoom and move map with controls upper left."
+msgstr "To create a journey, just click on the map to add points to your route. You can zoom and move map with controls upper left."
+
+#: application/views/scripts/idx/index.phtml:34
+msgid "When you have finished a path, press \"save\", button."
+msgstr "When you have finished a path, press \"save\", button."
+
+#: application/views/scripts/idx/index.phtml:40
+msgid "edit"
+msgstr "edit"
+
+#: application/views/scripts/termsofuse/index.phtml:2
+msgid "Show Your Journey is a site whose goal is to allow anyone to publish routes, for example, hiking itinerary, bicycle trip, travel itinerary or whatever."
+msgstr "Show Your Journey is a site whose goal is to allow anyone to publish routes, for example, hiking itinerary, bicycle trip, travel itinerary or whatever."
+
+#: application/views/scripts/termsofuse/index.phtml:6
+msgid "In order to publish a route, you must first create an account.  A valid email is asked for, and ip address of account creation is stored on the server. Those informations will not be divulged to anyone without the user explicit permission."
+msgstr "In order to publish a route, you must first create an account.  A valid email is asked for, and ip address of account creation is stored on the server. Those informations will not be divulged to anyone without the user explicit permission."
+
+#: application/views/scripts/termsofuse/index.phtml:10
+msgid "When you create a route, you accept that it's available under a <a href=\"http://creativecommons.org/licenses/by/2.0/\">creative commons <strong>by</strong> license</a>. This means you accept that anyone can reproduce and republish your itinerary, or a modified version of it, under the condition that he specify the proper creator of this work. This also means you need to get appropriate permissions from the creator if you want to upload a route you didn't create yourself."
+msgstr "When you create a route, you accept that it's available under a <a href=\"http://creativecommons.org/licenses/by/2.0/\">creative commons <strong>by</strong> license</a>. This means you accept that anyone can reproduce and republish your itinerary, or a modified version of it, under the condition that he specify the proper creator of this work. This also means you need to get appropriate permissions from the creator if you want to upload a route you didn't create yourself."
+
+#: application/views/scripts/termsofuse/index.phtml:14
+msgid "Show Your Journey is not responsible for the accuracy of the routes published.  It's the user responsibility to check that a route is accessible and safe."
+msgstr "Show Your Journey is not responsible for the accuracy of the routes published.  It's the user responsibility to check that a route is accessible and safe."
+
+#: application/views/scripts/termsofuse/index.phtml:18
+msgid "Sources of the software running the website are <a href=\"http://dev.renevier.net/?p=syj.git\">publicly available</a> under a agpl license. The map used to display the routes comes from <a href=\"http://www.openstreetmap.org/\">openstreetmap</a>."
+msgstr "Sources of the software running the website are <a href=\"http://dev.renevier.net/?p=syj.git\">publicly available</a> under a agpl license. The map used to display the routes comes from <a href=\"http://www.openstreetmap.org/\">openstreetmap</a>."
+
+#: application/views/scripts/newpwd/success.phtml:4
+#: application/controllers/IdxController.php:119
+msgid "A link to reset your password has been emailed to you"
+msgstr "A link to reset your password has been emailed to you"
+
+#: application/views/scripts/pending/password_cancel.phtml:12
+msgid "You have canceled the request."
+msgstr "You have canceled the request."
+
+#: application/views/scripts/pending/password_cancel.phtml:14
+#: application/views/scripts/pending/creation_validate.phtml:14
+#: application/views/scripts/pending/creation_cancel.phtml:14
+#: application/views/helpers/Returnto.php:22
+#: application/views/helpers/Returnto.php:25
+#: application/views/helpers/Returnto.php:28
+msgid "You can now"
+msgstr "You can now"
+
+#: application/views/scripts/pending/creation_validate.phtml:12
+msgid "You have validated your account."
+msgstr "You have validated your account."
+
+#: application/views/scripts/pending/index.phtml:15
+msgid "If you need more informations, please"
+msgstr "If you need more informations, please"
+
+#: application/views/scripts/pending/index.phtml:16
+msgid "contact us"
+msgstr "contact us"
+
+#: application/views/scripts/pending/creation_cancel.phtml:12
+msgid "You have canceled the account."
+msgstr "You have canceled the account."
+
+#: application/views/scripts/pending/password_validate.phtml:17
+msgid "log in"
+msgstr "log in"
+
+#: application/views/scripts/pending/password_validate.phtml:15
+#, php-format
+msgid "Your new password is now <strong>%s</strong>. You can %s with this new password. Don't forget to change it again to a personal password as soon as possible."
+msgstr "Your new password is now <strong>%s</strong>. You can %s with this new password. Don't forget to change it again to a personal password as soon as possible."
+
+#: application/views/scripts/account/success.phtml:4
+msgid "Your account was modified successfully"
+msgstr "Your account was modified successfully"
+
+#: application/views/helpers/LogoutLink.php:12
+#: application/layouts/scripts/footer.phtml:52
+msgid "logout"
+msgstr "logout"
+
+# This is language name. translate english to the name of your language. For example: "deutsch" or "français"
+#: application/views/helpers/LocaleSwitcher.php:17
+msgid "english"
+msgstr "english"
+
+#: application/views/helpers/Returnto.php:26
+#: application/views/helpers/Returnto.php:29
+#, php-format
+msgid "go back to %s"
+msgstr "go back to %s"
+
+#: application/views/helpers/Returnto.php:30
+msgid "or you can"
+msgstr "or you can"
+
+#: application/models/Pending/ResetPassword.php:19
+msgid "[SYJ] Reset your password"
+msgstr "[SYJ] Reset your password"
+
+#: application/models/Pending/ResetPassword.php:20
+msgid ""
+"Hi %user%,\n"
+"\n"
+"Someone, probably you, has asked to reset your password. If you want to reset\n"
+"your password, please follow this link:\n"
+"%hashurl%\n"
+"\n"
+"If you do not not confirm within 2 days, your password will not be reset.\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Thanks,\n"
+"\n"
+"Syj team"
+msgstr ""
+"Hi %user%,\n"
+"\n"
+"Someone, probably you, has asked to reset your password. If you want to reset\n"
+"your password, please follow this link:\n"
+"%hashurl%\n"
+"\n"
+"If you do not not confirm within 2 days, your password will not be reset.\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Thanks,\n"
+"\n"
+"Syj team"
+
+#: application/models/Pending/ValidateCreation.php:15
+msgid "[SYJ] Validate your account"
+msgstr "[SYJ] Validate your account"
+
+#: application/models/Pending/ValidateCreation.php:16
+msgid ""
+"Hi %user%, and welcome on syj\n"
+"\n"
+"Your account is currently active, but you need to confirm your inscription by\n"
+"following this link:\n"
+"%hashurl%\n"
+"\n"
+"If you do not not confirm your inscription within 7 days, your account and all\n"
+"your items will be deleted.\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Thanks,\n"
+"\n"
+"Syj team"
+msgstr ""
+"Hi %user%, and welcome on syj\n"
+"\n"
+"Your account is currently active, but you need to confirm your inscription by\n"
+"following this link:\n"
+"%hashurl%\n"
+"\n"
+"If you do not not confirm your inscription within 7 days, your account and all\n"
+"your items will be deleted.\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Thanks,\n"
+"\n"
+"Syj team"
+
+#: application/models/Pending/ValidateCreation.php:34
+msgid "[SYJ] Reminder: Validate your account"
+msgstr "[SYJ] Reminder: Validate your account"
+
+#: application/models/Pending/ValidateCreation.php:35
+msgid ""
+"Hi %user%,\n"
+"\n"
+"You need to validate your account on syj since 6 days. Otherwise, your\n"
+"account will be deleted tomorrow. Please follow this link:\n"
+"%hashurl%\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Thanks,\n"
+"\n"
+"Syj team"
+msgstr ""
+"Hi %user%,\n"
+"\n"
+"You need to validate your account on syj since 6 days. Otherwise, your\n"
+"account will be deleted tomorrow. Please follow this link:\n"
+"%hashurl%\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Thanks,\n"
+"\n"
+"Syj team"
+
+#: application/models/Pending/ValidateCreation.php:51
+msgid "[SYJ] Account deactivated"
+msgstr "[SYJ] Account deactivated"
+
+#: application/models/Pending/ValidateCreation.php:52
+msgid ""
+"Hi %user%,\n"
+"\n"
+"You have not validated your syj account on time. Therefore, your account and\n"
+"all your data have been deleted. Nevertheless, you can still create a new\n"
+"account.\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Regards,\n"
+"\n"
+"Syj team"
+msgstr ""
+"Hi %user%,\n"
+"\n"
+"You have not validated your syj account on time. Therefore, your account and\n"
+"all your data have been deleted. Nevertheless, you can still create a new\n"
+"account.\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Regards,\n"
+"\n"
+"Syj team"
+
+#: application/controllers/LoginController.php:95
+#: application/controllers/IdxController.php:105
+msgid "you must enter a login name"
+msgstr "you must enter a login name"
+
+#: application/controllers/PendingController.php:32
+msgid "account validated"
+msgstr "account validated"
+
+#: application/controllers/PendingController.php:39
+msgid "account deleted"
+msgstr "account deleted"
+
+#: application/controllers/PendingController.php:43
+msgid "account creation validation"
+msgstr "account creation validation"
+
+#: application/controllers/PendingController.php:53
+msgid "password changed"
+msgstr "password changed"
+
+#: application/controllers/PendingController.php:64
+msgid "request canceled"
+msgstr "request canceled"
+
+#: application/controllers/PendingController.php:68
+msgid "password reset validation"
+msgstr "password reset validation"
+
+#: application/controllers/ContactController.php:13
+msgid "contact form"
+msgstr "contact form"
+
+#: application/controllers/ContactController.php:112
+msgid "Hi,"
+msgstr "Hi,"
+
+#: application/controllers/ContactController.php:121
+#: application/controllers/NewpwdController.php:68
+#: application/controllers/AccountController.php:74
+#: application/forms/Contact.php:27
+msgid "Value is required and can't be empty"
+msgstr "Value is required and can't be empty"
+
+#: application/controllers/ContactController.php:122
+#: application/forms/Contact.php:32
+#: application/validate/EmailAddress.php:13
+msgid "Invalid email"
+msgstr "Invalid email"
+
+#: application/controllers/ErrorController.php:55
+msgid "Oups, something went wrong"
+msgstr "Oups, something went wrong"
+
+#: application/controllers/TermsofuseController.php:12
+#: application/layouts/scripts/footer.phtml:74
+#: application/forms/User.php:41
+msgid "terms of use"
+msgstr "terms of use"
+
+#: application/controllers/AccountController.php:13
+#: application/layouts/scripts/footer.phtml:46
+msgid "my account"
+msgstr "my account"
+
+#: application/controllers/AccountController.php:34
+msgid "Wrong password"
+msgstr "Wrong password"
+
+#: application/controllers/AccountController.php:47
+#: application/controllers/IdxController.php:117
+msgid "an user is already registered with this email"
+msgstr "an user is already registered with this email"
+
+#: application/controllers/AccountController.php:75
+#: application/controllers/IdxController.php:111
+#: application/forms/Account.php:40
+msgid "Password do not match"
+msgstr "Password do not match"
+
+#: application/controllers/AccountController.php:76
+#: application/forms/Account.php:33
+#: application/forms/User.php:18
+#, php-format
+msgid "At least %d characters"
+msgstr "At least %d characters"
+
+#: application/controllers/AccountController.php:77
+msgid "You have made no change"
+msgstr "You have made no change"
+
+#: application/controllers/IdxController.php:98
+msgid "save took place successfully"
+msgstr "save took place successfully"
+
+#: application/controllers/IdxController.php:99
+msgid "server did not understood request. That's probably caused by a bug in SYJ"
+msgstr "server did not understood request. That's probably caused by a bug in SYJ"
+
+#: application/controllers/IdxController.php:100
+msgid "path did not exist in the server. May be it has been already deleted"
+msgstr "path did not exist in the server. May be it has been already deleted"
+
+#: application/controllers/IdxController.php:101
+msgid "similar path seems to already exist. Please do not create two exactly identical paths"
+msgstr "similar path seems to already exist. Please do not create two exactly identical paths"
+
+#: application/controllers/IdxController.php:102
+msgid "server could not be reached"
+msgstr "server could not be reached"
+
+#: application/controllers/IdxController.php:103
+msgid "there was a server error"
+msgstr "there was a server error"
+
+#: application/controllers/IdxController.php:104
+msgid "there was an unknown error"
+msgstr "there was an unknown error"
+
+#: application/controllers/IdxController.php:106
+msgid "Login correct"
+msgstr "Login correct"
+
+#: application/controllers/IdxController.php:107
+msgid "Wrong login/password"
+msgstr "Wrong login/password"
+
+#: application/controllers/IdxController.php:108
+msgid "You need to login before retrying to save"
+msgstr "You need to login before retrying to save"
+
+#: application/controllers/IdxController.php:109
+msgid "You need to have cookies enabled to login to SYJ"
+msgstr "You need to have cookies enabled to login to SYJ"
+
+#: application/controllers/IdxController.php:110
+msgid "you must enter a password"
+msgstr "you must enter a password"
+
+#: application/controllers/IdxController.php:112
+msgid "You must accept terms of use"
+msgstr "You must accept terms of use"
+
+#: application/controllers/IdxController.php:113
+msgid "you must enter an email"
+msgstr "you must enter an email"
+
+#: application/controllers/IdxController.php:114
+msgid "invalid email"
+msgstr "invalid email"
+
+#: application/controllers/IdxController.php:115
+msgid "pseudo must only contain letters, digits, dots or underscores"
+msgstr "pseudo must only contain letters, digits, dots or underscores"
+
+#: application/controllers/IdxController.php:116
+msgid "unavailable pseudo"
+msgstr "unavailable pseudo"
+
+#: application/controllers/IdxController.php:118
+msgid "Account created"
+msgstr "Account created"
+
+#: application/controllers/IdxController.php:120
+msgid "Now, you can retry to save"
+msgstr "Now, you can retry to save"
+
+#: application/controllers/IdxController.php:121
+msgid "route by"
+msgstr "route by"
+
+#: application/controllers/IdxController.php:122
+msgid "Map by <a href='http://openstreetmap.org/'>OpenStreetMap</a>"
+msgstr "Map by <a href='http://openstreetmap.org/'>OpenStreetMap</a>"
+
+#: application/layouts/scripts/footer.phtml:24
+msgid "main page"
+msgstr "main page"
+
+#: application/layouts/scripts/footer.phtml:35
+msgid "contact"
+msgstr "contact"
+
+#: application/forms/Login.php:9
+msgid "user"
+msgstr "user"
+
+#: application/forms/Login.php:10
+#: application/forms/Account.php:35
+#: application/forms/User.php:21
+msgid "password"
+msgstr "password"
+
+#: application/forms/Login.php:23
+msgid "I forgot my password"
+msgstr "I forgot my password"
+
+#: application/forms/Contact.php:36
+msgid "Email:"
+msgstr "Email:"
+
+#: application/forms/Contact.php:40
+msgid "Subject must be %max% characters long or less"
+msgstr "Subject must be %max% characters long or less"
+
+#: application/forms/Contact.php:45
+msgid "Subject:"
+msgstr "Subject:"
+
+#: application/forms/Contact.php:49
+msgid "Message:"
+msgstr "Message:"
+
+#: application/forms/Contact.php:56
+msgid "Send"
+msgstr "Send"
+
+#: application/forms/Contact.php:64
+msgid "Send a message"
+msgstr "Send a message"
+
+#: application/forms/Geom.php:19
+msgid "optional title for this journey"
+msgstr "optional title for this journey"
+
+#: application/forms/Geom.php:23
+#: application/forms/Pending/ValidateCreation.php:17
+msgid "save"
+msgstr "save"
+
+#: application/forms/Account.php:27
+#: application/forms/User.php:34
+#: application/forms/Newpwd.php:28
+msgid "email"
+msgstr "email"
+
+#: application/forms/Account.php:42
+#: application/forms/User.php:28
+msgid "confirm password"
+msgstr "confirm password"
+
+#: application/forms/Account.php:48
+msgid "current password"
+msgstr "current password"
+
+#: application/forms/Account.php:50
+msgid "modify my informations"
+msgstr "modify my informations"
+
+#: application/forms/User.php:11
+msgid "user name"
+msgstr "user name"
+
+#: application/forms/User.php:35
+msgid "After creating your account, you will receive a confirmation email. You have 7 days to confirm otherwise, your account and your routes will all be deleted."
+msgstr "After creating your account, you will receive a confirmation email. You have 7 days to confirm otherwise, your account and your routes will all be deleted."
+
+#: application/forms/User.php:42
+#, php-format
+msgid "I've read and accepted %s"
+msgstr "I've read and accepted %s"
+
+#: application/forms/User.php:54
+msgid "create account"
+msgstr "create account"
+
+#: application/forms/Pending/ResetPassword.php:11
+#, php-format
+msgid "Hi %s. Someone, probably you, has asked to reset password for your account. To get a new password, validate with following button."
+msgstr "Hi %s. Someone, probably you, has asked to reset password for your account. To get a new password, validate with following button."
+
+#: application/forms/Pending/ResetPassword.php:16
+#: application/forms/Newpwd.php:33
+msgid "reset my password"
+msgstr "reset my password"
+
+#: application/forms/Pending/ResetPassword.php:23
+msgid "cancel request"
+msgstr "cancel request"
+
+#: application/forms/Pending/ResetPassword.php:24
+msgid "To cancel this request, press following button. Your password will not change."
+msgstr "To cancel this request, press following button. Your password will not change."
+
+#: application/forms/Pending/ValidateCreation.php:11
+#, php-format
+msgid "Someone, probably you, has registered an account %s with email address %s on syj. To confirm this account creation, validate with following button."
+msgstr "Someone, probably you, has registered an account %s with email address %s on syj. To confirm this account creation, validate with following button."
+
+#: application/forms/Pending/ValidateCreation.php:23
+msgid "delete"
+msgstr "delete"
+
+#: application/forms/Pending/ValidateCreation.php:24
+msgid "To cancel account creation, press following button. The account and all its data will be deleted."
+msgstr "To cancel account creation, press following button. The account and all its data will be deleted."
+
+#~ msgid "reset password"
+#~ msgstr "reset password"
+
diff --git a/application/languages/lang_fr.po b/application/languages/lang_fr.po
new file mode 100644 (file)
index 0000000..11356d8
--- /dev/null
@@ -0,0 +1,606 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: syj\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-07-23 10:53+0200\n"
+"PO-Revision-Date: \n"
+"Last-Translator: arno <arno@renevier.net>\n"
+"Language-Team: arno <arno@renevier.net>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: French\n"
+"X-Poedit-Country: FRANCE\n"
+"X-Poedit-SourceCharset: utf-8\n"
+"X-Poedit-KeywordsList: translate;__\n"
+"X-Poedit-Basepath: application\n"
+"X-Poedit-Bookmarks: -1,-1,-1,-1,13,-1,-1,-1,-1,-1\n"
+"X-Poedit-SearchPath-0: application\n"
+
+#: application/views/scripts/error/error.phtml:1
+msgid "An error occurred"
+msgstr "Il s'est produit une erreur"
+
+#: application/views/scripts/error/error.phtml:23
+msgid "Please try again later"
+msgstr "Veuillez réessayer plus tard"
+
+#: application/views/scripts/error/error.phtml:25
+#: application/views/scripts/pending/password_cancel.phtml:15
+#: application/views/scripts/pending/creation_validate.phtml:15
+#: application/views/scripts/pending/creation_cancel.phtml:15
+#: application/views/helpers/Returnto.php:23
+#: application/views/helpers/Returnto.php:31
+msgid "go to main page"
+msgstr "aller à la page d'accueil"
+
+#: application/views/scripts/contact/index.phtml:7
+#, php-format
+msgid "There was an unkwown message when sending the message. Please try again later, or send a mail directly to <a href=\"mailto:%s\">%s</a>"
+msgstr "Il s'est produit une erreur inconnue lors de l'envoi du message. Merci de réessayer plus tard, ou d'écrire directement à <a href=\"mailto:%s\">%s</a>"
+
+#: application/views/scripts/contact/success.phtml:4
+msgid "Email was send successfully"
+msgstr "L'email a été envoyé avec succès"
+
+#: application/views/scripts/idx/index.phtml:8
+msgid "SYJ needs javascript. Please activate scripts in your browser."
+msgstr "SYJ a besoin de javascript pour fonctionner. Veuillez activer les scripts dans votre navigateur."
+
+#: application/views/scripts/idx/index.phtml:14
+#: application/controllers/LoginController.php:8
+#: application/layouts/scripts/footer.phtml:61
+#: application/forms/Login.php:26
+msgid "login"
+msgstr "connexion"
+
+#: application/views/scripts/idx/index.phtml:17
+#: application/views/scripts/idx/index.phtml:69
+msgid "create an account"
+msgstr "créer un compte"
+
+#: application/views/scripts/idx/index.phtml:30
+msgid "Welcome on Syj."
+msgstr "Bienvenue sur Syj."
+
+#: application/views/scripts/idx/index.phtml:32
+msgid "To create a journey, just click on the map to add points to your route. You can zoom and move map with controls upper left."
+msgstr "Pour créer un trajet, cliquez simplement sur la carte pour ajouter des points à votre tracé. Vous pouvez zoomer et bouger la carte avec les boutons en haut à gauche."
+
+#: application/views/scripts/idx/index.phtml:34
+msgid "When you have finished a path, press \"save\", button."
+msgstr "Lorsque vous avez fini votre tracé, pressez le bouton \"enregistrer\"."
+
+#: application/views/scripts/idx/index.phtml:40
+msgid "edit"
+msgstr "modifier"
+
+#: application/views/scripts/termsofuse/index.phtml:2
+msgid "Show Your Journey is a site whose goal is to allow anyone to publish routes, for example, hiking itinerary, bicycle trip, travel itinerary or whatever."
+msgstr "Show Your Journey est un site dont le but est de permettre à quiconque de publier des itinéraires, par exemples, des itinéraires de randonnées, des trajets cyclistes, des itinéraires de voyages, ou n'importe quoi d'autre."
+
+#: application/views/scripts/termsofuse/index.phtml:6
+msgid "In order to publish a route, you must first create an account.  A valid email is asked for, and ip address of account creation is stored on the server. Those informations will not be divulged to anyone without the user explicit permission."
+msgstr "Pour publier un itinéraire, vous devez tout d'abord créer un compte. Un email valide est demandé, et l'adresse ip de création du compte est enregistrée sur le serveur. Ces informations ne seront divulguées à personne sans la permission explicite de l'utilisateur."
+
+#: application/views/scripts/termsofuse/index.phtml:10
+msgid "When you create a route, you accept that it's available under a <a href=\"http://creativecommons.org/licenses/by/2.0/\">creative commons <strong>by</strong> license</a>. This means you accept that anyone can reproduce and republish your itinerary, or a modified version of it, under the condition that he specify the proper creator of this work. This also means you need to get appropriate permissions from the creator if you want to upload a route you didn't create yourself."
+msgstr "Lorsque vous créez un itinéraire, vous acceptez qu'il soit disponible sous <a href=\"http://creativecommons.org/licenses/by/2.0/\">licence creative commons <strong>by</strong></a>. Cela veut dire que n'importe qui peut reproduire et redistribuer votre itinéraire, ou une version modifiée de celui-ci, à la condition qu'il indique correctement l'auteur de l'œuvre.  Cela veut également dire que vous devez obtenir les autorisations nécessaires si vous voulez publier un itinéraire dont vous n'êtes pas l'auteur."
+
+#: application/views/scripts/termsofuse/index.phtml:14
+msgid "Show Your Journey is not responsible for the accuracy of the routes published.  It's the user responsibility to check that a route is accessible and safe."
+msgstr "Show Your Journey n'est pas responsable de l'exactitude des itinéraires publiés. Il appartient à l'utilisateur de vérifier qu'un chemin est praticable et sécurisé."
+
+#: application/views/scripts/termsofuse/index.phtml:18
+msgid "Sources of the software running the website are <a href=\"http://dev.renevier.net/?p=syj.git\">publicly available</a> under a agpl license. The map used to display the routes comes from <a href=\"http://www.openstreetmap.org/\">openstreetmap</a>."
+msgstr "Les sources du logiciel qui fait tourner le site web sont <a href=\"http://dev.renevier.net/?p=syj.git\">disponibles publiquement</a> sous une licence agpl. La carte utilisée pour l'affichage des itinéraires vient d'<a href=\"http://www.openstreetmap.org/\">openstreetmap</a>."
+
+#: application/views/scripts/newpwd/success.phtml:4
+#: application/controllers/IdxController.php:119
+msgid "A link to reset your password has been emailed to you"
+msgstr "Un email contenant un lien pour réinitialiser votre mot de passe vous a été envoyé"
+
+#: application/views/scripts/pending/password_cancel.phtml:12
+msgid "You have canceled the request."
+msgstr "Vous avez annulé la requête."
+
+#: application/views/scripts/pending/password_cancel.phtml:14
+#: application/views/scripts/pending/creation_validate.phtml:14
+#: application/views/scripts/pending/creation_cancel.phtml:14
+#: application/views/helpers/Returnto.php:22
+#: application/views/helpers/Returnto.php:25
+#: application/views/helpers/Returnto.php:28
+msgid "You can now"
+msgstr "Vous pouvez maintenant"
+
+#: application/views/scripts/pending/creation_validate.phtml:12
+msgid "You have validated your account."
+msgstr "Vous avez validé votre compte."
+
+#: application/views/scripts/pending/index.phtml:15
+msgid "If you need more informations, please"
+msgstr "Si vous avez besoin de plus d'informations, veuillez"
+
+#: application/views/scripts/pending/index.phtml:16
+msgid "contact us"
+msgstr "nous contacter"
+
+#: application/views/scripts/pending/creation_cancel.phtml:12
+msgid "You have canceled the account."
+msgstr "Vous avez annulé le compte."
+
+#: application/views/scripts/pending/password_validate.phtml:17
+msgid "log in"
+msgstr "vous connecter"
+
+#: application/views/scripts/pending/password_validate.phtml:15
+#, php-format
+msgid "Your new password is now <strong>%s</strong>. You can %s with this new password. Don't forget to change it again to a personal password as soon as possible."
+msgstr "Votre nouveau mot de passe est <strong>%s</strong>. Vous pouvez %s avec le nouveau mot de passe. N'oubliez pas de le rechanger le plus tôt possible pour utiliser un mot de passe personnel."
+
+#: application/views/scripts/account/success.phtml:4
+msgid "Your account was modified successfully"
+msgstr "Votre compte a bien été modifié."
+
+#: application/views/helpers/LogoutLink.php:12
+#: application/layouts/scripts/footer.phtml:52
+msgid "logout"
+msgstr "déconnexion"
+
+#: application/views/helpers/LocaleSwitcher.php:17
+msgid "english"
+msgstr "français"
+
+#: application/views/helpers/Returnto.php:26
+#: application/views/helpers/Returnto.php:29
+#, php-format
+msgid "go back to %s"
+msgstr "retourner à %s"
+
+#: application/views/helpers/Returnto.php:30
+msgid "or you can"
+msgstr "ou vous pouvez"
+
+#: application/models/Pending/ResetPassword.php:19
+msgid "[SYJ] Reset your password"
+msgstr "[SYJ] Réinitialisation de votre mot de passe"
+
+#: application/models/Pending/ResetPassword.php:20
+msgid ""
+"Hi %user%,\n"
+"\n"
+"Someone, probably you, has asked to reset your password. If you want to reset\n"
+"your password, please follow this link:\n"
+"%hashurl%\n"
+"\n"
+"If you do not not confirm within 2 days, your password will not be reset.\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Thanks,\n"
+"\n"
+"Syj team"
+msgstr ""
+"Bonjour %user%,\n"
+"\n"
+"Quelqu'un, probablement vous, a demandé à réinitialiser votre mot de\n"
+"passe. Si vous voulez le réinitialiser, veuillez suivre ce lien:\n"
+"%hashurl%\n"
+"\n"
+"Si vous n'avez pas confirmé d'ici 2 jours, votre mot de passe ne sera pas\n"
+"réinitialisé.\n"
+"\n"
+"Veuillez ne pas répondre à cet email. Si vous avez besoin de nous contacter,\n"
+"merci d'utiliser le formulaire à l'adresse suivante:\n"
+"%contacturl%\n"
+"\n"
+"Merci,\n"
+"\n"
+"l'équipe de Syj"
+
+#: application/models/Pending/ValidateCreation.php:15
+msgid "[SYJ] Validate your account"
+msgstr "[SYJ] Validation de la création du compte"
+
+#: application/models/Pending/ValidateCreation.php:16
+msgid ""
+"Hi %user%, and welcome on syj\n"
+"\n"
+"Your account is currently active, but you need to confirm your inscription by\n"
+"following this link:\n"
+"%hashurl%\n"
+"\n"
+"If you do not not confirm your inscription within 7 days, your account and all\n"
+"your items will be deleted.\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Thanks,\n"
+"\n"
+"Syj team"
+msgstr ""
+"Bonjour %user%, et bienvenue sur syj\n"
+"\n"
+"Votre compte est actif, mais vous devez confirmer votre inscription en\n"
+"suivant ce lien:\n"
+"%hashurl%\n"
+"\n"
+"Si vous ne confirmez pas votre inscription d'ici 7 jours, votre compte ainsi que\n"
+"toutes vos modifications seront supprimés.\n"
+"\n"
+"Veuillez ne pas répondre à cet email. Si vous avez besoin de nous contacter,\n"
+"merci d'utiliser le formulaire à l'adresse suivante:\n"
+"%contacturl%\n"
+"\n"
+"Merci,\n"
+"\n"
+"l'équipe de Syj"
+
+#: application/models/Pending/ValidateCreation.php:34
+msgid "[SYJ] Reminder: Validate your account"
+msgstr "[SYJ] Rappel: Validation de votre compte"
+
+#: application/models/Pending/ValidateCreation.php:35
+msgid ""
+"Hi %user%,\n"
+"\n"
+"You need to validate your account on syj since 6 days. Otherwise, your\n"
+"account will be deleted tomorrow. Please follow this link:\n"
+"%hashurl%\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Thanks,\n"
+"\n"
+"Syj team"
+msgstr ""
+"Bonjour %user%,\n"
+"\n"
+"Votre compte est en attente de validation depuis 6 jours. Si vous ne le\n"
+"validez pas, il sera supprimé demain. Merci de suivre ce lien:\n"
+"%hashurl%\n"
+"\n"
+"VVeuillez ne pas répondre à cet email. Si vous avez besoin de nous contacter,\n"
+"merci d'utiliser le formulaire à l'adresse suivante:\n"
+"%contacturl%\n"
+"\n"
+"Merci\n"
+"\n"
+"L'équipe de Syj"
+
+#: application/models/Pending/ValidateCreation.php:51
+msgid "[SYJ] Account deactivated"
+msgstr "[SYJ] Compte désactivé"
+
+#: application/models/Pending/ValidateCreation.php:52
+msgid ""
+"Hi %user%,\n"
+"\n"
+"You have not validated your syj account on time. Therefore, your account and\n"
+"all your data have been deleted. Nevertheless, you can still create a new\n"
+"account.\n"
+"\n"
+"Please do not reply this email. If you need to contact us, please use the form\n"
+"contact at %contacturl%\n"
+"\n"
+"Regards,\n"
+"\n"
+"Syj team"
+msgstr ""
+"Bonjour %user%,\n"
+"\n"
+"Vous n'avez pas validé votre compte à temps. Votre compte et toutes\n"
+"vous données ont donc été supprimés. Vous pouvez toujours recréer\n"
+"un nouveau compte.\n"
+"\n"
+"Veuillez ne pas répondre à cet email. Si vous avez besoin de nous contacter,\n"
+"merci d'utiliser le formulaire à l'adresse suivante:\n"
+"%contacturl%\n"
+"\n"
+"L'équipe de Syj"
+
+#: application/controllers/LoginController.php:95
+#: application/controllers/IdxController.php:105
+msgid "you must enter a login name"
+msgstr "vous devez entrer un nom d'utilisateur"
+
+#: application/controllers/PendingController.php:32
+msgid "account validated"
+msgstr "compte validé"
+
+#: application/controllers/PendingController.php:39
+msgid "account deleted"
+msgstr "Compte supprimé"
+
+#: application/controllers/PendingController.php:43
+msgid "account creation validation"
+msgstr "validation de la création du compte"
+
+#: application/controllers/PendingController.php:53
+msgid "password changed"
+msgstr "mot de passe modifié"
+
+#: application/controllers/PendingController.php:64
+msgid "request canceled"
+msgstr "requête annulée"
+
+#: application/controllers/PendingController.php:68
+msgid "password reset validation"
+msgstr "validation de la réinitialisation du mot de passe"
+
+#: application/controllers/ContactController.php:13
+msgid "contact form"
+msgstr "formulaire de contact"
+
+#: application/controllers/ContactController.php:112
+msgid "Hi,"
+msgstr "Bonjour,"
+
+#: application/controllers/ContactController.php:121
+#: application/controllers/NewpwdController.php:68
+#: application/controllers/AccountController.php:74
+#: application/forms/Contact.php:27
+msgid "Value is required and can't be empty"
+msgstr "Le champ est requis, et ne doit pas être vide"
+
+#: application/controllers/ContactController.php:122
+#: application/forms/Contact.php:32
+#: application/validate/EmailAddress.php:13
+msgid "Invalid email"
+msgstr "Email invalide"
+
+#: application/controllers/ErrorController.php:55
+msgid "Oups, something went wrong"
+msgstr "Oups, il y a eu un souci"
+
+#: application/controllers/TermsofuseController.php:12
+#: application/layouts/scripts/footer.phtml:74
+#: application/forms/User.php:41
+msgid "terms of use"
+msgstr "conditions d'utilisation"
+
+#: application/controllers/AccountController.php:13
+#: application/layouts/scripts/footer.phtml:46
+msgid "my account"
+msgstr "mon compte"
+
+#: application/controllers/AccountController.php:34
+msgid "Wrong password"
+msgstr "Mauvais mot de passe"
+
+#: application/controllers/AccountController.php:47
+#: application/controllers/IdxController.php:117
+msgid "an user is already registered with this email"
+msgstr "il y'a déjà un utilisateur enregistré avec cet email"
+
+#: application/controllers/AccountController.php:75
+#: application/controllers/IdxController.php:111
+#: application/forms/Account.php:40
+msgid "Password do not match"
+msgstr "Les mots de passe ne correspondent pas"
+
+#: application/controllers/AccountController.php:76
+#: application/forms/Account.php:33
+#: application/forms/User.php:18
+#, php-format
+msgid "At least %d characters"
+msgstr "Au moins %d caractères"
+
+#: application/controllers/AccountController.php:77
+msgid "You have made no change"
+msgstr "Vous n'avez fait aucun changement"
+
+#: application/controllers/IdxController.php:98
+msgid "save took place successfully"
+msgstr "La sauvegarde s'est déroulée correctement"
+
+#: application/controllers/IdxController.php:99
+msgid "server did not understood request. That's probably caused by a bug in SYJ"
+msgstr "Le serveur n'a pas compris la requête. Il s'agit probablement d'un bug dans SYJ"
+
+#: application/controllers/IdxController.php:100
+msgid "path did not exist in the server. May be it has been already deleted"
+msgstr "Le chemin n'existait pas sur le serveur. Il a peut-être supprimé"
+
+#: application/controllers/IdxController.php:101
+msgid "similar path seems to already exist. Please do not create two exactly identical paths"
+msgstr "Il semble qu'il y ait déjà un chemin similaire. Veuillez ne pas créer deux chemins exactement identiques"
+
+#: application/controllers/IdxController.php:102
+msgid "server could not be reached"
+msgstr "serveur inaccessible"
+
+#: application/controllers/IdxController.php:103
+msgid "there was a server error"
+msgstr "Il s'est produit une erreur serveur"
+
+#: application/controllers/IdxController.php:104
+msgid "there was an unknown error"
+msgstr "Il s'est produit une erreur inconnue"
+
+#: application/controllers/IdxController.php:106
+msgid "Login correct"
+msgstr "Vous êtes connectés"
+
+#: application/controllers/IdxController.php:107
+msgid "Wrong login/password"
+msgstr "Mauvais nom d'utilisateur ou mot de passe"
+
+#: application/controllers/IdxController.php:108
+msgid "You need to login before retrying to save"
+msgstr "Vous devez vous connecter avant de réesayer de sauvegarder"
+
+#: application/controllers/IdxController.php:109
+msgid "You need to have cookies enabled to login to SYJ"
+msgstr "Vous devez activer les cookies pour pouvoir vous connecter à SYJ"
+
+#: application/controllers/IdxController.php:110
+msgid "you must enter a password"
+msgstr "vous devez entrer un mot de passe"
+
+#: application/controllers/IdxController.php:112
+msgid "You must accept terms of use"
+msgstr "Vous devez accepter les conditions d'utilisation"
+
+#: application/controllers/IdxController.php:113
+msgid "you must enter an email"
+msgstr "vous devez entrer un email"
+
+#: application/controllers/IdxController.php:114
+msgid "invalid email"
+msgstr "email invalide"
+
+#: application/controllers/IdxController.php:115
+msgid "pseudo must only contain letters, digits, dots or underscores"
+msgstr "le pseudo ne peut contenir que des lettres, des chiffres, des points ou des soulignés"
+
+#: application/controllers/IdxController.php:116
+msgid "unavailable pseudo"
+msgstr "pseudo non disponible"
+
+#: application/controllers/IdxController.php:118
+msgid "Account created"
+msgstr "Compte créé"
+
+#: application/controllers/IdxController.php:120
+msgid "Now, you can retry to save"
+msgstr "Maintenant, vous pouvez réessayer de sauvegarder"
+
+#: application/controllers/IdxController.php:121
+msgid "route by"
+msgstr "tracé par"
+
+#: application/controllers/IdxController.php:122
+msgid "Map by <a href='http://openstreetmap.org/'>OpenStreetMap</a>"
+msgstr "Carte par <a href='http://openstreetmap.org/'>OpenStreetMap</a>"
+
+#: application/layouts/scripts/footer.phtml:24
+msgid "main page"
+msgstr "page d'accueil"
+
+#: application/layouts/scripts/footer.phtml:35
+msgid "contact"
+msgstr "contact"
+
+#: application/forms/Login.php:9
+msgid "user"
+msgstr "utilisateur"
+
+#: application/forms/Login.php:10
+#: application/forms/Account.php:35
+#: application/forms/User.php:21
+msgid "password"
+msgstr "mot de passe"
+
+#: application/forms/Login.php:23
+msgid "I forgot my password"
+msgstr "J'ai oublié mon mot de passe"
+
+#: application/forms/Contact.php:36
+msgid "Email:"
+msgstr "Email:"
+
+#: application/forms/Contact.php:40
+msgid "Subject must be %max% characters long or less"
+msgstr "Le sujet doit faire au plus %max% caractères"
+
+#: application/forms/Contact.php:45
+msgid "Subject:"
+msgstr "Sujet:"
+
+#: application/forms/Contact.php:49
+msgid "Message:"
+msgstr "Message:"
+
+#: application/forms/Contact.php:56
+msgid "Send"
+msgstr "Envoyer"
+
+#: application/forms/Contact.php:64
+msgid "Send a message"
+msgstr "Envoyer un message"
+
+#: application/forms/Geom.php:19
+msgid "optional title for this journey"
+msgstr "titre facultatif pour ce trajet"
+
+#: application/forms/Geom.php:23
+#: application/forms/Pending/ValidateCreation.php:17
+msgid "save"
+msgstr "enregistrer"
+
+#: application/forms/Account.php:27
+#: application/forms/User.php:34
+#: application/forms/Newpwd.php:28
+msgid "email"
+msgstr "email"
+
+#: application/forms/Account.php:42
+#: application/forms/User.php:28
+msgid "confirm password"
+msgstr "confirmation du mot de passe"
+
+#: application/forms/Account.php:48
+msgid "current password"
+msgstr "mot de passe actuel"
+
+#: application/forms/Account.php:50
+msgid "modify my informations"
+msgstr "modifier mes informations"
+
+#: application/forms/User.php:11
+msgid "user name"
+msgstr "nom d'utilisateur"
+
+#: application/forms/User.php:35
+msgid "After creating your account, you will receive a confirmation email. You have 7 days to confirm otherwise, your account and your routes will all be deleted."
+msgstr "Après la création de votre compte, vous recevrez un mail de confirmation. Vous avez 7 jours pour confirmer sinon, votre compte et tous vos tracés seront supprimés."
+
+#: application/forms/User.php:42
+#, php-format
+msgid "I've read and accepted %s"
+msgstr "J'ai lu et accepté les %s"
+
+#: application/forms/User.php:54
+msgid "create account"
+msgstr "créer le compte"
+
+#: application/forms/Pending/ResetPassword.php:11
+#, php-format
+msgid "Hi %s. Someone, probably you, has asked to reset password for your account. To get a new password, validate with following button."
+msgstr "Bonjour %s. Quelqu'un, probablement vous, a demandé de réinitialiser le mot de passe de votre compte. Pour avoir un nouveau mot de passe, validez avec le bouton suivant."
+
+#: application/forms/Pending/ResetPassword.php:16
+#: application/forms/Newpwd.php:33
+msgid "reset my password"
+msgstr "réinitialiser mon mot de passe"
+
+#: application/forms/Pending/ResetPassword.php:23
+msgid "cancel request"
+msgstr "annuler la requête"
+
+#: application/forms/Pending/ResetPassword.php:24
+msgid "To cancel this request, press following button. Your password will not change."
+msgstr "Pour annuler la requête, pressez le bouton suivant. Votre mot de passe ne sera pas changé."
+
+#: application/forms/Pending/ValidateCreation.php:11
+#, php-format
+msgid "Someone, probably you, has registered an account %s with email address %s on syj. To confirm this account creation, validate with following button."
+msgstr "Quelqu'un, probablement vous, a enregistré un compte %s avec l'adresse email %s sur syj. Pour confirmer la création du compte, validez avec le bouton suivant."
+
+#: application/forms/Pending/ValidateCreation.php:23
+msgid "delete"
+msgstr "supprimer"
+
+#: application/forms/Pending/ValidateCreation.php:24
+msgid "To cancel account creation, press following button. The account and all its data will be deleted."
+msgstr "Pour annuler la création du compte, pressez le bouton suivant. Le compte ainsi que toutes ses données seront supprimés."
+
+#, fuzzy
+#~ msgid "reset password"
+#~ msgstr "Réinitialiser mon mot de passe"
+
diff --git a/application/layouts/scripts/footer.phtml b/application/layouts/scripts/footer.phtml
new file mode 100644 (file)
index 0000000..4003423
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+echo '<div id="footer">' . PHP_EOL;
+echo '<div id="footer-padding"></div>' . PHP_EOL;
+
+/*
+ * main page link
+ */
+$page = new Zend_Navigation_Page_Mvc(array(
+    'route' => 'idx',
+    'params' => array(
+        'action'     => 'index',
+        'controller' => 'idx',
+        'url' => '')));
+
+$front = Zend_Controller_Front::getInstance();
+$reqParams = $front->getRequest()->getParams();
+if ($reqParams['controller'] == 'idx' and (!isset($reqParams['url']))) {
+    $current = true;
+} else {
+    $current = false;
+}
+
+$mainpage = $current;
+
+$content = $this->translate("main page");
+$link = ($current) ? $this->escape($content) : $this->anchor($page->getHRef(), $content, array('class' => 'footer-anchor'));
+echo '<div class="footer-link">' . $link . '</div>' . PHP_EOL;
+
+/*
+ * contact page link
+ */
+echo $this->footerLink(array(
+        'action'     => 'index',
+        'controller' => 'contact',
+        'route' => 'contact'),
+    $this->translate("contact"),
+    isset($this->redirectLinks) ? $this->redirectLinks : true);
+
+/*
+ * login, logout, account links
+ */
+if ($this->loggedUser()) {
+    echo $this->footerLink(array(
+            'route' => 'account',
+            'action'     => 'index',
+            'controller' => 'account'),
+        $this->translate("my account"));
+    if (!$mainpage) {
+        echo $this->footerLink(array(
+            'route' => 'logout',
+            'action'     => 'logout',
+            'controller' => 'login'),
+        $this->translate("logout"),
+        false);
+    }
+} else {
+    if (!$mainpage) {
+        echo $this->footerLink(array(
+            'route' => 'login',
+            'action'     => 'login',
+            'controller' => 'login'),
+        $this->translate("login"),
+        isset($this->redirectLinks) ? $this->redirectLinks : true
+        );
+    }
+}
+
+/*
+ * termsofuse
+ */
+echo $this->footerLink(array(
+    'route' => 'termsofuse',
+    'action'     => 'index',
+    'controller' => 'termsofuse'),
+    $this->translate("terms of use"),
+    false);
+
+echo '</div>' . PHP_EOL;
+
+?>
diff --git a/application/layouts/scripts/header.phtml b/application/layouts/scripts/header.phtml
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml
new file mode 100644 (file)
index 0000000..5736ac1
--- /dev/null
@@ -0,0 +1,41 @@
+<!doctype html>
+<html lang="<?php echo $this->localeShort();?>">
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
+
+<?php
+
+    if ($this->jslocales) {
+        $syjStrings = new phptojs\JsObject('SyjStrings');
+        foreach ($this->jslocales as $prop => $value) {
+            if (is_array($value)) {
+                $syjStrings->$prop = call_user_func_array(array($this, 'translate'), $value);
+            } else {
+                $syjStrings->$prop = $this->translate($value);
+            }
+        }
+        $this->headScript()->prependScript((string) $syjStrings);
+    }
+
+    echo $this->headBase()->setIndent(4) . PHP_EOL;
+    echo $this->headTitle()->setIndent(4) . PHP_EOL;
+    echo $this->headLink()->setIndent(4) . PHP_EOL;
+    echo $this->headScript()->setIndent(4) . PHP_EOL;
+
+?>
+
+</head>
+<body>
+<?php
+    echo $this->render('header.phtml');
+?>
+
+<?php
+    echo $this->layout()->content;
+?>
+
+<?php
+    echo $this->render('footer.phtml');
+?>
+</body>
+</html>
diff --git a/application/models/Generic.php b/application/models/Generic.php
new file mode 100644 (file)
index 0000000..8801b87
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+abstract class Syj_Model_Generic
+{
+    protected $_translator = null;
+
+    public function __construct(array $options = null) {
+        if (is_array($options)) {
+            $this->setOptions($options);
+        }
+    }
+
+    public function __set($name, $value) {
+        $method = 'set' . $name;
+        if (('mapper' == $name) || !method_exists($this, $method)) {
+            throw new Zend_Exception($name . ': Invalid property for ' . get_class($this));
+        }
+        $this->$method($value);
+    }
+
+    public function __get($name) {
+        $method = 'get' . $name;
+        if (('mapper' == $name) || !method_exists($this, $method)) {
+            throw new Zend_Exception($name . ': Invalid property for ' . get_class($this));
+        }
+        return $this->$method();
+    }
+
+    public function __isset($name) {
+        $method = 'get' . $name;
+        if (('mapper' == $name) || !method_exists($this, $method)) {
+            throw new Zend_Exception($name . ': Invalid property for ' . get_class($this));
+        }
+        $result = $this->$method();
+        return isset($result);
+    }
+
+    public function setOptions(array $options) {
+        $methods = get_class_methods($this);
+        foreach ($options as $key => $value) {
+            $method = 'set' . ucfirst($key);
+            if (in_array($method, $methods)) {
+                $this->$method($value);
+            }
+        }
+        return $this;
+    }
+
+    protected function getTranslator() {
+        if ($this->_translator) {
+            return $this->_translator;
+        }
+        if (Zend_Registry::isRegistered('Zend_Translate')) {
+            $translator = Zend_Registry::get('Zend_Translate');
+            $this->_translator = $translator->getAdapter();
+        }
+        return $this->_translator;
+    }
+
+    protected function translate($messageId, $locale = null) {
+        $translator = $this->getTranslator();
+        if ($translator) {
+            return $translator->translate($messageId, $locale);
+        }
+        return $messageId;
+    }
+
+}
diff --git a/application/models/Path.php b/application/models/Path.php
new file mode 100644 (file)
index 0000000..41706e4
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Model_Path extends Syj_Model_Generic
+{
+    protected $_id;
+    protected $_geom;
+    protected $_owner;
+    protected $_title;
+    protected $_urlcomp;
+
+    public function setId($id) {
+        $this->_id = (int) $id;
+        return $this;
+    }
+
+    public function getId() {
+        return $this->_id;
+    }
+
+    public function setGeom(gisconverter\Geometry $geom) {
+        $this->_geom = $geom;
+        return $this;
+    }
+
+    public function getGeom() {
+        return $this->_geom;
+    }
+
+    public function setOwner(Syj_Model_User $owner) {
+        $this->_owner = $owner;
+        return $this;
+    }
+
+    public function getOwner() {
+        return $this->_owner;
+    }
+
+    public function setTitle($title) {
+        $this->_title = (string) $title;
+        return $this;
+    }
+
+    public function getTitle() {
+        return $this->_title;
+    }
+
+    public function getDisplayTitle() {
+        if ($this->_title) {
+            return $this->_title;
+        } else if ($this->_id) {
+            return "journey number " . (string)$this->_id;
+        } else {
+            return "";
+        }
+    }
+
+    public function setUrlComp($_urlcomp) {
+        $this->_urlcomp = (string) $_urlcomp;
+        return $this;
+    }
+
+    public function getUrlComp() {
+        return $this->_urlcomp;
+    }
+
+}
diff --git a/application/models/PathMapper.php b/application/models/PathMapper.php
new file mode 100644 (file)
index 0000000..01e2818
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Model_PathMapper
+{
+    protected $_dbTable;
+    protected $_tableInfos = array('name' => 'paths');
+
+    public function getDbTable() {
+        if (null === $this->_dbTable) {
+            $this->_dbTable = new Zend_Db_Table($this->_tableInfos);
+        }
+        return $this->_dbTable;
+    }
+
+    /*
+     * return true if a path with id $id has been created one day, even if the
+     * path has been deleted since. Returns false if path has never existed.
+     */
+    public function hasexisted($id) {
+        if (!is_numeric($id)) {
+            return false;
+        }
+        $db = $this->getDbTable()->getAdapter();
+        $expr = $db->quoteInto('seq_attained_value(?)', array('paths_id_seq', (int)$id));
+        $select = $db->select()->from(new Zend_Db_Expr($expr));
+        print $select->assemble();
+        $row = $db->fetchRow($select);
+        return $row['t'];
+    }
+
+    public function find($id, Syj_Model_Path $path) {
+        $select = $this->_select();
+        $select->where('id = ?', (int)$id);
+        return $this->_fetchItem($select, $path);
+    }
+
+    public function findByUrl($url, Syj_Model_Path $path) {
+        $select = $this->_select();
+        $select->where('id = ?', (int)$url)->orWhere('urlcomp = ?', (string)$url);
+        return $this->_fetchItem($select, $path);
+    }
+
+    public function fetchAll() {
+        $select = $this->_select();
+
+        $resultSet = $table->fetchAll($select);
+
+        $entries   = array();
+        foreach ($resultSet as $row) {
+            $entry = new Syj_Model_Path();
+            $entries[] = $this->_itemFromRow($entry, $row);
+        }
+        return $entries;
+    }
+
+    public function save (Syj_Model_Path $path) {
+        $data = array(
+            'geom'=> (string)$path->geom,
+            'owner'=> $path->owner->id,
+            'title'=> $path->title
+        );
+        if (null === ($id = $path->getId())) {
+            $path->id = $this->getDbTable()->insert($data);
+        } else {
+            $this->getDbTable()->update($data, array('id = ?' => $id));
+        }
+    }
+
+    protected function _itemFromRow(Syj_Model_Path $item, Zend_Db_Table_Row $row) {
+        $decoder = new gisconverter\WKT();
+        $geom = $decoder->geomFromText($row->wkt);
+
+        $item->setId($row->id)->
+            setGeom($geom)->
+            setTitle($row->title)->
+            setUrlComp($row->urlcomp);
+
+        if (!$item->getOwner()) {
+            $user = new Syj_Model_User();
+            $userMapper = new Syj_Model_UserMapper();
+            if ($userMapper->find($row->owner, $user)) {
+                $item->setOwner($user);
+            }
+        }
+        return $item;
+    }
+
+    protected function _fetchItem(Zend_Db_Select $select, Syj_Model_Path $path) {
+        $row = $select->getTable()->fetchRow($select);
+        if ($row) {
+            $this->_itemFromRow($path, $row);
+            return true;
+        }
+        return false;
+    }
+
+    protected function _select() {
+        $table = $this->getDbTable();
+        $select = $table->select();
+        $select->from($table, array('id', 'ST_AsText(geom) AS wkt', 'owner', 'title', 'urlcomp'));
+        return $select;
+    }
+
+}
+
diff --git a/application/models/Pending.php b/application/models/Pending.php
new file mode 100644 (file)
index 0000000..fe4808f
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+abstract class Syj_Model_Pending extends Syj_Model_Generic
+{
+    protected $_id;
+    protected $_user;
+    protected $_action;
+    protected $_hash;
+    protected $_notifications_number;
+    protected $_creation_time;
+
+    protected $_baseUrl;
+
+    public static $rules = array('validate_creation' => array(null, '6d', '7d'),
+                            'reset_password' => array(null, '2d'));
+
+    public function setId($id) {
+        $this->_id = (int) $id;
+        return $this;
+    }
+
+    public function getId() {
+        return $this->_id;
+    }
+
+    public function setUser(Syj_Model_User $user) {
+        $this->_user = $user;
+        return $this;
+    }
+
+    public function getUser() {
+        return $this->_user;
+    }
+
+    public function setAction($action) {
+        $possibleactions = array("validate_creation", "reset_password");
+        if (!in_array($action, $possibleactions)) {
+            throw new Zend_Exception((string)$action . ': Invalid value for Pending::action');
+        }
+        $this->_action = (string)$action;
+        return $this;
+    }
+
+    public function getAction() {
+        return $this->_action;
+    }
+
+    public function setHash($hash) {
+        $this->_hash = (string)$hash;
+        return $this;
+    }
+
+    public function getHash() {
+        return $this->_hash;
+    }
+
+    public function setNotificationsNumber($number) {
+        $this->_notifications_number = (int)$number;
+        return $this;
+    }
+
+    public function getNotificationsNumber() {
+        return $this->_notifications_number;
+    }
+
+    public function setCreationTime($timestamp) {
+        $this->_creation_time = date_create($timestamp);
+        return $this;
+    }
+
+    public function getCreationTime() {
+        return $this->_creation_time;
+    }
+
+    protected function getHashUrl() {
+        $rooturl = Zend_Controller_Front::getInstance()->getParam('rooturl');
+        return $rooturl . "pending/" . $this->_hash;
+    }
+
+    protected function getContactUrl() {
+        $rooturl = Zend_Controller_Front::getInstance()->getParam('rooturl');
+        return $rooturl . "contact";
+    }
+
+    protected function _sendMail($subject, $text) {
+        $mail = new Zend_Mail('utf-8');
+        $mail->addTo($this->_user->email)
+             ->setSubject($subject)
+             ->setBodyText($text);
+
+        try {
+            $mail->send();
+        } catch(Exception $e) {
+            return false;
+        }
+        return true;
+    }
+
+    public function run() {
+        if ($this->_run() === false) {
+            return false;
+        }
+        $mapper = new Syj_Model_PendingMapper();
+        $mapper->delete($this);
+        return true;
+    }
+    abstract protected function _run();
+
+    public function notify() {
+        $mapper = new Syj_Model_PendingMapper();
+        if (!$this->_hash) {
+            $mapper->save($this);
+        }
+
+        if ($this->_notify() === false) {
+            return false;
+        }
+
+        $this->_notifications_number++;
+
+        if ($this->_notifications_number >= count(self::$rules[$this->_action])) {
+            $this->cancel();
+        } else {
+            $mapper->save($this);
+        }
+        return true;
+    }
+    abstract protected function _notify();
+
+    public function cancel() {
+        if ($this->_cancel() === false) {
+            return false;
+        }
+        $mapper = new Syj_Model_PendingMapper();
+        $mapper->delete($this);
+        return true;
+    }
+    abstract protected function _cancel();
+
+}
diff --git a/application/models/Pending/ResetPassword.php b/application/models/Pending/ResetPassword.php
new file mode 100644 (file)
index 0000000..655878e
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Model_Pending_ResetPassword extends Syj_Model_Pending
+{
+    protected $_action = 'reset_password';
+    protected $_newpwd;
+    protected function _run() {
+        $this->_newpwd = pwdgen\PwdGenerator::generate();
+        $this->_user->password = sha1($this->_newpwd);
+        $userMapper = new Syj_Model_UserMapper();
+        $userMapper->save($this->_user);
+        return true;
+    }
+    public function _notify() {
+        switch ($this->_notifications_number) {
+            case 0:
+                $subject = $this->translate("[SYJ] Reset your password", $this->_user->lang);
+                $text = $this->translate("Hi %user%,
+
+Someone, probably you, has asked to reset your password. If you want to reset
+your password, please follow this link:
+%hashurl%
+
+If you do not not confirm within 2 days, your password will not be reset.
+
+Please do not reply this email. If you need to contact us, please use the form
+contact at %contacturl%
+
+Thanks,
+
+Syj team", $this->_user->lang);
+            break;
+        }
+
+        $text = str_replace('%user%', $this->_user->pseudo, $text);
+        $text = str_replace('%hashurl%', $this->getHashUrl(), $text);
+        $text = str_replace('%contacturl%', $this->getContactUrl(), $text);
+
+        return $this->_sendMail($subject, $text);
+    }
+    protected function _cancel() {
+        return true;
+    }
+
+    public function getNewpwd() {
+        return $this->_newpwd;
+    }
+}
diff --git a/application/models/Pending/ValidateCreation.php b/application/models/Pending/ValidateCreation.php
new file mode 100644 (file)
index 0000000..be7e6a6
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Model_Pending_ValidateCreation extends Syj_Model_Pending
+{
+    protected $_action = 'validate_creation';
+    protected function _run() {
+        return true;
+    }
+
+    public function _notify() {
+        switch ($this->_notifications_number) {
+            case 0:
+                $subject = $this->translate("[SYJ] Validate your account", $this->_user->lang);
+                $text = $this->translate("Hi %user%, and welcome on syj
+
+Your account is currently active, but you need to confirm your inscription by
+following this link:
+%hashurl%
+
+If you do not not confirm your inscription within 7 days, your account and all
+your items will be deleted.
+
+Please do not reply this email. If you need to contact us, please use the form
+contact at %contacturl%
+
+Thanks,
+
+Syj team", $this->_user->lang);
+            break;
+
+            case 1:
+                $subject = $this->translate("[SYJ] Reminder: Validate your account", $this->_user->lang);
+                $text = $this->translate("Hi %user%,
+
+You need to validate your account on syj since 6 days. Otherwise, your
+account will be deleted tomorrow. Please follow this link:
+%hashurl%
+
+Please do not reply this email. If you need to contact us, please use the form
+contact at %contacturl%
+
+Thanks,
+
+Syj team", $this->_user->lang);
+
+            break;
+
+            default:
+                $subject = $this->translate("[SYJ] Account deactivated", $this->_user->lang);
+                $text = $this->translate("Hi %user%,
+
+You have not validated your syj account on time. Therefore, your account and
+all your data have been deleted. Nevertheless, you can still create a new
+account.
+
+Please do not reply this email. If you need to contact us, please use the form
+contact at %contacturl%
+
+Regards,
+
+Syj team", $this->_user->lang);
+        }
+
+        $text = str_replace('%user%', $this->_user->pseudo, $text);
+        $text = str_replace('%hashurl%', $this->getHashUrl(), $text);
+        $text = str_replace('%contacturl%', $this->getContactUrl(), $text);
+
+        return $this->_sendMail($subject, $text);
+    }
+
+    protected function _cancel() {
+        $mapper = new Syj_Model_UserMapper();
+        $mapper->delete($this->_user);
+        return true;
+    }
+}
diff --git a/application/models/PendingMapper.php b/application/models/PendingMapper.php
new file mode 100644 (file)
index 0000000..6b66f67
--- /dev/null
@@ -0,0 +1,161 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Model_PendingMapper
+{
+    protected $_dbTable;
+    protected $_tableInfos = array('name' => 'pending_actions');
+
+    public function getDbTable() {
+        if (null === $this->_dbTable) {
+            $this->_dbTable = new Zend_Db_Table($this->_tableInfos);
+        }
+        return $this->_dbTable;
+    }
+
+    public function fetchByHash($hash) {
+        $table = $this->getDbTable();
+        $result = $table->fetchAll(array('hash = ?' => (string)$hash));
+
+        if (1 !== count($result)) {
+            return null;
+        }
+        $row = $result->current();
+
+        $entry = $this->pendingFactory($row->action);
+        if (!isset($entry)) {
+            continue;
+        }
+        $this->_itemFromRow($entry, $row);
+        return $entry;
+    }
+
+    public function find($id, Syj_Model_Pending $pending) {
+        $result = $this->getDbTable()->find((int)$id);
+        if (0 == count($result)) {
+            return false;
+        }
+        $row = $result->current();
+        $this->_itemFromRow($pending,$row);
+        return true;
+    }
+
+
+    public function fetchForUser(Syj_Model_User $user) {
+        $table = $this->getDbTable();
+        $select = $table->select();
+        $select->union(array_map(function($select) use (&$user) {
+            return $select->where('userid = ?', $user->id);
+        }, $this->_selects()));
+
+        $resultSet = $table->fetchAll($select);
+        $entries   = array();
+        foreach ($resultSet as $row) {
+            $entry = $this->pendingFactory($row->action);
+            if (!isset($entry)) {
+                continue;
+            }
+            $entry->setUser($user);
+            $entries[] = $this->_itemFromRow($entry, $row);
+        }
+        return $entries;
+    }
+
+    public function fetchAll() {
+        $table = $this->getDbTable();
+        $select = $table->select();
+        $select->union($this->_selects());
+
+        $resultSet = $table->fetchAll($select);
+        $entries   = array();
+        foreach ($resultSet as $row) {
+            $entry = $this->pendingFactory($row->action);
+            if (!isset($entry)) {
+                continue;
+            }
+            $entries[] = $this->_itemFromRow($entry, $row);
+        }
+        return $entries;
+    }
+
+    protected function pendingFactory($action) {
+        switch ($action) {
+            case 'validate_creation':
+                return new Syj_Model_Pending_ValidateCreation();
+            break;
+            case 'reset_password':
+                return new Syj_Model_Pending_ResetPassword();
+            break;
+            default:
+                return null;
+            break;
+        }
+    }
+
+    protected function _selects() {
+        $res = array();
+        $table = $this->getDbTable();
+
+        foreach (Syj_Model_Pending::$rules as $action_name => $action) {
+            foreach ($action as $number => $item) {
+                $select = $table->select();
+                $select->where('action = ?', $action_name);
+                if (isset($item)) {
+                    $select->where('creation_time < (NOW() - interval ?)', $item);
+                }
+                if ($item === end($action)) {
+                    $select->where('notifications_number >= ?', $number);
+                } else {
+                    $select->where('notifications_number = ?', $number);
+                }
+                $res[] = $select;
+            }
+        }
+
+        return $res;
+    }
+
+    protected function _itemFromRow(Syj_Model_Pending $item, Zend_Db_Table_Row $row) {
+        $item->setId($row->id)
+             ->setHash($row->hash)
+             ->setNotificationsNumber($row->notifications_number)
+             ->setCreationTime($row->creation_time);
+
+        if (!$item->getUser()) {
+            $user = new Syj_Model_User();
+            $userMapper = new Syj_Model_UserMapper();
+            if ($userMapper->find($row->userid, $user)) {
+                $item->setUser($user);
+            }
+        }
+
+        return $item;
+    }
+
+    public function save (Syj_Model_Pending $pending) {
+        $data = array(
+            'userid'=> (string) $pending->user->id,
+            'action'=> (string)$pending->action,
+        );
+        if (isset($pending->hash)) {
+            $data['hash'] = (string) $pending->hash;
+        }
+        if (isset($pending->notificationsNumber)) {
+            $data['notifications_number'] = (string) $pending->notificationsNumber;
+        }
+         if (null === ($id = $pending->getId())) {
+            $id = $this->getDbTable()->insert($data);
+            $this->find($id, $pending);
+        } else {
+            $this->getDbTable()->update($data, array('id = ?' => $id));
+            $this->find($id, $pending);
+        }
+    }
+
+    public function delete (Syj_Model_Pending $pending) {
+         if (null !== ($id = $pending->getId())) {
+            $this->getDbTable()->delete(array('id = ?' => $id));
+         }
+    }
+}
diff --git a/application/models/User.php b/application/models/User.php
new file mode 100644 (file)
index 0000000..14d1588
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Model_User extends Syj_Model_Generic
+{
+    protected $_id;
+    protected $_pseudo;
+    protected $_password;
+    protected $_email;
+    protected $_lang;
+    protected $_creation_addr;
+
+    public function setId($id) {
+        $this->_id = (int) $id;
+        return $this;
+    }
+
+    public function getId() {
+        return $this->_id;
+    }
+
+    public function setPassword($password) {
+        $this->_password = (string) $password;
+        return $this;
+    }
+
+    public function getPassword() {
+        return $this->_password;
+    }
+
+    public function setPseudo($pseudo) {
+        $this->_pseudo = (string) $pseudo;
+        return $this;
+    }
+
+    public function getPseudo() {
+        return $this->_pseudo;
+    }
+
+    public function setEmail($email) {
+        $this->_email = (string) $email;
+        return $this;
+    }
+
+    public function getEmail() {
+        return $this->_email;
+    }
+
+    public function setLang($lang) {
+        $this->_lang = (string) $lang;
+        return $this;
+    }
+
+    public function getLang() {
+        return $this->_lang;
+    }
+
+    public function setCreationAddr($creation_addr) {
+        $this->_creation_addr = (string) $creation_addr;
+        return $this;
+    }
+
+    public function getCreationAddr() {
+        return $this->_creation_addr;
+    }
+
+    public function notifyPendings() {
+        $pendingMapper = new Syj_Model_PendingMapper();
+        $pendings = $pendingMapper->fetchForUser($this);
+        foreach ($pendings as $pending) {
+            $pending->notify();
+        }
+    }
+
+}
+
diff --git a/application/models/UserMapper.php b/application/models/UserMapper.php
new file mode 100644 (file)
index 0000000..a4364a0
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Model_UserMapper
+{
+    protected $_dbTable;
+    protected $_tableInfos = array('name' => 'users');
+
+    public function getDbTable() {
+        if (null === $this->_dbTable) {
+            $this->_dbTable = new Zend_Db_Table($this->_tableInfos);
+        }
+        return $this->_dbTable;
+    }
+
+    public function find($id, Syj_Model_User $user) {
+        $result = $this->getDbTable()->find((int)$id);
+        if (0 == count($result)) {
+            return false;
+        }
+        $row = $result->current();
+        $this->_itemFromRow($user, $row);
+        return true;
+    }
+
+    public function findByEmail($email, Syj_Model_User $user) {
+        $table = $this->getDbTable();
+        $select = $table->select()->where('email = ?', (string)$email);
+        $row = $table->fetchRow($select);
+        if (!$row) {
+            return false;
+        }
+        $this->_itemFromRow($user, $row);
+        return true;
+    }
+
+    public function fetchAll() {
+        $resultSet = $this->getDbTable()->fetchAll();
+        $entries   = array();
+        foreach ($resultSet as $row) {
+            $entry = new Syj_Model_User();
+            $this->_itemFromRow($entry, $row);
+            $entries[] = $entry;
+        }
+        return $entries;
+    }
+
+    protected function _itemFromRow(Syj_Model_User $item, Zend_Db_Table_Row $row) {
+        $item->setId($row->id)
+            ->setPassword($row->password)
+            ->setPseudo($row->pseudo)
+            ->setEmail($row->email)
+            ->setLang($row->lang)
+            ->setCreationAddr($row->creation_addr);
+    }
+
+    public function save (Syj_Model_User $user) {
+        $data = array(
+            'pseudo'=> (string) $user->pseudo,
+            'password'=> (string)$user->password,
+            'email'=> (string) $user->email,
+            'lang'=> (string) $user->lang,
+            'creation_addr'=> (string) $user->creationAddr
+        );
+        if (null === ($id = $user->getId())) {
+            $user->id = $this->getDbTable()->insert($data);
+        } else {
+            $this->getDbTable()->update($data, array('id = ?' => $id));
+        }
+        $user->notifyPendings();
+    }
+
+    public function delete (Syj_Model_User $pending) {
+         if (null !== ($id = $pending->getId())) {
+            $this->getDbTable()->delete(array('id = ?' => $id));
+         }
+    }
+}
+
diff --git a/application/validate/EmailAddress.php b/application/validate/EmailAddress.php
new file mode 100644 (file)
index 0000000..b6b2ccb
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Validate_EmailAddress extends Zend_Validate_EmailAddress {
+    public function __construct($options = array()) {
+        parent::__construct($options);
+        $this->setMailValidatorMessage();
+    }
+
+    protected function setMailValidatorMessage($message = null) {
+        if (!$message) {
+            $message = __("Invalid email");
+        }
+
+        foreach (array(Zend_Validate_EmailAddress::INVALID,
+                    Zend_Validate_EmailAddress::INVALID_FORMAT,
+                    Zend_Validate_EmailAddress::INVALID_HOSTNAME,
+                    Zend_Validate_EmailAddress::INVALID_MX_RECORD,
+                    Zend_Validate_EmailAddress::INVALID_SEGMENT,
+                    Zend_Validate_EmailAddress::DOT_ATOM,
+                    Zend_Validate_EmailAddress::QUOTED_STRING,
+                    Zend_Validate_EmailAddress::INVALID_LOCAL_PART,
+                    Zend_Validate_EmailAddress::LENGTH_EXCEEDED,
+
+                    Zend_Validate_Hostname::INVALID,
+                    Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED,
+                    Zend_Validate_Hostname::UNKNOWN_TLD,
+                    Zend_Validate_Hostname::INVALID_DASH,
+                    Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA,
+                    Zend_Validate_Hostname::UNDECIPHERABLE_TLD,
+                    Zend_Validate_Hostname::INVALID_HOSTNAME,
+                    Zend_Validate_Hostname::INVALID_LOCAL_NAME,
+                    Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED,
+                    Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE) as $key) {
+            $this->setMessage($message, $key);
+        }
+    }
+
+    public function isValid($value) {
+        $valid = parent::isValid($value);
+        // only one error message
+        if (!$valid) {
+            $this->_messages = array(current($this->_messages));
+            $this->_errors = array(current($this->_errors));
+        }
+        return $valid;
+    }
+}
+
+?>
diff --git a/application/views/helpers/AddParamToUrl.php b/application/views/helpers/AddParamToUrl.php
new file mode 100644 (file)
index 0000000..e0b37a3
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_View_Helper_AddParamToUrl extends Zend_View_Helper_Abstract
+{
+    public function addParamToUrl($url, $param, $value, $replace = false) {
+        if (strpos ($url, '?') === false) {
+            return $url . '?' . $param . '=' . $this->view->escape($value);
+        }
+
+        $parts = explode('&', substr(strstr($url, '?'), 1));
+
+        foreach (explode('&', substr(strstr($url, '?'), 1)) as $key => $part) {
+            if (substr($part, 0, strlen($param . '=')) === ($param . '=')) {
+                if ($replace) {
+                    unset($parts[$key]);
+                } else {
+                    return $url;
+                }
+            }
+        }
+
+        $parts[] = $param . '=' . $this->view->escape($value);
+
+        return strstr($url, '?', true) . '?' . implode('&', $parts);
+    }
+}
diff --git a/application/views/helpers/Anchor.php b/application/views/helpers/Anchor.php
new file mode 100644 (file)
index 0000000..ddfe744
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_View_Helper_Anchor extends Zend_View_Helper_HtmlElement
+{
+    public function Anchor($href, $text = null, array $attribs=array()) {
+        $lang = Zend_Controller_Front::getInstance()->getRequest()->getQuery('lang');
+        if ($lang) {
+            $translator = Zend_Registry::get('Zend_Translate');
+            $adapter = $translator->getAdapter();
+            if ($adapter->isAvailable($lang)) {
+                $href = $this->view->addParamToUrl($href, 'lang', $lang);
+            }
+        }
+
+        $attribs = array_merge(array('href' => $href), $attribs);
+        if (!isset($text)) {
+            $text = $href;
+        }
+        $html = '<a' . $this->_htmlAttribs($attribs) . '>' . $this->view->escape($text) . '</a>';
+        return $html;
+    }
+}
+
diff --git a/application/views/helpers/FooterLink.php b/application/views/helpers/FooterLink.php
new file mode 100644 (file)
index 0000000..529221d
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_View_Helper_FooterLink extends Zend_View_Helper_Abstract
+{
+    public function FooterLink($routeoptions, $text, $redirect=true) {
+        $page = new Zend_Navigation_Page_Mvc($routeoptions);
+        if ($page->isActive()) {
+            $link = $this->view->escape($text);
+        } else {
+            $href = $page->getHRef();
+            if ($redirect) {
+                $currentUri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
+                if (strpos($currentUri, '?') !== false) {
+                    $currentUri = strstr($currentUri, '?', true);
+                }
+                $href = $this->view->addParamToUrl($href, 'redirect', $currentUri, true);
+            }
+            $link = $this->view->anchor($href, $text, array('class' => 'footer-anchor'));
+        }
+        return '<div class="footer-link">' . $link . '</div>' . PHP_EOL;
+    }
+}
+
+?>
diff --git a/application/views/helpers/HeadBase.php b/application/views/helpers/HeadBase.php
new file mode 100644 (file)
index 0000000..8bb9467
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_View_Helper_HeadBase extends Zend_View_Helper_Placeholder_Container_Standalone
+{
+
+    /* base uri */
+    protected $href;
+
+    /* string to use as an indent of output */
+    protected $_indent = '';
+
+    public function headBase($href = null) {
+        $href = (string) $href;
+        if ($href == '') {
+            $serverUrl = rtrim($this->view->serverUrl(), '/');
+            $baseUrl = trim($this->view->baseUrl(), '/');
+            $href = $serverUrl . '/' . ($baseUrl ? ($baseUrl . '/'): '');
+        }
+        $this->href = $href;
+        return $this;
+    }
+
+    public function toString($indent = null) {
+        $indent = (null !== $indent)
+                ? $this->getWhitespace($indent)
+                : $this->getIndent();
+
+        return $indent . '<base href="' . $this->href . '">';
+    }
+
+    /* following part of the file is copied from Zend_View_Helper_Placeholder_Container_Abstract */
+
+    /**
+     * Retrieve whitespace representation of $indent
+     *
+     * @param  int|string $indent
+     * @return string
+     */
+    public function getWhitespace($indent)
+    {
+        if (is_int($indent)) {
+            $indent = str_repeat(' ', $indent);
+        }
+
+        return (string) $indent;
+    }
+
+    /**
+     * Set the indentation string for __toString() serialization,
+     * optionally, if a number is passed, it will be the number of spaces
+     *
+     * @param  string|int $indent
+     * @return Zend_View_Helper_Placeholder_Container_Abstract
+     */
+    public function setIndent($indent)
+    {
+        $this->_indent = $this->getWhitespace($indent);
+        return $this;
+    }
+
+    /**
+     * Retrieve indentation
+     *
+     * @return string
+     */
+    public function getIndent()
+    {
+        return $this->_indent;
+    }
+
+}
diff --git a/application/views/helpers/LocaleShort.php b/application/views/helpers/LocaleShort.php
new file mode 100644 (file)
index 0000000..e37310c
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_View_Helper_LocaleShort extends Zend_View_Helper_Abstract
+{
+    public function localeShort() {
+        $translator = $this->view->getHelper('translate')->getTranslator();
+        $locale = $translator->getLocale();
+        if (!($translator->isAvailable($locale))) {
+            $defaults = Zend_Locale::getDefault();
+            arsort($defaults);
+            $locale = key($defaults);
+        }
+        $locale = new Zend_Locale($locale);
+        return $locale->getLanguage();
+    }
+}
diff --git a/application/views/helpers/LocaleSwitcher.php b/application/views/helpers/LocaleSwitcher.php
new file mode 100644 (file)
index 0000000..cd4e26d
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_View_Helper_LocaleSwitcher extends Zend_View_Helper_Abstract
+{
+    public function localeSwitcher() {
+        $translator = $this->view->getHelper('translate')->getTranslator();
+        $availables = $translator->getList();
+        $current = $translator->getLocale();
+
+        $requestUri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
+
+        $links = array();
+        foreach ($availables as $lang) {
+
+            $langname = $translator->translate('english', $lang);
+            if ($lang == $current) {
+                array_push ($links, "<a class=\"other-language-anchor\">$langname</a>");
+            } else {
+                $href = $this->view->addParamToUrl($requestUri, 'lang', $lang, true);
+                array_push ($links, $this->view->anchor($href, $langname,
+                                          array('class' => 'other-language-anchor',
+                                                'title' => $langname, 'lang' => $lang, 'hreflang' => $lang)));
+            }
+        }
+        return "<div id=\"other-language\">" . join("", $links) . "</div>\n";
+    }
+}
diff --git a/application/views/helpers/LoggedUser.php b/application/views/helpers/LoggedUser.php
new file mode 100644 (file)
index 0000000..59af93d
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_View_Helper_LoggedUser extends Zend_View_Helper_Abstract
+{
+    public function LoggedUser() {
+        try {
+            $sessionStorage = Zend_Auth::getInstance()->getStorage();
+        } catch(Exception $e) {
+            return null;
+        }
+        $sessionData = $sessionStorage->read();
+        if ($sessionStorage->isEmpty()) {
+            return null;
+        }
+
+        $userMapper = new Syj_Model_UserMapper();
+        $user = new Syj_Model_User();
+        if ($userMapper->find($sessionData['user'], $user)) {
+            return $user;
+        } else {
+            return null;
+        }
+    }
+}
+
+?>
diff --git a/application/views/helpers/LogoutLink.php b/application/views/helpers/LogoutLink.php
new file mode 100644 (file)
index 0000000..d76682e
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_View_Helper_LogoutLink extends Zend_View_Helper_Abstract
+{
+    public function logoutLink() {
+        $currentUri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
+        if (strpos($currentUri, '?') !== false) {
+            $currentUri = strstr($currentUri, '?', true);
+        }
+        $translatedString = $this->view->translate('logout');
+        $href = $this->view->addParamToUrl('logout', 'redirect', $currentUri, true);
+        return $this->view->anchor($href, $translatedString, array('id' => 'logout', 'class' => 'login-anchor'));
+    }
+}
diff --git a/application/views/helpers/Returnto.php b/application/views/helpers/Returnto.php
new file mode 100644 (file)
index 0000000..a90822e
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_View_Helper_Returnto extends Zend_View_Helper_HtmlElement
+{
+
+    protected function getHref() {
+        $param = Zend_Controller_Front::getInstance()->getRequest()->getQuery('redirect');
+        if (!isset($param)) {
+            return false;
+        }
+        $href = $this->view->escape(implode('/', array_map('urlencode', explode('/', $param ))));
+        return $href;
+    }
+
+    public function returnto() {
+        $returnto = $this->getHref();
+        $baseurl = $this->view->baseUrl();
+
+        if ($returnto === false) {
+            return $this->view->translate('You can now') . ' '
+                   . $this->view->anchor($baseurl, $this->view->translate('go to main page'));
+        } else if ($returnto == $baseurl) {
+            return $this->view->translate('You can now') . ' '
+            . $this->view->anchor($returnto, $this->view->translate('go back to %s', $returnto));
+        } else {
+            return $this->view->translate('You can now') . ' ' .
+                    $this->view->anchor($returnto, $this->view->translate('go back to %s', $returnto)) .
+                    ' ' . $this->view->translate('or you can') . ' ' .
+                    $this->view->anchor($baseurl, $this->view->translate('go to main page'));
+        }
+
+    }
+}
diff --git a/application/views/scripts/account/index.phtml b/application/views/scripts/account/index.phtml
new file mode 100644 (file)
index 0000000..aa1f67e
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+    print $this->localeSwitcher();
+    print $this->form;
+?>
diff --git a/application/views/scripts/account/success.phtml b/application/views/scripts/account/success.phtml
new file mode 100644 (file)
index 0000000..a749df7
--- /dev/null
@@ -0,0 +1,8 @@
+<p class="success message">
+<?php
+    $this->redirectLinks = false;
+    echo $this->translate("Your account was modified successfully");
+    echo "<br>";
+    echo $this->returnto();
+?>
+</p>
diff --git a/application/views/scripts/contact/index.phtml b/application/views/scripts/contact/index.phtml
new file mode 100644 (file)
index 0000000..339ae6a
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+    print $this->localeSwitcher();
+    print $this->form;
+
+    if ($this->sendError) {
+        $to = Zend_Controller_Front::getInstance()->getParam('webmasterEmail');
+        print '<p class="error message">';
+        print $this->translate('There was an unkwown message when sending the message. Please try again later, or send a mail directly to <a href="mailto:%s">%s</a>', $this->escape($to), $this->escape($to));
+        print "</p>" . PHP_EOL;
+    }
+?>
diff --git a/application/views/scripts/contact/success.phtml b/application/views/scripts/contact/success.phtml
new file mode 100644 (file)
index 0000000..d770d8c
--- /dev/null
@@ -0,0 +1,8 @@
+<p class="success message">
+<?php
+    $this->redirectLinks = false;
+    echo $this->translate("Email was send successfully");
+    echo "<br>";
+    echo $this->returnto();
+?>
+</p>
diff --git a/application/views/scripts/error/error.phtml b/application/views/scripts/error/error.phtml
new file mode 100644 (file)
index 0000000..085621b
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+    $this->redirectLinks = false;
+?>
+  <h1><?php echo $this->translate('An error occurred')?></h1>
+  <h2><?php echo $this->message ?></h2>
+
+  <?php if (isset($this->exception)): ?>
+
+  <h3>Exception information:</h3>
+  <p>
+      <b>Message:</b> <?php echo $this->exception->getMessage() ?>
+  </p>
+
+  <h3>Stack trace:</h3>
+  <pre><?php echo $this->exception->getTraceAsString() ?>
+  </pre>
+
+  <h3>Request Parameters:</h3>
+  <pre><?php echo var_export($this->request->getParams(), true) ?>
+  </pre>
+  <?php endif ?>
+
+    <p id="message">
+    <?php
+        if ($this->isServerError) {
+            echo $this->translate('Please try again later');
+        } else {
+            echo $this->anchor($this->baseUrl(), $this->translate('go to main page'));
+        }
+        ?>
+
+    </p>
diff --git a/application/views/scripts/idx/index.phtml b/application/views/scripts/idx/index.phtml
new file mode 100644 (file)
index 0000000..38f1e3b
--- /dev/null
@@ -0,0 +1,73 @@
+    <noscript>
+        <style type="text/css">
+            #map, #message, #data_controls, #login_controls, #user_area, #login_area, #newpwd_area {
+                display: none;
+            }
+        </style>
+
+        <p><?php echo $this->translate('SYJ needs javascript. Please activate scripts in your browser.');?></p>
+    </noscript>
+
+    <div id="map"></div>
+
+    <div id="message" class="message info">
+    <?php if (!$this->path and !$this->loggedUser()) {?>
+    <?php echo $this->translate('Welcome on Syj.')?>
+    <br/>
+    <?php echo $this->translate('To create a journey, just click on the map to add points to your route. You can zoom and move map with controls upper left.')?>
+    <br/>
+    <?php echo $this->translate('When you have finished a path, press "save", button.')?>
+    <?php }?>
+    </div>
+
+    <div id="data_controls">
+    <input id="edit-btn" name="edit-btn" type="button" value="<?php echo $this->translate('edit')?>">
+
+    <?php
+        print $this->geomform;
+    ?>
+
+    </div>
+
+    <div id="login_controls">
+        <div>
+            <?php
+                echo $this->anchor('login', $this->translate('login'), array('id' => 'login_control_anchor', 'class' => 'login-anchor'));
+                echo $this->anchor('', $this->translate('create an account'), array('id' => 'user_control_anchor', 'class' => 'login-anchor'));
+            ?>
+        </div>
+        <div>
+            <?php echo $this->logoutLink(); ?>
+        </div>
+    </div>
+
+    <div id="newpwd_area" class="modal">
+        <div id="newpwd_message" class="message"></div>
+        <?php
+            print $this->newpwdform;
+        ?>
+    </div>
+
+    <div id="user_area" class="modal">
+        <div id="user_message" class="message"></div>
+        <?php
+            print $this->userform;
+        ?>
+    </div>
+
+      <div id="login_area" class="modal">
+         <div id="login_message" class="message"></div>
+
+      <?php
+        print $this->loginform;
+      ?>
+
+      <p id="login_area_create"><a id="login_area_create_anchor" href=""><?php echo $this->translate('create an account')?></a></p>
+
+      </div>
+
+      <div id="termsofusearea" class="modal">
+        <iframe id="termsofuseiframe" width="100%" height="100%" frameborder="0"></iframe>
+      </div>
+
+<?php echo $this->localeSwitcher(); ?>
diff --git a/application/views/scripts/login/login.phtml b/application/views/scripts/login/login.phtml
new file mode 100644 (file)
index 0000000..aa1f67e
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+    print $this->localeSwitcher();
+    print $this->form;
+?>
diff --git a/application/views/scripts/newpwd/index.phtml b/application/views/scripts/newpwd/index.phtml
new file mode 100644 (file)
index 0000000..c110b3c
--- /dev/null
@@ -0,0 +1,5 @@
+<?php
+    $this->redirectLinks = false;
+    print $this->localeSwitcher();
+    print $this->form;
+?>
diff --git a/application/views/scripts/newpwd/success.phtml b/application/views/scripts/newpwd/success.phtml
new file mode 100644 (file)
index 0000000..01b4b34
--- /dev/null
@@ -0,0 +1,8 @@
+<p class="success message">
+<?php
+    $this->redirectLinks = false;
+    echo $this->translate("A link to reset your password has been emailed to you");
+    echo "<br>";
+    echo $this->returnto();
+?>
+</p>
diff --git a/application/views/scripts/pending/creation_cancel.phtml b/application/views/scripts/pending/creation_cancel.phtml
new file mode 100644 (file)
index 0000000..d5ee773
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+    $this->redirectLinks = false;
+
+    $title = "";
+    foreach ($this->headTitle() as $item) {
+        $title .= $item;
+    }
+
+    echo '<h1>' . $title . '</h1>' . PHP_EOL;
+
+    print '<p class="center success">';
+    print $this->translate('You have canceled the account.');
+    print ' ';
+    print $this->translate('You can now') . ' ' .
+          $this->anchor($this->baseUrl(), $this->translate('go to main page'));
+    print '</p>';
+?>
diff --git a/application/views/scripts/pending/creation_validate.phtml b/application/views/scripts/pending/creation_validate.phtml
new file mode 100644 (file)
index 0000000..b70e27c
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+    $this->redirectLinks = false;
+
+    $title = "";
+    foreach ($this->headTitle() as $item) {
+        $title .= $item;
+    }
+
+    echo '<h1>' . $title . '</h1>' . PHP_EOL;
+
+    print '<p class="center success">';
+    print $this->translate('You have validated your account.');
+    print ' ';
+    print $this->translate('You can now') . ' ' .
+          $this->anchor($this->baseUrl(), $this->translate('go to main page'));
+    print '</p>';
+?>
diff --git a/application/views/scripts/pending/index.phtml b/application/views/scripts/pending/index.phtml
new file mode 100644 (file)
index 0000000..a7a74c2
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+    $this->redirectLinks = false;
+    echo $this->localeSwitcher();
+
+    $title = "";
+    foreach ($this->headTitle() as $item) {
+        $title .= $item;
+    }
+
+
+    echo '<h1>' . $title . '</h1>' . PHP_EOL;
+
+    print $this->form;
+
+    print '<p class="center">';
+    print $this->translate("If you need more informations, please") . ' ' .
+          $this->anchor("contact", $this->translate("contact us"));
+    print '</p>';
+?>
diff --git a/application/views/scripts/pending/password_cancel.phtml b/application/views/scripts/pending/password_cancel.phtml
new file mode 100644 (file)
index 0000000..f6de7e2
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+    $this->redirectLinks = false;
+
+    $title = "";
+    foreach ($this->headTitle() as $item) {
+        $title .= $item;
+    }
+
+    echo '<h1>' . $title . '</h1>' . PHP_EOL;
+
+    print '<p class="center success">';
+    print $this->translate('You have canceled the request.');
+    print ' ';
+    print $this->translate('You can now') . ' ' .
+          $this->anchor($this->baseUrl(), $this->translate('go to main page'));
+    print '</p>';
+?>
diff --git a/application/views/scripts/pending/password_validate.phtml b/application/views/scripts/pending/password_validate.phtml
new file mode 100644 (file)
index 0000000..1d1c892
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+    $this->redirectLinks = false;
+
+    $title = "";
+    foreach ($this->headTitle() as $item) {
+        $title .= $item;
+    }
+
+    echo '<h1>' . $title . '</h1>' . PHP_EOL;
+
+    print '<p class="center success">';
+
+    $href = $this->addParamToUrl('login', 'redirect', 'account');
+
+    print $this->translate('Your new password is now <strong>%s</strong>. You can %s with this new password. Don\'t forget to change it again to a personal password as soon as possible.',
+            $this->escape($this->newpwd),
+            $this->anchor($href, $this->translate('log in'))
+            );
+    print '</p>';
+?>
diff --git a/application/views/scripts/termsofuse/index.phtml b/application/views/scripts/termsofuse/index.phtml
new file mode 100644 (file)
index 0000000..737c5b9
--- /dev/null
@@ -0,0 +1,21 @@
+<?php echo $this->localeSwitcher(); ?>
+<p><?php
+echo $this->translate('Show Your Journey is a site whose goal is to allow anyone to publish routes, for example, hiking itinerary, bicycle trip, travel itinerary or whatever.');
+?></p>
+
+<p><?php
+echo $this->translate('In order to publish a route, you must first create an account.  A valid email is asked for, and ip address of account creation is stored on the server. Those informations will not be divulged to anyone without the user explicit permission.');
+?></p>
+
+<p><?php
+echo $this->translate('When you create a route, you accept that it\'s available under a <a href="http://creativecommons.org/licenses/by/2.0/">creative commons <strong>by</strong> license</a>. This means you accept that anyone can reproduce and republish your itinerary, or a modified version of it, under the condition that he specify the proper creator of this work. This also means you need to get appropriate permissions from the creator if you want to upload a route you didn\'t create yourself.');
+?></p>
+
+<p><?php
+echo $this->translate('Show Your Journey is not responsible for the accuracy of the routes published.  It\'s the user responsibility to check that a route is accessible and safe.');
+?></p>
+
+<p><?php
+echo $this->translate('Sources of the software running the website are <a href="http://dev.renevier.net/?p=syj.git">publicly available</a> under a agpl license. The map used to display the routes comes from <a href="http://www.openstreetmap.org/">openstreetmap</a>.');
+?></p>
+
diff --git a/generated/.placeholder b/generated/.placeholder
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/library/Zend b/library/Zend
new file mode 160000 (submodule)
index 0000000..a6a6d95
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit a6a6d95a75d5a657bd23602ebeb7e8ae3a547cb1
diff --git a/library/gisconverter b/library/gisconverter
new file mode 160000 (submodule)
index 0000000..063610d
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 063610dca1ee201535e71a63b9e4b5ae92add507
diff --git a/library/gisconverter.php b/library/gisconverter.php
new file mode 120000 (symlink)
index 0000000..6127f5a
--- /dev/null
@@ -0,0 +1 @@
+gisconverter/gisconverter.php
\ No newline at end of file
diff --git a/library/phptojs.php b/library/phptojs.php
new file mode 100644 (file)
index 0000000..2ca2439
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+namespace phptojs;
+
+class JsObject {
+    protected $_name;
+    protected $_data = array();
+    public function __construct($name = null, $data = array()) {
+        $this->_name = $name;
+        if (is_array($data)) {
+            $this->_data = $data;
+        }
+    }
+
+    public function getName() {
+        return $this->_name;
+    }
+
+    public function setName($name) {
+        $this->_name = (string)$name;
+        return $this;
+    }
+
+    public function __set($property, $value) {
+        $this->_data[$property] = $value;
+    }
+    public function __get($property) {
+        if (array_key_exists($property, $this->_data)) {
+            return $this->_data[$property];
+        }
+        return null;
+    }
+
+    public function __unset($property) {
+        unset($this->_data[$property]);
+    }
+    public function __isset($property) {
+        return __isset($this->_data[$property]);
+    }
+
+    public function __toString() {
+        if ($this->_name) {
+            $prefix = "var " . $this->_name . " = ";
+        } else {
+            $prefix = "";
+        }
+        return $prefix . " " . json_encode($this->_data, JSON_FORCE_OBJECT) . ";" . PHP_EOL;
+    }
+
+}
diff --git a/library/pwdgen.php b/library/pwdgen.php
new file mode 100644 (file)
index 0000000..61c0916
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+namespace pwdgen;
+
+class PwdGenerator {
+    protected static $_allowed = "0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+    public static function generate($length = 8, $allowed = null) {
+        if (!$allowed or !is_string($allowed)) {
+            $allowed = self::$_allowed;
+        }
+
+        return array_reduce(range(0, $length), function($res) use ($allowed) {
+            return $res . $allowed[mt_rand(0,strlen($allowed) - 1)];
+        }, "");
+    }
+}
diff --git a/public/css/account.css b/public/css/account.css
new file mode 100644 (file)
index 0000000..c112fc8
--- /dev/null
@@ -0,0 +1,22 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+/*
+ * form
+ */
+#account_email {
+    margin-bottom: 1em;
+}
+#account_password_confirm {
+    margin-bottom: 1em;
+}
+#account_password_current {
+    margin-bottom: 1em;
+}
+form {
+    clear: left;
+    margin: 3em 1em 1em 1em;
+}
+fieldset {
+    margin: 20px 30px 0px 30px;
+}
diff --git a/public/css/contact.css b/public/css/contact.css
new file mode 100644 (file)
index 0000000..c1e8fa1
--- /dev/null
@@ -0,0 +1,22 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+body {
+    margin: 0px;
+    padding: 0px;
+}
+
+/*
+ * form
+ */
+fieldset {
+    margin: 20px 30px 0px 30px;
+}
+
+.error li {
+    list-style-type: none;
+}
+
+.required:before {
+    content:"*";
+    color:#FF8C00;
+}
diff --git a/public/css/error.css b/public/css/error.css
new file mode 100644 (file)
index 0000000..d9e27f7
--- /dev/null
@@ -0,0 +1,5 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+body {
+    text-align: center;
+}
diff --git a/public/css/generic.css b/public/css/generic.css
new file mode 100644 (file)
index 0000000..466d059
--- /dev/null
@@ -0,0 +1,100 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+/*
+ * generic rules
+ */
+.message {
+    text-align: center;
+}
+
+.disabled {
+    color: #A9A9A9;
+}
+noscript {
+    text-align: center;
+    color: red;
+    font-weight: bold;
+}
+noscript p {
+    margin-top: 4em;
+}
+
+.success {
+    color: green;
+    border-color: green;
+    font-weight: bold;
+    background-color: white;
+}
+
+.warn {
+    color: #FF8C00;
+    border-color: #FF8C00;
+    font-weight: bold;
+    background-color: white;
+}
+
+.error {
+    border-color: red;
+    font-weight: bold;
+    background-color: #FFFF33;
+    color: red;
+}
+
+.info {
+    border-color: black;
+    color: black;
+    background-color: white;
+}
+
+.center {
+    text-align: center;
+}
+label {
+    font-weight: bold;
+    white-space: nowrap;
+    vertical-align: top;
+}
+
+/*
+ * footer
+ */
+#footer {
+    position: absolute;
+    bottom: 0px;
+    left: 0px; right: 0px;
+    height: 2em;
+    text-align: center;
+    border-top: 1px solid gray;
+    *background-color: white;
+}
+#footer-padding {
+    height: 5px;
+}
+.footer-link {
+    display: inline;
+    margin: 0px 10px 0px 10px;
+}
+.footer-anchor {
+    text-decoration: none;
+}
+
+/*
+ * locale switcher
+ */
+#other-language {
+    float: right;
+    padding: 5px;
+    margin: 10px 10px 20px 20px;
+}
+.other-language-anchor:hover {
+    background-color: #BBBBFF;
+}
+.other-language-anchor {
+    text-decoration: none;
+    padding-left: 10px;
+    padding-right: 10px;
+    padding-top: 3px;
+    padding-bottom: 3px;
+    border: #1E90FF 1px solid;
+}
diff --git a/public/css/login.css b/public/css/login.css
new file mode 100644 (file)
index 0000000..7f23dfa
--- /dev/null
@@ -0,0 +1,16 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+#loginform {
+    width: 40em;
+}
+.form-table-elem {
+    display: block;
+    width: 100%;
+}
+.form-errors {
+    color: red;
+    font-weight: bold;
+}
+ul {
+    list-style-type: none;
+}
diff --git a/public/css/newpwd.css b/public/css/newpwd.css
new file mode 100644 (file)
index 0000000..17a5578
--- /dev/null
@@ -0,0 +1,13 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+#newpwdform {
+    width: 40em;
+}
+.form-table-elem {
+    display: block;
+    width: 100%;
+}
+.form-errors {
+    color: red;
+    font-weight: bold;
+}
diff --git a/public/css/openlayers b/public/css/openlayers
new file mode 120000 (symlink)
index 0000000..320aa47
--- /dev/null
@@ -0,0 +1 @@
+../openlayers/openlayers/theme/default/
\ No newline at end of file
diff --git a/public/css/pending.css b/public/css/pending.css
new file mode 100644 (file)
index 0000000..7b51ebc
--- /dev/null
@@ -0,0 +1,51 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+body {
+    margin: 0px;
+}
+
+h1 {
+    text-align: center;
+}
+
+.desc {
+    border: 1px solid gray;
+    margin: 40px 15% 40px 15%;
+    padding: 20px 30px 15px 30px;
+    -moz-border-radius: 10px;
+    -webkit-border-radius: 10px;
+    border-radius: 10px;
+}
+#pending_validate, #pending_cancel {
+    margin-top: 15px;
+}
+
+.success {
+    width: 50%;
+    margin: auto;
+}
+.success strong {
+    font-size: 130%;
+    color: #808000;
+    text-decoration: underline;
+}
+
+.message.success{
+    border-color: green;
+}
+.message.warn{
+    border-color: #FF8C00;
+}
+.message.error{
+    border-color: red;
+}
+.message {
+    text-align: center;
+    position: absolute;
+    bottom: 30px;
+    width: 50%;
+    border: 1px solid black;
+    margin-left: 25%;
+    margin-right: 25%;
+    padding: 25px 0px 25px 0px;
+}
diff --git a/public/css/syj.css b/public/css/syj.css
new file mode 100644 (file)
index 0000000..6f7e36d
--- /dev/null
@@ -0,0 +1,136 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+body, html {
+    margin: 0; padding: 0;
+    width: 100%;
+    height: 100%;
+}
+
+/*
+ * map rules
+ */
+#map {
+    position: absolute;
+    top: 0; left: 0; right: 0;
+    bottom: 2em;
+    *width: 100%;
+    *height: 100%;
+}
+
+.olControlAttribution {
+    bottom: 0.5em;
+    left: 0.5em;
+}
+
+/*
+ * main message rules
+ */
+
+#message {
+    position: absolute;
+    bottom: 3.5em;
+    width: 40%;
+    margin: 0px 45% 0px 15%;
+    padding: 1.5em 1.5em 1.5em 1.5em;
+    text-align: center;
+    border-width: 2px;
+    border-style: solid;
+    -moz-border-radius: 5px;
+    -webkit-border-radius: 5px;
+    border-radius: 5px;
+}
+
+/*
+ * controls rules
+ */
+#data_controls {
+    position: absolute;
+    right: 0.5em;
+    bottom: 3em;
+    text-align: center;
+    background-color: white;
+    padding: 25px 45px 20px 45px;
+    opacity: 0.85;
+    filter:alpha(opacity=85);
+    border: 1px solid gray;
+}
+#geom_title {
+    margin-top: 0.7em;
+    background-color: #FDFDFD; /* work around webkit bug #42985 */
+}
+#geom_submit {
+    margin-top: 0.7em;
+}
+
+#login_controls {
+    margin-top: 8px;
+    margin-left: 3em;
+}
+
+.login-anchor {
+    display: block;
+    float: left;
+    position: relative;
+    background-color: white;
+    margin: 0px 10px 0px 10px;
+    text-decoration: none;
+    color: #0000EE;
+    border: #1E90FF 2px solid;
+    padding: 2px 15px 2px 15px;
+    -moz-border-radius: 5px;
+    -webkit-border-radius: 5px;
+    border-radius: 5px;
+    background-color: white;
+    opacity: 0.85;
+    filter:alpha(opacity=85);
+}
+.login-anchor:hover {
+    background-color: #BBBBFF;
+}
+
+/*
+ * login rules
+ */
+.modal {
+    background-color: white;
+    text-align: center;
+    width: 50%;
+    margin-left: auto;
+    margin-right: auto;
+    padding: 21px;
+    border: 1px solid gray;
+    opacity: 0.85;
+    filter:alpha(opacity=85);
+}
+
+.form-table-elem {
+    display: block;
+    width: 100%;
+}
+.modal .message {
+    margin: 0 35px 12px 35px;
+}
+#login_area_create {
+    text-align: right;
+}
+
+#user_email-desc {
+    margin: 0px 0px 12px 0px;
+    padding: 8px 2px 8px 2px;
+    background-color: #D3D3D3; /* lightgrey */
+}
+
+#termsofusearea {
+    height: 50%;
+}
+
+#other-language {
+    opacity: 0.85;
+    filter:alpha(opacity=85);
+    position: absolute;
+    right: 10px;
+    top: 10px;
+    background-color: white;
+    padding: 5px 1px 5px 1px;
+    margin: 0;
+}
diff --git a/public/css/termsofuse.css b/public/css/termsofuse.css
new file mode 100644 (file)
index 0000000..d43211c
--- /dev/null
@@ -0,0 +1,6 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+body {
+    text-align: justify;
+    text-indent: 0.6em;
+}
diff --git a/public/icons/close.png b/public/icons/close.png
new file mode 120000 (symlink)
index 0000000..0ebb963
--- /dev/null
@@ -0,0 +1 @@
+../simplebox/icons/close.png
\ No newline at end of file
diff --git a/public/icons/delete.png b/public/icons/delete.png
new file mode 100644 (file)
index 0000000..08f2493
Binary files /dev/null and b/public/icons/delete.png differ
diff --git a/public/index.php b/public/index.php
new file mode 100644 (file)
index 0000000..f38470e
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+// Define path to application directory
+defined('APPLICATION_PATH')
+    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
+
+// Define application environment
+defined('APPLICATION_ENV')
+    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
+
+// set include directories to '.' and ../library
+set_include_path('.' . PATH_SEPARATOR . realpath(APPLICATION_PATH . '/../library'));
+
+/** Zend_Application */
+require_once 'Zend/Application.php';
+
+// Create application, bootstrap, and run
+$application = new Zend_Application(
+    APPLICATION_ENV,
+    APPLICATION_PATH . '/configs/application.ini'
+);
+
+# we use this function as a marker so xgettext knows it must extract this
+# string. This function can be used when string must be translated, but not at
+# the place it's called. For example, Zend_Form uses a translator to translate
+# string it has been given. So, we must pass it a non translated string.
+function __($str) {
+    return $str;
+}
+
+$application->bootstrap()
+            ->run();
diff --git a/public/js/ModifiablePath.js b/public/js/ModifiablePath.js
new file mode 120000 (symlink)
index 0000000..b4a03e1
--- /dev/null
@@ -0,0 +1 @@
+../modifiablepath/ModifiablePath.js
\ No newline at end of file
diff --git a/public/js/OpenLayers.js b/public/js/OpenLayers.js
new file mode 120000 (symlink)
index 0000000..74f2a15
--- /dev/null
@@ -0,0 +1 @@
+lib/OpenLayers.js
\ No newline at end of file
diff --git a/public/js/account.js b/public/js/account.js
new file mode 100644 (file)
index 0000000..f6e204a
--- /dev/null
@@ -0,0 +1,58 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+document.observe("dom:loaded", function() {
+    var currentmail = $("account_email").value, form = $("accountform");
+
+    form.focus();
+
+    form.observe('submit', function(evt) {
+        var control, errorElements;
+
+        $$('.error').invoke('remove');
+
+        errorElements = $$('#account_email, #account_password').findAll(
+            function(elt) {
+                return (!elt.check(function() {
+                    return !this.value.strip().empty();
+                }, SyjStrings.notEmptyField));
+            });
+
+
+        if (!errorElements.length) {
+            control = $("account_password");
+            if (!control.check(function() {
+                return this.value.length >= 6;
+            }, SyjStrings.passwordLenghtWarn)) {
+                errorElements.push(control);
+            }
+        }
+
+        if (!errorElements.length) {
+            control = $("account_password");
+            if (control.check(function() {
+                return this.value === $("account_password_confirm").value;
+            }, SyjStrings.passwordNoMatchWarn)) {
+                errorElements.push(control);
+            }
+        }
+
+        if (!errorElements.length) {
+            control = $("account_email");
+            if (!control.check(function() {
+                return this.value !== currentmail || $("account_password").value !== $("account_password_current").value;
+            }, SyjStrings.nochangeWarn)) {
+                errorElements.push(control);
+            }
+        }
+
+        /*
+         * if there are errors, cancel submission
+         */
+        if (errorElements.length) {
+            errorElements[0].focus();
+            errorElements[0].select();
+            evt.stop();
+        }
+    });
+});
diff --git a/public/js/ajaxize.js b/public/js/ajaxize.js
new file mode 100644 (file)
index 0000000..6680110
--- /dev/null
@@ -0,0 +1,58 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+// wrapper around Form.request that sets up the submit listener, stops the
+// submit event, calls presubmit function, calls Form.request and calls a
+// postsubmit function
+Element.addMethods('form', {ajaxize : function(form, options) {
+    var reqoptions, timeout;
+
+    options = Object.clone(options);
+    reqoptions = Object.clone(options);
+    timeout = null;
+
+    function onSuccess(transport, json) {
+        if (timeout) {
+            window.clearTimeout(timeout);
+            timeout = null;
+        }
+        if (transport.getStatus() === 0) {
+            options.onFailure(transport, json);
+        } else {
+            options.onSuccess(transport, json);
+        }
+    }
+
+    function onFailure(transport, json) {
+        if (timeout) {
+            window.clearTimeout(timeout);
+            timeout = null;
+        }
+        options.onFailure(transport, json);
+    }
+
+    delete(reqoptions.presubmit);
+    delete(reqoptions.postsubmit);
+
+    $(form).observe('submit', function(evt) {
+        var req;
+
+        evt.stop(); // cancel form submission
+        if (Object.isFunction(options.presubmit)) {
+            if (options.presubmit(this) === false) {
+                return;
+            }
+        }
+        req = this.request(Object.extend(reqoptions, {
+            onSuccess: onSuccess,
+            onFailure: onFailure
+        }));
+        timeout = (function() {
+            options.onFailure(null);
+            req.abort();
+        }).delay(options.timeout || 20);
+        if (Object.isFunction(options.postsubmit)) {
+            options.postsubmit(this);
+        }
+    });
+}});
diff --git a/public/js/closebtn.js b/public/js/closebtn.js
new file mode 100644 (file)
index 0000000..84be90a
--- /dev/null
@@ -0,0 +1,27 @@
+/* Copyright (c) 2010 Arnaud Renevier, Inc, published under the modified BSD
+ * license. */
+
+var CloseBtn = Class.create({
+    initialize: function(elt, options) {
+        var btn, imgsrc, style;
+
+        elt = $(elt);
+        if (!elt) {
+            return;
+        }
+
+        style = Object.extend({
+            float: "right",
+            margin: "2px",
+            fontWeight: "bold",
+            padding: "0px"
+        }, typeof options === "object" ? options.style: {});
+
+        imgsrc = (options && options.closeBtnSrc) || "icons/close.png";
+        btn = new Element("input", { type: "image", src: imgsrc, alt: "X"}).setStyle(style);
+        elt.insert({top: btn});
+        btn.observe("click", function(evt) {
+            elt.hide();
+        });
+    }
+});
diff --git a/public/js/contact.js b/public/js/contact.js
new file mode 100644 (file)
index 0000000..2f47875
--- /dev/null
@@ -0,0 +1,39 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+document.observe("dom:loaded", function() {
+    var form = $("contactform");
+    form.focus();
+
+    form.observe('submit', function(evt) {
+        var control, errorElements;
+
+        $$('.error').invoke('remove');
+
+        errorElements = $$('input:not([type="submit"]),textarea').findAll(
+            function(elt) {
+                return (!elt.check(function() {
+                    return !this.value.strip().empty();
+                }, SyjStrings.notEmptyField));
+            });
+
+        if (!errorElements.length) {
+            control = $("contact_email");
+            if (!control.check(function() {
+                return this.value.match(/^[A-Z0-9._\-]+@[A-Z0-9][A-Z0-9.\-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}$/i);
+              }, SyjStrings.invalidMail)) {
+                errorElements.push($("contact_email"));
+            }
+        }
+
+        /*
+         * if there are errors, cancel submission
+         */
+        if (errorElements.length) {
+            errorElements[0].focus();
+            errorElements[0].select();
+            evt.stop();
+        }
+    });
+
+});
diff --git a/public/js/deck.js b/public/js/deck.js
new file mode 100644 (file)
index 0000000..73bc3d2
--- /dev/null
@@ -0,0 +1,35 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+var Deck = Class.create();
+Deck.prototype = {
+    initialize: function(elt, options) {
+        this.element = $(elt);
+        this.index = null;
+        this.setIndex(parseInt(this.element.readAttribute("selectedindex") || 0, 10));
+    },
+    setIndex: function(idx) {
+        if (idx === this.index) {
+            return;
+        }
+
+        var childs = this.element.childElements();
+        if (childs.length === 0) {
+            this.index = -1;
+            return;
+        }
+        idx = Math.max(0, idx);
+        idx = Math.min(childs.length - 1, idx);
+
+        childs.each(function(item, i) {
+            if (idx === i) {
+                item.show();
+            } else {
+                item.hide();
+            }
+        });
+        this.index = idx;
+    },
+    getIndex: function() {
+        return this.index;
+    }
+};
diff --git a/public/js/forms.js b/public/js/forms.js
new file mode 100644 (file)
index 0000000..b96fe20
--- /dev/null
@@ -0,0 +1,33 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+Element.addMethods('form', {
+    focus: function(form) {
+        var tofocus, error;
+
+        tofocus = null;
+        error = form.down('.error');
+        if (error) {
+            tofocus = error.previous('input,textarea');
+        } else {
+            tofocus = form.down('input:not([readonly],[disabled]),textarea:not([readonly][disabled])');
+        }
+        if (tofocus) {
+            tofocus.focus();
+            tofocus.select();
+        }
+    }
+});
+
+Element.addMethods(['input', 'textarea'], {
+    check: function(control, callback, errorMessage) {
+        if (callback.call(control)) {
+            return true;
+        }
+        control.focus();
+        control.select();
+        control.insert({
+            after: new Element("div", {className: 'error'}).update(errorMessage)
+        });
+        return false;
+    }
+});
diff --git a/public/js/img b/public/js/img
new file mode 120000 (symlink)
index 0000000..0f03e30
--- /dev/null
@@ -0,0 +1 @@
+../openlayers/openlayers/img/
\ No newline at end of file
diff --git a/public/js/lib b/public/js/lib
new file mode 120000 (symlink)
index 0000000..c1cf3b1
--- /dev/null
@@ -0,0 +1 @@
+../openlayers/openlayers/lib/
\ No newline at end of file
diff --git a/public/js/login.js b/public/js/login.js
new file mode 100644 (file)
index 0000000..44d8e08
--- /dev/null
@@ -0,0 +1,16 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+document.observe("dom:loaded", function() {
+    var form = $("loginform");
+    form.focus();
+
+    form.observe("submit", function(evt) {
+        $$('.error').invoke('remove');
+
+        if (!$("login_user").check(function() { return !this.value.strip().empty(); }, SyjStrings.userEmptyWarn)) {
+            evt.stop();
+            return;
+        }
+    });
+});
diff --git a/public/js/message.js b/public/js/message.js
new file mode 100644 (file)
index 0000000..795ae2b
--- /dev/null
@@ -0,0 +1,44 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+Element.addMethods('div', {
+    setMessage: function(div, message, status) {
+        div.clearMessages();
+        if (status) {
+            div.setMessageStatus(status);
+        }
+        if (message) {
+            div.addMessage(message);
+        }
+        return div;
+    },
+
+    clearMessages: function(div) {
+        var node = div.firstChild;
+        while (node) {
+            var nextNode = node.nextSibling;
+            if (node.nodeType == 3 || node.tagName.toLowerCase() == 'br') {
+                div.removeChild(node);
+            }
+                node = nextNode;
+        }
+
+        return div;
+    },
+
+    addMessage: function(div, message) {
+        var node = (div.ownerDocument || document).createTextNode(message);
+        if (!div.empty()) {
+            div.insert(new Element('br'));
+        }
+        div.appendChild(node);
+        return div.show();
+    },
+
+    setMessageStatus: function(div, status) {
+        return div.removeClassName('error').
+                removeClassName('warn').
+                removeClassName('info').
+                removeClassName('success').
+                addClassName(status);
+    }
+});
diff --git a/public/js/newpwd.js b/public/js/newpwd.js
new file mode 100644 (file)
index 0000000..5dc898f
--- /dev/null
@@ -0,0 +1,33 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+function insertErrorBefore(elt, messageError) {
+    var message = new Element("div", {className: 'error'}).update(messageError);
+    elt.insert({before: message});
+}
+
+document.observe("dom:loaded", function() {
+    var errors, tofocus;
+
+    errors = $$('.error');
+    tofocus = null;
+    if (errors.length) {
+        tofocus = $('newpwd_email');
+    } else {
+        tofocus = $$('form input:not([readonly],[disabled])')[0];
+    }
+    if (tofocus) {
+        tofocus.focus();
+        tofocus.select();
+    }
+
+    $("newpwdform").observe('submit', function(evt) {
+        $$('.error').invoke('remove');
+        if ($('newpwd_email').value.strip().empty()) {
+            insertErrorBefore($('newpwdform').select('table')[0], SyjStrings.notEmptyField);
+            $('newpwd_email').focus();
+            $('newpwd_email').select();
+            evt.stop();
+        }
+    });
+
+});
diff --git a/public/js/prototype.js b/public/js/prototype.js
new file mode 120000 (symlink)
index 0000000..b3ab4cf
--- /dev/null
@@ -0,0 +1 @@
+../prototype/dist/prototype.js
\ No newline at end of file
diff --git a/public/js/simplebox.js b/public/js/simplebox.js
new file mode 120000 (symlink)
index 0000000..52977e3
--- /dev/null
@@ -0,0 +1 @@
+../simplebox/js/simplebox.js
\ No newline at end of file
diff --git a/public/js/syj.js b/public/js/syj.js
new file mode 100644 (file)
index 0000000..670b64c
--- /dev/null
@@ -0,0 +1,811 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+Element.addMethods('input', {
+    observe : Element.Methods.observe.wrap(function(proceed, element, eventName, handler) {
+        if (eventName === "contentchange") {
+            proceed(element, 'keyup', function(evt) {
+                if (evt.keyCode == 13) {
+                    return;
+                }
+                handler.apply(null, arguments);
+            });
+            return proceed(element, 'change', handler);
+        }
+        return proceed(element, eventName, handler);
+    })
+});
+
+// avoid openlayers alerts
+OpenLayers.Console.userError = function(error) {
+    SYJView.messenger.setMessage(error, "error");
+};
+
+var SyjSaveUI = {
+    status: "unknown",
+
+    init: function() {
+        $("geom_title").observe('contentchange', this.enableSubmit.bindAsEventListener(this));
+        return this;
+    },
+
+    hide: function() {
+        $("geom_submit").blur();
+        $("geom_title").blur();
+        $("geomform").hide();
+        return this;
+    },
+
+    show: function() {
+        $("geomform").show();
+        return this;
+    },
+
+    enable: function() {
+        if (this.status === "enabled") {
+            return this;
+        }
+        this.enableSubmit();
+        $("geom_title").disabled = false;
+        $("geom_title").focus();
+        $("geom_title").select();
+        $("geomform").removeClassName("disabled");
+        this.status = "enabled";
+        return this;
+    },
+
+    disable: function() {
+        if (this.status === "disabled") {
+            return this;
+        }
+        this.disableSubmit();
+        $("geom_title").blur();
+        $("geom_title").disabled = true;
+        $("geomform").addClassName("disabled");
+        this.status = "disabled";
+        return this;
+    },
+
+    enableSubmit: function() {
+        $("geom_submit").disabled = false;
+        this.status = "partial";
+        return this;
+    },
+
+    disableSubmit: function() {
+        $("geom_submit").blur();
+        $("geom_submit").disabled = true;
+        this.status = "partial";
+        return this;
+    }
+};
+
+var SyjEditUI = {
+    init: function() {
+        return this;
+    },
+
+    hide: function() {
+        $("edit-btn").blur();
+        $("edit-btn").hide();
+        return this;
+    },
+
+    show: function() {
+        $("edit-btn").show();
+        return this;
+    }
+};
+
+OpenLayers.Handler.SyjModifiablePath = OpenLayers.Class(OpenLayers.Handler.ModifiablePath, {
+    mouseup: function(evt) {
+        // do not add a point when navigating
+        var mapControls = this.control.map.controls, idx, ctrl;
+
+        for (idx = mapControls.length; idx-->0; ) {
+            ctrl = mapControls[idx];
+            if (this.isCtrlNavigationActive(ctrl, evt)) {
+                return true;
+            }
+        }
+        return OpenLayers.Handler.ModifiablePath.prototype.mouseup.apply(this, arguments);
+    },
+
+    addPoints: function(pixel) {
+        // redraw before last point. As we have a special style for last point, we
+        // need to redraw before last point after adding a new point (otherwise, it
+        // keeps special style forever)
+        var oldpoint = this.point;
+        OpenLayers.Handler.ModifiablePath.prototype.addPoints.apply(this, arguments);
+        this.layer.drawFeature(oldpoint);
+    },
+
+    isCtrlNavigationActive: function(ctrl, evt) {
+        var tolerance = 4, xDiff, yDiff;
+
+        if (!(ctrl instanceof OpenLayers.Control.Navigation)) {
+            return false;
+        }
+
+        if (ctrl.zoomBox &&
+            ctrl.zoomBox.active &&
+            ctrl.zoomBox.handler &&
+            ctrl.zoomBox.handler.active &&
+            ctrl.zoomBox.handler.dragHandler &&
+            ctrl.zoomBox.handler.dragHandler.start) {
+            return true;
+        }
+
+        if (!ctrl.dragPan ||
+            !ctrl.dragPan.active ||
+            !ctrl.dragPan.handler ||
+            !ctrl.dragPan.handler.started ||
+            !ctrl.dragPan.handler.start) {
+            return false;
+        }
+
+        // if mouse moved 4 or less pixels, consider it has not moved.
+        tolerance = 4;
+
+        xDiff = evt.xy.x - ctrl.dragPan.handler.start.x;
+        yDiff = evt.xy.y - ctrl.dragPan.handler.start.y;
+
+        if (Math.sqrt(Math.pow(xDiff,2) + Math.pow(yDiff,2)) <= tolerance) {
+            return false;
+        }
+        return true;
+    },
+
+    finalize: function(cancel) {
+        // do nothing. We don't want to finalize path
+    }
+});
+
+var styleMap = {
+    edit: new OpenLayers.StyleMap({
+        "default": new OpenLayers.Style({
+            pointRadius: "${radius}", // sized according to type attribute
+            fillColor: "#ffcc66",
+            strokeColor: "#ff9933",
+            strokeWidth: 2,
+            strokeOpacity: "${opacity}",
+            fillOpacity: "${opacity}"
+        },
+        {
+            context: {
+                radius: function(feature) {
+                    var features;
+
+                    if (!(feature.geometry instanceof OpenLayers.Geometry.Point)) {
+                        return 0;
+                    }
+                    if (feature.type === "middle") {
+                        return 4;
+                    }
+                    features = feature.layer.features;
+                    if (OpenLayers.Util.indexOf(features, feature) === 0) {
+                        return 5;
+                    } else if (OpenLayers.Util.indexOf(features, feature) === features.length - 1) {
+                        return 5;
+                    }
+                    return 3;
+                },
+                opacity: function (feature) {
+                    if (feature.type === "middle") {
+                        return 0.5;
+                    } else {
+                        return 1;
+                    }
+                }
+            }
+        }),
+
+        "select": new OpenLayers.Style({
+            externalGraphic: "icons/delete.png",
+            graphicHeight: 16
+        }),
+
+        "select_for_canvas": new OpenLayers.Style({
+            strokeColor: "blue",
+            fillColor: "lightblue"
+        })
+
+    }),
+
+    view: new OpenLayers.StyleMap({
+        "default": new OpenLayers.Style({
+            strokeColor: "blue",
+            strokeWidth: 5,
+            strokeOpacity: 0.7
+        })
+    })
+};
+
+var WGS84 = new OpenLayers.Projection("EPSG:4326");
+var Mercator = new OpenLayers.Projection("EPSG:900913");
+
+var SYJView = {
+    viewLayer: null,
+    editControl: null,
+    map: null,
+    wkt: new OpenLayers.Format.WKT({ internalProjection: Mercator, externalProjection: WGS84 }),
+    needsFormResubmit: false,
+
+    init: function() {
+        var externalGraphic, baseURL, baseLayer, layerOptions, extent = null, hidemessenger;
+
+        // is svg context, opera does not resolve links with base element is svg context
+        externalGraphic = styleMap.edit.styles.select.defaultStyle.externalGraphic;
+        baseURL = document.getElementsByTagName("base")[0].href;
+        styleMap.edit.styles.select.defaultStyle.externalGraphic = baseURL + externalGraphic;
+
+        this.map = new OpenLayers.Map('map', {
+            controls: [
+                new OpenLayers.Control.Navigation(),
+                new OpenLayers.Control.PanZoom(),
+                new OpenLayers.Control.Attribution()
+            ],
+            theme: null
+        });
+
+        baseLayer = new OpenLayers.Layer.OSM("OSM", null, { wrapDateLine: true , attribution: SyjStrings.osmAttribution });
+
+        layerOptions = {format:     OpenLayers.Format.WKT,
+                        projection: WGS84,
+                        styleMap:   styleMap.view};
+        if (gLoggedInfo.ownername) {
+            layerOptions.attribution = SyjStrings.routeBy + ' ' + '<strong>' + gLoggedInfo.ownername + '</strong>';
+        }
+
+        this.viewLayer = new OpenLayers.Layer.Vector("View Layer", layerOptions);
+        this.map.addLayers([baseLayer, this.viewLayer]);
+
+        $("edit-btn").observe('click', (function() {
+            this.messenger.hide();
+            this.editMode();
+        }).bind(this));
+        SyjEditUI.init().hide();
+
+        $("geomform").ajaxize({
+                presubmit: this.prepareForm.bind(this),
+                onSuccess: this.saveSuccess.bind(this),
+                onFailure: this.saveFailure.bind(this)
+                });
+        SyjSaveUI.init().hide();
+
+        this.messenger = $('message');
+        hidemessenger = this.messenger.empty();
+        new CloseBtn(this.messenger, {
+            style: {
+                margin: "-1em"
+            }
+        });
+        if (hidemessenger) {
+            this.messenger.hide();
+        }
+
+        extent = null;
+        if ($("geom_data").value) {
+            this.viewLayer.addFeatures([this.wkt.read($("geom_data").value)]);
+            extent = this.viewLayer.getDataExtent();
+            // XXX: ie has not guessed height of map main div yet during map
+            // initialisation. Now, it will read it correctly.
+            this.map.updateSize();
+            SyjEditUI.show();
+        } else {
+            extent = new OpenLayers.Bounds(gMaxExtent.minlon, gMaxExtent.minlat, gMaxExtent.maxlon, gMaxExtent.maxlat)
+                                         .transform(WGS84, Mercator);
+            this.editMode();
+        }
+        this.map.zoomToExtent(extent);
+        document.observe('simplebox:shown', this.observer.bindAsEventListener(this));
+    },
+
+    observer: function(evt) {
+        if (evt.eventName === "simplebox:shown" && evt.memo.element !== $("termsofusearea")) {
+            this.messenger.hide();
+        }
+    },
+
+    prepareForm: function(form) {
+        var line, realPoints, idx, handler;
+
+        line = new OpenLayers.Geometry.LineString();
+        realPoints = this.editControl.handler.realPoints;
+        for (idx = 0; idx < realPoints.length; idx++) {
+            line.addComponent(realPoints[idx].geometry.clone());
+        }
+        this.viewLayer.addFeatures(new OpenLayers.Feature.Vector(line));
+        handler = this.editControl.handler;
+        OpenLayers.Handler.ModifiablePath.prototype.finalize.apply(handler, arguments);
+        // we need to recreate them on next createFeature; otherwise
+        // they'll reference destroyed features
+        delete(handler.handlers.drag);
+        delete(handler.handlers.feature);
+        this.editControl.deactivate();
+
+        $("geom_data").value = this.wkt.write(new OpenLayers.Feature.Vector(line));
+        this.needsFormResubmit = false;
+        SyjSaveUI.disable.bind(SyjSaveUI).defer();
+        this.messenger.hide();
+    },
+
+    editMode: function() {
+        var components, point0, point, pixels, pixel, idx;
+
+        this.initEditControl();
+
+        this.editControl.activate();
+        if (this.viewLayer.features.length) {
+            components = this.viewLayer.features[0].geometry.components;
+            point0 = components[0];
+            if (point0) {
+                pixel = this.map.getPixelFromLonLat(new OpenLayers.LonLat(point0.x, point0.y));
+                this.editControl.handler.createFeature(pixel);
+                this.editControl.handler.lastUp = pixel;
+                pixels = [];
+                for (idx = 1; idx < components.length; idx++) {
+                    point = components[idx];
+                    pixels.push(this.map.getPixelFromLonLat(new OpenLayers.LonLat(point.x, point.y)));
+                }
+                this.editControl.handler.addPoints(pixels);
+            }
+        }
+
+        this.viewLayer.destroyFeatures();
+
+        SyjEditUI.hide();
+        if (this.editControl.handler.realPoints && this.editControl.handler.realPoints.length >= 2) {
+            SyjSaveUI.show().disableSubmit();
+        } else {
+            SyjSaveUI.show().disable();
+        }
+    },
+
+    initEditControl: function() {
+        var styles;
+
+        if (this.editControl) {
+            return;
+        }
+
+        this.editControl = new OpenLayers.Control.DrawFeature(new OpenLayers.Layer.Vector(), OpenLayers.Handler.SyjModifiablePath, {
+            callbacks: {
+                modify: function(f, line) {
+                    if (this.handler.realPoints.length < 2) {
+                        SyjSaveUI.show().disable();
+                    } else {
+                        SyjSaveUI.show().enable();
+                    }
+                }
+            },
+
+            handlerOptions: {
+                layerOptions: {
+                    styleMap: styleMap.edit
+                }
+            }
+        });
+        this.map.addControl(this.editControl);
+        if (this.editControl.layer.renderer instanceof OpenLayers.Renderer.Canvas) {
+            // using externalGraphic with canvas renderer is definitively too buggy
+            styles = this.editControl.handler.layerOptions.styleMap.styles;
+            styles.select = styles.select_for_canvas;
+        }
+    },
+
+    saveSuccess: function(transport) {
+      if (!$("geom_id").value) {
+          location = "idx/" + transport.responseText;
+          return;
+      }
+      this.messenger.setMessage(SyjStrings.saveSuccess, "success");
+
+      SyjSaveUI.hide();
+      SyjEditUI.show();
+      document.title = $('geom_title').value;
+    },
+
+    saveFailure: function(transport) {
+        var httpCode = 0, message = "";
+
+        if (transport) {
+            httpCode = transport.getStatus();
+        }
+        message = "";
+        switch (httpCode) {
+            case 0:
+                message = SyjStrings.notReachedError;
+            break;
+            case 400:
+            case 404:
+            case 410:
+                message = SyjStrings.requestError; // default message
+                if (transport.responseJSON) {
+                    switch (transport.responseJSON.message) {
+                        case "unreferenced":
+                            message = SyjStrings.unreferencedError;
+                        break;
+                        case "uniquepath":
+                            message = SyjStrings.uniquePathError;
+                        break;
+                        default:
+                        break;
+                    }
+                }
+            break;
+            case 403:
+                message = "";
+                this.needsFormResubmit = true;
+                if (loginMgr.hasAlreadyConnected()) {
+                    SYJLogin.messenger.setMessage(SyjStrings.cookiesNeeded, "warn");
+                } else {
+                    SYJLogin.messenger.setMessage(SyjStrings.loginNeeded, "warn");
+                }
+                SYJLogin.modalbox.show();
+            break;
+            case 500:
+                message = SyjStrings.serverError;
+                this.needsFormResubmit = true;
+            break;
+            default:
+                message = SyjStrings.unknownError;
+            break;
+        }
+
+        this.editMode();
+        // is some cases, we let the user resubmit, in some other cases, he
+        // needs to modify the path before submitting again
+        if (this.needsFormResubmit) {
+            SyjSaveUI.enable();
+        }
+
+        this.messenger.setMessage(message, "error");
+    }
+};
+
+var SYJModalClass = Class.create({
+    type: "",
+
+    init: function() {
+        this.area = $(this.type + '_area');
+        this.messenger = $(this.type + "_message");
+        this.modalbox = new SimpleBox(this.area, {
+            closeMethods: ["onescapekey", "onouterclick", "onbutton"]
+        });
+
+        $(this.type + "_control_anchor").observe("click", function(evt) {
+            this.modalbox.show();
+            evt.stop();
+        }.bindAsEventListener(this));
+
+        document.observe('simplebox:shown', this.observer.bindAsEventListener(this));
+        document.observe('simplebox:hidden', this.observer.bindAsEventListener(this));
+
+        $(this.type + "form").ajaxize({
+            presubmit: this.presubmit.bind(this),
+            onSuccess: this.success.bind(this),
+            onFailure: this.failure.bind(this)
+        });
+    },
+
+    checkNotEmpty: function(input, message) {
+        if ($(input).value.strip().empty()) {
+            this.messenger.setMessage(message, "warn");
+            $(input).focus();
+            return false;
+        }
+        return true;
+    },
+
+    observer: function(evt) {
+        var simplebox, input;
+
+        if (evt.eventName === "simplebox:shown" && evt.memo.element !== $("termsofusearea")) {
+            simplebox = evt.memo;
+            if (simplebox === this.modalbox) {
+                input = this.area.select('input[type="text"]')[0];
+                (function () {
+                    input.focus();
+                    input.select();
+                }).defer();
+            } else {
+                this.modalbox.hide();
+            }
+
+        } else if (evt.eventName === "simplebox:hidden" && evt.memo.element !== $("termsofusearea")) {
+            simplebox = evt.memo;
+            if (simplebox === this.modalbox) {
+                this.reset();
+            }
+        }
+    },
+
+    failure: function(transport) {
+        var httpCode = 0, message = SyjStrings.unknownError, input; // default message error
+
+        if (transport) {
+            httpCode = transport.getStatus();
+        }
+
+        switch (httpCode) {
+            case 0:
+                message = SyjStrings.notReachedError;
+            break;
+            case 400:
+            case 404:
+            case 410:
+                message = SyjStrings.requestError;
+            break;
+            case 500:
+                message = SyjStrings.serverError;
+            break;
+        }
+
+        this.messenger.setMessage(message, "error");
+        input = this.area.select('input[type="text"]')[0];
+        input.focus();
+        input.select();
+    },
+
+    reset: function() {
+        this.messenger.hide();
+        this.area.select('.message').invoke('setMessageStatus', null);
+    }
+});
+
+var SYJUserClass = Class.create(SYJModalClass, {
+    type: "user",
+    toubox: null,
+
+    init: function($super) {
+        $super();
+        $("termsofusearea").hide();
+
+        $("user_termsofuse_anchor").observe("click", function(evt) {
+            if (!this.toubox) {
+                $("termsofusearea").show();
+                $("termsofuseiframe").setAttribute("src", evt.target.href);
+                this.toubox = new SimpleBox($("termsofusearea"), {
+                    closeMethods: ["onescapekey", "onouterclick", "onbutton"]
+                });
+            }
+            this.toubox.show();
+            evt.stop();
+        }.bindAsEventListener(this));
+
+        $$("#login_area_create > a").invoke('observe', 'click',
+            function(evt) {
+                this.modalbox.show();
+                evt.stop();
+            }.bindAsEventListener(this));
+
+        $("user_password").observe('contentchange', function(evt) {
+            if (evt.target.value.length < 6) {
+                $("user_password-desc").setMessageStatus("warn");
+            } else {
+                $("user_password-desc").setMessageStatus("success");
+            }
+        }.bindAsEventListener(this));
+    },
+
+    presubmit: function() {
+        if (!(this.checkNotEmpty("user_pseudo", SyjStrings.userEmptyWarn))) {
+            return false;
+        }
+
+        if (!($("user_pseudo").value.match(/[a-zA-Z0-9_.]+$/))) {
+            this.messenger.setMessage(SyjStrings.invalidPseudo, "warn");
+            $("user_pseudo").focus();
+            $("user_pseudo").select();
+            return false;
+        }
+
+        if (!(this.checkNotEmpty("user_password", SyjStrings.passwordEmptyWarn))) {
+            return false;
+        }
+
+        if ($("user_password").value.length < 6) {
+            $("user_password-desc").setMessageStatus("warn");
+            $("user_password").focus();
+            $("user_password").select();
+            return false;
+        }
+
+        if ($("user_password").value !== $("user_password_confirm").value) {
+            this.messenger.setMessage(SyjStrings.passwordNoMatchWarn, "warn");
+            $("user_password").focus();
+            $("user_password").select();
+            return false;
+        }
+
+        if (!(this.checkNotEmpty("user_email", SyjStrings.emailEmptyWarn))) {
+            return false;
+        }
+
+        if (!$("user_accept").checked) {
+            this.messenger.setMessage(SyjStrings.acceptTermsofuseWarn, "warn");
+            $("user_accept").focus();
+            return false;
+        }
+
+        this.reset();
+        return true;
+    },
+
+    success: function(transport) {
+        loginMgr.login();
+        SYJView.messenger.setMessage(SyjStrings.userSuccess, "success");
+        this.modalbox.hide();
+        if (SYJView.needsFormResubmit) {
+            SYJView.messenger.addMessage(SyjStrings.canResubmit);
+            $("geom_submit").focus();
+        }
+    },
+
+    failure: function($super, transport) {
+        var httpCode = 0, focusInput = null, message = "";
+
+        if (transport) {
+            httpCode = transport.getStatus();
+        }
+
+        focusInput = null;
+        message = "";
+
+        switch (httpCode) {
+            case 400:
+                if (transport.responseJSON) {
+                    switch (transport.responseJSON.message) {
+                        case "invalidemail":
+                            message = SyjStrings.emailInvalidWarn;
+                            focusInput = $("user_email");
+                        break;
+                        case "uniquepseudo":
+                            message = SyjStrings.uniqueUserError;
+                            focusInput = $("user_pseudo");
+                        break;
+                        case "uniqueemail":
+                            message = SyjStrings.uniqueEmailError;
+                            focusInput = $("user_email");
+                        break;
+                    }
+                }
+            break;
+        }
+
+        if (message) {
+            this.messenger.setMessage(message, "error");
+            if (focusInput) {
+                focusInput.focus();
+                focusInput.select();
+            }
+            return;
+        }
+
+        $super(transport);
+    }
+});
+var SYJUser = new SYJUserClass();
+
+var SYJLoginClass = Class.create(SYJModalClass, {
+    type: "login",
+
+    init: function($super) {
+        $super();
+    },
+
+    presubmit: function() {
+        if (!(this.checkNotEmpty("login_user", SyjStrings.userEmptyWarn))) {
+            return false;
+        }
+
+        this.reset();
+        return true;
+    },
+
+    success: function(transport) {
+        if (transport.responseText === "1") {
+            loginMgr.login(true);
+        } else {
+            loginMgr.login();
+        }
+        SYJView.messenger.setMessage(SyjStrings.loginSuccess, "success");
+        this.modalbox.hide();
+        if (SYJView.needsFormResubmit) {
+            SYJView.messenger.addMessage(SyjStrings.canResubmit);
+            $("geom_submit").focus();
+        }
+    },
+
+    failure: function($super, transport) {
+        var httpCode = 0, focusInput = null, message = "";
+
+        if (transport) {
+            httpCode = transport.getStatus();
+        }
+
+        focusInput = null;
+        message = "";
+
+        switch (httpCode) {
+            case 403:
+                message = SyjStrings.loginFailure;
+                focusInput = $("login_user");
+            break;
+        }
+
+        if (message) {
+            this.messenger.setMessage(message, "error");
+            if (focusInput) {
+                focusInput.focus();
+                focusInput.select();
+            }
+            return;
+        }
+
+        $super(transport);
+    }
+});
+var SYJLogin = new SYJLoginClass();
+
+var SYJNewpwdClass = Class.create(SYJModalClass, {
+    type: "newpwd",
+
+    presubmit: function() {
+        if (!(this.checkNotEmpty("newpwd_email", SyjStrings.emailEmptyWarn))) {
+            return false;
+        }
+        this.reset();
+        return true;
+    },
+    success: function(transport) {
+        SYJView.messenger.setMessage(SyjStrings.newpwdSuccess, "success");
+        this.modalbox.hide();
+    }
+
+});
+var SYJNewpwd = new SYJNewpwdClass();
+
+var loginMgr = Object.extend(gLoggedInfo, {
+    controlsdeck: null,
+
+    updateUI: function() {
+        if (!this.controlsdeck) {
+            this.controlsdeck = new Deck("login_controls");
+        }
+        if (this.logged) {
+            this.controlsdeck.setIndex(1);
+        } else {
+            this.controlsdeck.setIndex(0);
+        }
+
+        if (this.isowner) {
+            $("data_controls").show();
+        } else {
+            $("data_controls").hide();
+        }
+    },
+
+    login: function(aIsOwner) {
+        if (typeof aIsOwner === "boolean") {
+            this.isowner = aIsOwner;
+        }
+        this.logged = true;
+        this.connections++;
+        this.updateUI();
+    },
+
+    // needed in case of 403 errors: if user has already connected successfully
+    // before, it probably means he has cookies disabled
+    hasAlreadyConnected: function() {
+        return (this.connections >= 1);
+    }
+});
+
+document.observe("dom:loaded", function() {
+    SYJLogin.init();
+    SYJUser.init();
+    SYJView.init();
+    SYJNewpwd.init();
+    loginMgr.updateUI();
+});
diff --git a/public/js/termsofuse.js b/public/js/termsofuse.js
new file mode 100644 (file)
index 0000000..e67ee76
--- /dev/null
@@ -0,0 +1,8 @@
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+document.observe("dom:loaded", function() {
+    if (window.top !== window) {
+        $("other-language").hide();
+        $("footer").hide();
+    }
+});
diff --git a/public/js/theme b/public/js/theme
new file mode 120000 (symlink)
index 0000000..78edd8d
--- /dev/null
@@ -0,0 +1 @@
+../openlayers/openlayers/theme/
\ No newline at end of file
diff --git a/public/modifiablepath b/public/modifiablepath
new file mode 160000 (submodule)
index 0000000..0e7edb4
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 0e7edb46ec038c310e03ac72fc6ad454d3d16e5c
diff --git a/public/openlayers b/public/openlayers
new file mode 160000 (submodule)
index 0000000..f2a457c
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit f2a457cae0c516e35a7c4c3c32c3b4af040415da
diff --git a/public/prototype b/public/prototype
new file mode 160000 (submodule)
index 0000000..ec15b2c
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit ec15b2c0a916725dc56c1d536dc383eaf109b97c
diff --git a/public/simplebox b/public/simplebox
new file mode 160000 (submodule)
index 0000000..3adf48e
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 3adf48eb6d0fa8449407fe52c680f78ccdf39da1
diff --git a/scripts/crontab.syj b/scripts/crontab.syj
new file mode 100644 (file)
index 0000000..e8c0c11
--- /dev/null
@@ -0,0 +1,5 @@
+MAILTO=arno@renevier.net
+# every 5 minutes, call syj php cron
+*/5 * * * * /usr/bin/wget --header="Host: osm-syj.crans.org" http://localhost/cron -O /dev/null  -o /dev/null
+# every month, update geoip db
+0 0 3 * * /data/project/syj/scripts/updategeoip.sh
diff --git a/scripts/data.postgres.sql b/scripts/data.postgres.sql
new file mode 100644 (file)
index 0000000..0d47807
--- /dev/null
@@ -0,0 +1,23 @@
+BEGIN;
+
+INSERT INTO users (password, pseudo, email, creation_addr, lang) VALUES
+    ('0b9c2625dc21ef05f6ad4ddf47c5f203837aa32c', -- sha1 of "toto"
+    'arno', 'arno@renevier.net', '127.0.0.1', 'fr');
+
+INSERT INTO users (password, pseudo, email, creation_addr, lang) VALUES
+    ('0b9c2625dc21ef05f6ad4ddf47c5f203837aa32c', -- sha1 of "toto"
+    'user', 'user@renevier.net', '127.0.0.1', 'en');
+
+INSERT INTO paths (geom, owner, title) VALUES
+    (ST_GeographyFromText ('SRID=4326;LINESTRING(2.437892 48.638297, 2.431111 48.643628, 2.436218 48.648108, 2.415104 48.660355)'),
+    1, 'ris-orangis');
+
+INSERT INTO paths (geom, owner, title) VALUES
+    (ST_GeographyFromText ('SRID=4326;LINESTRING(2.466474 48.649242, 2.459993 48.651766, 2.478619 48.656160, 2.462826 48.672883, 2.468061 48.690564)'),
+    1, 'Forêt de Sénart');
+
+INSERT INTO paths (geom, owner, title, urlcomp) VALUES
+    (ST_GeographyFromText ('SRID=4326; LINESTRING(2.452204 48.634880, 2.453599 48.635745, 2.449908 48.637744, 2.448149 48.638595, 2.442999 48.642593, 2.440360 48.645500, 2.438471 48.646847, 2.436712 48.647938, 2.433729 48.650036, 2.423387 48.655877, 2.415297 48.660384, 2.417142 48.661659, 2.417700 48.662297, 2.417700 48.662921, 2.416434 48.663941, 2.415361 48.665018, 2.411671 48.671211, 2.410340 48.672585, 2.408237 48.674272, 2.407122 48.675717, 2.405341 48.677403, 2.403431 48.678933, 2.402251 48.680619, 2.401006 48.680605, 2.399504 48.680662, 2.397702 48.684189, 2.397294 48.684203, 2.395213 48.683849, 2.391522 48.684359, 2.392466 48.688057, 2.389891 48.688467, 2.386994 48.689402, 2.386029 48.689742, 2.386351 48.690280, 2.387445 48.690040, 2.389269 48.692589, 2.396221 48.699034, 2.399182 48.702206, 2.400384 48.703934, 2.401328 48.705718, 2.403173 48.710589, 2.404118 48.712288, 2.406478 48.714440, 2.408667 48.715459, 2.412915 48.718234, 2.417250 48.720527, 2.423215 48.722962, 2.428107 48.724123, 2.433043 48.724463, 2.440381 48.726246, 2.442688 48.727386, 2.441475 48.727754, 2.440048 48.727563, 2.441733 48.728518, 2.443042 48.728256, 2.445359 48.727860, 2.445037 48.727265, 2.444565 48.727449, 2.445724 48.729558, 2.445853 48.732163, 2.445917 48.735630, 2.444522 48.738460, 2.444673 48.738574, 2.443085 48.740229, 2.440810 48.741842, 2.437935 48.744984, 2.435575 48.748493, 2.428579 48.754774, 2.421241 48.760546, 2.414289 48.766628, 2.413559 48.769117, 2.413731 48.771521, 2.415104 48.773473, 2.415919 48.775481, 2.415962 48.776640, 2.422957 48.787160, 2.424116 48.789619, 2.423773 48.792418, 2.421498 48.796857, 2.420340 48.798270, 2.423601 48.798949, 2.428966 48.800164, 2.427936 48.800673, 2.427163 48.801521, 2.427721 48.802426, 2.428579 48.802765, 2.425833 48.806977, 2.422442 48.812064, 2.420254 48.815342, 2.419739 48.817037, 2.419953 48.824186, 2.422957 48.824130, 2.423429 48.824610, 2.426906 48.828622, 2.429094 48.831984, 2.430382 48.834696, 2.431326 48.835176, 2.432270 48.839921, 2.433043 48.841136, 2.434416 48.844921, 2.415361 48.846700, 2.414589 48.846982, 2.413816 48.846898, 2.396865 48.848423, 2.396007 48.848959, 2.395191 48.848592, 2.384119 48.850258, 2.380342 48.850286, 2.374763 48.851642, 2.369356 48.853223, 2.365150 48.853873, 2.360902 48.855172, 2.347941 48.858588, 2.340817 48.860960, 2.335238 48.862682, 2.335539 48.863247, 2.332363 48.870587, 2.323651 48.869203, 2.321806 48.866747, 2.321334 48.866296, 2.320261 48.864771, 2.313738 48.864912, 2.313437 48.862767, 2.310390 48.862597, 2.309961 48.857148, 2.303181 48.852800)'),
+        2, 'Convergence 2010 départ d''Évry', 'convergence_2010');
+
+COMMIT;
diff --git a/scripts/db_auth.sh b/scripts/db_auth.sh
new file mode 100755 (executable)
index 0000000..e10755d
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+export PGUSER=syj
+export PGDATABASE=syj
diff --git a/scripts/reset.postgres.sh b/scripts/reset.postgres.sh
new file mode 100755 (executable)
index 0000000..1b20907
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+set -e
+
+. ${0%/*}/db_auth.sh
+
+
+##
+# Script for creating and loading database
+##
+
+usage() {
+    echo Usage: ${0##*/} [options]
+    echo
+    echo Options:
+    echo "  " -h display this help message
+    echo "  " -w load database with sample data
+    echo "  " -g resets geographic informations \(geoip and geonames\)
+    echo "  " -s be more silent \(show only warnings\)
+}
+
+# getopt
+WITHDATA=""
+SILENT=""
+GEODATA=""
+args=`getopt -o hwgs -l help,withdata,geo,silent -- "$@"`
+eval set -- "$args"
+while true; do
+    case "$1" in
+        -h|--help) usage; exit 0 ;;
+        -w|--withdata) WITHDATA="1"; shift ;;
+        -g|--geo) GEODATA="1"; shift ;;
+        -s|--silent) SILENT="1"; shift ;;
+        --) shift; break ;;
+        *) echo "Invalid option: $1"; exit 1 ;;
+    esac
+done
+
+if [ ${#SILENT} -ne 0 ]; then
+    # we won't see all the index creation notices when creating tables
+    export PGOPTIONS='--client_min_messages=warning'
+fi
+
+# load schema
+psql --set "ON_ERROR_STOP=1" -f ${0%/*}/schema.postgres.sql
+
+# optionally load sample data
+if [ ${#WITHDATA} -ne 0 ]; then
+    psql --set "ON_ERROR_STOP=1" -f ${0%/*}/data.postgres.sql
+fi
+
+if [ ${#GEODATA} -ne 0 ]; then
+    sh ${0%/*}/updategeoip.sh "${@}"
+    sh ${0%/*}/updategeonames.sh "${@}"
+fi
diff --git a/scripts/schema.postgres.sql b/scripts/schema.postgres.sql
new file mode 100644 (file)
index 0000000..5877f8c
--- /dev/null
@@ -0,0 +1,127 @@
+BEGIN;
+
+---
+--- users table
+---
+DROP TABLE IF EXISTS users CASCADE;
+CREATE TABLE users (
+    id SERIAL PRIMARY KEY,
+    password CHAR(40) NOT NULL,
+    pseudo VARCHAR(20) UNIQUE NOT NULL CHECK (pseudo ~ '^[a-zA-Z0-9_.]+$'),
+    email VARCHAR(320) UNIQUE NOT NULL,
+    lang VARCHAR(3),
+    creation_time TIMESTAMP NOT NULL DEFAULT NOW(),
+    creation_addr INET NOT NULL
+);
+
+---
+--- pending_actions table
+---
+CREATE OR REPLACE FUNCTION randomchars(reslength INTEGER, letters TEXT = 'abcdefghijklmnopqrstuvwxyz0123456789')
+    RETURNS TEXT AS
+$$
+DECLARE
+    choices CHAR ARRAY;
+    choices_length INTEGER;
+    result TEXT := '';
+BEGIN
+    choices := regexp_split_to_array(letters, '');
+    choices_length = array_length(choices, 1);
+
+    WHILE length(result) < reslength LOOP
+        result := result || choices[ceil(random() * choices_length)];
+    END LOOP;
+
+    return result;
+END;
+$$ LANGUAGE plpgsql;
+
+DROP TYPE IF EXISTS ACTION CASCADE;
+CREATE TYPE ACTION AS ENUM ('validate_creation', 'reset_password');
+
+DROP TABLE IF EXISTS pending_actions CASCADE;
+CREATE TABLE pending_actions (
+    id SERIAL PRIMARY KEY,
+    userid INTEGER NOT NULL REFERENCES users ON DELETE CASCADE,
+    action ACTION NOT NULL,
+    hash CHAR(40) NOT NULL UNIQUE CHECK (hash ~ '^[a-z0-9]+$') DEFAULT randomchars(40),
+    notifications_number INTEGER DEFAULT 0,
+    creation_time TIMESTAMP NOT NULL DEFAULT NOW(),
+    UNIQUE (userid, action)
+);
+
+CREATE OR REPLACE FUNCTION tg_user_ai() RETURNS TRIGGER AS $$
+BEGIN
+    INSERT INTO pending_actions (userid, action, creation_time) VALUES
+                    (NEW.id, 'validate_creation', NEW.creation_time);
+    RETURN NEW;
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE OR REPLACE FUNCTION tg_pending_bi() RETURNS TRIGGER AS $$
+BEGIN
+    IF NEW.action = 'reset_password' THEN
+        DELETE FROM pending_actions WHERE action = 'reset_password' AND userid=NEW.userid;
+    END IF;
+    RETURN NEW;
+END;
+$$ LANGUAGE PLPGSQL;
+
+DROP TRIGGER IF EXISTS tg_user_ai ON users;
+CREATE TRIGGER tg_user_ai AFTER INSERT ON users FOR EACH ROW EXECUTE PROCEDURE tg_user_ai();
+
+DROP TRIGGER IF EXISTS tg_pending_bi ON pending_actions;
+CREATE TRIGGER tg_pending_bi BEFORE INSERT ON pending_actions FOR EACH ROW EXECUTE PROCEDURE tg_pending_bi();
+
+---
+--- paths table
+---
+DROP SEQUENCE IF EXISTS paths_id_seq CASCADE;
+CREATE SEQUENCE paths_id_seq;
+
+CREATE OR REPLACE FUNCTION seq_attained_value(seqname TEXT, idx INTEGER)
+    RETURNS BOOLEAN AS
+$$
+DECLARE
+    rec RECORD;
+BEGIN
+    EXECUTE 'SELECT * FROM ' || quote_ident (seqname) INTO rec;
+    IF rec.is_called = FALSE
+            OR idx < rec.min_value OR idx > rec.max_value
+            OR (idx > rec.last_value AND rec.increment_by > 0)
+            OR (idx < rec.last_value AND rec.increment_by < 0)
+            THEN
+        RETURN FALSE;
+    END IF;
+    return (((idx - rec.start_value) * abs(rec.increment_by) / rec.increment_by) % rec.increment_by) = 0;
+END;
+$$ LANGUAGE plpgsql;
+
+DROP TABLE IF EXISTS paths CASCADE;
+CREATE TABLE paths (
+    id INTEGER PRIMARY KEY DEFAULT nextval('paths_id_seq'),
+    geom GEOGRAPHY (LINESTRING, 4326) NOT NULL,
+    owner INTEGER NOT NULL REFERENCES users ON DELETE CASCADE,
+    title VARCHAR(40),
+    urlcomp VARCHAR(20) UNIQUE CHECK (urlcomp ~ '^[a-z][a-zA-Z0-9_]*$') -- ~: matches regular expression; case sensitive
+);
+
+-- unique (geom, owner) constraint will not work: first because of postgis
+-- #541; then because equality is checked by comparing bbox instead of real
+-- geometries. So, we implement that constraint in a trigger
+CREATE OR REPLACE FUNCTION tg_paths_bu() RETURNS TRIGGER AS $$
+DECLARE res INTEGER;
+BEGIN
+    SELECT INTO res COUNT(*) FROM paths WHERE ST_AsBinary(geom) = ST_AsBinary(NEW.geom) AND owner = NEW.owner AND id != NEW.id;
+    IF res >= 1 THEN
+        RAISE 'duplicate key paths_geom_key' using ERRCODE = 'unique_violation';
+    ELSE
+        RETURN NEW;
+    END IF;
+END;
+$$ LANGUAGE PLPGSQL;
+
+DROP TRIGGER IF EXISTS tg_paths_bu ON paths;
+CREATE TRIGGER tg_paths_bu BEFORE INSERT OR UPDATE ON paths FOR EACH ROW EXECUTE PROCEDURE tg_paths_bu();
+
+COMMIT;
diff --git a/scripts/trailingspaces.sh b/scripts/trailingspaces.sh
new file mode 100755 (executable)
index 0000000..0e66c43
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+sed -i -e 's/\s*$//' "${@}"
diff --git a/scripts/updategeoip.sh b/scripts/updategeoip.sh
new file mode 100755 (executable)
index 0000000..eb9327e
--- /dev/null
@@ -0,0 +1,83 @@
+#!/bin/sh
+set -e
+
+GEOIPDB=http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
+
+EXECDIR=$PWD/${0%/*}
+. $EXECDIR/db_auth.sh
+
+usage() {
+    echo Usage: ${0##*/} [options]
+    echo
+    echo Options:
+    echo "  " -h display this help message
+    echo "  " -s be more silent \(show only warnings\)
+}
+
+# getopt
+SILENT=""
+args=`getopt -o sh -l silent,help -- "$@"`
+eval set -- "$args"
+while true; do
+    case "$1" in
+        -h|--help) usage; exit 0 ;;
+        -s|--silent) SILENT="1"; shift ;;
+        --) shift; break ;;
+        *) echo "Invalid option: $1"; exit 1 ;;
+    esac
+done
+
+if [ ${#SILENT} -ne 0 ]; then
+    # we won't see all the index creation notices when creating tables
+    export PGOPTIONS='--client_min_messages=warning'
+fi
+
+psql --set "ON_ERROR_STOP=1" -f - <<EOF
+BEGIN;
+
+DROP TABLE IF EXISTS geoip CASCADE;
+CREATE TABLE geoip (
+    id SERIAL PRIMARY KEY,
+    begin_ip BIGINT,
+    end_ip BIGINT,
+    country CHAR(2)
+);
+
+DROP FUNCTION IF EXISTS inet_to_bigint(INET);
+CREATE OR REPLACE FUNCTION inet_to_bigint(ip INET)
+    RETURNS BIGINT AS
+\$\$
+DECLARE
+    w TEXT;
+    x TEXT;
+    y TEXT;
+    z TEXT;
+    sp TEXT[];
+BEGIN
+    sp := regexp_split_to_array(ip::text, E'\\\\.');
+    w := sp[1];
+    x := sp[2];
+    y := sp[3];
+    z := substring(sp[4], 0, strpos(sp[4], '/'));
+    return 16777216*w::bigint + 65536*x::bigint + 256*y::bigint + z::bigint;
+END;
+\$\$ LANGUAGE plpgsql IMMUTABLE;
+
+COMMIT;
+EOF
+
+
+DIR=`mktemp -d`
+trap "rm -rf $DIR;" EXIT
+cd $DIR
+wget $GEOIPDB
+GEOIPCVS=$(zipinfo -1 ${GEOIPDB##*/} | grep '\.csv$')
+if [ $(echo $GEOIPCVS | wc -w) -lt "1" ]; then
+    echo There is no csv file in the archive. Canceling
+elif [ $(echo $GEOIPCVS | wc -w) -gt "1" ]; then
+    echo There is more than one csv file in the archive. Which one should I pick ?
+fi
+unzip ${GEOIPDB##*/} $GEOIPCVS
+
+# insert all values from csv to database
+sed -e 's/"\([^"]\+\)","\([^"]\+\)","\([^"]\+\)","\([^"]\+\)","\([^"]\+\)","\([^"]\+\)"/INSERT INTO geoip (begin_ip, end_ip, country) VALUES ('\''\3'\'','\''\4'\'','\''\5'\'');/' $GEOIPCVS | psql --set "ON_ERROR_STOP=1" -f -
diff --git a/scripts/updategeonames.sh b/scripts/updategeonames.sh
new file mode 100755 (executable)
index 0000000..ff5c8cd
--- /dev/null
@@ -0,0 +1,75 @@
+#!/bin/sh
+set -e
+
+GEONAMESXML=http://ws.geonames.org/countryInfo
+
+EXECDIR=$PWD/${0%/*}
+. $EXECDIR/db_auth.sh
+
+usage() {
+    echo Usage: ${0##*/} [options]
+    echo
+    echo Options:
+    echo "  " -h display this help message
+    echo "  " -s be more silent \(show only warnings\)
+}
+
+# getopt
+SILENT=""
+args=`getopt -o sh -l silent,help -- "$@"`
+eval set -- "$args"
+while true; do
+    case "$1" in
+        -h|--help) usage; exit 0 ;;
+        -s|--silent) SILENT="1"; shift ;;
+        --) shift; break ;;
+        *) echo "Invalid option: $1"; exit 1 ;;
+    esac
+done
+
+if [ ${#SILENT} -ne 0 ]; then
+    # we won't see all the index creation notices when creating tables
+    export PGOPTIONS='--client_min_messages=warning'
+fi
+
+psql --set "ON_ERROR_STOP=1" -f - <<EOF
+BEGIN;
+DROP TABLE IF EXISTS geonames CASCADE;
+CREATE TABLE geonames (
+    country CHAR(2) UNIQUE PRIMARY KEY,
+    minlon real,
+    minlat real,
+    maxlon real,
+    maxlat real
+);
+COMMIT;
+EOF
+
+TMPDIR=`mktemp -d`
+TMPFILE=`mktemp --tmpdir=$TMPDIR`
+trap "rm -rf $TMPDIR;" EXIT
+cd $TMPDIR
+wget $GEONAMESXML
+
+for line in $(cat ${GEONAMESXML##*/}); do
+    if echo $line | grep -qi '<country>'; then
+        COUNTRY=""; MINLON=""; MINLAT=""; MAXLON=""; MAXLAT=""
+    elif echo $line | grep -qi '<countryCode>.*</countryCode>'; then
+        COUNTRY=$(echo $line | sed -e 's/^\s*<countryCode>\(.*\)<\/countryCode>\s*/\1/i')
+    elif echo $line | grep -qi '<bBoxWest>.*</bBoxWest>'; then
+        MINLON=$(echo $line | sed -e 's/^\s*<bBoxWest>\(.*\)<\/bBoxWest>\s*/\1/i')
+    elif echo $line | grep -qi '<bBoxSouth>.*</bBoxSouth>'; then
+        MINLAT=$(echo $line | sed -e 's/^\s*<bBoxSouth>\(.*\)<\/bBoxSouth>\s*/\1/i')
+    elif echo $line | grep -qi '<bBoxEast>.*</bBoxEast>'; then
+        MAXLON=$(echo $line | sed -e 's/^\s*<bBoxEast>\(.*\)<\/bBoxEast>\s*/\1/i')
+    elif echo $line | grep -qi '<bBoxNorth>.*</bBoxNorth>'; then
+        MAXLAT=$(echo $line | sed -e 's/^\s*<bBoxNorth>\(.*\)<\/bBoxNorth>\s*/\1/i')
+    elif echo $line | grep -qi '<\/country>'; then
+        if [ ${#COUNTRY} -ne 0 -a ${#MINLON} -ne 0 -a ${#MINLAT} -ne 0 -a ${#MAXLON} -ne 0 -a ${#MAXLAT} -ne 0 ]; then
+            echo "INSERT INTO geonames (country, minlon, minlat, maxlon, maxlat) VALUES ('$COUNTRY', $MINLON, $MINLAT, $MAXLON, $MAXLAT);" >> $TMPFILE
+        fi
+    fi
+done
+echo "INSERT INTO geonames (country, minlon, minlat, maxlon, maxlat) VALUES ('EU', -26, 34, 40, 68);" >> $TMPFILE
+echo "INSERT INTO geonames (country, minlon, minlat, maxlon, maxlat) VALUES ('AP', 90, -20, -140, 68);" >> $TMPFILE
+psql --set "ON_ERROR_STOP=1" -f $TMPFILE
diff --git a/scripts/updatepo.sh b/scripts/updatepo.sh
new file mode 100755 (executable)
index 0000000..be5ce1a
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+POTFILE=`mktemp /tmp/XXXXXXXXXX.pot`
+GITROOT=`git rev-parse --show-cdup`
+GITROOT=${GITROOT:-.}
+APPROOT=$GITROOT/application
+find $APPROOT -name '*.php' -o -name '*.phtml' | xgettext -L php --keyword=translate --keyword=__ --from-code=UTF-8 -o $POTFILE -f -
+for lang in en fr; do
+    echo $lang language
+    msgmerge -U $APPROOT/languages/lang_${lang}.po $POTFILE
+    msgfmt --statistics -o $APPROOT/languages/lang_${lang}.mo $APPROOT/languages/lang_${lang}.po
+done
+rm -f $POTFILE