30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-06-01 05:50:52 +00:00

Compare commits

...

314 Commits

Author SHA1 Message Date
Hannes Papenberg
68b3aae886 Updating JoRobo 2023-10-19 23:43:57 +02:00
Tuan Pham Ngoc
c4e411e42e More Joomla 5.0 native fixes 2023-10-19 20:56:05 +07:00
Tuan Pham Ngoc
447a5fe9b7 Use namespace class to work with 5.0 native 2023-10-19 20:19:43 +07:00
Hannes Papenberg
4537e436c1
Updating dependencies (#535) 2023-08-22 10:02:03 +02:00
Nicola Galgano
e22533aacf
Division Not Closed in a /mod_weblinks/tmpl/ (#534) 2023-08-22 09:26:46 +02:00
Hannes Papenberg
7f7caebd90
[4.0] Updating dependencies (#529) 2023-06-23 11:28:51 +02:00
Hannes Papenberg
0934f8464e
Merge pull request #528 from Hackwar/4.0-drone 2023-06-23 11:20:03 +02:00
Hannes Papenberg
0104e1bab1 Fixing file permissions in cypress 2023-06-23 10:50:04 +02:00
Hannes Papenberg
13c3d89945 Fixing dependency of steps in drone 2023-05-18 19:17:34 +02:00
Hannes Papenberg
2576be4bb2 Adding phan and phpstan to drone setup 2023-05-18 19:11:25 +02:00
Hannes Papenberg
691361cb9f Removing old Travis stuff 2023-05-18 18:47:15 +02:00
Hannes Papenberg
4292a06af6 Switch to PSR-12 2023-05-18 18:45:59 +02:00
Hannes Papenberg
9f6606a8a4 Adding codestyle checks to drone 2023-05-18 18:13:56 +02:00
Hannes Papenberg
a780693f1d Adding artifacts step to drone 2023-05-18 18:01:39 +02:00
Hannes Papenberg
b674c4f836 Fixing path for cypress execution 2023-05-18 17:55:27 +02:00
Hannes Papenberg
eeefcc33ad Fixing cypress.config.dist.js 2023-05-18 17:44:56 +02:00
Hannes Papenberg
f3df23f423 Merge branch '4.0-dev' of github.com:joomla-extensions/weblinks into 4.0-cypress
# Conflicts:
#	composer.lock
2023-05-18 17:40:49 +02:00
Hannes Papenberg
5de0f2d32f Adding minimal setup to run cypress tests 2023-05-18 17:38:28 +02:00
Robert Deutz
4ab53cd8fb
Merge pull request #526 from Hackwar/4.0-static-code-analyser
Adding setup for phpstan and phan
2023-05-16 18:52:50 +02:00
Hannes Papenberg
404aa2ad10 Merge branch '4.0-dev' of github.com:joomla-extensions/weblinks into 4.0-static-code-analyser
# Conflicts:
#	composer.lock
2023-05-16 17:45:30 +02:00
Robert Deutz
e5decfae6d
Merge pull request #525 from Hackwar/4.0-jorobo
Switching to JoRobo dev-develop and Robo 3
2023-05-16 17:41:52 +02:00
Hannes Papenberg
5f83ca9b7c Adding setup for phpstan and phan 2023-05-16 17:17:32 +02:00
Hannes Papenberg
a779bf41c4 Switching to JoRobo dev-develop and Robo 3 2023-05-16 17:06:41 +02:00
Hannes Papenberg
40420a4914 Initial setup for cypress in drone 2023-05-15 22:28:55 +02:00
Tuan Pham Ngoc
ecae4eb2ae Move to right folder 2023-03-16 18:11:39 +07:00
Tuan Pham Ngoc
4bb87b8845
Merge pull request #517 from joomdonation/convert_weblink_system_plugin
Convert System - Weblinks plugin to service provider
2023-03-16 18:10:29 +07:00
Tuan Pham Ngoc
5f77274fa4 Consistent name 2023-03-16 18:08:26 +07:00
Tuan Pham Ngoc
e0710f4bed Clean up and delete the old plugin file 2023-03-16 18:07:01 +07:00
Tuan Pham Ngoc
eba461fe1d Merge branch '4.0-dev' into convert_weblink_system_plugin 2023-03-16 18:01:13 +07:00
Tuan Pham Ngoc
270f22954b
Merge pull request #518 from joomdonation/convert_weblink_editor_xtd_plugin
Convert weblink editor-xtd plugin to service provider
2023-03-16 18:00:37 +07:00
Tuan Pham Ngoc
a07ab47744 Delete old plugin file 2023-03-16 17:58:41 +07:00
Tuan Pham Ngoc
510c296a7a Merge branch '4.0-dev' into convert_weblink_editor_xtd_plugin 2023-03-16 17:55:50 +07:00
Tuan Pham Ngoc
65d16b97e8
Merge pull request #519 from joomdonation/convert_finder_weblinks_plugin
Convert Finder - Weblinks plugin to service provider
2023-03-16 17:55:04 +07:00
Tuan Pham Ngoc
ccb2938226 Delete old plugin file 2023-03-16 17:54:18 +07:00
Tuan Pham Ngoc
1451e89e98 Merge branch '4.0-dev' into convert_finder_weblinks_plugin 2023-03-16 17:50:04 +07:00
Tuan Pham Ngoc
4c2f6f5d7e
Merge pull request #520 from joomdonation/convert_search_weblinks_plugin
Convert Search - Weblinks plugin to service provider
2023-03-16 17:49:03 +07:00
Tuan Pham Ngoc
cd658395da Delete old file 2023-03-16 17:48:03 +07:00
Tuan Pham Ngoc
8cdc1c26bc Merge branch '4.0-dev' into convert_search_weblinks_plugin 2023-03-16 17:46:13 +07:00
Tuan Pham Ngoc
c23da94103
Merge pull request #516 from joomdonation/mod_weblinks_services_provider
Convert mod_weblinks module to use services provider
2023-03-16 17:42:25 +07:00
Tuan Pham Ngoc
34db9cad30 Add delete file 2023-03-16 17:39:44 +07:00
Tuan Pham Ngoc
fa5c5223fb Revert "Add module files manually"
This reverts commit 811e133f0a.
2023-03-16 17:35:13 +07:00
Tuan Pham Ngoc
79cbc8b98b Add result 2023-03-16 16:35:52 +07:00
Tuan Pham Ngoc
a4f68feacb Convert Search - Weblinks plugin to service provider 2023-03-16 16:17:31 +07:00
Tuan Pham Ngoc
6262e22a18 Convert Finder - Weblinks plugin to service provider 2023-03-16 15:55:14 +07:00
Tuan Pham Ngoc
11a50bf1cc Convert weblink editor-xtd plugin to service provider structure 2023-03-16 15:32:37 +07:00
Tuan Pham Ngoc
9bf525590b Convert System - Weblinks plugin to service provider 2023-03-16 15:11:25 +07:00
Tuan Pham Ngoc
811e133f0a Add module files manually 2023-03-16 14:50:35 +07:00
Tuan Pham Ngoc
35ab8a7048 Convert mod_weblinks module to use services provider 2023-03-16 14:45:55 +07:00
Tuan Pham Ngoc
8d928181e9
Merge pull request #513 from alikon/patch-4
php8.1deprecations
2022-11-10 22:45:16 +07:00
Nicola Galgano
2c52e13a24
php8.1-deprecated 2022-11-06 08:22:27 +01:00
Tuan Pham Ngoc
4b8cd0c779 Use getCurrentUser() to get current user in models and views 2022-09-04 23:20:31 +07:00
Tuan Pham Ngoc
5103c48c95 Replace getDbo() by getDatabase() in models 2022-09-04 22:03:36 +07:00
Tuan Pham Ngoc
86e7dc2797 Convert search plugin to use prepared statement 2022-09-04 22:01:32 +07:00
Tuan Pham Ngoc
b3953c554c Fix Deprecated when create new weblink 2022-09-04 10:16:20 +07:00
Tuan Pham Ngoc
feec722574 Add back necessary fields description 2022-09-03 18:22:18 +07:00
Tuan Pham Ngoc
4b8da16d8f Improve component config
1. Add inline help tongle button

2. Use show on for Select Icon field

3. Make Integration tab consistent with other core extensions, add missing Remove IDs from URLs parameter
2022-09-03 17:34:06 +07:00
Tuan Pham Ngoc
da9e6ecde8 Improve performance of getting weblink's tags data 2022-09-03 17:11:25 +07:00
Tuan Pham Ngoc
53578a124a Improve smart search plugin, make it works in the same way with other core plugins 2022-09-03 16:38:05 +07:00
Tuan Pham Ngoc
3f15c60950 Remove redundant column from SQL 2022-09-03 16:16:28 +07:00
Renovate Joomla Bot
32e2762578
Lock file maintenance (4.0-dev) (#507)
Co-authored-by: Renovate Bot <renovate@whitesourcesoftware.com>
2022-08-03 17:20:24 +02:00
Tuan Pham Ngoc
6c3d57cd59
Merge pull request #496 from GeraintEdwards/4.0-dev
Handle situation where webslinks are trashed within trashed categories
2022-05-20 23:32:32 +07:00
Tuan Pham Ngoc
e79bc928e9
Merge pull request #497 from chmst/controller-postsavehook
Update postsavehook params
2022-05-20 22:39:58 +07:00
chmst
21865207ee Update postsavehook params 2022-05-19 09:06:34 +02:00
Geraint Edwards
3dbcd69b8e Handle situation where webslinks are trashed within trashed categories 2022-05-18 12:11:10 +01:00
Hannes Papenberg
4b996063b7
[4.x] Updating composer dependencies (#494) 2022-04-21 14:04:07 +02:00
Hannes Papenberg
5d714e43bb
Merge pull request #443 from richard67/4.0-dev-fix-references-to-cms-staging-branch
[4.0] Fix references to the CMS staging branch
2022-04-21 10:17:32 +02:00
Tuan Pham Ngoc
7a56af50f8 PHP 8.1 compatible 2022-03-23 11:48:59 +07:00
Tuan Pham Ngoc
ba3dfff2a4 Fix method signature mismatch 2022-01-21 22:30:05 +07:00
Tuan Pham Ngoc
03954566ed Fix wrong value for Hide filter field option 2021-12-21 21:13:03 +07:00
Tuan Pham Ngoc
6fc7f0cda6 Fix robots language items 2021-12-21 18:29:11 +07:00
Tuan Pham Ngoc
5ff1fba180 Update admin-weblinks-modal.min.js 2021-12-21 18:20:54 +07:00
Tuan Pham Ngoc
73ff2844d7
Merge pull request #467 from chmst/categories-layout-fixes
[4.0] Fix adapting view categories to the core categories view
2021-10-31 17:32:26 +07:00
Tuan Pham Ngoc
4667f40277 Correct id of editors-xtd plugin in manifest 2021-10-29 16:36:50 +07:00
Tuan Pham Ngoc
e59001b982 Do not DROP TABLE to avoid data removed by mistake 2021-10-29 16:35:07 +07:00
Tuan Pham Ngoc
bfa420baa2
Merge pull request #474 from joomdonation/parameters_improvement
Improve weblinks parameter handling in weblinks module
2021-10-29 16:25:54 +07:00
Tuan Pham Ngoc
a261aa7b42 Remove unnecessary string concat 2021-10-29 15:58:09 +07:00
Tuan Pham Ngoc
5efeddf586 CS 2021-10-29 15:56:08 +07:00
Tuan Pham Ngoc
ead943e2d1 Some corrections to weblinks module layout 2021-10-29 15:52:38 +07:00
Tuan Pham Ngoc
2b84808ce3 Small code simplify 2021-10-28 22:06:16 +07:00
Tuan Pham Ngoc
56d3984ece Do not display icon when it is configured to not display 2021-10-28 21:32:04 +07:00
Tuan Pham Ngoc
3a2efc5838 Improve weblinks parameter handling in weblinks module 2021-10-28 18:43:34 +07:00
Tuan Pham Ngoc
925c4518d6 Improve item parameters merging code 2021-10-28 12:18:17 +07:00
Tuan Pham Ngoc
f4ef7768e0
Merge pull request #472 from chmst/typo-in-serviceprovider
fix typo
2021-10-27 07:42:14 +07:00
chmst
2fbc693386 fix typo 2021-10-26 18:46:23 +02:00
chmst
e01ce0337d move expand button to first line of a category 2021-10-06 13:50:05 +02:00
Tuan Pham Ngoc
1bff687429 Correct parameter name for show #Web Links 2021-10-02 13:00:55 +07:00
Tuan Pham Ngoc
27d8fdc7ce Fix typo for filter_field value 2021-10-02 12:53:07 +07:00
Tuan Pham Ngoc
6c30c95114
Merge pull request #468 from Bakual/4_FixHelp
[4.0] fix help buttons
2021-10-02 12:25:18 +07:00
Tuan Pham Ngoc
f1ef9662d0 Do not show Empty Trash button for empty state 2021-10-02 12:02:33 +07:00
Tuan Pham Ngoc
4d8a5c532d Prevent trashed web links from being displayed by default 2021-10-02 11:58:42 +07:00
Tuan Pham Ngoc
52406b258a
Merge pull request #466 from chmst/emptystate-2
Replace pr #460, add empty state
2021-10-02 11:56:33 +07:00
Thomas Hunziker
5e14f810c1 Adding help buttons for existing help pages. 2021-09-27 20:49:39 +02:00
Thomas Hunziker
36f1012f78 Hardcode the ref_keys for the help site 2021-09-27 20:40:14 +02:00
chmst
859fb5a2a0 fix alt description for image 2021-09-26 10:51:30 +02:00
chmst
9f53917bf7 move expand button to the end of a category description 2021-09-25 23:46:01 +02:00
chmst
95b07343a9 repeat adapting to com_categories 2021-09-25 23:32:56 +02:00
chmst
f53b42c8cc Replace pr #460, add empty state 2021-09-24 07:49:35 +02:00
Tuan Pham Ngoc
8aa92f906b Fix issue #463 2021-09-21 12:42:32 +07:00
Tuan Pham Ngoc
31e9e2719c Remove un-used code 2021-09-19 14:23:25 +07:00
Tuan Pham Ngoc
3b821980d9 Clear, not reset 2021-09-05 12:28:38 +07:00
Tuan Pham Ngoc
9747160c09 Update version number. 2021-09-05 11:27:23 +07:00
Tuan Pham Ngoc
19a9462651
Merge pull request #458 from chmst/remove-show-headings
Remove unused param show_headings
2021-09-05 11:02:58 +07:00
Tuan Pham Ngoc
2f999679a0
Merge pull request #457 from chmst/copyright-as-core
Adapt copyright in com_weblinks to files in joomla core
2021-09-05 10:55:10 +07:00
chmst
2a16f0fd44 Reove unused param show_headings 2021-09-01 18:55:31 +02:00
chmst
1334e9a732 Adapt copyright in com_weblinks to files in joomla core 2021-09-01 18:50:55 +02:00
Tuan Pham Ngoc
d1ed9aaa49 Update version number 2021-08-28 20:52:21 +07:00
Tuan Pham Ngoc
eb64d61a03 Let's the build script update version number 2021-08-28 17:00:08 +07:00
Tuan Pham Ngoc
ddd23d1fbc Make search plugin works with search minimal for now 2021-08-27 10:08:21 +07:00
Tuan Pham Ngoc
c3a9a90220 Minor fix to search plugin 2021-08-25 16:33:31 +07:00
Tuan Pham Ngoc
8ef8a677f9
Merge pull request #451 from joomdonation/component_params_corrections
[4.0] Component params corrections
2021-08-20 17:29:34 +07:00
Tuan Pham Ngoc
aa8a250003 Small corrections to component parameters 2021-08-20 17:28:00 +07:00
Tuan Pham Ngoc
e3933f61c6
Merge pull request #450 from chmst/frontend-edit-link-use-gloabal-float-second
[4.0] Frontend - edit weblink: Use global for float second
2021-08-20 15:59:15 +07:00
Tuan Pham Ngoc
b26903c754
Merge pull request #449 from chmst/fix-module-class-text
Thanks @chmst
2021-08-18 20:56:56 +07:00
chmst
ffc98ecb09 Use global for float second 2021-08-18 15:28:49 +02:00
chmst
338df13486 fix language class 2021-08-18 14:55:06 +02:00
Tuan Pham Ngoc
12f69ad542
Merge pull request #448 from joomdonation/bring_some_changes_from_master_to_4.0-dev
[4.0] Bring some changes from master to 4.0 dev
2021-08-18 17:27:33 +07:00
Tuan Pham Ngoc
1f0611a4f3 Bring some changes from master to 4.0-dev 2021-08-18 17:26:11 +07:00
Tuan Pham Ngoc
ac0bee47a5
Merge pull request #447 from joomdonation/small_fixes
[4.0] Few small fixes
2021-08-18 12:12:07 +07:00
Tuan Pham Ngoc
d2fba23da9 Few small fixes 2021-08-18 12:07:20 +07:00
Richard Fath
8491a67566
Merge pull request #436 from joomdonation/4.0-compatible
Make weblinks 4.0-compatible
2021-08-17 18:39:33 +02:00
Tuan Pham Ngoc
6e0dfb59af Simplify validateSection as we do not support custom fields in other view 2021-08-17 23:26:09 +07:00
Tuan Pham Ngoc
b668befbb2 Secure created_by like other core components 2021-08-17 23:24:43 +07:00
Tuan Pham Ngoc
f6a5e30925 Revert "Show custom fields in category view"
This reverts commit c4b4dfcc6f.
2021-08-17 20:07:32 +07:00
Tuan Pham Ngoc
c4b4dfcc6f Show custom fields in category view 2021-08-17 19:59:53 +07:00
Tuan Pham Ngoc
d569edd0dd Few small fixes 2021-08-17 19:11:51 +07:00
Tuan Pham Ngoc
dd71d76ebb
Merge pull request #13 from chmst/language-fixes
Language fixes
2021-08-16 17:54:28 +07:00
Tuan Pham Ngoc
10bdf18875
Merge pull request #15 from chmst/adapt-module
Adapt module layout to changes component frontend
2021-08-16 17:53:49 +07:00
Tuan Pham Ngoc
d908b846ca
Merge pull request #12 from alikon/patch-6
module - postgresql fix
2021-08-16 17:53:28 +07:00
chmst
daf0359558 Adapt module layout to changes component frontend 2021-08-16 11:24:04 +02:00
chmst
6fbb3663e8 Language fixes 2021-08-16 10:45:27 +02:00
Tuan Pham Ngoc
73b144fb48 Some old files/folders were deleted by ComponentAdapter, so we do not need to delete ourself 2021-08-16 14:11:11 +07:00
Tuan Pham Ngoc
a80e3d4dab CS Fix 2021-08-16 13:17:32 +07:00
Nicola Galgano
ea95995833
postgresql fix 2021-08-16 07:58:35 +02:00
Tuan Pham Ngoc
966e62786a Fix warning while search by ID from admin 2021-08-16 12:43:31 +07:00
Tuan Pham Ngoc
8dff15ff93 Show tags in details view 2021-08-16 12:40:29 +07:00
Tuan Pham Ngoc
72c7f9b072
Merge pull request #11 from chmst/fix-changed-float-params
Float params have changed - fix layouts
2021-08-16 12:12:35 +07:00
Tuan Pham Ngoc
eddc2a2ea7
Merge pull request #10 from chmst/weblinks-module-language-fix
fix language in module
2021-08-16 12:10:36 +07:00
chmst
a38d53c69f Add tags 2021-08-15 23:30:13 +02:00
chmst
f80b667017 Float params have changed 2021-08-15 21:58:38 +02:00
Tuan Pham Ngoc
e3f4a72281 We do not have this parameter 2021-08-15 23:27:03 +07:00
Tuan Pham Ngoc
d187fa98f8 Fix typo causes by null date change 2021-08-15 22:58:36 +07:00
Tuan Pham Ngoc
4805fc16f2 Apply auto cs fix from phpcbf 2021-08-15 22:12:14 +07:00
Richard Fath
19e2682349 Fix wrong default path in documentation 2021-08-15 16:49:06 +02:00
Richard Fath
3adac90941 Fix references to the CMS staging branch 2021-08-15 16:38:26 +02:00
Tuan Pham Ngoc
2b960d4bed Update publish_up and publish_down query after null date change 2021-08-15 20:29:13 +07:00
Tuan Pham Ngoc
c1f3652257
Merge pull request #9 from richard67/4.0-dev-joomdonation-4.0-compatible-mod-1
Real null values for datetimes and checked out user for weblinks 4.0
2021-08-15 20:20:54 +07:00
chmst
4060886ea4 fix language in module 2021-08-15 15:16:18 +02:00
Richard Fath
5d0f54ece8 Fix order of processing for postgresql 2021-08-15 14:14:52 +02:00
Richard Fath
b42034431f Real null values for checked_out 2021-08-15 14:11:24 +02:00
Richard Fath
520a1ec6a1 Real null datetimes for weblinks 4.0 2021-08-15 14:11:23 +02:00
Tuan Pham Ngoc
efa61dea5b Add edit button to weblink details view 2021-08-15 19:01:39 +07:00
Tuan Pham Ngoc
d18740065b Remove behavior.modal with bootstrap modal 2021-08-15 18:49:38 +07:00
Tuan Pham Ngoc
42d4286c6b Language files must be in $files array 2021-08-15 18:31:30 +07:00
Tuan Pham Ngoc
0530c51ad6 Add missing frontend language items 2021-08-15 18:30:16 +07:00
Tuan Pham Ngoc
be7d522bcf Remove remaining old language files 2021-08-15 17:46:25 +07:00
Tuan Pham Ngoc
20c38d7a95 Remove old language files during update 2021-08-15 17:42:11 +07:00
Tuan Pham Ngoc
931b5c453d Remove width modifier from INT data type 2021-08-15 17:39:00 +07:00
Tuan Pham Ngoc
4f9368e9dd Remove old code 2021-08-15 17:27:05 +07:00
Tuan Pham Ngoc
56e50168c3 Merge branch '4.0-compatible' of https://github.com/joomdonation/weblinks into 4.0-compatible 2021-08-15 17:24:51 +07:00
Tuan Pham Ngoc
a04d12a554 Add icon for weblink - button plugin 2021-08-15 17:23:19 +07:00
Tuan Pham Ngoc
065f724ae3
Merge pull request #8 from chmst/mod-weblinks-first
First step to mod_weblinks 4.0 compatible
2021-08-15 16:53:33 +07:00
Tuan Pham Ngoc
a2fc2fbf08 Remove un-used frontend language items 2021-08-15 16:51:40 +07:00
Tuan Pham Ngoc
47950faf90 Remove un-used backend language items 2021-08-15 16:23:51 +07:00
chmst
ef3251471a Improve layout 2021-08-15 11:20:51 +02:00
Tuan Pham Ngoc
c310ef8298 Alpha sort language items 2021-08-15 15:38:11 +07:00
Tuan Pham Ngoc
09f7753f34 Space To Tab 2021-08-15 14:03:36 +07:00
Tuan Pham Ngoc
047cee28aa Various code cleanup + permissions check improvement 2021-08-15 12:49:55 +07:00
Tuan Pham Ngoc
4274af68e3 Show Associations button on edit screen 2021-08-15 11:46:40 +07:00
Tuan Pham Ngoc
4372ed85aa Fix association on weblink edit screen 2021-08-15 11:42:09 +07:00
chmst
39b33103c0 use col, not span - bs5 2021-08-15 01:19:30 +02:00
chmst
a5e96da0ea fix some params 2021-08-15 00:34:51 +02:00
chmst
757119be52 First step to 4.0 compatible 2021-08-14 15:11:12 +02:00
Tuan Pham Ngoc
425daabf42
Merge pull request #7 from chmst/images-weblink
4.0 compatible - Add images to weblink single view
2021-08-14 18:07:10 +07:00
chmst
0ed90865ca Add images to weblink single view 2021-08-14 12:46:56 +02:00
Tuan Pham Ngoc
a25ea580fb Remove access check because it is handled inside modal already 2021-08-14 17:40:26 +07:00
Tuan Pham Ngoc
19c67005f0 Missing language items + correct typo 2021-08-14 15:59:18 +07:00
Tuan Pham Ngoc
c3bf647c03 Fix categories accordion 2021-08-14 15:32:36 +07:00
Tuan Pham Ngoc
515471ca54
Merge pull request #6 from chmst/40-weblinks-blog-layout
4.0-compatible-frontend-fixes
2021-08-14 15:16:03 +07:00
chmst
0528642f90 fix edit form caption 2021-08-12 09:57:34 +02:00
chmst
92b8d92e2a fix options float 2021-08-12 09:56:55 +02:00
chmst
46205b2dcd admin edit form use global 2021-08-12 09:55:58 +02:00
chmst
ed31e08ba6 fix form - image alt empty 2021-08-12 09:26:26 +02:00
chmst
1288cc3270 Language strings in weblink form 2021-08-12 09:15:44 +02:00
chmst
fb07654070 fix no weblinks found, add new button 2021-08-12 09:13:58 +02:00
Tuan Pham Ngoc
efe415d633 Clear search value when Clear button is pressed 2021-08-11 21:32:58 +07:00
Tuan Pham Ngoc
66f238e1c4
Merge pull request #5 from chmst/wblinks-blog-layout
Rebuild weblinks overview
2021-08-11 17:44:45 +07:00
chmst
d195434aa9 Rebuild weblinks overview 2021-08-11 12:38:04 +02:00
Tuan Pham Ngoc
cbefa5cdf8 Fix delete permission 2021-08-11 12:42:57 +07:00
Tuan Pham Ngoc
91a7214d1d Fix empty trash error 2021-08-11 12:37:58 +07:00
Tuan Pham Ngoc
0fb8a4be86
Merge pull request #4 from chmst/40-compatible-layouts2
40 compatible layouts2
2021-08-10 22:58:55 +07:00
chmst
6bcda2fa50 Add images to the frontend edit view 2021-08-10 16:05:04 +02:00
chmst
5c0d9d9da5 Add image-alt-empty to images in backend 2021-08-10 15:41:50 +02:00
chmst
eafb0239f5 badge background 2021-08-10 15:25:09 +02:00
chmst
45b9e33466 fix save in frontend 2021-08-10 15:15:18 +02:00
Tuan Pham Ngoc
fcf6986194 Typo 2021-07-30 13:34:10 +07:00
Tuan Pham Ngoc
b7d4a32fe4 Simplify + optimize tags display 2021-07-30 13:22:34 +07:00
Tuan Pham Ngoc
efae6df533 Improve menu params handling 2021-07-30 13:15:31 +07:00
Tuan Pham Ngoc
1bc0b8ea82 Fix batch action + minor cleanup 2021-07-30 13:05:35 +07:00
Tuan Pham Ngoc
ddb6bf3c91 Move model creation into getList method (same with core) 2021-07-30 12:34:21 +07:00
Tuan Pham Ngoc
baddd59e16
Merge pull request #3 from chmst/4.0-compatible-layouts-frontend
4.0 compatible layouts frontend
2021-07-29 22:04:13 +07:00
Tuan Pham Ngoc
57077f04df
Merge pull request #2 from chmst/4.0-compatible-layouts
4.0 compatible layouts
2021-07-29 22:03:55 +07:00
chmst
54e3d39a5c default-children 2021-07-29 09:03:53 +02:00
chmst
83b37e4699 cs 2021-07-29 09:03:32 +02:00
chmst
43145030c7 Layout Weblinks Category - first attempt 2021-07-26 21:14:51 +02:00
chmst
3b0edd7d49 changes as desired 2021-07-26 18:19:05 +02:00
chmst
5dc2bfb818 Merge branch '4.0-compatible-layouts' into 4.0-compatible-layouts-frontend 2021-07-26 17:08:20 +02:00
chmst
e5251bf473 revert last change 2021-07-25 23:52:10 +02:00
chmst
d822541c7e Remove tab layout from menu item type categories 2021-07-25 23:28:28 +02:00
chmst
f4bc69f6c6 indent with tabs 2021-07-25 23:12:01 +02:00
chmst
be8e34e76a adapt categories default.xml 2021-07-25 22:32:09 +02:00
chmst
b065affd47 Adapt weblink.xml to J4 2021-07-23 20:17:49 +02:00
chmst
5a2d9859f8 Hide language in batch 2021-07-22 23:18:49 +02:00
chmst
e6c5daafa7 adapt weblink edit form 2021-07-22 22:01:42 +02:00
chmst
3483659877 batch modal 2021-07-22 22:00:20 +02:00
chmst
d5512492f0 Adapt weblinks modal to J4 2021-07-21 15:19:00 +02:00
chmst
89554eea66 Adapt filter weblinks to j4 to j4 2021-07-21 13:48:24 +02:00
chmst
c39f02ba0f fix variable name 2021-07-21 13:46:38 +02:00
chmst
f898f9ba7d Adapted to J4 2021-07-20 14:37:31 +02:00
chmst
74b5ae8cfa Remove descriptions in J4 2021-07-20 11:25:26 +02:00
chmst
469442699d Adapt config.xml to j4 2021-07-20 11:23:41 +02:00
Harald Leithner
63a03c5a33
Update .drone.yml 2021-07-19 15:23:16 +02:00
Harald Leithner
f9cd3409b7
Update .drone.yml 2021-07-19 15:21:37 +02:00
Harald Leithner
7ea20a7586
Update .drone.yml 2021-07-19 15:19:15 +02:00
Harald Leithner
37052b942b
Update .drone.yml 2021-07-19 15:15:37 +02:00
Harald Leithner
c70fe166ab
Update .drone.yml 2021-07-19 15:13:36 +02:00
Harald Leithner
8234904c4e
Update codeception.yml 2021-07-19 15:08:00 +02:00
Harald Leithner
85dfec4235
Update build.sh 2021-07-19 15:07:41 +02:00
Harald Leithner
df177b5a66
Update build.sh 2021-07-19 15:03:36 +02:00
Harald Leithner
c366d57d0d
Update build.sh 2021-07-19 15:01:41 +02:00
Harald Leithner
6588b7e55d
Update .drone.yml 2021-07-19 14:38:21 +02:00
Harald Leithner
6e6814a200
Update .drone.yml 2021-07-19 14:33:35 +02:00
Harald Leithner
a032eded85
Update .drone.yml 2021-07-19 14:32:15 +02:00
Harald Leithner
528a3fd2c5
Update .drone.yml 2021-07-19 14:21:40 +02:00
Harald Leithner
89c1cd7d78
Update .drone.yml 2021-07-19 14:19:56 +02:00
Harald Leithner
3202988ee3
Update .drone.yml 2021-07-19 14:19:14 +02:00
Tuan Pham Ngoc
6bedd432f8 Fix frontend edit weblink URL 2021-07-18 20:02:12 +07:00
Tuan Pham Ngoc
9107b7e1de Clean up code 2021-07-18 18:39:55 +07:00
Tuan Pham Ngoc
8d714ace8d Adding menu items to com_fields should be simple 2021-07-18 18:23:35 +07:00
Tuan Pham Ngoc
706d6777b1 Remove un-used language items 2021-07-17 23:05:45 +07:00
Tuan Pham Ngoc
31d588492b Add Fields and Field Groups menu item during installation 2021-07-17 22:43:08 +07:00
Tuan Pham Ngoc
c50f4c7dbe Remove spacer field as it is used on description of field set 2021-07-17 20:33:20 +07:00
Tuan Pham Ngoc
e6e8b6c9ea Remove description from fields in menu item types 2021-07-17 20:17:28 +07:00
Tuan Pham Ngoc
f7d819bb6e Remove description from some fields in component config (base on similar settings in com_contact) 2021-07-17 20:01:24 +07:00
Tuan Pham Ngoc
193f549f05 Use switcher for radio settings 2021-07-17 18:23:53 +07:00
Tuan Pham Ngoc
2219b15291 Look like $item->path is not used in J4 anymore 2021-07-17 18:03:24 +07:00
Tuan Pham Ngoc
c3cf5e6936 Fix errors on weblinks module 2021-07-17 17:56:09 +07:00
Tuan Pham Ngoc
30c155797f Replace Factory::getConfig()->get with Factory::getApplication()->get 2021-07-17 17:42:53 +07:00
Tuan Pham Ngoc
226e81f7ab Fix prepared statement, we need different parameters to bind same value :( 2021-07-17 17:40:29 +07:00
Tuan Pham Ngoc
8b9d34ca7d Replace deprecated castAsChar with castAs 2021-07-17 11:58:17 +07:00
Tuan Pham Ngoc
01bc443bc0 Replace Factory::getUser() with Factory::getApplication()->getIdentity() 2021-07-17 11:49:07 +07:00
Tuan Pham Ngoc
92d01d2bc6 Misc Cleanup to component code 2021-07-17 11:45:13 +07:00
Tuan Pham Ngoc
c6455b275a Convert frontend models to prepared statements 2021-07-16 23:53:54 +07:00
Tuan Pham Ngoc
e225dc705e Convert backend models to prepared statement 2021-07-16 23:02:40 +07:00
Tuan Pham Ngoc
269b6f0bbf Convert remaining J classes to namespace 2021-07-16 21:58:51 +07:00
Tuan Pham Ngoc
a2ca619d87 use Joomla\CMS\Layout\LayoutHelper; 2021-07-16 21:51:48 +07:00
Tuan Pham Ngoc
7918b466dc Merge branch '4.0-dev' into 4.0-compatible 2021-07-11 20:08:29 +07:00
Tuan Pham Ngoc
f4108b74b3 Drop SQL Server support 2021-07-10 18:25:33 +07:00
Tuan Pham Ngoc
3a8c0c10b5 Delete files/folders when update from old version 2021-07-10 18:23:14 +07:00
Tuan Pham Ngoc
56ddfa6938 Look like metadata.xml is not used in J4 anymore 2021-07-10 17:41:49 +07:00
Tuan Pham Ngoc
98e0ee2bed Minor clean up to submit weblink form 2021-07-10 17:35:11 +07:00
Tuan Pham Ngoc
70bb539931 Basic category layout (base on layout from com_contact) 2021-07-10 17:28:40 +07:00
Tuan Pham Ngoc
c2084a7ff9 Borrow categories layout from com_contact 2021-07-09 23:05:55 +07:00
Tuan Pham Ngoc
02baa68d28 Support Custom Fields 2021-07-09 19:43:13 +07:00
Tuan Pham Ngoc
a007ae9a2c Optimize namespace import 2021-07-09 16:42:45 +07:00
Tuan Pham Ngoc
ffd3663c58 More Copy/paste fixes 2021-07-01 22:06:22 +07:00
Tuan Pham Ngoc
1cab511a4e Replace JRoute 2021-07-01 21:55:05 +07:00
Tuan Pham Ngoc
d42ef8dbdf Replace JFactory 2021-07-01 21:46:35 +07:00
Tuan Pham Ngoc
bab5787a77 Replace JText with use Joomla\CMS\Language\Text; 2021-07-01 21:41:54 +07:00
Tuan Pham Ngoc
4d3e52bd73 Replace JHtml with HTMLHelper 2021-07-01 21:37:36 +07:00
Tuan Pham Ngoc
84d245a445 Another copy/paste 2021-07-01 21:26:06 +07:00
Tuan Pham Ngoc
3f5df08915 Fix copy/paste errors 2021-07-01 21:25:05 +07:00
Tuan Pham Ngoc
e7c0beed89
Merge pull request #1 from alikon/patch-6
fix for postgresql
2021-06-27 19:34:13 +07:00
Harald Leithner
6bffc54ccb
Move to new docker images and composer update (#438)
* Move to new docker images

* Update composer dependencies

* Sign drone
2021-06-27 13:46:07 +02:00
Tuan Pham Ngoc
882e4ac7dc Correct language file for package 2021-06-27 18:21:50 +07:00
Nicola Galgano
af30a2a151
frontend save 2021-06-27 09:53:37 +02:00
Nicola Galgano
9b9e42ff5d
hits for postgres 2021-06-27 09:28:50 +02:00
Tuan Pham Ngoc
b9330b42a9 Codestyle error fixes 2021-06-26 17:36:16 +07:00
Tuan Pham Ngoc
f9d7f8625b CS 2021-06-26 17:13:37 +07:00
Tuan Pham Ngoc
a39c5f6b12 Remove manual setState calls 2021-06-26 14:18:27 +07:00
Tuan Pham Ngoc
15466baa0f Set default value for fields (fix frontend submit weblink error) 2021-06-26 14:12:43 +07:00
Tuan Pham Ngoc
6c68bcad5d Make weblink editor-xtd works 2021-06-25 23:56:03 +07:00
Tuan Pham Ngoc
1a415435af Remove un-used helpers 2021-06-25 18:33:44 +07:00
Tuan Pham Ngoc
922e4353eb Convert weblinks module 2021-06-25 17:57:37 +07:00
Tuan Pham Ngoc
49242aa1e2 Convert weblink editor-xtd plugin 2021-06-25 17:11:42 +07:00
Tuan Pham Ngoc
6186bfe022 Convert weblinks system plugin 2021-06-25 17:04:12 +07:00
Tuan Pham Ngoc
3d07471705 Convert search plugin 2021-06-25 16:57:30 +07:00
Tuan Pham Ngoc
13c2dc32da Convert weblinks finder plugin 2021-06-25 16:49:01 +07:00
Tuan Pham Ngoc
23650d0891 Add back icon and route class for backward compatible purpose 2021-06-20 21:42:26 +07:00
Tuan Pham Ngoc
7b12f1c360 Remove JHtmlIcon classs 2021-06-20 20:26:27 +07:00
Tuan Pham Ngoc
d455713663 Remove un-necessary JHtml::addIncludePath usage 2021-06-20 20:25:16 +07:00
Tuan Pham Ngoc
554dde6c03 Add icon service 2021-06-20 20:21:32 +07:00
Tuan Pham Ngoc
8336c0095d Use weblinksadministrator service to display associations 2021-06-20 20:19:36 +07:00
Tuan Pham Ngoc
b7f9b7056f Typo 2021-06-20 19:41:16 +07:00
Tuan Pham Ngoc
f499b9ee7b Start supporting Multilingual Associations 2021-06-20 18:40:26 +07:00
Tuan Pham Ngoc
0c4a9ce8b5 Add HTML Service 2021-06-20 18:25:20 +07:00
Tuan Pham Ngoc
08fe10e0ef Weblink Model Field 2021-06-20 17:58:47 +07:00
Tuan Pham Ngoc
703477306a Support version history 2021-06-20 16:53:42 +07:00
Tuan Pham Ngoc
56c770f088 Remove tag field description, it is not needed for J4 2021-06-20 16:41:51 +07:00
Tuan Pham Ngoc
908870576f Use namespace class + remove un-used code 2021-06-20 16:33:55 +07:00
Tuan Pham Ngoc
17fbda865c Controller Cleanup 2021-06-20 16:27:34 +07:00
Tuan Pham Ngoc
02f9811d37 Quick change to weblinks list 2021-06-20 16:16:01 +07:00
Tuan Pham Ngoc
b7fe535a17 Use J4 Toolbar 2021-06-20 15:45:18 +07:00
Tuan Pham Ngoc
31a4a595c1 Fix weblinks details page 2021-06-20 12:49:35 +07:00
Tuan Pham Ngoc
b318b68d07 Make weblinks 4.0-compatible 2021-06-19 21:17:09 +07:00
Tobias Zulauf
c1cff7a7ed
[4.0] Move de-DE to this repo (#415) 2020-09-07 12:38:49 +01:00
wilsonge
1559654ddc
Bump string package to fix build on PHP 7.4 2020-03-11 19:00:46 +00:00
George Wilson
ff97f09a8e
Bump version number 2020-03-11 18:57:28 +00:00
Thomas Hunziker
aed17785a4
Remove language file prefix (#417) 2020-03-11 18:42:02 +00:00
George Wilson
25fa454c98
Remove not required code in j4 2019-09-05 15:57:42 +01:00
wilsonge
2be3dec52a
Allow editing the form 2019-08-19 21:48:37 +01:00
wilsonge
828325e86c
Move to new dispatcher concept 2019-08-19 21:47:59 +01:00
wilsonge
5f348f81b9
Fix merge conflict 2019-08-19 20:53:36 +01:00
wilsonge
3b8ade5bd8
Merge branch 'master' into 4.0-dev 2019-08-19 20:52:26 +01:00
Allon Moritz
2247d9ba4d Move to namespaces (#384)
* Make it joomla 4 compatible

* Joomla 4 compatibility

* Move to dispatcher

* Move controller.php to DisplayController

* Define default view for DisplayController

* Move the model weblinks.php to WeblinksModel

* Move the view weblinks list view view.html.php to HtmlView.php

* Move the view templates like default.php to the right position

* Move the weblinks controller weblins.php to WeblinksController.php

* Move the weblink model weblink.php to WeblinkModel.php

* Remove the get table function in the WeblinkModel

* Moved the table weblink.php to WeblinkTable.php

* Moved the controller weblink.php to WeblinkController.php

* Moved the web link form view view.html.php to HtmlView.php

* Move the weblink layouts to the right folder

* Convert list template to Bootstrap 4

* Convert form layout to Bootstrap 4

* Move forms to root folder

* Namespace field

* Calling the parent check function in the table

* Adapt travis file

* Pass factory to parent class
2018-02-19 10:44:55 +01:00
193 changed files with 15419 additions and 10102 deletions

View File

@ -3,28 +3,152 @@ kind: pipeline
name: default
steps:
- name: weblinks-codeception-tests
image: joomlaprojects/docker-systemtests:latest
- name: composer
image: joomlaprojects/docker-images:php8.2
volumes:
- name: composer-cache
path: /tmp/composer-cache
commands:
- composer install
- chmod a+x .drone/build.sh
- ./.drone/build.sh
- apache2ctl start
- service mysql start
- cd /tests/www
- export DISPLAY=:0
- Xvfb -screen 0 1024x768x24 -ac +extension GLX +render -noreset > /dev/null 2>&1 &
- sleep 3
- fluxbox > /dev/null 2>&1 &
- vendor/bin/robo run:tests
- composer install --no-progress
- name: phpcs
image: joomlaprojects/docker-images:php8.1
depends_on: [ composer ]
commands:
- echo $(date)
- ./vendor/bin/php-cs-fixer fix -vvv --dry-run --diff
- ./vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml src/
- echo $(date)
- name: npm
image: node:16-bullseye-slim
depends_on: [ phpcs ]
volumes:
- name: npm-cache
path: /tmp/npm-cache
environment:
npm_config_cache: /tmp/npm-cache
commands:
- npm i --unsafe-perm
- name: prepare_system_tests
depends_on: [ npm ]
image: joomlaprojects/docker-images:systemtests
volumes:
- name: cypress-cache
path: /root/.cache/Cypress
commands:
- mv cypress.config.dist.js cypress.config.js
- npx cypress install
- npx cypress verify
- vendor/bin/robo build
- curl https://joomla.org/latest -L --output joomla.zip
- mkdir joomla
- cp joomla.zip joomla/joomla.zip
- cd joomla
- unzip joomla.zip
- name: phan
image: joomlaprojects/docker-images:php8.1-ast
depends_on: [ prepare_system_tests ]
failure: ignore
commands:
- vendor/bin/phan
- name: phpstan
image: joomlaprojects/docker-images:php8.1
depends_on: [ prepare_system_tests ]
failure: ignore
commands:
- vendor/bin/phpstan analyse src
- name: phpmin-system-mysql
depends_on: [ prepare_system_tests ]
image: joomlaprojects/docker-images:cypress
volumes:
- name: cypress-cache
path: /root/.cache/Cypress
commands:
- mkdir /tests/www/mysql/
- cp joomla.zip /tests/www/mysql/joomla.zip
- cp dist/pkg-weblinks-current.zip /tests/www/mysql/pkg-weblinks-current.zip
- cd /tests/www/mysql/
- unzip joomla.zip
- apache2ctl -D FOREGROUND &
- chmod +rwx /root
- php installation/joomla.php install --verbose --site-name="Joomla CMS test" --admin-email=admin@example.org --admin-username=ci-admin --admin-user="jane doe" --admin-password=joomla-17082005 --db-type=mysqli --db-host=mysql --db-name=test_joomla --db-pass=joomla_ut --db-user=root --db-encryption=0 --db-prefix=mysql_
- php cli/joomla.php config:set debug=true error_reporting=maximum
- php cli/joomla.php extension:install --path=/tests/www/mysql/pkg-weblinks-current.zip
- chmod -R 777 /tests/www/mysql/
- chown -R www-data /tests/www/mysql/
- cd /drone/src
- npx cypress run --browser=firefox --e2e --config baseUrl=http://localhost/mysql,screenshotsFolder=/drone/src/tests/cypress/output/screenshots
- name: artifacts-system-tests
image: joomlaprojects/docker-images:packager
depends_on:
- phpmin-system-mysql
environment:
FTP_USERNAME:
from_secret: ftpusername
FTP_PASSWORD:
from_secret: ftppassword
GITHUB_TOKEN:
from_secret: github_token
commands:
- export PLUGIN_DEST_DIR=/artifacts/$DRONE_REPO/$DRONE_BRANCH/$DRONE_PULL_REQUEST/system-tests/$DRONE_BUILD_NUMBER
- echo https://ci.joomla.org$PLUGIN_DEST_DIR
- rclone config create artifacts ftp host ci.joomla.org user $FTP_USERNAME port 21 pass $FTP_PASSWORD
- rclone mkdir artifacts:$PLUGIN_DEST_DIR
- rclone copy tests/cypress/output/ artifacts:$PLUGIN_DEST_DIR
- 'curl -X POST "https://api.github.com/repos/$DRONE_REPO/statuses/$DRONE_COMMIT" -H "Content-Type: application/json" -H "Authorization: token $GITHUB_TOKEN" -d "{\"state\":\"failure\", \"context\": \"Artifacts from Failure\", \"description\": \"You can find artifacts from the failure of the build here:\", \"target_url\": \"https://ci.joomla.org$PLUGIN_DEST_DIR\"}" > /dev/null'
when:
status:
- failure
volumes:
- name: weblinks_cache
host:
path: /tmp/weblinks_cache
- name: composer-cache
host:
path: /tmp/composer-cache
- name: cypress-cache
host:
path: /tmp/cypress-cache
- name: npm-cache
host:
path: /tmp/npm-cache
services:
- name: mysql
image: mysql:5.7
environment:
MYSQL_USER: joomla_ut
MYSQL_PASSWORD: joomla_ut
MYSQL_ROOT_PASSWORD: joomla_ut
MYSQL_DATABASE: test_joomla
- name: mysql8
image: mysql:8
command: ["--default-authentication-plugin=mysql_native_password"]
environment:
MYSQL_USER: joomla_ut
MYSQL_PASSWORD: joomla_ut
MYSQL_ROOT_PASSWORD: joomla_ut
MYSQL_DATABASE: test_joomla
- name: postgres
image: postgres:11-alpine
ports:
- 5432
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: joomla_ut
POSTGRES_DB: test_joomla
---
kind: signature
hmac: 41c9d399a788c8e97a0444ee8483682cfcb5b21d920b4012852a48ed3b2e9db8
hmac: 8b2b4e6fe85da897755c46d961b49c1e53a13e5a2cf6df5cde70aa07233b2494
...

View File

@ -22,6 +22,8 @@ cd /tests/www
cp jorobo.dist.ini jorobo.ini
cp RoboFile.dist.ini RoboFile.ini
# Build package
vendor/bin/robo build --dev

20
.editorconfig Normal file
View File

@ -0,0 +1,20 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style end of lines and a blank line at the end of the file
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.php]
indent_style = space
indent_size = 4
[*.{js,json,scss,css,yml,vue}]
indent_style = space
indent_size = 2

137
.gitignore vendored
View File

@ -1,64 +1,73 @@
# Builds
build
releases
# OSX
.DS_Store
._*
.Spotlight-V100
.Trashes
# Windows
Thumbs.db
Desktop.ini
# PHPStorm
.idea/
# Sublime Text
*.sublime*
# Eclipse
.buildpath
.project
.settings
# Temp files
*.tmp
*.bak
*.swp
*~.nib
*~
# Phing
build.properties
phing-latest.phar
# Github pages and Jekyll files
/_site/
/Gemfile
/Gemfile.lock
# composer
composer.phar
vendor/*
# Robo
robo.phar
RoboFile.ini
# Test related files
tests/acceptance.suite.yml
tests/*/*Tester.php
tests/_support/_generated/*TesterActions.php
tests/joomla*
tests/_output*
selenium-server-standalone.jar
codecept.phar
selenium.log
tests/cache
# Package building related
/dist
jorobo.ini
# Builds
build
releases
# OSX
.DS_Store
._*
.Spotlight-V100
.Trashes
# Windows
Thumbs.db
Desktop.ini
# PHPStorm
.idea/
# Sublime Text
*.sublime*
# Eclipse
.buildpath
.project
.settings
# Temp files
*.tmp
*.bak
*.swp
*~.nib
*~
# Phing
build.properties
phing-latest.phar
# Github pages and Jekyll files
/_site/
/Gemfile
/Gemfile.lock
# composer
composer.phar
vendor/*
# Robo
robo.phar
RoboFile.ini
# Test related files
tests/acceptance.suite.yml
tests/*/*Tester.php
tests/_support/_generated/*TesterActions.php
tests/joomla*
tests/_output*
selenium-server-standalone.jar
codecept.phar
selenium.log
tests/cache
#cypress
node_modules
/tests/cypress/output/screenshots
!/tests/cypress/output/screenshots/.gitkeep
/tests/cypress/output/videos
!/tests/cypress/output/videos/.gitkeep
cypress.config.js
joomla
# Package building related
/dist
jorobo.ini

350
.phan/config.php Normal file
View File

@ -0,0 +1,350 @@
<?php
/**
* This configuration file was automatically generated by 'phan --init --init-level=5'
*
* TODOs (added by 'phan --init'):
*
* - Go through this file and verify that there are no missing/unnecessary files/directories.
* (E.g. this only includes direct composer dependencies - You may have to manually add indirect composer dependencies to 'directory_list')
* - Look at 'plugins' and add or remove plugins if appropriate (see https://github.com/phan/phan/tree/v4/.phan/plugins#plugins)
* - Add global suppressions for pre-existing issues to suppress_issue_types (https://github.com/phan/phan/wiki/Tutorial-for-Analyzing-a-Large-Sloppy-Code-Base)
* - Consider setting up a baseline if there are a large number of pre-existing issues (see `phan --extended-help`)
*
* This configuration will be read and overlaid on top of the
* default configuration. Command line arguments will be applied
* after this file is read.
*
* @see https://github.com/phan/phan/wiki/Phan-Config-Settings for all configurable options
* @see https://github.com/phan/phan/tree/v4/src/Phan/Config.php
*
* A Note About Paths
* ==================
*
* Files referenced from this file should be defined as
*
* ```
* Config::projectPath('relative_path/to/file')
* ```
*
* where the relative path is relative to the root of the
* project which is defined as either the working directory
* of the phan executable or a path passed in via the CLI
* '-d' flag.
*/
use Phan\Issue;
return [
// The PHP version that the codebase will be checked for compatibility against.
// For best results, the PHP binary used to run Phan should have the same PHP version.
// (Phan relies on Reflection for some types, param counts,
// and checks for undefined classes/methods/functions)
//
// Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, `null`.
// If this is set to `null`,
// then Phan assumes the PHP version which is closest to the minor version
// of the php executable used to execute Phan.
//
// Note that the **only** effect of choosing `'5.6'` is to infer that functions removed in php 7.0 exist.
// (See `backward_compatibility_checks` for additional options)
// Automatically inferred from composer.json requirement for "php" of "^7.2.5"
'target_php_version' => '8.1',
// If enabled, missing properties will be created when
// they are first seen. If false, we'll report an
// error message if there is an attempt to write
// to a class property that wasn't explicitly
// defined.
'allow_missing_properties' => true,
// If enabled, null can be cast to any type and any
// type can be cast to null. Setting this to true
// will cut down on false positives.
'null_casts_as_any_type' => true,
// If enabled, allow null to be cast as any array-like type.
//
// This is an incremental step in migrating away from `null_casts_as_any_type`.
// If `null_casts_as_any_type` is true, this has no effect.
'null_casts_as_array' => true,
// If enabled, allow any array-like type to be cast to null.
// This is an incremental step in migrating away from `null_casts_as_any_type`.
// If `null_casts_as_any_type` is true, this has no effect.
'array_casts_as_null' => true,
// If enabled, scalars (int, float, bool, string, null)
// are treated as if they can cast to each other.
// This does not affect checks of array keys. See `scalar_array_key_cast`.
'scalar_implicit_cast' => true,
// If enabled, any scalar array keys (int, string)
// are treated as if they can cast to each other.
// E.g. `array<int,stdClass>` can cast to `array<string,stdClass>` and vice versa.
// Normally, a scalar type such as int could only cast to/from int and mixed.
'scalar_array_key_cast' => true,
// If this has entries, scalars (int, float, bool, string, null)
// are allowed to perform the casts listed.
//
// E.g. `['int' => ['float', 'string'], 'float' => ['int'], 'string' => ['int'], 'null' => ['string']]`
// allows casting null to a string, but not vice versa.
// (subset of `scalar_implicit_cast`)
'scalar_implicit_partial' => [],
// If enabled, Phan will warn if **any** type in a method invocation's object
// is definitely not an object,
// or if **any** type in an invoked expression is not a callable.
// Setting this to true will introduce numerous false positives
// (and reveal some bugs).
'strict_method_checking' => false,
// If enabled, Phan will warn if **any** type of the object expression for a property access
// does not contain that property.
'strict_object_checking' => false,
// If enabled, Phan will warn if **any** type in the argument's union type
// cannot be cast to a type in the parameter's expected union type.
// Setting this to true will introduce numerous false positives
// (and reveal some bugs).
'strict_param_checking' => false,
// If enabled, Phan will warn if **any** type in a property assignment's union type
// cannot be cast to a type in the property's declared union type.
// Setting this to true will introduce numerous false positives
// (and reveal some bugs).
'strict_property_checking' => false,
// If enabled, Phan will warn if **any** type in a returned value's union type
// cannot be cast to the declared return type.
// Setting this to true will introduce numerous false positives
// (and reveal some bugs).
'strict_return_checking' => false,
// If true, seemingly undeclared variables in the global
// scope will be ignored.
//
// This is useful for projects with complicated cross-file
// globals that you have no hope of fixing.
'ignore_undeclared_variables_in_global_scope' => true,
// Set this to false to emit `PhanUndeclaredFunction` issues for internal functions that Phan has signatures for,
// but aren't available in the codebase, or from Reflection.
// (may lead to false positives if an extension isn't loaded)
//
// If this is true(default), then Phan will not warn.
//
// Even when this is false, Phan will still infer return values and check parameters of internal functions
// if Phan has the signatures.
'ignore_undeclared_functions_with_known_signatures' => true,
// Backwards Compatibility Checking. This is slow
// and expensive, but you should consider running
// it before upgrading your version of PHP to a
// new version that has backward compatibility
// breaks.
//
// If you are migrating from PHP 5 to PHP 7,
// you should also look into using
// [php7cc (no longer maintained)](https://github.com/sstalle/php7cc)
// and [php7mar](https://github.com/Alexia/php7mar),
// which have different backwards compatibility checks.
//
// If you are still using versions of php older than 5.6,
// `PHP53CompatibilityPlugin` may be worth looking into if you are not running
// syntax checks for php 5.3 through another method such as
// `InvokePHPNativeSyntaxCheckPlugin` (see .phan/plugins/README.md).
'backward_compatibility_checks' => false,
// If true, check to make sure the return type declared
// in the doc-block (if any) matches the return type
// declared in the method signature.
'check_docblock_signature_return_type_match' => true,
// This setting maps case-insensitive strings to union types.
//
// This is useful if a project uses phpdoc that differs from the phpdoc2 standard.
//
// If the corresponding value is the empty string,
// then Phan will ignore that union type (E.g. can ignore 'the' in `@return the value`)
//
// If the corresponding value is not empty,
// then Phan will act as though it saw the corresponding UnionTypes(s)
// when the keys show up in a UnionType of `@param`, `@return`, `@var`, `@property`, etc.
//
// This matches the **entire string**, not parts of the string.
// (E.g. `@return the|null` will still look for a class with the name `the`, but `@return the` will be ignored with the below setting)
//
// (These are not aliases, this setting is ignored outside of doc comments).
// (Phan does not check if classes with these names exist)
//
// Example setting: `['unknown' => '', 'number' => 'int|float', 'char' => 'string', 'long' => 'int', 'the' => '']`
'phpdoc_type_mapping' => [],
// Set to true in order to attempt to detect dead
// (unreferenced) code. Keep in mind that the
// results will only be a guess given that classes,
// properties, constants and methods can be referenced
// as variables (like `$class->$property` or
// `$class->$method()`) in ways that we're unable
// to make sense of.
//
// To more aggressively detect dead code,
// you may want to set `dead_code_detection_prefer_false_negative` to `false`.
'dead_code_detection' => false,
// Set to true in order to attempt to detect unused variables.
// `dead_code_detection` will also enable unused variable detection.
//
// This has a few known false positives, e.g. for loops or branches.
'unused_variable_detection' => false,
// Set to true in order to attempt to detect redundant and impossible conditions.
//
// This has some false positives involving loops,
// variables set in branches of loops, and global variables.
'redundant_condition_detection' => false,
// If enabled, Phan will act as though it's certain of real return types of a subset of internal functions,
// even if those return types aren't available in reflection (real types were taken from php 7.3 or 8.0-dev, depending on target_php_version).
//
// Note that with php 7 and earlier, php would return null or false for many internal functions if the argument types or counts were incorrect.
// As a result, enabling this setting with target_php_version 8.0 may result in false positives for `--redundant-condition-detection` when codebases also support php 7.x.
'assume_real_types_for_internal_functions' => false,
// If true, this runs a quick version of checks that takes less
// time at the cost of not running as thorough
// of an analysis. You should consider setting this
// to true only when you wish you had more **undiagnosed** issues
// to fix in your code base.
//
// In quick-mode the scanner doesn't rescan a function
// or a method's code block every time a call is seen.
// This means that the problem here won't be detected:
//
// ```php
// <?php
// function test($arg):int {
// return $arg;
// }
// test("abc");
// ```
//
// This would normally generate:
//
// ```
// test.php:3 PhanTypeMismatchReturn Returning type string but test() is declared to return int
// ```
//
// The initial scan of the function's code block has no
// type information for `$arg`. It isn't until we see
// the call and rescan `test()`'s code block that we can
// detect that it is actually returning the passed in
// `string` instead of an `int` as declared.
'quick_mode' => false,
// Override to hardcode existence and types of (non-builtin) globals in the global scope.
// Class names should be prefixed with `\`.
//
// (E.g. `['_FOO' => '\FooClass', 'page' => '\PageClass', 'userId' => 'int']`)
'globals_type_map' => [],
// The minimum severity level to report on. This can be
// set to `Issue::SEVERITY_LOW`, `Issue::SEVERITY_NORMAL` or
// `Issue::SEVERITY_CRITICAL`. Setting it to only
// critical issues is a good place to start on a big
// sloppy mature code base.
'minimum_severity' => Issue::SEVERITY_NORMAL,
// Add any issue types (such as `'PhanUndeclaredMethod'`)
// to this list to inhibit them from being reported.
'suppress_issue_types' => ['PhanDeprecatedClass', 'PhanUndeclaredConstant','PhanDeprecatedFunction'],
// A regular expression to match files to be excluded
// from parsing and analysis and will not be read at all.
//
// This is useful for excluding groups of test or example
// directories/files, unanalyzable files, or files that
// can't be removed for whatever reason.
// (e.g. `'@Test\.php$@'`, or `'@vendor/.*/(tests|Tests)/@'`)
'exclude_file_regex' => '',
// A list of files that will be excluded from parsing and analysis
// and will not be read at all.
//
// This is useful for excluding hopelessly unanalyzable
// files that can't be removed for whatever reason.
'exclude_file_list' => [
],
// A directory list that defines files that will be excluded
// from static analysis, but whose class and method
// information should be included.
//
// Generally, you'll want to include the directories for
// third-party code (such as "vendor/") in this list.
//
// n.b.: If you'd like to parse but not analyze 3rd
// party code, directories containing that code
// should be added to the `directory_list` as well as
// to `exclude_analysis_directory_list`.
'exclude_analysis_directory_list' => [
'joomla/administrator/components/com_finder/src/Indexer',
'joomla/libraries'
],
// Enable this to enable checks of require/include statements referring to valid paths.
// The settings `include_paths` and `warn_about_relative_include_statement` affect the checks.
'enable_include_path_checks' => false,
// The number of processes to fork off during the analysis
// phase.
'processes' => 1,
// List of case-insensitive file extensions supported by Phan.
// (e.g. `['php', 'html', 'htm']`)
'analyzed_file_extensions' => [
'php',
],
// You can put paths to stubs of internal extensions in this config option.
// If the corresponding extension is **not** loaded, then Phan will use the stubs instead.
// Phan will continue using its detailed type annotations,
// but load the constants, classes, functions, and classes (and their Reflection types)
// from these stub files (doubling as valid php files).
// Use a different extension from php to avoid accidentally loading these.
// The `tools/make_stubs` script can be used to generate your own stubs (compatible with php 7.0+ right now)
//
// (e.g. `['xdebug' => '.phan/internal_stubs/xdebug.phan_php']`)
'autoload_internal_extension_signatures' => [
],
// A list of plugin files to execute.
//
// Plugins which are bundled with Phan can be added here by providing their name (e.g. `'AlwaysReturnPlugin'`)
//
// Documentation about available bundled plugins can be found [here](https://github.com/phan/phan/tree/v4/.phan/plugins).
//
// Alternately, you can pass in the full path to a PHP file with the plugin's implementation (e.g. `'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php'`)
'plugins' => [],
// A list of directories that should be parsed for class and
// method information. After excluding the directories
// defined in `exclude_analysis_directory_list`, the remaining
// files will be statically analyzed for errors.
//
// Thus, both first-party and third-party code being used by
// your application should be included in this list.
'directory_list' => [
'src',
'joomla/administrator/components/com_finder/src/Indexer',
'joomla/libraries'
],
// A list of individual files to include in analysis
// with a path relative to the root directory of the
// project.
'file_list' => [],
];

67
.php-cs-fixer.dist.php Normal file
View File

@ -0,0 +1,67 @@
<?php
/**
* @package Joomla.Site
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* This is the configuration file for php-cs-fixer
*
* @see https://github.com/FriendsOfPHP/PHP-CS-Fixer
* @see https://mlocati.github.io/php-cs-fixer-configurator/#version:3.0
*
*
* If you would like to run the automated clean up, then open a command line and type one of the commands below
*
* To run a quick dry run to see the files that would be modified:
*
* ./component/backend/vendor/bin/php-cs-fixer fix --dry-run
*
* To run a full check, with automated fixing of each problem :
*
* ./component/backend/vendor/bin/php-cs-fixer fix
*
* You can run the clean up on a single file if you need to, this is faster
*
* ./component/backend/vendor/bin/php-cs-fixer fix --dry-run administrator/index.php
* ./component/backend/vendor/bin/php-cs-fixer fix administrator/index.php
*/
// Add all the core Joomla folders
$finder = PhpCsFixer\Finder::create()
->in(
[
__DIR__ . '/src',
]
)
// Ignore template files as PHP CS fixer can't handle them properly
// https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/3702#issuecomment-396717120
->notPath('/vendor/')
->notPath('/tmpl/');
$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setHideProgress(false)
->setUsingCache(false)
->setRules(
[
// Basic ruleset is PSR 12
'@PSR12' => true,
// Short array syntax
'array_syntax' => ['syntax' => 'short'],
// Lists should not have a trailing comma like list($foo, $bar,) = ...
'no_trailing_comma_in_list_call' => true,
// Arrays on multiline should have a trailing comma
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
// Align elements in multiline array and variable declarations on new lines below each other
'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align']],
// The "No break" comment in switch statements
'no_break_comment' => ['comment_text' => 'No break'],
]
)
->setFinder($finder);
return $config;

View File

@ -1,54 +0,0 @@
sudo: true
language: php
services:
- xvfb
env:
global:
- RUN_PHPCS="no"
matrix:
fast_finish: true
include:
- php: 5.6
env: RUN_PHPCS="yes"
- php: 7.0
sudo: true
addons:
firefox: 'latest-esr'
- php: 7.1
- php: 7.2
- php: 7.3
before_script:
# Forcing localhost in hosts file
- sudo sed -i '1s/^/127.0.0.1 localhost\n/' /etc/hosts
- sudo apt-get update -qq
- sudo apt-get install -y --force-yes apache2 libapache2-mod-fastcgi > /dev/null
- sudo mkdir $(pwd)/.run
- chmod a+x tests/travis-php-fpm.sh
- sudo ./tests/travis-php-fpm.sh $USER $(phpenv version-name)
- sudo a2enmod rewrite actions fastcgi alias
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
- sudo cp -f tests/travis-ci-apache.conf /etc/apache2/sites-available/default
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default
- sudo sed -e "s?%PHPVERSION%?${TRAVIS_PHP_VERSION:0:1}?g" --in-place /etc/apache2/sites-available/default
- git submodule update --init --recursive
- sudo service apache2 restart
# Fluxbox
- sudo apt-get install fluxbox -y --force-yes
- fluxbox &
- sleep 3 # give fluxbox some time to start
# Composer
- composer install
script:
# Build
- mv jorobo.dist.ini jorobo.ini
- vendor/bin/robo build
# System tests (Codeception)
- mv tests/acceptance.suite.dist.yml tests/acceptance.suite.yml
- vendor/bin/robo run:tests --use-htaccess
# Run phpcs on PHP 5.6 against weblinks source
- if [[ $RUN_PHPCS == "yes" ]]; then vendor/bin/phpcs --report=full --extensions=php -p --standard=tests/joomla/build/phpcs/Joomla ./src; fi

View File

@ -166,10 +166,10 @@ Bye
class_name: AcceptanceTester
modules:
enabled:
- JoomlaBrowser
- AcceptanceHelper
- Joomla\Browser\JoomlaBrowser
- Helper\Acceptance
config:
JoomlaBrowser:
Joomla\Browser\JoomlaBrowser:
url: 'http://localhost/weblinks/tests/joomla-cms3' # the url that points to the joomla installation at /tests/system/joomla-cms
browser: 'firefox'
window_size: 1024x768
@ -197,12 +197,12 @@ env:
tablet:
modules:
config:
JoomlaBrowser:
Joomla\Browser\JoomlaBrowser:
window_size: 768x1024
phone:
modules:
config:
JoomlaBrowser:
Joomla\Browser\JoomlaBrowser:
window_size: 480x640
```
@ -221,7 +221,7 @@ skipClone = false
cmsPath = tests/joomla-cms3
; If you want to clone a different branch, you can set it here
branch = staging
branch = 4.0-dev
; (Linux / Mac only) If you want to set a different owner for the CMS root folder, you can set it here.
localUser =
@ -258,13 +258,13 @@ The tests in Weblinks Extension use Codeception Testing Framework, if you want t
This is not required, and if in doubt you can just skip this section, but there may be some specific use cases when you need (or want) to override the default behaviour of RoboFile.php. To do this, copy `RoboFile.dist.ini` to `RoboFile.ini` and add options in INI format, one per line, e.g.
skipClone = true
cmsPath = tests/joomla-cms3
cmsPath = tests/joomla
The currently available options are as follows:
* `skipClone`: set to `true` to avoid the cms repo being deleted and re-cloned at each test execution. Useful to save time and bandwidth while you're debugging your test environment. But please be aware that if you don't refresh the repo you'll have to manually check the `installation` folder is present and the `configuration.php` is not.
* `cmsPath`: set to the local path (absolute or relative) where you'd like the test website to be installed. Default is `tests/joomla-cms3`.
* `branch`: set to whatever existing branch from the `joomla-cms` project if you want to clone that specific branch. Default is `staging`.
* `branch`: set to whatever existing branch from the `joomla-cms` project if you want to clone that specific branch. Default is `4.0-dev`.
## Additional options

View File

@ -7,7 +7,7 @@ skipClone = false
cmsPath = tests/joomla
; If you want to clone a different branch, you can set it here
branch = staging
branch = 4.0-dev
; (Linux / Mac only) If you want to set a different owner for the CMS root folder, you can set it here.
localUser = www-data

View File

@ -12,8 +12,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use Joomla\Jorobo\Tasks\loadTasks as loadReleaseTasks;
use Joomla\Testing\Robo\Tasks\loadTasks as loadTestingTasks;
use Joomla\Jorobo\Tasks\Tasks as loadReleaseTasks;
use Robo\Tasks;
require_once 'vendor/autoload.php';
@ -33,7 +32,6 @@ if (!defined('JPATH_BASE'))
class RoboFile extends Tasks
{
// Load tasks from composer, see composer.json
use loadTestingTasks;
use loadReleaseTasks;
/**
@ -398,7 +396,7 @@ class RoboFile extends Tasks
*/
private function buildGitCloneCommand()
{
$branch = empty($this->configuration->branch) ? 'staging' : $this->configuration->branch;
$branch = empty($this->configuration->branch) ? '4.0-dev' : $this->configuration->branch;
return "git" . $this->executableExtension . " clone -b $branch --single-branch --depth 1 https://github.com/joomla/joomla-cms.git tests/cache";
}
@ -595,7 +593,7 @@ class RoboFile extends Tasks
{
$suiteConfig = $this->getSuiteConfig();
$codeceptMainConfig = \Codeception\Configuration::config();
$browser = $suiteConfig['modules']['config']['JoomlaBrowser']['browser'];
$browser = $suiteConfig['modules']['config']['Joomla\Browser\JoomlaBrowser']['browser'];
if ($browser == 'chrome')
{

View File

@ -5,9 +5,9 @@ paths:
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
bootstrap: _bootstrap.php
webdrivers:
firefox:
windows: vendor\joomla-projects\selenium-server-standalone\bin\webdrivers\gecko\windows\geckodriver64.exe

View File

@ -4,22 +4,26 @@
"license" : "GPL-2.0+",
"config": {
"platform": {
"php": "5.6.0"
"php": "7.2.5"
}
},
"require" : {
"php": ">=5.4"
"php": ">=7.2.5|~8"
},
"require-dev": {
"php": ">=5.6",
"codeception/codeception": "^3",
"phpunit/phpunit": "^5.7.27",
"joomla-projects/joomla-browser": "v3.9.0",
"consolidation/robo": "^1.0.0",
"joomla-projects/joomla-testing-robo": "~1.0",
"joomla-projects/selenium-server-standalone": "^v3.1.0",
"behat/gherkin": "^4.4.1",
"codeception/codeception": "^4.1",
"fzaninotto/faker": "^1.6",
"joomla-projects/jorobo": "~0.7",
"behat/gherkin": "^4.4.1"
"joomla-projects/joomla-browser": "^4.0",
"joomla-projects/jorobo": "dev-develop",
"joomla-projects/selenium-server-standalone": "^3.14",
"phpunit/phpunit": "^5.7.27",
"friendsofphp/php-cs-fixer": "^3.4.0",
"squizlabs/php_codesniffer": "^3.7.1",
"codeception/module-filesystem": "^1.0",
"codeception/module-asserts": "^1.3",
"phpstan/phpstan": "^1.10",
"phan/phan": "^5.4",
"phpstan/phpstan-deprecation-rules": "^1.1"
}
}

5680
composer.lock generated

File diff suppressed because it is too large Load Diff

36
cypress.config.dist.js Normal file
View File

@ -0,0 +1,36 @@
const { defineConfig } = require('cypress')
module.exports = defineConfig({
fixturesFolder: 'tests/cypress/fixtures',
videosFolder: 'tests/cypress/output/videos',
screenshotsFolder: 'tests/cypress/output/screenshots',
viewportHeight: 1000,
viewportWidth: 1200,
e2e: {
setupNodeEvents(on, config) {},
baseUrl: 'http://localhost/',
specPattern: [
'tests/cypress/integration/install/*.cy.{js,jsx,ts,tsx}',
'tests/cypress/integration/administrator/**/*.cy.{js,jsx,ts,tsx}',
'tests/cypress/integration/site/**/*.cy.{js,jsx,ts,tsx}'
],
supportFile: 'tests/cypress/support/index.js',
scrollBehavior: 'center',
browser: 'firefox',
screenshotOnRunFailure: true,
video: false
},
env: {
sitename: 'Joomla CMS Test',
name: 'jane doe',
email: 'admin@example.com',
username: 'ci-admin',
password: 'joomla-17082005',
db_type: 'MySQLi',
db_host: 'localhost',
db_name: 'test_joomla',
db_user: 'root',
db_password: 'joomla_ut',
db_prefix: 'jos_',
},
})

View File

@ -1,5 +1,5 @@
extension = weblinks
version = 3.7.0
version = 4.0.0
source = src
target = package
@ -32,7 +32,7 @@ text = "
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - ##YEAR## Open Source Matters, Inc. All rights reserved.
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
"

12
node_modules/.bin/cypress generated vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../cypress/bin/cypress" "$@"
else
exec node "$basedir/../cypress/bin/cypress" "$@"
fi

1942
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

25
package.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "joomla-weblinks",
"version": "4.0.0",
"description": "Weblinks extension",
"license": "GPL-2.0-or-later",
"repository": {
"type": "git",
"url": "https://github.com/joomla-extensions/weblinks.git"
},
"engines": {
"node": ">=16",
"npm": ">=8.5.5"
},
"scripts": {
"cypress:install": "cypress install",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
"dependencies": {
},
"devDependencies": {
"cypress": "^12.7.0",
"joomla-cypress": "^0.0.16"
}
}

11
phpstan.neon Normal file
View File

@ -0,0 +1,11 @@
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
parameters:
level: 6
paths:
- src
scanDirectories:
- joomla/libraries
- joomla/administrator/components/com_finder/src/Indexer
ignoreErrors:
reportUnmatchedIgnoredErrors: false

48
ruleset.xml Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0"?>
<ruleset name="Joomla-CMS">
<description>The Joomla CMS PSR-12 exceptions.</description>
<!-- Exclude folders not containing production code -->
<!-- Exclude 3rd party libraries and Framework code. -->
<exclude-pattern type="relative">src/administrator/components/com_weblinks/layouts/*</exclude-pattern>
<rule ref="PSR12" />
<!-- temporary extend the line length -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="560"/>
<property name="absoluteLineLimit" value="560"/>
</properties>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration">
<exclude-pattern type="relative">src/administrator/components/com_weblinks/script\.php</exclude-pattern>
<exclude-pattern type="relative">src/administrator/manifests/packages/weblinks/script\.php</exclude-pattern>
<exclude-pattern type="relative">src/administrator/components/com_weblinks/helpers/weblinks\.php</exclude-pattern>
<exclude-pattern type="relative">src/components/com_weblinks/helpers/icon\.php</exclude-pattern>
<exclude-pattern type="relative">src/components/com_weblinks/helpers/route\.php</exclude-pattern>
</rule>
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
<exclude-pattern type="relative">src/components/com_weblinks/src/Model/CategoriesModel\.php</exclude-pattern>
<exclude-pattern type="relative">src/components/com_weblinks/src/Model/CategoryModel\.php</exclude-pattern>
<exclude-pattern type="relative">src/components/com_weblinks/src/Model/WeblinkModel\.php</exclude-pattern>
<exclude-pattern type="relative">src/administrator/components/com_weblinks/src/Table/*\.php</exclude-pattern>
</rule>
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern type="relative">src/administrator/components/com_weblinks/script\.php</exclude-pattern>
<exclude-pattern type="relative">src/administrator/manifests/packages/weblinks/script\.php</exclude-pattern>
</rule>
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<exclude-pattern type="relative">src/administrator/components/com_weblinks/src/Table/*\.php</exclude-pattern>
</rule>
<rule ref="Squiz.Classes.ValidClassName">
<exclude-pattern type="relative">src/administrator/components/com_weblinks/script\.php</exclude-pattern>
<exclude-pattern type="relative">src/administrator/manifests/packages/weblinks/script\.php</exclude-pattern>
</rule>
</ruleset>

View File

@ -1,35 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<access component="com_weblinks">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.options" title="JACTION_OPTIONS" description="JACTION_OPTIONS_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
<action name="core.edit.value" title="JACTION_EDITVALUE" description="JACTION_EDITVALUE_COMPONENT_DESC" />
<action name="core.admin" title="JACTION_ADMIN" />
<action name="core.options" title="JACTION_OPTIONS" />
<action name="core.manage" title="JACTION_MANAGE" />
<action name="core.create" title="JACTION_CREATE" />
<action name="core.delete" title="JACTION_DELETE" />
<action name="core.edit" title="JACTION_EDIT" />
<action name="core.edit.state" title="JACTION_EDITSTATE" />
<action name="core.edit.own" title="JACTION_EDITOWN" />
<action name="core.edit.value" title="JACTION_EDITVALUE" />
</section>
<section name="category">
<action name="core.create" title="JACTION_CREATE" description="COM_CATEGORIES_ACCESS_CREATE_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="COM_CATEGORIES_ACCESS_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="COM_CATEGORIES_ACCESS_EDIT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="COM_CATEGORIES_ACCESS_EDITOWN_DESC" />
<action name="core.create" title="JACTION_CREATE" />
<action name="core.delete" title="JACTION_DELETE" />
<action name="core.edit" title="JACTION_EDIT" />
<action name="core.edit.state" title="JACTION_EDITSTATE" />
<action name="core.edit.own" title="JACTION_EDITOWN" />
</section>
<section name="fieldgroup">
<action name="core.create" title="JACTION_CREATE" description="COM_FIELDS_GROUP_PERMISSION_CREATE_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="COM_FIELDS_GROUP_PERMISSION_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="COM_FIELDS_GROUP_PERMISSION_EDIT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_FIELDS_GROUP_PERMISSION_EDITSTATE_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="COM_FIELDS_GROUP_PERMISSION_EDITOWN_DESC" />
<action name="core.edit.value" title="JACTION_EDITVALUE" description="COM_FIELDS_GROUP_PERMISSION_EDITVALUE_DESC" />
<action name="core.create" title="JACTION_CREATE" />
<action name="core.delete" title="JACTION_DELETE" />
<action name="core.edit" title="JACTION_EDIT" />
<action name="core.edit.state" title="JACTION_EDITSTATE" />
<action name="core.edit.own" title="JACTION_EDITOWN" />
<action name="core.edit.value" title="JACTION_EDITVALUE" />
</section>
<section name="field">
<action name="core.delete" title="JACTION_DELETE" description="COM_FIELDS_FIELD_PERMISSION_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="COM_FIELDS_FIELD_PERMISSION_EDIT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_FIELDS_FIELD_PERMISSION_EDITSTATE_DESC" />
<action name="core.edit.value" title="JACTION_EDITVALUE" description="COM_FIELDS_FIELD_PERMISSION_EDITVALUE_DESC" />
<action name="core.delete" title="JACTION_DELETE" />
<action name="core.edit" title="JACTION_EDIT" />
<action name="core.edit.state" title="JACTION_EDITSTATE" />
<action name="core.edit.value" title="JACTION_EDITVALUE" />
</section>
</access>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<inlinehelp button="show"/>
<fieldset
name="component"
label="COM_WEBLINKS_COMPONENT_LABEL"
@ -9,7 +10,6 @@
name="captcha"
type="plugins"
label="COM_WEBLINKS_FIELD_CAPTCHA_LABEL"
description="COM_WEBLINKS_FIELD_CAPTCHA_DESC"
default=""
folder="captcha"
filter="cmd"
@ -21,9 +21,10 @@
<field
name="target"
type="list"
default="0"
description="COM_WEBLINKS_FIELD_TARGET_DESC"
label="COM_WEBLINKS_FIELD_TARGET_LABEL"
description="COM_WEBLINKS_FIELD_TARGET_DESC"
default="0"
validate="options"
>
<option value="0">JBROWSERTARGET_PARENT</option>
<option value="1">JBROWSERTARGET_NEW</option>
@ -34,35 +35,33 @@
<field
name="save_history"
type="radio"
class="btn-group btn-group-yesno"
default="0"
label="JGLOBAL_SAVE_HISTORY_OPTIONS_LABEL"
description="JGLOBAL_SAVE_HISTORY_OPTIONS_DESC"
layout="joomla.form.field.radio.switcher"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="history_limit"
type="text"
filter="integer"
type="number"
label="JGLOBAL_HISTORY_LIMIT_OPTIONS_LABEL"
description="JGLOBAL_HISTORY_LIMIT_OPTIONS_DESC"
default="5"
filter="integer"
default="10"
showon="save_history:1"
/>
<field
name="count_clicks"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="COM_WEBLINKS_FIELD_COUNTCLICKS_LABEL"
description="COM_WEBLINKS_FIELD_COUNTCLICKS_DESC"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
@ -89,6 +88,7 @@
type="media"
description="COM_WEBLINKS_FIELD_CONFIG_ICON_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_ICON_LABEL"
showon="icons:1"
/>
<field
@ -101,7 +101,8 @@
name="float_first"
type="list"
label="COM_WEBLINKS_FLOAT_FIRST_LABEL"
description="COM_WEBLINKS_FLOAT_FIRST_DESC"
default="none"
validate="options"
>
<option value="right">COM_WEBLINKS_RIGHT</option>
<option value="left">COM_WEBLINKS_LEFT</option>
@ -112,7 +113,8 @@
name="float_second"
type="list"
label="COM_WEBLINKS_FLOAT_SECOND_LABEL"
description="COM_WEBLINKS_FLOAT_SECOND_DESC"
default="none"
validate="options"
>
<option value="right">COM_WEBLINKS_RIGHT</option>
<option value="left">COM_WEBLINKS_LEFT</option>
@ -124,18 +126,15 @@
type="spacer"
hr="true"
/>
<field
id="show_tags"
name="show_tags"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="COM_WEBLINKS_FIELD_SHOW_TAGS_LABEL"
description="COM_WEBLINKS_FIELD_SHOW_TAGS_DESC"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
@ -148,7 +147,7 @@
name="category_layout"
type="componentlayout"
label="JGLOBAL_FIELD_LAYOUT_LABEL"
description="JGLOBAL_FIELD_LAYOUT_DESC"
class="form-select"
menuitems="true"
extension="com_weblinks"
view="category"
@ -157,45 +156,42 @@
<field
name="show_category_title"
type="radio"
class="btn-group btn-group-yesno"
label="JGLOBAL_SHOW_CATEGORY_TITLE"
description="JGLOBAL_SHOW_CATEGORY_TITLE_DESC"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_description"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
description="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_DESC"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_description_image"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
description="JGLOBAL_SHOW_CATEGORY_IMAGE_DESC"
layout="joomla.form.field.radio.switcher"
default="0"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="maxLevel"
type="list"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
default="-1"
validate="options"
>
<option value="0">JNONE</option>
<option value="-1">JALL</option>
@ -209,49 +205,45 @@
<field
name="show_empty_categories"
type="radio"
class="btn-group btn-group-yesno"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
layout="joomla.form.field.radio.switcher"
default="0"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_subcat_desc"
type="radio"
class="btn-group btn-group-yesno"
default="1"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
default="1"
layout="joomla.form.field.radio.switcher"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_cat_num_links"
type="radio"
class="btn-group btn-group-yesno"
default="1"
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_cat_tags"
type="radio"
layout="joomla.form.field.radio.switcher"
label="COM_WEBLINKS_FIELD_SHOW_CAT_TAGS_LABEL"
description="COM_WEBLINKS_FIELD_SHOW_CAT_TAGS_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
@ -263,23 +255,22 @@
<field
name="show_base_description"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_LABEL"
description="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_DESC"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="maxLevelcat"
type="list"
default="-1"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
default="-1"
validate="options"
>
<option value="0">JNONE</option>
<option value="-1">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
@ -291,37 +282,36 @@
<field
name="show_empty_categories_cat"
type="radio"
class="btn-group btn-group-yesno"
default="0"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
layout="joomla.form.field.radio.switcher"
default="0"
showon="maxLevelcat:-1,1,2,3,4,5"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_subcat_desc_cat"
type="radio"
class="btn-group btn-group-yesno"
default="1"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
showon="maxLevelcat:-1,1,2,3,4,5"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_cat_num_links_cat"
type="radio"
class="btn-group btn-group-yesno"
default="1"
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
@ -332,34 +322,21 @@
>
<field
name="filter_field"
type="list"
default="1"
description="JGLOBAL_FILTER_FIELD_DESC"
type="radio"
layout="joomla.form.field.radio.switcher"
label="JGLOBAL_FILTER_FIELD_LABEL"
default="0"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
<option value="hide">JHIDE</option>
</field>
<field
name="show_pagination_limit"
type="radio"
default="1"
class="btn-group btn-group-yesno"
layout="joomla.form.field.radio.switcher"
default="0"
label="JGLOBAL_DISPLAY_SELECT_LABEL"
description="JGLOBAL_DISPLAY_SELECT_DESC"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="show_headings"
type="radio"
default="1"
class="btn-group btn-group-yesno"
description="JGLOBAL_SHOW_HEADINGS_DESC"
label="JGLOBAL_SHOW_HEADINGS_LABEL"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
@ -368,25 +345,23 @@
<field
name="show_link_description"
type="radio"
layout="joomla.form.field.radio.switcher"
default="1"
class="btn-group btn-group-yesno"
description="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_LABEL"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_link_hits"
type="radio"
class="btn-group btn-group-yesno"
layout="joomla.form.field.radio.switcher"
default="1"
description="COM_WEBLINKS_FIELD_CONFIG_HITS_DESC"
label="JGLOBAL_HITS"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
@ -394,7 +369,6 @@
type="list"
default="2"
label="JGLOBAL_PAGINATION_LABEL"
description="JGLOBAL_PAGINATION_DESC"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
@ -404,13 +378,12 @@
<field
name="show_pagination_results"
type="radio"
class="btn-group btn-group-yesno"
layout="joomla.form.field.radio.switcher"
default="1"
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
description="JGLOBAL_PAGINATION_RESULTS_DESC"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
@ -419,29 +392,51 @@
label="JGLOBAL_INTEGRATION_LABEL"
description="COM_WEBLINKS_CONFIG_INTEGRATION_SETTINGS_DESC"
>
<field
name="show_feed_link"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="JGLOBAL_SHOW_FEED_LINK_LABEL"
description="JGLOBAL_SHOW_FEED_LINK_DESC"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="custom_fields_enable"
type="radio"
label="JGLOBAL_CUSTOM_FIELDS_ENABLE_LABEL"
description="JGLOBAL_CUSTOM_FIELDS_ENABLE_DESC"
default="0"
class="btn-group btn-group-yesno"
<fieldset
name="integration_newsfeeds"
label="JGLOBAL_FEED_TITLE"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="show_feed_link"
type="radio"
layout="joomla.form.field.radio.switcher"
label="JGLOBAL_SHOW_FEED_LINK_LABEL"
default="1"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset
name="integration_sef"
label="JGLOBAL_SEF_TITLE"
>
<field
name="sef_ids"
type="radio"
layout="joomla.form.field.radio.switcher"
default="0"
label="JGLOBAL_SEF_NOIDS_LABEL"
filter="integer">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
<fieldset
name="integration_customfields"
label="JGLOBAL_FIELDS_TITLE"
>
<field
name="custom_fields_enable"
type="radio"
layout="joomla.form.field.radio.switcher"
label="JGLOBAL_CUSTOM_FIELDS_ENABLE_LABEL"
default="1"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
</fieldset>
<fieldset

View File

@ -1,51 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks Main Controller
*
* @since 1.5
*/
class WeblinksController extends JControllerLegacy
{
/**
* Method to display a view.
*
* @param boolean $cacheable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types,
* for valid values see {@link JFilterInput::clean()}.
*
* @return JControllerLegacy This object to support chaining.
*
* @since 1.5
*/
public function display($cacheable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/weblinks.php';
$view = $this->input->get('view', 'weblinks');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');
// Check for edit form.
if ($view == 'weblink' && $layout == 'edit' && !$this->checkEditId('com_weblinks.edit.weblink', $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks', false));
return false;
}
return parent::display();
}
}

View File

@ -1,129 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Weblink controller class.
*
* @since 1.6
*/
class WeblinksControllerWeblink extends JControllerForm
{
/**
* Method override to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 1.6
*/
protected function allowAdd($data = array())
{
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
$allow = null;
if ($categoryId)
{
// If the category has been passed in the URL check it.
$allow = JFactory::getUser()->authorise('core.create', $this->option . '.category.' . $categoryId);
}
if ($allow !== null)
{
return $allow;
}
// In the absense of better information, revert to the component permissions.
return parent::allowAdd($data);
}
/**
* Method to check if you can add a new record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = array(), $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
// Since there is no asset tracking, fallback to the component permissions.
if (!$recordId)
{
return parent::allowEdit($data, $key);
}
// Get the item.
$item = $this->getModel()->getItem($recordId);
// Since there is no item, return false.
if (empty($item))
{
return false;
}
$user = JFactory::getUser();
// Check if can edit own core.edit.own.
$canEditOwn = $user->authorise('core.edit.own', $this->option . '.category.' . (int) $item->catid) && $item->created_by == $user->id;
// Check the category core.edit permissions.
return $canEditOwn || $user->authorise('core.edit', $this->option . '.category.' . (int) $item->catid);
}
/**
* Method to run batch operations.
*
* @param object $model The model.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 1.7
*/
public function batch($model = null)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Set the model
$model = $this->getModel('Weblink', '', array());
// Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks' . $this->getRedirectToListAppend(), false));
return parent::batch($model);
}
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 1.6
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$task = $this->getTask();
if ($task == 'save')
{
$this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks', false));
}
}
}

View File

@ -1,34 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks list controller class.
*
* @since 1.6
*/
class WeblinksControllerWeblinks extends JControllerAdmin
{
/**
* Proxy for getModel
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config The array of possible config values. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'Weblink', $prefix = 'WeblinksModel', $config = array('ignore_request' => true))
{
return parent::getModel($name, $prefix, $config);
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<help key="Components_Weblinks_Categories_Edit" />
<listhelp key="Components_Weblinks_Categories" />
</form>

View File

@ -12,7 +12,6 @@
name="published"
type="status"
label="JOPTION_FILTER_PUBLISHED"
description="JOPTION_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
@ -21,7 +20,6 @@
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
extension="com_weblinks"
onchange="this.form.submit();"
>
@ -31,7 +29,6 @@
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
@ -40,7 +37,6 @@
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
@ -50,7 +46,6 @@
name="tag"
type="tag"
label="JOPTION_FILTER_TAG"
description="JOPTION_FILTER_TAG_DESC"
mode="nested"
onchange="this.form.submit();"
>
@ -60,7 +55,6 @@
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"

View File

@ -7,7 +7,6 @@
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
readonly="true"
class="readonly"
default="0"
@ -17,18 +16,15 @@
name="title"
type="text"
label="JGLOBAL_TITLE"
description="COM_WEBLINKS_FIELD_TITLE_DESC"
class="input-xxlarge input-large-text"
size="40"
required="true"
maxlength="250"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="COM_WEBLINKS_FIELD_ALIAS_DESC"
size="40"
description="JFIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER"
/>
@ -36,7 +32,6 @@
name="catid"
type="categoryedit"
label="JCATEGORY"
description="COM_WEBLINKS_FIELD_CATEGORY_DESC"
extension="com_weblinks"
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
required="true"
@ -47,10 +42,8 @@
name="url"
type="url"
label="COM_WEBLINKS_FIELD_URL_LABEL"
description="COM_WEBLINKS_FIELD_URL_DESC"
class="span12"
filter="url"
size="40"
validate="url"
required="true"
/>
@ -58,31 +51,28 @@
name="description"
type="editor"
label="JGLOBAL_DESCRIPTION"
description="COM_WEBLINKS_FIELD_DESCRIPTION_DESC"
buttons="true"
hide="pagebreak,readmore"
filter="JComponentHelper::filterText"
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
/>
<field
name="hits"
type="text"
label="JGLOBAL_HITS"
description="COM_WEBLINKS_HITS_DESC"
class="readonly"
size="6"
readonly="true"
filter="unset"
default="0"
/>
<field
name="state"
type="list"
label="JSTATUS"
description="COM_WEBLINKS_FIELD_STATE_DESC"
class="chzn-color-state"
size="1"
class="form-select-color-state"
default="1"
validate="options"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
@ -95,7 +85,6 @@
name="ordering"
type="ordering"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
content_type="com_weblinks.weblink"
/>
@ -103,15 +92,14 @@
name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
size="1"
filter="UINT"
validate="options"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_WEBLINKS_FIELD_LANGUAGE_DESC"
>
<option value="*">JALL</option>
</field>
@ -120,7 +108,7 @@
name="tags"
type="tag"
label="JTAG"
description="JTAG_DESC"
class="advancedSelect"
multiple="true"
/>
@ -128,18 +116,15 @@
name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
size="45"
labelclass="control-label"
maxlength="250"
/>
<field
name="created"
type="calendar"
label="JGLOBAL_FIELD_CREATED_LABEL"
description="JGLOBAL_FIELD_CREATED_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
translateformat="true"
showtime="true"
filter="user_utc"
/>
@ -147,26 +132,23 @@
name="created_by"
type="user"
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
description="JGLOBAL_FIELD_CREATED_BY_Desc"
validate="UserId"
/>
<field
name="created_by_alias"
type="text"
label="JGLOBAL_FIELD_CREATED_BY_ALIAS_LABEL"
description="JGLOBAL_FIELD_CREATED_BY_ALIAS_DESC"
size="20"
/>
<field
name="modified"
type="calendar"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
description="COM_WEBLINKS_FIELD_MODIFIED_DESC"
class="readonly"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
translateformat="true"
showtime="true"
filter="user_utc"
/>
@ -177,6 +159,7 @@
class="readonly"
readonly="true"
filter="unset"
validate="UserId"
/>
<field
@ -195,9 +178,8 @@
name="publish_up"
type="calendar"
label="JGLOBAL_FIELD_PUBLISH_UP_LABEL"
description="JGLOBAL_FIELD_PUBLISH_UP_DESC"
format="%Y-%m-%d %H:%M:%S"
size="22"
translateformat="true"
showtime="true"
filter="user_utc"
/>
@ -205,9 +187,8 @@
name="publish_down"
type="calendar"
label="JGLOBAL_FIELD_PUBLISH_DOWN_LABEL"
description="JGLOBAL_FIELD_PUBLISH_DOWN_DESC"
format="%Y-%m-%d %H:%M:%S"
size="22"
translateformat="true"
showtime="true"
filter="user_utc"
/>
@ -215,9 +196,7 @@
name="version"
type="text"
label="COM_WEBLINKS_FIELD_VERSION_LABEL"
description="COM_WEBLINKS_FIELD_VERSION_DESC"
class="readonly"
size="6"
readonly="true"
filter="unset"
/>
@ -226,7 +205,6 @@
name="metakey"
type="textarea"
label="JFIELD_META_KEYWORDS_LABEL"
description="JFIELD_META_KEYWORDS_DESC"
rows="3"
cols="30"
/>
@ -235,17 +213,16 @@
name="metadesc"
type="textarea"
label="JFIELD_META_DESCRIPTION_LABEL"
description="JFIELD_META_DESCRIPTION_DESC"
rows="3"
cols="30"
maxlength="160"
charcounter="true"
/>
<field
name="xreference"
type="text"
label="JFIELD_XREFERENCE_LABEL"
description="JFIELD_XREFERENCE_DESC"
size="20"
/>
</fieldset>
@ -261,7 +238,6 @@
name="target"
type="list"
label="COM_WEBLINKS_FIELD_TARGET_LABEL"
description="COM_WEBLINKS_FIELD_TARGET_DESC"
default=""
useglobal="true"
>
@ -275,7 +251,6 @@
name="width"
type="text"
label="COM_WEBLINKS_FIELD_WIDTH_LABEL"
description="COM_WEBLINKS_FIELD_WIDTH_DESC"
class="validate-numeric"
/>
@ -283,7 +258,6 @@
name="height"
type="text"
label="COM_WEBLINKS_FIELD_HEIGHT_LABEL"
description="COM_WEBLINKS_FIELD_HEIGHT_DESC"
class="validate-numeric"
/>
@ -291,8 +265,6 @@
name="count_clicks"
type="list"
label="COM_WEBLINKS_FIELD_COUNTCLICKS_LABEL"
description="COM_WEBLINKS_FIELD_COUNTCLICKS_DESC"
class="chzn-color"
useglobal="true"
>
<option value="0">JNO</option>
@ -312,14 +284,12 @@
name="image_first"
type="media"
label="COM_WEBLINKS_FIELD_FIRST_LABEL"
description="COM_WEBLINKS_FIELD_FIRST_DESC"
/>
<field
name="float_first"
type="list"
label="COM_WEBLINKS_FLOAT_FIRST_LABEL"
description="COM_WEBLINKS_FLOAT_FIRST_DESC"
useglobal="true"
>
<option value="right">COM_WEBLINKS_RIGHT</option>
@ -331,16 +301,19 @@
name="image_first_alt"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_ALT_DESC"
size="20"
/>
<field
name="image_first_alt_empty"
type="checkbox"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_DESC"
/>
<field
name="image_first_caption"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_CAPTION_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_CAPTION_DESC"
size="20"
/>
<field
@ -353,16 +326,14 @@
name="image_second"
type="media"
label="COM_WEBLINKS_FIELD_SECOND_LABEL"
description="COM_WEBLINKS_FIELD_SECOND_DESC"
/>
<field
name="float_second"
type="list"
label="COM_WEBLINKS_FLOAT_SECOND_LABEL"
description="COM_WEBLINKS_FLOAT_SECOND_DESC"
useglobal="true"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="right">COM_WEBLINKS_RIGHT</option>
<option value="left">COM_WEBLINKS_LEFT</option>
<option value="none">COM_WEBLINKS_NONE</option>
@ -372,16 +343,19 @@
name="image_second_alt"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_ALT_DESC"
size="20"
/>
<field
name="image_second_alt_empty"
type="checkbox"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_DESC"
/>
<field
name="image_second_caption"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_CAPTION_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_CAPTION_DESC"
size="20"
/>
</fieldset>
</fields>
@ -398,24 +372,19 @@
name="robots"
type="list"
label="JFIELD_METADATA_ROBOTS_LABEL"
description="JFIELD_METADATA_ROBOTS_DESC"
validate="options"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>
<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>
<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>
<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>
<option value="index, follow" />
<option value="noindex, follow" />
<option value="index, nofollow" />
<option value="noindex, nofollow" />
</field>
<field
name="rights"
type="text"
label="JFIELD_META_RIGHTS_LABEL"
description="JFIELD_META_RIGHTS_DESC"
required="false"
filter="string"
cols="30"
rows="2"
/>
</fieldset>
</fields>

View File

@ -1,192 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JTable::addIncludePath(__DIR__ . '/../tables');
/**
* Content associations helper.
*
* @since __DEPLOY_VERSION__
*/
class WeblinksAssociationsHelper extends JAssociationExtensionHelper
{
/**
* The extension name
*
* @var array $extension
*
* @since __DEPLOY_VERSION__
*/
protected $extension = 'com_weblinks';
/**
* Array of item types
*
* @var array $itemTypes
*
* @since __DEPLOY_VERSION__
*/
protected $itemTypes = array('weblink', 'category');
/**
* Has the extension association support
*
* @var boolean $associationsSupport
*
* @since __DEPLOY_VERSION__
*/
protected $associationsSupport = true;
/**
* Get the associated items for an item
*
* @param string $typeName The item type
* @param int $id The id of item for which we need the associated items
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public function getAssociations($typeName, $id)
{
$type = $this->getType($typeName);
$context = $this->extension . '.item';
$catidField = 'catid';
if ($typeName === 'category')
{
$context = 'com_categories.item';
$catidField = '';
}
// Get the associations.
$associations = JLanguageAssociations::getAssociations(
$this->extension,
$type['tables']['a'],
$context,
$id,
'id',
'alias',
$catidField
);
return $associations;
}
/**
* Get item information
*
* @param string $typeName The item type
* @param int $id The id of item for which we need the associated items
*
* @return JTable|null
*
* @since __DEPLOY_VERSION__
*/
public function getItem($typeName, $id)
{
if (empty($id))
{
return null;
}
$table = null;
switch ($typeName)
{
case 'weblink':
$table = JTable::getInstance('Weblink', 'WeblinksTable');
break;
case 'category':
$table = JTable::getInstance('Category');
break;
}
if (empty($table))
{
return null;
}
$table->load($id);
return $table;
}
/**
* Get information about the type
*
* @param string $typeName The item type
*
* @return array Array of item types
*
* @since __DEPLOY_VERSION__
*/
public function getType($typeName = '')
{
$fields = $this->getFieldsTemplate();
$tables = array();
$joins = array();
$support = $this->getSupportTemplate();
$title = '';
if (in_array($typeName, $this->itemTypes))
{
switch ($typeName)
{
case 'weblink':
$support['state'] = true;
$support['acl'] = true;
$support['checkout'] = true;
$support['category'] = true;
$support['save2copy'] = true;
$tables = array(
'a' => '#__weblinks'
);
$title = 'weblink';
break;
case 'category':
$fields['created_user_id'] = 'a.created_user_id';
$fields['ordering'] = 'a.lft';
$fields['level'] = 'a.level';
$fields['catid'] = '';
$fields['state'] = 'a.published';
$support['state'] = true;
$support['acl'] = true;
$support['checkout'] = true;
$support['level'] = true;
$tables = array(
'a' => '#__categories'
);
$title = 'category';
break;
}
}
return array(
'fields' => $fields,
'support' => $support,
'tables' => $tables,
'joins' => $joins,
'title' => $title
);
}
}

View File

@ -1,94 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
/**
* Weblink HTML helper class.
*
* @since __DELPOY_VERSION__
*/
abstract class JHtmlWeblink
{
/**
* Get the associated language flags
*
* @param integer $weblinkid The item id to search associations
*
* @return string The language HTML
*
* @throws Exception
*
* @since ___DEPLOY_VERSION__
*/
public static function association($weblinkid)
{
// Defaults
$html = '';
$associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $weblinkid);
// Get the associations
if ($associations)
{
foreach ($associations as $tag => $associated)
{
$associations[$tag] = (int) $associated->id;
}
// Get the associated weblinks items
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('c.id, c.title as title')
->select('l.sef as lang_sef, lang_code')
->from('#__weblinks as c')
->select('cat.title as category_title')
->join('LEFT', '#__categories as cat ON cat.id=c.catid')
->where('c.id IN (' . implode(',', array_values($associations)) . ')')
->join('LEFT', '#__languages as l ON c.language=l.lang_code')
->select('l.image')
->select('l.title as language_title');
$db->setQuery($query);
try
{
$items = $db->loadObjectList('id');
}
catch (RuntimeException $e)
{
throw new Exception($e->getMessage(), 500, $e);
}
if ($items)
{
foreach ($items as &$item)
{
$text = strtoupper($item->lang_sef);
$url = JRoute::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id);
$tooltip = htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '<br />' . JText::sprintf('JCATEGORY_SPRINTF', $item->category_title);
$classes = 'hasPopover label label-association label-' . $item->lang_sef;
$item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes
. '" data-content="' . $tooltip . '" data-placement="top">'
. $text . '</a>';
}
}
JHtml::_('bootstrap.popover');
$html = JLayoutHelper::render('joomla.content.associations', $items);
}
return $html;
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
@ -7,160 +8,15 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Weblinks helper.
*
* @since 1.6
*/
class WeblinksHelper extends JHelperContent
class WeblinksHelper extends \Joomla\Component\Weblinks\Administrator\Helper\WeblinksHelper
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName = 'weblinks')
{
JHtmlSidebar::addEntry(
JText::_('COM_WEBLINKS_SUBMENU_WEBLINKS'),
'index.php?option=com_weblinks&view=weblinks',
$vName == 'weblinks'
);
JHtmlSidebar::addEntry(
JText::_('COM_WEBLINKS_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_weblinks',
$vName == 'categories'
);
if (JComponentHelper::isEnabled('com_fields') && JComponentHelper::getParams('com_weblinks')->get('custom_fields_enable', '1'))
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELDS'),
'index.php?option=com_fields&context=com_weblinks.weblink',
$vName == 'fields.fields'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELD_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_weblinks.weblink',
$vName == 'fields.groups'
);
}
}
/**
* Adds Count Items for WebLinks Category Manager.
*
* @param stdClass[] &$items The weblinks category objects.
*
* @return stdClass[] The weblinks category objects.
*
* @since 3.6.0
*/
public static function countItems(&$items)
{
$db = JFactory::getDbo();
foreach ($items as $item)
{
$item->count_trashed = 0;
$item->count_archived = 0;
$item->count_unpublished = 0;
$item->count_published = 0;
$query = $db->getQuery(true)
->select('state, COUNT(*) AS count')
->from($db->qn('#__weblinks'))
->where($db->qn('catid') . ' = ' . (int) $item->id)
->group('state');
$db->setQuery($query);
$weblinks = $db->loadObjectList();
foreach ($weblinks as $weblink)
{
if ($weblink->state == 1)
{
$item->count_published = $weblink->count;
}
elseif ($weblink->state == 0)
{
$item->count_unpublished = $weblink->count;
}
elseif ($weblink->state == 2)
{
$item->count_archived = $weblink->count;
}
elseif ($weblink->state == -2)
{
$item->count_trashed = $weblink->count;
}
}
}
return $items;
}
/**
* Adds Count Items for Tag Manager.
*
* @param stdClass[] &$items The weblink tag objects
* @param string $extension The name of the active view.
*
* @return stdClass[]
*
* @since 3.7.0
*/
public static function countTagItems(&$items, $extension)
{
$db = JFactory::getDbo();
foreach ($items as $item)
{
$item->count_trashed = 0;
$item->count_archived = 0;
$item->count_unpublished = 0;
$item->count_published = 0;
$query = $db->getQuery(true);
$query->select('published as state, count(*) AS count')
->from($db->qn('#__contentitem_tag_map') . 'AS ct ')
->where('ct.tag_id = ' . (int) $item->id)
->where('ct.type_alias =' . $db->q($extension))
->join('LEFT', $db->qn('#__categories') . ' AS c ON ct.content_item_id=c.id')
->group('state');
$db->setQuery($query);
$weblinks = $db->loadObjectList();
foreach ($weblinks as $weblink)
{
if ($weblink->state == 1)
{
$item->count_published = $weblink->count;
}
if ($weblink->state == 0)
{
$item->count_unpublished = $weblink->count;
}
if ($weblink->state == 2)
{
$item->count_archived = $weblink->count;
}
if ($weblink->state == -2)
{
$item->count_trashed = $weblink->count;
}
}
}
return $items;
}
}

View File

@ -1,257 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
/**
* Supports a modal weblink picker.
*
* @since __DEPLOY_VERSION__
*/
class JFormFieldModal_Weblink extends JFormField
{
/**
* The form field type.
*
* @var string
* @since __DEPLOY_VERSION__
*/
protected $type = 'Modal_Weblink';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since __DEPLOY_VERSION__
*/
protected function getInput()
{
$allowNew = ((string) $this->element['new'] == 'true');
$allowEdit = ((string) $this->element['edit'] == 'true');
$allowClear = ((string) $this->element['clear'] != 'false');
$allowSelect = ((string) $this->element['select'] != 'false');
// Load language
JFactory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR);
// The active weblink id field.
$value = (int) $this->value > 0 ? (int) $this->value : '';
// Create the modal id.
$modalId = 'Weblink_' . $this->id;
// Add the modal field script to the document head.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/modal-fields.js', array('version' => 'auto', 'relative' => true));
// Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect)
{
static $scriptSelect = null;
if (is_null($scriptSelect))
{
$scriptSelect = array();
}
if (!isset($scriptSelect[$this->id]))
{
JFactory::getDocument()->addScriptDeclaration("
function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, language) {
window.processModalSelect('Weblink', '" . $this->id . "', id, title, catid, object, url, language);
}
");
$scriptSelect[$this->id] = true;
}
}
// Setup variables for display.
$linkWeblinks = 'index.php?option=com_weblinks&amp;view=weblinks&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
$linkWeblink = 'index.php?option=com_weblinks&amp;view=weblink&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
$modalTitle = JText::_('COM_WEBLINKS_CHANGE_WEBLINK');
if (isset($this->element['language']))
{
$linkWeblinks .= '&amp;forcedLanguage=' . $this->element['language'];
$linkWeblink .= '&amp;forcedLanguage=' . $this->element['language'];
$modalTitle .= ' &#8212; ' . $this->element['label'];
}
$urlSelect = $linkWeblinks . '&amp;function=jSelectWeblink_' . $this->id;
$urlEdit = $linkWeblink . '&amp;task=weblink.edit&amp;id=\' + document.getElementById("' . $this->id . '_id").value + \'';
$urlNew = $linkWeblink . '&amp;task=weblink.add';
if ($value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__weblinks'))
->where($db->quoteName('id') . ' = ' . (int) $value);
$db->setQuery($query);
try
{
$title = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
}
$title = empty($title) ? JText::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// The current weblink display field.
$html = '<span class="input-append">';
$html .= '<input class="input-medium" id="' . $this->id . '_name" type="text" value="' . $title . '" disabled="disabled" size="35" />';
// Select weblink button
if ($allowSelect)
{
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? ' hidden' : '') . '"'
. ' id="' . $this->id . '_select"'
. ' data-toggle="modal"'
. ' role="button"'
. ' href="#ModalSelect' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_WEBLINKS_CHANGE_WEBLINK') . '">'
. '<span class="icon-file" aria-hidden="true"></span> ' . JText::_('JSELECT')
. '</a>';
}
// New weblink button
if ($allowNew)
{
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? ' hidden' : '') . '"'
. ' id="' . $this->id . '_new"'
. ' data-toggle="modal"'
. ' role="button"'
. ' href="#ModalNew' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_WEBLINKS_NEW_WEBLINK') . '">'
. '<span class="icon-new" aria-hidden="true"></span> ' . JText::_('JACTION_CREATE')
. '</a>';
}
// Edit weblink button
if ($allowEdit)
{
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? '' : ' hidden') . '"'
. ' id="' . $this->id . '_edit"'
. ' data-toggle="modal"'
. ' role="button"'
. ' href="#ModalEdit' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT_WEBLINK') . '">'
. '<span class="icon-edit" aria-hidden="true"></span> ' . JText::_('JACTION_EDIT')
. '</a>';
}
// Clear weblink button
if ($allowClear)
{
$html .= '<a'
. ' class="btn' . ($value ? '' : ' hidden') . '"'
. ' id="' . $this->id . '_clear"'
. ' href="#"'
. ' onclick="window.processModalParent(\'' . $this->id . '\'); return false;">'
. '<span class="icon-remove" aria-hidden="true"></span>' . JText::_('JCLEAR')
. '</a>';
}
$html .= '</span>';
// Select weblink modal
if ($allowSelect)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalSelect' . $modalId,
array(
'title' => $modalTitle,
'url' => $urlSelect,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<a role="button" class="btn" data-dismiss="modal" aria-hidden="true">' . JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>',
)
);
}
// New weblink modal
if ($allowNew)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalNew' . $modalId,
array(
'title' => JText::_('COM_WEBLINKS_NEW_WEBLINK'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlNew,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<a role="button" class="btn" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>'
. '<a role="button" class="btn btn-primary" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'save\', \'weblink-form\'); return false;">'
. JText::_('JSAVE') . '</a>'
. '<a role="button" class="btn btn-success" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'apply\', \'weblink-form\'); return false;">'
. JText::_('JAPPLY') . '</a>',
)
);
}
// Edit weblink modal
if ($allowEdit)
{
$html .= JHtml::_(
'bootstrap.renderModal',
'ModalEdit' . $modalId,
array(
'title' => JText::_('COM_WEBLINKS_EDIT_WEBLINK'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlEdit,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<a role="button" class="btn" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>'
. '<a role="button" class="btn btn-primary" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'save\', \'weblink-form\'); return false;">'
. JText::_('JSAVE') . '</a>'
. '<a role="button" class="btn btn-success" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'apply\', \'weblink-form\'); return false;">'
. JText::_('JAPPLY') . '</a>',
)
);
}
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required modal-value"' : '';
$html .= '<input type="hidden" id="' . $this->id . '_id" ' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
. '" data-text="' . htmlspecialchars(JText::_('COM_WEBLINKS_SELECT_A_WEBLINK', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';
return $html;
}
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since __DEPLOY_VERSION__
*/
protected function getLabel()
{
return str_replace($this->id, $this->id . '_id', parent::getLabel());
}
}

View File

@ -1,452 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
/**
* Weblinks model.
*
* @since 1.5
*/
class WeblinksModelWeblink extends JModelAdmin
{
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_weblinks.weblink';
/**
* The context used for the associations table
*
* @var string
* @since __DEPLOY_VERSION__
*/
protected $associationsContext = 'com_weblinks.item';
/**
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
protected $text_prefix = 'COM_WEBLINKS';
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->state != -2)
{
return;
}
if ($record->catid)
{
return JFactory::getUser()->authorise('core.delete', 'com_weblinks.category.' . (int) $record->catid);
}
return parent::canDelete($record);
}
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission for the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.edit.state', 'com_weblinks.category.' . (int) $record->catid);
}
return parent::canEditState($record);
}
/**
* Method to get a table object, load it if necessary.
*
* @param string $type The table name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A JTable object
*
* @since 1.6
*/
public function getTable($type = 'Weblink', $prefix = 'WeblinksTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Abstract method for getting the form from the model.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_weblinks.weblink', 'weblink', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Determine correct permissions to check.
if ($this->getState('weblink.id'))
{
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.edit');
}
else
{
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.create');
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled', 'true');
$form->setFieldAttribute('state', 'disabled', 'true');
$form->setFieldAttribute('publish_up', 'disabled', 'true');
$form->setFieldAttribute('publish_down', 'disabled', 'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('ordering', 'filter', 'unset');
$form->setFieldAttribute('state', 'filter', 'unset');
$form->setFieldAttribute('publish_up', 'filter', 'unset');
$form->setFieldAttribute('publish_down', 'filter', 'unset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return array The default data is an empty array.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_weblinks.edit.weblink.data', array());
if (empty($data))
{
$data = $this->getItem();
// Prime some default values.
if ($this->getState('weblink.id') == 0)
{
$app = JFactory::getApplication();
$data->set('catid', $app->input->get('catid', $app->getUserState('com_weblinks.weblinks.filter.category_id'), 'int'));
}
}
$this->preprocessData('com_weblinks.weblink', $data);
return $data;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
// Convert the images field to an array.
$registry = new Registry;
$registry->loadString($item->images);
$item->images = $registry->toArray();
// Load associated web links items
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$item->associations = array();
if ($item->id != null)
{
$associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $item->id);
foreach ($associations as $tag => $association)
{
$item->associations[$tag] = $association->id;
}
}
}
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id, 'com_weblinks.weblink');
$item->metadata['tags'] = $item->tags;
}
}
return $item;
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A reference to a JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = JApplicationHelper::stringURLSafe($table->alias);
if (empty($table->alias))
{
$table->alias = JApplicationHelper::stringURLSafe($table->title);
}
if (empty($table->id))
{
// Set the values
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__weblinks'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
else
{
// Set the values
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
}
// Increment the weblink version number.
$table->version++;
}
/**
* A protected method to get a set of ordering conditions.
*
* @param JTable $table A JTable object.
*
* @return array An array of conditions to add to ordering queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
$condition = array();
$condition[] = 'catid = ' . (int) $table->catid;
return $condition;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 3.1
*/
public function save($data)
{
$app = JFactory::getApplication();
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');
// Cast catid to integer for comparison
$catid = (int) $data['catid'];
// Check if New Category exists
if ($catid > 0)
{
$catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_weblinks');
}
// Save New Category
if ($catid == 0 && $this->canCreateCategory())
{
$table = array();
$table['title'] = $data['catid'];
$table['parent_id'] = 1;
$table['extension'] = 'com_weblinks';
$table['language'] = $data['language'];
$table['published'] = 1;
// Create new category and get catid back
$data['catid'] = CategoriesHelper::createCategory($table);
}
// Alter the title for save as copy
if ($app->input->get('task') == 'save2copy')
{
list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
$data['title'] = $name;
$data['alias'] = $alias;
$data['state'] = 0;
}
return parent::save($data);
}
/**
* Method to change the title & alias.
*
* @param integer $category_id The id of the parent.
* @param string $alias The alias.
* @param string $name The title.
*
* @return array Contains the modified title and alias.
*
* @since 3.1
*/
protected function generateNewTitle($category_id, $alias, $name)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias, 'catid' => $category_id)))
{
if ($name == $table->title)
{
$name = JString::increment($name);
}
$alias = JString::increment($alias, 'dash');
}
return array($name, $alias);
}
/**
* Allows preprocessing of the JForm object.
*
* @param JForm $form The form object
* @param array $data The data to be merged into the form object
* @param string $group The plugin group to be executed
*
* @return void
*
* @since 3.6.0
*/
protected function preprocessForm(JForm $form, $data, $group = 'content')
{
if ($this->canCreateCategory())
{
$form->setFieldAttribute('catid', 'allowAdd', 'true');
}
// Association weblinks items
if (JLanguageAssociations::isEnabled())
{
$languages = JLanguageHelper::getContentLanguages(false, true, null, 'ordering', 'asc');
if (count($languages) > 1)
{
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name', 'item_associations');
foreach ($languages as $language)
{
$field = $fieldset->addChild('field');
$field->addAttribute('name', $language->lang_code);
$field->addAttribute('type', 'modal_weblink');
$field->addAttribute('language', $language->lang_code);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label', 'false');
$field->addAttribute('select', 'true');
$field->addAttribute('new', 'true');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
}
$form->load($addform, false);
}
}
parent::preprocessForm($form, $data, $group);
}
/**
* Is the user allowed to create an on the fly category?
*
* @return bool
*
* @since 3.6.0
*/
private function canCreateCategory()
{
return JFactory::getUser()->authorise('core.create', 'com_weblinks');
}
}

View File

@ -1,285 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Methods supporting a list of weblink records.
*
* @since 1.6
*/
class WeblinksModelWeblinks extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'catid', 'a.catid', 'category_id',
'c.title', 'category_title',
'state', 'a.state', 'published',
'access', 'a.access',
'ag.title', 'access_level',
'created', 'a.created',
'created_by', 'a.created_by',
'ordering', 'a.ordering',
'featured', 'a.featured',
'language', 'a.language',
'l.title', 'language_title',
'hits', 'a.hits',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'url', 'a.url',
'tag',
'level', 'c.level',
);
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$config['filter_fields'][] = 'association';
}
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @note Calling getState in this method will result in recursion.
* @since 1.6
*/
protected function populateState($ordering = 'a.title', $direction = 'asc')
{
$app = JFactory::getApplication();
$forcedLanguage = $app->input->get('forcedLanguage', '', 'cmd');
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Adjust the context to support forced languages.
if ($forcedLanguage)
{
$this->context .= '.' . $forcedLanguage;
}
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.access', $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', '', 'cmd'));
$this->setState('filter.published', $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '', 'string'));
$this->setState('filter.category_id', $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '', 'cmd'));
$this->setState('filter.language', $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '', 'string'));
$this->setState('filter.tag', $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', '', 'string'));
$this->setState('filter.level', $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level', '', 'cmd'));
// Load the parameters.
$params = JComponentHelper::getParams('com_weblinks');
$this->setState('params', $params);
// Force a language.
if (!empty($forcedLanguage))
{
$this->setState('filter.language', $forcedLanguage);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.language');
$id .= ':' . $this->getState('filter.tag');
$id .= ':' . $this->getState('filter.level');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.created, a.created_by, ' .
'a.hits, a.state, a.access, a.ordering, a.language, a.publish_up, a.publish_down'
)
);
$query->from($db->quoteName('#__weblinks', 'a'));
// Join over the language
$query->select($db->quoteName('l.title', 'language_title'))
->select($db->quoteName('l.image', 'language_image'))
->join('LEFT', $db->quoteName('#__languages', 'l') . ' ON ' . $db->qn('l.lang_code') . ' = ' . $db->qn('a.language'));
// Join over the users for the checked out user.
$query->select($db->quoteName('uc.name', 'editor'))
->join('LEFT', $db->quoteName('#__users', 'uc') . ' ON ' . $db->qn('uc.id') . ' = ' . $db->qn('a.checked_out'));
// Join over the asset groups.
$query->select($db->quoteName('ag.title', 'access_level'))
->join('LEFT', $db->quoteName('#__viewlevels', 'ag') . ' ON ' . $db->qn('ag.id') . ' = ' . $db->qn('a.access'));
// Join over the categories.
$query->select('c.title AS category_title')
->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON ' . $db->qn('c.id') . ' = ' . $db->qn('a.catid'));
// Join over the associations.
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$query->select('COUNT(asso2.id)>1 AS association')
->join('LEFT', $db->quoteName('#__associations', 'asso') . ' ON asso.id = a.id AND asso.context = ' . $db->quote('com_weblinks.item'))
->join('LEFT', $db->quoteName('#__associations', 'asso2') . ' ON asso2.key = asso.key')
->group('a.id, l.title, l.image, uc.name, ag.title, c.title');
}
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
$query->where($db->quoteName('a.access') . ' = ' . (int) $access);
}
// Implement View Level Access
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where($db->quoteName('a.access') . ' IN (' . $groups . ')');
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where($db->quoteName('a.state') . ' = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(' . $db->quoteName('a.state') . ' IN (0, 1))');
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
$query->where($db->quoteName('a.catid') . ' = ' . (int) $categoryId);
}
// Filter on the level.
if ($level = $this->getState('filter.level'))
{
$query->where($db->quoteName('c.level') . ' <= ' . (int) $level);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where($db->quoteName('a.id') . ' = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
$query->where('(' . $db->quoteName('a.title') . ' LIKE ' . $search . ' OR ' . $db->quoteName('a.alias') . ' LIKE ' . $search . ')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$query->where($db->quoteName('a.language') . ' = ' . $db->quote($language));
}
$tagId = $this->getState('filter.tag');
// Filter by a single tag.
if (is_numeric($tagId))
{
$query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId)
->join(
'LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_weblinks.weblink')
);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'a.title');
$orderDirn = $this->state->get('list.direction', 'ASC');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title')
{
$orderCol = 'c.title ' . $orderDirn . ', a.ordering';
}
$query->order($db->escape($orderCol . ' ' . $orderDirn));
return $query;
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
@ -7,7 +8,16 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Installer\InstallerAdapter;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Table\Table;
/**
* Installation class to perform additional changes during install/uninstall/update
@ -16,182 +26,231 @@ defined('_JEXEC') or die;
*/
class Com_WeblinksInstallerScript
{
/**
* Function to perform changes during install
*
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void
*
* @since 3.4
*/
public function install($parent)
{
// Initialize a new category
/** @type JTableCategory $category */
$category = JTable::getInstance('Category');
/**
* Function called before extension installation/update/removal procedure commences
*
* @param string $type The type of change (install, update or discover_install, not uninstall)
* @param InstallerAdapter $parent The class calling this method
*
* @return boolean True on success
*
* @since 4.0
*/
public function preflight($type, $parent)
{
$files = [
'/administrator/components/com_weblinks/helpers/associations.php',
'/administrator/components/com_weblinks/sql/install.sqlsrv.sql',
'/administrator/components/com_weblinks/sql/uninstall.sqlsrv.sql',
'/administrator/language/en-GB/en-GB.com_weblinks.ini',
'/administrator/language/en-GB/en-GB.com_weblinks.sys.ini',
'/components/com_weblinks/helpers/association.php',
'/components/com_weblinks/helpers/category.php',
'/language/en-GB/en-GB.com_weblinks.ini',
'/language/en-GB/en-GB.mod_weblinks.ini',
'/language/en-GB/en-GB.mod_weblinks.sys.ini',
'/language/en-GB/en-GB.pkg_weblinks.sys.ini',
'/modules/mod_weblinks/helper.php',
'/modules/mod_weblinks/mod_weblinks.php',
'/plugins/search/weblinks/weblinks.php',
'/plugins/finder/weblinks/weblinks.php',
'/plugins/editors-xtd/weblink/weblink.php',
'plugins/system/weblinks/weblinks.php',
];
// Check if the Uncategorised category exists before adding it
if (!$category->load(array('extension' => 'com_weblinks', 'title' => 'Uncategorised')))
{
$category->extension = 'com_weblinks';
$category->title = 'Uncategorised';
$category->description = '';
$category->published = 1;
$category->access = 1;
$category->params = '{"category_layout":"","image":""}';
$category->metadata = '{"author":"","robots":""}';
$category->metadesc = '';
$category->metakey = '';
$category->language = '*';
$category->checked_out_time = JFactory::getDbo()->getNullDate();
$category->version = 1;
$category->hits = 0;
$category->modified_user_id = 0;
$category->checked_out = 0;
$folders = [
'/administrator/components/com_weblinks/helpers/html',
'/administrator/components/com_weblinks/sql/updates/sqlsrv',
];
// Set the location in the tree
$category->setLocation(1, 'last-child');
foreach ($files as $file) {
if (File::exists(JPATH_ROOT . $file)) {
File::delete(JPATH_ROOT . $file);
}
}
// Check to make sure our data is valid
if (!$category->check())
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
foreach ($folders as $folder) {
if (Folder::exists(JPATH_ROOT . $folder)) {
Folder::delete(JPATH_ROOT . $folder);
}
}
return;
}
return true;
}
// Now store the category
if (!$category->store(true))
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
/**
* Function to perform changes during install
*
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void
*
* @since 3.4
*/
public function install($parent)
{
// Initialize a new category
/** @type Joomla\CMS\Table\Category $category */
$category = Table::getInstance('Category', 'Joomla\\CMS\\Table\\');
return;
}
// Check if the Uncategorised category exists before adding it
if (!$category->load(['extension' => 'com_weblinks', 'title' => 'Uncategorised'])) {
$category->extension = 'com_weblinks';
$category->title = 'Uncategorised';
$category->description = '';
$category->published = 1;
$category->access = 1;
$category->params = '{"category_layout":"","image":""}';
$category->metadata = '{"author":"","robots":""}';
$category->metadesc = '';
$category->metakey = '';
$category->language = '*';
$category->checked_out_time = null;
$category->version = 1;
$category->hits = 0;
$category->modified_user_id = 0;
$category->checked_out = null;
// Build the path for our category
$category->rebuildPath($category->id);
}
}
// Set the location in the tree
$category->setLocation(1, 'last-child');
/**
* Method to run after the install routine.
*
* @param string $type The action being performed
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void
*
* @since 3.4.1
*/
public function postflight($type, $parent)
{
// Only execute database changes on MySQL databases
$dbName = JFactory::getDbo()->name;
// Check to make sure our data is valid
if (!$category->check()) {
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
if (strpos($dbName, 'mysql') !== false)
{
// Add Missing Table Colums if needed
$this->addColumnsIfNeeded();
return;
}
// Drop the Table Colums if needed
$this->dropColumnsIfNeeded();
}
// Now store the category
if (!$category->store(true)) {
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
// Insert missing UCM Records if needed
$this->insertMissingUcmRecords();
}
return;
}
/**
* Method to insert missing records for the UCM tables
*
* @return void
*
* @since 3.4.1
*/
private function insertMissingUcmRecords()
{
// Insert the rows in the #__content_types table if they don't exist already
$db = JFactory::getDbo();
// Build the path for our category
$category->rebuildPath($category->id);
}
}
// Get the type ID for a Weblink
$query = $db->getQuery(true);
$query->select($db->quoteName('type_id'))
->from($db->quoteName('#__content_types'))
->where($db->quoteName('type_alias') . ' = ' . $db->quote('com_weblinks.weblink'));
$db->setQuery($query);
/**
* Method to run after the install routine.
*
* @param string $type The action being performed
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void
*
* @since 3.4.1
*/
public function postflight($type, $parent)
{
// Only execute database changes on MySQL databases
$dbName = Factory::getDbo()->name;
$weblinkTypeId = $db->loadResult();
if (strpos($dbName, 'mysql') !== false) {
// Add Missing Table Columns if needed
$this->addColumnsIfNeeded();
// Get the type ID for a Weblink Category
$query->clear('where');
$query->where($db->quoteName('type_alias') . ' = ' . $db->quote('com_weblinks.category'));
$db->setQuery($query);
// Drop the Table Columns if needed
$this->dropColumnsIfNeeded();
}
$categoryTypeId = $db->loadResult();
// Insert missing UCM Records if needed
$this->insertMissingUcmRecords();
}
// Set the table columns to insert table to
$columnsArray = array(
$db->quoteName('type_title'),
$db->quoteName('type_alias'),
$db->quoteName('table'),
$db->quoteName('rules'),
$db->quoteName('field_mappings'),
$db->quoteName('router'),
$db->quoteName('content_history_options'),
);
/**
* Method to insert missing records for the UCM tables
*
* @return void
*
* @since 3.4.1
*/
private function insertMissingUcmRecords()
{
// Insert the rows in the #__content_types table if they don't exist already
$db = Factory::getDbo();
// If we have no type id for com_weblinks.weblink insert it
if (!$weblinkTypeId)
{
// Insert the data.
$query->clear();
$query->insert($db->quoteName('#__content_types'));
$query->columns($columnsArray);
$query->values(
$db->quote('Weblink') . ', '
. $db->quote('com_weblinks.weblink') . ', '
. $db->quote(
'{"special":{"dbtable":"#__weblinks","key":"id","type":"Weblink","prefix":"WeblinksTable","config":"array()"},
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', '
. $db->quote('') . ', '
. $db->quote(
'{"common":{"core_content_item_id":"id","core_title":"title","core_state":"state","core_alias":"alias",
// Get the type ID for a Weblink
$query = $db->getQuery(true);
$query->select($db->quoteName('type_id'))
->from($db->quoteName('#__content_types'))
->where($db->quoteName('type_alias') . ' = ' . $db->quote('com_weblinks.weblink'));
$db->setQuery($query);
$weblinkTypeId = $db->loadResult();
// Get the type ID for a Weblink Category
$query->clear('where');
$query->where($db->quoteName('type_alias') . ' = ' . $db->quote('com_weblinks.category'));
$db->setQuery($query);
$categoryTypeId = $db->loadResult();
// Set the table columns to insert table to
$columnsArray = [
$db->quoteName('type_title'),
$db->quoteName('type_alias'),
$db->quoteName('table'),
$db->quoteName('rules'),
$db->quoteName('field_mappings'),
$db->quoteName('router'),
$db->quoteName('content_history_options'),
];
// If we have no type id for com_weblinks.weblink insert it
if (!$weblinkTypeId) {
// Insert the data.
$query->clear();
$query->insert($db->quoteName('#__content_types'));
$query->columns($columnsArray);
$query->values(
$db->quote('Weblink') . ', '
. $db->quote('com_weblinks.weblink') . ', '
. $db->quote(
'{"special":{"dbtable":"#__weblinks","key":"id","type":"Weblink","prefix":"WeblinksTable","config":"array()"},
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'
) . ', '
. $db->quote('') . ', '
. $db->quote(
'{"common":{"core_content_item_id":"id","core_title":"title","core_state":"state","core_alias":"alias",
"core_created_time":"created","core_modified_time":"modified","core_body":"description", "core_hits":"hits",
"core_publish_up":"publish_up","core_publish_down":"publish_down","core_access":"access", "core_params":"params",
"core_featured":"featured", "core_metadata":"metadata", "core_language":"language", "core_images":"images", "core_urls":"url",
"core_version":"version", "core_ordering":"ordering", "core_metakey":"metakey", "core_metadesc":"metadesc",
"core_catid":"catid", "core_xreference":"xreference", "asset_id":"null"}, "special":{}}') . ', '
. $db->quote('WeblinksHelperRoute::getWeblinkRoute') . ', '
. $db->quote(
'{"formFile":"administrator\\/components\\/com_weblinks\\/models\\/forms\\/weblink.xml",
"core_catid":"catid", "core_xreference":"xreference", "asset_id":"null"}, "special":{}}'
) . ', '
. $db->quote('WeblinksHelperRoute::getWeblinkRoute') . ', '
. $db->quote(
'{"formFile":"administrator\\/components\\/com_weblinks\\/models\\/forms\\/weblink.xml",
"hideFields":["asset_id","checked_out","checked_out_time","version","featured","images"], "ignoreChanges":["modified_by",
"modified", "checked_out", "checked_out_time", "version", "hits"], "convertToInt":["publish_up", "publish_down", "featured",
"ordering"], "displayLookup":[{"sourceColumn":"catid","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"},
{"sourceColumn":"created_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},
{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},
{"sourceColumn":"modified_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"} ]}')
);
{"sourceColumn":"modified_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"} ]}'
)
);
$db->setQuery($query);
$db->execute();
}
$db->setQuery($query);
$db->execute();
}
// If we have no type id for com_weblinks.category insert it
if (!$categoryTypeId)
{
// Insert the data.
$query->clear();
$query->insert($db->quoteName('#__content_types'));
$query->columns($columnsArray);
$query->values(
$db->quote('Weblinks Category') . ', '
. $db->quote('com_weblinks.category') . ', '
. $db->quote('
// If we have no type id for com_weblinks.category insert it
if (!$categoryTypeId) {
// Insert the data.
$query->clear();
$query->insert($db->quoteName('#__content_types'));
$query->columns($columnsArray);
$query->values(
$db->quote('Weblinks Category') . ', '
. $db->quote('com_weblinks.category') . ', '
. $db->quote('
{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', '
. $db->quote('') . ', '
. $db->quote('
. $db->quote('') . ', '
. $db->quote('
{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias",
"core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description",
"core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access",
@ -199,8 +258,8 @@ class Com_WeblinksInstallerScript
"core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey",
"core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"},
"special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}') . ', '
. $db->quote('WeblinksHelperRoute::getCategoryRoute') . ', '
. $db->quote('
. $db->quote('WeblinksHelperRoute::getCategoryRoute') . ', '
. $db->quote('
{"formFile":"administrator\\/components\\/com_categories\\/models\\/forms\\/category.xml",
"hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"],
"ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version",
@ -210,66 +269,63 @@ class Com_WeblinksInstallerScript
"displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id",
"displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id",
"displayColumn":"title"}]}')
);
);
$db->setQuery($query);
$db->execute();
}
}
$db->setQuery($query);
$db->execute();
}
}
/**
* Method to drop colums from #__weblinks if they still there.
*
* @return void
*
* @since 3.4.1
*/
private function dropColumnsIfNeeded()
{
$oldColumns = array(
'sid',
'date',
'archived',
'approved',
);
/**
* Method to drop colums from #__weblinks if they still there.
*
* @return void
*
* @since 3.4.1
*/
private function dropColumnsIfNeeded()
{
$oldColumns = [
'sid',
'date',
'archived',
'approved',
];
$db = JFactory::getDbo();
$table = $db->getTableColumns('#__weblinks');
$db = Factory::getDbo();
$table = $db->getTableColumns('#__weblinks');
$columns = array_intersect($oldColumns, array_keys($table));
$columns = array_intersect($oldColumns, array_keys($table));
foreach ($columns as $column)
{
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' DROP COLUMN ' . $db->quoteName($column);
$db->setQuery($sql);
$db->execute();
}
}
foreach ($columns as $column) {
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' DROP COLUMN ' . $db->quoteName($column);
$db->setQuery($sql);
$db->execute();
}
}
/**
* Method to add colums from #__weblinks if they are missing.
*
* @return void
*
* @since 3.4.1
*/
private function addColumnsIfNeeded()
{
$db = JFactory::getDbo();
$table = $db->getTableColumns('#__weblinks');
/**
* Method to add colums from #__weblinks if they are missing.
*
* @return void
*
* @since 3.4.1
*/
private function addColumnsIfNeeded()
{
$db = Factory::getDbo();
$table = $db->getTableColumns('#__weblinks');
if (!array_key_exists('version', $table))
{
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' ADD COLUMN ' . $db->quoteName('version') . " int(10) unsigned NOT NULL DEFAULT '1'";
$db->setQuery($sql);
$db->execute();
}
if (!array_key_exists('version', $table)) {
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' ADD COLUMN ' . $db->quoteName('version') . " int unsigned NOT NULL DEFAULT '1'";
$db->setQuery($sql);
$db->execute();
}
if (!array_key_exists('images', $table))
{
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' ADD COLUMN ' . $db->quoteName('images') . ' text NOT NULL';
$db->setQuery($sql);
$db->execute();
}
}
if (!array_key_exists('images', $table)) {
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' ADD COLUMN ' . $db->quoteName('images') . ' text NOT NULL';
$db->setQuery($sql);
$db->execute();
}
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Association\AssociationExtensionInterface;
use Joomla\CMS\Categories\CategoryFactoryInterface;
use Joomla\CMS\Component\Router\RouterFactoryInterface;
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\Service\Provider\CategoryFactory;
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
use Joomla\CMS\Extension\Service\Provider\RouterFactory;
use Joomla\CMS\HTML\Registry;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Component\Weblinks\Administrator\Extension\WeblinksComponent;
use Joomla\Component\Weblinks\Administrator\Helper\AssociationsHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
/**
* The weblinks service provider.
*
* @since 4.0.0
*/
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.0.0
*/
public function register(Container $container)
{
$container->set(AssociationExtensionInterface::class, new AssociationsHelper());
$componentNamespace = '\\Joomla\\Component\\Weblinks';
$container->registerServiceProvider(new CategoryFactory($componentNamespace));
$container->registerServiceProvider(new MVCFactory($componentNamespace));
$container->registerServiceProvider(new ComponentDispatcherFactory($componentNamespace));
$container->registerServiceProvider(new RouterFactory($componentNamespace));
$container->set(ComponentInterface::class, function (Container $container) {
$component = new WeblinksComponent($container->get(ComponentDispatcherFactoryInterface::class));
$component->setRegistry($container->get(Registry::class));
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
$component->setCategoryFactory($container->get(CategoryFactoryInterface::class));
$component->setAssociationExtension($container->get(AssociationExtensionInterface::class));
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
return $component;
});
}
};

View File

@ -11,33 +11,33 @@ INSERT INTO `#__content_types` (`type_title`, `type_alias`, `table`, `rules`, `f
--
CREATE TABLE IF NOT EXISTS `#__weblinks` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`catid` int(11) NOT NULL DEFAULT 0,
`id` int unsigned NOT NULL AUTO_INCREMENT,
`catid` int NOT NULL DEFAULT 0,
`title` varchar(250) NOT NULL DEFAULT '',
`alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
`url` varchar(250) NOT NULL DEFAULT '',
`description` text NOT NULL,
`hits` int(11) NOT NULL DEFAULT 0,
`state` tinyint(1) NOT NULL DEFAULT 0,
`checked_out` int(11) NOT NULL DEFAULT 0,
`checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ordering` int(11) NOT NULL DEFAULT 0,
`access` int(11) NOT NULL DEFAULT 1,
`hits` int NOT NULL DEFAULT 0,
`state` tinyint NOT NULL DEFAULT 0,
`checked_out` int unsigned,
`checked_out_time` datetime,
`ordering` int NOT NULL DEFAULT 0,
`access` int NOT NULL DEFAULT 1,
`params` text NOT NULL,
`language` char(7) NOT NULL DEFAULT '',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` int(10) unsigned NOT NULL DEFAULT 0,
`created` datetime NOT NULL,
`created_by` int unsigned NOT NULL DEFAULT 0,
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_by` int(10) unsigned NOT NULL DEFAULT 0,
`modified` datetime NOT NULL,
`modified_by` int unsigned NOT NULL DEFAULT 0,
`metakey` text NOT NULL,
`metadesc` text NOT NULL,
`metadata` text NOT NULL,
`featured` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT 'Set if link is featured.',
`featured` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Set if link is featured.',
`xreference` varchar(50) NOT NULL COMMENT 'A reference to enable linkages to external data sets.',
`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`version` int(10) unsigned NOT NULL DEFAULT 1,
`publish_up` datetime,
`publish_down` datetime,
`version` int unsigned NOT NULL DEFAULT 1,
`images` text NOT NULL,
PRIMARY KEY (`id`),
KEY `idx_access` (`access`),

View File

@ -17,24 +17,24 @@ CREATE TABLE "#__weblinks" (
"description" text NOT NULL,
"hits" bigint DEFAULT 0 NOT NULL,
"state" smallint DEFAULT 0 NOT NULL,
"checked_out" bigint DEFAULT 0 NOT NULL,
"checked_out_time" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"checked_out" integer,
"checked_out_time" timestamp without time zone,
"ordering" bigint DEFAULT 0 NOT NULL,
"access" bigint DEFAULT 1 NOT NULL,
"params" text NOT NULL,
"language" varchar(7) DEFAULT '' NOT NULL,
"created" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"created" timestamp without time zone NOT NULL,
"created_by" integer DEFAULT 0 NOT NULL,
"created_by_alias" varchar(255) DEFAULT '' NOT NULL,
"modified" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"modified" timestamp without time zone NOT NULL,
"modified_by" integer DEFAULT 0 NOT NULL,
"metakey" text NOT NULL,
"metadesc" text NOT NULL,
"metadata" text NOT NULL,
"featured" smallint DEFAULT 0 NOT NULL,
"xreference" varchar(50) NOT NULL,
"publish_up" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"publish_down" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"publish_up" timestamp without time zone,
"publish_down" timestamp without time zone,
"version" bigint DEFAULT 1 NOT NULL,
"images" text NOT NULL,
PRIMARY KEY ("id")

View File

@ -1,84 +0,0 @@
/****** Insert data into table [#__content_types] for UCM functions ******/
INSERT [#__content_types] ([type_title], [type_alias], [table], [rules], [field_mappings], [router], [content_history_options])
SELECT 'Weblink', 'com_weblinks.weblink', '{"special":{"dbtable":"#__weblinks","key":"id","type":"Weblink","prefix":"WeblinksTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}', '', '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"state","core_alias":"alias","core_created_time":"created","core_modified_time":"modified","core_body":"description", "core_hits":"hits","core_publish_up":"publish_up","core_publish_down":"publish_down","core_access":"access", "core_params":"params", "core_featured":"featured", "core_metadata":"metadata", "core_language":"language", "core_images":"images", "core_urls":"urls", "core_version":"version", "core_ordering":"ordering", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"catid", "core_xreference":"xreference", "asset_id":"null"}, "special":{}}', 'WeblinksHelperRoute::getWeblinkRoute', '{"formFile":"administrator\/components\/com_weblinks\/models\/forms\/weblink.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","featured","images"], "ignoreChanges":["modified_by", "modified", "checked_out", "checked_out_time", "version", "hits"], "convertToInt":["publish_up", "publish_down", "featured", "ordering"], "displayLookup":[{"sourceColumn":"catid","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"created_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"} ]}'
UNION ALL
SELECT 'Weblinks Category', 'com_weblinks.category', '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}', '', '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}', 'WeblinksHelperRoute::getCategoryRoute', '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}';
/****** Object: Table [#__weblinks] ******/
SET QUOTED_IDENTIFIER ON;
CREATE TABLE [#__weblinks](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[catid] [int] NOT NULL DEFAULT 0,
[title] [nvarchar](250) NOT NULL DEFAULT '',
[alias] [nvarchar](255) NOT NULL,
[url] [nvarchar](250) NOT NULL DEFAULT '',
[description] [nvarchar](max) NOT NULL,
[hits] [int] NOT NULL DEFAULT 0,
[state] [smallint] NOT NULL DEFAULT 0,
[checked_out] [int] NOT NULL DEFAULT 0,
[checked_out_time] [datetime] NOT NULL DEFAULT '1900-01-01T00:00:00.000',
[ordering] [int] NOT NULL DEFAULT 0,
[access] [int] NOT NULL DEFAULT 1,
[params] [nvarchar](max) NOT NULL,
[language] [nvarchar](7) NOT NULL DEFAULT '',
[created] [datetime] NOT NULL DEFAULT '1900-01-01T00:00:00.000',
[created_by] [bigint] NOT NULL DEFAULT 0,
[created_by_alias] [nvarchar](255) NOT NULL DEFAULT '',
[modified] [datetime] NOT NULL DEFAULT '1900-01-01T00:00:00.000',
[modified_by] [bigint] NOT NULL DEFAULT 0,
[metakey] [nvarchar](max) NOT NULL,
[metadesc] [nvarchar](max) NOT NULL,
[metadata] [nvarchar](max) NOT NULL,
[featured] [tinyint] NOT NULL DEFAULT 0,
[xreference] [nvarchar](50) NOT NULL,
[publish_up] [datetime] NOT NULL DEFAULT '1900-01-01T00:00:00.000',
[publish_down] [datetime] NOT NULL DEFAULT '1900-01-01T00:00:00.000',
[version] [bigint] NOT NULL DEFAULT 1,
[images] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_#__weblinks_id] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY];
CREATE NONCLUSTERED INDEX [idx_access] ON [#__weblinks]
(
[access] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF);
CREATE NONCLUSTERED INDEX [idx_catid] ON [#__weblinks]
(
[catid] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF);
CREATE NONCLUSTERED INDEX [idx_checkout] ON [#__weblinks]
(
[checked_out] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF);
CREATE NONCLUSTERED INDEX [idx_createdby] ON [#__weblinks]
(
[created_by] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF);
CREATE NONCLUSTERED INDEX [idx_featured_catid] ON [#__weblinks]
(
[featured] ASC,
[catid] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF);
CREATE NONCLUSTERED INDEX [idx_language] ON [#__weblinks]
(
[language] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF);
CREATE NONCLUSTERED INDEX [idx_state] ON [#__weblinks]
(
[state] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF);
CREATE NONCLUSTERED INDEX [idx_xreference] ON [#__weblinks]
(
[xreference] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF);

View File

@ -1,3 +1 @@
DELETE FROM `#__content_types` WHERE `type_alias` IN ('com_weblinks.weblink', 'com_weblinks.category');
DROP TABLE IF EXISTS `#__weblinks`;

View File

@ -1,3 +1 @@
DELETE FROM "#__content_types" WHERE "type_alias" IN ('com_weblinks.weblink', 'com_weblinks.category');
DROP TABLE IF EXISTS "#__weblinks";

View File

@ -1,3 +0,0 @@
DELETE FROM [#__content_types] WHERE [type_alias] IN ('com_weblinks.weblink', 'com_weblinks.category');
DROP TABLE IF EXISTS [#__weblinks];

View File

@ -0,0 +1,35 @@
ALTER TABLE `#__weblinks` MODIFY `created` datetime NOT NULL;
ALTER TABLE `#__weblinks` MODIFY `modified` datetime NOT NULL;
ALTER TABLE `#__weblinks` MODIFY `publish_up` datetime NULL DEFAULT NULL;
ALTER TABLE `#__weblinks` MODIFY `publish_down` datetime NULL DEFAULT NULL;
ALTER TABLE `#__weblinks` MODIFY `checked_out_time` datetime NULL DEFAULT NULL;
ALTER TABLE `#__weblinks` MODIFY `checked_out` int unsigned;
UPDATE `#__weblinks` SET `modified` = `created` WHERE `modified` = '0000-00-00 00:00:00';
UPDATE `#__weblinks` SET `publish_up` = NULL WHERE `publish_up` = '0000-00-00 00:00:00';
UPDATE `#__weblinks` SET `publish_down` = NULL WHERE `publish_down` = '0000-00-00 00:00:00';
UPDATE `#__weblinks` SET `checked_out_time` = NULL WHERE `checked_out_time` = '0000-00-00 00:00:00';
UPDATE `#__weblinks` SET `checked_out` = null WHERE `checked_out` = 0;
UPDATE `#__categories` SET `modified_time` = `created_time` WHERE `modified_time` = '0000-00-00 00:00:00' AND `extension` = 'com_weblinks';
UPDATE `#__categories` SET `checked_out_time` = NULL WHERE `checked_out_time` = '0000-00-00 00:00:00' AND `extension` = 'com_weblinks';
UPDATE `#__ucm_content` SET `core_modified_time` = `core_created_time`
WHERE `core_type_alias` IN ('com_weblinks.weblink', 'com_weblinks.category')
AND `core_modified_time` = '0000-00-00 00:00:00';
UPDATE `#__ucm_content` SET `core_publish_up` = NULL
WHERE `core_type_alias` = 'com_weblinks.weblink'
AND `core_publish_up` = '0000-00-00 00:00:00';
UPDATE `#__ucm_content` SET `core_publish_down` = NULL
WHERE `core_type_alias` = 'com_weblinks.weblink'
AND `core_publish_down` = '0000-00-00 00:00:00';
UPDATE `#__ucm_content` SET `core_checked_out_time` = NULL
WHERE `core_type_alias` IN ('com_weblinks.weblink', 'com_weblinks.category')
AND `core_checked_out_time` = '0000-00-00 00:00:00';

View File

@ -0,0 +1,42 @@
ALTER TABLE "#__weblinks" ALTER COLUMN "created" DROP DEFAULT;
ALTER TABLE "#__weblinks" ALTER COLUMN "modified" DROP DEFAULT;
ALTER TABLE "#__weblinks" ALTER COLUMN "publish_up" DROP NOT NULL;
ALTER TABLE "#__weblinks" ALTER COLUMN "publish_up" DROP DEFAULT;
ALTER TABLE "#__weblinks" ALTER COLUMN "publish_down" DROP NOT NULL;
ALTER TABLE "#__weblinks" ALTER COLUMN "publish_down" DROP DEFAULT;
ALTER TABLE "#__weblinks" ALTER COLUMN "checked_out_time" DROP NOT NULL;
ALTER TABLE "#__weblinks" ALTER COLUMN "checked_out_time" DROP DEFAULT;
ALTER TABLE "#__weblinks" ALTER COLUMN "checked_out" DROP NOT NULL;
ALTER TABLE "#__weblinks" ALTER COLUMN "checked_out" DROP DEFAULT;
UPDATE "#__weblinks" SET "modified" = "created" WHERE "modified" = '1970-01-01 00:00:00';
UPDATE "#__weblinks" SET "publish_up" = NULL WHERE "publish_up" = '1970-01-01 00:00:00';
UPDATE "#__weblinks" SET "publish_down" = NULL WHERE "publish_down" = '1970-01-01 00:00:00';
UPDATE "#__weblinks" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00';
UPDATE "#__weblinks" SET "checked_out" = null WHERE "checked_out" = 0;
UPDATE "#__categories" SET "modified_time" = "created_time" WHERE "modified_time" = '1970-01-01 00:00:00' AND "extension" = 'com_weblinks';
UPDATE "#__categories" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00' AND "extension" = 'com_weblinks';
UPDATE "#__ucm_content" SET "core_modified_time" = "core_created_time"
WHERE "core_type_alias" IN ('com_weblinks.weblink', 'com_weblinks.category')
AND "core_modified_time" = '1970-01-01 00:00:00';
UPDATE "#__ucm_content" SET "core_publish_up" = NULL
WHERE "core_type_alias" = 'com_weblinks.weblink'
AND "core_publish_up" = '1970-01-01 00:00:00';
UPDATE "#__ucm_content" SET "core_publish_down" = NULL
WHERE "core_type_alias" = 'com_weblinks.weblink'
AND "core_publish_down" = '1970-01-01 00:00:00';
UPDATE "#__ucm_content" SET "core_checked_out_time" = NULL
WHERE "core_type_alias" IN ('com_weblinks.weblink', 'com_weblinks.category')
AND "core_checked_out_time" = '1970-01-01 00:00:00';

View File

@ -1 +0,0 @@
# Placeholder file to set the extension database schema version

View File

@ -0,0 +1,63 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Controller;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Router\Route;
/**
* Weblinks Main Controller
*
* @since 1.5
*/
class DisplayController extends BaseController
{
/**
* The default view.
*
* @var string
* @since 1.6
*/
protected $default_view = 'weblinks';
/**
* Method to display a view.
*
* @param boolean $cacheable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types,
* for valid values see {@link JFilterInput::clean()}.
*
* @return BaseController|boolean This object to support chaining.
*
* @since 1.5
*/
public function display($cacheable = false, $urlparams = false)
{
$view = $this->input->get('view', 'weblinks');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');
// Check for edit form.
if ($view == 'weblink' && $layout == 'edit' && !$this->checkEditId('com_weblinks.edit.weblink', $id)) {
// Somehow the person just went to the form - we don't allow that.
if (!\count($this->app->getMessageQueue())) {
$this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');
}
$this->setRedirect(Route::_('index.php?option=com_weblinks&view=weblinks', false));
return false;
}
return parent::display();
}
}

View File

@ -0,0 +1,130 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Controller;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Versioning\VersionableControllerTrait;
use Joomla\Utilities\ArrayHelper;
/**
* Weblink controller class.
*
* @since 1.6
*/
class WeblinkController extends FormController
{
use VersionableControllerTrait;
/**
* Method override to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 1.6
*/
protected function allowAdd($data = [])
{
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
if ($categoryId) {
// If the category has been passed in the URL check it.
return $this->app->getIdentity()->authorise('core.create', $this->option . '.category.' . $categoryId);
}
// In the absence of better information, revert to the component permissions.
return parent::allowAdd($data);
}
/**
* Method to check if you can add a new record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = [], $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
// Since there is no asset tracking, fallback to the component permissions.
if (!$recordId) {
return parent::allowEdit($data, $key);
}
// Get the item.
$item = $this->getModel()->getItem($recordId);
// Since there is no item, return false.
if (empty($item)) {
return false;
}
$user = $this->app->getIdentity();
// Check if can edit own core.edit.own.
$canEditOwn = $user->authorise('core.edit.own', $this->option . '.category.' . (int) $item->catid) && $item->created_by == $user->id;
// Check the category core.edit permissions.
return $canEditOwn || $user->authorise('core.edit', $this->option . '.category.' . (int) $item->catid);
}
/**
* Method to run batch operations.
*
* @param object $model The model.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 1.7
*/
public function batch($model = null)
{
$this->checkToken();
// Set the model
$model = $this->getModel('Weblink', 'Administrator', []);
// Preset the redirect
$this->setRedirect(Route::_('index.php?option=com_weblinks&view=weblinks' . $this->getRedirectToListAppend(), false));
return parent::batch($model);
}
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param \Joomla\CMS\MVC\Model\BaseDatabaseModel $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 1.6
*/
protected function postSaveHook(BaseDatabaseModel $model, $validData = [])
{
$task = $this->getTask();
if ($task == 'save') {
$this->setRedirect(Route::_('index.php?option=com_weblinks&view=weblinks', false));
}
}
}

View File

@ -0,0 +1,40 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Controller;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\MVC\Controller\AdminController;
/**
* Weblinks list controller class.
*
* @since 1.6
*/
class WeblinksController extends AdminController
{
/**
* Proxy for getModel
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config The array of possible config values. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'Weblink', $prefix = 'Administrator', $config = ['ignore_request' => true])
{
return parent::getModel($name, $prefix, $config);
}
}

View File

@ -0,0 +1,143 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Extension;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Association\AssociationServiceInterface;
use Joomla\CMS\Association\AssociationServiceTrait;
use Joomla\CMS\Categories\CategoryServiceInterface;
use Joomla\CMS\Categories\CategoryServiceTrait;
use Joomla\CMS\Component\Router\RouterServiceInterface;
use Joomla\CMS\Component\Router\RouterServiceTrait;
use Joomla\CMS\Extension\BootableExtensionInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Factory;
use Joomla\CMS\Fields\FieldsServiceInterface;
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Tag\TagServiceInterface;
use Joomla\CMS\Tag\TagServiceTrait;
use Joomla\Component\Weblinks\Administrator\Service\HTML\AdministratorService;
use Joomla\Component\Weblinks\Administrator\Service\HTML\Icon;
use Psr\Container\ContainerInterface;
/**
* Component class for com_weblinks
*
* @since 4.0.0
*/
class WeblinksComponent extends MVCComponent implements
CategoryServiceInterface,
AssociationServiceInterface,
TagServiceInterface,
RouterServiceInterface,
BootableExtensionInterface,
FieldsServiceInterface
{
use CategoryServiceTrait;
use AssociationServiceTrait;
use HTMLRegistryAwareTrait;
use RouterServiceTrait;
use CategoryServiceTrait, TagServiceTrait {
CategoryServiceTrait::getTableNameForSection insteadof TagServiceTrait;
CategoryServiceTrait::getStateColumnForSection insteadof TagServiceTrait;
}
/**
* Booting the extension. This is the function to set up the environment of the extension like
* registering new class loaders, etc.
*
* If required, some initial set up can be done from services of the container, eg.
* registering HTML services.
*
* @param ContainerInterface $container The container
*
* @return void
*
* @since 4.0.0
*/
public function boot(ContainerInterface $container)
{
$this->getRegistry()->register('weblinksadministrator', new AdministratorService());
$this->getRegistry()->register('weblinkicon', new Icon($container->get(SiteApplication::class)));
}
/**
* Returns a valid section for the given section. If it is not valid then null
* is returned.
*
* @param string $section The section to get the mapping for
* @param object $item The item
*
* @return string|null The new section
*
* @since 4.0.0
*/
public function validateSection($section, $item = null)
{
if ($section != 'weblink') {
// We don't know other sections
return null;
}
return $section;
}
/**
* Returns valid contexts
*
* @return array
*
* @since 4.0.0
*/
public function getContexts(): array
{
Factory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR);
$contexts = [
'com_weblinks.weblink' => Text::_('COM_WEBLINKS'),
];
return $contexts;
}
/**
* Returns the table for the count items functions for the given section.
*
* @param string $section The section
*
* @return string|null
*
* @since 4.0.0
*/
protected function getTableNameForSection(string $section = null)
{
return ($section === 'category' ? 'categories' : 'weblinks');
}
/**
* Returns the state column for the count items functions for the given section.
*
* @param string $section The section
*
* @return string|null
*
* @since 4.0.0
*/
protected function getStateColumnForSection(string $section = null)
{
return 'state';
}
}

View File

@ -0,0 +1,251 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Field\Modal;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
use Joomla\Database\ParameterType;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Supports a modal weblink picker.
*
* @since __DEPLOY_VERSION__
*/
class WeblinkField extends FormField
{
/**
* The form field type.
*
* @var string
* @since __DEPLOY_VERSION__
*/
protected $type = 'Modal_Weblink';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since __DEPLOY_VERSION__
*/
protected function getInput()
{
$allowNew = ((string) $this->element['new'] == 'true');
$allowEdit = ((string) $this->element['edit'] == 'true');
$allowClear = ((string) $this->element['clear'] != 'false');
$allowSelect = ((string) $this->element['select'] != 'false');
// Load language
Factory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR);
// The active weblink id field.
$value = (int) $this->value > 0 ? (int) $this->value : '';
// Create the modal id.
$modalId = 'Weblink_' . $this->id;
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
// Add the modal field script to the document head.
$wa->useScript('field.modal-fields');
// Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect) {
static $scriptSelect = null;
if (is_null($scriptSelect)) {
$scriptSelect = [];
}
if (!isset($scriptSelect[$this->id])) {
$wa->addInlineScript(
"
window.jSelectWeblink_" . $this->id . " = function (id, title, catid, object, url, language) {
window.processModalSelect('Article', '" . $this->id . "', id, title, catid, object, url, language);
}",
[],
['type' => 'module']
);
Text::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
$scriptSelect[$this->id] = true;
}
}
// Setup variables for display.
$linkWeblinks = 'index.php?option=com_weblinks&amp;view=weblinks&amp;layout=modal&amp;tmpl=component&amp;' . Session::getFormToken() . '=1';
$linkWeblink = 'index.php?option=com_weblinks&amp;view=weblink&amp;layout=modal&amp;tmpl=component&amp;' . Session::getFormToken() . '=1';
$modalTitle = Text::_('COM_WEBLINKS_CHANGE_WEBLINK');
if (isset($this->element['language'])) {
$linkWeblinks .= '&amp;forcedLanguage=' . $this->element['language'];
$linkWeblink .= '&amp;forcedLanguage=' . $this->element['language'];
$modalTitle .= ' &#8212; ' . $this->element['label'];
}
$urlSelect = $linkWeblinks . '&amp;function=jSelectWeblink_' . $this->id;
$urlEdit = $linkWeblink . '&amp;task=weblink.edit&amp;id=\' + document.getElementById("' . $this->id . '_id").value + \'';
$urlNew = $linkWeblink . '&amp;task=weblink.add';
if ($value) {
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__weblinks'))
->where($db->quoteName('id') . ' = :id')
->bind(':id', $value, ParameterType::INTEGER);
$db->setQuery($query);
try {
$title = $db->loadResult();
} catch (\RuntimeException $e) {
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
}
$title = empty($title) ? Text::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// The current weblink display field.
$html = '';
if ($allowSelect || $allowNew || $allowEdit || $allowClear) {
$html .= '<span class="input-group">';
}
$html .= '<input class="form-control" id="' . $this->id . '_name" type="text" value="' . $title . '" readonly size="35">';
// Select weblink button
if ($allowSelect) {
$html .= '<button'
. ' class="btn btn-primary' . ($value ? ' hidden' : '') . '"'
. ' id="' . $this->id . '_select"'
. ' data-bs-toggle="modal"'
. ' type="button"'
. ' data-bs-target="#ModalSelect' . $modalId . '">'
. '<span class="icon-file" aria-hidden="true"></span> ' . Text::_('JSELECT')
. '</button>';
}
// New weblink button
if ($allowNew) {
$html .= '<button'
. ' class="btn btn-secondary' . ($value ? ' hidden' : '') . '"'
. ' id="' . $this->id . '_new"'
. ' data-bs-toggle="modal"'
. ' type="button"'
. ' data-bs-target="#ModalNew' . $modalId . '">'
. '<span class="icon-plus" aria-hidden="true"></span> ' . Text::_('JACTION_CREATE')
. '</button>';
}
// Edit weblink button
if ($allowEdit) {
$html .= '<button'
. ' class="btn btn-primary' . ($value ? '' : ' hidden') . '"'
. ' id="' . $this->id . '_edit"'
. ' data-bs-toggle="modal"'
. ' type="button"'
. ' data-bs-target="#ModalEdit' . $modalId . '">'
. '<span class="icon-pen-square" aria-hidden="true"></span> ' . Text::_('JACTION_EDIT')
. '</button>';
}
// Clear weblink button
if ($allowClear) {
$html .= '<button'
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
. ' id="' . $this->id . '_clear"'
. ' type="button"'
. ' onclick="window.processModalParent(\'' . $this->id . '\'); return false;">'
. '<span class="icon-times" aria-hidden="true"></span> ' . Text::_('JCLEAR')
. '</button>';
}
if ($allowSelect || $allowNew || $allowEdit || $allowClear) {
$html .= '</span>';
}
// Select weblink modal
if ($allowSelect) {
$html .= HTMLHelper::_('bootstrap.renderModal', 'ModalSelect' . $modalId, [
'title' => $modalTitle,
'url' => $urlSelect,
'height' => '400px',
'width' => '800px',
'bodyHeight' => 70,
'modalWidth' => 80,
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>',
]);
}
$closeButtonClick = "window.processModalEdit(this, '$this->id', 'add', 'weblink', 'cancel', 'weblink-form'); return false;";
$saveButtonClick = "window.processModalEdit(this, '$this->id', 'add', 'weblink', 'save', 'weblink-form'); return false;";
$applyButtonClick = "window.processModalEdit(this, '$this->id', 'add', 'weblink', 'apply', 'weblink-form'); return false;";
// New weblink modal
if ($allowNew) {
$html .= HTMLHelper::_('bootstrap.renderModal', 'ModalNew' . $modalId, [
'title' => Text::_('COM_WEBLINKS_NEW_WEBLINK'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlNew,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<a role="button" class="btn" aria-hidden="true"'
. ' onclick="' . $closeButtonClick . '">'
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>'
. '<a role="button" class="btn btn-primary" aria-hidden="true"'
. ' onclick="' . $saveButtonClick . '">'
. Text::_('JSAVE') . '</a>'
. '<a role="button" class="btn btn-success" aria-hidden="true"'
. ' onclick="' . $applyButtonClick . '">'
. Text::_('JAPPLY') . '</a>',
]);
}
// Edit weblink modal
if ($allowEdit) {
$html .= HTMLHelper::_('bootstrap.renderModal', 'ModalEdit' . $modalId, [
'title' => Text::_('COM_WEBLINKS_EDIT_WEBLINK'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
'url' => $urlEdit,
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => '<a role="button" class="btn" aria-hidden="true"'
. ' onclick="' . $closeButtonClick . '">'
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>'
. '<a role="button" class="btn btn-primary" aria-hidden="true"'
. ' onclick="' . $saveButtonClick . '">'
. Text::_('JSAVE') . '</a>'
. '<a role="button" class="btn btn-success" aria-hidden="true"'
. ' onclick="' . $applyButtonClick . '">'
. Text::_('JAPPLY') . '</a>',
]);
}
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required modal-value"' : '';
$html .= '<input type="hidden" id="' . $this->id . '_id" ' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
. '" data-text="' . htmlspecialchars(Text::_('COM_WEBLINKS_SELECT_A_WEBLINK', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';
return $html;
}
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since __DEPLOY_VERSION__
*/
protected function getLabel()
{
return str_replace($this->id, $this->id . '_name', parent::getLabel());
}
}

View File

@ -0,0 +1,188 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Helper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Association\AssociationExtensionHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Table\Table;
use Joomla\Component\Weblinks\Site\Helper\AssociationHelper;
/**
* Content associations helper.
*
* @since __DEPLOY_VERSION__
*/
class AssociationsHelper extends AssociationExtensionHelper
{
/**
* The extension name
*
* @var string $extension
*
* @since __DEPLOY_VERSION__
*/
protected $extension = 'com_weblinks';
/**
* Array of item types
*
* @var array $itemTypes
*
* @since __DEPLOY_VERSION__
*/
protected $itemTypes = ['weblink', 'category'];
/**
* Has the extension association support
*
* @var boolean $associationsSupport
*
* @since __DEPLOY_VERSION__
*/
protected $associationsSupport = true;
/**
* Method to get the associations for a given item.
*
* @param integer $id Id of the item
* @param string $view Name of the view
*
* @return array Array of associations for the item
*
* @since 4.0.0
*/
public function getAssociationsForItem($id = 0, $view = null)
{
return AssociationHelper::getAssociations($id, $view);
}
/**
* Get the associated items for an item
*
* @param string $typeName The item type
* @param int $id The id of item for which we need the associated items
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public function getAssociations($typeName, $id)
{
$type = $this->getType($typeName);
$context = $this->extension . '.item';
$catidField = 'catid';
if ($typeName === 'category') {
$context = 'com_categories.item';
$catidField = '';
}
// Get the associations.
$associations = Associations::getAssociations($this->extension, $type['tables']['a'], $context, $id, 'id', 'alias', $catidField);
return $associations;
}
/**
* Get item information
*
* @param string $typeName The item type
* @param int $id The id of item for which we need the associated items
*
* @return Table|null
*
* @since __DEPLOY_VERSION__
*/
public function getItem($typeName, $id)
{
if (empty($id)) {
return null;
}
$table = null;
switch ($typeName) {
case 'weblink':
$table = Table::getInstance('WeblinkTable', 'Joomla\\Component\\Weblinks\\Administrator\\Table\\');
break;
case 'category':
$table = Table::getInstance('Category', 'Joomla\\CMS\\Table\\');
break;
}
if (empty($table)) {
return null;
}
$table->load($id);
return $table;
}
/**
* Get information about the type
*
* @param string $typeName The item type
*
* @return array Array of item types
*
* @since __DEPLOY_VERSION__
*/
public function getType($typeName = '')
{
$fields = $this->getFieldsTemplate();
$tables = [];
$joins = [];
$support = $this->getSupportTemplate();
$title = '';
if (in_array($typeName, $this->itemTypes)) {
switch ($typeName) {
case 'weblink':
$support['state'] = true;
$support['acl'] = true;
$support['checkout'] = true;
$support['category'] = true;
$support['save2copy'] = true;
$tables = [
'a' => '#__weblinks',
];
$title = 'weblink';
break;
case 'category':
$fields['created_user_id'] = 'a.created_user_id';
$fields['ordering'] = 'a.lft';
$fields['level'] = 'a.level';
$fields['catid'] = '';
$fields['state'] = 'a.published';
$support['state'] = true;
$support['acl'] = true;
$support['checkout'] = true;
$support['level'] = true;
$tables = [
'a' => '#__categories',
];
$title = 'category';
break;
}
}
return [
'fields' => $fields,
'support' => $support,
'tables' => $tables,
'joins' => $joins,
'title' => $title,
];
}
}

View File

@ -0,0 +1,25 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Helper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Helper\ContentHelper;
/**
* Weblinks helper.
*
* @since 1.6
*/
class WeblinksHelper extends ContentHelper
{
}

View File

@ -0,0 +1,418 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Model;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\TagsHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Versioning\VersionableModelTrait;
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
/**
* Weblinks model.
*
* @since 1.5
*/
class WeblinkModel extends AdminModel
{
use VersionableModelTrait;
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_weblinks.weblink';
/**
* The context used for the associations table
*
* @var string
* @since __DEPLOY_VERSION__
*/
protected $associationsContext = 'com_weblinks.item';
/**
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
protected $text_prefix = 'COM_WEBLINKS';
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (empty($record->id) || $record->state != -2) {
return false;
}
return $this->getCurrentUser()->authorise('core.delete', 'com_weblinks.category.' . (int) $record->catid);
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission for the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
if (!empty($record->catid)) {
return $this->getCurrentUser()->authorise('core.edit.state', 'com_weblinks.category.' . (int) $record->catid);
}
return parent::canEditState($record);
}
/**
* Abstract method for getting the form from the model.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = [], $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_weblinks.weblink', 'weblink', ['control' => 'jform', 'load_data' => $loadData]);
if (empty($form)) {
return false;
}
// Determine correct permissions to check.
if ($this->getState('weblink.id')) {
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.edit');
} else {
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.create');
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data)) {
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled', 'true');
$form->setFieldAttribute('state', 'disabled', 'true');
$form->setFieldAttribute('publish_up', 'disabled', 'true');
$form->setFieldAttribute('publish_down', 'disabled', 'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('ordering', 'filter', 'unset');
$form->setFieldAttribute('state', 'filter', 'unset');
$form->setFieldAttribute('publish_up', 'filter', 'unset');
$form->setFieldAttribute('publish_down', 'filter', 'unset');
}
// Don't allow to change the created_by user if not allowed to access com_users.
if (!$this->getCurrentUser()->authorise('core.manage', 'com_users')) {
$form->setFieldAttribute('created_by', 'filter', 'unset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return array The default data is an empty array.
*
* @since 1.6
*/
protected function loadFormData()
{
$app = Factory::getApplication();
// Check the session for previously entered form data.
$data = $app->getUserState('com_weblinks.edit.weblink.data', []);
if (empty($data)) {
$data = $this->getItem();
// Prime some default values.
if ($this->getState('weblink.id') == 0) {
$data->set('catid', $app->input->get('catid', $app->getUserState('com_weblinks.weblinks.filter.category_id'), 'int'));
}
}
$this->preprocessData('com_weblinks.weblink', $data);
return $data;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk)) {
// Convert the metadata field to an array.
$registry = new Registry($item->metadata ?? '');
$item->metadata = $registry->toArray();
// Convert the images field to an array.
$registry = new Registry($item->images ?? '');
$item->images = $registry->toArray();
// Load associated web links items
$assoc = Associations::isEnabled();
if ($assoc) {
$item->associations = [];
if ($item->id != null) {
$associations = Associations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $item->id);
foreach ($associations as $tag => $association) {
$item->associations[$tag] = $association->id;
}
}
}
if (!empty($item->id)) {
$item->tags = new TagsHelper();
$item->tags->getTagIds($item->id, 'com_weblinks.weblink');
$item->metadata['tags'] = $item->tags;
}
}
return $item;
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param \Joomla\CMS\Table\Table $table A reference to a JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = Factory::getDate();
$user = $this->getCurrentUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
if (empty($table->alias)) {
$table->alias = ApplicationHelper::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set the values
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__weblinks'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
} else {
// Set the values
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
}
// Increment the weblink version number.
$table->version++;
}
/**
* A protected method to get a set of ordering conditions.
*
* @param \Joomla\CMS\Table\Table $table A JTable object.
*
* @return array An array of conditions to add to ordering queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
$condition = [];
$condition[] = 'catid = ' . (int) $table->catid;
return $condition;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 3.1
*/
public function save($data)
{
$app = Factory::getApplication();
// Cast catid to integer for comparison
$catid = (int) $data['catid'];
// Check if New Category exists
if ($catid > 0) {
$catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_weblinks');
}
// Save New Category
if ($catid == 0 && $this->canCreateCategory()) {
$table = [];
$table['title'] = $data['catid'];
$table['parent_id'] = 1;
$table['extension'] = 'com_weblinks';
$table['language'] = $data['language'];
$table['published'] = 1;
// Create new category and get catid back
$data['catid'] = CategoriesHelper::createCategory($table);
}
// Alter the title for save as copy
if ($app->input->get('task') == 'save2copy') {
[$name, $alias] = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
$data['title'] = $name;
$data['alias'] = $alias;
$data['state'] = 0;
}
return parent::save($data);
}
/**
* Method to change the title & alias.
*
* @param integer $category_id The id of the parent.
* @param string $alias The alias.
* @param string $name The title.
*
* @return array Contains the modified title and alias.
*
* @since 3.1
*/
protected function generateNewTitle($category_id, $alias, $name)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(['alias' => $alias, 'catid' => $category_id])) {
if ($name == $table->title) {
$name = StringHelper::increment($name);
}
$alias = StringHelper::increment($alias, 'dash');
}
return [$name, $alias];
}
/**
* Allows preprocessing of the JForm object.
*
* @param \JForm $form The form object
* @param array $data The data to be merged into the form object
* @param string $group The plugin group to be executed
*
* @return void
*
* @since 3.6.0
*/
protected function preprocessForm(Form $form, $data, $group = 'content')
{
if ($this->canCreateCategory()) {
$form->setFieldAttribute('catid', 'allowAdd', 'true');
}
// Association weblinks items
if (Associations::isEnabled()) {
$languages = LanguageHelper::getContentLanguages(false, false, null, 'ordering', 'asc');
if (count($languages) > 1) {
$addform = new \SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name', 'item_associations');
foreach ($languages as $language) {
$field = $fieldset->addChild('field');
$field->addAttribute('name', $language->lang_code);
$field->addAttribute('type', 'modal_weblink');
$field->addAttribute('language', $language->lang_code);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label', 'false');
$field->addAttribute('select', 'true');
$field->addAttribute('new', 'true');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
$field->addAttribute('addfieldprefix', 'Joomla\\Component\\Weblinks\\Administrator\\Field');
}
$form->load($addform, false);
}
}
parent::preprocessForm($form, $data, $group);
}
/**
* Is the user allowed to create an on the fly category?
*
* @return bool
*
* @since 3.6.0
*/
private function canCreateCategory()
{
return $this->getCurrentUser()->authorise('core.create', 'com_weblinks');
}
}

View File

@ -0,0 +1,279 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Model;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Database\ParameterType;
/**
* Methods supporting a list of weblink records.
*
* @since 1.6
*/
class WeblinksModel extends ListModel
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* @param MVCFactoryInterface $factory The factory.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = [], MVCFactoryInterface $factory = null)
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = [
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'catid', 'a.catid', 'category_id',
'c.title', 'category_title',
'state', 'a.state', 'published',
'access', 'a.access',
'ag.title', 'access_level',
'created', 'a.created',
'created_by', 'a.created_by',
'ordering', 'a.ordering',
'featured', 'a.featured',
'language', 'a.language',
'l.title', 'language_title',
'hits', 'a.hits',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'url', 'a.url',
'tag',
'level', 'c.level',
];
$assoc = Associations::isEnabled();
if ($assoc) {
$config['filter_fields'][] = 'association';
}
}
parent::__construct($config, $factory);
}
/**
* Method to auto-populate the model state.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @note Calling getState in this method will result in recursion.
* @since 1.6
*/
protected function populateState($ordering = 'a.title', $direction = 'asc')
{
$app = Factory::getApplication();
$forcedLanguage = $app->input->get('forcedLanguage', '', 'cmd');
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout')) {
$this->context .= '.' . $layout;
}
// Adjust the context to support forced languages.
if ($forcedLanguage) {
$this->context .= '.' . $forcedLanguage;
}
// Load the parameters.
$params = ComponentHelper::getParams('com_weblinks');
$this->setState('params', $params);
// Force a language.
if (!empty($forcedLanguage)) {
$this->setState('filter.language', $forcedLanguage);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.language');
$id .= ':' . $this->getState('filter.tag');
$id .= ':' . $this->getState('filter.level');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return \JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDatabase();
$query = $db->getQuery(true);
$user = $this->getCurrentUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.created, a.created_by, ' .
'a.hits, a.state, a.access, a.ordering, a.language, a.publish_up, a.publish_down'
)
);
$query->from($db->quoteName('#__weblinks', 'a'));
// Join over the language
$query->select($db->quoteName('l.title', 'language_title'))
->select($db->quoteName('l.image', 'language_image'))
->join('LEFT', $db->quoteName('#__languages', 'l') . ' ON ' . $db->qn('l.lang_code') . ' = ' . $db->qn('a.language'));
// Join over the users for the checked out user.
$query->select($db->quoteName('uc.name', 'editor'))
->join('LEFT', $db->quoteName('#__users', 'uc') . ' ON ' . $db->qn('uc.id') . ' = ' . $db->qn('a.checked_out'));
// Join over the asset groups.
$query->select($db->quoteName('ag.title', 'access_level'))
->join('LEFT', $db->quoteName('#__viewlevels', 'ag') . ' ON ' . $db->qn('ag.id') . ' = ' . $db->qn('a.access'));
// Join over the categories.
$query->select('c.title AS category_title')
->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON ' . $db->qn('c.id') . ' = ' . $db->qn('a.catid'));
// Join over the associations.
$assoc = Associations::isEnabled();
if ($assoc) {
$query->select('COUNT(asso2.id)>1 AS association')
->join('LEFT', $db->quoteName('#__associations', 'asso') . ' ON asso.id = a.id AND asso.context = ' . $db->quote('com_weblinks.item'))
->join('LEFT', $db->quoteName('#__associations', 'asso2') . ' ON asso2.key = asso.key')
->group('a.id, l.title, l.image, uc.name, ag.title, c.title');
}
// Filter by access level.
if ($access = $this->getState('filter.access')) {
$query->where($db->quoteName('a.access') . ' = :access')
->bind(':access', $access, ParameterType::INTEGER);
}
// Implement View Level Access
if (!$user->authorise('core.admin')) {
$query->whereIn($db->quoteName('a.access'), $user->getAuthorisedViewLevels());
}
// Filter by published state
$published = (string) $this->getState('filter.published');
if (is_numeric($published)) {
$query->where($db->quoteName('a.state') . ' = :state')
->bind(':state', $published, ParameterType::INTEGER);
} elseif ($published === '') {
$query->whereIn($db->quoteName('a.state'), [0, 1]);
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId)) {
$query->where($db->quoteName('a.catid') . ' = :catid')
->bind(':catid', $categoryId, ParameterType::INTEGER);
}
// Filter on the level.
if ($level = $this->getState('filter.level')) {
$query->where($db->quoteName('c.level') . ' <= :level')
->bind(':level', $level, ParameterType::INTEGER);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$search = substr($search, 3);
$query->where($db->quoteName('a.id') . ' = :id')
->bind(':id', $search, ParameterType::INTEGER);
} else {
$search = '%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%');
$query->where('(' . $db->quoteName('a.title') . ' LIKE :title OR ' . $db->quoteName('a.alias') . ' LIKE :alias)')
->bind(':title', $search)
->bind(':alias', $search);
}
}
// Filter on the language.
if ($language = $this->getState('filter.language')) {
$query->where($db->quoteName('a.language') . ' = :language')
->bind(':language', $language);
}
$tagId = $this->getState('filter.tag');
// Filter by a single tag.
if (is_numeric($tagId)) {
$query->where($db->quoteName('tagmap.tag_id') . ' = :tagId')
->bind(':tagId', $tagId, ParameterType::INTEGER)
->join(
'LEFT',
$db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_weblinks.weblink')
);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'a.title');
$orderDirn = $this->state->get('list.direction', 'ASC');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
$orderCol = 'c.title ' . $orderDirn . ', a.ordering';
}
$query->order($db->escape($orderCol . ' ' . $orderDirn));
return $query;
}
}

View File

@ -0,0 +1,101 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Service\HTML;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\Database\ParameterType;
/**
* Weblinks HTML helper class.
*
* @since 1.6
*/
class AdministratorService
{
/**
* Get the associated language flags
*
* @param integer $weblinkid The item id to search associations
*
* @return string The language HTML
*
* @throws \Exception
*/
public function association($weblinkid)
{
// Defaults
$html = '';
// Get the associations
if ($associations = Associations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $weblinkid)) {
foreach ($associations as $tag => $associated) {
$associations[$tag] = (int) $associated->id;
}
// Get the associated contact items
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select([
$db->quoteName('c.id'),
$db->quoteName('c.title', 'title'),
$db->quoteName('l.sef', 'lang_sef'),
$db->quoteName('lang_code'),
$db->quoteName('cat.title', 'category_title'),
$db->quoteName('l.image'),
$db->quoteName('l.title', 'language_title'),
])
->from($db->quoteName('#__weblinks', 'c'))
->join('LEFT', $db->quoteName('#__categories', 'cat'), $db->quoteName('cat.id') . ' = ' . $db->quoteName('c.catid'))
->join('LEFT', $db->quoteName('#__languages', 'l'), $db->quoteName('c.language') . ' = ' . $db->quoteName('l.lang_code'))
->whereIn($db->quoteName('c.id'), array_values($associations))
->where($db->quoteName('c.id') . ' != :id')
->bind(':id', $weblinkid, ParameterType::INTEGER);
$db->setQuery($query);
try {
$items = $db->loadObjectList('id');
} catch (\RuntimeException $e) {
throw new \Exception($e->getMessage(), 500, $e);
}
if ($items) {
$app = Factory::getApplication();
$languages = LanguageHelper::getContentLanguages([0, 1]);
$content_languages = array_column($languages, 'lang_code');
foreach ($items as &$item) {
if (in_array($item->lang_code, $content_languages)) {
$text = $item->lang_code;
$url = Route::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id);
$tooltip = '<strong>' . htmlspecialchars($item->language_title, ENT_QUOTES, 'UTF-8') . '</strong><br>'
. htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8')
. '<br>' . Text::sprintf('JCATEGORY_SPRINTF', $item->category_title);
$classes = 'badge bg-secondary';
$item->link = '<a href="' . $url . '" class="' . $classes . '">' . $text . '</a>'
. '<div role="tooltip" id="tip-' . (int) $weblinkid . '-' . (int) $item->id . '">' . $tooltip . '</div>';
} else {
// Display warning if Content Language is trashed or deleted
$app->enqueueMessage(Text::sprintf('JGLOBAL_ASSOCIATIONS_CONTENTLANGUAGE_WARNING', $item->lang_code), 'warning');
}
}
}
$html = LayoutHelper::render('joomla.content.associations', $items);
}
return $html;
}
}

View File

@ -0,0 +1,154 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Service\HTML;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
use Joomla\Registry\Registry;
/**
* Weblinks Component HTML Helper
*
* @since 4.0.0
*/
class Icon
{
/**
* The application
*
* @var CMSApplication
*
* @since 4.0.0
*/
private $application;
/**
* Service constructor
*
* @param CMSApplication $application The application
*
* @since 4.0.0
*/
public function __construct(CMSApplication $application)
{
$this->application = $application;
}
/**
* Method to generate a link to the create item page for the given category
*
* @param object $category The category information
* @param Registry $params The item parameters
* @param array $attribs Optional attributes for the link
*
* @return string The HTML markup for the create item link
*
* @since 4.0.0
*/
public static function create($category, $params, $attribs = [])
{
$uri = Uri::getInstance();
$url = 'index.php?option=com_weblinks&task=weblink.add&return=' . base64_encode($uri) . '&w_id=0&catid=' . $category->id;
$text = LayoutHelper::render('joomla.content.icons.create', ['params' => $params, 'legacy' => false]);
// Add the button classes to the attribs array
if (isset($attribs['class'])) {
$attribs['class'] .= ' btn btn-primary';
} else {
$attribs['class'] = 'btn btn-primary';
}
$button = HTMLHelper::_('link', Route::_($url), $text, $attribs);
$output = '<span class="hasTooltip" title="' . HTMLHelper::_('tooltipText', 'COM_WEBLINKS_FORM_CREATE_WEBLINK') . '">' . $button . '</span>';
return $output;
}
/**
* Display an edit icon for the weblink.
*
* This icon will not display in a popup window, nor if the weblink is trashed.
* Edit access checks must be performed in the calling code.
*
* @param object $weblink The weblink information
* @param Registry $params The item parameters
* @param array $attribs Optional attributes for the link
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
*
* @return string The HTML for the weblink edit icon.
*
* @since 4.0.0
*/
public static function edit($weblink, $params, $attribs = [], $legacy = false)
{
$user = Factory::getApplication()->getIdentity();
$uri = Uri::getInstance();
// Ignore if in a popup window.
if ($params && $params->get('popup')) {
return '';
}
// Ignore if the state is negative (trashed).
if ($weblink->state < 0) {
return '';
}
// Show checked_out icon if the contact is checked out by a different user
if (
property_exists($weblink, 'checked_out')
&& property_exists($weblink, 'checked_out_time')
&& $weblink->checked_out
&& $weblink->checked_out !== $user->get('id')
) {
$checkoutUser = Factory::getUser($weblink->checked_out);
$date = HTMLHelper::_('date', $weblink->checked_out_time);
$tooltip = Text::sprintf('COM_WEBLINKS_CHECKED_OUT_BY', $checkoutUser->name)
. ' <br> ' . $date;
$text = LayoutHelper::render('joomla.content.icons.edit_lock', ['contact' => $weblink, 'tooltip' => $tooltip, 'legacy' => $legacy]);
$attribs['aria-describedby'] = 'editweblink-' . (int) $weblink->id;
$output = HTMLHelper::_('link', '#', $text, $attribs);
return $output;
}
$weblinkUrl = RouteHelper::getWeblinkRoute($weblink->slug, $weblink->catid, $weblink->language);
$url = $weblinkUrl . '&task=weblink.edit&w_id=' . $weblink->id . '&return=' . base64_encode($uri);
if ((int) $weblink->state === 0) {
$tooltip = Text::_('COM_WEBLINKS_EDIT_UNPUBLISHED_WEBLINK');
} else {
$tooltip = Text::_('COM_WEBLINKS_EDIT_PUBLISHED_WEBLINK');
}
$nowDate = strtotime(Factory::getDate());
$icon = $weblink->state ? 'edit' : 'eye-slash';
if (
($weblink->publish_up !== null && strtotime($weblink->publish_up) > $nowDate)
|| ($weblink->publish_down !== null && strtotime($weblink->publish_down) < $nowDate
&& $weblink->publish_down !== Factory::getDbo()->getNullDate())
) {
$icon = 'eye-slash';
}
$aria_described = 'editweblink-' . (int) $weblink->id;
$text = '<span class="icon-' . $icon . '" aria-hidden="true"></span>';
$text .= Text::_('JGLOBAL_EDIT');
$text .= '<div role="tooltip" id="' . $aria_described . '">' . $tooltip . '</div>';
$attribs['aria-describedby'] = $aria_described;
$output = HTMLHelper::_('link', Route::_($url), $text, $attribs);
return $output;
}
}

View File

@ -0,0 +1,254 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\Table;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Language\Text;
use Joomla\CMS\String\PunycodeHelper;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Tag\TaggableTableInterface;
use Joomla\CMS\Tag\TaggableTableTrait;
use Joomla\CMS\Versioning\VersionableTableInterface;
use Joomla\Database\ParameterType;
use Joomla\String\StringHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Weblink Table class
*
* @since 1.5
*/
class WeblinkTable extends Table implements VersionableTableInterface, TaggableTableInterface
{
use TaggableTableTrait;
/**
* Indicates that columns fully support the NULL value in the database
*
* @var boolean
* @since __DEPLOY_VERSION__
*/
protected $_supportNullValue = true;
/**
* Ensure the params and metadata in json encoded in the bind method
*
* @var array
* @since 3.4
*/
protected $_jsonEncode = ['params', 'metadata', 'images'];
/**
* Constructor
*
* @param \JDatabaseDriver &$db A database connector object
*
* @since 1.5
*/
public function __construct($db)
{
$this->typeAlias = 'com_weblinks.weblink';
parent::__construct('#__weblinks', 'id', $db);
// Set the published column alias
$this->setColumnAlias('published', 'state');
}
/**
* Overload the store method for the Weblinks table.
*
* @param boolean $updateNulls Toggle whether null values should be updated.
*
* @return boolean True on success, false on failure.
*
* @since 1.6
*/
public function store($updateNulls = true)
{
$date = Factory::getDate()->toSql();
$user = Factory::getApplication()->getIdentity();
$this->modified = $date;
if ($this->id) {
// Existing item
$this->modified_by = $user->id;
$this->modified = $date;
} else {
// New weblink. A weblink created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int) $this->created) {
$this->created = $date;
}
if (empty($this->created_by)) {
$this->created_by = $user->id;
}
if (!(int) $this->modified) {
$this->modified = $date;
}
if (empty($this->modified_by)) {
$this->modified_by = $user->id;
}
if (empty($this->hits)) {
$this->hits = 0;
}
}
// Set publish_up to null if not set
if (!$this->publish_up) {
$this->publish_up = null;
}
// Set publish_down to null if not set
if (!$this->publish_down) {
$this->publish_down = null;
}
// Verify that the alias is unique
$table = new WeblinkTable($this->getDbo());
if (
$table->load(['language' => $this->language, 'alias' => $this->alias, 'catid' => (int) $this->catid])
&& ($table->id != $this->id || $this->id == 0)
) {
$this->setError(Text::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS'));
return false;
}
// Convert IDN urls to punycode
$this->url = PunycodeHelper::urlToPunycode($this->url);
return parent::store($updateNulls);
}
/**
* Overloaded check method to ensure data integrity.
*
* @return boolean True on success.
*
* @since 1.5
*/
public function check()
{
if (InputFilter::checkAttribute(['href', $this->url])) {
$this->setError(Text::_('COM_WEBLINKS_ERR_TABLES_PROVIDE_URL'));
return false;
}
// Check for valid name
if (trim($this->title) == '') {
$this->setError(Text::_('COM_WEBLINKS_ERR_TABLES_TITLE'));
return false;
}
// Check for existing name
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__weblinks'))
->where($db->quoteName('title') . ' = :title')
->where($db->quoteName('language') . ' = :language')
->where($db->quoteName('catid') . ' = :catid')
->bind(':title', $this->title)
->bind(':language', $this->language)
->bind(':catid', $this->catid, ParameterType::INTEGER);
$db->setQuery($query);
$xid = (int) $db->loadResult();
if ($xid && $xid != (int) $this->id) {
$this->setError(Text::_('COM_WEBLINKS_ERR_TABLES_NAME'));
return false;
}
if (empty($this->alias)) {
$this->alias = $this->title;
}
$this->alias = ApplicationHelper::stringURLSafe($this->alias, $this->language);
if (trim(str_replace('-', '', $this->alias)) == '') {
$this->alias = Factory::getDate()->format("Y-m-d-H-i-s");
}
// Check the publish down date is not earlier than publish up.
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up) {
$this->setError(Text::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false;
}
/*
* Clean up keywords -- eliminate extra spaces between phrases
* and cr (\r) and lf (\n) characters from string
*/
if (!empty($this->metakey)) {
// Array of characters to remove
$bad_characters = ["\n", "\r", "\"", "<", ">"];
$after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey);
$keys = explode(',', $after_clean);
$clean_keys = [];
foreach ($keys as $key) {
// Ignore blank keywords
if (trim($key)) {
$clean_keys[] = trim($key);
}
}
// Put array back together delimited by ", "
$this->metakey = implode(", ", $clean_keys);
}
/**
* Ensure any new items have compulsory fields set. This is needed for things like
* frontend editing where we don't show all the fields or using some kind of API
*/
if (!$this->id) {
if (!isset($this->xreference)) {
$this->xreference = '';
}
if (!isset($this->metakey)) {
$this->metakey = '';
}
if (!isset($this->metadesc)) {
$this->metadesc = '';
}
if (!isset($this->images)) {
$this->images = '{}';
}
if (!isset($this->metadata)) {
$this->metadata = '{}';
}
if (!isset($this->params)) {
$this->params = '{}';
}
}
return parent::check();
}
/**
* Get the type alias for the history table
*
* @return string The alias as described above
*
* @since 4.0.0
*/
public function getTypeAlias()
{
return $this->typeAlias;
}
}

View File

@ -0,0 +1,168 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\View\Weblink;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
/**
* View to edit a weblink.
*
* @since 1.5
*/
class HtmlView extends BaseHtmlView
{
/**
* The Form object
*
* @var \Joomla\CMS\Form\Form
*/
protected $form;
/**
* The active item
*
* @var object
*/
protected $item;
/**
* The model state
*
* @var \Joomla\CMS\Object\CMSObject
*/
protected $state;
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
// If we are forcing a language in modal (used for associations).
if ($this->getLayout() === 'modal' && $forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$app = Factory::getApplication();
$app->input->set('hidemainmenu', true);
$user = $this->getCurrentUser();
$isNew = ($this->item->id == 0);
$checkedOut = $this->item->checked_out && $this->item->checked_out !== $user->get('id');
// Since we don't track these assets at the item level, use the category id.
$canDo = ContentHelper::getActions('com_weblinks', 'category', $this->item->catid);
ToolbarHelper::title($isNew ? Text::_('COM_WEBLINKS_MANAGER_WEBLINK_NEW') : Text::_('COM_WEBLINKS_MANAGER_WEBLINK_EDIT'), 'link weblinks');
// Build the actions for new and existing records.
if ($isNew) {
// For new records, check the create permission.
if (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0) {
ToolbarHelper::apply('weblink.apply');
ToolbarHelper::saveGroup(
[
['save', 'weblink.save'],
['save2new', 'weblink.save2new'],
],
'btn-success'
);
}
ToolbarHelper::cancel('weblink.cancel');
} else {
// Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
$itemEditable = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $user->id);
$toolbarButtons = [];
// Can't save the record if it's checked out and editable
if (!$checkedOut && $itemEditable) {
ToolbarHelper::apply('weblink.apply');
$toolbarButtons[] = ['save', 'weblink.save'];
// We can save this record, but check the create permission to see if we can return to make a new one.
if ($canDo->get('core.create')) {
$toolbarButtons[] = ['save2new', 'weblink.save2new'];
}
}
// If checked out, we can still save
if ($canDo->get('core.create')) {
$toolbarButtons[] = ['save2copy', 'weblink.save2copy'];
}
ToolbarHelper::saveGroup(
$toolbarButtons,
'btn-success'
);
ToolbarHelper::cancel('weblink.cancel', 'JTOOLBAR_CLOSE');
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $itemEditable) {
ToolbarHelper::versions('com_weblinks.weblink', $this->item->id);
}
if (Associations::isEnabled() && ComponentHelper::isEnabled('com_associations')) {
ToolbarHelper::custom('weblink.editAssociations', 'contract', '', 'JTOOLBAR_ASSOCIATIONS', false, false);
}
}
ToolbarHelper::help('Components_Weblinks_Links_Edit');
}
}

View File

@ -0,0 +1,192 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Weblinks\Administrator\View\Weblinks;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
/**
* View class for a list of weblinks.
*
* @since 1.5
*/
class HtmlView extends BaseHtmlView
{
/**
* An array of items
*
* @var array
*/
protected $items;
/**
* The pagination object
*
* @var \Joomla\CMS\Pagination\Pagination
*/
protected $pagination;
/**
* The model state
*
* @var \Joomla\CMS\Object\CMSObject
*/
protected $state;
/**
* Form object for search filters
*
* @var \Joomla\CMS\Form\Form
*/
public $filterForm;
/**
* The active search filters
*
* @var array
*/
public $activeFilters;
/**
* Is this view an Empty State
*
* @var boolean
* @since 4.0.0
*/
private $isEmptyState = false;
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
$this->setLayout('emptystate');
}
// We don't need toolbar in the modal layout.
if ($this->getLayout() !== 'modal') {
$this->addToolbar();
} else {
// In article associations modal we need to remove language filter if forcing a language.
// We also need to change the category filter to show show categories with All or the forced language.
if ($forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'CMD')) {
// If the language is forced we can't allow to select the language, so transform the language selector filter into an hidden field.
$languageXml = new \SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
$this->filterForm->setField($languageXml, 'filter', true);
// Also, unset the active language filter so the search tools is not open by default with this filter.
unset($this->activeFilters['language']);
// One last changes needed is to change the category filter to just show categories with All language or with the forced language.
$this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter');
}
}
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = ContentHelper::getActions('com_weblinks', 'category', $this->state->get('filter.category_id'));
$user = $this->getCurrentUser();
// Get the toolbar object instance
$toolbar = Toolbar::getInstance('toolbar');
ToolbarHelper::title(Text::_('COM_WEBLINKS_MANAGER_WEBLINKS'), 'link weblinks');
if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0) {
ToolbarHelper::addNew('weblink.add');
}
if (!$this->isEmptyState && $canDo->get('core.edit.state')) {
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
->toggleSplit(false)
->icon('icon-ellipsis-h')
->buttonClass('btn btn-action')
->listCheck(true);
$childBar = $dropdown->getChildToolbar();
$childBar->publish('weblinks.publish')->listCheck(true);
$childBar->unpublish('weblinks.unpublish')->listCheck(true);
$childBar->archive('weblinks.archive')->listCheck(true);
if ($user->authorise('core.admin')) {
$childBar->checkin('weblinks.checkin')->listCheck(true);
}
if ($this->state->get('filter.published') != -2) {
$childBar->trash('weblinks.trash')->listCheck(true);
}
// Add a batch button
if (
$user->authorise('core.create', 'com_weblinks')
&& $user->authorise('core.edit', 'com_weblinks')
&& $user->authorise('core.edit.state', 'com_weblinks')
) {
$childBar->popupButton('batch')
->text('JTOOLBAR_BATCH')
->selector('collapseModal')
->listCheck(true);
}
}
if (!$this->isEmptyState && $this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
$toolbar->delete('weblinks.delete')
->text('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}
if ($user->authorise('core.admin', 'com_weblinks') || $user->authorise('core.options', 'com_weblinks')) {
ToolbarHelper::preferences('com_weblinks');
}
ToolbarHelper::help('Components_Weblinks_Links');
}
}

View File

@ -1,203 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblink Table class
*
* @since 1.5
*/
class WeblinksTableWeblink extends JTable
{
/**
* Ensure the params and metadata in json encoded in the bind method
*
* @var array
* @since 3.4
*/
protected $_jsonEncode = array('params', 'metadata', 'images');
/**
* Constructor
*
* @param JDatabaseDriver &$db A database connector object
*
* @since 1.5
*/
public function __construct(&$db)
{
parent::__construct('#__weblinks', 'id', $db);
// Set the published column alias
$this->setColumnAlias('published', 'state');
if (version_compare(JVERSION, '4.0', '<' ) == 1)
{
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_weblinks.weblink'));
JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_weblinks.weblink'));
}
}
/**
* Overload the store method for the Weblinks table.
*
* @param boolean $updateNulls Toggle whether null values should be updated.
*
* @return boolean True on success, false on failure.
*
* @since 1.6
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
$this->modified = $date->toSql();
if ($this->id)
{
// Existing item
$this->modified_by = $user->id;
}
else
{
// New weblink. A weblink created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int) $this->created)
{
$this->created = $date->toSql();
}
if (empty($this->created_by))
{
$this->created_by = $user->id;
}
}
// Set publish_up to null date if not set
if (!$this->publish_up)
{
$this->publish_up = $this->getDbo()->getNullDate();
}
// Set publish_down to null date if not set
if (!$this->publish_down)
{
$this->publish_down = $this->getDbo()->getNullDate();
}
// Verify that the alias is unique
$table = JTable::getInstance('Weblink', 'WeblinksTable', array('dbo' => $this->getDbo()));
if ($table->load(array('language' => $this->language, 'alias' => $this->alias, 'catid' => $this->catid))
&& ($table->id != $this->id || $this->id == 0))
{
$this->setError(JText::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS'));
return false;
}
// Convert IDN urls to punycode
$this->url = JStringPunycode::urlToPunycode($this->url);
return parent::store($updateNulls);
}
/**
* Overloaded check method to ensure data integrity.
*
* @return boolean True on success.
*
* @since 1.5
*/
public function check()
{
if (JFilterInput::checkAttribute(array('href', $this->url)))
{
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_PROVIDE_URL'));
return false;
}
// Check for valid name
if (trim($this->title) == '')
{
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE'));
return false;
}
// Check for existing name
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__weblinks'))
->where($db->quoteName('title') . ' = ' . $db->quote($this->title))
->where($db->quoteName('language') . ' = ' . $db->quote($this->language))
->where($db->quoteName('catid') . ' = ' . (int) $this->catid);
$db->setQuery($query);
$xid = (int) $db->loadResult();
if ($xid && $xid != (int) $this->id)
{
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_NAME'));
return false;
}
if (empty($this->alias))
{
$this->alias = $this->title;
}
$this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
}
// Check the publish down date is not earlier than publish up.
if ($this->publish_down > $db->getNullDate() && $this->publish_down < $this->publish_up)
{
$this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false;
}
/*
* Clean up keywords -- eliminate extra spaces between phrases
* and cr (\r) and lf (\n) characters from string
*/
if (!empty($this->metakey))
{
// Array of characters to remove
$bad_characters = array("\n", "\r", "\"", "<", ">");
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey);
$keys = explode(',', $after_clean);
$clean_keys = array();
foreach ($keys as $key)
{
// Ignore blank keywords
if (trim($key))
{
$clean_keys[] = trim($key);
}
}
// Put array back together delimited by ", "
$this->metakey = implode(", ", $clean_keys);
}
return parent::check();
}
}

