1
+ <?php
2
+ /**
3
+ * @package WebTolk plugin info field
4
+ * @version 1.7.0
5
+ * @Author Sergey Tolkachyov, https://web-tolk.ru
6
+ * @copyright Copyright (C) 2020 Sergey Tolkachyov
7
+ * @license GNU/GPL http://www.gnu.org/licenses/gpl-2.0.html
8
+ * @since 1.0.0
9
+ */
10
+
11
+ defined ('_JEXEC ' ) or die;
12
+
13
+ use Joomla \CMS \Form \Field \NoteField ;
14
+ use Joomla \CMS \Form \FormHelper ;
15
+ use Joomla \CMS \HTML \HTMLHelper ;
16
+ use Joomla \CMS \Plugin \PluginHelper ;
17
+ use Joomla \CMS \Language \Text ;
18
+ use \Joomla \CMS \Factory ;
19
+ use Joomla \CMS \Uri \Uri ;
20
+ use Joomla \CMS \Router \Route ;
21
+ use Joomla \CMS \MVC \Model \BaseDatabaseModel ;
22
+ use Joomla \CMS \Component \ComponentHelper ;
23
+
24
+ class JFormFieldProjectupdateserverurl extends JFormField
25
+ {
26
+
27
+ protected $ type = 'projectupdateserverurl ' ;
28
+
29
+ /**
30
+ * Method to get the field input markup for a spacer.
31
+ * The spacer does not have accept input.
32
+ *
33
+ * @return string The field input markup.
34
+ *
35
+ * @since 1.7.0
36
+ */
37
+ protected function getInput ()
38
+ {
39
+ return '' ;
40
+ }
41
+
42
+ /**
43
+ * @return string The field label markup.
44
+ *
45
+ * @since 1.7.0
46
+ */
47
+ protected function getLabel ()
48
+ {
49
+ $ app = Factory::getApplication ();
50
+
51
+ if ($ app ->input ->get ('view ' ) == 'project ' && !empty ($ project_id = $ app ->input ->get ('id ' )))
52
+
53
+ {
54
+ JLoader::register ('SWJProjectsHelperRoute ' , JPATH_SITE . '/components/com_swjprojects/helpers/route.php ' );
55
+
56
+ BaseDatabaseModel::addIncludePath (JPATH_SITE . '/components/com_swjprojects/models ' );
57
+ $ model = BaseDatabaseModel::getInstance ('Project ' , 'SWJProjectsModel ' , array ('ignore_request ' => false ));
58
+ $ project = $ model ->getItem ();
59
+ $ url = Uri::getInstance (Uri::root ());
60
+
61
+ $ component_params = ComponentHelper::getParams ('com_swjprojects ' );
62
+ // Join over current translates
63
+ $ lang = $ component_params ->get ('changelogurl_language ' , 'en-GB ' );
64
+ $ project_name = $ project ->translates [$ lang ]->title ;
65
+ if (empty ($ project_name )){
66
+ $ project_name = 'Your extension name ' ;
67
+ }
68
+ $ url ->setPath (Route::link ('site ' , SWJProjectsHelperRoute::getJUpdateRoute ('' , $ project ->element )));
69
+
70
+
71
+ return $ html = '</div>
72
+ <div class="col-12 alert alert-info mt-4">
73
+ <h4> ' .Text::_ ('COM_SWJPROJECTS_JOOMLA_UPDATE_SERVER ' ).'</h4>
74
+ <p><code> ' .$ url ->toString ().'</code></p>
75
+ <p> ' .Text::sprintf ('COM_SWJPROJECTS_JOOMLA_UPDATE_SERVER_URL_FIELD_DESC ' ,$ project_name , $ url ->toString ()).'</p>
76
+ </div><div>
77
+ ' ;
78
+
79
+ }
80
+
81
+
82
+ }
83
+
84
+ /**
85
+ * Method to get the field title.
86
+ *
87
+ * @return string The field title.
88
+ *
89
+ * @since 1.7.0
90
+ */
91
+ protected function getTitle ()
92
+ {
93
+ return $ this ->getLabel ();
94
+ }
95
+
96
+ }
97
+
98
+ ?>
0 commit comments