aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Micieli <fumseckworld@gmail.com>2018-06-30 15:18:26 +0200
committerWilly Micieli <fumseckworld@gmail.com>2018-06-30 15:18:26 +0200
commit47e23b06db5a0c3073244d3f5d355254ad62f02f (patch)
tree3bf0e13399a8a8f86d0b1513f2a99f9ec542a0ee
downloadeywa-47e23b06db5a0c3073244d3f5d355254ad62f02f.zip
eywa-47e23b06db5a0c3073244d3f5d355254ad62f02f.tar.gz
add project3.01.0
-rw-r--r--.gitignore9
-rw-r--r--.travis.yml38
-rw-r--r--LICENSE674
-rw-r--r--Makefile53
-rw-r--r--README.md57
-rw-r--r--_config.yml1
-rw-r--r--app/helpers.php1554
-rw-r--r--composer.json42
-rw-r--r--css/off-canvas.css91
-rw-r--r--db/migrations/20180327104242_workstable.php41
-rw-r--r--db/migrations/20180327105746_patientstable.php38
-rw-r--r--db/migrations/20180327105857_countrytable.php35
-rw-r--r--db/migrations/20180327110010_doctorstable.php39
-rw-r--r--db/seeds/CountrySeeds.php29
-rw-r--r--db/seeds/DoctorsSeeds.php32
-rw-r--r--db/seeds/PatientsSeeds.php31
-rw-r--r--db/seeds/WorksSeeds.php35
-rw-r--r--documentations/BASE.md22
-rw-r--r--documentations/DUMPER.md43
-rw-r--r--documentations/FILE.md64
-rw-r--r--documentations/FORM.md47
-rw-r--r--documentations/HELPERS.md839
-rw-r--r--documentations/QUERY.md73
-rw-r--r--documentations/TABLE.md73
-rw-r--r--grumphp.yml9
-rw-r--r--imperium/Auth/Exceptions/OauthExceptions.php43
-rw-r--r--imperium/Auth/Oauth.php75
-rw-r--r--imperium/Databases/Core/ConnexionManagement.php105
-rw-r--r--imperium/Databases/Core/DatabasesManagement.php199
-rw-r--r--imperium/Databases/Core/UserManagement.php130
-rw-r--r--imperium/Databases/Dumper/Databases/MySQLDatabase.php212
-rw-r--r--imperium/Databases/Dumper/Databases/PostgreSQLDatabase.php147
-rw-r--r--imperium/Databases/Dumper/Databases/SQLiteDatabase.php70
-rw-r--r--imperium/Databases/Dumper/Dumper.php330
-rw-r--r--imperium/Databases/Dumper/Exceptions/CannotSetParameter.php38
-rw-r--r--imperium/Databases/Dumper/Exceptions/CannotStartDump.php39
-rw-r--r--imperium/Databases/Dumper/Exceptions/DumpFailed.php57
-rw-r--r--imperium/Databases/Dumper/Tables/MySQLTable.php205
-rw-r--r--imperium/Databases/Dumper/Tables/PostgreSQLTable.php136
-rw-r--r--imperium/Databases/Dumper/Tables/SQLiteTable.php70
-rw-r--r--imperium/Databases/Eloquent/Bases/Base.php473
-rw-r--r--imperium/Databases/Eloquent/Connexion/Connexion.php255
-rw-r--r--imperium/Databases/Eloquent/Eloquent.php154
-rw-r--r--imperium/Databases/Eloquent/Exception/EloquentException.php41
-rw-r--r--imperium/Databases/Eloquent/Query/EloquentQueryBuilder.php208
-rw-r--r--imperium/Databases/Eloquent/Query/Query.php739
-rw-r--r--imperium/Databases/Eloquent/Share.php71
-rw-r--r--imperium/Databases/Eloquent/Tables/EloquentTableBuilder.php402
-rw-r--r--imperium/Databases/Eloquent/Tables/Table.php1583
-rw-r--r--imperium/Databases/Eloquent/Users/Users.php282
-rw-r--r--imperium/Databases/Exception/IdentifierException.php34
-rw-r--r--imperium/Directory/Dir.php47
-rw-r--r--imperium/File/File.php1588
-rw-r--r--imperium/Html/Bar/Icon.php142
-rw-r--r--imperium/Html/Bar/IconManagement.php80
-rw-r--r--imperium/Html/Canvas/Canvas.php208
-rw-r--r--imperium/Html/Canvas/CanvasManagement.php105
-rw-r--r--imperium/Html/Form/Core/FormBuilder.php436
-rw-r--r--imperium/Html/Form/Form.php2542
-rw-r--r--imperium/Html/Pagination/Pagination.php647
-rw-r--r--imperium/Html/Pagination/PaginationManagement.php170
-rw-r--r--imperium/Html/Records/Records.php153
-rw-r--r--imperium/Html/Records/RecordsManagement.php67
-rw-r--r--phinx.yml35
-rw-r--r--phpunit.xml22
-rw-r--r--tests/AuthenticationTest.php86
-rw-r--r--tests/BaseTest.php143
-rw-r--r--tests/ConnectionTest.php97
-rw-r--r--tests/FileTest.php398
-rw-r--r--tests/FormTest.php1935
-rw-r--r--tests/HelpersTest.php669
-rw-r--r--tests/OauthTest.php64
-rw-r--r--tests/PaginationTest.php62
-rw-r--r--tests/PasswordsTest.php37
-rw-r--r--tests/SqlBuilderTest.php301
-rw-r--r--tests/TablesTest.php170
-rw-r--r--tests/UsersTest.php95
-rw-r--r--tests/files/bootstrap.css8975
-rw-r--r--tests/files/bootstrap.js3894
-rw-r--r--tests/files/file.php2
-rw-r--r--tests/files/index.html22
-rw-r--r--tests/files/load.php4
-rwxr-xr-xtests/files/rename0
-rw-r--r--tests/files/test.txt4
84 files changed, 33267 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a0bd098
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+.idea
+vendor
+composer.lock
+index.php
+dump
+lion
+*_link
+imperiums
+testing \ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7d49f09
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,38 @@
+language: php
+
+php:
+ - 7.2
+ - 7.1
+ - 7.0
+sudo: required
+addons:
+ mariadb: 10.2
+ postgresql: 9.6
+before_install:
+ # stop old version
+ - sudo /etc/init.d/postgresql stop
+ # add postgresql 10 repository
+ - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
+ - sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs 2>/dev/null)-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
+ # install new version
+ - sudo apt-get update -qq
+ - sudo apt-get install -qq postgresql-10 postgresql-client-10 build-essential
+ # clone auth config (might need to fix source path for another version)
+ - sudo cp /etc/postgresql/9.6/main/pg_hba.conf /etc/postgresql/10/main/pg_hba.conf
+ # start new version
+ - sudo /etc/init.d/postgresql restart
+ # I haven't investigated or tried to fix, but pg10 uses another port
+ # for some reason, so tell applications to use correct port
+ - export PGPORT=5433
+
+install:
+ - composer selfupdate
+ - composer install
+
+before_script:
+ - make conf
+script:
+ - ./vendor/bin/phpunit --colors --coverage-text --coverage-clover build/logs/clover.xml
+
+after_success:
+ - travis_retry php vendor/bin/coveralls
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..9cecc1d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 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 General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is 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. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ 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.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ 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 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. Use with the GNU Affero General Public License.
+
+ 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 Affero 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 special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 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 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 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 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 General Public License for more details.
+
+ You should have received a copy of the GNU 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 the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ {project} Copyright (C) {year} {fullname}
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ 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 GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..950ab69
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,53 @@
+.PHONY:serve all serve add mysql pgsql sqlite dbs drop
+
+BASE=imperiums
+
+ifeq (phinx,$(firstword $(MAKECMDGOALS)))
+ # use the rest as arguments for "run"
+ PHINX := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
+ # ...and turn them into do-nothing targets
+ $(eval $(PHINX):;@:)
+endif
+
+all: dbs pgsql mysql sqlite
+ @phpunit
+
+conf: dbs pgsql mysql sqlite
+
+serve: ## Start php server
+ clear
+ @php -S localhost:8000 -d display_errors=1
+
+add: ## Add a library
+ ${COMPOSER} require $(COMPOSER_ARGS)
+
+phinx: phinx.yml ## Create migration and seed
+ vendor/bin/phinx create $(PHINX)table
+ vendor/bin/phinx seed:create $(PHINX)Seeds
+sql:
+ ./vendor/bin/phinx migrate -e $@
+ ./vendor/bin/phinx seed:run -e $@
+
+pgsql:
+ ./vendor/bin/phinx migrate -e $@
+ ./vendor/bin/phinx seed:run -e $@
+lpgsql:
+ ./vendor/bin/phinx migrate -e $@
+ ./vendor/bin/phinx seed:run -e $@
+
+mysql:
+ ./vendor/bin/phinx migrate -e $@
+ ./vendor/bin/phinx seed:run -e $@
+
+sqlite:
+ ./vendor/bin/phinx migrate -e $@
+ ./vendor/bin/phinx seed:run -e $@
+
+dbs: drop
+ psql -c "create database $(BASE);" -U postgres
+ mysql -uroot -e "CREATE DATABASE $(BASE);"
+ touch $(BASE) && chmod 777 $(BASE)
+drop:
+ psql -c "DROP DATABASE IF EXISTS $(BASE);" -U postgres
+ mysql -uroot -e "DROP DATABASE IF EXISTS $(BASE);"
+ $(RM) $(BASE)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8806d0a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,57 @@
+<p align="center"><img src="https://zupimages.net/up/18/08/rd2u.png" width="300" alt="imperium"></p>
+<p align="center">
+<img src="https://travis-ci.org/fumseck/imperium.svg?branch=master" alt="Build Status">
+<img src="https://coveralls.io/repos/github/fumseck/imperium/badge.svg?branch=master" alt="Coverage Status">
+</p>
+
+
+# What it's ?
+
+It is a free php library written to be useful for everybody and to be included in [Aphrodite](https://github.com/fumseck/aphrodite), and [Lumos](https://github.com/fumseck/lumos) projects.
+* [Source code](https://github.com/fumseck/imperium)
+ * [SGBD](#sgbd)
+ * [Helpers](https://github.com/fumseck/imperium/blob/master/documentations/HELPERS.md)
+ * [Query builder](https://github.com/fumseck/imperium/blob/master/documentations/QUERY.md)
+ * [Table builder](https://github.com/fumseck/imperium/blob/master/documentations/TABLE.md)
+ * [Base builder](https://github.com/fumseck/imperium/blob/master/documentations/BASE.md)
+ * [Form builder](https://github.com/fumseck/imperium/blob/master/documentations/FORM.md)
+ * [File management system](https://github.com/fumseck/imperium/blob/master/documentations/FILE.md)
+ * [Dump database content](https://github.com/fumseck/imperium/blob/master/documentations/DUMPER.md)
+ * [Reporting Bugs](https://github.com/fumseck/imperium/issues)
+ * [License](https://github.com/fumseck/imperium/blob/master/LICENSE)
+
+# Objectives
+
+Imperium was born to you offer a system to manage your databases more simply without use obligatory a framework.
+
+To allow you to use it in your own projects, and group my projects in one to update them more simply.
+
+Its objectives are to supports all [types of databases](http://php.net/manual/en/pdo.drivers.php) possibles, and be useful for all developers to build a admin area more simply.
+
+# Installation
+
+`$ composer require imperium/imperium`
+
+# SGBD
+
+| Name | Supported |
+|-----------------------|-----------|
+| MariaDB | yes |
+| MySQL | yes |
+| PostgreSQL | yes |
+| SQLite | yes |
+| Oracle | partly |
+| SQL Server | no |
+| Firebird | no |
+| MongoDB | no |
+| Other | no |
+
+> oracle support is in development
+
+# Canvas css
+
+`$ wget https://raw.githubusercontent.com/fumseck/imperium/master/css/off-canvas.css`
+
+# To run tests
+
+`$ wget https://raw.githubusercontent.com/fumseck/imperium/master/tools/imperium` \ No newline at end of file
diff --git a/_config.yml b/_config.yml
new file mode 100644
index 0000000..3397c9a
--- /dev/null
+++ b/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-architect \ No newline at end of file
diff --git a/app/helpers.php b/app/helpers.php
new file mode 100644
index 0000000..dedef1b
--- /dev/null
+++ b/app/helpers.php
@@ -0,0 +1,1554 @@
+<?php
+/**
+ * fumseck added helpers.php to imperium
+ * The 09/09/17 at 15:11
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+use Carbon\Carbon;
+use Cz\Git\GitRepository;
+use Imperium\Auth\Exceptions\OauthExceptions;
+use Imperium\Databases\Dumper\Databases\MySQLDatabase;
+use Imperium\Databases\Dumper\Databases\PostgreSQLDatabase;
+use Imperium\Databases\Dumper\Databases\SQLiteDatabase;
+use Imperium\Databases\Dumper\Tables\MySQLTable;
+use Imperium\Databases\Dumper\Tables\PostgreSQLTable;
+use Imperium\Databases\Dumper\Tables\SQLiteTable;
+use Imperium\Databases\Eloquent\Bases\Base;
+use Imperium\Databases\Eloquent\Connexion\Connexion;
+use Imperium\Databases\Eloquent\Eloquent;
+use Imperium\Databases\Eloquent\Query\Query;
+use Imperium\Databases\Eloquent\Tables\Table;
+use Imperium\Databases\Eloquent\Users\Users;
+use Imperium\File\File;
+use Imperium\Html\Bar\Icon;
+use Imperium\Html\Canvas\Canvas;
+use Imperium\Html\Form\Form;
+use Imperium\Html\Pagination\Pagination;
+use Imperium\Html\Records\Records;
+use Intervention\Image\ImageManager;
+use PragmaRX\Google2FA\Google2FA;
+use Sinergi\BrowserDetector\Browser;
+use Sinergi\BrowserDetector\Device;
+use Sinergi\BrowserDetector\Os;
+
+if (!exist('generateKey'))
+{
+ /**
+ * generate secret key
+ *
+ * @return string
+ */
+ function generateKey() : string
+ {
+ return (new Google2FA())->generateSecretKey();
+ }
+}
+if (!exist('records'))
+{
+ /**
+ * @param string $driver
+ * @param string $class
+ * @param \Imperium\Databases\Eloquent\Tables\Table $instance
+ * @param string $table
+ * @param string $editPrefix
+ * @param string $deletePrefix
+ * @param string $orderBy
+ * @param string $editText
+ * @param string $deleteText
+ * @param string $editClass
+ * @param string $deleteClass
+ * @param string $editIcon
+ * @param string $deleteIcon
+ * @param int $limit
+ * @param int $current
+ * @param string $paginationUrl
+ * @param \PDO $pdo
+ * @param int $formType
+ * @param string $searchPlaceholder
+ * @param string $confirmDeleteText
+ * @param string $startPaginationText
+ * @param string $endPaginationText
+ * @param string $updatePaginationPlaceholder
+ * @param bool $framework
+ *
+ * @return string
+ */
+ function records(string $driver, string $class, Table $instance, string $table, string $editPrefix, string $deletePrefix, string $orderBy, string $editText, string $deleteText, string $editClass, string $deleteClass, string $editIcon, string $deleteIcon, int $limit, int $current, string $paginationUrl, PDO $pdo, int $formType, string $searchPlaceholder, string $confirmDeleteText, string $startPaginationText, string $endPaginationText, string $updatePaginationPlaceholder,bool $framework = false): string
+ {
+ return Records::show($driver,$class,$instance,$table,$editPrefix,$deletePrefix,$orderBy,$editText,$deleteText,$editClass,$deleteClass,$editIcon,$deleteIcon,$limit,$current,$paginationUrl,$pdo,$formType,$searchPlaceholder,$confirmDeleteText,$startPaginationText,$endPaginationText,$updatePaginationPlaceholder,$framework);
+ }
+}
+
+if (!exist('bootswatch'))
+{
+ /**
+ * generate bootswatch css link
+ *
+ * @param string $theme
+ * @param string $version
+ *
+ * @return string
+ */
+ function bootswatch(string $theme = 'bootstrap',string $version = '4.0.0'): string
+ {
+ if ($theme == "bootstrap")
+ return '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/'.$version.'/css/bootstrap.min.css">';
+
+ return '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/'.$version.'/'.$theme.'/bootstrap.min.css">';
+
+ }
+}
+
+if (!exist('themes'))
+{
+ /**
+ * get all bootswatch themes
+ *
+ * @return array
+ */
+ function themes(): array
+ {
+ return array (
+ 'cerulean',
+ 'cosmo',
+ 'cyborg',
+ 'darkly',
+ 'flatly',
+ 'journal',
+ 'litera',
+ 'lumen',
+ 'lux',
+ 'materia',
+ 'minty',
+ 'pulse',
+ 'sandstone',
+ 'simplex',
+ 'slate',
+ 'solar',
+ 'spacelab',
+ 'superhero',
+ 'united',
+ 'yeti',
+ 'bootstrap',
+ );
+ }
+}
+
+if (!exist('push'))
+{
+ /**
+ * push one or more elements onto the end of array
+ *
+ * @param array $array
+ * @param mixed $value
+ *
+ * @return int
+ */
+ function push(array &$array,$value): int
+ {
+ return array_push($array,$value);
+ }
+}
+
+if (!exist('pop'))
+{
+ /**
+ * pop the element off the end of array
+ *
+ * @param array $array
+ *
+ * @return mixed
+ */
+ function pop(array &$array)
+ {
+ return array_pop($array);
+ }
+}
+
+if (!exist('has'))
+{
+ /**
+ * checks if a value exists in an array
+ *
+ * @param mixed $needle
+ * @param array $array
+ *
+ * @param bool $mode
+ *
+ * @return mixed
+ */
+ function has($needle,array $array,bool $mode = true)
+ {
+ return in_array($needle,$array,$mode);
+ }
+}
+
+if (!exist('values'))
+{
+ /**
+ * Return all the values of an array
+ *
+ * @param array $array
+ *
+ * @return array
+ */
+ function values(array &$array): array
+ {
+ return array_values($array);
+ }
+}
+
+if (!exist('merge'))
+{
+ /**
+ * merge two array
+ *
+ * @param array $array
+ * @param array $second
+ *
+ * @return array
+ */
+ function merge(array $array,array $second): array
+ {
+ return array_merge($array,$second);
+ }
+}
+
+if (!exist('session'))
+{
+ /**
+ * get a $_SESSION value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ function session(string $key): string
+ {
+ if (isset($_SESSION[$key]) && !empty($_SESSION[$key]))
+ return $_SESSION[$key];
+
+ return '';
+ }
+}
+
+if (!exist('cookie'))
+{
+ /**
+ * get a $_COOKIE value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ function cookie(string $key): string
+ {
+ if (isset($_COOKIE[$key]) && !empty($_COOKIE[$key]))
+ return $_COOKIE[$key];
+
+ return '';
+ }
+}
+if (!exist('get'))
+{
+ /**
+ * get a $_GET value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ function get(string $key): string
+ {
+ if (isset($_GET[$key]) && !empty($_GET[$key]))
+ return htmlentities($_GET[$key]);
+
+ return '';
+ }
+}
+
+if (!exist('files'))
+{
+ /**
+ * get a $_FILE value
+ *
+ * @param string $key
+ *
+ * @return mixed
+ */
+ function files(string $key)
+ {
+ if (isset($_FILES[$key]) && !empty($_FILES[$key]))
+ return $_FILES[$key];
+
+ return '';
+ }
+}
+if (!exist('server'))
+{
+ /**
+ * get a $_SERVER value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ function server(string $key): string
+ {
+ if (isset($_SERVER[$key]) && !empty($_SERVER[$key]))
+ return $_SERVER[$key];
+
+ return '';
+ }
+}
+
+if (!exist('post'))
+{
+ /**
+ * get a $_POST value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ function post(string $key): string
+ {
+ if (isset($_POST[$key]) && !empty($_POST[$key]))
+ return htmlentities($_POST[$key]);
+
+ return '';
+ }
+}
+if (!exist('generate'))
+{
+ /**
+ * generate a form to edit or create a record
+ *
+ * @param int $type
+ * @param string $formId
+ * @param string $class
+ * @param string $action
+ * @param string $table
+ * @param Table $instance
+ * @param string $submitText
+ * @param string $submitClass
+ * @param string $submitIcon
+ * @param string $submitId
+ * @param string $csrfToken
+ * @param int $mode
+ * @param int $id
+ *
+ * @return string
+ * @throws Exception
+ */
+ function generate(int $type,string $formId,string $class,string $action,string $table,Table $instance,string $submitText,string $submitClass,string $submitIcon,string $submitId,string $csrfToken = '',int $mode = Form::CREATE,int $id = 0): string
+ {
+ return form($type)->start($action,$formId,$class)->csrf($csrfToken)->generate($table,$instance,$submitText,$submitClass,$submitId,$submitIcon,$mode,$id);
+ }
+}
+
+if (!exist('root'))
+{
+ /**
+ * get the connexion with all rights
+ *
+ * @param string $driver
+ * @param string $password
+ * @return null|PDO
+ */
+ function root(string $driver,string $password = '')
+ {
+ switch ($driver)
+ {
+ case Connexion::MYSQL:
+ return connect($driver,'','root',$password);
+ break;
+ case Connexion::POSTGRESQL:
+ return connect($driver,'','postgres',$password);
+ break;
+ default:
+ return null;
+ break;
+ }
+
+
+ }
+}
+if (!exist('collation'))
+{
+ /**
+ * get all collation
+ *
+ * @param string $driver
+ * @param PDO $connexion
+ *
+ * @return array
+ */
+ function collation(string $driver,PDO $connexion): array
+ {
+ $collation = array();
+
+ switch ($driver)
+ {
+ case Connexion::MYSQL:
+
+ foreach (req($connexion,"SHOW COLLATION") as $char)
+ push($collation,$char->Collation);
+
+ break;
+
+ case Connexion::POSTGRESQL:
+
+ foreach (req($connexion,"SELECT collname FROM pg_collation") as $char)
+ push($collation,$char->collname);
+ break;
+ default:
+ return $collation;
+ break;
+ }
+ return $collation;
+ }
+}
+if (!exist('charset'))
+{
+ /**
+ * get all charset
+ *
+ * @param string $driver
+ * @param PDO $connexion
+ *
+ * @return array
+ */
+ function charset(string $driver,PDO $connexion): array
+ {
+ $encoding = array();
+ switch ($driver)
+ {
+ case Connexion::MYSQL:
+ foreach (req($connexion,"SHOW CHARACTER SET") as $char)
+ push($encoding,$char->Charset);
+ break;
+
+ case Connexion::POSTGRESQL:
+ foreach (req($connexion,"SELECT DISTINCT pg_encoding_to_char(conforencoding) FROM pg_conversion ORDER BY 1") as $char)
+ push($encoding,$char->pg_encoding_to_char);
+ break;
+ default:
+ return $encoding;
+ break;
+ }
+ return $encoding;
+ }
+}
+
+if (!exist('git'))
+{
+ /**
+ * manage git repository
+ *
+ * @param string $repository
+ *
+ * @return GitRepository
+ * @throws \Cz\Git\GitException
+ */
+ function git(string $repository): GitRepository
+ {
+ return new GitRepository($repository);
+ }
+}
+
+if (!exist('getCurrentBranch'))
+{
+ /**
+ * get the current git branch
+ *
+ * @param string $repository
+ *
+ * @return string
+ */
+ function getCurrentBranch(string $repository): string
+ {
+ return (new GitRepository($repository))->getCurrentBranchName();
+ }
+}
+if (!exist('checkCode'))
+{
+ /**
+ * check if a code is valid
+ *
+ * @param string $secret
+ * @param string $code
+ *
+ * @return bool|int
+ * @throws OauthExceptions
+ */
+ function checkCode(string $secret,string $code)
+ {
+ if (strlen($code) != 6)
+ throw OauthExceptions::codeLengthIncorrect();
+ else
+ return (new Google2FA())->verifyKey($secret,$code);
+
+ }
+}
+
+if (!exist('generateQrCode'))
+{
+ /**
+ * generate Qr code
+ *
+ * @param string $company
+ * @param string $username
+ * @param string $secret
+ *
+ * @param int $size
+ * @return string
+ */
+ function generateQrCode(string $company,string $username,string $secret,int $size = 200) : string
+ {
+ return (new Google2FA())->getQRCodeGoogleUrl($company,$username,$secret,$size);
+ }
+}
+
+if (!exist('base'))
+{
+ /**
+ * manage database
+ *
+ * @param string $driver
+ * @param string $base
+ * @param string $username
+ * @param string $password
+ * @param string $dumpPath
+ * @param array $hidden
+ *
+ * @return Base
+ */
+ function base(string $driver,string $base,string $username,string $password,string $dumpPath,array $hidden = [])
+ {
+ return Base::manage()->setName($base)->setDriver($driver)->setUser($username)->setPassword($password)->setDumpDirectory($dumpPath)->setHidden($hidden);
+ }
+}
+
+if (!exist('user'))
+{
+ /**
+ * manage users
+ *
+ * @param string $driver
+ * @param string $username
+ * @param string $password
+ * @param array $hidden
+ *
+ * @return Users
+ */
+ function user(string $driver,string $username,string $password,array $hidden = []) : Users
+ {
+ return Users::manage()->setDriver($driver)->setName($username)->setPassword($password)->setHidden($hidden);
+ }
+}
+
+if (!exist('connect'))
+{
+ /**
+ * connect to a database
+ *
+ * @param string $driver
+ * @param string $database
+ * @param string $username
+ * @param string $password
+ *
+ * @return null|PDO
+ */
+ function connect(string $driver,string $database = '',string $username = '',$password = '')
+ {
+ return Connexion::connect()->setDriver($driver)->setDatabase($database)->setUser($username)->setPassword($password)->getConnexion();
+ }
+}
+
+if (!exist('pass'))
+{
+ /**
+ * update user password
+ *
+ * @param string $driver
+ * @param string $username
+ * @param string $current
+ * @param string $new
+ *
+ * @return bool
+ */
+ function pass(string $driver,string $username,string $current,string $new) : bool
+ {
+ try {
+ return user($driver, $username, $current)->updatePassword($username, $new);
+ }catch (PDOException $e)
+ {
+ return false;
+ }
+ }
+}
+
+
+if (!exist('os'))
+{
+ /**
+ * see os
+ *
+ * @param bool $name
+ *
+ * @return Os|string
+ */
+ function os(bool $name = false)
+ {
+ if ($name)
+ return (new Os())->getName();
+ else
+ return new Os();
+ }
+}
+
+if (!exist('device'))
+{
+ /**
+ * see devices
+ *
+ * @param bool $name
+ *
+ * @return string|Device
+ */
+ function device(bool $name = false)
+ {
+ if ($name)
+ return (new Device())->getName();
+ else
+ return new Device();
+ }
+}
+
+if (!exist('getDevice'))
+{
+ /**
+ * get device
+ *
+ * @return string
+ */
+ function getDevice(): string
+ {
+ return (new Device())->getName();
+ }
+}
+
+if (!exist('getOs'))
+{
+ /**
+ * get operating system
+ *
+ * @return string
+ */
+ function getOs(): string
+ {
+ return (new Os())->getName();
+ }
+}
+
+if (!exist('getBrowser'))
+{
+ /**
+ * get browser name
+ *
+ * @return string
+ */
+ function getBrowser(): string
+ {
+ return (new Browser())->getName();
+ }
+}
+
+if (!exist('browser'))
+{
+ /**
+ * see browser
+ *
+ * @param bool $name
+ *
+ * @return Browser|string
+ */
+ function browser(bool $name = false)
+ {
+ if ($name)
+ return (new Browser())->getName();
+ else
+ return new Browser();
+ }
+}
+
+if (!exist('isBrowser'))
+{
+ /**
+ * check if is name is browser
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+ function isBrowser(string $name): bool
+ {
+ return (new Browser())->isBrowser($name);
+ }
+}
+
+if (!exist('isMobile'))
+{
+ /**
+ * check if device is mobile
+ *
+ * @return bool
+ */
+ function isMobile(): bool
+ {
+ return (new Os())->isMobile();
+ }
+}
+
+if (!exist('restore'))
+{
+ /**
+ * restore a database
+ *
+ * @param Base $instance
+ * @param string $base
+ * @param string $sqlFile
+ *
+ * @return bool
+ */
+ function restore(Base $instance,string $base,string $sqlFile): bool
+ {
+ return $instance->restore($base,$sqlFile);
+ }
+}
+if (!exist('create'))
+{
+ /**
+ * create a new database
+ *
+ * @param string $driver
+ * @param string $database
+ * @param string $charset
+ * @param string $collation
+ * @param PDO $connexion
+ *
+ * @return bool
+ */
+ function create(string $driver,string $database,string $charset,string $collation,PDO $connexion): bool
+ {
+ switch ($driver)
+ {
+ case Connexion::MYSQL:
+ return execute($connexion,"CREATE DATABASE IF NOT EXISTS $database DEFAULT CHARACTER SET $charset DEFAULT COLLATE $collation");
+ break;
+ case Connexion::POSTGRESQL:
+ return execute($connexion,"CREATE DATABASE $database ENCODING '$charset' LC_COLLATE='$collation' LC_CTYPE='$collation' TEMPLATE=template0");
+ break;
+ case Connexion::ORACLE:
+ return execute($connexion,"CREATE DATABASE $database CHARACTER SET $charset");
+ break;
+ case Connexion::SQLITE:
+ return new PDO("sqlite:$database") instanceof PDO;
+ break;
+ default:
+ return false;
+ break;
+
+ }
+ }
+}
+
+if(!exist('show'))
+{
+ /**
+ * show databases, users, tables
+ *
+ * @param string $driver
+ * @param string $database
+ * @param string $username
+ * @param string $password
+ * @param array $hidden
+ * @param int $mode
+ *
+ * @return array
+ * @throws \Imperium\Databases\Exception\IdentifierException
+ */
+ function show(string $driver,string $database,string $username,string $password,int $mode = Eloquent::MODE_ALL_DATABASES,array $hidden = []) : array
+ {
+ switch ($mode)
+ {
+ case Eloquent::MODE_ALL_DATABASES:
+ return base($driver,$database,$username,$password,'')->setHidden($hidden)->show();
+ break;
+ case Eloquent::MODE_ALL_USERS:
+ return user($driver,$username,$password)->setHidden($hidden)->show();
+ break;
+ case Eloquent::MODE_ALL_TABLES:
+ return table($driver,$database,$username,$password,'')->setHidden($hidden)->show();
+ break;
+ default:
+ return array();
+ break;
+ }
+
+ }
+}
+
+if(!exist('req'))
+{
+ /**
+ * execute a query return an array with results
+ *
+ * @param PDO $instance
+ * @param string $request
+ * @param int $fetchStyle
+ *
+ * @return array
+ */
+ function req(PDO $instance,string $request,int $fetchStyle = PDO::FETCH_OBJ): array
+ {
+ $query = $instance->prepare($request);
+ if ($query->execute())
+ {
+ $data = $query->fetchAll($fetchStyle);
+
+ if ($query->closeCursor())
+ {
+ return $data;
+ }
+ }
+ return array();
+ }
+}
+
+if(!exist('execute'))
+{
+
+ /**
+ * execute a query return a boolean
+ *
+ * @param PDO $instance
+ * @param string $request
+ * @return bool
+ */
+ function execute(PDO $instance,string $request): bool
+ {
+ $query = $instance->prepare($request);
+ return $query->execute();
+ }
+}
+if (!exist('db'))
+{
+ /**
+ * create a new database with optional parameters
+ *
+ * @param Base $instance
+ * @param string $base
+ * @param string $charset
+ * @param string $collation
+ *
+ * @return bool
+ * @throws \Imperium\Databases\Exception\IdentifierException
+ */
+ function db(Base $instance,string $base,string $charset ='',string $collation =''): bool
+ {
+ return $instance->setCollation($collation)->setEncoding($charset)->create($base);
+ }
+}
+
+if (!exist('drop'))
+{
+ /**
+ * @param $instance
+ * @param string[] ...$to
+ *
+ * @return bool
+ */
+ function drop($instance,string ...$to): bool
+ {
+ if ($instance instanceof Users)
+ foreach ($to as $user)
+ if (!$instance->drop($user))
+ return false;
+
+ if ($instance instanceof Base)
+ foreach ($to as $base)
+ if (!$instance->drop($base))
+ return false;
+
+ if ($instance instanceof Table)
+ foreach ($to as $table)
+ if (!$instance->drop($table))
+ return false;
+
+
+
+ return true;
+ }
+}
+
+if (!exist('table'))
+{
+ /**
+ * manage tables
+ *
+ * @param string $driver
+ * @param string $database
+ * @param string $username
+ * @param string $password
+ * @param string $dumpPath
+ *
+ * @return Table
+ */
+ function table(string $driver,string $database,string $username,string $password,string $dumpPath): Table
+ {
+ return Table::manage()->setDriver($driver)->setDatabase($database)->setUsername($username)->setPassword($password)->setDumpPath($dumpPath);
+ }
+}
+
+if (!exist('faker'))
+{
+ /**
+ * get an instance of faker
+ *
+ * @param string $locale
+ *
+ * @return \Faker\Generator
+ */
+ function faker(string $locale = 'en_US' ): Faker\Generator
+ {
+ return Faker\Factory::create($locale);
+ }
+}
+
+
+if (!exist('userDel'))
+{
+ /**
+ * delete an user
+ *
+ * @param string $driver
+ * @param string[] $users
+ * @param PDO $connexion
+ *
+ * @return bool
+ */
+ function userDel(string $driver,PDO $connexion,string ...$users): bool
+ {
+ if (is_null($connexion))
+ return false;
+
+ switch ($driver)
+ {
+ case Connexion::MYSQL:
+ foreach ($users as $user)
+ if (!execute($connexion,"DROP USER '$user'@'localhost'"))
+ return false;
+ break;
+ case Connexion::POSTGRESQL:
+ foreach ($users as $user)
+ if (!execute($connexion,"DROP USER $user"))
+ return false;
+
+ break;
+ case Connexion::ORACLE:
+ foreach ($users as $user)
+ if (!execute($connexion,"DROP USER $user"))
+ return false;
+ break;
+ default:
+ return false;
+ break;
+ }
+ return true;
+ }
+}
+
+if (!exist('form'))
+{
+ /**
+ * @param int $type
+ *
+ * @return Form
+ */
+ function form(int $type = Form::BOOTSTRAP)
+ {
+ if (has($type,[Form::BOOTSTRAP,Form::FOUNDATION],true))
+ return Form::create()->setType($type);
+ else
+ return Form::create()->setType(Form::BOOTSTRAP);
+ }
+}
+
+if (!exist('dumper'))
+{
+ /**
+ * dump a database or a table
+ *
+ * @param string $driver
+ * @param string $username
+ * @param string $password
+ * @param string $database
+ * @param string $dumpPath
+ * @param int $mode
+ * @param string $table
+ *
+ * @return bool
+ */
+ function dumper(string $driver, string $username, string $password, string $database, string $dumpPath, int $mode = Eloquent::MODE_DUMP_DATABASE, string $table ='')
+ {
+ $filename = $mode == Eloquent::MODE_DUMP_DATABASE ? "$dumpPath/$database.sql" : "$dumpPath/$table.sql";
+
+ switch ($driver)
+ {
+ case Connexion::MYSQL:
+ if ($mode == Eloquent::MODE_DUMP_DATABASE)
+ MySQLDatabase::dump()->setDbName($database)->setUserName($username)->setPassword($password)->dumpToFile("$dumpPath/$database.sql",$dumpPath);
+ else
+ MySQLTable::dump()->setTable($table)->setUserName($username)->setPassword($password)->setDbName($database)->dumpToFile("$dumpPath/$table.sql",$dumpPath);
+ break;
+ case Connexion::POSTGRESQL:
+ if ($mode == Eloquent::MODE_DUMP_DATABASE)
+ PostgreSQLDatabase::dump()->setDbName($database)->setUserName($username)->setPassword($password)->dumpToFile("$dumpPath/$database.sql",$dumpPath);
+ else
+ PostgreSQLTable::dump()->setTable($table)->setUserName($username)->setPassword($password)->setDbName($database)->dumpToFile("$dumpPath/$table.sql",$dumpPath);
+ break;
+ case Connexion::SQLITE:
+ if ($mode == Eloquent::MODE_DUMP_DATABASE)
+ SQLiteDatabase::dump()->setDbName($database)->dumpToFile("$dumpPath/$database.sql",$dumpPath);
+ else
+ SQLiteTable::dump()->setTable($table)->setDbName($database)->dumpToFile("$dumpPath/$table.sql",$dumpPath);
+ break;
+ default:
+ return false;
+ break;
+ }
+ return File::download($filename) != false;
+ }
+}
+
+if (!exist('sql'))
+{
+ /**
+ * sql table builder
+ *
+ * @param string $table
+ *
+ * @return Query
+ */
+ function sql(string $table): Query
+ {
+ return Query::start()->setTable($table);
+ }
+}
+
+if (!exist('union'))
+{
+ /**
+ * @param int $mode
+ * @param string $firstTable
+ * @param string $secondTable
+ * @param array $firstColumns
+ * @param array $secondColumns
+ *
+ * @return Query
+ */
+ function union(int $mode,string $firstTable,string $secondTable,array $firstColumns,array $secondColumns): Query
+ {
+ return Query::start()->union($mode,$firstTable,$secondTable,$firstColumns,$secondColumns);
+ }
+}
+
+if (!exist('getLines'))
+{
+ /**
+ * get all lines in filename
+ *
+ * @param string $filename
+ *
+ * @return array
+ */
+ function getLines(string $filename): array
+ {
+ return File::getLines($filename);
+ }
+}
+if (!exist('getKeys'))
+{
+ /**
+ * get all keys in filename
+ *
+ * @param string $filename
+ * @param string $delimiter
+ *
+ * @return array
+ */
+ function getKeys(string $filename,string $delimiter): array
+ {
+ return File::getKeys($filename,$delimiter);
+ }
+
+}
+
+if (!exist('getValues'))
+{
+ /**
+ * get all values in filename
+ *
+ * @param string $filename
+ * @param string $delimiter
+ *
+ * @return array
+ */
+ function getValues(string $filename,string $delimiter): array
+ {
+ return File::getValues($filename,$delimiter);
+ }
+
+}
+
+if (!exist('joins'))
+{
+ /**
+ * generate a join clause
+ *
+ * @param int $type
+ * @param string $firstTable
+ * @param string $secondTable
+ * @param string $firstParam
+ * @param string $secondParam
+ * @param array $firstColumns
+ * @param string $condition
+ *
+ * @return Query
+ */
+ function joins(int $type,string $firstTable,string $secondTable,string $firstParam,string $secondParam,array $firstColumns = [], string $condition ='='): Query
+ {
+ return Query::start()->join($type,$firstTable,$secondTable,$firstParam,$secondParam,$firstColumns,$condition);
+ }
+}
+
+if (!exist('pagination'))
+{
+ /**
+ * create a pagination
+ *
+ * @param int $perPage
+ * @param string $instance
+ * @param int $current
+ * @param int $total
+ * @param string $startChar
+ * @param string $endChar
+ *
+ * @param string $ulClass
+ * @param string $startCssClass
+ * @param string $endCssClass
+ * @param int $type
+ *
+ * @return string
+ */
+ function pagination(int $perPage,string $instance,int $current,int $total,string $startChar,string $endChar,string $ulClass = 'pagination',string $startCssClass = 'page-item',string $endCssClass = 'page-item',int $type = 1): string
+ {
+ return Pagination::paginate($perPage,$instance)->setTotal($total)->setStartChar($startChar)->setEndChar($endChar)->setUlCssClass($ulClass)->setStartCssClass($startCssClass)->setEndCssClass($endCssClass)->setCurrent($current)->setType($type)->get('');
+ }
+}
+if (!exist('userAdd'))
+{
+ /**
+ * create a new user
+ *
+ * @param string $driver
+ * @param string $user
+ * @param string $password
+ * @param string $rights
+ * @param PDO $connexion
+ *
+ * @return bool
+ */
+ function userAdd(string $driver,string $user,string $password,string $rights,PDO $connexion): bool
+ {
+ if (is_null($connexion))
+ return false;
+
+ switch($driver)
+ {
+ case Connexion::MYSQL:
+ return execute($connexion,"CREATE USER '$user'@'localhost' IDENTIFIED BY '$password' $rights");
+ break;
+ case Connexion::POSTGRESQL:
+ return execute($connexion,"CREATE ROLE $user PASSWORD '$password' $rights");
+ break;
+ case Connexion::ORACLE:
+ return execute($connexion,"CREATE ROLE $user IDENTIFIED BY '$password' $rights");
+ break;
+ default:
+ return false;
+ break;
+ }
+ }
+}
+if (!exist('jasnyCss'))
+{
+ function jasnyCss(string $version = '3.1.3')
+ {
+ return '<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/'.$version.'/css/jasny-bootstrap.min.css">';
+ }
+}
+
+if (!exist('foundation'))
+{
+ function foundation(string $version = '6.4.3')
+ {
+ return '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/'.$version.'/css/foundation.min.css"/>';
+ }
+}
+if (!exist('loadFontAwesome'))
+{
+ function fontAwesome(string $version = 'v5.0.8')
+ {
+ return '<link rel="stylesheet" href="https://use.fontawesome.com/releases/'.$version.'/css/fontawesome.css"><link rel="stylesheet" href="https://use.fontawesome.com/releases/'.$version.'/css/solid.css">';
+ }
+}
+
+if (!exist('jasnyJs'))
+{
+ function jasnyJs(string $version ='3.1.3')
+ {
+ return '<script src="//cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/'.$version.'/js/jasny-bootstrap.min.js"></script>';
+ }
+}
+
+if (!exist('icon'))
+{
+ /**
+ * build and icon bar
+ *
+ * @param string $ulClass
+ * @param string $linkClass
+ * @param string $iconClass
+ * @return Icon
+ */
+ function icon(string $ulClass = 'list-inline',string $linkClass = 'link',string $iconClass = 'icon'): Icon
+ {
+ return Icon::start()->setIconClass($iconClass)->setLinkClass($linkClass)->startUl($ulClass);
+ }
+}
+
+if (!exist('canvas'))
+{
+ /**
+ * start canvas
+ *
+ * @param string $id
+ * @param string $position
+ * @param string $ulClass
+ * @param string $linkClass
+ *
+ * @return Canvas
+ */
+ function canvas(string $id,string $position = 'navmenu-fixed-right',string $ulClass = 'list-inline offCanvasLinkBackground',string $linkClass = 'offCanvasLink'): Canvas
+ {
+ return Canvas::start()->setPosition($position)->setId($id)->startUl($ulClass)->setLinkClass($linkClass);
+ }
+}
+
+
+if(!exist('fa'))
+{
+ /**
+ * generate a fa icon
+ *
+ * @param string $icon
+ * @param string $options
+ *
+ * @return string
+ */
+ function fa(string $icon, string $options = ''): string
+ {
+ return '<i class="fas '.$icon.' '.$options.'" ></i>';
+ }
+}
+
+if (!exist('cssLoader'))
+{
+ /**
+ * load a css files
+ *
+ * @param string $url
+ *
+ * @return string
+ */
+ function cssLoader(string $url): string
+ {
+ return '<link href="'.$url.'" rel="stylesheet">';
+ }
+}
+
+if (!exist('jsLoader'))
+{
+ /**
+ * load a js files
+ *
+ * @param string $url
+ * @param string $type
+ *
+ * @return string
+ */
+ function jsLoader(string $url,string $type = 'text/javascript'): string
+ {
+ return '<script src="'.$url.'" type="'.$type.'"></script>';
+ }
+}
+
+if (!exist('faGroup'))
+{
+ /**
+ * generate a link icon group area
+ *
+ * @param array $icons
+ * @param array $urls
+ * @param array $text
+ * @param array $class
+ * @param string $containerClass
+ *
+ * @return null|string
+ */
+ function faGroup(array $icons, array $urls ,array $text, array $class, string $containerClass = 'list-group')
+ {
+ $total = count($icons);
+
+ if ($total > 0 && count($urls) == $total && count($text) == $total && count($class) == $total)
+ {
+ $fa = '<div class="'.$containerClass.'">';
+
+ for ($i=0;$i<count($icons);++$i)
+ $fa .= '<a class="'.$class[$i].'" href="'.$urls[$i].'">'.$icons[$i] .' '.$text[$i].'</a>';
+
+
+ $fa .= '</div>';
+
+ return $fa;
+ }
+ return null;
+ }
+}
+if (!exist('iconic'))
+{
+ /**
+ * generate a iconic icon
+ *
+ * @param string $type
+ * @param string $icon
+ * @param string $viewBox
+ *
+ * @return string
+ */
+ function iconic(string $type,string $icon,$viewBox = '0 0 8 8'): string
+ {
+ switch ($type)
+ {
+ case 'svg':
+ return'<svg viewBox="'.$viewBox.'"><use xlink:href="'.$icon.'"></use></svg>';
+ break;
+ case 'img':
+ return '<img src="'.$icon.'">';
+ break;
+ case 'icon':
+ return '<span class="oi" data-glyph="'.$icon.'"></span>';
+ break;
+ case 'bootstrap':
+ return '<span class="oi '.$icon.'"></span>';
+ break;
+ case 'foundation':
+ return '<span class="'.$icon.'"></span>';
+ break;
+ default:
+ return '';
+ break;
+ }
+ }
+}
+
+if (!exist('glyph'))
+{
+ /**
+ * generate a glyph icon
+ *
+ * @param string $icon
+ * @param string $type
+ *
+ * @return string
+ */
+ function glyph(string $icon,$type = 'svg'): string
+ {
+ if ($type == 'svg')
+ return '<svg-icon><src href="'.$icon.'"/></svg-icon>';
+ else
+ return '<img src="'.$icon.'"/>';
+ }
+}
+
+if (!exist('image'))
+{
+ /**
+ * manage image
+ *
+ * @param string $driver
+ *
+ * @return ImageManager
+ */
+ function image(string $driver): ImageManager
+ {
+ $config = array('driver' => $driver);
+ return new ImageManager($config);
+ }
+}
+
+if (!exist('today')) {
+
+ /**
+ * Create a new Carbon instance for the current date.
+ *
+ * @param \DateTimeZone|string|null $tz
+ * @return Carbon
+ */
+ function today($tz = null): Carbon
+ {
+ return Carbon::today($tz);
+ }
+}
+if (!exist('now')) {
+ /**
+ * Create a new Carbon instance for the current date.
+ *
+ * @param \DateTimeZone|string|null $tz
+ * @return Carbon
+ */
+ function now($tz = null): Carbon
+ {
+ return Carbon::now($tz);
+ }
+}
+
+if (!exist('future')) {
+
+ /**
+ * Create a new future date.
+ *
+ * @param \DateTimeZone|string|null $tz
+ * @param string $mode
+ * @param int $time
+ *
+ * @return string
+ */
+ function future(string $mode,int $time,$tz = null): string
+ {
+ switch ($mode)
+ {
+ case 'second':
+ return Carbon::now($tz)->addSecond($time)->toDateString();
+ break;
+ case 'seconds':
+ return Carbon::now($tz)->addSeconds($time)->toDateString();
+ break;
+ case 'minute':
+ return Carbon::now($tz)->addMinute($time)->toDateString();
+ break;
+ case 'minutes':
+ return Carbon::now($tz)->addMinutes($time)->toDateString();
+ break;
+ case 'hour':
+ return Carbon::now($tz)->addHour($time)->toDateString();
+ break;
+ case 'hours':
+ return Carbon::now($tz)->addHours($time)->toDateString();
+ break;
+ case 'day':
+ return Carbon::now($tz)->addDay($time)->toDateString();
+ break;
+ case 'days':
+ return Carbon::now($tz)->addDays($time)->toDateString();
+ break;
+ case 'week':
+ return Carbon::now($tz)->addWeek($time)->toDateString();
+ break;
+ case 'weeks':
+ return Carbon::now($tz)->addWeeks($time)->toDateString();
+ break;
+ case 'month':
+ return Carbon::now($tz)->addMonth($time)->toDateString();
+ break;
+ case 'months':
+ return Carbon::now($tz)->addMonths($time)->toDateString();
+ break;
+ case 'year':
+ return Carbon::now($tz)->addYear($time)->toDateString();
+ break;
+ case 'years':
+ return Carbon::now($tz)->addYears($time)->toDateString();
+ break;
+ case 'century':
+ return Carbon::now($tz)->addCentury($time)->toDateString();
+ break;
+ case 'centuries':
+ return Carbon::now($tz)->addCenturies($time)->toDateString();
+ break;
+ default:
+ return Carbon::now($tz)->addHour($time)->toDateString();
+ break;
+ }
+
+ }
+}
+
+if (!exist('ago'))
+{
+ /**
+ * return time based on a time
+ *
+ * @param string $locale
+ * @param string $time
+ * @param null $tz
+ *
+ * @return string
+ */
+ function ago(string $locale,string $time,$tz = null): string
+ {
+ Carbon::setLocale($locale);
+
+ return Carbon::parse($time,$tz)->diffForHumans();
+ }
+}
+
+/**
+ * check if a function exist
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+function exist(string $name) : bool
+{
+ return function_exists($name);
+}
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..daa41e7
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,42 @@
+{
+ "name": "imperium/imperium",
+ "type": "library",
+ "description": "A free library to create websites administration more simply",
+ "license": "GPL-3.0-or-later",
+ "support": {
+ "issues": "https://github.com/fumseck/imperium/issues",
+ "source": "https://github.com/fumseck/imperium"
+ },
+ "authors": [
+ {
+ "name": "fumseck",
+ "email": "fumseckworld@gmail.com"
+ }
+ ],
+ "require": {
+ "php": ">=7.0",
+ "pragmarx/google2fa": "^2.0",
+ "czproject/git-php": "^3.10",
+ "sinergi/browser-detector": "^6.1",
+ "intervention/image": "^2.4",
+ "guzzlehttp/guzzle": "^6.3",
+ "nesbot/carbon": "^1.22",
+ "robmorgan/phinx": "^0.9.0",
+ "ralouphie/mimey": "^1.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "Imperium\\": "imperium/"
+ },
+ "files": [
+ "app/helpers.php"
+ ]
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.3",
+ "php-coveralls/php-coveralls": "^1.0",
+ "jakub-onderka/php-parallel-lint": "^0.9.2",
+ "fzaninotto/faker": "^1.7",
+ "phpro/grumphp": "^0.14.0"
+ }
+}
diff --git a/css/off-canvas.css b/css/off-canvas.css
new file mode 100644
index 0000000..d638afc
--- /dev/null
+++ b/css/off-canvas.css
@@ -0,0 +1,91 @@
+.link{
+ height: 10%;
+ margin: 0;
+ position:fixed;
+ background-color: #126990;
+ color: #ffffff;
+ width: 5%;
+ cursor: pointer;
+ display: inline-block;
+ text-align: center;
+ white-space: nowrap;
+ vertical-align: middle;
+ user-select: none;
+ border: 1px solid transparent;
+ padding: 1.5rem 1rem;
+ line-height: 1.5;
+}
+.link:hover{
+ background-color: #129dc6;
+}
+.offCanvasLinkBackground{
+ background-color: #126990;
+ color: #ffffff;
+}
+.offCanvasLink
+{
+ font-size: 12px;
+ font-weight: bold;
+ line-height: 1.5;
+ text-align: justify;
+ background-color: #129dc6;
+ color: #ffffff;
+ width: 100%;
+ cursor: pointer;
+ display: inline-block;
+
+ border: 1px solid transparent;
+ padding: 0.375rem 0.75rem;
+ white-space: nowrap;
+ vertical-align: middle;
+ user-select: none;
+
+}
+.icon{
+ color: #ffffff;
+ font-size: 25px;
+}
+
+#menu{
+ right:0;
+ top: 0;
+}
+#tables{
+ right: 0;
+ top: 10%;
+}
+#database{
+ right: 0;
+ top: 20%;
+}
+#users{
+ right: 0;
+ top: 30%;
+}
+#user{
+ right: 0;
+ top: 40%;
+}
+
+#dashboard{
+ right: 0;
+ top: 50%;
+}
+
+
+#graph{
+ right: 0;
+ top: 60%;
+}
+#sql{
+ right: 0;
+ top: 70%;
+}
+#home{
+ right: 0;
+ top: 80%;
+}
+#logout{
+ right: 0;
+ top: 90%;
+} \ No newline at end of file
diff --git a/db/migrations/20180327104242_workstable.php b/db/migrations/20180327104242_workstable.php
new file mode 100644
index 0000000..ba5a049
--- /dev/null
+++ b/db/migrations/20180327104242_workstable.php
@@ -0,0 +1,41 @@
+<?php
+
+
+use Phinx\Migration\AbstractMigration;
+
+class Workstable extends AbstractMigration
+{
+ /**
+ * Change Method.
+ *
+ * Write your reversible migrations using this method.
+ *
+ * More information on writing migrations is available here:
+ * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+ *
+ * The following commands can be used in this method and Phinx will
+ * automatically reverse them when rolling back:
+ *
+ * createTable
+ * renameTable
+ * addColumn
+ * renameColumn
+ * addIndex
+ * addForeignKey
+ *
+ * Remember to call "create()" or "update()" and NOT "save()" when working
+ * with the Table class.
+ */
+ public function change()
+ {
+ $this->table('works')
+ ->addColumn('name', 'string')
+ ->addColumn('age', 'integer')
+ ->addColumn('phone', 'integer')
+ ->addColumn('sex', 'string')
+ ->addColumn('status','string')
+ ->addColumn('days','datetime')
+ ->addColumn('date','datetime')
+ ->create();
+ }
+}
diff --git a/db/migrations/20180327105746_patientstable.php b/db/migrations/20180327105746_patientstable.php
new file mode 100644
index 0000000..985dfe3
--- /dev/null
+++ b/db/migrations/20180327105746_patientstable.php
@@ -0,0 +1,38 @@
+<?php
+
+
+use Phinx\Migration\AbstractMigration;
+
+class Patientstable extends AbstractMigration
+{
+ /**
+ * Change Method.
+ *
+ * Write your reversible migrations using this method.
+ *
+ * More information on writing migrations is available here:
+ * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+ *
+ * The following commands can be used in this method and Phinx will
+ * automatically reverse them when rolling back:
+ *
+ * createTable
+ * renameTable
+ * addColumn
+ * renameColumn
+ * addIndex
+ * addForeignKey
+ *
+ * Remember to call "create()" or "update()" and NOT "save()" when working
+ * with the Table class.
+ */
+ public function change()
+ {
+ $this->table('patients')
+ ->addColumn('name', 'string')
+ ->addColumn('age', 'integer')
+ ->addColumn('sex', 'string')
+ ->addColumn('status','string')
+ ->create();
+ }
+}
diff --git a/db/migrations/20180327105857_countrytable.php b/db/migrations/20180327105857_countrytable.php
new file mode 100644
index 0000000..2bfd49f
--- /dev/null
+++ b/db/migrations/20180327105857_countrytable.php
@@ -0,0 +1,35 @@
+<?php
+
+
+use Phinx\Migration\AbstractMigration;
+
+class Countrytable extends AbstractMigration
+{
+ /**
+ * Change Method.
+ *
+ * Write your reversible migrations using this method.
+ *
+ * More information on writing migrations is available here:
+ * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+ *
+ * The following commands can be used in this method and Phinx will
+ * automatically reverse them when rolling back:
+ *
+ * createTable
+ * renameTable
+ * addColumn
+ * renameColumn
+ * addIndex
+ * addForeignKey
+ *
+ * Remember to call "create()" or "update()" and NOT "save()" when working
+ * with the Table class.
+ */
+ public function change()
+ {
+ $this->table('country')
+ ->addColumn('name', 'string')
+ ->create();
+ }
+}
diff --git a/db/migrations/20180327110010_doctorstable.php b/db/migrations/20180327110010_doctorstable.php
new file mode 100644
index 0000000..bdf1508
--- /dev/null
+++ b/db/migrations/20180327110010_doctorstable.php
@@ -0,0 +1,39 @@
+<?php
+
+
+use Phinx\Migration\AbstractMigration;
+
+class Doctorstable extends AbstractMigration
+{
+ /**
+ * Change Method.
+ *
+ * Write your reversible migrations using this method.
+ *
+ * More information on writing migrations is available here:
+ * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+ *
+ * The following commands can be used in this method and Phinx will
+ * automatically reverse them when rolling back:
+ *
+ * createTable
+ * renameTable
+ * addColumn
+ * renameColumn
+ * addIndex
+ * addForeignKey
+ *
+ * Remember to call "create()" or "update()" and NOT "save()" when working
+ * with the Table class.
+ */
+ public function change()
+ {
+ $this->table('doctors')
+ ->addColumn('name', 'string')
+ ->addColumn('age', 'integer')
+ ->addColumn('sex', 'string')
+ ->addColumn('status','string')
+ ->addColumn('date','datetime')
+ ->create();
+ }
+}
diff --git a/db/seeds/CountrySeeds.php b/db/seeds/CountrySeeds.php
new file mode 100644
index 0000000..bb4049c
--- /dev/null
+++ b/db/seeds/CountrySeeds.php
@@ -0,0 +1,29 @@
+<?php
+
+
+use Phinx\Seed\AbstractSeed;
+
+class CountrySeeds extends AbstractSeed
+{
+ /**
+ * Run Method.
+ *
+ * Write your database seeder using this method.
+ *
+ * More information on writing seeders is available here:
+ * http://docs.phinx.org/en/latest/seeding.html
+ */
+ public function run()
+ {
+ $country = [];
+
+ $number = 100;
+ for ($i = 0; $i !=$number ; ++$i)
+ {
+ $country[] = [
+ 'name' => faker()->country,
+ ];
+ }
+ $this->insert('country', $country);
+ }
+}
diff --git a/db/seeds/DoctorsSeeds.php b/db/seeds/DoctorsSeeds.php
new file mode 100644
index 0000000..d0856d6
--- /dev/null
+++ b/db/seeds/DoctorsSeeds.php
@@ -0,0 +1,32 @@
+<?php
+
+
+use Phinx\Seed\AbstractSeed;
+
+class DoctorsSeeds extends AbstractSeed
+{
+ /**
+ * Run Method.
+ *
+ * Write your database seeder using this method.
+ *
+ * More information on writing seeders is available here:
+ * http://docs.phinx.org/en/latest/seeding.html
+ */
+ public function run()
+ {
+ $doctors = [];
+ $number = 100;
+ for ($i = 0; $i != $number; ++$i)
+ {
+ $doctors[] = [
+ 'name' => faker()->name(),
+ 'age' => faker()->numberBetween(1,80),
+ 'sex' => rand(1,2) == 1 ? 'M': 'F',
+ 'status' => faker()->text(20),
+ 'date' => faker()->date()
+ ];
+ }
+ $this->insert('doctors', $doctors);
+ }
+}
diff --git a/db/seeds/PatientsSeeds.php b/db/seeds/PatientsSeeds.php
new file mode 100644
index 0000000..a3c62c9
--- /dev/null
+++ b/db/seeds/PatientsSeeds.php
@@ -0,0 +1,31 @@
+<?php
+
+
+use Phinx\Seed\AbstractSeed;
+
+class PatientsSeeds extends AbstractSeed
+{
+ /**
+ * Run Method.
+ *
+ * Write your database seeder using this method.
+ *
+ * More information on writing seeders is available here:
+ * http://docs.phinx.org/en/latest/seeding.html
+ */
+ public function run()
+ {
+ $patients = [];
+ $number = 100;
+ for ($i = 0; $i != $number; ++$i)
+ {
+ $patients[] = [
+ 'name' => faker()->name(),
+ 'age' => faker()->numberBetween(1,80),
+ 'sex' => rand(1,2) == 1 ? 'M': 'F',
+ 'status' => faker()->text(20)
+ ];
+ }
+ $this->insert('patients', $patients);
+ }
+}
diff --git a/db/seeds/WorksSeeds.php b/db/seeds/WorksSeeds.php
new file mode 100644
index 0000000..3628675
--- /dev/null
+++ b/db/seeds/WorksSeeds.php
@@ -0,0 +1,35 @@
+<?php
+
+
+use Phinx\Seed\AbstractSeed;
+
+class WorksSeeds extends AbstractSeed
+{
+ /**
+ * Run Method.
+ *
+ * Write your database seeder using this method.
+ *
+ * More information on writing seeders is available here:
+ * http://docs.phinx.org/en/latest/seeding.html
+ */
+ public function run()
+ {
+ $country = [];
+
+ $number = 100;
+ for ($i = 0; $i != $number ; ++$i)
+ {
+ $country[] = [
+ 'name' => faker()->name,
+ 'age' => faker()->numberBetween(1,100),
+ 'phone' => faker()->randomNumber(8),
+ 'sex' => faker()->firstNameMale,
+ 'status' => faker()->text(20),
+ 'days' => faker()->date(),
+ 'date' => faker()->date(),
+ ];
+ }
+ $this->insert('works', $country);
+ }
+}
diff --git a/documentations/BASE.md b/documentations/BASE.md
new file mode 100644
index 0000000..ec30870
--- /dev/null
+++ b/documentations/BASE.md
@@ -0,0 +1,22 @@
+# Base methods
+
+| Name | Do | Arguments | Return |
+|-----------------------|-------------------------------------------|-----------------------------------|---------------|
+| show | get all databases in server | void | array |
+| create | create a database | void | bool |
+| setEncodingOptions | set the encoding options | string $conf | Base |
+| setEncoding | set the encoding preference | string $encoding | Base |
+| setCollation | set database collation | string $collation | Base |
+| setDriver | set database driver | string $driver | Base |
+| setPassword | set password | string $password | Base |
+| setUser | set username | string $username | Base |
+| setName | set database name | string $name | Base |
+| drop | delete a database | void | bool |
+| dump | dump a database | void | mixed |
+| exist | verify if a database exist | void | bool |
+| getCharset | get all database characters | void | array |
+| getCollation | get all database collation | void | array |
+| setHidden | define hidden databases | array $databases | Base |
+| manage | start query builder | void | Base |
+| getInstance | get a pdo instance | void | PDO|null |
+| setDumpDirectory | define the dump directory path | string $path | Base |
diff --git a/documentations/DUMPER.md b/documentations/DUMPER.md
new file mode 100644
index 0000000..23a06ee
--- /dev/null
+++ b/documentations/DUMPER.md
@@ -0,0 +1,43 @@
+# Dumper
+
+```php
+
+ /**
+ * dump a database or a table
+ *
+ * @param string $driver
+ * @param string $username
+ * @param string $password
+ * @param string $database
+ * @param string $dumpPath
+ * @param int $mode
+ * @param string $table
+ *
+ * @return bool
+ */
+ dumper(string $driver, string $username, string $password, string $database, string $dumpPath, int $mode = Eloquent::MODE_DUMP_DATABASE, string $table ='')
+
+ // dump a database
+
+ dumper('mysql', 'username','password', 'database', 'dump');
+
+ dumper('pgsql', 'username','password', 'database', 'dump');
+
+ dumper('sqlite', '','', 'database', 'dump');
+
+ // dump a table
+
+ dumper('mysql', 'username','password', 'database', 'dump',Eloquent::MODE_DUMP_TABLE,'table);
+
+ dumper('pgsql', 'username','password', 'database', 'dump',Eloquent::MODE_DUMP_TABLE,'table');
+
+ dumper('sqlite', '','', 'database', 'dump',Eloquent::MODE_DUMP_TABLE,'table');
+
+
+ $tables = table(Connexion::MYSQL,'database','username','secure,'dump');
+
+ $tables->dump('users'); // dump table users
+
+
+
+```
diff --git a/documentations/FILE.md b/documentations/FILE.md
new file mode 100644
index 0000000..2706990
--- /dev/null
+++ b/documentations/FILE.md
@@ -0,0 +1,64 @@
+# File management system
+
+# Methods static
+
+| Name | Do | Arguments | Return |
+|-----------------------|-------------------------------------------|-----------------------------------|---------------|
+| hash | Get the MD5 hash of the file | string $filename | string |
+| lastModified | Get the file's last modification time | string $filename | bool|int |
+| download | download a file | string $filename | bool|int |
+| search | search files likes a pattern | string $pattern int $flag | array |
+| create | create a file is not exist | string filename | bool |
+| delete | delete a file or a folder if exist | string filename | bool |
+| deleteFolder | delete a folder if exist | string $folder | bool |
+| getLines | get all lines in a file | string $filename, string $mode | array |
+| getKeys | get all keys in a file | string multiples | array |
+| getValues | get all values in a file | string multiples | array |
+| copyFolder | copy a folder to destination | string multiples | void |
+| copy | copy a source to destination | string multiples | bool |
+| isReadable | check if a file or a folder is readable | string $filename | bool |
+| isWritable | check if a file or a folder is writable | string $filename | bool |
+| hardLink | create a hard link | string multiples | bool |
+| symlink | create a symlink link | string multiples | bool |
+| isLink | check if filename is a symlink | string $filename | bool |
+| getMime | get the mime of file | string $filename | string |
+| getStat | get the file's info | string $filename | array |
+| getStartKey | get a part of stat by a key | string multiples | string |
+| write | write data on a file | string multiples | bool |
+| isFile | check if filename is a file | string $filename | bool |
+| isImg | check if filename is an image | string $filename | bool |
+| isHtml | check if filename is a html file | string $filename | bool |
+| isPhp | check if filename is a php file | string $filename | bool |
+| isJS | check if filename is a js file | string $filename | bool |
+| isJson | check if filename is a json file | string $filename | bool |
+| isXml | check if filename is a xml file | string $filename | bool |
+| isCss | check if filename is a css file | string $filename | bool |
+| isPdf | check if filename is a pdf file | string $filename | bool |
+| isEnd | check if is the end of file | string $filename | bool |
+| getGroup | get the group of the file | string $filename | int |
+| getOwner | get the owner of the file | string $filename | int |
+| loads |include all file passed in parameters | string multiples | void |
+| getContent | get content in a file | string $filename | string |
+| putContents | write data on a file | string $filename | bool |
+| getFile | get super global $_FILES | void | $_FILES |
+| uploadedFileType | get uploaded file type | string $inputName | string |
+| uploadedFileSize | get uploaded file sie | string $inputName | int |
+| uploadedFileName | get uploaded file name | string $inputName | string |
+| uploadedFileTmpPath | get uploaded file tmp path | string $inputName | string |
+| uploadedFileErrors | get uploaded file tmp error | string $inputName | int |
+| moveUploadedFile | move a uploaded file to destination | string multiples | bool |
+| rename | rename a file | string multiples | bool |
+| verify | verify a file exist and if is a file | string $filename | bool |
+| exist | verify a file exist | string $filename | bool |
+| open | open a file with a mode | string multiple | resource |
+| isEmptyArgs | check if function argument is empty | void | bool |
+| close | close a file | resource $file | bool |
+| realPath | get absolute path | resource $file | string |
+| chmod | Changes file mod | string multiples | bool |
+| chgrp | Changes file group | string multiples | bool |
+| lchgrp | Changes group ownership of symlink | string multiples | bool |
+| chown | Changes file owner | string multiples | bool |
+| isExecutable | Tells whether the filename is executable | string $filename | bool |
+| getType | gets file type | string $filename | string |
+| fileTime | gets last access time of file | string $filename | int |
+| fileOwner | gets file owner | string $filename | int | \ No newline at end of file
diff --git a/documentations/FORM.md b/documentations/FORM.md
new file mode 100644
index 0000000..ab59ad6
--- /dev/null
+++ b/documentations/FORM.md
@@ -0,0 +1,47 @@
+# A form builder
+
+```php
+ /**
+ * @param int $type
+ *
+ * @return Form|null
+ */
+ form(int $type);
+
+ $form = form(Form::BOOTSTRAP || Form::FOUNDATION)
+ ->start('action')
+ ->method()
+ ->method()
+ ->end();
+
+```
+
+
+# Methods
+
+| Name | Do | Arguments | Return |
+|-----------------------|---------------------------------------|---------------------------|---------------|
+| create | start form builder | string multiple | Form |
+| startHide | start hidden input | void | Form |
+| endHide | close hidden input | void | Form |
+| file | add a file input | string multiples | Form |
+| input | add an input | string multiples | Form |
+| setType | set form type | int $type | Form |
+| twoInlineInput | add two inline input | string multiples | Form |
+| csrf | add csrf token in form | string $csrf | Form |
+| button | add a button | string multiples | Form |
+| reset | add a reset button | string multiples | Form |
+| textarea | add a textarea | string multiples | Form |
+| img | add an image | string multiples | Form |
+| submit | add a submit button | string multiples | Form |
+| link | add a link button | string multiples | Form |
+| select | add a select input | string multiples | Form |
+| twoInlineSelect | add two inline select | string multiples | Form |
+| checkbox | add a checkbox | string multiples | Form |
+| radio | add a radio | string multiples | Form |
+| end | close and return form | void | string |
+| redirectSelect | add a redirect select | string multiples | Form |
+| twoRedirectSelect | add two redirect select | string multiples | Form |
+| oneSelectAndOneInput | add one select and one input | string multiples | Form |
+| oneInputAndOneSelect | add one input and one select | string multiples | Form |
+ \ No newline at end of file
diff --git a/documentations/HELPERS.md b/documentations/HELPERS.md
new file mode 100644
index 0000000..d584d0f
--- /dev/null
+++ b/documentations/HELPERS.md
@@ -0,0 +1,839 @@
+# Helpers
+
+```php
+
+ /**
+ * connect to a database
+ *
+ * @param string $driver
+ * @param string $database
+ * @param string $username
+ * @param string $password
+ *
+ * @return null|PDO
+ */
+ connect(string $driver,string $database = '',string $username = '',$password = '') : ?PDO
+
+ /**
+ * update user password
+ *
+ * @param string $driver
+ * @param string $username
+ * @param string $currentPassword
+ * @param string $newPassword
+ *
+ * @return bool
+ */
+ pass(string $driver,string $username,string $currentPassword,string $newPassword) : bool
+
+ /**
+ * manage users
+ *
+ * @param string $driver
+ * @param string $username
+ * @param string $password
+ * @param array $hidden
+ *
+ * @return Users
+ */
+ user(string $driver,string $username,string $password,array $hidden = []) : Users
+
+ /**
+ * manage database
+ *
+ * @param string $driver
+ * @param string $base
+ * @param string $username
+ * @param string $password
+ * @param string $dumpPath
+ * @param array $hidden
+ *
+ * @return Base
+ */
+ base(string $driver,string $base,string $username,string $password,string $dumpPath,array $hidden = [])
+
+ /**
+ * show databases, users, tables
+ *
+ * @param string $driver
+ * @param string $database
+ * @param string $username
+ * @param string $password
+ * @param array $hidden
+ * @param int $mode
+ *
+ * @return array
+ */
+ show(string $driver,string $database,string $username,string $password,int $mode = Eloquent::MODE_ALL_DATABASES,array $hidden = []) : array
+
+ /**
+ * create a new user
+ *
+ * @param string $driver
+ * @param string $user
+ * @param string $password
+ * @param string $rights
+ * @param PDO $connexion
+ *
+ * @return bool
+ */
+ userAdd(string $driver,string $user,string $password,string $rights,PDO $connexion): bool
+
+ /**
+ * delete an user
+ *
+ * @param string $driver
+ * @param string $user
+ * @param PDO $connexion
+ *
+ * @return bool
+ */
+ userDel(string $driver,string $user,PDO $connexion): bool
+
+ /**
+ * get all charset
+ *
+ * @param string $driver
+ * @param PDO $connexion
+ *
+ * @return array
+ */
+ charset(string $driver,PDO $connexion): array
+
+ /**
+ * get all collation
+ *
+ * @param string $driver
+ * @param PDO $connexion
+ *
+ * @return array
+ */
+ collation(string $driver,PDO $connexion): array
+
+ /**
+ * create a new database
+ *
+ * @param string $driver
+ * @param string $database
+ * @param string $charset
+ * @param string $collation
+ * @param PDO $connexion
+ *
+ * @return bool
+ */
+ create(string $driver,string $database,string $charset,string $collation,PDO $connexion): bool
+
+ /**
+ * manage tables
+ *
+ * @param string $driver
+ * @param string $database
+ * @param string $username
+ * @param string $password
+ *
+ * @param string $dumpPath
+ *
+ * @return Table
+ */
+ table(string $driver,string $database,string $username,string $password,string $dumpPath): Table
+
+ /**
+ * dump a database or a table
+ *
+ * @param string $driver
+ * @param string $username
+ * @param string $password
+ * @param string $database
+ * @param string $dumpPath
+ * @param int $mode
+ * @param string $table
+ *
+ * @return bool
+ */
+ dumper(string $driver, string $username, string $password, string $database, string $dumpPath, int $mode = Eloquent::MODE_DUMP_DATABASE, string $table ='')
+
+ /**
+ * build pagination
+ *
+ * @param int $perPage
+ * @param string $instance
+ *
+ * @return Paginator
+ */
+ paginate(int $perPage,string $instance): Paginator
+
+ /**
+ * @param int $type
+ *
+ * @return Form|null
+ */
+ form(int $type)
+
+ /**
+ * get an instance of faker
+ *
+ * @param string $locale
+ *
+ * @return \Faker\Generator
+ */
+ faker(string $locale = 'en_US' ): Faker\Generator
+
+ /**
+ * generate a fa icon
+ *
+ * @param string $icon
+ * @param string $options
+ *
+ * @return string
+ */
+ fa(string $icon, string $options = ''): string
+
+ /**
+ * generate a link icon group area
+ *
+ * @param array $icons
+ * @param array $urls
+ * @param array $text
+ * @param array $options
+ * @param array $class
+ *
+ * @param string $containerClass
+ *
+ * @return null|string
+ */
+ faGroup(array $icons, array $urls ,array $text, array $options, array $class, string $containerClass = 'list-group')
+
+ /**
+ * generate a iconic icon
+ *
+ * @param string $type
+ * @param string $icon
+ * @param string $viewBox
+ *
+ * @return string
+ */
+ iconic(string $type,string $icon,$viewBox = '0 0 8 8'): string
+
+ /**
+ * generate a glyph icon
+ *
+ * @param string $icon
+ * @param string $type
+ *
+ * @return string
+ */
+ glyph(string $icon,$type = 'svg'): string
+
+ /**
+ * see os
+ *
+ * @param bool $name
+ *
+ * @return Os|string
+ */
+ os(bool $name = false)
+
+ /**
+ * get operating system
+ *
+ * @return string
+ */
+ getOs(): string
+
+ /**
+ * see devices
+ *
+ * @param bool $name
+ *
+ * @return string|Device
+ */
+ device(bool $name = false)
+
+ /**
+ * get device
+ *
+ * @return string
+ */
+ getDevice(): string
+
+ /**
+ * see browser
+ *
+ * @param bool $name
+ *
+ * @return Browser|string
+ */
+ browser(bool $name = false)
+
+ /**
+ * get browser name
+ *
+ * @return string
+ */
+ getBrowser(): string
+
+ /**
+ * check if is name is browser
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+ isBrowser(string $name): bool
+
+ /**
+ * check if device is mobile
+ *
+ * @return bool
+ */
+ isMobile(): bool
+
+ /**
+ * generate a join clause
+ *
+ * @param int $type
+ * @param string $firstTable
+ * @param string $secondTable
+ * @param string $firstParam
+ * @param string $secondParam
+ * @param array $firstColumns
+ * @param string $condition
+ *
+ * @return Query
+ */
+ joins(int $type,string $firstTable,string $secondTable,string $firstParam,string $secondParam,array $firstColumns = [], string $condition ='='): Query
+
+ /**
+ * generate a union clause
+ *
+ * @param int $mode
+ * @param string $firstTable
+ * @param string $secondTable
+ * @param array $firstColumns
+ * @param array $secondColumns
+ *
+ * @return Query
+ */
+ union(int $mode,string $firstTable,string $secondTable,array $firstColumns,array $secondColumns): Query
+
+ /**
+ * sql table builder
+ *
+ * @param string $table
+ *
+ * @return Query
+ */
+ sql(string $table): Query
+
+ /**
+ * get all lines in filename
+ *
+ * @param string $filename
+ *
+ * @return array
+ */
+ getLines(string $filename): array
+
+ /**
+ * get all keys in filename
+ *
+ * @param string $filename
+ * @param string $delimiter
+ *
+ * @return array
+ */
+ getKeys(string $filename,string $delimiter): array
+
+ /**
+ * get all values in filename
+ *
+ * @param string $filename
+ * @param string $delimiter
+ *
+ * @return array
+ */
+ getValues(string $filename,string $delimiter): array
+
+ /**
+ * get the current git branch
+ *
+ * @param string $repository
+ *
+ * @return string
+ */
+ getCurrentBranch(string $repository): string
+
+ /**
+ * manage git repository
+ *
+ * @param string $repository
+ *
+ * @return GitRepository
+ */
+ git(string $repository): GitRepository
+
+ /**
+ * check if a code is valid
+ *
+ * @param string $secret
+ * @param string $code
+ *
+ * @return bool|int
+ * @throws OauthExceptions
+ */
+ checkCode(string $secret,string $code)
+
+ /**
+ * generate Qr code
+ *
+ * @param string $company
+ * @param string $username
+ * @param string $secret
+ *
+ * @throws OauthExceptions
+ * @return string
+ */
+ generateQrCode(string $company,string $username,string $secret) : string
+
+ /**
+ * generate secret two factor key
+ *
+ * @return string
+ */
+ generateKey() : string
+
+ /**
+ * load a css file
+ *
+ * @param string $url
+ *
+ * @return string
+ */
+ cssLoader(string $url): string
+
+ /* load a js file
+ *
+ * @param string $url
+ * @param string $type
+ *
+ * @return string
+ */
+ jsLoader(string $url,string $type = 'text/javascript'): string
+
+ /**
+ * manage image
+ *
+ * @param string $driver
+ *
+ * @return ImageManager
+ */
+ image(string $driver): ImageManager
+
+ /**
+ * Create a new future date.
+ *
+ * @param \DateTimeZone|string|null $tz
+ * @param string $mode
+ * @param int $time
+ *
+ * @return string
+ */
+ future(string $mode,int $time,$tz = null): string
+
+ /**
+ * Create a new Carbon instance for the current date.
+ *
+ * @param \DateTimeZone|string|null $tz
+ * @return Carbon
+ */
+ now($tz = null): Carbon
+
+ /**
+ * Create a new Carbon instance for the current date.
+ *
+ * @param \DateTimeZone|string|null $tz
+ * @return Carbon
+ */
+ today($tz = null): Carbon
+
+ /**
+ * return time based on a time
+ *
+ * @param string $locale
+ * @param string $time
+ * @param null $tz
+ *
+ * @return string
+ */
+ ago(string $locale,string $time,$tz = null): string
+
+ /**
+ * execute a query return a boolean
+ *
+ * @param PDO $instance
+ * @param string $request
+ * @return bool
+ */
+ execute(PDO $instance,string $request): bool
+
+ /**
+ * execute a query return an array with results
+ *
+ * @param PDO $instance
+ * @param string $request
+ * @param int $fetchStyle
+ *
+ * @return array
+ */
+ req(PDO $instance,string $request,int $fetchStyle = PDO::FETCH_OBJ): array
+
+ /***
+ * generate a table with record pagination and search field
+ *
+ * @param string $class
+ * @param Table $instance
+ * @param string $table
+ * @param string $editPrefix
+ * @param string $deletePrefix
+ * @param string $orderBy
+ * @param string $editText
+ * @param string $deleteText
+ * @param string $editClass
+ * @param string $deleteClass
+ * @param string $editIcon
+ * @param string $deleteIcon
+ * @param int $limit
+ * @param int $current
+ * @param string $paginationUrl
+ * @param PDO $pdo
+ * @param int $formType
+ * @param string $placeholder
+ * @param string $paginationPositionClass
+ *
+ * @return string
+ */
+ records(string $class, Table $instance,string $table,string $editPrefix, string $deletePrefix,string $orderBy,string $editText,string $deleteText,string $editClass,string $deleteClass,string $editIcon,string $deleteIcon,int $limit,int $current,string $paginationUrl,PDO $pdo,int $formType,string $placeholder,string $paginationPositionClass =''): string
+
+ /**
+ * generate a form to edit or create a record
+ *
+ * @param int $type
+ * @param string $class
+ * @param string $action
+ * @param string $table
+ * @param Table $instance
+ * @param string $submitText
+ * @param string $submitClass
+ * @param string $submitIcon
+ * @param int $mode
+ * @param int $id
+ *
+ * @return string
+ */
+ generate(int $type,string $class,string $action,string $table,Table $instance,string $submitText,string $submitClass,string $submitIcon,int $mode = Form::CREATE,int $id = 0): string
+
+ /**
+ * get a $_GET value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ get(string $key): string
+
+ /**
+ * get a $_POST value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ post(string $key): string
+
+ /**
+ * get a $_SERVER value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ server(string $key): string
+
+ /**
+ * get a $_FILE value
+ *
+ * @param string $key
+ *
+ * @return mixed
+ */
+ file(string $key)
+
+ /**
+ * push one or more elements onto the end of array
+ *
+ * @param array $array
+ * @param mixed $value
+ *
+ * @return int
+ */
+ function push(array &$array,mixed $value): int
+
+ /**
+ * pop the element off the end of array
+ *
+ * @param array $array
+ *
+ * @return mixed
+ */
+ function pop(array &$array)
+
+ /**
+ * checks if a value exists in an array
+ *
+ * @param mixed $needle
+ * @param array $array
+ *
+ * @param bool $mode
+ *
+ * @return mixed
+ */
+ function has(mixed $needle,array &$array,bool $mode = false)
+
+ /**
+ * Return all the values of an array
+ *
+ * @param array $array
+ *
+ * @return array
+ */
+ function values(array &$array): array
+
+ /**
+ * Return all the values of an array
+ *
+ * @param array $array
+ * @param null $search_value
+ * @param null $strict
+ *
+ * @return array
+ */
+ function keys(array $array, $search_value = null, $strict = null): array
+
+ /**
+ * get a $_SESSION value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ function session(string $key): string
+
+ /**
+ * get a $_COOKIE value
+ *
+ * @param string $key
+ *
+ * @return string
+ */
+ function cookie(string $key): string
+
+ /**
+ * generate bootswatch css link
+ *
+ * @param string $theme
+ * @param string $version
+ *
+ * @return string
+ */
+ bootswatch(string $theme,string $version = '4.0.0'): string
+
+ /**
+ * restore a database
+ *
+ * @param Base $instance
+ * @param string $base
+ * @param string $sqlFile
+ *
+ * @return bool
+ */
+ restore(Base $instance,string $base,string $sqlFile): bool
+```
+# Examples
+
+```php
+
+ if(pass('mysql','root','secure','root'))
+ {
+ // password updated
+ } else {
+ // password not updated
+ }
+
+ if(pass('pgsql','postgres','secure','postgres'))
+ {
+ // password updated
+ } else {
+ // password not updated
+ }
+
+ // Show mysql databases
+
+ $base = base('mysql','root','secure','dump');
+
+ foreach($base->show() as $item)
+ {
+ echo $item
+ }
+
+
+ $pdo = connect('mysql','','root','secure');
+
+ // execute a statement and return an array
+ $databases = sql()->setPdo($pdo)->request("SHOW DATABASES")
+
+ // execute a statement and return a boolean
+ $result = sql()->setPdo($pdo)->query("CREATE DATABASE IF NOT EXIST $database");
+
+ if($result)
+ {
+ // database created
+ }
+
+ $users = sql('users')->setPdo($pdo)->getRecords();
+
+ $totalOfUsers = sql('users')->setPdo($pdo)->count();
+
+ $user = sql('users')->where('id','=',1)->setPdo($pdo)->getRecords();
+
+ $users = sql('users')->orderBy('id')->setPdo($pdo)->getRecords();
+
+ if(create('mysql','imperium','utf8','utf8_general_ci',$pdo))
+ {
+ // database created successfully
+ }
+
+ // or more simply
+
+ foreach(show('mysql', 'root','secure') as $base)
+ {
+ echo $base;
+ }
+
+ // show helper
+
+ // get all mysql users
+ $users = show('mysql','judo','root','root', Eloquent::MODE_ALL_USERS)
+
+ // get all mysql databases
+ $databases = show('mysql','judo','root','root',Eloquent::MODE_ALL_DATABASES)
+
+ // get all table in a mysql database
+ $tables = show('mysql','judo','root','root',Eloquent::MODE_ALL_TABLES)
+
+ $users = user('mysql','root','secure');
+
+ foreach($users->show() as $user)
+ {
+ echo $user
+ }
+
+ foreach(show('mysql','judo','root','root', Eloquent::MODE_ALL_USERS) as $user)
+ {
+ echo $user;
+ }
+ // dump a mysql database
+
+ dump(Connexion::MYSQL,'root','secure','database','dump');
+
+ // dump a postgresql database
+
+ dump(Connexion::POSTGRESQL,'postgres','secure','database','dump');
+
+ // dump a mysql table
+
+ dump(Connexion::MYSQL,'root','secure','database','dump',Eloquent::MODE_DUMP_TABLE,'table');
+
+ // dump a postgresql table
+
+ dump(Connexion::POSTGRESQL,'postgres','secure','database','dump',Eloquent::MODE_DUMP_TABLE,'table');
+
+ $instance = "/table/$table";
+
+ $pages = paginate($perPage,$instance)->set_pageIdentifierFromGet($current)->set_total($total);
+
+ $pagination = $pages->page_links(null);
+
+ $records = sql($table)->setPdo($pdo)->setPaginationLimit($pages)->getRecords();
+
+ foreach($records as $record)
+ {
+ echo $record->property
+ }
+
+ echo $pagination
+```
+
+# Laravel
+
+```php
+
+ namespace App\Http\Controller;
+
+ class DatabaseController extends Controller
+ {
+ private $driver;
+
+ private $charset;
+
+ private $collation;
+
+ private $pdo;
+
+ private $base;
+
+ public function __construct()
+ {
+ $this->driver = env('DB_CONNECTION');
+ $database = env('DB_DATABASE');
+ $username = env('DB_USERNAME');
+ $password = env('DB_PASSWORD');
+
+ $this->pdo = connect($this->driver,$database,$username,$password);
+ $this->base = base($this->driver,$database,$username,public_path('../dump'));
+ $this->collation = collation($this->driver,$this->pdo);
+ $this->charset = charset($this->driver,$this->pdo);
+ }
+
+ public function addUser(Request $request)
+ {
+ $user = $request->get('user');
+ $password = $request->get('password');
+ $rights = $request->get('rights');
+
+ if(userAdd($this->driver,$user,$password,$rights,$this->pdo))
+ {
+ // user was added
+ return redirect('/')->with('success',"$user was added successfully");
+ }
+ return redirect('/')->with('error',"Creation of user $user has failed");
+ }
+
+ public function delUser(Request $request)
+ {
+ $user = $request->get('user');
+
+ if(userDel($this->driver,$user,$this->pdo))
+ {
+ // user was removed
+ return redirect('/')->with('success',"$user was removed successfully");
+ }
+ return redirect('/')->with('error',"Deletion of user $user has failed");
+ }
+
+ public function showDatabase()
+ {
+ $databases = $this->base->show();
+ return view('database.show',compact('databases'));
+ }
+ }
+``` \ No newline at end of file
diff --git a/documentations/QUERY.md b/documentations/QUERY.md
new file mode 100644
index 0000000..b85dc2c
--- /dev/null
+++ b/documentations/QUERY.md
@@ -0,0 +1,73 @@
+# SQL Query builder
+
+```php
+
+ /**
+ * sql query builder
+ *
+ * @param string $table
+ *
+ * @return Query
+ */
+ sql(string $table = ''): Query
+
+ // SELECT * FROM users
+ $users = sql('users')->setPdo($pdo)->getRecords();
+ $users = sql()->setTable('users')->setPdo($pdo)->getRecords();
+
+ // SELECT * FROM users WHERE id = 1
+ $user = sql('users')->setPdo($pdo)->where('id','=',1)->getRecords();
+
+ // SELECT COUNT(*) FROM users
+ $numberOfUsers = sql('users')->setPdo($pdo)->count();
+
+ // SELECT * FROM articles ORDER BY id DESC
+ $articles = sql('articles')->setPdo($pdo)->orderBy('id')->getRecords();
+
+ // SELECT * FROM articles ORDER BY id ASC
+ $articles = sql('articles')->setPdo($pdo)->orderBy('id','ASC')->getRecords();
+
+ // SELECT * FROM articles ORDER BY id ASC LIMIT 4 OFFSET 2
+ $articles = sql('articles')->setPdo($pdo)->orderBy('id','ASC')->limit(4,2)->getRecords();
+
+ // DELETE FROM articles WHERE id = 200
+ $deleted = sql('articles')->setPdo($pdo)->setMode('DELETE' || Query::DELETE )->where('id','=',200)->delete();
+
+ // DELETE FROM articles WHERE id > 3
+ $deleted = sql('articles')->setPdo($pdo)->setMode('DELETE' || Query::DELETE )->where('id','>',3)->delete();
+
+ // SELECT name,email FROM users
+ $users = sql('users')->setPdo($pdo)->setColumns(['name','email'])->getRecords();
+
+ // SELECT name,email FROM users ORDER BY id DESC
+ $users = sql('users')->setPdo($pdo)->setColumns(['name','email'])->orderBy('id')->getRecords();
+
+ // Execute a custom query
+
+ $created = sql()->setPdo($pdo)->query("CREATE DATABASE $database');
+ $databases = sql()->setPdo($pdo)->request("SHOW DATABASES');
+```
+
+# Methods
+
+| Name | Do | Arguments | Return |
+|-----------------------|---------------------------------------|---------------------------|---------------|
+| start | start query builder | void | Query |
+| setPdo | define pdo instance | PDO $pdo | Query |
+| count | count number of records | void | int |
+| getRecords | get all records | void | array |
+| setMode | define the mode | string $mode(SELECT) | Query |
+| delete | run a delete query | void | bool |
+| query | execute a statement | string $statement | bool |
+| request | execute a statement | string $statement | array |
+| limit | define a limit and an offset | int $limit int $offset | Query |
+| setTable | define the table name | string $table | Query |
+| setPaginationLimit | define pagination limit | string $table | Query |
+| setColumns | define columns to select | array $columns | Query |
+| get | get the sql query | void | string |
+| where | define the where clause | string multiples | Query |
+| orderBy | define the order by clause | string multiples | Query |
+| join | define the join clause | multiples | Query |
+| union | define the union clause | multiples | Query |
+| execute | execute the generated statement | void | bool |
+
diff --git a/documentations/TABLE.md b/documentations/TABLE.md
new file mode 100644
index 0000000..6fb5076
--- /dev/null
+++ b/documentations/TABLE.md
@@ -0,0 +1,73 @@
+# A table builder
+
+```php
+
+ /**
+ * manage tables
+ *
+ * @param string $driver
+ * @param string $database
+ * @param string $username
+ * @param string $password
+ *
+ * @return Table
+ */
+ table(string $driver,string $database,string $username,string $password): Table
+
+ $tables = table('mysql','database','username','password'): Table
+
+ //check if database as a table
+
+ if($tables->has())
+ {
+ // has table
+ // show table
+ foreach ($tables->show() as $table)
+ {
+ echo $table
+ }
+ }
+```
+
+# Methods
+
+| Name | Do | Arguments | Return |
+|-------------------|-------------------------------------------|-----------------------|---------------|
+| manage | start query builder | void | Table |
+| setHidden | define table to ignore | array $tables | Table |
+| setName | define current table name | string $name | Table |
+| setNewName | define new table name | string $name | Table |
+| rename | rename a table | string $name | bool |
+| has | check if database has table | void | bool |
+| hasColumn | check if column exist in table | string $column | bool |
+| getColumnsTypes | get types of columns in a table | void | array |
+| getColumns | get all columns in a table | void | array |
+| drop | Delete a table | void | bool |
+| truncate | Truncate a table or all tables | int $mode | bool |
+| addField | add a field in table creation | multiples | Table |
+| addColumn | add a column in an existing table | multiples | Table |
+| create | create table | string $engine(null) | bool |
+| dump | dump a table | void | bool |
+| primaryKey | get the primary key of a table | void | string|null |
+| isEmpty | check if a table is empty | void | bool |
+| selectById | select a record by id | int $id | array |
+| deleteById | delete a record by id | int $id | bool |
+| renameColumn | rename a column | string multiple | bool |
+| deleteColumn | delete a column | string $column | bool |
+| exist | check if a table exist | void | bool |
+| insert | insert data in a table | array $values | bool |
+| ignore | define the tables to ignore | array $tables | Table |
+| setDumpPath | define the dump directory path | string $path | Table |
+| show | get all tables in current database | void | array |
+| count | count records in a table or all tables | int $mode | int|array |
+| setDriver | Set driver | string $driver | Table |
+| setDatabase | Set database name | string $database | Table |
+| setUsername | Set username | string $username | Table |
+| setPassword | Set username password | string $password | Table |
+| exec | execute a statement | string $statement | bool |
+| request | execute a statement | string $statement | array |
+| getRecords | get all records in a table | void | array |
+| countTable | count the number of tables in database | void | int |
+| optimize | optimize a table | void | bool |
+| modifyColumn | modify an existing column | string multiples | bool |
+| setEngine | define the engine | string $engine | bool |
diff --git a/grumphp.yml b/grumphp.yml
new file mode 100644
index 0000000..0b70a3f
--- /dev/null
+++ b/grumphp.yml
@@ -0,0 +1,9 @@
+parameters:
+ bin_dir: "./vendor/bin"
+ git_dir: "."
+ tasks:
+ phpunit: ~
+ phplint: ~
+ ascii:
+ failed: ~
+ succeeded: ~ \ No newline at end of file
diff --git a/imperium/Auth/Exceptions/OauthExceptions.php b/imperium/Auth/Exceptions/OauthExceptions.php
new file mode 100644
index 0000000..b50e8a1
--- /dev/null
+++ b/imperium/Auth/Exceptions/OauthExceptions.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * fumseck added OauthExceptions.php to imperium
+ * The 09/09/17 at 17:05
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Auth\Exceptions {
+
+ use Exception;
+
+ class OauthExceptions extends Exception
+ {
+ /**
+ * throw an exception if code digits length is not equal to 6
+ *
+ * @return static
+ */
+ public static function codeLengthIncorrect()
+ {
+ return new static('the length of the code must be 6 digits');
+ }
+
+ public static function invalidSecretCode()
+ {
+ return new static('Invalid secret code');
+ }
+ }
+}
diff --git a/imperium/Auth/Oauth.php b/imperium/Auth/Oauth.php
new file mode 100644
index 0000000..33415b4
--- /dev/null
+++ b/imperium/Auth/Oauth.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * fumseck added Oauth.php to imperium
+ * The 09/09/17 at 14:59
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Auth {
+
+ use PragmaRX\Google2FA\Google2FA;
+
+ class Oauth
+ {
+ /**
+ * generate a secret key
+ *
+ * @return string
+ */
+ public static function generateSecret(): string
+ {
+ if (function_exists('generateKey'))
+ return generateKey();
+ else
+ return (new Google2FA())->generateSecretKey();
+ }
+
+ /**
+ * check if code is valid
+ *
+ * @param string $secret
+ * @param string $code
+ *
+ * @return bool
+ */
+ public static function checkCode(string $secret,string $code): bool
+ {
+ if (function_exists('checkCode'))
+ return checkCode($secret,$code);
+ else
+ return (new Google2FA())->verifyKey($secret,$code);
+ }
+
+ /**
+ * generate Qr code
+ *
+ * @param string $company
+ * @param string $username
+ * @param string $secret
+ *
+ * @param int $size
+ * @return string
+ */
+ public static function generateQrCode(string $company, string $username, string $secret,int $size = 200): string
+ {
+ if (function_exists('generateQrCode'))
+ return generateQrCode($company,$username,$secret,$size);
+
+ return (new Google2FA())->getQRCodeGoogleUrl($company,$username,$secret,$size);
+ }
+ }
+}
diff --git a/imperium/Databases/Core/ConnexionManagement.php b/imperium/Databases/Core/ConnexionManagement.php
new file mode 100644
index 0000000..30778c1
--- /dev/null
+++ b/imperium/Databases/Core/ConnexionManagement.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * fumseck added ConnexionBuilder.php to imperium
+ * The 11/09/17 at 06:18
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+namespace Imperium\Databases\Core {
+
+
+ use Imperium\Databases\Eloquent\Connexion\Connexion;
+
+ interface ConnexionManagement
+ {
+ /**
+ * start connection
+ *
+ * @return Connexion
+ */
+ public static function connect(): Connexion;
+
+ /**
+ * set type of database
+ *
+ * @param string $driver
+ *
+ * @return Connexion
+ */
+ public function setDriver(string $driver): Connexion;
+
+ /**
+ * define username
+ *
+ * @param string $username
+ *
+ * @return Connexion
+ */
+ public function setUser(string $username): Connexion;
+
+ /**
+ * define database name
+ *
+ * @param string $database
+ *
+ * @return Connexion
+ */
+ public function setDatabase(string $database): Connexion;
+
+ /**
+ * set password
+ *
+ * @param string $password
+ *
+ * @return Connexion
+ */
+ public function setPassword(string $password): Connexion;
+
+ /**
+ * set database encoding
+ *
+ * @param string $encoding
+ *
+ * @return Connexion
+ */
+ public function setEncoding(string $encoding): Connexion;
+
+ /**
+ *
+ *
+ * @return null|\PDO
+ */
+ public function getMysqlConnection();
+
+ /**
+ * @return \PDO|null
+ */
+ public function getPostgresqlConnection();
+
+ /**
+ * @return \PDO|null
+ */
+ public function getSqliteConnection();
+
+ /**
+ * get the connexion
+ *
+ * @return \PDO|null
+ */
+ public function getConnexion();
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Core/DatabasesManagement.php b/imperium/Databases/Core/DatabasesManagement.php
new file mode 100644
index 0000000..10f09ce
--- /dev/null
+++ b/imperium/Databases/Core/DatabasesManagement.php
@@ -0,0 +1,199 @@
+<?php
+/**
+ * fumseck added DatabasesManagement.php to imperium
+ * The 11/09/17 at 09:36
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+
+namespace Imperium\Databases\Core {
+
+
+ use Imperium\Databases\Eloquent\Bases\Base;
+ use Imperium\Databases\Exception\IdentifierException;
+ use PDO;
+
+ interface DatabasesManagement
+ {
+ /**
+ * show databases
+ *
+ * @return array
+ */
+ public function show(): array;
+
+ /**
+ * delete all database hosted on server not ignored
+ *
+ * @return bool
+ * @throws IdentifierException
+ */
+ public function dropAll():bool;
+
+ /**
+ * create database
+ *
+ * @param string $database
+ *
+ * @return bool
+ */
+ public function create(string $database): bool;
+
+ /**
+ * set the encoding option
+ *
+ * @param string $option
+ *
+ * @return Base
+ */
+ public function setEncodingOptions(string $option): Base;
+
+ /**
+ * set database encoding
+ *
+ * @param string $encoding
+ *
+ * @return Base
+ */
+ public function setEncoding(string $encoding): Base;
+
+ /**
+ * set database charset
+ *
+ * @param string $collation
+ *
+ * @return Base
+ *
+ */
+ public function setCollation(string $collation): Base;
+
+ /**
+ * set database type
+ *
+ * @param string $driver
+ *
+ * @return Base
+ */
+ public function setDriver(string $driver): Base;
+
+ /**
+ * set database password
+ *
+ * @param string $password
+ *
+ * @return Base
+ */
+ public function setPassword(string $password): Base;
+
+ /**
+ * set database user
+ *
+ * @param string $username
+ *
+ * @return Base
+ */
+ public function setUser(string $username): Base;
+
+ /**
+ * set database name
+ *
+ * @param string $name
+ *
+ * @return Base
+ */
+ public function setName(string $name): Base;
+
+ /**
+ * delete a database
+ *
+ * @param string $database
+ *
+ * @return bool
+ */
+ public function drop(string $database): bool;
+
+ /**
+ * restore a database
+ *
+ * @param string $base
+ * @param string $sqlFile
+ *
+ * @return bool
+ */
+ public function restore(string $base,string $sqlFile): bool;
+
+ /**
+ * dump a database
+ */
+ public function dump();
+
+ /**
+ * check if a database exist
+ *
+ * @param string $base
+ * @return bool
+ */
+ public function exist(string $base = ''): bool;
+
+ /**
+ * get database charset
+ *
+ * @return array
+ */
+ public function getCharset(): array;
+
+ /**
+ * get database collation
+ *
+ * @return array
+ */
+ public function getCollation(): array;
+
+ /**
+ * define hidden databases
+ *
+ * @param array $databases
+ *
+ * @return Base
+ */
+ public function setHidden(array $databases): Base;
+
+ /**
+ * start query builder
+ *
+ * @return Base
+ */
+ public static function manage(): Base;
+
+ /**
+ * Get a pdo instance
+ *
+ * @return PDO|null
+ */
+ public function getInstance();
+
+
+ /**
+ * set dump directory path
+ *
+ * @param string $path
+ *
+ * @return Base
+ */
+ public function setDumpDirectory(string $path) : Base;
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Core/UserManagement.php b/imperium/Databases/Core/UserManagement.php
new file mode 100644
index 0000000..f945bb8
--- /dev/null
+++ b/imperium/Databases/Core/UserManagement.php
@@ -0,0 +1,130 @@
+<?php
+/**
+ * fumseck added UserManagement.php to imperium
+ * The 11/09/17 at 08:57
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+namespace Imperium\Databases\Core {
+
+
+ use Imperium\Databases\Eloquent\Users\Users;
+ use PDO;
+
+ interface UserManagement
+ {
+ /**
+ * delete an user
+ *
+ * @param string $user
+ *
+ * @return bool
+ */
+ public function drop(string $user): bool;
+
+ /**
+ * return all users
+ *
+ * @return array
+ */
+ public function show(): array;
+
+ /**
+ * define username
+ *
+ * @param string $name
+ *
+ * @return Users
+ */
+ public function setName(string $name): Users;
+
+ /**
+ * define user password
+ *
+ * @param string $password
+ *
+ * @return Users
+ */
+ public function setPassword(string $password): Users;
+
+ /**
+ * create a new user
+ *
+ * @return bool
+ */
+ public function create(): bool;
+
+ /**
+ * set user rights
+ *
+ * @param string $rights
+ *
+ * @return Users
+ */
+ public function setRights(string $rights): Users;
+
+ /**
+ * check if a user exist
+ *
+ * @param string $user
+ * @return bool
+ */
+ public function exist(string $user = ''): bool;
+
+ /**
+ * update user password
+ *
+ * @param string $user
+ * @param string $password
+ *
+ * @return bool
+ */
+ public function updatePassword(string $user, string $password): bool;
+
+ /**
+ * define hidden users
+ *
+ * @param array $users
+ *
+ * @return Users
+ */
+ public function setHidden(array $users): Users;
+
+ /**
+ * define user type
+ *
+ * @param string $driver
+ *
+ * @return Users
+ */
+ public function setDriver(string $driver): Users;
+
+ /**
+ * start query builder
+ *
+ * @return Users
+ */
+ public static function manage(): Users;
+
+ /**
+ * Get a pdo instance
+ *
+ * @return null|PDO
+ */
+ public function getInstance();
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Databases/MySQLDatabase.php b/imperium/Databases/Dumper/Databases/MySQLDatabase.php
new file mode 100644
index 0000000..ac7f891
--- /dev/null
+++ b/imperium/Databases/Dumper/Databases/MySQLDatabase.php
@@ -0,0 +1,212 @@
+<?php
+/**
+ * fumseck added MysqlDatabase.php to imperium
+ * The 09/09/17 at 13:12
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+namespace Imperium\Databases\Dumper\Databases {
+
+
+ use Imperium\Databases\Dumper\Dumper;
+ use Imperium\Databases\Dumper\Exceptions\CannotStartDump;
+ use Symfony\Component\Process\Process;
+
+ class MySQLDatabase extends Dumper
+ {
+ /** @var bool */
+ protected $skipComments = true;
+
+ /** @var bool */
+ protected $useExtendedInserts = true;
+
+ /** @var bool */
+ protected $useSingleTransaction = false;
+
+ public function __construct()
+ {
+ $this->port = 3306;
+ }
+
+ /**
+ * @return $this
+ */
+ public function skipComments()
+ {
+ $this->skipComments = true;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function dontSkipComments()
+ {
+ $this->skipComments = false;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function useExtendedInserts()
+ {
+ $this->useExtendedInserts = true;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function dontUseExtendedInserts()
+ {
+ $this->useExtendedInserts = false;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function useSingleTransaction()
+ {
+ $this->useSingleTransaction = true;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function dontUseSingleTransaction()
+ {
+ $this->useSingleTransaction = false;
+
+ return $this;
+ }
+
+ /**
+ * Dump the contents of the database to the given files.
+ *
+ * @param string $dumpFile
+ * @param $directory
+ */
+ public function dumpToFile($dumpFile,$directory)
+ {
+ self::clear($directory);
+
+ $this->guardAgainstIncompleteCredentials();
+
+ $tempFileHandle = tmpfile();
+ fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
+ $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
+
+ $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile);
+
+ $process = new Process($command);
+
+ if (! is_null($this->timeout)) {
+ $process->setTimeout($this->timeout);
+ }
+
+ $process->run();
+
+ $this->checkIfDumpWasSuccessFul($process, $dumpFile);
+ }
+
+ /**
+ * Get the command that should be performed to dump the database.
+ *
+ * @param string $dumpFile
+ * @param string $temporaryCredentialsFile
+ *
+ * @return string
+ */
+ public function getDumpCommand($dumpFile, $temporaryCredentialsFile)
+ {
+ $quote = $this->determineQuote();
+
+ $command = [
+ "{$quote}{$this->dumpBinaryPath}mysqldump{$quote}",
+ "--defaults-extra-files=\"{$temporaryCredentialsFile}\"",
+ ];
+
+ if ($this->skipComments) {
+ $command[] = '--skip-comments';
+ }
+
+ $command[] = $this->useExtendedInserts ? '--extended-insert' : '--skip-extended-insert';
+
+ if ($this->useSingleTransaction) {
+ $command[] = '--single-transaction';
+ }
+
+ if ($this->socket !== '') {
+ $command[] = "--socket={$this->socket}";
+ }
+
+ if (! empty($this->excludeTables)) {
+ $command[] = '--ignore-table='.implode(' --ignore-table=', $this->excludeTables);
+ }
+
+ foreach ($this->extraOptions as $extraOption) {
+ $command[] = $extraOption;
+ }
+
+ $command[] = "{$this->dbName}";
+
+ if (! empty($this->includeTables)) {
+ $command[] = implode(' ', $this->includeTables);
+ }
+
+ $command[] = "> \"{$dumpFile}\"";
+
+ return implode(' ', $command);
+ }
+
+ public function getContentsOfCredentialsFile()
+ {
+ $contents = [
+ '[client]',
+ "user = '{$this->userName}'",
+ "password = '{$this->password}'",
+ "host = '{$this->host}'",
+ "port = '{$this->port}'",
+ ];
+
+ return implode(PHP_EOL, $contents);
+ }
+
+ protected function guardAgainstIncompleteCredentials()
+ {
+ foreach (['userName', 'dbName', 'host'] as $requiredProperty) {
+ if (strlen($this->$requiredProperty) === 0) {
+ throw CannotStartDump::emptyParameter($requiredProperty);
+ }
+ }
+ }
+
+ protected function determineQuote()
+ {
+ return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? '"' : "'";
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Databases/PostgreSQLDatabase.php b/imperium/Databases/Dumper/Databases/PostgreSQLDatabase.php
new file mode 100644
index 0000000..c0eb1d8
--- /dev/null
+++ b/imperium/Databases/Dumper/Databases/PostgreSQLDatabase.php
@@ -0,0 +1,147 @@
+<?php
+/**
+ * fumseck added PostgreSQLDatabase.php to imperium
+ * The 09/09/17 at 13:13
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+namespace Imperium\Databases\Dumper\Databases {
+
+
+ use Imperium\Databases\Dumper\Dumper;
+ use Imperium\Databases\Dumper\Exceptions\CannotStartDump;
+ use Symfony\Component\Process\Process;
+
+ class PostgreSQLDatabase extends Dumper
+ {
+ /** @var bool */
+ protected $useInserts = false;
+
+ public function __construct()
+ {
+ $this->port = 5432;
+ }
+
+ /**
+ * @return $this
+ */
+ public function useInserts()
+ {
+ $this->useInserts = true;
+
+ return $this;
+ }
+
+ /**
+ * Dump the contents of the database to the given files.
+ * @param string $dumpFile
+ * @param $directory
+ */
+ public function dumpToFile($dumpFile,$directory)
+ {
+ self::clear($directory);
+
+
+ $this->guardAgainstIncompleteCredentials();
+
+ $command = $this->getDumpCommand($dumpFile);
+
+ $tempFileHandle = tmpfile();
+ fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
+ $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
+
+ $process = new Process($command, null, $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile));
+
+ if (! is_null($this->timeout)) {
+ $process->setTimeout($this->timeout);
+ }
+
+ $process->run();
+
+ $this->checkIfDumpWasSuccessFul($process, $dumpFile);
+ }
+
+ /**
+ * Get the command that should be performed to dump the database.
+ *
+ * @param string $dumpFile
+ *
+ * @return string
+ */
+ public function getDumpCommand($dumpFile)
+ {
+ $command = [
+ "'{$this->dumpBinaryPath}pg_dump'",
+ "-U {$this->userName}",
+ '-h '.($this->socket === '' ? $this->host : $this->socket),
+ "-p {$this->port}",
+ "--files=\"{$dumpFile}\"",
+ ];
+
+ if ($this->useInserts) {
+ $command[] = '--inserts';
+ }
+
+ foreach ($this->extraOptions as $extraOption) {
+ $command[] = $extraOption;
+ }
+
+ if (! empty($this->includeTables)) {
+ $command[] = '-t '.implode(' -t ', $this->includeTables);
+ }
+
+ if (! empty($this->excludeTables)) {
+ $command[] = '-T '.implode(' -T ', $this->excludeTables);
+ }
+
+ return implode(' ', $command);
+ }
+
+ public function getContentsOfCredentialsFile()
+ {
+ $contents = [
+ $this->host,
+ $this->port,
+ $this->dbName,
+ $this->userName,
+ $this->password,
+ ];
+
+ return implode(':', $contents);
+ }
+
+ protected function guardAgainstIncompleteCredentials()
+ {
+ foreach (['userName', 'dbName', 'host'] as $requiredProperty)
+ {
+ if (empty($this->$requiredProperty))
+ {
+ throw CannotStartDump::emptyParameter($requiredProperty);
+ }
+ }
+ }
+
+ protected function getEnvironmentVariablesForDumpCommand( $temporaryCredentialsFile)
+ {
+ return [
+ 'PGPASSFILE' => $temporaryCredentialsFile,
+ 'PGDATABASE' => $this->dbName,
+ ];
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Databases/SQLiteDatabase.php b/imperium/Databases/Dumper/Databases/SQLiteDatabase.php
new file mode 100644
index 0000000..413e1fd
--- /dev/null
+++ b/imperium/Databases/Dumper/Databases/SQLiteDatabase.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * fumseck added SQLiteDatabase.php to imperium
+ * The 09/09/17 at 13:14
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Databases\Dumper\Databases {
+
+
+ use Imperium\Databases\Dumper\Dumper;
+ use Symfony\Component\Process\Process;
+
+ class SQLiteDatabase extends Dumper
+ {
+
+ /**
+ * Dump the contents of the database to a given files.
+ * @param string $dumpFile
+ * @param $directory
+ */
+ public function dumpToFile($dumpFile,$directory)
+ {
+ self::clear($directory);
+
+ $command = $this->getDumpCommand($dumpFile);
+
+ $process = new Process($command);
+
+ if (! is_null($this->timeout)) {
+ $process->setTimeout($this->timeout);
+ }
+
+ $process->run();
+
+ $this->checkIfDumpWasSuccessFul($process, $dumpFile);
+ }
+
+ /**
+ * Get the command that should be performed to dump the database.
+ *
+ * @param string $dumpFile
+ *
+ * @return string
+ */
+ public function getDumpCommand($dumpFile)
+ {
+ return implode(' ', [
+ 'echo $\'BEGIN IMMEDIATE;\n.dump\' |',
+ "\"{$this->dumpBinaryPath}sqlite3\" --bail",
+ "\"{$this->dbName}\" >",
+ "\"{$dumpFile}\"",
+ ]);
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Dumper.php b/imperium/Databases/Dumper/Dumper.php
new file mode 100644
index 0000000..b1204fe
--- /dev/null
+++ b/imperium/Databases/Dumper/Dumper.php
@@ -0,0 +1,330 @@
+<?php
+/**
+ * fumseck added Dumper.php to imperium
+ * The 09/09/17 at 13:15
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Databases\Dumper {
+
+ use Imperium\Databases\Dumper\Exceptions\CannotSetParameter;
+ use Imperium\Databases\Dumper\Exceptions\DumpFailed;
+ use Imperium\Directory\Dir;
+ use Symfony\Component\Process\Process;
+
+
+ /**
+ * Class Dumper
+ * @package Pegasus\Dump
+ */
+ abstract class Dumper
+ {
+ /** @var string */
+ protected $dbName;
+
+ /** @var string */
+ protected $userName;
+
+ /** @var string */
+ protected $password;
+
+ /** @var string */
+ protected $host = 'localhost';
+
+ /** @var int */
+ protected $port = 5432;
+
+ /** @var string */
+ protected $socket = '';
+
+ /** @var int */
+ protected $timeout = 0;
+
+ /** @var string */
+ protected $dumpBinaryPath = '';
+
+ /** @var array */
+ protected $includeTables = [];
+
+ /** @var array */
+ protected $excludeTables = [];
+
+ /** @var array */
+ protected $extraOptions = [];
+
+ /** @var string */
+ protected $table;
+
+ /**
+ * @return static
+ */
+ public static function dump()
+ {
+ return new static();
+ }
+
+ /**
+ * clear a directory
+ *
+ * @param $directory
+ */
+ public static function clear($directory)
+ {
+ switch (is_dir($directory))
+ {
+ case true:
+ Dir::clear($directory);
+ break;
+ default:
+ mkdir($directory);
+ break;
+ }
+ }
+ /**
+ * get database name
+ *
+ * @return string
+ */
+ public function getDbName()
+ {
+ return $this->dbName;
+ }
+
+ /**
+ * define database name
+ *
+ * @param string $dbName
+ * @return $this
+ */
+ public function setDbName($dbName)
+ {
+ $this->dbName = $dbName;
+
+ return $this;
+ }
+
+ /**
+ * define user name
+ *
+ * @param string $userName
+ * @return $this
+ */
+ public function setUserName($userName)
+ {
+ $this->userName = $userName;
+
+ return $this;
+ }
+
+ /**
+ * define database password
+ *
+ * @param string $password
+ * @return $this
+ */
+ public function setPassword($password)
+ {
+ $this->password = $password;
+
+ return $this;
+ }
+
+ /**
+ * define host
+ *
+ * @param string $host
+ * @return $this
+ */
+ public function setHost($host)
+ {
+ $this->host = $host;
+
+ return $this;
+ }
+
+ /**
+ * get host
+ *
+ * @return string
+ */
+ public function getHost()
+ {
+ return $this->host;
+ }
+
+ /**
+ * define database port
+ *
+ * @param int $port
+ * @return $this
+ */
+ public function setPort($port)
+ {
+ $this->port = $port;
+
+ return $this;
+ }
+
+ /**
+ * define socket
+ *
+ * @param string $socket
+ * @return $this
+ */
+ public function setSocket($socket)
+ {
+ $this->socket = $socket;
+
+ return $this;
+ }
+
+ /**
+ * define time out
+ *
+ * @param int $timeout
+ * @return $this
+ */
+ public function setTimeout($timeout)
+ {
+ $this->timeout = $timeout;
+
+ return $this;
+ }
+
+ /**
+ * define table name
+ *
+ * @param string $table
+ * @return $this
+ */
+ public function setTable($table)
+ {
+ $this->table = $table;
+
+ return $this;
+ }
+
+
+ /**
+ * get table name
+ *
+ * @return string
+ */
+ public function getTable()
+ {
+ return $this->table;
+
+ }
+
+ /**
+ * set path
+ *
+ * @param string $dumpBinaryPath
+ * @return $this
+ */
+ public function setDumpBinaryPath($dumpBinaryPath)
+ {
+ if ($dumpBinaryPath !== '' && substr($dumpBinaryPath, -1) !== '/') {
+ $dumpBinaryPath .= '/';
+ }
+
+ $this->dumpBinaryPath = $dumpBinaryPath;
+
+ return $this;
+ }
+
+ /**
+ * @param string|array $includeTables
+ * @return $this
+ * @throws CannotSetParameter
+ */
+ public function includeTables($includeTables)
+ {
+ if (! empty($this->excludeTables)) {
+ throw CannotSetParameter::conflictingParameters('includeTables', 'excludeTables');
+ }
+
+ if (! is_array($includeTables)) {
+ $includeTables = explode(', ', $includeTables);
+ }
+
+ $this->includeTables = $includeTables;
+
+ return $this;
+ }
+
+ /**
+ * @param string|array $excludeTables
+ * @return $this
+ * @throws CannotSetParameter
+ */
+ public function excludeTables($excludeTables)
+ {
+ if (! empty($this->includeTables)) {
+ throw CannotSetParameter::conflictingParameters('excludeTables', 'includeTables');
+ }
+
+ if (! is_array($excludeTables)) {
+ $excludeTables = explode(', ', $excludeTables);
+ }
+
+ $this->excludeTables = $excludeTables;
+
+ return $this;
+ }
+
+ /**
+ * @param string $extraOption
+ * @return $this
+ */
+ public function addExtraOption($extraOption)
+ {
+ if (! empty($extraOption)) {
+ $this->extraOptions[] = $extraOption;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param $dumpFile
+ * @param $directory
+ * @return
+ */
+ abstract public function dumpToFile($dumpFile,$directory);
+
+ /**
+ * @param Process $process
+ * @param $outputFile
+ * @throws DumpFailed
+ */
+ protected function checkIfDumpWasSuccessFul(Process $process, $outputFile)
+ {
+ if (! $process->isSuccessful()) {
+ throw DumpFailed::processDidNotEndSuccessfully($process);
+ }
+
+ if (! file_exists($outputFile)) {
+ throw DumpFailed::dumpfileWasNotCreated();
+ }
+
+ if (filesize($outputFile) === 0) {
+ throw DumpFailed::dumpfileWasEmpty();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Exceptions/CannotSetParameter.php b/imperium/Databases/Dumper/Exceptions/CannotSetParameter.php
new file mode 100644
index 0000000..d1deb35
--- /dev/null
+++ b/imperium/Databases/Dumper/Exceptions/CannotSetParameter.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * fumseck added CannotSetParameter.php to imperium
+ * The 09/09/17 at 13:19
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Databases\Dumper\Exceptions {
+
+ use Exception;
+
+ class CannotSetParameter extends Exception
+ {
+ /**
+ * @param string $name
+ * @param string $conflictName
+ * @return CannotSetParameter
+ */
+ public static function conflictingParameters($name, $conflictName)
+ {
+ return new static("Cannot set `{$name}` because it conflicts with parameter `{$conflictName}`.");
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Exceptions/CannotStartDump.php b/imperium/Databases/Dumper/Exceptions/CannotStartDump.php
new file mode 100644
index 0000000..befd2e1
--- /dev/null
+++ b/imperium/Databases/Dumper/Exceptions/CannotStartDump.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * fumseck added CannotStartDump.php to imperium
+ * The 09/09/17 at 13:20
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+namespace Imperium\Databases\Dumper\Exceptions {
+
+ use Exception;
+
+ class CannotStartDump extends Exception
+ {
+ /**
+ * @param string $name
+ *
+ * @return CannotStartDump
+ */
+ public static function emptyParameter($name)
+ {
+ return new static("Parameter `{$name}` cannot be empty.");
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Exceptions/DumpFailed.php b/imperium/Databases/Dumper/Exceptions/DumpFailed.php
new file mode 100644
index 0000000..742ad92
--- /dev/null
+++ b/imperium/Databases/Dumper/Exceptions/DumpFailed.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * fumseck added DumpFailed.php to imperium
+ * The 09/09/17 at 13:21
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+namespace Imperium\Databases\Dumper\Exceptions {
+
+ use Exception;
+ use Symfony\Component\Process\Process;
+
+ class DumpFailed extends Exception
+ {
+ /**
+ * @param \Symfony\Component\Process\Process $process
+ *
+ * @return DumpFailed
+ */
+ public static function processDidNotEndSuccessfully(Process $process)
+ {
+ return new static("The dump process failed with exit code {$process->getExitCode()} : {$process->getExitCodeText()} : {$process->getErrorOutput()}");
+ }
+
+ /**
+ * @return DumpFailed
+ */
+ public static function dumpfileWasNotCreated()
+ {
+ return new static('The dumpfile could not be created');
+ }
+
+ /**
+ * @return DumpFailed
+ */
+ public static function dumpfileWasEmpty()
+ {
+ return new static('The created dumpfile is empty');
+ }
+
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Tables/MySQLTable.php b/imperium/Databases/Dumper/Tables/MySQLTable.php
new file mode 100644
index 0000000..628f1bc
--- /dev/null
+++ b/imperium/Databases/Dumper/Tables/MySQLTable.php
@@ -0,0 +1,205 @@
+<?php
+/**
+ * fumseck added MySQLTable.php to imperium
+ * The 09/09/17 at 13:23
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+namespace Imperium\Databases\Dumper\Tables {
+
+
+ use Imperium\Databases\Dumper\Dumper;
+ use Imperium\Databases\Dumper\Exceptions\CannotStartDump;
+ use Symfony\Component\Process\Process;
+
+ class MySQLTable extends Dumper
+ {
+ /** @var bool */
+ protected $skipComments = true;
+
+ /** @var bool */
+ protected $useExtendedInserts = true;
+
+ /** @var bool */
+ protected $useSingleTransaction = false;
+
+ public function __construct()
+ {
+ $this->port = 3306;
+ }
+
+ /**
+ * @return $this
+ */
+ public function skipComments()
+ {
+ $this->skipComments = true;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function dontSkipComments()
+ {
+ $this->skipComments = false;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function useExtendedInserts()
+ {
+ $this->useExtendedInserts = true;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function dontUseExtendedInserts()
+ {
+ $this->useExtendedInserts = false;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function useSingleTransaction()
+ {
+ $this->useSingleTransaction = true;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function dontUseSingleTransaction()
+ {
+ $this->useSingleTransaction = false;
+
+ return $this;
+ }
+
+ /**
+ * Dump the contents of the database to the given files.
+ *
+ * @param string $dumpFile
+ * @param $directory
+ */
+ public function dumpToFile($dumpFile,$directory)
+ {
+ self::clear($directory);
+
+ $this->guardAgainstIncompleteCredentials();
+
+ $tempFileHandle = tmpfile();
+ fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
+ $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
+
+ $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile);
+
+ $process = new Process($command);
+
+ if (! is_null($this->timeout)) {
+ $process->setTimeout($this->timeout);
+ }
+
+ $process->run();
+
+ $this->checkIfDumpWasSuccessFul($process, $dumpFile);
+ }
+
+ /**
+ * Get the command that should be performed to dump the database.
+ *
+ * @param string $dumpFile
+ * @param string $temporaryCredentialsFile
+ *
+ * @return string
+ */
+ public function getDumpCommand($dumpFile, $temporaryCredentialsFile)
+ {
+ $quote = $this->determineQuote();
+
+ $command = [
+ "{$quote}{$this->dumpBinaryPath}mysqldump{$quote}",
+ "--defaults-extra-files=\"{$temporaryCredentialsFile}\"",
+ ];
+
+ if ($this->skipComments) {
+ $command[] = '--skip-comments';
+ }
+
+ $command[] = $this->useExtendedInserts ? '--extended-insert' : '--skip-extended-insert';
+
+ if ($this->useSingleTransaction) {
+ $command[] = '--single-transaction';
+ }
+
+ if ($this->socket !== '') {
+ $command[] = "--socket={$this->socket}";
+ }
+
+ foreach ($this->extraOptions as $extraOption) {
+ $command[] = $extraOption;
+ }
+
+ $command[] = "{$this->dbName}";
+ $command[] = "{$this->table}";
+
+ $command[] = "> \"{$dumpFile}\"";
+
+ return implode(' ', $command);
+ }
+
+ public function getContentsOfCredentialsFile()
+ {
+ $contents = [
+ '[client]',
+ "user = '{$this->userName}'",
+ "password = '{$this->password}'",
+ "host = '{$this->host}'",
+ "port = '{$this->port}'",
+ ];
+
+ return implode(PHP_EOL, $contents);
+ }
+
+ protected function guardAgainstIncompleteCredentials()
+ {
+ foreach (['userName', 'dbName', 'host'] as $requiredProperty) {
+ if (strlen($this->$requiredProperty) === 0) {
+ throw CannotStartDump::emptyParameter($requiredProperty);
+ }
+ }
+ }
+
+ protected function determineQuote()
+ {
+ return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? '"' : "'";
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Tables/PostgreSQLTable.php b/imperium/Databases/Dumper/Tables/PostgreSQLTable.php
new file mode 100644
index 0000000..687866c
--- /dev/null
+++ b/imperium/Databases/Dumper/Tables/PostgreSQLTable.php
@@ -0,0 +1,136 @@
+<?php
+/**
+ * fumseck added PostgreSQLTable.php to imperium
+ * The 09/09/17 at 13:24
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+
+namespace Imperium\Databases\Dumper\Tables {
+
+
+ use Imperium\Databases\Dumper\Dumper;
+ use Imperium\Databases\Dumper\Exceptions\CannotStartDump;
+ use Symfony\Component\Process\Process;
+
+ class PostgreSQLTable extends Dumper
+ {
+ /** @var bool */
+ protected $useInserts = false;
+
+ public function __construct()
+ {
+ $this->port = 5432;
+ }
+
+ /**
+ * @return $this
+ */
+ public function useInserts()
+ {
+ $this->useInserts = true;
+
+ return $this;
+ }
+
+ /**
+ * Dump the contents of the database to the given files.
+ * @param string $dumpFile
+ * @param $directory
+ */
+ public function dumpToFile($dumpFile,$directory)
+ {
+ self::clear($directory);
+
+ $this->guardAgainstIncompleteCredentials();
+
+ $command = $this->getDumpCommand($dumpFile);
+
+ $tempFileHandle = tmpfile();
+ fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
+ $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
+
+ $process = new Process($command, null, $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile));
+
+ if (! is_null($this->timeout)) {
+ $process->setTimeout($this->timeout);
+ }
+
+ $process->run();
+
+ $this->checkIfDumpWasSuccessFul($process, $dumpFile);
+ }
+
+ /**
+ * Get the command that should be performed to dump the database.
+ *
+ * @param string $dumpFile
+ *
+ * @return string
+ */
+ public function getDumpCommand($dumpFile)
+ {
+ $command = [
+ "'{$this->dumpBinaryPath}pg_dump'",
+ "-U {$this->userName}",
+ "-d {$this->dbName}",
+ "-t {$this->table}",
+ "-h {$this->host}",
+ "-p {$this->port}",
+ "--files=\"{$dumpFile}\"",
+ ];
+
+
+ foreach ($this->extraOptions as $extraOption) {
+ $command[] = $extraOption;
+ }
+
+ return implode(' ', $command);
+ }
+
+ public function getContentsOfCredentialsFile()
+ {
+ $contents = [
+ $this->host,
+ $this->port,
+ $this->dbName,
+ $this->userName,
+ $this->password,
+ ];
+
+ return implode(':', $contents);
+ }
+
+ protected function guardAgainstIncompleteCredentials()
+ {
+ foreach (['userName', 'dbName', 'host'] as $requiredProperty) {
+ if (empty($this->$requiredProperty)) {
+ throw CannotStartDump::emptyParameter($requiredProperty);
+ }
+ }
+ }
+
+ protected function getEnvironmentVariablesForDumpCommand( $temporaryCredentialsFile)
+ {
+ return [
+ 'PGPASSFILE' => $temporaryCredentialsFile,
+ 'PGDATABASE' => $this->dbName,
+ ];
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Dumper/Tables/SQLiteTable.php b/imperium/Databases/Dumper/Tables/SQLiteTable.php
new file mode 100644
index 0000000..0ce2b26
--- /dev/null
+++ b/imperium/Databases/Dumper/Tables/SQLiteTable.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * fumseck added SQLiteTable.php to imperium
+ * The 09/09/17 at 13:25
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Databases\Dumper\Tables{
+
+
+ use Imperium\Databases\Dumper\Dumper;
+ use Symfony\Component\Process\Process;
+
+ class SQLiteTable extends Dumper
+ {
+
+ /**
+ * Dump the contents of the database to a given files.
+ * @param string $dumpFile
+ * @param $directory
+ */
+ public function dumpToFile($dumpFile,$directory)
+ {
+ self::clear($directory);
+
+ $command = $this->getDumpCommand($dumpFile);
+
+ $process = new Process($command);
+
+ if (! is_null($this->timeout)) {
+ $process->setTimeout($this->timeout);
+ }
+
+ $process->run();
+
+ $this->checkIfDumpWasSuccessFul($process, $dumpFile);
+ }
+
+ /**
+ * Get the command that should be performed to dump the database.
+ *
+ * @param string $dumpFile
+ *
+ * @return string
+ */
+ public function getDumpCommand($dumpFile)
+ {
+ return implode(' ', [
+ 'echo $\'BEGIN IMMEDIATE;\n.dump\' |',
+ "\"{$this->dumpBinaryPath}sqlite3\" --bail",
+ "\"{$this->dbName}\" '.dump {$this->table}' >",
+ "\"{$dumpFile}\"",
+ ]);
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Bases/Base.php b/imperium/Databases/Eloquent/Bases/Base.php
new file mode 100644
index 0000000..ab3fffa
--- /dev/null
+++ b/imperium/Databases/Eloquent/Bases/Base.php
@@ -0,0 +1,473 @@
+<?php
+/**
+ * fumseck added Base.php to imperium
+ * The 11/09/17 at 09:36
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+
+namespace Imperium\Databases\Eloquent\Bases {
+
+ use Imperium\Databases\Core\DatabasesManagement;
+ use Imperium\Databases\Dumper\Databases\MySQLDatabase;
+ use Imperium\Databases\Dumper\Databases\PostgreSQLDatabase;
+ use Imperium\Databases\Dumper\Databases\SQLiteDatabase;
+ use Imperium\Databases\Eloquent\Connexion\Connexion;
+ use Imperium\Databases\Eloquent\Share;
+ use Imperium\Databases\Exception\IdentifierException;
+ use Imperium\File\File;
+ use PDO;
+
+ class Base implements DatabasesManagement
+ {
+ use Share;
+
+ /**
+ * @var string
+ */
+ private $options;
+
+ /**
+ * show databases
+ *
+ * @throws IdentifierException
+ * @return array
+ */
+ public function show(): array
+ {
+ $databases = array();
+
+ if (is_null($this->getInstance()))
+ throw IdentifierException::incorrectIdentifiers();
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ $query = $this->getInstance()->prepare('SHOW DATABASES');
+ $query->execute();
+ break;
+ case Connexion::POSTGRESQL:
+ $query = $this->getInstance()->prepare('select datname from pg_database');
+ $query->execute();
+ break;
+ case Connexion::ORACLE:
+ $query = $this->getInstance()->prepare('SELECT NAME FROM V$DATABASE;');
+ $query->execute();
+ break;
+ default:
+ return $databases;
+ break;
+ }
+
+ foreach ($query->fetchAll() as $database)
+ {
+ if (!empty($this->hidden))
+ {
+ if (!has(current($database), $this->hidden))
+ {
+ push($databases, current($database));
+ }
+ } else {
+ push($databases, current($database));
+ }
+ }
+ return $databases;
+ }
+
+ /**
+ * create database
+ * @param string $database
+ * @throws IdentifierException
+ *
+ * @return bool
+ */
+ public function create(string $database): bool
+ {
+ if (is_null($this->getInstance()))
+ throw IdentifierException::incorrectIdentifiers();
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ if (empty($this->collation) && empty($this->encoding))
+ return execute($this->getInstance()," CREATE DATABASE IF NOT EXISTS $database");
+
+ return execute($this->getInstance()," CREATE DATABASE IF NOT EXISTS $database DEFAULT CHARACTER SET {$this->encoding} DEFAULT COLLATE {$this->collation};");
+ break;
+ case Connexion::POSTGRESQL:
+ if(empty($this->collation) && empty($this->encoding))
+ return execute($this->getInstance(),"CREATE DATABASE $database TEMPLATE template0");
+ return execute($this->getInstance(),"CREATE DATABASE $database ENCODING '{$this->encoding}' LC_COLLATE='{$this->collation}' LC_CTYPE='{$this->collation}' TEMPLATE template0; ");
+ break;
+ case Connexion::ORACLE:
+ if(empty($this->options) && empty($this->encoding))
+ return execute($this->getInstance()," CREATE DATABASE IF NOT EXISTS $database");
+ return execute($this->getInstance(),"CREATE DATABASE $database {$this->options} '{$this->encoding}';");
+ break;
+ case Connexion::SQLITE:
+ new PDO("sqlite:$database",null,null);
+ return chmod($database,0777);
+ break;
+ default:
+ return false;
+ break;
+ }
+ }
+
+ /**
+ * set database encoding
+ *
+ * @param string $encoding
+ *
+ * @return Base
+ */
+ public function setEncoding(string $encoding): Base
+ {
+ $this->encoding = $encoding;
+
+ return $this;
+ }
+
+ /**
+ * set database charset
+ *
+ * @param string $collation
+ *
+ * @return Base
+ *
+ */
+ public function setCollation(string $collation): Base
+ {
+ $this->collation = $collation;
+
+ return $this;
+ }
+
+ /**
+ * set database type
+ *
+ * @param string $driver
+ *
+ * @return Base
+ */
+ public function setDriver(string $driver): Base
+ {
+ $this->driver = $driver;
+
+ return $this;
+ }
+
+ /**
+ * set database password
+ *
+ * @param string $password
+ *
+ * @return Base
+ */
+ public function setPassword(string $password): Base
+ {
+ $this->password = $password;
+
+ return $this;
+ }
+
+ /**
+ * set database user
+ *
+ * @param string $username
+ *
+ * @return Base
+ */
+ public function setUser(string $username): Base
+ {
+ $this->username = $username;
+
+ return $this;
+ }
+
+ /**
+ * set database name
+ *
+ * @param string $name
+ *
+ * @return Base
+ */
+ public function setName(string $name): Base
+ {
+ $this->database = $name;
+
+ return $this;
+ }
+
+ /**
+ * delete a database
+ *
+ * @param string $database
+ *
+ * @return bool
+ * @throws IdentifierException
+ */
+ public function drop(string $database): bool
+ {
+ if (is_null($this->getInstance()))
+ throw IdentifierException::incorrectIdentifiers();
+
+ switch ($this->driver)
+ {
+ case Connexion::SQLITE:
+ return File::delete($database);
+ break;
+ default:
+ return execute($this->getInstance(),"DROP DATABASE $database;");
+ break;
+ }
+ }
+
+ /**
+ * dump a database
+ */
+ public function dump()
+ {
+ $filename = "{$this->path}/{$this->database}.sql";
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+
+ MySQLDatabase::dump()
+ ->setDbName($this->database)
+ ->setPassword($this->password)
+ ->setUserName($this->username)
+ ->dumpToFile($filename, $this->path);
+
+ File::download($filename);
+
+ break;
+ case Connexion::POSTGRESQL:
+
+ PostgreSQLDatabase::dump()
+ ->setDbName($this->database)
+ ->setUserName($this->username)
+ ->setPassword($this->password)
+ ->dumpToFile($filename, $this->path);
+
+ File::download($filename);
+ break;
+ case Connexion::SQLITE:
+ SQLiteDatabase::dump()->setDbName($this->database)->dumpToFile($filename,$this->path);
+
+ File::download($filename);
+ break;
+ }
+ }
+
+ /**
+ * check if a database exist
+ *
+ * @param string $base
+ * @throws IdentifierException
+ *
+ * @return bool
+ */
+ public function exist(string $base = ''): bool
+ {
+ if (!empty($base))
+ return has($base,$this->show());
+ else
+ return has($this->database,$this->show());
+
+ }
+
+ /**
+ * get database charset
+ *
+ * @return array
+ * @throws IdentifierException
+ */
+ public function getCharset(): array
+ {
+ $charset = array();
+
+ if (is_null($this->getInstance()))
+ throw IdentifierException::incorrectIdentifiers();
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ $query = $this->getInstance()->prepare('SHOW CHARACTER SET');
+ $query->execute();
+ break;
+ case Connexion::POSTGRESQL:
+ $query = $this->getInstance()->prepare("SELECT DISTINCT pg_encoding_to_char(conforencoding) FROM pg_conversion ORDER BY 1");
+ $query->execute();
+ break;
+ case Connexion::ORACLE:
+ $query = $this->getInstance()->prepare("select * from database_properties");
+ $query->execute();
+ break;
+ default:
+ return $charset;
+ break;
+ }
+
+ foreach ($query->fetchAll() as $char)
+ {
+ push($charset, current($char));
+ }
+ return $charset;
+ }
+
+ /**
+ * get database collation
+ *
+ * @return array
+ * @throws IdentifierException
+ */
+ public function getCollation(): array
+ {
+ if (is_null($this->getInstance()))
+ throw IdentifierException::incorrectIdentifiers();
+
+ $collation = array();
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ $query = $this->getInstance()->prepare('SHOW COLLATION');
+ $query->execute();
+ break;
+ case Connexion::POSTGRESQL:
+ $query = $this->getInstance()->prepare("SELECT collname FROM pg_collation");
+ $query->execute();
+ break;
+ default:
+ return $collation;
+ break;
+ }
+
+ foreach ($query->fetchAll() as $char)
+ {
+ push($collation, current($char));
+ }
+ return $collation;
+ }
+
+ /**
+ * define hidden databases
+ *
+ * @param array $databases
+ *
+ * @return Base
+ */
+ public function setHidden(array $databases): Base
+ {
+ $this->hidden = $databases;
+
+ return $this;
+ }
+
+ /**
+ * start query builder
+ *
+ * @return Base
+ */
+ public static function manage(): Base
+ {
+ return new static();
+ }
+
+ /**
+ * Get a pdo instance
+ *
+ * @return PDO|null
+ */
+ public function getInstance()
+ {
+ return connect($this->driver,$this->database,$this->username,$this->password);
+ }
+
+
+ /**
+ * set dump directory path
+ *
+ * @param string $path
+ *
+ * @return Base
+ */
+ public function setDumpDirectory(string $path): Base
+ {
+ $this->path = $path;
+
+ return $this;
+ }
+
+ /**
+ * set the encoding option
+ *
+ * @param string $option
+ *
+ * @return Base
+ */
+ public function setEncodingOptions(string $option): Base
+ {
+ $this->options = $option;
+
+ return $this;
+ }
+
+ /**
+ * restore a database
+ *
+ * @param string $base
+ * @param string $sqlFile
+ *
+ * @return bool
+ */
+ public function restore(string $base,string $sqlFile): bool
+ {
+ if (File::exist($sqlFile))
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ return system("mysql -uroot $base < $sqlFile");
+ break;
+ case Connexion::POSTGRESQL:
+ return system("psql -U postgres $base < $sqlFile");
+ break;
+ default:
+ return false;
+ break;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * delete all database hosted on server not ignored
+ *
+ * @return bool
+ * @throws IdentifierException
+ */
+ public function dropAll(): bool
+ {
+ foreach ($this->show() as $base)
+ if (!$this->drop($base))
+ return false;
+
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Connexion/Connexion.php b/imperium/Databases/Eloquent/Connexion/Connexion.php
new file mode 100644
index 0000000..fac4fef
--- /dev/null
+++ b/imperium/Databases/Eloquent/Connexion/Connexion.php
@@ -0,0 +1,255 @@
+<?php
+/**
+ * fumseck added Connexion.php to imperium
+ * The 11/09/17 at 06:18
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+namespace Imperium\Databases\Eloquent\Connexion {
+
+
+ use Imperium\Databases\Core\ConnexionManagement;
+ use PDO;
+ use PDOException;
+
+ class Connexion implements ConnexionManagement
+ {
+ const MYSQL = 'mysql';
+
+ const POSTGRESQL = 'pgsql';
+
+ const SQLITE = 'sqlite';
+
+ const ORACLE = 'oci';
+
+ /**
+ * @var string $type
+ */
+ private $driver;
+
+ /**
+ * @var string $username
+ */
+ private $username;
+
+ /**
+ * @var string $database
+ */
+ private $database;
+
+ /**
+ * @var string $password
+ */
+ private $password;
+
+ /**
+ * @var string $encoding
+ */
+ private $encoding;
+
+ /**
+ * start connection
+ *
+ * @return Connexion
+ */
+ public static function connect(): Connexion
+ {
+ return new static();
+ }
+
+ /**
+ * set type of database
+ *
+ * @param string $driver
+ *
+ * @return Connexion
+ *
+ */
+ public function setDriver(string $driver): Connexion
+ {
+ $this->driver = $driver;
+
+ return $this;
+ }
+
+ /**
+ * define username
+ *
+ * @param string $username
+ *
+ * @return Connexion
+ */
+ public function setUser(string $username): Connexion
+ {
+ $this->username = $username;
+
+ return $this;
+ }
+
+ /**
+ * define database name
+ *
+ * @param string $database
+ *
+ * @return Connexion
+ */
+ public function setDatabase(string $database): Connexion
+ {
+ $this->database = $database;
+
+ return $this;
+ }
+
+ /**
+ * set password
+ *
+ * @param string $password
+ *
+ * @return Connexion
+ */
+ public function setPassword(string $password): Connexion
+ {
+ $this->password = $password;
+
+ return $this;
+ }
+
+ /**
+ * set database encoding
+ *
+ * @param string $encoding
+ *
+ * @return Connexion
+ */
+ public function setEncoding(string $encoding): Connexion
+ {
+ $this->encoding = $encoding;
+
+ return $this;
+ }
+
+ /**
+ * get the connexion
+ *
+ * @return \PDO|null
+ */
+ public function getConnexion()
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ return $this->getMysqlConnection();
+ break;
+ case Connexion::POSTGRESQL:
+ return $this->getPostgresqlConnection();
+ break;
+ case Connexion::SQLITE:
+ return $this->getSqliteConnection();
+ break;
+ case Connexion::ORACLE:
+ return $this->getOracleConnection();
+ break;
+ default:
+ return null;
+ break;
+ }
+ }
+
+ /**
+ *
+ * @return null|PDO
+ */
+ public function getMysqlConnection()
+ {
+ if (empty($this->database))
+ {
+ try{
+ return new PDO("mysql:host=localhost;",$this->username,$this->password);
+ }catch (PDOException $e)
+ {
+ return null;
+ }
+ }
+
+ try{
+ return new PDO("mysql:host=localhost;dbname={$this->database}",$this->username,$this->password);
+ }catch (PDOException $e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @return \PDO|null
+ */
+ public function getPostgresqlConnection()
+ {
+ if(empty($this->database))
+ {
+ try{
+ return new PDO("pgsql:host=localhost;",$this->username,$this->password);
+ }catch (PDOException $e)
+ {
+ return null;
+ }
+ } else
+ {
+
+ try{
+ return new PDO("pgsql:host=localhost;dbname={$this->database}",$this->username,$this->password);
+ }catch (PDOException $e)
+ {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * @return \PDO|null
+ */
+ public function getSqliteConnection()
+ {
+ if (empty($this->database))
+ {
+ try {
+ return new PDO('sqlite::memory:');
+ }catch (PDOException $e)
+ {
+ return null;
+ }
+
+ }
+
+ try{
+ return new PDO("sqlite:{$this->database}",null,null);
+ }catch (PDOException $e)
+ {
+ return null;
+ }
+ }
+
+ public function getOracleConnection()
+ {
+ try{
+ return new PDO("oci:dbname{$this->database}",$this->username,$this->password);
+ }catch (PDOException $e)
+ {
+ return null;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Eloquent.php b/imperium/Databases/Eloquent/Eloquent.php
new file mode 100644
index 0000000..bc9abf0
--- /dev/null
+++ b/imperium/Databases/Eloquent/Eloquent.php
@@ -0,0 +1,154 @@
+<?php
+/**
+ * fumseck added Eloquent.php to imperium
+ * The 09/09/17 at 19:01
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+namespace Imperium\Databases\Eloquent {
+
+ class Eloquent
+ {
+ const MYSQL = 1;
+
+ const POSTGRESQL = 2;
+
+ const SQLITE = 3;
+
+ const MODE_ALL_TABLES = 10;
+
+ const MODE_ONE_TABLE = 11;
+
+ const MODE_ALL_DATABASES = 12;
+
+ const MODE_ALL_USERS = 13;
+
+ const MODE_DUMP_DATABASE = 14;
+
+ const MODE_DUMP_TABLE = 15;
+
+ const MODE_PRODUCTION = 16;
+
+ const MODE_DEBUG = 17;
+
+ const MODE_UNION = 18;
+
+ const MODE_UNION_ALL = 19;
+
+ const SUPPORTED = array(Eloquent::MYSQL, Eloquent::POSTGRESQL, Eloquent::SQLITE);
+
+ const INNER_JOIN = 20;
+
+ const CROSS_JOIN = 21;
+
+ const LEFT_JOIN = 22;
+
+ const RIGHT_JOIN = 23;
+
+ const FULL_JOIN = 24;
+
+ const SELF_JOIN = 25;
+
+ const NATURAL_JOIN = 26;
+
+ const SELECT = 'SELECT';
+
+ const DELETE = 'DELETE';
+
+ const MODE = array(Eloquent::SELECT,Eloquent::DELETE);
+
+ const BETWEEN = "BETWEEN";
+
+ const NOT_BETWEEN = "NOT BETWEEN";
+
+ const DESC = 'DESC';
+
+ const ASC = 'ASC';
+
+ const FIELD_TYPE = 'type';
+
+ const FIELD_NAME = 'name';
+
+ const FIELD_LENGTH = 'length';
+
+ const FIELD_PRIMARY = 'primary';
+
+ const FIELD_UNIQUE = 'unique';
+
+ const FIELD_NULLABLE = 'nullable';
+
+ /**
+ |-------------------------------|
+ | DATA TYPES |
+ |-------------------------------|
+ */
+ const TINYINT = 'TINYINT';
+ const SMALLINT = 'SMALLINT';
+ const MEDIUMINT = 'MEDIUMINT';
+ const INT = 'INT';
+ const REAL = 'REAL';
+ const SERIAL = 'SERIAL';
+ const BIG_SERIAL = 'BIG SERIAL';
+ const BIT_VARYING = 'BIT VARYING';
+ const BOOLEAN = 'BOOLEAN';
+ const BOX = 'BOX';
+ const BITEA = 'BITEA';
+ const CHARACTER_VARYING = 'CHARACTER VARYING';
+ const CHARACTER = 'CHARACTER';
+ const CIDR = 'CIDR';
+ const CIRCLE = 'CIRCLE';
+ const FLOAT8 = 'FLOAT8';
+ const INET = 'INET';
+ const INTERVAL = 'INTERVAL';
+ const LINE = 'LINE';
+ const LSEG = 'LSEG';
+ const MACADDR = 'MACADDR';
+ const MONEY = 'MONEY';
+ const PATH = 'PATH';
+ const POINT = 'POINT';
+ const POLYGON = 'POLYGON';
+ const TIMEZ = 'TIMEZ';
+ const TSQUERY = 'TSQUERY';
+ const TSVECTOR = 'TSVECTOR';
+ const UUID = 'UUID';
+ const XML = 'XML';
+ const INTEGER = 'INTEGER';
+ const BIGINT = 'BIGINT';
+ const NUMERIC = 'NUMERIC';
+ const DECIMAL = 'DECIMAL';
+ const BIT = 'BIT';
+ const DATE = 'DATE';
+ const DATETIME = 'DATETIME';
+ const TIMESTAMP = 'TIMESTAMP';
+ const TIMESTAMPZ = 'TIMESTAMPZ';
+ const CHAR = 'CHAR';
+ const VARCHAR = 'VARCHAR';
+ const ENUM = 'ENUM';
+ const TEXT = 'TEXT';
+ const LONGTEXT = 'LONGTEXT';
+ const BLOB = 'BLOB';
+ const VARBINARY = 'VARBINARY';
+ const MEDIUMBLOB = 'MEDIUMBLOB';
+ const MEDIUMTEXT = 'MEDIUMTEXT';
+ const LONGBLOB = 'LONGBLOB';
+ const NULL = 'NULL';
+ const NONE = 'NONE';
+ const NUMBER = 'NUMBER';
+ const VARCHAR2 = 'VARCHAR2';
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Exception/EloquentException.php b/imperium/Databases/Eloquent/Exception/EloquentException.php
new file mode 100644
index 0000000..840ad2f
--- /dev/null
+++ b/imperium/Databases/Eloquent/Exception/EloquentException.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * fumseck added EloquentException.php to imperium
+ * The 09/09/17 at 20:58
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Databases\Eloquent\Exception {
+
+ use Exception;
+
+ class EloquentException extends Exception
+ {
+ /**
+ * throw a exception if not found primary key
+ *
+ * @param string $table
+ *
+ * @return static
+ */
+ public static function notFoundPrimaryKey(string $table)
+ {
+ return new static("We have not found primary key inside table $table");
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Query/EloquentQueryBuilder.php b/imperium/Databases/Eloquent/Query/EloquentQueryBuilder.php
new file mode 100644
index 0000000..e9eb015
--- /dev/null
+++ b/imperium/Databases/Eloquent/Query/EloquentQueryBuilder.php
@@ -0,0 +1,208 @@
+<?php
+/**
+ * fumseck added EloquentBuilder.php to imperium
+ * The 09/09/17 at 19:01
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Databases\Eloquent\Query {
+
+
+ use Imperium\Databases\Eloquent\Tables\Table;
+ use PDO;
+
+ interface EloquentQueryBuilder
+ {
+ /**
+ * start the query builder
+ *
+ * @return Query
+ */
+ public static function start(): Query;
+
+ /**
+ * set pdo instance
+ *
+ * @param PDO $pdo
+ *
+ * @return Query
+ */
+ public function setPdo(PDO $pdo): Query;
+
+ /**
+ * @param Table $table
+ * @param string $like
+ *
+ * @return Query
+ */
+ public function like(Table $table,string $like): Query;
+
+ /**
+ * count all record in a table
+ *
+ * @return int
+ */
+ public function count(): int;
+
+ /**
+ * get all records in a table
+ *
+ * @return array
+ */
+ public function getRecords(): array;
+
+ /**
+ * set mode
+ *
+ * @param string $mode
+ *
+ * @return Query
+ */
+ public function setMode(string $mode = Query::SELECT): Query;
+
+ /**
+ * run a delete query
+ *
+ * @return bool
+ */
+ public function delete(): bool;
+
+ /**
+ * execute a statement
+ *
+ * @param string $statement
+ *
+ * @return bool
+ */
+ public function query(string $statement): bool;
+
+ /**
+ * execute a statement
+ *
+ * @param string $statement
+ *
+ * @return array
+ */
+ public function request(string $statement): array;
+
+ /**
+ * define a limit
+ *
+ * @param int $limit
+ *
+ * @param int $offset
+ *
+ * @return Query
+ */
+ public function limit(int $limit, int $offset): Query;
+
+ /**
+ * define name of table
+ *
+ * @param string $table
+ *
+ * @return Query
+ */
+ public function setTable(string $table): Query;
+
+ /**
+ * set database driver
+ *
+ * @param string $driver
+ *
+ * @return \Imperium\Databases\Eloquent\Query\Query
+ */
+ public function setDriver(string $driver): Query;
+
+ /**
+ * select columns
+ *
+ * @param array $columns
+ *
+ * @return Query
+ */
+ public function setColumns(array $columns = []): Query;
+
+ /**
+ * get the query result
+ *
+ * @return string
+ */
+ public function get(): string;
+
+ /**
+ * where clause
+ *
+ * @param string $param
+ * @param string $condition
+ * @param mixed $expected
+ * @param string $like
+ * @param null $betweenOne
+ * @param null $betweenTwo
+ *
+ * @return Query
+ */
+ public function where(string $param, string $condition, $expected,string $like = '',$betweenOne = null,$betweenTwo = null ): Query;
+
+ /**
+ * define the order by
+ *
+ * @param string $key
+ * @param string $order
+ *
+ * @return Query
+ */
+ public function orderBy(string $key, string $order = 'desc'): Query;
+
+ /**
+ * join clause
+ *
+ * @param int $type
+ * @param string $firstTable
+ * @param string $secondTable
+ * @param string $firstParam
+ * @param string $secondParam
+ * @param array $columns
+ * @param string $condition
+ *
+ * @return Query
+ */
+ public function join(int $type, string $firstTable,string $secondTable,string $firstParam ,string $secondParam,array $columns = [], string $condition = '=') : Query;
+
+ /**
+ * union clause
+ *
+ * @param int $mode
+ * @param string $firstTable
+ * @param string $secondTable
+ * @param array $firstColumns
+ * @param array $secondColumns
+ *
+ * @return Query
+ */
+ public function union(int $mode,string $firstTable,string $secondTable,array $firstColumns,array $secondColumns): Query;
+
+ /**
+ * execute the query
+ *
+ * @return bool
+ */
+ public function execute(): bool;
+
+
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Query/Query.php b/imperium/Databases/Eloquent/Query/Query.php
new file mode 100644
index 0000000..ea9285e
--- /dev/null
+++ b/imperium/Databases/Eloquent/Query/Query.php
@@ -0,0 +1,739 @@
+<?php
+/**
+ * fumseck added Query.php to imperium
+ * The 09/09/17 at 18:59
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Databases\Eloquent\Query {
+
+
+ use Imperium\Databases\Eloquent\Connexion\Connexion;
+ use Imperium\Databases\Eloquent\Eloquent;
+ use Imperium\Databases\Eloquent\Tables\Table;
+ use PDO;
+
+
+
+ class Query extends Eloquent implements EloquentQueryBuilder
+ {
+ /**
+ * @var string
+ */
+ private $table;
+
+ /**
+ * @var string
+ */
+ private $where;
+
+ /**
+ * @var string
+ */
+ private $select;
+
+ /**
+ * @var string
+ */
+ private $order;
+
+ /**
+ * @var int
+ */
+ private $limit;
+
+ /**
+ * @var string
+ */
+ private $join;
+
+ /**
+ * @var string
+ */
+ private $union;
+
+ /**
+ * @var PDO
+ */
+ private $pdo;
+
+ /**
+ * @var int
+ */
+ private $fetch = PDO::FETCH_OBJ;
+
+ /**
+ * @var string
+ */
+ private $mode;
+
+ /**
+ * @var string
+ */
+ private $driver;
+
+
+ /**
+ * start the query builder
+ *
+ * @return Query
+ */
+ public static function start(): Query
+ {
+ return new static();
+ }
+
+ /**
+ * define name of table
+ *
+ * @param string $table
+ *
+ * @return Query
+ */
+ public function setTable(string $table): Query
+ {
+ $this->table = "FROM $table";
+
+ return $this;
+ }
+
+
+
+ private function notDefine(array $keys)
+ {
+ $values = array();
+ foreach ($keys as $key)
+ array_push($values,is_null($key));
+
+ return !in_array(false,$values);
+
+
+ }
+
+ private function deleteSpace(string $key): string
+ {
+ return trim($key);
+ }
+
+ private function isNotNull(array $keys)
+ {
+ $values = array();
+ foreach ($keys as $key)
+ array_push($values,is_null($key));
+
+ return !in_array(true,$values);
+ }
+
+ public function get(): string
+ {
+ $mode = empty($this->mode) ? Query::SELECT : Query::DELETE;
+
+ switch ($mode)
+ {
+ case Query::SELECT:
+
+ // DEFAULT CLAUSE
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->order,$this->limit,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->limit,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->order,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->order,$this->limit,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->select,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->select, $this->limit,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table, $this->select,$this->order,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->select,$this->order,$this->limit,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->where,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->where,$this->order ,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->where,$this->order,$this->limit,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->limit,$this->join,$this->union]))
+ return '';
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->join,$this->union]))
+ return '';
+
+
+ // END DEFAULT CLAUSE
+
+ // START JOIN CLAUSE
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->order,$this->limit,$this->union]))
+ return "{$this->deleteSpace($this->join)}";
+
+ if ($this->notDefine([$this->table,$this->select,$this->order,$this->limit,$this->union]) && $this->isNotNull([$this->where]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)}";
+
+ if ($this->notDefine([$this->table,$this->select,$this->union]) && $this->isNotNull([$this->where,$this->limit,$this->order]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->table,$this->select,$this->limit,$this->union]) && $this->isNotNull([$this->order,$this->where]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->table,$this->select,$this->order,$this->union]) && $this->isNotNull([$this->where,$this->limit]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->table,$this->select,$this->order,$this->limit,$this->union]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)}";
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->union]) && $this->isNotNull([$this->order,$this->limit]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->limit,$this->union]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->order,$this->union]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->limit)}";
+
+ // END JOIN CLAUSE
+
+ // START UNION CLAUSE
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->order,$this->limit,$this->join]))
+ return "{$this->deleteSpace($this->union)}";
+
+ if ($this->notDefine([$this->table, $this->select,$this->join]) && $this->isNotNull([$this->where,$this->limit,$this->order]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->table,$this->select,$this->limit,$this->join]) && $this->isNotNull([$this->order,$this->where]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->table,$this->select,$this->order,$this->join]) && $this->isNotNull([$this->limit,$this->where]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->table,$this->select,$this->order,$this->limit,$this->join]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->where)}";
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->join]) && $this->isNotNull([$this->order,$this->limit]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->join]) && $this->isNotNull([$this->order,$this->limit]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->limit,$this->join]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->table,$this->where,$this->select,$this->order,$this->join]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->limit)}";
+
+ // END UNION CLAUSE
+
+ // START TABLE CLAUSE
+
+ if ($this->notDefine([$this->where,$this->select,$this->order,$this->limit,$this->join,$this->union]))
+ return "SELECT * {$this->deleteSpace($this->table)}";
+
+ if ($this->notDefine([$this->select,$this->order,$this->limit,$this->join,$this->union]))
+ return "SELECT * {$this->deleteSpace($this->table)} {$this->deleteSpace($this->where)}";
+
+ if ($this->notDefine([$this->join,$this->union]) && $this->isNotNull([$this->where,$this->select,$this->order,$this->limit]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->order,$this->limit,$this->join,$this->union]) && $this->isNotNull([$this->where,$this->select]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->where)}";
+
+ if ($this->notDefine([$this->select,$this->union]) && $this->isNotNull([$this->join,$this->where,$this->order,$this->limit]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->select,$this->join]) && $this->isNotNull([$this->union,$this->where,$this->limit,$this->order]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->select,$this->join,$this->union]) && $this->isNotNull([$this->where,$this->order,$this->limit]))
+ return "SELECT * {$this->deleteSpace($this->table)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->select, $this->limit,$this->union]) && $this->isNotNull([$this->join,$this->where]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)}";
+
+ if ($this->notDefine([$this->select,$this->limit,$this->join,$this->union]) && $this->isNotNull([$this->order,$this->where]))
+ return "SELECT * {$this->deleteSpace($this->table)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->select,$this->limit,$this->join]) && $this->isNotNull([$this->order,$this->where,$this->union]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->select,$this->limit,$this->union]) && $this->isNotNull([$this->order,$this->where,$this->join]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->select,$this->order,$this->join]) && $this->isNotNull([$this->limit,$this->union,$this->where]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->select,$this->order,$this->union]) && $this->isNotNull([$this->limit,$this->join,$this->where]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->select,$this->order,$this->join,$this->union]) && $this->isNotNull([$this->limit,$this->where]))
+ return "SELECT * {$this->deleteSpace($this->table)} {$this->deleteSpace($this->where)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->select,$this->order,$this->limit,$this->join,$this->union]) && $this->isNotNull([$this->where]))
+ return "SELECT * {$this->deleteSpace($this->table)} {$this->deleteSpace($this->where)}";
+
+ if ($this->notDefine([$this->select,$this->order,$this->limit,$this->join]) && $this->isNotNull([$this->where,$this->union]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->where)}";
+
+ if ($this->notDefine([$this->select,$this->order,$this->limit,$this->union]) && $this->isNotNull([$this->join,$this->where]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->where)}";
+
+ if ($this->notDefine([$this->where,$this->join,$this->union]) && $this->isNotNull([$this->select,$this->order,$this->limit]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where ,$this->union]) && $this->isNotNull([$this->select,$this->order,$this->limit]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where ,$this->join]) && $this->isNotNull([$this->select,$this->order,$this->limit]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where,$this->limit,$this->join,$this->union]) && $this->isNotNull([$this->select,$this->order]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->where,$this->limit,$this->union]) && $this->isNotNull([$this->select,$this->order]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->where,$this->limit,$this->join]) && $this->isNotNull([$this->select,$this->order]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->where,$this->order,$this->join,$this->union]) && $this->isNotNull([$this->select,$this->limit]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where,$this->order,$this->union]) && $this->isNotNull([$this->select,$this->limit]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where,$this->order,$this->join]) && $this->isNotNull([$this->select,$this->limit]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where, $this->order,$this->limit,$this->join]) && $this->isNotNull([$this->select]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)}";
+
+ if ($this->notDefine([$this->where, $this->order,$this->limit,$this->union]) && $this->isNotNull([$this->select]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)}";
+
+ if ($this->notDefine([$this->where,$this->order,$this->limit,$this->join,$this->union]))
+ return "SELECT {$this->deleteSpace($this->select)} {$this->deleteSpace($this->table)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->join]) && $this->isNotNull([$this->union,$this->order,$this->limit]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->union]) && $this->isNotNull([$this->join,$this->order,$this->limit]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->join,$this->union]) && $this->isNotNull([$this->limit,$this->order]))
+ return "SELECT * {$this->deleteSpace($this->table)} {$this->deleteSpace($this->order)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->limit,$this->union]) && $this->isNotNull([$this->order,$this->join]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->limit,$this->join]) && $this->isNotNull([$this->order,$this->union]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->limit,$this->join,$this->union]) && $this->isNotNull([$this->order]))
+ return "SELECT * {$this->deleteSpace($this->table)} {$this->deleteSpace($this->order)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->order,$this->union]) && $this->isNotNull([$this->join,$this->limit]))
+ return "{$this->deleteSpace($this->join)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->order,$this->join]) && $this->isNotNull([$this->limit,$this->union]))
+ return "{$this->deleteSpace($this->union)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->order,$this->join,$this->union]))
+ return "SELECT * {$this->deleteSpace($this->table)} {$this->deleteSpace($this->limit)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->order,$this->limit,$this->union]))
+ return "{$this->deleteSpace($this->join)}";
+
+ if ($this->notDefine([$this->where,$this->select,$this->order,$this->limit,$this->join]))
+ return "{$this->deleteSpace($this->union)}";
+
+ // END TABLE CLAUSE
+
+ break;
+ case Query::DELETE:
+ if (!empty($this->table) && !empty($this->where))
+ return "$mode {$this->table} {$this->where}";
+ break;
+
+ }
+ return '';
+ }
+
+
+ /**
+ * where clause
+ *
+ * @param string $param
+ * @param string $condition
+ * @param mixed $expected
+ * @param string $like
+ * @param null $betweenOne
+ * @param null $betweenTwo
+ *
+ * @return Query
+ */
+ public function where(string $param, string $condition, $expected,string $like = '',$betweenOne = null,$betweenTwo = null ): Query
+ {
+ $likeClause = empty($like) ? false : true;
+ $betweenClause = is_null($betweenOne) && is_null($betweenTwo) ? false : true;
+
+ if ($likeClause)
+ {
+ $this->where = "FROM {$this->table} WHERE $param LIKE '%$like%'";
+ }
+
+ if ($betweenClause)
+ {
+ if (is_string($betweenOne) && is_string($betweenTwo))
+ $this->where = "FROM {$this->table} WHERE $param BETWEEN '$betweenOne' AND '$betweenTwo'";
+ else
+ $this->where = "FROM {$this->table} WHERE $param BETWEEN $betweenOne AND $betweenTwo";
+ }
+
+ if (!$likeClause && !$betweenClause)
+ {
+ if (is_string($expected))
+ $this->where = "WHERE $param $condition '$expected'";
+ else
+ $this->where = "WHERE $param $condition $expected";
+ }
+
+ return $this;
+
+ }
+
+ /**
+ * define the order by
+ *
+ * @param string $key
+ * @param string $order
+ *
+ * @return Query
+ */
+ public function orderBy(string $key, string $order = 'DESC'): Query
+ {
+ $this->order = "ORDER BY $key $order";
+
+ return $this;
+ }
+
+
+ /**
+ * select columns
+ *
+ * @param array $columns
+ *
+ * @return Query
+ */
+ public function setColumns(array $columns = []): Query
+ {
+ $this->select = join(', ', $columns);
+
+ return $this;
+ }
+
+ /**
+ * set pdo instance
+ *
+ * @param PDO $pdo
+ *
+ * @return Query
+ */
+ public function setPdo(PDO $pdo): Query
+ {
+ $this->pdo = $pdo;
+
+ return $this;
+ }
+
+ /**
+ * count all record in a table
+ *
+ * @return int
+ */
+ public function count(): int
+ {
+ $query = $this->pdo->prepare("SELECT COUNT(*) $this->table");
+ $query->execute();
+ return $query->fetchColumn();
+ }
+
+
+ /**
+ * get all records in a table
+ *
+ * @return array
+ */
+ public function getRecords(): array
+ {
+
+ $query = $this->pdo->prepare($this->get());
+ $query->execute();
+ return $query->fetchAll($this->fetch);
+ }
+
+ /**
+ * define a limit
+ *
+ * @param int $limit
+ *
+ * @param int $offset
+ *
+ * @return Query
+ */
+ public function limit(int $limit,int $offset): Query
+ {
+ $this->limit = "LIMIT $limit OFFSET $offset";
+
+ return $this;
+ }
+
+
+ /**
+ * set mode
+ *
+ * @param string $mode
+ *
+ * @return Query
+ */
+ public function setMode(string $mode = Query::SELECT): Query
+ {
+ if (in_array($mode,Query::MODE,true))
+ $this->mode = $mode;
+
+ return $this;
+ }
+
+ /**
+ * run a delete query
+ *
+ * @return bool
+ */
+ public function delete(): bool
+ {
+ if (!empty($this->table) && !empty($this->where))
+ {
+ $query = $this->pdo->prepare("DELETE {$this->table} {$this->where}");
+ return $query->execute();
+ }
+ return false;
+ }
+
+ /**
+ * execute a statement
+ *
+ * @param string $statement
+ *
+ * @return bool
+ */
+ public function query(string $statement): bool
+ {
+ $query = $this->pdo->prepare($statement);
+ return $query->execute();
+ }
+
+ /**
+ * execute a statement
+ *
+ * @param string $statement
+ *
+ * @return array
+ */
+ public function request(string $statement): array
+ {
+ $query = $this->pdo->prepare($statement);
+ $query->execute();
+ return $query->fetchAll($this->fetch);
+ }
+
+
+ /**
+ * join clause
+ *
+ * @param int $type
+ * @param string $firstTable
+ * @param string $secondTable
+ * @param string $firstParam
+ * @param string $secondParam
+ * @param array $columns
+ * @param string $condition
+ *
+ * @return Query
+ */
+ public function join(int $type, string $firstTable,string $secondTable,string $firstParam ,string $secondParam,array $columns = [], string $condition = '=') : Query
+ {
+ $columnsDefine = empty($columns) ? false : true;
+ $select = join(', ',$columns);
+ $mode = empty($this->mode) ? "SELECT" : $this->mode;
+
+ switch ($type)
+ {
+ case Query::INNER_JOIN:
+ if ($columnsDefine)
+ $this->join = "$mode $select FROM $firstTable INNER JOIN $secondTable ON $firstTable.$firstParam $condition $secondTable.$secondParam";
+ else
+ $this->join = "$mode * FROM $firstTable INNER JOIN $secondTable ON $firstTable.$firstParam $condition $secondTable.$secondParam";
+ break;
+ case Query::CROSS_JOIN:
+ if ($columnsDefine)
+ $this->join = "$mode $select FROM $firstTable CROSS JOIN $secondTable";
+ else
+ $this->join = "$mode * FROM $firstTable CROSS JOIN $secondTable";
+ break;
+ case Query::LEFT_JOIN:
+ if ($columnsDefine)
+ $this->join = "$mode $select FROM $firstTable LEFT JOIN $secondTable ON $firstTable.$firstParam $condition $secondTable.$secondParam";
+ else
+ $this->join = "$mode * FROM $firstTable LEFT JOIN $secondTable ON $firstTable.$firstParam $condition $secondTable.$secondParam";
+ break;
+ case Query::RIGHT_JOIN:
+ if ($columnsDefine)
+ $this->join = "$mode $select FROM $firstTable RIGHT JOIN $secondTable ON $firstTable.$firstParam $condition $secondTable.$secondParam";
+ else
+ $this->join = "$mode * FROM $firstTable RIGHT JOIN $secondTable ON $firstTable.$firstParam $condition $secondTable.$secondParam";
+ break;
+ case Query::FULL_JOIN:
+ if ($columnsDefine)
+ $this->join = "$mode $select FROM $firstTable FULL JOIN $secondTable ON $firstTable.$firstParam $condition $secondTable.$secondParam";
+ else
+ $this->join = "$mode * FROM $firstTable FULL JOIN $secondTable ON $firstTable.$firstParam $condition $secondTable.$secondParam";
+ break;
+ case Query::NATURAL_JOIN:
+ if ($columnsDefine)
+ $this->join = "$mode $select FROM $firstTable NATURAL JOIN $secondTable";
+ else
+ $this->join = "$mode * FROM $firstTable NATURAL JOIN $secondTable";
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * union clause
+ *
+ * @param int $mode
+ * @param string $firstTable
+ * @param string $secondTable
+ * @param array $firstColumns
+ * @param array $secondColumns
+ *
+ * @return Query
+ */
+ public function union(int $mode,string $firstTable,string $secondTable,array $firstColumns,array $secondColumns): Query
+ {
+ $first = join(', ',$firstColumns);
+ $second = join(', ',$secondColumns);
+
+ switch ($mode)
+ {
+ case Query::MODE_UNION:
+ if (empty($firstColumns) && empty($secondColumns))
+ $this->union = "SELECT * FROM $firstTable UNION SELECT * FROM $secondTable";
+ else
+ $this->union = "SELECT $first FROM $firstTable UNION SELECT $second FROM $secondTable";
+ break;
+
+ case Query::MODE_UNION_ALL:
+ if (empty($firstColumns) && empty($secondColumns))
+ $this->union = "SELECT * FROM $firstTable UNION ALL SELECT * FROM $secondTable";
+ else
+ $this->union = "SELECT $first FROM $firstTable UNION ALL SELECT $second FROM $secondTable";
+ break;
+
+ }
+
+ return $this;
+ }
+
+ /**
+ * execute the query
+ *
+ * @return bool
+ */
+ public function execute(): bool
+ {
+ return $this->query($this->get());
+ }
+
+ /**
+ * @param Table $table
+ * @param string $like
+ *
+ * @return Query
+ */
+ public function like(Table $table,string $like): Query
+ {
+ if (in_array($this->driver,[Connexion::POSTGRESQL,Connexion::MYSQL]))
+ {
+ $columns = join(', ', $table->getColumns());
+
+ $this->where = "WHERE CONCAT($columns) LIKE '%$like%'";
+ }
+
+ if (in_array($this->driver,[Connexion::SQLITE]))
+ {
+ $fields = $table->getColumns();
+ $end = end($fields);
+ $columns = '';
+
+ foreach ($fields as $column)
+ {
+ if ($column != $end)
+ $columns .= "$column LIKE '%$like%' OR ";
+ else
+ $columns .= "$column LIKE '%$like%'";
+ }
+
+ $this->where = "WHERE $columns";
+ }
+ return $this;
+ }
+
+ /**
+ * set database driver
+ *
+ * @param string $driver
+ *
+ * @return \Imperium\Databases\Eloquent\Query\Query
+ */
+ public function setDriver(string $driver): Query
+ {
+ $this->driver = $driver;
+ return $this;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Share.php b/imperium/Databases/Eloquent/Share.php
new file mode 100644
index 0000000..b190e7f
--- /dev/null
+++ b/imperium/Databases/Eloquent/Share.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * fumseck added Share.php to imperium
+ * The 11/09/17 at 09:40
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+
+namespace Imperium\Databases\Eloquent;
+
+
+trait Share
+{
+ /**
+ * @var string $driver
+ */
+ private $driver;
+ /**
+ * @var string $database
+ */
+ private $database;
+
+ /**
+ * @var string $username
+ */
+ private $username;
+
+ /**
+ * @var string $password
+ */
+ private $password;
+
+ /**
+ * @var string $rights
+ */
+ private $rights;
+
+ /**
+ * @var array $hidden
+ */
+ private $hidden;
+
+ /**
+ * @var string $encoding
+ */
+ private $encoding;
+
+ /**
+ * @var string $collation
+ */
+ private $collation;
+
+ /**
+ * @var string $dump
+ */
+ private $path;
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Tables/EloquentTableBuilder.php b/imperium/Databases/Eloquent/Tables/EloquentTableBuilder.php
new file mode 100644
index 0000000..3afb681
--- /dev/null
+++ b/imperium/Databases/Eloquent/Tables/EloquentTableBuilder.php
@@ -0,0 +1,402 @@
+<?php
+/**
+ * fumseck added EloquentBuilder.php to imperium
+ * The 09/09/17 at 19:41
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Databases\Eloquent\Tables {
+
+ use Imperium\Databases\Eloquent\Eloquent;
+
+
+ /**
+ * Interface EloquentTableBuilder
+ *
+ * @package Imperium\Eloquent
+ */
+ interface EloquentTableBuilder
+ {
+
+ /**
+ * start table query builder
+ *
+ * @return Table
+ */
+ public static function manage(): Table;
+
+ /**
+ * update a table
+ *
+ * @param int $id
+ * @param array $values
+ * @param array $ignore
+ * @param string|null $table
+ *
+ * @return bool
+ */
+ public function update(int $id,array $values,array $ignore= [],string $table = ''): bool;
+
+ /**
+ * set hidden tables
+ *
+ * @param array $hidden
+ *
+ * @return Table
+ */
+ public function setHidden(array $hidden): Table;
+
+ /**
+ * define name of table
+ *
+ * @param string $table
+ *
+ * @return Table
+ */
+ public function setName(string $table): Table;
+
+ /**
+ * define new name of table
+ *
+ * @param string $newName
+ *
+ * @return Table
+ */
+ public function setNewName(string $newName): Table;
+
+ /**
+ * rename a table
+ *
+ * @return bool
+ */
+ public function rename(): bool;
+
+ /**
+ * check if current database has table
+ *
+ * @return bool
+ */
+ public function has(): bool;
+
+ /**
+ * check if table has a special column
+ *
+ * @param string $column
+ *
+ * @return bool
+ */
+ public function hasColumn(string $column): bool;
+
+
+ /**
+ * get columns types
+ *
+ * @return array
+ */
+ public function getColumnsTypes(): array;
+
+ /**
+ * get all columns in a table
+ *
+ * @return array
+ */
+ public function getColumns(): array;
+
+
+ /**
+ * delete a table
+ *
+ * @param string $table
+ *
+ * @return bool
+ */
+ public function drop(string $table = ''): bool;
+
+ /**
+ * delete all tables not ignored in database
+ *
+ * @return bool
+ */
+ public function dropAll(): bool;
+
+ /**
+ * truncate one or all tables
+ *
+ * @param string $table
+ * @param int $mode
+ *
+ * @return bool
+ */
+ public function truncate(string $table = '', int $mode = Eloquent::MODE_ONE_TABLE): bool;
+
+ /**
+ * add a new field in create task
+ *
+ * @param string $type
+ * @param string $name
+ * @param bool $primary
+ * @param int $length
+ * @param bool $unique
+ * @param bool $nullable
+ *
+ * @return Table
+ */
+ public function addField(string $type, string $name, bool $primary = false, int $length = 0, bool $unique = true, bool $nullable = false): Table;
+
+ /**
+ * add a column in a existing table
+ *
+ * @param string $column
+ * @param string $type
+ * @param int $size
+ * @param bool $unique
+ * @param bool $nullable
+ *
+ * @return bool
+ */
+ public function addColumn(string $column, string $type, int $size = 0, bool $unique = true, bool $nullable = false): bool;
+
+ /**
+ * create the table
+ *
+ *
+ * @return bool|string
+ */
+ public function create();
+
+ /**
+ * set the engine
+ *
+ * @param string $engine
+ *
+ * @return Table
+ */
+ public function setEngine(string $engine): Table;
+
+ /**
+ * return create table sql query
+ *
+ * @return string
+ */
+ public function get(): string;
+
+ /**
+ * dump a table
+ *
+ * @param string $table
+ *
+ * @return mixed
+ */
+ public function dump(string $table = null);
+
+ /**
+ * get the primary key of a table
+ *
+ * @return string|null
+ */
+ public function primaryKey();
+
+ /**
+ * check if a table is empty
+ *
+ * @return bool
+ */
+ public function isEmpty(): bool;
+
+ /**
+ * select a record by id
+ *
+ * @param int $id
+ *
+ * @return array
+ */
+ public function selectById(int $id): array;
+
+ /**
+ * delete a record by id
+ *
+ * @param int $id
+ *
+ * @return bool
+ */
+ public function deleteById(int $id): bool;
+
+ /**
+ * rename a existing column
+ *
+ * @param string $old
+ * @param string $new
+ *
+ * @return bool
+ */
+ public function renameColumn(string $old, string $new): bool;
+
+ /**
+ * delete a column
+ *
+ * @param string $column
+ *
+ * @return bool
+ */
+ public function deleteColumn(string $column): bool;
+
+ /**
+ * check if a table exist
+ *
+ * @param string $table
+ *
+ * @return bool
+ */
+ public function exist(string $table = ''): bool;
+
+ /**
+ * insert values
+ *
+ * @param array $values
+ * @param array $toIgnore
+ * @param string|null $table
+ *
+ * @return bool
+ */
+ public function insert(array $values,array $toIgnore = [],string $table = null): bool;
+
+ /**
+ * set tables to ignore
+ *
+ * @param array $tables
+ *
+ * @return Table
+ */
+ public function ignore(array $tables): Table;
+
+ /**
+ * set the dump directory path
+ *
+ * @param string $path
+ *
+ * @return Table
+ */
+ public function setDumpPath(string $path): Table;
+
+ /**
+ * show all tables in a database
+ *
+ * @return array
+ */
+ public function show(): array;
+
+ /**
+ * count all table in current database
+ *
+ * @return int
+ */
+ public function countTable(): int;
+
+ /**
+ * count number of records in a or multiples tables
+ *
+ * @param string|null $table
+ * @param int $mode
+ *
+ * @return array|int
+ */
+ public function count(string $table = '', int $mode = Eloquent::MODE_ONE_TABLE);
+
+ /**
+ * set the database driver
+ *
+ * @param string $driver
+ *
+ * @return Table
+ */
+ public function setDriver(string $driver): Table;
+
+ /**
+ * set name of database
+ *
+ * @param string $database
+ *
+ * @return Table
+ */
+ public function setDatabase(string $database): Table;
+
+ /**
+ * define database username
+ *
+ * @param string $username
+ *
+ * @return Table
+ */
+ public function setUsername(string $username): Table;
+
+ /**
+ * define username password
+ *
+ * @param string $password
+ *
+ * @return Table
+ */
+ public function setPassword(string $password): Table;
+
+ /**
+ * execute a statement
+ *
+ * @param string $statement
+ *
+ * @return bool
+ */
+ public function exec(string $statement): bool;
+
+ /**
+ * execute a statement
+ *
+ * @param string $statement
+ *
+ * @return array
+ */
+ public function request(string $statement): array;
+
+ /**
+ * get all record in a table
+ *
+ * @param string $orderBy
+ *
+ * @return array
+ */
+ public function getRecords(string $orderBy = ''): array;
+
+ /**
+ * optimize a table
+ *
+ * @return bool
+ */
+ public function optimize(): bool;
+
+ /**
+ * modify an existing column
+ *
+ * @param string $column
+ * @param string $type
+ * @param int $size
+ *
+ * @return bool
+ */
+ public function modifyColumn(string $column,string $type,int $size = 0): bool;
+
+ }
+
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Tables/Table.php b/imperium/Databases/Eloquent/Tables/Table.php
new file mode 100644
index 0000000..b1dd787
--- /dev/null
+++ b/imperium/Databases/Eloquent/Tables/Table.php
@@ -0,0 +1,1583 @@
+<?php
+/**
+ * fumseck added Builder.php to imperium
+ * The 09/09/17 at 19:39
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+namespace Imperium\Databases\Eloquent\Tables {
+
+
+ use Imperium\Databases\Dumper\Tables\MySQLTable;
+ use Imperium\Databases\Dumper\Tables\PostgreSQLTable;
+ use Imperium\Databases\Dumper\Tables\SQLiteTable;
+ use Imperium\Databases\Eloquent\Connexion\Connexion;
+ use Imperium\Databases\Eloquent\Eloquent;
+ use Imperium\File\File;
+ use Monolog\Handler\IFTTTHandler;
+ use PDO;
+
+ class Table extends Eloquent implements EloquentTableBuilder
+ {
+
+
+ /**
+ * @var string
+ */
+ private $driver;
+
+ /**
+ * @var string
+ */
+ private $table;
+
+ /**
+ * @var string
+ */
+ private $new;
+
+ /**
+ * @var string
+ */
+ private $database;
+
+ /**
+ * @var string
+ */
+ private $username;
+
+ /**
+ * @var string
+ */
+ private $password;
+
+ /**
+ * @var array
+ */
+ private $columns = array();
+
+ /**
+ * @var string
+ */
+ private $path;
+
+ /**
+ * @var array
+ */
+ private $hidden;
+
+ /**
+ * @var int
+ */
+ private $fetch = PDO::FETCH_OBJ;
+
+ /**
+ * @var string
+ */
+ private $engine;
+
+ /**
+ * start table query builder
+ *
+ * @return Table
+ */
+ public static function manage(): Table
+ {
+ return new static();
+ }
+
+ /**
+ * define name of table
+ *
+ * @param string $table
+ *
+ * @return Table
+ */
+ public function setName(string $table): Table
+ {
+ $this->table = $table;
+
+ return $this;
+ }
+
+ /**
+ * get driver
+ *
+ * @return string
+ */
+ public function getDriver(): string
+ {
+ return $this->driver;
+ }
+ /**
+ * define new name of table
+ *
+ * @param string $newName
+ *
+ * @return Table
+ */
+ public function setNewName(string $newName): Table
+ {
+ $this->new = $newName;
+
+ return $this;
+ }
+
+ /**
+ * rename a table
+ *
+ * @return bool
+ */
+ public function rename(): bool
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL :
+ return $this->exec("RENAME TABLE {$this->table} TO {$this->new}");
+ break;
+ case Connexion::POSTGRESQL:
+ return $this->exec("ALTER TABLE {$this->table} RENAME TO {$this->new}");
+ break;
+ case Connexion::SQLITE:
+ return $this->exec("ALTER TABLE {$this->table} RENAME TO {$this->new}");
+ break;
+
+ case Connexion::ORACLE:
+ return $this->exec("ALTER TABLE {$this->table} RENAME TO {$this->new}");
+ break;
+ default:
+ return false;
+ break;
+ }
+ }
+
+ /**
+ * check if current database has table
+ *
+ * @return bool
+ */
+ public function has(): bool
+ {
+ return !empty($this->show());
+ }
+
+ /**
+ * check if table has a special column
+ *
+ * @param string $column
+ *
+ * @return bool
+ */
+ public function hasColumn(string $column): bool
+ {
+ return in_array($column,$this->getColumns());
+ }
+
+
+
+ /**
+ * get columns types
+ *
+ * @return array
+ */
+ public function getColumnsTypes(): array
+ {
+ $types = array();
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+
+ foreach ($this->request("SHOW FULL COLUMNS FROM $this->table") as $type)
+ push($types, $type->Type);
+
+ break;
+
+ case Connexion::POSTGRESQL:
+
+ foreach ($this->request("SELECT data_type FROM information_schema.columns WHERE table_name ='$this->table';") as $type)
+ push($types,$type->data_type);
+
+ break;
+
+ case Connexion::SQLITE:
+
+ foreach ($this->request("PRAGMA table_info($this->table)") as $type)
+ push($types, $type->type);
+
+ break;
+
+ case Connexion::ORACLE :
+
+ foreach ($this->request("SELECT data_type FROM user_tab_cols WHERE table_name = '$this->table'") as $field)
+ push($fields,$field->data_type);
+ break;
+ default:
+ return $types;
+ break;
+ }
+ return $types;
+ }
+
+ /**
+ * get all columns in a table
+ *
+ * @return array
+ */
+ public function getColumns(): array
+ {
+ $fields = array();
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL :
+ foreach ($this->request("SHOW FULL COLUMNS FROM $this->table") as $column)
+ array_push($fields,$column->Field);
+ break;
+
+ case Connexion::POSTGRESQL :
+
+ foreach ($this->request("SELECT column_name FROM information_schema.columns WHERE table_name ='$this->table'") as $field)
+ array_push($fields, $field->column_name);
+
+ break;
+
+ case Connexion::SQLITE :
+
+ foreach ($this->request("PRAGMA table_info($this->table)") as $field)
+ array_push($fields,"$field->name");
+ break;
+
+ case Connexion::ORACLE :
+
+ foreach ($this->request("SELECT column_name FROM user_tab_cols WHERE table_name = '$this->table'") as $field)
+ array_push($fields,$field->column_name);
+ break;
+ }
+ return $fields;
+ }
+
+ /**
+ * delete a table
+ *
+ * @param string|null $table
+ *
+ * @return bool
+ */
+ public function drop(string $table = '' ): bool
+ {
+
+ if ($this->isOracle())
+ {
+ if (!empty($table))
+ return $this->exec("DROP TABLE $table CASCADE CONSTRAINT PURGE");
+ else
+ return $this->exec("DROP TABLE {$this->table} CASCADE CONSTRAINT PURGE");
+ }
+
+ if (!empty($table) && $this->isMysql())
+ return $this->exec("DROP TABLE `{$table}`");
+
+ if (empty($table) && $this->isMysql())
+ return $this->exec("DROP TABLE `{$this->table}`");
+
+ if (!empty($table))
+ return $this->exec("DROP TABLE $table");
+ else
+ return $this->exec("DROP TABLE {$this->table}");
+ }
+
+ /**
+ * truncate one or all tables
+ *
+ * @param string|null $table
+ * @param int $mode
+ *
+ * @return bool
+ */
+ public function truncate(string $table = '',int $mode = Eloquent::MODE_ONE_TABLE): bool
+ {
+ if (!empty($table))
+ $this->table = $table;
+
+ if ($mode == Eloquent::MODE_ONE_TABLE)
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL :
+ return $this->exec("TRUNCATE TABLE {$this->table}");
+
+ case Connexion::POSTGRESQL :
+ return $this->exec("TRUNCATE TABLE {$this->table} RESTART IDENTITY");
+ break;
+
+ case Connexion::SQLITE :
+ return $this->truncateSqliteTable($this->table);
+ break;
+ case Connexion::ORACLE :
+ return $this->exec("TRUNCATE TABLE {$this->table} DROP STORAGE");
+ break;
+ }
+
+ }
+ if ($mode == Eloquent::MODE_ALL_TABLES)
+ {
+ foreach ($this->show() as $table)
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL :
+ if (!$this->exec("TRUNCATE TABLE $table"))
+ return false;
+ break;
+
+ case Connexion::POSTGRESQL :
+ if (!$this->exec("TRUNCATE TABLE $table RESTART IDENTITY"))
+ return false;
+ break;
+
+ case Connexion::ORACLE :
+ if (!$this->exec("TRUNCATE TABLE $table DROP STORAGE"))
+ return false;
+ break;
+
+ case Connexion::SQLITE :
+ if (!$this->truncateSqliteTable($table))
+ return false;
+ break;
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * add a new field in create task
+ *
+ * @param string $type
+ * @param string $name
+ * @param bool $primary
+ * @param int $length
+ * @param bool $unique
+ * @param bool $nullable
+ *
+ * @return Table
+ */
+ public function addField(string $type, string $name, bool $primary = false, int $length = 0, bool $unique = true, bool $nullable = false): Table
+ {
+ if (empty($this->columns))
+ {
+ $this->columns[] = [Table::FIELD_NAME => $name ,Table::FIELD_TYPE => $type,Table::FIELD_PRIMARY=> $primary,Table::FIELD_LENGTH => $length,Table::FIELD_UNIQUE => $unique,Table::FIELD_NULLABLE => $nullable];
+ } else {
+ $new[] = [Table::FIELD_NAME => $name ,Table::FIELD_TYPE => $type,Table::FIELD_PRIMARY=> $primary,Table::FIELD_LENGTH => $length,Table::FIELD_UNIQUE => $unique,Table::FIELD_NULLABLE => $nullable];
+ $this->columns = array_merge($this->columns,$new);
+ }
+
+ return $this;
+
+ }
+
+ /**
+ * add a column in a existing table
+ *
+ * @param string $column
+ * @param string $type
+ * @param int $size
+ * @param bool $unique
+ * @param bool $nullable
+ *
+ * @return bool
+ */
+ public function addColumn(string $column, string $type, int $size = 0, bool $unique = true, bool $nullable = false): bool
+ {
+ $command = "ALTER TABLE {$this->table} ADD COLUMN ";
+
+ if ($size)
+ $command .= " $column $type($size)";
+ else
+ $command .= " $column $type";
+
+ return $this->exec($command);
+ }
+
+ /**
+ * create the table
+ *
+ * @return bool
+ */
+ public function create()
+ {
+ $command = $this->startCreateCommand();
+
+ foreach ($this->columns as $field)
+ $command .= $this->updateCreateCommand($field);
+
+ $command .= ')';
+
+ if ($this->isMysql() && !is_null($this->engine))
+ $command .= " ENGINE = {$this->engine}";
+
+ $this->columns = [];
+
+ return $this->exec($command);
+ }
+
+ /**
+ * start creation of a table
+ *
+ * @return string
+ */
+ protected function startCreateCommand() : string
+ {
+ if ($this->isMysql())
+ return "CREATE TABLE IF NOT EXISTS `{$this->table}` ( ";
+ else
+ return "CREATE TABLE IF NOT EXISTS {$this->table} ( ";
+ }
+
+ /**
+ * append field in command to create table
+ *
+ * @param array $field
+ * @return string
+ */
+ protected function updateCreateCommand(array $field) : string
+ {
+
+ $size = $field[Table::FIELD_LENGTH];
+
+ $command = '';
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+
+ foreach ($field as $k => $v)
+ {
+ if ($k == Table::FIELD_NAME)
+ $command .= "`$v`";
+
+ if ($k == Table::FIELD_TYPE)
+ {
+ if ($size)
+ $command .= " $v($size)";
+ else
+ $command .= " $v";
+ }
+
+
+ if ($k == Table::FIELD_PRIMARY)
+ {
+ if ($v)
+ $command .= ' AUTO_INCREMENT PRIMARY KEY';
+ }
+
+ if ($k == Table::FIELD_UNIQUE)
+ {
+
+ if ($v)
+ $command .= " UNIQUE";
+ }
+
+ if ($k == Table::FIELD_NULLABLE)
+ {
+ if (!$v)
+ $command .= " NOT NULL";
+ }
+
+
+ }
+ if (!$this->isEnd($field))
+ $command .= ', ';
+
+ break;
+
+ case Connexion::POSTGRESQL:
+
+ foreach ($field as $k => $v)
+ {
+ if ($k == Table::FIELD_NAME)
+ $command .= "$v";
+
+ if ($k == Table::FIELD_TYPE)
+ {
+ if ($field[Table::FIELD_LENGTH])
+ $command .= " $v($size)";
+ else
+ $command .= " $v";
+ }
+
+
+ if ($k == Table::FIELD_PRIMARY)
+ {
+ if ($v)
+ $command .= ' PRIMARY KEY';
+ }
+
+ if ($k == Table::FIELD_UNIQUE)
+ {
+ if ($v)
+ $command .= " UNIQUE";
+ }
+
+ if ($k == Table::FIELD_NULLABLE)
+ {
+ if (!$v)
+ $command .= " NOT NULL";
+ }
+ }
+
+ if (!$this->isEnd($field))
+ $command .= ', ';
+
+ break;
+
+ case Connexion::SQLITE:
+
+ foreach ($field as $k => $v)
+ {
+ if ($k == Table::FIELD_NAME)
+ $command .= "'$v'";
+
+ if ($k == Table::FIELD_TYPE)
+ {
+ if ($size)
+ $command .= " $v($size)";
+ else
+ $command .= " $v";
+ }
+
+
+ if ($k == Table::FIELD_PRIMARY)
+ {
+ if ($v)
+ $command .= ' PRIMARY KEY AUTOINCREMENT';
+ }
+
+ if ($k == Table::FIELD_UNIQUE)
+ {
+ if ($v)
+ $command .= " UNIQUE";
+ }
+
+ if ($k == Table::FIELD_NULLABLE)
+ {
+ if (!$v)
+ $command .= " NOT NULL";
+ }
+ }
+
+ if (!$this->isEnd($field))
+ $command .= ', ';
+
+
+ break;
+ case Connexion::ORACLE;
+
+ foreach ($field as $k => $v)
+ {
+ if ($k == Table::FIELD_NAME)
+ $command .= "$v";
+
+ if ($k == Table::FIELD_TYPE)
+ {
+ if ($size)
+ $command .= " $v($size)";
+ else
+ $command .= " $v";
+ }
+
+
+ if ($k == Table::FIELD_PRIMARY)
+ {
+ if ($v)
+ $command .= ' PRIMARY KEY';
+ }
+
+ if ($k == Table::FIELD_UNIQUE)
+ {
+
+ if ($v)
+ $command .= " UNIQUE";
+ }
+
+ if ($k == Table::FIELD_NULLABLE)
+ {
+ if (!$v)
+ $command .= " NOT NULL";
+ }
+ }
+
+ if (!$this->isEnd($field))
+ $command .= ', ';
+
+ break;
+ }
+ return $command;
+ }
+
+ /**
+ * set hidden tables
+ *
+ * @param array $hidden
+ *
+ * @return Table
+ */
+ public function setHidden(array $hidden) : Table
+ {
+ $this->hidden = $hidden;
+
+ return $this;
+ }
+
+ /**
+ * check if current type id mysql
+ *
+ * @return bool
+ */
+ protected function isMysql() : bool
+ {
+ return $this->driver == Connexion::MYSQL;
+ }
+ /**
+ * check if current type is postgresql
+ *
+ * @return bool
+ */
+ protected function isPostgresql() : bool
+ {
+ return $this->driver == Connexion::POSTGRESQL;
+ }
+
+ /**
+ * check if current type is oracle
+ *
+ * @return bool
+ */
+ protected function isOracle()
+ {
+ return $this->driver == Connexion::ORACLE;
+ }
+ /**
+ * check if current type is sqlite
+ *
+ * @return bool
+ */
+ protected function isSqlite() : bool
+ {
+ return $this->driver == Connexion::SQLITE;
+ }
+
+ /**
+ * return the last field name
+ *
+ * @param array $fields
+ * @return string
+ */
+ protected function end(array $fields) : string
+ {
+ $fieldsKeys = array_keys($fields);
+ $end = end($fieldsKeys);
+ foreach ($fields as $k => $field)
+ {
+ if($k == $end)
+ return $field[Table::FIELD_NAME];
+ }
+ return '';
+ }
+ /**
+ * check if is the end of fields
+ *
+ * @param $field
+ * @return bool
+ */
+ protected function isEnd($field) : bool
+ {
+ if (is_array($field))
+ return $this->end($this->columns) == $field[Table::FIELD_NAME];
+ else
+ return $this->end($this->columns) == $field ;
+ }
+
+
+ /**
+ * dump a table
+ *
+ * @param string $table
+ *
+ * @return mixed
+ */
+ public function dump(string $table = null)
+ {
+ if(empty($this->table) && is_null($table))
+ return false;
+
+ if (is_null($table))
+ $file = "{$this->path}/{$this->table}.sql";
+ else
+ $file = "{$this->path}/$table.sql";
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL :
+ if (is_null($table))
+ MySQLTable::dump()->setTable($this->table)->setDbName($this->database)->setPassword($this->password)->setUserName($this->username)->dumpToFile($file,$this->path);
+ else
+ MySQLTable::dump()->setTable($table)->setDbName($this->database)->setPassword($this->password)->setUserName($this->username)->dumpToFile($file,$this->path);
+ File::download($file);
+ break;
+ case Connexion::POSTGRESQL :
+ if (is_null($table))
+ PostgreSQLTable::dump()->setTable($this->table)->setDbName($this->database)->setPassword($this->password)->setUserName($this->username)->dumpToFile($file,$this->path);
+ else
+ PostgreSQLTable::dump()->setTable($table)->setDbName($this->database)->setPassword($this->password)->setUserName($this->username)->dumpToFile($file,$this->path);
+ File::download($file);
+ break;
+ case Connexion::SQLITE:
+ if (is_null($table))
+ SQLiteTable::dump()->setTable($this->table)->setDbName($this->database)->dumpToFile( $file,$this->path);
+ else
+ SQLiteTable::dump()->setTable($table)->setDbName($this->database)->dumpToFile( $file,$this->path);
+ File::download($file);
+ break;
+ }
+ return null;
+ }
+
+ /**
+ * get the primary key of a table
+ *
+ * @return string|null
+ */
+ public function primaryKey()
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+
+ foreach ($this->request("show columns from {$this->table} where `Key` = 'PRI';") as $key)
+ return current($key);
+
+ break;
+
+ case Connexion::POSTGRESQL:
+
+ foreach($this->request (
+ "SELECT a.attname, format_type(a.atttypid, a.atttypmod) AS data_type
+ FROM pg_index i
+ JOIN pg_attribute a ON a.attrelid = i.indrelid
+ AND a.attnum = ANY(i.indkey)
+ WHERE i.indrelid = '{$this->table}'::regclass AND i.indisprimary;") as $key
+ )
+ return current($key);
+ break;
+
+ case Connexion::SQLITE:
+
+ foreach ($this->request("PRAGMA table_info($this->table)") as $field)
+ {
+ if ($field->pk)
+ return $field->name;
+ }
+
+ break;
+ case Connexion::ORACLE:
+ foreach ($this->request
+
+ ("SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
+ FROM all_constraints cons, all_cons_columns cols
+ WHERE cols.table_name = UPPER({$this->table})
+ AND cons.constraint_type = 'P'
+ AND cons.constraint_name = cols.constraint_name
+ AND cons.owner = cols.owner
+ ORDER BY cols.table_name, cols.position;") as $key
+ )
+ {
+ return current($key);
+ }
+ break;
+ }
+ return null;
+ }
+
+ /**
+ * check if a table is empty
+ *
+ * @return bool
+ */
+ public function isEmpty(): bool
+ {
+ return empty($this->getRecords());
+ }
+
+ /**
+ * select a record by id
+ *
+ * @param int $id
+ *
+ * @return array
+ */
+ public function selectById(int $id): array
+ {
+ return $this->request("SELECT * FROM {$this->table} WHERE {$this->primaryKey()} = $id" );
+ }
+
+ /**
+ * delete a record by id
+ *
+ * @param int $id
+ *
+ * @return bool
+ */
+ public function deleteById(int $id): bool
+ {
+ return $this->exec("DELETE FROM {$this->table} WHERE {$this->primaryKey()} = $id");
+ }
+
+ /**
+ * rename a existing column
+ *
+ * @param string $old
+ * @param string $new
+ *
+ * @return bool
+ */
+ public function renameColumn(string $old, string $new): bool
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ if ($old != $this->primaryKey())
+ return $this->exec("ALTER TABLE $this->table RENAME $old TO $new");
+ else
+ return false;
+ break;
+
+ case Connexion::POSTGRESQL:
+ if ($old != $this->primaryKey())
+ return $this->exec("ALTER TABLE $this->table RENAME COLUMN $old TO $new");
+ else
+ return false;
+ break;
+
+ case Connexion::ORACLE:
+ if ($old != $this->primaryKey())
+ return $this->exec("ALTER TABLE $this->table RENAME COLUMN $old TO $new");
+ else
+ return false;
+ break;
+
+ case Connexion::SQLITE:
+ $newColumns = array();
+ $columns = $this->getColumns();
+ $types = $this->getColumnsTypes();
+ $tmp = "_$this->table";
+
+ foreach ($columns as $k => $column)
+ {
+ switch ($column)
+ {
+ case $this->primaryKey():
+ if ($column == $old)
+ array_push($newColumns," '$new' $types[$k] PRIMARY KEY AUTOINCREMENT ");
+ else
+ array_push($newColumns," '$column' $types[$k] PRIMARY KEY AUTOINCREMENT ");
+ break;
+ case $old:
+ array_push($newColumns," '$new' $types[$k] ");
+ break;
+ default:
+ array_push($newColumns," '$column' $types[$k] ");
+ break;
+ }
+
+ }
+
+ $columns = join(', ',$newColumns);
+
+ $query = "CREATE TABLE IF NOT EXISTS $this->table (";
+ $query .= $columns;
+ $query .= ')';
+
+
+ $this->setNewName($tmp)->rename();
+ $this->exec($query);
+ $this->exec("INSERT INTO $this->table SELECT * FROM '$tmp'") ;
+ return $this->drop($tmp);
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * delete a column
+ *
+ * @param string $column
+ *
+ * @return bool
+ */
+ public function deleteColumn(string $column): bool
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ return $this->exec("ALTER TABLE $this->table DROP $column");
+ break;
+ case Connexion::POSTGRESQL:
+ return $this->exec("ALTER TABLE $this->table DROP COLUMN $column RESTRICT");
+ break;
+ case Connexion::ORACLE:
+ return $this->exec("ALTER TABLE $this->table DROP COLUMN $column");
+ break;
+ case Connexion::SQLITE:
+
+ $new = md5($this->table);
+ $origin = $this->getColumns();
+ $types = $this->getColumnsTypes();
+ $fields = array();
+
+ foreach ($origin as $k => $value)
+ {
+ switch ($value)
+ {
+ case $column: // do nothing if is the column to delete it
+ break;
+ case $this->isEnd($value):
+ array_push($fields,"$origin[$k] $types[$k]");
+ break;
+ default:
+ array_push($fields,"$origin[$k] $types[$k],");
+ break;
+ }
+ }
+
+ $query = "CREATE TABLE IF NOT EXISTS $this->table (";
+ $tableFields = '';
+ foreach ($fields as $item)
+ {
+ $query .= $item;
+ $tableFields .= $item;
+ }
+
+ $query .= ')';
+ $old = implode(' ',$origin);
+
+ $this->exec("ALTER TABLE $this->table RENAME TO $new;");
+ $this->exec($query);
+ $this->exec("INSERT INTO $this->table ($tableFields) SELECT $old FROM $new");
+ return $this->exec("DROP TABLE $new");
+ break;
+ default:
+ return false;
+ break;
+
+ }
+ }
+
+
+ /**
+ * check if a table exist
+ *
+ * @param string $table
+ *
+ * @return bool
+ */
+ public function exist(string $table = ""): bool
+ {
+ if (!empty($table))
+ return has($table,$this->show());
+ else
+ return has($this->table,$this->show());
+ }
+
+ /**
+ * insert values
+ *
+ * @param array $values
+ * @param array $toIgnore
+ * @param string|null $table
+ *
+ * @return bool
+ */
+ public function insert(array $values,array $toIgnore = [],string $table = null): bool
+ {
+ if (!is_null($table))
+ $this->table = $table;
+
+ $columns = join(', ',$this->getColumns());
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ $val = array();
+
+ foreach ($values as $key => $value)
+ {
+ if (!in_array($value,$toIgnore))
+ {
+ if (empty($value))
+ {
+ array_push($val,'NULL');
+ }else {
+ if (is_numeric($value))
+ array_push($val,$value);
+ else
+ array_push($val,"'".addslashes($value)."'");
+ }
+ }
+ }
+
+ $value = '(' . join(', ',$val) .')';
+ $command = "INSERT INTO `$this->table` ($columns) VALUES $value";
+
+ return $this->exec($command);
+ break;
+
+ case Connexion::POSTGRESQL:
+
+ $val = array();
+ foreach ($values as $key => $value)
+ {
+ if (!in_array($value,$toIgnore))
+ {
+ if (empty($value))
+ {
+ array_push($val,'DEFAULT');
+ }else{
+ if (is_numeric($value))
+ array_push($val,$value);
+ else
+ array_push($val,"'".addslashes($value)."'");
+
+ }
+ }
+ }
+
+ $value = '(' . join(', ',$val) .')';
+ $command = "INSERT INTO $this->table ($columns) VALUES $value";
+ return $this->exec($command);
+ break;
+
+ case Connexion::SQLITE:
+
+ $val = array();
+
+ foreach ($values as $key => $value)
+ {
+ if (!in_array($value,$toIgnore))
+ {
+ if (empty($value))
+ {
+ array_push($val,'NULL');
+ }else {
+ if (is_numeric($value))
+ array_push($val,$value);
+ else
+ array_push($val,"'".addslashes($value)."'");
+ }
+ }
+ }
+
+ $value = '(' . join(', ',$val) .')';
+ $command = "INSERT INTO $this->table ($columns) VALUES $value";
+ return $this->exec($command);
+ break;
+ default:
+ return false;
+ break;
+ }
+ }
+
+ /**
+ * set tables to ignore
+ *
+ * @param array $tables
+ *
+ * @return Table
+ */
+ public function ignore(array $tables): Table
+ {
+ $this->hidden = $tables;
+
+ return $this;
+ }
+
+ /**
+ * set the dump directory path
+ *
+ * @param string $path
+ *
+ * @return Table
+ */
+ public function setDumpPath(string $path): Table
+ {
+ $this->path = $path;
+
+ return $this;
+ }
+
+ /**
+ * show all tables in a database
+ *
+ * @return array
+ */
+ public function show(): array
+ {
+ $tables = array();
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL :
+
+ foreach ($this->request("SHOW TABLES") as $table)
+ {
+ if (!empty($this->hidden))
+ {
+ if (!has(current($table),$this->hidden))
+ push($tables,current($table));
+ } else {
+ push($tables,current($table));
+ }
+ }
+ break;
+
+ case Connexion::POSTGRESQL:
+
+ foreach ($this->request("SELECT table_schema || '.' || table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema NOT IN ('pg_catalog', 'information_schema');") as $table)
+ {
+
+ if (!empty($this->hidden))
+ {
+ if (!has(current($table),$this->hidden))
+ push($tables,current($table));
+ } else {
+ push($tables,current($table));
+ }
+ }
+ break;
+
+ case Connexion::SQLITE:
+
+ foreach ($this->request("SELECT tbl_name FROM sqlite_master") as $table)
+ {
+ $t = $table->tbl_name;
+ if (!has($t,$tables))
+ {
+ if (!empty($this->hidden))
+ {
+ if (!has($t,$this->hidden))
+ {
+ push($tables,$t);
+ }
+ }else{
+ push($tables,$t);
+ }
+ }
+
+ }
+
+ break;
+
+ case Connexion::ORACLE:
+ foreach ($this->request('SELECT table_name FROM user_tables') as $table)
+ {
+ if (!empty($this->hidden))
+ {
+ if (!has(current($table),$this->hidden))
+ push($tables,current($table));
+ } else {
+ push($tables,current($table));
+ }
+ }
+ break;
+ }
+
+ return $tables;
+ }
+
+ /**
+ * count number of records in a or multiples tables
+ *
+ * @param string|null $table
+ * @param int $mode
+ *
+ * @return array|int
+ */
+ public function count(string $table = '',int $mode = Eloquent::MODE_ONE_TABLE)
+ {
+ if (!empty($table) && $mode == Eloquent::MODE_ONE_TABLE)
+ {
+ foreach ($this->request("SELECT COUNT(*) FROM {$table}") as $number)
+ return current($number);
+ }
+
+ if ($mode == Eloquent::MODE_ONE_TABLE && ! empty($this->table))
+ {
+ foreach ($this->request("SELECT COUNT(*) FROM {$this->table}") as $number)
+ return current($number);
+
+ }
+
+ if ($mode == Eloquent::MODE_ALL_TABLES)
+ {
+ $numbers = array();
+
+ foreach ($this->show() as $table)
+ {
+ foreach ($this->request("SELECT COUNT(*) FROM $table") as $number)
+ {
+ $numbers = array_merge($numbers,[$table => current($number)]);
+ }
+
+ }
+ return $numbers;
+ }
+ return null;
+ }
+
+ /**
+ * set the database driver
+ *
+ * @param string $driver
+ *
+ * @return Table
+ */
+ public function setDriver(string $driver): Table
+ {
+ $this->driver = $driver;
+
+ return $this;
+ }
+
+ /**
+ * set name of database
+ *
+ * @param string $database
+ *
+ * @return Table
+ */
+ public function setDatabase(string $database): Table
+ {
+ $this->database = $database;
+
+ return $this;
+ }
+
+ /**
+ * define database username
+ *
+ * @param string $username
+ *
+ * @return Table
+ */
+ public function setUsername(string $username): Table
+ {
+ $this->username = $username;
+
+ return $this;
+ }
+
+ /**
+ * define username password
+ *
+ * @param string $password
+ *
+ * @return Table
+ */
+ public function setPassword(string $password): Table
+ {
+ $this->password = $password;
+
+ return $this;
+ }
+
+ /**
+ * execute a statement
+ *
+ * @param string $statement
+ *
+ * @return bool
+ */
+ public function exec(string $statement): bool
+ {
+
+ if ($this->isSqlite())
+ {
+ if (empty($this->database))
+ $pdo = connect($this->driver);
+ else
+ $pdo = connect($this->driver,$this->database);
+
+ $request = $pdo->prepare($statement);
+
+ return $request->execute();
+ }
+
+ $pdo = connect($this->driver,$this->database,$this->username,$this->password);
+ if (is_null($pdo))
+ return false;
+ $request = $pdo->prepare($statement);
+
+ return $request->execute();
+
+ }
+
+ /**
+ * execute a statement
+ *
+ * @param string $statement
+ *
+ * @return array
+ */
+ public function request(string $statement): array
+ {
+ $pdo = connect($this->driver,$this->database,$this->username,$this->password);
+
+ if (is_null($pdo))
+ return array();
+
+ $request = $pdo->prepare($statement);
+ $request->execute();
+ return $request->fetchAll($this->fetch);
+
+ }
+
+ /**
+ * truncate a sqlite table
+ *
+ * @param string $table
+ * @return bool
+ */
+ protected function truncateSqliteTable(string $table) : bool
+ {
+ $fields = $this->getColumns();
+ $types = $this->getColumnsTypes();
+ $primary = $this->primaryKey();
+
+ $end = end($fields);
+ $this->drop($table);
+
+
+ $query = "CREATE TABLE $table ( ";
+
+ foreach ($fields as $k => $field)
+ {
+ switch ($field)
+ {
+ case $primary:
+ if ($field == $end)
+ $query .= " '$primary' $types[$k] PRIMARY KEY AUTOINCREMENT";
+ else
+ $query .= " '$primary' $types[$k] PRIMARY KEY AUTOINCREMENT ,";
+ break;
+ default:
+ if ($field == $end)
+ $query .= " '$field' $types[$k]";
+ else
+ $query .= " '$field' $types[$k] ,";
+ break;
+ }
+
+ }
+ $query .= ')';
+
+ return $this->exec($query);
+ }
+
+ /**
+ * get all record in a table
+ *
+ * @param string $orderBy
+ *
+ * @return array
+ */
+ public function getRecords(string $orderBy = ''): array
+ {
+ if (!empty($orderBy))
+ return $this->request("SELECT * FROM {$this->table} ORDER BY {$this->primaryKey()} $orderBy");
+ else
+ return $this->request("SELECT * FROM {$this->table}");
+ }
+
+ /**
+ * count all table in current database
+ *
+ * @return int
+ */
+ public function countTable(): int
+ {
+ return count($this->show());
+ }
+
+ /**
+ * update a table
+ *
+ * @param int $id
+ * @param array $values
+ * @param array $ignore
+ * @param string|null $table
+ *
+ * @return bool
+ */
+ public function update(int $id,array $values,array $ignore= [],string $table = ''): bool
+ {
+ if (!empty($table))
+ $this->table = $table;
+
+ $primary = $this->primaryKey();
+ $columns = array();
+
+ foreach ($values as $k => $value)
+ {
+ if ($k != $primary)
+ {
+ if (empty($ignore))
+ {
+ if (is_numeric($value))
+ array_push($columns,"$k = $value");
+ else
+ array_push($columns,"$k = '".addslashes($value)."'");
+ }else {
+ if (!in_array($value,$ignore))
+ {
+ if (is_numeric($value))
+ array_push($columns,"$k = $value");
+ else
+ array_push($columns,"$k = '".addslashes($value)."'");
+ }
+ }
+ }
+
+ }
+
+
+
+ $columns = join(' , ',$columns);
+
+ $command = "UPDATE {$this->table} SET $columns WHERE $primary = $id";
+ return $this->exec($command);
+ }
+
+
+ /**
+ * optimize a table
+ *
+ * @return bool
+ */
+ public function optimize(): bool
+ {
+ if (!empty($this->table))
+ return $this->exec("OPTIMIZE {$this->table}");
+ return
+ false;
+ }
+
+ /**
+ * modify an existing column
+ *
+ * @param string $column
+ * @param string $type
+ * @param int $size
+ *
+ * @return bool
+ */
+ public function modifyColumn(string $column,string $type,int $size = 0): bool
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+
+ if ($size)
+ return $this->exec("ALTER TABLE {$this->table} MODIFY $column $type($size)");
+ else
+ return $this->exec("ALTER TABLE {$this->table} MODIFY $column $type");
+
+ break;
+ case Connexion::POSTGRESQL:
+
+ if ($size)
+ return $this->exec("ALTER TABLE {$this->table} ALTER COLUMN $column TYPE $type($size)");
+ else
+ return $this->exec("ALTER TABLE {$this->table} ALTER COLUMN $column TYPE $type");
+
+ break;
+ case Connexion::ORACLE:
+
+ if ($size)
+ return $this->exec("ALTER TABLE {$this->table} MODIFY $column $type($size)");
+ else
+ return $this->exec("ALTER TABLE {$this->table} MODIFY $column $type");
+
+ break;
+ default:
+ return false;
+ break;
+ }
+ }
+
+ /**
+ * return create table sql query
+ *
+ * @return string
+ */
+ public function get(): string
+ {
+ $command = $this->startCreateCommand();
+
+ foreach ($this->columns as $column)
+ $command .= $this->updateCreateCommand($column);
+
+ $command .= ')';
+
+ if ($this->isMysql() && !is_null($this->engine))
+ $command .= " ENGINE = $this->engine";
+
+ $this->columns = [];
+
+ return $command;
+ }
+
+ /**
+ * set the engine
+ *
+ * @param string $engine
+ *
+ * @return Table
+ */
+ public function setEngine(string $engine): Table
+ {
+ $this->engine = $engine;
+
+ return $this;
+ }
+
+ /**
+ * delete all tables not ignored in database
+ *
+ * @return bool
+ */
+ public function dropAll(): bool
+ {
+ foreach ($this->show() as $table)
+ if (!$this->drop($table))
+ return false;
+
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Eloquent/Users/Users.php b/imperium/Databases/Eloquent/Users/Users.php
new file mode 100644
index 0000000..5da0af9
--- /dev/null
+++ b/imperium/Databases/Eloquent/Users/Users.php
@@ -0,0 +1,282 @@
+<?php
+/**
+ * fumseck added Users.php to imperium
+ * The 11/09/17 at 08:56
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+
+namespace Imperium\Databases\Eloquent\Users {
+
+ use Imperium\Databases\Core\UserManagement;
+ use Imperium\Databases\Eloquent\Connexion\Connexion;
+ use Imperium\Databases\Eloquent\Share;
+ use PDO;
+ use PDOException;
+
+ class Users implements UserManagement
+ {
+ use Share;
+
+ /**
+ * delete an user
+ *
+ * @param string $user
+ *
+ * @return bool
+ */
+ public function drop(string $user): bool
+ {
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ return execute($this->getInstance(),"DROP USER '$user'@'localhost'");
+ break;
+
+ case Connexion::POSTGRESQL:
+ return execute($this->getInstance(),"DROP ROLE $user;");
+ break;
+ case Connexion::ORACLE:
+ return execute($this->getInstance(),"DROP USER $user");
+ break;
+
+ default:
+ return false;
+ break;
+ }
+
+ }
+
+ /**
+ * return all users
+ *
+ * @return array
+ */
+ public function show(): array
+ {
+ $users = array();
+
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ try{
+ $query = $this->getInstance()->prepare('SELECT user from mysql.user');
+ $query->execute();
+ }catch (PDOException $e)
+ {
+ return $users;
+ }
+ break;
+ case Connexion::POSTGRESQL:
+ try{
+ $query = $this->getInstance()->prepare('SELECT rolname FROM pg_roles;');
+ $query->execute();
+ }catch (PDOException $e)
+ {
+ return $users;
+ }
+
+ break;
+ case Connexion::ORACLE:
+ try{
+ $query = $this->getInstance()->prepare('select username from dba_users;');
+ $query->execute();
+ }catch (PDOException $e)
+ {
+ return $users;
+ }
+
+ break;
+ default:
+ return $users;
+ break;
+ }
+
+ foreach ($query->fetchAll() as $user)
+ {
+ if (!empty($this->hidden))
+ {
+ if (!has(current($user), $this->hidden))
+ {
+ push($users, current($user));
+ }
+ } else {
+ push($users, current($user));
+ }
+
+ }
+ return $users;
+ }
+
+ /**
+ * define username
+ *
+ * @param string $name
+ *
+ * @return Users
+ */
+ public function setName(string $name): Users
+ {
+ $this->username = $name;
+
+ return $this;
+ }
+
+ /**
+ * define user password
+ *
+ * @param string $password
+ *
+ * @return Users
+ */
+ public function setPassword(string $password): Users
+ {
+ $this->password = $password;
+
+ return $this;
+ }
+
+ /**
+ * create a new user
+ *
+ * @return bool
+ */
+ public function create(): bool
+ {
+ return userAdd($this->driver,$this->username,$this->password,$this->rights,$this->getInstance());
+
+ }
+
+ /**
+ * set user rights
+ *
+ * @param string $rights
+ *
+ * @return Users
+ */
+ public function setRights(string $rights): Users
+ {
+ $this->rights = $rights;
+ return $this;
+ }
+
+ /**
+ * check if a user exist
+ *
+ * @param string $user
+ * @return bool
+ */
+ public function exist(string $user = ''): bool
+ {
+ if (!empty($user))
+ return has($user,$this->show());
+ else
+ return has($this->username,$this->show());
+ }
+
+ /**
+ * update user password
+ *
+ * @param string $user
+ * @param string $password
+ *
+ * @return bool
+ */
+ public function updatePassword(string $user, string $password): bool
+ {
+ switch ($this->driver)
+ {
+ case Connexion::MYSQL:
+ return execute($this->getInstance(),"SET PASSWORD FOR '$user'@'localhost' = PASSWORD('$password');FLUSH PRIVILEGES");
+ break;
+ case Connexion::POSTGRESQL:
+ return execute($this->getInstance(),"ALTER ROLE $user WITH PASSWORD '$password'");
+ break;
+ case Connexion::ORACLE:
+ return execute($this->getInstance(),"ALTER USER $user IDENTIFIED BY $password;");
+ break;
+ default:
+ return false;
+ break;
+ }
+ }
+
+ /**
+ * define hidden users
+ *
+ * @param array $users
+ *
+ * @return Users
+ */
+ public function setHidden(array $users): Users
+ {
+ $this->hidden = $users;
+
+ return $this;
+ }
+
+ /**
+ * define user type
+ *
+ * @param string $driver
+ *
+ * @return Users
+ */
+ public function setDriver(string $driver): Users
+ {
+ $this->driver = $driver;
+
+ return $this;
+ }
+
+ /**
+ * start query builder
+ *
+ * @return Users
+ */
+ public static function manage(): Users
+ {
+ return new static();
+ }
+
+ /**
+ * Get a pdo instance
+ *
+ * @return null|PDO
+ */
+ public function getInstance()
+ {
+ switch ($this->driver)
+ {
+ case Connexion::SQLITE:
+ if (empty($this->database))
+ return connect($this->driver);
+ else
+ return connect($this->driver,$this->database);
+ break;
+
+ default:
+ if (empty($this->database))
+ return connect($this->driver,'',$this->username,$this->password);
+ return connect($this->driver,$this->database,$this->username,$this->password);
+
+ break;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Databases/Exception/IdentifierException.php b/imperium/Databases/Exception/IdentifierException.php
new file mode 100644
index 0000000..b6ffe49
--- /dev/null
+++ b/imperium/Databases/Exception/IdentifierException.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * fumseck added HelpersExecption.php to imperium
+ * The 11/09/17 at 15:50
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+
+namespace Imperium\Databases\Exception {
+
+ use Exception;
+
+ class IdentifierException extends Exception
+ {
+ public static function incorrectIdentifiers()
+ {
+ return new static('Incorrect identifiers');
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/Directory/Dir.php b/imperium/Directory/Dir.php
new file mode 100644
index 0000000..770f822
--- /dev/null
+++ b/imperium/Directory/Dir.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * fumseck added Dir.php to imperium
+ * The 09/09/17 at 13:16
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Directory {
+
+ class Dir
+ {
+
+ /**
+ * delete a folder with files
+ *
+ * @param $folder
+ * @return bool
+ */
+ public static function clear($folder)
+ {
+ $files = array_diff(scandir($folder), array('.','..'));
+ foreach ($files as $file)
+ {
+ if($file != '.gitignore')
+ {
+ (is_dir("$folder/$file")) ? self::clear("$folder/$file") : unlink("$folder/$file");
+ }
+
+ }
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/imperium/File/File.php b/imperium/File/File.php
new file mode 100644
index 0000000..1783c9c
--- /dev/null
+++ b/imperium/File/File.php
@@ -0,0 +1,1588 @@
+<?php
+/**
+ * fumseck added File.php to imperium
+ * The 09/09/17 at 13:26
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\File {
+
+ use Exception;
+ use Mimey\MimeTypes;
+ use RecursiveDirectoryIterator;
+ use RecursiveIteratorIterator;
+
+ /**
+ * Class File
+ */
+ class File
+ {
+
+ /**
+ * for search all html files
+ */
+ const HTML = 'html';
+
+ /**
+ * for search all css files
+ */
+ const CSS = 'css';
+
+ /**
+ * for search all php files
+ */
+ const PHP = 'php';
+
+ /**
+ * for search all js files
+ */
+ const JS = 'js';
+
+ /**
+ * for search all jpeg files
+ */
+ const JPEG = 'jpeg';
+
+ /**
+ * for search all jpg files
+ */
+ const JPG = 'jpg';
+
+ /**
+ * for search all svg files
+ */
+ const SVG = 'svg';
+
+ /**
+ * for search all png files
+ */
+ const PNG = 'png';
+
+ /**
+ * for search all json files
+ */
+ const JSON = 'json';
+
+ /**
+ * for search all xml files
+ */
+ const XML = 'xml';
+
+ /**
+ * for search all pdf files
+ */
+ const PDF = 'pdf';
+
+ /**
+ * for search all pdf files
+ */
+ const GIF = 'gif';
+
+ /**
+ *
+ */
+ const IMG = array(
+ File::PNG,
+ File::JPEG,
+ File::JPG,
+ File::SVG,
+ File::GIF
+ );
+
+ const MIME_TYPES = array(
+ 'txt' => 'text/plain',
+ 'htm' => 'text/html',
+ 'html' => 'text/html',
+ 'php' => 'text/html',
+ 'css' => 'text/css',
+ 'js' => 'application/javascript',
+ 'json' => 'application/json',
+ 'xml' => 'application/xml',
+ 'swf' => 'application/x-shockwave-flash',
+ 'flv' => 'video/x-flv',
+
+ 'png' => 'image/png',
+ 'jpe' => 'image/jpeg',
+ 'jpeg' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'gif' => 'image/gif',
+ 'bmp' => 'image/bmp',
+ 'ico' => 'image/vnd.microsoft.icon',
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'svg' => 'image/svg+xml',
+ 'svgz' => 'image/svg+xml',
+
+ 'zip' => 'application/zip',
+ 'rar' => 'application/x-rar-compressed',
+ 'exe' => 'application/x-msdownload',
+ 'msi' => 'application/x-msdownload',
+ 'cab' => 'application/vnd.ms-cab-compressed',
+
+ 'mp3' => 'audio/mpeg',
+ 'qt' => 'video/quicktime',
+ 'mov' => 'video/quicktime',
+
+ 'pdf' => 'application/pdf',
+ 'psd' => 'image/vnd.adobe.photoshop',
+ 'ai' => 'application/postscript',
+ 'eps' => 'application/postscript',
+ 'ps' => 'application/postscript',
+
+ 'doc' => 'application/msword',
+ 'rtf' => 'application/rtf',
+ 'xls' => 'application/vnd.ms-excel',
+ 'ppt' => 'application/vnd.ms-powerpoint',
+
+ 'odt' => 'application/vnd.oasis.opendocument.text',
+ 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+ );
+
+ /**
+ * Open for reading only;
+ * place the files pointer at the beginning of the files.
+ */
+ const READ = 'r';
+
+ /**
+ * Open for reading and writing;
+ * place the files pointer at the beginning of the files.
+ */
+ const READ_AND_WRITE = 'r+';
+
+ /**
+ * Open for writing only;
+ * place the files pointer at the beginning of the files and truncate the files
+ * to zero length. If the files does not exist, attempt to create it.
+ */
+ const EMPTY_AND_WRITE = 'w';
+
+ /**
+ * Open for reading and writing;
+ * place the files pointer at the beginning of the files and truncate the files
+ * to zero length. If the files does not exist, attempt to create it.
+ */
+ const EMPTY_READ_AND_WRITE = 'w+';
+
+ /**
+ * Open for writing only;
+ * place the files pointer at the end of the files.
+ * If the files does not exist, attempt to create it.
+ * In this mode, fseek() has no effect, writes are always appended.
+ */
+ const END_WRITE = 'a';
+
+ /**
+ * Open for reading and writing;
+ * place the files pointer at the end of the files.
+ * If the files does not exist, attempt to create it.
+ * In this mode, fseek() only affects the reading position, writes are always appended.
+ */
+ const END_READ_AND_WRITE = 'a+';
+
+ /**
+ * Create and open for writing only;
+ * place the files pointer at the beginning of the files.
+ * If the files already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING.
+ * If the files does not exist, attempt to create it.
+ * This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
+ */
+ const CREATE_ON_WRITE = 'x';
+
+ /**
+ * Create and open for reading and writing;
+ * otherwise it has the same behavior as 'x'.
+ */
+ const CREATE_ON_READ_AND_WRITE = 'x+';
+
+ /**
+ * Open the files for writing only.
+ * If the files does not exist, it is created.
+ * If it exists, it is neither truncated (as opposed to 'w'),
+ * nor the call to this function fails (as is the case with 'x').
+ * The files pointer is positioned on the beginning of the files.
+ * This may be useful if it's desired to get an advisory lock (see flock()) before attempting to modify the files,
+ * as using 'w' could truncate the files before the lock was obtained (if truncation is desired, ftruncate()
+ * can be used after the lock is requested).
+ */
+ const CREATE_WITHOUT_TRUNCATE_ON_WRITE = 'c';
+
+ /**
+ * Open the files for reading and writing; otherwise it has the same behavior as 'c'.
+ */
+ const CREATE_WITHOUT_TRUNCATE_ON_READ_AND_WRITE = 'c+';
+
+ /**
+ * device number
+ */
+ const DEV = 'dev';
+
+ /**
+ * inode number *
+ */
+ const INO = 'ino';
+
+ /**
+ * inode protection mode
+ */
+ const MODE = 'mode';
+
+ /**
+ * number of links
+ */
+ const LINK = 'nlink';
+
+ /**
+ * userid of owner *
+ */
+ const UID = 'uid';
+
+ /**
+ * groupid of owner *
+ */
+ const GID = 'gid';
+
+ /**
+ * device type, if inode device
+ */
+ const RDEV = 'rdev';
+
+ /**
+ * size in bytes
+ */
+ const SIZE = 'size';
+
+ /**
+ * time of last access (Unix timestamp)
+ */
+ const ATIME = 'atime';
+
+ /**
+ * time of last modification (Unix timestamp)
+ */
+ const MTIME = 'mtime';
+
+ /**
+ * time of last inode change (Unix timestamp)
+ */
+ const CTIME = 'ctime';
+
+ /**
+ * blocksize of filesystem IO **
+ */
+ const BLOCK_SIZE = 'blksize';
+
+ /**
+ * number of 512-byte blocks allocated **
+ */
+ const BLOCKS = 'blocks';
+
+ /**
+ * index in $_FILES
+ * to get uploaded files size
+ */
+ const FILE_SIZE = 'size';
+
+ /**
+ * index in $_FILES
+ * to get uploaded files type
+ */
+ const FILE_TYPE = 'type';
+
+ /**
+ * index in $_FILES
+ * to get uploaded filename
+ */
+ const FILE_NAME = 'name';
+
+ /**
+ * index in $_FILES
+ * to get uploaded files tmp
+ */
+ const FILE_TMP = 'tmp_name';
+
+ /**
+ * index in $_FILES
+ * to get uploaded files error
+ */
+ const FILE_ERROR = 'error';
+
+ /**
+ * to search all php files
+ */
+ const ALL_PHP = '*.php';
+
+ /**
+ * to search all css files
+ */
+ const ALL_CSS = '*.css';
+
+ /**
+ * to search all js files
+ */
+ const ALL_JS = '*.js';
+
+ /**
+ * to search all html files
+ */
+ const ALL_HTML = '*.html';
+
+ /**
+ * to search all png image
+ */
+ const ALL_PNG = '*.png';
+
+ /**
+ * to search all jpeg image
+ */
+ const ALL_JPEG = '*.jpeg';
+
+ /**
+ * to search all jpg image
+ */
+ const ALL_JPG = '*.jpg';
+
+ /**
+ * to search all svg image
+ */
+ const ALL_SVG = '*.svg';
+
+ /**
+ * to search all gif image
+ */
+ const ALL_GIF = '*.gif';
+ /**
+ * to search all json
+ */
+ const ALL_JSON = '*.json';
+
+ /**
+ * Get the MD5 hash of the files at the given path.
+ *
+ * @param string $filename
+ *
+ * @return string
+ */
+ public static function hash(string $filename): string
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::exist($filename))
+ return md5_file($filename);
+ else
+ return '';
+ }
+
+ /**
+ * Get the files's last modification time.
+ *
+ * @param string $filename
+ *
+ * @return bool|int
+ */
+ public static function lastModified(string $filename)
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::exist($filename))
+ return filemtime($filename);
+ else
+ return false;
+ }
+
+
+ /**
+ * download a files
+ *
+ * @param string $filename
+ *
+ * @return false|int
+ */
+ public static function download(string $filename)
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::exist($filename))
+ {
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename="'.basename($filename).'"');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate');
+ header('Pragma: public');
+ header('Content-Length: ' . filesize($filename));
+ return readfile($filename);
+ }
+ self::fileNotExist($filename);
+ return false;
+ }
+
+ /**
+ * return files likes pattern
+ *
+ * @param string $pattern
+ * @param int $flags
+ *
+ * @return array
+ */
+ public static function search(string $pattern, int $flags = null): array
+ {
+ self::quitIfEmpty([$pattern],__FUNCTION__);
+
+ $files = array();
+
+ foreach (glob($pattern,$flags) as $file)
+ {
+ array_push($files,$file);
+ }
+
+ return $files;
+ }
+
+ /**
+ * create a new files if not exist
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function create(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (!self::exist($filename))
+ {
+ return touch($filename);
+ }
+
+ return false;
+ }
+
+ /**
+ * delete a files if exist
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function delete(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (is_dir($filename))
+ {
+ return self::deleteFolder($filename);
+ }
+
+ if (self::exist($filename))
+ {
+ return unlink($filename);
+ }
+ return false;
+ }
+
+ /**
+ * delete a folder
+ *
+ * @param $folder
+ *
+ * @return bool
+ */
+ public static function deleteFolder(string $folder): bool
+ {
+ self::quitIfEmpty([$folder],__FUNCTION__);
+
+ if (!is_dir($folder))
+ {
+ return false;
+ }
+
+ $files = array_diff(scandir($folder), array('.','..'));
+
+ foreach ($files as $file)
+ {
+ (is_dir("$folder/$file")) ? self::deleteFolder("$folder/$file") : unlink("$folder/$file");
+ }
+
+ return rmdir($folder);
+ }
+
+ /**
+ * return all files lines
+ *
+ * @param string $filename
+ * @param string $mode
+ *
+ * @return array
+ */
+ public static function getLines(string $filename, string $mode = File::READ): array
+ {
+ self::quitIfEmpty([$filename,$mode],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ $file = self::open($filename,$mode);
+
+ if ($file)
+ {
+ $lines = array();
+
+ while (!self::isEnd($file))
+ {
+ array_push($lines,fgets($file));
+ }
+ if (self::close($file))
+ {
+ return $lines;
+ } else {
+ self::quit('error on close files');
+ }
+ }
+ }
+ return array();
+ }
+
+ /**
+ * get all keys
+ *
+ * @param string $filename
+ * @param string $delimiter
+ * @param string $mode
+ *
+ * @return array
+ */
+ public static function getKeys(string $filename,string $delimiter,string $mode = File::READ): array
+ {
+ self::quitIfEmpty([$filename,$mode],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ $file = self::open($filename,$mode);
+
+ if ($file)
+ {
+ $lines = array();
+
+ while (!self::isEnd($file))
+ {
+ $parts = explode($delimiter,fgets($file));
+ if (!empty($parts[0]))
+ array_push($lines,$parts[0]);
+
+ }
+ if (self::close($file))
+ {
+ return $lines;
+ } else {
+ self::quit('error on close files');
+ }
+ }
+ }
+ return array();
+ }
+
+ /**
+ * get all values
+ *
+ * @param string $filename
+ * @param string $delimiter
+ * @param string $mode
+ *
+ * @return array
+ */
+ public static function getValues(string $filename,string $delimiter,string $mode = File::READ): array
+ {
+ self::quitIfEmpty([$filename,$mode],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ $file = self::open($filename,$mode);
+
+ if ($file)
+ {
+ $lines = array();
+
+ while (!self::isEnd($file))
+ {
+ $parts = explode($delimiter,fgets($file));
+ if (!empty($parts[1]))
+ array_push($lines,rtrim($parts[1]));
+ }
+ if (self::close($file))
+ {
+ return $lines;
+ } else {
+ self::quit('error on close files');
+ }
+ }
+ }
+ return array();
+ }
+
+ /**
+ * return the files size
+ *
+ * @param string $filename
+ *
+ * @return int
+ */
+ public static function getSize(string $filename): int
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ return filesize($filename);
+ }
+
+ return -1;
+ }
+
+ /**
+ * Returns the files extensions
+ *
+ * @param string $filename
+ *
+ * @return string
+ */
+ public static function getExtension(string $filename): string
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ return pathinfo($filename, PATHINFO_EXTENSION);
+ }
+
+ return '';
+ }
+
+ /**
+ * copy a folder to destination
+ *
+ * @param string $source
+ * @param string $destination
+ * @return bool
+ */
+ public static function copyFolder(string $source, string $destination)
+ {
+ self::quitIfEmpty([$source,$destination],__FUNCTION__);
+
+ switch (is_dir($destination))
+ {
+ case true:
+ File::deleteFolder($destination);
+ mkdir($destination);
+ break;
+ default:
+ mkdir($destination);
+ break;
+ }
+
+ $dir_iterator = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
+
+ $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
+
+ foreach($iterator as $element)
+ {
+ switch ($element->isDir())
+ {
+ case true:
+ mkdir($destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
+ break;
+ default:
+ copy($element, $destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
+ break;
+ }
+ }
+ foreach($iterator as $element)
+ {
+ switch ($element->isDir()) {
+ case true:
+ if (!is_dir($destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { return false; }
+ break;
+ default:
+ if (!self::isFile($destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { return false; }
+ break;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * copy a files in an other files
+ *
+ * @param string $source
+ * @param string $destination
+ *
+ * @return bool
+ */
+ public static function copy(string $source, string $destination): bool
+ {
+ self::quitIfEmpty([$source,$destination],__FUNCTION__);
+
+ if (self::exist($source))
+ {
+ return copy($source,$destination);
+ }
+ return false;
+ }
+
+ /**
+ * test if a files or a folder is readable
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isReadable(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (is_dir($filename) && is_writable($filename))
+ {
+ $objects = scandir($filename);
+
+ foreach ($objects as $object)
+ {
+ if ($object != "." && $object != "..")
+ {
+ if (!self::isReadable($filename."/".$object))
+ {
+ return false;
+
+ } else {
+ continue;
+ }
+ }
+ }
+ return true;
+ }
+
+ if (self::exist($filename))
+ {
+ return is_readable($filename);
+ }
+ return false;
+ }
+
+ /**
+ * test if a files is writable
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isWritable(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (is_dir($filename))
+ {
+ return is_writable($filename);
+ }
+
+ if (self::exist($filename))
+ {
+ return is_writable($filename);
+ }
+ return false;
+ }
+
+
+ /**
+ * create a hard link
+ *
+ * @param string $target
+ * @param string $link
+ *
+ * @return bool
+ */
+ public static function hardLink(string $target, string $link): bool
+ {
+ self::quitIfEmpty([$target,$link],__FUNCTION__);
+
+ if (self::exist($target))
+ {
+ return link($target, $link);
+ }
+ return false;
+ }
+
+ /**
+ * create a symlink link
+ *
+ * @param string $target
+ * @param string $link
+ *
+ * @return bool
+ */
+ public static function symlink(string $target, string $link): bool
+ {
+ self::quitIfEmpty([$target,$link],__FUNCTION__);
+
+ if (self::exist($target))
+ {
+ return symlink($target, $link);
+ }
+ return false;
+ }
+
+ /**
+ * test if filename is a symlink
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isLink(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+ if (self::exist($filename))
+ {
+ return is_link($filename);
+ }
+ return false;
+ }
+
+ /**
+ * get the mime of files
+ *
+ * @param string $filename
+ *
+ * @return string
+ */
+ public static function getMime(string $filename): string
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ return mime_content_type($filename);
+ }
+
+ return '';
+ }
+
+ /**
+ * get the files's info
+ *
+ * @param string $filename
+ *
+ * @return array
+ */
+ public static function getStat(string $filename): array
+ {
+ self::quitIfEmpty([$filename], __FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ $stat = stat($filename);
+
+ if ($stat)
+ {
+ return $stat;
+ }
+ }
+ return array();
+ }
+
+ /**
+ * get a part of stat by a key
+ *
+ * @param string $filename
+ * @param string $key
+ *
+ * @return mixed
+ */
+ public static function getStartKey(string $filename,string $key)
+ {
+ self::quitIfEmpty([$filename,$key],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ $file = self::getStat($filename);
+ return $file[$key];
+ }
+ return null;
+ }
+
+ /**
+ * write data on a files
+ *
+ * @param string$filename
+ * @param string$data
+ * @param string $mode
+ *
+ * @return bool
+ */
+ public static function write(string $filename, string $data,string $mode = File::READ_AND_WRITE): bool
+ {
+ self::quitIfEmpty([$filename,$data,$mode],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ $file = self::open($filename, $mode);
+ fwrite($file, $data, strlen($data));
+ return self::close($file);
+ }
+ return false;
+ }
+
+ /**
+ * check if filename is a files
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isFile(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+ return is_file($filename);
+ }
+
+ public static function mimes()
+ {
+ return new MimeTypes;
+ }
+
+ /**
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isImg(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+ if (self::verify($filename))
+ {
+ return in_array(self::getExtension($filename),File::IMG,true);
+ }
+ return false;
+ }
+
+ /**
+ * test if filename is a html files
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isHtml(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+ if (self::verify($filename))
+ return self::getExtension($filename) == File::HTML && strcmp('text/html', self::mimes()->getMimeType('html')) == 0;
+
+ return false;
+ }
+
+
+ /**
+ * test if filename is a php files
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isPhp(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ return self::getExtension($filename) == File::PHP && strcmp(mime_content_type($filename),'text/x-php') == 0;
+
+ return false;
+ }
+
+ /**
+ * test if filename is a js files
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isJS(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ return self::getExtension($filename) == File::JS && strcmp('application/javascript',self::mimes()->getMimeType('js') == 0);
+
+ return false;
+ }
+
+ /**
+ * test if filename is a json files
+ *<
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isJson(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ return self::getExtension($filename) == File::JSON && strcmp('application/json',self::mimes()->getMimeType('json')) == 0;
+ return false;
+ }
+
+ /**
+ * test if filename is a xml files
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isXml(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+ if (self::verify($filename))
+ return self::getExtension($filename) == File::XML && strcmp('application/xml',self::mimes()->getMimeType('xml')) == 0;
+ return false;
+ }
+
+ /**
+ * test if filename is a css files
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isCss(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ return self::getExtension($filename) == File::CSS && strcmp('text/css',self::mimes()->getMimeType('css')) == 0;
+
+ return false;
+ }
+
+ /**
+ * test if filename is a pdf files
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isPdf(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ return self::getExtension($filename) === File::PDF && strcmp('application/pdf', self::mimes()->getMimeType('pdf')) == 0;
+ }
+ return false;
+ }
+
+ /**
+ * test the end of files
+ *
+ * @param $file
+ *
+ * @return bool
+ */
+ public static function isEnd($file): bool
+ {
+ self::quitIfEmpty([$file],__FUNCTION__);
+
+ return feof($file);
+
+ }
+
+ /**
+ * get the group of the files
+ *
+ * @param string $filename
+ *
+ * @return int
+ */
+ public static function getGroup(string $filename): int
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ return filegroup($filename);
+ }
+
+ return -1;
+ }
+
+ /**
+ * get the owner of the files
+ *
+ * @param string $filename
+ *
+ * @return int
+ */
+ public static function getOwner(string $filename): int
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ return fileowner($filename);
+ }
+ return -1;
+ }
+
+ /**
+ * Include in page all files passed by parameters
+ *
+ * @throws Exception
+ *
+ * @return bool
+ */
+ public static function loads(): bool
+ {
+ if (func_num_args() == 0)
+ throw new Exception("Load function require files in parameters");
+
+
+ foreach (func_get_args() as $file)
+ {
+ if (self::verify($file))
+ require_once "$file";
+ else
+ throw new Exception("$file not exist");
+ }
+ return true;
+ }
+
+ /**
+ * return the content of a files
+ *
+ * @param string $filename
+ *
+ * @return string
+ */
+ public static function getContent(string $filename): string
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ return file_get_contents($filename);
+ }
+
+ return '';
+ }
+
+ /**
+ * write data on a files
+ *
+ * @param string $filename
+ * @param mixed $data
+ * @param int $flags
+ *
+ * @return bool|int
+ */
+ public static function putContents(string $filename, $data, int $flags = 0)
+ {
+ self::quitIfEmpty([$filename,$data],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ return file_put_contents($filename,$data,$flags);
+ }
+ return false;
+ }
+
+ /**
+ * return $_FILES
+ *
+ * @return array
+ */
+ public static function getFile():array
+ {
+ return $_FILES;
+ }
+
+ /**
+ * get the uploaded files type
+ *
+ * @param string $inputName
+ *
+ * @return string
+ */
+ public static function uploadedFileType(string $inputName): string
+ {
+ self::quitIfEmpty([$inputName],__FUNCTION__);
+
+ return $_FILES[$inputName][File::FILE_TYPE];
+ }
+
+ /**
+ * return the uploaded files size
+ *
+ * @param string $inputName
+ *
+ * @return int
+ */
+ public static function uploadedFileSize(string $inputName): int
+ {
+ self::quitIfEmpty([$inputName],__FUNCTION__);
+
+ return $_FILES[$inputName][File::FILE_SIZE];
+ }
+
+ /**
+ * return the uploaded files name
+ *
+ * @param string $inputName
+ *
+ * @return string
+ */
+ public static function uploadedFileName(string $inputName): string
+ {
+ self::quitIfEmpty([$inputName],__FUNCTION__);
+
+ return $_FILES[$inputName][File::FILE_NAME];
+ }
+
+ /**
+ * return the uploaded files tmp directory
+ *
+ * @param string $inputName
+ *
+ * @return string
+ */
+ public static function uploadedFileTmpPath(string $inputName): string
+ {
+ self::quitIfEmpty([$inputName],__FUNCTION__);
+
+ return $_FILES[$inputName][File::FILE_TMP];
+ }
+
+ /**
+ * return the uploaded errors
+ *
+ * @param string $inputName
+ *
+ * @return int
+ */
+ public static function uploadedFileErrors(string $inputName): int
+ {
+ self::quitIfEmpty([$inputName],__FUNCTION__);
+
+ return $_FILES[$inputName][File::FILE_ERROR];
+ }
+
+ /**
+ * change filename old on new
+ *
+ * @param string $old
+ * @param string $new
+ *
+ * @return bool
+ */
+ public static function rename(string $old, string $new): bool
+ {
+ self::quitIfEmpty([$old,$new],__FUNCTION__);
+
+ if (self::exist($old) && !self::exist($new))
+ return rename($old,$new);
+
+ return false;
+ }
+
+ /**
+ * move a uploaded files to destination
+ *
+ * @param string $inputName
+ * @param string $destination
+ *
+ * @return bool
+ */
+ public static function moveUploadedFile(string $inputName,string $destination): bool
+ {
+ return move_uploaded_file(self::uploadedFileTmpPath($inputName),$destination);
+ }
+
+ /**
+ * test if it's files exist and if it's a files
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function verify(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ return self::isFile($filename) && self::exist($filename);
+ }
+
+ /**
+ * verify if it's files exist
+ *
+ * @param string $file
+ *
+ * @return bool
+ */
+ public static function exist(string $file): bool
+ {
+ self::quitIfEmpty([$file],__FUNCTION__);
+
+ return file_exists($file);
+ }
+
+ /**
+ * exit the app with a message
+ *
+ * @param $function
+ */
+ private static function nameIsEmpty(string $function)
+ {
+ die("Please enter the input name parameter on $function function");
+ }
+
+ /**
+ * verify if files is empty
+ *
+ * @param $name
+ * @return bool
+ */
+ private static function isEmpty($name)
+ {
+ return empty($name);
+ }
+
+ /**
+ * open a files
+ *
+ * @param string $filename
+ * @param string $mode
+ *
+ * @return bool|resource
+ */
+ public static function open(string $filename, string $mode)
+ {
+ self::quitIfEmpty([$filename,$mode],__FUNCTION__);
+
+ if (self::verify($filename))
+ {
+ return fopen($filename,$mode);
+ }
+
+ return false;
+ }
+
+ /**
+ * quit app
+ *
+ * @param array $name
+ * @param string $function
+ */
+ private static function quitIfEmpty(array $name,string $function)
+ {
+ foreach ($name as $item)
+ {
+ if (self::isEmpty($item))
+ {
+ self::nameIsEmpty($function);
+ }
+ }
+
+ }
+
+ /**
+ * quit app
+ *
+ * @param string $filename
+ */
+ private static function fileNotExist(string $filename)
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ die("$filename does'nt exist ");
+ }
+
+ /**
+ * quit app with a different message
+ *
+ * @param string $message
+ */
+ private static function quit(string $message)
+ {
+ self::quitIfEmpty([$message],__FUNCTION__);
+ die($message);
+ }
+
+ /**
+ * close a files
+ *
+ * @param resource $filename
+ *
+ * @return bool
+ */
+ public static function close($filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ return fclose($filename);
+ }
+
+ /**
+ * get absolute path
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ public static function realPath(string $path): string
+ {
+ self::quitIfEmpty([$path],__FUNCTION__);
+ if (self::verify($path))
+ return realpath($path);
+
+ return '';
+ }
+
+ /**
+ * Changes files mod
+ *
+ * @param string $filename
+ * @param int $mode
+ *
+ * @return bool
+ */
+ public static function chmod(string $filename, int $mode): bool
+ {
+ self::quitIfEmpty([$filename,$mode],__FUNCTION__);
+ if (self::verify($filename))
+ return chmod($filename,$mode);
+ return false;
+ }
+
+ /**
+ * Changes files group
+ *
+ * @param string $filename
+ * @param mixed $group
+ *
+ * @return bool
+ */
+ public static function chgrp(string $filename, $group): bool
+ {
+ self::quitIfEmpty([$filename,$group],__FUNCTION__);
+ if (self::verify($filename))
+ return chgrp($filename,$group);
+
+ return false;
+ }
+
+ /**
+ * Changes group ownership of symlink
+ *
+ * @param string $filename
+ * @param mixed $group
+ *
+ * @return bool
+ */
+ public static function lchgrp(string $filename, $group): bool
+ {
+ self::quitIfEmpty([$filename,$group],__FUNCTION__);
+
+ return lchgrp($filename,$group);
+ }
+
+ /**
+ * Changes files owner
+ *
+ * @param string $filename
+ * @param mixed $user
+ *
+ * @return bool
+ */
+ public static function chown(string $filename, $user): bool
+ {
+ self::quitIfEmpty([$filename,$user],__FUNCTION__);
+ if (self::verify($filename))
+ return chown($filename,$user);
+ return false;
+ }
+
+ /**
+ * Tells whether the filename is executable
+ *
+ * @param string $filename
+ *
+ * @return bool
+ */
+ public static function isExecutable(string $filename): bool
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ return is_executable($filename);
+ }
+
+ /**
+ * Gets files type
+ *
+ * @param string $filename
+ *
+ * @return string
+ */
+ public static function getType(string $filename): string
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+ if (self::verify($filename))
+ return filetype($filename);
+
+ return '';
+ }
+
+ /**
+ * Gets last access time of files
+ *
+ * @param string $filename
+ *
+ * @return int
+ */
+ public static function fileTime(string $filename): int
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+ if (self::verify($filename))
+ return fileatime($filename);
+ return -1;
+ }
+
+ /**
+ * Gets files owner
+ *
+ * @param string $filename
+ *
+ * @return int
+ */
+ public static function fileOwner(string $filename): int
+ {
+ self::quitIfEmpty([$filename],__FUNCTION__);
+
+ if (self::verify($filename))
+ return fileowner($filename);
+
+ return -1;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/imperium/Html/Bar/Icon.php b/imperium/Html/Bar/Icon.php
new file mode 100644
index 0000000..2f014bb
--- /dev/null
+++ b/imperium/Html/Bar/Icon.php
@@ -0,0 +1,142 @@
+<?php
+/**
+ * fumseck added Icon.php to imperium
+ * The 26/03/18 at 18:05
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+namespace Imperium\Html\Bar;
+
+
+use Imperium\Html\Form\Form;
+
+class Icon implements IconManagement
+{
+
+
+ /**
+ * icon bar
+ *
+ * @var string
+ */
+ private $bar = '';
+
+ /**
+ * link class
+ *
+ * @var string
+ */
+ private $link;
+
+ /**
+ * icon class
+ *
+ * @var string
+ */
+ private $icon;
+
+ /**
+ * start icon bar
+ *
+ *
+ * @return Icon
+ */
+ public static function start(): Icon
+ {
+ return new static();
+ }
+
+
+ /**
+ * add a new icon
+ *
+ * @param string $icon
+ * @param string $id
+ * @param string $href
+ * @param string $title
+ * @param bool $offCanvas
+ *
+ * @return Icon
+ */
+ public function add(string $icon, string $id, string $href,string $title,bool $offCanvas = false): Icon
+ {
+ if (empty($this->icon))
+ $this->icon = 'icon';
+
+ if (empty($this->link))
+ $this->link = 'link';
+
+ if ($offCanvas)
+ $this->bar .= '<li><a class="'.$this->link.'" data-toggle="offcanvas" data-target="'.$href.'" data-canvas="body" id="'.$id.'" title="'.$title.'"><span class="'.$this->icon.'"> '.$icon.'</span></a></li>';
+ else
+ $this->bar .= '<li><a href="'.$href.'" class="'.$this->link.'" id="'.$id.'"><span class="'.$this->icon.'" title="'.$title.'"> '.$icon.'</span></a></li>';
+
+ return $this;
+ }
+
+ /**
+ * get icon bar
+ *
+ * @return string
+ */
+ public function end(): string
+ {
+ $this->bar .= '</ul>';
+
+ return $this->bar;
+ }
+
+ /**
+ * define icon class
+ *
+ * @param string $class
+ *
+ * @return Icon
+ */
+ public function setIconClass(string $class): Icon
+ {
+ $this->icon = $class;
+
+ return $this;
+ }
+
+ /**
+ * define link class
+ *
+ * @param string $class
+ *
+ * @return Icon
+ */
+ public function setLinkClass(string $class): Icon
+ {
+ $this->link = $class;
+
+ return $this;
+ }
+
+ /**
+ * generate ul
+ *
+ * @param string $class
+ *
+ * @return Icon
+ */
+ public function startUl(string $class): Icon
+ {
+ $this->bar .='<ul class="'.$class.'">';
+
+ return $this;
+ }
+} \ No newline at end of file
diff --git a/imperium/Html/Bar/IconManagement.php b/imperium/Html/Bar/IconManagement.php
new file mode 100644
index 0000000..4c70006
--- /dev/null
+++ b/imperium/Html/Bar/IconManagement.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * fumseck added IconManagement.php to imperium
+ * The 26/03/18 at 18:05
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+namespace Imperium\Html\Bar;
+
+
+interface IconManagement
+{
+ /**
+ * start icon bar
+ *
+ *
+ * @return Icon
+ */
+ public static function start(): Icon;
+
+ /**
+ * add a new icon
+ *
+ * @param string $icon
+ * @param string $id
+ * @param string $href
+ * @param string $title
+ * @param bool $offCanvas
+ *
+ * @return Icon
+ */
+ public function add(string $icon,string $id,string $href,string $title,bool $offCanvas = false): Icon;
+
+ /**
+ * define icon class
+ *
+ * @param string $class
+ *
+ * @return Icon
+ */
+ public function setIconClass(string $class): Icon;
+
+ /**
+ * define link class
+ *
+ * @param string $class
+ *
+ * @return Icon
+ */
+ public function setLinkClass(string $class): Icon;
+
+ /**
+ * generate ul
+ *
+ * @param string $class
+ *
+ * @return Icon
+ */
+ public function startUl(string $class): Icon;
+
+ /**
+ * get icon bar
+ *
+ * @return string
+ */
+ public function end(): string;
+
+} \ No newline at end of file
diff --git a/imperium/Html/Canvas/Canvas.php b/imperium/Html/Canvas/Canvas.php
new file mode 100644
index 0000000..679a682
--- /dev/null
+++ b/imperium/Html/Canvas/Canvas.php
@@ -0,0 +1,208 @@
+<?php
+/**
+ * fumseck added Canvas.php to imperium
+ * The 26/03/18 at 19:37
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+namespace Imperium\Html\Canvas;
+
+
+class Canvas implements CanvasManagement
+
+{
+ /**
+ * canvas
+ *
+ * @var string
+ */
+ private $canvas = '';
+
+ /**
+ * off canvas links class
+ *
+ * @var string
+ */
+ private $class;
+
+ /**
+ * canvas position
+ *
+ * @var string
+ */
+ private $position;
+
+ /**
+ * off canvas identifier
+ *
+ * @var string
+ */
+ private $id;
+
+ /**
+ * the grid class
+ *
+ * @var string
+ */
+ private $gridClass;
+
+
+
+ private $rowClass;
+
+ /**
+ * start canvas menu
+ *
+ * @return Canvas
+ */
+ public static function start(): Canvas
+ {
+ return new static();
+ }
+
+ /**
+ * add a link in canvas
+ *
+ * @param string $text
+ * @param string $href
+ * @param string $id
+ *
+ * @return Canvas
+ */
+ public function add(string $text, string $href, string $id): Canvas
+ {
+ $this->canvas .= '<li> <a href="'.$href.'" class="'.$this->class.'" id="'.$id.'">'.$text.'</a></li>';
+
+ return $this;
+ }
+
+ /**
+ * define canvas link class
+ *
+ * @param string $class
+ *
+ * @return Canvas
+ */
+ public function setLinkClass(string $class): Canvas
+ {
+ $this->class = $class;
+
+ return $this;
+ }
+
+ /**
+ * generate ul
+ *
+ * @param string $class
+ *
+ * @return Canvas
+ */
+ public function startUl(string $class): Canvas
+ {
+ $this->canvas = '<ul id="'.$this->id.'" class="navmenu '.$this->position.' '.$class.' offcanvas" role="navigation">';
+
+ return $this;
+ }
+
+ /**
+ * get canvas bar
+ *
+ * @return string
+ */
+ public function end(): string
+ {
+ $this->canvas .= '</ul>';
+
+ return $this->canvas;
+ }
+
+ /**
+ * define canvas position
+ *
+ * @param string $position
+ *
+ * @return Canvas
+ */
+ public function setPosition(string $position): Canvas
+ {
+ $this->position = $position;
+
+ return $this;
+ }
+
+ /**
+ * define off canvas id
+ *
+ * @param string $id
+ *
+ * @return Canvas
+ */
+ public function setId(string $id): Canvas
+ {
+ $this->id = $id;
+
+ return $this;
+ }
+
+ /**
+ * add form
+ *
+ * @param string ...$form
+ *
+ * @return Canvas
+ */
+ public function addForm(string ...$form): Canvas
+ {
+ $this->canvas .= '<div class="'.$this->rowClass.'">';
+
+ foreach ($form as $item)
+ {
+ $this->canvas .= '<div class="'.$this->gridClass.'">';
+ $this->canvas .= $item;
+ $this->canvas .= '</div>';
+ }
+ $this->canvas .= '</div>';
+
+ return $this;
+ }
+
+ /***
+ * define grid class
+ *
+ * @param string $class
+ *
+ * @return Canvas
+ */
+ public function setGridClass(string $class): Canvas
+ {
+ $this->gridClass = $class;
+
+ return $this;
+ }
+
+ /***
+ * define grid class
+ *
+ * @param string $class
+ *
+ * @return Canvas
+ */
+ public function setRowClass(string $class): Canvas
+ {
+ $this->rowClass = $class;
+
+ return $this;
+ }
+}
diff --git a/imperium/Html/Canvas/CanvasManagement.php b/imperium/Html/Canvas/CanvasManagement.php
new file mode 100644
index 0000000..f1442c7
--- /dev/null
+++ b/imperium/Html/Canvas/CanvasManagement.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * fumseck added CanvasManagement.php to imperium
+ * The 26/03/18 at 19:38
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+namespace Imperium\Html\Canvas;
+
+
+interface CanvasManagement
+{
+ /**
+ * start canvas menu
+ *
+ *
+ * @return Canvas
+ */
+ public static function start(): Canvas;
+
+ /**
+ * add a link in canvas
+ *
+ * @param string $text
+ * @param string $href
+ * @param string $id
+ *
+ * @return Canvas
+ */
+ public function add(string $text,string $href,string $id): Canvas;
+
+ /**
+ * add form
+ *
+ * @param string ...$form
+ *
+ * @return Canvas
+ */
+ public function addForm(string ...$form): Canvas;
+
+ /***
+ * define grid class
+ *
+ * @param string $class
+ *
+ * @return Canvas
+ */
+ public function setGridClass(string $class): Canvas;
+
+ /**
+ * define canvas link class
+ *
+ * @param string $class
+ *
+ * @return Canvas
+ */
+ public function setLinkClass(string $class): Canvas;
+
+ /**
+ * generate ul
+ *
+ * @param string $class
+ *
+ * @return Canvas
+ */
+ public function startUl(string $class): Canvas;
+
+ /**
+ * define canvas position
+ *
+ * @param string $position
+ *
+ * @return Canvas
+ */
+ public function setPosition(string $position): Canvas;
+
+ /**
+ * define off canvas id
+ *
+ * @param string $id
+ *
+ * @return Canvas
+ */
+ public function setId(string $id): Canvas;
+
+
+ /**
+ * get canvas bar
+ *
+ * @return string
+ */
+ public function end(): string;
+} \ No newline at end of file
diff --git a/imperium/Html/Form/Core/FormBuilder.php b/imperium/Html/Form/Core/FormBuilder.php
new file mode 100644
index 0000000..4fa9255
--- /dev/null
+++ b/imperium/Html/Form/Core/FormBuilder.php
@@ -0,0 +1,436 @@
+<?php
+/**
+ * fumseck added Create.php to imperium
+ * The 09/09/17 at 13:30
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Html\Form\Core {
+
+ use Imperium\Databases\Eloquent\Tables\Table;
+ use Imperium\Html\Form\Form;
+
+
+ /**
+ * Interface FormBuilder
+ *
+ * @package Imperium\Form\Core
+ */
+ interface FormBuilder
+ {
+ /**
+ * start the form
+ *
+ * @param string $action
+ * @param string $id
+ * @param string|null $class
+ * @param bool $enctype
+ * @param string $method
+ * @param string $charset
+ *
+ * @return Form
+ */
+ public function start(string $action,string $id,string $class = '', bool $enctype = false, string $method = Form::POST, string $charset = 'utf8'): Form;
+
+ /**
+ * generate a form
+ *
+ * @param string $table
+ * @param Table $instance
+ * @param string $submitText
+ * @param string $submitClass
+ * @param string $submitId
+ * @param string $submitIcon
+ * @param int $mode
+ * @param int $id
+ *
+ * @return string
+ */
+ public function generate(string $table, Table $instance,string $submitText,string $submitClass,string $submitId,string $submitIcon = '',int $mode = Form::CREATE,int $id = 0): string;
+
+ /**
+ * start hidden input
+ *
+ * @return Form
+ */
+ public function startHide(): Form;
+
+ /**
+ * close hidden input
+ *
+ * @return Form
+ */
+ public function endHide(): Form;
+
+ /**
+ * generate a files input
+ *
+ * @param string $name
+ * @param string $class
+ * @param string $text
+ * @param string $ico
+ *
+ * @return Form
+ */
+ public function file(string $name, string $class, string $text, string $ico = ''): Form;
+
+ /**
+ * define input size to large
+ *
+ * @param bool $large
+ *
+ * @return Form
+ */
+ public function setLargeInput(bool $large): Form;
+
+ /**
+ * define input size to small
+ *
+ * @param bool small
+ *
+ * @return Form
+ */
+ public function setSmallInput(bool $small): Form;
+
+ /**
+ * generate an input
+ *
+ * @param string $type
+ * @param string $name
+ * @param string $placeholder
+ * @param string $value
+ * @param string $icon
+ * @param bool $required
+ * @param bool $autofocus
+ * @param bool $autoComplete
+ *
+ * @return Form
+ */
+ public function input(string $type, string $name, string $placeholder, string $icon = '', string $value = '', bool $required = true, bool $autofocus = false, bool $autoComplete = false): Form;
+
+ /**
+ * set form type
+ *
+ * @param int $type
+ *
+ * @return Form
+ */
+ public function setType(int $type): Form;
+
+ /**
+ * generate two inline input
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ *
+ * @return Form
+ */
+ public function twoInlineInput(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo): Form;
+
+ /**
+ * generate three inline input
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $typeThree
+ * @param string $nameThree
+ * @param string $placeholderThree
+ * @param string $valueThree
+ * @param string $iconThree
+ * @param bool $requiredThree
+ *
+ * @return Form
+ */
+ public function threeInlineInput(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo, string $typeThree, string $nameThree, string $placeholderThree, string $valueThree, string $iconThree, bool $requiredThree): Form;
+
+ /**
+ * generate four inline input
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $typeThree
+ * @param string $nameThree
+ * @param string $placeholderThree
+ * @param string $valueThree
+ * @param string $iconThree
+ * @param bool $requiredThree
+ * @param string $typefour
+ * @param string $nameFour
+ * @param string $placeholderFour
+ * @param string $valueFour
+ * @param string $iconFour
+ * @param bool $requiredFour
+ *
+ * @return Form
+ */
+ public function fourInlineInput(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo, string $typeThree, string $nameThree, string $placeholderThree, string $valueThree, string $iconThree, bool $requiredThree, string $typefour, string $nameFour, string $placeholderFour, string $valueFour, string $iconFour, bool $requiredFour): Form;
+
+ /**
+ * generate four select
+ *
+ * @param string $nameOne
+ * @param array $optionsOne
+ * @param string $iconOne
+ * @param string $nameTwo
+ * @param array $optionsTwo
+ * @param string $iconTwo
+ * @param string $nameThree
+ * @param array $optionsThree
+ * @param string $iconThree
+ * @param string $nameFour
+ * @param array $optionsFour
+ * @param string $iconFour
+ *
+ * @return Form
+ */
+ public function fourInlineSelect(string $nameOne,array $optionsOne,string $iconOne,string $nameTwo,array $optionsTwo,string $iconTwo,string $nameThree,array $optionsThree,string $iconThree,string $nameFour,array $optionsFour,string $iconFour): Form;
+
+ /**
+ * add csrf token in form
+ *
+ * @param string $csrf
+ *
+ * @return Form
+ */
+ public function csrf(string $csrf): Form;
+
+ /**
+ * generate a button
+ *
+ * @param string $text
+ * @param string $class
+ * @param string $icon
+ * @param string $type
+ *
+ * @return Form
+ */
+ public function button(string $text, string $class, string $icon = '',string $type = Form::BUTTON ): Form;
+
+ /**
+ * generate a button to reset the form
+ *
+ * @param string $text
+ * @param string $class
+ * @param string|null $icon
+ *
+ * @return Form
+ */
+ public function reset(string $text, string $class, string $icon = ''):Form;
+
+ /**
+ * generate a textarea
+ *
+ * @param string $name
+ * @param string $placeholder
+ * @param int $cols
+ * @param int $row
+ * @param string $value
+ * @param bool $autofocus
+ *
+ * @return Form
+ */
+ public function textarea(string $name, string $placeholder, int $cols, int $row,bool $autofocus = false,string $value = ''): Form;
+
+ /**
+ * generate a image
+ *
+ * @param string $src
+ * @param string $alt
+ * @param string $class
+ * @param string $width
+ *
+ * @return Form
+ */
+ public function img(string $src, string $alt, string $class = '', string $width = '100%'): Form;
+
+ /**
+ * call form builder
+ *
+ * @return Form
+ */
+ public static function create(): Form;
+
+ /**
+ * generate a submit button
+ *
+ * @param string $text
+ * @param string $class
+ * @param string $id
+ * @param string $icon
+ *
+ * @return Form
+ */
+ public function submit(string $text, string $class, string $id,string $icon = ''): Form;
+
+ /**
+ * generate a link
+ *
+ * @param string $url
+ * @param string $class
+ * @param string $text
+ * @param string|null $icon
+ *
+ * @return Form
+ */
+ public function link(string $url, string $class, string $text, string $icon = ''): Form;
+
+ /**
+ * generate a select input
+ *
+ * @param string $name
+ * @param array $options
+ * @param string|null $icon
+ *
+ * @param bool $multiple
+ * @return Form
+ */
+ public function select(string $name, array $options,string $icon = '',bool $multiple = false): Form;
+
+ /**
+ * @param string $nameOne
+ * @param array $optionsOne
+ * @param string $iconOne
+ * @param string $nameTwo
+ * @param array $optionsTwo
+ * @param string $iconTwo
+ *
+ * @return Form
+ */
+ public function twoInlineSelect(string $nameOne, array $optionsOne, string $iconOne, string $nameTwo, array $optionsTwo, string $iconTwo):Form;
+
+ /**
+ * generate a checkbox input
+ *
+ * @param string $name
+ * @param string $text
+ * @param string $class
+ * @param bool $checked
+ *
+ * @return Form
+ */
+ public function checkbox(string $name, string $text, string $class, bool $checked = false): Form;
+
+ /**
+ * generate a radio input
+ *
+ * @param string $name
+ * @param string $text
+ * @param string $class
+ * @param bool $checked
+ *
+ * @return Form
+ */
+ public function radio(string $name, string $text, string $class, bool $checked = false): Form;
+
+ /**
+ * return the form
+ *
+ * @return string
+ */
+ public function end(): string;
+
+ /**
+ * generate a redirect select
+ *
+ * @param string $name
+ * @param array $options
+ * @param string $icon
+ *
+ * @return Form
+ */
+ public function redirectSelect(string $name, array $options, string $icon = ''): Form;
+
+ /**
+ * generate two inline redirect select
+ *
+ * @param string $nameOne
+ * @param array $optionsOne
+ * @param string $iconOne
+ * @param string $nameTwo
+ * @param array $optionsTwo
+ * @param string $iconTwo
+ *
+ * @return Form
+ * @throws Exception
+ */
+ public function twoRedirectSelect(string $nameOne, array $optionsOne, string $iconOne, string $nameTwo, array $optionsTwo, string $iconTwo): Form;
+
+ /**
+ * generate one select and one input inline
+ *
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIconOne
+ * @param string $type
+ * @param string $name
+ * @param string $placeholder
+ * @param bool $required
+ * @param string $iconTwo
+ * @param string $value
+ *
+ * @return Form
+ */
+ public function oneSelectOneInput(string $selectName, array $selectOptions, string $selectIconOne, string $type, string $name, string $placeholder, bool $required , string $iconTwo, string $value): Form;
+
+ /**
+ * generate one input and one select
+ *
+ * @param string $type
+ * @param string $name
+ * @param string $placeholder
+ * @param bool $required
+ * @param string $inputIcon
+ * @param string $value
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIconOne
+ *
+ * @return Form
+ */
+ public function oneInputOneSelect(string $type, string $name, string $placeholder, bool $required, string $inputIcon, string $value , string $selectName, array $selectOptions, string $selectIconOne): Form;
+ }
+} \ No newline at end of file
diff --git a/imperium/Html/Form/Form.php b/imperium/Html/Form/Form.php
new file mode 100644
index 0000000..a8e9b79
--- /dev/null
+++ b/imperium/Html/Form/Form.php
@@ -0,0 +1,2542 @@
+<?php
+/**
+ * fumseck added Form.php to imperium
+ * The 16/09/17 at 17:22
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+
+namespace Imperium\Html\Form;
+
+use Exception;
+use Imperium\Databases\Eloquent\Tables\Table;
+use Imperium\Html\Form\Core\FormBuilder;
+
+
+class Form implements FormBuilder
+{
+ /**
+ * to generate a bootstrap form
+ */
+ const BOOTSTRAP = 1;
+
+ /**
+ * to generate a foundation form
+ */
+ const FOUNDATION = 2;
+
+ /**
+ * to create a reset button
+ */
+ const RESET = 'reset';
+
+ /**
+ * to create a submit button
+ */
+ const SUBMIT = 'submit';
+
+ /**
+ * to create a form with post method
+ */
+ const POST = 'post';
+
+ /**
+ * to create a form with get method
+ */
+ const GET = 'post';
+
+ /**
+ * to create a button
+ */
+ const BUTTON = 'button';
+
+ /**
+ * to create a number input
+ */
+ const NUMBER = 'number';
+
+ /**
+ * to create an input hidden
+ */
+ const HIDDEN = 'hidden';
+ /**
+ * to create a text input
+ */
+ const TEXT = 'text';
+
+ /**
+ * to create a password input
+ */
+ const PASSWORD = 'password';
+
+ /**
+ * to create an email input
+ */
+ const EMAIL = 'email';
+
+ /**
+ * to create a date input
+ */
+ const DATE = 'date';
+
+ /**
+ * to create a datetime input
+ */
+ const DATETIME = 'datetime';
+
+ /**
+ * to create a phone input
+ */
+ const TEL = 'tel';
+
+ /**
+ * to create a url input
+ */
+ const URL = 'url';
+
+ /**
+ * to create a time input
+ */
+ const TIME = 'time';
+
+ /**
+ * to create a text input
+ */
+ const RANGE = 'range';
+
+ /**
+ * to create a color input
+ */
+ const COLOR = 'color';
+
+ /**
+ * to create a search input
+ */
+ const SEARCH = 'search';
+
+ /**
+ * to create a week input
+ */
+ const WEEK = 'week';
+
+ /**
+ * to create a checkbox input
+ */
+ const CHECKBOX = 'checkbox';
+
+ /**
+ * to create a radio input
+ */
+ const RADIO = 'radio';
+ /**
+ * option to get the result
+ */
+ const GET_TIME = 0;
+
+ /**
+ * option to have a datetime input
+ */
+ const GET_DATETIME = 1;
+
+ /**
+ * to create a files input
+ */
+ const FILE = 'file';
+
+
+ /**
+ * to create a datetime-local input
+ */
+ const DATETIME_LOCAL = 'datetime-local';
+
+ /**
+ * to create a image input
+ */
+ const IMAGE = 'image';
+
+ /**
+ * to create a month input
+ */
+ const MONTH = 'month';
+
+ const EDIT = 3;
+
+ const CREATE = 4;
+
+ /**
+ * @var string
+ */
+ private $form;
+
+ /**
+ * @var int
+ */
+ private $type;
+
+ private $inputSize;
+
+ /**
+ * start the form
+ *
+ * @param string $action
+ * @param string $id
+ * @param string $class
+ * @param bool $enctype
+ * @param string $method
+ * @param string $charset
+ *
+ * @return Form
+ */
+ public function start(string $action, string $id,string $class = '', bool $enctype = false, string $method = Form::POST, string $charset = 'utf8'): Form
+ {
+ if ($enctype)
+ {
+ if (empty($class))
+ $this->form = '<form action="'.$action.'" method="'. $method.'" accept-charset="'. $charset.'" enctype="multipart/form-data" id="'.$id.'">';
+ else
+ $this->form = '<form action="'.$action.'" method="'. $method.'" accept-charset="'. $charset.'" class="'.$class.'" enctype="multipart/form-data" id="'.$id.'">';
+ }
+ else
+ {
+ if (empty($class))
+ $this->form = '<form action="'.$action.'" method="'. $method.'" accept-charset="'. $charset.'" id="'.$id.'">';
+ else
+ $this->form = '<form action="'.$action.'" method="'. $method.'" accept-charset="'. $charset.'" class="'.$class.'" id="'.$id.'">';
+ }
+
+
+ return $this;
+ }
+
+ /**
+ * start hidden input
+ *
+ * @return Form
+ */
+ public function startHide(): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ $this->form .= '<div class="d-none">';
+ break;
+ case Form::FOUNDATION:
+ $this->form .= '<div class="hide">';
+ break;
+
+ }
+ return $this;
+ }
+
+ /**
+ * close hidden input
+ *
+ * @return Form
+ */
+ public function endHide(): Form
+ {
+ $this->form .= '</div>';
+
+ return $this;
+ }
+
+ /**
+ * generate a files input
+ *
+ * @param string $name
+ * @param string $class
+ * @param string $text
+ * @param string|null $ico
+ *
+ * @return Form
+ */
+ public function file(string $name, string $class, string $text, string $ico = ''): Form
+ {
+
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ if (empty($ico))
+ $this->form .= '<div class="form-group"><label for="'.$name.'">'.$text.'</label><input type="file" class="form-control-file '.$class.'" id="'.$name.'"></div>';
+ else
+ $this->form .= '<div class="form-group"><label for="'.$name.'">'. $ico .' '.$text.'</label><input type="file" class="form-control-file '.$class.'" id="'.$name.'"></div>';
+ break;
+ case Form::FOUNDATION:
+ if (empty($ico))
+ $this->form .= '<label for="'.$name.'" class="'.$class.'">'.$text.'</label><input type="file" id="'.$name.'" class="show-for-sr">';
+ else
+ $this->form .= '<label for="'.$name.'" class="'.$class.'">' .$ico .' ' .$text.'</label><input type="file" id="'.$name.'" class="show-for-sr">';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * @param string $start
+ * @param string $end
+ * @param string $input
+ * @param string $name
+ * @param string $placeholder
+ * @param string $value
+ * @param bool $required
+ * @param bool $autofocus
+ * @param bool $autoComplete
+ * @return string
+ */
+ private function generateInput(string $start, string $end, string $input,string $name, string $placeholder, string $value ,bool $required , bool $autofocus , bool $autoComplete)
+ {
+ if ($this->type == Form::BOOTSTRAP)
+ {
+ if(empty($this->inputSize) && $input != Form::FILE)
+ $class = 'form-control';
+ else
+ $class = $this->inputSize;
+
+ if ($input == Form::FILE)
+ $class = 'form-control-file';
+
+ if ($required) // WITH REQUIRED
+ {
+ if ($autofocus)
+ {
+ if ($autoComplete)
+ {
+ return ''.$start.' <input type="'.$input.'" class="'.$class.'" required="required" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autofocus="autofocus" autocomplete="on"> '.$end.'';
+ }
+ return ''.$start.' <input type="'.$input.'" class="'.$class.'" required="required" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autofocus="autofocus" autocomplete="off"> '.$end.'';
+ }
+ if ($autoComplete)
+ return ''.$start.' <input type="'.$input.'" class="'.$class.'" required="required" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autocomplete="on"> '.$end.'';
+ else
+ return ''.$start.' <input type="'.$input.'" class="'.$class.'" required="required" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autocomplete="off"> '.$end.'';
+
+ } else
+ {
+ // WITHOUT REQUIRED
+ if ($autofocus) // WITH AUTO FOCUS
+ {
+ if ($autoComplete) // AUTO FOCUS , AND AUTO COMPLETE
+ {
+ return ''.$start.' <input type="'.$input.'" class="'.$class.'" autofocus="autofocus" autocomplete="on" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'"> '.$end.'';
+ }
+ return ''.$start.' <input type="'.$input.'" class="'.$class.'" autofocus="autofocus" placeholder="'.$placeholder.'" autocomplete="off" name="'.$name.'" value="'.$value.'"> '.$end.'';
+ }else
+ { // WITHOUT AUTO FOCUS
+ if ($autoComplete) // AUTO FOCUS , AND AUTO COMPLETE
+ {
+ return ''.$start.' <input type="'.$input.'" class="'.$class.'" autocomplete="on">placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'"> '.$end.'';
+ } // AUTO FOCUS , WITHOUT AUTO COMPLETE
+ return ''.$start.' <input type="'.$input.'" class="'.$class.'" autocomplete="off" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'"> '.$end.'';
+ }
+ }
+ }
+
+ # NOT BOOTSTRAP
+
+ if ($required) // WITH REQUIRED
+ {
+ if ($autofocus)
+ {
+ if ($autoComplete)
+ {
+ return ''.$start.' <input type="'.$input.'" required="required" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autofocus="autofocus" autocomplete="on"> '.$end.'';
+ }
+ return ''.$start.' <input type="'.$input.'" required="required" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autofocus="autofocus" autocomplete="off"> '.$end.'';
+ }
+ if ($autoComplete)
+ return ''.$start.' <input type="'.$input.'" required="required" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autocomplete="on"> '.$end.'';
+ else
+ return ''.$start.' <input type="'.$input.'" required="required" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autocomplete="off"> '.$end.'';
+
+ }
+ else
+ {
+ // WITHOUT REQUIRED
+ if ($autofocus) // WITH AUTO FOCUS
+ {
+ if ($autoComplete) // REQUIRED , AUTO FOCUS , AND AUTO COMPLETE
+ {
+ return ''.$start.' <input type="'.$input.'" autofocus="autofocus" autocomplete="on" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'"> '.$end.'';
+ } // REQUIRED , AUTO FOCUS , WITHOUT AUTO COMPLETE
+
+ return ''.$start.' <input type="'.$input.'" autofocus="autofocus" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autocomplete="off"> '.$end.'';
+ }else
+ { // WITHOUT AUTO FOCUS
+ if ($autoComplete) // REQUIRED , AUTO FOCUS , AND AUTO COMPLETE
+ {
+ return ''.$start.' <input type="'.$input.'" autocomplete="on" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'"> '.$end.'';
+ } // REQUIRED , AUTO FOCUS , WITHOUT AUTO COMPLETE
+ return ''.$start.' <input type="'.$input.'" placeholder="'.$placeholder.'" name="'.$name.'" value="'.$value.'" autocomplete="off"> '.$end.'';
+ }
+ }
+ }
+
+ /**
+ * generate an input
+ *
+ * @param string $type
+ * @param string $name
+ * @param string $placeholder
+ * @param string $value
+ * @param string $icon
+ * @param bool $required
+ * @param bool $autofocus
+ * @param bool $autoComplete
+ *
+ * @return Form
+ */
+ public function input(string $type, string $name, string $placeholder, string $icon = '', string $value = '',bool $required = true, bool $autofocus = false, bool $autoComplete = false): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ if (empty($icon))
+ {
+ $start = '<div class="form-group">';
+ $end = "</div>";
+ $this->form .= $this->generateInput($start,$end,$type,$name,$placeholder,$value,$required,$autofocus,$autoComplete);
+ } else
+ {
+ $start = '<div class="form-group"><div class="input-group"><div class="input-group-prepend"><div class="input-group-text">'.$icon.'</div></div> ';
+ $end = "</div></div>";
+ $this->form .= $this->generateInput($start,$end,$type,$name,$placeholder,$value,$required,$autofocus,$autoComplete);
+ }
+
+ break;
+
+ case Form::FOUNDATION:
+ if (empty($icon))
+ {
+ $start = '<div class="input-group">';
+ $end = '</div>';
+ $this->form .= $this->generateInput($start,$end,$type,$name,$placeholder,$value,$required,$autofocus,$autoComplete);
+ } else
+ {
+ $start = '<div class="input-group"><span class="input-group-label">'.$icon.'</span>';
+ $end = '</div>';
+ $this->form .= $this->generateInput($start,$end,$type,$name,$placeholder,$value,$required,$autofocus,$autoComplete);
+ }
+ break;
+
+ }
+
+ return $this;
+ }
+
+ /**
+ * set form type
+ *
+ * @param int $type
+ *
+ * @return Form
+ */
+ public function setType(int $type): Form
+ {
+ $this->type = $type;
+
+ return $this;
+ }
+
+ /**
+ * generate two inline input
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ *
+ * @return Form
+ */
+ public function twoInlineInput(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= '<div class="col">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$valueOne,$iconOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$valueTwo,$iconTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate three inline input
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $typeThree
+ * @param string $nameThree
+ * @param string $placeholderThree
+ * @param string $valueThree
+ * @param string $iconThree
+ * @param bool $requiredThree
+ *
+ * @return Form
+ */
+ public function threeInlineInput(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo, string $typeThree, string $nameThree, string $placeholderThree, string $valueThree, string $iconThree, bool $requiredThree): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-6 col-lg-6 col-sm-12 col-xl-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate one input one select and two input
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIcon
+ * @param string $typeThree
+ * @param string $nameThree
+ * @param string $placeholderThree
+ * @param string $valueThree
+ * @param string $iconThree
+ * @param bool $requiredThree
+ * @param string $typeFour
+ * @param string $nameFour
+ * @param string $placeholderFour
+ * @param string $valueFour
+ * @param string $iconFour
+ * @param bool $requiredFour
+ *
+ * @return Form
+ */
+ public function oneInputOneSelectTwoInput(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $selectName,array $selectOptions,string $selectIcon, string $typeThree,string $nameThree, string $placeholderThree,string $valueThree, string $iconThree, bool $requiredThree, string $typeFour, string $nameFour, string $placeholderFour, string $valueFour, string $iconFour, bool $requiredFour): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-6 col-lg-6 col-sm-12 col-xl-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeFour,$nameFour,$placeholderFour,$iconFour,$valueFour,$requiredFour);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeFour,$nameFour,$placeholderFour,$iconFour,$valueFour,$requiredFour);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate one input one select one input one select
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $selectNameOne
+ * @param array $selectOptionsOne
+ * @param string $selectIconOne
+ * @param string $typeThree
+ * @param string $nameThree
+ * @param string $placeholderThree
+ * @param string $valueThree
+ * @param string $iconThree
+ * @param bool $requiredThree
+ * @param string $selectNameFour
+ * @param array $selectOptionFour
+ * @param string $selectIconFour
+ *
+ * @return Form
+ */
+ public function oneInputOneSelectOneInputOneSelect(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $selectNameOne,array $selectOptionsOne,string $selectIconOne, string $typeThree,string $nameThree, string $placeholderThree,string $valueThree, string $iconThree, bool $requiredThree, string $selectNameFour, array $selectOptionFour, string $selectIconFour): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-6 col-lg-6 col-sm-12 col-xl-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameFour,$selectOptionFour,$selectIconFour);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameFour,$selectOptionFour,$selectIconFour);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate one input two select one input
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $selectNameOne
+ * @param array $selectOptionsOne
+ * @param string $selectIconOne
+ * @param string $selectNameTwo
+ * @param array $selectOptionsTwo
+ * @param string $selectIconTwo
+ * @param string $typeFour
+ * @param $nameFour
+ * @param string $placeholderFour
+ * @param string $valueFour
+ * @param string $iconFour
+ * @param bool $requiredFour
+ *
+ * @return Form
+ *
+ */
+ public function oneInputTwoSelectOneInput(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $selectNameOne,array $selectOptionsOne,string $selectIconOne, string $selectNameTwo,array $selectOptionsTwo,string $selectIconTwo, string $typeFour, $nameFour, string $placeholderFour,string $valueFour, string $iconFour, bool $requiredFour): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-6 col-lg-6 col-sm-12 col-xl-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeFour,$nameFour,$placeholderFour,$iconFour,$valueFour,$requiredFour);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeFour,$nameFour,$placeholderFour,$iconFour,$valueFour,$requiredFour);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+
+ /**
+ * generate one input three select
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $selectNameOne
+ * @param array $selectOptionsOne
+ * @param string $selectIconOne
+ * @param string $selectNameTwo
+ * @param array $selectOptionsTwo
+ * @param string $selectIconTwo
+ * @param string $selectNameThree
+ * @param array $selectOptionsThree
+ * @param string $selectIconThree
+ *
+ * @return Form
+ */
+ public function oneInputThreeSelect(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $selectNameOne,array $selectOptionsOne,string $selectIconOne, string $selectNameTwo,array $selectOptionsTwo,string $selectIconTwo,string $selectNameThree ,array $selectOptionsThree,string $selectIconThree): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-6 col-lg-6 col-sm-12 col-xl-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameThree,$selectOptionsThree,$selectIconThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameThree,$selectOptionsThree,$selectIconThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate one select three input
+ *
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIcon
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $typeThree
+ * @param string $nameThree
+ * @param string $placeholderThree
+ * @param string $valueThree
+ * @param string $iconThree
+ * @param bool $requiredThree
+ *
+ * @return Form
+ */
+ public function oneSelectThreeInput( string $selectName ,array $selectOptions ,string $selectIcon , string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne,string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo,string $typeThree, string $nameThree, string $placeholderThree, string $valueThree, string $iconThree, bool $requiredThree): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-6 col-lg-6 col-sm-12 col-xl-6">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate one select two input one select
+ *
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIcon
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $selectNameTwo
+ * @param array $selectOptionsTwo
+ * @param string $selectIconTwo
+ *
+ * @return Form
+ */
+ public function oneSelectTwoInputOneSelect( string $selectName ,array $selectOptions ,string $selectIcon , string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne,string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo, string $selectNameTwo,array $selectOptionsTwo,string $selectIconTwo): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-6 col-lg-6 col-sm-12 col-xl-6">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate one select one input one select one input
+ *
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIcon
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $selectNameTwo
+ * @param array $selectOptionsTwo
+ * @param string $selectIconTwo
+ *
+ * @return Form
+ */
+ public function oneSelectOneInputOneSelectOneInput(string $selectName ,array $selectOptions ,string $selectIcon , string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne,string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo, string $selectNameTwo,array $selectOptionsTwo,string $selectIconTwo): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-6 col-lg-6 col-sm-12 col-xl-6">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate one select one input two select
+ *
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIcon
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $selectNameTwo
+ * @param array $selectOptionsTwo
+ * @param string $selectIconTwo
+ * @param string $selectNameThree
+ * @param array $selectOptionsThree
+ * @param string $selectIconThree
+ *
+ * @return Form
+ */
+ public function oneSelectOneInputTwoSelect(string $selectName ,array $selectOptions ,string $selectIcon , string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $selectNameTwo,array $selectOptionsTwo,string $selectIconTwo, string $selectNameThree,array $selectOptionsThree,string $selectIconThree): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-6 col-lg-6 col-sm-12 col-xl-6">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameThree,$selectOptionsThree,$selectIconThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameThree,$selectOptionsThree,$selectIconThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate three inline input and one select
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $typeThree
+ * @param string $nameThree
+ * @param string $placeholderThree
+ * @param string $valueThree
+ * @param string $iconThree
+ * @param bool $requiredThree
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIcon
+ *
+ * @return Form
+ */
+ public function threeInlineInputAndOneSelect(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo, string $typeThree, string $nameThree, string $placeholderThree, string $valueThree, string $iconThree, bool $requiredThree,string $selectName,array $selectOptions,string $selectIcon): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+
+ /**
+ * generate two select and two input
+ *
+ * @param string $selectNameOne
+ * @param array $selectOptionsOne
+ * @param string $selectIconOne
+ * @param string $selectNameTwo
+ * @param array $selectOptionsTwo
+ * @param string $selectIconTwo
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ *
+ * @return Form
+ */
+ public function twoSelectTwoInput(string $selectNameOne,array $selectOptionsOne,string $selectIconOne,string $selectNameTwo,array $selectOptionsTwo,string $selectIconTwo,string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate two select one input one select
+ *
+ * @param string $selectNameOne
+ * @param array $selectOptionsOne
+ * @param string $selectIconOne
+ * @param string $selectNameTwo
+ * @param array $selectOptionsTwo
+ * @param string $selectIconTwo
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $selectNameThree
+ * @param array $selectOptionsThree
+ * @param string $selectIconThree
+ *
+ * @return Form
+ */
+ public function twoSelectOneInputOneSelect(string $selectNameOne,array $selectOptionsOne,string $selectIconOne,string $selectNameTwo,array $selectOptionsTwo,string $selectIconTwo,string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $selectNameThree,array $selectOptionsThree,string $selectIconThree): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameThree,$selectOptionsThree,$selectIconThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameThree,$selectOptionsThree,$selectIconThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+
+ /**
+ * generate three select one input
+ *
+ * @param string $selectNameOne
+ * @param array $selectOptionsOne
+ * @param string $selectIconOne
+ * @param string $selectNameTwo
+ * @param array $selectOptionsTwo
+ * @param string $selectIconTwo
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $selectNameThree
+ * @param array $selectOptionsThree
+ * @param string $selectIconThree
+ *
+ * @return Form
+ */
+ public function threeSelectOneInput(string $selectNameOne,array $selectOptionsOne,string $selectIconOne,string $selectNameTwo,array $selectOptionsTwo,string $selectIconTwo,string $selectNameThree,array $selectOptionsThree,string $selectIconThree,string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne ): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameThree,$selectOptionsThree,$selectIconThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameThree,$selectOptionsThree,$selectIconThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate two inline input one select and one input
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIcon
+ * @param string $typeThree
+ * @param string $nameThree
+ * @param string $placeholderThree
+ * @param string $valueThree
+ * @param string $iconThree
+ * @param bool $requiredThree
+ *
+ * @return Form
+ */
+ public function twoInputOneSelectOneInput(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo,string $selectName,array $selectOptions,string $selectIcon, string $typeThree, string $nameThree, string $placeholderThree, string $valueThree, string $iconThree, bool $requiredThree): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectName,$selectOptions,$selectIcon);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate two inline input and two select
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $selectNameOne
+ * @param array $selectOptionsOne
+ * @param string $selectIconOne
+ * @param string $selectNameTwo
+ * @param array $selectOptionsTwo
+ * @param string $selectIconTwo
+ *
+ * @return Form
+ */
+ public function twoInputTwoSelect(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo,string $selectNameOne,array $selectOptionsOne,string $selectIconOne,string $selectNameTwo,array $selectOptionsTwo,string $selectIconTwo): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="columns small-12 large-6 medium-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameOne,$selectOptionsOne,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="columns small-12 large-3 medium-3">';
+ $this->select($selectNameTwo,$selectOptionsTwo,$selectIconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate a button
+ *
+ * @param string $text
+ * @param string $class
+ * @param string $icon
+ * @param string $type
+ *
+ * @return Form
+ */
+ public function button(string $text, string $class, string $icon = '',string $type = Form::BUTTON ): Form
+ {
+ switch ($type)
+ {
+ case Form::BUTTON:
+ $this->form .='<button class="'.$class.'" type="button"> '.$icon.' ' .$text.'</button>';
+ break;
+ case Form::RESET:
+ $this->form .='<button class="'.$class.'" type="reset"> '.$icon.' ' .$text.'</button>';
+ break;
+ case Form::SUBMIT:
+ $this->form .='<button class="'.$class.'" type="submit"> '.$icon.' ' .$text.'</button>';
+ break;
+
+ }
+
+ return $this;
+
+ }
+
+ /**
+ * generate four inline input
+ *
+ * @param string $typeOne
+ * @param string $nameOne
+ * @param string $placeholderOne
+ * @param string $valueOne
+ * @param string $iconOne
+ * @param bool $requiredOne
+ * @param string $typeTwo
+ * @param string $nameTwo
+ * @param string $placeholderTwo
+ * @param string $valueTwo
+ * @param string $iconTwo
+ * @param bool $requiredTwo
+ * @param string $typeThree
+ * @param string $nameThree
+ * @param string $placeholderThree
+ * @param string $valueThree
+ * @param string $iconThree
+ * @param bool $requiredThree
+ * @param string $typefour
+ * @param string $nameFour
+ * @param string $placeholderFour
+ * @param string $valueFour
+ * @param string $iconFour
+ * @param bool $requiredFour
+ *
+ * @return Form
+ */
+ public function fourInlineInput(string $typeOne, string $nameOne, string $placeholderOne, string $valueOne, string $iconOne, bool $requiredOne, string $typeTwo, string $nameTwo, string $placeholderTwo, string $valueTwo, string $iconTwo, bool $requiredTwo, string $typeThree, string $nameThree, string $placeholderThree, string $valueThree, string $iconThree, bool $requiredThree, string $typefour, string $nameFour, string $placeholderFour, string $valueFour, string $iconFour, bool $requiredFour): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class=" col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->input($typefour,$nameFour,$placeholderFour,$iconFour,$valueFour,$requiredFour);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= ' <div class="columns small-12 large-6 medium-6">';
+ $this->input($typeOne,$nameOne,$placeholderOne,$iconOne,$valueOne,$requiredOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="columns small-12 large-3 medium-3">';
+ $this->input($typeTwo,$nameTwo,$placeholderTwo,$iconTwo,$valueTwo,$requiredTwo);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="columns small-12 large-3 medium-3">';
+ $this->input($typeThree,$nameThree,$placeholderThree,$iconThree,$valueThree,$requiredThree);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ public function fourInlineSelect(string $nameOne,array $optionsOne,string $iconOne,string $nameTwo,array $optionsTwo,string $iconTwo,string $nameThree,array $optionsThree,string $iconThree,string $nameFour,array $optionsFour,string $iconFour): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+
+ $this->form .= '<div class="form-row">';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($nameOne,$optionsOne,$iconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($nameTwo,$optionsTwo,$iconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($nameThree,$optionsThree,$iconThree);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-3 col-lg-3 col-sm-12 col-xl-3">';
+ $this->select($nameFour,$optionsFour,$iconFour);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= ' <div class="columns small-12 large-3 medium-3">';
+ $this->select($nameOne,$optionsOne,$iconOne);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="columns small-12 large-3 medium-3">';
+ $this->select($nameTwo,$optionsTwo,$iconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="columns small-12 large-3 medium-3">';
+ $this->select($nameThree,$optionsThree,$iconThree);
+ $this->form .= '</div>';
+
+ $this->form .= ' <div class="columns small-12 large-3 medium-3">';
+ $this->select($nameFour,$optionsFour,$iconFour);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+
+ break;
+ }
+ return $this;
+ }
+ /**
+ * add csrf token in form
+ *
+ * @param string $csrf
+ *
+ * @return Form
+ */
+ public function csrf(string $csrf): Form
+ {
+ $this->form .= $csrf;
+
+ return $this;
+ }
+
+ /**
+ * generate a button to reset the form
+ *
+ * @param string $text
+ * @param string $class
+ * @param string|null $icon
+ *
+ * @return Form
+ */
+ public function reset(string $text, string $class, string $icon = ''): Form
+ {
+ $this->form .= '<button class="'.$class.'" type="reset"> '.$icon.' ' .' '.$text.'</button>';
+
+ return $this;
+ }
+
+ /**
+ * generate a textarea
+ *
+ * @param string $name
+ * @param string $placeholder
+ * @param int $cols
+ * @param int $row
+ * @param string $value
+ * @param bool $autofocus
+ * @return Form
+ */
+ public function textarea(string $name, string $placeholder, int $cols, int $row,bool $autofocus = false,string $value = ''): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ if ($autofocus)
+ {
+ $this->form .= ' <div class="form-group"><textarea rows="'.$row.'" cols="'.$cols.'" placeholder="'.$placeholder.'" autofocus="autofocus" class="form-control" required="required" name="'.$name.'">'.$value.'</textarea></div>';
+ } else {
+ $this->form .= ' <div class="form-group"><textarea rows="'.$row.'" cols="'.$cols.'" placeholder="'.$placeholder.'" class="form-control" required="required" name="'.$name.'">'.$value.'</textarea></div>';
+ }
+ break;
+ case Form::FOUNDATION:
+ if ($autofocus)
+ {
+ $this->form .= '<textarea rows="'.$row.'" cols="'.$cols.'" placeholder="'.$placeholder.'" autofocus="autofocus" name="'.$name.'"> '.$value.'</textarea>';
+ } else {
+ $this->form .= '<textarea rows="'.$row.'" cols="'.$cols.'" placeholder="'.$placeholder.'" name="'.$name.'">'.$value.'</textarea>';
+ }
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate a image
+ *
+ * @param string $src
+ * @param string $alt
+ * @param string $class
+ * @param string $width
+ *
+ * @return Form
+ */
+ public function img(string $src, string $alt, string $class = '', string $width = '100%'): Form
+ {
+ if (empty($class))
+ $this->form .= '<img src="'.$src.'" alt="'.$alt.'" width="'.$width.'">';
+ else
+ $this->form .= '<img src="'.$src.'" alt="'.$alt.'" class="'.$class.'" width="'.$width.'">';
+
+ return $this;
+ }
+
+ /**
+ * call form builder
+ *
+ * @return Form
+ */
+ public static function create(): Form
+ {
+ return new static();
+ }
+
+ /**
+ * generate a submit button
+ *
+ * @param string $text
+ * @param string $class
+ * @param string $id
+ * @param string $icon
+ *
+ * @return Form
+ */
+ public function submit(string $text, string $class, string $id,string $icon = ''): Form
+ {
+
+ if ($this->type == Form::BOOTSTRAP)
+ $this->form .= '<div class="form-group"><button type="submit" class="'.$class.'" id="'.$id.'">'.$icon.' '.$text.'</button></div>';
+ else
+ $this->form .= '<div><button type="submit" class="'.$class.'" id="'.$id.'">'.$icon.' '.$text.'</button></div>';
+
+ return $this;
+ }
+
+ /**
+ * generate a link
+ *
+ * @param string $url
+ * @param string $class
+ * @param string $text
+ * @param string|null $icon
+ *
+ * @return Form
+ */
+ public function link(string $url, string $class, string $text, string $icon = ''): Form
+ {
+ $this->form .= '<a href="'.$url.'" class="'.$class.'"> '. $icon .' '.$text .'</a>';
+
+ return $this;
+ }
+
+ /**
+ * generate a select input
+ *
+ * @param string $name
+ * @param array $options
+ * @param string|null $icon
+ *
+ * @param bool $multiple
+ * @return Form
+ */
+ public function select(string $name, array $options,string $icon = '',bool $multiple = false): Form
+ {
+
+ if(empty($this->inputSize))
+ $class = 'form-control';
+ else
+ $class = $this->inputSize;
+
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ if (empty($icon))
+ {
+ if ($multiple)
+ $this->form .= '<div class="form-group"><select class="'.$class.'" name="'.$name.'" multiple>';
+ else
+ $this->form .= '<div class="form-group"><select class="'.$class.'" name="'.$name.'">';
+ foreach ($options as $value)
+ {
+ $this->form .= ' <option value="'.$value.'" class="'.$class.'"> '.$value.'</option>';
+ }
+ $this->form .= '</select></div>';
+
+ } else {
+
+ if ($multiple)
+ $this->form .= '<div class="form-group"><div class="input-group"><div class="input-group-prepend"> <span class="input-group-text"> '.$icon.' </span></div> <select class="'.$class.'" name="'.$name.'" multiple>';
+ else
+ $this->form .= '<div class="form-group"><div class="input-group"><div class="input-group-prepend"> <span class="input-group-text"> '.$icon.' </span></div> <select class="'.$class.'" name="'.$name.'">';
+
+ foreach ($options as $value)
+ $this->form .= '<option value="'.$value.'" class="'.$class.'"> '.$value.'</option>';
+
+ $this->form .= '</select> </div></div>';
+ }
+
+ break;
+ case Form::FOUNDATION:
+
+ if (empty($icon))
+ {
+ if ($multiple)
+ $this->form .= ' <select name="'.$name.'" multiple>';
+ else
+ $this->form .= ' <select name="'.$name.'">';
+
+ foreach ($options as $value)
+ $this->form .= ' <option value="'.$value.'">'.$value.'</option>';
+
+ $this->form .= '</select>';
+ } else {
+
+ if ($multiple)
+ $this->form .= '<div class="input-group"><span class="input-group-label">'.$icon.'</span><select class="input-group-field" name="'.$name.'" multiple>';
+ else
+ $this->form .= '<div class="input-group"><span class="input-group-label">'.$icon.'</span><select class="input-group-field" name="'.$name.'">';
+
+ foreach ($options as $value)
+ $this->form .= ' <option class="input-group-field" value="'.$value.'">'.$value.'</option>';
+
+ $this->form .= '</select></div>';
+ }
+
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * @param string $nameOne
+ * @param array $optionsOne
+ * @param string $iconOne
+ * @param string $nameTwo
+ * @param array $optionsTwo
+ * @param string $iconTwo
+ *
+ * @return Form
+ */
+ public function twoInlineSelect(string $nameOne, array $optionsOne, string $iconOne, string $nameTwo, array $optionsTwo, string $iconTwo): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="col-md-6">';
+ $this->select($nameOne,$optionsOne,$iconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-6">';
+ $this->select($nameTwo,$optionsTwo,$iconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+ $this->form .= '<div class="row">';
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->select($nameOne,$optionsOne,$iconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->select($nameTwo,$optionsTwo,$iconTwo);
+ $this->form .= '</div>';
+ $this->form .= '</div>';
+ break;
+ }
+
+ return $this;
+ }
+
+ /**
+ * generate a checkbox input
+ *
+ * @param string $name
+ * @param string $text
+ * @param string $class
+ * @param bool $checked
+ *
+ * @return Form
+ */
+ public function checkbox(string $name, string $text, string $class, bool $checked = false): Form
+ {
+ if ($checked)
+ {
+ $this->form .= '<div class="'.$class.'"><input id="'.$name.'" type="checkbox" checked="checked"><label for="'.$name.'"> '.$text.'</label> </div>' ;
+ } else {
+ $this->form .= '<div class="'.$class.'"><input id="'.$name.'" type="checkbox"><label for="'.$name.'"> '.$text.'</label> </div>';
+ }
+ return $this;
+ }
+
+ /**
+ * generate a radio input
+ *
+ * @param string $name
+ * @param string $text
+ * @param string $class
+ * @param bool $checked
+ *
+ * @return Form
+ */
+ public function radio(string $name, string $text, string $class, bool $checked = false): Form
+ {
+ if ($checked)
+ {
+ $this->form .= '<div class="'.$class.'">
+ <label>
+ <input type="radio" name="'.$name.'" checked="checked">
+ '.$text.'
+ </label>
+ </div>' ;
+ } else {
+ $this->form .= '<div class="'.$class.'">
+ <label>
+ <input type="radio" name="'.$name.'">
+ '.$text.'
+ </label>
+ </div>' ;
+ }
+ return $this;
+ }
+
+ /**
+ * return the form
+ *
+ * @return string
+ */
+ public function end(): string
+ {
+ $this->form .= '</form>';
+
+ return $this->form;
+ }
+
+ /**
+ * generate a redirect select
+ *
+ * @param string $name
+ * @param array $options
+ * @param string $icon
+ *
+ * @throws Exception
+ * @return Form
+ */
+ public function redirectSelect(string $name, array $options, string $icon = ''): Form
+ {
+ $op = array('url','value');
+
+ if ($this->type == Form::BOOTSTRAP)
+ {
+ if (!empty($icon))
+ $this->form .= '<div class="form-group"><div class="input-group"><div class="input-group-prepend"><div class="input-group-text">' . $icon . '</div></div>';
+ else
+ $this->form .= '<div class="form-group">';
+
+ if (!empty($this->inputSize))
+ $this->form .= '<select class="' . $this->inputSize . '" name="' . $name . '" size="1" onChange="location = this.options[this.selectedIndex].value">';
+ else
+ $this->form .= '<select class="form-control" name="' . $name . '" size="1" onChange="location = this.options[this.selectedIndex].value">';
+
+ foreach ($options as $k => $option)
+ {
+ if (is_array($option))
+ {
+ foreach ($op as $o)
+ if(!key_exists($o,$option))
+ throw new Exception("missing $o key");
+
+ if (!empty($this->inputSize))
+ $this->form .= '<option value="'.$option['url'].'" class="'.$this->inputSize.'"> '.$option['value'].'</option>';
+ else
+ $this->form .= '<option value="'.$option['url'].'" class="form-control"> '.$option['value'].'</option>';
+
+ }else {
+ if (!empty($this->inputSize))
+ $this->form .= '<option value="'.$k.'" class="'.$this->inputSize.'"> '.$option.'</option>';
+ else
+ $this->form .= '<option value="'.$k.'" class="form-control"> '.$option .'</option>';
+
+ }
+
+ }
+ if (!empty($icon))
+ $this->form .= '</select></div></div>';
+ else
+ $this->form .= '</select></div>';
+
+ }
+
+ if ($this->type == Form::FOUNDATION)
+ {
+ if (!empty($icon))
+ $this->form .= '<div class="input-group"><span class="input-group-label">'.$icon.'</span>';
+ else
+ $this->form .= '<div class="input-group">';
+
+
+ $this->form .= '<select name="'. $name.'" size="1" onChange="location = this.options[this.selectedIndex].value" class="input-group-field">';
+
+ foreach ($options as $k => $option)
+ {
+ foreach ($op as $o)
+ if(!key_exists($o,$option))
+ throw new Exception("missing $o key");
+
+ $this->form .= '<option value="'.$option['url'].'"> '.$option['value'].'</option>';
+ }
+
+ $this->form .= '</select></div>';
+
+ }
+
+ return $this;
+ }
+
+ /**
+ * generate two inline redirect select
+ *
+ * @param string $nameOne
+ * @param array $optionsOne
+ * @param string $iconOne
+ * @param string $nameTwo
+ * @param array $optionsTwo
+ * @param string $iconTwo
+ *
+ * @return Form
+ * @throws Exception
+ */
+ public function twoRedirectSelect(string $nameOne, array $optionsOne, string $iconOne, string $nameTwo, array $optionsTwo, string $iconTwo): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="col-md-6">';
+ $this->redirectSelect($nameOne,$optionsOne,$iconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-6">';
+ $this->redirectSelect($nameTwo,$optionsTwo,$iconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+
+ case Form::FOUNDATION:
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->redirectSelect($nameOne,$optionsOne,$iconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->redirectSelect($nameTwo,$optionsTwo,$iconTwo);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate one select and one input inline
+ *
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIconOne
+ * @param string $type
+ * @param string $name
+ * @param string $placeholder
+ * @param bool $required
+ * @param string $iconTwo
+ * @param string|null $value
+ *
+ * @return Form
+ */
+ public function oneSelectOneInput(string $selectName, array $selectOptions, string $selectIconOne, string $type, string $name, string $placeholder, bool $required, string $iconTwo , string $value): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="col-md-6">';
+ $this->select($selectName,$selectOptions,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-6">';
+ $this->input($type,$name,$placeholder,$value,$iconTwo,$required);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->select($selectName,$selectOptions,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->input($type,$name,$placeholder,$value,$iconTwo,$required);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate one input and one select
+ *
+ * @param string $type
+ * @param string $name
+ * @param string $placeholder
+ * @param bool $required
+ * @param string $inputIcon
+ * @param string $value
+ * @param string $selectName
+ * @param array $selectOptions
+ * @param string $selectIconOne
+ *
+ * @return Form
+ */
+ public function oneInputOneSelect(string $type, string $name, string $placeholder, bool $required, string $inputIcon, string $value, string $selectName, array $selectOptions, string $selectIconOne): Form
+ {
+
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="col-md-6">';
+ $this->input($type,$name,$placeholder,$inputIcon,$value,$required);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="col-md-6">';
+ $this->select($selectName,$selectOptions,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ case Form::FOUNDATION:
+
+ $this->form .= '<div class="row">';
+
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->input($type,$name,$placeholder,$value,$inputIcon,$required);
+ $this->form .= '</div>';
+
+ $this->form .= '<div class="large-6 medium-6 small-12 columns">';
+ $this->select($selectName,$selectOptions,$selectIconOne);
+ $this->form .= '</div>';
+
+ $this->form .= '</div>';
+ break;
+ }
+ return $this;
+ }
+
+ /**
+ * generate a form
+ *
+ * @param string $table
+ * @param Table $instance
+ * @param string $submitText
+ * @param string $submitClass
+ * @param string $submitId
+ * @param string $submitIcon
+ * @param int $mode
+ * @param int $id
+ *
+ * @return string
+ * @throws Exception
+ */
+ public function generate(string $table, Table $instance,string $submitText,string $submitClass,string $submitId,string $submitIcon = '',int $mode = Form::CREATE,int $id = 0): string
+ {
+ $instance = $instance->setName($table);
+ $types = $instance->getColumnsTypes();
+ $columns = $instance->getColumns();
+ $primary = $instance->primaryKey();
+
+
+ if(is_null($primary))
+ {
+ throw new Exception('We have not found a primary key');
+ }
+
+ $number = array(
+ 'smallint',
+ 'integer',
+ 'bigint',
+ 'decimal',
+ 'numeric',
+ 'real',
+ 'double',
+ 'double precision',
+ 'smallserial',
+ 'serial',
+ 'integer',
+ 'int',
+ 'bigserial',
+ 'smallint',
+ 'float',
+ );
+
+ $date = array(
+ 'date',
+ 'datetime',
+ 'timestamp',
+ 'time',
+ 'interval',
+ 'real',
+ 'float4',
+ 'timestamp without time zone'
+ );
+
+
+ if ($mode == Form::EDIT)
+ {
+ $records = $instance->selectById($id);
+
+ if (count($records) > 1)
+ throw new Exception('The primary key are not unique');
+ if (empty($records))
+ throw new Exception('Record was not found');
+
+ foreach ($records as $record)
+ {
+ foreach ($columns as $k => $column)
+ {
+ $type = $types[$k];
+
+ if (is_null($record->$column))
+ $record->$column = '';
+
+ if($column != $primary)
+ {
+ $type = explode('(',$type);
+ $type = $type[0];
+
+ switch ($type)
+ {
+ case has($type,$number):
+ $this->input(Form::NUMBER,$column,$column,'',$record->$column);
+ break;
+ case has($type,$date):
+ $this->input(Form::DATETIME,$column,$column,'',$record->$column);
+ break;
+ default:
+ $this->textarea($column,$column,10,10,false,$record->$column);
+ break;
+
+ }
+ } else {
+
+
+ $this->input(Form::HIDDEN,$column,$column,'',$record->$column);
+
+ }
+ }
+ }
+ $this->submit($submitText,$submitClass,$submitId,$submitIcon);
+ return $this->end();
+ }
+
+ if ($mode == Form::CREATE)
+ {
+ foreach ($types as $k => $type)
+ {
+ $column = $columns[$k];
+
+ if ($column != $primary)
+ {
+
+ $current = date('Y-m-d');
+
+ $type = explode('(',$type);
+
+ $type = $type[0];
+
+ switch ($type)
+ {
+ case has($type,$number):
+ $this->input(Form::NUMBER,$column,$column);
+ break;
+ case has($type,$date):
+ $this->input(Form::DATE,$column,$column,'',$current);
+ break;
+ default:
+ $this->textarea($column,$column,10,10);
+ break;
+ }
+ } else {
+ $this->input(Form::HIDDEN,$column,$column);
+ }
+
+ }
+ $this->submit( $submitText,$submitClass,$submitId,$submitIcon);
+ return $this->end();
+ }
+ throw new Exception('missing mode edit or create');
+ }
+
+ /**
+ * define input size to large
+ *
+ * @param bool $large
+ *
+ * @return Form
+ */
+ public function setLargeInput(bool $large): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ if ($large)
+ $this->inputSize = 'form-control form-control-lg';
+ else
+ $this->inputSize = 'form-control';
+ break;
+
+ }
+ return $this;
+ }
+
+ /**
+ * define input size to small
+ *
+ * @param bool small
+ *
+ * @return Form
+ */
+ public function setSmallInput(bool $small): Form
+ {
+ switch ($this->type)
+ {
+ case Form::BOOTSTRAP:
+ if ($small)
+ $this->inputSize = 'form-control form-control-sm';
+ else
+ $this->inputSize = 'form-control';
+ break;
+ }
+ return $this;
+ }
+}
+
+
diff --git a/imperium/Html/Pagination/Pagination.php b/imperium/Html/Pagination/Pagination.php
new file mode 100644
index 0000000..00a43c3
--- /dev/null
+++ b/imperium/Html/Pagination/Pagination.php
@@ -0,0 +1,647 @@
+<?php
+/**
+ * fumseck added Pagination.php to imperium
+ * The 06/11/17 at 11:52
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+namespace Imperium\Html\Pagination;
+
+
+use Imperium\Html\Form\Form;
+
+class Pagination implements PaginationManagement
+{
+ /**
+ * current page
+ *
+ * @var int
+ */
+ private static $current;
+
+ /**
+ * the per page number
+ *
+ * @var int
+ */
+ private static $perPage;
+
+ /**
+ * string the get-parameter for the pager
+ *
+ * @var string
+ */
+ private static $instance;
+
+ /**
+ * @var int
+ */
+ private static $rows = 0;
+
+ /**
+ * @var string
+ */
+ private static $ulClass;
+
+ /**
+ * @var string
+ */
+ private static $startCssClass;
+
+ /**
+ * @var string
+ */
+ private static $endCssClass;
+
+ /**
+ * @var string
+ */
+ private static $startText;
+
+ /**
+ * @var string
+ */
+ private static $endText;
+
+ /**
+ * @var int
+ */
+ private static $type;
+
+ /**
+ * @var int
+ */
+ private static $adjacent = 2;
+
+ /**
+ * @var bool
+ */
+ private static $withLinkInCurrentLi = false;
+
+ /**
+ * start pagination
+ *
+ * @param int $perPage
+ * @param string $instance
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public static function paginate(int $perPage, string $instance): Pagination
+ {
+ self::$instance = $instance;
+ self::$perPage = $perPage;
+ self::setInstance();
+ return new static();
+ }
+
+ /**
+ * set the object parameter
+ */
+ private static function setInstance()
+ {
+ $instance = get(self::$instance);
+ if (isset($instance))
+ {
+ self::$current = get(self::$instance);
+ }
+
+ if (!self::$current)
+ {
+ self::$current = 1;
+ }
+
+ }
+
+
+ /**
+ * @param string $path
+ * @param int $counter
+ *
+ * @return string
+ */
+ private static function createLiCurrentOrNot(string $path,int $counter): string
+ {
+ // init
+ $html = '';
+ if (self::isBoot())
+ $textAndOrLink = '<a href="' . $path . self::$instance . '/' . $counter . '" class="page-link">' . $counter . '</a>';
+ else
+ $textAndOrLink = '<a href="' . $path . self::$instance . '/' . $counter . '">' . $counter . '</a>';
+ if (self::$withLinkInCurrentLi === false)
+ $currentTextAndOrLink = $counter;
+ else
+ $currentTextAndOrLink = $textAndOrLink;
+
+ if (self::isBoot())
+ {
+ if ($counter == self::$current)
+ $html .= '<li class="page-item active"><a href="#" class="page-link">' . $currentTextAndOrLink . ' </a></li>';
+ else
+ $html .= '<li class="page-item">' . $textAndOrLink . '</li>';
+ } else {
+ if ($counter == self::$current)
+ $html .= '<li class="current">' . $currentTextAndOrLink . '</li>';
+ else
+ $html .= '<li>' . $textAndOrLink . '</li>';
+ }
+
+
+ return $html;
+ }
+
+ /**
+ * @param string $path
+ * @param int $counter
+ *
+ * @return string|array
+ */
+ private static function createLiCurrentOrNotRaw($path, $counter)
+ {
+ $textAndOrLink = $path . self::$instance . '/' . $counter;
+
+ if (self::$withLinkInCurrentLi === false)
+ $currentTextAndOrLink = $counter;
+ else
+ $currentTextAndOrLink = $textAndOrLink;
+
+ if ($counter == self::$current)
+ return array($currentTextAndOrLink => true);
+ else
+ return array($textAndOrLink => false);
+
+ }
+
+ /**
+ * check if pagination to bootstrap
+ *
+ * @return bool
+ */
+ private static function isBoot(): bool
+ {
+ return self::$type == Form::BOOTSTRAP;
+ }
+ /**
+ * @param string $path
+ *
+ * @return string
+ */
+ private static function createLiFirstAndSecond(string $path): string
+ {
+ if (self::isBoot())
+ return '<li class="'.self::$startCssClass.'"> <a href="'.$path. self::$instance. '/1" class="page-link"> 1 </a></li><li class="'.self::$startCssClass.'"> <a href="'.$path. self::$instance.'/2" class="page-link"> 2</a></li>';
+
+ return '<li class="'.self::$startCssClass.'"> <a href="'.$path. self::$instance. '/1"> 1 </a></li><li class="'.self::$startCssClass.'"> <a href="'.$path. self::$instance.'/2"> 2</a></li>';
+ }
+
+ /**
+ * @param string $path
+ * @param array $pagination
+ *
+ * @return void
+ */
+ private static function createLiFirstAndSecondRaw($path, array &$pagination)
+ {
+ $pagination[] = array($path . self::$instance . '/1' => false);
+ $pagination[] = array($path . self::$instance . '/2' => false);
+ }
+
+ /**
+ * get next and prev meta-links
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ public function getNextPrevLinks(string $path = '?') : string
+ {
+
+ $nextLink = '';
+ $prevLink = '';
+ $prev = self::$current - 1;
+ $next = self::$current + 1;
+ $last = (int)ceil(self::$rows / self::$perPage);
+ if ($last > 1)
+ {
+ if (self::$current > 1)
+ {
+ if (self::isBoot())
+ $prevLink = '<li class="'.self::$startCssClass.'"> <a href="' . $path . self::$instance . '/' . $prev . '" class="page-link"></li>';
+ else
+ $prevLink = '<li> <a href="' . $path . self::$instance . '/' . $prev . '"></li>';
+ }
+
+ if (self::$current < $last)
+ {
+ if (self::isBoot())
+ $prevLink = '<li class="'.self::$startCssClass.'"> <a href="' . $path . self::$instance . '/' . $next . '" class="page-link"></li>';
+ else
+ $prevLink = '<li> <a href="' . $path . self::$instance . '/' . $next . '"></li>';
+ }
+
+
+ }
+
+ return "$nextLink $prevLink";
+ }
+
+ /**
+ * returns the limit for the data source
+ *
+ * @return string LIMIT-String for an SQL-query
+ */
+ public function getLimit(): string
+ {
+ return ' LIMIT ' . $this->getStart() . ',' . self::$perPage;
+ }
+
+ /**
+ * create the starting point for getLimit()
+ *
+ * @return int
+ */
+ public function getStart(): int
+ {
+ return (self::$current * self::$perPage) - self::$perPage;
+ }
+
+ /**
+ * create pagination
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ public function get(string $path = '?'): string
+ {
+ $pagination = '';
+ if (!self::isBoot())
+ {
+ // init
+ $counter = 0;
+
+ $prev = self::$current - 1;
+ $next = self::$current + 1;
+ $last = ceil(self::$rows / self::$perPage);
+ $tmpSave = $last - 1;
+
+ if(self::$current < $last)
+ $nextDataAttribute = $next;
+ else
+ $nextDataAttribute = 'false';
+
+ if (self::$current > 1)
+ $prevDataAttribute = $prev;
+ else
+ $prevDataAttribute = 'false';
+ if ($last > 1)
+ {
+ $pagination .= '<ul class="' . self::$ulClass . '" data-pagination-current="' . self::$current . '" data-pagination-prev="' . $prevDataAttribute . '" data-pagination-next="' . $nextDataAttribute . '" data-pagination-length="' . $last . '">';
+
+ if (self::$current > 1)
+ $pagination .= '<li class="' . self::$startCssClass . '"><a href="' . $path . self::$instance . '/' . $prev . '">' . self::$startText . '</a></li>';
+ else
+ $pagination .= '<li class="' . self::$startCssClass . '">' . self::$startText . '</li>';
+
+
+ if ($last < 7 + (self::$adjacent * 2))
+ {
+ for ($counter = 1; $counter <= $last; $counter++)
+ {
+ $pagination .= $this->createLiCurrentOrNot($path, $counter);
+ }
+
+ } elseif (self::$current < 5 && ($last > 5 + (self::$adjacent * 2)))
+ {
+ if (self::$current < 1 + (self::$adjacent * 2))
+ {
+ for ($counter = 1; $counter < 4 + (self::$adjacent * 2); $counter++)
+ {
+ $pagination .= $this->createLiCurrentOrNot($path, $counter);
+ }
+ }
+ $pagination .= '<li><a href="' . $path . self::$instance . '/' . $tmpSave . '">' . $tmpSave . '</a></li>';
+ $pagination .= '<li><a href="' . $path . self::$instance . '/' . $last . '">' . $last . '</a></li>';
+ } elseif ($last - (self::$adjacent * 2) > self::$current && self::$current > (self::$adjacent * 2))
+ {
+ $pagination .= $this->createLiFirstAndSecond($path);
+
+ for ($counter = self::$current - self::$adjacent;$counter <= self::$current + self::$adjacent; $counter++)
+ {
+ $pagination .= $this->createLiCurrentOrNot($path, $counter);
+ }
+
+ $pagination .= '<li><a href="' . $path . self::$instance . '/' . $tmpSave . '">' . $tmpSave . '</a></li>';
+ $pagination .= '<li><a href="' . $path .self::$instance . '/' . $last . '">' . $last . '</a></li>';
+ } else {
+ $pagination .= $this->createLiFirstAndSecond($path);
+
+
+ for ($counter = $last - (2 + (self::$adjacent * 2)); $counter <= $last; $counter++)
+ {
+ $pagination .= $this->createLiCurrentOrNot($path, $counter);
+ }
+ }
+ if (self::$current < $counter - 1) {
+ $pagination .= '<li class="' . self::$endCssClass. '"><a href="' . $path .self::$instance . '/' . $next . '">' . self::$endText. '</a></li>';
+ } else {
+ $pagination .= '<li class="' . self::$endCssClass . '">' . self::$endText. '</li>';
+ }
+ $pagination .= '</ul>';
+ }
+ } else {
+ // init
+ $counter = 0;
+
+ $prev = self::$current - 1;
+ $next = self::$current + 1;
+ $last = ceil(self::$rows / self::$perPage);
+ $tmpSave = $last - 1;
+
+ if(self::$current < $last)
+ $nextDataAttribute = $next;
+ else
+ $nextDataAttribute = 'false';
+
+ if (self::$current > 1)
+ $prevDataAttribute = $prev;
+ else
+ $prevDataAttribute = 'false';
+ if ($last > 1)
+ {
+ $pagination .= '<ul class="' . self::$ulClass . '" data-pagination-current="' . self::$current . '" data-pagination-prev="' . $prevDataAttribute . '" data-pagination-next="' . $nextDataAttribute . '" data-pagination-length="' . $last . '">';
+ if (self::$current > 1)
+ $pagination .= '<li class="' . self::$startCssClass . '"><a href="' . $path . self::$instance . '/' . $prev . '" class="page-link"> ' . self::$startText . '</a></li>';
+ else
+ $pagination .= '<li class="disabled ' . self::$startCssClass . '"> <a class="page-link"> ' . self::$startText . '</a> </li>';
+
+ if ($last < 7 + (self::$adjacent * 2))
+ {
+ for ($counter = 1; $counter <= $last; $counter++)
+ {
+ $pagination .= $this->createLiCurrentOrNot($path, $counter);
+ }
+
+ } elseif (self::$current < 5 && ($last > 5 + (self::$adjacent * 2)))
+ {
+ if (self::$current < 1 + (self::$adjacent * 2))
+ {
+ for ($counter = 1; $counter < 4 + (self::$adjacent * 2); $counter++)
+ {
+ $pagination .= $this->createLiCurrentOrNot($path, $counter);
+ }
+ }
+
+ $pagination .= '<li class="'.self::$startCssClass.'"><a href="' . $path . self::$instance . '/' . $tmpSave . '" class="page-link"> ' . $tmpSave . '</a></li>';
+ $pagination .= '<li><a href="' . $path . self::$instance . '/' . $last . '" class="page-link"> ' . $last . ' </a></li>';
+ } elseif ($last - (self::$adjacent * 2) > self::$current && self::$current > (self::$adjacent * 2))
+ {
+ $pagination .= $this->createLiFirstAndSecond($path);
+ for ($counter = self::$current - self::$adjacent;$counter <= self::$current + self::$adjacent; $counter++)
+ {
+ $pagination .= $this->createLiCurrentOrNot($path, $counter);
+ }
+
+ $pagination .= '<li><a href="' . $path . self::$instance . '/' . $tmpSave . '" class="page-link"> ' . $tmpSave . ' </a></li>';
+ $pagination .= '<li><a href="' . $path .self::$instance . '/' . $last . '" class="page-link"> ' . $last . ' </a></li>';
+ } else {
+ $pagination .= $this->createLiFirstAndSecond($path);
+
+ for ($counter = $last - (2 + (self::$adjacent * 2)); $counter <= $last; $counter++)
+ {
+ $pagination .= $this->createLiCurrentOrNot($path, $counter);
+ }
+ }
+ if (self::$current < $counter - 1) {
+ $pagination .= '<li class="' . self::$endCssClass. '"><a href="' . $path .self::$instance . '/' . $next . '" class="page-link"> ' . self::$endText. ' </a></li>';
+ } else {
+ $pagination .= '<li class="disabled ' . self::$endCssClass . '" > <a class="page-link">' . self::$endText. '</a> </li>';
+ }
+ $pagination .= '</ul>';
+ }
+ }
+
+
+ return $pagination;
+ }
+
+ /**
+ * create links as array
+ *
+ * @param string $path
+ *
+ * @return array
+ */
+ public function linksRaw(string $path = '?'): array
+ {
+ $counter = 0;
+ $pagination = array();
+ $prev = self::$current - 1;
+ $next = self::$current + 1;
+ $last = ceil(self::$rows / self::$perPage);
+ $tmpSave = $last - 1;
+
+ if ($last > 1)
+ {
+ if (self::$current > 1)
+ {
+ $pagination[] = array($path . self::$instance. '/' . $prev => false);
+ }
+ if ($last < 7 + (self::$adjacent * 2))
+ {
+ for ($counter = 1; $counter <= $last; $counter++)
+ {
+ $pagination[] = $this->createLiCurrentOrNotRaw($path, $counter);
+ }
+ } elseif (self::$current < 5 && ($last > 5 + (self::$adjacent * 2)))
+ {
+ if (self::$current < 1 + (self::$adjacent * 2))
+ {
+ for ($counter = 1; $counter < 4 + (self::$adjacent * 2); $counter++)
+ {
+ $pagination[] = $this->createLiCurrentOrNotRaw($path, $counter);
+ }
+ }
+ $pagination[] = array('' => false);
+ $pagination[] = array($path . self::$instance . '/' . $tmpSave => false);
+ $pagination[] = array($path . self::$instance . '/' . $last => false);
+ } elseif ($last - (self::$adjacent * 2) > self::$current && self::$current > (self::$adjacent * 2))
+ {
+ $this->createLiFirstAndSecondRaw($path, $pagination);
+ if (self::$current != 5)
+ {
+ $pagination[] = array('' => false);
+ }
+ for ($counter = self::$current - self::$adjacent; $counter <= self::$current + self::$adjacent; $counter++)
+ {
+ $pagination[] = $this->createLiCurrentOrNotRaw($path, $counter);
+ }
+ $pagination[] = array('' => false);
+ $pagination[] = array($path . self::$instance . '/' . $tmpSave => false);
+ $pagination[] = array($path . self::$instance . '/' . $last => false);
+ } else {
+ $this->createLiFirstAndSecondRaw($path, $pagination);
+ $pagination[] = array('' => false);
+ for ($counter = $last - (2 + (self::$adjacent * 2)); $counter <= $last; $counter++)
+ {
+ $pagination[] = $this->createLiCurrentOrNot($path, $counter);
+ }
+ }
+ if (self::$current < $counter - 1)
+ {
+ $pagination[] = array($path . self::$instance . '/' . $next => false);
+ }
+ }
+ return $pagination;
+ }
+
+ /**
+ * set the adjacent
+ *
+ * @param int $adjacent
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setAdjacent(int $adjacent): Pagination
+ {
+ self::$adjacent = $adjacent;
+ return $this;
+ }
+
+ /**
+ * set current page
+ *
+ * @param int $current
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setCurrent(int $current): Pagination
+ {
+ self::$current = $current;
+ return $this;
+ }
+
+ /**
+ * define the end char
+ *
+ * @param string $endChar
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setEndChar(string $endChar): Pagination
+ {
+ self::$endText = $endChar;
+
+ return $this;
+ }
+
+ /**
+ * define the char char
+ *
+ * @param string $startChar
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setStartChar(string $startChar): Pagination
+ {
+ self::$startText = $startChar;
+
+ return $this;
+ }
+
+ /**
+ * define the end css class
+ *
+ * @param string $endClass
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setEndCssClass(string $endClass): Pagination
+ {
+ self::$endCssClass = $endClass;
+
+ return $this;
+ }
+
+ /**
+ * define start css class
+ *
+ * @param string $startClass
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setStartCssClass(string $startClass): Pagination
+ {
+ self::$startCssClass = $startClass;
+
+ return $this;
+ }
+
+ /**
+ * define ul pagination class
+ *
+ * @param string $ulClass
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setUlCssClass(string $ulClass): Pagination
+ {
+ self::$ulClass = $ulClass;
+ return $this;
+ }
+
+ /**
+ * define total of records
+ *
+ * @param int $total
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setTotal(int $total): Pagination
+ {
+ self::$rows = $total;
+
+ return $this;
+ }
+
+ /**
+ * @param bool $bool
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setWithLinkInCurrentLi(bool $bool): Pagination
+ {
+ self::$withLinkInCurrentLi = $bool;
+
+ return $this;
+ }
+
+ /**
+ * set pagination type
+ *
+ * @param int $type
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setType(int $type): Pagination
+ {
+ self::$type = $type;
+
+ return $this;
+ }
+} \ No newline at end of file
diff --git a/imperium/Html/Pagination/PaginationManagement.php b/imperium/Html/Pagination/PaginationManagement.php
new file mode 100644
index 0000000..3a20143
--- /dev/null
+++ b/imperium/Html/Pagination/PaginationManagement.php
@@ -0,0 +1,170 @@
+<?php
+/**
+ * fumseck added PaginationManagement.php to imperium
+ * The 06/11/17 at 11:53
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+
+namespace Imperium\Html\Pagination;
+
+
+interface PaginationManagement
+{
+ /**
+ * start pagination
+ *
+ * @param int $perPage
+ * @param string $instance
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public static function paginate(int $perPage,string $instance): Pagination;
+
+ /**
+ * get next and prev meta-links
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ public function getNextPrevLinks(string $path = '?') : string;
+
+ /**
+ * set pagination type
+ *
+ * @param int $type
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setType(int $type) : Pagination;
+
+
+ /**
+ * returns the limit for the data source
+ *
+ * @return string LIMIT-String for an SQL-query
+ */
+ public function getLimit(): string;
+
+ /**
+ * create the starting point for getLimit()
+ *
+ * @return int
+ */
+ public function getStart(): int;
+
+ /**
+ * create pagination
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ public function get(string $path = '?'): string;
+
+ /**
+ * create links as array
+ *
+ * @param string $path
+ *
+ * @return array
+ */
+ public function linksRaw(string $path = '?'): array;
+
+ /**
+ * set the adjacent
+ *
+ * @param int $adjacent
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setAdjacent(int $adjacent): Pagination;
+
+ /**
+ * set current page
+ *
+ * @param int $current
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setCurrent(int $current): Pagination;
+
+
+ /**
+ * define the end char
+ *
+ * @param string $endChar
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setEndChar(string $endChar): Pagination;
+
+ /**
+ * define the char char
+ *
+ * @param string $startChar
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setStartChar(string $startChar): Pagination;
+
+ /**
+ * define the end css class
+ *
+ * @param string $endClass
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setEndCssClass(string $endClass): Pagination;
+
+ /**
+ * define start css class
+ *
+ * @param string $startClass
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setStartCssClass(string $startClass): Pagination;
+
+ /**
+ * define ul pagination class
+ *
+ * @param string $ulClass
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setUlCssClass(string $ulClass): Pagination;
+
+ /**
+ * define total of records
+ *
+ * @param int $total
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setTotal(int $total): Pagination;
+
+ /**
+ * @param bool $bool
+ *
+ * @return \Imperium\Html\Pagination\Pagination
+ */
+ public function setWithLinkInCurrentLi(bool $bool): Pagination;
+
+} \ No newline at end of file
diff --git a/imperium/Html/Records/Records.php b/imperium/Html/Records/Records.php
new file mode 100644
index 0000000..4709a58
--- /dev/null
+++ b/imperium/Html/Records/Records.php
@@ -0,0 +1,153 @@
+<?php
+/**
+ * fumseck added HtmlTable.php to imperium
+ * The 28/10/17 at 11
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+namespace Imperium\Html\Records {
+
+ use Exception;
+ use Imperium\Databases\Eloquent\Tables\Table;
+ use Imperium\Html\Form\Form;
+ use PDO;
+
+ class Records implements RecordsManagement
+ {
+
+ /**
+ * @param string $driver
+ * @param string $class
+ * @param \Imperium\Databases\Eloquent\Tables\Table $instance
+ * @param string $table
+ * @param string $editPrefix
+ * @param string $deletePrefix
+ * @param string $orderBy
+ * @param string $editText
+ * @param string $deleteText
+ * @param string $editClass
+ * @param string $deleteClass
+ * @param string $editIcon
+ * @param string $deleteIcon
+ * @param int $limit
+ * @param int $current
+ * @param string $paginationUrl
+ * @param \PDO $pdo
+ * @param int $formType
+ * @param string $searchPlaceholder
+ * @param string $confirmDeleteText
+ * @param string $startPaginationText
+ * @param string $endPaginationText
+ * @param string $updatePaginationPlaceholder
+ * @param bool $framework
+ *
+ * @return string
+ * @throws Exception
+ */
+ public static function show(string $driver,string $class, Table $instance,string $table,string $editPrefix, string $deletePrefix,string $orderBy,string $editText,string $deleteText,string $editClass,string $deleteClass,string $editIcon,string $deleteIcon,int $limit,int $current,string $paginationUrl,PDO $pdo,int $formType,string $searchPlaceholder,string $confirmDeleteText,string $startPaginationText,string $endPaginationText,string $updatePaginationPlaceholder,bool $framework = false): string
+ {
+
+ $total = $instance->count($table);
+
+ if ($formType == Form::BOOTSTRAP)
+ $pagination = pagination( $limit,$paginationUrl,$current,$total,$startPaginationText,$endPaginationText);
+ else
+ $pagination = pagination($limit,$paginationUrl,$current,$total,$startPaginationText,$endPaginationText,'','','',$formType);
+ $instance = $instance->setName($table);
+ $offset = ($limit * $current) - $limit;
+ $key = $instance->primaryKey();
+
+
+ if(is_null($key))
+ {
+ throw new Exception('We have not found a primary key');
+ }
+
+ $columns = $instance->getColumns();
+
+
+
+ if ($framework)
+ {
+ $parts = explode('/',server('REQUEST_URI'));
+ $search = has('search',$parts);
+ if ($search)
+ $like = end($parts);
+ else
+ $like = '';
+
+ if (empty($like))
+ $records = sql($table)->setPdo($pdo)->limit($limit, $offset)->orderBy($key,$orderBy)->getRecords();
+ else
+ $records = sql($table)->setDriver($driver)->setPdo($pdo)->like($instance, $like)->orderBy($key,$orderBy)->getRecords();
+ } else {
+ $like = get('search');
+ if (empty($like))
+ $records = sql($table)->setPdo($pdo)->limit($limit,$offset)->orderBy($key,$orderBy)->getRecords();
+ else
+ $records = sql($table)->setDriver($driver)->setPdo($pdo)->like($instance,$like)->orderBy($key,$orderBy)->getRecords();
+ }
+
+
+ if ($formType == Form::BOOTSTRAP)
+ $html = '<div class="row"> <div class="col-lg-6 col-md-6 form-group col-sm-12"><input data-url="'.$paginationUrl.'" class="form-control" placeholder="'.$searchPlaceholder.'" onchange="search(this)" value="'.$like.'" autofocus="autofocus" type="text"></div> <div class="col-lg-6 form-group col-md-6 col-sm-12"><input type="number" onchange="location = this.attributes[3].value + this.value " value="'.$limit.'" data-url="/" placeholder="'.$updatePaginationPlaceholder.'" class="form-control"></div></div>';
+ else
+ $html = '<div class="row"> <div class="large-6 medium-6 small-12 columns"><input data-url="'.$paginationUrl.'" placeholder="'.$searchPlaceholder.'" onchange="search(this)" value="'.$like.'" autofocus="autofocus" type="text"></div> <div class="large-6 medium-6 small-12 columns"><input type="number" onchange="location = this.attributes[3].value + this.value " value="'.$limit.'" data-url="/" placeholder="'.$updatePaginationPlaceholder.'"></div></div>';
+
+ if ($framework)
+ $html .= '<script>function search(elem){var pagination = elem.attributes[0].value;window.location = pagination + "/search/" + elem.value;}</script>';
+ else
+ $html .= '<script>function search(elem){var pagination = elem.attributes[0].value;window.location = pagination + "?search=" + elem.value;}</script>';
+ if ($formType == Form::BOOTSTRAP)
+ $html .= '<div class="table-responsive"><table class="'.$class.'"><thead><tr>';
+ else
+ $html .= '<div class="table-scroll"><table class="'.$class.'"><thead><tr>';
+
+ $html .= "<th>$editText</th><th>$deleteText</th>";
+
+ foreach ($columns as $column)
+ $html .= "<th> ".strtoupper($column)."</th>";
+
+ $html .= '</tr></thead><tbody>';
+
+ $html .= '<script>function sure(e,text){if(!confirm(text)){e.preventDefault();}}</script>';
+
+
+
+ foreach ($records as $record)
+ {
+ $i = $record->$key;
+ $html .= '<tr>';
+
+ $html .= '<td> <a href="'.$editPrefix.'/'.$i.'" class="'.$editClass.'" id="edit-'.$i.'"> '.$editIcon.'</a></td>';
+ $html .= '<td> <a href="'.$deletePrefix.'/'.$i.'" class="'.$deleteClass.'" id="delete-'.$i.'" onclick="sure(event,this.attributes[4].value)" data-text="'.$confirmDeleteText.'" >'.$deleteIcon.' </a></td>';
+ foreach ($record as $value)
+ {
+
+ $html .= '<td> '.htmlentities(substr($value,0,40)).' </td>';
+ }
+ }
+ $html .= '</tr></tbody></table></div>';
+
+ $html .= '<p><div class="float-right">'.$pagination.'</div></p>';
+
+
+
+ return $html;
+ }
+ }
+}
diff --git a/imperium/Html/Records/RecordsManagement.php b/imperium/Html/Records/RecordsManagement.php
new file mode 100644
index 0000000..9d67c41
--- /dev/null
+++ b/imperium/Html/Records/RecordsManagement.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * fumseck added TableGenerationManagement.php to imperium
+ * The 28/10/17 at 11
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * @package : imperium
+ * @author : fumseck
+ */
+
+namespace Imperium\Html\Records {
+
+ use Exception;
+ use Imperium\Databases\Eloquent\Tables\Table;
+ use PDO;
+
+ /**
+ * Interface TableGenerationManagement
+ *
+ * @package Imperium\Html\Table
+ */
+ interface RecordsManagement
+ {
+ /**
+ * @param string $driver
+ * @param string $class
+ * @param \Imperium\Databases\Eloquent\Tables\Table $instance
+ * @param string $table
+ * @param string $editPrefix
+ * @param string $deletePrefix
+ * @param string $orderBy
+ * @param string $editText
+ * @param string $deleteText
+ * @param string $editClass
+ * @param string $deleteClass
+ * @param string $editIcon
+ * @param string $deleteIcon
+ * @param int $limit
+ * @param int $current
+ * @param string $paginationUrl
+ * @param \PDO $pdo
+ * @param int $formType
+ * @param string $searchPlaceholder
+ * @param string $confirmDeleteText
+ * @param string $startPaginationText
+ * @param string $endPaginationText
+ * @param string $updatePaginationPlaceholder
+ * @param bool $framework
+ *
+ * @throws Exception
+ * @return string
+ */
+ public static function show(string $driver,string $class, Table $instance,string $table,string $editPrefix, string $deletePrefix,string $orderBy,string $editText,string $deleteText,string $editClass,string $deleteClass,string $editIcon,string $deleteIcon,int $limit,int $current,string $paginationUrl,PDO $pdo,int $formType,string $searchPlaceholder,string $confirmDeleteText,string $startPaginationText,string $endPaginationText,string $updatePaginationPlaceholder,bool $framework = false): string;
+ }
+} \ No newline at end of file
diff --git a/phinx.yml b/phinx.yml
new file mode 100644
index 0000000..eab0b16
--- /dev/null
+++ b/phinx.yml
@@ -0,0 +1,35 @@
+paths:
+ migrations: '%%PHINX_CONFIG_DIR%%/db/migrations'
+ seeds: '%%PHINX_CONFIG_DIR%%/db/seeds'
+
+environments:
+ default_migration_table: phinxlog
+ default_database: development
+ mysql:
+ adapter: mysql
+ host: localhost
+ name: imperiums
+ user: root
+ pass: ''
+ port: 3306
+ charset: utf8
+
+ pgsql:
+ adapter: pgsql
+ host: localhost
+ name: imperiums
+ user: postgres
+ pass: ''
+ port: 5432
+ charset: utf8
+
+ sqlite:
+ adapter: sqlite
+ host: localhost
+ name: imperiums
+ user: root
+ pass: ''
+ port: 3306
+ charset: utf8
+
+version_order: creation
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644
index 0000000..3d31865
--- /dev/null
+++ b/phpunit.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ bootstrap="vendor/autoload.php"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="true">
+ <testsuites>
+ <testsuite name="Application Test Suite">
+ <directory suffix="Test.php">./tests</directory>
+ </testsuite>
+ </testsuites>
+ <filter>
+ <whitelist>
+ <directory>imperium/</directory>
+ <directory>tests/</directory>
+ </whitelist>
+ </filter>
+</phpunit>
diff --git a/tests/AuthenticationTest.php b/tests/AuthenticationTest.php
new file mode 100644
index 0000000..59a1140
--- /dev/null
+++ b/tests/AuthenticationTest.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * fumseck added AuthenticationTest.php to imperium
+ * The 09/09/17 at 16:41
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace tests;
+
+use Imperium\Auth\Exceptions\OauthExceptions;
+use Imperium\Auth\Oauth;
+use PHPUnit\Framework\TestCase;
+
+class AuthenticationTest extends TestCase
+{
+ /**
+ * @var string
+ */
+ private $secret;
+
+ public function setUp()
+ {
+ $this->secret = generateKey();
+ }
+
+ public function testTwoFactorKeyLength()
+ {
+ $this->assertEquals(16,strlen($this->secret));
+ $this->assertEquals(16,strlen(Oauth::generateSecret()));
+ }
+
+ /**
+ * @throws OauthExceptions
+ */
+ public function testIsValidCode()
+ {
+ $this->assertEquals(false,checkCode($this->secret,'333333'));
+ $this->assertEquals(false,Oauth::checkCode($this->secret,'333333'));
+ }
+
+ /**
+ * @throws OauthExceptions
+ */
+ public function testIsNotValidCode()
+ {
+ $this->assertEquals(true,!checkCode($this->secret,'333333'));
+ $this->assertEquals(true,!Oauth::checkCode($this->secret,'333333'));
+ }
+
+ /**
+ * @throws OauthExceptions
+ */
+ public function testCodeLength()
+ {
+ $this->expectException(OauthExceptions::class);
+ checkCode($this->secret,'333333333');
+ Oauth::checkCode($this->secret,'333333333');
+ }
+
+ public function testGenerateQrCode()
+ {
+ $code = generateQrCode('venus','fumseck',$this->secret);
+ $this->assertStringMatchesFormat('%s',$code);
+ $this->assertContains('venus',$code);
+ $this->assertContains('fumseck',$code);
+ $this->assertContains($this->secret,$code);
+
+ $code = Oauth::generateQrCode('venus','fumseck',$this->secret);
+ $this->assertStringMatchesFormat('%s',$code);
+ $this->assertContains('venus',$code);
+ $this->assertContains('fumseck',$code);
+ $this->assertContains($this->secret,$code);
+
+ }
+} \ No newline at end of file
diff --git a/tests/BaseTest.php b/tests/BaseTest.php
new file mode 100644
index 0000000..ac23016
--- /dev/null
+++ b/tests/BaseTest.php
@@ -0,0 +1,143 @@
+<?php
+/**
+ * fumseck added BaseTest.php to imperium
+ * The 11/09/17 at 17:08
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+
+namespace tests;
+
+
+use Imperium\Databases\Eloquent\Connexion\Connexion;
+use PDO;
+use PHPUnit\Framework\TestCase;
+
+class BaseTest extends TestCase
+{
+ /**
+ * @var \Imperium\Databases\Eloquent\Bases\Base
+ */
+ private $mariadb;
+
+ /**
+ * @var \Imperium\Databases\Eloquent\Bases\Base
+ */
+ private $pgsql;
+ /**
+ * @var \Imperium\Databases\Eloquent\Bases\Base
+ */
+ private $sqlite;
+
+ /**
+ * name of database
+ *
+ * @var string
+ */
+ private $base = 'imperiums';
+
+ /**
+ * Pdo
+ * @var string
+ */
+ private $pdo = PDO::class;
+
+ public function setUp()
+ {
+ $this->mariadb = base(Connexion::MYSQL,'','root','',"dump");
+ $this->pgsql = base(Connexion::POSTGRESQL,'','postgres','',"dump");
+ $this->sqlite = base(Connexion::SQLITE,'imperiums','','',"dump");
+ }
+
+ /**
+ * @throws \Imperium\Databases\Exception\IdentifierException
+ */
+ public function testCreateOnExisting()
+ {
+ $this->assertEquals(false,$this->mariadb->setCollation('utf8')->setEncoding('utf8_general_ci')->create($this->base));
+ $this->assertEquals(false,$this->pgsql ->setCollation('UTF8')->setEncoding('')->create($this->base));
+ }
+
+ /**
+ * @throws \Imperium\Databases\Exception\IdentifierException
+ */
+ public function test()
+ {
+ $this->assertEquals(true,db($this->mariadb,"a"));
+ $this->assertEquals(true,$this->mariadb->drop('a'));
+
+ $this->assertEquals(true,db($this->pgsql,"a"));
+ $this->assertEquals(true,$this->pgsql->drop('a'));
+
+
+
+ }
+
+ public function testGetInstance()
+ {
+ $this->assertInstanceOf($this->pdo, $this->mariadb->getInstance());
+ $this->assertInstanceOf($this->pdo, $this->pgsql->getInstance());
+ }
+
+ /**
+ * @throws \Imperium\Databases\Exception\IdentifierException
+ */
+ public function testShow()
+ {
+ $this->assertContains($this->base,$this->mariadb->show());
+ $this->assertContains($this->base,$this->pgsql->show());
+ }
+
+ /**
+ * @throws \Imperium\Databases\Exception\IdentifierException
+ */
+ public function testExist()
+ {
+ $this->assertEquals(true,$this->mariadb->exist($this->base));
+ $this->assertEquals(true,$this->pgsql->exist($this->base));
+ }
+
+
+ /**
+ * @throws \Imperium\Databases\Exception\IdentifierException
+ */
+ public function testGetCharset()
+ {
+ $this->assertContains('utf8',$this->mariadb->getCharset());
+ $this->assertContains('UTF8',$this->pgsql->getCharset());
+ }
+
+ /**
+ * @throws \Imperium\Databases\Exception\IdentifierException
+ */
+ public function testGetCollation()
+ {
+ $this->assertContains('utf8_general_ci',$this->mariadb->getCollation());
+ $this->assertNotEmpty($this->mariadb->getCollation());
+ $this->assertNotEmpty($this->pgsql->getCollation());
+ }
+
+ /**
+ * @throws \Imperium\Databases\Exception\IdentifierException
+ */
+ public function testHidden()
+ {
+ $this->assertNotContains($this->base,$this->pgsql->setHidden([$this->base])->show());
+ $this->assertNotContains($this->base,$this->mariadb->setHidden([$this->base])->show());
+ }
+
+} \ No newline at end of file
diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php
new file mode 100644
index 0000000..b579f35
--- /dev/null
+++ b/tests/ConnectionTest.php
@@ -0,0 +1,97 @@
+<?php
+/**
+ * fumseck added ConnectionTest.php to imperium
+ * The 11/09/17 at 06:34
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+
+namespace tests;
+
+use Imperium\Databases\Eloquent\Connexion\Connexion;
+use Imperium\File\File;
+use PDO;
+use PHPUnit\Framework\TestCase;
+
+class ConnectionTest extends TestCase
+{
+ private $base = 'imperiums';
+
+ public function testMysql()
+ {
+ $this->assertEquals(null,
+ Connexion::connect()
+ ->setDriver('mysql')
+ ->setDatabase('a')
+ ->setUser('a')
+ ->setPassword('a')
+ ->setEncoding('utf8')->getConnexion());
+
+ $this->assertInstanceOf(PDO::class,connect(Connexion::MYSQL,$this->base,'root'));
+ $this->assertInstanceOf(PDO::class,Connexion::connect()
+ ->setDriver('mysql')->setDatabase($this->base)->setUser('root')->getConnexion());
+ }
+
+ public function testPostgresql()
+ {
+ $this->assertEquals(null,
+ Connexion::connect()
+ ->setDriver('pgsql')
+ ->setDatabase('a')
+ ->setUser('a')
+ ->setPassword('a')
+ ->setEncoding('utf8')->getConnexion());
+
+ $this->assertInstanceOf(PDO::class,connect(Connexion::POSTGRESQL,$this->base,'postgres'));
+ $this->assertInstanceOf(PDO::class,Connexion::connect()
+ ->setDriver(Connexion::POSTGRESQL)->setDatabase($this->base)->setUser('postgres')->getConnexion());
+ }
+
+ public function testSqlite()
+ {
+ $this->assertInstanceOf(PDO::class,Connexion::connect()->setDriver('sqlite')->getConnexion());
+ $this->assertInstanceOf(PDO::class,Connexion::connect()->setDriver('sqlite')->setDatabase('alex')->getConnexion());
+ $this->assertEquals(true,File::delete('alex'));
+ }
+
+ public function testConnectHelper()
+ {
+ $this->assertEquals(null,connect('mysql','db','user','pass'));
+ $this->assertEquals(null,connect('pgsql','db','user','pass'));
+ $this->assertInstanceOf(PDO::class,connect('sqlite'));
+ $this->assertInstanceOf(PDO::class,connect('sqlite','alex'));
+ $this->assertEquals(true,File::delete('alex'));
+
+ }
+
+ public function testNotValid()
+ {
+ $this->assertEquals(null,Connexion::connect()->setDriver('a')->setDatabase('a')->setUser('a')->setPassword('a')->getConnexion());
+ $this->assertEquals(null,Connexion::connect()->setDriver('b')->setDatabase('a')->setUser('a')->setPassword('a')->getConnexion());
+ $this->assertEquals(null,Connexion::connect()->setDriver('c')->setDatabase('a')->setUser('a')->setPassword('a')->getConnexion());
+ $this->assertEquals(null,Connexion::connect()->setDriver('d')->setDatabase('a')->setUser('a')->setPassword('a')->getConnexion());
+ }
+
+ public function testWithoutDatabase()
+ {
+ $this->assertInstanceOf(PDO::class,connect(Connexion::MYSQL,'','root'));
+ $this->assertInstanceOf(PDO::class,connect(Connexion::POSTGRESQL,'','postgres'));
+ $this->assertInstanceOf(PDO::class,root(Connexion::MYSQL));
+ $this->assertInstanceOf(PDO::class,root(Connexion::POSTGRESQL));
+ $this->assertEquals(null,root(Connexion::ORACLE));
+ }
+} \ No newline at end of file
diff --git a/tests/FileTest.php b/tests/FileTest.php
new file mode 100644
index 0000000..5c05dac
--- /dev/null
+++ b/tests/FileTest.php
@@ -0,0 +1,398 @@
+<?php
+/**
+ * fumseck added FileTest.php to imperium
+ * The 19/09/17 at 18:51
+ *
+ * imperium is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ *
+ * imperium 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package : imperium
+ * @author : fumseck
+ **/
+
+
+namespace tests;
+
+use Exception;
+use Imperium\File\File;
+use PHPUnit\Framework\TestCase;
+
+class FileTest extends TestCase
+{
+ private $fileDir = "tests/files";
+ private $file = "test";
+ private $filename = "tests/files/test.txt";
+ private $rename = "tests/files/rename";
+ private $destination = 'tests/files/destination';
+ private $html = "tests/files/index.html";
+ private $css = "tests/files/bootstrap.css";
+ private $php = "tests/files/file.php";
+ private $js = "tests/files/bootstrap.js";
+
+ private function getTestFile(string $ext): string
+ {
+ return "$this->fileDir/$this->file.$ext";
+ }
+
+ private function createTestFile(string $ext)
+ {
+ $file = $this->getTestFile($ext);
+ if (File::exist($file))
+ {
+ File::delete($file);
+ }
+ return File::create($file);
+ }
+
+
+ private function deleteTestFile(string $ext)
+ {
+ return File::delete($this->getTestFile($ext));
+ }
+
+ private function create()
+ {
+ if (File::exist($this->file))
+ File::delete($this->file);
+
+ return File::create($this->file);
+ }
+
+ private function delete()
+ {
+ return File::delete($this->file);
+ }
+
+
+
+ public function testCreateAndDelete()
+ {
+ $this->assertEquals(true,$this->create());
+ $this->assertEquals(true,$this->delete());
+ }
+
+ public function testGetContent()
+ {
+ $this->assertEquals('',File::getContent($this->file));
+ $this->create();
+ $this->assertNotEquals(false,File::putContents($this->file,'a'));
+ $this->assertEquals('a',File::getContent($this->file));
+ $this->delete();
+ }
+
+ public function testPutContent()
+ {
+ $this->assertEquals(false,File::putContents($this->file,"a"));
+ $this->create();
+ $this->assertEquals(true,File::putContents($this->file,'a'));
+ $this->assertEquals(true,File::putContents($this->file,'alexandra'));
+ $this->delete();
+ }
+
+ public function testHash()
+ {
+ $this->assertEquals('',File::hash($this->file));
+ $this->create();
+ $this->assertEquals('d41d8cd98f00b204e9800998ecf8427e',File::hash($this->file));
+ $this->assertStringMatchesFormat('%S',File::hash($this->file));
+ $this->delete();
+ }
+
+
+ public function testExist()
+ {
+ $this->create();
+ $this->assertEquals(true,File::exist($this->file));
+ $this->delete();
+ }
+ public function testNotExist()
+ {
+ $this->delete();
+ $this->assertEquals(false,File::exist($this->file));
+ }
+ public function testIsFile()
+ {
+ $this->assertEquals(false,File::isFile($this->file));
+ $this->create();
+ $this->assertEquals(true,File::isFile($this->file));
+ $this->delete();
+ }
+
+ public function testDeleteFolder()
+ {
+ $this->assertEquals(false,File::deleteFolder('a'));
+ mkdir('a');
+ $this->assertEquals(true,File::deleteFolder('a'));
+ }
+ public function testCopy()
+ {
+ $this->create();
+ $this->assertEquals(true,File::copy($this->file,$this->destination));
+ $this->assertEquals(true,File::delete($this->destination));
+ $this->delete();
+ }
+
+ public function testSearch()
+ {
+ $this->createTestFile(File::PHP);
+ $this->assertContains($this->getTestFile(File::PHP),File::search("$this->fileDir/*.php"));
+ $this->deleteTestFile(File::PHP);
+
+ $this->createTestFile(File::HTML);
+ $this->assertContains($this->getTestFile(File::HTML),File::search("$this->fileDir/*.html"));
+ $this->deleteTestFile(File::HTML);
+ $this->assertEquals([],File::search("$this->fileDir/*.xml"));
+
+
+ }
+ public function testGetLines()
+ {
+ $this->assertEquals([],File::getLines($this->file));
+ $this->create();
+ File::putContents($this->file,"a");
+ $this->assertEquals([ 0 => "a"],File::getLines($this->file));
+ $this->delete();
+ }
+
+ public function testCopyDirectory()
+ {
+ $this->assertEquals(true,File::copyFolder('imperium',"lion"));
+ }
+
+ public function testLastModified()
+ {
+ $this->create();
+ $this->assertEquals(!false,File::lastModified($this->file));
+ $this->delete();
+ $this->assertEquals(false,File::lastModified($this->file));
+
+ }
+
+ public function testCreateExistingFile()
+ {
+ $this->create();
+ $this->assertEquals(false,File::create($this->file));
+ $this->delete();
+ }
+
+ public function testDelete()
+ {
+ File::copyFolder('imperium','lion');
+ $this->assertEquals(true,File::delete('lion'));
+ }
+
+ public function testDeleteNotExistingFolder()
+ {
+ $this->assertEquals(false,File::delete('lion'));
+ }
+
+ public function testGetKeys()
+ {
+ $this->assertEquals([],File::getKeys($this->file,''));
+ $this->assertEquals(['ENV','DB','DB_USERNAME','DB_PASSWORD'],File::getKeys($this->filename,"="));
+ }
+ public function testGetValues()
+ {
+ $this->assertEquals([],File::getValues($this->file,''));
+ $this->assertEquals(['laravel', 'mars' ,'imperium', 'pass'],File::getValues($this->filename,"="));
+ }
+
+ public function testGetSize()
+ {
+ $this->assertEquals(-1,File::getSize($this->file));
+ $this->create();
+ $this->assertNotEquals(-1,File::getSize($this->file));
+ $this->delete();
+ }
+
+ public function testGetExtention()
+ {
+ $this->assertEquals('txt',File::getExtension($this->filename));
+ $this->assertEquals('',File::getExtension($this->file));
+ }
+
+ public function testCopySourceNotExist()
+ {
+ $this->assertEquals(false,File::copy($this->file,$this->destination));
+ }
+
+ public function testIsReadable()
+ {
+ $this->assertEquals(false,File::isReadable($this->file));
+ $this->assertEquals(true,File::isReadable('imperium'));
+ $this->assertNotEquals(false,File::isReadable($this->filename));
+ }
+ public function testIsWritable()
+ {
+ $this->assertEquals(true,File::isWritable('imperium'));
+ $this->assertEquals(false,File::isWritable($this->file));
+ $this->assertNotEquals(false,File::isWritable($this->filename));
+ }
+
+ public function testHardLink()
+ {
+ $this->assertEquals(false,File::hardLink($this->file,'a'));
+ $this->assertEquals(false,File::symlink($this->file,'a'));
+ $this->assertEquals(false,File::isLink('a'));
+ $this->assertNotEquals(false,File::hardLink($this->filename,'hard_link'));
+ $this->assertNotEquals(false,File::symlink($this->filename,'sym_link'));
+ $this->assertEquals(true,File::isLink('sym_link'));
+ File::delete('hard_link');
+ File::delete('sym_link');
+ }
+
+ public function testGetMime()
+ {
+ $this->assertEquals('',File::getMime($this->file));
+ $this->assertEquals('text/plain',File::getMime($this->filename));
+ }
+
+ public function testGetStat()
+ {
+ $this->assertNotEquals([],File::getStat($this->filename));
+ $this->assertEquals([],File::getStat($this->file));
+ }
+
+ public function testGetStatKey()
+ {
+ $this->assertEquals(null,File::getStartKey($this->file,'blocks'));
+ $this->assertEquals(8,File::getStartKey($this->filename,'blocks'));
+ }
+
+ public function testWrite()
+ {
+ $this->assertEquals(false,File::write($this->file,"a"));
+ File::copy($this->filename,$this->destination);
+ $this->assertNotEquals(false,File::write($this->filename,"alexandra")) ;
+ File::delete($this->filename);
+ File::copy($this->destination,$this->filename);
+ File::delete($this->destination);
+ }
+
+ public function testIs()
+ {
+ $this->assertEquals(false,File::isImg($this->filename));
+ $this->assertEquals(false,File::isImg($this->file));
+ $this->assertEquals(false,File::isLink($this->filename));
+ $this->assertEquals(false,File::isLink($this->file));
+ $this->assertEquals(true,File::isWritable($this->filename));
+ $this->assertEquals(false,File::isWritable($this->file));
+ $this->assertEquals(true,File::isReadable($this->filename));
+ $this->assertEquals(false,File::isReadable($this->file));
+ $this->assertEquals(true,File::isFile($this->filename));
+ $this->assertEquals(false,File::isFile($this->file));
+ $this->assertEquals(false,File::isCss($this->filename));
+ $this->assertEquals(false,File::isCss($this->file));
+ $this->assertEquals(false,File::isExecutable($this->filename));
+ $this->assertEquals(false,File::isExecutable($this->file));
+ $this->assertEquals(false,File::isHtml($this->filename));
+ $this->assertEquals(false,File::isHtml($this->file));
+ $this->assertEquals(false,File::isJS($this->filename));
+ $this->assertEquals(false,File::isJS($this->file));
+ $this->assertEquals(false,File::isPhp($this->filename));
+ $this->assertEquals(false,File::isPhp($this->file));
+ $this->assertEquals(false,File::isXml($this->filename));
+ $this->assertEquals(false,File::isXml($this->file));
+ $this->assertEquals(false,File::isPdf($this->filename));
+ $this->assertEquals(false,File::isPdf($this->file));
+ $this->assertEquals(false,File::isJson($this->filename));
+ $this->assertEquals(false,File::isJson($this->file));
+ $this->assertEquals(true,File::exist($this->filename));
+ $this->assertEquals(false,File::exist($this->file));
+
+ $this->assertEquals(true,File::isHtml($this->html));
+ $this->assertEquals(false,File::isHtml($this->css));
+
+ $this->assertEquals(true,File::isCss($this->css));
+ $this->assertEquals(false,File::isCss($this->php));
+
+ $this->assertEquals(true,File::isPhp($this->php));
+ $this->assertEquals(false,File::isPhp($this->css));
+
+ $this->assertEquals(true,File::isJS($this->js));
+ $this->assertEquals(false,File::isJS($this->css));
+
+ $this->assertEquals(true,File::isXml('phpunit.xml'));
+ $this->assertEquals(false,File::isXml('composer.json'));
+
+ $this->assertEquals(true,File::isJson('composer.json'));
+ $this->assertEquals(false,File::isJson('phpunit.xml'));
+ $this->assertEquals(false,File::isPdf('phpunit.xml'));
+
+
+
+ }
+
+
+ public function testRename()
+ {
+ $this->assertEquals(false,File::rename($this->file,$this->destination));
+ $this->assertEquals(true,File::rename($this->rename,$this->destination));
+ $this->assertEquals(true,File::rename($this->destination,$this->rename));
+ }
+ public function testGetGroup()
+ {
+ $this->assertNotEquals(-1,File::getGroup($this->filename));
+ $this->assertEquals(-1,File::getGroup($this->file));
+ }
+
+ public function testGetsOwner()
+ {
+ $this->assertNotEquals(-1,File::getOwner($this->filename));
+ $this->assertEquals(-1,File::getOwner($this->file));
+ }
+
+ /**
+ * @throws Exception
+ */
+ public function testLoad()
+ {
+ $this->assertEquals(true,File::loads('tests/files/load.php'));
+ $this->expectException(Exception::class);
+ File::loads();
+ File::loads('abc');
+ }
+
+ public function testOpen()
+ {
+ $this->assertEquals(false,File::open($this->file,File::READ));
+ $this->assertNotEquals(false,File::open($this->filename,File::READ));
+ }
+
+ public function testRealPath()
+ {
+ $this->assertNotEmpty(File::realPath($this->filename));
+ $this->assertEquals('',File::realPath($this->file));
+ }
+
+
+ public function testFileTime()
+ {
+ $this->assertNotEmpty(File::fileTime($this->filename));
+ $this->assertEquals(-1,File::fileTime($this->file));
+ }
+ public function testChmod()
+ {
+ $this->assertEquals(true,File::chmod($this->rename,0777));
+ $this->assertEquals(false,File::chmod($this->file,0777));
+ }
+
+ public function testNotEmpty()
+ {
+ $this->assertNotEmpty(File::fileOwner($this->filename));
+ $this->assertEquals(-1,File::fileOwner($this->file));
+ $this->assertNotEmpty(File::getType($this->filename));
+ $this->assertEquals('',File::getType($this->file));
+ $this->assertNotEmpty(File::getType($this->filename));
+ }
+
+} \ No newline at end of file
diff --git a/tests/FormTest.php b/tests/FormTest.php
new file mode 100644
index 0000000..b092060
--- /dev/null
+++ b/tests/FormTest.php
@@ -0,0 +1,1935 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: fumseck
+ * Date: 12/03/18
+ * Time: 12:03
+ */
+
+namespace tests;
+
+
+use Exception;
+use Imperium\Databases\Eloquent\Connexion\Connexion;
+use Imperium\Html\Form\Form;
+use PHPUnit\Framework\TestCase;
+
+class FormTest extends TestCase
+{
+ /***
+ * @var Form
+ */
+ private $boot;
+
+ /**
+ * @var Form
+ */
+ private $foundation;
+
+ private $class = 'btn btn-primary';
+
+ private $icon = '<i class="fa fa-user">';
+
+ public function setUp()
+ {
+ $this->boot = form(Form::BOOTSTRAP);
+ $this->foundation = form(Form::FOUNDATION);
+ }
+
+ public function testStartAndEnd()
+ {
+
+ $html = $this->boot->start('/','demo')->end();
+ $this->assertContains('/',$html);
+ $this->assertContains('post',$html);
+ $this->assertContains('utf8',$html);
+ $this->assertStringStartsWith('<form',$html);
+ $this->assertStringEndsWith('</form>',$html);
+
+ $html = $this->foundation->start('/','demo')->end();
+ $this->assertContains('/',$html);
+ $this->assertContains('post',$html);
+ $this->assertContains('utf8',$html);
+ $this->assertStringStartsWith('<form',$html);
+ $this->assertStringEndsWith('</form>',$html);
+ }
+
+ public function testHide()
+ {
+ $boot = $this->boot->start('/','demo')->startHide()->endHide()->end();
+ $foundation = $this->foundation->start('/','demo')->startHide()->endHide()->end();
+ $this->assertContains('d-none',$boot);
+ $this->assertContains('hide',$foundation);
+ $this->assertContains('</div>',$boot);
+ $this->assertContains('</div>',$foundation);
+
+ }
+
+ public function testFile()
+ {
+ $bootHtmlWithoutIcon = $this->boot->start('/','demo')->file('avatar',$this->class,'upload')->end();
+ $bootHtmlWithIcon = $this->boot->start('/','demo')->file('avatar',$this->class,'upload',$this->icon)->end();
+
+ $foundationWithoutIcon = $this->foundation->start('/','demo')->file('avatar',$this->class,'upload')->end();
+ $foundationWithIcon = $this->foundation->start('/','demo')->file('avatar',$this->class,'upload',$this->icon)->end();
+
+ $this->assertContains('avatar',$bootHtmlWithIcon);
+ $this->assertContains('avatar',$bootHtmlWithoutIcon);
+ $this->assertContains('avatar',$foundationWithIcon);
+ $this->assertContains('avatar',$foundationWithoutIcon);
+
+ $this->assertContains($this->class,$bootHtmlWithIcon);
+ $this->assertContains($this->class,$bootHtmlWithoutIcon);
+ $this->assertContains($this->class,$foundationWithIcon);
+ $this->assertContains($this->class,$foundationWithoutIcon);
+
+ $this->assertContains('upload',$bootHtmlWithIcon);
+ $this->assertContains('upload',$bootHtmlWithoutIcon);
+ $this->assertContains('upload',$foundationWithIcon);
+ $this->assertContains('upload',$foundationWithoutIcon);
+
+ $this->assertContains($this->icon,$bootHtmlWithIcon);
+ $this->assertNotContains($this->icon,$bootHtmlWithoutIcon);
+
+ $this->assertContains($this->icon,$foundationWithIcon);
+ $this->assertNotContains($this->icon,$foundationWithoutIcon);
+
+ }
+
+
+ public function testInput()
+ {
+
+ $bootHtmlWithoutIcon = $this->boot->start('/','demo')->input(Form::TEXT,'username','Username')->end();
+ $foundationWithoutIcon = $this->foundation->start('/','demo')->input(Form::TEXT,'username','Username')->end();
+
+ $bootHtmlWithIcon = $this->boot->start('/','demo')->input(Form::TEXT,'username','Username',$this->icon)->end();
+ $foundationWithIcon = $this->foundation->start('/','demo')->input(Form::TEXT,'username','Username',$this->icon)->end();
+
+ $this->assertContains('username',$bootHtmlWithIcon);
+ $this->assertContains('username',$bootHtmlWithoutIcon);
+ $this->assertContains('username',$foundationWithIcon);
+ $this->assertContains('username',$foundationWithoutIcon);
+
+ $this->assertContains('text',$bootHtmlWithIcon);
+ $this->assertContains('text',$bootHtmlWithoutIcon);
+ $this->assertContains('text',$foundationWithIcon);
+ $this->assertContains('text',$foundationWithoutIcon);
+
+ $this->assertContains('Username',$bootHtmlWithIcon);
+ $this->assertContains('Username',$bootHtmlWithoutIcon);
+ $this->assertContains('Username',$foundationWithIcon);
+ $this->assertContains('Username',$foundationWithoutIcon);
+
+ $this->assertContains($this->icon,$bootHtmlWithIcon);
+ $this->assertNotContains($this->icon,$bootHtmlWithoutIcon);
+
+ $this->assertContains($this->icon,$foundationWithIcon);
+ $this->assertNotContains($this->icon,$foundationWithoutIcon);
+
+ }
+
+ public function testSubmit()
+ {
+
+ $bootHtmlWithoutIcon = $this->boot->start('/','demo')->input(Form::TEXT,'username','Username')->submit('submit',$this->class,'d')->end();
+ $foundationWithoutIcon = $this->foundation->start('/','demo')->input(Form::TEXT,'username','Username')->submit('submit',$this->class,'d')->end();
+
+ $bootHtmlWithIcon = $this->boot->start('/','demo')->input(Form::TEXT,'username','Username')->submit('submit',$this->class,fa('fa-send'))->end();
+ $foundationWithIcon = $this->foundation->start('/','demo')->input(Form::TEXT,'username','Username')->submit('submit',$this->class,fa('fa-send'))->end();
+
+ $this->assertContains('submit',$bootHtmlWithIcon);
+ $this->assertContains('submit',$bootHtmlWithoutIcon);
+ $this->assertContains('submit',$foundationWithIcon);
+ $this->assertContains('submit',$foundationWithoutIcon);
+
+ $this->assertContains($this->class,$bootHtmlWithIcon);
+ $this->assertContains($this->class,$bootHtmlWithoutIcon);
+ $this->assertContains($this->class,$foundationWithIcon);
+ $this->assertContains($this->class,$foundationWithoutIcon);
+
+ $this->assertContains(fa('fa-send'),$bootHtmlWithIcon);
+ $this->assertNotContains(fa('fa-send'),$bootHtmlWithoutIcon);
+ $this->assertContains(fa('fa-send'),$foundationWithIcon);
+ $this->assertNotContains(fa('fa-send'),$foundationWithoutIcon);
+ }
+
+ public function testTextarea()
+ {
+ $boot = $this->boot->start('/','demo')->textarea('bio','biography',10,15)->end();
+ $foundation = $this->foundation->start('/','demo')->textarea('bio','biography',10,15)->end();
+
+ $bootAuto = $this->boot->start('/','demo')->textarea('bio','biography',10,15,true)->end();
+ $foundationAuto = $this->foundation->start('/','demo')->textarea('bio','biography',10,15,true)->end();
+
+ $this->assertContains('bio',$boot);
+ $this->assertContains('bio',$foundation);
+
+ $this->assertContains('biography',$boot);
+ $this->assertContains('biography',$foundation);
+
+ $this->assertContains('10',$boot);
+ $this->assertContains('10',$foundation);
+
+ $this->assertContains('15',$boot);
+ $this->assertContains('15',$foundation);
+
+ $this->assertContains('autofocus="autofocus"',$bootAuto);
+ $this->assertContains('autofocus="autofocus"',$foundationAuto);
+ }
+
+ public function testCsrf()
+ {
+ $csrf = "<input type='hidden' value='#ffee00'>";
+ $boot = $this->boot->start('/','demo')->csrf($csrf)->textarea('bio','biography',10,15)->end();
+ $foundation = $this->foundation->start('/','demo')->csrf($csrf)->textarea('bio','biography',10,15)->end();
+
+ $this->assertContains($csrf,$boot);
+ $this->assertContains($csrf,$foundation);
+ }
+
+ public function testReset()
+ {
+ $boot = $this->boot->start('/','demo')->reset('clear',$this->class)->textarea('bio','biography',10,15)->end();
+ $foundation = $this->foundation->start('/','demo')->reset('clear',$this->class)->textarea('bio','biography',10,15)->end();
+
+ $this->assertContains('clear',$boot);
+ $this->assertContains('clear',$foundation);
+
+ $this->assertContains($this->class,$boot);
+ $this->assertContains($this->class,$foundation);
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+ }
+
+ public function testLink()
+ {
+ $boot = $this->boot->start('/','demo')->link('/register',$this->class,'create an account')->end();
+ $foundation = $this->foundation->start('/','demo')->link('/register',$this->class,'create an account')->end();
+
+ $this->assertContains('/register',$boot);
+ $this->assertContains('/register',$foundation);
+
+ $this->assertContains('create an account',$boot);
+ $this->assertContains('create an account',$foundation);
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+
+ $boot = $this->boot->start('/','demo')->link('/register',$this->class,'create an account',$this->icon)->end();
+ $foundation = $this->foundation->start('/','demo')->link('/register',$this->class,'create an account',$this->icon)->end();
+
+ $this->assertContains($this->icon,$boot);
+ $this->assertContains($this->icon,$foundation);
+ }
+
+ public function testSelect()
+ {
+ $users = array('marc','antoine','marion','alexandre');
+
+ $boot = $this->boot->start('/','demo')->select('users',$users)->end();
+ $foundation = $this->foundation->start('/','demo')->select('users',$users)->end();
+
+ $this->assertContains('marc',$boot);
+ $this->assertContains('antoine',$boot);
+ $this->assertContains('alexandre',$boot);
+ $this->assertContains('marc',$foundation);
+ $this->assertContains('antoine',$foundation);
+ $this->assertContains('alexandre',$foundation);
+
+ $boot = $this->boot->start('/','demo')->select('users',$users,$this->icon)->end();
+ $foundation = $this->foundation->start('/','demo')->select('users',$users,$this->icon)->end();
+
+ $this->assertContains($this->icon,$boot);
+ $this->assertContains($this->icon,$foundation);
+ }
+ public function testTwoInput()
+ {
+ $boot = $this->boot->start('/','demo')->twoInlineInput(Form::TEXT,'name','username','','',true,Form::EMAIL,'email','Email','','',true)->end();
+ $foundation = $this->foundation->start('/','demo')->twoInlineInput(Form::TEXT,'name','username','','',true,Form::EMAIL,'email','Email','','',true)->end();
+
+ $this->assertContains(Form::TEXT,$boot);
+ $this->assertContains(Form::EMAIL,$boot);
+ $this->assertContains(Form::TEXT,$foundation);
+ $this->assertContains(Form::EMAIL,$foundation);
+
+ $this->assertContains('username',$boot);
+ $this->assertContains('username',$boot);
+ $this->assertContains('username',$foundation);
+ $this->assertContains('username',$foundation);
+
+ $this->assertContains('Email',$boot);
+ $this->assertContains('Email',$boot);
+ $this->assertContains('Email',$foundation);
+ $this->assertContains('Email',$foundation);
+ }
+ public function testEnctype()
+ {
+ $this->assertContains('enctype',form(Form::BOOTSTRAP)->start('/','','',true)->end());
+ $this->assertContains('enctype',form(Form::FOUNDATION)->start('/','','',true)->end());
+ }
+
+ public function testTwoInlineInput()
+ {
+ $boot = $this->boot->start('/','demo')->twoInlineInput(Form::TEXT,'name','username','','',true,Form::EMAIL,'email','Email','','',true)->end();
+ $foundation = $this->foundation->start('/','demo')->twoInlineInput(Form::TEXT,'name','username','','',true,Form::EMAIL,'email','Email','','',true)->end();
+
+ $this->assertContains('username',$boot);
+ $this->assertContains('username',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('email',$boot);
+ $this->assertContains('email',$foundation);
+
+ $this->assertContains('Email',$boot);
+ $this->assertContains('Email',$foundation);
+
+ $this->assertContains('required',$boot);
+ $this->assertContains('required',$foundation);
+ }
+
+ public function testTwoSelect()
+ {
+ $users = array('marc','alex','jupiter');
+ $capital = array('1111','98956','2325');
+
+ $boot = $this->boot->start('/','demo')->twoInlineSelect('users',$users,$this->icon,'capitals',$capital,$this->icon)->end();
+ $foundation = $this->foundation->start('/','demo')->twoInlineSelect('users',$users,$this->icon,'capitals',$capital,$this->icon)->end();
+
+ foreach ($users as $k => $user)
+ {
+ $this->assertContains($this->icon,$boot);
+ $this->assertContains($this->icon,$foundation);
+ $this->assertContains($user,$boot);
+ $this->assertContains($capital[$k],$boot);
+ $this->assertContains($user,$foundation);
+ $this->assertContains($capital[$k],$foundation);
+ }
+
+
+ }
+ public function OneInputAndSelect()
+ {
+ $bases = array('marc','alex','jupiter');
+
+ $boot = $this->boot->start('/','demo')->oneInputOneSelect('text','user','username',true,$this->icon,'','bases',$bases,$this->icon)->end();
+ $foundation = $this->foundation->start('/','demo')->oneInputOneSelect('text','user','username',true,$this->icon,'','bases',$bases,$this->icon)->end();
+
+
+ foreach ($bases as $base)
+ {
+ $this->assertContains($this->icon,$boot);
+ $this->assertContains($this->icon,$foundation);
+
+ $this->assertContains('user',$boot);
+ $this->assertContains('user',$foundation);
+
+ $this->assertContains('username',$boot);
+ $this->assertContains('username',$foundation);
+
+ $this->assertContains('text',$boot);
+ $this->assertContains('text',$foundation);
+
+ $this->assertContains('bases',$boot);
+ $this->assertContains('bases',$foundation);
+
+ $this->assertContains($base,$boot);
+ $this->assertContains($base,$foundation);
+
+ }
+
+
+ }
+
+ public function testThreeInput()
+ {
+ $boot = $this->boot->start('/','demo')->threeInlineInput(Form::TEXT,'name','username','','',true,Form::EMAIL,'email','Email','','',true,Form::COLOR,'color','','#FF0000','',true)->end();
+ $foundation = $this->foundation->start('/','demo')->threeInlineInput(Form::TEXT,'name','username','','',true,Form::EMAIL,'email','Email','','',true,Form::COLOR,'color','','#FF0000','',true)->end();
+
+
+ $this->assertContains(Form::TEXT,$boot);
+ $this->assertContains(Form::EMAIL,$boot);
+ $this->assertContains(Form::COLOR,$boot);
+ $this->assertContains(Form::COLOR,$foundation);
+ $this->assertContains(Form::TEXT,$foundation);
+ $this->assertContains(Form::EMAIL,$foundation);
+
+ $this->assertContains('username',$boot);
+ $this->assertContains('username',$boot);
+ $this->assertContains('username',$foundation);
+ $this->assertContains('username',$foundation);
+
+ $this->assertContains('email',$boot);
+ $this->assertContains('email',$boot);
+ $this->assertContains('email',$foundation);
+ $this->assertContains('email',$foundation);
+
+ $this->assertContains('Email',$boot);
+ $this->assertContains('Email',$boot);
+ $this->assertContains('Email',$foundation);
+ $this->assertContains('Email',$foundation);
+
+ $this->assertContains('color',$boot);
+ $this->assertContains('color',$boot);
+ $this->assertContains('color',$foundation);
+ $this->assertContains('color',$foundation);
+
+ $this->assertContains('#FF0000',$boot);
+ $this->assertContains('#FF0000',$foundation);
+
+ }
+
+ public function testFourInput()
+ {
+ $boot = $this->boot->start('/','demo')->fourInlineInput('text','four1','four','','',true,'text','four2','four','supersonic','',true,'text','four3','four','','',true,'text','four4','for','','',true)->end();
+ $foundation = $this->foundation->start('/','demo')->fourInlineInput('text','four1','four','','',true,'text','four2','four','supersonic','',true,'text','four3','four','','',true,'text','four4','for','','',true)->end();
+
+
+ $this->assertContains('four',$boot);
+ $this->assertContains('four',$foundation);
+
+ $this->assertContains('supersonic',$boot);
+ $this->assertContains('supersonic',$foundation);
+
+ $this->assertContains('required',$boot);
+ $this->assertContains('required',$foundation);
+
+ }
+
+ public function testGenerate()
+ {
+
+ // DEFAULT
+
+ $boot = $this->boot->start('/','demo')->setLargeInput(true)->input('text','code','name')->end();
+
+ $this->assertContains('form-control form-control-lg',$boot);
+
+ $boot = $this->boot->start('/','demo')->setSmallInput(true)->input('text','code','name')->end();
+
+ $this->assertContains('form-control form-control-sm',$boot);
+
+ $boot = $this->boot->start('/','demo')->setSmallInput(true)->input('file','code','name')->end();
+
+ $this->assertContains('form-control-file',$boot);
+
+ // DEFAULT
+
+ $boot = $this->boot->start('/','demo')->input('text','code','name')->end();
+ $foundation = $this->foundation->start('/','demo')->input('text','code','name')->end();
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+
+ $this->assertNotContains('autofocus',$boot);
+ $this->assertNotContains('autofocus',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('code',$boot);
+ $this->assertContains('code',$foundation);
+
+ $this->assertContains('autocomplete="off"',$boot);
+ $this->assertContains('autocomplete="off"',$foundation);
+
+ $this->assertContains('required',$boot);
+ $this->assertContains('required',$foundation);
+
+
+ // AUTOCOMPLETE ENABLED
+
+ $boot = $this->boot->start('/','demo')->input('text','code','name','','',false,false,true)->end();
+ $foundation = $this->foundation->start('/','demo')->input('text','code','name','','',false,false,true)->end();
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+
+ $this->assertNotContains('autofocus',$boot);
+ $this->assertNotContains('autofocus',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('code',$boot);
+ $this->assertContains('code',$foundation);
+
+ $this->assertContains('autocomplete="on"',$boot);
+ $this->assertContains('autocomplete="on"',$foundation);
+
+ $this->assertNotContains('required',$boot);
+ $this->assertNotContains('required',$foundation);
+
+ // AUTOFOCUS ENABLED
+
+ $boot = $this->boot->start('/','demo')->input('text','code','name','','',false,true,false)->end();
+ $foundation = $this->foundation->start('/','demo')->input('text','code','name','','',false,true,false)->end();
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+
+ $this->assertContains('autofocus',$boot);
+ $this->assertContains('autofocus',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('code',$boot);
+ $this->assertContains('code',$foundation);
+
+ $this->assertContains('autocomplete="off"',$boot);
+ $this->assertContains('autocomplete="off"',$foundation);
+
+ $this->assertNotContains('required',$boot);
+ $this->assertNotContains('required',$foundation);
+
+ // AUTOFOCUS AND AUTOCOMPLETE ENABLED
+
+ $boot = $this->boot->start('/','demo')->input('text','code','name','','',false,true,true)->end();
+ $foundation = $this->foundation->start('/','demo')->input('text','code','name','','',false,true,true)->end();
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+
+ $this->assertContains('autofocus',$boot);
+ $this->assertContains('autofocus',$foundation);
+
+ $this->assertContains('autocomplete="on"',$boot);
+ $this->assertContains('autocomplete="on"',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('code',$boot);
+ $this->assertContains('code',$foundation);
+
+ $this->assertNotContains('required',$boot);
+ $this->assertNotContains('required',$foundation);
+
+
+ // REQUIRE ENABLED
+
+ $boot = $this->boot->start('/','demo')->input('text','code','name','','',true,false,false)->end();
+ $foundation = $this->foundation->start('/','demo')->input('text','code','name','','',true,false,false)->end();
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+
+ $this->assertNotContains('autofocus',$boot);
+ $this->assertNotContains('autofocus',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('code',$boot);
+ $this->assertContains('code',$foundation);
+
+ $this->assertContains('autocomplete="off"',$boot);
+ $this->assertContains('autocomplete="off"',$foundation);
+
+ $this->assertContains('required',$boot);
+ $this->assertContains('required',$foundation);
+
+
+ // REQUIRE AND AUTOCOMPLETE ENABLED
+
+ $boot = $this->boot->start('/','demo')->input('text','code','name','','',true,false,true)->end();
+ $foundation = $this->foundation->start('/','demo')->input('text','code','name','','',true,false,true)->end();
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+
+ $this->assertNotContains('autofocus',$boot);
+ $this->assertNotContains('autofocus',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('code',$boot);
+ $this->assertContains('code',$foundation);
+
+ $this->assertContains('autocomplete="on"',$boot);
+ $this->assertContains('autocomplete="on"',$foundation);
+
+ $this->assertContains('required',$boot);
+ $this->assertContains('required',$foundation);
+
+
+
+ // REQUIRE AND AUTOCOMPLETE ENABLED
+
+ $boot = $this->boot->start('/','demo')->input('text','code','name','','',true,false,true)->end();
+ $foundation = $this->foundation->start('/','demo')->input('text','code','name','','',true,false,true)->end();
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+
+ $this->assertNotContains('autofocus',$boot);
+ $this->assertNotContains('autofocus',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('code',$boot);
+ $this->assertContains('code',$foundation);
+
+ $this->assertContains('autocomplete="on"',$boot);
+ $this->assertContains('autocomplete="on"',$foundation);
+
+ $this->assertContains('required',$boot);
+ $this->assertContains('required',$foundation);
+
+
+ // REQUIRE AUTOFOCUS AND AUTOCOMPLETE ENABLED
+
+ $boot = $this->boot->start('/','demo')->input('text','code','name','','',true,true,true)->end();
+ $foundation = $this->foundation->start('/','demo')->input('text','code','name','','',true,true,true)->end();
+
+ $this->assertNotContains($this->icon,$boot);
+ $this->assertNotContains($this->icon,$foundation);
+
+ $this->assertContains('autofocus',$boot);
+ $this->assertContains('autofocus',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('code',$boot);
+ $this->assertContains('code',$foundation);
+
+ $this->assertContains('autocomplete="on"',$boot);
+ $this->assertContains('autocomplete="on"',$foundation);
+
+ $this->assertContains('required',$boot);
+ $this->assertContains('required',$foundation);
+
+
+ // ICON ENABLED
+
+ $boot = $this->boot->start('/','demo')->input('text','code','name',$this->icon,'',false,false,false)->end();
+ $foundation = $this->foundation->start('/','demo')->input('text','code','name',$this->icon,'',false,false,false)->end();
+
+ $this->assertContains($this->icon,$boot);
+ $this->assertContains($this->icon,$foundation);
+
+ $this->assertNotContains('autofocus',$boot);
+ $this->assertNotContains('autofocus',$foundation);
+
+ $this->assertContains('name',$boot);
+ $this->assertContains('name',$foundation);
+
+ $this->assertContains('code',$boot);
+ $this->assertContains('code',$foundation);
+
+ $this->assertContains('autocomplete="off"',$boot);
+ $this->assertContains('autocomplete="off"',$foundation);
+
+ $this->assertNotContains('required',$boot);
+ $this->assertNotContains('required',$foundation);