View File

@ -0,0 +1,118 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
HTMLHelper::_('behavior.formvalidator');
$app = Factory::getApplication();
$input = $app->input;
$assoc = Associations::isEnabled();
// Fieldsets to not automatically render by /layouts/joomla/edit/params.php
$this->ignore_fieldsets = array('details', 'images', 'item_associations', 'jmetadata');
$this->useCoreUI = true;
// In case of modal
$isModal = $input->get('layout') == 'modal' ? true : false;
$layout = $isModal ? 'modal' : 'edit';
$tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : '';
?>
<form action="<?php echo Route::_('index.php?option=com_weblinks&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="weblink-form" class="form-validate">
<?php echo LayoutHelper::render('joomla.edit.title_alias', $this); ?>
<div class="main-card">
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', array('active' => 'details')); ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'details', empty($this->item->id) ? Text::_('COM_WEBLINKS_NEW_WEBLINK', true) : Text::_('COM_WEBLINKS_EDIT_WEBLINK', true)); ?>
<div class="row">
<div class="col-md-9">
<div class="form-vertical">
<div>
<fieldset class="adminform">
<?php echo $this->form->renderField('url'); ?>
<?php echo $this->form->renderField('description'); ?>
</fieldset>
</div>
</div>
</div>
<div class="col-md-3">
<?php echo LayoutHelper::render('joomla.edit.global', $this); ?>
</div>
</div>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'images', Text::_('JGLOBAL_FIELDSET_IMAGE_OPTIONS', true)); ?>
<div class="row">
<div class="col-12">
<fieldset id="fieldset-image; ?>" class="options-form">
<legend><?php echo Text::_('JGLOBAL_FIELDSET_IMAGE_OPTIONS'); ?></legend>
<div>
<?php echo $this->form->renderField('imaJGLOBAL_FIELDSET_IMAGE_OPTIONSges'); ?>
<?php foreach ($this->form->getGroup('images') as $field) :
?>
<?php echo $field->renderField(); ?>
<?php
endforeach; ?>
</div>
</fieldset>
</div>
</div>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'publishing', Text::_('JGLOBAL_FIELDSET_PUBLISHING', true)); ?>
<div class="row">
<div class="col-12 col-lg-6">
<fieldset id="fieldset-publishingdata" class="options-form">
<legend><?php echo Text::_('JGLOBAL_FIELDSET_PUBLISHING'); ?></legend>
<?php echo LayoutHelper::render('joomla.edit.publishingdata', $this); ?>
</fieldset>
</div>
<div class="col-12 col-lg-6">
<fieldset id="fieldset-metadata" class="options-form">
<legend><?php echo Text::_('JGLOBAL_FIELDSET_METADATA_OPTIONS'); ?></legend>
<?php echo LayoutHelper::render('joomla.edit.metadata', $this); ?>
</fieldset>
</div>
</div>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>
<?php if (!$isModal && $assoc) :
?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'associations', Text::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?>
<fieldset id="fieldset-associations" class="options-form">
<legend><?php echo Text::_('JGLOBAL_FIELDSET_ASSOCIATIONS'); ?></legend>
<?php echo LayoutHelper::render('joomla.edit.associations', $this); ?>
</fieldset>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php
elseif ($isModal && $assoc) :
?>
<div class="hidden"><?php echo $this->loadTemplate('associations'); ?></div>
<?php
endif; ?>
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
</div>
<input type="hidden" name="task" value="" />
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" />
<?php echo HTMLHelper::_('form.token'); ?>
</form>

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
@ -7,6 +8,8 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
echo JLayoutHelper::render('joomla.edit.associations', $this);
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Layout\LayoutHelper;
echo LayoutHelper::render('joomla.edit.associations', $this);

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
@ -7,6 +8,8 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
echo JLayoutHelper::render('joomla.edit.metadata', $this);
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Layout\LayoutHelper;
echo LayoutHelper::render('joomla.edit.metadata', $this);

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Language\Text;
$fieldSets = $this->form->getFieldsets('params'); ?>
<?php foreach ($fieldSets as $name => $fieldSet) :
?>
<div class="tab-pane" id="params-<?php echo $name; ?>">
<?php if (isset($fieldSet->description) && trim($fieldSet->description)) :
?>
<?php echo '<p class="alert alert-info">' . $this->escape(Text::_($fieldSet->description)) . '</p>'; ?>
<?php
endif; ?>
<?php foreach ($this->form->getFieldset($name) as $field) :
?>
<div class="control-group">
<div class="control-label"><?php echo $field->label; ?></div>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php
endforeach; ?>
</div>
<?php
endforeach; ?>

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
@ -6,14 +7,17 @@
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
HTMLHelper::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
// @deprecated 4.0 the function parameter, the inline js and the buttons are not needed since 3.7.0.
$function = JFactory::getApplication()->input->getCmd('function', 'jEditWeblink_' . (int) $this->item->id);
$function = Factory::getApplication()->input->getCmd('function', 'jEditWeblink_' . (int) $this->item->id);
// Function to update input title when changed
JFactory::getDocument()->addScriptDeclaration('
Factory::getDocument()->addScriptDeclaration('
function jEditWeblinkModal() {
if (window.parent && document.formvalidator.isValid(document.getElementById("weblink-form"))) {
return window.parent.' . $this->escape($function) . '(document.getElementById("jform_title").value);
@ -26,6 +30,6 @@ JFactory::getDocument()->addScriptDeclaration('
<button id="closeBtn" type="button" class="hidden" onclick="Joomla.submitbutton('weblink.cancel');"></button>
<div class="container-popup">
<?php $this->setLayout('edit'); ?>
<?php echo $this->loadTemplate(); ?>
<?php $this->setLayout('edit'); ?>
<?php echo $this->loadTemplate(); ?>
</div>

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
@ -7,6 +8,8 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
echo JLayoutHelper::render('joomla.edit.associations', $this);
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Layout\LayoutHelper;
echo LayoutHelper::render('joomla.edit.associations', $this);

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
@ -7,6 +8,8 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
echo JLayoutHelper::render('joomla.edit.metadata', $this);
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Layout\LayoutHelper;
echo LayoutHelper::render('joomla.edit.metadata', $this);

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Language\Text;
$fieldSets = $this->form->getFieldsets('params'); ?>
<?php foreach ($fieldSets as $name => $fieldSet) :
?>
<div class="tab-pane" id="params-<?php echo $name; ?>">
<?php if (isset($fieldSet->description) && trim($fieldSet->description)) :
?>
<?php echo '<p class="alert alert-info">' . $this->escape(Text::_($fieldSet->description)) . '</p>'; ?>
<?php
endif; ?>
<?php foreach ($this->form->getFieldset($name) as $field) :
?>
<div class="control-group">
<div class="control-label"><?php echo $field->label; ?></div>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php
endforeach; ?>
</div>
<?php
endforeach; ?>

View File

@ -0,0 +1,217 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
/** @var \Joomla\Component\Weblinks\Administrator\View\Weblinks\HtmlView $this */
HTMLHelper::_('behavior.multiselect');
$user = Factory::getApplication()->getIdentity();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 'a.ordering';
$assoc = Associations::isEnabled();
if ($saveOrder && !empty($this->items)) {
$saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component';
HTMLHelper::_('draggablelist.draggable');
}
?>
<form action="<?php echo Route::_('index.php?option=com_weblinks&view=weblinks'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
<div class="col-md-12">
<div id="j-main-container" class="j-main-container">
<?php
// Search tools bar
echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]);
?>
<?php if (empty($this->items)) :
?>
<div class="alert alert-info">
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php
else :
?>
<table class="table" id="weblinkList">
<caption class="visually-hidden">
<?php echo Text::_('COM_WEBLINKS_WEBLINKS_TABLE_CAPTION'); ?>,
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
</caption>
<thead>
<tr>
<td class="w-1 text-center">
<?php echo HTMLHelper::_('grid.checkall'); ?>
</td>
<th scope="col" class="w-1 text-center d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
</th>
<th scope="col" style="min-width:85px" class="w-1 text-center">
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th scope="col">
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'access_level', $listDirn, $listOrder); ?>
</th>
<th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<?php if ($assoc) :
?>
<th scope="col" class="w-10">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_WEBLINKS_HEADING_ASSOCIATION', 'association', $listDirn, $listOrder); ?>
</th>
<?php
endif; ?>
<?php if (Multilanguage::isEnabled()) :
?>
<th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
</th>
<?php
endif; ?>
<th scope="col" class="w-5 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tbody <?php if ($saveOrder) :
?> class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="<?php echo strtolower($listDirn); ?>" data-nested="true"<?php
endif; ?>>
<?php foreach ($this->items as $i => $item) :
?>
<?php $item->cat_link = Route::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]=' . $item->catid); ?>
<?php $canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid); ?>
<?php $canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid); ?>
<?php $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || !$item->checked_out; ?>
<?php $canEditOwn = $user->authorise('core.edit.own', 'com_weblinks.category.' . $item->catid) && $item->created_by == $user->id; ?>
<?php $canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; ?>
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->catid; ?>">
<td class="text-center">
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->title); ?>
</td>
<td class="text-center d-none d-md-table-cell">
<?php
$iconClass = '';
if (!$canChange) {
$iconClass = ' inactive';
} elseif (!$saveOrder) {
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
}
?>
<span class="sortable-handler<?php echo $iconClass; ?>">
<span class="icon-ellipsis-v" aria-hidden="true"></span>
</span>
<?php if ($canChange && $saveOrder) :
?>
<input type="text" name="order[]" size="5"
value="<?php echo $item->ordering; ?>" class="width-20 text-area-order hidden">
<?php
endif; ?>
</td>
<td class="text-center">
<?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
</td>
<th scope="row" class="has-context">
<div>
<?php if ($item->checked_out) :
?>
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?>
<?php
endif; ?>
<?php if ($canEdit || $canEditOwn) :
?>
<a href="<?php echo Route::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->title); ?>">
<?php echo $this->escape($item->title); ?></a>
<?php
else :
?>
<?php echo $this->escape($item->title); ?>
<?php
endif; ?>
<span class="small">
<?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
</span>
<div class="small">
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div>
</div>
</th>
<td class="small d-none d-md-table-cell">
<?php echo $this->escape($item->access_level); ?>
</td>
<td class="d-none d-md-table-cell">
<?php echo $item->hits; ?>
</td>
<?php if ($assoc) :
?>
<td class="hidden-phone hidden-tablet">
<?php if ($item->association) :
?>
<?php echo HTMLHelper::_('weblinksadministrator.association', $item->id); ?>
<?php
endif; ?>
</td>
<?php
endif; ?>
<?php if (Multilanguage::isEnabled()) :
?>
<td class="small d-none d-md-table-cell">
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
</td>
<?php
endif; ?>
<td class="d-none d-md-table-cell">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php
endforeach; ?>
</tbody>
</table>
<?php // Load the pagination. ?>
<?php echo $this->pagination->getListFooter(); ?>
<?php // Load the batch processing form. ?>
<?php if (
$user->authorise('core.create', 'com_weblinks')
&& $user->authorise('core.edit', 'com_weblinks')
&& $user->authorise('core.edit.state', 'com_weblinks')
) :
?>
<?php echo HTMLHelper::_('bootstrap.renderModal', 'collapseModal', [
'title' => Text::_('COM_WEBLINKS_BATCH_OPTIONS'),
'footer' => $this->loadTemplate('batch_footer')
], $this->loadTemplate('batch_body')); ?>
<?php
endif; ?>
<?php
endif; ?>
<input type="hidden" name="task" value="">
<input type="hidden" name="boxchecked" value="0">
<?php echo HTMLHelper::_('form.token'); ?>
</div>
</div>
</div>
</form>

