Compare commits

...

108 Commits

Author SHA1 Message Date
415a069f72 add default filter for UriFieldComponent 2024-07-05 19:21:31 -04:00
b58f22ea21 bug fixes 2024-06-04 22:50:46 -04:00
c08e4ce976 update version, install script 2024-06-03 18:48:39 -04:00
384354e307 install script 2024-06-03 16:39:49 -04:00
26d98853f8 added temporary file cleaner 2024-06-02 23:34:34 -04:00
e3601dbd84 remodeled module selection action 2024-06-02 15:52:55 -04:00
ed8165c7fa added AssetListColumn and AssetListActionButton 2024-06-02 01:56:43 -04:00
d7fbcc24b5 added Plugin->getConfig, Module->getConfig, PluginClass->getPluginConfig, ModuleClass->getModuleConfig 2024-06-02 00:35:46 -04:00
4f05dcdf91 added Crispage\Backend\Field 2024-06-02 00:19:47 -04:00
a01278d604 resolveUri now part of Router 2024-06-01 17:53:02 -04:00
bc55c8c27b update version 2024-06-01 17:39:07 -04:00
4ff76c5698 fixed plugin options 2024-06-01 17:32:33 -04:00
824ff96e22 changed arguments to events crispage.plugin_loaded, crispage.plugin_run and crispage.module_loaded 2024-05-31 00:46:49 -04:00
31699ff335 update version, install scripts 2024-05-31 00:45:26 -04:00
30e164948e added Asset->getExtensionInfo 2024-05-27 22:22:17 -04:00
a1c3d94816 more package info fixes 2024-05-27 00:32:24 -04:00
872f035fb9 more package info fixes 2024-05-27 00:24:49 -04:00
06db1c99db more changes to Template->getTemplateInfo and PackageManager->getPackageInfo 2024-05-26 23:43:11 -04:00
ebe0d548dd fixed Template->getTemplateInfo and PackageManager->getPackageInfo 2024-05-26 23:32:47 -04:00
750b7651aa removed problematic whitespace from templates 2024-05-26 15:23:53 -04:00
e03a4a272d added extensions for core assets, bug fixes 2024-05-25 21:11:05 -04:00
6fd22471da update version, installer scripts 2024-05-24 20:37:32 -04:00
c7d0b4b61f fixed asset creation issue 2024-05-24 20:02:04 -04:00
81d3b43f18 authenticator bug fixes 2024-05-23 17:09:06 -04:00
d344acd964 fix upgrade script 2024-05-23 16:38:08 -04:00
4daf406b41 fix upgrade script 2024-05-23 16:31:30 -04:00
26119b0f7c installation scripts 2024-05-23 16:24:33 -04:00
c1965c778d build ckeditor from source 2024-05-23 15:03:48 -04:00
bfe7b0c1b4 separate token hash cost, Authenticator->userHasPermission now takes user as second parameter 2024-05-23 00:00:19 -04:00
7347fbe32f new ini-based config format 2024-05-22 23:50:36 -04:00
bee067a898 additional licenses, updated README, remodeled about page 2024-05-21 23:38:15 -04:00
e96d3f9c1c added scripts for package building and pulling corelibs, consolidated license files 2024-05-21 19:55:33 -04:00
bde8dac543 exception handler now handles multiple exceptions 2024-05-21 13:54:51 -04:00
1d656ce1ca added select fields for templates, layouts, locations 2024-05-21 11:55:18 -04:00
8a2340e529 new Template->setLayout and other methods 2024-05-20 22:13:12 -04:00
4a8bc32bab Asset now part of \Crispage\Framework
Assets now loadable with Crispage->loadClass
new shortnames parameter for Crispage->loadClass
2024-05-20 00:16:44 -04:00
3dabd9209e added ApplicationFeature class 2024-05-19 20:44:50 -04:00
b1ab0bced2 reorganized core
\Crispage\Events renamed to \Crispage\Signaling
Action, Component, ExtensionClass, ModuleComponent, Renderable, Runnable now part of \Crispage\Framework
PluginRunnable now \Crispage\Framework\PluginClass
core extensions modified to fit new naming scheme
/core/app/media and /core/app/search moved to /core/app/cms/
2024-05-19 12:31:01 -04:00
6d882ec119 update version, installer scripts 2024-05-18 20:51:28 -04:00
33447d08b7 updated package.php 2024-05-11 10:19:03 -04:00
9d3569e85f update version, install scripts 2024-04-20 21:18:17 -04:00
5c067e4664 prevent duplicate asset creation 2024-04-19 18:58:49 -04:00
23c4de2a89 update version, package.ini, install scripts 2024-04-19 13:26:37 -04:00
30f3cd2890 update version 2024-03-30 16:12:49 -04:00
f21f7daa83 mkdir now uses permissions of ROOT directory 2024-03-29 19:25:51 -04:00
54ec82fe9e info file handling changes 2024-03-28 19:53:11 -04:00
9e89636bd3 implemented template/translation info files 2024-03-10 23:25:36 -04:00
a2718cc19a update version, install scripts 2024-03-10 23:06:09 -04:00
d90a60bb4e update version, install scripts 2024-03-10 22:49:53 -04:00
0993d73210 fixes for dispatcher, sqlite database adapter 2024-02-29 13:14:47 -05:00
7a2f3bd66e update version, install scripts 2024-02-29 13:01:52 -05:00
2afb88f9be clear cache on package, content updated 2024-02-21 16:12:42 -05:00
26d12d2883 install files 2024-02-21 16:07:12 -05:00
1d28e74c41 search fixes, update version 2024-02-20 22:37:08 -05:00
d4bb449787 fixes 2024-02-20 15:56:20 -05:00
0d5d17ee25 fixes 2024-02-20 15:30:53 -05:00
b24c9fc884 fixes 2024-02-20 13:49:24 -05:00
ad21dca2f0 installer files 2024-02-20 10:16:00 -05:00
c3f8f37edd content caching 2024-02-19 15:52:27 -05:00
eb3dd86780 fixes and optimizations around assets, caching 2024-02-19 14:16:41 -05:00
e8a180f3ae clear cache button, fixes 2024-02-17 19:24:46 -05:00
dcf46315db settings caching 2024-02-17 19:15:51 -05:00
fdc1270676 caching policies, fixes 2024-02-17 19:10:01 -05:00
41cc3f7745 fixes 2024-02-17 18:25:59 -05:00
3c30f5927d temporary entries, events 2024-02-17 18:19:10 -05:00
05fd338d03 caching tweaks 2024-02-13 18:14:54 -05:00
1b1c7f3a4c implement CacheEngine, component caching 2024-02-12 23:09:06 -05:00
f04c71c319 installer sample data 2024-02-08 14:11:55 -05:00
e478233457 installer css 2024-02-08 12:40:41 -05:00
ef2eec4658 update version, install scripts 2024-02-08 12:17:31 -05:00
d622f22e3b update version, add install files 2024-02-07 15:42:21 -05:00
8ca81cbbf1 update version, add installer files 2024-02-07 15:17:20 -05:00
e7b630eb42 install files 2024-02-02 23:17:53 -05:00
812a84e9f8 fixed I18n->translate(), username validation 2024-02-02 23:06:01 -05:00
798e274503 update version, add installer files 2024-02-02 21:54:31 -05:00
0732dee1b0 user messages, added Database::OP_REGEX 2024-02-02 21:41:28 -05:00
9af09efcf5 online users component 2024-01-28 22:55:05 -05:00
558ef7eecc dedicated new user creation view 2024-01-28 19:29:07 -05:00
386d47a1d0 user confirmation fixes 2024-01-28 16:06:47 -05:00
6d354f0a4a regex optimizations 2024-01-21 22:39:50 -05:00
68aba2b545 add dispatcher suppress and return values 2024-01-21 22:30:14 -05:00
9f7f96712c database cleaner now includes rme, userconfirmation 2024-01-21 17:09:38 -05:00
ce46da026b v0.20.1a 2024-01-17 16:27:40 -05:00
3e2b56669b default backend layout 2024-01-16 15:06:18 -05:00
0e14b6e94b invalid template error handling 2024-01-15 21:54:21 -05:00
dd721188f9 translations 2024-01-15 17:47:02 -05:00
016abf3037 add system information 2024-01-15 17:41:10 -05:00
83a3a03b21 update script 2024-01-15 16:25:36 -05:00
fb06e263da fix 2024-01-15 16:16:45 -05:00
8689d2f7ba fix 2024-01-15 16:13:04 -05:00
1f18a9ec85 installer permissions check 2024-01-15 15:50:29 -05:00
1ff0b09444 removed publish date requirement in editor 2024-01-15 14:40:17 -05:00
d589e059d8 unpublished articles no longer show in new/popular content modules 2024-01-13 14:11:11 -05:00
60bc77910a add update script for 0.20.1a-rc1 2023-12-09 21:57:17 -05:00
0e9923c8a4 additional events for Crispage (crispage.*) 2023-12-09 21:54:34 -05:00
6a78633f81 html module shortcodes 2023-12-09 21:30:06 -05:00
c6450ef51a hard routes 2023-12-09 21:20:32 -05:00
04912a83ab fix editor 2023-12-03 18:40:02 -05:00
bd55faf7bf ui tweaks 2023-12-03 18:13:16 -05:00
c4991ad11b fix update scripts 2023-12-03 16:06:07 -05:00
83857c7268 add update scripts 2023-12-03 15:27:31 -05:00
b923741398 added breadcrumbs module 2023-12-03 15:18:46 -05:00
0d36ecf866 ui changes 2023-12-02 20:44:00 -05:00
7e22308aec added redirects 2023-12-02 17:55:11 -05:00
514b312036 more shortcode stuff, added content linker in editor 2023-12-02 16:23:41 -05:00
5476e60a1b added shortcodes 2023-11-30 22:37:40 -05:00
8187868edd update script for 0.20.0a-rc2 2023-09-24 17:03:38 -04:00
ad8c9a1580 ContentAsset author_id now set in editor, comments now displayed with correct time, NewContentComponent lists content correctly 2023-09-18 21:42:37 -04:00
1234 changed files with 5431 additions and 2203 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ packages/**
!packages/crispage.core/**
!packages/.htaccess
crispage_*.tar.gz
_build/**

237
LICENSE
View File

@ -1,232 +1,13 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Crispage 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.
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Crispage 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.
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
A copy of the GNU General Public License and the licenses for the libraries
which Crispage is built on can be found in the _licenses/ directory.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
“This License” refers to version 3 of the GNU General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based on the Program.
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
<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 <http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -1,3 +1,5 @@
# crispage
# Crispage
Crispage is CMS software with a focus on flexibility, modularity and lightness. It is designed for LAMP servers and is compatible with PHP 8.1+.
Crispage is free CMS and web application software designed to be fast, light and modular. It is compatible with PHP 8.1+ and is designed to run on LAMP server stacks.
### [Crispage on crispy.cat](https://crispy.cat/software/crispage) | [Matrix Chat](https://matrix.to/#/#crispage:matrix.calitabby.com) | [Documentation](https://git.calitabby.com/crispage/crispage/wiki)

View File

@ -1,6 +1,6 @@
[Package]
id = crispage.updater
version = 0.20.0a-rc1
version = VERSION
[PackageData]

View File

@ -0,0 +1,32 @@
<?php
$this->log("Backing up config.php");
copy(ROOT . "/config.php", ROOT . "/config.old.php");
$this->runScript(PACKAGE, "copy_files");
copy(PACKAGE_PATH . "/index.php", ROOT . "/index.php");
copy(PACKAGE_PATH . "/package.php", ROOT . "/package.php");
$this->app->database->renameColumn($this->app->assets->getTable("\\Crispage\\Assets\\Plugin"), "runnable", "classname");
$this->log("Creating new config.php");
$template = file_get_contents(ROOT . "/packages/crispage.core/config_template.php");
$nmatches = preg_match_all(\Crispage\Text\I18n::TS_REGEX, $template, $matches, PREG_OFFSET_CAPTURE);
$pos = 0;
$config = "";
for ($i = 0; $i < $nmatches; $i++) {
$start = $matches[0][$i][1];
$length = strlen($matches[0][$i][0]);
$key = $matches[1][$i][0];
$config .= substr($template, $pos, $start - $pos);
$config .= constant("Config::$key") ?? $key;
$pos = $start + $length;
}
$config .= substr($template, $pos);
file_put_contents(ROOT . "/config.php", $config);
$this->log("Done");
?>

View File

@ -1,27 +0,0 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
// monkey patch for 0.20.0a-rc1
if (!file_exists(ROOT . "/core/_patched")) {
copy(PACKAGE_PATH . "/core/utils/FileUtils.php", ROOT . "/core/utils/FileUtils.php");
touch(ROOT . "/core/_patched");
header("Refresh: 0");
die();
}
$this->runScript(PACKAGE, "copy_files");
if ($this->status != $this::SUCCESS) throw new \Exception("Could not copy files");
$this->runScript(PACKAGE, "update_database");
if ($this->status != $this::SUCCESS) throw new \Exception("Could not update database");
//$this->runScript(PACKAGE, "update_config");
if ($this->status != $this::SUCCESS) throw new \Exception("Could not update config");
?>

View File

@ -0,0 +1 @@
<?php $this->runScript(PACKAGE, "changes_0.25"); ?>

View File

@ -0,0 +1,4 @@
<?php
$this->runScript(PACKAGE, "copy_files");
$this->runScript(PACKAGE, "update_database");
?>

View File

@ -0,0 +1,4 @@
<?php
$this->runScript(PACKAGE, "copy_files");
$this->runScript(PACKAGE, "update_database");
?>

View File

@ -0,0 +1,4 @@
<?php
$this->runScript(PACKAGE, "copy_files");
$this->runScript(PACKAGE, "update_database");
?>

View File

@ -0,0 +1,4 @@
<?php
$this->runScript(PACKAGE, "copy_files");
$this->runScript(PACKAGE, "update_database");
?>

View File

@ -1 +1 @@
0.20.0a-rc2
0.26.1a

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2023 Jeremy Thomas
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,28 @@
Software License Agreement
==========================
**CKEditor&nbsp;5** https://github.com/ckeditor/ckeditor5 <br>
Copyright (c) 20032024, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
Sources of Intellectual Property Included in CKEditor
-----------------------------------------------------
Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.
The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):
* BlurHash - Copyright (c) 2018 Wolt Enterprises (MIT license).
* color-convert - Copyright (c) 20112016 Heather Arthur <fayearthur@gmail.com>, copyright (c) 20162021 Josh Junon <josh@junon.me>.
* color-parse - Copyright (c) 2015 Dmitry Ivanov.
* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.
* Marked - Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/), copyright (c) 20112018, Christopher Jeffrey (https://github.com/chjj/).
* Turndown - Copyright (c) 2017+ Dom Christie.
* turndown-plugin-gfm - Copyright (c) 2017+ Dom Christie.
* vanilla-colorful - Copyright (c) 2020 Serhii Kulykov <iamkulykov@gmail.com>.
Trademarks
----------
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.

View File

@ -0,0 +1,21 @@
MIT License
Copyright (C) 2017 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,232 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
“This License” refers to version 3 of the GNU General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based on the Program.
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
<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 <http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -475,10 +475,8 @@ convey the exclusion of warranty; and each file should have at least the
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by
the Free Software Foundation; either
version 2.1 of the License, or
(at your option) any later version.
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of

View File

@ -0,0 +1,37 @@
Original readme (from author of the icons)
----------
Silk icon set 1.3
_________________________________________
Mark James
http://www.famfamfam.com/lab/icons/silk/
_________________________________________
This work is licensed under a
Creative Commons Attribution 2.5 License.
[ http://creativecommons.org/licenses/by/2.5/ ]
This means you may use it for any purpose,
and make any changes you like.
All I ask is that you include a link back
to this page in your credits.
Are you using this icon set? Send me an email
(including a link or picture if available) to
mjames@gmail.com
Any other questions about this icon set please
contact mjames@gmail.com
About the rest (all this repository but the icons)
----------
All the content of this repository (excepted the icon pack)
is licensed under the [MIT license](http://opensource.org/licenses/MIT).
Though, it is just composed a few trivial json files and a Readme.

View File

@ -0,0 +1,20 @@
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1
_scripts/.htaccess Normal file
View File

@ -0,0 +1 @@
Require all denied

27
_scripts/build_package.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
PWD="$(pwd)";
WORK_DIR="${1:-$PWD}";
BUILD_DIR="$WORK_DIR/_build";
VERSION="$(cat $WORK_DIR/_crispage/version)";
GIT_URL="https://git.calitabby.com/crispage/crispage.git";
REPO_DIR="$BUILD_DIR/repo";
ARCHIVE="$BUILD_DIR/crispage_$VERSION.tar.gz";
echo "Building package for $VERSION";
echo "Cleaning build directory";
rm -rf "$BUILD_DIR";
mkdir "$BUILD_DIR";
mkdir "$REPO_DIR";
echo "Cloning repository";
git clone "$GIT_URL" -b "$VERSION" "$REPO_DIR";
rm -rf "$REPO_DIR/.git";
rm -rf "$REPO_DIR/_scripts";
echo "Creating archive";
cd "$REPO_DIR";
GZIP=-9 tar -cvzf "$ARCHIVE" *;
cd "$WORK_DIR";
echo "Archive created at $ARCHIVE";

37
_scripts/pull_corelibs.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
PWD="$(pwd)";
WORK_DIR="${1:-$PWD}";
BUILD_DIR="$WORK_DIR/_build/corelibs";
GIT_URL="https://git.calitabby.com/crispage/corelibs.git";
REPO_DIR="$BUILD_DIR/repo";
LIB_PATH="/lib";
MEDIALIB_PATH="/media/lib";
LICENSE_PATH="/_license";
echo "Pulling corelibs";
echo "Cleaning build directory";
rm -rf "$BUILD_DIR";
mkdir -p "$REPO_DIR";
echo "Cloning repository";
git clone "$GIT_URL" "$REPO_DIR";
echo "Cleaning destinations";
rm -rf "$WORK_DIR$LIB_PATH";
mkdir "$WORK_DIR$LIB_PATH";
rm -rf "$WORK_DIR$MEDIALIB_PATH";
mkdir "$WORK_DIR$MEDIALIB_PATH";
rm -rf "$WORK_DIR$LICENSE_PATH";
mkdir "$WORK_DIR$LICENSE_PATH";
echo "Copying files";
cp -rv "$REPO_DIR$LIB_PATH"/* "$WORK_DIR$LIB_PATH";
cp -rv "$REPO_DIR$MEDIALIB_PATH"/* "$WORK_DIR$MEDIALIB_PATH";
cp -rv "$REPO_DIR$LICENSE_PATH"/* "$WORK_DIR$LICENSE_PATH";
echo "Adding .htaccess to lib"
echo "Require all denied" > "$WORK_DIR$LIB_PATH/.htaccess";
echo "Copied";

View File

@ -14,10 +14,10 @@
defined("ROOT") or die();
use \Crispage\Asset;
use \Crispage\Framework\Asset;
use \Crispage\Auth\CorePermissions;
class APIAssetAction extends \Crispage\Response\Action
class APIAssetAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [
@ -67,7 +67,7 @@
$class = strval($this->app->request->json["_class"] ?? null);
if (
!class_exists($class) ||
!is_a($class, "\\Crispage\\Asset", true)
!is_a($class, "\\Crispage\\Framework\\Asset", true)
) {
http_response_code(400);
$out = ["error" => "Bad Request"];
@ -76,7 +76,7 @@
// Check perms
$perm = $class::getPermissions()["create"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
http_response_code(401);
$out = ["error" => "Unauthorized"];
break;
@ -86,9 +86,9 @@
$asset = $this->app->assets->create($class, [], true);
$fields = $asset::getEditorFields();
foreach ($fields as $prop => $field) {
$val = $this->app->request->json[$prop] ?? null;
if ($val !== null) $asset->$prop = $field["filter"]($val);
foreach ($fields as $field) {
if (isset($this->app->request->json[$field->name]))
$asset->{$field->name} = $field->filter($this->app, $this->app->request->json[$field->name]);
}
// Automatic slug
@ -132,7 +132,7 @@
$perm = $asset::getPermissions()["modify_own"];
else $perm = $asset::getPermissions()["modify"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
http_response_code(401);
$out = ["error" => "Unauthorized"];
break;
@ -140,9 +140,9 @@
// Edit asset
$fields = $asset::getEditorFields();
foreach ($fields as $prop => $field) {
$val = $this->app->request->json[$prop] ?? null;
if ($val !== null) $asset->$prop = $field["filter"]($val);
foreach ($fields as $field) {
if (isset($this->app->request->json[$field->name]))
$asset->{$field->name} = $field->filter($this->app, $this->app->request->json[$field->name]);
}
// Automatic slug
@ -186,7 +186,7 @@
$perm = $asset::getPermissions()["delete_own"];
else $perm = $asset::getPermissions()["delete"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
http_response_code(401);
$out = ["error" => "Unauthorized"];
break;

View File

@ -16,7 +16,7 @@
use \Crispage\Auth\CorePermissions;
class APIAssetBySlugAction extends \Crispage\Response\Action
class APIAssetBySlugAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [

View File

@ -14,10 +14,10 @@
defined("ROOT") or die();
use \Crispage\Asset;
use \Crispage\Framework\Asset;
use \Crispage\Auth\CorePermissions;
class APIAssetOptionsAction extends \Crispage\Response\Action
class APIAssetOptionsAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [
@ -76,7 +76,7 @@
$perm = $asset::getPermissions()["modify_own"];
else $perm = $asset::getPermissions()["modify"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
http_response_code(401);
$out = ["error" => "Unauthorized"];
break;
@ -88,6 +88,14 @@
$val = $this->app->request->json[$name] ?? null;
if ($val !== null) $asset->setOption($name, $field["filter"]($val));
}
foreach ($options as $field) {
if (isset($this->app->request->json[$field->name])) {
$asset->setOption(
$field->name,
$field->filter($this->app, $this->app->request->json[$field->name])
);
}
}
// Save to database
$this->app->assets->set($asset);

View File

@ -17,7 +17,7 @@
use \Crispage\Auth\CorePermissions;
use \Crispage\Search\SearchFilter;
class APIAssetSearchAction extends \Crispage\Response\Action
class APIAssetSearchAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [
@ -58,7 +58,7 @@
$this->app->search->fromText($query);
if (!$this->app->auth->userHasPermission(null, CorePermissions::VIEW_UNPUBLISHED))
if (!$this->app->auth->userHasPermission(CorePermissions::VIEW_UNPUBLISHED))
$this->app->search->addFilter(new SearchFilter("state", 0, SearchFilter::FOP_GREATER));
$this->app->search->collect();

View File

@ -15,9 +15,9 @@
defined("ROOT") or die();
use \Crispage\Auth\CorePermissions;
use \Crispage\Asset;
use \Crispage\Framework\Asset;
class APIAssetsAction extends \Crispage\Response\Action
class APIAssetsAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [

View File

@ -16,7 +16,7 @@
use \Crispage\Auth\CorePermissions;
class APIDefaultAction extends \Crispage\Response\Action
class APIDefaultAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [

View File

@ -16,7 +16,7 @@
use \Crispage\Auth\CorePermissions;
class APIMediaAction extends \Crispage\Response\Action
class APIMediaAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [

View File

@ -16,7 +16,7 @@
use \Crispage\Auth\CorePermissions;
class APIMediaFolderAction extends \Crispage\Response\Action
class APIMediaFolderAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [

View File

@ -16,7 +16,7 @@
use \Crispage\Auth\CorePermissions;
class APISessionAction extends \Crispage\Response\Action
class APISessionAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [

View File

@ -16,7 +16,7 @@
use \Crispage\Auth\CorePermissions;
class APISettingsAction extends \Crispage\Response\Action
class APISettingsAction extends \Crispage\Framework\Action
implements \Crispage\Response\APIPermissions {
public static function getExtensionInfo(): array {
return [

View File

@ -19,7 +19,7 @@
use \Crispage\Utils\URIUtils;
use \Crispage\Auth\CorePermissions;
class APIInitAction extends \Crispage\Response\Action {
class APIInitAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.api",
@ -55,7 +55,7 @@
}
// Get required permissions
$this->app->loadClass($route->action, "\\Crispage\\Response\\Action");
$this->app->loadClass($route->action, "action");
if (!is_a($route->action, "\\Crispage\\Response\\APIPermissions", true)) {
http_response_code(500);
header("Content-Type: application/json");
@ -87,7 +87,7 @@
}
// Check that user has required permissions
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
http_response_code(401);
header("Content-Type: application/json");
$com = $this->app->page->createComponent(
@ -103,8 +103,8 @@
$this->app->route = $route;
$this->app->page->template->setLayout(
$route->data["template"] ?? "default",
$route->data["layout"] ?? "api"
$route->data["layout"] ?? "api",
$route->data["template"] ?? "default"
);
$this->app->page->setAction(
$route->action, array_merge($this->data, $route->data)

View File

@ -18,7 +18,7 @@
use \Crispage\Auth\CorePermissions;
use \Crispage\Assets\Article;
class ArticleAction extends \Crispage\Response\Action {
class ArticleAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.article",
@ -44,7 +44,7 @@
// If not published and user does not have unpublished perms, error 404
$show_unpublished = $this->app->auth->userHasPermission(
null, CorePermissions::VIEW_UNPUBLISHED
CorePermissions::VIEW_UNPUBLISHED
);
if ($article->state < Article::PUBLISHED && !$show_unpublished) {
$this->app->handleException(new CrispageException(

View File

@ -14,7 +14,17 @@
defined("ROOT") or die();
class AboutAction extends \Crispage\Response\Action {
class AboutAction extends \Crispage\Framework\Action {
public const LICENSES = [
"Crispage" => ROOT . "/_license/Crispage.license.txt",
"PHPMailer" => ROOT . "/_license/PHPMailer.license.txt",
"jQuery" => ROOT . "/_license/jQuery.license.txt",
"CodeMirror" => ROOT . "/_license/CodeMirror.license.txt",
"CKEditor" => ROOT . "/_license/CKEditor.license.txt",
"Bulma" => ROOT . "/_license/Bulma.license.txt",
"Silkicons" => ROOT . "/_license/Silkicons.license.txt"
];
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.about",
@ -27,12 +37,16 @@
}
public function run(): void {
$licenses = [];
foreach (self::LICENSES as $lib => $path)
$licenses[$lib] = htmlentities(wordwrap(file_get_contents($path), 80));
// Set title
$this->app->page->data["title"] = $this->app->i18n->getTranslation("ABOUT_CRISPAGE");
// Set main component
$com = $this->app->page->createComponent(
"\\Crispage\\Components\\Backend\\AboutComponent", []
"\\Crispage\\Components\\Backend\\AboutComponent", ["licenses" => $licenses]
);
$this->app->page->setMainComponent($com);

View File

@ -16,9 +16,9 @@
use \Crispage\CrispageException;
use \Crispage\Utils\URIUtils;
use \Crispage\Asset;
use \Crispage\Framework\Asset;
class AssetDeleteAction extends \Crispage\Response\Action {
class AssetDeleteAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.assetdelete",
@ -33,11 +33,11 @@
public function run(): void {
// Get class name
$this->data["classname"] = strval(
$this->app->request->params["classname"] ?? "\\Crispage\\Asset"
$this->app->request->params["classname"] ?? "\\Crispage\\Framework\\Asset"
);
if (
!class_exists($this->data["classname"]) ||
!is_a($this->data["classname"], "\\Crispage\\Asset", true)
!is_a($this->data["classname"], "\\Crispage\\Framework\\Asset", true)
) {
$this->app->handleException(
new CrispageException(
@ -73,7 +73,7 @@
$perm = $this->data["asset"]::getPermissions()["delete_own"];
else $perm = $this->data["asset"]::getPermissions()["delete"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(

View File

@ -16,9 +16,9 @@
use \Crispage\CrispageException;
use \Crispage\Utils\URIUtils;
use \Crispage\Asset;
use \Crispage\Framework\Asset;
class AssetEditorAction extends \Crispage\Response\Action {
class AssetEditorAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.editor",
@ -33,12 +33,12 @@
public function run(): void {
// Get class name
$this->data["classname"] = strval(
$this->app->request->params["classname"] ?? "\\Crispage\\Asset"
$this->app->request->params["classname"] ?? "\\Crispage\\Framework\\Asset"
);
if (
!class_exists($this->data["classname"]) ||
!is_a($this->data["classname"], "\\Crispage\\Asset", true)
!is_a($this->data["classname"], "\\Crispage\\Framework\\Asset", true)
) {
$this->app->handleException(
new CrispageException(
@ -80,7 +80,7 @@
$perm = $this->data["asset"]::getPermissions()["modify_own"];
else $perm = $this->data["asset"]::getPermissions()["modify"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(
@ -96,7 +96,7 @@
$this->data["asset"] = null;
$perm = $this->data["classname"]::getPermissions()["create"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(
@ -120,14 +120,21 @@
);
}
foreach ($this->data["fields"] as $prop => $field) {
$val = $this->app->request->params["fields"][$prop] ?? null;
if ($val !== null) $this->data["asset"]->$prop = $field["filter"]($val);
foreach ($this->data["fields"] as $field) {
$this->data["asset"]->{$field->name} = $field->filter(
$this->app, $this->app->request->params["fields"][$field->name] ?? null,
$this->data["asset"]->{$field->name}
);
}
foreach ($this->data["options"] as $name => $field) {
$val = $this->app->request->params["options"][$name] ?? null;
if ($val !== null) $this->data["asset"]->setOption($name, $field["filter"]($val));
foreach ($this->data["options"] as $field) {
$this->data["asset"]->setOption(
$field->name,
$field->filter(
$this->app, $this->app->request->params["options"][$field->name] ?? null,
$this->data["asset"]->getOption($field->name)
)
);
}
// Automatic slug

View File

@ -15,8 +15,9 @@
defined("ROOT") or die();
use \Crispage\Utils\Paginator;
use \Crispage\CrispageException;
class AssetListAction extends \Crispage\Response\Action {
class AssetListAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.assetlist",
@ -31,11 +32,11 @@
public function run(): void {
// Get class name
$this->data["classname"] = strval(
$this->app->request->params["classname"] ?? "\\Crispage\\Asset"
$this->app->request->params["classname"] ?? "\\Crispage\\Framework\\Asset"
);
if (
!class_exists($this->data["classname"]) ||
!is_a($this->data["classname"], "\\Crispage\\Asset", true)
!is_a($this->data["classname"], "\\Crispage\\Framework\\Asset", true)
) {
$this->app->handleException(
new CrispageException(

View File

@ -17,7 +17,7 @@
use \Crispage\Utils\URIUtils;
use \Crispage\Assets\Comment;
class CommentApproveAction extends \Crispage\Response\Action {
class CommentApproveAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.approvecomment",
@ -37,7 +37,7 @@
// Check perms
$perm = Comment::getPermissions()["modify"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(

View File

@ -17,7 +17,7 @@
use \Crispage\Utils\URIUtils;
use \Crispage\Assets\Comment;
class CommentHideAction extends \Crispage\Response\Action {
class CommentHideAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.hidecomment",
@ -37,7 +37,7 @@
// Check perms
$perm = Comment::getPermissions()["modify"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
class DashboardAction extends \Crispage\Response\Action {
class DashboardAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.dashboard",

View File

@ -17,7 +17,7 @@
use \Crispage\Utils\URIUtils;
use \Crispage\Auth\CorePermissions;
class ExtensionInstallAction extends \Crispage\Response\Action {
class ExtensionInstallAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.extensioninstall",
@ -34,7 +34,7 @@
"route" => "extensions/list"
]);
if (!$this->app->auth->userHasPermission(null, CorePermissions::MANAGE_EXTENSIONS)) {
if (!$this->app->auth->userHasPermission(CorePermissions::MANAGE_EXTENSIONS)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(

View File

@ -17,7 +17,7 @@
use \Crispage\Utils\Paginator;
use \Crispage\Utils\URIUtils;
class ExtensionListAction extends \Crispage\Response\Action {
class ExtensionListAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.extensionlist",

View File

@ -17,7 +17,7 @@
use \Crispage\Utils\URIUtils;
use \Crispage\Auth\CorePermissions;
class ExtensionUninstallAction extends \Crispage\Response\Action {
class ExtensionUninstallAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.extensionuninstall",
@ -36,7 +36,7 @@
$this->data["package"] = strval($this->app->request->params["package"] ?? "");
if (!$this->app->auth->userHasPermission(null, CorePermissions::MANAGE_EXTENSIONS)) {
if (!$this->app->auth->userHasPermission(CorePermissions::MANAGE_EXTENSIONS)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(

View File

@ -17,7 +17,7 @@
use \Crispage\Utils\URIUtils;
use \Crispage\Auth\CorePermissions;
class MediaCreateFolderAction extends \Crispage\Response\Action {
class MediaCreateFolderAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.mediacreatefolder",
@ -38,7 +38,7 @@
"folder" => $this->data["folder"]->path
]);
if (!$this->app->auth->userHasPermission(null, CorePermissions::MANAGE_MEDIA)) {
if (!$this->app->auth->userHasPermission(CorePermissions::MANAGE_MEDIA)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(

View File

@ -17,7 +17,7 @@
use \Crispage\Utils\URIUtils;
use \Crispage\Auth\CorePermissions;
class MediaDeleteAction extends \Crispage\Response\Action {
class MediaDeleteAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.mediadelete",
@ -38,7 +38,7 @@
"folder" => $this->data["folder"]
]);
if (!$this->app->auth->userHasPermission(null, CorePermissions::MANAGE_MEDIA)) {
if (!$this->app->auth->userHasPermission(CorePermissions::MANAGE_MEDIA)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(

View File

@ -17,7 +17,7 @@
use \Crispage\Utils\Paginator;
use \Crispage\Utils\URIUtils;
class MediaListAction extends \Crispage\Response\Action {
class MediaListAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.medialist",

View File

@ -17,7 +17,7 @@
use \Crispage\Utils\URIUtils;
use \Crispage\Auth\CorePermissions;
class MediaUploadAction extends \Crispage\Response\Action {
class MediaUploadAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.mediaupload",
@ -38,7 +38,7 @@
"folder" => $this->data["folder"]->path
]);
if (!$this->app->auth->userHasPermission(null, CorePermissions::MANAGE_MEDIA)) {
if (!$this->app->auth->userHasPermission(CorePermissions::MANAGE_MEDIA)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(

View File

@ -16,10 +16,10 @@
use \Crispage\CrispageException;
use \Crispage\Utils\URIUtils;
use \Crispage\Asset;
use \Crispage\Framework\Asset;
use \Crispage\Assets\Module;
class ModuleCreateAction extends \Crispage\Response\Action {
class ModuleCreateAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.modulecreate",
@ -40,7 +40,7 @@
// Check perms
$perm = Module::getPermissions()["create"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(
@ -54,8 +54,8 @@
// If classname given, create the module
$component = strval($this->app->request->params["component"] ?? "");
if (!empty($component)) {
$this->app->loadClass($component, "\\Crispage\\Response\\Component");
if (!is_a($component, "\\Crispage\\Response\\ModuleComponent", true)) {
$this->app->loadClass($component, "component");
if (!is_a($component, "\Crispage\Framework\ModuleComponent", true)) {
$this->app->page->setPersistentMessage(
"invalid_module_component",
$this->app->i18n->translate(

View File

@ -15,8 +15,10 @@
defined("ROOT") or die();
use \Crispage\Auth\CorePermissions;
use \Crispage\ApplicationConfig;
use \Crispage\Utils\FileUtils;
class SettingsAction extends \Crispage\Response\Action {
class SettingsAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.settings",
@ -24,16 +26,12 @@
];
}
public function __construct(\Crispage $app, array $data) {
parent::__construct($app, $data);
}
public function run(): void {
$settings = $this->app->request->params["settings"] ?? [];
if (!is_array($settings)) $settings = [];
if (!empty($settings)) {
if (!$this->app->auth->userHasPermission(null, CorePermissions::MODIFY_SETTINGS)) {
if (!$this->app->auth->userHasPermission(CorePermissions::MODIFY_SETTINGS)) {
$this->app->page->data["messages"]["no_permission"] = [
"content" => $this->app->i18n->translate("{%YOU_DO_NOT_HAVE_PERMISSION_TO_PERFORM_}"),
"color" => "danger"
@ -53,7 +51,7 @@
if (!is_array($tools)) $tools = [];
if (!empty($tools)) {
if (!$this->app->auth->userHasPermission(null, CorePermissions::MODIFY_SETTINGS)) {
if (!$this->app->auth->userHasPermission(CorePermissions::MODIFY_SETTINGS)) {
$this->app->page->data["messages"]["no_permission"] = [
"content" => $this->app->i18n->translate("{%YOU_DO_NOT_HAVE_PERMISSION_TO_PERFORM_}"),
"color" => "danger"
@ -98,14 +96,44 @@
break;
}
case "clean": {
$this->app->database->delete(
"sessions", ["expire_time" => [time(), $this->app->database::OP_LESS]]
);
$this->app->page->data["messages"]["database_cleaned"] = [
"content" => $this->app->i18n->translate("{%DATABASE_CLEANED}"),
"color" => "success"
];
break;
switch ($data) {
case "database": {
$this->app->database->delete(
"sessions", ["expire_time" => [time(), $this->app->database::OP_LESS]]
);
$this->app->database->delete(
"rme", ["expire_time" => [time(), $this->app->database::OP_LESS]]
);
$this->app->database->delete(
"userconfirmation", ["expire_time" => [time(), $this->app->database::OP_LESS]]
);
$this->app->page->data["messages"]["database_cleaned"] = [
"content" => $this->app->i18n->translate("{%DATABASE_CLEANED}"),
"color" => "success"
];
break;
}
case "cache": {
$count = $this->app->cache->initializeCache();
$this->app->page->data["messages"]["cache_cleared"] = [
"content" => $this->app->i18n->translate("{%CLEARED_CACHE_ENTRIES}", $count),
"color" => "success"
];
break;
}
case "temp": {
$temp_path = ROOT . ApplicationConfig::get("crispage.paths.temp");
$paths = ["$temp_path/pkguploads"];
$count = 0;
foreach ($paths as $path)
$count += FileUtils::emptyDirectory($path);
$this->app->page->data["messages"]["tempfiles_deleted"] = [
"content" => $this->app->i18n->translate("{%DELETED_TEMP_FILES}", $count),
"color" => "success"
];
}
}
}
}
}

View File

@ -0,0 +1,125 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage\Actions\Backend;
defined("ROOT") or die();
use \Crispage\CrispageException;
use \Crispage\Utils\URIUtils;
use \Crispage\Framework\Asset;
use \Crispage\Assets\User;
class UserCreateAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.usercreate",
"version" => VERSION
];
}
public function __construct(\Crispage $app, array $data) {
parent::__construct($app, $data);
}
public function run(): void {
$this->data["list_uri"] = URIUtils::iuri("/backend", [
"route" => "assets/list",
"classname" => "\\Crispage\\Assets\\User"
]);
// Check perms
$perm = User::getPermissions()["create"];
if (!$this->app->auth->userHasPermission($perm)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(
"{%YOU_DO_NOT_HAVE_PERMISSION__THIS_ACTION}",
),
"danger"
);
$this->app->page->redirect($this->data["list_uri"]);
}
$err = null;
$redirect = false;
// Register the user
$username = strval($this->app->request->params["username"] ?? "");
$password = strval($this->app->request->params["password"] ?? "");
$passconf = strval($this->app->request->params["passconf"] ?? "");
$data = $this->app->request->params["data"] ?? [];
if (!is_array($data)) $data = [];
$sendmail = boolval($this->app->request->params["sendmail"] ?? true);
if ($password == $passconf) {
if ($this->app->request->method = "POST" && $username && $password) {
switch ($this->app->auth->registerUser($username, $password, $data, $sendmail, false)) {
case $this->app->auth::SUCCESS:
$err = "USER_CREATED";
$redirect = true;
break;
case $this->app->auth::ERR_REGISTER_DISABLED:
$err = "REGISTRATION_DISABLED";
break;
case $this->app->auth::ERR_REGISTER_TAKEN:
$err = "USERNAME_TAKEN";
break;
case $this->app->auth::ERR_SENDCONF_EMAIL_FAILED:
$err = "MAILING_FAILED";
$redirect = true;
break;
default:
$err = "UNKNOWN_ERROR";
}
}
}
else $err = "PASSWORDS_DO_NOT_MATCH";
// Redirect/show error
if ($redirect) {
$user = $this->app->assets->getBySlug("\\Crispage\\Assets\\User", $username);
$this->app->page->setPersistentMessage(
strtolower($err),
$this->app->i18n->translate("{%$err}", $this->app->mailer->pm->ErrorInfo),
($err == "USER_CREATED") ? "success" : "danger"
);
$this->app->page->redirect(URIUtils::iuri("/backend", [
"route" => "assets/editor",
"classname" => "\\Crispage\\Assets\\User",
"asset_id" => $user->id
]));
}
elseif (!empty($err)) {
$this->app->page->data["messages"][strtolower($err)] = [
"content" => $this->app->i18n->translate("{%$err}"),
"color" => "danger"
];
}
// Set title
$this->app->page->data["title"] = $this->app->i18n->translate(
"{%EDITOR_TITLE_CREATE}", "User"
);
// Set main component
$com = $this->app->page->createComponent(
"\\Crispage\\Components\\Backend\\UserCreateComponent", $this->data
);
$this->app->page->setMainComponent($com);
$this->app->page->actionFinished();
}
}
?>

View File

@ -0,0 +1,107 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage\Actions\Backend;
defined("ROOT") or die();
use \Crispage\CrispageException;
use \Crispage\Utils\URIUtils;
use \Crispage\Auth\CorePermissions;
class UserMessageAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend.usermessage",
"version" => VERSION
];
}
public function __construct(\Crispage $app, array $data) {
parent::__construct($app, $data);
}
public function run(): void {
$this->data["list_uri"] = URIUtils::iuri("/backend", [
"route" => "assets/list",
"classname" => "\\Crispage\\Assets\\User"
]);
if (!$this->app->auth->userHasPermission(CorePermissions::SEND_MESSAGES)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate(
"{%YOU_DO_NOT_HAVE_PERMISSION__THIS_ACTION}",
),
"danger"
);
$this->app->page->redirect($this->data["list_uri"]);
}
$users = $this->app->request->params["users"] ?? [];
if (!is_array($users)) $users = [];
$roles = $this->app->request->params["roles"] ?? [];
if (!is_array($roles)) $roles = [];
$subject = strval($this->app->request->params["subject"] ?? "");
$body = strval($this->app->request->params["body"] ?? "");
$html = boolval($this->app->request->params["html"] ?? 0);
if (!empty($body)) {
$addrs = [];
foreach ($users as $uid) {
$user = $this->app->assets->get($uid);
if ($user && !in_array($user, $addrs))
$addrs[] = $user;
}
foreach ($roles as $rid) {
$rusers = $this->app->auth->getUsersInRole($rid);
foreach ($rusers as $ruser) {
if (!in_array($ruser, $addrs))
$addrs[] = $ruser;
}
}
$sitename = $this->app->settings->get("crispage.site_name");
$this->app->mailer->setContent("[%s] %s", $body, [$sitename, $subject]);
$this->app->mailer->setHTML($html);
if ($this->app->mailer->sendTo($addrs)) {
$this->app->page->data["messages"]["sent_message"] = [
"content" => $this->app->i18n->translate("{%SENT_MESSAGE_TO_USERS}", count($addrs)),
"color" => "success"
];
}
else {
$this->app->page->data["messages"]["message_error"] = [
"content" => $this->app->i18n->translate("{%ERROR_SENDING_MESSAGE}", $this->app->mailer->pm->ErrorInfo),
"color" => "danger"
];
}
}
// Set title
$this->app->page->data["title"] = $this->app->i18n->translate("{%SEND_USER_MESSAGE}");
// Set main component
$com = $this->app->page->createComponent(
"\\Crispage\\Components\\Backend\\UserMessageComponent", $this->data
);
$this->app->page->setMainComponent($com);
$this->app->page->actionFinished();
}
}
?>

View File

@ -19,7 +19,7 @@
use \Crispage\Utils\URIUtils;
use \Crispage\Auth\CorePermissions;
class BackendInitAction extends \Crispage\Response\Action {
class BackendInitAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.backend",
@ -37,7 +37,7 @@
$this->app->page->redirect(URIUtils::iuri("/login", ["rl" => "/backend"]));
// Check that user has backend perms
if (!$this->app->auth->userHasPermission(null, CorePermissions::BACKEND)) {
if (!$this->app->auth->userHasPermission(CorePermissions::BACKEND)) {
$this->app->page->setPersistentMessage(
"backend_access_denied",
$this->app->i18n->getTranslation("BACKEND_ACCESS_DENIED"),
@ -84,8 +84,8 @@
$this->app->route = $route;
$this->app->page->template->setLayout(
$route->data["template"] ?? null,
$route->data["layout"] ?? null
$route->data["layout"] ?? null,
$route->data["template"] ?? null
);
$this->app->page->setAction(
$route->action, array_merge($this->data, $route->data)

View File

@ -19,7 +19,7 @@
use \Crispage\Utils\Paginator;
use \Crispage\Assets\Category;
class CategoryAction extends \Crispage\Response\Action {
class CategoryAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.category",
@ -45,7 +45,7 @@
// If not published and user does not have unpublished perms, error 404
$show_unpublished = $this->app->auth->userHasPermission(
null, CorePermissions::VIEW_UNPUBLISHED
CorePermissions::VIEW_UNPUBLISHED
);
if ($category->state < Category::PUBLISHED && !$show_unpublished) {
$this->app->handleException(new CrispageException(

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
class ConfirmAccountAction extends \Crispage\Response\Action {
class ConfirmAccountAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.confirmaccount",

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
class DefaultAction extends \Crispage\Response\Action {
class DefaultAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.default",

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
class LoginAction extends \Crispage\Response\Action {
class LoginAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.login",
@ -81,6 +81,12 @@
"content" => $this->app->i18n->translate("{%ACCOUNT_DISABLED}")
];
break;
case $this->app->auth::ERR_LOGIN_ACCOUNT_NOT_ACTIVATED:
$this->app->page->data["messages"]["account_not_activated"] = [
"color" => "danger",
"content" => $this->app->i18n->translate("{%ACCOUNT_NOT_ACTIVATED} <a href=\"" . WROOT . "/resend_confirmation\">{%RESEND_CONFIRMATION_EMAIL}</a>")
];
break;
default:
$this->app->page->data["messages"]["error"] = [
"color" => "danger",

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
class LogoutAction extends \Crispage\Response\Action {
class LogoutAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.logout",

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
class PasswordResetAction extends \Crispage\Response\Action {
class PasswordResetAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.passwordreset",

View File

@ -16,7 +16,7 @@
use \Crispage\Assets\Comment;
class PostCommentAction extends \Crispage\Response\Action {
class PostCommentAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.postcomment",
@ -43,7 +43,7 @@
}
$perm = Comment::getPermissions()["create"];
if (!$this->app->auth->userHasPermission(null, $perm)) {
if (!$this->app->auth->userHasPermission($perm)) {
$this->app->page->setPersistentMessage(
"no_permission",
$this->app->i18n->translate("{%YOU_DO_NOT_HAVE_PERMISSION_TO_PERFORM_}"),

View File

@ -0,0 +1,48 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage\Actions;
defined("ROOT") or die();
use \Crispage\CrispageException;
use \Crispage\Auth\CorePermissions;
use \Crispage\Assets\Redirect;
class RedirectAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.redirect",
"version" => VERSION
];
}
public function __construct(\Crispage $app, array $data) {
parent::__construct($app, $data);
}
public function run(): void {
$redirect = $this->app->assets->get($this->data["asset_id"] ?? 0);
if (!$redirect) {
$this->app->handleException(new CrispageException(
"Page Not Found", 404, null, false
));
return;
}
$redirect->hits++;
$this->app->assets->set($redirect);
$this->app->page->redirect($this->app->router->resolveUri($redirect->uri), $redirect->permanent);
}
}
?>

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
class RegisterAction extends \Crispage\Response\Action {
class RegisterAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.register",
@ -70,7 +70,7 @@
case $this->app->auth::ERR_SENDCONF_EMAIL_FAILED:
$this->app->page->data["messages"]["mailing_failed"] = [
"color" => "danger",
"content" => $this->app->i18n->translate("{%MAILING_FAILED}")
"content" => $this->app->i18n->translate("{%MAILING_FAILED}", $this->app->mailer->pm->ErrorInfo)
];
break;
default:

View File

@ -16,7 +16,7 @@
use \Crispage\Utils\TextUtils;
class ResendConfirmAction extends \Crispage\Response\Action {
class ResendConfirmAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.resendconfirmation",
@ -53,7 +53,13 @@
case $this->app->auth::ERR_SENDCONF_EMAIL_FAILED:
$this->app->page->data["messages"]["mailing_failed"] = [
"color" => "danger",
"content" => $this->app->i18n->translate("{%MAILING_FAILED}")
"content" => $this->app->i18n->translate("{%MAILING_FAILED}", $this->app->mailer->pm->ErrorInfo)
];
break;
case $this->app->auth::ERR_SENDCONF_USER_ACTIVATED:
$this->app->page->data["messages"]["mailing_failed"] = [
"color" => "danger",
"content" => $this->app->i18n->translate("{%USER_ALREADY_ACTIVATED}")
];
break;
default:

View File

@ -18,7 +18,7 @@
use \Crispage\Search\SearchFilter;
use \Crispage\Auth\CorePermissions;
class SearchAction extends \Crispage\Response\Action {
class SearchAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.search",
@ -51,7 +51,7 @@
$this->app->search->fromText($query);
if (!$this->app->auth->userHasPermission(null, CorePermissions::VIEW_UNPUBLISHED))
if (!$this->app->auth->userHasPermission(CorePermissions::VIEW_UNPUBLISHED))
$this->app->search->addFilter(new SearchFilter("state", 0, SearchFilter::FOP_GREATER));
$this->app->search->collect();

View File

@ -16,7 +16,7 @@
use \Crispage\Utils\TextUtils;
class SendResetTokenAction extends \Crispage\Response\Action {
class SendResetTokenAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.sendtoken",
@ -53,7 +53,7 @@
case $this->app->auth::ERR_SENDRESET_EMAIL_FAILED:
$this->app->page->data["messages"]["mailing_failed"] = [
"color" => "danger",
"content" => $this->app->i18n->translate("{%MAILING_FAILED}")
"content" => $this->app->i18n->translate("{%MAILING_FAILED}", $this->app->mailer->pm->ErrorInfo)
];
break;
default:

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
class UserSettingsAction extends \Crispage\Response\Action {
class UserSettingsAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.actions.usersettings",

View File

@ -0,0 +1,27 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage;
defined("ROOT") or die();
if (!defined("CONFIG_PATH")) define("CONFIG_PATH", ROOT . "/config.php");
define("CONFIG_DATA", parse_ini_file(CONFIG_PATH, false, INI_SCANNER_TYPED));
class ApplicationConfig {
public static function get(string $key, mixed $default = null): mixed {
if (!defined("CONFIG_DATA")) return $default;
return CONFIG_DATA[$key] ?? $default;
}
}
?>

View File

@ -1,72 +0,0 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage;
defined("ROOT") or die();
class CoreBackendLinks {
public static function get(): array {
return [
"dashboard" => [
"uri" => "backend://dashboard",
"label" => "{%DASHBOARD}",
"position" => 0,
"dropdown" => []
],
"content" => [
"uri" => "#",
"label" => "{%CONTENT}",
"position" => 128,
"dropdown" => [
["uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Article", "label" => "{%ARTICLES}"],
["uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Category", "label" => "{%CATEGORIES}"],
["uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Comment", "label" => "{%COMMENTS}"],
["uri" => "backend://media/list?folder=/uploads", "label" => "{%MEDIA}"]
]
],
"layout" => [
"uri" => "#",
"label" => "{%LAYOUT}",
"position" => 256,
"dropdown" => [
["uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Menu", "label" => "{%MENUS}"],
["uri" => "backend://assets/list?classname=\\Crispage\\Assets\\MenuItem", "label" => "{%MENU_ITEMS}"],
["uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Module", "label" => "{%MODULES}"]
]
],
"users" => [
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\User",
"label" => "{%USERS}",
"position" => 384,
"dropdown" => [
["uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Role", "label" => "{%ROLES}"]
]
],
"settings" => [
"uri" => "backend://settings",
"label" => "{%SETTINGS}",
"position" => 512,
"dropdown" => [
["uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Plugin", "label" => "{%PLUGINS}"],
["uri" => "backend://extensions/list", "label" => "{%EXTENSIONS}"]
]
],
"about" => [
"uri" => "backend://about",
"label" => "{%ABOUT}",
"position" => 640
]
];
}
}
?>

View File

@ -12,26 +12,29 @@
defined("ROOT") or die();
use \Crispage\Config;
use \Crispage\ApplicationConfig;
use \Crispage\CrispageException;
require_once ROOT . "/core/app/CrispageException.php";
use \Crispage\ExtensionClass;
require_once ROOT . "/core/app/ExtensionClass.php";
require_once ROOT . "/core/app/framework/ExtensionClass.php";
use \Crispage\Renderable;
require_once ROOT . "/core/app/Renderable.php";
require_once ROOT . "/core/app/framework/Renderable.php";
use \Crispage\Runnable;
require_once ROOT . "/core/app/Runnable.php";
require_once ROOT . "/core/app/framework/Runnable.php";
require_once ROOT . "/core/app/framework/ApplicationFeature.php";
use \Crispage\Database;
use \Crispage\Database\TemporaryDatabase;
require_once ROOT . "/core/app/database/Database.php";
use \Crispage\Events\Dispatcher;
use \Crispage\Events\Receiver;
require_once ROOT . "/core/app/events/Dispatcher.php";
use \Crispage\Signaling\Dispatcher;
use \Crispage\Signaling\Receiver;
require_once ROOT . "/core/app/signaling/Dispatcher.php";
use \Crispage\SettingsManager;
require_once ROOT . "/core/app/settings/SettingsManager.php";
use \Crispage\Caching\CacheEngine;
require_once ROOT . "/core/app/cache/CacheEngine.php";
use \Crispage\Extensions\ExtensionManager;
use \Crispage\Extensions\PackageManager;
require_once ROOT . "/core/app/extensions/ExtensionManager.php";
@ -44,9 +47,9 @@
use \Crispage\Auth\Authenticator;
require_once ROOT . "/core/app/auth/Authenticator.php";
use \Crispage\Search\Searcher;
require_once ROOT . "/core/app/search/Searcher.php";
require_once ROOT . "/core/app/cms/search/Searcher.php";
use \Crispage\Media\MediaManager;
require_once ROOT . "/core/app/media/MediaManager.php";
require_once ROOT . "/core/app/cms/media/MediaManager.php";
use \Crispage\Media\MediaItem;
use \Crispage\Request\Request;
@ -59,10 +62,12 @@
use \Crispage\Text\I18n;
require_once ROOT . "/core/app/text/I18n.php";
use \Crispage\Text\ShortcodeEngine;
require_once ROOT . "/core/app/text/ShortcodeEngine.php";
use \Crispage\Assets\Plugin;
use \Crispage\PluginRunnable;
require_once ROOT . "/core/app/PluginRunnable.php";
use \Crispage\Framework\PluginClass;
require_once ROOT . "/core/app/framework/PluginClass.php";
require_once ROOT . "/core/app/utils/FileUtils.php";
require_once ROOT . "/core/app/utils/SystemUtils.php";
@ -71,46 +76,23 @@
require_once ROOT . "/core/app/utils/URIUtils.php";
require_once ROOT . "/core/app/utils/TextUtils.php";
class Crispage {
public static function uriFilters(): array {
return [
"frontend" => function(string $uri, array $parse) {
$route = $parse["host"];
if (!empty($parse["path"])) $route .= $parse["path"];
parse_str($parse["query"] ?? "", $query);
return URIUtils::iuri("/$route", $query, $parse["fragment"] ?? null);
},
"backend" => function(string $uri, array $parse) {
$route = $parse["host"];
if (!empty($parse["path"])) $route .= $parse["path"];
parse_str($parse["query"] ?? "", $query);
return URIUtils::iuri(
"/backend",
array_merge($query, ["route" => $route]),
$parse["fragment"] ?? null
);
},
"api" => function(string $uri, array $parse) {
$route = $parse["host"];
if (!empty($parse["path"])) $route .= $parse["path"];
parse_str($parse["query"] ?? "", $query);
return URIUtils::iuri(
"/api/$route", $query, $parse["fragment"] ?? null
);
},
"asset" => function(string $uri, array $parse) {
global $Crispage;
$asset = $Crispage->assets->get(intval($parse["host"] ?? 0));
if (!$asset) return $uri;
return WROOT . $Crispage->assets->getURI($asset);
}
];
}
require_once ROOT . "/core/app/cms/backend/Field.php";
require_once ROOT . "/core/app/cms/backend/AssetListColumn.php";
require_once ROOT . "/core/app/cms/backend/AssetListActionButton.php";
#[\AllowDynamicProperties]
class Crispage {
public const FRAMEWORK_CLASSES = [
"asset" => "\\Crispage\\Framework\\Asset",
"action" => "\\Crispage\\Framework\\Action",
"component" => "\\Crispage\\Framework\\Component",
"plugin" => "\\Crispage\\Framework\\PluginClass"
];
public ?Database $database = null;
public Dispatcher $dispatcher;
public SettingsManager $settings;
public CacheEngine $cache;
public ExtensionManager $extensions;
public PackageManager $packages;
public Router $router;
@ -121,22 +103,24 @@
public MediaManager $media;
public Page $page;
public I18n $i18n;
public ShortcodeEngine $shortcodes;
public ?Request $request = null;
public ?Route $route = null;
private array $loadedClasses = [];
private array $plugins = [];
private array $uriFilters;
private bool $handlingException = false;
private array $additionalExceptions = [];
public function __construct() {
$this->uriFilters = self::uriFilters();
$this->dispatcher = new Dispatcher($this);
$this->settings = new SettingsManager($this);
$this->cache = new CacheEngine($this);
$this->extensions = new ExtensionManager($this);
$this->packages = new PackageManager($this);
$this->router = new Router($this);
$this->shortcodes = new ShortcodeEngine($this);
$this->assets = new AssetManager($this);
$this->mailer = new Mailer($this);
$this->auth = new Authenticator($this);
@ -147,16 +131,16 @@
}
public function loadDatabase(): void {
$db = Config::DB_TYPE;
$db = ApplicationConfig::get("crispage.database.type");
if (!class_exists($db)) die("Invalid database type; please check config");
$this->database = new $db([
"location" => Config::DB_LOC,
"port" => Config::DB_PORT,
"username" => Config::DB_USER,
"password" => Config::DB_PASSWD,
"dbname" => Config::DB_NAME,
"prefix" => Config::DB_PREFIX,
"options" => Config::DB_OPTS
"location" => ApplicationConfig::get("crispage.database.location"),
"port" => ApplicationConfig::get("crispage.database.port"),
"username" => ApplicationConfig::get("crispage.database.user"),
"password" => ApplicationConfig::get("crispage.database.password"),
"dbname" => ApplicationConfig::get("crispage.database.name"),
"prefix" => ApplicationConfig::get("crispage.database.prefix"),
"options" => ApplicationConfig::get("crispage.database.options")
]);
}
@ -174,6 +158,7 @@
$this->i18n->loadTranslationSets();
$this->i18n->setLanguage($this->settings->get("crispage.default_language", "en-US"));
$this->cache->loadDefaultPolicy();
$this->mailer->loadDefaults();
// Set timezone
@ -183,8 +168,8 @@
// Set layout
$this->page->template->setLayout(
$this->settings->get("crispage.page.default_template", "default"),
$this->settings->get("crispage.page.default_layout", "default")
$this->settings->get("crispage.page.default_layout", "default"),
$this->settings->get("crispage.page.default_template", "default")
);
// Set metas
@ -207,7 +192,7 @@
];
// Default scripts
$domain = Config::SITE_DOMAIN;
$domain = ApplicationConfig::get("crispage.site_domain");
$wroot = WROOT;
$version = VERSION;
$mbase = MediaItem::uri("/");
@ -221,31 +206,48 @@
$this->page->data["scripts"]["crispage"] = [
"src" => WROOT . "/media/system/crispage/crispage.js"
];
$this->dispatcher->trigger("crispage.initialized");
}
public function loadClass(string $classname, string $type = "\\Crispage\\Response\\Component"): void {
public function loadClass(string $classname, string $type, bool $shortnames = false): void {
// Return if already loaded
if (in_array($classname, $this->loadedClasses)) return;
// Assemble paths
$pathend = preg_replace("/\\\\/", "/", $classname) . ".php";
$paths = Config::CLASS_PATHS[$type] ?? null;
if (!$paths) {
if (!in_array($type, array_keys(self::FRAMEWORK_CLASSES))) {
$this->handleException(new CrispageException(
"Unknown class type $type", 500
));
}
$fullpaths = array_map(fn(string $p): string => ROOT . $p . $pathend, $paths);
$typeclass = self::FRAMEWORK_CLASSES[$type];
// Assemble paths
$classpaths = ApplicationConfig::get("crispage.paths.$type") ?? [];
if (empty($classpaths)) {
$this->handleException(new CrispageException(
"No paths for class type $type", 500
));
}
$name = preg_replace("/\\\\/", "/", $classname) . ".php";
$paths = [];
foreach ($classpaths as $cpath) $paths[] = ROOT . $cpath . $name;
if ($shortnames) {
foreach ($classpaths as $cpath)
$paths[] = ROOT . $cpath . "/" . basename($name);
}
// Try each path and return if class loaded
foreach ($fullpaths as $path) {
foreach ($paths as $path) {
if (!file_exists($path)) continue;
include_once $path;
if (class_exists($classname)) {
// Check that class is of the right type
if (!is_a($classname, $type, true)) {
$this->app->handleException(new CrispageException(
"$classname is not a $type", 500
if (!is_a($classname, $typeclass, true)) {
$this->handleException(new CrispageException(
"$classname is not a $typeclass", 500
));
}
// Add to loaded classes
@ -262,13 +264,13 @@
);
}
public function loadPlugin(Plugin $plugin): array {
public function loadPlugin(Plugin $plugin): ?array {
// If module is not enabled, return null
if (!$plugin->enabled) return null;
// Load class and create runnable
$this->loadClass($plugin->runnable, "\\Crispage\\PluginRunnable");
$runnable = new ($plugin->runnable)(
// Load class and create plugin class
$this->loadClass($plugin->classname, "plugin");
$pclass = new ($plugin->classname)(
$this, array_merge($plugin->getOptions(), ["plugin" => $plugin])
);
@ -277,19 +279,19 @@
$inserted = false;
foreach ($this->plugins as $ind => $plug) {
if ($plug[0]->priority > $plugin->priority) {
array_splice($this->plugins, $ind, 0, [[$plugin, $runnable]]);
array_splice($this->plugins, $ind, 0, [[$plugin, $pclass]]);
$inserted = true;
break;
}
}
// If no place for the new plugin was found, insert it at the end
if (!$inserted) $this->plugins[] = [$plugin, $runnable];
if (!$inserted) $this->plugins[] = [$plugin, $pclass];
// Trigger event
$this->dispatcher->trigger("crispage.plugin_loaded", [$plugin, $runnable]);
$this->dispatcher->trigger("crispage.plugin_loaded", $plugin, $pclass);
// Return
return [$plugin, $runnable];
return [$plugin, $pclass];
}
public function unloadPlugin(string $mid): ?array {
@ -332,6 +334,7 @@
public function clearPlugins(): array {
$plugins = $this->plugins;
$this->plugins = [];
$this->dispatcher->trigger("crispage.plugins_cleared");
return $plugins;
}
@ -346,7 +349,7 @@
$plugin[1]->run();
$count++;
$this->dispatcher->trigger(
"crispage.plugin_run", $plugin, $count
"crispage.plugin_run", $plugin[0], $plugin[1], $count
);
}
catch (\Throwable $e) {
@ -354,12 +357,13 @@
$plugin[0]->enabled = false;
$this->assets->set($plugin[0]);
// Handle exception
$this->handleException(
new CrispageException(
"Plugin Error ({$plugin[0]->runnable}\${$plugin[0]->id})",
500, $e
)
$err = new CrispageException(
"Plugin Error ({$plugin[0]->classname}\${$plugin[0]->id})",
500, $e
);
$this->dispatcher->trigger("crispage.plugin_error", $plugin[0], $plugin[1], $err);
$this->handleException($err);
}
}
// Return count
@ -394,8 +398,8 @@
// Set template and layout
$this->page->template->setLayout(
$this->route->data["template"] ?? null,
$this->route->data["layout"] ?? null
$this->route->data["layout"] ?? null,
$this->route->data["template"] ?? null
);
// Set action
@ -409,18 +413,22 @@
}
public function handleException(\Throwable $exception): void {
if ($this->handlingException) return;
if (ApplicationConfig::get("crispage.dev.disable_exception_handling", false))
throw $exception;
// if already handling an exception, add to the additional list
if ($this->handlingException) {
$this->additionalExceptions[] = $exception;
return;
}
$this->handlingException = true;
// Convert to CrispageException
// Wrap and send http code
if (!is_a($exception, "\\Crispage\\CrispageException")) {
$exception = new CrispageException(
"Uncaught exception", 500, $exception
);
}
http_response_code($exception->getCode());
$this->dispatcher->trigger("crispage.exception", $exception);
// Cancel render
@ -432,7 +440,10 @@
// Set main component
$com = $this->page->createComponent(
"\\Crispage\\Components\\ErrorInfoComponent",
array_merge($this->route->data ?? [], ["exceptions" => [$exception]])
array_merge(
$this->route->data ?? [],
["exceptions" => array_merge([$exception], $this->additionalExceptions)]
)
);
$this->page->setMainComponent($com);
@ -454,17 +465,5 @@
$this->page->stopBuffering();
die();
}
public function resolveUri(string $uri): string {
$parse = parse_url($uri);
$scheme = $parse["scheme"] ?? "";
if (isset($this->uriFilters[$scheme]))
return $this->uriFilters[$scheme]($uri, $parse);
else return $uri;
}
public function registerUriFilter(string $scheme, callable $func): void {
$this->uriFilters[$scheme] = \Closure::fromCallable($func);
}
}
?>

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
use \Crispage\Config;
use \Crispage\ApplicationConfig;
class CrispageException extends \Exception {
public bool $showDebug;
@ -24,7 +24,7 @@
bool $showDebug = true
) {
parent::__construct($message, $code, $previous);
$this->showDebug = $showDebug || Config::DEV_FORCE_ERRMSGS;
$this->showDebug = $showDebug || ApplicationConfig::get("crispage.dev.force_errmsgs");
}
}
?>

View File

@ -14,39 +14,37 @@
defined("ROOT") or die();
require_once ROOT . "/core/app/assets/Asset.php";
use \Crispage\Framework\Asset;
require_once ROOT . "/core/app/framework/Asset.php";
// Include default assets
require_once ROOT . "/core/app/assets/class/Article.php";
require_once ROOT . "/core/app/assets/class/Category.php";
require_once ROOT . "/core/app/assets/class/Comment.php";
require_once ROOT . "/core/app/assets/class/Menu.php";
require_once ROOT . "/core/app/assets/class/MenuItem.php";
require_once ROOT . "/core/app/assets/class/Module.php";
require_once ROOT . "/core/app/assets/class/Plugin.php";
require_once ROOT . "/core/app/assets/class/Role.php";
require_once ROOT . "/core/app/assets/class/User.php";
use \Crispage\Events\Receiver;
use \Crispage\Framework\ApplicationFeature;
use \Crispage\Signaling\Receiver;
use \Crispage\Assets\ContentAsset;
use \Crispage\Text\ShortcodeRenderer;
class AssetManager {
public \Crispage $app;
private array $registeredClasses = [];
class AssetManager extends ApplicationFeature {
public const CORE_CLASSES = [
"\\Crispage\\Assets\\ContentAsset",
"\\Crispage\\Assets\\Article",
"\\Crispage\\Assets\\Category",
"\\Crispage\\Assets\\Comment",
"\\Crispage\\Assets\\Redirect",
"\\Crispage\\Assets\\Menu",
"\\Crispage\\Assets\\MenuItem",
"\\Crispage\\Assets\\Module",
"\\Crispage\\Assets\\Plugin",
"\\Crispage\\Assets\\Role",
"\\Crispage\\Assets\\User"
];
private int $nextTempId = PHP_INT_MIN;
public function __construct(\Crispage $app) {
$this->app = $app;
parent::__construct($app);
// Register default assets
$this->registerClass("\\Crispage\\Assets\\Article");
$this->registerClass("\\Crispage\\Assets\\Category");
$this->registerClass("\\Crispage\\Assets\\Comment");
$this->registerClass("\\Crispage\\Assets\\Menu");
$this->registerClass("\\Crispage\\Assets\\MenuItem");
$this->registerClass("\\Crispage\\Assets\\Module");
$this->registerClass("\\Crispage\\Assets\\Plugin");
$this->registerClass("\\Crispage\\Assets\\Role");
$this->registerClass("\\Crispage\\Assets\\User");
// Load default asset classes
foreach (self::CORE_CLASSES as $class)
$this->app->loadClass($class, "asset", true);
// Automatically update routes
$this->app->dispatcher->register(
@ -56,6 +54,7 @@
function (Asset $asset): void {
$this->app->router->createContentRoute($asset);
$this->app->router->createAdditionalContentRoutes($asset);
$this->app->cache->emptyBucket("content");
}
)
);
@ -68,6 +67,7 @@
$this->app->router->deleteContentRoutes($asset);
$this->app->router->createContentRoute($asset);
$this->app->router->createAdditionalContentRoutes($asset);
$this->app->cache->emptyBucket("content");
}
)
);
@ -81,29 +81,19 @@
}
)
);
}
public function getRegisteredClasses(): array {
return $this->registeredClasses;
}
public function registerClass(string $classname): void {
if (!in_array($classname, $this->registeredClasses))
$this->registeredClasses[] = $classname;
}
public function unregisterClass(string $classname): void {
$this->registeredClasses = array_filter(
$this->registeredClasses,
fn(string $cn): bool => $cn != $classname
);
$this->app->shortcodes->mapShortcode(new ShortcodeRenderer(
"asset", fn(array $args): string => $this->app->router->resolveUri("asset://" . ($args["id"] ?? 0))
));
}
public function getTable(string $classname): string {
return "assets_" . substr(md5($classname), 0, 8) . @end(explode("\\", $classname));
}
public function getNewID(): int {
public function getNewID(bool $temp = false): int {
if ($temp) return ++$this->nextTempId;
// Get id from table
$res = $this->app->database->select("system", ["next_asset_id"]);
$id = $res->fetchColumn();
@ -117,7 +107,7 @@
public function createTable(string $classname): bool {
// Error if class is not an asset
if (!is_a($classname, "\\Crispage\\Asset", true)) return false;
if (!is_a($classname, "\\Crispage\\Framework\\Asset", true)) return false;
// Get table name
$table = $this->getTable($classname);
@ -179,7 +169,7 @@
if (!class_exists($class)) return null;
// Return asset from data
$row["_table"] = $table;
return new $class($row);
return new $class($this->app, $row);
}
public function get(int $id): ?Asset {
@ -253,21 +243,32 @@
// Error if class is not an asset
if (
!class_exists($classname) ||
!is_a($classname, "\\Crispage\\Asset", true)
!is_a($classname, "\\Crispage\\Framework\\Asset", true)
) {
$this->app->handleException(
new CrispageException("$classname is not an Asset", 500)
);
}
$data["_table"] = $this->getTable($classname);
$data["slug"] ??= uniqid("asset_");
// Check that asset doesn't already exist
$res = $this->app->database->select("assets", null, [
"tablename" => $data["_table"],
"slug" => $data["slug"]
]);
if ($res->fetch() !== false) {
$this->app->handleException(
new CrispageException("Asset of type $classname with slug {$data["slug"]} already exists", 500)
);
}
// Create asset
$asset = new $classname($data);
$asset->id = $this->getNewID();
$data["id"] = $this->getNewID($temp);
$asset = new $classname($this->app, $data);
if (!$temp) {
// Get table name
$asset->_table = $this->getTable($classname);
// Insert into tables
$this->app->database->insert("assets", [
"id" => $asset->id,
@ -309,7 +310,7 @@
}
public function delete(Asset $asset): void {
if ($asset->isTemporary) return;
if ($asset->isTemporary()) return;
// Delete from tables
$this->app->database->delete($asset->_table, ["id" => $asset->id]);
$this->app->database->delete("assets", ["id" => $asset->id]);
@ -322,26 +323,29 @@
public function makePermanent(Asset $asset): Asset {
if (!$asset->isTemporary()) return $asset;
// Get table name
$asset->_table = $this->getTable("\\" . $asset::class);
$data = $asset->toArray();
$data["id"] = $this->getNewID();
$data["_table"] = $this->getTable("\\" . $asset::class);
$passet = new ($asset::class)($this->app, $data);
// Insert into tables
$this->app->database->insert("assets", [
"id" => $asset->id,
"classname" => "\\" . $asset::class,
"tablename" => $asset->_table,
"slug" => $asset->slug
"id" => $passet->id,
"classname" => "\\" . $passet::class,
"tablename" => $passet->_table,
"slug" => $passet->slug
]);
$this->app->database->insert(
$asset->_table, $asset->toArray()
$passet->_table, $passet->toArray()
);
// Trigger event
$this->app->dispatcher->trigger(
"crispage.assets.asset_created", $asset
"crispage.assets.asset_created", $passet
);
return $asset;
return $passet;
}
public function getURI(Asset $asset, int $max = 15): string {

View File

@ -14,9 +14,17 @@
defined("ROOT") or die();
require_once ROOT . "/core/app/assets/class/ContentAsset.php";
use \Crispage\Backend\Field;
use \Crispage\Backend\AssetListColumn;
class Article extends ContentAsset {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.article",
"version" => VERSION
];
}
public static function getNames(): array {
return ["{%ARTICLE}", "{%ARTICLES}"];
}
@ -31,142 +39,138 @@
public static function getListColumns(): array {
global $Crispage;
return [
"id" => ["label" => "{%ID}"],
"slug" => [
"label" => "{%SLUG}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"title" => ["label" => "{%TITLE}", "filter" => "htmlentities"],
"category_id" => [
"label" => "{%CATEGORY}",
"filter" => [$Crispage->assets, "assetNameFromID"]
],
"state" => [
"label" => "{%STATE}",
"filter" => function(int $s): string {
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"slug", "{%SLUG}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn("title", "{%TITLE}", "htmlentities"),
new AssetListColumn(
"category_id", "{%CATEGORY}",
[$Crispage->assets, "assetNameFromID"]
),
new AssetListColumn(
"state", "{%STATE}",
function(int $s): string {
global $Crispage;
return $Crispage->i18n->translate(
($s == self::PUBLISHED) ? "{%PUBLISHED}" : "{%UNPUBLISHED}"
);
}
],
"author_id" => [
"label" => "{%AUTHOR}",
"filter" => [$Crispage->assets, "assetNameFromID"]
],
"hits" => [
"label" => "{%HITS}",
"filter" => null
],
"mtime" => [
"label" => "{%MODIFIED}",
"filter" => [$Crispage->i18n, "datetime"]
]
),
new AssetListColumn(
"author_id", "{%AUTHOR}",
[$Crispage->assets, "assetNameFromID"]
),
new AssetListColumn("hits", "{%HITS}"),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
)
];
}
public static function getEditorFields(): array {
global $Crispage;
return [
"title" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
new Field(
"title", 0,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%TITLE}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"body" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\EditorFieldComponent",
"com_data" => [
]
),
new Field(
"body", 0,
"\\Crispage\\Components\\Fields\\EditorFieldComponent", [
"label" => "{%BODY}:"
],
"filter" => "strval"
],
"summary" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\TextareaFieldComponent",
"com_data" => [
]
),
new Field(
"summary", 0,
"\\Crispage\\Components\\Fields\\TextareaFieldComponent", [
"label" => "{%SUMMARY}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"slug" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"slug", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%SLUG}:",
"attrs" => ["placeholder" => "automatic"]
],
"filter" => "strval"
],
"state" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\SelectFieldComponent",
"com_data" => [
]
),
new Field(
"state", 1,
"\\Crispage\\Components\\Fields\\SelectFieldComponent", [
"label" => "{%STATE}:",
"options" => [
"{%UNPUBLISHED}",
"{%PUBLISHED}"
]
],
"filter" => "intval"
],
"publish_date" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\DateTimeFieldComponent",
"com_data" => [
"intval"
),
new Field(
"publish_date", 1,
"\\Crispage\\Components\\Fields\\DateTimeFieldComponent", [
"label" => "{%PUBLISH_DATE}:",
"attrs" => ["required"]
"attrs" => []
],
"filter" => "strtotime"
],
"category_id" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\AssetSelectFieldComponent",
"com_data" => [
function(string $val): int {
$ts = strtotime($val);
if (!$ts) $ts = time();
return $ts;
}
),
new Field(
"author_id", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%AUTHOR}:",
"attrs" => ["readonly", "value" => $Crispage->auth->currentUser->displayname]
],
function(): int {
global $Crispage;
return $Crispage->auth->currentUser->id;
}
),
new Field(
"category_id", 1,
"\\Crispage\\Components\\Fields\\AssetSelectFieldComponent", [
"label" => "{%CATEGORY}:",
"classname" => "\\Crispage\\Assets\\Category",
"option_none" => "{%UNCATEGORIZED}"
],
"filter" => "intval"
],
"meta_desc" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"meta_desc", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%META_DESCRIPTION}:",
"attrs" => ["placeholder" => "site default"]
],
"filter" => "strval"
],
"meta_keys" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"meta_keys", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent",
[
"label" => "{%META_KEYWORDS}:",
"attrs" => ["placeholder" => "site default"]
],
"filter" => "strval"
],
"meta_robots" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"meta_robots", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%META_ROBOTS}:",
"attrs" => ["placeholder" => "site default"]
],
"filter" => "strval"
]
]
)
];
}
public string $summary;
public function __construct(array $props) {
parent::__construct($props);
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->summary = $props["summary"] ?? "";
}
}

View File

@ -14,9 +14,17 @@
defined("ROOT") or die();
require_once ROOT . "/core/app/assets/class/ContentAsset.php";
use \Crispage\Backend\Field;
use \Crispage\Backend\AssetListColumn;
class Category extends ContentAsset {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.category",
"version" => VERSION
];
}
public static function getNames(): array {
return ["{%CATEGORY}", "{%CATEGORIES}"];
}
@ -31,131 +39,130 @@
public static function getListColumns(): array {
global $Crispage;
return [
"id" => ["label" => "{%ID}"],
"slug" => [
"label" => "{%SLUG}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"title" => ["label" => "{%TITLE}", "filter" => "htmlentities"],
"category_id" => [
"label" => "{%PARENT}",
"filter" => [$Crispage->assets, "assetNameFromID"]
],
"state" => [
"label" => "{%STATE}",
"filter" => function(int $s): string {
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"slug", "{%SLUG}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn("title", "{%TITLE}", "htmlentities"),
new AssetListColumn(
"category_id", "{%PARENT}",
[$Crispage->assets, "assetNameFromID"]
),
new AssetListColumn(
"state", "{%STATE}",
function(int $s): string {
global $Crispage;
return $Crispage->i18n->translate(
($s == self::PUBLISHED) ? "{%PUBLISHED}" : "{%UNPUBLISHED}"
);
}
],
"author_id" => [
"label" => "{%AUTHOR}",
"filter" => [$Crispage->assets, "assetNameFromID"]
],
"hits" => [
"label" => "{%HITS}",
"filter" => null
],
"mtime" => [
"label" => "{%MODIFIED}",
"filter" => [$Crispage->i18n, "datetime"]
]
),
new AssetListColumn(
"author_id", "{%AUTHOR}",
[$Crispage->assets, "assetNameFromID"]
),
new AssetListColumn("hits", "{%HITS}"),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
)
];
}
public static function getEditorFields(): array {
global $Crispage;
return [
"title" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
new Field(
"title", 0,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%TITLE}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"body" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\EditorFieldComponent",
"com_data" => [
]
),
new Field(
"body", 0,
"\\Crispage\\Components\\Fields\\EditorFieldComponent", [
"label" => "{%BODY}:"
],
"filter" => "strval"
],
"slug" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"slug", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent",
[
"label" => "{%SLUG}:",
"attrs" => ["placeholder" => "automatic"]
],
"filter" => "strval"
],
"state" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\SelectFieldComponent",
"com_data" => [
]
),
new Field(
"state", 1,
"\\Crispage\\Components\\Fields\\SelectFieldComponent", [
"label" => "{%STATE}:",
"options" => [
"{%UNPUBLISHED}",
"{%PUBLISHED}"
]
],
"filter" => "intval"
],
"publish_date" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\DateTimeFieldComponent",
"com_data" => [
"intval"
),
new Field(
"publish_date", 1,
"\\Crispage\\Components\\Fields\\DateTimeFieldComponent", [
"label" => "{%PUBLISH_DATE}:",
"attrs" => ["required"]
"attrs" => []
],
"filter" => "strtotime"
],
"category_id" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\AssetSelectFieldComponent",
"com_data" => [
function(string $val): int {
$ts = strtotime($val);
if (!$ts) $ts = time();
return $ts;
}
),
new Field(
"author_id", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%AUTHOR}:",
"attrs" => ["readonly", "value" => $Crispage->auth->currentUser->displayname]
],
function(): int {
global $Crispage;
return $Crispage->auth->currentUser->id;
}
),
new Field(
"category_id", 1,
"\\Crispage\\Components\\Fields\\AssetSelectFieldComponent", [
"label" => "{%CATEGORY}:",
"classname" => "\\Crispage\\Assets\\Category",
"option_none" => "{%UNCATEGORIZED}"
],
"filter" => "intval"
],
"meta_desc" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"meta_desc", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%META_DESCRIPTION}:",
"attrs" => ["placeholder" => "site default"]
],
"filter" => "strval"
],
"meta_keys" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"meta_keys", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent",
[
"label" => "{%META_KEYWORDS}:",
"attrs" => ["placeholder" => "site default"]
],
"filter" => "strval"
],
"meta_robots" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"meta_robots", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%META_ROBOTS}:",
"attrs" => ["placeholder" => "site default"]
],
"filter" => "strval"
]
]
)
];
}
public function __construct(array $props) {
parent::__construct($props);
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
}
}
?>

View File

@ -15,12 +15,21 @@
defined("ROOT") or die();
use \Crispage\Auth\CorePermissions;
use \Crispage\Backend\AssetListColumn;
use \Crispage\Backend\AssetListActionButton;
class Comment extends \Crispage\Asset {
class Comment extends \Crispage\Framework\Asset {
public const HIDDEN = -1;
public const PENDING_APPROVAL = 0;
public const APPROVED = 1;
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.comment",
"version" => VERSION
];
}
public static function getNames(): array {
return ["{%COMMENT}", "{%COMMENTS}"];
}
@ -38,22 +47,19 @@
public static function getListColumns(): array {
global $Crispage;
return [
"id" => ["label" => "{%ID}"],
"slug" => [
"label" => "{%SLUG}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"content_id" => [
"label" => "{%CONTENT}",
"filter" => [$Crispage->assets, "assetNameFromID"]
],
"body" => [
"label" => "{%BODY}",
"filter" => null
],
"state" => [
"label" => "{%STATE}",
"filter" => function(int $s): string {
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"slug", "{%SLUG}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn(
"content_id", "{%CONTENT}",
[$Crispage->assets, "assetNameFromID"]
),
new AssetListColumn("body", "{%BODY}", "htmlentities"),
new AssetListColumn(
"state", "{%STATE}",
function(int $s): string {
global $Crispage;
switch ($s) {
case self::HIDDEN:
@ -67,15 +73,15 @@
}
return $Crispage->i18n->translate("{%$str}");
}
],
"author_id" => [
"label" => "{%AUTHOR}",
"filter" => [$Crispage->assets, "assetNameFromID"]
],
"mtime" => [
"label" => "{%MODIFIED}",
"filter" => [$Crispage->i18n, "datetime"]
]
),
new AssetListColumn(
"author_id", "{%AUTHOR}",
[$Crispage->assets, "assetNameFromID"]
),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
)
];
}
@ -85,30 +91,18 @@
public static function getListItemActions(): array {
return [
[
"route" => "comments/approve",
"label" => "{%APPROVE}",
"color" => "success",
"fields" => [
"comment_id" => "id"
]
],
[
"route" => "comments/hide",
"label" => "{%HIDE}",
"color" => "warning",
"fields" => [
"comment_id" => "id"
]
],
[
"route" => "assets/delete",
"label" => "{%DELETE}",
"color" => "danger",
"fields" => [
"asset_id" => "id"
]
]
new AssetListActionButton(
"comments/approve", "{%APPROVE}", "success",
["comment_id" => "id"]
),
new AssetListActionButton(
"comments/hide", "{%HIDE}", "warning",
["comment_id" => "id"]
),
new AssetListActionButton(
"assets/delete", "{%DELETE}", "danger",
["asset_id" => "id"]
)
];
}
@ -121,8 +115,8 @@
public string $body;
public int $state;
public function __construct(array $props) {
parent::__construct($props);
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->author_id = $props["author_id"] ?? 0;
$this->content_id = $props["content_id"] ?? 0;
$this->body = $props["body"] ?? "";

View File

@ -14,14 +14,22 @@
defined("ROOT") or die();
require_once ROOT . "/core/app/assets/Asset.php";
use \Crispage\Auth\CorePermissions;
use \Crispage\Caching\CacheEngine;
use \Crispage\Caching\CacheEntry;
use \Crispage\Backend\Field;
abstract class ContentAsset extends \Crispage\Asset {
abstract class ContentAsset extends \Crispage\Framework\Asset {
public const UNPUBLISHED = 0;
public const PUBLISHED = 1;
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.contentasset",
"version" => VERSION
];
}
public static function getPermissions(): array {
return [
"create" => CorePermissions::MODIFY_CONTENT,
@ -41,50 +49,65 @@
public static function getOptionFields(): array {
return [
"template" => [
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
new Field(
"template", 0,
"\\Crispage\\Components\\Fields\\TemplateSelectFieldComponent", [
"label" => "{%TEMPLATE}:",
"attrs" => ["placeholder" => "site default"]
],
"filter" => "strval"
],
"layout" => [
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
"empty_option" => "site default"
]
),
new Field(
"layout", 0,
"\\Crispage\\Components\\Fields\\TemplateLayoutSelectFieldComponent", [
"label" => "{%LAYOUT}:",
"attrs" => ["placeholder" => "site default"]
],
"filter" => "strval"
],
"show_title" => [
"component" => "\\Crispage\\Components\\Fields\\BooleanFieldComponent",
"com_data" => [
"empty_option" => "site default"
]
),
new Field(
"show_title", 0,
"\\Crispage\\Components\\Fields\\BooleanFieldComponent", [
"label" => "{%SHOW_TITLE}:"
],
"filter" => "boolval"
],
"show_info" => [
"component" => "\\Crispage\\Components\\Fields\\BooleanFieldComponent",
"com_data" => [
], "boolval", true
),
new Field(
"show_info", 0,
"\\Crispage\\Components\\Fields\\BooleanFieldComponent", [
"label" => "{%SHOW_INFO}:"
],
"filter" => "boolval"
],
"show_comments" => [
"component" => "\\Crispage\\Components\\Fields\\BooleanFieldComponent",
"com_data" => [
], "boolval", true
),
new Field(
"show_comments", 0,
"\\Crispage\\Components\\Fields\\BooleanFieldComponent", [
"label" => "{%SHOW_COMMENTS}:"
],
"filter" => "boolval"
],
"show_title_suffix" => [
"component" => "\\Crispage\\Components\\Fields\\BooleanFieldComponent",
"com_data" => [
], "boolval", true
),
new Field(
"show_title_suffix", 0,
"\\Crispage\\Components\\Fields\\BooleanFieldComponent", [
"label" => "{%SHOW_TITLE_PREFIX_SUFFIX}"
], "boolval", true
),
new Field(
"cache.policy", 0,
"\\Crispage\\Components\\Fields\\SelectFieldComponent", [
"label" => "{%CACHE_POLICY}:",
"options" => [
0 => "{%DEFAULT}",
-1 => "{%NO_CACHING}",
1 => "{%USER}",
2 => "{%GLOBAL}"
]
],
"filter" => "boolval"
]
"intval"
),
new Field(
"cache.ttl", 0,
"\\Crispage\\Components\\Fields\\NumberFieldComponent", [
"label" => "{%CACHE_TTL}:",
"attrs" => ["min" => 0, "max" => 86400]
],
"intval", 900
)
];
}
@ -99,8 +122,8 @@
public string $meta_robots;
public int $hits;
protected function __construct(array $props) {
parent::__construct($props);
protected function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->body = $props["body"] ?? "";
$this->title = $props["title"] ?? "";
$this->category_id = $props["category_id"] ?? 0;
@ -124,5 +147,41 @@
public function getParentId(): int {
return $this->category_id;
}
public function cacheKey(array $policy): string {
$key = preg_replace("/\\W+/", "_", $this::class) . "_$this->id";
if ($policy["policy"] == CacheEngine::POL_USER) {
$uid = $this->_app->auth->currentUser->id ?? 0;
$key .= "\$$uid";
}
return $key;
}
public function getBody(): string {
return $this->_app->shortcodes->renderShortcodeText($this->body);
}
public function getBodyCached(): string {
$policy = $this->_app->cache->getPolicy(
$this->getOption("cache.policy"),
$this->getOption("cache.ttl")
);
if ($policy["policy"] == CacheEngine::POL_NOCACHE)
return $this->getBody();
$key = $this->cacheKey($policy);
$entry = $this->_app->cache->get("content", $key);
if ($entry) return $entry->data;
else {
$body = $this->getBody();
$this->_app->cache->set(
new CacheEntry("content", $key, time() + $policy["ttl"], $body)
);
return $body;
}
}
}
?>

View File

@ -15,8 +15,17 @@
defined("ROOT") or die();
use \Crispage\Auth\CorePermissions;
use \Crispage\Backend\Field;
use \Crispage\Backend\AssetListColumn;
class Menu extends \Crispage\Framework\Asset {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.menu",
"version" => VERSION
];
}
class Menu extends \Crispage\Asset {
public static function getNames(): array {
return ["{%MENU}", "{%MENUS}"];
}
@ -41,46 +50,42 @@
public static function getListColumns(): array {
global $Crispage;
return [
"id" => ["label" => "{%ID}"],
"slug" => [
"label" => "{%SLUG}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"name" => ["label" => "{%NAME}", "filter" => "htmlentities"],
"mtime" => [
"label" => "{%MODIFIED}",
"filter" => [$Crispage->i18n, "datetime"]
]
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"slug", "{%SLUG}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn("name", "{%NAME}", "htmlentities"),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
)
];
}
public static function getEditorFields(): array {
return [
"name" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
new Field(
"name", 0,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%NAME}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"slug" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"slug", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%SLUG}:",
"attrs" => ["placeholder" => "automatic"]
],
"filter" => "strval"
]
]
)
];
}
public string $name;
public function __construct(array $props) {
parent::__construct($props);
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->name = $props["name"] ?? "";
}

View File

@ -15,8 +15,17 @@
defined("ROOT") or die();
use \Crispage\Auth\CorePermissions;
use \Crispage\Backend\Field;
use \Crispage\Backend\AssetListColumn;
class MenuItem extends \Crispage\Framework\Asset {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.menuitem",
"version" => VERSION
];
}
class MenuItem extends \Crispage\Asset {
public static function getNames(): array {
return ["{%MENU_ITEM}", "{%MENU_ITEMS}"];
}
@ -41,89 +50,74 @@
public static function getListColumns(): array {
global $Crispage;
return [
"id" => ["label" => "{%ID}"],
"slug" => [
"label" => "{%SLUG}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"uri" => ["label" => "{%URI}", "filter" => "htmlentities"],
"menu_id" => [
"label" => "{%MENU}",
"filter" => [$Crispage->assets, "assetNameFromID"]
],
"parent_id" => [
"label" => "{%PARENT}",
"filter" => [$Crispage->assets, "assetNameFromID"]
],
"position" => [
"label" => "{%POSITION}",
"filter" => null
],
"mtime" => [
"label" => "{%MODIFIED}",
"filter" => [$Crispage->i18n, "datetime"]
]
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"slug", "{%SLUG}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn("uri", "{%URI}", "htmlentities"),
new AssetListColumn(
"menu_id", "{%MENU}",
[$Crispage->assets, "assetNameFromID"]
),
new AssetListColumn(
"parent_id", "{%PARENT}",
[$Crispage->assets, "assetNameFromID"]
),
new AssetListColumn("position", "{%POSITION}"),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
)
];
}
public static function getEditorFields(): array {
return [
"label" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
new Field(
"label", 0,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%LABEL}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"uri" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\UriFieldComponent",
"com_data" => [
]
),
new Field(
"uri", 0,
"\\Crispage\\Components\\Fields\\UriFieldComponent", [
"label" => "{%URI}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"slug" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"slug", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%SLUG}:",
"attrs" => ["placeholder" => "automatic"]
],
"filter" => "strval"
],
"menu_id" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\AssetSelectFieldComponent",
"com_data" => [
]
),
new Field(
"menu_id", 1,
"\\Crispage\\Components\\Fields\\AssetSelectFieldComponent", [
"label" => "{%MENU}:",
"classname" => "\\Crispage\\Assets\\Menu",
"option_none" => "{%NONE_}"
],
"filter" => "intval"
],
"parent_id" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\AssetSelectFieldComponent",
"com_data" => [
]
),
new Field(
"parent_id", 1,
"\\Crispage\\Components\\Fields\\AssetSelectFieldComponent", [
"label" => "{%PARENT}:",
"classname" => "\\Crispage\\Assets\\MenuItem",
"option_none" => "{%NONE_}"
],
"filter" => "intval"
],
"position" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\NumberFieldComponent",
"com_data" => [
]
),
new Field(
"position", 1,
"\\Crispage\\Components\\Fields\\NumberFieldComponent", [
"label" => "{%POSITION}:",
"attrs" => ["required"]
],
"filter" => "intval"
]
]
)
];
}
@ -133,8 +127,8 @@
public int $parent_id;
public int $position;
public function __construct(array $props) {
parent::__construct($props);
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->label = $props["label"] ?? "";
$this->uri = $props["uri"] ?? "#";
$this->menu_id = $props["menu_id"] ?? 0;

View File

@ -15,8 +15,18 @@
defined("ROOT") or die();
use \Crispage\Auth\CorePermissions;
use \Crispage\Backend\Field;
use \Crispage\Backend\AssetListColumn;
use \Crispage\Backend\AssetListActionButton;
class Module extends \Crispage\Framework\Asset {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.module",
"version" => VERSION
];
}
class Module extends \Crispage\Asset {
public static function getNames(): array {
return ["{%MODULE}", "{%MODULES}"];
}
@ -41,109 +51,95 @@
public static function getListColumns(): array {
global $Crispage;
return [
"id" => ["label" => "{%ID}"],
"slug" => [
"label" => "{%SLUG}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"component" => [
"label" => "{%TYPE}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"location" => [
"label" => "{%LOCATION}",
"filter" => "htmlentities"
],
"position" => [
"label" => "{%POSITION}",
"filter" => null
],
"enabled" => [
"label" => "{%STATE}",
"filter" => function(bool $s): string {
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"slug", "{%SLUG}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn(
"component", "{%TYPE}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn("location", "{%LOCATION}", "htmlentities"),
new AssetListColumn("position", "{%POSITION}"),
new AssetListColumn(
"enabled", "{%STATE}",
function(bool $s): string {
global $Crispage;
return $Crispage->i18n->translate(
($s) ? "{%ENABLED}" : "{%DISABLED}"
);
}
],
"mtime" => [
"label" => "{%MODIFIED}",
"filter" => [$Crispage->i18n, "datetime"]
]
),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
)
];
}
public static function getListActions(): array {
return [
[
"route" => "module_create",
"label" => "{%CREATE_NEW}",
"color" => "success"
]
new AssetListActionButton("module_create", "{%CREATE_NEW}", "success")
];
}
public static function getEditorFields(): array {
return [
"enabled" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\BooleanFieldComponent",
"com_data" => [
new Field(
"enabled", 0,
"\\Crispage\\Components\\Fields\\BooleanFieldComponent", [
"label" => "{%ENABLED}:"
],
"filter" => "boolval"
],
"slug" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"slug", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%SLUG}:",
"attrs" => ["placeholder" => "automatic"]
],
"filter" => "strval"
],
"location" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
"label" => "{%LOCATION}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"position" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\NumberFieldComponent",
"com_data" => [
]
),
new Field(
"location", 1,
"\\Crispage\\Components\\Fields\\TemplateLocationSelectFieldComponent", [
"label" => "{%LOCATION}:"
]
),
new Field(
"position", 1,
"\\Crispage\\Components\\Fields\\NumberFieldComponent", [
"label" => "{%POSITION}:",
"attrs" => ["required"]
],
"filter" => "intval"
]
]
)
];
}
public static function getOptionFields(): array {
return [
"config" => [
"component" => "\\Crispage\\Components\\Fields\\ModuleConfigFieldComponent",
"com_data" => [],
"filter" => function($data): array {
new Field(
"config", 0,
"\\Crispage\\Components\\Fields\\ModuleConfigFieldComponent", [],
function($data): array {
global $Crispage;
if (!is_array($data)) return [];
$asset = $Crispage->assets->get(
intval($Crispage->request->params["asset_id"]) ?? 0
);
$Crispage->loadClass($asset->component);
$Crispage->loadClass($asset->component, "component");
$ndata = [];
foreach ($asset->component::getModuleFields() as $name => $field)
$ndata[$name] = $field["filter"]($data[$name] ?? null);
foreach (($asset->component)::getModuleFields() as $field) {
$ndata[$field->name] = $field->filter(
$Crispage, $data[$field->name] ?? null,
$asset->getConfig($field->name)
);
}
return $ndata;
}
]
)
];
}
@ -152,16 +148,30 @@
public int $position;
public bool $enabled;
public function __construct(array $props) {
parent::__construct($props);
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->component = $props["component"] ?? "\\Crispage\\Components\\DefaultComponent";
$this->location = $props["location"] ?? "default";
$this->position = $props["position"] ?? 0;
$this->enabled = $props["enabled"] ?? false;
}
public function config(string $key, $default = null) {
public function getConfig(string $key, mixed $default = null): mixed {
return $this->_options_array["config"][$key] ?? $default;
}
public function getConfigs(): array {
return $this->_options_array["config"];
}
public function setConfig(string $key, mixed $value): void {
$this->_options_array["config"][$key] = $value;
$this->options = json_encode($this->_options_array);
}
public function setOptions(array $data): void {
$this->_options_array["config"] = array_merge($this->_options_array["config"], $data);
$this->options = json_encode($this->_options_array);
}
}
?>

View File

@ -3,7 +3,7 @@
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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
@ -15,8 +15,18 @@
defined("ROOT") or die();
use \Crispage\Auth\CorePermissions;
use \Crispage\Backend\Field;
use \Crispage\Backend\AssetListColumn;
use \Crispage\Backend\AssetListActionButton;
class Plugin extends \Crispage\Framework\Asset {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.plugin",
"version" => VERSION
];
}
class Plugin extends \Crispage\Asset {
public static function getNames(): array {
return ["{%PLUGIN}", "{%PLUGINS}"];
}
@ -41,28 +51,25 @@
public static function getListColumns(): array {
global $Crispage;
return [
"id" => ["label" => "{%ID}"],
"runnable" => [
"label" => "{%TYPE}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"priority" => [
"label" => "{%PRIORITY}",
"filter" => null
],
"enabled" => [
"label" => "{%STATE}",
"filter" => function(bool $s): string {
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"classname", "{%TYPE}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn("priority", "{%PRIORITY}"),
new AssetListColumn(
"enabled", "{%STATE}",
function(bool $s): string {
global $Crispage;
return $Crispage->i18n->translate(
($s) ? "{%ENABLED}" : "{%DISABLED}"
);
}
],
"mtime" => [
"label" => "{%MODIFIED}",
"filter" => [$Crispage->i18n, "datetime"]
]
),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
)
];
}
@ -72,75 +79,86 @@
public static function getListItemActions(): array {
return [
[
"route" => "assets/editor",
"label" => "{%EDIT}",
"color" => "primary",
"fields" => [
"asset_id" => "id"
]
]
new AssetListActionButton(
"assets/editor", "{%EDIT}", "primary",
["asset_id" => "id"]
)
];
}
public static function getEditorFields(): array {
return [
"enabled" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\BooleanFieldComponent",
"com_data" => [
new Field(
"enabled", 0,
"\\Crispage\\Components\\Fields\\BooleanFieldComponent", [
"label" => "{%ENABLED}:"
],
"filter" => "boolval"
],
"priority" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\NumberFieldComponent",
"com_data" => [
]
),
new Field(
"priority", 1,
"\\Crispage\\Components\\Fields\\NumberFieldComponent", [
"label" => "{%PRIORITY}:",
"attrs" => ["required"]
],
"filter" => "intval"
]
]
)
];
}
public static function getOptionFields(): array {
return [
"config" => [
"component" => "\\Crispage\\Components\\Fields\\PluginConfigFieldComponent",
"com_data" => [],
"filter" => function($data): array {
new Field(
"config", 0,
"\\Crispage\\Components\\Fields\\PluginConfigFieldComponent", [],
function($data): array {
global $Crispage;
if (!is_array($data)) return [];
$asset = $Crispage->assets->get(
intval($Crispage->request->params["asset_id"]) ?? 0
);
$Crispage->loadClass($asset->component);
$Crispage->loadClass($asset->classname, "plugin");
$ndata = [];
foreach ($asset->component::getPluginFields() as $name => $field)
$ndata[$name] = $field["filter"]($data[$name] ?? null);
foreach (($asset->classname)::getPluginFields() as $field) {
$ndata[$field->name] = $field->filter(
$Crispage, $data[$field->name] ?? null,
$asset->getConfig($field->name)
);
}
return $ndata;
}
]
)
];
}
public string $runnable;
public string $classname;
public int $priority;
public bool $enabled;
public function __construct(array $props) {
parent::__construct($props);
$this->runnable = $props["runnable"] ?? "\\Crispage\\Plugins\\DefaultPluginRunnable";
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->classname = $props["classname"] ?? "\\Crispage\\Plugins\\DefaultPluginClass";
$this->priority = $props["priority"] ?? 0;
$this->enabled = $props["enabled"] ?? false;
}
public function config(string $key, $default = null) {
public function getConfig(string $key, mixed $default = null): mixed {
return $this->_options_array["config"][$key] ?? $default;
}
public function getConfigs(): array {
return $this->_options_array["config"];
}
public function setConfig(string $key, mixed $value): void {
$this->_options_array["config"][$key] = $value;
$this->options = json_encode($this->_options_array);
}
public function setOptions(array $data): void {
$this->_options_array["config"] = array_merge($this->_options_array["config"], $data);
$this->options = json_encode($this->_options_array);
}
}
?>

View File

@ -0,0 +1,132 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage\Assets;
defined("ROOT") or die();
use \Crispage\Auth\CorePermissions;
use \Crispage\Backend\Field;
use \Crispage\Backend\AssetListColumn;
class Redirect extends \Crispage\Framework\Asset {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.redirect",
"version" => VERSION
];
}
public static function getNames(): array {
return ["{%REDIRECT}", "{%REDIRECTS}"];
}
public static function getPermissions(): array {
return [
"create" => CorePermissions::MODIFY_CONTENT,
"modify" => CorePermissions::MODIFY_CONTENT,
"modify_own"=> CorePermissions::MODIFY_CONTENT,
"delete" => CorePermissions::MODIFY_CONTENT,
"delete_own"=> CorePermissions::MODIFY_CONTENT
];
}
public static function getSortingInfo(): array {
return [
"field" => "slug",
"desc" => false
];
}
public static function getRoutingInfo(): array {
return [
"action" => "\\Crispage\\Actions\\RedirectAction",
"data" => []
];
}
public static function getListColumns(): array {
global $Crispage;
return [
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"slug", "{%SLUG}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn("uri", "{%URI}", "htmlentities"),
new AssetListColumn(
"category_id", "{%CATEGORY}",
[$Crispage->assets, "assetNameFromID"]
),
new AssetListColumn("hits", "{%HITS}"),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
)
];
}
public static function getEditorFields(): array {
return [
new Field(
"uri", 0,
"\\Crispage\\Components\\Fields\\UriFieldComponent", [
"label" => "{%URI}:",
"attrs" => ["required"]
]
),
new Field(
"permanent", 0,
"\\Crispage\\Components\\Fields\\BooleanFieldComponent", [
"label" => "{%PERMANENT}:"
]
),
new Field(
"slug", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%SLUG}:",
"attrs" => ["placeholder" => "automatic"]
]
),
new Field(
"category_id", 1,
"\\Crispage\\Components\\Fields\\AssetSelectFieldComponent", [
"label" => "{%CATEGORY}:",
"classname" => "\\Crispage\\Assets\\Category",
"option_none" => "{%NONE_}"
]
)
];
}
public string $uri;
public bool $permanent;
public int $category_id;
public int $hits;
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->uri = $props["uri"] ?? "#";
$this->permanent = $props["permanent"] ?? false;
$this->category_id = $props["category_id"] ?? 0;
$this->hits = $props["hits"] ?? 0;
}
public function getName(): string {
return $this->slug;
}
public function getParentId(): int {
return $this->category_id;
}
}
?>

View File

@ -14,11 +14,18 @@
defined("ROOT") or die();
require_once ROOT . "/core/app/assets/Asset.php";
use \Crispage\Auth\CorePermissions;
use \Crispage\Backend\Field;
use \Crispage\Backend\AssetListColumn;
class Role extends \Crispage\Framework\Asset {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.role",
"version" => VERSION
];
}
class Role extends \Crispage\Asset {
public static function getNames(): array {
return ["{%ROLE}", "{%ROLES}"];
}
@ -43,64 +50,50 @@
public static function getListColumns(): array {
global $Crispage;
return [
"id" => ["label" => "{%ID}"],
"slug" => [
"label" => "{%SLUG}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"name" => [
"label" => "{%NAME}",
"filter" => "htmlentities"
],
"rank" => [
"label" => "{%RANK}",
"filter" => null
],
"mtime" => [
"label" => "{%MODIFIED}",
"filter" => [$Crispage->i18n, "datetime"]
]
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"slug", "{%SLUG}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn("name", "{%NAME}", "htmlentities"),
new AssetListColumn("rank", "{%RANK}"),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
),
];
}
public static function getEditorFields(): array {
return [
"name" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
new Field(
"name", 0,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%NAME}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"permissions" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\PermissionsFieldComponent",
"com_data" => [
]
),
new Field(
"permissions", 0,
"\\Crispage\\Components\\Fields\\PermissionsFieldComponent", [
"label" => "{%PERMISSIONS}:",
"attrs" => ["required"]
],
"filter" => "intval"
],
"slug" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"slug", 1,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%SLUG}:",
"attrs" => ["placeholder" => "automatic"]
],
"filter" => "strval"
],
"rank" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\NumberFieldComponent",
"com_data" => [
]
),
new Field(
"rank", 1,
"\\Crispage\\Components\\Fields\\NumberFieldComponent", [
"label" => "{%RANK}:",
"attrs" => ["required"]
],
"filter" => "intval"
]
]
)
];
}
@ -108,8 +101,8 @@
public int $permissions;
public int $rank;
public function __construct(array $props) {
parent::__construct($props);
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->name = $props["name"] ?? "";
$this->permissions = $props["permissions"] ?? 0;
$this->rank = $props["rank"] ?? 0;

View File

@ -14,14 +14,23 @@
defined("ROOT") or die();
require_once ROOT . "/core/app/assets/Asset.php";
use \Crispage\Auth\CorePermissions;
use \Crispage\Backend\Field;
use \Crispage\Backend\AssetListColumn;
use \Crispage\Backend\AssetListActionButton;
class User extends \Crispage\Asset {
public const UNCONFIRMED = 0;
public const CONFIRMED = 1;
public const ACTIVATED = 2;
class User extends \Crispage\Framework\Asset {
public const DISABLED = -1;
public const UNCONFIRMED= 0;
public const CONFIRMED = 1;
public const ACTIVATED = 2;
public static function getExtensionInfo(): array {
return [
"id" => "crispage.assets.user",
"version" => VERSION
];
}
public static function getNames(): array {
return ["{%USER}", "{%USERS}"];
@ -29,7 +38,7 @@
public static function getPermissions(): array {
return [
"create" => CorePermissions::NONE,
"create" => CorePermissions::MODIFY_OTHERS,
"modify" => CorePermissions::MODIFY_OTHERS,
"modify_own"=> CorePermissions::MODIFY_SELF,
"delete" => CorePermissions::NEVER,
@ -44,25 +53,29 @@
];
}
public static function getListActions(): array {
return [
new AssetListActionButton("user_create", "{%CREATE_NEW}", "success"),
new AssetListActionButton( "user_message", "{%SEND_MESSAGE}", "info")
];
}
public static function getListColumns(): array {
global $Crispage;
return [
"id" => ["label" => "{%ID}"],
"slug" => [
"label" => "{%USERNAME}",
"filter" => "\\Crispage\\Utils\\TextUtils::codeify"
],
"displayname" => [
"label" => "{%DISPLAY_NAME}",
"filter" => "htmlentities"
],
"last_login" => [
"label" => "{%LAST_LOGIN}",
"filter" => [$Crispage->i18n, "datetime"]
],
"state" => [
"label" => "{%STATE}",
"filter" => function(int $s): string {
new AssetListColumn("id", "{%ID}"),
new AssetListColumn(
"slug", "{%USERNAME}",
"\\Crispage\\Utils\\TextUtils::codeify"
),
new AssetListColumn("displayname", "{%DISPLAY_NAME}", "htmlentities"),
new AssetListColumn(
"last_login", "{%LAST_LOGIN}",
[$Crispage->i18n, "datetime"]
),
new AssetListColumn(
"state", "{%STATE}",
function(int $s): string {
global $Crispage;
switch ($s) {
case self::CONFIRMED:
@ -71,63 +84,58 @@
case self::ACTIVATED:
$str = "ACTIVATED";
break;
case self::DISABLED:
$str = "DISABLED";
default:
$str = "UNCONFIRMED";
}
return $Crispage->i18n->translate("{%$str}");
}
],
"mtime" => [
"label" => "{%MODIFIED}",
"filter" => [$Crispage->i18n, "datetime"]
]
),
new AssetListColumn(
"mtime", "{%MODIFIED}",
[$Crispage->i18n, "datetime"]
)
];
}
public static function getEditorFields(): array {
return [
"displayname" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
new Field(
"displayname", 0,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%DISPLAY_NAME}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"email" => [
"column" => 0,
"component" => "\\Crispage\\Components\\Fields\\TextFieldComponent",
"com_data" => [
]
),
new Field(
"email", 0,
"\\Crispage\\Components\\Fields\\TextFieldComponent", [
"label" => "{%EMAIL}:",
"attrs" => ["required"]
],
"filter" => "strval"
],
"role_ids" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\RoleSelectFieldComponent",
"com_data" => [
]
),
new Field(
"role_ids", 1,
"\\Crispage\\Components\\Fields\\RoleSelectFieldComponent", [
"label" => "{%ROLES}:"
],
"filter" => function($data): string {
function($data): string {
if (!is_array($data)) return "[]";
$data = array_filter($data, "ctype_digit");
return json_encode(array_values($data));
}
],
"state" => [
"column" => 1,
"component" => "\\Crispage\\Components\\Fields\\SelectFieldComponent",
"com_data" => [
),
new Field(
"state", 1,
"\\Crispage\\Components\\Fields\\SelectFieldComponent", [
"label" => "{%STATE}:",
"options" => [
0 => "{%DEACTIVATED}",
2 => "{%ACTIVATED}"
]
],
"filter" => "intval"
]
]
)
];
}
@ -138,8 +146,8 @@
private array $_role_ids_array;
public int $state;
public function __construct(array $props) {
parent::__construct($props);
public function __construct(\Crispage $app, array $props) {
parent::__construct($app, $props);
$this->displayname = $props["displayname"] ?? $props["slug"] ?? "";
$this->email = $props["email"] ?? "";
$this->last_login = $props["last_login"] ?? 0;

View File

@ -16,11 +16,12 @@
require_once ROOT . "/core/app/auth/CorePermissions.php";
use \Crispage\Config;
use \Crispage\ApplicationConfig;
use \Crispage\Framework\ApplicationFeature;
use \Crispage\Assets\User;
use \Crispage\Utils\UriUtils;
class Authenticator {
class Authenticator extends ApplicationFeature {
public const SUCCESS = 0;
public const ERR_SESSION_INACTIVE = 0x11;
@ -38,6 +39,7 @@
public const ERR_LOGIN_EXPIRED = 0x32;
public const ERR_LOGIN_PASSWD_MISMATCH = 0x33;
public const ERR_LOGIN_ACCOUNT_DISABLED = 0x34;
public const ERR_LOGIN_ACCOUNT_NOT_ACTIVATED=0x35;
public const ERR_SETPASSWD_REQS_NOT_MET = 0x41;
@ -53,6 +55,7 @@
public const ERR_RESET_TOKEN_MISMATCH = 0x73;
public const ERR_SENDCONF_EMAIL_FAILED = 0x81;
public const ERR_SENDCONF_USER_ACTIVATED= 0x82;
public const ERR_SENDRESET_EMAIL_FAILED = 0x91;
@ -60,24 +63,24 @@
public const ERR_VERIFY_EXPIRED = 0xa2;
public const ERR_VERIFY_PASSWD_MISMATCH = 0xa3;
public \Crispage $app;
public ?User $currentUser = null;
public ?string $sessionId = null;
public function __construct(\Crispage $app) {
$this->app = $app;
}
public function sessionActive(): bool {
return $this->currentUser && $this->sessionId;
}
public function password_hash(string $passwd): string {
return password_hash($passwd, Config::PASSWD_ALGO, Config::PASSWD_OPTS);
public function password_hash(string $passwd, bool $token = false): string {
$ckey = ($token) ? "crispage.security.token_opts" : "crispage.security.password_opts";
return password_hash(
$passwd,
ApplicationConfig::get("crispage.security.password_algo"),
ApplicationConfig::get($ckey)
);
}
public function token(): string {
return bin2hex(random_bytes(Config::TOKEN_BYTES));
return bin2hex(random_bytes(ApplicationConfig::get("crispage.security.token_bytes")));
}
public function startSession(User $user): int {
@ -87,7 +90,7 @@
$sessid = uniqid("cspg_", true);
$token = $this->token();
$token_hash = $this->password_hash($token);
$token_hash = $this->password_hash($token, true);
$expire_time = time() + (int)$this->app->settings->get(
"crispage.auth.session_timeout", 3600
);
@ -213,10 +216,16 @@
if (!$user) return static::ERR_LOGIN_INVALID;
// Check permissions
if (
$user->state < User::ACTIVATED ||
!$this->userHasPermission($user, CorePermissions::LOG_IN)
) return static::ERR_LOGIN_ACCOUNT_DISABLED;
if (!$this->userHasPermission(CorePermissions::LOG_IN, $user))
return static::ERR_LOGIN_ACCOUNT_DISABLED;
switch ($user->state) {
case User::DISABLED:
return static::ERR_LOGIN_ACCOUNT_DISABLED;
case User::UNCONFIRMED:
case User::CONFIRMED:
return static::ERR_LOGIN_ACCOUNT_NOT_ACTIVATED;
}
// Get password info
$res = $this->app->database->select("passwd", null, ["user_id" => $user->id]);
@ -283,31 +292,33 @@
return static::SUCCESS;
}
public function setPassword(User $user, string $password): int {
// Get password requirements
$min_chars = intval(
$this->app->settings->get("crispage.auth.password.min_chars", 12)
);
$min_alpha = intval(
$this->app->settings->get("crispage.auth.password.min_alpha", 2)
);
$min_digits = intval(
$this->app->settings->get("crispage.auth.password.min_digits", 2)
);
$min_special = intval(
$this->app->settings->get("crispage.auth.password.min_special", 1)
);
$timeout = intval(
$this->app->settings->get("crispage.auth.password_timeout", 0)
);
public function setPassword(User $user, string $password, bool $checkpass = true): int {
if ($checkpass) {
// Get password requirements
$min_chars = intval(
$this->app->settings->get("crispage.auth.password.min_chars", 12)
);
$min_alpha = intval(
$this->app->settings->get("crispage.auth.password.min_alpha", 2)
);
$min_digits = intval(
$this->app->settings->get("crispage.auth.password.min_digits", 2)
);
$min_special = intval(
$this->app->settings->get("crispage.auth.password.min_special", 1)
);
$timeout = intval(
$this->app->settings->get("crispage.auth.password_timeout", 0)
);
// Check password against requirements
if (
strlen($password) < $min_chars ||
preg_match_all("/[a-z]/i", $password) < $min_alpha ||
preg_match_all("/[\d]/", $password) < $min_digits ||
preg_match_all("/[^a-z\d]/i", $password) < $min_special
) return static::ERR_SETPASSWD_REQS_NOT_MET;
// Check password against requirements
if (
strlen($password) < $min_chars ||
preg_match_all("/[a-z]/i", $password) < $min_alpha ||
preg_match_all("/[\d]/", $password) < $min_digits ||
preg_match_all("/[^a-z\d]/i", $password) < $min_special
) return static::ERR_SETPASSWD_REQS_NOT_MET;
}
$hash = $this->password_hash($password);
$etime = ($timeout < 0) ? (time() + $timeout) : 2147483647;
@ -377,13 +388,16 @@
return $res->rowCount();
}
public function registerUser(string $username, string $password, array $data = []): int {
public function registerUser(string $username, string $password, array $data = [], bool $sendconf = true, bool $checkpass = true): int {
// Check that registration is enabled
$registration_enabled = boolval(
$this->app->settings->get("crispage.auth.registration_enabled", 0)
);
if (!$registration_enabled) return static::ERR_REGISTER_DISABLED;
if (!ApplicationConfig::get("crispage.security.enable_registration") || !$registration_enabled)
return static::ERR_REGISTER_DISABLED;
$username = preg_replace("/\\W/", "_", strtolower($username));
// Check that user doesn't exist
$user = $this->app->assets->getBySlug(
@ -410,7 +424,7 @@
}
// Set password
$res = $this->setPassword($user, $password);
$res = $this->setPassword($user, $password, $checkpass);
if ($res) return $res;
$this->app->assets->makePermanent($user);
@ -418,10 +432,14 @@
$this->app->dispatcher->trigger("crispage.auth.user_registered", $user);
// Send email
return $this->sendConfirmationEmail($user);
if ($sendconf) return $this->sendConfirmationEmail($user);
else return static::SUCCESS;
}
public function sendConfirmationEmail(User $user): int {
if ($user->state > User::UNCONFIRMED)
return static::ERR_SENDCONF_USER_ACTIVATED;
$token = $this->token();
$timeout = intval(
$this->app->settings->get(
@ -437,10 +455,10 @@
"expire_time" => $etime
]);
$sitename = $this->app->settings->get("crispage.site_name", Config::SITE_DOMAIN);
$sitename = $this->app->settings->get("crispage.site_name", ApplicationConfig::get("crispage.site_domain"));
$link = UriUtils::uri(
Config::SITE_DOMAIN, WROOT . "/confirm_account",
ApplicationConfig::get("crispage.site_domain"), WROOT . "/confirm_account",
($this->app->request->secure) ? "https://" : "http://",
["user_id" => $user->id, "token" => $token]
);
@ -501,10 +519,10 @@
"expire_time" => $etime
]);
$sitename = $this->app->settings->get("crispage.site_name", Config::SITE_DOMAIN);
$sitename = $this->app->settings->get("crispage.site_name", ApplicationConfig::get("crispage.site_domain"));
$link = UriUtils::uri(
Config::SITE_DOMAIN, WROOT . "/reset_password",
ApplicationConfig::get("crispage.site_domain"), WROOT . "/reset_password",
($this->app->request->secure) ? "https://" : "http://",
["user_id" => $user->id, "token" => $token]
);
@ -547,12 +565,12 @@
return $this->setPassword($user, $password);
}
public function getRank(User $user = null): int {
public function getRank(?User $user = null): int {
// Default to current user
$user ??= $this->currentUser;
if (!$user) return -1;
if (in_array($user->slug, Config::SUPERUSERS)) return 0;
if (in_array($user->slug, ApplicationConfig::get("crispage.dev.superusers"))) return 0;
// Start with lowest rank (highest number)
$rank = PHP_INT_MAX;
@ -567,12 +585,12 @@
return $rank;
}
public function getPermissions(User $user = null): int {
public function getPermissions(?User $user = null): int {
// Default to current user
$user ??= $this->currentUser;
if (!$user) return 0;
if (in_array($user->slug, Config::SUPERUSERS))
if (in_array($user->slug, ApplicationConfig::get("crispage.superusers")))
return CorePermissions::ALL;
// Start with no perms
@ -588,7 +606,7 @@
return $perms;
}
public function userHasPermission(?User $user, int $perms = null): bool {
public function userHasPermission(?int $perms = null, ?User $user = null): bool {
if ($perms === CorePermissions::NEVER) return false;
return ($this->getPermissions($user) & $perms) == $perms;
}
@ -612,5 +630,13 @@
// Compare and return
return $rank2 <=> $rank1;
}
public function getUsersInRole(Role|int $role): \Generator {
$rid = (is_int($role)) ? $role : $role->id;
return $this->app->assets->getAllFiltered(
"\\Crispage\\Assets\\User",
["role_ids" => ["[,\\[]{$rid}[,\\]]", $this->app->database::OP_REGEXP]]
);
}
}
?>

View File

@ -31,6 +31,7 @@
public const MODIFY_SELF = 0b0000000000000000000010000000000;
public const MODIFY_OTHERS = 0b0000000000000000000100000000000;
public const MODIFY_ROLES = 0b0000000000000000001000000000000;
public const SEND_MESSAGES = 0b0000000000000000010000000000000;
public const MODIFY_LAYOUT = 0b0000000000000001000000000000000;
public const MODIFY_SETTINGS = 0b0000000000000010000000000000000;

131
core/app/cache/CacheEngine.php vendored Normal file
View File

@ -0,0 +1,131 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage\Caching;
defined("ROOT") or die();
require_once ROOT . "/core/app/cache/CacheEntry.php";
use \Crispage\ApplicationConfig;
use \Crispage\Framework\ApplicationFeature;
use \Crispage\Framework\Component;
use \Crispage\Utils\FileUtils;
class CacheEngine extends ApplicationFeature {
public const POL_NOCACHE = -1;
public const POL_DEFAULT = 0;
public const POL_USER = 1;
public const POL_GLOBAL = 2;
public readonly string $path;
private ?array $default_policy;
private array $entries = [];
public function __construct(\Crispage $app) {
parent::__construct($app);
$this->path = ROOT . ApplicationConfig::get("crispage.paths.temp") . "/cache";
$this->initializeCache(false);
}
public function loadDefaultPolicy(): void {
$this->default_policy = [
"policy" => $this->app->settings->get("crispage.cache.default_policy", CacheEngine::POL_GLOBAL),
"ttl" => $this->app->settings->get("crispage.cache.default_ttl", 300)
];
}
public function getPolicy(?int $policy, ?int $ttl): array {
if (ApplicationConfig::get("crispage.dev.disable_caching"))
return ["policy" => static::POL_NOCACHE, "ttl" => 0];
switch ($policy) {
case static::POL_NOCACHE:
case static::POL_USER:
case static::POL_GLOBAL:
break;
default:
$policy = null;
}
return [
"policy" => $policy ?? $this->default_policy["policy"],
"ttl" => $ttl ?? intval($this->default_policy["ttl"])
];
}
public function initializeCache(bool $clear = true): int {
$count = 0;
if (!file_exists($this->path)) mkdir($this->path, CSPG_PERMS);
elseif ($clear) $count = FileUtils::emptyDirectory($this->path);
$this->app->dispatcher->trigger("crispage.cache.initialize", $count);
return $count;
}
public function createBucket(string $name): string {
$path = "$this->path/$name";
if (!file_exists($path)) mkdir($path, CSPG_PERMS);
return $path;
}
public function emptyBucket(string $name): ?int {
$path = "$this->path/$name";
if (!file_exists($path)) return null;
$count = FileUtils::emptyDirectory($path);
$this->app->dispatcher->trigger("crispage.cache.clear", $name, $count);
return $count;
}
public function path(string $bucket, string $entry): ?string {
if (!file_exists("$this->path/$bucket"))
mkdir("$this->path/$bucket", CSPG_PERMS);
$path = "$this->path/$bucket/" . md5($entry) . ".ccache";
return $path;
}
public function get(string $bucket, string $key): ?CacheEntry {
if (ApplicationConfig::get("crispage.dev.disable_caching")) return null;
$this->entries[$bucket] ??= [];
$entry = $this->entries[$bucket][md5($key)] ?? null;
if ($entry && !$entry->expired()) return $entry;
$path = $this->path($bucket, $key);
if (!$path || !file_exists($path)) return null;
$entry = unserialize(
file_get_contents($path), [
"allowed_classes" => [CacheEntry::class],
"max_depth" => 1
]
);
if ($entry->expired()) {
unlink($path);
return null;
}
return $entry;
}
public function set(CacheEntry $entry): void {
if (ApplicationConfig::get("crispage.dev.disable_caching")) return;
$this->entries[$entry->bucket] ??= [];
$this->entries[$entry->bucket][$entry->key] = $entry;
if (!$entry->temporary()) {
$path = $this->path($entry->bucket, $entry->key);
file_put_contents($path, serialize($entry));
}
$this->app->dispatcher->trigger("crispage.cache.entry", $entry);
}
}
?>

40
core/app/cache/CacheEntry.php vendored Normal file
View File

@ -0,0 +1,40 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage\Caching;
defined("ROOT") or die();
class CacheEntry {
public readonly string $bucket;
public readonly string $key;
public int $expires;
public mixed $data;
public function __construct(
string $bucket, string $key, int $expires, mixed $data
) {
$this->bucket = $bucket;
$this->key = $key;
$this->expires = $expires;
$this->data = $data;
}
public function temporary(): bool {
return $this->expires <= 0;
}
public function expired(): bool {
return ($this->expires <= 0) && ($this->expires >= time());
}
}
?>

View File

@ -0,0 +1,30 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage\Backend;
defined("ROOT") or die();
class AssetListActionButton {
public readonly string $route;
public readonly string $label;
public readonly string $color;
public readonly array $params;
public function __construct(string $route, string $label, string $color = "primary", array $params = []) {
$this->route = $route;
$this->label = $label;
$this->color = $color;
$this->params = $params;
}
}
?>

View File

@ -0,0 +1,36 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage\Backend;
defined("ROOT") or die();
class AssetListColumn {
public readonly string $name;
public readonly string $label;
public readonly ?\Closure $filter;
public function __construct(string $name, ?string $label = null, ?callable $filter = null) {
$this->name = $name;
$this->label = $label ?? strtolower($name);
if ($filter) $this->filter = \Closure::fromCallable($filter);
else $this->filter = null;
}
public function getValue(\Crispage\Framework\Asset $asset): string {
$aval = $asset->{$this->name};
if ($this->filter) return ($this->filter)($aval);
else return $aval;
}
}
?>

View File

@ -0,0 +1,126 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage;
defined("ROOT") or die();
use \Crispage\Media\MediaItem;
class CoreBackendLinks {
public static function get(): array {
return [
"dashboard" => [
"uri" => "backend://dashboard",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/house.png") . "\" />&nbsp;{%DASHBOARD}",
"position" => 0,
"dropdown" => []
],
"content" => [
"uri" => "#",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/folder_star.png") . "\" />&nbsp;{%CONTENT}",
"position" => 128,
"dropdown" => [
[
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Article",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/page_white_stack.png") . "\" />&nbsp;{%ARTICLES}"
],
[
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Category",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/folder_page_white.png") . "\" />&nbsp;{%CATEGORIES}"
],
[
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Comment",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/comments.png") . "\" />&nbsp;{%COMMENTS}"
],
[
"uri" => "backend://media/list?folder=/uploads",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/photos.png") . "\" />&nbsp;{%MEDIA}"
],
[
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Redirect",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/link_go.png") . "\" />&nbsp;{%REDIRECTS}"
]
]
],
"layout" => [
"uri" => "#",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/layout.png") . "\" />&nbsp;{%LAYOUT}",
"position" => 256,
"dropdown" => [
[
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Menu",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/application_view_list.png") . "\" />&nbsp;{%MENUS}"
],
[
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\MenuItem",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/link.png") . "\" />&nbsp;{%MENU_ITEMS}"
],
[
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Module",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/bricks.png") . "\" />&nbsp;{%MODULES}"
]
]
],
"users" => [
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\User",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/user.png") . "\" />&nbsp;{%USERS}",
"position" => 384,
"dropdown" => [
[
"uri" => "backend://user_message",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/email_edit.png") . "\" />&nbsp;{%SEND_MESSAGE}"
],
[
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Role",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/group.png") . "\" />&nbsp;{%ROLES}"
]
]
],
"settings" => [
"uri" => "backend://settings",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/cog.png") . "\" />&nbsp;{%SETTINGS}",
"position" => 512,
"dropdown" => [
[
"uri" => "backend://assets/list?classname=\\Crispage\\Assets\\Plugin",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/plugin.png") . "\" />&nbsp;{%PLUGINS}"
],
[
"uri" => "backend://extensions/list",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/package.png") . "\" />&nbsp;{%EXTENSIONS}"
]
]
],
"about" => [
"uri" => "#",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/help.png") . "\" />&nbsp;{%HELP}",
"position" => 640,
"dropdown" => [
[
"uri" => "backend://about",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/star.png") . "\" />&nbsp;{%ABOUT_CRISPAGE}"
],
[
"uri" => "https://crispy.cat",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/cake.png") . "\" />&nbsp;crispy.cat"
],
[
"uri" => "https://matrix.to/#/#crispage:matrix.calitabby.com",
"label" => "<img src=\"" . MediaItem::uri("/system/icons/telephone.png") . "\" />&nbsp;{%MATRIX_CHAT}"
]
]
]
];
}
}
?>

View File

@ -0,0 +1,58 @@
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
https://crispy.cat/software/crispage
Crispage 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.
*/
namespace Crispage\Backend;
defined("ROOT") or die();
class Field {
public readonly string $name;
public readonly int $column;
public readonly string $com_name;
public array $com_data;
public readonly ?\Closure $filter;
public readonly mixed $default_value;
public function __construct(
string $name, int $column = 0,
string $com_name = "\\Crispage\\Components\\DefaultComponent",
array $com_data = [], ?callable $filter = null, mixed $default_value = null
) {
$this->name = $name;
$this->com_name = $com_name;
$this->com_data = $com_data;
$this->column = $column;
$this->default_value = $default_value;
if ($filter) $this->filter = \Closure::fromCallable($filter);
else $this->filter = null;
}
public function render(\Crispage $app): void {
$com = $app->page->createComponent($this->com_name, $this->com_data);
$app->page->renderComponent($com);
}
public function filter(\Crispage $app, mixed $value = null, mixed $default = null): mixed {
if ($value == null && isset($app->request->params[$this->name]))
$value = $app->request->params[$this->name];
$value ??= $default ?? $this->default_value;
if ($this->filter) return ($this->filter)($value);
else {
$app->loadClass($this->com_name, "component");
if (defined("$this->com_name::DEFAULT_FILTER"))
return (\Closure::fromCallable(constant("$this->com_name::DEFAULT_FILTER")))($value);
else return $default ?? $this->default_value;
}
}
}
?>

