Week 7: Moved week 6 CMS into week 7
This commit is contained in:
parent
dcd75b5004
commit
b42071a44f
46
week-06/homework/README.md
Normal file
46
week-06/homework/README.md
Normal file
@ -0,0 +1,46 @@
|
||||
# WEBD-325-45 – PHP Programming, Adv.
|
||||
> Llewellyn van der Merwe<br />
|
||||
Week 6: Homework – Understanding Frameworks<br />
|
||||
May 1st, 2022
|
||||
|
||||
### Little background
|
||||
|
||||
So many years ago I did a course by Bernard Pineda on Symphony 3 and I build a little basic application for (Landon Hotel), so this time I chose to use Zend, now called Laminas and the experience was better. This could be because I am now much more knowledgeable then I was back in the day when I looked at Symphony, and since my daily work environment is Ubuntu Linux, the installation and startup of a projects was easy. I made use for their online documentation tutorial to setup an MVC wire-frame.
|
||||
|
||||
### How does the framework work?
|
||||
|
||||
So with the help of composer commands we got a basic list of questions that help speedup some of the development flow. Once we finished making our selection composer installs our skeleton set of files with the basic defaults ready to start development.
|
||||
|
||||
To view these we can either link our project to an Apache server, or simple run a PHP command to serve our application over a port of our choosing.
|
||||
|
||||
At this point we can say the application is working, as to how it works… this can get very technical.
|
||||
|
||||
Again looking at the documentation they start by explaining that laminas-mvc uses a module system.
|
||||
|
||||
https://docs.laminas.dev/tutorials/getting-started/modules/
|
||||
|
||||
This is easy to understand and a great entry point into the whole MVC architecture of Laminas. Once your able to understand how these things come together in the router and controller the door is open and you can start extending your business logic.
|
||||
|
||||
https://docs.laminas.dev/tutorials/getting-started/database-and-models/
|
||||
|
||||
Needless to say I found all these examples super easy, and very powerful and extremely quick to achieve otherwise very complex and difficult tasks.
|
||||
|
||||
My overall feel is that Laminas works very well and will be a great choice for any application need.
|
||||
|
||||
### Does using a framework make sense all the time? Why? Why not?
|
||||
|
||||
This issue also came up in one of our conversation in the discussion last week, and I will quote my reply to one of the students.
|
||||
|
||||
> Yes the MVC adds unnecessary complexity to small projects. But how will you determine that a project is no longer small? And if a small project grows... when will we need to change the project's architecture?<br /><br />
|
||||
You see my problem is that I have written way to many small projects that ended up becoming huge and then to refactor those projects is much harder then having just started it with scalability in mind from the start.<br /><br />
|
||||
So my question is when is a project no longer small? Is it the number of lines or the number of views? I mean the CMS we are building for this course is a small project in comparison to some of the projects I work on everyday.<br /><br />
|
||||
Yet, it has more than 10k lines (excluding the composer libraries) of code, and it already has about ten MVC sets of classes. Having all that code in one file will be very hard to maintain.<br /><br />
|
||||
But yes, I realize working with MVC in Joomla for so many years, it no longer feels complex to me, but in fact seems like the easy way out from complexity... :)
|
||||
|
||||
So in my world I hardly every not use MVC frameworks, yet having said that I am not saying that is the normal, or the best way, it is just how I work. Testing a small snipped of PHP and looking at the result of a small algorithmic I still have a few test.php files in my server path to do quick little bits of code. But the moment I am in projects that are for online systems I hardly ever no use some kind of framework.
|
||||
|
||||
### Reference
|
||||
|
||||
- "Laminas." Wikipedia, 1 May 2022. Wikipedia, https://en.wikipedia.org/w/index.php?title=Laminas&oldid=1078914186.
|
||||
- Tutorials - Laminas Docs. https://docs.laminas.dev/tutorials/. Accessed 1 May 2022.
|
||||
|
32
week-07/README.md
Normal file
32
week-07/README.md
Normal file
@ -0,0 +1,32 @@
|
||||
# Homework: PHP Advanced Techniques
|
||||
|
||||
Write a one to a two-page paper that reflects on the knowledge you obtained and how you have grown as a PHP web programmer in this course. Be sure to address the following questions in your submission:
|
||||
|
||||
- Which basic PHP programming skills do you better understand? Have more proficiency in?
|
||||
- Which advanced PHP programming technique learned throughout the past 7 weeks do you believe you'll use most in the future?
|
||||
- Which advanced PHP programming technique do you believe was the easiest concept to learn? The hardest?
|
||||
- Which advanced PHP programming technique do you believe you still don't fully understand? How will you help yourself learn the content after the course is over?
|
||||
|
||||
Please make sure that any sources that you use in your submission are appropriately cited and referenced in APA format.
|
||||
|
||||
> See [homework](https://git.vdm.dev/champlain/WEBD-325-45/src/branch/master/week-07/homework)...
|
||||
|
||||
# Project: Testing and Debugging
|
||||
|
||||
Now it's time to make sure that your project works and to finalize everything by testing and debugging every aspect of your project. The past few weeks, you should have verified that everything worked before you submitted the assignment for each week. Now, you'll need to develop some test data that you'll use to run the CMS through its paces. Walk through your site, test every login and logout module, check all CRUD abilities for subjects and pages, check all links (in the navigation bar and on the static pages), make sure users can be added to the site and all forms work appropriately, and last but not least make sure every page that had placeholder text is an actual page that is updated with real-world text regarding your project.
|
||||
|
||||
In this case, your professor is your client. Please include the following items in your final project submission, zip all files and submit in this assignment. once completed:
|
||||
|
||||
- Your entire project that you have done throughout the past six weeks, including all PHP, HTML, and CSS pages, images, your project proposal, and anything else you have done throughout your project in the past six weeks. Make sure before submission that it all works, nothing has broken week-to-week, and you have tested and debugged all aspects of the project as described above.
|
||||
- A dump of your test database that includes all of your tables that you created for your project using the mysqldump program or phpMyAdmin.
|
||||
- A brief report explaining to your client the features of your CMS design, how users will use the application, and the instructions on how to install it.
|
||||
|
||||
Make sure the databases, the entire project, and the brief report have been zipped up and submitted together in this assignment.
|
||||
|
||||
As a reminder, here are some sites with tutorials that show you how to use mysqldump and phpMyAdmin:
|
||||
|
||||
[How to export a database with mysqldump](http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html)
|
||||
[How to export a database using phpMyAdmin](http://fragments.turtlemeat.com/mysql-database-backup-restore-phpmyadmin.php)
|
||||
|
||||
> See [project](https://git.vdm.dev/champlain/WEBD-325-45/src/branch/master/week-07/project)...
|
||||
|
9
week-07/project/.gitignore
vendored
Normal file
9
week-07/project/.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# IDE & System Related Files
|
||||
.idea
|
||||
|
||||
# Local System File
|
||||
octoconfig.php
|
||||
php.ini
|
||||
|
||||
# Vendor directory handling
|
||||
/libraries/vendor
|
52
week-07/project/.htaccess
Normal file
52
week-07/project/.htaccess
Normal file
@ -0,0 +1,52 @@
|
||||
###########################################
|
||||
# ======= Enable the Rewrite Engine =======
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
###########################################
|
||||
|
||||
|
||||
###########################################
|
||||
# ======= No directory listings =======
|
||||
|
||||
IndexIgnore *
|
||||
Options +FollowSymLinks
|
||||
Options -Indexes
|
||||
|
||||
###########################################
|
||||
|
||||
|
||||
###########################################
|
||||
# ======== Remove multiple slashes ========
|
||||
|
||||
RewriteCond %{HTTP_HOST} !=""
|
||||
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR]
|
||||
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$
|
||||
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]
|
||||
|
||||
###########################################
|
||||
|
||||
|
||||
###########################################
|
||||
# ======== Remove trailing slashes ========
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.*)/$ /$1 [R=301,L]
|
||||
|
||||
###########################################
|
||||
|
||||
|
||||
###########################################
|
||||
# ======== SEF URL Routing ========
|
||||
|
||||
# If the request is not for a static asset
|
||||
RewriteCond %{REQUEST_URI} !^/media/
|
||||
|
||||
# Or for a file that exists in the web directory
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
# Rewrite the request to run the application
|
||||
RewriteRule (.*) index.php
|
||||
|
||||
###########################################
|
674
week-07/project/LICENSE
Normal file
674
week-07/project/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
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
|
||||
<https://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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
53
week-07/project/README.md
Normal file
53
week-07/project/README.md
Normal file
@ -0,0 +1,53 @@
|
||||
# Login to the administrator area to manage your pages (items/menus)
|
||||
|
||||
Content Management of Pages in the Octoleo CMS
|
||||
|
||||
## To install this CMS
|
||||
|
||||
1. Import the SQL tables into your database found in /sql/install.sql
|
||||
2. Copy the /octoconfig.php.example file to /octoconfig.php
|
||||
3. Update the /octoconfig.php to reflect your CMS details
|
||||
4. Copy the /htaccess.txt file to /.htaccess
|
||||
5. **Remove** the /installation folder from you root directory
|
||||
|
||||
## To install all composer libraries
|
||||
|
||||
0. Make sure you have [composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos) installed on your system.
|
||||
1. In your terminal go to the root folder of your Octoleo website where you will find the composer.json file.
|
||||
2. Run the following command composer install to install all PHP packages.
|
||||
|
||||
## To create an account
|
||||
|
||||
1. Open [hostname:]/administrator
|
||||
2. Click on link that says [Create Account] __FIRST account will get admin access, but there rest created will need admin approval__
|
||||
3. Fill in your details [done]
|
||||
|
||||
## To login to admin/staff area again
|
||||
|
||||
1. Open [hostname:]/administrator
|
||||
2. Add you username and password
|
||||
3. Click login [done]
|
||||
|
||||
## To add Items
|
||||
|
||||
> Items get linked to menus and are the text of your pages
|
||||
|
||||
1. Login to [hostname:]/administrator
|
||||
2. Click on items menu [hostname:]/administrator/index.php/items
|
||||
3. Here you can update, delete and create items
|
||||
|
||||
## To add menus
|
||||
|
||||
> Menus link to items, and mange the menus of your site
|
||||
|
||||
1. Login to [hostname:]/administrator
|
||||
2. Click on menus menu [hostname:]/administrator/index.php/menus
|
||||
3. Here you can update, delete and create menus (pages) that link to items
|
||||
|
||||
## To set site home page
|
||||
|
||||
> Home page is the first page you see when you open your public website
|
||||
|
||||
1. Inside the menu edit/create view [hostname:]/administrator/index.php/menu
|
||||
2. You can select one to be the home page
|
||||
|
BIN
week-07/project/administrator/favicon.ico
Normal file
BIN
week-07/project/administrator/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
100
week-07/project/administrator/includes/app.php
Normal file
100
week-07/project/administrator/includes/app.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// Option to override defines from root folder
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L15
|
||||
if (file_exists(dirname(__DIR__) . '/defines.php'))
|
||||
{
|
||||
include_once dirname(__DIR__) . '/defines.php';
|
||||
}
|
||||
|
||||
// Load the default defines
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L20
|
||||
if (!defined('_LDEFINES'))
|
||||
{
|
||||
define('LPATH_BASE', dirname(__DIR__));
|
||||
require_once LPATH_BASE . '/includes/defines.php';
|
||||
}
|
||||
|
||||
// Check for presence of vendor dependencies not included in the git repository
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L26
|
||||
if (!file_exists(LPATH_LIBRARIES . '/vendor/autoload.php'))
|
||||
{
|
||||
echo file_get_contents(LPATH_ROOT . '/templates/system/build_incomplete.html');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// Load configuration (or install)
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L34
|
||||
require_once LPATH_BASE . '/includes/framework.php';
|
||||
|
||||
// Wrap in a try/catch so we can display an error if need be
|
||||
try
|
||||
{
|
||||
$container = (new Joomla\DI\Container)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\ConfigurationProvider(LPATH_CONFIGURATION . '/octoconfig.php'))
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\SessionProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\UserProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\InputProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\AdminApplicationProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\AdminRouterProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\AdminMVCProvider)
|
||||
->registerServiceProvider(new Joomla\Database\Service\DatabaseProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\EventProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\HttpProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\LoggingProvider)
|
||||
->registerServiceProvider(new Joomla\Preload\Service\PreloadProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\AdminTemplatingProvider);
|
||||
|
||||
// Alias the web application to Octoleo's base application class as this is the primary application for the environment
|
||||
$container->alias(Joomla\Application\AbstractApplication::class, Joomla\Application\AbstractWebApplication::class);
|
||||
|
||||
// Alias the web logger to the PSR-3 interface as this is the primary logger for the environment
|
||||
$container->alias(Monolog\Logger::class, 'monolog.logger.application.web')
|
||||
->alias(Psr\Log\LoggerInterface::class, 'monolog.logger.application.web');
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
error_log($e);
|
||||
|
||||
header('HTTP/1.1 500 Internal Server Error', null, 500);
|
||||
echo '<html><head><title>Container Initialization Error</title></head><body><h1>Container Initialization Error</h1><p>An error occurred while creating the DI container: ' . $e->getMessage() . '</p></body></html>';
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Execute the application
|
||||
// source: https://github.com/joomla/framework.joomla.org/blob/master/www/index.php#L85
|
||||
try
|
||||
{
|
||||
$app = $container->get(Joomla\Application\AbstractApplication::class);
|
||||
// Set the application as global app
|
||||
\Octoleo\CMS\Factory::$application = $app;
|
||||
// Execute the application.
|
||||
$app->execute();
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
error_log($e);
|
||||
|
||||
if (!headers_sent())
|
||||
{
|
||||
header('HTTP/1.1 500 Internal Server Error', null, 500);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
}
|
||||
|
||||
echo '<html><head><title>Application Error</title></head><body><h1>Application Error</h1><p>An error occurred while executing the application: ' . $e->getMessage() . '</p></body></html>';
|
||||
|
||||
exit(1);
|
||||
}
|
||||
// I am just playing around... ((ewɘ))yn purring
|
24
week-07/project/administrator/includes/defines.php
Normal file
24
week-07/project/administrator/includes/defines.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// Global definitions
|
||||
$parts = explode(DIRECTORY_SEPARATOR, LPATH_BASE);
|
||||
array_pop($parts);
|
||||
|
||||
// Defines.
|
||||
define('LPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
|
||||
define('LPATH_SITE', LPATH_ROOT);
|
||||
define('LPATH_CONFIGURATION', LPATH_ROOT);
|
||||
define('LPATH_ADMINISTRATOR', LPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
|
||||
define('LPATH_LIBRARIES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
|
||||
define('LPATH_INSTALLATION', LPATH_ROOT . DIRECTORY_SEPARATOR . 'installation');
|
||||
define('LPATH_TEMPLATES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'templates/admin');
|
35
week-07/project/administrator/includes/framework.php
Normal file
35
week-07/project/administrator/includes/framework.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// System includes
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/framework.php#L14
|
||||
require_once LPATH_LIBRARIES . '/bootstrap.php';
|
||||
|
||||
// Installation check, and check on removal of the installation directory.
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/framework.php#L17
|
||||
if (!file_exists(LPATH_CONFIGURATION . '/octoconfig.php')
|
||||
|| (filesize(LPATH_CONFIGURATION . '/octoconfig.php') < 10)
|
||||
|| (file_exists(LPATH_INSTALLATION . '/index.php')))
|
||||
{
|
||||
if (file_exists(LPATH_INSTALLATION . '/index.php'))
|
||||
{
|
||||
header('Location: ../installation/index.php');
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'No configuration file found and no installation code available. Exiting...';
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
1
week-07/project/administrator/includes/index.html
Normal file
1
week-07/project/administrator/includes/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
35
week-07/project/administrator/index.php
Normal file
35
week-07/project/administrator/index.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 3rd April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// NOTE: This file should remain compatible with PHP 5.2 to allow us to run our PHP minimum check and show a friendly error message
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/index.php#L9
|
||||
|
||||
// Define the application's minimum supported PHP version as a constant, so it can be referenced within the application.
|
||||
define('OCTOLEO_MINIMUM_PHP', '7.2.5');
|
||||
|
||||
if (version_compare(PHP_VERSION, OCTOLEO_MINIMUM_PHP, '<'))
|
||||
{
|
||||
die(
|
||||
str_replace(
|
||||
'{{phpversion}}',
|
||||
OCTOLEO_MINIMUM_PHP,
|
||||
file_get_contents(dirname(__FILE__) . '/../templates/system/incompatible.html')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant that is checked in included files to prevent direct access.
|
||||
*/
|
||||
define('_LEXEC', 1);
|
||||
|
||||
// We must setup some house rules, since we can't have all
|
||||
// this code just doing what it wants can we.... <<eWɘ>>yn growling
|
||||
require_once dirname(__FILE__) . '/includes/app.php';
|
1
week-07/project/administrator/media/css/index.html
Normal file
1
week-07/project/administrator/media/css/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
12595
week-07/project/administrator/media/css/uikit-rtl.css
Normal file
12595
week-07/project/administrator/media/css/uikit-rtl.css
Normal file
File diff suppressed because it is too large
Load Diff
1
week-07/project/administrator/media/css/uikit-rtl.min.css
vendored
Normal file
1
week-07/project/administrator/media/css/uikit-rtl.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
12595
week-07/project/administrator/media/css/uikit.css
Normal file
12595
week-07/project/administrator/media/css/uikit.css
Normal file
File diff suppressed because it is too large
Load Diff
1
week-07/project/administrator/media/css/uikit.min.css
vendored
Normal file
1
week-07/project/administrator/media/css/uikit.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
week-07/project/administrator/media/index.html
Normal file
1
week-07/project/administrator/media/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
week-07/project/administrator/media/js/index.html
Normal file
1
week-07/project/administrator/media/js/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
0
week-07/project/administrator/media/js/template.js
Normal file
0
week-07/project/administrator/media/js/template.js
Normal file
169
week-07/project/administrator/media/js/uikit-icons.js
Normal file
169
week-07/project/administrator/media/js/uikit-icons.js
Normal file
@ -0,0 +1,169 @@
|
||||
/*! UIkit 3.6.22 | https://www.getuikit.com | (c) 2014 - 2021 YOOtheme | MIT License */
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define('uikiticons', factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.UIkitIcons = factory());
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
function plugin(UIkit) {
|
||||
|
||||
if (plugin.installed) {
|
||||
return;
|
||||
}
|
||||
|
||||
UIkit.icon.add({
|
||||
"500px": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M9.624,11.866c-0.141,0.132,0.479,0.658,0.662,0.418c0.051-0.046,0.607-0.61,0.662-0.664c0,0,0.738,0.719,0.814,0.719 c0.1,0,0.207-0.055,0.322-0.17c0.27-0.269,0.135-0.416,0.066-0.495l-0.631-0.616l0.658-0.668c0.146-0.156,0.021-0.314-0.1-0.449 c-0.182-0.18-0.359-0.226-0.471-0.125l-0.656,0.654l-0.654-0.654c-0.033-0.034-0.08-0.045-0.124-0.045 c-0.079,0-0.191,0.068-0.307,0.181c-0.202,0.202-0.247,0.351-0.133,0.462l0.665,0.665L9.624,11.866z\"/><path d=\"M11.066,2.884c-1.061,0-2.185,0.248-3.011,0.604c-0.087,0.034-0.141,0.106-0.15,0.205C7.893,3.784,7.919,3.909,7.982,4.066 c0.05,0.136,0.187,0.474,0.452,0.372c0.844-0.326,1.779-0.507,2.633-0.507c0.963,0,1.9,0.191,2.781,0.564 c0.695,0.292,1.357,0.719,2.078,1.34c0.051,0.044,0.105,0.068,0.164,0.068c0.143,0,0.273-0.137,0.389-0.271 c0.191-0.214,0.324-0.395,0.135-0.575c-0.686-0.654-1.436-1.138-2.363-1.533C13.24,3.097,12.168,2.884,11.066,2.884z\"/><path d=\"M16.43,15.747c-0.092-0.028-0.242,0.05-0.309,0.119l0,0c-0.652,0.652-1.42,1.169-2.268,1.521 c-0.877,0.371-1.814,0.551-2.779,0.551c-0.961,0-1.896-0.189-2.775-0.564c-0.848-0.36-1.612-0.879-2.268-1.53 c-0.682-0.688-1.196-1.455-1.529-2.268c-0.325-0.799-0.471-1.643-0.471-1.643c-0.045-0.24-0.258-0.249-0.567-0.203 c-0.128,0.021-0.519,0.079-0.483,0.36v0.01c0.105,0.644,0.289,1.284,0.545,1.895c0.417,0.969,1.002,1.849,1.756,2.604 c0.757,0.754,1.636,1.34,2.604,1.757C8.901,18.785,9.97,19,11.088,19c1.104,0,2.186-0.215,3.188-0.645 c1.838-0.896,2.604-1.757,2.604-1.757c0.182-0.204,0.227-0.317-0.1-0.643C16.779,15.956,16.525,15.774,16.43,15.747z\"/><path d=\"M5.633,13.287c0.293,0.71,0.723,1.341,1.262,1.882c0.54,0.54,1.172,0.971,1.882,1.264c0.731,0.303,1.509,0.461,2.298,0.461 c0.801,0,1.578-0.158,2.297-0.461c0.711-0.293,1.344-0.724,1.883-1.264c0.543-0.541,0.971-1.172,1.264-1.882 c0.314-0.721,0.463-1.5,0.463-2.298c0-0.79-0.148-1.569-0.463-2.289c-0.293-0.699-0.721-1.329-1.264-1.881 c-0.539-0.541-1.172-0.959-1.867-1.263c-0.721-0.303-1.5-0.461-2.299-0.461c-0.802,0-1.613,0.159-2.322,0.461 c-0.577,0.25-1.544,0.867-2.119,1.454v0.012V2.108h8.16C15.1,2.104,15.1,1.69,15.1,1.552C15.1,1.417,15.1,1,14.809,1H5.915 C5.676,1,5.527,1.192,5.527,1.384v6.84c0,0.214,0.273,0.372,0.529,0.428c0.5,0.105,0.614-0.056,0.737-0.224l0,0 c0.18-0.273,0.776-0.884,0.787-0.894c0.901-0.905,2.117-1.408,3.416-1.408c1.285,0,2.5,0.501,3.412,1.408 c0.914,0.914,1.408,2.122,1.408,3.405c0,1.288-0.508,2.496-1.408,3.405c-0.9,0.896-2.152,1.406-3.438,1.406 c-0.877,0-1.711-0.229-2.433-0.671v-4.158c0-0.553,0.237-1.151,0.643-1.614c0.462-0.519,1.094-0.799,1.782-0.799 c0.664,0,1.293,0.253,1.758,0.715c0.459,0.459,0.709,1.071,0.709,1.723c0,1.385-1.094,2.468-2.488,2.468 c-0.273,0-0.769-0.121-0.781-0.125c-0.281-0.087-0.405,0.306-0.438,0.436c-0.159,0.496,0.079,0.585,0.123,0.607 c0.452,0.137,0.743,0.157,1.129,0.157c1.973,0,3.572-1.6,3.572-3.57c0-1.964-1.6-3.552-3.572-3.552c-0.97,0-1.872,0.36-2.546,1.038 c-0.656,0.631-1.027,1.487-1.027,2.322v3.438v-0.011c-0.372-0.42-0.732-1.041-0.981-1.682c-0.102-0.248-0.315-0.202-0.607-0.113 c-0.135,0.035-0.519,0.157-0.44,0.439C5.372,12.799,5.577,13.164,5.633,13.287z\"/></svg>",
|
||||
"album": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"5\" y=\"2\" width=\"10\" height=\"1\"/><rect x=\"3\" y=\"4\" width=\"14\" height=\"1\"/><rect fill=\"none\" stroke=\"#000\" x=\"1.5\" y=\"6.5\" width=\"17\" height=\"11\"/></svg>",
|
||||
"arrow-down": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"10.5,16.08 5.63,10.66 6.37,10 10.5,14.58 14.63,10 15.37,10.66\"/><line fill=\"none\" stroke=\"#000\" x1=\"10.5\" y1=\"4\" x2=\"10.5\" y2=\"15\"/></svg>",
|
||||
"arrow-left": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" points=\"10 14 5 9.5 10 5\"/><line fill=\"none\" stroke=\"#000\" x1=\"16\" y1=\"9.5\" x2=\"5\" y2=\"9.52\"/></svg>",
|
||||
"arrow-right": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" points=\"10 5 15 9.5 10 14\"/><line fill=\"none\" stroke=\"#000\" x1=\"4\" y1=\"9.5\" x2=\"15\" y2=\"9.5\"/></svg>",
|
||||
"arrow-up": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"10.5,4 15.37,9.4 14.63,10.08 10.5,5.49 6.37,10.08 5.63,9.4\"/><line fill=\"none\" stroke=\"#000\" x1=\"10.5\" y1=\"16\" x2=\"10.5\" y2=\"5\"/></svg>",
|
||||
"ban": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"10\" cy=\"10\" r=\"9\"/><line fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" x1=\"4\" y1=\"3.5\" x2=\"16\" y2=\"16.5\"/></svg>",
|
||||
"behance": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M9.5,10.6c-0.4-0.5-0.9-0.9-1.6-1.1c1.7-1,2.2-3.2,0.7-4.7C7.8,4,6.3,4,5.2,4C3.5,4,1.7,4,0,4v12c1.7,0,3.4,0,5.2,0 c1,0,2.1,0,3.1-0.5C10.2,14.6,10.5,12.3,9.5,10.6L9.5,10.6z M5.6,6.1c1.8,0,1.8,2.7-0.1,2.7c-1,0-2,0-2.9,0V6.1H5.6z M2.6,13.8v-3.1 c1.1,0,2.1,0,3.2,0c2.1,0,2.1,3.2,0.1,3.2L2.6,13.8z\"/><path d=\"M19.9,10.9C19.7,9.2,18.7,7.6,17,7c-4.2-1.3-7.3,3.4-5.3,7.1c0.9,1.7,2.8,2.3,4.7,2.1c1.7-0.2,2.9-1.3,3.4-2.9h-2.2 c-0.4,1.3-2.4,1.5-3.5,0.6c-0.4-0.4-0.6-1.1-0.6-1.7H20C20,11.7,19.9,10.9,19.9,10.9z M13.5,10.6c0-1.6,2.3-2.7,3.5-1.4 c0.4,0.4,0.5,0.9,0.6,1.4H13.5L13.5,10.6z\"/><rect x=\"13\" y=\"4\" width=\"5\" height=\"1.4\"/></svg>",
|
||||
"bell": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M17,15.5 L3,15.5 C2.99,14.61 3.79,13.34 4.1,12.51 C4.58,11.3 4.72,10.35 5.19,7.01 C5.54,4.53 5.89,3.2 7.28,2.16 C8.13,1.56 9.37,1.5 9.81,1.5 L9.96,1.5 C9.96,1.5 11.62,1.41 12.67,2.17 C14.08,3.2 14.42,4.54 14.77,7.02 C15.26,10.35 15.4,11.31 15.87,12.52 C16.2,13.34 17.01,14.61 17,15.5 L17,15.5 Z\"/><path fill=\"none\" stroke=\"#000\" d=\"M12.39,16 C12.39,17.37 11.35,18.43 9.91,18.43 C8.48,18.43 7.42,17.37 7.42,16\"/></svg>",
|
||||
"bold": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M5,15.3 C5.66,15.3 5.9,15 5.9,14.53 L5.9,5.5 C5.9,4.92 5.56,4.7 5,4.7 L5,4 L8.95,4 C12.6,4 13.7,5.37 13.7,6.9 C13.7,7.87 13.14,9.17 10.86,9.59 L10.86,9.7 C13.25,9.86 14.29,11.28 14.3,12.54 C14.3,14.47 12.94,16 9,16 L5,16 L5,15.3 Z M9,9.3 C11.19,9.3 11.8,8.5 11.85,7 C11.85,5.65 11.3,4.8 9,4.8 L7.67,4.8 L7.67,9.3 L9,9.3 Z M9.185,15.22 C11.97,15 12.39,14 12.4,12.58 C12.4,11.15 11.39,10 9,10 L7.67,10 L7.67,15 L9.18,15 Z\"/></svg>",
|
||||
"bolt": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M4.74,20 L7.73,12 L3,12 L15.43,1 L12.32,9 L17.02,9 L4.74,20 L4.74,20 L4.74,20 Z M9.18,11 L7.1,16.39 L14.47,10 L10.86,10 L12.99,4.67 L5.61,11 L9.18,11 L9.18,11 L9.18,11 Z\"/></svg>",
|
||||
"bookmark": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon fill=\"none\" stroke=\"#000\" points=\"5.5 1.5 15.5 1.5 15.5 17.5 10.5 12.5 5.5 17.5\"/></svg>",
|
||||
"calendar": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M 2,3 2,17 18,17 18,3 2,3 Z M 17,16 3,16 3,8 17,8 17,16 Z M 17,7 3,7 3,4 17,4 17,7 Z\"/><rect width=\"1\" height=\"3\" x=\"6\" y=\"2\"/><rect width=\"1\" height=\"3\" x=\"13\" y=\"2\"/></svg>",
|
||||
"camera": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"10\" cy=\"10.8\" r=\"3.8\"/><path fill=\"none\" stroke=\"#000\" d=\"M1,4.5 C0.7,4.5 0.5,4.7 0.5,5 L0.5,17 C0.5,17.3 0.7,17.5 1,17.5 L19,17.5 C19.3,17.5 19.5,17.3 19.5,17 L19.5,5 C19.5,4.7 19.3,4.5 19,4.5 L13.5,4.5 L13.5,2.9 C13.5,2.6 13.3,2.5 13,2.5 L7,2.5 C6.7,2.5 6.5,2.6 6.5,2.9 L6.5,4.5 L1,4.5 L1,4.5 Z\"/></svg>",
|
||||
"cart": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"7.3\" cy=\"17.3\" r=\"1.4\"/><circle cx=\"13.3\" cy=\"17.3\" r=\"1.4\"/><polyline fill=\"none\" stroke=\"#000\" points=\"0 2 3.2 4 5.3 12.5 16 12.5 18 6.5 8 6.5\"/></svg>",
|
||||
"check": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" points=\"4,10 8,15 17,4\"/></svg>",
|
||||
"chevron-double-left": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.03\" points=\"10 14 6 10 10 6\"/><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.03\" points=\"14 14 10 10 14 6\"/></svg>",
|
||||
"chevron-double-right": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.03\" points=\"10 6 14 10 10 14\"/><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.03\" points=\"6 6 10 10 6 14\"/></svg>",
|
||||
"chevron-down": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.03\" points=\"16 7 10 13 4 7\"/></svg>",
|
||||
"chevron-left": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.03\" points=\"13 16 7 10 13 4\"/></svg>",
|
||||
"chevron-right": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.03\" points=\"7 4 13 10 7 16\"/></svg>",
|
||||
"chevron-up": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.03\" points=\"4 13 10 7 16 13\"/></svg>",
|
||||
"clock": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"10\" cy=\"10\" r=\"9\"/><rect x=\"9\" y=\"4\" width=\"1\" height=\"7\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M13.018,14.197 L9.445,10.625\"/></svg>",
|
||||
"close": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.06\" d=\"M16,16 L4,4\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.06\" d=\"M16,4 L4,16\"/></svg>",
|
||||
"cloud-download": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M6.5,14.61 L3.75,14.61 C1.96,14.61 0.5,13.17 0.5,11.39 C0.5,9.76 1.72,8.41 3.3,8.2 C3.38,5.31 5.75,3 8.68,3 C11.19,3 13.31,4.71 13.89,7.02 C14.39,6.8 14.93,6.68 15.5,6.68 C17.71,6.68 19.5,8.45 19.5,10.64 C19.5,12.83 17.71,14.6 15.5,14.6 L12.5,14.6\"/><polyline fill=\"none\" stroke=\"#000\" points=\"11.75 16 9.5 18.25 7.25 16\"/><path fill=\"none\" stroke=\"#000\" d=\"M9.5,18 L9.5,9.5\"/></svg>",
|
||||
"cloud-upload": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M6.5,14.61 L3.75,14.61 C1.96,14.61 0.5,13.17 0.5,11.39 C0.5,9.76 1.72,8.41 3.31,8.2 C3.38,5.31 5.75,3 8.68,3 C11.19,3 13.31,4.71 13.89,7.02 C14.39,6.8 14.93,6.68 15.5,6.68 C17.71,6.68 19.5,8.45 19.5,10.64 C19.5,12.83 17.71,14.6 15.5,14.6 L12.5,14.6\"/><polyline fill=\"none\" stroke=\"#000\" points=\"7.25 11.75 9.5 9.5 11.75 11.75\"/><path fill=\"none\" stroke=\"#000\" d=\"M9.5,18 L9.5,9.5\"/></svg>",
|
||||
"code": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.01\" points=\"13,4 19,10 13,16\"/><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.01\" points=\"7,4 1,10 7,16\"/></svg>",
|
||||
"cog": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" cx=\"9.997\" cy=\"10\" r=\"3.31\"/><path fill=\"none\" stroke=\"#000\" d=\"M18.488,12.285 L16.205,16.237 C15.322,15.496 14.185,15.281 13.303,15.791 C12.428,16.289 12.047,17.373 12.246,18.5 L7.735,18.5 C7.938,17.374 7.553,16.299 6.684,15.791 C5.801,15.27 4.655,15.492 3.773,16.237 L1.5,12.285 C2.573,11.871 3.317,10.999 3.317,9.991 C3.305,8.98 2.573,8.121 1.5,7.716 L3.765,3.784 C4.645,4.516 5.794,4.738 6.687,4.232 C7.555,3.722 7.939,2.637 7.735,1.5 L12.263,1.5 C12.072,2.637 12.441,3.71 13.314,4.22 C14.206,4.73 15.343,4.516 16.225,3.794 L18.487,7.714 C17.404,8.117 16.661,8.988 16.67,10.009 C16.672,11.018 17.415,11.88 18.488,12.285 L18.488,12.285 Z\"/></svg>",
|
||||
"comment": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6,18.71 L6,14 L1,14 L1,1 L19,1 L19,14 L10.71,14 L6,18.71 L6,18.71 Z M2,13 L7,13 L7,16.29 L10.29,13 L18,13 L18,2 L2,2 L2,13 L2,13 Z\"/></svg>",
|
||||
"commenting": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon fill=\"none\" stroke=\"#000\" points=\"1.5,1.5 18.5,1.5 18.5,13.5 10.5,13.5 6.5,17.5 6.5,13.5 1.5,13.5\"/><circle cx=\"10\" cy=\"8\" r=\"1\"/><circle cx=\"6\" cy=\"8\" r=\"1\"/><circle cx=\"14\" cy=\"8\" r=\"1\"/></svg>",
|
||||
"comments": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" points=\"2 0.5 19.5 0.5 19.5 13\"/><path d=\"M5,19.71 L5,15 L0,15 L0,2 L18,2 L18,15 L9.71,15 L5,19.71 L5,19.71 L5,19.71 Z M1,14 L6,14 L6,17.29 L9.29,14 L17,14 L17,3 L1,3 L1,14 L1,14 L1,14 Z\"/></svg>",
|
||||
"copy": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect fill=\"none\" stroke=\"#000\" x=\"3.5\" y=\"2.5\" width=\"12\" height=\"16\"/><polyline fill=\"none\" stroke=\"#000\" points=\"5 0.5 17.5 0.5 17.5 17\"/></svg>",
|
||||
"credit-card": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect fill=\"none\" stroke=\"#000\" x=\"1.5\" y=\"4.5\" width=\"17\" height=\"12\"/><rect x=\"1\" y=\"7\" width=\"18\" height=\"3\"/></svg>",
|
||||
"database": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><ellipse fill=\"none\" stroke=\"#000\" cx=\"10\" cy=\"4.64\" rx=\"7.5\" ry=\"3.14\"/><path fill=\"none\" stroke=\"#000\" d=\"M17.5,8.11 C17.5,9.85 14.14,11.25 10,11.25 C5.86,11.25 2.5,9.84 2.5,8.11\"/><path fill=\"none\" stroke=\"#000\" d=\"M17.5,11.25 C17.5,12.99 14.14,14.39 10,14.39 C5.86,14.39 2.5,12.98 2.5,11.25\"/><path fill=\"none\" stroke=\"#000\" d=\"M17.49,4.64 L17.5,14.36 C17.5,16.1 14.14,17.5 10,17.5 C5.86,17.5 2.5,16.09 2.5,14.36 L2.5,4.64\"/></svg>",
|
||||
"desktop": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"8\" y=\"15\" width=\"1\" height=\"2\"/><rect x=\"11\" y=\"15\" width=\"1\" height=\"2\"/><rect x=\"5\" y=\"16\" width=\"10\" height=\"1\"/><rect fill=\"none\" stroke=\"#000\" x=\"1.5\" y=\"3.5\" width=\"17\" height=\"11\"/></svg>",
|
||||
"discord": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\"><path d=\"M16.074,4.361a14.243,14.243,0,0,0-3.61-1.134,10.61,10.61,0,0,0-.463.96,13.219,13.219,0,0,0-4,0,10.138,10.138,0,0,0-.468-.96A14.206,14.206,0,0,0,3.919,4.364,15.146,15.146,0,0,0,1.324,14.5a14.435,14.435,0,0,0,4.428,2.269A10.982,10.982,0,0,0,6.7,15.21a9.294,9.294,0,0,1-1.494-.727c.125-.093.248-.19.366-.289a10.212,10.212,0,0,0,8.854,0c.119.1.242.2.366.289a9.274,9.274,0,0,1-1.5.728,10.8,10.8,0,0,0,.948,1.562,14.419,14.419,0,0,0,4.431-2.27A15.128,15.128,0,0,0,16.074,4.361Zm-8.981,8.1a1.7,1.7,0,0,1-1.573-1.79A1.689,1.689,0,0,1,7.093,8.881a1.679,1.679,0,0,1,1.573,1.791A1.687,1.687,0,0,1,7.093,12.462Zm5.814,0a1.7,1.7,0,0,1-1.573-1.79,1.689,1.689,0,0,1,1.573-1.791,1.679,1.679,0,0,1,1.573,1.791A1.688,1.688,0,0,1,12.907,12.462Z\"/></svg>",
|
||||
"download": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" points=\"14,10 9.5,14.5 5,10\"/><rect x=\"3\" y=\"17\" width=\"13\" height=\"1\"/><line fill=\"none\" stroke=\"#000\" x1=\"9.5\" y1=\"13.91\" x2=\"9.5\" y2=\"3\"/></svg>",
|
||||
"dribbble": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.4\" d=\"M1.3,8.9c0,0,5,0.1,8.6-1c1.4-0.4,2.6-0.9,4-1.9 c1.4-1.1,2.5-2.5,2.5-2.5\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.4\" d=\"M3.9,16.6c0,0,1.7-2.8,3.5-4.2 c1.8-1.3,4-2,5.7-2.2C16,10,19,10.6,19,10.6\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.4\" d=\"M6.9,1.6c0,0,3.3,4.6,4.2,6.8 c0.4,0.9,1.3,3.1,1.9,5.2c0.6,2,0.9,4.4,0.9,4.4\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.4\" cx=\"10\" cy=\"10\" r=\"9\"/></svg>",
|
||||
"etsy": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\"><path d=\"M8,4.26C8,4.07,8,4,8.31,4h4.46c.79,0,1.22.67,1.53,1.91l.25,1h.76c.14-2.82.26-4,.26-4S13.65,3,12.52,3H6.81L3.75,2.92v.84l1,.2c.73.11.9.27,1,1,0,0,.06,2,.06,5.17s-.06,5.14-.06,5.14c0,.59-.23.81-1,.94l-1,.2v.84l3.06-.1h5.11c1.15,0,3.82.1,3.82.1,0-.7.45-3.88.51-4.22h-.73l-.76,1.69a2.25,2.25,0,0,1-2.45,1.47H9.4c-1,0-1.44-.4-1.44-1.24V10.44s2.16,0,2.86.06c.55,0,.85.19,1.06,1l.23,1H13L12.9,9.94,13,7.41h-.85l-.28,1.13c-.16.74-.28.84-1,1-1,.1-2.89.09-2.89.09Z\"/></svg>",
|
||||
"expand": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"13 2 18 2 18 7 17 7 17 3 13 3\"/><polygon points=\"2 13 3 13 3 17 7 17 7 18 2 18\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M11,9 L17,3\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M3,17 L9,11\"/></svg>",
|
||||
"facebook": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M11,10h2.6l0.4-3H11V5.3c0-0.9,0.2-1.5,1.5-1.5H14V1.1c-0.3,0-1-0.1-2.1-0.1C9.6,1,8,2.4,8,5v2H5.5v3H8v8h3V10z\"/></svg>",
|
||||
"file-edit": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" d=\"M18.65,1.68 C18.41,1.45 18.109,1.33 17.81,1.33 C17.499,1.33 17.209,1.45 16.98,1.68 L8.92,9.76 L8,12.33 L10.55,11.41 L18.651,3.34 C19.12,2.87 19.12,2.15 18.65,1.68 L18.65,1.68 L18.65,1.68 Z\"/><polyline fill=\"none\" stroke=\"#000\" points=\"16.5 8.482 16.5 18.5 3.5 18.5 3.5 1.5 14.211 1.5\"/></svg>",
|
||||
"file-pdf": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect fill=\"none\" stroke=\"#000\" width=\"13\" height=\"17\" x=\"3.5\" y=\"1.5\"/><path d=\"M14.65 11.67c-.48.3-1.37-.19-1.79-.37a4.65 4.65 0 0 1 1.49.06c.35.1.36.28.3.31zm-6.3.06l.43-.79a14.7 14.7 0 0 0 .75-1.64 5.48 5.48 0 0 0 1.25 1.55l.2.15a16.36 16.36 0 0 0-2.63.73zM9.5 5.32c.2 0 .32.5.32.97a1.99 1.99 0 0 1-.23 1.04 5.05 5.05 0 0 1-.17-1.3s0-.71.08-.71zm-3.9 9a4.35 4.35 0 0 1 1.21-1.46l.24-.22a4.35 4.35 0 0 1-1.46 1.68zm9.23-3.3a2.05 2.05 0 0 0-1.32-.3 11.07 11.07 0 0 0-1.58.11 4.09 4.09 0 0 1-.74-.5 5.39 5.39 0 0 1-1.32-2.06 10.37 10.37 0 0 0 .28-2.62 1.83 1.83 0 0 0-.07-.25.57.57 0 0 0-.52-.4H9.4a.59.59 0 0 0-.6.38 6.95 6.95 0 0 0 .37 3.14c-.26.63-1 2.12-1 2.12-.3.58-.57 1.08-.82 1.5l-.8.44A3.11 3.11 0 0 0 5 14.16a.39.39 0 0 0 .15.42l.24.13c1.15.56 2.28-1.74 2.66-2.42a23.1 23.1 0 0 1 3.59-.85 4.56 4.56 0 0 0 2.91.8.5.5 0 0 0 .3-.21 1.1 1.1 0 0 0 .12-.75.84.84 0 0 0-.14-.25z\"/></svg>",
|
||||
"file-text": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect fill=\"none\" stroke=\"#000\" width=\"13\" height=\"17\" x=\"3.5\" y=\"1.5\"/><line fill=\"none\" stroke=\"#000\" x1=\"6\" x2=\"12\" y1=\"12.5\" y2=\"12.5\"/><line fill=\"none\" stroke=\"#000\" x1=\"6\" x2=\"14\" y1=\"8.5\" y2=\"8.5\"/><line fill=\"none\" stroke=\"#000\" x1=\"6\" x2=\"14\" y1=\"6.5\" y2=\"6.5\"/><line fill=\"none\" stroke=\"#000\" x1=\"6\" x2=\"14\" y1=\"10.5\" y2=\"10.5\"/></svg>",
|
||||
"file": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect fill=\"none\" stroke=\"#000\" x=\"3.5\" y=\"1.5\" width=\"13\" height=\"17\"/></svg>",
|
||||
"flickr": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"5.5\" cy=\"9.5\" r=\"3.5\"/><circle cx=\"14.5\" cy=\"9.5\" r=\"3.5\"/></svg>",
|
||||
"folder": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon fill=\"none\" stroke=\"#000\" points=\"9.5 5.5 8.5 3.5 1.5 3.5 1.5 16.5 18.5 16.5 18.5 5.5\"/></svg>",
|
||||
"forward": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M2.47,13.11 C4.02,10.02 6.27,7.85 9.04,6.61 C9.48,6.41 10.27,6.13 11,5.91 L11,2 L18.89,9 L11,16 L11,12.13 C9.25,12.47 7.58,13.19 6.02,14.25 C3.03,16.28 1.63,18.54 1.63,18.54 C1.63,18.54 1.38,15.28 2.47,13.11 L2.47,13.11 Z M5.3,13.53 C6.92,12.4 9.04,11.4 12,10.92 L12,13.63 L17.36,9 L12,4.25 L12,6.8 C11.71,6.86 10.86,7.02 9.67,7.49 C6.79,8.65 4.58,10.96 3.49,13.08 C3.18,13.7 2.68,14.87 2.49,16 C3.28,15.05 4.4,14.15 5.3,13.53 L5.3,13.53 Z\"/></svg>",
|
||||
"foursquare": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M15.23,2 C15.96,2 16.4,2.41 16.5,2.86 C16.57,3.15 16.56,3.44 16.51,3.73 C16.46,4.04 14.86,11.72 14.75,12.03 C14.56,12.56 14.16,12.82 13.61,12.83 C13.03,12.84 11.09,12.51 10.69,13 C10.38,13.38 7.79,16.39 6.81,17.53 C6.61,17.76 6.4,17.96 6.08,17.99 C5.68,18.04 5.29,17.87 5.17,17.45 C5.12,17.28 5.1,17.09 5.1,16.91 C5.1,12.4 4.86,7.81 5.11,3.31 C5.17,2.5 5.81,2.12 6.53,2 L15.23,2 L15.23,2 Z M9.76,11.42 C9.94,11.19 10.17,11.1 10.45,11.1 L12.86,11.1 C13.12,11.1 13.31,10.94 13.36,10.69 C13.37,10.64 13.62,9.41 13.74,8.83 C13.81,8.52 13.53,8.28 13.27,8.28 C12.35,8.29 11.42,8.28 10.5,8.28 C9.84,8.28 9.83,7.69 9.82,7.21 C9.8,6.85 10.13,6.55 10.5,6.55 C11.59,6.56 12.67,6.55 13.76,6.55 C14.03,6.55 14.23,6.4 14.28,6.14 C14.34,5.87 14.67,4.29 14.67,4.29 C14.67,4.29 14.82,3.74 14.19,3.74 L7.34,3.74 C7,3.75 6.84,4.02 6.84,4.33 C6.84,7.58 6.85,14.95 6.85,14.99 C6.87,15 8.89,12.51 9.76,11.42 L9.76,11.42 Z\"/></svg>",
|
||||
"future": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline points=\"19 2 18 2 18 6 14 6 14 7 19 7 19 2\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M18,6.548 C16.709,3.29 13.354,1 9.6,1 C4.6,1 0.6,5 0.6,10 C0.6,15 4.6,19 9.6,19 C14.6,19 18.6,15 18.6,10\"/><rect x=\"9\" y=\"4\" width=\"1\" height=\"7\"/><path d=\"M13.018,14.197 L9.445,10.625\" fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\"/></svg>",
|
||||
"git-branch": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" cx=\"7\" cy=\"3\" r=\"2\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" cx=\"14\" cy=\"6\" r=\"2\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" cx=\"7\" cy=\"17\" r=\"2\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"2\" d=\"M14,8 C14,10.41 12.43,10.87 10.56,11.25 C9.09,11.54 7,12.06 7,15 L7,5\"/></svg>",
|
||||
"git-fork": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" cx=\"5.79\" cy=\"2.79\" r=\"1.79\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" cx=\"14.19\" cy=\"2.79\" r=\"1.79\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" cx=\"10.03\" cy=\"16.79\" r=\"1.79\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"2\" d=\"M5.79,4.57 L5.79,6.56 C5.79,9.19 10.03,10.22 10.03,13.31 C10.03,14.86 10.04,14.55 10.04,14.55 C10.04,14.37 10.04,14.86 10.04,13.31 C10.04,10.22 14.2,9.19 14.2,6.56 L14.2,4.57\"/></svg>",
|
||||
"github-alt": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10,0.5 C4.75,0.5 0.5,4.76 0.5,10.01 C0.5,15.26 4.75,19.51 10,19.51 C15.24,19.51 19.5,15.26 19.5,10.01 C19.5,4.76 15.25,0.5 10,0.5 L10,0.5 Z M12.81,17.69 C12.81,17.69 12.81,17.7 12.79,17.69 C12.47,17.75 12.35,17.59 12.35,17.36 L12.35,16.17 C12.35,15.45 12.09,14.92 11.58,14.56 C12.2,14.51 12.77,14.39 13.26,14.21 C13.87,13.98 14.36,13.69 14.74,13.29 C15.42,12.59 15.76,11.55 15.76,10.17 C15.76,9.25 15.45,8.46 14.83,7.8 C15.1,7.08 15.07,6.29 14.75,5.44 L14.51,5.42 C14.34,5.4 14.06,5.46 13.67,5.61 C13.25,5.78 12.79,6.03 12.31,6.35 C11.55,6.16 10.81,6.05 10.09,6.05 C9.36,6.05 8.61,6.15 7.88,6.35 C7.28,5.96 6.75,5.68 6.26,5.54 C6.07,5.47 5.9,5.44 5.78,5.44 L5.42,5.44 C5.06,6.29 5.04,7.08 5.32,7.8 C4.7,8.46 4.4,9.25 4.4,10.17 C4.4,11.94 4.96,13.16 6.08,13.84 C6.53,14.13 7.05,14.32 7.69,14.43 C8.03,14.5 8.32,14.54 8.55,14.55 C8.07,14.89 7.82,15.42 7.82,16.16 L7.82,17.51 C7.8,17.69 7.7,17.8 7.51,17.8 C4.21,16.74 1.82,13.65 1.82,10.01 C1.82,5.5 5.49,1.83 10,1.83 C14.5,1.83 18.17,5.5 18.17,10.01 C18.18,13.53 15.94,16.54 12.81,17.69 L12.81,17.69 Z\"/></svg>",
|
||||
"github": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10,1 C5.03,1 1,5.03 1,10 C1,13.98 3.58,17.35 7.16,18.54 C7.61,18.62 7.77,18.34 7.77,18.11 C7.77,17.9 7.76,17.33 7.76,16.58 C5.26,17.12 4.73,15.37 4.73,15.37 C4.32,14.33 3.73,14.05 3.73,14.05 C2.91,13.5 3.79,13.5 3.79,13.5 C4.69,13.56 5.17,14.43 5.17,14.43 C5.97,15.8 7.28,15.41 7.79,15.18 C7.87,14.6 8.1,14.2 8.36,13.98 C6.36,13.75 4.26,12.98 4.26,9.53 C4.26,8.55 4.61,7.74 5.19,7.11 C5.1,6.88 4.79,5.97 5.28,4.73 C5.28,4.73 6.04,4.49 7.75,5.65 C8.47,5.45 9.24,5.35 10,5.35 C10.76,5.35 11.53,5.45 12.25,5.65 C13.97,4.48 14.72,4.73 14.72,4.73 C15.21,5.97 14.9,6.88 14.81,7.11 C15.39,7.74 15.73,8.54 15.73,9.53 C15.73,12.99 13.63,13.75 11.62,13.97 C11.94,14.25 12.23,14.8 12.23,15.64 C12.23,16.84 12.22,17.81 12.22,18.11 C12.22,18.35 12.38,18.63 12.84,18.54 C16.42,17.35 19,13.98 19,10 C19,5.03 14.97,1 10,1 L10,1 Z\"/></svg>",
|
||||
"gitter": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"3.5\" y=\"1\" width=\"1.531\" height=\"11.471\"/><rect x=\"7.324\" y=\"4.059\" width=\"1.529\" height=\"15.294\"/><rect x=\"11.148\" y=\"4.059\" width=\"1.527\" height=\"15.294\"/><rect x=\"14.971\" y=\"4.059\" width=\"1.529\" height=\"8.412\"/></svg>",
|
||||
"google": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M17.86,9.09 C18.46,12.12 17.14,16.05 13.81,17.56 C9.45,19.53 4.13,17.68 2.47,12.87 C0.68,7.68 4.22,2.42 9.5,2.03 C11.57,1.88 13.42,2.37 15.05,3.65 C15.22,3.78 15.37,3.93 15.61,4.14 C14.9,4.81 14.23,5.45 13.5,6.14 C12.27,5.08 10.84,4.72 9.28,4.98 C8.12,5.17 7.16,5.76 6.37,6.63 C4.88,8.27 4.62,10.86 5.76,12.82 C6.95,14.87 9.17,15.8 11.57,15.25 C13.27,14.87 14.76,13.33 14.89,11.75 L10.51,11.75 L10.51,9.09 L17.86,9.09 L17.86,9.09 Z\"/></svg>",
|
||||
"grid": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"2\" y=\"2\" width=\"3\" height=\"3\"/><rect x=\"8\" y=\"2\" width=\"3\" height=\"3\"/><rect x=\"14\" y=\"2\" width=\"3\" height=\"3\"/><rect x=\"2\" y=\"8\" width=\"3\" height=\"3\"/><rect x=\"8\" y=\"8\" width=\"3\" height=\"3\"/><rect x=\"14\" y=\"8\" width=\"3\" height=\"3\"/><rect x=\"2\" y=\"14\" width=\"3\" height=\"3\"/><rect x=\"8\" y=\"14\" width=\"3\" height=\"3\"/><rect x=\"14\" y=\"14\" width=\"3\" height=\"3\"/></svg>",
|
||||
"happy": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"13\" cy=\"7\" r=\"1\"/><circle cx=\"7\" cy=\"7\" r=\"1\"/><circle fill=\"none\" stroke=\"#000\" cx=\"10\" cy=\"10\" r=\"8.5\"/><path fill=\"none\" stroke=\"#000\" d=\"M14.6,11.4 C13.9,13.3 12.1,14.5 10,14.5 C7.9,14.5 6.1,13.3 5.4,11.4\"/></svg>",
|
||||
"hashtag": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M15.431,8 L15.661,7 L12.911,7 L13.831,3 L12.901,3 L11.98,7 L9.29,7 L10.21,3 L9.281,3 L8.361,7 L5.23,7 L5,8 L8.13,8 L7.21,12 L4.23,12 L4,13 L6.98,13 L6.061,17 L6.991,17 L7.911,13 L10.601,13 L9.681,17 L10.611,17 L11.531,13 L14.431,13 L14.661,12 L11.76,12 L12.681,8 L15.431,8 Z M10.831,12 L8.141,12 L9.061,8 L11.75,8 L10.831,12 Z\"/></svg>",
|
||||
"heart": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.03\" d=\"M10,4 C10,4 8.1,2 5.74,2 C3.38,2 1,3.55 1,6.73 C1,8.84 2.67,10.44 2.67,10.44 L10,18 L17.33,10.44 C17.33,10.44 19,8.84 19,6.73 C19,3.55 16.62,2 14.26,2 C11.9,2 10,4 10,4 L10,4 Z\"/></svg>",
|
||||
"history": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"#000\" points=\"1 2 2 2 2 6 6 6 6 7 1 7 1 2\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M2.1,6.548 C3.391,3.29 6.746,1 10.5,1 C15.5,1 19.5,5 19.5,10 C19.5,15 15.5,19 10.5,19 C5.5,19 1.5,15 1.5,10\"/><rect x=\"9\" y=\"4\" width=\"1\" height=\"7\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M13.018,14.197 L9.445,10.625\"/></svg>",
|
||||
"home": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"18.65 11.35 10 2.71 1.35 11.35 0.65 10.65 10 1.29 19.35 10.65\"/><polygon points=\"15 4 18 4 18 7 17 7 17 5 15 5\"/><polygon points=\"3 11 4 11 4 18 7 18 7 12 12 12 12 18 16 18 16 11 17 11 17 19 11 19 11 13 8 13 8 19 3 19\"/></svg>",
|
||||
"image": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"16.1\" cy=\"6.1\" r=\"1.1\"/><rect fill=\"none\" stroke=\"#000\" x=\".5\" y=\"2.5\" width=\"19\" height=\"15\"/><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.01\" points=\"4,13 8,9 13,14\"/><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.01\" points=\"11,12 12.5,10.5 16,14\"/></svg>",
|
||||
"info": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12.13,11.59 C11.97,12.84 10.35,14.12 9.1,14.16 C6.17,14.2 9.89,9.46 8.74,8.37 C9.3,8.16 10.62,7.83 10.62,8.81 C10.62,9.63 10.12,10.55 9.88,11.32 C8.66,15.16 12.13,11.15 12.14,11.18 C12.16,11.21 12.16,11.35 12.13,11.59 C12.08,11.95 12.16,11.35 12.13,11.59 L12.13,11.59 Z M11.56,5.67 C11.56,6.67 9.36,7.15 9.36,6.03 C9.36,5 11.56,4.54 11.56,5.67 L11.56,5.67 Z\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"10\" cy=\"10\" r=\"9\"/></svg>",
|
||||
"instagram": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13.55,1H6.46C3.45,1,1,3.44,1,6.44v7.12c0,3,2.45,5.44,5.46,5.44h7.08c3.02,0,5.46-2.44,5.46-5.44V6.44 C19.01,3.44,16.56,1,13.55,1z M17.5,14c0,1.93-1.57,3.5-3.5,3.5H6c-1.93,0-3.5-1.57-3.5-3.5V6c0-1.93,1.57-3.5,3.5-3.5h8 c1.93,0,3.5,1.57,3.5,3.5V14z\"/><circle cx=\"14.87\" cy=\"5.26\" r=\"1.09\"/><path d=\"M10.03,5.45c-2.55,0-4.63,2.06-4.63,4.6c0,2.55,2.07,4.61,4.63,4.61c2.56,0,4.63-2.061,4.63-4.61 C14.65,7.51,12.58,5.45,10.03,5.45L10.03,5.45L10.03,5.45z M10.08,13c-1.66,0-3-1.34-3-2.99c0-1.65,1.34-2.99,3-2.99s3,1.34,3,2.99 C13.08,11.66,11.74,13,10.08,13L10.08,13L10.08,13z\"/></svg>",
|
||||
"italic": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12.63,5.48 L10.15,14.52 C10,15.08 10.37,15.25 11.92,15.3 L11.72,16 L6,16 L6.2,15.31 C7.78,15.26 8.19,15.09 8.34,14.53 L10.82,5.49 C10.97,4.92 10.63,4.76 9.09,4.71 L9.28,4 L15,4 L14.81,4.69 C13.23,4.75 12.78,4.91 12.63,5.48 L12.63,5.48 Z\"/></svg>",
|
||||
"joomla": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7.8,13.4l1.7-1.7L5.9,8c-0.6-0.5-0.6-1.5,0-2c0.6-0.6,1.4-0.6,2,0l1.7-1.7c-1-1-2.3-1.3-3.6-1C5.8,2.2,4.8,1.4,3.7,1.4 c-1.3,0-2.3,1-2.3,2.3c0,1.1,0.8,2,1.8,2.3c-0.4,1.3-0.1,2.8,1,3.8L7.8,13.4L7.8,13.4z\"/><path d=\"M10.2,4.3c1-1,2.5-1.4,3.8-1c0.2-1.1,1.1-2,2.3-2c1.3,0,2.3,1,2.3,2.3c0,1.2-0.9,2.2-2,2.3c0.4,1.3,0,2.8-1,3.8L13.9,8 c0.6-0.5,0.6-1.5,0-2c-0.5-0.6-1.5-0.6-2,0L8.2,9.7L6.5,8\"/><path d=\"M14.1,16.8c-1.3,0.4-2.8,0.1-3.8-1l1.7-1.7c0.6,0.6,1.5,0.6,2,0c0.5-0.6,0.6-1.5,0-2l-3.7-3.7L12,6.7l3.7,3.7 c1,1,1.3,2.4,1,3.6c1.1,0.2,2,1.1,2,2.3c0,1.3-1,2.3-2.3,2.3C15.2,18.6,14.3,17.8,14.1,16.8\"/><path d=\"M13.2,12.2l-3.7,3.7c-1,1-2.4,1.3-3.6,1c-0.2,1-1.2,1.8-2.2,1.8c-1.3,0-2.3-1-2.3-2.3c0-1.1,0.8-2,1.8-2.3 c-0.3-1.3,0-2.7,1-3.7l1.7,1.7c-0.6,0.6-0.6,1.5,0,2c0.6,0.6,1.4,0.6,2,0l3.7-3.7\"/></svg>",
|
||||
"laptop": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect y=\"16\" width=\"20\" height=\"1\"/><rect fill=\"none\" stroke=\"#000\" x=\"2.5\" y=\"4.5\" width=\"15\" height=\"10\"/></svg>",
|
||||
"lifesaver": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10,0.5 C4.76,0.5 0.5,4.76 0.5,10 C0.5,15.24 4.76,19.5 10,19.5 C15.24,19.5 19.5,15.24 19.5,10 C19.5,4.76 15.24,0.5 10,0.5 L10,0.5 Z M10,1.5 C11.49,1.5 12.89,1.88 14.11,2.56 L11.85,4.82 C11.27,4.61 10.65,4.5 10,4.5 C9.21,4.5 8.47,4.67 7.79,4.96 L5.58,2.75 C6.87,1.95 8.38,1.5 10,1.5 L10,1.5 Z M4.96,7.8 C4.67,8.48 4.5,9.21 4.5,10 C4.5,10.65 4.61,11.27 4.83,11.85 L2.56,14.11 C1.88,12.89 1.5,11.49 1.5,10 C1.5,8.38 1.95,6.87 2.75,5.58 L4.96,7.79 L4.96,7.8 L4.96,7.8 Z M10,18.5 C8.25,18.5 6.62,17.97 5.27,17.06 L7.46,14.87 C8.22,15.27 9.08,15.5 10,15.5 C10.79,15.5 11.53,15.33 12.21,15.04 L14.42,17.25 C13.13,18.05 11.62,18.5 10,18.5 L10,18.5 Z M10,14.5 C7.52,14.5 5.5,12.48 5.5,10 C5.5,7.52 7.52,5.5 10,5.5 C12.48,5.5 14.5,7.52 14.5,10 C14.5,12.48 12.48,14.5 10,14.5 L10,14.5 Z M15.04,12.21 C15.33,11.53 15.5,10.79 15.5,10 C15.5,9.08 15.27,8.22 14.87,7.46 L17.06,5.27 C17.97,6.62 18.5,8.25 18.5,10 C18.5,11.62 18.05,13.13 17.25,14.42 L15.04,12.21 L15.04,12.21 Z\"/></svg>",
|
||||
"link": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M10.625,12.375 L7.525,15.475 C6.825,16.175 5.925,16.175 5.225,15.475 L4.525,14.775 C3.825,14.074 3.825,13.175 4.525,12.475 L7.625,9.375\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M9.325,7.375 L12.425,4.275 C13.125,3.575 14.025,3.575 14.724,4.275 L15.425,4.975 C16.125,5.675 16.125,6.575 15.425,7.275 L12.325,10.375\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M7.925,11.875 L11.925,7.975\"/></svg>",
|
||||
"linkedin": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M5.77,17.89 L5.77,7.17 L2.21,7.17 L2.21,17.89 L5.77,17.89 L5.77,17.89 Z M3.99,5.71 C5.23,5.71 6.01,4.89 6.01,3.86 C5.99,2.8 5.24,2 4.02,2 C2.8,2 2,2.8 2,3.85 C2,4.88 2.77,5.7 3.97,5.7 L3.99,5.7 L3.99,5.71 L3.99,5.71 Z\"/><path d=\"M7.75,17.89 L11.31,17.89 L11.31,11.9 C11.31,11.58 11.33,11.26 11.43,11.03 C11.69,10.39 12.27,9.73 13.26,9.73 C14.55,9.73 15.06,10.71 15.06,12.15 L15.06,17.89 L18.62,17.89 L18.62,11.74 C18.62,8.45 16.86,6.92 14.52,6.92 C12.6,6.92 11.75,7.99 11.28,8.73 L11.3,8.73 L11.3,7.17 L7.75,7.17 C7.79,8.17 7.75,17.89 7.75,17.89 L7.75,17.89 L7.75,17.89 Z\"/></svg>",
|
||||
"list": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"6\" y=\"4\" width=\"12\" height=\"1\"/><rect x=\"6\" y=\"9\" width=\"12\" height=\"1\"/><rect x=\"6\" y=\"14\" width=\"12\" height=\"1\"/><rect x=\"2\" y=\"4\" width=\"2\" height=\"1\"/><rect x=\"2\" y=\"9\" width=\"2\" height=\"1\"/><rect x=\"2\" y=\"14\" width=\"2\" height=\"1\"/></svg>",
|
||||
"location": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.01\" d=\"M10,0.5 C6.41,0.5 3.5,3.39 3.5,6.98 C3.5,11.83 10,19 10,19 C10,19 16.5,11.83 16.5,6.98 C16.5,3.39 13.59,0.5 10,0.5 L10,0.5 Z\"/><circle fill=\"none\" stroke=\"#000\" cx=\"10\" cy=\"6.8\" r=\"2.3\"/></svg>",
|
||||
"lock": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect fill=\"none\" stroke=\"#000\" height=\"10\" width=\"13\" y=\"8.5\" x=\"3.5\"/><path fill=\"none\" stroke=\"#000\" d=\"M6.5,8 L6.5,4.88 C6.5,3.01 8.07,1.5 10,1.5 C11.93,1.5 13.5,3.01 13.5,4.88 L13.5,8\"/></svg>",
|
||||
"mail": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" points=\"1.4,6.5 10,11 18.6,6.5\"/><path d=\"M 1,4 1,16 19,16 19,4 1,4 Z M 18,15 2,15 2,5 18,5 18,15 Z\"/></svg>",
|
||||
"menu": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"2\" y=\"4\" width=\"16\" height=\"1\"/><rect x=\"2\" y=\"9\" width=\"16\" height=\"1\"/><rect x=\"2\" y=\"14\" width=\"16\" height=\"1\"/></svg>",
|
||||
"microphone": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><line fill=\"none\" stroke=\"#000\" x1=\"10\" x2=\"10\" y1=\"16.44\" y2=\"18.5\"/><line fill=\"none\" stroke=\"#000\" x1=\"7\" x2=\"13\" y1=\"18.5\" y2=\"18.5\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M13.5 4.89v5.87a3.5 3.5 0 0 1-7 0V4.89a3.5 3.5 0 0 1 7 0z\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M15.5 10.36V11a5.5 5.5 0 0 1-11 0v-.6\"/></svg>",
|
||||
"minus-circle": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"9.5\" cy=\"9.5\" r=\"9\"/><line fill=\"none\" stroke=\"#000\" x1=\"5\" y1=\"9.5\" x2=\"14\" y2=\"9.5\"/></svg>",
|
||||
"minus": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect height=\"1\" width=\"18\" y=\"9\" x=\"1\"/></svg>",
|
||||
"more-vertical": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"10\" cy=\"3\" r=\"2\"/><circle cx=\"10\" cy=\"10\" r=\"2\"/><circle cx=\"10\" cy=\"17\" r=\"2\"/></svg>",
|
||||
"more": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"3\" cy=\"10\" r=\"2\"/><circle cx=\"10\" cy=\"10\" r=\"2\"/><circle cx=\"17\" cy=\"10\" r=\"2\"/></svg>",
|
||||
"move": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"4,5 1,5 1,9 2,9 2,6 4,6\"/><polygon points=\"1,16 2,16 2,18 4,18 4,19 1,19\"/><polygon points=\"14,16 14,19 11,19 11,18 13,18 13,16\"/><rect fill=\"none\" stroke=\"#000\" x=\"5.5\" y=\"1.5\" width=\"13\" height=\"13\"/><rect x=\"1\" y=\"11\" width=\"1\" height=\"3\"/><rect x=\"6\" y=\"18\" width=\"3\" height=\"1\"/></svg>",
|
||||
"nut": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon fill=\"none\" stroke=\"#000\" points=\"2.5,5.7 10,1.3 17.5,5.7 17.5,14.3 10,18.7 2.5,14.3\"/><circle fill=\"none\" stroke=\"#000\" cx=\"10\" cy=\"10\" r=\"3.5\"/></svg>",
|
||||
"pagekit": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"3,1 17,1 17,16 10,16 10,13 14,13 14,4 6,4 6,16 10,16 10,19 3,19\"/></svg>",
|
||||
"paint-bucket": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10.21,1 L0,11.21 L8.1,19.31 L18.31,9.1 L10.21,1 L10.21,1 Z M16.89,9.1 L15,11 L1.7,11 L10.21,2.42 L16.89,9.1 Z\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M6.42,2.33 L11.7,7.61\"/><path d=\"M18.49,12 C18.49,12 20,14.06 20,15.36 C20,16.28 19.24,17 18.49,17 L18.49,17 C17.74,17 17,16.28 17,15.36 C17,14.06 18.49,12 18.49,12 L18.49,12 Z\"/></svg>",
|
||||
"pencil": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" d=\"M17.25,6.01 L7.12,16.1 L3.82,17.2 L5.02,13.9 L15.12,3.88 C15.71,3.29 16.66,3.29 17.25,3.88 C17.83,4.47 17.83,5.42 17.25,6.01 L17.25,6.01 Z\"/><path fill=\"none\" stroke=\"#000\" d=\"M15.98,7.268 L13.851,5.148\"/></svg>",
|
||||
"phone-landscape": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" d=\"M17,5.5 C17.8,5.5 18.5,6.2 18.5,7 L18.5,14 C18.5,14.8 17.8,15.5 17,15.5 L3,15.5 C2.2,15.5 1.5,14.8 1.5,14 L1.5,7 C1.5,6.2 2.2,5.5 3,5.5 L17,5.5 L17,5.5 L17,5.5 Z\"/><circle cx=\"3.8\" cy=\"10.5\" r=\".8\"/></svg>",
|
||||
"phone": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" d=\"M15.5,17 C15.5,17.8 14.8,18.5 14,18.5 L7,18.5 C6.2,18.5 5.5,17.8 5.5,17 L5.5,3 C5.5,2.2 6.2,1.5 7,1.5 L14,1.5 C14.8,1.5 15.5,2.2 15.5,3 L15.5,17 L15.5,17 L15.5,17 Z\"/><circle cx=\"10.5\" cy=\"16.5\" r=\".8\"/></svg>",
|
||||
"pinterest": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10.21,1 C5.5,1 3,4.16 3,7.61 C3,9.21 3.85,11.2 5.22,11.84 C5.43,11.94 5.54,11.89 5.58,11.69 C5.62,11.54 5.8,10.8 5.88,10.45 C5.91,10.34 5.89,10.24 5.8,10.14 C5.36,9.59 5,8.58 5,7.65 C5,5.24 6.82,2.91 9.93,2.91 C12.61,2.91 14.49,4.74 14.49,7.35 C14.49,10.3 13,12.35 11.06,12.35 C9.99,12.35 9.19,11.47 9.44,10.38 C9.75,9.08 10.35,7.68 10.35,6.75 C10.35,5.91 9.9,5.21 8.97,5.21 C7.87,5.21 6.99,6.34 6.99,7.86 C6.99,8.83 7.32,9.48 7.32,9.48 C7.32,9.48 6.24,14.06 6.04,14.91 C5.7,16.35 6.08,18.7 6.12,18.9 C6.14,19.01 6.26,19.05 6.33,18.95 C6.44,18.81 7.74,16.85 8.11,15.44 C8.24,14.93 8.79,12.84 8.79,12.84 C9.15,13.52 10.19,14.09 11.29,14.09 C14.58,14.09 16.96,11.06 16.96,7.3 C16.94,3.7 14,1 10.21,1\"/></svg>",
|
||||
"play-circle": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" points=\"8.5 7 13.5 10 8.5 13\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"10\" cy=\"10\" r=\"9\"/></svg>",
|
||||
"play": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon fill=\"none\" stroke=\"#000\" points=\"6.5,5 14.5,10 6.5,15\"/></svg>",
|
||||
"plus-circle": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"9.5\" cy=\"9.5\" r=\"9\"/><line fill=\"none\" stroke=\"#000\" x1=\"9.5\" y1=\"5\" x2=\"9.5\" y2=\"14\"/><line fill=\"none\" stroke=\"#000\" x1=\"5\" y1=\"9.5\" x2=\"14\" y2=\"9.5\"/></svg>",
|
||||
"plus": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"9\" y=\"1\" width=\"1\" height=\"17\"/><rect x=\"1\" y=\"9\" width=\"17\" height=\"1\"/></svg>",
|
||||
"print": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" points=\"4.5 13.5 1.5 13.5 1.5 6.5 18.5 6.5 18.5 13.5 15.5 13.5\"/><polyline fill=\"none\" stroke=\"#000\" points=\"15.5 6.5 15.5 2.5 4.5 2.5 4.5 6.5\"/><rect fill=\"none\" stroke=\"#000\" width=\"11\" height=\"6\" x=\"4.5\" y=\"11.5\"/><rect width=\"8\" height=\"1\" x=\"6\" y=\"13\"/><rect width=\"8\" height=\"1\" x=\"6\" y=\"15\"/></svg>",
|
||||
"pull": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"6.85,8 9.5,10.6 12.15,8 12.85,8.7 9.5,12 6.15,8.7\"/><line fill=\"none\" stroke=\"#000\" x1=\"9.5\" y1=\"11\" x2=\"9.5\" y2=\"2\"/><polyline fill=\"none\" stroke=\"#000\" points=\"6,5.5 3.5,5.5 3.5,18.5 15.5,18.5 15.5,5.5 13,5.5\"/></svg>",
|
||||
"push": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"12.15,4 9.5,1.4 6.85,4 6.15,3.3 9.5,0 12.85,3.3\"/><line fill=\"none\" stroke=\"#000\" x1=\"9.5\" y1=\"10\" x2=\"9.5\" y2=\"1\"/><polyline fill=\"none\" stroke=\"#000\" points=\"6 5.5 3.5 5.5 3.5 18.5 15.5 18.5 15.5 5.5 13 5.5\"/></svg>",
|
||||
"question": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"10\" cy=\"10\" r=\"9\"/><circle cx=\"10.44\" cy=\"14.42\" r=\"1.05\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" d=\"M8.17,7.79 C8.17,4.75 12.72,4.73 12.72,7.72 C12.72,8.67 11.81,9.15 11.23,9.75 C10.75,10.24 10.51,10.73 10.45,11.4 C10.44,11.53 10.43,11.64 10.43,11.75\"/></svg>",
|
||||
"quote-right": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M17.27,7.79 C17.27,9.45 16.97,10.43 15.99,12.02 C14.98,13.64 13,15.23 11.56,15.97 L11.1,15.08 C12.34,14.2 13.14,13.51 14.02,11.82 C14.27,11.34 14.41,10.92 14.49,10.54 C14.3,10.58 14.09,10.6 13.88,10.6 C12.06,10.6 10.59,9.12 10.59,7.3 C10.59,5.48 12.06,4 13.88,4 C15.39,4 16.67,5.02 17.05,6.42 C17.19,6.82 17.27,7.27 17.27,7.79 L17.27,7.79 Z\"/><path d=\"M8.68,7.79 C8.68,9.45 8.38,10.43 7.4,12.02 C6.39,13.64 4.41,15.23 2.97,15.97 L2.51,15.08 C3.75,14.2 4.55,13.51 5.43,11.82 C5.68,11.34 5.82,10.92 5.9,10.54 C5.71,10.58 5.5,10.6 5.29,10.6 C3.47,10.6 2,9.12 2,7.3 C2,5.48 3.47,4 5.29,4 C6.8,4 8.08,5.02 8.46,6.42 C8.6,6.82 8.68,7.27 8.68,7.79 L8.68,7.79 Z\"/></svg>",
|
||||
"receiver": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.01\" d=\"M6.189,13.611C8.134,15.525 11.097,18.239 13.867,18.257C16.47,18.275 18.2,16.241 18.2,16.241L14.509,12.551L11.539,13.639L6.189,8.29L7.313,5.355L3.76,1.8C3.76,1.8 1.732,3.537 1.7,6.092C1.667,8.809 4.347,11.738 6.189,13.611\"/></svg>",
|
||||
"reddit": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M19 9.05a2.56 2.56 0 0 0-2.56-2.56 2.59 2.59 0 0 0-1.88.82 10.63 10.63 0 0 0-4.14-1v-.08c.58-1.62 1.58-3.89 2.7-4.1.38-.08.77.12 1.19.57a1.15 1.15 0 0 0-.06.37 1.48 1.48 0 1 0 1.51-1.45 1.43 1.43 0 0 0-.76.19A2.29 2.29 0 0 0 12.91 1c-2.11.43-3.39 4.38-3.63 5.19 0 0 0 .11-.06.11a10.65 10.65 0 0 0-3.75 1A2.56 2.56 0 0 0 1 9.05a2.42 2.42 0 0 0 .72 1.76A5.18 5.18 0 0 0 1.24 13c0 3.66 3.92 6.64 8.73 6.64s8.74-3 8.74-6.64a5.23 5.23 0 0 0-.46-2.13A2.58 2.58 0 0 0 19 9.05zm-16.88 0a1.44 1.44 0 0 1 2.27-1.19 7.68 7.68 0 0 0-2.07 1.91 1.33 1.33 0 0 1-.2-.72zM10 18.4c-4.17 0-7.55-2.4-7.55-5.4S5.83 7.53 10 7.53 17.5 10 17.5 13s-3.38 5.4-7.5 5.4zm7.69-8.61a7.62 7.62 0 0 0-2.09-1.91 1.41 1.41 0 0 1 .84-.28 1.47 1.47 0 0 1 1.44 1.45 1.34 1.34 0 0 1-.21.72z\"/><path d=\"M6.69 12.58a1.39 1.39 0 1 1 1.39-1.39 1.38 1.38 0 0 1-1.38 1.39z\"/><path d=\"M14.26 11.2a1.39 1.39 0 1 1-1.39-1.39 1.39 1.39 0 0 1 1.39 1.39z\"/><path d=\"M13.09 14.88a.54.54 0 0 1-.09.77 5.3 5.3 0 0 1-3.26 1.19 5.61 5.61 0 0 1-3.4-1.22.55.55 0 1 1 .73-.83 4.09 4.09 0 0 0 5.25 0 .56.56 0 0 1 .77.09z\"/></svg>",
|
||||
"refresh": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M17.08,11.15 C17.09,11.31 17.1,11.47 17.1,11.64 C17.1,15.53 13.94,18.69 10.05,18.69 C6.16,18.68 3,15.53 3,11.63 C3,7.74 6.16,4.58 10.05,4.58 C10.9,4.58 11.71,4.73 12.46,5\"/><polyline fill=\"none\" stroke=\"#000\" points=\"9.9 2 12.79 4.89 9.79 7.9\"/></svg>",
|
||||
"reply": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M17.7,13.11 C16.12,10.02 13.84,7.85 11.02,6.61 C10.57,6.41 9.75,6.13 9,5.91 L9,2 L1,9 L9,16 L9,12.13 C10.78,12.47 12.5,13.19 14.09,14.25 C17.13,16.28 18.56,18.54 18.56,18.54 C18.56,18.54 18.81,15.28 17.7,13.11 L17.7,13.11 Z M14.82,13.53 C13.17,12.4 11.01,11.4 8,10.92 L8,13.63 L2.55,9 L8,4.25 L8,6.8 C8.3,6.86 9.16,7.02 10.37,7.49 C13.3,8.65 15.54,10.96 16.65,13.08 C16.97,13.7 17.48,14.86 17.68,16 C16.87,15.05 15.73,14.15 14.82,13.53 L14.82,13.53 Z\"/></svg>",
|
||||
"rss": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"3.12\" cy=\"16.8\" r=\"1.85\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M1.5,8.2 C1.78,8.18 2.06,8.16 2.35,8.16 C7.57,8.16 11.81,12.37 11.81,17.57 C11.81,17.89 11.79,18.19 11.76,18.5\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M1.5,2.52 C1.78,2.51 2.06,2.5 2.35,2.5 C10.72,2.5 17.5,9.24 17.5,17.57 C17.5,17.89 17.49,18.19 17.47,18.5\"/></svg>",
|
||||
"search": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"9\" cy=\"9\" r=\"7\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M14,14 L18,18 L14,14 Z\"/></svg>",
|
||||
"server": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"3\" y=\"3\" width=\"1\" height=\"2\"/><rect x=\"5\" y=\"3\" width=\"1\" height=\"2\"/><rect x=\"7\" y=\"3\" width=\"1\" height=\"2\"/><rect x=\"16\" y=\"3\" width=\"1\" height=\"1\"/><rect x=\"16\" y=\"10\" width=\"1\" height=\"1\"/><circle fill=\"none\" stroke=\"#000\" cx=\"9.9\" cy=\"17.4\" r=\"1.4\"/><rect x=\"3\" y=\"10\" width=\"1\" height=\"2\"/><rect x=\"5\" y=\"10\" width=\"1\" height=\"2\"/><rect x=\"9.5\" y=\"14\" width=\"1\" height=\"2\"/><rect x=\"3\" y=\"17\" width=\"6\" height=\"1\"/><rect x=\"11\" y=\"17\" width=\"6\" height=\"1\"/><rect fill=\"none\" stroke=\"#000\" x=\"1.5\" y=\"1.5\" width=\"17\" height=\"5\"/><rect fill=\"none\" stroke=\"#000\" x=\"1.5\" y=\"8.5\" width=\"17\" height=\"5\"/></svg>",
|
||||
"settings": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><ellipse fill=\"none\" stroke=\"#000\" cx=\"6.11\" cy=\"3.55\" rx=\"2.11\" ry=\"2.15\"/><ellipse fill=\"none\" stroke=\"#000\" cx=\"6.11\" cy=\"15.55\" rx=\"2.11\" ry=\"2.15\"/><circle fill=\"none\" stroke=\"#000\" cx=\"13.15\" cy=\"9.55\" r=\"2.15\"/><rect x=\"1\" y=\"3\" width=\"3\" height=\"1\"/><rect x=\"10\" y=\"3\" width=\"8\" height=\"1\"/><rect x=\"1\" y=\"9\" width=\"8\" height=\"1\"/><rect x=\"15\" y=\"9\" width=\"3\" height=\"1\"/><rect x=\"1\" y=\"15\" width=\"3\" height=\"1\"/><rect x=\"10\" y=\"15\" width=\"8\" height=\"1\"/></svg>",
|
||||
"shrink": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"11 4 12 4 12 8 16 8 16 9 11 9\"/><polygon points=\"4 11 9 11 9 16 8 16 8 12 4 12\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M12,8 L18,2\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M2,18 L8,12\"/></svg>",
|
||||
"sign-in": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"7 2 17 2 17 17 7 17 7 16 16 16 16 3 7 3\"/><polygon points=\"9.1 13.4 8.5 12.8 11.28 10 4 10 4 9 11.28 9 8.5 6.2 9.1 5.62 13 9.5\"/></svg>",
|
||||
"sign-out": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"13.1 13.4 12.5 12.8 15.28 10 8 10 8 9 15.28 9 12.5 6.2 13.1 5.62 17 9.5\"/><polygon points=\"13 2 3 2 3 17 13 17 13 16 4 16 4 3 13 3\"/></svg>",
|
||||
"social": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><line fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" x1=\"13.4\" y1=\"14\" x2=\"6.3\" y2=\"10.7\"/><line fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" x1=\"13.5\" y1=\"5.5\" x2=\"6.5\" y2=\"8.8\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"15.5\" cy=\"4.6\" r=\"2.3\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"15.5\" cy=\"14.8\" r=\"2.3\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"4.5\" cy=\"9.8\" r=\"2.3\"/></svg>",
|
||||
"soundcloud": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M17.2,9.4c-0.4,0-0.8,0.1-1.101,0.2c-0.199-2.5-2.399-4.5-5-4.5c-0.6,0-1.2,0.1-1.7,0.3C9.2,5.5,9.1,5.6,9.1,5.6V15h8 c1.601,0,2.801-1.2,2.801-2.8C20,10.7,18.7,9.4,17.2,9.4L17.2,9.4z\"/><rect x=\"6\" y=\"6.5\" width=\"1.5\" height=\"8.5\"/><rect x=\"3\" y=\"8\" width=\"1.5\" height=\"7\"/><rect y=\"10\" width=\"1.5\" height=\"5\"/></svg>",
|
||||
"star": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon fill=\"none\" stroke=\"#000\" stroke-width=\"1.01\" points=\"10 2 12.63 7.27 18.5 8.12 14.25 12.22 15.25 18 10 15.27 4.75 18 5.75 12.22 1.5 8.12 7.37 7.27\"/></svg>",
|
||||
"strikethrough": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6,13.02 L6.65,13.02 C7.64,15.16 8.86,16.12 10.41,16.12 C12.22,16.12 12.92,14.93 12.92,13.89 C12.92,12.55 11.99,12.03 9.74,11.23 C8.05,10.64 6.23,10.11 6.23,7.83 C6.23,5.5 8.09,4.09 10.4,4.09 C11.44,4.09 12.13,4.31 12.72,4.54 L13.33,4 L13.81,4 L13.81,7.59 L13.16,7.59 C12.55,5.88 11.52,4.89 10.07,4.89 C8.84,4.89 7.89,5.69 7.89,7.03 C7.89,8.29 8.89,8.78 10.88,9.45 C12.57,10.03 14.38,10.6 14.38,12.91 C14.38,14.75 13.27,16.93 10.18,16.93 C9.18,16.93 8.17,16.69 7.46,16.39 L6.52,17 L6,17 L6,13.02 L6,13.02 Z\"/><rect x=\"3\" y=\"10\" width=\"15\" height=\"1\"/></svg>",
|
||||
"table": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"1\" y=\"3\" width=\"18\" height=\"1\"/><rect x=\"1\" y=\"7\" width=\"18\" height=\"1\"/><rect x=\"1\" y=\"11\" width=\"18\" height=\"1\"/><rect x=\"1\" y=\"15\" width=\"18\" height=\"1\"/></svg>",
|
||||
"tablet-landscape": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" d=\"M1.5,5 C1.5,4.2 2.2,3.5 3,3.5 L17,3.5 C17.8,3.5 18.5,4.2 18.5,5 L18.5,16 C18.5,16.8 17.8,17.5 17,17.5 L3,17.5 C2.2,17.5 1.5,16.8 1.5,16 L1.5,5 L1.5,5 L1.5,5 Z\"/><circle cx=\"3.7\" cy=\"10.5\" r=\".8\"/></svg>",
|
||||
"tablet": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" d=\"M5,18.5 C4.2,18.5 3.5,17.8 3.5,17 L3.5,3 C3.5,2.2 4.2,1.5 5,1.5 L16,1.5 C16.8,1.5 17.5,2.2 17.5,3 L17.5,17 C17.5,17.8 16.8,18.5 16,18.5 L5,18.5 L5,18.5 L5,18.5 Z\"/><circle cx=\"10.5\" cy=\"16.3\" r=\".8\"/></svg>",
|
||||
"tag": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M17.5,3.71 L17.5,7.72 C17.5,7.96 17.4,8.2 17.21,8.39 L8.39,17.2 C7.99,17.6 7.33,17.6 6.93,17.2 L2.8,13.07 C2.4,12.67 2.4,12.01 2.8,11.61 L11.61,2.8 C11.81,2.6 12.08,2.5 12.34,2.5 L16.19,2.5 C16.52,2.5 16.86,2.63 17.11,2.88 C17.35,3.11 17.48,3.4 17.5,3.71 L17.5,3.71 Z\"/><circle cx=\"14\" cy=\"6\" r=\"1\"/></svg>",
|
||||
"thumbnails": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect fill=\"none\" stroke=\"#000\" x=\"3.5\" y=\"3.5\" width=\"5\" height=\"5\"/><rect fill=\"none\" stroke=\"#000\" x=\"11.5\" y=\"3.5\" width=\"5\" height=\"5\"/><rect fill=\"none\" stroke=\"#000\" x=\"11.5\" y=\"11.5\" width=\"5\" height=\"5\"/><rect fill=\"none\" stroke=\"#000\" x=\"3.5\" y=\"11.5\" width=\"5\" height=\"5\"/></svg>",
|
||||
"tiktok": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M17.24,6V8.82a6.79,6.79,0,0,1-4-1.28v5.81A5.26,5.26,0,1,1,8,8.1a4.36,4.36,0,0,1,.72.05v2.9A2.57,2.57,0,0,0,7.64,11a2.4,2.4,0,1,0,2.77,2.38V2h2.86a4,4,0,0,0,1.84,3.38A4,4,0,0,0,17.24,6Z\"/></svg>",
|
||||
"trash": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" points=\"6.5 3 6.5 1.5 13.5 1.5 13.5 3\"/><polyline fill=\"none\" stroke=\"#000\" points=\"4.5 4 4.5 18.5 15.5 18.5 15.5 4\"/><rect x=\"8\" y=\"7\" width=\"1\" height=\"9\"/><rect x=\"11\" y=\"7\" width=\"1\" height=\"9\"/><rect x=\"2\" y=\"3\" width=\"16\" height=\"1\"/></svg>",
|
||||
"triangle-down": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"5 7 15 7 10 12\"/></svg>",
|
||||
"triangle-left": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"12 5 7 10 12 15\"/></svg>",
|
||||
"triangle-right": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"8 5 13 10 8 15\"/></svg>",
|
||||
"triangle-up": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"5 13 10 8 15 13\"/></svg>",
|
||||
"tripadvisor": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M19.021,7.866C19.256,6.862,20,5.854,20,5.854h-3.346C14.781,4.641,12.504,4,9.98,4C7.363,4,4.999,4.651,3.135,5.876H0\tc0,0,0.738,0.987,0.976,1.988c-0.611,0.837-0.973,1.852-0.973,2.964c0,2.763,2.249,5.009,5.011,5.009\tc1.576,0,2.976-0.737,3.901-1.879l1.063,1.599l1.075-1.615c0.475,0.611,1.1,1.111,1.838,1.451c1.213,0.547,2.574,0.612,3.825,0.15\tc2.589-0.963,3.913-3.852,2.964-6.439c-0.175-0.463-0.4-0.876-0.675-1.238H19.021z M16.38,14.594\tc-1.002,0.371-2.088,0.328-3.06-0.119c-0.688-0.317-1.252-0.817-1.657-1.438c-0.164-0.25-0.313-0.52-0.417-0.811\tc-0.124-0.328-0.186-0.668-0.217-1.014c-0.063-0.689,0.037-1.396,0.339-2.043c0.448-0.971,1.251-1.71,2.25-2.079\tc2.075-0.765,4.375,0.3,5.14,2.366c0.762,2.066-0.301,4.37-2.363,5.134L16.38,14.594L16.38,14.594z M8.322,13.066\tc-0.72,1.059-1.935,1.76-3.309,1.76c-2.207,0-4.001-1.797-4.001-3.996c0-2.203,1.795-4.002,4.001-4.002\tc2.204,0,3.999,1.8,3.999,4.002c0,0.137-0.024,0.261-0.04,0.396c-0.067,0.678-0.284,1.313-0.648,1.853v-0.013H8.322z M2.472,10.775\tc0,1.367,1.112,2.479,2.476,2.479c1.363,0,2.472-1.11,2.472-2.479c0-1.359-1.11-2.468-2.472-2.468\tC3.584,8.306,2.473,9.416,2.472,10.775L2.472,10.775z M12.514,10.775c0,1.367,1.104,2.479,2.471,2.479\tc1.363,0,2.474-1.108,2.474-2.479c0-1.359-1.11-2.468-2.474-2.468c-1.364,0-2.477,1.109-2.477,2.468H12.514z M3.324,10.775\tc0-0.893,0.726-1.618,1.614-1.618c0.889,0,1.625,0.727,1.625,1.618c0,0.898-0.725,1.627-1.625,1.627\tc-0.901,0-1.625-0.729-1.625-1.627H3.324z M13.354,10.775c0-0.893,0.726-1.618,1.627-1.618c0.886,0,1.61,0.727,1.61,1.618\tc0,0.898-0.726,1.627-1.626,1.627s-1.625-0.729-1.625-1.627H13.354z M9.977,4.875c1.798,0,3.425,0.324,4.849,0.968\tc-0.535,0.015-1.061,0.108-1.586,0.3c-1.264,0.463-2.264,1.388-2.815,2.604c-0.262,0.551-0.398,1.133-0.448,1.72\tC9.79,7.905,7.677,5.873,5.076,5.82C6.501,5.208,8.153,4.875,9.94,4.875H9.977z\"/></svg>",
|
||||
"tumblr": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6.885,8.598c0,0,0,3.393,0,4.996c0,0.282,0,0.66,0.094,0.942c0.377,1.509,1.131,2.545,2.545,3.11 c1.319,0.472,2.356,0.472,3.676,0c0.565-0.188,1.132-0.659,1.132-0.659l-0.849-2.263c0,0-1.036,0.378-1.603,0.283 c-0.565-0.094-1.226-0.66-1.226-1.508c0-1.603,0-4.902,0-4.902h2.828V5.771h-2.828V2H8.205c0,0-0.094,0.66-0.188,0.942 C7.828,3.791,7.262,4.733,6.603,5.394C5.848,6.147,5,6.43,5,6.43v2.168H6.885z\"/></svg>",
|
||||
"tv": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"7\" y=\"16\" width=\"6\" height=\"1\"/><rect fill=\"none\" stroke=\"#000\" x=\".5\" y=\"3.5\" width=\"19\" height=\"11\"/></svg>",
|
||||
"twitch": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M5.23,1,2,4.23V15.85H5.88v3.23L9.1,15.85h2.59L17.5,10V1Zm11,8.4L13.62,12H11L8.78,14.24V12H5.88V2.29H16.21Z\"/><rect x=\"12.98\" y=\"4.55\" width=\"1.29\" height=\"3.88\"/><rect x=\"9.43\" y=\"4.55\" width=\"1.29\" height=\"3.88\"/></svg>",
|
||||
"twitter": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M19,4.74 C18.339,5.029 17.626,5.229 16.881,5.32 C17.644,4.86 18.227,4.139 18.503,3.28 C17.79,3.7 17.001,4.009 16.159,4.17 C15.485,3.45 14.526,3 13.464,3 C11.423,3 9.771,4.66 9.771,6.7 C9.771,6.99 9.804,7.269 9.868,7.539 C6.795,7.38 4.076,5.919 2.254,3.679 C1.936,4.219 1.754,4.86 1.754,5.539 C1.754,6.82 2.405,7.95 3.397,8.61 C2.79,8.589 2.22,8.429 1.723,8.149 L1.723,8.189 C1.723,9.978 2.997,11.478 4.686,11.82 C4.376,11.899 4.049,11.939 3.713,11.939 C3.475,11.939 3.245,11.919 3.018,11.88 C3.49,13.349 4.852,14.419 6.469,14.449 C5.205,15.429 3.612,16.019 1.882,16.019 C1.583,16.019 1.29,16.009 1,15.969 C2.635,17.019 4.576,17.629 6.662,17.629 C13.454,17.629 17.17,12 17.17,7.129 C17.17,6.969 17.166,6.809 17.157,6.649 C17.879,6.129 18.504,5.478 19,4.74\"/></svg>",
|
||||
"uikit": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon points=\"14.4,3.1 11.3,5.1 15,7.3 15,12.9 10,15.7 5,12.9 5,8.5 2,6.8 2,14.8 9.9,19.5 18,14.8 18,5.3\"/><polygon points=\"9.8,4.2 6.7,2.4 9.8,0.4 12.9,2.3\"/></svg>",
|
||||
"unlock": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect fill=\"none\" stroke=\"#000\" x=\"3.5\" y=\"8.5\" width=\"13\" height=\"10\"/><path fill=\"none\" stroke=\"#000\" d=\"M6.5,8.5 L6.5,4.9 C6.5,3 8.1,1.5 10,1.5 C11.9,1.5 13.5,3 13.5,4.9\"/></svg>",
|
||||
"upload": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" points=\"5 8 9.5 3.5 14 8\"/><rect x=\"3\" y=\"17\" width=\"13\" height=\"1\"/><line fill=\"none\" stroke=\"#000\" x1=\"9.5\" y1=\"15\" x2=\"9.5\" y2=\"4\"/></svg>",
|
||||
"user": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"9.9\" cy=\"6.4\" r=\"4.4\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2\"/></svg>",
|
||||
"users": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"7.7\" cy=\"8.6\" r=\"3.5\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M1,18.1 C1.7,14.6 4.4,12.1 7.6,12.1 C10.9,12.1 13.7,14.8 14.3,18.3\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M11.4,4 C12.8,2.4 15.4,2.8 16.3,4.7 C17.2,6.6 15.7,8.9 13.6,8.9 C16.5,8.9 18.8,11.3 19.2,14.1\"/></svg>",
|
||||
"video-camera": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><polygon fill=\"none\" stroke=\"#000\" points=\"17.5 6.9 17.5 13.1 13.5 10.4 13.5 14.5 2.5 14.5 2.5 5.5 13.5 5.5 13.5 9.6 17.5 6.9\"/></svg>",
|
||||
"vimeo": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M2.065,7.59C1.84,7.367,1.654,7.082,1.468,6.838c-0.332-0.42-0.137-0.411,0.274-0.772c1.026-0.91,2.004-1.896,3.127-2.688 c1.017-0.713,2.365-1.173,3.286-0.039c0.849,1.045,0.869,2.629,1.084,3.891c0.215,1.309,0.421,2.648,0.88,3.901 c0.127,0.352,0.37,1.018,0.81,1.074c0.567,0.078,1.145-0.917,1.408-1.289c0.684-0.987,1.611-2.317,1.494-3.587 c-0.115-1.349-1.572-1.095-2.482-0.773c0.146-1.514,1.555-3.216,2.912-3.792c1.439-0.597,3.579-0.587,4.302,1.036 c0.772,1.759,0.078,3.802-0.763,5.396c-0.918,1.731-2.1,3.333-3.363,4.829c-1.114,1.329-2.432,2.787-4.093,3.422 c-1.897,0.723-3.021-0.686-3.667-2.318c-0.705-1.777-1.056-3.771-1.565-5.621C4.898,8.726,4.644,7.836,4.136,7.191 C3.473,6.358,2.72,7.141,2.065,7.59C1.977,7.502,2.115,7.551,2.065,7.59L2.065,7.59z\"/></svg>",
|
||||
"warning": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"10\" cy=\"14\" r=\"1\"/><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"10\" cy=\"10\" r=\"9\"/><path d=\"M10.97,7.72 C10.85,9.54 10.56,11.29 10.56,11.29 C10.51,11.87 10.27,12 9.99,12 C9.69,12 9.49,11.87 9.43,11.29 C9.43,11.29 9.16,9.54 9.03,7.72 C8.96,6.54 9.03,6 9.03,6 C9.03,5.45 9.46,5.02 9.99,5 C10.53,5.01 10.97,5.44 10.97,6 C10.97,6 11.04,6.54 10.97,7.72 L10.97,7.72 Z\"/></svg>",
|
||||
"whatsapp": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M16.7,3.3c-1.8-1.8-4.1-2.8-6.7-2.8c-5.2,0-9.4,4.2-9.4,9.4c0,1.7,0.4,3.3,1.3,4.7l-1.3,4.9l5-1.3c1.4,0.8,2.9,1.2,4.5,1.2 l0,0l0,0c5.2,0,9.4-4.2,9.4-9.4C19.5,7.4,18.5,5,16.7,3.3 M10.1,17.7L10.1,17.7c-1.4,0-2.8-0.4-4-1.1l-0.3-0.2l-3,0.8l0.8-2.9 l-0.2-0.3c-0.8-1.2-1.2-2.7-1.2-4.2c0-4.3,3.5-7.8,7.8-7.8c2.1,0,4.1,0.8,5.5,2.3c1.5,1.5,2.3,3.4,2.3,5.5 C17.9,14.2,14.4,17.7,10.1,17.7 M14.4,11.9c-0.2-0.1-1.4-0.7-1.6-0.8c-0.2-0.1-0.4-0.1-0.5,0.1c-0.2,0.2-0.6,0.8-0.8,0.9 c-0.1,0.2-0.3,0.2-0.5,0.1c-0.2-0.1-1-0.4-1.9-1.2c-0.7-0.6-1.2-1.4-1.3-1.6c-0.1-0.2,0-0.4,0.1-0.5C8,8.8,8.1,8.7,8.2,8.5 c0.1-0.1,0.2-0.2,0.2-0.4c0.1-0.2,0-0.3,0-0.4C8.4,7.6,7.9,6.5,7.7,6C7.5,5.5,7.3,5.6,7.2,5.6c-0.1,0-0.3,0-0.4,0 c-0.2,0-0.4,0.1-0.6,0.3c-0.2,0.2-0.8,0.8-0.8,2c0,1.2,0.8,2.3,1,2.4c0.1,0.2,1.7,2.5,4,3.5c0.6,0.2,1,0.4,1.3,0.5 c0.6,0.2,1.1,0.2,1.5,0.1c0.5-0.1,1.4-0.6,1.6-1.1c0.2-0.5,0.2-1,0.1-1.1C14.8,12.1,14.6,12,14.4,11.9\"/></svg>",
|
||||
"wordpress": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10,0.5c-5.2,0-9.5,4.3-9.5,9.5s4.3,9.5,9.5,9.5c5.2,0,9.5-4.3,9.5-9.5S15.2,0.5,10,0.5L10,0.5L10,0.5z M15.6,3.9h-0.1 c-0.8,0-1.4,0.7-1.4,1.5c0,0.7,0.4,1.3,0.8,1.9c0.3,0.6,0.7,1.3,0.7,2.3c0,0.7-0.3,1.5-0.6,2.7L14.1,15l-3-8.9 c0.5,0,0.9-0.1,0.9-0.1C12.5,6,12.5,5.3,12,5.4c0,0-1.3,0.1-2.2,0.1C9,5.5,7.7,5.4,7.7,5.4C7.2,5.3,7.2,6,7.6,6c0,0,0.4,0.1,0.9,0.1 l1.3,3.5L8,15L5,6.1C5.5,6.1,5.9,6,5.9,6C6.4,6,6.3,5.3,5.9,5.4c0,0-1.3,0.1-2.2,0.1c-0.2,0-0.3,0-0.5,0c1.5-2.2,4-3.7,6.9-3.7 C12.2,1.7,14.1,2.6,15.6,3.9L15.6,3.9L15.6,3.9z M2.5,6.6l3.9,10.8c-2.7-1.3-4.6-4.2-4.6-7.4C1.8,8.8,2,7.6,2.5,6.6L2.5,6.6L2.5,6.6 z M10.2,10.7l2.5,6.9c0,0,0,0.1,0.1,0.1C11.9,18,11,18.2,10,18.2c-0.8,0-1.6-0.1-2.3-0.3L10.2,10.7L10.2,10.7L10.2,10.7z M14.2,17.1 l2.5-7.3c0.5-1.2,0.6-2.1,0.6-2.9c0-0.3,0-0.6-0.1-0.8c0.6,1.2,1,2.5,1,4C18.3,13,16.6,15.7,14.2,17.1L14.2,17.1L14.2,17.1z\"/></svg>",
|
||||
"world": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"none\" stroke=\"#000\" d=\"M1,10.5 L19,10.5\"/><path fill=\"none\" stroke=\"#000\" d=\"M2.35,15.5 L17.65,15.5\"/><path fill=\"none\" stroke=\"#000\" d=\"M2.35,5.5 L17.523,5.5\"/><path fill=\"none\" stroke=\"#000\" d=\"M10,19.46 L9.98,19.46 C7.31,17.33 5.61,14.141 5.61,10.58 C5.61,7.02 7.33,3.83 10,1.7 C10.01,1.7 9.99,1.7 10,1.7 L10,1.7 C12.67,3.83 14.4,7.02 14.4,10.58 C14.4,14.141 12.67,17.33 10,19.46 L10,19.46 L10,19.46 L10,19.46 Z\"/><circle fill=\"none\" stroke=\"#000\" cx=\"10\" cy=\"10.5\" r=\"9\"/></svg>",
|
||||
"xing": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M4.4,4.56 C4.24,4.56 4.11,4.61 4.05,4.72 C3.98,4.83 3.99,4.97 4.07,5.12 L5.82,8.16 L5.82,8.17 L3.06,13.04 C2.99,13.18 2.99,13.33 3.06,13.44 C3.12,13.55 3.24,13.62 3.4,13.62 L6,13.62 C6.39,13.62 6.57,13.36 6.71,13.12 C6.71,13.12 9.41,8.35 9.51,8.16 C9.49,8.14 7.72,5.04 7.72,5.04 C7.58,4.81 7.39,4.56 6.99,4.56 L4.4,4.56 L4.4,4.56 Z\"/><path d=\"M15.3,1 C14.91,1 14.74,1.25 14.6,1.5 C14.6,1.5 9.01,11.42 8.82,11.74 C8.83,11.76 12.51,18.51 12.51,18.51 C12.64,18.74 12.84,19 13.23,19 L15.82,19 C15.98,19 16.1,18.94 16.16,18.83 C16.23,18.72 16.23,18.57 16.16,18.43 L12.5,11.74 L12.5,11.72 L18.25,1.56 C18.32,1.42 18.32,1.27 18.25,1.16 C18.21,1.06 18.08,1 17.93,1 L15.3,1 L15.3,1 Z\"/></svg>",
|
||||
"yelp": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M17.175,14.971c-0.112,0.77-1.686,2.767-2.406,3.054c-0.246,0.1-0.487,0.076-0.675-0.069\tc-0.122-0.096-2.446-3.859-2.446-3.859c-0.194-0.293-0.157-0.682,0.083-0.978c0.234-0.284,0.581-0.393,0.881-0.276\tc0.016,0.01,4.21,1.394,4.332,1.482c0.178,0.148,0.263,0.379,0.225,0.646L17.175,14.971L17.175,14.971z M11.464,10.789\tc-0.203-0.307-0.199-0.666,0.009-0.916c0,0,2.625-3.574,2.745-3.657c0.203-0.135,0.452-0.141,0.69-0.025\tc0.691,0.335,2.085,2.405,2.167,3.199v0.027c0.024,0.271-0.082,0.491-0.273,0.623c-0.132,0.083-4.43,1.155-4.43,1.155\tc-0.322,0.096-0.68-0.06-0.882-0.381L11.464,10.789z M9.475,9.563C9.32,9.609,8.848,9.757,8.269,8.817c0,0-3.916-6.16-4.007-6.351\tc-0.057-0.212,0.011-0.455,0.202-0.65C5.047,1.211,8.21,0.327,9.037,0.529c0.27,0.069,0.457,0.238,0.522,0.479\tc0.047,0.266,0.433,5.982,0.488,7.264C10.098,9.368,9.629,9.517,9.475,9.563z M9.927,19.066c-0.083,0.225-0.273,0.373-0.54,0.421\tc-0.762,0.13-3.15-0.751-3.647-1.342c-0.096-0.131-0.155-0.262-0.167-0.394c-0.011-0.095,0-0.189,0.036-0.272\tc0.061-0.155,2.917-3.538,2.917-3.538c0.214-0.272,0.595-0.355,0.952-0.213c0.345,0.13,0.56,0.428,0.536,0.749\tC10.014,14.479,9.977,18.923,9.927,19.066z M3.495,13.912c-0.235-0.009-0.444-0.148-0.568-0.382c-0.089-0.17-0.151-0.453-0.19-0.794\tC2.63,11.701,2.761,10.144,3.07,9.648c0.145-0.226,0.357-0.345,0.592-0.336c0.154,0,4.255,1.667,4.255,1.667\tc0.321,0.118,0.521,0.453,0.5,0.833c-0.023,0.37-0.236,0.655-0.551,0.738L3.495,13.912z\"/></svg>",
|
||||
"youtube": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M15,4.1c1,0.1,2.3,0,3,0.8c0.8,0.8,0.9,2.1,0.9,3.1C19,9.2,19,10.9,19,12c-0.1,1.1,0,2.4-0.5,3.4c-0.5,1.1-1.4,1.5-2.5,1.6 c-1.2,0.1-8.6,0.1-11,0c-1.1-0.1-2.4-0.1-3.2-1c-0.7-0.8-0.7-2-0.8-3C1,11.8,1,10.1,1,8.9c0-1.1,0-2.4,0.5-3.4C2,4.5,3,4.3,4.1,4.2 C5.3,4.1,12.6,4,15,4.1z M8,7.5v6l5.5-3L8,7.5z\"/></svg>"
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined' && window.UIkit) {
|
||||
window.UIkit.use(plugin);
|
||||
}
|
||||
|
||||
return plugin;
|
||||
|
||||
})));
|
3
week-07/project/administrator/media/js/uikit-icons.min.js
vendored
Normal file
3
week-07/project/administrator/media/js/uikit-icons.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12368
week-07/project/administrator/media/js/uikit.js
Normal file
12368
week-07/project/administrator/media/js/uikit.js
Normal file
File diff suppressed because it is too large
Load Diff
3
week-07/project/administrator/media/js/uikit.min.js
vendored
Normal file
3
week-07/project/administrator/media/js/uikit.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
week-07/project/administrator/media/mix-manifest.json
Normal file
1
week-07/project/administrator/media/mix-manifest.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
1
week-07/project/administrator/media/sri-manifest.json
Normal file
1
week-07/project/administrator/media/sri-manifest.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
72
week-07/project/composer.json
Normal file
72
week-07/project/composer.json
Normal file
@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "octoleo/cms",
|
||||
"type": "project",
|
||||
"description": "Octoleo CMS",
|
||||
"keywords": [
|
||||
"octoleo",
|
||||
"cms"
|
||||
],
|
||||
"homepage": "https://github.com/mychamplain",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"platform": {
|
||||
"php": "7.2.5"
|
||||
},
|
||||
"vendor-dir": "libraries/vendor",
|
||||
"github-protocols": ["https"],
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Octoleo\\CMS\\": "libraries/src/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"ext-json": "*",
|
||||
"joomla/application": "~2.0",
|
||||
"joomla/archive": "~2.0",
|
||||
"joomla/authentication": "~2.0",
|
||||
"joomla/console": "~2.0",
|
||||
"joomla/controller": "~2.0",
|
||||
"joomla/crypt": "~2.0",
|
||||
"joomla/data": "~2.0",
|
||||
"joomla/database": "~2.0",
|
||||
"joomla/di": "~2.0",
|
||||
"joomla/event": "~2.0",
|
||||
"joomla/filter": "~2.0",
|
||||
"joomla/filesystem": "~2.0",
|
||||
"joomla/http": "~2.0",
|
||||
"joomla/input": "~2.0",
|
||||
"joomla/model": "~2.0",
|
||||
"joomla/preload": "~2.0",
|
||||
"joomla/ldap": "~2.0",
|
||||
"joomla/oauth1": "~2.0",
|
||||
"joomla/oauth2": "~2.0",
|
||||
"joomla/registry": "~2.0",
|
||||
"joomla/renderer": "~2.0",
|
||||
"joomla/router": "~2.0",
|
||||
"joomla/session": "~2.0",
|
||||
"joomla/string": "~2.0",
|
||||
"joomla/uri": "~2.0",
|
||||
"joomla/utilities": "~2.0",
|
||||
"algo26-matthias/idna-convert": "~3.0",
|
||||
"joomla/view": "~2.0",
|
||||
"laminas/laminas-diactoros": "^2.3",
|
||||
"monolog/monolog": "^2.1",
|
||||
"psr/link": "^1.0",
|
||||
"ramsey/uuid": "^4.0.1",
|
||||
"robmorgan/phinx": "^0.12.3",
|
||||
"defuse/php-encryption": "^2.0",
|
||||
"symfony/asset": "^5.1.2",
|
||||
"symfony/process": "^5.1.2",
|
||||
"symfony/web-link": "^5.1.2",
|
||||
"symfony/yaml": "^5.1.2",
|
||||
"theiconic/php-ga-measurement-protocol": "^2.7.2",
|
||||
"twig/twig": "^2.13",
|
||||
"phpmailer/phpmailer": "~6.0"
|
||||
}
|
||||
}
|
5393
week-07/project/composer.lock
generated
Normal file
5393
week-07/project/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
BIN
week-07/project/favicon.ico
Normal file
BIN
week-07/project/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
52
week-07/project/htaccess.txt
Normal file
52
week-07/project/htaccess.txt
Normal file
@ -0,0 +1,52 @@
|
||||
###########################################
|
||||
# ======= Enable the Rewrite Engine =======
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
###########################################
|
||||
|
||||
|
||||
###########################################
|
||||
# ======= No directory listings =======
|
||||
|
||||
IndexIgnore *
|
||||
Options +FollowSymLinks
|
||||
Options -Indexes
|
||||
|
||||
###########################################
|
||||
|
||||
|
||||
###########################################
|
||||
# ======== Remove multiple slashes ========
|
||||
|
||||
RewriteCond %{HTTP_HOST} !=""
|
||||
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR]
|
||||
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$
|
||||
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]
|
||||
|
||||
###########################################
|
||||
|
||||
|
||||
###########################################
|
||||
# ======== Remove trailing slashes ========
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.*)/$ /$1 [R=301,L]
|
||||
|
||||
###########################################
|
||||
|
||||
|
||||
###########################################
|
||||
# ======== SEF URL Routing ========
|
||||
|
||||
# If the request is not for a static asset
|
||||
RewriteCond %{REQUEST_URI} !^/media/
|
||||
|
||||
# Or for a file that exists in the web directory
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
# Rewrite the request to run the application
|
||||
RewriteRule (.*) index.php
|
||||
|
||||
###########################################
|
96
week-07/project/includes/app.php
Normal file
96
week-07/project/includes/app.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// Option to override defines from root folder
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L15
|
||||
if (file_exists(dirname(__DIR__) . '/defines.php'))
|
||||
{
|
||||
include_once dirname(__DIR__) . '/defines.php';
|
||||
}
|
||||
|
||||
// Load the default defines
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L20
|
||||
if (!defined('_LDEFINES'))
|
||||
{
|
||||
define('LPATH_BASE', dirname(__DIR__));
|
||||
require_once LPATH_BASE . '/includes/defines.php';
|
||||
}
|
||||
|
||||
// Check for presence of vendor dependencies not included in the git repository
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L26
|
||||
if (!file_exists(LPATH_LIBRARIES . '/vendor/autoload.php'))
|
||||
{
|
||||
echo file_get_contents(LPATH_ROOT . '/templates/system/build_incomplete.html');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// Load configuration (or install)
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L34
|
||||
require_once LPATH_BASE . '/includes/framework.php';
|
||||
|
||||
// Wrap in a try/catch so we can display an error if need be
|
||||
try
|
||||
{
|
||||
$container = (new Joomla\DI\Container)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\SiteApplicationProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\ConfigurationProvider(LPATH_CONFIGURATION . '/octoconfig.php'))
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\InputProvider)
|
||||
->registerServiceProvider(new Joomla\Database\Service\DatabaseProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\EventProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\HttpProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\LoggingProvider)
|
||||
->registerServiceProvider(new Joomla\Preload\Service\PreloadProvider)
|
||||
->registerServiceProvider(new Octoleo\CMS\Service\SiteTemplatingProvider);
|
||||
|
||||
// Alias the web application to Octoleo's base application class as this is the primary application for the environment
|
||||
$container->alias(Joomla\Application\AbstractApplication::class, Joomla\Application\AbstractWebApplication::class);
|
||||
|
||||
// Alias the web logger to the PSR-3 interface as this is the primary logger for the environment
|
||||
$container->alias(Monolog\Logger::class, 'monolog.logger.application.web')
|
||||
->alias(Psr\Log\LoggerInterface::class, 'monolog.logger.application.web');
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
error_log($e);
|
||||
|
||||
header('HTTP/1.1 500 Internal Server Error', null, 500);
|
||||
echo '<html><head><title>Container Initialization Error</title></head><body><h1>Container Initialization Error</h1><p>An error occurred while creating the DI container: ' . $e->getMessage() . '</p></body></html>';
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Execute the application
|
||||
// source: https://github.com/joomla/framework.joomla.org/blob/master/www/index.php#L85
|
||||
try
|
||||
{
|
||||
$app = $container->get(Joomla\Application\AbstractApplication::class);
|
||||
// Set the application as global app
|
||||
\Octoleo\CMS\Factory::$application = $app;
|
||||
// Execute the application.
|
||||
$app->execute();
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
error_log($e);
|
||||
|
||||
if (!headers_sent())
|
||||
{
|
||||
header('HTTP/1.1 500 Internal Server Error', null, 500);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
}
|
||||
|
||||
echo '<html><head><title>Application Error</title></head><body><h1>Application Error</h1><p>An error occurred while executing the application: ' . $e->getMessage() . '</p></body></html>';
|
||||
|
||||
exit(1);
|
||||
}
|
||||
// I am just playing around... ((ewɘ))yn purring
|
23
week-07/project/includes/defines.php
Normal file
23
week-07/project/includes/defines.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// Global definitions
|
||||
$parts = explode(DIRECTORY_SEPARATOR, LPATH_BASE);
|
||||
|
||||
// Defines.
|
||||
define('LPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
|
||||
define('LPATH_SITE', LPATH_ROOT);
|
||||
define('LPATH_CONFIGURATION', LPATH_ROOT);
|
||||
define('LPATH_ADMINISTRATOR', LPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
|
||||
define('LPATH_LIBRARIES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
|
||||
define('LPATH_INSTALLATION', LPATH_ROOT . DIRECTORY_SEPARATOR . 'installation');
|
||||
define('LPATH_TEMPLATES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'templates/site');
|
35
week-07/project/includes/framework.php
Normal file
35
week-07/project/includes/framework.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// System includes
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/framework.php#L14
|
||||
require_once LPATH_LIBRARIES . '/bootstrap.php';
|
||||
|
||||
// Installation check, and check on removal of the installation directory.
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/framework.php#L17
|
||||
if (!file_exists(LPATH_CONFIGURATION . '/octoconfig.php')
|
||||
|| (filesize(LPATH_CONFIGURATION . '/octoconfig.php') < 10)
|
||||
|| (file_exists(LPATH_INSTALLATION . '/index.php')))
|
||||
{
|
||||
if (file_exists(LPATH_INSTALLATION . '/index.php'))
|
||||
{
|
||||
header('Location: ' . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php')) . 'installation/index.php');
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'No configuration file found and no installation code available. Exiting...';
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
1
week-07/project/includes/index.html
Normal file
1
week-07/project/includes/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
35
week-07/project/index.php
Normal file
35
week-07/project/index.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 3rd April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// NOTE: This file should remain compatible with PHP 5.2 to allow us to run our PHP minimum check and show a friendly error message
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/index.php#L9
|
||||
|
||||
// Define the application's minimum supported PHP version as a constant, so it can be referenced within the application.
|
||||
define('OCTOLEO_MINIMUM_PHP', '7.2.5');
|
||||
|
||||
if (version_compare(PHP_VERSION, OCTOLEO_MINIMUM_PHP, '<'))
|
||||
{
|
||||
die(
|
||||
str_replace(
|
||||
'{{phpversion}}',
|
||||
OCTOLEO_MINIMUM_PHP,
|
||||
file_get_contents(dirname(__FILE__) . '/templates/system/incompatible.html')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant that is checked in included files to prevent direct access.
|
||||
*/
|
||||
define('_LEXEC', 1);
|
||||
|
||||
// We must setup some house rules, since we can't have all
|
||||
// this code just doing what it wants can we?... <<eWɘ>>yn growling
|
||||
require_once dirname(__FILE__) . '/includes/app.php';
|
31
week-07/project/installation/includes/app.php
Normal file
31
week-07/project/installation/includes/app.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// Option to override defines from root folder
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L15
|
||||
if (file_exists(dirname(__DIR__) . '/defines.php'))
|
||||
{
|
||||
include_once dirname(__DIR__) . '/defines.php';
|
||||
}
|
||||
|
||||
// Load the default defines
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L20
|
||||
if (!defined('_LDEFINES'))
|
||||
{
|
||||
define('LPATH_BASE', dirname(__DIR__));
|
||||
require_once LPATH_BASE . '/includes/defines.php';
|
||||
}
|
||||
|
||||
// I have not yet had time to finish this part of the application (CMS)
|
||||
echo file_get_contents(LPATH_ROOT . '/templates/system/install_notice.html');
|
||||
|
||||
exit;
|
23
week-07/project/installation/includes/defines.php
Normal file
23
week-07/project/installation/includes/defines.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// Global definitions
|
||||
$parts = explode(DIRECTORY_SEPARATOR, LPATH_BASE);
|
||||
array_pop($parts);
|
||||
|
||||
// Defines.
|
||||
define('LPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
|
||||
define('LPATH_SITE', LPATH_ROOT);
|
||||
define('LPATH_CONFIGURATION', LPATH_ROOT);
|
||||
define('LPATH_ADMINISTRATOR', LPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
|
||||
define('LPATH_LIBRARIES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
|
||||
define('LPATH_INSTALLATION', LPATH_ROOT . DIRECTORY_SEPARATOR . 'installation');
|
41
week-07/project/installation/includes/framework.php
Normal file
41
week-07/project/installation/includes/framework.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// System includes
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/administrator/includes/framework.php#L14
|
||||
require_once LPATH_LIBRARIES . '/bootstrap.php';
|
||||
|
||||
// Installation check, and check on removal of the installation directory.
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/administrator/includes/framework.php#L17
|
||||
if (!file_exists(LPATH_CONFIGURATION . '/octoconfig.php')
|
||||
|| (filesize(LPATH_CONFIGURATION . '/octoconfig.php') < 10)
|
||||
|| (file_exists(LPATH_INSTALLATION . '/index.php')))
|
||||
{
|
||||
if (file_exists(LPATH_INSTALLATION . '/index.php'))
|
||||
{
|
||||
header('Location: ../installation/index.php');
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'No configuration file found and no installation code available. Exiting...';
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Pre-Load configuration. Don't remove the Output Buffering due to BOM issues.
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/administrator/includes/framework.php#L36
|
||||
ob_start();
|
||||
require_once LPATH_CONFIGURATION . '/octoconfig.php';
|
||||
ob_end_clean();
|
35
week-07/project/installation/index.php
Normal file
35
week-07/project/installation/index.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// NOTE: This file should remain compatible with PHP 5.2 to allow us to run our PHP minimum check and show a friendly error message
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/index.php#L9
|
||||
|
||||
// Define the application's minimum supported PHP version as a constant, so it can be referenced within the application.
|
||||
define('OCTOLEO_MINIMUM_PHP', '7.2.5');
|
||||
|
||||
if (version_compare(PHP_VERSION, OCTOLEO_MINIMUM_PHP, '<'))
|
||||
{
|
||||
die(
|
||||
str_replace(
|
||||
'{{phpversion}}',
|
||||
OCTOLEO_MINIMUM_PHP,
|
||||
file_get_contents(dirname(__FILE__) . '/../templates/system/incompatible.html')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant that is checked in included files to prevent direct access.
|
||||
*/
|
||||
define('_LEXEC', 1);
|
||||
|
||||
// We must setup some house rules, since we can't have all
|
||||
// this code just doing what it wants can we.... <<eWɘ>>yn growling
|
||||
require_once dirname(__FILE__) . '/includes/app.php';
|
9
week-07/project/libraries/.htaccess
Normal file
9
week-07/project/libraries/.htaccess
Normal file
@ -0,0 +1,9 @@
|
||||
# Apache 2.4+
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
|
||||
# Apache 2.0-2.2
|
||||
<IfModule !mod_authz_core.c>
|
||||
Deny from all
|
||||
</IfModule>
|
48
week-07/project/libraries/bootstrap.php
Normal file
48
week-07/project/libraries/bootstrap.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_LEXEC') or die;
|
||||
|
||||
// Set the platform root path as a constant if necessary.
|
||||
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/bootstrap.php#L12
|
||||
defined('LPATH_PLATFORM') or define('LPATH_PLATFORM', __DIR__);
|
||||
|
||||
// Detect the native operating system type.
|
||||
$os = strtoupper(substr(PHP_OS, 0, 3));
|
||||
|
||||
defined('IS_WIN') or define('IS_WIN', ($os === 'WIN'));
|
||||
defined('IS_UNIX') or define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')));
|
||||
|
||||
// Import the library loader if necessary.
|
||||
if (!class_exists('LLoader'))
|
||||
{
|
||||
require_once LPATH_PLATFORM . '/loader.php';
|
||||
|
||||
// If JLoader still does not exist panic.
|
||||
if (!class_exists('LLoader'))
|
||||
{
|
||||
throw new RuntimeException('Octoleo Platform not loaded.');
|
||||
}
|
||||
}
|
||||
|
||||
// Setup the autoloaders.
|
||||
LLoader::setup();
|
||||
|
||||
// Create the Composer autoloader
|
||||
/** @var \Composer\Autoload\ClassLoader $loader */
|
||||
$loader = require LPATH_LIBRARIES . '/vendor/autoload.php';
|
||||
|
||||
// We need to pull our decorated class loader into memory before unregistering Composer's loader
|
||||
class_exists('\\Octoleo\\CMS\\Autoload\\ClassLoader');
|
||||
|
||||
$loader->unregister();
|
||||
|
||||
// Decorate Composer autoloader
|
||||
spl_autoload_register([new \Octoleo\CMS\Autoload\ClassLoader($loader), 'loadClass'], true, true);
|
599
week-07/project/libraries/loader.php
Normal file
599
week-07/project/libraries/loader.php
Normal file
@ -0,0 +1,599 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* Joomla! Content Management System
|
||||
*
|
||||
* @source https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/loader.php
|
||||
* @adapted Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
*
|
||||
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
**/
|
||||
|
||||
defined('LPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Static class to handle loading of libraries.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class LLoader
|
||||
{
|
||||
/**
|
||||
* Container for already imported library paths.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.7.0
|
||||
*/
|
||||
protected static $classes = array();
|
||||
|
||||
/**
|
||||
* Container for already imported library paths.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.7.0
|
||||
*/
|
||||
protected static $imported = array();
|
||||
|
||||
/**
|
||||
* Container for registered library class prefixes and path lookups.
|
||||
*
|
||||
* @var array
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected static $prefixes = array();
|
||||
|
||||
/**
|
||||
* Holds proxy classes and the class names the proxy.
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2
|
||||
*/
|
||||
protected static $classAliases = array();
|
||||
|
||||
/**
|
||||
* Holds the inverse lookup for proxy classes and the class names the proxy.
|
||||
*
|
||||
* @var array
|
||||
* @since 3.4
|
||||
*/
|
||||
protected static $classAliasesInverse = array();
|
||||
|
||||
/**
|
||||
* Container for namespace => path map.
|
||||
*
|
||||
* @var array
|
||||
* @since 3.1.4
|
||||
*/
|
||||
protected static $namespaces = array();
|
||||
|
||||
/**
|
||||
* Holds a reference for all deprecated aliases (mainly for use by a logging platform).
|
||||
*
|
||||
* @var array
|
||||
* @since 3.6.3
|
||||
*/
|
||||
protected static $deprecatedAliases = array();
|
||||
|
||||
/**
|
||||
* The root folders where extensions can be found.
|
||||
*
|
||||
* @var array
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected static $extensionRootFolders = array();
|
||||
|
||||
/**
|
||||
* Method to get the list of registered classes and their respective file paths for the autoloader.
|
||||
*
|
||||
* @return array The array of class => path values for the autoloader.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public static function getClassList()
|
||||
{
|
||||
return self::$classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the list of deprecated class aliases.
|
||||
*
|
||||
* @return array An associative array with deprecated class alias data.
|
||||
*
|
||||
* @since 3.6.3
|
||||
*/
|
||||
public static function getDeprecatedAliases()
|
||||
{
|
||||
return self::$deprecatedAliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the list of registered namespaces.
|
||||
*
|
||||
* @return array The array of namespace => path values for the autoloader.
|
||||
*
|
||||
* @since 3.1.4
|
||||
*/
|
||||
public static function getNamespaces()
|
||||
{
|
||||
return self::$namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the file for a class.
|
||||
*
|
||||
* @param string $class The class to be loaded.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public static function load($class)
|
||||
{
|
||||
// Sanitize class name.
|
||||
$key = strtolower($class);
|
||||
|
||||
// If the class already exists do nothing.
|
||||
if (class_exists($class, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the class is registered include the file.
|
||||
if (isset(self::$classes[$key]))
|
||||
{
|
||||
$found = (bool) include_once self::$classes[$key];
|
||||
|
||||
if ($found)
|
||||
{
|
||||
self::loadAliasFor($class);
|
||||
}
|
||||
|
||||
// If the class doesn't exists, we probably have a class alias available
|
||||
if (!class_exists($class, false))
|
||||
{
|
||||
// Search the alias class, first none namespaced and then namespaced
|
||||
$original = array_search($class, self::$classAliases) ? : array_search('\\' . $class, self::$classAliases);
|
||||
|
||||
// When we have an original and the class exists an alias should be created
|
||||
if ($original && class_exists($original, false))
|
||||
{
|
||||
class_alias($original, $class);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a class prefix with lookup path. This will allow developers to register library
|
||||
* packages with different class prefixes to the system autoloader. More than one lookup path
|
||||
* may be registered for the same class prefix, but if this method is called with the reset flag
|
||||
* set to true then any registered lookups for the given prefix will be overwritten with the current
|
||||
* lookup path. When loaded, prefix paths are searched in a "last in, first out" order.
|
||||
*
|
||||
* @param string $prefix The class prefix to register.
|
||||
* @param string $path Absolute file path to the library root where classes with the given prefix can be found.
|
||||
* @param boolean $reset True to reset the prefix with only the given lookup path.
|
||||
* @param boolean $prepend If true, push the path to the beginning of the prefix lookup paths array.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public static function registerPrefix($prefix, $path, $reset = false, $prepend = false)
|
||||
{
|
||||
// Verify the library path exists.
|
||||
if (!is_dir($path))
|
||||
{
|
||||
$path = (str_replace(LPATH_ROOT, '', $path) == $path) ? basename($path) : str_replace(LPATH_ROOT, '', $path);
|
||||
|
||||
throw new RuntimeException('Library path ' . $path . ' cannot be found.', 500);
|
||||
}
|
||||
|
||||
// If the prefix is not yet registered or we have an explicit reset flag then set set the path.
|
||||
if ($reset || !isset(self::$prefixes[$prefix]))
|
||||
{
|
||||
self::$prefixes[$prefix] = array($path);
|
||||
}
|
||||
// Otherwise we want to simply add the path to the prefix.
|
||||
else
|
||||
{
|
||||
if ($prepend)
|
||||
{
|
||||
array_unshift(self::$prefixes[$prefix], $path);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$prefixes[$prefix][] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Offers the ability for "just in time" usage of `class_alias()`.
|
||||
* You cannot overwrite an existing alias.
|
||||
*
|
||||
* @param string $alias The alias name to register.
|
||||
* @param string $original The original class to alias.
|
||||
* @param string|boolean $version The version in which the alias will no longer be present.
|
||||
*
|
||||
* @return boolean True if registration was successful. False if the alias already exists.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public static function registerAlias($alias, $original, $version = false)
|
||||
{
|
||||
// PHP is case insensitive so support all kind of alias combination
|
||||
$lowercasedAlias = strtolower($alias);
|
||||
|
||||
if (!isset(self::$classAliases[$lowercasedAlias]))
|
||||
{
|
||||
self::$classAliases[$lowercasedAlias] = $original;
|
||||
|
||||
$original = self::stripFirstBackslash($original);
|
||||
|
||||
if (!isset(self::$classAliasesInverse[$original]))
|
||||
{
|
||||
self::$classAliasesInverse[$original] = array($lowercasedAlias);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$classAliasesInverse[$original][] = $lowercasedAlias;
|
||||
}
|
||||
|
||||
// If given a version, log this alias as deprecated
|
||||
if ($version)
|
||||
{
|
||||
self::$deprecatedAliases[] = array('old' => $alias, 'new' => $original, 'version' => $version);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a namespace to the autoloader. When loaded, namespace paths are searched in a "last in, first out" order.
|
||||
*
|
||||
* @param string $namespace A case sensitive Namespace to register.
|
||||
* @param string $path A case sensitive absolute file path to the library root where classes of the given namespace can be found.
|
||||
* @param boolean $reset True to reset the namespace with only the given lookup path.
|
||||
* @param boolean $prepend If true, push the path to the beginning of the namespace lookup paths array.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @since 3.1.4
|
||||
*/
|
||||
public static function registerNamespace($namespace, $path, $reset = false, $prepend = false)
|
||||
{
|
||||
// Verify the library path exists.
|
||||
if (!is_dir($path))
|
||||
{
|
||||
$path = (str_replace(LPATH_ROOT, '', $path) == $path) ? basename($path) : str_replace(LPATH_ROOT, '', $path);
|
||||
|
||||
throw new RuntimeException('Library path ' . $path . ' cannot be found.', 500);
|
||||
}
|
||||
|
||||
// Trim leading and trailing backslashes from namespace, allowing "\Parent\Child", "Parent\Child\" and "\Parent\Child\" to be treated the same way.
|
||||
$namespace = trim($namespace, '\\');
|
||||
|
||||
// If the namespace is not yet registered or we have an explicit reset flag then set the path.
|
||||
if ($reset || !isset(self::$namespaces[$namespace]))
|
||||
{
|
||||
self::$namespaces[$namespace] = array($path);
|
||||
}
|
||||
|
||||
// Otherwise we want to simply add the path to the namespace.
|
||||
else
|
||||
{
|
||||
if ($prepend)
|
||||
{
|
||||
array_unshift(self::$namespaces[$namespace], $path);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$namespaces[$namespace][] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to setup the autoloaders for the Octoleo Platform.
|
||||
* Since the SPL autoloaders are called in a queue we will add our explicit
|
||||
* class-registration based loader first, then fall back on the autoloader based on conventions.
|
||||
* This will allow people to register a class in a specific location and override platform libraries
|
||||
* as was previously possible.
|
||||
*
|
||||
* @param boolean $enablePsr True to enable autoloading based on PSR-0.
|
||||
* @param boolean $enablePrefixes True to enable prefix based class loading (needed to auto load the Octoleo core).
|
||||
* @param boolean $enableClasses True to enable class map based class loading (needed to auto load the Octoleo core).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.1.4
|
||||
*/
|
||||
public static function setup($enablePsr = true, $enablePrefixes = true, $enableClasses = true)
|
||||
{
|
||||
if ($enableClasses)
|
||||
{
|
||||
// Register the class map based autoloader.
|
||||
spl_autoload_register(array('LLoader', 'load'));
|
||||
}
|
||||
|
||||
if ($enablePrefixes)
|
||||
{
|
||||
// Register the prefix autoloader.
|
||||
spl_autoload_register(array('LLoader', '_autoload'));
|
||||
}
|
||||
|
||||
if ($enablePsr)
|
||||
{
|
||||
// Register the PSR based autoloader.
|
||||
spl_autoload_register(array('LLoader', 'loadByPsr'));
|
||||
spl_autoload_register(array('LLoader', 'loadByAlias'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to autoload classes that are namespaced to the PSR-4 standard.
|
||||
*
|
||||
* @param string $class The fully qualified class name to autoload.
|
||||
*
|
||||
* @return boolean True on success, false otherwise.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @deprecated 5.0 Use LLoader::loadByPsr instead
|
||||
*/
|
||||
public static function loadByPsr4($class)
|
||||
{
|
||||
return self::loadByPsr($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to autoload classes that are namespaced to the PSR-4 standard.
|
||||
*
|
||||
* @param string $class The fully qualified class name to autoload.
|
||||
*
|
||||
* @return boolean True on success, false otherwise.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public static function loadByPsr($class)
|
||||
{
|
||||
$class = self::stripFirstBackslash($class);
|
||||
|
||||
// Find the location of the last NS separator.
|
||||
$pos = strrpos($class, '\\');
|
||||
|
||||
// If one is found, we're dealing with a NS'd class.
|
||||
if ($pos !== false)
|
||||
{
|
||||
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
|
||||
$className = substr($class, $pos + 1);
|
||||
}
|
||||
// If not, no need to parse path.
|
||||
else
|
||||
{
|
||||
$classPath = null;
|
||||
$className = $class;
|
||||
}
|
||||
|
||||
$classPath .= $className . '.php';
|
||||
|
||||
// Loop through registered namespaces until we find a match.
|
||||
foreach (self::$namespaces as $ns => $paths)
|
||||
{
|
||||
if (strpos($class, "{$ns}\\") === 0)
|
||||
{
|
||||
$nsPath = trim(str_replace('\\', DIRECTORY_SEPARATOR, $ns), DIRECTORY_SEPARATOR);
|
||||
|
||||
// Loop through paths registered to this namespace until we find a match.
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$classFilePath = realpath($path . DIRECTORY_SEPARATOR . substr_replace($classPath, '', 0, strlen($nsPath) + 1));
|
||||
|
||||
// We do not allow files outside the namespace root to be loaded
|
||||
if (strpos($classFilePath, realpath($path)) !== 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// We check for class_exists to handle case-sensitive file systems
|
||||
if (is_file($classFilePath) && !class_exists($class, false))
|
||||
{
|
||||
$found = (bool) include_once $classFilePath;
|
||||
|
||||
if ($found)
|
||||
{
|
||||
self::loadAliasFor($class);
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to autoload classes that have been aliased using the registerAlias method.
|
||||
*
|
||||
* @param string $class The fully qualified class name to autoload.
|
||||
*
|
||||
* @return boolean True on success, false otherwise.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public static function loadByAlias($class)
|
||||
{
|
||||
$class = strtolower(self::stripFirstBackslash($class));
|
||||
|
||||
if (isset(self::$classAliases[$class]))
|
||||
{
|
||||
// Force auto-load of the regular class
|
||||
class_exists(self::$classAliases[$class], true);
|
||||
|
||||
// Normally this shouldn't execute as the autoloader will execute applyAliasFor when the regular class is
|
||||
// auto-loaded above.
|
||||
if (!class_exists($class, false) && !interface_exists($class, false))
|
||||
{
|
||||
class_alias(self::$classAliases[$class], $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a class alias for an already loaded class, if a class alias was created for it.
|
||||
*
|
||||
* @param string $class We'll look for and register aliases for this (real) class name
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
public static function applyAliasFor($class)
|
||||
{
|
||||
$class = self::stripFirstBackslash($class);
|
||||
|
||||
if (isset(self::$classAliasesInverse[$class]))
|
||||
{
|
||||
foreach (self::$classAliasesInverse[$class] as $alias)
|
||||
{
|
||||
class_alias($class, $alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload a class based on name.
|
||||
*
|
||||
* @param string $class The class to be loaded.
|
||||
*
|
||||
* @return boolean True if the class was loaded, false otherwise.
|
||||
*
|
||||
* @since 1.7.3
|
||||
*/
|
||||
public static function _autoload($class)
|
||||
{
|
||||
foreach (self::$prefixes as $prefix => $lookup)
|
||||
{
|
||||
$chr = strlen($prefix) < strlen($class) ? $class[strlen($prefix)] : 0;
|
||||
|
||||
if (strpos($class, $prefix) === 0 && ($chr === strtoupper($chr)))
|
||||
{
|
||||
return self::_load(substr($class, strlen($prefix)), $lookup);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a class based on name and lookup array.
|
||||
*
|
||||
* @param string $class The class to be loaded (without prefix).
|
||||
* @param array $lookup The array of base paths to use for finding the class file.
|
||||
*
|
||||
* @return boolean True if the class was loaded, false otherwise.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
private static function _load($class, $lookup)
|
||||
{
|
||||
// Split the class name into parts separated by camelCase.
|
||||
$parts = preg_split('/(?<=[a-z0-9])(?=[A-Z])/x', $class);
|
||||
$partsCount = count($parts);
|
||||
|
||||
foreach ($lookup as $base)
|
||||
{
|
||||
// Generate the path based on the class name parts.
|
||||
$path = realpath($base . '/' . implode('/', array_map('strtolower', $parts)) . '.php');
|
||||
|
||||
// Load the file if it exists and is in the lookup path.
|
||||
if (strpos($path, realpath($base)) === 0 && is_file($path))
|
||||
{
|
||||
$found = (bool) include_once $path;
|
||||
|
||||
if ($found)
|
||||
{
|
||||
self::loadAliasFor($class);
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
// Backwards compatibility patch
|
||||
|
||||
// If there is only one part we want to duplicate that part for generating the path.
|
||||
if ($partsCount === 1)
|
||||
{
|
||||
// Generate the path based on the class name parts.
|
||||
$path = realpath($base . '/' . implode('/', array_map('strtolower', array($parts[0], $parts[0]))) . '.php');
|
||||
|
||||
// Load the file if it exists and is in the lookup path.
|
||||
if (strpos($path, realpath($base)) === 0 && is_file($path))
|
||||
{
|
||||
$found = (bool) include_once $path;
|
||||
|
||||
if ($found)
|
||||
{
|
||||
self::loadAliasFor($class);
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the aliases for the given class.
|
||||
*
|
||||
* @param string $class The class.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.8.0
|
||||
*/
|
||||
private static function loadAliasFor($class)
|
||||
{
|
||||
if (!array_key_exists($class, self::$classAliasesInverse))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (self::$classAliasesInverse[$class] as $alias)
|
||||
{
|
||||
// Force auto-load of the alias class
|
||||
class_exists($alias, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips the first backslash from the given class if present.
|
||||
*
|
||||
* @param string $class The class to strip the first prefix from.
|
||||
*
|
||||
* @return string The striped class name.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*/
|
||||
private static function stripFirstBackslash($class)
|
||||
{
|
||||
return $class && $class[0] === '\\' ? substr($class, 1) : $class;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Framework Website
|
||||
*
|
||||
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Application;
|
||||
|
||||
use Joomla\Application\AbstractWebApplication;
|
||||
use Joomla\Application\Controller\ControllerResolverInterface;
|
||||
use Joomla\Application\SessionAwareWebApplicationInterface;
|
||||
use Joomla\Application\SessionAwareWebApplicationTrait;
|
||||
use Joomla\Application\Web\WebClient;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Router\RouterInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Site application class
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/WebApplication.php
|
||||
*/
|
||||
class AdminApplication extends AbstractWebApplication implements SessionAwareWebApplicationInterface, SessionMessageAwareInterface, IdentityAwareInterface
|
||||
{
|
||||
use IdentityAwareTrait, SessionMessageAwareTrait, SessionAwareWebApplicationTrait;
|
||||
|
||||
/**
|
||||
* The application's controller resolver.
|
||||
*
|
||||
* @var ControllerResolverInterface
|
||||
*/
|
||||
protected $controllerResolver;
|
||||
|
||||
/**
|
||||
* The application's router.
|
||||
*
|
||||
* @var RouterInterface
|
||||
*/
|
||||
protected $router;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param ControllerResolverInterface $controllerResolver The application's controller resolver
|
||||
* @param RouterInterface $router The application's router
|
||||
* @param Input $input An optional argument to provide dependency injection for the application's
|
||||
* input object.
|
||||
* @param Registry $config An optional argument to provide dependency injection for the application's
|
||||
* config object.
|
||||
* @param WebClient $client An optional argument to provide dependency injection for the application's
|
||||
* client object.
|
||||
* @param ResponseInterface $response An optional argument to provide dependency injection for the application's
|
||||
* response object.
|
||||
*/
|
||||
public function __construct(
|
||||
ControllerResolverInterface $controllerResolver,
|
||||
RouterInterface $router,
|
||||
Input $input = null,
|
||||
Registry $config = null,
|
||||
WebClient $client = null,
|
||||
ResponseInterface $response = null
|
||||
)
|
||||
{
|
||||
$this->controllerResolver = $controllerResolver;
|
||||
$this->router = $router;
|
||||
|
||||
// Call the constructor as late as possible (it runs `initialise`).
|
||||
parent::__construct($input, $config, $client, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to run the application routines.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function doExecute(): void
|
||||
{
|
||||
$route = $this->router->parseRoute($this->get('uri.route'), $this->input->getMethod());
|
||||
|
||||
// Add variables to the input if not already set
|
||||
foreach ($route->getRouteVariables() as $key => $value)
|
||||
{
|
||||
$this->input->def($key, $value);
|
||||
}
|
||||
|
||||
\call_user_func($this->controllerResolver->resolve($route));
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Application;
|
||||
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
|
||||
interface IdentityAwareInterface
|
||||
{
|
||||
/**
|
||||
* Get the application identity.
|
||||
*
|
||||
* @return User
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getIdentity(): User;
|
||||
|
||||
/**
|
||||
* Allows the application to load a custom or default identity.
|
||||
*
|
||||
* @param User $identity An optional identity object. If omitted, a null user object is created.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function loadIdentity(User $identity = null): IdentityAwareInterface;
|
||||
|
||||
/**
|
||||
* Set the user factory to use.
|
||||
*
|
||||
* @param UserFactoryInterface $userFactory The user factory to use
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setUserFactory(UserFactoryInterface $userFactory);
|
||||
|
||||
/**
|
||||
* Get the user factory to use.
|
||||
*
|
||||
* @return UserFactoryInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getUserFactory(): UserFactoryInterface;
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Content Management System
|
||||
*
|
||||
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Application;
|
||||
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
|
||||
/**
|
||||
* Trait for application classes which are identity (user) aware
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait IdentityAwareTrait
|
||||
{
|
||||
/**
|
||||
* The application identity object.
|
||||
*
|
||||
* @var User
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $identity;
|
||||
|
||||
/**
|
||||
* UserFactoryInterface
|
||||
*
|
||||
* @var UserFactoryInterface
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $userFactory;
|
||||
|
||||
/**
|
||||
* Get the application identity.
|
||||
*
|
||||
* @return User
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getIdentity(): User
|
||||
{
|
||||
return $this->identity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the application to load a custom or default identity.
|
||||
*
|
||||
* @param User $identity An optional identity object. If omitted, a null user object is created.
|
||||
*
|
||||
* @return IdentityAwareInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function loadIdentity(User $identity = null): IdentityAwareInterface
|
||||
{
|
||||
$this->identity = $identity ?: $this->userFactory->loadUserById(0);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user factory to use.
|
||||
*
|
||||
* @param UserFactoryInterface $userFactory The user factory to use
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setUserFactory(UserFactoryInterface $userFactory)
|
||||
{
|
||||
$this->userFactory = $userFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user factory to use.
|
||||
*
|
||||
* @return UserFactoryInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getUserFactory(): UserFactoryInterface
|
||||
{
|
||||
return $this->userFactory;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Application;
|
||||
|
||||
/**
|
||||
* Application Session Message Aware Interface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface SessionMessageAwareInterface
|
||||
{
|
||||
const MSG_INFO = 'info';
|
||||
|
||||
/**
|
||||
* Enqueue a system message.
|
||||
*
|
||||
* @param string $msg The message to enqueue.
|
||||
* @param string $type The message type. Default is message.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function enqueueMessage(string $msg, string $type = self::MSG_INFO);
|
||||
|
||||
/**
|
||||
* Get the system message queue.
|
||||
*
|
||||
* @param boolean $clear Clear the messages currently attached to the application object
|
||||
*
|
||||
* @return array The system message queue.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function getMessageQueue(bool $clear = false): array;
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Application;
|
||||
|
||||
use Joomla\Filter\InputFilter as InputFilterAlias;
|
||||
use Octoleo\CMS\Filter\InputFilter;
|
||||
|
||||
/**
|
||||
* Trait for application classes which are identity (user) aware
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait SessionMessageAwareTrait
|
||||
{
|
||||
/**
|
||||
* Enqueue a system message.
|
||||
*
|
||||
* @param string $msg The message to enqueue.
|
||||
* @param string $type The message type. Default is message.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function enqueueMessage(string $msg, string $type = self::MSG_INFO)
|
||||
{
|
||||
// Don't add empty messages.
|
||||
if ($msg === null || trim($msg) === '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$inputFilter = InputFilter::getInstance(
|
||||
[],
|
||||
[],
|
||||
InputFilterAlias::ONLY_BLOCK_DEFINED_TAGS,
|
||||
InputFilterAlias::ONLY_BLOCK_DEFINED_ATTRIBUTES
|
||||
);
|
||||
|
||||
// Build the message array and apply the HTML InputFilter with the default blacklist to the message
|
||||
$message = array(
|
||||
'message' => $inputFilter->clean($msg, 'html'),
|
||||
'type' => $inputFilter->clean(strtolower($type), 'cmd'),
|
||||
);
|
||||
|
||||
// For empty queue, if messages exists in the session, enqueue them first.
|
||||
$messages = $this->getMessageQueue();
|
||||
|
||||
if (!\in_array($message, $messages))
|
||||
{
|
||||
// Enqueue the message.
|
||||
$messages[] = $message;
|
||||
|
||||
// update the session
|
||||
$this->getSession()->set('application.queue', $messages);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the system message queue.
|
||||
*
|
||||
* @param boolean $clear Clear the messages currently attached to the application object
|
||||
*
|
||||
* @return array The system message queue.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMessageQueue(bool $clear = false): array
|
||||
{
|
||||
// Get messages from Session
|
||||
$sessionQueue = $this->getSession()->get('application.queue', []);
|
||||
|
||||
if ($clear)
|
||||
{
|
||||
$this->getSession()->set('application.queue', []);
|
||||
}
|
||||
|
||||
return $sessionQueue;
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Framework Website
|
||||
*
|
||||
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Application;
|
||||
|
||||
use Joomla\Application\AbstractWebApplication;
|
||||
use Joomla\Application\Controller\ControllerResolverInterface;
|
||||
use Joomla\Application\Web\WebClient;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Router\RouterInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Site application class
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/WebApplication.php
|
||||
*/
|
||||
class SiteApplication extends AbstractWebApplication
|
||||
{
|
||||
/**
|
||||
* The application's controller resolver.
|
||||
*
|
||||
* @var ControllerResolverInterface
|
||||
*/
|
||||
protected $controllerResolver;
|
||||
|
||||
/**
|
||||
* The application's router.
|
||||
*
|
||||
* @var RouterInterface
|
||||
*/
|
||||
protected $router;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param ControllerResolverInterface $controllerResolver The application's controller resolver
|
||||
* @param RouterInterface $router The application's router
|
||||
* @param Input $input An optional argument to provide dependency injection for the application's
|
||||
* input object.
|
||||
* @param Registry $config An optional argument to provide dependency injection for the application's
|
||||
* config object.
|
||||
* @param WebClient $client An optional argument to provide dependency injection for the application's
|
||||
* client object.
|
||||
* @param ResponseInterface $response An optional argument to provide dependency injection for the application's
|
||||
* response object.
|
||||
*/
|
||||
public function __construct(
|
||||
ControllerResolverInterface $controllerResolver,
|
||||
RouterInterface $router,
|
||||
Input $input = null,
|
||||
Registry $config = null,
|
||||
WebClient $client = null,
|
||||
ResponseInterface $response = null
|
||||
)
|
||||
{
|
||||
$this->controllerResolver = $controllerResolver;
|
||||
$this->router = $router;
|
||||
|
||||
// Call the constructor as late as possible (it runs `initialise`).
|
||||
parent::__construct($input, $config, $client, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to run the application routines.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function doExecute(): void
|
||||
{
|
||||
$route = $this->router->parseRoute($this->get('uri.route'), $this->input->getMethod());
|
||||
|
||||
// Add variables to the input if not already set
|
||||
foreach ($route->getRouteVariables() as $key => $value)
|
||||
{
|
||||
$this->input->def($key, $value);
|
||||
}
|
||||
|
||||
\call_user_func($this->controllerResolver->resolve($route));
|
||||
}
|
||||
}
|
71
week-07/project/libraries/src/Asset/MixPathPackage.php
Normal file
71
week-07/project/libraries/src/Asset/MixPathPackage.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Framework Website
|
||||
*
|
||||
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Asset;
|
||||
|
||||
use Symfony\Component\Asset\Context\ContextInterface;
|
||||
use Symfony\Component\Asset\Package;
|
||||
use Symfony\Component\Asset\PathPackage;
|
||||
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
|
||||
|
||||
/**
|
||||
* Extended path package for resolving assets from a Laravel Mix manifest
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Asset/MixPathPackage.php
|
||||
*/
|
||||
class MixPathPackage extends PathPackage
|
||||
{
|
||||
/**
|
||||
* Decorated Package instance
|
||||
*
|
||||
* @var Package
|
||||
*/
|
||||
private $decoratedPackage;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Package $decoratedPackage Decorated Package instance
|
||||
* @param string $basePath The base path to be prepended to relative paths
|
||||
* @param VersionStrategyInterface $versionStrategy The version strategy
|
||||
* @param ContextInterface $context The context
|
||||
*/
|
||||
public function __construct(
|
||||
Package $decoratedPackage,
|
||||
string $basePath,
|
||||
VersionStrategyInterface $versionStrategy,
|
||||
ContextInterface $context = null
|
||||
) {
|
||||
parent::__construct($basePath, $versionStrategy, $context);
|
||||
|
||||
$this->decoratedPackage = $decoratedPackage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an absolute or root-relative public path.
|
||||
*
|
||||
* @param string $path A path
|
||||
*
|
||||
* @return string The public path
|
||||
*/
|
||||
public function getUrl($path)
|
||||
{
|
||||
if ($this->isAbsoluteUrl($path))
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
|
||||
$versionedPath = $this->getVersionStrategy()->applyVersion("/$path");
|
||||
|
||||
if ($versionedPath === $path)
|
||||
{
|
||||
return $this->decoratedPackage->getUrl($path);
|
||||
}
|
||||
|
||||
return $this->getBasePath() . ltrim($versionedPath, '/');
|
||||
}
|
||||
}
|
63
week-07/project/libraries/src/Autoload/ClassLoader.php
Normal file
63
week-07/project/libraries/src/Autoload/ClassLoader.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Content Management System
|
||||
*
|
||||
* @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Autoload;
|
||||
|
||||
\defined('_LEXEC') or die;
|
||||
|
||||
use Composer\Autoload\ClassLoader as ComposerClassLoader;
|
||||
|
||||
/**
|
||||
* Decorate Composer ClassLoader for Octoleo!
|
||||
*
|
||||
* For backward compatibility due to class aliasing in the CMS, the loadClass() method was modified to call
|
||||
* the LLoader::applyAliasFor() method.
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/**
|
||||
* The Composer class loader
|
||||
*
|
||||
* @var ComposerClassLoader
|
||||
* @since 3.4
|
||||
*/
|
||||
private $loader;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ComposerClassLoader $loader Composer autoloader
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
public function __construct(ComposerClassLoader $loader)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return boolean|null True if loaded, null otherwise
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($result = $this->loader->loadClass($class))
|
||||
{
|
||||
\LLoader::applyAliasFor($class);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Uri\Uri;
|
||||
use Octoleo\CMS\Controller\Util\AccessInterface;
|
||||
use Octoleo\CMS\Controller\Util\AccessTrait;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
||||
use Octoleo\CMS\View\Admin\DashboardHtmlView;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
||||
*/
|
||||
class DashboardController extends AbstractController implements AccessInterface, CheckTokenInterface
|
||||
{
|
||||
use AccessTrait, CheckTokenTrait;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var DashboardHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param DashboardHtmlView $view The view object.
|
||||
* @param Input|null $input The input object.
|
||||
* @param AbstractApplication|null $app The application object.
|
||||
*/
|
||||
public function __construct(DashboardHtmlView $view, Input $input = null, AbstractApplication $app = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$task = $this->getInput()->getString('task', '');
|
||||
$id = $this->getInput()->getInt('id', 0);
|
||||
|
||||
$this->view->setActiveDashboard($task);
|
||||
$this->view->setActiveId($id);
|
||||
|
||||
// validate form token
|
||||
if ('access' === $task || 'signup' === $task)
|
||||
{
|
||||
$this->checkToken();
|
||||
}
|
||||
|
||||
// check if user is allowed to access
|
||||
if ($this->allow($task))
|
||||
{
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// go to set page
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
272
week-07/project/libraries/src/Controller/ItemController.php
Normal file
272
week-07/project/libraries/src/Controller/ItemController.php
Normal file
@ -0,0 +1,272 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Filter\InputFilter as InputFilterAlias;
|
||||
use Joomla\Input\Input;
|
||||
use Octoleo\CMS\Controller\Util\AccessInterface;
|
||||
use Octoleo\CMS\Controller\Util\AccessTrait;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
||||
use Octoleo\CMS\Date\Date;
|
||||
use Octoleo\CMS\Factory;
|
||||
use Octoleo\CMS\Filter\InputFilter;
|
||||
use Octoleo\CMS\Model\ItemModel;
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\View\Admin\ItemHtmlView;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
||||
*/
|
||||
class ItemController extends AbstractController implements AccessInterface, CheckTokenInterface
|
||||
{
|
||||
use AccessTrait, CheckTokenTrait;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var ItemHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* The model object.
|
||||
*
|
||||
* @var ItemModel
|
||||
*/
|
||||
private $model;
|
||||
|
||||
/**
|
||||
* @var InputFilter
|
||||
*/
|
||||
private $inputFilter;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ItemModel $model The model object.
|
||||
* @param ItemHtmlView $view The view object.
|
||||
* @param Input|null $input The input object.
|
||||
* @param AbstractApplication|null $app The application object.
|
||||
* @param User|null $user
|
||||
*/
|
||||
public function __construct(
|
||||
ItemModel $model,
|
||||
$view,
|
||||
Input $input = null,
|
||||
AbstractApplication $app = null,
|
||||
User $user = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->model = $model;
|
||||
$this->view = $view;
|
||||
$this->user = ($user) ?: Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
$this->inputFilter = InputFilter::getInstance(
|
||||
[],
|
||||
[],
|
||||
InputFilterAlias::ONLY_BLOCK_DEFINED_TAGS,
|
||||
InputFilterAlias::ONLY_BLOCK_DEFINED_ATTRIBUTES
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$method = $this->getInput()->getMethod();
|
||||
$task = $this->getInput()->getString('task', '');
|
||||
$id = $this->getInput()->getInt('id', 0);
|
||||
|
||||
// if task is delete
|
||||
if ('delete' === $task)
|
||||
{
|
||||
// check that the user does not delete him/her self
|
||||
if ($this->allow('item') && $this->user->get('access.item.delete', false))
|
||||
{
|
||||
if ($id > 0 && $this->model->linked($id))
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('This item is still linked to a menu, first remove it from the menu.', 'error');
|
||||
}
|
||||
elseif ($id > 0 && $this->model->delete($id))
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('Item was deleted!', 'success');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('Item could not be deleted!', 'error');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to delete this item!', 'error');
|
||||
}
|
||||
// go to set page
|
||||
$this->_redirect('items');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ('POST' === $method)
|
||||
{
|
||||
// check permissions
|
||||
$update = ($id > 0 && $this->user->get('access.item.update', false));
|
||||
$create = ($id == 0 && $this->user->get('access.item.create', false));
|
||||
|
||||
if ( $create || $update )
|
||||
{
|
||||
$id = $this->setItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
// not allowed creating item
|
||||
if ($id == 0)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to create items!', 'error');
|
||||
}
|
||||
// not allowed updating item
|
||||
if ($id > 0)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to update the item details!', 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check permissions
|
||||
$read = ($id > 0 && $this->user->get('access.item.read', false));
|
||||
$create = ($id == 0 && $this->user->get('access.item.create', false));
|
||||
|
||||
// check if user is allowed to access
|
||||
if ($this->allow('item') && ( $read || $create ))
|
||||
{
|
||||
// set values for view
|
||||
$this->view->setActiveId($id);
|
||||
$this->view->setActiveView('item');
|
||||
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// not allowed creating item
|
||||
if ($id == 0 && !$create)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to create items!', 'error');
|
||||
}
|
||||
// not allowed read item
|
||||
if ($id > 0 && !$read)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to read the item details!', 'error');
|
||||
}
|
||||
|
||||
// go to set page
|
||||
$this->_redirect('items');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an item
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setItem(): int
|
||||
{
|
||||
// always check the post token
|
||||
$this->checkToken();
|
||||
// get the post
|
||||
$post = $this->getInput()->getInputForRequestMethod();
|
||||
|
||||
// we get all the needed items
|
||||
$tempItem = [];
|
||||
$tempItem['id'] = $post->getInt('item_id', 0);
|
||||
$tempItem['title'] = $post->getString('title', '');
|
||||
$tempItem['fulltext'] = $this->inputFilter->clean($post->getRaw('fulltext', ''), 'html');
|
||||
$tempItem['created_by_alias'] = $post->getString('created_by_alias', '');
|
||||
$tempItem['state'] = $post->getInt('state', 1);
|
||||
$tempItem['metakey'] = $post->getString('metakey', '');
|
||||
$tempItem['metadesc'] = $post->getString('metadesc', '');
|
||||
$tempItem['metadata'] = $post->getString('metadata', '');
|
||||
$tempItem['publish_up'] = $post->getString('publish_up', '');
|
||||
$tempItem['publish_down'] = $post->getString('publish_down', '');
|
||||
$tempItem['featured'] = $post->getInt('featured', 0);
|
||||
|
||||
// check that we have a Title
|
||||
$can_save = true;
|
||||
if (empty($tempItem['title']))
|
||||
{
|
||||
// we show a warning message
|
||||
$tempItem['title'] = '';
|
||||
$this->getApplication()->enqueueMessage('Title field is required.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
// we actually can also not continue if we don't have content
|
||||
if (empty($tempItem['fulltext']))
|
||||
{
|
||||
// we show a warning message
|
||||
$tempItem['fulltext'] = '';
|
||||
$this->getApplication()->enqueueMessage('Content field is required.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
// can we save the item
|
||||
if ($can_save)
|
||||
{
|
||||
/** @var \Octoleo\CMS\User\User $user */
|
||||
$user = Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
|
||||
$user_id = (int) $user->get('id', 0);
|
||||
$today = (new Date())->toSql();
|
||||
|
||||
return $this->model->setItem(
|
||||
$tempItem['id'],
|
||||
$tempItem['title'],
|
||||
$tempItem['fulltext'],
|
||||
$tempItem['state'],
|
||||
$today,
|
||||
$user_id,
|
||||
$tempItem['created_by_alias'],
|
||||
$today,
|
||||
$user_id,
|
||||
$tempItem['publish_up'],
|
||||
$tempItem['publish_down'],
|
||||
$tempItem['metakey'],
|
||||
$tempItem['metadesc'],
|
||||
$tempItem['metadata'],
|
||||
$tempItem['featured']);
|
||||
}
|
||||
|
||||
// add to model the post values
|
||||
$this->model->tempItem = $tempItem;
|
||||
|
||||
return $tempItem['id'];
|
||||
}
|
||||
}
|
94
week-07/project/libraries/src/Controller/ItemsController.php
Normal file
94
week-07/project/libraries/src/Controller/ItemsController.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
use Octoleo\CMS\Controller\Util\AccessInterface;
|
||||
use Octoleo\CMS\Controller\Util\AccessTrait;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
||||
use Octoleo\CMS\Factory;
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\View\Admin\ItemsHtmlView;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
||||
*/
|
||||
class ItemsController extends AbstractController implements AccessInterface, CheckTokenInterface
|
||||
{
|
||||
use AccessTrait, CheckTokenTrait;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var ItemsHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ItemsHtmlView $view The view object.
|
||||
* @param Input|null $input The input object.
|
||||
* @param AbstractApplication|null $app The application object.
|
||||
* @param User|null $user
|
||||
*/
|
||||
public function __construct(
|
||||
ItemsHtmlView $view,
|
||||
Input $input = null,
|
||||
AbstractApplication $app = null,
|
||||
User $user = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->view = $view;
|
||||
$this->user = ($user) ?: Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$this->view->setActiveView('items');
|
||||
|
||||
// check if user is allowed to access
|
||||
if ($this->allow('items') && $this->user->get('access.item.read', false))
|
||||
{
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// go to set page
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
95
week-07/project/libraries/src/Controller/LoginController.php
Normal file
95
week-07/project/libraries/src/Controller/LoginController.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Renderer\RendererInterface;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
use Octoleo\CMS\View\Admin\DashboardHtmlView;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\SiteApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\SiteApplication $app Application object
|
||||
*/
|
||||
class LoginController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* The template renderer.
|
||||
*
|
||||
* @var RendererInterface
|
||||
*/
|
||||
private $renderer;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var DashboardHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param DashboardHtmlView $view The view object.
|
||||
* @param RendererInterface $renderer The template renderer.
|
||||
* @param Input $input The input object.
|
||||
* @param AbstractApplication $app The application object.
|
||||
*/
|
||||
public function __construct(DashboardHtmlView $view, RendererInterface $renderer, Input $input = null, AbstractApplication $app = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->view = $view;
|
||||
$this->renderer = $renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$task = $this->getInput()->getString('account', null);
|
||||
|
||||
/** @var \Octoleo\CMS\Application\AdminApplication $app */
|
||||
$app = $this->getApplication();
|
||||
|
||||
/** @var \Octoleo\CMS\User\UserFactory $userFactory */
|
||||
$userFactory = $app->getUserFactory();
|
||||
|
||||
// if the user is logged in we go to dashboard
|
||||
if ($userFactory->active())
|
||||
{
|
||||
$this->view->setActiveDashboard('dashboard');
|
||||
$this->view->setActiveId(0);
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
elseif ('signup' === $task)
|
||||
{
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->renderer->render('signup.twig')));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->renderer->render('login.twig')));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
249
week-07/project/libraries/src/Controller/MenuController.php
Normal file
249
week-07/project/libraries/src/Controller/MenuController.php
Normal file
@ -0,0 +1,249 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
use Octoleo\CMS\Controller\Util\AccessInterface;
|
||||
use Octoleo\CMS\Controller\Util\AccessTrait;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
||||
use Octoleo\CMS\Factory;
|
||||
use Octoleo\CMS\Filter\InputFilter;
|
||||
use Octoleo\CMS\Model\MenuModel;
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\View\Admin\MenuHtmlView;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
||||
*/
|
||||
class MenuController extends AbstractController implements AccessInterface, CheckTokenInterface
|
||||
{
|
||||
use AccessTrait, CheckTokenTrait;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var MenuHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* The model object.
|
||||
*
|
||||
* @var MenuModel
|
||||
*/
|
||||
private $model;
|
||||
|
||||
/**
|
||||
* @var InputFilter
|
||||
*/
|
||||
private $inputFilter;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param MenuModel $model The model object.
|
||||
* @param MenuHtmlView $view The view object.
|
||||
* @param Input|null $input The input object.
|
||||
* @param AbstractApplication|null $app The application object.
|
||||
*/
|
||||
public function __construct(
|
||||
MenuModel $model,
|
||||
MenuHtmlView $view,
|
||||
Input $input = null,
|
||||
AbstractApplication $app = null,
|
||||
User $user = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->model = $model;
|
||||
$this->view = $view;
|
||||
$this->user = ($user) ?: Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$method = $this->getInput()->getMethod();
|
||||
$task = $this->getInput()->getString('task', '');
|
||||
$id = $this->getInput()->getInt('id', 0);
|
||||
|
||||
// if task is delete
|
||||
if ('delete' === $task)
|
||||
{
|
||||
if ($this->allow('menu') && $this->user->get('access.menu.delete', false))
|
||||
{
|
||||
if ($this->model->delete($id))
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('Menu was deleted!', 'success');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('Menu could not be deleted!', 'error');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to delete this menu!', 'error');
|
||||
}
|
||||
// go to set page
|
||||
$this->_redirect('menus');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ('POST' === $method)
|
||||
{
|
||||
// check permissions
|
||||
$update = ($id > 0 && $this->user->get('access.menu.update', false));
|
||||
$create = ($id == 0 && $this->user->get('access.menu.create', false));
|
||||
|
||||
if ( $create || $update )
|
||||
{
|
||||
$id = $this->setItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
// not allowed creating menu
|
||||
if ($id == 0)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to create menus!', 'error');
|
||||
}
|
||||
// not allowed updating menu
|
||||
if ($id > 0)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to update the menu details!', 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check permissions
|
||||
$read = ($id > 0 && $this->user->get('access.menu.read', false));
|
||||
$create = ($id == 0 && $this->user->get('access.menu.create', false));
|
||||
|
||||
// check if user is allowed to access
|
||||
if ($this->allow('menu') && ( $read || $create ))
|
||||
{
|
||||
// set values for view
|
||||
$this->view->setActiveId($id);
|
||||
$this->view->setActiveView('menu');
|
||||
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// not allowed creating menu
|
||||
if ($id == 0 && !$create)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to create menus!', 'error');
|
||||
}
|
||||
// not allowed read menu
|
||||
if ($id > 0 && !$read)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to read the menu details!', 'error');
|
||||
}
|
||||
|
||||
// go to set page
|
||||
$this->_redirect('menus');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an item
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setItem(): int
|
||||
{
|
||||
// always check the post token
|
||||
$this->checkToken();
|
||||
// get the post
|
||||
$post = $this->getInput()->getInputForRequestMethod();
|
||||
|
||||
// we get all the needed items
|
||||
$tempItem = [];
|
||||
$tempItem['id'] = $post->getInt('menu_id', 0);
|
||||
$tempItem['title'] = $post->getString('title', '');
|
||||
$tempItem['alias'] = $post->getString('alias', '');
|
||||
$tempItem['path'] = $post->getString('path', '');
|
||||
$tempItem['item_id'] = $post->getInt('item_id', 0);
|
||||
$tempItem['published'] = $post->getInt('published', 1);
|
||||
$tempItem['publish_up'] = $post->getString('publish_up', '');
|
||||
$tempItem['publish_down'] = $post->getString('publish_down', '');
|
||||
$tempItem['position'] = $post->getString('position', 'center');
|
||||
$tempItem['home'] = $post->getInt('home', 0);
|
||||
$tempItem['parent_id'] = $post->getInt('parent_id', 0);
|
||||
|
||||
// check that we have a Title
|
||||
$can_save = true;
|
||||
if (empty($tempItem['title']))
|
||||
{
|
||||
// we show a warning message
|
||||
$tempItem['title'] = '';
|
||||
$this->getApplication()->enqueueMessage('Title field is required.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
// we actually can also not continue if we don't have content
|
||||
if (empty($tempItem['item_id']) || $tempItem['item_id'] == 0)
|
||||
{
|
||||
// we show a warning message
|
||||
$tempItem['item_id'] = 0;
|
||||
$this->getApplication()->enqueueMessage('Item field is required.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
|
||||
// can we save the item
|
||||
if ($can_save)
|
||||
{
|
||||
return $this->model->setItem(
|
||||
$tempItem['id'],
|
||||
$tempItem['title'],
|
||||
$tempItem['alias'],
|
||||
$tempItem['item_id'],
|
||||
$tempItem['path'],
|
||||
$tempItem['published'],
|
||||
$tempItem['publish_up'],
|
||||
$tempItem['publish_down'],
|
||||
$tempItem['position'],
|
||||
$tempItem['home'],
|
||||
$tempItem['parent_id']);
|
||||
}
|
||||
|
||||
// add to model the post values
|
||||
$this->model->tempItem = $tempItem;
|
||||
|
||||
return $tempItem['id'];
|
||||
}
|
||||
}
|
94
week-07/project/libraries/src/Controller/MenusController.php
Normal file
94
week-07/project/libraries/src/Controller/MenusController.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
use Octoleo\CMS\Controller\Util\AccessInterface;
|
||||
use Octoleo\CMS\Controller\Util\AccessTrait;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
||||
use Octoleo\CMS\Factory;
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\View\Admin\MenusHtmlView;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
||||
*/
|
||||
class MenusController extends AbstractController implements AccessInterface, CheckTokenInterface
|
||||
{
|
||||
use AccessTrait, CheckTokenTrait;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var MenusHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param MenusHtmlView $view The view object.
|
||||
* @param Input|null $input The input object.
|
||||
* @param AbstractApplication|null $app The application object.
|
||||
* @param User|null $user The user object.
|
||||
*/
|
||||
public function __construct(
|
||||
MenusHtmlView $view,
|
||||
Input $input = null,
|
||||
AbstractApplication $app = null,
|
||||
User $user = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->view = $view;
|
||||
$this->user = ($user) ?: Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$this->view->setActiveView('menus');
|
||||
|
||||
// check if user is allowed to access
|
||||
if ($this->allow('menus') && $this->user->get('access.menu.read', false))
|
||||
{
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// go to set page
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
105
week-07/project/libraries/src/Controller/PageController.php
Normal file
105
week-07/project/libraries/src/Controller/PageController.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Uri\Uri;
|
||||
use Octoleo\CMS\Utilities\StringHelper;
|
||||
use Octoleo\CMS\View\Site\PageHtmlView;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
use Laminas\Diactoros\Response\RedirectResponse;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\SiteApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\SiteApplication $app Application object
|
||||
*/
|
||||
class PageController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var PageHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param PageHtmlView $view The view object.
|
||||
* @param Input|null $input The input object.
|
||||
* @param AbstractApplication|null $app The application object.
|
||||
*/
|
||||
public function __construct(PageHtmlView $view, Input $input = null, AbstractApplication $app = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Disable all cache for now
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
// get the root name
|
||||
$root = $this->getInput()->getString('root', '');
|
||||
// start building the full path
|
||||
$path = [];
|
||||
$path[] = $root;
|
||||
// set a mad depth TODO: we should limit the menu depth to 6 or something
|
||||
$depth = range(1,20);
|
||||
// load the whole path
|
||||
foreach ($depth as $page)
|
||||
{
|
||||
$page = StringHelper::numbers($page);
|
||||
// check if there is a value
|
||||
$result = $this->getInput()->getString($page, false);
|
||||
if ($result)
|
||||
{
|
||||
$path[] = $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
// first false means we are at the end of the line
|
||||
break;
|
||||
}
|
||||
}
|
||||
// set the final path
|
||||
$path = implode('/', $path);
|
||||
|
||||
// if for some reason the view value is administrator
|
||||
if ('administrator' === $root)
|
||||
{
|
||||
// get uri request to get host
|
||||
$uri = new Uri($this->getApplication()->get('uri.request'));
|
||||
|
||||
// Redirect to the administrator area
|
||||
$this->getApplication()->setResponse(new RedirectResponse($uri->getScheme() . '://' . $uri->getHost() . '/administrator/', 301));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->view->setPage($path);
|
||||
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
452
week-07/project/libraries/src/Controller/UserController.php
Normal file
452
week-07/project/libraries/src/Controller/UserController.php
Normal file
@ -0,0 +1,452 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Exception;
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Authentication\Password\BCryptHandler;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
use Octoleo\CMS\Controller\Util\AccessInterface;
|
||||
use Octoleo\CMS\Controller\Util\AccessTrait;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
||||
use Octoleo\CMS\Date\Date;
|
||||
use Octoleo\CMS\Factory;
|
||||
use Octoleo\CMS\Model\UserModel;
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\View\Admin\UserHtmlView;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
||||
*/
|
||||
class UserController extends AbstractController implements AccessInterface, CheckTokenInterface
|
||||
{
|
||||
use AccessTrait, CheckTokenTrait;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var UserHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* The model object.
|
||||
*
|
||||
* @var UserModel
|
||||
*/
|
||||
private $model;
|
||||
|
||||
/**
|
||||
* @var BCryptHandler
|
||||
*/
|
||||
private $secure;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param UserModel $model The model object.
|
||||
* @param UserHtmlView $view The view object.
|
||||
* @param Input|null $input The input object.
|
||||
* @param User|null $user The current user.
|
||||
* @param AbstractApplication|null $app The application object.
|
||||
*/
|
||||
public function __construct(
|
||||
UserModel $model,
|
||||
UserHtmlView $view,
|
||||
Input $input = null,
|
||||
AbstractApplication $app = null,
|
||||
User $user = null,
|
||||
BCryptHandler $secure = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->model = $model;
|
||||
$this->view = $view;
|
||||
$this->user = ($user) ?: Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
$this->secure = ($secure) ?: new BCryptHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$method = $this->getInput()->getMethod();
|
||||
$task = $this->getInput()->getString('task', '');
|
||||
$id = $this->getInput()->getInt('id', 0);
|
||||
|
||||
// if task is delete
|
||||
if ('delete' === $task)
|
||||
{
|
||||
// check that the user does not delete him/her self
|
||||
if ($this->allow('user') && $this->user->get('access.user.delete', false))
|
||||
{
|
||||
// get the current user being deleted
|
||||
/** @var \Octoleo\CMS\User\User $userBeingDeleted */
|
||||
$userBeingDeleted = Factory::getContainer()->get(UserFactoryInterface::class)->getUser($id);
|
||||
// get the current active user ID
|
||||
$user_id = $this->user->get('id', -1);
|
||||
// is this the same user account as the active user
|
||||
if ($user_id == $id)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You can not delete your own account!', 'warning');
|
||||
}
|
||||
elseif ($userBeingDeleted->get('is_admin', false) && !$this->user->get('is_admin', false))
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You dont have the permission to delete an administrator account!', 'error');
|
||||
}
|
||||
elseif ($this->model->delete($id))
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('User was deleted!', 'success');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('User could not be deleted!', 'error');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to delete this user!', 'error');
|
||||
}
|
||||
// go to set page
|
||||
$this->_redirect('users');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// set the current user ID
|
||||
$user_id = $this->user->get('id', -1);
|
||||
|
||||
if ('POST' === $method)
|
||||
{
|
||||
// always check the post token
|
||||
$this->checkToken();
|
||||
// get the post
|
||||
$post = $this->getInput()->getInputForRequestMethod();
|
||||
|
||||
// we get all the needed items
|
||||
$tempItem = $post->getArray(['groups' => 'INT']);
|
||||
$tempItem['id'] = $post->getInt('user_id', 0);
|
||||
$tempItem['name'] = $post->getString('name', '');
|
||||
$tempItem['username'] = $post->getUsername('username', '');
|
||||
$tempItem['password'] = $post->getString('password', '');
|
||||
$tempItem['password2'] = $post->getString('password2', '');
|
||||
$tempItem['email'] = $post->getString('email', '');
|
||||
$tempItem['block'] = $post->getInt('block', 1);
|
||||
$tempItem['sendEmail'] = $post->getInt('sendEmail', 1);
|
||||
$tempItem['activation'] = $post->getInt('activation', 0);
|
||||
|
||||
// check permissions
|
||||
$update = ($tempItem['id'] > 0 && $this->user->get('access.user.update', false));
|
||||
$create = ($tempItem['id'] == 0 && $this->user->get('access.user.create', false));
|
||||
$selfUpdate = ($tempItem['id'] > 0 && $tempItem['id'] == $user_id);
|
||||
|
||||
if ($create || $update || $selfUpdate)
|
||||
{
|
||||
$id = $this->setItem($tempItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
// not allowed creating user
|
||||
if ($id == 0)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to create users!', 'error');
|
||||
}
|
||||
// not allowed updating user
|
||||
if ($id > 0)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to update the user details!', 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check permissions
|
||||
$read = ($id > 0 && $this->user->get('access.user.read', false));
|
||||
$create = ($id == 0 && $this->user->get('access.user.create', false));
|
||||
$selfUpdate = ($id > 0 && $id == $user_id);
|
||||
|
||||
// check if user is allowed to access
|
||||
if ($this->allow('user') && ($read || $create || $selfUpdate))
|
||||
{
|
||||
// set values for view
|
||||
$this->view->setActiveId($id);
|
||||
$this->view->setActiveView('user');
|
||||
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// not allowed creating user
|
||||
if ($id == 0 && !$create)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to create users!', 'error');
|
||||
}
|
||||
// not allowed updating user
|
||||
if ($id > 0 && !$read)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to read the user details!', 'error');
|
||||
}
|
||||
|
||||
// go to set page
|
||||
$this->_redirect('users');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an item
|
||||
*
|
||||
* @param array $tempItem
|
||||
*
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setItem(array $tempItem): int
|
||||
{
|
||||
$can_save = true;
|
||||
// check that we have a name
|
||||
if (empty($tempItem['name']))
|
||||
{
|
||||
// we show an error message
|
||||
$tempItem['name'] = '';
|
||||
$this->getApplication()->enqueueMessage('Name field is required.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
// check that we have a username
|
||||
if (empty($tempItem['username']))
|
||||
{
|
||||
// we show an error message
|
||||
$tempItem['username'] = '';
|
||||
$this->getApplication()->enqueueMessage('Username field is required.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
// check that we have an email TODO: check that we have a valid email
|
||||
if (empty($tempItem['email']))
|
||||
{
|
||||
// we show an error message
|
||||
$tempItem['email'] = '';
|
||||
$this->getApplication()->enqueueMessage('Email field is required.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
// check passwords
|
||||
if (isset($tempItem['password2']) && $tempItem['password'] != $tempItem['password2'])
|
||||
{
|
||||
// we show an error message
|
||||
$tempItem['password'] = 'xxxxxxxxxx';
|
||||
$tempItem['password2'] = 'xxxxxxxxxx';
|
||||
$this->getApplication()->enqueueMessage('Passwords do not match.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
unset ($tempItem['password2']);
|
||||
// do not set password that has not changed
|
||||
if ($tempItem['password'] === 'xxxxxxxxxx')
|
||||
{
|
||||
if ($tempItem['id'] == 0)
|
||||
{
|
||||
// we show an error message
|
||||
$tempItem['password'] = 'xxxxxxxxxx';
|
||||
$tempItem['password2'] = 'xxxxxxxxxx';
|
||||
$this->getApplication()->enqueueMessage('Passwords not set.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tempItem['password'] = '';
|
||||
}
|
||||
}
|
||||
elseif (strlen($tempItem['password']) < 7)
|
||||
{
|
||||
// we show an error message
|
||||
$tempItem['password'] = 'xxxxxxxxxx';
|
||||
$tempItem['password2'] = 'xxxxxxxxxx';
|
||||
$this->getApplication()->enqueueMessage('Passwords must be longer than 6 characters.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// hash the password
|
||||
$tempItem['password'] = $this->secure->hashPassword($tempItem['password']);
|
||||
}
|
||||
|
||||
// can we save the item
|
||||
if ($can_save)
|
||||
{
|
||||
// check that the user does not block him/her self
|
||||
$user_id = $this->user->get('id', -1);
|
||||
$block_status = $tempItem['block'];
|
||||
// this user is the current user
|
||||
if ($user_id == $tempItem['id'])
|
||||
{
|
||||
// don't allow user to block self
|
||||
if ($tempItem['block'] != 0)
|
||||
{
|
||||
// we show a warning message
|
||||
$this->getApplication()->enqueueMessage('You can not block yourself!', 'warning');
|
||||
$tempItem['block'] = 0;
|
||||
}
|
||||
// don't allow user remove self from admin groups
|
||||
if ($this->user->get('is_admin', false))
|
||||
{
|
||||
$admin_groups = $this->user->get('is_admin_groups', []);
|
||||
if (is_array($admin_groups) && count($admin_groups) > 0)
|
||||
{
|
||||
$notice_set_groups = true;
|
||||
foreach ($admin_groups as $admin_group)
|
||||
{
|
||||
if (!is_array($tempItem['groups']) || !in_array($admin_group, $tempItem['groups']))
|
||||
{
|
||||
if ($notice_set_groups)
|
||||
{
|
||||
// we show a warning message
|
||||
$this->getApplication()->enqueueMessage('You can not remove yourself from the administrator group!', 'warning');
|
||||
$notice_set_groups = false;
|
||||
}
|
||||
$tempItem['groups'][] = $admin_group;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we show an error message
|
||||
$this->getApplication()->enqueueMessage('There is a problem with the admin user groups, we can not save the user details.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// can we save the item
|
||||
if ($can_save)
|
||||
{
|
||||
// check that the user will have some groups left
|
||||
if (!is_array($tempItem['groups']) || count($tempItem['groups']) == 0)
|
||||
{
|
||||
// we show a warning message
|
||||
$this->getApplication()->enqueueMessage('You must select at least one group.', 'warning');
|
||||
// this user is the current user
|
||||
if ($user_id == $tempItem['id'])
|
||||
{
|
||||
$tempItem['groups'] = $this->user->get('groups_ids', []);
|
||||
// check if we still have no groups
|
||||
if (count($tempItem['groups']) == 0)
|
||||
{
|
||||
$can_save = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$can_save = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// can we save the item
|
||||
if ($can_save)
|
||||
{
|
||||
// none admin restrictions TODO would like to move this to the database and not hard code it
|
||||
if (!$this->user->get('is_admin', false))
|
||||
{
|
||||
// with existing users
|
||||
if ($tempItem['id'] > 0)
|
||||
{
|
||||
// get the current user being saved
|
||||
/** @var \Octoleo\CMS\User\User $userBeingSaved */
|
||||
$userBeingSaved = Factory::getContainer()->get(UserFactoryInterface::class)->getUser($tempItem['id']);
|
||||
// don't allow block status change by none admin users
|
||||
$block = $userBeingSaved->get('block', 1);
|
||||
$current_posted_block = $tempItem['block'];
|
||||
// if the status changed we revert and give message
|
||||
// we allow block but not un-block
|
||||
if ($block != $current_posted_block && $current_posted_block == 0)
|
||||
{
|
||||
// we show a warning message
|
||||
$this->getApplication()->enqueueMessage('Only the administrator can update user access to system.', 'warning');
|
||||
$tempItem['block'] = 1;
|
||||
}
|
||||
// get current group to see if we must give a notice
|
||||
$groups = $userBeingSaved->get('groups_ids', []);
|
||||
$current_posted_groups = $tempItem['groups'];
|
||||
sort($groups);
|
||||
sort($current_posted_groups);
|
||||
// if the groups changes we give a message
|
||||
if ($groups !== $current_posted_groups)
|
||||
{
|
||||
// we show a warning message
|
||||
$this->getApplication()->enqueueMessage('Only the administrator can update user group selection.', 'warning');
|
||||
}
|
||||
// if the current user being saved is an admin account
|
||||
// we don't allow the following changes
|
||||
if ($userBeingSaved->get('is_admin', false))
|
||||
{
|
||||
// we do not allow password changes of admin accounts
|
||||
$tempItem['password'] = '';
|
||||
// we don't allow username changes
|
||||
$tempItem['username'] = $userBeingSaved->get('username', $tempItem['username']);
|
||||
// we don't allow change of status
|
||||
if ($block != $current_posted_block)
|
||||
{
|
||||
// we show an error message
|
||||
$this->getApplication()->enqueueMessage('Only the administrator can update another administrator account access to system.', 'error');
|
||||
$tempItem['block'] = $block;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// new users created by none admin must be blocked by default
|
||||
// since only admin can unblock any users
|
||||
$tempItem['block'] = 1;
|
||||
}
|
||||
// only admin can change groups
|
||||
// empty groups will not get updated
|
||||
$tempItem['groups'] = [];
|
||||
}
|
||||
|
||||
$today = (new Date())->toSql();
|
||||
|
||||
return $this->model->setItem(
|
||||
$tempItem['id'],
|
||||
$tempItem['name'],
|
||||
$tempItem['username'],
|
||||
$tempItem['groups'],
|
||||
$tempItem['email'],
|
||||
$tempItem['password'],
|
||||
$tempItem['block'],
|
||||
$tempItem['sendEmail'],
|
||||
$today,
|
||||
$tempItem['activation']);
|
||||
}
|
||||
}
|
||||
|
||||
// add to model the post values
|
||||
$this->model->tempItem = $tempItem;
|
||||
|
||||
return $tempItem['id'];
|
||||
}
|
||||
}
|
262
week-07/project/libraries/src/Controller/UserGroupController.php
Normal file
262
week-07/project/libraries/src/Controller/UserGroupController.php
Normal file
@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 20th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Octoleo\CMS\Controller\Util\AccessInterface;
|
||||
use Octoleo\CMS\Controller\Util\AccessTrait;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
||||
use Octoleo\CMS\Factory;
|
||||
use Octoleo\CMS\Model\UsergroupModel;
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\View\Admin\UsergroupHtmlView;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
||||
*/
|
||||
class UserGroupController extends AbstractController implements AccessInterface, CheckTokenInterface
|
||||
{
|
||||
use AccessTrait, CheckTokenTrait;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var UsergroupHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* The model object.
|
||||
*
|
||||
* @var UsergroupModel
|
||||
*/
|
||||
private $model;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param UsergroupModel $model The model object.
|
||||
* @param UsergroupHtmlView $view The view object.
|
||||
* @param Input|null $input The input object.
|
||||
* @param AbstractApplication|null $app The application object.
|
||||
*/
|
||||
public function __construct(
|
||||
UsergroupModel $model,
|
||||
UsergroupHtmlView $view,
|
||||
Input $input = null,
|
||||
AbstractApplication $app = null,
|
||||
User $user = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->model = $model;
|
||||
$this->view = $view;
|
||||
$this->user = ($user) ?: Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$method = $this->getInput()->getMethod();
|
||||
$task = $this->getInput()->getString('task', '');
|
||||
$id = $this->getInput()->getInt('id', 0);
|
||||
|
||||
// if task is delete
|
||||
if ('delete' === $task)
|
||||
{
|
||||
if ($this->allow('usergroup') && $this->user->get('access.usergroup.delete', false))
|
||||
{
|
||||
// TODO not ideal to hard code any ID
|
||||
if ($id == 1)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('This is the administrator user group that can not be deleted.', 'error');
|
||||
}
|
||||
elseif ($id > 0 && $this->model->linked($id))
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('This user group is still in use and can therefore no be deleted.', 'error');
|
||||
}
|
||||
elseif ($this->model->delete($id))
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('User group was deleted!', 'success');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('User group could not be deleted!', 'error');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to delete this user group!', 'error');
|
||||
}
|
||||
// go to set page
|
||||
$this->_redirect('usergroups');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ('POST' === $method)
|
||||
{
|
||||
// check permissions
|
||||
$update = ($id > 0 && $this->user->get('access.usergroup.update', false));
|
||||
$create = ($id == 0 && $this->user->get('access.usergroup.create', false));
|
||||
|
||||
// TODO not ideal to hard code any ID
|
||||
if ($id == 1 && $update)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('This is the administrator user group that can not change.', 'error');
|
||||
}
|
||||
elseif ( $create || $update )
|
||||
{
|
||||
$id = $this->setItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
// not allowed creating user group
|
||||
if ($id == 0)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to create user groups!', 'error');
|
||||
}
|
||||
// not allowed updating user group
|
||||
if ($id > 0)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to update the user group details!', 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check permissions
|
||||
$read = ($id > 0 && $this->user->get('access.usergroup.read', false));
|
||||
$create = ($id == 0 && $this->user->get('access.usergroup.create', false));
|
||||
|
||||
// check if user is allowed to access
|
||||
if ($this->allow('usergroup') && ( $read || $create ))
|
||||
{
|
||||
// set values for view
|
||||
$this->view->setActiveId($id);
|
||||
$this->view->setActiveView('usergroup');
|
||||
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// not allowed creating user group
|
||||
if ($id == 0 && !$create)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to create user groups!', 'error');
|
||||
}
|
||||
// not allowed read user group
|
||||
if ($id > 0 && !$read)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage('You do not have permission to read the user group details!', 'error');
|
||||
}
|
||||
|
||||
// go to set page
|
||||
$this->_redirect('items');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an item
|
||||
*
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setItem(): int
|
||||
{
|
||||
// always check the post token
|
||||
$this->checkToken();
|
||||
// get the post
|
||||
$post = $this->getInput()->getInputForRequestMethod();
|
||||
|
||||
// we get all the needed items
|
||||
$tempItem = $post->getArray(['params' => 'STRING']);;
|
||||
$tempItem['id'] = $post->getInt('usergroup_id', 0);
|
||||
$tempItem['title'] = $post->getString('title', '');
|
||||
|
||||
$can_save = true;
|
||||
// check that we have a name
|
||||
if (empty($tempItem['title']))
|
||||
{
|
||||
// we show a warning message
|
||||
$tempItem['name'] = '';
|
||||
$this->getApplication()->enqueueMessage('User group name field is required.', 'error');
|
||||
$can_save = false;
|
||||
}
|
||||
// set the params
|
||||
$build_params = $this->model->getGroupDefaultsAccess();
|
||||
if (isset($tempItem['params']) && is_array($tempItem['params']) && count($tempItem['params']))
|
||||
{
|
||||
$only = 'CRUD';
|
||||
foreach ($build_params as $n => &$item)
|
||||
{
|
||||
if (isset($tempItem['params'][$item->area]) && strlen($tempItem['params'][$item->area]))
|
||||
{
|
||||
$array_of_access = str_split(strtoupper($tempItem['params'][$item->area]));
|
||||
$access_keeper = [];
|
||||
if ($array_of_access)
|
||||
{
|
||||
foreach ($array_of_access as $char)
|
||||
{
|
||||
if (strpos($only, $char) === false)
|
||||
{
|
||||
$this->getApplication()->enqueueMessage("User group access in ({$item->area} area) had a wrong key ({$char}) so we removed it. Please only use the keys prescribed.", 'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
$access_keeper[] = $char;
|
||||
}
|
||||
}
|
||||
}
|
||||
$item->access = implode($access_keeper);
|
||||
}
|
||||
}
|
||||
}
|
||||
// update the params
|
||||
$tempItem['params'] = $build_params;
|
||||
|
||||
// can we save the item
|
||||
if ($can_save)
|
||||
{
|
||||
return $this->model->setItem(
|
||||
$tempItem['id'],
|
||||
$tempItem['title'],
|
||||
$tempItem['params']);
|
||||
}
|
||||
|
||||
// add to model the post values
|
||||
$this->model->tempItem = $tempItem;
|
||||
|
||||
return $tempItem['id'];
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 20th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Octoleo\CMS\Controller\Util\AccessInterface;
|
||||
use Octoleo\CMS\Controller\Util\AccessTrait;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
||||
use Octoleo\CMS\Factory;
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\View\Admin\UsergroupsHtmlView;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
||||
*/
|
||||
class UsergroupsController extends AbstractController implements AccessInterface, CheckTokenInterface
|
||||
{
|
||||
use AccessTrait, CheckTokenTrait;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var UsergroupsHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param UsergroupsHtmlView $view The view object.
|
||||
* @param Input|null $input The input object.
|
||||
* @param AbstractApplication|null $app The application object.
|
||||
* @param User|null $user
|
||||
*/
|
||||
public function __construct(
|
||||
UsergroupsHtmlView $view,
|
||||
Input $input = null,
|
||||
AbstractApplication $app = null,
|
||||
User $user = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->view = $view;
|
||||
$this->user = ($user) ?: Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$this->view->setActiveView('usergroups');
|
||||
|
||||
// check if user is allowed to access
|
||||
if ($this->allow('usergroups') && $this->user->get('access.usergroup.read', false))
|
||||
{
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// go to set page
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
93
week-07/project/libraries/src/Controller/UsersController.php
Normal file
93
week-07/project/libraries/src/Controller/UsersController.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Joomla\Input\Input;
|
||||
use Octoleo\CMS\Controller\Util\AccessInterface;
|
||||
use Octoleo\CMS\Controller\Util\AccessTrait;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
||||
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
||||
use Octoleo\CMS\Factory;
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\View\Admin\UsersHtmlView;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
|
||||
/**
|
||||
* Controller handling the requests
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
||||
*/
|
||||
class UsersController extends AbstractController implements AccessInterface, CheckTokenInterface
|
||||
{
|
||||
use AccessTrait, CheckTokenTrait;
|
||||
|
||||
/**
|
||||
* The view object.
|
||||
*
|
||||
* @var UsersHtmlView
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param UsersHtmlView $view The view object.
|
||||
* @param Input $input The input object.
|
||||
* @param AbstractApplication $app The application object.
|
||||
*/
|
||||
public function __construct(
|
||||
UsersHtmlView $view,
|
||||
Input $input = null,
|
||||
AbstractApplication $app = null,
|
||||
User $user = null)
|
||||
{
|
||||
parent::__construct($input, $app);
|
||||
|
||||
$this->view = $view;
|
||||
$this->user = ($user) ?: Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Do not Enable browser caching
|
||||
$this->getApplication()->allowCache(false);
|
||||
|
||||
$this->view->setActiveView('users');
|
||||
|
||||
// check if user is allowed to access
|
||||
if ($this->allow('users') && $this->user->get('access.user.read', false))
|
||||
{
|
||||
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// go to set page
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller\Util;
|
||||
|
||||
/**
|
||||
* Class for checking the user access
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface AccessInterface
|
||||
{
|
||||
/**
|
||||
* @param string $task
|
||||
* @param string $default
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function allow(string $task, string $default = ''): bool;
|
||||
}
|
111
week-07/project/libraries/src/Controller/Util/AccessTrait.php
Normal file
111
week-07/project/libraries/src/Controller/Util/AccessTrait.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller\Util;
|
||||
|
||||
use Joomla\Uri\Uri;
|
||||
|
||||
/**
|
||||
* Trait for checking the user access
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait AccessTrait
|
||||
{
|
||||
/**
|
||||
* When access not allowed this is the path to redirect to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $noAccessRedirect = '';
|
||||
|
||||
/**
|
||||
* Check if user is allowed to access this area
|
||||
*
|
||||
* @param string $task
|
||||
* @param string $default
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function allow(string $task = 'post', string $default = ''): bool
|
||||
{
|
||||
// our little access controller TODO: we can do better
|
||||
$has_access = false;
|
||||
|
||||
/** @var \Octoleo\CMS\Application\AdminApplication $app */
|
||||
$app = $this->getApplication();
|
||||
|
||||
/** @var \Octoleo\CMS\User\UserFactory $userFactory */
|
||||
$userFactory = $app->getUserFactory();
|
||||
|
||||
// user actions [logout]
|
||||
if ('logout' === $task)
|
||||
{
|
||||
if ($userFactory->logout())
|
||||
{
|
||||
$this->noAccessRedirect = '/';
|
||||
// clear the message queue
|
||||
$app->getMessageQueue(true);
|
||||
}
|
||||
}
|
||||
// check if this is a user valid
|
||||
elseif ($userFactory->active())
|
||||
{
|
||||
$has_access = true;
|
||||
}
|
||||
// user actions [access, signup]
|
||||
elseif ('access' === $task || 'signup' === $task)
|
||||
{
|
||||
if ('access' === $task)
|
||||
{
|
||||
if ($userFactory->login())
|
||||
{
|
||||
$has_access = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($userFactory->create())
|
||||
{
|
||||
$has_access = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->noAccessRedirect = '/?account=signup';
|
||||
}
|
||||
}
|
||||
|
||||
// we by default always load the dashboard
|
||||
$this->view->setActiveDashboard($default);
|
||||
}
|
||||
|
||||
return $has_access;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $target
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _redirect(string $target = null)
|
||||
{
|
||||
// get uri request to get host
|
||||
$uri = new Uri($this->getApplication()->get('uri.request'));
|
||||
|
||||
// get redirect path
|
||||
$redirect = (!empty($target)) ? $target : $this->noAccessRedirect;
|
||||
// fix the path
|
||||
$path = $uri->getPath();
|
||||
$path = substr($path, 0, strripos($path, '/')) . '/' . $redirect;
|
||||
// redirect to the set area
|
||||
$this->getApplication()->redirect($uri->getScheme() . '://' . $uri->getHost() . $path );
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller\Util;
|
||||
|
||||
/**
|
||||
* Class for checking the form had a token
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface CheckTokenInterface
|
||||
{
|
||||
/**
|
||||
* Check the token of the form
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkToken(): bool;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller\Util;
|
||||
|
||||
/**
|
||||
* Class for checking the form had a token
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait CheckTokenTrait
|
||||
{
|
||||
/**
|
||||
* Check the token of the form
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkToken(): bool
|
||||
{
|
||||
$token = $this->getApplication()->getSession()->getToken();
|
||||
$form_token = $this->getInput()->getString($token, 0);
|
||||
|
||||
if ($form_token == 0)
|
||||
{
|
||||
exit('Invalid form token');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Controller;
|
||||
|
||||
use Joomla\Controller\AbstractController;
|
||||
use Laminas\Diactoros\Response\TextResponse;
|
||||
|
||||
/**
|
||||
* Controller class to display a message to individuals looking for the wrong CMS
|
||||
*
|
||||
* @method \Octoleo\CMS\Application\SiteApplication getApplication() Get the application object.
|
||||
* @property-read \Octoleo\CMS\Application\SiteApplication $app Application object
|
||||
*/
|
||||
class WrongCmsController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function execute(): bool
|
||||
{
|
||||
// Enable browser caching
|
||||
$this->getApplication()->allowCache(true);
|
||||
|
||||
$response = new TextResponse("This isn't the what you're looking for.", 404);
|
||||
|
||||
$this->getApplication()->setResponse($response);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
484
week-07/project/libraries/src/Date/Date.php
Normal file
484
week-07/project/libraries/src/Date/Date.php
Normal file
@ -0,0 +1,484 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Content Management System
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Date;
|
||||
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Octoleo\CMS\Factory;
|
||||
|
||||
/**
|
||||
* Date is a class that stores a date and provides logic to manipulate
|
||||
* and render that date in a variety of formats.
|
||||
*
|
||||
* @method Date|bool add(\DateInterval $interval) Adds an amount of days, months, years, hours, minutes and seconds to a Date object.
|
||||
* @method Date|bool sub(\DateInterval $interval) Subtracts an amount of days, months, years, hours, minutes and seconds from a Date object.
|
||||
* @method Date|bool modify(string $modify) Alter the timestamp of this object by incre/decre-menting in a format accepted by strtotime().
|
||||
*
|
||||
* @property-read string $daysinmonth t - Number of days in the given month.
|
||||
* @property-read string $dayofweek N - ISO-8601 numeric representation of the day of the week.
|
||||
* @property-read string $dayofyear z - The day of the year (starting from 0).
|
||||
* @property-read boolean $isleapyear L - Whether it's a leap year.
|
||||
* @property-read string $day d - Day of the month, 2 digits with leading zeros.
|
||||
* @property-read string $hour H - 24-hour format of an hour with leading zeros.
|
||||
* @property-read string $minute i - Minutes with leading zeros.
|
||||
* @property-read string $second s - Seconds with leading zeros.
|
||||
* @property-read string $microsecond u - Microseconds with leading zeros.
|
||||
* @property-read string $month m - Numeric representation of a month, with leading zeros.
|
||||
* @property-read string $ordinal S - English ordinal suffix for the day of the month, 2 characters.
|
||||
* @property-read string $week W - ISO-8601 week number of year, weeks starting on Monday.
|
||||
* @property-read string $year Y - A full numeric representation of a year, 4 digits.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
class Date extends \DateTime
|
||||
{
|
||||
const DAY_ABBR = "\x021\x03";
|
||||
const DAY_NAME = "\x022\x03";
|
||||
const MONTH_ABBR = "\x023\x03";
|
||||
const MONTH_NAME = "\x024\x03";
|
||||
|
||||
/**
|
||||
* The format string to be applied when using the __toString() magic method.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public static $format = 'Y-m-d H:i:s';
|
||||
|
||||
/**
|
||||
* Placeholder for a \DateTimeZone object with GMT as the time zone.
|
||||
*
|
||||
* @var object
|
||||
* @since 1.7.0
|
||||
*
|
||||
* @deprecated 5.0 Without replacement
|
||||
*/
|
||||
protected static $gmt;
|
||||
|
||||
/**
|
||||
* Placeholder for a \DateTimeZone object with the default server
|
||||
* time zone as the time zone.
|
||||
*
|
||||
* @var object
|
||||
* @since 1.7.0
|
||||
*
|
||||
* @deprecated 5.0 Without replacement
|
||||
*/
|
||||
protected static $stz;
|
||||
|
||||
/**
|
||||
* The \DateTimeZone object for usage in rending dates as strings.
|
||||
*
|
||||
* @var \DateTimeZone
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected $tz;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $date String in a format accepted by strtotime(), defaults to "now".
|
||||
* @param mixed $tz Time zone to be used for the date. Might be a string or a DateTimeZone object.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function __construct($date = 'now', $tz = null)
|
||||
{
|
||||
// Create the base GMT and server time zone objects.
|
||||
if (empty(self::$gmt) || empty(self::$stz))
|
||||
{
|
||||
// @TODO: This code block stays here only for B/C, can be removed in 5.0
|
||||
self::$gmt = new \DateTimeZone('GMT');
|
||||
self::$stz = new \DateTimeZone(@date_default_timezone_get());
|
||||
}
|
||||
|
||||
// If the time zone object is not set, attempt to build it.
|
||||
if (!($tz instanceof \DateTimeZone))
|
||||
{
|
||||
if (\is_string($tz))
|
||||
{
|
||||
$tz = new \DateTimeZone($tz);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tz = new \DateTimeZone('UTC');
|
||||
}
|
||||
}
|
||||
|
||||
// Backup active time zone
|
||||
$activeTZ = date_default_timezone_get();
|
||||
|
||||
// Force UTC timezone for correct time handling
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// If the date is numeric assume a unix timestamp and convert it.
|
||||
$date = is_numeric($date) ? date('c', $date) : $date;
|
||||
|
||||
// Call the DateTime constructor.
|
||||
parent::__construct($date, $tz);
|
||||
|
||||
// Restore previously active timezone
|
||||
date_default_timezone_set($activeTZ);
|
||||
|
||||
// Set the timezone object for access later.
|
||||
$this->tz = $tz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to access properties of the date given by class to the format method.
|
||||
*
|
||||
* @param string $name The name of the property.
|
||||
*
|
||||
* @return mixed A value if the property name is valid, null otherwise.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
$value = null;
|
||||
|
||||
switch ($name)
|
||||
{
|
||||
case 'daysinmonth':
|
||||
$value = $this->format('t', true);
|
||||
break;
|
||||
|
||||
case 'dayofweek':
|
||||
$value = $this->format('N', true);
|
||||
break;
|
||||
|
||||
case 'dayofyear':
|
||||
$value = $this->format('z', true);
|
||||
break;
|
||||
|
||||
case 'isleapyear':
|
||||
$value = (boolean) $this->format('L', true);
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$value = $this->format('d', true);
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$value = $this->format('H', true);
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$value = $this->format('i', true);
|
||||
break;
|
||||
|
||||
case 'second':
|
||||
$value = $this->format('s', true);
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$value = $this->format('m', true);
|
||||
break;
|
||||
|
||||
case 'ordinal':
|
||||
$value = $this->format('S', true);
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$value = $this->format('W', true);
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$value = $this->format('Y', true);
|
||||
break;
|
||||
|
||||
default:
|
||||
$trace = debug_backtrace();
|
||||
trigger_error(
|
||||
'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'],
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to render the date object in the format specified in the public
|
||||
* static member Date::$format.
|
||||
*
|
||||
* @return string The date as a formatted string.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) parent::format(self::$format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy for new Date().
|
||||
*
|
||||
* @param string $date String in a format accepted by strtotime(), defaults to "now".
|
||||
* @param mixed $tz Time zone to be used for the date.
|
||||
*
|
||||
* @return Date
|
||||
*
|
||||
* @since 1.7.3
|
||||
*/
|
||||
public static function getInstance($date = 'now', $tz = null)
|
||||
{
|
||||
return new static($date, $tz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates day of week number to a string.
|
||||
*
|
||||
* @param integer $day The numeric day of the week.
|
||||
* @param boolean $abbr Return the abbreviated day string?
|
||||
*
|
||||
* @return string The day of the week.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function dayToString($day, $abbr = false)
|
||||
{
|
||||
switch ($day)
|
||||
{
|
||||
case 0:
|
||||
return $abbr ? 'Sun' : 'Sunday';
|
||||
case 1:
|
||||
return $abbr ? 'Mon' : 'Monday';
|
||||
case 2:
|
||||
return $abbr ? 'Tue' : 'Tuesday';
|
||||
case 3:
|
||||
return $abbr ? 'Wed' : 'Wednesday';
|
||||
case 4:
|
||||
return $abbr ? 'Thu' : 'Thursday';
|
||||
case 5:
|
||||
return $abbr ? 'Fri' : 'Friday';
|
||||
case 6:
|
||||
return $abbr ? 'Sat' : 'Saturday';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date as a formatted string in a local calendar.
|
||||
*
|
||||
* @param string $format The date format specification string (see {@link PHP_MANUAL#date})
|
||||
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
|
||||
* @param boolean $translate True to translate localised strings
|
||||
*
|
||||
* @return string The date string in the specified format format.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function calendar($format, $local = false, $translate = true)
|
||||
{
|
||||
return $this->format($format, $local, $translate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date as a formatted string.
|
||||
*
|
||||
* @param string $format The date format specification string (see {@link PHP_MANUAL#date})
|
||||
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
|
||||
* @param boolean $translate True to translate localised strings
|
||||
*
|
||||
* @return string The date string in the specified format format.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function format($format, $local = false, $translate = true)
|
||||
{
|
||||
if ($translate)
|
||||
{
|
||||
// Do string replacements for date format options that can be translated.
|
||||
$format = preg_replace('/(^|[^\\\])D/', "\\1" . self::DAY_ABBR, $format);
|
||||
$format = preg_replace('/(^|[^\\\])l/', "\\1" . self::DAY_NAME, $format);
|
||||
$format = preg_replace('/(^|[^\\\])M/', "\\1" . self::MONTH_ABBR, $format);
|
||||
$format = preg_replace('/(^|[^\\\])F/', "\\1" . self::MONTH_NAME, $format);
|
||||
}
|
||||
|
||||
// If the returned time should not be local use UTC.
|
||||
if ($local == false)
|
||||
{
|
||||
parent::setTimezone(new \DateTimeZone('UTC'));
|
||||
}
|
||||
|
||||
// Format the date.
|
||||
$return = parent::format($format);
|
||||
|
||||
if ($translate)
|
||||
{
|
||||
// Manually modify the month and day strings in the formatted time.
|
||||
if (strpos($return, self::DAY_ABBR) !== false)
|
||||
{
|
||||
$return = str_replace(self::DAY_ABBR, $this->dayToString(parent::format('w'), true), $return);
|
||||
}
|
||||
|
||||
if (strpos($return, self::DAY_NAME) !== false)
|
||||
{
|
||||
$return = str_replace(self::DAY_NAME, $this->dayToString(parent::format('w')), $return);
|
||||
}
|
||||
|
||||
if (strpos($return, self::MONTH_ABBR) !== false)
|
||||
{
|
||||
$return = str_replace(self::MONTH_ABBR, $this->monthToString(parent::format('n'), true), $return);
|
||||
}
|
||||
|
||||
if (strpos($return, self::MONTH_NAME) !== false)
|
||||
{
|
||||
$return = str_replace(self::MONTH_NAME, $this->monthToString(parent::format('n')), $return);
|
||||
}
|
||||
}
|
||||
|
||||
if ($local == false && $this->tz !== null)
|
||||
{
|
||||
parent::setTimezone($this->tz);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time offset from GMT in hours or seconds.
|
||||
*
|
||||
* @param boolean $hours True to return the value in hours.
|
||||
*
|
||||
* @return float The time offset from GMT either in hours or in seconds.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function getOffsetFromGmt($hours = false)
|
||||
{
|
||||
return (float) $hours ? ($this->tz->getOffset($this) / 3600) : $this->tz->getOffset($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates month number to a string.
|
||||
*
|
||||
* @param integer $month The numeric month of the year.
|
||||
* @param boolean $abbr If true, return the abbreviated month string
|
||||
*
|
||||
* @return string The month of the year.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function monthToString($month, $abbr = false)
|
||||
{
|
||||
switch ($month)
|
||||
{
|
||||
case 1:
|
||||
return $abbr ? 'Jan' : 'January'; //
|
||||
case 2:
|
||||
return $abbr ? 'Feb' : 'February';
|
||||
case 3:
|
||||
return $abbr ? 'Mar' : 'March';
|
||||
case 4:
|
||||
return $abbr ? 'Apr' : 'April';
|
||||
case 5:
|
||||
return 'May';
|
||||
case 6:
|
||||
return $abbr ? 'Jun' : 'June';
|
||||
case 7:
|
||||
return $abbr ? 'Jul' : 'July';
|
||||
case 8:
|
||||
return $abbr ? 'Aug' : 'August';
|
||||
case 9:
|
||||
return $abbr ? 'Sep' : 'September';
|
||||
case 10:
|
||||
return $abbr ? 'Oct' : 'October';
|
||||
case 11:
|
||||
return $abbr ? 'Nov' : 'November';
|
||||
case 12:
|
||||
return $abbr ? 'Dec' : 'December';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to wrap the setTimezone() function and set the internal time zone object.
|
||||
*
|
||||
* @param \DateTimeZone $tz The new \DateTimeZone object.
|
||||
*
|
||||
* @return Date
|
||||
*
|
||||
* @since 1.7.0
|
||||
* @note This method can't be type hinted due to a PHP bug: https://bugs.php.net/bug.php?id=61483
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function setTimezone($tz)
|
||||
{
|
||||
$this->tz = $tz;
|
||||
|
||||
return parent::setTimezone($tz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date as an ISO 8601 string. IETF RFC 3339 defines the ISO 8601 format
|
||||
* and it can be found at the IETF Web site.
|
||||
*
|
||||
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
|
||||
*
|
||||
* @return string The date string in ISO 8601 format.
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc3339.txt
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function toISO8601($local = false)
|
||||
{
|
||||
return $this->format(\DateTimeInterface::RFC3339, $local, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date as an SQL datetime string.
|
||||
*
|
||||
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
|
||||
* @param DatabaseInterface $db The database driver or null to use Factory::getDbo()
|
||||
*
|
||||
* @return string The date string in SQL datetime format.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 2.5.0
|
||||
* @link http://dev.mysql.com/doc/refman/5.0/en/datetime.html
|
||||
*/
|
||||
public function toSql($local = false, DatabaseInterface $db = null)
|
||||
{
|
||||
if ($db === null)
|
||||
{
|
||||
/** @var \Joomla\Database\DatabaseInterface $db */
|
||||
$db = Factory::getContainer()->get(DatabaseInterface::class);
|
||||
}
|
||||
|
||||
return $this->format($db->getDateFormat(), $local, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date as an RFC 822 string. IETF RFC 2822 supercedes RFC 822 and its definition
|
||||
* can be found at the IETF Web site.
|
||||
*
|
||||
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
|
||||
*
|
||||
* @return string The date string in RFC 822 format.
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc2822.txt
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function toRFC822($local = false)
|
||||
{
|
||||
return $this->format(\DateTimeInterface::RFC2822, $local, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date as UNIX time stamp.
|
||||
*
|
||||
* @return integer The date as a UNIX timestamp.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function toUnix()
|
||||
{
|
||||
return (int) parent::format('U');
|
||||
}
|
||||
}
|
195
week-07/project/libraries/src/EventListener/ErrorSubscriber.php
Normal file
195
week-07/project/libraries/src/EventListener/ErrorSubscriber.php
Normal file
@ -0,0 +1,195 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Framework Website
|
||||
*
|
||||
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\EventListener;
|
||||
|
||||
use Joomla\Application\ApplicationEvents;
|
||||
use Joomla\Application\Event\ApplicationErrorEvent;
|
||||
use Joomla\Console\ConsoleEvents;
|
||||
use Joomla\Console\Event\ApplicationErrorEvent as ConsoleApplicationErrorEvent;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
use Octoleo\CMS\Application\SiteApplication;
|
||||
use Joomla\Renderer\RendererInterface;
|
||||
use Joomla\Router\Exception\MethodNotAllowedException;
|
||||
use Joomla\Router\Exception\RouteNotFoundException;
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
use Laminas\Diactoros\Response\JsonResponse;
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Psr\Log\LoggerAwareTrait;
|
||||
|
||||
/**
|
||||
* Error handling event subscriber
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/EventListener/ErrorSubscriber.php
|
||||
*/
|
||||
class ErrorSubscriber implements SubscriberInterface, LoggerAwareInterface
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
|
||||
/**
|
||||
* Layout renderer
|
||||
*
|
||||
* @var RendererInterface
|
||||
*/
|
||||
private $renderer;
|
||||
|
||||
/**
|
||||
* Event subscriber constructor.
|
||||
*
|
||||
* @param RendererInterface $renderer Layout renderer
|
||||
*/
|
||||
public function __construct(RendererInterface $renderer)
|
||||
{
|
||||
$this->renderer = $renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of events this subscriber will listen to.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
ApplicationEvents::ERROR => 'handleWebError',
|
||||
ConsoleEvents::APPLICATION_ERROR => 'handleConsoleError',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle console application errors.
|
||||
*
|
||||
* @param ConsoleApplicationErrorEvent $event Event object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handleConsoleError(ConsoleApplicationErrorEvent $event): void
|
||||
{
|
||||
$this->logError($event->getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle web application errors.
|
||||
*
|
||||
* @param ApplicationErrorEvent $event Event object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handleWebError(ApplicationErrorEvent $event): void
|
||||
{
|
||||
/** @var SiteApplication $app */
|
||||
$app = $event->getApplication();
|
||||
|
||||
switch (true)
|
||||
{
|
||||
case $event->getError() instanceof MethodNotAllowedException :
|
||||
// Log the error for reference
|
||||
$this->logger->error(
|
||||
sprintf('Route `%s` not supported by method `%s`', $app->get('uri.route'), $app->input->getMethod()),
|
||||
['exception' => $event->getError()]
|
||||
);
|
||||
|
||||
$this->prepareResponse($event);
|
||||
|
||||
$app->setHeader('Allow', implode(', ', $event->getError()->getAllowedMethods()));
|
||||
|
||||
break;
|
||||
|
||||
case $event->getError() instanceof RouteNotFoundException :
|
||||
// Log the error for reference
|
||||
$this->logger->error(
|
||||
sprintf('Route `%s` not found', $app->get('uri.route')),
|
||||
['exception' => $event->getError()]
|
||||
);
|
||||
|
||||
$this->prepareResponse($event);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->logError($event->getError());
|
||||
|
||||
$this->prepareResponse($event);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the error.
|
||||
*
|
||||
* @param \Throwable $throwable The error being processed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function logError(\Throwable $throwable): void
|
||||
{
|
||||
$this->logger->error(
|
||||
sprintf('Uncaught Throwable of type %s caught.', \get_class($throwable)),
|
||||
['exception' => $throwable]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the response for the event
|
||||
*
|
||||
* @param ApplicationErrorEvent $event Event object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function prepareResponse(ApplicationErrorEvent $event): void
|
||||
{
|
||||
/** @var SiteApplication $app */
|
||||
$app = $event->getApplication();
|
||||
|
||||
$app->allowCache(false);
|
||||
|
||||
switch (true)
|
||||
{
|
||||
case $app->input->getString('_format', 'html') === 'json' :
|
||||
case $app->mimeType === 'application/json' :
|
||||
case $app->getResponse() instanceof JsonResponse :
|
||||
$data = [
|
||||
'code' => $event->getError()->getCode(),
|
||||
'message' => $event->getError()->getMessage(),
|
||||
'error' => true,
|
||||
];
|
||||
|
||||
$response = new JsonResponse($data);
|
||||
|
||||
break;
|
||||
|
||||
default :
|
||||
$response = new HtmlResponse(
|
||||
$this->renderer->render('exception.twig', ['exception' => $event->getError()])
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($event->getError()->getCode())
|
||||
{
|
||||
case 404 :
|
||||
$response = $response->withStatus(404);
|
||||
|
||||
break;
|
||||
|
||||
case 405 :
|
||||
$response = $response->withStatus(405);
|
||||
|
||||
break;
|
||||
|
||||
case 500 :
|
||||
default :
|
||||
$response = $response->withStatus(500);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$app->setResponse($response);
|
||||
}
|
||||
}
|
301
week-07/project/libraries/src/Factory.php
Normal file
301
week-07/project/libraries/src/Factory.php
Normal file
@ -0,0 +1,301 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 3rd April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS;
|
||||
|
||||
\defined('LPATH_PLATFORM') or die;
|
||||
|
||||
use Joomla\Application\WebApplicationInterface;
|
||||
use Joomla\Database\Service\DatabaseProvider;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\Registry\Registry;
|
||||
use PHPMailer\PHPMailer\Exception as phpmailerException;
|
||||
|
||||
/**
|
||||
* Octoleo Platform Factory class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* SOURCE: https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/src/Factory.php#L39
|
||||
*/
|
||||
abstract class Factory
|
||||
{
|
||||
/**
|
||||
* Global application object
|
||||
*
|
||||
* @var WebApplicationInterface
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static $application = null;
|
||||
|
||||
/**
|
||||
* Global configuration object
|
||||
*
|
||||
* @var \LConfig
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static $config = null;
|
||||
|
||||
/**
|
||||
* Global container object
|
||||
*
|
||||
* @var Container
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static $container = null;
|
||||
|
||||
/**
|
||||
* Global mailer object
|
||||
*
|
||||
* @var Mail
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static $mailer = null;
|
||||
|
||||
/**
|
||||
* Get the global application object. When the global application doesn't exist, an exception is thrown.
|
||||
*
|
||||
* @return WebApplicationInterface object
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getApplication() : WebApplicationInterface
|
||||
{
|
||||
if (!self::$application)
|
||||
{
|
||||
throw new \Exception('Failed to start application', 500);
|
||||
}
|
||||
|
||||
return self::$application;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a container object
|
||||
*
|
||||
* Returns the global service container object, only creating it if it doesn't already exist.
|
||||
*
|
||||
* This method is only suggested for use in code whose responsibility is to create new services
|
||||
* and needs to be able to resolve the dependencies, and should therefore only be used when the
|
||||
* container is not accessible by other means. Valid uses of this method include:
|
||||
*
|
||||
* - A static `getInstance()` method calling a factory service from the container,
|
||||
* see `Joomla\CMS\Toolbar\Toolbar::getInstance()` as an example
|
||||
* - An application front controller loading and executing the Joomla application class,
|
||||
* see the `cli/joomla.php` file as an example
|
||||
* - Retrieving optional constructor dependencies when not injected into a class during a transitional
|
||||
* period to retain backward compatibility, in this case a deprecation notice should also be emitted to
|
||||
* notify developers of changes needed in their code
|
||||
*
|
||||
* This method is not suggested for use as a one-for-one replacement of static calls, such as
|
||||
* replacing calls to `Factory::getDbo()` with calls to `Factory::getContainer()->get('db')`, code
|
||||
* should be refactored to support dependency injection instead of making this change.
|
||||
*
|
||||
* @return Container
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public static function getContainer(): Container
|
||||
{
|
||||
if (!self::$container)
|
||||
{
|
||||
self::$container = self::createContainer();
|
||||
}
|
||||
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a mailer object.
|
||||
*
|
||||
* Returns the global {@link Mail} object, only creating it if it doesn't already exist.
|
||||
*
|
||||
* @return Mail object
|
||||
*
|
||||
* @see Mail
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public static function getMailer()
|
||||
{
|
||||
if (!self::$mailer)
|
||||
{
|
||||
self::$mailer = self::createMailer();
|
||||
}
|
||||
|
||||
$copy = clone self::$mailer;
|
||||
|
||||
return $copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container)
|
||||
->registerServiceProvider(new Service\ConfigurationProvider(LPATH_CONFIGURATION . '/octoconfig.php'))
|
||||
->registerServiceProvider(new Service\SessionProvider)
|
||||
->registerServiceProvider(new Service\UserProvider)
|
||||
->registerServiceProvider(new Service\InputProvider)
|
||||
->registerServiceProvider(new DatabaseProvider)
|
||||
->registerServiceProvider(new Service\EventProvider)
|
||||
->registerServiceProvider(new Service\HttpProvider)
|
||||
->registerServiceProvider(new Service\LoggingProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration object
|
||||
*
|
||||
* Returns the global {@link \JConfig} object, only creating it if it doesn't already exist.
|
||||
*
|
||||
* @param string $file The path to the configuration file
|
||||
* @param string $type The type of the configuration file
|
||||
* @param string $namespace The namespace of the configuration file
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @see Registry
|
||||
* @since 1.1.1
|
||||
*/
|
||||
public static function getConfig($file = null, $type = 'PHP', $namespace = '')
|
||||
{
|
||||
/**
|
||||
* If there is an application object, fetch the configuration from there.
|
||||
* Check it's not null because LanguagesModel can make it null and if it's null
|
||||
* we would want to re-init it from configuration.php.
|
||||
*/
|
||||
if (self::$application && self::$application->getConfig() !== null)
|
||||
{
|
||||
return self::$application->getConfig();
|
||||
}
|
||||
|
||||
if (!self::$config)
|
||||
{
|
||||
if ($file === null)
|
||||
{
|
||||
$file = JPATH_CONFIGURATION . '/octoconfig.php';
|
||||
}
|
||||
|
||||
self::$config = self::createConfig($file, $type, $namespace);
|
||||
}
|
||||
|
||||
return self::$config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a configuration object
|
||||
*
|
||||
* @param string $file The path to the configuration file.
|
||||
* @param string $type The type of the configuration file.
|
||||
* @param string $namespace The namespace of the configuration file.
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @see Registry
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static function createConfig($file, $type = 'PHP', $namespace = '')
|
||||
{
|
||||
if (is_file($file))
|
||||
{
|
||||
include_once $file;
|
||||
}
|
||||
|
||||
// Create the registry with a default namespace of config
|
||||
$registry = new Registry;
|
||||
|
||||
// Sanitize the namespace.
|
||||
$namespace = ucfirst((string) preg_replace('/[^A-Z_]/i', '', $namespace));
|
||||
|
||||
// Build the config name.
|
||||
$name = 'LConfig' . $namespace;
|
||||
|
||||
// Handle the PHP configuration type.
|
||||
if ($type === 'PHP' && class_exists($name))
|
||||
{
|
||||
// Create the LConfig object
|
||||
$config = new $name;
|
||||
|
||||
// Load the configuration values into the registry
|
||||
$registry->loadObject($config);
|
||||
}
|
||||
|
||||
return $registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a mailer object
|
||||
*
|
||||
* @return Mail object
|
||||
*
|
||||
* @see Mail
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static function createMailer()
|
||||
{
|
||||
// $conf = self::getConfig();
|
||||
//
|
||||
// $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1;
|
||||
// $smtpuser = $conf->get('smtpuser');
|
||||
// $smtppass = $conf->get('smtppass');
|
||||
// $smtphost = $conf->get('smtphost');
|
||||
// $smtpsecure = $conf->get('smtpsecure');
|
||||
// $smtpport = $conf->get('smtpport');
|
||||
// $mailfrom = $conf->get('mailfrom');
|
||||
// $fromname = $conf->get('fromname');
|
||||
// $mailer = $conf->get('mailer');
|
||||
//
|
||||
// // Create a Mail object
|
||||
// $mail = Mail::getInstance();
|
||||
//
|
||||
// // Clean the email address
|
||||
// $mailfrom = MailHelper::cleanLine($mailfrom);
|
||||
//
|
||||
// // Set default sender without Reply-to if the mailfrom is a valid address
|
||||
// if (MailHelper::isEmailAddress($mailfrom))
|
||||
// {
|
||||
// // Wrap in try/catch to catch phpmailerExceptions if it is throwing them
|
||||
// try
|
||||
// {
|
||||
// // Check for a false return value if exception throwing is disabled
|
||||
// if ($mail->setFrom($mailfrom, MailHelper::cleanLine($fromname), false) === false)
|
||||
// {
|
||||
// Log::add(__METHOD__ . '() could not set the sender data.', Log::WARNING, 'mail');
|
||||
// }
|
||||
// }
|
||||
// catch (phpmailerException $e)
|
||||
// {
|
||||
// Log::add(__METHOD__ . '() could not set the sender data.', Log::WARNING, 'mail');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Default mailer is to use PHP's mail function
|
||||
// switch ($mailer)
|
||||
// {
|
||||
// case 'smtp':
|
||||
// $mail->useSmtp($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
|
||||
// break;
|
||||
//
|
||||
// case 'sendmail':
|
||||
// $mail->isSendmail();
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// $mail->isMail();
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// return $mail;
|
||||
}
|
||||
}
|
527
week-07/project/libraries/src/Filter/InputFilter.php
Normal file
527
week-07/project/libraries/src/Filter/InputFilter.php
Normal file
@ -0,0 +1,527 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Content Management System
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Filter;
|
||||
|
||||
use Octoleo\CMS\String\PunycodeHelper;
|
||||
use Joomla\Filter\InputFilter as BaseInputFilter;
|
||||
|
||||
/**
|
||||
* InputFilter is a class for filtering input from any data source
|
||||
*
|
||||
* Forked from the php input filter library by: Daniel Morris <dan@rootcube.com>
|
||||
* Original Contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
class InputFilter extends BaseInputFilter
|
||||
{
|
||||
/**
|
||||
* An array containing a list of extensions for files that are typically
|
||||
* executable directly in the webserver context, potentially resulting in code executions
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public const FORBIDDEN_FILE_EXTENSIONS = [
|
||||
'php', 'phps', 'pht', 'phtml', 'php3', 'php4', 'php5', 'php6', 'php7', 'asp',
|
||||
'php8', 'phar', 'inc', 'pl', 'cgi', 'fcgi', 'java', 'jar', 'py', 'aspx'
|
||||
];
|
||||
|
||||
/**
|
||||
* A flag for Unicode Supplementary Characters (4-byte Unicode character) stripping.
|
||||
*
|
||||
* @var integer
|
||||
* @since 3.5
|
||||
*/
|
||||
private $stripUSC = 0;
|
||||
|
||||
/**
|
||||
* A container for InputFilter instances.
|
||||
*
|
||||
* @var InputFilter[]
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected static $instances = array();
|
||||
/**
|
||||
* Constructor for inputFilter class. Only first parameter is required.
|
||||
*
|
||||
* @param array $tagsArray List of user-defined tags
|
||||
* @param array $attrArray List of user-defined attributes
|
||||
* @param integer $tagsMethod The constant static::ONLY_ALLOW_DEFINED_TAGS or static::BLOCK_DEFINED_TAGS
|
||||
* @param integer $attrMethod The constant static::ONLY_ALLOW_DEFINED_ATTRIBUTES or static::BLOCK_DEFINED_ATTRIBUTES
|
||||
* @param integer $xssAuto Only auto clean essentials = 0, Allow clean blocked tags/attributes = 1
|
||||
* @param integer $stripUSC Strip 4-byte unicode characters = 1, no strip = 0
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1, $stripUSC = 0)
|
||||
{
|
||||
parent::__construct($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto);
|
||||
|
||||
// Assign member variables
|
||||
$this->stripUSC = $stripUSC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an input filter object, only creating it if it doesn't already exist.
|
||||
*
|
||||
* @param array $tagsArray List of user-defined tags
|
||||
* @param array $attrArray List of user-defined attributes
|
||||
* @param integer $tagsMethod The constant static::ONLY_ALLOW_DEFINED_TAGS or static::BLOCK_DEFINED_TAGS
|
||||
* @param integer $attrMethod The constant static::ONLY_ALLOW_DEFINED_ATTRIBUTES or static::BLOCK_DEFINED_ATTRIBUTES
|
||||
* @param integer $xssAuto Only auto clean essentials = 0, Allow clean blocked tags/attributes = 1
|
||||
* @param integer $stripUSC Strip 4-byte unicode characters = 1, no strip = 0
|
||||
*
|
||||
* @return InputFilter The InputFilter object.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public static function getInstance($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1, $stripUSC = 0)
|
||||
{
|
||||
$sig = md5(serialize(array($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto)));
|
||||
|
||||
if (empty(self::$instances[$sig]))
|
||||
{
|
||||
self::$instances[$sig] = new InputFilter($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto, $stripUSC);
|
||||
}
|
||||
|
||||
return self::$instances[$sig];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to be called by another php script. Processes for XSS and
|
||||
* specified bad code.
|
||||
*
|
||||
* @param mixed $source Input string/array-of-string to be 'cleaned'
|
||||
* @param string $type The return type for the variable:
|
||||
* INT: An integer, or an array of integers,
|
||||
* UINT: An unsigned integer, or an array of unsigned integers,
|
||||
* FLOAT: A floating point number, or an array of floating point numbers,
|
||||
* BOOLEAN: A boolean value,
|
||||
* WORD: A string containing A-Z or underscores only (not case sensitive),
|
||||
* ALNUM: A string containing A-Z or 0-9 only (not case sensitive),
|
||||
* CMD: A string containing A-Z, 0-9, underscores, periods or hyphens (not case sensitive),
|
||||
* BASE64: A string containing A-Z, 0-9, forward slashes, plus or equals (not case sensitive),
|
||||
* STRING: A fully decoded and sanitised string (default),
|
||||
* HTML: A sanitised string,
|
||||
* ARRAY: An array,
|
||||
* PATH: A sanitised file path, or an array of sanitised file paths,
|
||||
* TRIM: A string trimmed from normal, non-breaking and multibyte spaces
|
||||
* USERNAME: Do not use (use an application specific filter),
|
||||
* RAW: The raw string is returned with no filtering,
|
||||
* unknown: An unknown filter will act like STRING. If the input is an array it will return an
|
||||
* array of fully decoded and sanitised strings.
|
||||
*
|
||||
* @return mixed 'Cleaned' version of input parameter
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public function clean($source, $type = 'string')
|
||||
{
|
||||
// Strip Unicode Supplementary Characters when requested to do so
|
||||
if ($this->stripUSC)
|
||||
{
|
||||
// Alternatively: preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xE2\xAF\x91", $source) but it'd be slower.
|
||||
$source = $this->stripUSC($source);
|
||||
}
|
||||
|
||||
return parent::clean($source, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to punyencode utf8 mail when saving content
|
||||
*
|
||||
* @param string $text The strings to encode
|
||||
*
|
||||
* @return string The punyencoded mail
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
public function emailToPunycode($text)
|
||||
{
|
||||
$pattern = '/(("mailto:)+[\w\.\-\+]+\@[^"?]+\.+[^."?]+("|\?))/';
|
||||
|
||||
if (preg_match_all($pattern, $text, $matches))
|
||||
{
|
||||
foreach ($matches[0] as $match)
|
||||
{
|
||||
$match = (string) str_replace(array('?', '"'), '', $match);
|
||||
$text = (string) str_replace($match, PunycodeHelper::emailToPunycode($match), $text);
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks an uploaded for suspicious naming and potential PHP contents which could indicate a hacking attempt.
|
||||
*
|
||||
* The options you can define are:
|
||||
* null_byte Prevent files with a null byte in their name (buffer overflow attack)
|
||||
* forbidden_extensions Do not allow these strings anywhere in the file's extension
|
||||
* php_tag_in_content Do not allow `<?php` tag in content
|
||||
* phar_stub_in_content Do not allow the `__HALT_COMPILER()` phar stub in content
|
||||
* shorttag_in_content Do not allow short tag `<?` in content
|
||||
* shorttag_extensions Which file extensions to scan for short tags in content
|
||||
* fobidden_ext_in_content Do not allow forbidden_extensions anywhere in content
|
||||
* php_ext_content_extensions Which file extensions to scan for .php in content
|
||||
*
|
||||
* This code is an adaptation and improvement of Admin Tools' UploadShield feature,
|
||||
* relicensed and contributed by its author.
|
||||
*
|
||||
* @param array $file An uploaded file descriptor
|
||||
* @param array $options The scanner options (see the code for details)
|
||||
*
|
||||
* @return boolean True of the file is safe
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
public static function isSafeFile($file, $options = array())
|
||||
{
|
||||
$defaultOptions = array(
|
||||
|
||||
// Null byte in file name
|
||||
'null_byte' => true,
|
||||
|
||||
// Forbidden string in extension (e.g. php matched .php, .xxx.php, .php.xxx and so on)
|
||||
'forbidden_extensions' => self::FORBIDDEN_FILE_EXTENSIONS,
|
||||
|
||||
// <?php tag in file contents
|
||||
'php_tag_in_content' => true,
|
||||
|
||||
// <? tag in file contents
|
||||
'shorttag_in_content' => true,
|
||||
|
||||
// __HALT_COMPILER()
|
||||
'phar_stub_in_content' => true,
|
||||
|
||||
// Which file extensions to scan for short tags
|
||||
'shorttag_extensions' => array(
|
||||
'inc', 'phps', 'class', 'php3', 'php4', 'php5', 'php6', 'php7', 'php8', 'txt', 'dat', 'tpl', 'tmpl',
|
||||
),
|
||||
|
||||
// Forbidden extensions anywhere in the content
|
||||
'fobidden_ext_in_content' => true,
|
||||
|
||||
// Which file extensions to scan for .php in the content
|
||||
'php_ext_content_extensions' => array('zip', 'rar', 'tar', 'gz', 'tgz', 'bz2', 'tbz', 'jpa'),
|
||||
);
|
||||
|
||||
$options = array_merge($defaultOptions, $options);
|
||||
|
||||
// Make sure we can scan nested file descriptors
|
||||
$descriptors = $file;
|
||||
|
||||
if (isset($file['name']) && isset($file['tmp_name']))
|
||||
{
|
||||
$descriptors = static::decodeFileData(
|
||||
array(
|
||||
$file['name'],
|
||||
$file['type'],
|
||||
$file['tmp_name'],
|
||||
$file['error'],
|
||||
$file['size'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Handle non-nested descriptors (single files)
|
||||
if (isset($descriptors['name']))
|
||||
{
|
||||
$descriptors = array($descriptors);
|
||||
}
|
||||
|
||||
// Scan all descriptors detected
|
||||
foreach ($descriptors as $fileDescriptor)
|
||||
{
|
||||
if (!isset($fileDescriptor['name']))
|
||||
{
|
||||
// This is a nested descriptor. We have to recurse.
|
||||
if (!static::isSafeFile($fileDescriptor, $options))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$tempNames = $fileDescriptor['tmp_name'];
|
||||
$intendedNames = $fileDescriptor['name'];
|
||||
|
||||
if (!\is_array($tempNames))
|
||||
{
|
||||
$tempNames = array($tempNames);
|
||||
}
|
||||
|
||||
if (!\is_array($intendedNames))
|
||||
{
|
||||
$intendedNames = array($intendedNames);
|
||||
}
|
||||
|
||||
$len = \count($tempNames);
|
||||
|
||||
for ($i = 0; $i < $len; $i++)
|
||||
{
|
||||
$tempName = array_shift($tempNames);
|
||||
$intendedName = array_shift($intendedNames);
|
||||
|
||||
// 1. Null byte check
|
||||
if ($options['null_byte'])
|
||||
{
|
||||
if (strstr($intendedName, "\x00"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. PHP-in-extension check (.php, .php.xxx[.yyy[.zzz[...]]], .xxx[.yyy[.zzz[...]]].php)
|
||||
if (!empty($options['forbidden_extensions']))
|
||||
{
|
||||
$explodedName = explode('.', $intendedName);
|
||||
$explodedName = array_reverse($explodedName);
|
||||
array_pop($explodedName);
|
||||
$explodedName = array_map('strtolower', $explodedName);
|
||||
|
||||
/*
|
||||
* DO NOT USE array_intersect HERE! array_intersect expects the two arrays to
|
||||
* be set, i.e. they should have unique values.
|
||||
*/
|
||||
foreach ($options['forbidden_extensions'] as $ext)
|
||||
{
|
||||
if (\in_array($ext, $explodedName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. File contents scanner (PHP tag in file contents)
|
||||
if ($options['php_tag_in_content']
|
||||
|| $options['shorttag_in_content'] || $options['phar_stub_in_content']
|
||||
|| ($options['fobidden_ext_in_content'] && !empty($options['forbidden_extensions'])))
|
||||
{
|
||||
$fp = strlen($tempName) ? @fopen($tempName, 'r') : false;
|
||||
|
||||
if ($fp !== false)
|
||||
{
|
||||
$data = '';
|
||||
|
||||
while (!feof($fp))
|
||||
{
|
||||
$data .= @fread($fp, 131072);
|
||||
|
||||
if ($options['php_tag_in_content'] && stripos($data, '<?php') !== false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($options['phar_stub_in_content'] && stripos($data, '__HALT_COMPILER()') !== false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($options['shorttag_in_content'])
|
||||
{
|
||||
$suspiciousExtensions = $options['shorttag_extensions'];
|
||||
|
||||
if (empty($suspiciousExtensions))
|
||||
{
|
||||
$suspiciousExtensions = array(
|
||||
'inc', 'phps', 'class', 'php3', 'php4', 'txt', 'dat', 'tpl', 'tmpl',
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DO NOT USE array_intersect HERE! array_intersect expects the two arrays to
|
||||
* be set, i.e. they should have unique values.
|
||||
*/
|
||||
$collide = false;
|
||||
|
||||
foreach ($suspiciousExtensions as $ext)
|
||||
{
|
||||
if (\in_array($ext, $explodedName))
|
||||
{
|
||||
$collide = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($collide)
|
||||
{
|
||||
// These are suspicious text files which may have the short tag (<?) in them
|
||||
if (strstr($data, '<?'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['fobidden_ext_in_content'] && !empty($options['forbidden_extensions']))
|
||||
{
|
||||
$suspiciousExtensions = $options['php_ext_content_extensions'];
|
||||
|
||||
if (empty($suspiciousExtensions))
|
||||
{
|
||||
$suspiciousExtensions = array(
|
||||
'zip', 'rar', 'tar', 'gz', 'tgz', 'bz2', 'tbz', 'jpa',
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DO NOT USE array_intersect HERE! array_intersect expects the two arrays to
|
||||
* be set, i.e. they should have unique values.
|
||||
*/
|
||||
$collide = false;
|
||||
|
||||
foreach ($suspiciousExtensions as $ext)
|
||||
{
|
||||
if (\in_array($ext, $explodedName))
|
||||
{
|
||||
$collide = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($collide)
|
||||
{
|
||||
/*
|
||||
* These are suspicious text files which may have an executable
|
||||
* file extension in them
|
||||
*/
|
||||
foreach ($options['forbidden_extensions'] as $ext)
|
||||
{
|
||||
if (strstr($data, '.' . $ext))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This makes sure that we don't accidentally skip a <?php tag if it's across
|
||||
* a read boundary, even on multibyte strings
|
||||
*/
|
||||
$data = substr($data, -10);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to decode a file data array.
|
||||
*
|
||||
* @param array $data The data array to decode.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
protected static function decodeFileData(array $data)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
if (\is_array($data[0]))
|
||||
{
|
||||
foreach ($data[0] as $k => $v)
|
||||
{
|
||||
$result[$k] = static::decodeFileData(array($data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k]));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return array('name' => $data[0], 'type' => $data[1], 'tmp_name' => $data[2], 'error' => $data[3], 'size' => $data[4]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to convert to plaintext
|
||||
*
|
||||
* @param string $source The source string.
|
||||
*
|
||||
* @return string Plaintext string
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function decode($source)
|
||||
{
|
||||
static $ttr;
|
||||
|
||||
if (!\is_array($ttr))
|
||||
{
|
||||
// Entity decode
|
||||
$trans_tbl = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');
|
||||
|
||||
foreach ($trans_tbl as $k => $v)
|
||||
{
|
||||
$ttr[$v] = utf8_encode($k);
|
||||
}
|
||||
}
|
||||
|
||||
$source = strtr($source, $ttr);
|
||||
|
||||
// Convert decimal
|
||||
$source = preg_replace_callback(
|
||||
'/&#(\d+);/m',
|
||||
function ($m) {
|
||||
return utf8_encode(\chr($m[1]));
|
||||
},
|
||||
$source
|
||||
);
|
||||
|
||||
// Convert hex
|
||||
$source = preg_replace_callback(
|
||||
'/&#x([a-f0-9]+);/mi',
|
||||
function ($m) {
|
||||
return utf8_encode(\chr('0x' . $m[1]));
|
||||
},
|
||||
$source
|
||||
);
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively strip Unicode Supplementary Characters from the source. Not: objects cannot be filtered.
|
||||
*
|
||||
* @param mixed $source The data to filter
|
||||
*
|
||||
* @return mixed The filtered result
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function stripUSC($source)
|
||||
{
|
||||
if (\is_object($source))
|
||||
{
|
||||
return $source;
|
||||
}
|
||||
|
||||
if (\is_array($source))
|
||||
{
|
||||
$filteredArray = array();
|
||||
|
||||
foreach ($source as $k => $v)
|
||||
{
|
||||
$filteredArray[$k] = $this->stripUSC($v);
|
||||
}
|
||||
|
||||
return $filteredArray;
|
||||
}
|
||||
|
||||
return preg_replace('/[\xF0-\xF7].../s', "\xE2\xAF\x91", $source);
|
||||
}
|
||||
}
|
47
week-07/project/libraries/src/Model/DashboardModel.php
Normal file
47
week-07/project/libraries/src/Model/DashboardModel.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Model/PackageModel.php
|
||||
*/
|
||||
class DashboardModel implements DatabaseModelInterface
|
||||
{
|
||||
use DatabaseModelTrait;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an active dashboard template name
|
||||
*
|
||||
* @param string $dashboardName The dashboard to lookup
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function getDashboard(string $dashboardName): string
|
||||
{
|
||||
return 'dashboard.twig'; // only one at this time
|
||||
}
|
||||
}
|
287
week-07/project/libraries/src/Model/ItemModel.php
Normal file
287
week-07/project/libraries/src/Model/ItemModel.php
Normal file
@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
use Octoleo\CMS\Date\Date;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
*/
|
||||
class ItemModel implements DatabaseModelInterface
|
||||
{
|
||||
use DatabaseModelTrait;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $tempItem;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $title
|
||||
* @param string $introtext
|
||||
* @param string $fulltext
|
||||
* @param int $state
|
||||
* @param string $created
|
||||
* @param int $createdBy
|
||||
* @param string $createdByAlias
|
||||
* @param string $modified
|
||||
* @param int $modifiedBy
|
||||
* @param string $publishUp
|
||||
* @param string $publishDown
|
||||
* @param string $metakey
|
||||
* @param string $metadesc
|
||||
* @param string $metadata
|
||||
* @param int $featured
|
||||
*
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setItem(
|
||||
int $id,
|
||||
string $title,
|
||||
string $fulltext,
|
||||
int $state,
|
||||
string $created,
|
||||
int $createdBy,
|
||||
string $createdByAlias,
|
||||
string $modified,
|
||||
int $modifiedBy,
|
||||
string $publishUp,
|
||||
string $publishDown,
|
||||
string $metakey,
|
||||
string $metadesc,
|
||||
string $metadata,
|
||||
int $featured): int
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
// extract the intro text
|
||||
$introtext = '';
|
||||
if (strpos($fulltext, '<p>intro-text</p>'))
|
||||
{
|
||||
$bucket = explode('<p>intro-text</p>', $fulltext);
|
||||
$introtext = array_shift($bucket);
|
||||
$fulltext = implode('', $bucket);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => (string) $title,
|
||||
'introtext' => (string) $introtext,
|
||||
'fulltext' => (string) $fulltext,
|
||||
'state' => (int) $state,
|
||||
'created' => (string) $created,
|
||||
'created_by' => (int) $createdBy,
|
||||
'created_by_alias' => (string) $createdByAlias,
|
||||
'modified' => (string) $modified,
|
||||
'modified_by' => (int) $modifiedBy,
|
||||
'publish_up' => (string) (empty($publishUp)) ? '0000-00-00 00:00:00' : (new Date($publishUp))->toSql(),
|
||||
'publish_down' => (string) (empty($publishDown)) ? '0000-00-00 00:00:00' : (new Date($publishDown))->toSql(),
|
||||
'metakey' => (string) $metakey,
|
||||
'metadesc' => (string) $metadesc,
|
||||
'metadata' => (string) $metadata,
|
||||
'featured' => (int) $featured
|
||||
];
|
||||
|
||||
// if we have ID update
|
||||
if ($id > 0)
|
||||
{
|
||||
$data['id'] = (int) $id;
|
||||
// remove what can not now be set
|
||||
unset($data['created']);
|
||||
unset($data['created_by']);
|
||||
// change to object
|
||||
$data = (object) $data;
|
||||
|
||||
try
|
||||
{
|
||||
$db->updateObject('#__item', $data, 'id');
|
||||
}
|
||||
catch (\RuntimeException $exception)
|
||||
{
|
||||
throw new \RuntimeException($exception->getMessage(), 404);
|
||||
}
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove what can not now be set
|
||||
$data['modified'] = '0000-00-00 00:00:00';
|
||||
$data['modified_by'] = 0;
|
||||
// we don't have any params for now
|
||||
$data['params'] = '';
|
||||
// change to object
|
||||
$data = (object) $data;
|
||||
|
||||
try
|
||||
{
|
||||
$db->insertObject('#__item', $data);
|
||||
}
|
||||
catch (\RuntimeException $exception)
|
||||
{
|
||||
throw new \RuntimeException($exception->getMessage(), 404);
|
||||
}
|
||||
|
||||
return $db->insertid();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item
|
||||
*
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return \stdClass
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getItem(?int $id): \stdClass
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// default object (use posted values if set)
|
||||
if (is_array($this->tempItem))
|
||||
{
|
||||
$default = (object) $this->tempItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = new \stdClass();
|
||||
}
|
||||
// to be sure ;)
|
||||
$default->today_date = (new Date())->toSql();
|
||||
$default->post_key = "?task=create";
|
||||
$default->state = 1;
|
||||
|
||||
// we return the default if id not correct
|
||||
if (!is_numeric($id))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__item'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER)
|
||||
->setLimit(1);
|
||||
|
||||
try
|
||||
{
|
||||
$result = $db->setQuery($query)->loadObject();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// we ignore this and just return an empty object
|
||||
}
|
||||
|
||||
if (isset($result) && $result instanceof \stdClass)
|
||||
{
|
||||
$result->post_key = "?id=$id&task=edit";
|
||||
$result->today_date = $default->today_date;
|
||||
// check if we have intro text we add it to full text
|
||||
if (!empty($result->introtext))
|
||||
{
|
||||
$result->fulltext = $result->introtext . '<p>intro-text</p>' . $result->fulltext;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setLayout(string $name): string
|
||||
{
|
||||
return $name . '.twig';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function linked(int $id): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// first check if this item is linked to menu
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('title'))
|
||||
->from($db->quoteName('#__menu'))
|
||||
->where($db->quoteName('item_id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
|
||||
try
|
||||
{
|
||||
$menu = $db->setQuery($query)->loadResult();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// not linked... or something
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($menu)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(int $id): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
// Purge the session
|
||||
$query = $db->getQuery(true)
|
||||
->delete($db->quoteName('#__item'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
try
|
||||
{
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// delete failed
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
54
week-07/project/libraries/src/Model/ItemsModel.php
Normal file
54
week-07/project/libraries/src/Model/ItemsModel.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
*/
|
||||
class ItemsModel implements DatabaseModelInterface
|
||||
{
|
||||
use DatabaseModelTrait;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getItems(): array
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__item'));
|
||||
|
||||
return $db->setQuery($query)->loadObjectList('id');
|
||||
}
|
||||
|
||||
public function setLayout(string $name): string
|
||||
{
|
||||
return $name . '.twig';
|
||||
}
|
||||
}
|
353
week-07/project/libraries/src/Model/MenuModel.php
Normal file
353
week-07/project/libraries/src/Model/MenuModel.php
Normal file
@ -0,0 +1,353 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 18th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
use Octoleo\CMS\Date\Date;
|
||||
use Octoleo\CMS\Model\Util\MenuInterface;
|
||||
use Octoleo\CMS\Model\Util\SelectMenuTrait;
|
||||
use Octoleo\CMS\Model\Util\UniqueInterface;
|
||||
use Octoleo\CMS\Model\Util\UniqueMenuAliasTrait;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
*/
|
||||
class MenuModel implements DatabaseModelInterface, UniqueInterface, MenuInterface
|
||||
{
|
||||
use DatabaseModelTrait, UniqueMenuAliasTrait, SelectMenuTrait;
|
||||
|
||||
/**
|
||||
* Active id
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $id = 0;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $tempItem;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $title
|
||||
* @param string $alias
|
||||
* @param int $itemId
|
||||
* @param string $path
|
||||
* @param int $published
|
||||
* @param string $publishUp
|
||||
* @param string $publishDown
|
||||
* @param string $position
|
||||
* @param int $home
|
||||
* @param int $parent
|
||||
*
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setItem(
|
||||
int $id,
|
||||
string $title,
|
||||
string $alias,
|
||||
int $itemId,
|
||||
string $path,
|
||||
int $published,
|
||||
string $publishUp,
|
||||
string $publishDown,
|
||||
string $position,
|
||||
int $home,
|
||||
int $parent): int
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
// set the alias if not set
|
||||
$alias = (empty($alias)) ? $title : $alias;
|
||||
$alias = $this->unique($id, $alias, $parent);
|
||||
// set the path
|
||||
$path = $this->getPath($alias, $parent);
|
||||
|
||||
$data = [
|
||||
'title' => (string) $title,
|
||||
'alias' => (string) $alias,
|
||||
'path' => (string) $path,
|
||||
'item_id' => (int) $itemId,
|
||||
'published' => (int) $published,
|
||||
'publish_up' => (string) (empty($publishUp)) ? '0000-00-00 00:00:00' : (new Date($publishUp))->toSql(),
|
||||
'publish_down' => (string) (empty($publishDown)) ? '0000-00-00 00:00:00' : (new Date($publishDown))->toSql(),
|
||||
'home' => (int) $home,
|
||||
'parent_id' => (int) $parent
|
||||
];
|
||||
|
||||
// we set position in params
|
||||
$data['params'] = json_encode(['position' => $position]);
|
||||
|
||||
// if we have ID update
|
||||
if ($id > 0)
|
||||
{
|
||||
// set active ID
|
||||
$data['id'] = (int) $id;
|
||||
$this->id = (int) $id;
|
||||
// change to object
|
||||
$data = (object) $data;
|
||||
|
||||
try
|
||||
{
|
||||
$db->updateObject('#__menu', $data, 'id');
|
||||
}
|
||||
catch (\RuntimeException $exception)
|
||||
{
|
||||
throw new \RuntimeException($exception->getMessage(), 404);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// change to object
|
||||
$data = (object) $data;
|
||||
|
||||
try
|
||||
{
|
||||
$db->insertObject('#__menu', $data);
|
||||
}
|
||||
catch (\RuntimeException $exception)
|
||||
{
|
||||
throw new \RuntimeException($exception->getMessage(), 404);
|
||||
}
|
||||
|
||||
$id = $db->insertid();
|
||||
}
|
||||
|
||||
// check if we have another home set
|
||||
if ($data->home == 1)
|
||||
{
|
||||
$this->setHome($id);
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all published items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getItems(): array
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName(array('id', 'title')))
|
||||
->from($db->quoteName('#__item'))
|
||||
->where('state = 1');
|
||||
|
||||
return $db->setQuery($query)->loadObjectList('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item
|
||||
*
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return \stdClass
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getItem(?int $id): \stdClass
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// default object (use posted values if set)
|
||||
if (is_array($this->tempItem))
|
||||
{
|
||||
$default = (object) $this->tempItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = new \stdClass();
|
||||
}
|
||||
// to be sure ;)
|
||||
$default->today_date = (new Date())->toSql();
|
||||
$default->post_key = "?task=create";
|
||||
$default->published = 1;
|
||||
$default->home = 0;
|
||||
|
||||
// we return the default if id not correct
|
||||
if (!is_numeric($id))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__menu'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER)
|
||||
->setLimit(1);
|
||||
|
||||
try
|
||||
{
|
||||
$result = $db->setQuery($query)->loadObject();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// we ignore this and just return an empty object
|
||||
}
|
||||
|
||||
if (isset($result) && $result instanceof \stdClass)
|
||||
{
|
||||
$result->post_key = "?id=$id&task=edit";
|
||||
$result->today_date = $default->today_date;
|
||||
// set the position
|
||||
$result->params = json_decode($result->params);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setLayout(string $name): string
|
||||
{
|
||||
return $name . '.twig';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(int $id): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// Purge the session
|
||||
$query = $db->getQuery(true)
|
||||
->delete($db->quoteName('#__menu'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
try
|
||||
{
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// delete failed
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that we have only one home
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function setHome($id): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// Purge the session
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__menu'))
|
||||
->set($db->quoteName('home') . ' = 0')
|
||||
->where($db->quoteName('id') . ' != :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
try
|
||||
{
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// delete failed
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* get path
|
||||
*
|
||||
* @param string $alias
|
||||
* @param int $parent
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getPath(string $alias, int $parent): string
|
||||
{
|
||||
// alias bucket
|
||||
$bucket = [];
|
||||
$bucket[] = $alias;
|
||||
$parent = $this->getParent($parent);
|
||||
// make sure to get all path aliases TODO: we should limit the menu depth to 6 or something
|
||||
while (isset($parent->alias))
|
||||
{
|
||||
// load the alias
|
||||
$bucket[] = $parent->alias;
|
||||
// get the next parent
|
||||
$parent = $this->getParent($parent->parent_id);
|
||||
}
|
||||
// now return the path
|
||||
return implode('/', array_reverse($bucket));
|
||||
}
|
||||
|
||||
/**
|
||||
* get parent
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
private function getParent(int $id): \stdClass
|
||||
{
|
||||
if ($id > 0)
|
||||
{
|
||||
$db = $this->getDb();
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__menu'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id)
|
||||
->setLimit(1);
|
||||
|
||||
try
|
||||
{
|
||||
$parent = $db->setQuery($query)->loadObject();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// we ignore this and just return an empty object
|
||||
}
|
||||
|
||||
// return only if found
|
||||
if (isset($parent) && $parent instanceof \stdClass)
|
||||
{
|
||||
return $parent;
|
||||
}
|
||||
}
|
||||
return new \stdClass();
|
||||
}
|
||||
}
|
62
week-07/project/libraries/src/Model/MenusModel.php
Normal file
62
week-07/project/libraries/src/Model/MenusModel.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 18th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
*/
|
||||
class MenusModel implements DatabaseModelInterface
|
||||
{
|
||||
use DatabaseModelTrait;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getItems(): array
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.*')
|
||||
->select($db->quoteName(array('t.title'), array('item_title')))
|
||||
->from($db->quoteName('#__menu', 'a'))
|
||||
->join('INNER', $db->quoteName('#__item', 't'), 'a.item_id = t.id');
|
||||
|
||||
return $db->setQuery($query)->loadObjectList('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setLayout(string $name): string
|
||||
{
|
||||
return $name . '.twig';
|
||||
}
|
||||
}
|
39
week-07/project/libraries/src/Model/PageModel.php
Normal file
39
week-07/project/libraries/src/Model/PageModel.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
use Octoleo\CMS\Model\Util\MenuInterface;
|
||||
use Octoleo\CMS\Model\Util\PageInterface;
|
||||
use Octoleo\CMS\Model\Util\HomeMenuInterface;
|
||||
use Octoleo\CMS\Model\Util\HomeMenuTrait;
|
||||
use Octoleo\CMS\Model\Util\SiteMenuTrait;
|
||||
use Octoleo\CMS\Model\Util\SitePageTrait;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
*/
|
||||
class PageModel implements DatabaseModelInterface, MenuInterface, PageInterface, HomeMenuInterface
|
||||
{
|
||||
use DatabaseModelTrait, HomeMenuTrait, SiteMenuTrait, SitePageTrait;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
}
|
337
week-07/project/libraries/src/Model/UserModel.php
Normal file
337
week-07/project/libraries/src/Model/UserModel.php
Normal file
@ -0,0 +1,337 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 18th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
use Octoleo\CMS\Date\Date;
|
||||
use Octoleo\CMS\Model\Util\GetUsergroupsInterface;
|
||||
use Octoleo\CMS\Model\Util\GetUsergroupsTrait;
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
*/
|
||||
class UserModel implements DatabaseModelInterface, GetUsergroupsInterface
|
||||
{
|
||||
use DatabaseModelTrait, GetUsergroupsTrait;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $tempItem;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver|null $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db = null)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param string $username
|
||||
* @param array $groups
|
||||
* @param string $email
|
||||
* @param string $password
|
||||
* @param int $block
|
||||
* @param int $sendEmail
|
||||
* @param string $registerDate
|
||||
* @param int $activation
|
||||
*
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setItem(
|
||||
int $id,
|
||||
string $name,
|
||||
string $username,
|
||||
array $groups,
|
||||
string $email,
|
||||
string $password,
|
||||
int $block,
|
||||
int $sendEmail,
|
||||
string $registerDate,
|
||||
int $activation): int
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$data = [
|
||||
'name' => (string) $name,
|
||||
'username' => (string) $username,
|
||||
'email' => (string) $email,
|
||||
'block' => (int) $block,
|
||||
'sendEmail' => (int) $sendEmail,
|
||||
'registerDate' => (string) (empty($registerDate)) ? (new Date())->toSql() : (new Date($registerDate))->toSql(),
|
||||
'activation' => (int) $activation
|
||||
];
|
||||
|
||||
// only update password if set
|
||||
if (!empty($password) && strlen($password) > 6)
|
||||
{
|
||||
$data['password'] = (string) $password;
|
||||
}
|
||||
|
||||
// if we have ID update
|
||||
if ($id > 0)
|
||||
{
|
||||
$data['id'] = (int) $id;
|
||||
// we remove registration date when we update the user
|
||||
unset($data['registerDate']);
|
||||
// change to object
|
||||
$data = (object) $data;
|
||||
|
||||
try
|
||||
{
|
||||
$db->updateObject('#__users', $data, 'id');
|
||||
}
|
||||
catch (RuntimeException $exception)
|
||||
{
|
||||
throw new RuntimeException($exception->getMessage(), 404);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we don't have any params for now
|
||||
$data['params'] = '';
|
||||
// change to object
|
||||
$data = (object) $data;
|
||||
|
||||
try
|
||||
{
|
||||
$db->insertObject('#__users', $data);
|
||||
}
|
||||
catch (RuntimeException $exception)
|
||||
{
|
||||
throw new RuntimeException($exception->getMessage(), 404);
|
||||
}
|
||||
|
||||
$id = $db->insertid();
|
||||
}
|
||||
|
||||
// update the group linked to this user
|
||||
// only if there are groups
|
||||
if (count($groups) > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->setGroups($id, $groups);
|
||||
}
|
||||
catch (RuntimeException $exception)
|
||||
{
|
||||
throw new RuntimeException($exception->getMessage(), 404);
|
||||
}
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add groups for this user
|
||||
*
|
||||
* @param int $id
|
||||
* @param array $groups
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
private function setGroups(int $id, array $groups): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// add the new groups
|
||||
$query = $db->getQuery(true)
|
||||
->insert($db->quoteName('#__user_usergroup_map'))
|
||||
->columns($db->quoteName(['user_id', 'group_id']));
|
||||
// Insert values.
|
||||
foreach ($groups as $group)
|
||||
{
|
||||
$query->values(implode(',', [(int) $id, (int) $group]));
|
||||
}
|
||||
// execute the update/change
|
||||
try
|
||||
{
|
||||
// delete link to groups
|
||||
if ($this->deleteGroups($id))
|
||||
{
|
||||
// add the new groups
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
throw new RuntimeException($e->getMessage(), 404);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item
|
||||
*
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return stdClass
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getItem(?int $id): stdClass
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// default object (use posted values if set)
|
||||
if (is_array($this->tempItem))
|
||||
{
|
||||
$default = (object) $this->tempItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = new stdClass();
|
||||
}
|
||||
// to be sure ;)
|
||||
$default->today_date = (new Date())->toSql();
|
||||
$default->post_key = "?task=create";
|
||||
$default->block = 0;
|
||||
$default->activation = 1;
|
||||
$default->sendEmail = 1;
|
||||
// always remove password
|
||||
$default->password = 'xxxxxxxxxx';
|
||||
$default->password2 = 'xxxxxxxxxx';
|
||||
|
||||
// we return the default if id not correct
|
||||
if (!is_numeric($id))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__users'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER)
|
||||
->setLimit(1);
|
||||
|
||||
try
|
||||
{
|
||||
$result = $db->setQuery($query)->loadObject();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
// we ignore this and just return an empty object
|
||||
}
|
||||
|
||||
if (isset($result) && $result instanceof stdClass && isset($result->id))
|
||||
{
|
||||
$result->post_key = "?id=$id&task=edit";
|
||||
$result->today_date = $default->today_date;
|
||||
// always remove password
|
||||
$result->password = $default->password;
|
||||
$result->password2 = $default->password2;
|
||||
|
||||
// Initialise some variables
|
||||
$query = $db->getQuery(true)
|
||||
->select('m.group_id')
|
||||
->from($db->quoteName('#__user_usergroup_map', 'm'))
|
||||
->where($db->quoteName('m.user_id') . ' = :user_id')
|
||||
->bind(':user_id', $result->id, ParameterType::INTEGER);
|
||||
|
||||
try
|
||||
{
|
||||
// we just load the ID's
|
||||
$result->groups = $db->setQuery($query)->loadColumn();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
// we ignore this and just return result
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setLayout(string $name): string
|
||||
{
|
||||
return $name . '.twig';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete(int $id): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// Delete the user from the database
|
||||
$query = $db->getQuery(true)
|
||||
->delete($db->quoteName('#__users'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
try
|
||||
{
|
||||
// delete link to groups
|
||||
if ($this->deleteGroups($id))
|
||||
{
|
||||
// delete user
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
throw new RuntimeException($e->getMessage(), 404);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all groups form this user
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
private function deleteGroups(int $id): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// Delete the user from the database
|
||||
$query = $db->getQuery(true)
|
||||
->delete($db->quoteName('#__user_usergroup_map'))
|
||||
->where($db->quoteName('user_id') . ' = :user_id')
|
||||
->bind(':user_id', $id, ParameterType::INTEGER);
|
||||
try
|
||||
{
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
throw new RuntimeException($e->getMessage(), 404);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
239
week-07/project/libraries/src/Model/UsergroupModel.php
Normal file
239
week-07/project/libraries/src/Model/UsergroupModel.php
Normal file
@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 21th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
use Octoleo\CMS\Model\Util\GetUsergroupsInterface;
|
||||
use Octoleo\CMS\Model\Util\GetUsergroupsTrait;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
*/
|
||||
class UsergroupModel implements DatabaseModelInterface, GetUsergroupsInterface
|
||||
{
|
||||
use DatabaseModelTrait, GetUsergroupsTrait;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $tempItem;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $title
|
||||
* @param array $params
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function setItem(
|
||||
int $id,
|
||||
string $title,
|
||||
array $params): int
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
if (count($params) > 0)
|
||||
{
|
||||
$params = json_encode($params);
|
||||
}
|
||||
else
|
||||
{
|
||||
$params = '';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => (string) $title,
|
||||
'params' => (string) $params
|
||||
];
|
||||
|
||||
// if we have ID update
|
||||
if ($id > 0)
|
||||
{
|
||||
$data['id'] = (int) $id;
|
||||
// change to object
|
||||
$data = (object) $data;
|
||||
|
||||
try
|
||||
{
|
||||
$db->updateObject('#__usergroups', $data, 'id');
|
||||
}
|
||||
catch (\RuntimeException $exception)
|
||||
{
|
||||
throw new \RuntimeException($exception->getMessage(), 404);
|
||||
}
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// change to object
|
||||
$data = (object) $data;
|
||||
|
||||
try
|
||||
{
|
||||
$db->insertObject('#__usergroups', $data);
|
||||
}
|
||||
catch (\RuntimeException $exception)
|
||||
{
|
||||
throw new \RuntimeException($exception->getMessage(), 404);
|
||||
}
|
||||
|
||||
return $db->insertid();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item
|
||||
*
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return \stdClass
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getItem(?int $id): \stdClass
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// default object (use posted values if set)
|
||||
if (is_array($this->tempItem))
|
||||
{
|
||||
$default = (object) $this->tempItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = new \stdClass();
|
||||
$default->params = $this->getGroupDefaultsAccess();
|
||||
}
|
||||
|
||||
// we return the default if id not correct
|
||||
if (!is_numeric($id))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__usergroups'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER)
|
||||
->setLimit(1);
|
||||
|
||||
try
|
||||
{
|
||||
$result = $db->setQuery($query)->loadObject();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// we ignore this and just return an empty object
|
||||
}
|
||||
|
||||
if (isset($result) && $result instanceof \stdClass)
|
||||
{
|
||||
$result->post_key = "?id=$id&task=edit";
|
||||
|
||||
// make sure to set the params
|
||||
$result->params = json_decode($result->params);
|
||||
// We set an empty default
|
||||
if (!is_array($result->params))
|
||||
{
|
||||
$result->params = $this->getGroupDefaultsAccess();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setLayout(string $name): string
|
||||
{
|
||||
return $name . '.twig';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(int $id): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// Purge the session
|
||||
$query = $db->getQuery(true)
|
||||
->delete($db->quoteName('#__usergroups'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
try
|
||||
{
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// delete failed
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function linked(int $id): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
// first check if this item is linked to menu
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('user_id'))
|
||||
->from($db->quoteName('#__user_usergroup_map'))
|
||||
->where($db->quoteName('group_id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
|
||||
try
|
||||
{
|
||||
$users = $db->setQuery($query)->loadColumn();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// not linked... or something
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($users)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
50
week-07/project/libraries/src/Model/UsergroupsModel.php
Normal file
50
week-07/project/libraries/src/Model/UsergroupsModel.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 21th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
use Octoleo\CMS\Model\Util\GetUsergroupsInterface;
|
||||
use Octoleo\CMS\Model\Util\GetUsergroupsTrait;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
*/
|
||||
class UsergroupsModel implements DatabaseModelInterface, GetUsergroupsInterface
|
||||
{
|
||||
use DatabaseModelTrait, GetUsergroupsTrait;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getItems(): array
|
||||
{
|
||||
return $this->getUsergroups();
|
||||
}
|
||||
|
||||
public function setLayout(string $name): string
|
||||
{
|
||||
return $name . '.twig';
|
||||
}
|
||||
}
|
67
week-07/project/libraries/src/Model/UsersModel.php
Normal file
67
week-07/project/libraries/src/Model/UsersModel.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 18th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model;
|
||||
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Model\DatabaseModelInterface;
|
||||
use Joomla\Model\DatabaseModelTrait;
|
||||
use Octoleo\CMS\Model\Util\GetUsergroupsInterface;
|
||||
use Octoleo\CMS\Model\Util\GetUsergroupsTrait;
|
||||
|
||||
/**
|
||||
* Model class
|
||||
*/
|
||||
class UsersModel implements DatabaseModelInterface, GetUsergroupsInterface
|
||||
{
|
||||
use DatabaseModelTrait, GetUsergroupsTrait;
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param DatabaseDriver $db The database adapter.
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
$this->setDb($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getItems(): array
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__users'));
|
||||
|
||||
$users = $db->setQuery($query)->loadObjectList('id');
|
||||
|
||||
// add groups
|
||||
if ($users)
|
||||
{
|
||||
foreach ($users as $id => &$user)
|
||||
{
|
||||
$user->groups = $this->getUsergroups($id);
|
||||
}
|
||||
}
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function setLayout(string $name): string
|
||||
{
|
||||
return $name . '.twig';
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 23th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
/**
|
||||
* Class for all user groups
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface GetUsergroupsInterface
|
||||
{
|
||||
/**
|
||||
* Get all user groups
|
||||
*
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUsergroups(?int $id = null): array;
|
||||
|
||||
/**
|
||||
* Get the group default full access values
|
||||
*
|
||||
* @param string $access
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupDefaultsAccess(string $access = 'CRUD'): array;
|
||||
}
|
103
week-07/project/libraries/src/Model/Util/GetUsergroupsTrait.php
Normal file
103
week-07/project/libraries/src/Model/Util/GetUsergroupsTrait.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 23th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
use Joomla\Database\ParameterType;
|
||||
use Octoleo\CMS\Utilities\StringHelper;
|
||||
use RuntimeException;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class for all user groups
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @method getDb()
|
||||
*/
|
||||
trait GetUsergroupsTrait
|
||||
{
|
||||
/**
|
||||
* Get all user groups
|
||||
*
|
||||
* @param int|null $id user ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUsergroups(?int $id = null): array
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('g.*')
|
||||
->from($db->quoteName('#__usergroups', 'g'));
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
$query
|
||||
->join('INNER', $db->quoteName('#__user_usergroup_map', 'm'), 'g.id = m.group_id')
|
||||
->where($db->quoteName('m.user_id') . ' = :user_id')
|
||||
->bind(':user_id', $id, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$groups = $db->setQuery($query)->loadObjectList('id');
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
throw new RuntimeException($e->getMessage(), 404);
|
||||
}
|
||||
|
||||
if (is_array($groups) && count($groups) > 0)
|
||||
{
|
||||
foreach ($groups as $n => &$group)
|
||||
{
|
||||
$group->params = json_decode($group->params);
|
||||
// We set an empty default
|
||||
if (!is_array($group->params))
|
||||
{
|
||||
$group->params = $this->getGroupDefaultsAccess();
|
||||
}
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the group default full access values
|
||||
*
|
||||
* @param string $access
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupDefaultsAccess(string $access = ''): array
|
||||
{
|
||||
return [
|
||||
(object) [
|
||||
'area' => 'user',
|
||||
'access' => $access
|
||||
],
|
||||
(object) [
|
||||
'area' => 'usergroup',
|
||||
'access' => $access
|
||||
],
|
||||
(object) [
|
||||
'area' => 'menu',
|
||||
'access' => $access
|
||||
],
|
||||
(object) [
|
||||
'area' => 'item',
|
||||
'access' => $access
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 21th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
/**
|
||||
* Class for getting the home page
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface HomeMenuInterface
|
||||
{
|
||||
/**
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function getHomePage(): \stdClass;
|
||||
}
|
51
week-07/project/libraries/src/Model/Util/HomeMenuTrait.php
Normal file
51
week-07/project/libraries/src/Model/Util/HomeMenuTrait.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 21th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
/**
|
||||
* Trait for getting home menu
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait HomeMenuTrait
|
||||
{
|
||||
/**
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function getHomePage(): \stdClass
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.*')
|
||||
->from($db->quoteName('#__menu', 'a'))
|
||||
->where($db->quoteName('a.parent_id') . ' = 0')
|
||||
->where($db->quoteName('a.published') . ' = 1')
|
||||
->where($db->quoteName('a.home') . ' = 1')
|
||||
->setLimit(1);
|
||||
|
||||
try
|
||||
{
|
||||
$home = $db->setQuery($query)->loadObject();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
return new \stdClass();
|
||||
}
|
||||
|
||||
if ($home)
|
||||
{
|
||||
return $home;
|
||||
}
|
||||
|
||||
return new \stdClass();
|
||||
}
|
||||
}
|
28
week-07/project/libraries/src/Model/Util/MenuInterface.php
Normal file
28
week-07/project/libraries/src/Model/Util/MenuInterface.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 18th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
/**
|
||||
* Class for getting menu items
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface MenuInterface
|
||||
{
|
||||
/**
|
||||
* Get all menu items
|
||||
*
|
||||
* @param int $active
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMenus(int $active = 0): array;
|
||||
}
|
41
week-07/project/libraries/src/Model/Util/PageInterface.php
Normal file
41
week-07/project/libraries/src/Model/Util/PageInterface.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 18th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
/**
|
||||
* Class for getting page data
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface PageInterface
|
||||
{
|
||||
/**
|
||||
* Get page data
|
||||
*
|
||||
* @param string $path The page path
|
||||
*
|
||||
* @return \stdClass
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getPageItemByPath(string $path): \stdClass;
|
||||
|
||||
/**
|
||||
* Get page data
|
||||
*
|
||||
* @param int $item The item id
|
||||
*
|
||||
* @return \stdClass
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getPageItemById(int $item): \stdClass;
|
||||
}
|
54
week-07/project/libraries/src/Model/Util/SelectMenuTrait.php
Normal file
54
week-07/project/libraries/src/Model/Util/SelectMenuTrait.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 21th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
/**
|
||||
* Trait for getting menu items
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait SelectMenuTrait
|
||||
{
|
||||
/**
|
||||
* Get all menu items
|
||||
*
|
||||
* @param int $active
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMenus(int $active = 0): array
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
if (empty($active) && !empty($this->id))
|
||||
{
|
||||
$active = $this->id;
|
||||
}
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName(array('id', 'title')))
|
||||
->from($db->quoteName('#__menu'))
|
||||
->where('published = 1')
|
||||
->where('home = 0');
|
||||
|
||||
// we need to remove the active menu
|
||||
if ($active > 0)
|
||||
{
|
||||
$query
|
||||
->where($db->quoteName('id') . ' != :id')
|
||||
->bind(':id', $active, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
return $db->setQuery($query)->loadObjectList('id');
|
||||
}
|
||||
}
|
70
week-07/project/libraries/src/Model/Util/SiteMenuTrait.php
Normal file
70
week-07/project/libraries/src/Model/Util/SiteMenuTrait.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 18th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
/**
|
||||
* Trait for getting menu items
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait SiteMenuTrait
|
||||
{
|
||||
/**
|
||||
* Get all menu items that are root and published and not home page
|
||||
*
|
||||
* @param int $active
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMenus(int $active = 0): array
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.*')
|
||||
->from($db->quoteName('#__menu', 'a'))
|
||||
->where($db->quoteName('a.published') . ' = 1')
|
||||
->where($db->quoteName('a.home') . ' = 0');
|
||||
|
||||
try
|
||||
{
|
||||
$menus = $db->setQuery($query)->loadObjectList();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($menus)
|
||||
{
|
||||
$bucket = [];
|
||||
foreach ($menus as $menu)
|
||||
{
|
||||
$row = [];
|
||||
// set the details
|
||||
$row['id'] = $menu->id;
|
||||
$row['title'] = $menu->title;
|
||||
$row['path'] = $menu->path;
|
||||
$row['parent'] = $menu->parent_id;
|
||||
// set position
|
||||
$params = (isset($menu->params) && strpos($menu->params, 'position') !== false) ? json_decode($menu->params) : null;
|
||||
// default is center
|
||||
$row['position'] = (is_object($params) && isset($params->position)) ? $params->position : 'center';
|
||||
|
||||
// add to our bucket
|
||||
$bucket[] = $row;
|
||||
}
|
||||
return $bucket;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
103
week-07/project/libraries/src/Model/Util/SitePageTrait.php
Normal file
103
week-07/project/libraries/src/Model/Util/SitePageTrait.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 18th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
/**
|
||||
* Trait for getting page data
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait SitePageTrait
|
||||
{
|
||||
/**
|
||||
* Get page data
|
||||
*
|
||||
* @param string $path The page path
|
||||
*
|
||||
* @return \stdClass
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getPageItemByPath(string $path): \stdClass
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('i.*')
|
||||
->select($db->quoteName(array('m.id'), array('menu_id')))
|
||||
->from($db->quoteName('#__menu', 'm'))
|
||||
->join('INNER', $db->quoteName('#__item', 'i'), 'm.item_id = i.id')
|
||||
->where($db->quoteName('i.state') . ' >= 1')
|
||||
->where($db->quoteName('m.published') . ' = 1')
|
||||
->where($db->quoteName('m.path') . ' = :path')
|
||||
->bind(':path', $path)
|
||||
->setLimit(1);
|
||||
|
||||
try
|
||||
{
|
||||
$page = $db->setQuery($query)->loadObject();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
return new \stdClass();
|
||||
}
|
||||
|
||||
if ($page)
|
||||
{
|
||||
return $page;
|
||||
}
|
||||
|
||||
return new \stdClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page data
|
||||
*
|
||||
* @param int $item The item id
|
||||
*
|
||||
* @return \stdClass
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getPageItemById(int $item): \stdClass
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('i.*')
|
||||
->select($db->quoteName(array('m.id'), array('menu_id')))
|
||||
->from($db->quoteName('#__item', 'i'))
|
||||
->join('INNER', $db->quoteName('#__menu', 'm'), 'i.id = m.item_id')
|
||||
->where($db->quoteName('m.published') . ' = 1')
|
||||
->where($db->quoteName('i.state') . ' >= 1')
|
||||
->where($db->quoteName('i.id') . ' = :id')
|
||||
->bind(':id', $item, ParameterType::INTEGER)
|
||||
->setLimit(1);
|
||||
|
||||
try
|
||||
{
|
||||
$page = $db->setQuery($query)->loadObject();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
return new \stdClass();
|
||||
}
|
||||
|
||||
if ($page)
|
||||
{
|
||||
return $page;
|
||||
}
|
||||
|
||||
return new \stdClass();
|
||||
}
|
||||
}
|
44
week-07/project/libraries/src/Model/Util/UniqueInterface.php
Normal file
44
week-07/project/libraries/src/Model/Util/UniqueInterface.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 21th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
/**
|
||||
* Class for getting unique string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface UniqueInterface
|
||||
{
|
||||
/**
|
||||
* Get a unique string
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $value
|
||||
* @param int $parent
|
||||
* @param string $key
|
||||
* @param string $spacer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function unique(int $id, string $value, int $parent = -1, string $key = 'alias', string $spacer = '-'): string;
|
||||
|
||||
/**
|
||||
* Check if an any key exist with same parent
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $value
|
||||
* @param string $key
|
||||
* @param int $parent
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exist(int $id, string $value, string $key = 'alias', int $parent = -1): bool;
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 21th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Model\Util;
|
||||
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
/**
|
||||
* Trait for getting unique string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait UniqueMenuAliasTrait
|
||||
{
|
||||
/**
|
||||
* Get a unique string
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $value
|
||||
* @param int $parent
|
||||
* @param string $key
|
||||
* @param string $spacer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function unique(int $id, string $value, int $parent = -1, string $key = 'alias', string $spacer = '-'): string
|
||||
{
|
||||
// start building the value
|
||||
$value = str_replace($spacer, ' ', $value);
|
||||
$value = preg_replace('/\s+/', $spacer, strtolower(preg_replace("/[^A-Za-z0-9\- ]/", '', $value)));
|
||||
// set a counter
|
||||
$counter = 2;
|
||||
// set original tracker
|
||||
$original = $value;
|
||||
// check if we found any with the same alias
|
||||
while ($this->exist($id, $value, $key, $parent))
|
||||
{
|
||||
$value = $original . '-' . $counter;
|
||||
$counter++;
|
||||
}
|
||||
// return the unique value (on this parent layer)
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an any key exist with same parent
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $value
|
||||
* @param string $key
|
||||
* @param int $parent
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exist(int $id, string $value, string $key = 'alias', int $parent = -1): bool
|
||||
{
|
||||
$db = $this->getDb();
|
||||
$query = $db->getQuery(true)
|
||||
->select('id')
|
||||
->from($db->quoteName('#__menu'))
|
||||
->where($db->quoteName($key) . " = :$key")
|
||||
->bind(":$key", $value)
|
||||
->setLimit(1);
|
||||
|
||||
// only add the id item exist
|
||||
if ($parent >= 0)
|
||||
{
|
||||
$query
|
||||
->where($db->quoteName('parent_id') . ' = :parent_id')
|
||||
->bind(':parent_id', $parent, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// only add the id item exist
|
||||
if ($id > 0)
|
||||
{
|
||||
$query
|
||||
->where($db->quoteName('id') . ' != :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$result = $db->setQuery($query)->loadResult();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// we ignore this and just return an empty object
|
||||
}
|
||||
|
||||
if (isset($result) && $result > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Framework Website
|
||||
*
|
||||
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Renderer;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Application\AbstractWebApplication;
|
||||
use Symfony\Component\Asset\Context\ContextInterface;
|
||||
|
||||
/**
|
||||
* Joomla! application aware context
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Renderer/ApplicationContext.php
|
||||
*/
|
||||
class ApplicationContext implements ContextInterface
|
||||
{
|
||||
/**
|
||||
* Application object
|
||||
*
|
||||
* @var AbstractApplication
|
||||
*/
|
||||
private $app;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param AbstractApplication $app The application object
|
||||
*/
|
||||
public function __construct(AbstractApplication $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base path.
|
||||
*
|
||||
* @return string The base path
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return rtrim($this->app->get('uri.base.path'), '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the request is secure or not.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSecure()
|
||||
{
|
||||
if ($this->app instanceof AbstractWebApplication)
|
||||
{
|
||||
return $this->app->isSslConnection();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Framework Website
|
||||
*
|
||||
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Renderer;
|
||||
|
||||
use Symfony\Component\Asset\Packages;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
* Framework site's Twig extension class
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Renderer/FrameworkExtension.php
|
||||
*/
|
||||
class FrameworkExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* Returns a list of filters to add to the existing list
|
||||
*
|
||||
* @return TwigFilter[] An array of TwigFilter instances
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
new TwigFilter('get_class', 'get_class'),
|
||||
new TwigFilter('strip_root_path', [$this, 'stripRootPath']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of functions to add to the existing list.
|
||||
*
|
||||
* @return TwigFunction[] An array of TwigFunction instances
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new TwigFunction('asset', [Packages::class, 'getUrl']),
|
||||
new TwigFunction('preload', [FrameworkTwigRuntime::class, 'preloadAsset']),
|
||||
new TwigFunction('request_uri', [FrameworkTwigRuntime::class, 'getRequestUri']),
|
||||
new TwigFunction('route', [FrameworkTwigRuntime::class, 'getRouteUri']),
|
||||
new TwigFunction('sri', [FrameworkTwigRuntime::class, 'getSriAttributes'], ['is_safe' => ['html']]),
|
||||
new TwigFunction('message_queue', [FrameworkTwigRuntime::class, 'getMessageQueue']),
|
||||
new TwigFunction('user_array', [FrameworkTwigRuntime::class, 'getUserArray']),
|
||||
new TwigFunction('user', [FrameworkTwigRuntime::class, 'getUser']),
|
||||
new TwigFunction('token', [FrameworkTwigRuntime::class, 'getToken']),
|
||||
new TwigFunction('shorten_string', [FrameworkTwigRuntime::class, 'shortenString']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the application root path defined by the constant "JPATH_ROOT"
|
||||
*
|
||||
* @param string $string The string to process
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function stripRootPath(string $string): string
|
||||
{
|
||||
return str_replace(JPATH_ROOT . DIRECTORY_SEPARATOR, '', $string);
|
||||
}
|
||||
}
|
278
week-07/project/libraries/src/Renderer/FrameworkTwigRuntime.php
Normal file
278
week-07/project/libraries/src/Renderer/FrameworkTwigRuntime.php
Normal file
@ -0,0 +1,278 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Framework Website
|
||||
*
|
||||
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Renderer;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\Preload\PreloadManager;
|
||||
use Joomla\Session\SessionInterface;
|
||||
use Octoleo\CMS\Factory;
|
||||
use Octoleo\CMS\User\User;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
|
||||
/**
|
||||
* Twig runtime class
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Renderer/FrameworkTwigRuntime.php
|
||||
*/
|
||||
class FrameworkTwigRuntime
|
||||
{
|
||||
/**
|
||||
* Application object
|
||||
*
|
||||
* @var AbstractApplication
|
||||
*/
|
||||
private $app;
|
||||
|
||||
/**
|
||||
* The HTTP/2 preload manager
|
||||
*
|
||||
* @var PreloadManager
|
||||
*/
|
||||
private $preloadManager;
|
||||
|
||||
/**
|
||||
* The SRI manifest data
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
private $sriManifestData;
|
||||
|
||||
/**
|
||||
* The path to the SRI manifest data
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $sriManifestPath;
|
||||
|
||||
/**
|
||||
* @var SessionInterface|null
|
||||
*/
|
||||
private $session;
|
||||
|
||||
/**
|
||||
* @var User|null
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param AbstractApplication $app The application object
|
||||
* @param PreloadManager $preloadManager The HTTP/2 preload manager
|
||||
* @param string $sriManifestPath The path to the SRI manifest data
|
||||
* @param SessionInterface|null $session The session object
|
||||
*/
|
||||
public function __construct(
|
||||
AbstractApplication $app,
|
||||
PreloadManager $preloadManager,
|
||||
string $sriManifestPath,
|
||||
SessionInterface $session = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->preloadManager = $preloadManager;
|
||||
$this->sriManifestPath = $sriManifestPath;
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current URI
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestUri(): string
|
||||
{
|
||||
return $this->app->get('uri.request');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URI for a route
|
||||
*
|
||||
* @param string $route Route to get the path for
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRouteUri(string $route = ''): string
|
||||
{
|
||||
return $this->app->get('uri.base.path') . $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full URL for a route
|
||||
*
|
||||
* @param string $route Route to get the URL for
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRouteUrl(string $route = ''): string
|
||||
{
|
||||
return $this->app->get('uri.base.host') . $this->getRouteUri($route);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get form Token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getToken(): string
|
||||
{
|
||||
if ($this->session instanceof SessionInterface)
|
||||
{
|
||||
return $this->session->getToken();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorten a string
|
||||
*
|
||||
* @input string The you would like to shorten
|
||||
*
|
||||
* @returns string on success
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function shortenString($string, $length = 100)
|
||||
{
|
||||
if (is_string($string) && strlen($string) > $length)
|
||||
{
|
||||
$initial = strlen($string);
|
||||
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$words_count = count((array)$words);
|
||||
|
||||
$word_length = 0;
|
||||
$last_word = 0;
|
||||
for (; $last_word < $words_count; ++$last_word)
|
||||
{
|
||||
$word_length += strlen($words[$last_word]);
|
||||
if ($word_length > $length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$newString = implode(array_slice($words, 0, $last_word));
|
||||
return trim($newString) . '...';
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current user as array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUserArray(): array
|
||||
{
|
||||
if (!$this->user instanceof User)
|
||||
{
|
||||
/** @var \Octoleo\CMS\User\User $user */
|
||||
$this->user = Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
}
|
||||
// check again
|
||||
if ($this->user instanceof User && method_exists($this->user, 'toArray'))
|
||||
{
|
||||
return $this->user->toArray();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getUser(string $key = 'name', $default = '')
|
||||
{
|
||||
if (!$this->user instanceof User)
|
||||
{
|
||||
/** @var \Octoleo\CMS\User\User $user */
|
||||
$this->user = Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
||||
}
|
||||
// check again
|
||||
if ($this->user instanceof User)
|
||||
{
|
||||
return $this->user->get($key, $default);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any messages in the queue
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMessageQueue(): array
|
||||
{
|
||||
if (method_exists($this->app, 'getMessageQueue'))
|
||||
{
|
||||
return $this->app->getMessageQueue(true);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SRI attributes for an asset
|
||||
*
|
||||
* @param string $path A public path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSriAttributes(string $path): string
|
||||
{
|
||||
if ($this->sriManifestData === null)
|
||||
{
|
||||
if (!file_exists($this->sriManifestPath))
|
||||
{
|
||||
throw new \RuntimeException(sprintf('SRI manifest file "%s" does not exist.', $this->sriManifestPath));
|
||||
}
|
||||
|
||||
$sriManifestContents = file_get_contents($this->sriManifestPath);
|
||||
|
||||
if ($sriManifestContents === false)
|
||||
{
|
||||
throw new \RuntimeException(sprintf('Could not read SRI manifest file "%s".', $this->sriManifestPath));
|
||||
}
|
||||
|
||||
$this->sriManifestData = json_decode($sriManifestContents, true);
|
||||
|
||||
if (0 < json_last_error())
|
||||
{
|
||||
throw new \RuntimeException(sprintf('Error parsing JSON from SRI manifest file "%s" - %s', $this->sriManifestPath, json_last_error_msg()));
|
||||
}
|
||||
}
|
||||
|
||||
$assetKey = "/$path";
|
||||
|
||||
if (!isset($this->sriManifestData[$assetKey]))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$attributes = '';
|
||||
|
||||
foreach ($this->sriManifestData[$assetKey] as $key => $value)
|
||||
{
|
||||
$attributes .= ' ' . $key . '="' . $value . '"';
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preload a resource
|
||||
*
|
||||
* @param string $uri The URI for the resource to preload
|
||||
* @param string $linkType The preload method to apply
|
||||
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function preloadAsset(string $uri, string $linkType = 'preload', array $attributes = []): string
|
||||
{
|
||||
$this->preloadManager->link($uri, $linkType, $attributes);
|
||||
|
||||
return $uri;
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Service;
|
||||
|
||||
use Joomla\Application\AbstractWebApplication;
|
||||
use Joomla\Application\Controller\ControllerResolverInterface;
|
||||
use Joomla\Application\Web\WebClient;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
|
||||
use Joomla\Session\SessionInterface;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\Application\AdminApplication;
|
||||
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Router\RouterInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Admin Application service provider
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Service/ApplicationProvider.php
|
||||
*/
|
||||
class AdminApplicationProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(Container $container): void
|
||||
{
|
||||
/*
|
||||
* Application Classes
|
||||
*/
|
||||
|
||||
// This service cannot be protected as it is decorated when the debug bar is available
|
||||
$container->alias(AdminApplication::class, AbstractWebApplication::class)
|
||||
->share(AbstractWebApplication::class, [$this, 'getAdminApplicationClassService']);
|
||||
|
||||
/*
|
||||
* Application Helpers and Dependencies
|
||||
*/
|
||||
$container->share(WebClient::class, [$this, 'getWebClientService'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WebApplication class service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return AdminApplication
|
||||
*/
|
||||
public function getAdminApplicationClassService(Container $container): AdminApplication
|
||||
{
|
||||
/** @var \Octoleo\CMS\Application\AdminApplication $application */
|
||||
$application = new AdminApplication(
|
||||
$container->get(ControllerResolverInterface::class),
|
||||
$container->get(RouterInterface::class),
|
||||
$container->get(Input::class),
|
||||
$container->get('config'),
|
||||
$container->get(WebClient::class)
|
||||
);
|
||||
|
||||
$application->httpVersion = '2';
|
||||
|
||||
// Inject extra services
|
||||
$application->setDispatcher($container->get(DispatcherInterface::class));
|
||||
$application->setLogger($container->get(LoggerInterface::class));
|
||||
$application->setSession($container->get(SessionInterface::class));
|
||||
$application->setUserFactory($container->get(UserFactoryInterface::class));
|
||||
|
||||
return $application;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the web client service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return WebClient
|
||||
*/
|
||||
public function getWebClientService(Container $container): WebClient
|
||||
{
|
||||
/** @var Input $input */
|
||||
$input = $container->get(Input::class);
|
||||
$userAgent = $input->server->getString('HTTP_USER_AGENT', '');
|
||||
$acceptEncoding = $input->server->getString('HTTP_ACCEPT_ENCODING', '');
|
||||
$acceptLanguage = $input->server->getString('HTTP_ACCEPT_LANGUAGE', '');
|
||||
|
||||
return new WebClient($userAgent, $acceptEncoding, $acceptLanguage);
|
||||
}
|
||||
}
|
605
week-07/project/libraries/src/Service/AdminMVCProvider.php
Normal file
605
week-07/project/libraries/src/Service/AdminMVCProvider.php
Normal file
@ -0,0 +1,605 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 14th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Service;
|
||||
|
||||
use Joomla\Application\Controller\ContainerControllerResolver;
|
||||
use Joomla\Application\Controller\ControllerResolverInterface;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
|
||||
use Octoleo\CMS\Controller\DashboardController;
|
||||
use Octoleo\CMS\Controller\ItemsController;
|
||||
use Octoleo\CMS\Controller\ItemController;
|
||||
use Octoleo\CMS\Controller\LoginController;
|
||||
use Octoleo\CMS\Controller\MenuController;
|
||||
use Octoleo\CMS\Controller\MenusController;
|
||||
use Octoleo\CMS\Controller\UserController;
|
||||
use Octoleo\CMS\Controller\UsersController;
|
||||
use Octoleo\CMS\Controller\UserGroupController;
|
||||
use Octoleo\CMS\Controller\UsergroupsController;
|
||||
use Octoleo\CMS\Controller\WrongCmsController;
|
||||
use Octoleo\CMS\Model\DashboardModel;
|
||||
use Octoleo\CMS\Model\ItemsModel;
|
||||
use Octoleo\CMS\Model\ItemModel;
|
||||
use Octoleo\CMS\Model\MenusModel;
|
||||
use Octoleo\CMS\Model\MenuModel;
|
||||
use Octoleo\CMS\Model\UserModel;
|
||||
use Octoleo\CMS\Model\UsersModel;
|
||||
use Octoleo\CMS\Model\UsergroupModel;
|
||||
use Octoleo\CMS\Model\UsergroupsModel;
|
||||
use Octoleo\CMS\User\UserFactoryInterface;
|
||||
use Octoleo\CMS\View\Admin\DashboardHtmlView;
|
||||
use Octoleo\CMS\View\Admin\ItemsHtmlView;
|
||||
use Octoleo\CMS\View\Admin\ItemHtmlView;
|
||||
use Octoleo\CMS\View\Admin\MenuHtmlView;
|
||||
use Octoleo\CMS\View\Admin\MenusHtmlView;
|
||||
use Octoleo\CMS\View\Admin\UserHtmlView;
|
||||
use Octoleo\CMS\View\Admin\UsersHtmlView;
|
||||
use Octoleo\CMS\View\Admin\UsergroupHtmlView;
|
||||
use Octoleo\CMS\View\Admin\UsergroupsHtmlView;
|
||||
use Octoleo\CMS\Application\AdminApplication;
|
||||
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Renderer\RendererInterface;
|
||||
|
||||
/**
|
||||
* Model View Controller service provider
|
||||
*/
|
||||
class AdminMVCProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(Container $container): void
|
||||
{
|
||||
// This service cannot be protected as it is decorated when the debug bar is available
|
||||
$container->alias(ContainerControllerResolver::class, ControllerResolverInterface::class)
|
||||
->share(ControllerResolverInterface::class, [$this, 'getControllerResolverService']);
|
||||
|
||||
// Controllers
|
||||
$container->alias(DashboardController::class, 'controller.dashboard')
|
||||
->share('controller.dashboard', [$this, 'getControllerDashboardService'], true);
|
||||
|
||||
$container->alias(UsersController::class, 'controller.users')
|
||||
->share('controller.users', [$this, 'getControllerUsersService'], true);
|
||||
|
||||
$container->alias(UserController::class, 'controller.user')
|
||||
->share('controller.user', [$this, 'getControllerUserService'], true);
|
||||
|
||||
$container->alias(UsergroupsController::class, 'controller.usergroups')
|
||||
->share('controller.usergroups', [$this, 'getControllerUsergroupsService'], true);
|
||||
|
||||
$container->alias(UsergroupController::class, 'controller.usergroup')
|
||||
->share('controller.usergroup', [$this, 'getControllerUsergroupService'], true);
|
||||
|
||||
$container->alias(MenusController::class, 'controller.menus')
|
||||
->share('controller.menus', [$this, 'getControllerMenusService'], true);
|
||||
|
||||
$container->alias(MenuController::class, 'controller.menu')
|
||||
->share('controller.menu', [$this, 'getControllerMenuService'], true);
|
||||
|
||||
$container->alias(ItemsController::class, 'controller.items')
|
||||
->share('controller.items', [$this, 'getControllerItemsService'], true);
|
||||
|
||||
$container->alias(ItemController::class, 'controller.item')
|
||||
->share('controller.item', [$this, 'getControllerItemService'], true);
|
||||
|
||||
$container->alias(LoginController::class, 'controller.login')
|
||||
->share('controller.login', [$this, 'getControllerLoginService'], true);
|
||||
|
||||
$container->alias(WrongCmsController::class, 'controller.wrong.cms')
|
||||
->share('controller.wrong.cms', [$this, 'getControllerWrongCmsService'], true);
|
||||
|
||||
// Models
|
||||
$container->alias(DashboardModel::class, 'model.dashboard')
|
||||
->share('model.dashboard', [$this, 'getModelDashboardService'], true);
|
||||
|
||||
$container->alias(UsersModel::class, 'model.users')
|
||||
->share('model.users', [$this, 'getModelUsersService'], true);
|
||||
|
||||
$container->alias(UserModel::class, 'model.user')
|
||||
->share('model.user', [$this, 'getModelUserService'], true);
|
||||
|
||||
$container->alias(UsergroupsModel::class, 'model.usergroups')
|
||||
->share('model.usergroups', [$this, 'getModelUsergroupsService'], true);
|
||||
|
||||
$container->alias(UsergroupModel::class, 'model.usergroup')
|
||||
->share('model.usergroup', [$this, 'getModelUsergroupService'], true);
|
||||
|
||||
$container->alias(MenusModel::class, 'model.menus')
|
||||
->share('model.menus', [$this, 'getModelMenusService'], true);
|
||||
|
||||
$container->alias(MenuModel::class, 'model.menu')
|
||||
->share('model.menu', [$this, 'getModelMenuService'], true);
|
||||
|
||||
$container->alias(ItemsModel::class, 'model.items')
|
||||
->share('model.items', [$this, 'getModelItemsService'], true);
|
||||
|
||||
$container->alias(ItemModel::class, 'model.item')
|
||||
->share('model.item', [$this, 'getModelItemService'], true);
|
||||
|
||||
// Views
|
||||
$container->alias(DashboardHtmlView::class, 'view.dashboard.html')
|
||||
->share('view.dashboard.html', [$this, 'getViewDashboardHtmlService'], true);
|
||||
|
||||
$container->alias(UsersHtmlView::class, 'view.users.html')
|
||||
->share('view.users.html', [$this, 'getViewUsersHtmlService'], true);
|
||||
|
||||
$container->alias(UserHtmlView::class, 'view.user.html')
|
||||
->share('view.user.html', [$this, 'getViewUserHtmlService'], true);
|
||||
|
||||
$container->alias(UsergroupsHtmlView::class, 'view.usergroups.html')
|
||||
->share('view.usergroups.html', [$this, 'getViewUsergroupsHtmlService'], true);
|
||||
|
||||
$container->alias(UsergroupHtmlView::class, 'view.usergroup.html')
|
||||
->share('view.usergroup.html', [$this, 'getViewUsergroupHtmlService'], true);
|
||||
|
||||
$container->alias(MenusHtmlView::class, 'view.menus.html')
|
||||
->share('view.menus.html', [$this, 'getViewMenusHtmlService'], true);
|
||||
|
||||
$container->alias(MenuHtmlView::class, 'view.menu.html')
|
||||
->share('view.menu.html', [$this, 'getViewMenuHtmlService'], true);
|
||||
|
||||
$container->alias(ItemsHtmlView::class, 'view.items.html')
|
||||
->share('view.items.html', [$this, 'getViewItemsHtmlService'], true);
|
||||
|
||||
$container->alias(ItemHtmlView::class, 'view.item.html')
|
||||
->share('view.item.html', [$this, 'getViewItemHtmlService'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the controller resolver service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ControllerResolverInterface
|
||||
*/
|
||||
public function getControllerResolverService(Container $container): ControllerResolverInterface
|
||||
{
|
||||
return new ContainerControllerResolver($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.login` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return LoginController
|
||||
*/
|
||||
public function getControllerLoginService(Container $container): LoginController
|
||||
{
|
||||
return new LoginController(
|
||||
$container->get(DashboardHtmlView::class),
|
||||
$container->get(RendererInterface::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.wrong.cms` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return WrongCmsController
|
||||
*/
|
||||
public function getControllerWrongCmsService(Container $container): WrongCmsController
|
||||
{
|
||||
return new WrongCmsController(
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.dashboard` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return DashboardController
|
||||
*/
|
||||
public function getControllerDashboardService(Container $container): DashboardController
|
||||
{
|
||||
return new DashboardController(
|
||||
$container->get(DashboardHtmlView::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `model.dashboard` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return DashboardModel
|
||||
*/
|
||||
public function getModelDashboardService(Container $container): DashboardModel
|
||||
{
|
||||
return new DashboardModel($container->get(DatabaseInterface::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `view.dashboard.html` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return DashboardHtmlView
|
||||
*/
|
||||
public function getViewDashboardHtmlService(Container $container): DashboardHtmlView
|
||||
{
|
||||
return new DashboardHtmlView(
|
||||
$container->get('model.dashboard'),
|
||||
$container->get('renderer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.users` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsersController
|
||||
*/
|
||||
public function getControllerUsersService(Container $container): UsersController
|
||||
{
|
||||
return new UsersController(
|
||||
$container->get(UsersHtmlView::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class),
|
||||
$container->get(UserFactoryInterface::class)->getUser()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `model.users` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsersModel
|
||||
*/
|
||||
public function getModelUsersService(Container $container): UsersModel
|
||||
{
|
||||
return new UsersModel($container->get(DatabaseInterface::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `view.users.html` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsersHtmlView
|
||||
*/
|
||||
public function getViewUsersHtmlService(Container $container): UsersHtmlView
|
||||
{
|
||||
return new UsersHtmlView(
|
||||
$container->get('model.users'),
|
||||
$container->get('renderer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.user` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UserController
|
||||
*/
|
||||
public function getControllerUserService(Container $container): UserController
|
||||
{
|
||||
return new UserController(
|
||||
$container->get(UserModel::class),
|
||||
$container->get(UserHtmlView::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class),
|
||||
$container->get(UserFactoryInterface::class)->getUser()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `model.user` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UserModel
|
||||
*/
|
||||
public function getModelUserService(Container $container): UserModel
|
||||
{
|
||||
return new UserModel($container->get(DatabaseInterface::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `view.user.html` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UserHtmlView
|
||||
*/
|
||||
public function getViewUserHtmlService(Container $container): UserHtmlView
|
||||
{
|
||||
return new UserHtmlView(
|
||||
$container->get('model.user'),
|
||||
$container->get('renderer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.usergroups` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsergroupsController
|
||||
*/
|
||||
public function getControllerUsergroupsService(Container $container): UsergroupsController
|
||||
{
|
||||
return new UsergroupsController(
|
||||
$container->get(UsergroupsHtmlView::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class),
|
||||
$container->get(UserFactoryInterface::class)->getUser()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `model.usergroups` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsergroupsModel
|
||||
*/
|
||||
public function getModelUsergroupsService(Container $container): UsergroupsModel
|
||||
{
|
||||
return new UsergroupsModel($container->get(DatabaseInterface::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `view.usergroups.html` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsergroupsHtmlView
|
||||
*/
|
||||
public function getViewUsergroupsHtmlService(Container $container): UsergroupsHtmlView
|
||||
{
|
||||
return new UsergroupsHtmlView(
|
||||
$container->get('model.usergroups'),
|
||||
$container->get('renderer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.usergroup` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsergroupController
|
||||
*/
|
||||
public function getControllerUsergroupService(Container $container): UsergroupController
|
||||
{
|
||||
return new UsergroupController(
|
||||
$container->get(UsergroupModel::class),
|
||||
$container->get(UsergroupHtmlView::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class),
|
||||
$container->get(UserFactoryInterface::class)->getUser()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `model.usergroup` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsergroupModel
|
||||
*/
|
||||
public function getModelUsergroupService(Container $container): UsergroupModel
|
||||
{
|
||||
return new UsergroupModel($container->get(DatabaseInterface::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `view.usergroup.html` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsergroupHtmlView
|
||||
*/
|
||||
public function getViewUsergroupHtmlService(Container $container): UsergroupHtmlView
|
||||
{
|
||||
return new UsergroupHtmlView(
|
||||
$container->get('model.usergroup'),
|
||||
$container->get('renderer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.menus` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MenusController
|
||||
*/
|
||||
public function getControllerMenusService(Container $container): MenusController
|
||||
{
|
||||
return new MenusController(
|
||||
$container->get(MenusHtmlView::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class),
|
||||
$container->get(UserFactoryInterface::class)->getUser()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `model.menus` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MenusModel
|
||||
*/
|
||||
public function getModelMenusService(Container $container): MenusModel
|
||||
{
|
||||
return new MenusModel($container->get(DatabaseInterface::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `view.menus.html` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MenusHtmlView
|
||||
*/
|
||||
public function getViewMenusHtmlService(Container $container): MenusHtmlView
|
||||
{
|
||||
return new MenusHtmlView(
|
||||
$container->get('model.menus'),
|
||||
$container->get('renderer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.menu` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MenuController
|
||||
*/
|
||||
public function getControllerMenuService(Container $container): MenuController
|
||||
{
|
||||
return new MenuController(
|
||||
$container->get(MenuModel::class),
|
||||
$container->get(MenuHtmlView::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class),
|
||||
$container->get(UserFactoryInterface::class)->getUser()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `model.menu` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MenuModel
|
||||
*/
|
||||
public function getModelMenuService(Container $container): MenuModel
|
||||
{
|
||||
return new MenuModel($container->get(DatabaseInterface::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `view.menu.html` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MenuHtmlView
|
||||
*/
|
||||
public function getViewMenuHtmlService(Container $container): MenuHtmlView
|
||||
{
|
||||
return new MenuHtmlView(
|
||||
$container->get('model.menu'),
|
||||
$container->get('renderer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.items` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemsController
|
||||
*/
|
||||
public function getControllerItemsService(Container $container): ItemsController
|
||||
{
|
||||
return new ItemsController(
|
||||
$container->get(ItemsHtmlView::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class),
|
||||
$container->get(UserFactoryInterface::class)->getUser()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `model.items` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemsModel
|
||||
*/
|
||||
public function getModelItemsService(Container $container): ItemsModel
|
||||
{
|
||||
return new ItemsModel($container->get(DatabaseInterface::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `view.items.html` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemsHtmlView
|
||||
*/
|
||||
public function getViewItemsHtmlService(Container $container): ItemsHtmlView
|
||||
{
|
||||
return new ItemsHtmlView(
|
||||
$container->get('model.items'),
|
||||
$container->get('renderer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `controller.item` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemController
|
||||
*/
|
||||
public function getControllerItemService(Container $container): ItemController
|
||||
{
|
||||
return new ItemController(
|
||||
$container->get(ItemModel::class),
|
||||
$container->get(ItemHtmlView::class),
|
||||
$container->get(Input::class),
|
||||
$container->get(AdminApplication::class),
|
||||
$container->get(UserFactoryInterface::class)->getUser()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `model.item` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemModel
|
||||
*/
|
||||
public function getModelItemService(Container $container): ItemModel
|
||||
{
|
||||
return new ItemModel($container->get(DatabaseInterface::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `view.item.html` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ItemHtmlView
|
||||
*/
|
||||
public function getViewItemHtmlService(Container $container): ItemHtmlView
|
||||
{
|
||||
return new ItemHtmlView(
|
||||
$container->get('model.item'),
|
||||
$container->get('renderer')
|
||||
);
|
||||
}
|
||||
}
|
108
week-07/project/libraries/src/Service/AdminRouterProvider.php
Normal file
108
week-07/project/libraries/src/Service/AdminRouterProvider.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 14th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Service;
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
|
||||
use Octoleo\CMS\Controller\DashboardController;
|
||||
use Octoleo\CMS\Controller\LoginController;
|
||||
use Octoleo\CMS\Controller\ItemsController;
|
||||
use Octoleo\CMS\Controller\ItemController;
|
||||
use Octoleo\CMS\Controller\MenuController;
|
||||
use Octoleo\CMS\Controller\MenusController;
|
||||
use Octoleo\CMS\Controller\UserController;
|
||||
use Octoleo\CMS\Controller\UsersController;
|
||||
use Octoleo\CMS\Controller\UserGroupController;
|
||||
use Octoleo\CMS\Controller\UsergroupsController;
|
||||
|
||||
use Joomla\Router\Router;
|
||||
use Joomla\Router\RouterInterface;
|
||||
|
||||
/**
|
||||
* Application service provider
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Service/ApplicationProvider.php
|
||||
*/
|
||||
class AdminRouterProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(Container $container): void
|
||||
{
|
||||
// This service cannot be protected as it is decorated when the debug bar is available
|
||||
$container->alias(RouterInterface::class, 'application.router')
|
||||
->alias(Router::class, 'application.router')
|
||||
->share('application.router', [$this, 'getApplicationRouterService']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `application.router` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return RouterInterface
|
||||
*/
|
||||
public function getApplicationRouterService(Container $container): RouterInterface
|
||||
{
|
||||
$router = new Router;
|
||||
|
||||
/**
|
||||
* CMS Admin Panels
|
||||
**/
|
||||
$router->all(
|
||||
'/index.php/dashboard',
|
||||
DashboardController::class
|
||||
);
|
||||
$router->get(
|
||||
'/index.php/users',
|
||||
UsersController::class
|
||||
);
|
||||
$router->all(
|
||||
'/index.php/user',
|
||||
UserController::class
|
||||
);
|
||||
$router->get(
|
||||
'/index.php/usergroups',
|
||||
UsergroupsController::class
|
||||
);
|
||||
$router->all(
|
||||
'/index.php/usergroup',
|
||||
UsergroupController::class
|
||||
);
|
||||
$router->get(
|
||||
'/index.php/menus',
|
||||
MenusController::class
|
||||
);
|
||||
$router->all(
|
||||
'/index.php/menu',
|
||||
MenuController::class
|
||||
);
|
||||
$router->get(
|
||||
'/index.php/items',
|
||||
ItemsController::class
|
||||
);
|
||||
$router->all(
|
||||
'/index.php/item',
|
||||
ItemController::class
|
||||
);
|
||||
$router->get(
|
||||
'/*',
|
||||
LoginController::class
|
||||
);
|
||||
|
||||
return $router;
|
||||
}
|
||||
}
|
@ -0,0 +1,314 @@
|
||||
<?php
|
||||
/**
|
||||
* Joomla! Framework Website
|
||||
*
|
||||
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Service;
|
||||
|
||||
use Joomla\Application\AbstractApplication;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Session\SessionInterface;
|
||||
use Octoleo\CMS\Asset\MixPathPackage;
|
||||
use Octoleo\CMS\Renderer\ApplicationContext;
|
||||
use Octoleo\CMS\Renderer\FrameworkExtension;
|
||||
use Octoleo\CMS\Renderer\FrameworkTwigRuntime;
|
||||
use Joomla\Preload\PreloadManager;
|
||||
use Joomla\Renderer\RendererInterface;
|
||||
use Joomla\Renderer\TwigRenderer;
|
||||
use Symfony\Component\Asset\Packages;
|
||||
use Symfony\Component\Asset\PathPackage;
|
||||
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
|
||||
use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy;
|
||||
use Twig\Cache\CacheInterface;
|
||||
use Twig\Cache\FilesystemCache;
|
||||
use Twig\Cache\NullCache;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\DebugExtension;
|
||||
use Twig\Extension\ProfilerExtension;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Profiler\Profile;
|
||||
use Twig\RuntimeLoader\ContainerRuntimeLoader;
|
||||
|
||||
/**
|
||||
* Templating service provider
|
||||
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Service/TemplatingProvider.php
|
||||
*/
|
||||
class AdminTemplatingProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(Container $container): void
|
||||
{
|
||||
$container->alias(Packages::class, 'asset.packages')
|
||||
->share('asset.packages', [$this, 'getAssetPackagesService'], true);
|
||||
|
||||
$container->alias(RendererInterface::class, 'renderer')
|
||||
->alias(TwigRenderer::class, 'renderer')
|
||||
->share('renderer', [$this, 'getRendererService'], true);
|
||||
|
||||
$container->alias(CacheInterface::class, 'twig.cache')
|
||||
->alias(\Twig_CacheInterface::class, 'twig.cache')
|
||||
->share('twig.cache', [$this, 'getTwigCacheService'], true);
|
||||
|
||||
$container->alias(Environment::class, 'twig.environment')
|
||||
->alias(\Twig_Environment::class, 'twig.environment')
|
||||
->share('twig.environment', [$this, 'getTwigEnvironmentService'], true);
|
||||
|
||||
$container->alias(DebugExtension::class, 'twig.extension.debug')
|
||||
->alias(\Twig_Extension_Debug::class, 'twig.extension.debug')
|
||||
->share('twig.extension.debug', [$this, 'getTwigExtensionDebugService'], true);
|
||||
|
||||
$container->alias(FrameworkExtension::class, 'twig.extension.framework')
|
||||
->share('twig.extension.framework', [$this, 'getTwigExtensionFrameworkService'], true);
|
||||
|
||||
// This service cannot be protected as it is decorated when the debug bar is available
|
||||
$container->alias(ProfilerExtension::class, 'twig.extension.profiler')
|
||||
->alias(\Twig_Extension_Profiler::class, 'twig.extension.profiler')
|
||||
->share('twig.extension.profiler', [$this, 'getTwigExtensionProfilerService']);
|
||||
|
||||
$container->alias(LoaderInterface::class, 'twig.loader')
|
||||
->alias(\Twig_LoaderInterface::class, 'twig.loader')
|
||||
->share('twig.loader', [$this, 'getTwigLoaderService'], true);
|
||||
|
||||
$container->alias(Profile::class, 'twig.profiler.profile')
|
||||
->alias(\Twig_Profiler_Profile::class, 'twig.profiler.profile')
|
||||
->share('twig.profiler.profile', [$this, 'getTwigProfilerProfileService'], true);
|
||||
|
||||
$container->alias(FrameworkTwigRuntime::class, 'twig.runtime.framework')
|
||||
->share('twig.runtime.framework', [$this, 'getTwigRuntimeFrameworkService'], true);
|
||||
|
||||
$container->alias(ContainerRuntimeLoader::class, 'twig.runtime.loader')
|
||||
->alias(\Twig_ContainerRuntimeLoader::class, 'twig.runtime.loader')
|
||||
->share('twig.runtime.loader', [$this, 'getTwigRuntimeLoaderService'], true);
|
||||
|
||||
$this->tagTwigExtensions($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `asset.packages` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Packages
|
||||
*/
|
||||
public function getAssetPackagesService(Container $container): Packages
|
||||
{
|
||||
/** @var AbstractApplication $app */
|
||||
$app = $container->get(AbstractApplication::class);
|
||||
|
||||
$context = new ApplicationContext($app);
|
||||
|
||||
$mediaPath = $app->get('uri.media.path', '/media/');
|
||||
|
||||
$defaultPackage = new PathPackage($mediaPath, new EmptyVersionStrategy, $context);
|
||||
|
||||
$mixStrategy = new MixPathPackage(
|
||||
$defaultPackage,
|
||||
$mediaPath,
|
||||
new JsonManifestVersionStrategy(LPATH_ROOT . '/media/mix-manifest.json'),
|
||||
$context
|
||||
);
|
||||
|
||||
return new Packages(
|
||||
$defaultPackage,
|
||||
[
|
||||
'mix' => $mixStrategy,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `renderer` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return RendererInterface
|
||||
*/
|
||||
public function getRendererService(Container $container): RendererInterface
|
||||
{
|
||||
return new TwigRenderer($container->get('twig.environment'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `twig.cache` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return \Twig_CacheInterface
|
||||
*/
|
||||
public function getTwigCacheService(Container $container): \Twig_CacheInterface
|
||||
{
|
||||
/** @var \Joomla\Registry\Registry $config */
|
||||
$config = $container->get('config');
|
||||
|
||||
// Pull down the renderer config
|
||||
$cacheEnabled = $config->get('template.cache.enabled', false);
|
||||
$cachePath = $config->get('template.cache.path', 'cache/twig');
|
||||
$debug = $config->get('template.debug', false);
|
||||
|
||||
if ($debug === false && $cacheEnabled !== false)
|
||||
{
|
||||
return new FilesystemCache(LPATH_ROOT . '/' . $cachePath);
|
||||
}
|
||||
|
||||
return new NullCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `twig.environment` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Environment
|
||||
*/
|
||||
public function getTwigEnvironmentService(Container $container): Environment
|
||||
{
|
||||
/** @var \Joomla\Registry\Registry $config */
|
||||
$config = $container->get('config');
|
||||
|
||||
$debug = $config->get('template.debug', false);
|
||||
|
||||
$environment = new Environment(
|
||||
$container->get('twig.loader'),
|
||||
['debug' => $debug]
|
||||
);
|
||||
|
||||
// Add the runtime loader
|
||||
$environment->addRuntimeLoader($container->get('twig.runtime.loader'));
|
||||
|
||||
// Set up the environment's caching service
|
||||
$environment->setCache($container->get('twig.cache'));
|
||||
|
||||
// Add the Twig extensions
|
||||
$environment->setExtensions($container->getTagged('twig.extension'));
|
||||
|
||||
// Add a global tracking the debug states
|
||||
$environment->addGlobal('appDebug', $config->get('debug', false));
|
||||
$environment->addGlobal('fwDebug', $debug);
|
||||
|
||||
return $environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `twig.extension.debug` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return DebugExtension
|
||||
*/
|
||||
public function getTwigExtensionDebugService(Container $container): DebugExtension
|
||||
{
|
||||
return new DebugExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `twig.extension.framework` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return FrameworkExtension
|
||||
*/
|
||||
public function getTwigExtensionFrameworkService(Container $container): FrameworkExtension
|
||||
{
|
||||
return new FrameworkExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `twig.extension.profiler` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ProfilerExtension
|
||||
*/
|
||||
public function getTwigExtensionProfilerService(Container $container): ProfilerExtension
|
||||
{
|
||||
return new ProfilerExtension($container->get('twig.profiler.profile'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `twig.loader` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return \Twig_LoaderInterface
|
||||
*/
|
||||
public function getTwigLoaderService(Container $container): \Twig_LoaderInterface
|
||||
{
|
||||
return new FilesystemLoader([LPATH_TEMPLATES]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `twig.profiler.profile` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Profile
|
||||
*/
|
||||
public function getTwigProfilerProfileService(Container $container): Profile
|
||||
{
|
||||
return new Profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `twig.runtime.framework` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return FrameworkTwigRuntime
|
||||
*/
|
||||
public function getTwigRuntimeFrameworkService(Container $container): FrameworkTwigRuntime
|
||||
{
|
||||
return new FrameworkTwigRuntime(
|
||||
$container->get(AbstractApplication::class),
|
||||
$container->get(PreloadManager::class),
|
||||
LPATH_ROOT . '/media/sri-manifest.json',
|
||||
$container->get(SessionInterface::class)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `twig.runtime.loader` service
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ContainerRuntimeLoader
|
||||
*/
|
||||
public function getTwigRuntimeLoaderService(Container $container): ContainerRuntimeLoader
|
||||
{
|
||||
return new ContainerRuntimeLoader($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag services which are Twig extensions
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function tagTwigExtensions(Container $container): void
|
||||
{
|
||||
/** @var \Joomla\Registry\Registry $config */
|
||||
$config = $container->get('config');
|
||||
|
||||
$debug = $config->get('template.debug', false);
|
||||
|
||||
$twigExtensions = ['twig.extension.framework'];
|
||||
|
||||
if ($debug)
|
||||
{
|
||||
$twigExtensions[] = 'twig.extension.debug';
|
||||
}
|
||||
|
||||
$container->tag('twig.extension', $twigExtensions);
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Octoleo CMS
|
||||
*
|
||||
* @created 9th April 2022
|
||||
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
||||
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Octoleo\CMS\Service;
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
/**
|
||||
* Configuration service provider
|
||||
*/
|
||||
class ConfigurationProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Configuration instance
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $file Path to the config file.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct(string $file)
|
||||
{
|
||||
// Verify the configuration exists and is readable.
|
||||
if (!is_readable($file))
|
||||
{
|
||||
throw new \RuntimeException('Configuration file does not exist or is unreadable.');
|
||||
}
|
||||
|
||||
// load the class
|
||||
include_once $file;
|
||||
$this->config = new Registry(new \LConfig());
|
||||
|
||||
// Set database values based on config values
|
||||
$this->config->loadObject( (object) [
|
||||
'database' => [
|
||||
'driver' => $this->config->get('dbtype'),
|
||||
'host' => $this->config->get('host'),
|
||||
'port' => $this->config->get('port', ''),
|
||||
'user' => $this->config->get('user'),
|
||||
'password' => $this->config->get('password'),
|
||||
'database' => $this->config->get('db'),
|
||||
'prefix' => $this->config->get('dbprefix')
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(Container $container): void
|
||||
{
|
||||
$container->share(
|
||||
'config',
|
||||
function (): Registry
|
||||
{
|
||||
return $this->config;
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user