View File

@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Layout\LayoutHelper;
$published = $this->state->get('filter.published');
?>
<div class="p-3">
<div class="row">
<?php if (Multilanguage::isEnabled()) :
?>
<div class="form-group col-md-6">
<div class="controls">
<?php echo LayoutHelper::render('joomla.html.batch.language', []); ?>
</div>
</div>
<?php
endif; ?>
<div class="form-group col-md-6">
<div class="controls">
<?php echo LayoutHelper::render('joomla.html.batch.access', []); ?>
</div>
</div>
</div>
<div class="row">
<?php if ($published >= 0) :
?>
<div class="form-group col-md-6">
<div class="controls">
<?php echo LayoutHelper::render('joomla.html.batch.item', ['extension' => 'com_weblinks']); ?>
</div>
</div>
<?php
endif; ?>
<div class="form-group col-md-6">
<div class="controls">
<?php echo LayoutHelper::render('joomla.html.batch.tag', []); ?>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,22 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Language\Text;
?>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</button>
<button type="submit" id='batch-submit-button-id' class="btn btn-success" onclick="Joomla.submitbutton('weblink.batch');return false;">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>

View File

@ -0,0 +1,27 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Factory;
use Joomla\CMS\Layout\LayoutHelper;
$displayData = [
'textPrefix' => 'COM_WEBLINKS',
'formURL' => 'index.php?option=com_weblinks',
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help4.x:Weblinks',
'icon' => 'icon-globe weblink',
];
$user = Factory::getApplication()->getIdentity();
if ($user->authorise('core.create', 'com_weblinks') || count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0) {
$displayData['createURL'] = 'index.php?option=com_weblinks&task=weblink.add';
}
echo LayoutHelper::render('joomla.content.emptystate', $displayData);