View File

@ -14,7 +14,7 @@
defined("ROOT") or die();
use \Crispage\Config;
use \Crispage\ApplicationConfig;
use \Crispage\Utils\FileUtils;
use \Crispage\Utils\URIUtils;
@ -27,7 +27,7 @@
public int $mtime;
public static function realpath(string $path): string {
$base = realpath(ROOT . Config::MEDIA_PATH);
$base = realpath(ROOT . ApplicationConfig::get("crispage.paths.media"));
if ($path == "/") return $base;
else {
$real = realpath("$base/$path");
@ -38,9 +38,9 @@
}
public static function uri(string $path): string {
return (Config::MEDIA_CUSTOM_PREFIX) ?
Config::MEDIA_CUSTOM_PREFIX . $path :
URIUtils::iuri(Config::MEDIA_PATH . $path);
$url = ApplicationConfig::get("crispage.paths.mediaurl");
return ($url) ? $url . $path :
URIUtils::iuri(ApplicationConfig::get("crispage.paths.media") . $path);
}
public function __construct(string $path) {

View File

@ -14,21 +14,26 @@
defined("ROOT") or die();
use \Crispage\Config;
use \Crispage\ApplicationConfig;
use \Crispage\Framework\ApplicationFeature;
use \Crispage\Utils\FileUtils;
use \Crispage\Utils\URIUtils;
use \Crispage\Text\ShortcodeRenderer;
require_once ROOT . "/core/app/media/MediaItem.php";
require_once ROOT . "/core/app/cms/media/MediaItem.php";
class MediaManager {
public \Crispage $app;
class MediaManager extends ApplicationFeature {
public function __construct(\Crispage $app) {
$this->app = $app;
parent::__construct($app);
$this->app->shortcodes->mapShortcode(new ShortcodeRenderer(
"media", fn(array $args): string => MediaItem::uri($args["path"] ?? "")
));
}
public function writable(string $path): bool {
foreach (Config::MEDIA_WRITABLE_PATHS as $prefix)
foreach (ApplicationConfig::get("crispage.security.media_paths") as $prefix)
if (!strncmp($path, $prefix, strlen($prefix))) return true;
return false;
}
@ -55,7 +60,7 @@
}
public function upload(array $file, MediaItem $folder): ?MediaItem {
if (in_array(mime_content_type($file["tmp_name"]), Config::MEDIA_MIMETYPE_BLACKLIST))
if (in_array(mime_content_type($file["tmp_name"]), ApplicationConfig::get("crispage.security.media_banned_mimes")))
return null;
if (!$this->writable($folder->path)) return null;
$sn = FileUtils::sanitizeName($file["name"]);
@ -67,7 +72,7 @@
public function createFolder(string $name, MediaItem $parent): ?MediaItem {
if (!$this->writable($parent->path)) return null;
$sn = FileUtils::sanitizeName($name);
if (mkdir("$parent->realpath/$sn"))
if (mkdir("$parent->realpath/$sn", CSPG_PERMS))
return new MediaItem("$parent->path/$sn");
else return null;
}

View File

@ -53,7 +53,7 @@
public function score($obj): float {
if (!is_object($obj) && !is_array($obj))
return $this->score_str(@(string)$obj) * self::DEFAULT_FIELD_WEIGHT;
return $this->score_str(strval($obj)) * self::DEFAULT_FIELD_WEIGHT;
$weights = [];
@ -68,8 +68,12 @@
$weights[$k] ??= self::DEFAULT_FIELD_WEIGHT / $propcount;
$score = 0;
foreach ($obj as $k => $v)
$score += $this->score_str($v) * $weights[$k];
foreach ($obj as $k => $v) {
try {
$score += $this->score_str(strval($v)) * $weights[$k];
}
catch (\Throwable $e) {}
}
return $score;
}
}

View File

@ -14,16 +14,16 @@
defined("ROOT") or die();
use \Crispage\Config;
use \Crispage\ApplicationConfig;
use \Crispage\Framework\ApplicationFeature;
require_once ROOT . "/core/app/search/SearchFilter.php";
require_once ROOT . "/core/app/search/SearchKeyword.php";
require_once ROOT . "/core/app/search/SearchResult.php";
require_once ROOT . "/core/app/cms/search/SearchFilter.php";
require_once ROOT . "/core/app/cms/search/SearchKeyword.php";
require_once ROOT . "/core/app/cms/search/SearchResult.php";
class Searcher {
class Searcher extends ApplicationFeature {
public const DEFAULT_MIN_SCORE = 0.1;
public \Crispage $app;
private array $sources = [];
private array $keywords = [];
private array $filters = [];
@ -31,10 +31,6 @@
private string $flags = "";
private float $highest = 0;
public function __construct(\Crispage $app) {
$this->app = $app;
}
public function getSources(): array {
return $this->sources;
}

View File

@ -38,6 +38,7 @@
public const OP_BETWEEN = "BETWEEN";
public const OP_LIKE = "LIKE";
public const OP_IN = "IN";
public const OP_REGEXP = "REGEXP";
protected \PDO $pdo;
public string $location;
@ -48,6 +49,7 @@
public string $dsn;
public array $options;
public string $prefix;
public int $qc = 0;
protected function __construct(array $options) {
$this->location = $options["location"];
@ -67,10 +69,11 @@
public function raw(string $query, array $params = []): \PDOStatement {
$stmt = $this->pdo->prepare($query);
$this->qc++;
try {
$stmt->execute($params);
} catch (\PDOException $e) {
if (Config::SHOW_DB_ERRORS) var_dump([$query, $params, $e]);
if (ApplicationConfig::get("crispage.dev.db_errors")) var_dump([$query, $params, $e]);
throw $e;
}
return $stmt;

View File

@ -36,9 +36,7 @@
$ph[] = "?";
$ph2[] = "$k = excluded.$k";
$params[] = $v;
$params2[] = $v;
}
array_push($params, ...$params2);
$query = "INSERT INTO $this->prefix$table (" . implode(", ", $cols) . ")";
$query .= " VALUES (" . implode(", ", $ph) . ")";

View File

@ -29,6 +29,63 @@
"crispage.core", "package", []
),
// Assets
new Extension(
"crispage.assets.article", VERSION, "crispage.core",
"\\Crispage\\Assets\\Article",
"asset", []
),
new Extension(
"crispage.assets.category", VERSION, "crispage.core",
"\\Crispage\\Assets\\Category",
"asset", []
),
new Extension(
"crispage.assets.comment", VERSION, "crispage.core",
"\\Crispage\\Assets\\Comment",
"asset", []
),
new Extension(
"crispage.assets.contentasset", VERSION, "crispage.core",
"\\Crispage\\Assets\\ContentAsset",
"asset", []
),
new Extension(
"crispage.assets.menu", VERSION, "crispage.core",
"\\Crispage\\Assets\\Menu",
"asset", []
),
new Extension(
"crispage.assets.menuitem", VERSION, "crispage.core",
"\\Crispage\\Assets\\MenuItem",
"asset", []
),
new Extension(
"crispage.assets.module", VERSION, "crispage.core",
"\\Crispage\\Assets\\Module",
"asset", []
),
new Extension(
"crispage.assets.plugin", VERSION, "crispage.core",
"\\Crispage\\Assets\\Plugin",
"asset", []
),
new Extension(
"crispage.assets.redirect", VERSION, "crispage.core",
"\\Crispage\\Assets\\Redirect",
"asset", []
),
new Extension(
"crispage.assets.role", VERSION, "crispage.core",
"\\Crispage\\Assets\\Role",
"asset", []
),
new Extension(
"crispage.assets.user", VERSION, "crispage.core",
"\\Crispage\\Assets\\User",
"asset", []
),
// Actions
new Extension(
"crispage.actions.api", VERSION, "crispage.core",
@ -220,6 +277,16 @@
"\\Crispage\\Actions\\Backend\\SettingsAction",
"action", []
),
new Extension(
"crispage.actions.backend.usercreate", VERSION, "crispage.core",
"\\Crispage\\Actions\\Backend\\UserCreateAction",
"action", []
),
new Extension(
"crispage.actions.backend.usermessage", VERSION, "crispage.core",
"\\Crispage\\Actions\\Backend\\UserMessageAction",
"action", []
),
// Components
@ -233,6 +300,11 @@
"\\Crispage\\Components\\ArticleComponent",
"component", []
),
new Extension(
"crispage.components.breadcrumbs", VERSION, "crispage.core",
"\\Crispage\\Components\\BreadcrumbsComponent",
"component", ["is_module" => true]
),
new Extension(
"crispage.components.buttons", VERSION, "crispage.core",
"\\Crispage\\Components\\ButtonsComponent",
@ -286,7 +358,7 @@
new Extension(
"crispage.components.messages", VERSION, "crispage.core",
"\\Crispage\\Components\\MessagesComponent",
"component", ["is_module" => true]
"component", []
),
new Extension(
"crispage.components.navbarbutton", VERSION, "crispage.core",
@ -433,6 +505,11 @@
"\\Crispage\\Components\\Backend\\ModuleCreateComponent",
"component", []
),
new Extension(
"crispage.components.backend.onlineusers", VERSION, "crispage.core",
"\\Crispage\\Components\\Backend\\OnlineUsersComponent",
"component", []
),
new Extension(
"crispage.components.backend.quickactions", VERSION, "crispage.core",
"\\Crispage\\Components\\Backend\\QuickActionsComponent",
@ -458,6 +535,16 @@
"\\Crispage\\Components\\Backend\\UpdatesComponent",
"component", []
),
new Extension(
"crispage.components.backend.usercreate", VERSION, "crispage.core",
"\\Crispage\\Components\\Backend\\UserCreateComponent",
"component", []
),
new Extension(
"crispage.components.backend.usermessage", VERSION, "crispage.core",
"\\Crispage\\Components\\Backend\\UserMessageComponent",
"component", []
),
new Extension(
"crispage.components.fields.assetselect", VERSION, "crispage.core",
"\\Crispage\\Components\\Fields\\AssetSelectFieldComponent",
@ -563,12 +650,27 @@
"\\Crispage\\Components\\Fields\\UriFieldComponent",
"component", []
),
new Extension(
"crispage.components.fields.templateselect", VERSION, "crispage.core",
"\\Crispage\\Components\\Fields\\TemplateSelectFieldComponent",
"component", []
),
new Extension(
"crispage.components.fields.templatelayoutselect", VERSION, "crispage.core",
"\\Crispage\\Components\\Fields\\TemplateLayoutSelectFieldComponent",
"component", []
),
new Extension(
"crispage.components.fields.templatelocationselect", VERSION, "crispage.core",
"\\Crispage\\Components\\Fields\\TemplateLocationSelectFieldComponent",
"component", []
),
// Plugins
new Extension(
"crispage.plugins.default", VERSION, "crispage.core",
"\\Crispage\\Plugins\\DefaultPluginRunnable",
"\\Crispage\\Plugins\\DefaultPluginClass",
"component", []
),

View File

@ -15,6 +15,12 @@
defined("ROOT") or die();
class Extension {
public const DEFAULT_INFO = [
"id" => "unknown",
"package" => "unknown",
"version" => "0.0.0"
];
public string $id;
public string $version;
public string $package;

Some files were not shown because too many files have changed in this diff Show More