Repository navigation
Expand file tree
/
Copy pathversion.php
More file actions
145 lines (121 loc) · 3.24 KB
/
Copy pathversion.php
File metadata and controls
145 lines (121 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* @package GJFileds
*
* @copyright 0000 Copyright (C) All rights reversed.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL or later
*/
// No direct access
defined('_JEXEC') or die;
jimport('joomla.form.formfield');
if (!class_exists('GJFieldsFormField'))
{
include 'gjfields.php';
}
/**
* Version field
*
* @author Gruz <arygroup@gmail.com>
* @since 0.0.1
*/
class GJFieldsFormFieldVersion extends GJFieldsFormField
{
/**
* The form field type
*
* @var string
*/
public $type = 'Version';
/**
* Cap
*
* @return void
*/
protected function getLabel()
{
return;
}
/**
* Get HTML output
*
* @return string
*/
public function getInput()
{
$return = '';
/*
if (version_compare(JVERSION, '3.0', 'ge'))
{
// Add CSS and JS once, define base global flag - runc only once
if (!isset($GLOBALS[$this->type . '_initialized']))
{
$path_to_assets = JURI::root() . 'libraries/gjfields/';
$scriptname = $path_to_assets . 'js/' . JString::strtolower($this->type) . '.js';
$doc = JFactory::getDocument();
$doc->addScript($scriptname);
}
// This input is used to store active tab position
$return .= '<input type="hidden" name="' . $this->name
. '" value="'
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . ' />';
}
*/
$xml = $this->def('xml');
// Load language
$jinput = JFactory::getApplication()->input;
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query
->select($db->quoteName(array('element','folder','type')))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('extension_id') . '=' . $db->Quote($jinput->get('extension_id', null)));
$db->setQuery($query, 0, 1);
$row = $db->loadAssoc();
if ($row['type'] == 'plugin')
{
$this->plg_full_name = 'plg_' . $row['folder'] . '_' . $row['element'];
// Is used for building joomfish links
$this->langShortCode = null;
$this->default_lang = JComponentHelper::getParams('com_languages')->get('admin');
$language = JFactory::getLanguage();
$language->load($this->plg_full_name, JPATH_ROOT . dirname($xml), 'en-GB', true);
$language->load($this->plg_full_name, JPATH_ROOT . dirname($xml), $this->default_lang, true);
}
$extension = $this->def('extension');
$user = JFactory::getUser();
$authorise = $user->authorise('core.manage', 'com_installer');
if (!JString::strlen($extension) || !JString::strlen($xml) || !$authorise)
{
return;
}
$version = '';
if ($xml)
{
$xml = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . '/' . $xml);
if ($xml && isset($xml['version']))
{
$version = $xml['version'];
}
}
$document = JFactory::getDocument();
$css = '';
$css .= ".version {display:block;text-align:right;color:brown;font-size:10px;}";
$css .= ".readonly.plg-desc {font-weight:normal;}";
$css .= "fieldset.radio label {width:auto;}";
$document->addStyleDeclaration($css);
$return .= '<span class="version">' . JText::_('JVERSION') . ' ' . $version . "</span>";
return $return;
}
}
// Preserve compatibility
if (!class_exists('JFormFieldNN_Version'))
{
/**
* Old-fashioned field name
*
* @since 1.2.0
*/
class JFormFieldNN_Version extends GJFieldsFormFieldVersion
{
}
}