View File

@ -0,0 +1,166 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
$app = Factory::getApplication();
if ($app->isClient('site')) {
Session::checkToken('get') or die(Text::_('JINVALID_TOKEN'));
}
HTMLHelper::_('behavior.multiselect');
$this->document->getWebAssetManager()
->registerAndUseScript('com_weblinks.admin-weblinks-modal', 'media/com_weblinks/js/admin-weblinks-modal.js', [], ['defer' => true], ['core']);
$function = $app->input->getCmd('function', 'jSelectWeblink');
$editor = $app->input->getCmd('editor', '');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$onclick = $this->escape($function);
$multilang = Multilanguage::isEnabled();
if (!empty($editor)) {
// This view is used also in com_menus. Load the xtd script only if the editor is set!
$this->document->addScriptOptions('xtd-weblinks', array('editor' => $editor));
$onclick = "jSelectWeblink";
}
$iconStates = array(
-2 => 'icon-trash',
0 => 'icon-unpublish',
1 => 'icon-publish',
2 => 'icon-archive',
);
?>
<div class="container-popup">
<form action="<?php echo Route::_('index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&function=' . $function . '&' . Session::getFormToken() . '=1&editor=' . $editor); ?>" method="post" name="adminForm" id="adminForm" class="form-inline">
<?php echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php if (empty($this->items)) :
?>
<div class="alert alert-no-items">
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php
else :
?>
<table class="table table-sm">
<caption class="visually-hidden">
<?php echo Text::_('COM_WEBLINKS_WEBLINKS_TABLE_CAPTION'); ?>,
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
</caption>
<thead>
<tr>
<th scope="col" class="w-1 text-center">
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th scope="col" class="title">
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
</th>
<?php if ($multilang) :
?>
<th scope="col" class="w-15">
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?>
</th>
<?php
endif; ?>
<th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JDATE', 'a.created', $listDirn, $listOrder); ?>
</th>
<th scope="col" class="w-1 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items as $i => $item) :
?>
<?php $lang = ''; ?>
<?php if ($item->language && $multilang) :
?>
<?php $tag = strlen($item->language); ?>
<?php if ($tag == 5) :
?>
<?php $lang = substr($item->language, 0, 2); ?>
<?php
elseif ($tag == 6) :
?>
<?php $lang = substr($item->language, 0, 3); ?>
<?php
endif; ?>
<?php
endif; ?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center">
<span class="<?php echo $iconStates[$this->escape($item->state)]; ?>"></span>
</td>
<th scope="row">
<?php $attribs = 'data-function="' . $this->escape($onclick) . '"'
. ' data-id="' . $item->id . '"'
. ' data-title="' . $this->escape(addslashes($item->title)) . '"'
. ' data-cat-id="' . $this->escape($item->catid) . '"'
. ' data-uri="' . $this->escape(RouteHelper::getWeblinkRoute($item->id, $item->catid, $item->language)) . '"'
. ' data-language="' . $this->escape($lang) . '"';
?>
<a class="select-link" href="javascript:void(0)" <?php echo $attribs; ?>>
<?php echo $this->escape($item->title); ?>
</a>
<div class="small">
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div>
</th>
<td class="small d-none d-md-table-cell">
<?php echo $this->escape($item->access_level); ?>
</td>
<?php if ($multilang) :
?>
<td class="small">
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
</td>
<?php
endif; ?>
<td class="small d-none d-md-table-cell">
<?php echo HTMLHelper::_('date', $item->created, Text::_('DATE_FORMAT_LC4')); ?>
</td>
<td class="small d-none d-md-table-cell">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php
endforeach; ?>
</tbody>
</table>
<?php
endif; ?>
<?php // load the pagination. ?>
<?php echo $this->pagination->getListFooter(); ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="forcedLanguage" value="<?php echo $app->input->get('forcedLanguage', '', 'CMD'); ?>" />
<?php echo HTMLHelper::_('form.token'); ?>
</form>
</div>

