-
Notifications
You must be signed in to change notification settings - Fork 3
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
0 parents
commit efe8b8d
Showing
21 changed files
with
820 additions
and
0 deletions.
There are no files selected for viewing
138 changes: 138 additions & 0 deletions
138
administrator/components/com_j2migrationchecker/controllers/cpanel.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,138 @@ | ||
<?php | ||
|
||
|
||
/** | ||
* @package 3.x | ||
* @subpackage J2 Store Easy Checkout | ||
* @author Alagesan, J2Store <[email protected]> | ||
* @copyright Copyright (c) 2018 J2Store . All rights reserved. | ||
* @license GNU GPL v3 or later | ||
* @link http://j2store.org | ||
* -------------------------------------------------------------------------------- | ||
* | ||
* */ | ||
// No direct access to this file | ||
defined('_JEXEC') or die; | ||
|
||
class J2MigrationCheckerControllerCpanel extends F0FController | ||
{ | ||
public function execute($task) | ||
{ | ||
|
||
if (!in_array($task, array('browse','renameFolder','customunpublish'))) { | ||
$task = 'browse'; | ||
} | ||
return parent::execute($task); | ||
} | ||
|
||
public function browse() | ||
{ | ||
JToolbarHelper::title(JText::_('COM_HELLOWORLD_MANAGER_HELLOWORLDS')); | ||
//JToolBarHelper::publish('testpublish'); | ||
JToolBarHelper::unpublish('customunpublish'); | ||
F0FModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2migrationchecker/models'); | ||
$model = FOFModel::getTmpInstance('J2MigrationCheckers', 'J2MigrationCheckerModel'); | ||
$list_components = $model->getListComponents(); | ||
$list_plugins = $model->getListPlugins(); | ||
$list_modules = $model->getListModules(); | ||
$templates = $model->getTemplate(); | ||
$components_status = $model->componentsStatus(); | ||
$modules_status = $model->modulesStatus(); | ||
$plugins_status = $model->pluginsStatus(); | ||
$template_status = $model->templateStatus(); | ||
$model->saveData(); | ||
$install_status = $this->installStatus(); | ||
$templates_override = $model->getTemplateOverride(); | ||
$renamed_template_override = $this->getRenamedTemaplateOverride(); | ||
$pagination = ''; | ||
$view = $this->getThisView('Cpanel'); | ||
$view->set('renamed_template_override',$renamed_template_override); | ||
$view->set('install_status',$install_status); | ||
$view->set('components_status',$components_status); | ||
$view->set('modules_status',$modules_status); | ||
$view->set('plugins_status',$plugins_status); | ||
$view->set('templates_status',$template_status); | ||
$view->set('list_modules',$list_modules); | ||
$view->set('list_components',$list_components); | ||
$view->set('list_plugins',$list_plugins); | ||
$view->set('pagination',$pagination); | ||
$view->set('template_override',$templates_override); | ||
$view->setModel( $model, true ); | ||
$view->setLayout( 'default' ); | ||
$view->display(); | ||
} | ||
|
||
|
||
|
||
public function getRenamedTemaplateOverride(){ | ||
F0FModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2migrationchecker/models'); | ||
$model = FOFModel::getTmpInstance('J2MigrationCheckers', 'J2MigrationCheckerModel'); | ||
$template_override = $model->getTemplate(); | ||
$template_overridePath = []; | ||
foreach ($template_override as $key => $value){ | ||
if(empty($value->client_id) ) { | ||
$templatePath = JPATH_SITE . '/templates/' . $value->template; | ||
}elseif($value->client_id == 1){ | ||
$templatePath = JPATH_ADMINISTRATOR . '/templates/' . $value->template; | ||
} | ||
$component = 'old_com_j2store'; | ||
$overridePath = $templatePath . '/html/' . $component ; | ||
if (file_exists($overridePath)) { | ||
$template_overridePath[] = $overridePath; | ||
} | ||
} | ||
return $template_overridePath; | ||
} | ||
public function installStatus() | ||
{ | ||
F0FModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2migrationchecker/models'); | ||
$model = FOFModel::getTmpInstance('J2MigrationCheckers', 'J2MigrationCheckerModel'); | ||
$components_status = $model->componentsStatus(); | ||
$modules_status = $model->modulesStatus(); | ||
$plugins_status = $model->pluginsStatus(); | ||
$template_status = $model->templateStatus(); | ||
$status = JText::_('COM_EXTENSIONCHECK_DEFAULT_INSTALLATION_STATUS'); | ||
if($components_status !== 'Not Ready' && $modules_status !== 'Not Ready' && $plugins_status !== 'Not Ready' && $template_status !== 'Not Ready' ) { | ||
$status = JText::_('COM_EXTENSIONCHECK_INSTALLATION_STATUS'); | ||
} | ||
return $status; | ||
} | ||
|
||
public function renameFolder(){ | ||
$app = JFactory::getApplication(); | ||
$data = $app->input->getArray($_POST); | ||
$link = JRoute::_('index.php?option=com_j2migrationchecker&view=cpanel',false); | ||
if(isset($data['folder_Path']) && !empty($data['folder_Path'])) { | ||
$newFolderPath = str_replace('com_j2store', 'old_com_j2store', $data['folder_Path']); | ||
if (rename($data['folder_Path'], $newFolderPath)) { | ||
// $this->setMessage("Folder renamed successfully."); | ||
$this->setRedirect($link,JText::_("COM_EXTENSIONCHECK_RENAMED_SUCCESSFULLY")); | ||
} else { | ||
// $this->setMessage("Error renaming the folder."); | ||
$this->setRedirect($link,JText::_("COM_EXTENSIONCHECK_RENAMED_FAILED")); | ||
} | ||
} | ||
|
||
} | ||
public function customunpublish() | ||
{ | ||
|
||
// Check for request forgeries. | ||
//$this->checkToken(); | ||
$app = JFactory::getApplication(); | ||
$link = JRoute::_('index.php?option=com_j2migrationchecker&view=cpanel',false); | ||
$ids = $this->input->get('cid', array(), 'array'); | ||
foreach ($ids as $id) { | ||
|
||
$db = JFactory::getDbo(); | ||
$updateQuery = $db->getQuery(true) | ||
->update($db->quoteName('#__extensions')) | ||
->set($db->quoteName('enabled') . ' = 0') | ||
->where($db->quoteName('extension_id') . ' = ' . (int)$id); | ||
$db->setQuery($updateQuery); | ||
$db->execute(); | ||
} | ||
$app->redirect($link); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
administrator/components/com_j2migrationchecker/controllers/index.html
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 @@ | ||
<html><body bgcolor="#FFFFFF"></body></html> |
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 @@ | ||
<html><body bgcolor="#FFFFFF"></body></html> |
33 changes: 33 additions & 0 deletions
33
administrator/components/com_j2migrationchecker/j2migrationchecker.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,33 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_helloworld | ||
* | ||
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
// No direct access to this file | ||
defined('_JEXEC') or die('Restricted access'); | ||
if(!defined('F0F_INCLUDED')) { | ||
require_once JPATH_LIBRARIES . '/f0f/include.php'; | ||
} | ||
if(!defined('F0F_INCLUDED')) { | ||
?> | ||
<h2>Incomplete installation detected</h2> | ||
<?php | ||
} | ||
//if j2store does not exist, just exit | ||
if(!JFile::exists(JPATH_ADMINISTRATOR.'/components/com_j2store/j2store.php')) { | ||
echo '<h2>Incomplete installation detected</h2>'; | ||
jexit(0); | ||
} | ||
|
||
if(!class_exists('J2StoreStrapper')){ | ||
require_once (JPATH_ADMINISTRATOR.'/components/com_j2store/helpers/strapper.php'); | ||
} | ||
J2StoreStrapper::addJS(); | ||
J2StoreStrapper::addCSS(); | ||
|
||
F0FDispatcher::getTmpInstance('com_j2migrationchecker')->dispatch(); | ||
|
1 change: 1 addition & 0 deletions
1
administrator/components/com_j2migrationchecker/models/index.html
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 @@ | ||
<html><body bgcolor="#FFFFFF"></body></html> |
201 changes: 201 additions & 0 deletions
201
administrator/components/com_j2migrationchecker/models/j2migrationcheckers.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,201 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_helloworld | ||
* | ||
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
// No direct access to this file | ||
defined('_JEXEC') or die('Restricted access'); | ||
|
||
/** | ||
* HelloWorld Model | ||
* | ||
* @since 0.0.1 | ||
*/ | ||
class J2MigrationCheckerModelJ2MigrationCheckers extends FOFModel | ||
{ | ||
/** | ||
* Method to get a table object, load it if necessary. | ||
* | ||
* @param string $type The table name. Optional. | ||
* @param string $prefix The class prefix. Optional. | ||
* @param array $config Configuration array for model. Optional. | ||
* | ||
* @return JTable A JTable object | ||
* | ||
* @since 1.6 | ||
*/ | ||
|
||
protected function getSelectQuery(&$query) | ||
{ | ||
$query->select("*") | ||
->from("#__extensions"); | ||
} | ||
|
||
|
||
public function getListComponents(){ | ||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
$this->getSelectQuery($query); | ||
$query->where("element='com_easycheckout'"); | ||
$db->setQuery($query); | ||
return $db->loadObjectList(); | ||
|
||
} | ||
public function getListPlugins(){ | ||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
$this->getSelectQuery($query); | ||
$query->where("type='plugin'"); | ||
$query->where("folder='j2store' or element='easycheckout'"); | ||
$db->setQuery($query); | ||
return $db->loadObjectList(); | ||
} | ||
|
||
public function getListModules(){ | ||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
$this->getSelectQuery($query); | ||
$query->where("type='module'"); | ||
$db->setQuery($query); | ||
$data = $db->loadObjectList(); | ||
$j2store_module = array('mod_j2store_related_products','mod_j2store_search','mod_j2store_categories','mod_j2products','mod_j2store_cart'); | ||
// in_array() | ||
$result = []; | ||
foreach($data as $key => $value) { | ||
if(isset($value->element) && !empty($value->element)){ | ||
if(in_array($value->element,$j2store_module)){ | ||
$result[] = $value; | ||
} | ||
} | ||
} | ||
|
||
return $result; | ||
|
||
} | ||
|
||
public function getTemplate(){ | ||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
$query->select("*")->from("#__template_styles"); | ||
$db->setQuery($query); | ||
$result = $db->loadObjectList(); | ||
|
||
return $result; | ||
} | ||
|
||
public function componentsStatus(){ | ||
$components_status = $this->getListComponents(); | ||
$status = ''; | ||
if(is_array($components_status) && !empty($components_status) ){ | ||
foreach ( $components_status as $key => $value) { | ||
if (empty($value->enabled)) { | ||
$status = 'Ready to install'; | ||
} else { | ||
$status = 'Not Ready'; | ||
break; | ||
} | ||
} | ||
} | ||
return $status; | ||
} | ||
public function pluginsStatus(){ | ||
$plugins_status = $this->getListPlugins(); | ||
$status = ''; | ||
if(is_array($plugins_status) && !empty($plugins_status) ) { | ||
foreach ($plugins_status as $key => $value) { | ||
if (empty($value->enabled)) { | ||
$status = 'Ready to install'; | ||
} else { | ||
$status = 'Not Ready'; | ||
break; | ||
} | ||
} | ||
} | ||
return $status; | ||
} | ||
public function modulesStatus(){ | ||
$module_status = $this->getListModules(); | ||
$status = ''; | ||
if(is_array($module_status) && !empty($module_status) ) { | ||
foreach ($module_status as $key => $value) { | ||
if (empty($value->enabled)) { | ||
$status = 'Ready to install'; | ||
} else { | ||
$status = 'Not Ready'; | ||
break; | ||
} | ||
} | ||
} | ||
return $status; | ||
} | ||
public function getTemplateOverride(){ | ||
$template_override = $this->getTemplate(); | ||
$template_overridePath = []; | ||
foreach ($template_override as $key => $value){ | ||
|
||
if(empty($value->client_id) ) { | ||
$templatePath = JPATH_SITE . '/templates/' . $value->template; | ||
}elseif($value->client_id == 1){ | ||
$templatePath = JPATH_ADMINISTRATOR . '/templates/' . $value->template; | ||
} | ||
$component = 'com_j2store'; | ||
$overridePath = $templatePath . '/html/' . $component ; | ||
if (file_exists($overridePath)) { | ||
$template_overridePath[] = $overridePath; | ||
} | ||
} | ||
return $template_overridePath; | ||
} | ||
public function templateStatus(){ | ||
$template_status = $this->getTemplateOverride(); | ||
$status = ''; | ||
if (empty($template_status)) { | ||
$status = 'Ready to install'; | ||
} else { | ||
$status = 'Not Ready'; | ||
} | ||
return $status; | ||
} | ||
public function saveData(){ | ||
|
||
$columns = array('component_status', 'plugins_status','modules_status','template_status','installation_status'); | ||
$modules_status = $this->modulesStatus(); | ||
$plugins_status = $this->pluginsStatus(); | ||
$components_status = $this->componentsStatus(); | ||
$template_status = $this->templateStatus(); | ||
$installation_status = false; | ||
if($components_status !== 'Not Ready' && $modules_status !== 'Not Ready' && $plugins_status !== 'Not Ready' && $template_status !== 'Not Ready' ) { | ||
$installation_status = true; | ||
} | ||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
$query->select('*')->from('#__extension_check'); | ||
$db->setQuery($query); | ||
$result = $db->loadObjectList();; | ||
if( is_array($result) && count($result)> 0 ){ | ||
foreach ($result as $key => $value ) { | ||
$query->update($db->qn('#__extension_check')); | ||
$query->set($db->qn('component_status') . ' = ' . $db->q($components_status)); | ||
$query->set($db->qn('plugins_status') . ' = ' . $db->q($plugins_status)); | ||
$query->set($db->qn('modules_status') . ' = ' . $db->q($modules_status)); | ||
$query->set($db->qn('template_status') . ' = ' . $db->q($template_status)); | ||
$query->set($db->qn('installation_status') . ' = ' . $db->q($installation_status)); | ||
$query->where($db->qn('extension_check_id') . ' = ' . (int)$value->extension_check_id); | ||
$db->setQuery($query); | ||
$db->execute(); | ||
} | ||
}else { | ||
$query->insert($db->qn('#__extension_check')) | ||
->columns($columns) | ||
->values($db->q($components_status) . ', ' . $db->q($plugins_status) . ',' . $db->q($modules_status). ',' . $db->q($template_status). ',' . $db->q($installation_status)); | ||
$db->setQuery($query); | ||
$db->execute(); | ||
} | ||
} | ||
|
||
|
||
} |
1 change: 1 addition & 0 deletions
1
administrator/components/com_j2migrationchecker/views/cpanel/index.html
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 @@ | ||
<html><head><title></title></head><body></body></html> |
Oops, something went wrong.