-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ff8bbd
commit 8c4681e
Showing
2 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
com_swjprojects/admin/models/fields/projectchangelogurl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* @package WebTolk plugin info field | ||
* @version 1.7.0 | ||
* @Author Sergey Tolkachyov, https://web-tolk.ru | ||
* @copyright Copyright (C) 2020 Sergey Tolkachyov | ||
* @license GNU/GPL http://www.gnu.org/licenses/gpl-2.0.html | ||
* @since 1.0.0 | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
use Joomla\CMS\Form\Field\NoteField; | ||
use Joomla\CMS\Form\FormHelper; | ||
use Joomla\CMS\HTML\HTMLHelper; | ||
use Joomla\CMS\Plugin\PluginHelper; | ||
use Joomla\CMS\Language\Text; | ||
use \Joomla\CMS\Factory; | ||
use Joomla\CMS\Uri\Uri; | ||
use Joomla\CMS\Router\Route; | ||
use Joomla\CMS\MVC\Model\BaseDatabaseModel; | ||
|
||
class JFormFieldProjectchangelogurl extends JFormField | ||
{ | ||
|
||
protected $type = 'projectchangelogurl'; | ||
|
||
/** | ||
* Method to get the field input markup for a spacer. | ||
* The spacer does not have accept input. | ||
* | ||
* @return string The field input markup. | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
protected function getInput() | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* @return string The field label markup. | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
protected function getLabel() | ||
{ | ||
$app = Factory::getApplication(); | ||
|
||
if ($app->input->get('view') == 'project' && !empty($project_id = $app->input->get('id'))) | ||
|
||
{ | ||
JLoader::register('SWJProjectsHelperRoute', JPATH_SITE . '/components/com_swjprojects/helpers/route.php'); | ||
|
||
BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_swjprojects/models'); | ||
$model = BaseDatabaseModel::getInstance('Project', 'SWJProjectsModel', array('ignore_request' => false)); | ||
$project = $model->getItem(); | ||
$url = Uri::getInstance(Uri::root()); | ||
$url->setPath(Route::link('site', SWJProjectsHelperRoute::getJChangelogRoute('', $project->element))); | ||
|
||
|
||
return $html = '</div> | ||
<div class="col-12 alert alert-info mt-4"> | ||
<h4>'.Text::_('COM_SWJPROJECTS_PARAMS_CHANGELOGURL').'</h4> | ||
<p>'.Text::sprintf('COM_SWJPROJECTS_JOOMLA_CHANGELOGURL_URL_FIELD_DESC', $url->toString()).'</p> | ||
</div><div> | ||
'; | ||
|
||
|
||
} | ||
return ''; | ||
|
||
} | ||
|
||
/** | ||
* Method to get the field title. | ||
* | ||
* @return string The field title. | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
protected function getTitle() | ||
{ | ||
return $this->getLabel(); | ||
} | ||
|
||
} | ||
|
||
?> |
98 changes: 98 additions & 0 deletions
98
com_swjprojects/admin/models/fields/projectupdateserverurl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
/** | ||
* @package WebTolk plugin info field | ||
* @version 1.7.0 | ||
* @Author Sergey Tolkachyov, https://web-tolk.ru | ||
* @copyright Copyright (C) 2020 Sergey Tolkachyov | ||
* @license GNU/GPL http://www.gnu.org/licenses/gpl-2.0.html | ||
* @since 1.0.0 | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
use Joomla\CMS\Form\Field\NoteField; | ||
use Joomla\CMS\Form\FormHelper; | ||
use Joomla\CMS\HTML\HTMLHelper; | ||
use Joomla\CMS\Plugin\PluginHelper; | ||
use Joomla\CMS\Language\Text; | ||
use \Joomla\CMS\Factory; | ||
use Joomla\CMS\Uri\Uri; | ||
use Joomla\CMS\Router\Route; | ||
use Joomla\CMS\MVC\Model\BaseDatabaseModel; | ||
use Joomla\CMS\Component\ComponentHelper; | ||
|
||
class JFormFieldProjectupdateserverurl extends JFormField | ||
{ | ||
|
||
protected $type = 'projectupdateserverurl'; | ||
|
||
/** | ||
* Method to get the field input markup for a spacer. | ||
* The spacer does not have accept input. | ||
* | ||
* @return string The field input markup. | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
protected function getInput() | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* @return string The field label markup. | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
protected function getLabel() | ||
{ | ||
$app = Factory::getApplication(); | ||
|
||
if ($app->input->get('view') == 'project' && !empty($project_id = $app->input->get('id'))) | ||
|
||
{ | ||
JLoader::register('SWJProjectsHelperRoute', JPATH_SITE . '/components/com_swjprojects/helpers/route.php'); | ||
|
||
BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_swjprojects/models'); | ||
$model = BaseDatabaseModel::getInstance('Project', 'SWJProjectsModel', array('ignore_request' => false)); | ||
$project = $model->getItem(); | ||
$url = Uri::getInstance(Uri::root()); | ||
|
||
$component_params = ComponentHelper::getParams('com_swjprojects'); | ||
// Join over current translates | ||
$lang = $component_params->get('changelogurl_language', 'en-GB'); | ||
$project_name = $project->translates[$lang]->title; | ||
if(empty($project_name)){ | ||
$project_name = 'Your extension name'; | ||
} | ||
$url->setPath(Route::link('site', SWJProjectsHelperRoute::getJUpdateRoute('', $project->element))); | ||
|
||
|
||
return $html = '</div> | ||
<div class="col-12 alert alert-info mt-4"> | ||
<h4>'.Text::_('COM_SWJPROJECTS_JOOMLA_UPDATE_SERVER').'</h4> | ||
<p><code>'.$url->toString().'</code></p> | ||
<p>'.Text::sprintf('COM_SWJPROJECTS_JOOMLA_UPDATE_SERVER_URL_FIELD_DESC',$project_name, $url->toString()).'</p> | ||
</div><div> | ||
'; | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
/** | ||
* Method to get the field title. | ||
* | ||
* @return string The field title. | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
protected function getTitle() | ||
{ | ||
return $this->getLabel(); | ||
} | ||
|
||
} | ||
|
||
?> |