View File

@ -1,102 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select', null, array('disable_search_threshold' => 0 ));
$app = JFactory::getApplication();
$input = $app->input;
$assoc = JLanguageAssociations::isEnabled();
// Fieldsets to not automatically render by /layouts/joomla/edit/params.php
$this->ignore_fieldsets = array('details', 'images', 'item_associations', 'jmetadata');
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
{
if (task == 'weblink.cancel' || document.formvalidator.isValid(document.getElementById('weblink-form'))) {
" . $this->form->getField('description')->save() . "
Joomla.submitform(task, document.getElementById('weblink-form'));
}
};
");
// In case of modal
$isModal = $input->get('layout') == 'modal' ? true : false;
$layout = $isModal ? 'modal' : 'edit';
$tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : '';
?>
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="weblink-form" class="form-validate">
<?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>
<div class="form-horizontal">
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', empty($this->item->id) ? JText::_('COM_WEBLINKS_NEW_WEBLINK', true) : JText::_('COM_WEBLINKS_EDIT_WEBLINK', true)); ?>
<div class="row-fluid">
<div class="span9">
<div class="form-vertical">
<?php echo $this->form->renderField('url'); ?>
<?php echo $this->form->renderField('description'); ?>
</div>
</div>
<div class="span3">
<?php echo JLayoutHelper::render('joomla.edit.global', $this); ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'images', JText::_('JGLOBAL_FIELDSET_IMAGE_OPTIONS', true)); ?>
<div class="row-fluid">
<div class="span6">
<?php echo $this->form->renderField('images'); ?>
<?php foreach ($this->form->getGroup('images') as $field) : ?>
<?php echo $field->renderField(); ?>
<?php endforeach; ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'publishing', JText::_('JGLOBAL_FIELDSET_PUBLISHING', true)); ?>
<div class="row-fluid form-horizontal-desktop">
<div class="span6">
<?php echo JLayoutHelper::render('joomla.edit.publishingdata', $this); ?>
</div>
<div class="span6">
<?php echo JLayoutHelper::render('joomla.edit.metadata', $this); ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
<?php if (!$isModal && $assoc) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'associations', JText::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?>
<?php echo $this->loadTemplate('associations'); ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php elseif ($isModal && $assoc) : ?>
<div class="hidden"><?php echo $this->loadTemplate('associations'); ?></div>
<?php endif; ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
</div>
<input type="hidden" name="task" value="" />
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@ -1,25 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$fieldSets = $this->form->getFieldsets('params'); ?>
<?php foreach ($fieldSets as $name => $fieldSet) : ?>
<div class="tab-pane" id="params-<?php echo $name; ?>">
<?php if (isset($fieldSet->description) && trim($fieldSet->description)) : ?>
<?php echo '<p class="alert alert-info">' . $this->escape(JText::_($fieldSet->description)) . '</p>'; ?>
<?php endif; ?>
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
<div class="control-group">
<div class="control-label"><?php echo $field->label; ?></div>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>

