Repository navigation
Releases
Releases · karapuzec/ka_extensions
4.1.1.34
Changes
- Document: addKaMeta(), getKaMeta(), addKaJsLabels(), getKaJsLabels() moved from OCMOD to the kamod child \extension\ka_extensions\SystemLibraryDocument (system/library/document.php).
- Storefront header and footer controllers: OCMOD replaced by kamod child classes (kaextensions.js, stylesheet, ka_meta, JS labels, form validation flag).
- Admin header: the OCMOD is removed. The kamod child added kaextensions.js and the stylesheet too late (after the parent call), now before it.
- Templates: OCMOD replaced by kapatches (storefront ka_meta, theme editor warning, footers). The footers include extension/ka_extensions/ka_extensions/footer/scripts.twig.
- Headers do not create the object ka_extensions any more, kaextensions.js creates it. After the update run Extensions > Modifications > Refresh.
- JS: the form validation of the footers moved to kaextensions.js as ka_extensions.initFormValidation(), called by the footer unless KA_DISABLE_FORM_VALIDATION. Behaviour unchanged.
- Registry: the shorthand $this->kamodel_xxx is deprecated, reported by an assertion with KA_DEBUG_DEPRECATED; it still works. Use $this->load->kamodel().
- Format: formatDateTime() displays dates with IntlDateFormatter when the intl extension is available (locale from the OpenCart language code, date() pattern converted to ICU), otherwise with PHP date().
- Tests: integration DeprecatedApiTest (group deprecated, needs zend.assertions = 1), e2e tests/e2e/form_validation.js, unit FormatDateTimeTest.
- Russian translation (ru-ru): the admin templates common/page.twig, common/pages/page.twig and the module info block of common/pages/settings.twig use t() instead of hardcoded English.
- Russian translation: missing ru-ru files added: ka_extensions/settings.php, ka_extensions/mail/common.php and common_txt.php (admin and storefront).
- Russian translation: ru-ru copies of the deprecated includes common/settings.php, common/mail/.php (admin) and common.php, common/mail/.php (storefront); before, only English was loaded.
- Russian translation: missing ru-ru keys txt_operation_successful, txt_operation_failed, texts of the library templates (Add, Delete, Save & Stay, ...) and 29 strings of the Ka Extensions page.
What's Changed
- OCMOD to kamod / kapatch: Document, storefront header and footer, templates; admin header OCMOD removed; registry kamodel_ deprecated by @gosha-bot in #45
- Russian translation: missing ru-ru files and keys, admin page templates via t() by @gosha-bot in #46
- Release 4.1.1.34: version in manifest.ini and ControllerInstaller, changelog heading without '(not released)', formatDateTime in the changelog, install example 4.1.1.34 by @gosha-bot in #47
- Package: the ru-ru deprecated includes (admin and storefront common/, storefront common.php) in manifest.ini, they were not packed by @gosha-bot in #48
Full Changelog: v4.1.1.33...v4.1.1.34
4.1.1.33
Changes
- Licenses: the library uses only the API of the ka_licenses module (api_version 1), the old scripts extension/domain_info and extension/register_key are not called any more (the license server ka-station is updated together with the library). The list of Ka Extensions asks for the state of all installed modules of the vendor with one request to index.php?route=extension/ka_extensions/ka_licenses/api/checkModules (vendor, code and the edition of the store - oc3 for Opencart 3.x, the Opencart version); registered / free modules are saved as before, unregistered and expired ones are not registered. The registration of a key goes to .../ka_licenses/api/linkLicense (license_key, surface_uri, vendor, code, edition, opencart_version). When the license server is not available or its answer is not valid (connection refused, timeout, HTTP 404 / 5xx, empty or not JSON answer, no api_version) or it returns an error, nothing is changed: one request, the saved states of modules are kept, no module is disabled or shown as unlicensed, the error is written to the log. Tests: integration LicenseServerTest (group license, a local test server tests/fixtures/license_server).
- JavaScript: the object ka_extensions was not created on storefront themes with their own header.twig and footer.twig (e.g. Milena on ka-station), only the class KaExtensions was defined: since 4.1.1.32 the object was created by the inline script of the library part of the default header.twig (and of footer.twig, only when the page had labels), the removed common.js created it itself before. Code of modules failed with 'ka_extensions is not defined' (the image upload of a vendor product in Multivendor). Fixed: kaextensions.js (admin and storefront) creates the object at its end when it is missing, the header and the footer create it only when it is missing as before (one object). The admin kaextensions.js keeps after it the block of the old admin common.js:
$.ka.alert(text, type) calls ka_extensions.showMessage(text, type) (the storefront common.js had no such block, there $ .ka.alert is set by the constructor of KaExtensions). Note: the labels of the footer (ka_extensions.setLabels()) are still not passed on such themes, getLabel() gives the English defaults. Test: e2e tests/e2e/common_js_post_links.js (a page with kaextensions.js only, admin and storefront: the object and $.ka.alert calling showMessage).
What's Changed
- JS: kaextensions.js creates the object ka_extensions with any theme, $.ka.alert block of the old admin common.js by @gosha-bot in #43
- Release 4.1.1.33: version in manifest.ini and ControllerInstaller, changelog heading without '(not released)', install example 4.1.1.33 by @gosha-bot in #44
Full Changelog: v4.1.1.32...v4.1.1.33
4.1.1.32
Changes
- New ControllerAdminList (optional, like ControllerAdminForm for forms): the admin list with the defaults $use_default_list = true and $enable_delete = true; delete() and deleteRecord() need the 'modify' permission of PAGE_ROUTE (validateDelete()). ControllerList is not changed (no permission check, it is generic). Field metadata 'options' (ADBTable): value => text, shown as the text of the value in the default list (formatListValue()), used by 'select' filters and select form fields; options from the database: the name of a method of the table class or a closure, resolved when needed by the new ADBTable::getOptions($code) (kept per object); new helpers ADBTable::getStoreOptions() (store_id => name, the default store first) and getLanguageOptions() (language_id => name), e.g. 'store_id' => ['type' => 'select', 'options' => 'getStoreOptions', 'list' => true]. Arrays in 'options' work as before. New admin language string column_action ('Action', ru-ru), the column of the default list table. Simple read queries of the library are built with QB: Language (by id, by code), Store (store, its settings), Format (weight / length units; the class id is cast to int now). Tests: unit TableMetaTest, ControllersTest, integration DefaultListTest (groups lists, forms).
- QB hooks: new trait TraitQB with getQB($table = '', $alias = '') and onQB($table, $callback, $sort_order = 0) (returns a subscription id), offQB($id) (removes it, an unknown id is ignored), used by the base Model and Controller of the library; a developer can use it in other classes too, e.g. a kamod child of a standard OpenCart model: class ModelCatalogProduct extends \ModelCatalogProduct { use \extension\ka_extensions\TraitQB; }. getQB() returns 'new QB()' with from($table, $alias) when the table is given and the callbacks of onQB() for the table and '' (all), use it instead of 'new QB()' so other modules can extend the queries: they subscribe with onQB() in a kamod child of the class (constructor or onLoad()) or override getQB(). The callbacks are kept by the object (protected $qb_hooks, no static storage), the ones of the table first, then '', by sort order and subscription order. Usually a module subscribes for a while in a method of a kamod child: $id = $this->onQB('product', function($qb) { $qb->where('p.ka_hidden', 0); }); $result = parent::getRecords($filter); $this->offQB($id); getQB() copies the current callbacks into the QB object, so a QB made while the subscription was active keeps the callback after offQB(), QB objects made after offQB() do not get it. QB: the table key is the table of the first from() call (QB::getTable(), joins do not change it, queries of several tables in from() are not supported by the hooks), QB::addHook($callback) - a callback called with the QB object at the start of every getSql() call (also query(), ModelRecordset::getRecordsTotal(), the QB objects inside fromUnionAll() run their own hooks once per getSql() of the outer one), so it may run several times per object. 'new QB()' works as before. Docs: docgen/guides/code_design_guidlines.rst. Tests: unit QBHooksTest, integration QbHooksTest (group smoke).
- JavaScript: the class KaExtensions is moved from common.js to its own file kaextensions.js (admin: admin/view/javascript/extension/ka_extensions/, storefront: catalog/view/javascript/extension/ka_extensions/) together with $.ka.alert() and the admin click handler of data-ka-post / legacy delete links (registered when the object is created, delegated to the document). The library header adds kaextensions.js and creates the object ka_extensions right after it in the head of the page (an inline script in the library part of the admin and storefront header.twig), so inline code of the page can use it. common.js is removed (admin and storefront): third-party code including extension/ka_extensions/common.js has to include kaextensions.js instead (the object is created by the header). For storefront themes with their own header.twig (without the library part) the footer creates the object when it is missing. ka_extensions.getLabel(key, params): optional substitutions as in the PHP Language::getka($key, $params) (str_replace: every key of params is replaced with its value, all occurrences, in the order of the keys), e.g. getLabel('txt_deleted', {'%count%': 5}).
- Labels of the library JS: the admin and storefront footers passed the standard labels (txt_info, txt_success, txt_warning, txt_error, txt_field_validation_error) only without KA_DISABLE_FORM_VALIDATION, and the global ka_js_labels printed by footer.twig (HTML-escaped values inside a JS string: a quote was shown as ", a backslash or a line break broke the script) was read only by the form validation; the titles of ka_extensions.showMessage() were always English. Now the footers always pass the standard labels and the new txt_confirm ('Are you sure?', en-gb, ru-ru; ru-ru got all six labels), the constant turns off the form validation only. The footer prints the labels of the document (Document::addKaJsLabels()) as ka_extensions.setLabels({...}) (JSON with JSON_HEX_TAG / AMP / APOS / QUOT, safe in an inline script); no global ka_js_labels is created any more. New ka_extensions.setLabels(labels) (Object.assign into ka_extensions.labels, later calls override earlier values, modules can call it) and ka_extensions.getLabel(key) (the label, the English default, the key itself). Document::addKaJsLables() is renamed to addKaJsLabels() (the typo, no alias): modules calling the old name have to be changed. Tests: unit JsLabelsTest, integration JsLabelsTest (group smoke), tests/e2e/common_js_post_links.js.
- Build (ka_build.php 3.3.3.0, the copy in this repository; synced with ka_tools/ka_build.o2 r275 first): the header keywords
$Project$ ,$Author$ ,$Version$ ,$Revision$ were not filled in the packages built from git (git has no keyword expansion, the files had the bare keywords since the move to git). The builder writes them into the package copies of the packed files, the source files are not changed: $Project: <keywords_project> $ (default: manifest 'name'), $Author: <keywords_author> $ (default: karapuz team support@ka-station.com),$Version: $ ,$Revision: $ ; the revision is the number of commits of HEAD for git (git rev-list --count HEAD), the working copy revision for svn. git: stale values (copied from svn) are written again; svn: only bare keywords, the values expanded by svn are kept. Text files only (php, tpl, twig, js, css, xml, txt, ini, html, json, md, ...), not vendor/ and node_modules/ folders, only these four names; manifest 'expand_keywords = "N"' turns it off. Test: unit BuildKeywordsTest (group build). - Default list page (optional): a list page without a template of its own (the model of the page is required, it can be an empty ModelRecordset child with $table_class). ADBTable fields can declare metadata for the list and the form, all keys optional: 'list', 'sort', 'filter' (like, eq, select, date_range), 'form' => false, 'title', 'format' (price, date, datetime, enabled), 'width', 'link' => 'edit', and the form keys 'type', 'required', 'max_length', 'options', 'default_value'; getters getListFields(), getSortFields(), getFilterFields(), getFormFields(), hasFieldMeta() (without metadata: columns and sorting by all fields except the primary key, no filters, form fields of type text). ControllerList: $use_default_list = true shows @ka_common/pages/list.twig (filter panel and table from the metadata, sort links, checkboxes with the bulk delete by POST selected[], row edit and button_row_delete(), pagination, the Add button); DEFAULT_LIST_TEMPLATE is the template of the page, a module sets its own template extending '@ka_common/pages/list.twig' to replace a part of it (blocks list_filter, list_table); getListColumns(); the filters of the metadata go to the url parameters and to getPageFilterFields() when a child class passes none; getSortFields() comes from the 'sort' metadata when a field declares it. ModelRecordset: getTable(); getRecordsQB() applies the filters of the metadata (filter_, filter__from / _to, LIKE wildcards escaped); getSortWhitelist() is built from the 'sort' metadata. ControllerForm: when getFields() returns nothing the fields come from ADBTable::getFormFields() of the recordset (set it before parent::onLoad()). Tables and pages without the metadata work as before. New language strings txt_filter_from, txt_filter_to, txt_clear_filter (en-gb, ru-ru). Tests: unit TableMetaTest, integration DefaultListTest (groups lists, forms).
- ControllerList::getPageFilterFields(): a filter value '0' from the url (e.g. store 0, status 'Disabled') was not shown in the filter field (!empty() check), the filtering itself worked. Fixed: a value is any string that is not empty (isset + strlen, not trimmed), an array is a value when it is not empty. Tests: unit ControllersTest (group lists).
- Select fields (@ka_common/fields/select.value.twig, admin and catalog): the selected option was found by the loose Twig comparison '==': with an empty value the option with key 0 was selected too (PHP 7.4 '' == 0, and null == 0 on all versions), e.g. 'Default store' or 'Disabled' in an empty filter. Fixed: the value and the key are compared as strings. Note: the radio and checkboxes fields have the same loose comparison, not changed yet. Tests: integration PagesTest (group lists).
- ControllerList: the 'delete' action of a row (fillRecord()) opens PAGE_ROUTE/deleteRecord, which accepts POST only since 4.1.1.29, so a plain link of a list template deleted nothing ('permission' error). New: the macro button_row_delete(href) of @ka_common/macros/table.twig and a handler in the admin common.js: a link with data-ka-post is posted as a hidden form after the data-confirm question. The action has the key 'method' => 'post'. Legacy row delete links of list templates are posted too: a.btn-danger with '/deleteRecord' in the href a...
4.1.1.31
Changes
- Storefront templates: '@ka_common' templates were not found with a theme without the folder template/extension/ka_extensions/common (Twig error 'Template "@ka_common/..." is not defined'), the folder of the default theme was registered only when the active theme had its own folder. Fixed: the folder of the active theme is registered first (when it exists), then the folder of the default theme, so a theme overrides only the templates it has. Also a kapatch of a '@ka_common' template was not applied with the default theme (the kamod cache of the common folder was registered for other themes only, and the theme folder was added by a path relative to the current directory). Fixed: the kamod cache of the default folder is registered for every theme; for another theme the order is the kamod cache of its folder, its folder, the kamod cache of the default folder, the default folder. Tests: group ka-common.
- Extensions > Ka Extensions: a Lite module (isLite() returns true) took the free flag, the license key, the expiry date and the wrong license flag from the record of the full version '
', so it showed 'Registered' without a key, or the key and the expiry date of the full version, instead of 'Free'. Fixed: all license data of a Lite module come from its own record '_lite' (the server marks a Lite product with price 0 as free), other modules are not changed.
Pull requests
- Ka Extensions list: Lite module reads its own '
_lite' license record by @gosha-bot in #22
- @ka_common templates: default theme fallback, kapatches with any theme by @gosha-bot in #23
- Release 4.1.1.31 by @gosha-bot in #24
Full Changelog: v4.1.1.30...v4.1.1.31
4.1.1.30
Changes
- Mail: inline images in emails. \extension\ka_extensions\Mail::addInlineImage($filename, $name = '') (it calls addInlineImage($filename, $name) of the OpenCart mail object, the name is required there) adds an image for the html part; it is shown by
where the cid is returned by the static \extension\ka_extensions\Mail::generateCid($filename) ('ka-.', the same for every call). $name is the file name in the email, basename($filename) when empty. The type (png, jpeg, gif, webp) is detected from the file; another file is added as a regular attachment and the method returns false. The patched mail adaptors (mail/mail.php.xml, mail/smtp.php.xml) send inline images as image/* parts with 'Content-Disposition: inline' inside multipart/related together with the text and html parts, other attachments stay in multipart/mixed; an email without an html part gets them as inline image/* parts of multipart/mixed. Emails without inline images are built exactly as before (checked on OpenCart 3.0.0.0, 3.0.4.0, 3.0.5.1 with the mail and smtp engines). A module can check method_exists($mail, 'addInlineImage') and call addAttachment() with older libraries. The kamod cache has to be rebuilt after the update: until then the OpenCart mail object of the old cache has no addInlineImage() and the call stops with a fatal error. The logo and the 'images are enclosed' setting are not changed. See docgen/guides/mail.rst.
- kamod.ini: depends_on, install_before and install_after are read by one function, KamodManager::getManifestModules(). Each field can be a comma-separated string (install_after = "a, b") or an array (install_after[] = "a"), array items can contain commas too; codes are trimmed, empty items and duplicates are dropped, a code without a vendor gets the 'ka_extensions/' prefix, e.g. install_after = "ka_extensions" is read as ka_extensions/ka_extensions (the library itself). Before, install_before and install_after were read as a comma-separated string only and short codes were compared without the prefix. The order of child classes is fixed: install_before listing modules none of which overrides the class dropped the module child class from the chain, install_after in the same case moved it after the first class of the chain; now the class keeps its position. The demo modules mod1, mod3, mod4 use full module codes in the array form. See docgen/guides/kamod_ini.rst.
Pull requests
- Release 4.1.1.30 by @gosha-bot in #21
Full Changelog: v4.1.1.29...v4.1.1.30
4.1.1.29
Changes
- Notifications (\extension\ka_extensions\Notifications): a bell in the admin header next to the Kamod Health Status icon (kamod child of common/header and the header.twig kapatch of the library). add($code, $text, $ttl = 0) for the logged in administrator (for all administrators when there is none, e.g. in the catalog), addForAll($code, $text, $ttl = 0) for all administrators, remove($code), get($code). $ttl in seconds, 0 = until closed. The bell is shown to administrators with access to Extensions > Ka Extensions when they have notifications; the text is escaped; the cross deletes a notification by POST (extension/extension/ka_extensions/deleteNotification, modify permission of Ka Extensions). New table ka_notification (created on the Ka Extensions page or on the first add()). en-gb and ru-ru strings. See docgen/guides/notifications.rst.
- HiddenSettings (\extension\ka_extensions\HiddenSettings): hidden values of a module in the admin area and in the catalog, get($ext_code, $key, $default = null), set($ext_code, $key, $value) and increase($ext_code, $key, $add = 1). The storage is the same as of getConfigHidden()/setConfigHidden() (group '<ext_code>_hidden', keys '<ext_code>hidden', arrays as JSON). set() writes one key instead of the whole group, increase() is one UPDATE value = value + N (a missing value is inserted once under a named lock), so parallel requests do not lose values. getConfigHidden()/setConfigHidden() of the admin setting model are wrappers of it now. See docgen/guides/upgrading_modules.rst.
- TraitDBFilter (DBProxy): removeFilter() removed all filters of the class, a nested method removing its filter also removed the filter of the calling method (e.g. several modules extending one model method). Fixed: setFilter() returns the filter id, removeFilter($id) removes only that filter, removeFilter() without the id removes only the last filter of the current class. Existing calls work as before; the recommended use is $id = setFilter(...) and removeFilter($id) in a 'finally' block.
- Forms: validateField() of a 'number' field returned true after the 'Minimum value is %s' / 'Maximum value is %s' error, a child class checking more could go on and replace the error. Fixed: it returns false. An empty value of a non-required 'number' field is not checked against min_value/max_value any more (a minimum above zero gave an error).
- Settings page (ControllerSettings): a validation error of a module without its own text was shown as the raw key 'error_field_is_empty'. Fixed: the page loads the library common language file before the module files (a module text still wins). New ru-ru texts of the field validation ('Поле не заполнено', minimum, maximum, not a number) in admin and catalog, the 'number' validation texts are in en-gb too.
- Extensions > Ka Extensions: a module installed without a stored version (0.0.0.0) showed the orange 'Files: ..., installed: 0.0.0.0' text under its version. Now nothing is shown under the version in this case, the hint stays in the tooltip of the 'Refresh' button. The Version column is wider (15%), the Name column is 45%.
- Module upgrade: Extensions > Ka Extensions shows a yellow 'Refresh' button next to an installed module when $extension_version of its files is greater than the installed version, with the hint 'Files: , installed: ' (en-gb and ru-ru). The button (POST only, the modify permission of Ka Extensions) calls the new upgradeExtension($from_version, $to_version) of the module installer; on success the new version is stored, the kamod cache is marked for a rebuild and the module page gets the permissions, on failure the installed version and the button stay. By default upgradeExtension() calls install(), a module overrides it for migrations. A module without $extension_version gets no button. See docgen/guides/upgrading_modules.rst.
- Installation: the version of the module ($extension_version) is stored on installation as the hidden value 'version' of the module. A module installed by an older library has no stored version, it is 0.0.0.0 (the 'Refresh' button is shown once).
- Admin setting model (kamod child of model/setting/setting): getConfigHidden($ext_code, $key) and setConfigHidden($ext_code, $key, $value) for hidden values of a module (the installed version, counters). They are stored by the OpenCart getSetting()/editSetting() in the group '<ext_code>_hidden' under the keys '<ext_code>hidden', other hidden values of the module are kept, saving the settings page does not touch them. A missing value is null.
- ControllerSettings: uninstallation does not delete the module settings any more, they are used again by the next installation or upgrade. getSettingCode() is moved to ControllerInstaller.
- KaURLify vendor: the composer.json files of the bundled libraries are removed, the portable-ascii ASCII class is not final.
- KaURLify: smaller package. voku/stop-words is not bundled (KaURLify does not remove stop words, remove_words() keeps its own list) and the CJK and Hangul transliteration tables of portable-ascii are removed: Chinese, Japanese and Korean characters are dropped from urls. See system/library/extension/ka_extensions/vendor/README.md.
- KaURLify (\extension\ka_extensions\KaURLify): url keywords and file names from any text, filter($text, $length, $language, $url_type) as in the KaURLify class of CSV Product Import and of the OpenCart 4 library. It wraps jbroadway/urlify 1.2.5 with voku/portable-ascii 2.1.1 and voku/stop-words 2.0.1, added to system/library/extension/ka_extensions/vendor (with their licenses, loaded without composer, PHP 7.2+). The language code ('ru', 'ru-ru') selects the transliteration rules; Ukrainian letters missing in the Ukrainian table are converted by the Russian rules.
- Forms: a 'text' or 'textarea' field can have 'max_length' (characters, e.g. the size of its database column). A longer posted value fails validation with the new language string error_field_too_long (admin and catalog, en-gb and ru-ru).
- Installation: permissions of the extension pages were added to the user group on every installation, a reinstalled module had its routes in the group lists several times. Fixed: a permission is added only when the group does not have it yet. Existing duplicates are removed when the user group is saved.
- Forms: a 'checkboxes' field (a list of checkboxes) could not be saved with all boxes unchecked, the old value was kept because unchecked boxes are not posted. Fixed: a submitted form without the field saves an empty list.
- ControllerList: delete() and deleteRecord() work by POST requests only, a GET request (e.g. a link) deletes nothing and shows the permission error. A delete link in a list template has to be replaced with a button posting to the same url.
- Language: the permission error of the library pages (e.g. a refused GET delete of ControllerList) was shown as the raw key 'error_permission' when the module language file did not define it. Fixed: error_permission is in the library common language file (en-gb, and a new ru-ru file); a module's own error_permission still wins.
- QB: orderBy($order, $after) and groupBy($groupBy, $after) dropped the value (wrong argument order of Arrays::insertAfterKey()). Fixed: the value is put after $after, at the end when $after is not in the list. Several from() tables are separated with commas.
- kamod: a kapatch for a newer or another major kamod version was skipped, but the patched file was written empty. Fixed: the file keeps its contents.
- kamod: the log (kamod.log) had the month name instead of the hour in the time. Fixed.
- Pagination: without the 'limit' parameter the OpenCart 3 setting 'Default Items Per Page (Admin)' (config_limit_admin) was ignored and 20 was used. Fixed.
- Model: the deprecated getNamespace() used an undefined variable for a class without a namespace (a warning). Fixed: an empty namespace is returned.
- Forms: validation of fields. A required field of spaces passed; a required 'checkboxes' field posted as an empty list gave a TypeError; a non-numeric value of a 'number' field with min_value/max_value passed the limits (now 'The value must be a number'); initFields() of no fields returned null instead of an empty array. Fixed.
- Forms (ControllerForm): the raw POST was saved. An unchecked checkbox kept its old value, a 'checkboxes' field with all boxes unchecked kept the old list. A posted primary key was trusted when the url had none: a new record form updated the posted record. Fixed in the new protected getPostedRecord(): unchecked boxes are saved as '0' / an empty list, the primary key is taken from the url only.
- Form fields: the field templates (common/fields/*.twig, admin and catalog) printed values without escaping (OpenCart 3 Twig has autoescape off), a quote broke an input and HTML in a value was output as is. Fixed: values, placeholders and option values are escaped with the new Twig filter ka_escape (htmlspecialchars without encoding existing entities again, so values stored html-escaped by OpenCart are shown as before). Labels, errors and 'plaintext' fields are printed as before.
- Settings page template: the form posted to an empty 'action' (the controller sets 'action_save'), Enter in a field submitted to the current url. Fixed: the form uses action_save ('action' still wins when a module sets it).
- ControllerSettings: for a vendor other than 'ka_extensions' the settings page saved the values under '<ext_code>', but install() stored the default values and uninstall() deleted the settings under '<ext_code>'. The defaults did not reach the group of the page (OpenCart skips keys not starting with the code) and uninstallation left the saved values. Fixed: one protected getSettingCode() ('<ext_code>' for vendor 'ka_extensions', '<ext_code>' for others) is used for saving and installation (the settings are not deleted on uninstallation any more, see above). Old rows stored ...
4.1.1.28
Changes
- Twig: added include_jska('path/file.js', ...) and include_csska('path/file.css', ...) functions. They print <script>/ tags for the given urls (as in src/href) with ?v=.
- Format: convertToByte() parses fractions ('1.5G', '1,5G'), values without a suffix ('512' gave 51), '-1' (unlimited) and suffixes like '10 Mb', '10 KB', '100 bytes', 'T'.
- Format: size unit labels are taken from the language file (ka_format, en-gb and ru-ru for admin and catalog); formatPassedTime() in the catalog printed 'text_hours' etc. Fixed.
- Format: no fatal error when the language is not found (a line is written to the log), the language list is read once per request. Added static parseBytes() and formatBytes() helpers.
- Top messages of the Ka Extensions pages are shown with the right type: success messages green ('S'), errors red ('E').
Pull requests
- Format: correct size parsing, translatable units, no fatal error without a language by @gosha-bot in #12
- Twig: include_jska() and include_csska() by @gosha-bot in #13
- Release 4.1.1.28 by @gosha-bot in #14
Full Changelog: v4.1.1.27...v4.1.1.28
4.1.1.27
Changes
- UrlParams: an array in the URL (e.g. 'filter_name[]=x') gave a fatal error on PHP 8. Fixed: arrays are accepted only for parameters with an array default value, otherwise the default value is used.
- ControllerList: a negative or non-numeric 'page' value gave a negative LIMIT and an SQL error. Fixed: the page is at least 1, ModelRecordset::getRecords() never uses a negative start.
- ModelRecordset: added the optional getSortWhitelist() method ('sort code' => 'SQL column or expression'). When a child class defines it, only the listed sort values are accepted, sorting by expressions is possible; by default (null or empty) the sorting works as before, only plain column names like 'name' or 't.name' are accepted.
- UrlParams: parameter values in the built URLs were not encoded, e.g. a filter 'a+b@x.com' became 'a b@x.com' on the next page of a list. Fixed: values are URL-encoded (rawurlencode), array values become 'name[key]=value' pairs, placeholders like '{page}' are kept.
- ControllerSettings: the template name is in the $settings_template property, a module can set its own template.
- ControllerSettings: the settings page shows the module version and author line for the 'ka_extensions' vendor (the vendor was not passed to the template).
- ControllerSettings: a successful save shows 'Settings have been stored sucessfully.' on the extensions page, a validation error shows a general warning above the form. A message the module has already added is not shown twice.
- ControllerList: added the $complete_records property. true (default) - every record of the list is read again with getRecord() as before, false - the records of getRecords() are used as they are, without one more query per row.
Pull requests
- Docs: FAQ, twig, settings page, mail guides and DEVELOPMENT.md by @gosha-bot in #4
- Safe mode: changed code takes effect at once (opcache) by @gosha-bot in #5
- Remove tests/safe_mode.sh, exclude tests/ from the build by @gosha-bot in #6
- Docs: mark as OpenCart 3 only by @gosha-bot in #7
- Show uninstall messages on OpenCart 3.0.3.9+ by @gosha-bot in #8
- Docs: All Documentation, GitHub and Releases links by @gosha-bot in #9
- UrlParams/ControllerList/ControllerSettings fixes, optional sort whitelist, complete_records flag by @gosha-bot in #10
- Release 4.1.1.27 by @gosha-bot in #11
Full Changelog: v4.1.1.26...v4.1.1.27
official release
latest available version
What's Changed
- Fix module dependency check on uninstall by @gosha-bot in #1
- Sync with 4.1.1.26 and build from git by @gosha-bot in #2
- ka_build.php 3.3.1.0 and ka_gen.php 3.3.4 (build from git) by @gosha-bot in #3
New Contributors
- @gosha-bot made their first contribution in #1
Full Changelog: https://github.com/karapuzec/ka_extensions/commits/v4.1.1.26