Current Path :
/
home
/
develito
/
www
/
administrator
/
components
/
com_quickform
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/www/administrator/components/com_quickform/script.php
<?php /** * @Copyright ((c) bigemot.ru * @ http://bigemot.ru/ * @license GNU/GPL */ defined('_JEXEC') or die('Restricted access'); class com_quickformInstallerScript { public function install($parent) { $db = JFactory::getDBO(); $status = new stdClass; $status->modules = array(); $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/'; $installer = new JInstaller; $result = $installer->install($path); $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); } $modules = $manifest->xpath('modules/module'); foreach ($modules as $module) { $name = (string)$module->attributes()->module; $client = (string)$module->attributes()->client; if (is_null($client)) { $client = 'site'; } ($client == 'administrator') ? $path = $src.'/administrator/modules/'.$name : $path = $src.'/modules/'.$name; $installer = new JInstaller; $result = $installer->install($path); $status->modules[] = array('name' => $name, 'client' => $client, 'result' => $result); } $this->installationResults($status); } public function uninstall($parent) { $db = JFactory::getDBO(); $status = new stdClass; $status->modules = array(); $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); } } $modules = $manifest->xpath('modules/module'); foreach ($modules as $module) { $name = (string)$module->attributes()->module; $client = (string)$module->attributes()->client; $db = JFactory::getDBO(); $query = "SELECT `extension_id` FROM `#__extensions` WHERE `type`='module' AND element = ".$db->Quote($name).""; $db->setQuery($query); $extensions = $db->loadColumn(); if (count($extensions)) { foreach ($extensions as $id) { $installer = new JInstaller; $result = $installer->uninstall('module', $id); } $status->modules[] = array('name' => $name, 'client' => $client, 'result' => $result); } } $this->uninstallationResults($status); } public function update($parent) { $db = JFactory::getDBO(); $status = new stdClass; $status->modules = array(); $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/'; $installer = new JInstaller; $result = $installer->install($path); $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); } $modules = $manifest->xpath('modules/module'); foreach ($modules as $module) { $name = (string)$module->attributes()->module; $client = (string)$module->attributes()->client; if (is_null($client)) { $client = 'site'; } ($client == 'administrator') ? $path = $src.'/administrator/modules/'.$name : $path = $src.'/modules/'.$name; $installer = new JInstaller; $result = $installer->install($path); $status->modules[] = array('name' => $name, 'client' => $client, 'result' => $result); } if (JFile::exists(JPATH_ADMINISTRATOR.'/components/com_quickform/admin.quickform.php')) { JFile::delete(JPATH_ADMINISTRATOR.'/components/com_quickform/admin.quickform.php'); } $param_array = array( 'img' => '/modules/mod_quickform/imgs/cart_0.png', 'text_before_cart' => 'Glad to have you! Your order:', 'text_1' => 'QF_ORDER_PRICE', 'text_2' => 'QF_FINAL_PRICE', 'text_3' => 'QF_TO_ORDER', 'text_4' => 'QF_SEND_ORDER', 'history' => '1', 'popmess' => 'Your order has been successfully submitted.' ); $this->setParams($param_array); $this->installationResults($status); } public function setParams($param_array) { if (count($param_array) > 0) { $db = JFactory::getDbo(); $db->setQuery('SELECT params FROM #__extensions WHERE name = ' . $db->quote('com_quickform')); $params = json_decode($db->loadResult(), true); foreach ( $param_array as $name => $value ) { if(!isset($params[(string) $name])){ $params[(string) $name] = (string) $value; } } $paramsString = json_encode( $params ); $db->setQuery('UPDATE #__extensions SET params = ' . $db->quote($paramsString) . ' WHERE name = ' . $db->quote('com_quickform')); $db->query(); } } public function preflight($type, $parent) { } private function uninstallationResults($status) { $language = JFactory::getLanguage(); $language->load('com_quickform'); $rows = 0; ?> <h2><?php echo JText::_('QF_REMOVAL_STATUS'); ?></h2> <table class="adminlist table table-striped"> <thead> <tr> <th class="title" colspan="2"><?php echo JText::_('QF_EXTENSION'); ?></th> <th width="30%"><?php echo JText::_('QF_STATUS'); ?></th> </tr> </thead> <tfoot> <tr> <td colspan="3"></td> </tr> </tfoot> <tbody> <tr class="row0"> <td class="key" colspan="2"><?php echo 'QF '.JText::_('QF_COMPONENT'); ?></td> <td><strong><?php echo JText::_('QF_REMOVED'); ?></strong></td> </tr> <?php if (count($status->modules)): ?> <tr> <th><?php echo JText::_('QF_MODULE'); ?></th> <th><?php echo JText::_('QF_CLIENT'); ?></th> <th></th> </tr> <?php foreach ($status->modules as $module): ?> <tr class="row<?php echo(++$rows % 2); ?>"> <td class="key"><?php echo $module['name']; ?></td> <td class="key"><?php echo ucfirst($module['client']); ?></td> <td><strong><?php echo ($module['result'])?JText::_('QF_REMOVED'):JText::_('QF_NOT_REMOVED'); ?></strong></td> </tr> <?php endforeach; ?> <?php endif; ?> <?php if (count($status->plugins)): ?> <tr> <th><?php echo JText::_('QF_PLUGIN'); ?></th> <th><?php echo JText::_('QF_GROUP'); ?></th> <th></th> </tr> <?php foreach ($status->plugins as $plugin): ?> <tr class="row<?php echo(++$rows % 2); ?>"> <td class="key"><?php echo ucfirst($plugin['name']); ?></td> <td class="key"><?php echo ucfirst($plugin['group']); ?></td> <td><strong><?php echo ($plugin['result'])?JText::_('QF_REMOVED'):JText::_('QF_NOT_REMOVED'); ?></strong></td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> <?php } private function installationResults($status){ $language = JFactory::getLanguage(); $language->load('com_quickform'); $rows = 0; ?> <h2><?php echo JText::_('QF_INSTALLATION_STATUS'); ?></h2> <table class="adminlist table table-striped"> <thead> <tr> <th class="title" colspan="2"><?php echo JText::_('QF_EXTENSION'); ?></th> <th width="30%"><?php echo JText::_('QF_STATUS'); ?></th> </tr> </thead> <tfoot> <tr> <td colspan="3"></td> </tr> </tfoot> <tbody> <tr class="row0"> <td class="key" colspan="2"><?php echo 'QF '.JText::_('QF_COMPONENT'); ?></td> <td><strong><?php echo JText::_('QF_INSTALLED'); ?></strong></td> </tr> <?php if (count($status->modules)): ?> <tr> <th><?php echo JText::_('QF_MODULE'); ?></th> <th><?php echo JText::_('QF_CLIENT'); ?></th> <th></th> </tr> <?php foreach ($status->modules as $module): ?> <tr class="row<?php echo(++$rows % 2); ?>"> <td class="key"><?php echo $module['name']; ?></td> <td class="key"><?php echo ucfirst($module['client']); ?></td> <td><strong><?php echo ($module['result'])?JText::_('QF_INSTALLED'):JText::_('QF_NOT_INSTALLED'); ?></strong></td> </tr> <?php endforeach; ?> <?php endif; ?> <?php if (count($status->plugins)): ?> <tr> <th><?php echo JText::_('QF_PLUGIN'); ?></th> <th><?php echo JText::_('QF_GROUP'); ?></th> <th></th> </tr> <?php foreach ($status->plugins as $plugin): ?> <tr class="row<?php echo(++$rows % 2); ?>"> <td class="key"><?php echo ucfirst($plugin['name']); ?></td> <td class="key"><?php echo ucfirst($plugin['group']); ?></td> <td><strong><?php echo ($plugin['result'])?JText::_('QF_INSTALLED'):JText::_('QF_NOT_INSTALLED'); ?></strong></td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> <?php } }