View File

@ -1,25 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$fieldSets = $this->form->getFieldsets('params'); ?>
<?php foreach ($fieldSets as $name => $fieldSet) : ?>
<div class="tab-pane" id="params-<?php echo $name; ?>">
<?php if (isset($fieldSet->description) && trim($fieldSet->description)) : ?>
<?php echo '<p class="alert alert-info">' . $this->escape(JText::_($fieldSet->description)) . '</p>'; ?>
<?php endif; ?>
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
<div class="control-group">
<div class="control-label"><?php echo $field->label; ?></div>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>

View File

@ -1,117 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View to edit a weblink.
*
* @since 1.5
*/
class WeblinksViewWeblink extends JViewLegacy
{
protected $state;
protected $item;
protected $form;
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
// If we are forcing a language in modal (used for associations).
if ($this->getLayout() === 'modal' && $forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd'))
{
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = ($this->item->id == 0);
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
// Since we don't track these assets at the item level, use the category id.
$canDo = JHelperContent::getActions('com_weblinks', 'category', $this->item->catid);
JToolbarHelper::title($isNew ? JText::_('COM_WEBLINKS_MANAGER_WEBLINK_NEW') : JText::_('COM_WEBLINKS_MANAGER_WEBLINK_EDIT'), 'link weblinks');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit')||(count($user->getAuthorisedCategories('com_weblinks', 'core.create')))))
{
JToolbarHelper::apply('weblink.apply');
JToolbarHelper::save('weblink.save');
}
if (!$checkedOut && (count($user->getAuthorisedCategories('com_weblinks', 'core.create'))))
{
JToolbarHelper::save2new('weblink.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0))
{
JToolbarHelper::save2copy('weblink.save2copy');
}
if (empty($this->item->id))
{
JToolbarHelper::cancel('weblink.cancel');
}
else
{
if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit'))
{
JToolbarHelper::versions('com_weblinks.weblink', $this->item->id);
}
JToolbarHelper::cancel('weblink.cancel', 'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS_EDIT');
}
}

View File

@ -1,187 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$canOrder = $user->authorise('core.edit.state', 'com_weblinks.category');
$saveOrder = $listOrder == 'a.ordering';
$assoc = JLanguageAssociations::isEnabled();
if ($saveOrder)
{
$saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component';
JHtml::_('sortablelist.sortable', 'weblinkList', 'adminForm', strtolower($listDirn), $saveOrderingUrl);
}
?>
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=weblinks'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty($this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<div class="clearfix"> </div>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped" id="weblinkList">
<thead>
<tr>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th class="title">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'access_level', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap center hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<?php if ($assoc) : ?>
<th width="5%" class="nowrap hidden-phone hidden-tablet">
<?php echo JHtml::_('searchtools.sort', 'COM_WEBLINKS_HEADING_ASSOCIATION', 'association', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="8">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<?php $ordering = ($listOrder == 'a.ordering'); ?>
<?php $item->cat_link = JRoute::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]=' . $item->catid); ?>
<?php $canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid); ?>
<?php $canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid); ?>
<?php $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; ?>
<?php $canEditOwn = $user->authorise('core.edit.own', 'com_weblinks.category.' . $item->catid) && $item->created_by == $user->id; ?>
<?php $canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; ?>
<tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->catid; ?>">
<td class="order nowrap center hidden-phone">
<?php $iconClass = ''; ?>
<?php if (!$canChange) : ?>
<?php $iconClass = ' inactive'; ?>
<?php elseif (!$saveOrder) : ?>
<?php $iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); ?>
<?php endif; ?>
<span class="sortable-handler<?php echo $iconClass ?>">
<i class="icon-menu" aria-hidden="true"></i>
</span>
<?php if ($canChange && $saveOrder) : ?>
<input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " />
<?php endif; ?>
</td>
<td class="center">
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td>
<td class="center">
<div class="btn-group">
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
<?php // Create dropdown items and render the dropdown list. ?>
<?php if ($canChange) : ?>
<?php JHtml::_('actionsdropdown.' . ((int) $item->state === 2 ? 'un' : '') . 'archive', 'cb' . $i, 'weblinks'); ?>
<?php JHtml::_('actionsdropdown.' . ((int) $item->state === -2 ? 'un' : '') . 'trash', 'cb' . $i, 'weblinks'); ?>
<?php echo JHtml::_('actionsdropdown.render', $this->escape($item->title)); ?>
<?php endif; ?>
</div>
</td>
<td class="nowrap has-context">
<?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit || $canEditOwn) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id); ?>">
<?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<?php echo $this->escape($item->title); ?>
<?php endif; ?>
<span class="small">
<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
</span>
<div class="small">
<?php echo JText::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div>
</td>
<td class="small hidden-phone">
<?php echo $this->escape($item->access_level); ?>
</td>
<td class="center hidden-phone">
<?php echo $item->hits; ?>
</td>
<?php if ($assoc) : ?>
<td class="hidden-phone hidden-tablet">
<?php if ($item->association) : ?>
<?php echo JHtml::_('weblink.association', $item->id); ?>
<?php endif; ?>
</td>
<?php endif; ?>
<td class="small hidden-phone">
<?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
</td>
<td class="center hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php // Load the batch processing form. ?>
<?php if ($user->authorise('core.create', 'com_content')
&& $user->authorise('core.edit', 'com_content')
&& $user->authorise('core.edit.state', 'com_content')) : ?>
<?php echo JHtml::_(
'bootstrap.renderModal',
'collapseModal',
array(
'title' => JText::_('COM_WEBLINKS_BATCH_OPTIONS'),
'footer' => $this->loadTemplate('batch_footer'),
),
$this->loadTemplate('batch_body')
); ?>
<?php endif; ?>
<?php endif; ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -1,40 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$published = $this->state->get('filter.published');
?>
<div class="container-fluid">
<div class="row-fluid">
<div class="control-group span6">
<div class="controls">
<?php echo JHtml::_('batch.language'); ?>
</div>
</div>
<div class="control-group span6">
<div class="controls">
<?php echo JHtml::_('batch.access'); ?>
</div>
</div>
</div>
<div class="row-fluid">
<?php if ($published >= 0) : ?>
<div class="control-group span6">
<div class="controls">
<?php echo JHtml::_('batch.item', 'com_weblinks'); ?>
</div>
</div>
<?php endif; ?>
<div class="control-group span6">
<div class="controls">
<?php echo JHtml::_('batch.tag'); ?>
</div>
</div>
</div>
</div>

