-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.k2additionalcategories.php
More file actions
114 lines (101 loc) · 4.31 KB
/
script.k2additionalcategories.php
File metadata and controls
114 lines (101 loc) · 4.31 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
<?php
/**
* @version 1.0.1
* @package Additional Categories for K2
* @author Thodoris Bgenopoulos <teobgeno@netpin.gr>
* @link http://www.netpin.gr
* @copyright Copyright (c) 2012 netpin.gr
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
class com_k2additionalcategoriesInstallerScript
{
public function postflight($type, $parent)
{
$db = JFactory::getDBO();
$status = new stdClass;
$status->plugins = array();
$src = $parent->getParent()->getPath('source');
$manifest = $parent->getParent()->manifest;
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $plugin)
{
$name = (string)$plugin->attributes()->plugin;
$group = (string)$plugin->attributes()->group;
$path = $src.'/plugins/'.$group;
if (JFolder::exists($src.'/plugins/'.$group.'/'.$name))
{
$path = $src.'/plugins/'.$group.'/'.$name;
}
$installer = new JInstaller;
$result = $installer->install($path);
if (JFile::exists(JPATH_SITE.'/plugins/'.$group.'/'.$name.'/'.$name.'.xml'))
{
JFile::delete(JPATH_SITE.'/plugins/'.$group.'/'.$name.'/'.$name.'.xml');
}
JFile::move(JPATH_SITE.'/plugins/'.$group.'/'.$name.'/'.$name.'.j25.xml', JPATH_SITE.'/plugins/'.$group.'/'.$name.'/'.$name.'.xml');
$query = "UPDATE #__extensions SET enabled=1 WHERE type='plugin' AND element=".$db->Quote($name)." AND folder=".$db->Quote($group);
$db->setQuery($query);
$db->query();
$status->plugins[] = array('name' => $name, 'group' => $group, 'result' => $result);
}
$this->installationResults($status);
}
public function uninstall($parent)
{
$db = JFactory::getDBO();
$status = new stdClass;
$status->plugins = array();
$manifest = $parent->getParent()->manifest;
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $plugin)
{
$name = (string)$plugin->attributes()->plugin;
$group = (string)$plugin->attributes()->group;
$query = "SELECT `extension_id` FROM #__extensions WHERE `type`='plugin' AND element = ".$db->Quote($name)." AND folder = ".$db->Quote($group);
$db->setQuery($query);
$extensions = $db->loadColumn();
if (count($extensions))
{
foreach ($extensions as $id)
{
$installer = new JInstaller;
$result = $installer->uninstall('plugin', $id);
}
$status->plugins[] = array('name' => $name, 'group' => $group, 'result' => $result);
}
}
$this->uninstallationResults($status);
}
public function update($type)
{
}
private function installationResults($status)
{
?>
<h2>
<a target='_blank' href='http://www.netpin.gr/'>Additional Categories for K2 Plugin v1.0.1</a>
</h2>
<a target='_blank' href='http://www.netpin.gr/'>
<img style='float:left;background:#fff;padding:2px;margin:0 0 8px 0px;' src='../media/k2additonalcategories/addcat_logo_219x125_24.png' border='0' alt='Additional Categories for K2'/>
</a>
<b>Additional Categories for K2</b> allows you to assign a K2 item to more than one K2 category.
<br/><br/>
You may also want to check out the following resources:
<ul>
<li>
<a target='_blank' href='http://www.netpin.gr/documentation/item/2-k2-additional-categories'>Additional Categories for K2 documentation
</a>.
</li>
</ul>
<b>Additional Categories for K2</b> is a <a target='_blank' href='http://getk2.org/'>K2</a> plugin developed by <a target='_blank' title='netpin.gr' href='http://www.netpin.gr'>Thodoris Bgenopoulos</a>, released under the <a target='_blank' title='GNU General Public License' href='http://www.gnu.org/copyleft/gpl.html'>GNU General Public License</a>.<br/><br/>Copyright © 2012 netpin.gr. All rights reserved.<br/><br/><i>(Last update: April 5th, 2013 - Version 1.0.1)</i>
<br />
<br />
<?php
}
private function uninstallationResults($status)
{
}
}
?>