Skip to content

Commit 8c4681e

Browse files
add missed field files
1 parent 3ff8bbd commit 8c4681e

File tree

2 files changed

+187
-0
lines changed

2 files changed

+187
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
23+
class JFormFieldProjectchangelogurl extends JFormField
24+
{
25+
26+
protected $type = 'projectchangelogurl';
27+
28+
/**
29+
* Method to get the field input markup for a spacer.
30+
* The spacer does not have accept input.
31+
*
32+
* @return string The field input markup.
33+
*
34+
* @since 1.7.0
35+
*/
36+
protected function getInput()
37+
{
38+
return '';
39+
}
40+
41+
/**
42+
* @return string The field label markup.
43+
*
44+
* @since 1.7.0
45+
*/
46+
protected function getLabel()
47+
{
48+
$app = Factory::getApplication();
49+
50+
if ($app->input->get('view') == 'project' && !empty($project_id = $app->input->get('id')))
51+
52+
{
53+
JLoader::register('SWJProjectsHelperRoute', JPATH_SITE . '/components/com_swjprojects/helpers/route.php');
54+
55+
BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_swjprojects/models');
56+
$model = BaseDatabaseModel::getInstance('Project', 'SWJProjectsModel', array('ignore_request' => false));
57+
$project = $model->getItem();
58+
$url = Uri::getInstance(Uri::root());
59+
$url->setPath(Route::link('site', SWJProjectsHelperRoute::getJChangelogRoute('', $project->element)));
60+
61+
62+
return $html = '</div>
63+
<div class="col-12 alert alert-info mt-4">
64+
<h4>'.Text::_('COM_SWJPROJECTS_PARAMS_CHANGELOGURL').'</h4>
65+
<p>'.Text::sprintf('COM_SWJPROJECTS_JOOMLA_CHANGELOGURL_URL_FIELD_DESC', $url->toString()).'</p>
66+
</div><div>
67+
';
68+
69+
70+
}
71+
return '';
72+
73+
}
74+
75+
/**
76+
* Method to get the field title.
77+
*
78+
* @return string The field title.
79+
*
80+
* @since 1.7.0
81+
*/
82+
protected function getTitle()
83+
{
84+
return $this->getLabel();
85+
}
86+
87+
}
88+
89+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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

Comments
 (0)