View File

@ -1,17 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<a class="btn" type="button" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value='';document.getElementById('batch-user-id').value='';document.getElementById('batch-tag-id').value=''" data-dismiss="modal">
<?php echo JText::_('JCANCEL'); ?>
</a>
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('weblink.batch');">
<?php echo JText::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>

View File

@ -1,147 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$app = JFactory::getApplication();
if ($app->isClient('site'))
{
JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
}
JLoader::register('WeblinksHelperRoute', JPATH_ROOT . '/components/com_weblinks/helpers/route.php');
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.core');
JHtml::_('behavior.polyfill', array('event'), 'lt IE 9');
JHtml::_('script', 'com_weblinks/admin-weblinks-modal.js', array('version' => 'auto', 'relative' => true));
JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
JHtml::_('formbehavior.chosen', 'select');
// Special case for the search field tooltip.
$searchFilterDesc = $this->filterForm->getFieldAttribute('search', 'description', null, 'filter');
JHtml::_('bootstrap.tooltip', '#filter_search', array('title' => JText::_($searchFilterDesc), 'placement' => 'bottom'));
$function = $app->input->getCmd('function', 'jSelectWeblink');
$editor = $app->input->getCmd('editor', '');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$onclick = $this->escape($function);
if (!empty($editor))
{
// This view is used also in com_menus. Load the xtd script only if the editor is set!
JFactory::getDocument()->addScriptOptions('xtd-weblinks', array('editor' => $editor));
$onclick = "jSelectWeblink";
}
$iconStates = array(
-2 => 'icon-trash',
0 => 'icon-unpublish',
1 => 'icon-publish',
2 => 'icon-archive',
);
?>
<div class="container-popup">
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&function=' . $function . '&' . JSession::getFormToken() . '=1&editor=' . $editor); ?>" method="post" name="adminForm" id="adminForm" class="form-inline">
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<div class="clearfix"></div>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th width="1%" class="center nowrap">
<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th class="title">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
</th>
<th width="15%" class="nowrap">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JDATE', 'a.created', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<?php $lang = ''; ?>
<?php if ($item->language && JLanguageMultilang::isEnabled()) : ?>
<?php $tag = strlen($item->language); ?>
<?php if ($tag == 5) : ?>
<?php $lang = substr($item->language, 0, 2); ?>
<?php elseif ($tag == 6) : ?>
<?php $lang = substr($item->language, 0, 3); ?>
<?php endif; ?>
<?php endif; ?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center">
<span class="<?php echo $iconStates[$this->escape($item->state)]; ?>"></span>
</td>
<td>
<?php $attribs = 'data-function="' . $this->escape($onclick) . '"'
. ' data-id="' . $item->id . '"'
. ' data-title="' . $this->escape(addslashes($item->title)) . '"'
. ' data-cat-id="' . $this->escape($item->catid) . '"'
. ' data-uri="' . $this->escape(WeblinksHelperRoute::getWeblinkRoute($item->id, $item->catid, $item->language)) . '"'
. ' data-language="' . $this->escape($lang) . '"';
?>
<a class="select-link" href="javascript:void(0)" <?php echo $attribs; ?>>
<?php echo $this->escape($item->title); ?>
</a>
<div class="small">
<?php echo JText::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div>
</td>
<td class="small hidden-phone">
<?php echo $this->escape($item->access_level); ?>
</td>
<td class="small">
<?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
</td>
<td class="nowrap small hidden-phone">
<?php echo JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC4')); ?>
</td>
<td class="nowrap small hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="forcedLanguage" value="<?php echo $app->input->get('forcedLanguage', '', 'CMD'); ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
</div>

View File

@ -1,169 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View class for a list of weblinks.
*
* @since 1.5
*/
class WeblinksViewWeblinks extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Modal layout doesn't need the submenu.
if ($this->getLayout() !== 'modal')
{
WeblinksHelper::addSubmenu('weblinks');
}
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
// We don't need toolbar in the modal layout.
if ($this->getLayout() !== 'modal')
{
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
}
else
{
// In article associations modal we need to remove language filter if forcing a language.
// We also need to change the category filter to show show categories with All or the forced language.
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'CMD'))
{
// If the language is forced we can't allow to select the language, so transform the language selector filter into an hidden field.
$languageXml = new SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
$this->filterForm->setField($languageXml, 'filter', true);
// Also, unset the active language filter so the search tools is not open by default with this filter.
unset($this->activeFilters['language']);
// One last changes needed is to change the category filter to just show categories with All language or with the forced language.
$this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter');
}
}
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
require_once JPATH_COMPONENT . '/helpers/weblinks.php';
$state = $this->get('State');
$canDo = JHelperContent::getActions('com_weblinks', 'category', $state->get('filter.category_id'));
$user = JFactory::getUser();
// Get the toolbar object instance
$bar = JToolbar::getInstance('toolbar');
JToolbarHelper::title(JText::_('COM_WEBLINKS_MANAGER_WEBLINKS'), 'link weblinks');
if (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)
{
JToolbarHelper::addNew('weblink.add');
}
if ($canDo->get('core.edit') || $canDo->get('core.edit.own'))
{
JToolbarHelper::editList('weblink.edit');
}
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::publish('weblinks.publish', 'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('weblinks.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolbarHelper::archiveList('weblinks.archive');
JToolbarHelper::checkin('weblinks.checkin');
}
if ($state->get('filter.published') == -2 && $canDo->get('core.delete'))
{
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'weblinks.delete', 'JTOOLBAR_EMPTY_TRASH');
}
elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::trash('weblinks.trash');
}
// Add a batch button
if ($user->authorise('core.create', 'com_weblinks') && $user->authorise('core.edit', 'com_weblinks')
&& $user->authorise('core.edit.state', 'com_weblinks'))
{
JHtml::_('bootstrap.renderModal', 'collapseModal');
$title = JText::_('JTOOLBAR_BATCH');
// Instantiate a new JLayoutFile instance and render the batch button
$layout = new JLayoutFile('joomla.toolbar.batch');
$dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch');
}
if ($user->authorise('core.admin', 'com_weblinks') || $user->authorise('core.options', 'com_weblinks'))
{
JToolbarHelper::preferences('com_weblinks');
}
JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS');
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
return array(
'a.ordering' => JText::_('JGRID_HEADING_ORDERING'),
'a.state' => JText::_('JSTATUS'),
'a.title' => JText::_('JGLOBAL_TITLE'),
'a.access' => JText::_('JGRID_HEADING_ACCESS'),
'a.hits' => JText::_('JGLOBAL_HITS'),
'a.language' => JText::_('JGRID_HEADING_LANGUAGE'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
}

View File

@ -1,20 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.tabstate');
if (!JFactory::getUser()->authorise('core.manage', 'com_weblinks'))
{
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
$controller = JControllerLegacy::getInstance('Weblinks');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();

View File

@ -1,66 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.5" method="upgrade">
<name>com_weblinks</name>
<author>Joomla! Project</author>
<creationDate>##DATE##</creationDate>
<copyright>(C) 2005 - ##YEAR## Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>##VERSION##</version>
<description>COM_WEBLINKS_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<install>
<sql>
<file charset="utf8" driver="mysql">sql/install.mysql.sql</file>
<file charset="utf8" driver="postgresql">sql/install.postgresql.sql</file>
<file charset="utf8" driver="sqlsrv">sql/install.sqlsrv.sql</file>
</sql>
</install>
<uninstall>
<sql>
<file charset="utf8" driver="mysql">sql/uninstall.mysql.sql</file>
<file charset="utf8" driver="postgresql">sql/uninstall.postgresql.sql</file>
<file charset="utf8" driver="sqlsrv">sql/uninstall.sqlsrv.sql</file>
</sql>
</uninstall>
<update>
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
<schemapath type="postgresql">sql/updates/postgresql</schemapath>
<schemapath type="sqlsrv">sql/updates/sqlsrv</schemapath>
</schemas>
</update>
<media folder="media/com_weblinks" destination="com_weblinks">
##MEDIA_FILES##
</media>
<files folder="components/com_weblinks">
##FRONTEND_COMPONENT_FILES##
</files>
<languages folder="language">
##FRONTEND_LANGUAGE_FILES##
</languages>
<administration>
<menu img="class:weblinks">com_weblinks</menu>
<submenu>
<!--
Note that all & must be escaped to &amp; for the file to be valid
XML and be parsed by the installer
-->
<menu link="option=com_weblinks" view="links" img="class:weblinks"
alt="Weblinks/Links">com_weblinks_links</menu>
<menu link="option=com_categories&amp;extension=com_weblinks"
view="categories" img="class:weblinks-cat" alt="Weblinks/Categories">com_weblinks_categories</menu>
</submenu>
<files folder="administrator/components/com_weblinks">
##BACKEND_COMPONENT_FILES##
</files>
<languages folder="administrator/language">
##BACKEND_LANGUAGE_FILES##
</languages>
</administration>
</extension>
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.5" method="upgrade">
<name>com_weblinks</name>
<element>com_weblinks</element>
<author>Joomla! Project</author>
<creationDate>##DATE##</creationDate>
<copyright>(C) 2005 - ##YEAR## Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>##VERSION##</version>
<description>COM_WEBLINKS_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<namespace path="src">Joomla\Component\Weblinks</namespace>
<install>
<sql>
<file charset="utf8" driver="mysql">sql/install.mysql.sql</file>
<file charset="utf8" driver="postgresql">sql/install.postgresql.sql</file>
</sql>
</install>
<uninstall>
<sql>
<file charset="utf8" driver="mysql">sql/uninstall.mysql.sql</file>
<file charset="utf8" driver="postgresql">sql/uninstall.postgresql.sql</file>
</sql>
</uninstall>
<update>
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
<schemapath type="postgresql">sql/updates/postgresql</schemapath>
</schemas>
</update>
<media folder="media/com_weblinks" destination="com_weblinks">
##MEDIA_FILES##
</media>
<files folder="components/com_weblinks">
##FRONTEND_COMPONENT_FILES##
</files>
<languages folder="language">
##FRONTEND_LANGUAGE_FILES##
</languages>
<administration>
<menu img="class:weblinks">com_weblinks</menu>
<submenu>
<!--
Note that all & must be escaped to &amp; for the file to be valid
XML and be parsed by the installer
-->
<menu link="option=com_weblinks" view="links" img="class:weblinks"
alt="Weblinks/Links">com_weblinks_links</menu>
<menu link="option=com_categories&amp;extension=com_weblinks"
view="categories" img="class:weblinks-cat" alt="Weblinks/Categories">com_weblinks_categories</menu>
<menu link="option=com_fields&amp;view=fields&amp;context=com_weblinks.weblink"
alt="Weblinks/Fields">com_weblinks_fields</menu>
<menu link="option=com_fields&amp;view=groups&amp;context=com_weblinks.weblink"
alt="Weblinks/Field Groups">com_weblinks_field_groups</menu>
</submenu>
<files folder="administrator/components/com_weblinks">
##BACKEND_COMPONENT_FILES##
</files>
<languages folder="administrator/language">
##BACKEND_LANGUAGE_FILES##
</languages>
</administration>
</extension>

View File

@ -0,0 +1,93 @@
; Joomla! Project
; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
COM_WEBLINKS="Web Links"
COM_WEBLINKS_BATCH_OPTIONS="Batch process the selected links"
COM_WEBLINKS_BATCH_TIP="If a category is selected for move/copy, any actions selected will be applied to the copied or moved links. Otherwise, all actions are applied to the selected links."
COM_WEBLINKS_CATEGORIES_DESC="These settings apply for Web Links Categories Options unless they are changed for a specific menu item."
COM_WEBLINKS_CATEGORY_DESC="These settings apply for Web Links Category Options unless they are changed for a specific menu item."
COM_WEBLINKS_CHANGE_WEBLINK="Select or Change Web Link"
COM_WEBLINKS_COMPONENT_DESC="These settings apply for Web Links unless they are changed for a specific menu item or Web Link."
COM_WEBLINKS_COMPONENT_LABEL="Web Link"
COM_WEBLINKS_CONFIGURATION="Web Links Manager Options"
COM_WEBLINKS_CONFIG_INTEGRATION_SETTINGS_DESC="These settings determine how the Web Links Component will integrate with other extensions."
COM_WEBLINKS_EDIT_WEBLINK="Edit Web Link"
COM_WEBLINKS_EMPTYSTATE_BUTTON_ADD="Add your first Web Link"
COM_WEBLINKS_EMPTYSTATE_CONTENT="Add, edit and remove links to other web sites on your Joomla! web site, and organize them into categories. You can then display these links on your site, and optionally let visitors add new links."
COM_WEBLINKS_EMPTYSTATE_TITLE="No Web Links have been created yet."
COM_WEBLINKS_ERROR_UNIQUE_ALIAS="Another Web Link from this category has the same alias (remember it may be a trashed item)."
COM_WEBLINKS_ERR_TABLES_NAME="There is already a Web Link with that name in this category. Please try again."
COM_WEBLINKS_ERR_TABLES_PROVIDE_URL="Please provide a valid URL"
COM_WEBLINKS_ERR_TABLES_TITLE="Your Web Link must contain a title."
COM_WEBLINKS_FIELDSET_OPTIONS="Options"
COM_WEBLINKS_FIELD_CAPTCHA_LABEL="Allow Captcha on Web Link"
COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL="# Web Links"
COM_WEBLINKS_FIELD_CONFIG_ICON_DESC="If Icon is chosen above, select an icon to display with the Web Links. If none is selected, the default icon will be used."
COM_WEBLINKS_FIELD_CONFIG_ICON_LABEL="Select Icon"
COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_LABEL="Links Description"
COM_WEBLINKS_FIELD_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded."
COM_WEBLINKS_FIELD_COUNTCLICKS_LABEL="Count Clicks"
COM_WEBLINKS_FIELD_FIRST_LABEL="First Image"
COM_WEBLINKS_FIELD_HEIGHT_LABEL="Height"
COM_WEBLINKS_FIELD_ICON_DESC="Displays a text, an icon or nothing with the Web links. Default is 'Icon'."
COM_WEBLINKS_FIELD_ICON_LABEL="Text/Icon/Web Link Only"
COM_WEBLINKS_FIELD_ICON_OPTION_ICON="Icon"
COM_WEBLINKS_FIELD_ICON_OPTION_TEXT="Text"
COM_WEBLINKS_FIELD_ICON_OPTION_WEBLINK="Web Link Only"
COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_DESC="Decorative Image - no description required"
COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_LABEL="No Description"
COM_WEBLINKS_FIELD_IMAGE_ALT_LABEL="Alt Text"
COM_WEBLINKS_FIELD_IMAGE_CAPTION_LABEL="Caption"
COM_WEBLINKS_FIELD_MODIFIED_DESC="The date and time the link was last modified."
COM_WEBLINKS_FIELD_SECOND_LABEL="Second Image"
COM_WEBLINKS_FIELD_SELECT_CATEGORY_LABEL="Select a Category"
COM_WEBLINKS_FIELD_SHOW_CAT_TAGS_LABEL="Category Tags"
COM_WEBLINKS_FIELD_SHOW_TAGS_LABEL="Tags"
COM_WEBLINKS_FIELD_TARGET_DESC="Target browser window when the link is selected."
COM_WEBLINKS_FIELD_TARGET_LABEL="Target"
COM_WEBLINKS_FIELD_URL_LABEL="URL"
COM_WEBLINKS_FIELD_VALUE_REPORTED="Reported"
COM_WEBLINKS_FIELD_VERSION_LABEL="Revision"
COM_WEBLINKS_FIELD_WIDTH_LABEL="Width"
COM_WEBLINKS_FILTER_SEARCH_DESC="Search in Web Link title and alias. Prefix with ID: to search for a Web Link ID."
COM_WEBLINKS_FILTER_SEARCH_LABEL="Search Web Links"
COM_WEBLINKS_FILTER_STATE="Filter State"
COM_WEBLINKS_FLOAT_FIRST_LABEL="First Image Float"
COM_WEBLINKS_FLOAT_SECOND_LABEL="Second Image Float"
COM_WEBLINKS_HEADING_ASSOCIATION="Association"
COM_WEBLINKS_LEFT="Left"
COM_WEBLINKS_LIST_LAYOUT_DESC="These settings apply for Web Links List Layout Options unless they are changed for a specific menu item."
COM_WEBLINKS_MANAGER_WEBLINK="Web Links"
COM_WEBLINKS_MANAGER_WEBLINKS="Web Links"
COM_WEBLINKS_MANAGER_WEBLINK_EDIT="Web Link: Edit"
COM_WEBLINKS_MANAGER_WEBLINK_NEW="Web Link: New"
COM_WEBLINKS_NEW_WEBLINK="New Web Link"
COM_WEBLINKS_NONE="None"
COM_WEBLINKS_N_ITEMS_ARCHIVED="%d Web Links archived."
COM_WEBLINKS_N_ITEMS_ARCHIVED_1="%d Web Link archived."
COM_WEBLINKS_N_ITEMS_CHECKED_IN_0="No Web Link checked in."
COM_WEBLINKS_N_ITEMS_CHECKED_IN_1="%d Web Link checked in."
COM_WEBLINKS_N_ITEMS_CHECKED_IN_MORE="%d Web Links checked in."
COM_WEBLINKS_N_ITEMS_DELETED="%d Web Links deleted."
COM_WEBLINKS_N_ITEMS_DELETED_1="%d Web Link deleted."
COM_WEBLINKS_N_ITEMS_PUBLISHED="%d Web Links published."
COM_WEBLINKS_N_ITEMS_PUBLISHED_1="%d Web Link published."
COM_WEBLINKS_N_ITEMS_TRASHED="%d Web Links trashed."
COM_WEBLINKS_N_ITEMS_TRASHED_1="%d Web Link trashed."
COM_WEBLINKS_N_ITEMS_UNPUBLISHED="%d Web Links unpublished."
COM_WEBLINKS_N_ITEMS_UNPUBLISHED_1="%d Web Link unpublished."
COM_WEBLINKS_OPTIONS="Options"
COM_WEBLINKS_RIGHT="Right"
COM_WEBLINKS_SAVE_SUCCESS="Web link saved"
COM_WEBLINKS_SELECT_A_WEBLINK="Select Web Link"
COM_WEBLINKS_SUBMENU_CATEGORIES="Categories"
COM_WEBLINKS_SUBMENU_WEBLINKS="Web Links"
COM_WEBLINKS_WEBLINKS="Web Links"
COM_WEBLINKS_XML_DESCRIPTION="Component for Web Links management"
JGLOBAL_NEWITEMSLAST_DESC="New Web links default to the last position. Ordering can be changed after this Web link is saved."
JGLOBAL_NO_ITEM_SELECTED="No Web Links selected"
JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE="You are not allowed to create new Web Links in this category."
JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT="You are not allowed to edit one or more of these Web Links."
JLIB_RULES_SETTING_NOTES="Changes apply to this component only.<br /><em><strong>Inherited</strong></em> - a Global Configuration setting or higher level setting is applied.<br /><em><strong>Denied</strong></em> always wins - whatever is set at the Global or higher level and applies to all child elements.<br /><em><strong>Allowed</strong></em> will enable the action for this component unless it is overruled by a Global Configuration setting."

View File

@ -15,11 +15,12 @@ COM_WEBLINKS_CATEGORY_VIEW_DEFAULT_OPTION="Default"
COM_WEBLINKS_CATEGORY_VIEW_DEFAULT_TITLE="List Web Links in a Category"
COM_WEBLINKS_CONTENT_TYPE_WEBLINK="Web Link"
COM_WEBLINKS_CONTENT_TYPE_CATEGORY="Web Links Category"
COM_WEBLINKS_FIELD_SELECT_WEBLINK_DESC="Select the desired Web link from the list."
COM_WEBLINKS_FIELD_SELECT_WEBLINK_LABEL="Select Weblink"
COM_WEBLINKS_FORM_VIEW_DEFAULT_DESC="Display a form to submit a web link in the Frontend."
COM_WEBLINKS_FORM_VIEW_DEFAULT_OPTION="Default"
COM_WEBLINKS_FORM_VIEW_DEFAULT_TITLE="Submit a Web Link"
COM_WEBLINKS_FIELDS="Fields"
COM_WEBLINKS_FIELD_GROUPS="Field Groups"
COM_WEBLINKS_LINKS="Links"
COM_WEBLINKS_TAGS_WEBLINK="Web Link"
COM_WEBLINKS_TAGS_CATEGORY="Web Link Category"

View File

@ -1,133 +0,0 @@
; Joomla! Project
; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
COM_WEBLINKS="Web Links"
COM_WEBLINKS_ACCESS_HEADING="Access"
COM_WEBLINKS_BATCH_OPTIONS="Batch process the selected links"
COM_WEBLINKS_BATCH_TIP="If a category is selected for move/copy, any actions selected will be applied to the copied or moved links. Otherwise, all actions are applied to the selected links."
COM_WEBLINKS_CATEGORIES_DESC="These settings apply for Web Links Categories Options unless they are changed for a specific menu item."
COM_WEBLINKS_CATEGORY_DESC="These settings apply for Web Links Category Options unless they are changed for a specific menu item."
COM_WEBLINKS_CHANGE_WEBLINK="Select or Change Web Link"
COM_WEBLINKS_COMPONENT_DESC="These settings apply for Web Links unless they are changed for a specific menu item or web link."
COM_WEBLINKS_COMPONENT_LABEL="Web Link"
COM_WEBLINKS_CONFIG_INTEGRATION_SETTINGS_DESC="These settings determine how the Web Links Component will integrate with other extensions."
COM_WEBLINKS_CONFIGURATION="Web Links Manager Options"
COM_WEBLINKS_EDIT_WEBLINK="Edit Web Link"
COM_WEBLINKS_ERR_TABLES_NAME="There is already a Web Link with that name in this category. Please try again."
COM_WEBLINKS_ERR_TABLES_PROVIDE_URL="Please provide a valid URL"
COM_WEBLINKS_ERR_TABLES_TITLE="Your web link must contain a title."
COM_WEBLINKS_ERROR_UNIQUE_ALIAS="Another web link from this category has the same alias (remember it may be a trashed item)."
COM_WEBLINKS_FIELD_ALIAS_DESC="The alias is for internal use only. Leave this blank and Joomla will fill in a default value from the title. It has to be unique for each web link in the same category."
COM_WEBLINKS_FIELD_CATEGORY_DESC="Choose a category for this Web link."
COM_WEBLINKS_FIELD_CATEGORYCHOOSE_DESC="Please choose a Web Links category to display."
COM_WEBLINKS_FIELD_CAPTCHA_DESC="Select the captcha plugin that will be used in the web link submit form. You may need to enter required information for your captcha plugin in the Plugin Manager.<br />If 'Use Default' is selected, make sure a captcha plugin is selected in Global Configuration."
COM_WEBLINKS_FIELD_CAPTCHA_LABEL="Allow Captcha on Web Link"
COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC="Show or hide the number of Web Links in each Category."
COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL="# Web Links"
COM_WEBLINKS_FIELD_CONFIG_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded."
COM_WEBLINKS_FIELD_CONFIG_COUNTCLICKS_LABEL="Count Clicks"
COM_WEBLINKS_FIELD_CONFIG_DESCRIPTION_DESC="Show or hide the description below."
COM_WEBLINKS_FIELD_CONFIG_HITS_DESC="Show or hide hits."
COM_WEBLINKS_FIELD_CONFIG_ICON_DESC="If Icon is chosen above, select an icon to display with the Web Links. If none is selected, the default icon will be used."
COM_WEBLINKS_FIELD_CONFIG_ICON_LABEL="Select Icon"
COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_DESC="Show or hide the links description."
COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_LABEL="Links Description"
COM_WEBLINKS_FIELD_CONFIG_OTHERCATS_DESC="Show or hide other categories."
COM_WEBLINKS_FIELD_CONFIG_OTHERCATS_LABEL="Other Categories"
COM_WEBLINKS_FIELD_CONFIG_SHOWREPORT_DESC="Show or hide the Report Bad Link option."
COM_WEBLINKS_FIELD_CONFIG_SHOWREPORT_LABEL="Reports"
COM_WEBLINKS_FIELD_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded."
COM_WEBLINKS_FIELD_COUNTCLICKS_LABEL="Count Clicks"
COM_WEBLINKS_FIELD_DESCRIPTION_DESC="Enter a description for the web link."
COM_WEBLINKS_FIELD_DISPLAY_NUM_DESC="Default number of Web links to list on a page."
COM_WEBLINKS_FIELD_DISPLAY_NUM_LABEL="# of Web links to List"
COM_WEBLINKS_FIELD_FIRST_DESC="The image to be displayed."
COM_WEBLINKS_FIELD_FIRST_LABEL="First Image"
COM_WEBLINKS_FIELD_HEIGHT_DESC="Height of the target popup or modal window. Defaults to 600x500 if one field is left empty."
COM_WEBLINKS_FIELD_HEIGHT_LABEL="Height"
COM_WEBLINKS_FIELD_ICON_DESC="Displays a text, an icon or nothing with the Web links. Default is 'Icon'."
COM_WEBLINKS_FIELD_ICON_LABEL="Text/Icon/Web Link Only"
COM_WEBLINKS_FIELD_ICON_OPTION_ICON="Icon"
COM_WEBLINKS_FIELD_ICON_OPTION_TEXT="Text"
COM_WEBLINKS_FIELD_ICON_OPTION_WEBLINK="Web Link Only"
COM_WEBLINKS_FIELD_IMAGE_ALT_DESC="Alternative text used for visitors without access to images. Replaced with caption text if it is present."
COM_WEBLINKS_FIELD_IMAGE_ALT_LABEL="Alt Text"
COM_WEBLINKS_FIELD_IMAGE_CAPTION_DESC="Caption attached to the image."
COM_WEBLINKS_FIELD_IMAGE_CAPTION_LABEL="Caption"
COM_WEBLINKS_FIELD_LANGUAGE_DESC="Assign a language to this web link."
COM_WEBLINKS_FIELD_MODIFIED_DESC="The date and time the link was last modified."
COM_WEBLINKS_FIELD_SECOND_DESC="The second image to be displayed."
COM_WEBLINKS_FIELD_SECOND_LABEL="Second Image"
COM_WEBLINKS_FIELD_SELECT_CATEGORY_DESC="Select a web links category to display."
COM_WEBLINKS_FIELD_SELECT_CATEGORY_LABEL="Select a Category"
COM_WEBLINKS_FIELD_SHOW_CAT_TAGS_DESC="Show the tags for a category."
COM_WEBLINKS_FIELD_SHOW_CAT_TAGS_LABEL="Show Tags"
COM_WEBLINKS_FIELD_SHOW_TAGS_DESC="Show the tags for a web link."
COM_WEBLINKS_FIELD_SHOW_TAGS_LABEL="Show Tags"
COM_WEBLINKS_FIELD_STATE_DESC="Set publication status."
COM_WEBLINKS_FIELD_TARGET_DESC="Target browser window when the link is selected."
COM_WEBLINKS_FIELD_TARGET_LABEL="Target"
COM_WEBLINKS_FIELD_TITLE_DESC="Web Link must have a title."
COM_WEBLINKS_FIELD_URL_DESC="You must enter a URL. IDN (International) Links are converted to punycode when they are saved."
COM_WEBLINKS_FIELD_URL_LABEL="URL"
COM_WEBLINKS_FIELD_VALUE_REPORTED="Reported"
COM_WEBLINKS_FIELD_VERSION_DESC="A count of the number of times this web link has been revised."
COM_WEBLINKS_FIELD_VERSION_LABEL="Revision"
COM_WEBLINKS_FIELD_WIDTH_DESC="Width of the target popup or modal window. Defaults to 600x500 if one field is left empty."
COM_WEBLINKS_FIELD_WIDTH_LABEL="Width"
COM_WEBLINKS_FIELDSET_IMAGES="Images"
COM_WEBLINKS_FIELDSET_OPTIONS="Options"
COM_WEBLINKS_FILTER_CATEGORY="Filter Category"
COM_WEBLINKS_FILTER_SEARCH_DESC="Search in web link title and alias. Prefix with ID: to search for a web link ID."
COM_WEBLINKS_FILTER_SEARCH_LABEL="Search Web Links"
COM_WEBLINKS_FILTER_STATE="Filter State"
COM_WEBLINKS_FLOAT_FIRST_DESC="Controls placement of the first image."
COM_WEBLINKS_FLOAT_FIRST_LABEL="First Image Float"
COM_WEBLINKS_FLOAT_SECOND_DESC="Controls placement of the second image."
COM_WEBLINKS_FLOAT_SECOND_LABEL="Second Image Float"
COM_WEBLINKS_HEADING_ASSOCIATION="Association"
COM_WEBLINKS_HITS_DESC="Number of hits for this web link."
COM_WEBLINKS_LEFT="Left"
COM_WEBLINKS_LIST_LAYOUT_DESC="These settings apply for Web Links List Layout Options unless they are changed for a specific menu item."
COM_WEBLINKS_MANAGER_WEBLINK="Web Links"
COM_WEBLINKS_MANAGER_WEBLINKS="Web Links"
COM_WEBLINKS_MANAGER_WEBLINK_EDIT="Web Link: Edit"
COM_WEBLINKS_MANAGER_WEBLINK_NEW="Web Link: New"
COM_WEBLINKS_N_ITEMS_ARCHIVED="%d web links successfully archived."
COM_WEBLINKS_N_ITEMS_ARCHIVED_1="%d web link successfully archived."
COM_WEBLINKS_N_ITEMS_CHECKED_IN_0="No web link successfully checked in."
COM_WEBLINKS_N_ITEMS_CHECKED_IN_1="%d web link successfully checked in."
COM_WEBLINKS_N_ITEMS_CHECKED_IN_MORE="%d web links successfully checked in."
COM_WEBLINKS_N_ITEMS_DELETED="%d web links successfully deleted."
COM_WEBLINKS_N_ITEMS_DELETED_1="%d web link successfully deleted."
COM_WEBLINKS_N_ITEMS_PUBLISHED="%d web links successfully published."
COM_WEBLINKS_N_ITEMS_PUBLISHED_1="%d web link successfully published."
COM_WEBLINKS_N_ITEMS_TRASHED="%d web links successfully trashed."
COM_WEBLINKS_N_ITEMS_TRASHED_1="%d web link successfully trashed."
COM_WEBLINKS_N_ITEMS_UNPUBLISHED="%d web links successfully unpublished."
COM_WEBLINKS_N_ITEMS_UNPUBLISHED_1="%d web link successfully unpublished."
COM_WEBLINKS_NEW_WEBLINK="New Web Link"
COM_WEBLINKS_NONE="None"
COM_WEBLINKS_OPTION_FILTER_ACCESS="- Filter Access -"
COM_WEBLINKS_OPTION_FILTER_CATEGORY="- Filter Category -"
COM_WEBLINKS_OPTION_FILTER_PUBLISHED="- Filter State -"
COM_WEBLINKS_OPTIONS="Options"
COM_WEBLINKS_ORDER_HEADING="Order"
COM_WEBLINKS_RIGHT="Right"
COM_WEBLINKS_SAVE_SUCCESS="Web link successfully saved"
COM_WEBLINKS_SEARCH_IN_TITLE="Search in title"
COM_WEBLINKS_SELECT_A_WEBLINK="Select Web Link"
COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC="If Show, empty categories will display. A category is only empty - if it has no Web links or subcategories."
COM_WEBLINKS_SUBMENU_CATEGORIES="Categories"
COM_WEBLINKS_SUBMENU_WEBLINKS="Web Links"
COM_WEBLINKS_WEBLINKS="Web Links"
COM_WEBLINKS_XML_DESCRIPTION="Component for web links management"
JGLOBAL_NO_ITEM_SELECTED="No web links selected"
JGLOBAL_NEWITEMSLAST_DESC="New Web links default to the last position. Ordering can be changed after this Web link is saved."
JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE="You are not allowed to create new web links in this category."
JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT="You are not allowed to edit one or more of these web links."
JLIB_RULES_SETTING_NOTES="Changes apply to this component only.<br /><em><strong>Inherited</strong></em> - a Global Configuration setting or higher level setting is applied.<br /><em><strong>Denied</strong></em> always wins - whatever is set at the Global or higher level and applies to all child elements.<br /><em><strong>Allowed</strong></em> will enable the action for this component unless it is overruled by a Global Configuration setting."

View File

@ -21,10 +21,10 @@
<file type="plugin" id="weblinks" group="finder">plg_finder_weblinks.zip</file>
<file type="plugin" id="weblinks" group="search">plg_search_weblinks.zip</file>
<file type="plugin" id="weblinks" group="system">plg_system_weblinks.zip</file>
<file type="plugin" id="weblinks" group="editors-xtd">plg_editors-xtd_weblink.zip</file>
<file type="plugin" id="weblink" group="editors-xtd">plg_editors-xtd_weblink.zip</file>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.pkg_weblinks.sys.ini</language>
<language tag="en-GB">en-GB/pkg_weblinks.sys.ini</language>
</languages>
<updateservers>
<!-- Note: No spaces or linebreaks allowed between the server tags -->

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
@ -7,23 +8,27 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Installer\InstallerScript;
/**
* Installation class to perform additional changes during install/uninstall/update
*
* @since __DEPLOY_VERSION__
*/
class Pkg_WeblinksInstallerScript extends JInstallerScript
class Pkg_WeblinksInstallerScript extends InstallerScript
{
/**
* Extension script constructor.
*
* @since __DEPLOY_VERSION__
*/
public function __construct()
{
$this->minimumJoomla = '3.6.3';
$this->minimumPhp = JOOMLA_MINIMUM_PHP;
}
/**
* Extension script constructor.
*
* @since __DEPLOY_VERSION__
*/
public function __construct()
{
$this->minimumJoomla = '4.3.0';
$this->minimumPhp = JOOMLA_MINIMUM_PHP;
}
}

View File

@ -1,67 +0,0 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks Component Controller
*
* @since 1.5
*/
class WeblinksController extends JControllerLegacy
{
/**
* Method to display a view.
*
* @param boolean $cacheable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types,
* for valid values see {@link JFilterInput::clean()}.
*
* @return WeblinksController This object to support chaining.
*
* @since 1.5
*/
public function display($cacheable = false, $urlparams = false)
{
// Huh? Why not just put that in the constructor?
$cacheable = true;
/**
* Set the default view name and format from the Request.
* Note we are using w_id to avoid collisions with the router and the return page.
* Frontend is a bit messier than the backend.
*/
$id = $this->input->getInt('w_id');
$vName = $this->input->get('view', 'categories');
$this->input->set('view', $vName);
if (JFactory::getUser()->id ||($this->input->getMethod() == 'POST' && $vName == 'categories'))
{
$cacheable = false;
}
$safeurlparams = array(
'id' => 'INT',
'limit' => 'UINT',
'limitstart' => 'UINT',
'filter_order' => 'CMD',
'filter_order_Dir' => 'CMD',
'lang' => 'CMD'
);
// Check for edit form.
if ($vName == 'form' && !$this->checkEditId('com_weblinks.edit.weblink', $id))
{
// Somehow the person just went to the form - we don't allow that.
return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
}
return parent::display($cacheable, $safeurlparams);
}
}

View File

@ -1,313 +0,0 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Weblinks class.
*
* @since 1.5
*/
class WeblinksControllerWeblink extends JControllerForm
{
/**
* The URL view item variable.
*
* @var string
* @since 1.6
*/
protected $view_item = 'form';
/**
* The URL view list variable.
*
* @var string
* @since 1.6
*/
protected $view_list = 'categories';
/**
* The URL edit variable.
*
* @var string
* @since 3.2
*/
protected $urlVar = 'a.id';
/**
* Method to add a new record.
*
* @return boolean True if the article can be added, false if not.
*
* @since 1.6
*/
public function add()
{
if (!parent::add())
{
// Redirect to the return page.
$this->setRedirect($this->getReturnPage());
}
}
/**
* Method override to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 1.6
*/
protected function allowAdd($data = array())
{
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('id'), 'int');
$allow = null;
if ($categoryId)
{
// If the category has been passed in the URL check it.
$allow = JFactory::getUser()->authorise('core.create', $this->option . '.category.' . $categoryId);
}
if ($allow !== null)
{
return $allow;
}
// In the absense of better information, revert to the component permissions.
return parent::allowAdd($data);
}
/**
* Method to check if you can add a new record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = array(), $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$categoryId = 0;
if ($recordId)
{
$categoryId = (int) $this->getModel()->getItem($recordId)->catid;
}
if ($categoryId)
{
// The category has been set. Check the category permissions.
return JFactory::getUser()->authorise('core.edit', $this->option . '.category.' . $categoryId);
}
// Since there is no asset tracking, revert to the component permissions.
return parent::allowEdit($data, $key);
}
/**
* Method to cancel an edit.
*
* @param string $key The name of the primary key of the URL variable.
*
* @return boolean True if access level checks pass, false otherwise.
*
* @since 1.6
*/
public function cancel($key = 'w_id')
{
$return = parent::cancel($key);
// Redirect to the return page.
$this->setRedirect($this->getReturnPage());
return $return;
}
/**
* Method to edit an existing record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return boolean True if access level check and checkout passes, false otherwise.
*
* @since 1.6
*/
public function edit($key = null, $urlVar = 'w_id')
{
return parent::edit($key, $urlVar);
}
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.5
*/
public function getModel($name = 'form', $prefix = '', $config = array('ignore_request' => true))
{
return parent::getModel($name, $prefix, $config);
}
/**
* Gets the URL arguments to append to an item redirect.
*
* @param integer $recordId The primary key id for the item.
* @param string $urlVar The name of the URL variable for the id.
*
* @return string The arguments to append to the redirect URL.
*
* @since 1.6
*/
protected function getRedirectToItemAppend($recordId = null, $urlVar = null)
{
$append = parent::getRedirectToItemAppend($recordId, $urlVar);
$itemId = $this->input->getInt('Itemid');
$return = $this->getReturnPage();
if ($itemId)
{
$append .= '&Itemid=' . $itemId;
}
if ($return)
{
$append .= '&return=' . base64_encode($return);
}
return $append;
}
/**
* Get the return URL if a "return" variable has been passed in the request
*
* @return string The return URL.
*
* @since 1.6
*/
protected function getReturnPage()
{
$return = $this->input->get('return', null, 'base64');
if (empty($return) || !JUri::isInternal(base64_decode($return)))
{
return JUri::base();
}
return base64_decode($return);
}
/**
* Method to save a record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return boolean True if successful, false otherwise.
*
* @since 1.6
*/
public function save($key = null, $urlVar = 'w_id')
{
// Get the application
$app = JFactory::getApplication();
// Get the data from POST
$data = $this->input->post->get('jform', array(), 'array');
// Save the data in the session.
$app->setUserState('com_weblinks.edit.weblink.data', $data);
$result = parent::save($key, $urlVar);
// If ok, redirect to the return page.
if ($result)
{
// Flush the data from the session
$app->setUserState('com_weblinks.edit.weblink.data', null);
$this->setRedirect($this->getReturnPage());
}
return $result;
}
/**
* Go to a weblink
*
* @return void
*
* @since 1.6
*/
public function go()
{
// Get the ID from the request
$id = $this->input->getInt('id');
// Get the model, requiring published items
$modelLink = $this->getModel('Weblink', '', array('ignore_request' => true));
$modelLink->setState('filter.published', 1);
// Get the item
$link = $modelLink->getItem($id);
// Make sure the item was found.
if (empty($link))
{
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'));
}
// Check whether item access level allows access.
$groups = JFactory::getUser()->getAuthorisedViewLevels();
if (!in_array($link->access, $groups))
{
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Check whether category access level allows access.
$modelCat = $this->getModel('Category', 'WeblinksModel', array('ignore_request' => true));
$modelCat->setState('filter.published', 1);
// Get the category
$category = $modelCat->getCategory($link->catid);
// Make sure the category was found.
if (empty($category))
{
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'));
}
// Check whether item access level allows access.
if (!in_array($category->access, $groups))
{
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Redirect to the URL
// @todo: Probably should check for a valid http link
if ($link->url)
{
$modelLink->hit($id);
JFactory::getApplication()->redirect($link->url, 301);
}
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_URL_INVALID'));
}
}

View File

@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_categories/models/fields">
<fieldset addfieldprefix="Joomla\Component\Categories\Administrator\Field">
<field
name="id"
type="hidden"
label="WEBLINK_ID_LABEL"
readonly="true"
required="true"
size="10"
default="0"
/>
@ -23,25 +21,21 @@
name="title"
type="text"
label="JGLOBAL_TITLE"
description="COM_WEBLINKS_FIELD_TITLE_DESC"
required="true"
size="30"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="COM_WEBLINKS_FIELD_ALIAS_DESC"
description="JFIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER"
size="45"
/>
<field
name="description"
type="editor"
label="JGLOBAL_DESCRIPTION"
description="COM_WEBLINKS_FIELD_DESCRIPTION_DESC"
buttons="true"
hide="pagebreak,readmore"
filter="safehtml"
@ -52,9 +46,10 @@
name="state"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
default="1"
class="form-select-color-state"
size="1"
default="1"
validate="options"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
@ -64,7 +59,6 @@
name="catid"
type="categoryedit"
label="JCATEGORY"
description="COM_WEBLINKS_FIELD_CATEGORY_DESC"
extension="com_weblinks"
required="true"
/>
@ -73,18 +67,14 @@
name="url"
type="url"
label="COM_WEBLINKS_FIELD_URL_LABEL"
description="COM_WEBLINKS_FIELD_URL_DESC"
filter="url"
required="true"
size="45"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="JFIELD_LANGUAGE_DESC"
class="inputbox"
>
<option value="*">JALL</option>
</field>
@ -93,8 +83,6 @@
name="tags"
type="tag"
label="JTAG"
description="JTAG_DESC"
class="inputbox"
multiple="true"
/>
@ -102,22 +90,105 @@
name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
class="inputbox"
size="45"
labelclass="control-label"
maxlength="255"
/>
<field
name="captcha"
type="captcha"
label="COM_WEBLINKS_CAPTCHA_LABEL"
description="COM_WEBLINKS_CAPTCHA_DESC"
validate="captcha"
namespace="weblink"
/>
</fieldset>
<fields
name="images"
>
<fieldset
name="images"
label="JGLOBAL_FIELDSET_IMAGE_OPTIONS"
>
<field
name="image_first"
type="media"
label="COM_WEBLINKS_FIELD_FIRST_LABEL"
/>
<field
name="float_first"
type="list"
label="COM_WEBLINKS_FLOAT_FIRST_LABEL"
useglobal="true"
>
<option value="right">COM_WEBLINKS_RIGHT</option>
<option value="left">COM_WEBLINKS_LEFT</option>
<option value="none">COM_WEBLINKS_NONE</option>
</field>
<field
name="image_first_alt"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_LABEL"
/>
<field
name="image_first_alt_empty"
type="checkbox"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_DESC"
/>
<field
name="image_first_caption"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_CAPTION_LABEL"
/>
<field
name="spacer1"
type="spacer"
hr="true"
/>
<field
name="image_second"
type="media"
label="COM_WEBLINKS_FIELD_SECOND_LABEL"
/>
<field
name="float_second"
type="list"
label="COM_WEBLINKS_FLOAT_SECOND_LABEL"
useglobal="true"
>
<option value="right">COM_WEBLINKS_RIGHT</option>
<option value="left">COM_WEBLINKS_LEFT</option>
<option value="none">COM_WEBLINKS_NONE</option>
</field>
<field
name="image_second_alt"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_LABEL"
/>
<field
name="image_second_alt_empty"
type="checkbox"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_ALT_EMPTY_DESC"
/>
<field
name="image_second_caption"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_CAPTION_LABEL"
/>
</fieldset>
</fields>
<fields name="metadata">
<fieldset
name="jmetadata"
@ -127,46 +198,34 @@
name="robots"
type="hidden"
label="JFIELD_METADATA_ROBOTS_LABEL"
description="JFIELD_METADATA_ROBOTS_DESC"
filter="unset"
labelclass="control-label"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>
<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>
<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>
<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>
<option value="index, follow" />
<option value="noindex, follow" />
<option value="index, nofollow" />
<option value="noindex, nofollow" />
</field>
<field
name="author"
type="hidden"
label="JAUTHOR"
description="JFIELD_METADATA_AUTHOR_DESC"
filter="unset"
size="20"
labelclass="control-label"
/>
<field
name="rights"
type="hidden"
label="JFIELD_META_RIGHTS_LABEL"
description="JFIELD_META_RIGHTS_DESC"
filter="unset"
required="false"
labelclass="control-label"
/>
<field
name="xreference"
type="hidden"
label="COM_CONTENT_FIELD_XREFERENCE_LABEL"
description="COM_CONTENT_FIELD_XREFERENCE_DESC"
filter="unset"
class="inputbox"
size="20"
labelclass="control-label"
/>
</fieldset>
</fields>

View File

@ -1,63 +0,0 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
JLoader::register('WeblinksHelperRoute', JPATH_SITE . '/components/com_weblinks/helpers/route.php');
JLoader::register('CategoryHelperAssociation', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/association.php');
/**
* Weblinks Component Association Helper
*
* @since 3.0
*/
abstract class WeblinksHelperAssociation extends CategoryHelperAssociation
{
/**
* Method to get the associations for a given item
*
* @param integer $id Id of the item
* @param string $view Name of the view
*
* @return array Array of associations for the item
*
* @since 3.0
*/
public static function getAssociations($id = 0, $view = null)
{
$jinput = JFactory::getApplication()->input;
$view = is_null($view) ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
if ($view === 'weblink')
{
if ($id)
{
$associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $id);
$return = array();
foreach ($associations as $tag => $item)
{
$return[$tag] = WeblinksHelperRoute::getWeblinkRoute($item->id, (int) $item->catid, $item->language);
}
return $return;
}
}
if ($view == 'category' || $view == 'categories')
{
return self::getCategoryAssociations($id, 'com_weblinks');
}
return array();
}
}

View File

@ -1,33 +0,0 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks Component Category Tree.
*
* @since 1.6
*/
class WeblinksCategories extends JCategories
{
/**
* Constructor
*
* @param array $options Array of options
*
* @since 1.6
*/
public function __construct($options = array())
{
$options['table'] = '#__weblinks';
$options['extension'] = 'com_weblinks';
parent::__construct($options);
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
@ -7,8 +8,9 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Weblink Component HTML Helper.
*
@ -16,74 +18,40 @@ defined('_JEXEC') or die;
*/
class JHtmlIcon
{
/**
* Create a link to create a new weblink
*
* @param mixed $weblink Unused
* @param mixed $params Unused
*
* @return string
*/
public static function create($weblink, $params)
{
JHtml::_('bootstrap.tooltip');
/**
* Create a link to create a new weblink
*
* @param object $category The category information
* @param \Joomla\Registry\Registry $params The item parameters
*
* @return string
*/
public static function create($category, $params)
{
return self::getIcon()->create($category, $params);
}
$uri = JUri::getInstance();
$url = JRoute::_(WeblinksHelperRoute::getFormRoute(0, base64_encode($uri)));
$text = JHtml::_('image', 'system/new.png', JText::_('JNEW'), null, true);
$button = JHtml::_('link', $url, $text);
/**
* Create a link to edit an existing weblink
*
* @param object $weblink Weblink data
* @param \Joomla\Registry\Registry $params Item params
* @param array $attribs Unused
*
* @return string
*/
public static function edit($weblink, $params, $attribs = [])
{
return self::getIcon()->edit($weblink, $params, $attribs);
}
return '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_FORM_CREATE_WEBLINK') . '">' . $button . '</span>';
}
/**
* Create a link to edit an existing weblink
*
* @param object $weblink Weblink data
* @param \Joomla\Registry\Registry $params Item params
* @param array $attribs Unused
*
* @return string
*/
public static function edit($weblink, $params, $attribs = array())
{
$uri = JUri::getInstance();
if ($params && $params->get('popup'))
{
return;
}
if ($weblink->state < 0)
{
return;
}
JHtml::_('bootstrap.tooltip');
$url = WeblinksHelperRoute::getFormRoute($weblink->id, base64_encode($uri));
$icon = $weblink->state ? 'edit.png' : 'edit_unpublished.png';
$text = JHtml::_('image', 'system/' . $icon, JText::_('JGLOBAL_EDIT'), null, true);
if ($weblink->state == 0)
{
$overlib = JText::_('JUNPUBLISHED');
}
else
{
$overlib = JText::_('JPUBLISHED');
}
$date = JHtml::_('date', $weblink->created);
$author = $weblink->created_by_alias ? $weblink->created_by_alias : $weblink->author;
$overlib .= '&lt;br /&gt;';
$overlib .= $date;
$overlib .= '&lt;br /&gt;';
$overlib .= htmlspecialchars($author, ENT_COMPAT, 'UTF-8');
$button = JHtml::_('link', JRoute::_($url), $text);
return '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT') . ' :: ' . $overlib . '">' . $button . '</span>';
}
/**
* Creates an icon instance.
*
* @return \Joomla\Component\Weblinks\Administrator\Service\HTML\Icon
*/
private static function getIcon()
{
return (new \Joomla\Component\Weblinks\Administrator\Service\HTML\Icon(Joomla\CMS\Factory::getApplication()));
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
@ -7,265 +8,16 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
/**
* Weblinks Component Route Helper.
*
* @since 1.5
*/
abstract class WeblinksHelperRoute
abstract class WeblinksHelperRoute extends RouteHelper
{
protected static $lookup;
protected static $lang_lookup = array();
/**
* Get the route of the weblink
*
* @param integer $id Web link ID
* @param integer $catid Category ID
* @param string $language Language
*
* @return string
*/
public static function getWeblinkRoute($id, $catid, $language = 0)
{
$needles = array('weblink' => array((int) $id));
// Create the link
$link = 'index.php?option=com_weblinks&view=weblink&id=' . $id;
if ($catid > 1)
{
$categories = JCategories::getInstance('Weblinks');
$category = $categories->get($catid);
if ($category)
{
$needles['category'] = array_reverse($category->getPath());
$needles['categories'] = $needles['category'];
$link .= '&catid=' . $catid;
}
}
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
self::buildLanguageLookup();
if (isset(self::$lang_lookup[$language]))
{
$link .= '&lang=' . self::$lang_lookup[$language];
$needles['language'] = $language;
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid=' . $item;
}
return $link;
}
/**
* Ge the form route
*
* @param integer $id The id of the weblink.
* @param string $return The return page variable.
*
* @return string
*/
public static function getFormRoute($id, $return = null)
{
// Create the link.
if ($id)
{
$link = 'index.php?option=com_weblinks&task=weblink.edit&w_id=' . $id;
}
else
{
$link = 'index.php?option=com_weblinks&task=weblink.add&w_id=0';
}
if ($return)
{
$link .= '&return=' . $return;
}
return $link;
}
/**
* Get the Category Route
*
* @param JCategoryNode|string|integer $catid JCategoryNode object or category ID
* @param integer $language Language code
*
* @return string
*/
public static function getCategoryRoute($catid, $language = 0)
{
if ($catid instanceof JCategoryNode)
{
$id = $catid->id;
$category = $catid;
}
else
{
$id = (int) $catid;
$category = JCategories::getInstance('Weblinks')->get($id);
}
if ($id < 1 || !($category instanceof JCategoryNode))
{
$link = '';
}
else
{
$needles = array();
// Create the link
$link = 'index.php?option=com_weblinks&view=category&id=' . $id;
$catids = array_reverse($category->getPath());
$needles['category'] = $catids;
$needles['categories'] = $catids;
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
self::buildLanguageLookup();
if (isset(self::$lang_lookup[$language]))
{
$link .= '&lang=' . self::$lang_lookup[$language];
$needles['language'] = $language;
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid=' . $item;
}
}
return $link;
}
/**
* Do a language lookup
*
* @return void
*/
protected static function buildLanguageLookup()
{
if (count(self::$lang_lookup) == 0)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.sef AS sef')
->select('a.lang_code AS lang_code')
->from('#__languages AS a');
$db->setQuery($query);
$langs = $db->loadObjectList();
foreach ($langs as $lang)
{
self::$lang_lookup[$lang->lang_code] = $lang->sef;
}
}
}
/**
* Find items per given $needles
*
* @param array $needles A given array of needles to find
*
* @return void
*/
protected static function _findItem($needles = null)
{
$app = JFactory::getApplication();
$menus = $app->getMenu('site');
$language = isset($needles['language']) ? $needles['language'] : '*';
// Prepare the reverse lookup array.
if (!isset(self::$lookup[$language]))
{
self::$lookup[$language] = array();
$component = JComponentHelper::getComponent('com_weblinks');
$attributes = array('component_id');
$values = array($component->id);
if ($language != '*')
{
$attributes[] = 'language';
$values[] = array($needles['language'], '*');
}
$items = $menus->getItems($attributes, $values);
if ($items)
{
foreach ($items as $item)
{
if (isset($item->query) && isset($item->query['view']))
{
$view = $item->query['view'];
if (!isset(self::$lookup[$language][$view]))
{
self::$lookup[$language][$view] = array();
}
if (isset($item->query['id']))
{
/**
* Here it will become a bit tricky
* language != * can override existing entries
* language == * cannot override existing entries
*/
if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
{
self::$lookup[$language][$view][$item->query['id']] = $item->id;
}
}
}
}
}
}
if ($needles)
{
foreach ($needles as $view => $ids)
{
if (isset(self::$lookup[$language][$view]))
{
foreach ($ids as $id)
{
if (isset(self::$lookup[$language][$view][(int) $id]))
{
return self::$lookup[$language][$view][(int) $id];
}
}
}
}
}
// Check if the active menuitem matches the requested language
$active = $menus->getActive();
if ($active && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled()))
{
return $active->id;
}
// If not found, return language specific home link
$default = $menus->getDefault($language);
return !empty($default->id) ? $default->id : null;
}
}

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
</metadata>

View File

@ -1,139 +0,0 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* This models supports retrieving lists of article categories.
*
* @since 1.6
*/
class WeblinksModelCategories extends JModelList
{
/**
* Context string for the model type. This is used to handle uniqueness
* when dealing with the getStoreId() method and caching data structures.
*
* @var string
*/
protected $context = 'com_weblinks.categories';
/**
* The category context (allows other extensions to derived from this model).
*
* @var string
*/
protected $_extension = 'com_weblinks';
private $_parent = null;
private $_items = null;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$this->setState('filter.extension', $this->_extension);
// Get the parent id if defined.
$parentId = $app->input->getInt('id');
$this->setState('filter.parentId', $parentId);
$params = $app->getParams();
$this->setState('params', $params);
$this->setState('filter.published', 1);
$this->setState('filter.access', true);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.extension');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.parentId');
return parent::getStoreId($id);
}
/**
* Redefine the function and add some properties to make the styling more easy
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
if (!count($this->_items))
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new JRegistry;
if ($active)
{
$params->loadString($active->params);
}
$options = array();
$options['countItems'] = $params->get('show_cat_num_links', 1) || !$params->get('show_empty_categories_cat', 0);
$categories = JCategories::getInstance('Weblinks', $options);
$this->_parent = $categories->get($this->getState('filter.parentId', 'root'));
if (is_object($this->_parent))
{
$this->_items = $this->_parent->getChildren();
}
else
{
$this->_items = false;
}
}
return $this->_items;
}
/**
* Get the parent
*
* @return mixed An array of data items on success, false on failure.
*/
public function getParent()
{
if (!is_object($this->_parent))
{
$this->getItems();
}
return $this->_parent;
}
}

View File

@ -1,407 +0,0 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/**
* Weblinks Component Weblink Model
*
* @since 1.5
*/
class WeblinksModelCategory extends JModelList
{
/**
* Category items data
*
* @var array
*/
protected $_item = null;
protected $_articles = null;
protected $_siblings = null;
protected $_children = null;
protected $_parent = null;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'hits', 'a.hits',
'ordering', 'a.ordering',
);
}
parent::__construct($config);
}
/**
* The category that applies.
*
* @var object
*/
protected $_category = null;
/**
* The list of other weblink categories.
*
* @var array
*/
protected $_categories = null;
/**
* Method to get a list of items.
*
* @return mixed An array of objects on success, false on failure.
*/
public function getItems()
{
// Invoke the parent getItems method to get the main list
$items = parent::getItems();
// Convert the params field into an object, saving original in _params
foreach ($items as $item)
{
if (!isset($this->_params))
{
$params = new Registry;
$params->loadString($item->params);
$item->params = $params;
}
// Get the tags
$item->tags = new JHelperTags;
$item->tags->getItemTags('com_weblinks.weblink', $item->id);
}
return $items;
}
/**
* Method to get a JDatabaseQuery object for retrieving the data set from a database.
*
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set.
*
* @since 1.6
*/
protected function getListQuery()
{
$groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select required fields from the categories.
$query->select($this->getState('list.select', 'a.*'))
->from($db->quoteName('#__weblinks') . ' AS a')
->where('a.access IN (' . $groups . ')');
// Filter by category.
if ($categoryId = $this->getState('category.id'))
{
// Group by subcategory
if ($this->getState('category.group', 0))
{
$query->select('c.title AS category_title')
->where('c.parent_id = ' . (int) $categoryId)
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' . $groups . ')');
}
else
{
$query->where('a.catid = ' . (int) $categoryId)
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' . $groups . ')');
}
// Filter by published category
$cpublished = $this->getState('filter.c.published');
if (is_numeric($cpublished))
{
$query->where('c.published = ' . (int) $cpublished);
}
}
// Join over the users for the author and modified_by names.
$query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author")
->select("ua.email AS author_email")
->join('LEFT', '#__users AS ua ON ua.id = a.created_by')
->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
// Filter by state
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where('a.state = ' . (int) $state);
}
// Do not show trashed links on the front-end
$query->where('a.state != -2');
// Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote(JFactory::getDate()->toSql());
if ($this->getState('filter.publish_date'))
{
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
// Filter by language
if ($this->getState('filter.language'))
{
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
// Filter by search in title
$search = $this->getState('list.filter');
if (!empty($search))
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.title LIKE ' . $search . ')');
}
// If grouping by subcategory, add the subcategory list ordering clause.
if ($this->getState('category.group', 0))
{
$query->order(
$db->escape($this->getState('category.ordering', 'c.lft')) . ' ' .
$db->escape($this->getState('category.direction', 'ASC'))
);
}
// Add the list ordering clause.
$query->order(
$db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' .
$db->escape($this->getState('list.direction', 'ASC'))
);
return $query;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_weblinks');
// List state information
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit'), 'uint');
$this->setState('list.limit', $limit);
$limitstart = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $limitstart);
// Optional filter text
$this->setState('list.filter', $app->input->getString('filter-search'));
$orderCol = $app->input->get('filter_order', 'ordering');
if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = 'ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = $app->input->get('filter_order_Dir', 'ASC');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$id = $app->input->get('id', 0, 'int');
$this->setState('category.id', $id);
$user = JFactory::getUser();
if ((!$user->authorise('core.edit.state', 'com_weblinks')) && (!$user->authorise('core.edit', 'com_weblinks')))
{
// Limit to published for people who can't edit or edit.state.
$this->setState('filter.state', 1);
// Filter by start and end dates.
$this->setState('filter.publish_date', true);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
// Load the parameters.
$this->setState('params', $params);
}
/**
* Method to get category data for the current category
*
* @return object
*
* @since 1.5
*/
public function getCategory()
{
if (!is_object($this->_item))
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new Registry;
if ($active)
{
$params->loadString($active->params);
}
$options = array();
$options['countItems'] = $params->get('show_cat_num_links_cat', 1)
|| $params->get('show_empty_categories', 0);
$categories = JCategories::getInstance('Weblinks', $options);
$this->_item = $categories->get($this->getState('category.id', 'root'));
if (is_object($this->_item))
{
$this->_children = $this->_item->getChildren();
$this->_parent = false;
if ($this->_item->getParent())
{
$this->_parent = $this->_item->getParent();
}
$this->_rightsibling = $this->_item->getSibling();
$this->_leftsibling = $this->_item->getSibling(false);
}
else
{
$this->_children = false;
$this->_parent = false;
}
}
return $this->_item;
}
/**
* Get the parent category
*
* @return mixed An array of categories or false if an error occurs.
*/
public function getParent()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_parent;
}
/**
* Get the leftsibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function &getLeftSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_leftsibling;
}
/**
* Get the rightsibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function &getRightSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_rightsibling;
}
/**
* Get the child categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function &getChildren()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_children;
}
/**
* Increment the hit counter for the category.
*
* @param integer $pk Optional primary key of the category to increment.
*
* @return boolean True if successful; false otherwise and internal error set.
*
* @since 3.2
*/
public function hit($pk = 0)
{
$hitcount = JFactory::getApplication()->input->getInt('hitcount', 1);
if ($hitcount)
{
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
$table = JTable::getInstance('Category', 'JTable');
$table->load($pk);
$table->hit($pk);
}
return true;
}
}

View File

@ -1,103 +0,0 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/weblink.php';
/**
* Weblinks model.
*
* @since 1.6
*/
class WeblinksModelForm extends WeblinksModelWeblink
{
/**
* Model typeAlias string. Used for version history.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_weblinks.weblink';
/**
* Get the return URL.
*
* @return string The return URL.
*
* @since 1.6
*/
public function getReturnPage()
{
return base64_encode($this->getState('return_page'));
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication();
// Load state from the request.
$pk = $app->input->getInt('w_id');
$this->setState('weblink.id', $pk);
// Add compatibility variable for default naming conventions.
$this->setState('form.id', $pk);
$categoryId = $app->input->getInt('catid');
$this->setState('weblink.catid', $categoryId);
$return = $app->input->get('return', null, 'base64');
if (!JUri::isInternal(base64_decode($return)))
{
$return = null;
}
$this->setState('return_page', base64_decode($return));
// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
$this->setState('layout', $app->input->getString('layout'));
}
/**
* Abstract method for getting the form from the model.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since __DEPLOY_VERSION__
*/
public function getForm($data = array(), $loadData = true)
{
$form = $this->loadForm('com_weblinks.form', 'weblink', array('control' => 'jform', 'load_data' => $loadData));
// Disable the buttons and just allow editor none for not authenticated users
if (JFactory::getUser()->guest)
{
$form->setFieldAttribute('description', 'editor', 'none');
$form->setFieldAttribute('description', 'buttons', 'no');
}
return $form;
}
}

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