mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
issue 2662 coding convention in modules/addon
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12233 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
7928ad163b
commit
da0146a8ae
5 changed files with 982 additions and 926 deletions
|
|
@ -1,216 +1,223 @@
|
|||
<?php
|
||||
require_once(_XE_PATH_.'modules/addon/addon.controller.php');
|
||||
require_once(_XE_PATH_.'modules/addon/addon.controller.php');
|
||||
|
||||
/**
|
||||
* Admin controller class of addon modules
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
class addonAdminController extends addonController {
|
||||
/**
|
||||
* Admin controller class of addon modules
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
*/
|
||||
class addonAdminController extends addonController
|
||||
{
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Set addon activate
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function procAddonAdminSaveActivate()
|
||||
/**
|
||||
* Set addon activate
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function procAddonAdminSaveActivate()
|
||||
{
|
||||
$pcOnList = Context::get('pc_on');
|
||||
$mobileOnList = Context::get('mobile_on');
|
||||
$fixed = Context::get('fixed');
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
if($site_module_info->site_srl) $site_srl = $site_module_info->site_srl;
|
||||
else $site_srl = 0;
|
||||
|
||||
if(!$pcOnList) $pcOnList = array();
|
||||
if(!$mobileOnList) $mobileOnList = array();
|
||||
if(!$fixed) $fixed = array();
|
||||
|
||||
if(!is_array($pcOnList)) $pcOnList = array($pcOnList);
|
||||
if(!is_array($mobileOnList)) $pcOnList = array($mobileOnList);
|
||||
if(!is_array($fixed)) $pcOnList = array($fixed);
|
||||
|
||||
// get current addon info
|
||||
$oModel = &getAdminModel('addon');
|
||||
$currentAddonList = $oModel->getAddonList($site_srl, 'site');
|
||||
|
||||
// get need update addon list
|
||||
$updateList = array();
|
||||
foreach($currentAddonList as $addon)
|
||||
{
|
||||
$pcOnList = Context::get('pc_on');
|
||||
$mobileOnList = Context::get('mobile_on');
|
||||
$fixed = Context::get('fixed');
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
if($site_module_info->site_srl) $site_srl = $site_module_info->site_srl;
|
||||
else $site_srl = 0;
|
||||
|
||||
if (!$pcOnList) $pcOnList = array();
|
||||
if (!$mobileOnList) $mobileOnList = array();
|
||||
if (!$fixed) $fixed = array();
|
||||
|
||||
if (!is_array($pcOnList)) $pcOnList = array($pcOnList);
|
||||
if (!is_array($mobileOnList)) $pcOnList = array($mobileOnList);
|
||||
if (!is_array($fixed)) $pcOnList = array($fixed);
|
||||
|
||||
// get current addon info
|
||||
$oModel = &getAdminModel('addon');
|
||||
$currentAddonList = $oModel->getAddonList($site_srl, 'site');
|
||||
|
||||
// get need update addon list
|
||||
$updateList = array();
|
||||
foreach($currentAddonList as $addon)
|
||||
if($addon->activated !== in_array($addon->addon_name, $pcOnList))
|
||||
{
|
||||
if ($addon->activated !== in_array($addon->addon_name, $pcOnList))
|
||||
{
|
||||
$updateList[] = $addon->addon_name;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($addon->mactivated !== in_array($addon->addon_name, $mobileOnList))
|
||||
{
|
||||
$updateList[] = $addon->addon_name;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($addon->fixed !== in_array($addon->addon_name, $fixed))
|
||||
{
|
||||
$updateList[] = $addon->addon_name;
|
||||
continue;
|
||||
}
|
||||
$updateList[] = $addon->addon_name;
|
||||
continue;
|
||||
}
|
||||
|
||||
// update
|
||||
foreach($updateList as $targetAddon)
|
||||
if($addon->mactivated !== in_array($addon->addon_name, $mobileOnList))
|
||||
{
|
||||
unset($args);
|
||||
|
||||
if (in_array($targetAddon, $pcOnList))
|
||||
$args->is_used = 'Y';
|
||||
else
|
||||
$args->is_used = 'N';
|
||||
|
||||
if (in_array($targetAddon, $mobileOnList))
|
||||
$args->is_used_m = 'Y';
|
||||
else
|
||||
$args->is_used_m = 'N';
|
||||
|
||||
if (in_array($targetAddon, $fixed))
|
||||
$args->fixed = 'Y';
|
||||
else
|
||||
$args->fixed = 'N';
|
||||
|
||||
$args->addon = $targetAddon;
|
||||
$args->site_srl = $site_srl;
|
||||
|
||||
$output = executeQuery('addon.updateSiteAddon', $args);
|
||||
if (!$output->toBool()) return $output;
|
||||
$updateList[] = $addon->addon_name;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($updateList))
|
||||
if($addon->fixed !== in_array($addon->addon_name, $fixed))
|
||||
{
|
||||
$this->makeCacheFile($site_srl, 'pc', 'site');
|
||||
$this->makeCacheFile($site_srl, 'mobile', 'site');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated', 'info');
|
||||
if (Context::get('success_return_url'))
|
||||
{
|
||||
$this->setRedirectUrl(Context::get('success_return_url'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAddonAdminIndex'));
|
||||
$updateList[] = $addon->addon_name;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add active/inactive change
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function procAddonAdminToggleActivate() {
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
// update
|
||||
foreach($updateList as $targetAddon)
|
||||
{
|
||||
unset($args);
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
// batahom addon values
|
||||
$addon = Context::get('addon');
|
||||
$type = Context::get('type');
|
||||
if(!$type) $type = "pc";
|
||||
if($addon) {
|
||||
// If enabled Disables
|
||||
if($oAddonModel->isActivatedAddon($addon, $site_module_info->site_srl, $type)) $this->doDeactivate($addon, $site_module_info->site_srl, $type);
|
||||
// If it is disabled Activate
|
||||
else $this->doActivate($addon, $site_module_info->site_srl, $type);
|
||||
}
|
||||
if(in_array($targetAddon, $pcOnList))
|
||||
$args->is_used = 'Y';
|
||||
else
|
||||
$args->is_used = 'N';
|
||||
|
||||
$this->makeCacheFile($site_module_info->site_srl, $type);
|
||||
}
|
||||
if(in_array($targetAddon, $mobileOnList))
|
||||
$args->is_used_m = 'Y';
|
||||
else
|
||||
$args->is_used_m = 'N';
|
||||
|
||||
/**
|
||||
* Add the configuration information input
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function procAddonAdminSetupAddon() {
|
||||
$args = Context::getRequestVars();
|
||||
$module = $args->module;
|
||||
$addon_name = $args->addon_name;
|
||||
unset($args->module);
|
||||
unset($args->act);
|
||||
unset($args->addon_name);
|
||||
unset($args->body);
|
||||
unset($args->error_return_url);
|
||||
if(in_array($targetAddon, $fixed))
|
||||
$args->fixed = 'Y';
|
||||
else
|
||||
$args->fixed = 'N';
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
$args->addon = $targetAddon;
|
||||
$args->site_srl = $site_srl;
|
||||
|
||||
$output = $this->doSetup($addon_name, $args, $site_module_info->site_srl, 'site');
|
||||
$output = executeQuery('addon.updateSiteAddon', $args);
|
||||
if (!$output->toBool()) return $output;
|
||||
}
|
||||
|
||||
$this->makeCacheFile($site_module_info->site_srl, "pc", 'site');
|
||||
$this->makeCacheFile($site_module_info->site_srl, "mobile", 'site');
|
||||
if(count($updateList))
|
||||
{
|
||||
$this->makeCacheFile($site_srl, 'pc', 'site');
|
||||
$this->makeCacheFile($site_srl, 'mobile', 'site');
|
||||
}
|
||||
|
||||
$this->setRedirectUrl(getNotEncodedUrl('', 'module', $module, 'act', 'dispAddonAdminSetup', 'selected_addon', $addon_name), $output);
|
||||
}
|
||||
$this->setMessage('success_updated', 'info');
|
||||
if(Context::get('success_return_url'))
|
||||
{
|
||||
$this->setRedirectUrl(Context::get('success_return_url'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAddonAdminIndex'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add active/inactive change
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function procAddonAdminToggleActivate()
|
||||
{
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
// batahom addon values
|
||||
$addon = Context::get('addon');
|
||||
$type = Context::get('type');
|
||||
if(!$type) $type = "pc";
|
||||
if($addon)
|
||||
{
|
||||
// If enabled Disables
|
||||
if($oAddonModel->isActivatedAddon($addon, $site_module_info->site_srl, $type)) $this->doDeactivate($addon, $site_module_info->site_srl, $type);
|
||||
// If it is disabled Activate
|
||||
else $this->doActivate($addon, $site_module_info->site_srl, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds addon to DB
|
||||
*
|
||||
* @param string $addon Addon name
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @param string $isUsed Whether to use
|
||||
* @return Object
|
||||
**/
|
||||
function doInsert($addon, $site_srl = 0, $gtype = 'site', $isUsed = 'N') {
|
||||
$args->addon = $addon;
|
||||
$args->is_used = $isUsed;
|
||||
if($gtype == 'global') return executeQuery('addon.insertAddon', $args);
|
||||
$args->site_srl = $site_srl;
|
||||
return executeQuery('addon.insertSiteAddon', $args);
|
||||
}
|
||||
$this->makeCacheFile($site_module_info->site_srl, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate addon
|
||||
*
|
||||
* @param string $addon Addon name
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $type pc or modile
|
||||
* @param string $gtype site or global
|
||||
* @return Object
|
||||
**/
|
||||
function doActivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site') {
|
||||
$args->addon = $addon;
|
||||
if($type == "pc") $args->is_used = 'Y';
|
||||
else $args->is_used_m = "Y";
|
||||
if($gtype == 'global') return executeQuery('addon.updateAddon', $args);
|
||||
$args->site_srl = $site_srl;
|
||||
return executeQuery('addon.updateSiteAddon', $args);
|
||||
}
|
||||
/**
|
||||
* Add the configuration information input
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function procAddonAdminSetupAddon()
|
||||
{
|
||||
$args = Context::getRequestVars();
|
||||
$module = $args->module;
|
||||
$addon_name = $args->addon_name;
|
||||
unset($args->module);
|
||||
unset($args->act);
|
||||
unset($args->addon_name);
|
||||
unset($args->body);
|
||||
unset($args->error_return_url);
|
||||
|
||||
/**
|
||||
* Deactivate Addon
|
||||
*
|
||||
* @param string $addon Addon name
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $type pc or mobile
|
||||
* @param string $gtype site or global
|
||||
**/
|
||||
function doDeactivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site') {
|
||||
$args->addon = $addon;
|
||||
if($type == "pc") $args->is_used = 'N';
|
||||
else $args->is_used_m = 'N';
|
||||
if($gtype == 'global') return executeQuery('addon.updateAddon', $args);
|
||||
$args->site_srl = $site_srl;
|
||||
return executeQuery('addon.updateSiteAddon', $args);
|
||||
}
|
||||
}
|
||||
?>
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
$output = $this->doSetup($addon_name, $args, $site_module_info->site_srl, 'site');
|
||||
if (!$output->toBool()) return $output;
|
||||
|
||||
$this->makeCacheFile($site_module_info->site_srl, "pc", 'site');
|
||||
$this->makeCacheFile($site_module_info->site_srl, "mobile", 'site');
|
||||
|
||||
$this->setRedirectUrl(getNotEncodedUrl('', 'module', $module, 'act', 'dispAddonAdminSetup', 'selected_addon', $addon_name), $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds addon to DB
|
||||
*
|
||||
* @param string $addon Addon name
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @param string $isUsed Whether to use
|
||||
* @return Object
|
||||
*/
|
||||
function doInsert($addon, $site_srl = 0, $gtype = 'site', $isUsed = 'N')
|
||||
{
|
||||
$args->addon = $addon;
|
||||
$args->is_used = $isUsed;
|
||||
if($gtype == 'global') return executeQuery('addon.insertAddon', $args);
|
||||
$args->site_srl = $site_srl;
|
||||
return executeQuery('addon.insertSiteAddon', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate addon
|
||||
*
|
||||
* @param string $addon Addon name
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $type pc or modile
|
||||
* @param string $gtype site or global
|
||||
* @return Object
|
||||
*/
|
||||
function doActivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site')
|
||||
{
|
||||
$args->addon = $addon;
|
||||
if($type == "pc") $args->is_used = 'Y';
|
||||
else $args->is_used_m = "Y";
|
||||
if($gtype == 'global') return executeQuery('addon.updateAddon', $args);
|
||||
$args->site_srl = $site_srl;
|
||||
return executeQuery('addon.updateSiteAddon', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate Addon
|
||||
*
|
||||
* @param string $addon Addon name
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $type pc or mobile
|
||||
* @param string $gtype site or global
|
||||
*/
|
||||
function doDeactivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site')
|
||||
{
|
||||
$args->addon = $addon;
|
||||
if($type == "pc") $args->is_used = 'N';
|
||||
else $args->is_used_m = 'N';
|
||||
if($gtype == 'global') return executeQuery('addon.updateAddon', $args);
|
||||
$args->site_srl = $site_srl;
|
||||
return executeQuery('addon.updateSiteAddon', $args);
|
||||
}
|
||||
}
|
||||
/* End of file addon.admin.controller.php */
|
||||
/* Location: ./modules/addon/addon.admin.controller.php */
|
||||
|
|
|
|||
|
|
@ -1,370 +1,396 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin model class of addon module
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
class addonAdminModel extends addon {
|
||||
/**
|
||||
* Admin model class of addon module
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
*/
|
||||
class addonAdminModel extends addon
|
||||
{
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
/**
|
||||
* Returns a path of addon
|
||||
*
|
||||
* @param string $addon_name Name to get path
|
||||
* @return string Returns a path
|
||||
*/
|
||||
function getAddonPath($addon_name)
|
||||
{
|
||||
$class_path = sprintf('./addons/%s/', $addon_name);
|
||||
if(is_dir($class_path)) return $class_path;
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a path of addon
|
||||
*
|
||||
* @param string $addon_name Name to get path
|
||||
* @return string Returns a path
|
||||
**/
|
||||
function getAddonPath($addon_name) {
|
||||
$class_path = sprintf('./addons/%s/', $addon_name);
|
||||
if(is_dir($class_path)) return $class_path;
|
||||
return "";
|
||||
}
|
||||
/**
|
||||
* Get addon list for super admin
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function getAddonListForSuperAdmin()
|
||||
{
|
||||
$addonList = $this->getAddonList(0, 'site');
|
||||
|
||||
/**
|
||||
* Get addon list for super admin
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function getAddonListForSuperAdmin()
|
||||
$oAutoinstallModel = &getModel('autoinstall');
|
||||
foreach($addonList as $key => $addon)
|
||||
{
|
||||
$addonList = $this->getAddonList(0, 'site');
|
||||
// get easyinstall remove url
|
||||
$packageSrl = $oAutoinstallModel->getPackageSrlByPath($addon->path);
|
||||
$addonList[$key]->remove_url = $oAutoinstallModel->getRemoveUrlByPackageSrl($packageSrl);
|
||||
|
||||
$oAutoinstallModel = &getModel('autoinstall');
|
||||
foreach($addonList as $key => $addon)
|
||||
// get easyinstall need update
|
||||
$package = $oAutoinstallModel->getInstalledPackages($packageSrl);
|
||||
$addonList[$key]->need_update = $package[$packageSrl]->need_update;
|
||||
|
||||
// get easyinstall update url
|
||||
if($addonList[$key]->need_update == 'Y')
|
||||
{
|
||||
// get easyinstall remove url
|
||||
$packageSrl = $oAutoinstallModel->getPackageSrlByPath($addon->path);
|
||||
$addonList[$key]->remove_url = $oAutoinstallModel->getRemoveUrlByPackageSrl($packageSrl);
|
||||
$addonList[$key]->update_url = $oAutoinstallModel->getUpdateUrlByPackageSrl($packageSrl);
|
||||
}
|
||||
}
|
||||
|
||||
// get easyinstall need update
|
||||
$package = $oAutoinstallModel->getInstalledPackages($packageSrl);
|
||||
$addonList[$key]->need_update = $package[$packageSrl]->need_update;
|
||||
return $addonList;
|
||||
}
|
||||
|
||||
// get easyinstall update url
|
||||
if ($addonList[$key]->need_update == 'Y')
|
||||
/**
|
||||
* Returns addon list
|
||||
*
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @return array Returns addon list
|
||||
*/
|
||||
function getAddonList($site_srl = 0, $gtype = 'site')
|
||||
{
|
||||
// Wanted to add a list of activated
|
||||
$inserted_addons = $this->getInsertedAddons($site_srl, $gtype);
|
||||
// Downloaded and installed add-on to the list of Wanted
|
||||
$searched_list = FileHandler::readDir('./addons','/^([a-zA-Z0-9-_]+)$/');
|
||||
$searched_count = count($searched_list);
|
||||
if(!$searched_count) return;
|
||||
sort($searched_list);
|
||||
|
||||
$oAddonAdminController = &getAdminController('addon');
|
||||
|
||||
for($i=0;$i<$searched_count;$i++)
|
||||
{
|
||||
// Add the name of
|
||||
$addon_name = $searched_list[$i];
|
||||
if($addon_name == "smartphone") continue;
|
||||
// Add the path (files/addons precedence)
|
||||
$path = $this->getAddonPath($addon_name);
|
||||
// Wanted information on the add-on
|
||||
unset($info);
|
||||
$info = $this->getAddonInfoXml($addon_name, $site_srl, $gtype);
|
||||
|
||||
$info->addon = $addon_name;
|
||||
$info->path = $path;
|
||||
$info->activated = false;
|
||||
$info->mactivated = false;
|
||||
$info->fixed = false;
|
||||
// Check if a permossion is granted entered in DB
|
||||
if(!in_array($addon_name, array_keys($inserted_addons)))
|
||||
{
|
||||
// If not, type in the DB type (model, perhaps because of the hate doing this haneungeo .. ㅡ. ㅜ)
|
||||
$oAddonAdminController->doInsert($addon_name, $site_srl, $type);
|
||||
// Is activated
|
||||
}
|
||||
else
|
||||
{
|
||||
if($inserted_addons[$addon_name]->is_used=='Y') $info->activated = true;
|
||||
if($inserted_addons[$addon_name]->is_used_m=='Y') $info->mactivated = true;
|
||||
if ($gtype == 'global' && $inserted_addons[$addon_name]->is_fixed == 'Y') $info->fixed = true;
|
||||
}
|
||||
|
||||
$list[] = $info;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a information of addon
|
||||
*
|
||||
* @param string $addon Name to get information
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @return object Returns a information
|
||||
*/
|
||||
function getAddonInfoXml($addon, $site_srl = 0, $gtype = 'site')
|
||||
{
|
||||
// Get a path of the requested module. Return if not exists.
|
||||
$addon_path = $this->getAddonPath($addon);
|
||||
if(!$addon_path) return;
|
||||
// Read the xml file for module skin information
|
||||
$xml_file = sprintf("%sconf/info.xml", $addon_path);
|
||||
if(!file_exists($xml_file)) return;
|
||||
|
||||
$oXmlParser = new XmlParser();
|
||||
$tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file);
|
||||
$xml_obj = $tmp_xml_obj->addon;
|
||||
|
||||
if(!$xml_obj) return;
|
||||
|
||||
// DB is set to bring history
|
||||
$db_args->addon = $addon;
|
||||
if($gtype == 'global') $output = executeQuery('addon.getAddonInfo',$db_args);
|
||||
else
|
||||
{
|
||||
$db_args->site_srl = $site_srl;
|
||||
$output = executeQuery('addon.getSiteAddonInfo',$db_args);
|
||||
}
|
||||
$extra_vals = unserialize($output->data->extra_vars);
|
||||
|
||||
if($extra_vals->mid_list)
|
||||
{
|
||||
$addon_info->mid_list = $extra_vals->mid_list;
|
||||
}
|
||||
else
|
||||
{
|
||||
$addon_info->mid_list = array();
|
||||
}
|
||||
|
||||
if($extra_vals->xe_run_method)
|
||||
{
|
||||
$addon_info->xe_run_method = $extra_vals->xe_run_method;
|
||||
}
|
||||
|
||||
// Add information
|
||||
if($xml_obj->version && $xml_obj->attrs->version == '0.2')
|
||||
{
|
||||
// addon format v0.2
|
||||
sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
$addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
|
||||
$addon_info->addon_name = $addon;
|
||||
$addon_info->title = $xml_obj->title->body;
|
||||
$addon_info->description = trim($xml_obj->description->body);
|
||||
$addon_info->version = $xml_obj->version->body;
|
||||
$addon_info->homepage = $xml_obj->link->body;
|
||||
$addon_info->license = $xml_obj->license->body;
|
||||
$addon_info->license_link = $xml_obj->license->attrs->link;
|
||||
|
||||
if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author;
|
||||
else $author_list = $xml_obj->author;
|
||||
|
||||
foreach($author_list as $author)
|
||||
{
|
||||
unset($author_obj);
|
||||
$author_obj->name = $author->name->body;
|
||||
$author_obj->email_address = $author->attrs->email_address;
|
||||
$author_obj->homepage = $author->attrs->link;
|
||||
$addon_info->author[] = $author_obj;
|
||||
}
|
||||
|
||||
// Expand the variable order
|
||||
if($xml_obj->extra_vars)
|
||||
{
|
||||
$extra_var_groups = $xml_obj->extra_vars->group;
|
||||
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars;
|
||||
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups);
|
||||
|
||||
foreach($extra_var_groups as $group)
|
||||
{
|
||||
$addonList[$key]->update_url = $oAutoinstallModel->getUpdateUrlByPackageSrl($packageSrl);
|
||||
$extra_vars = $group->var;
|
||||
if(!is_array($group->var)) $extra_vars = array($group->var);
|
||||
|
||||
foreach($extra_vars as $key => $val)
|
||||
{
|
||||
unset($obj);
|
||||
if(!$val->attrs->type) { $val->attrs->type = 'text'; }
|
||||
|
||||
$obj->group = $group->title->body;
|
||||
$obj->name = $val->attrs->name;
|
||||
$obj->title = $val->title->body;
|
||||
$obj->type = $val->attrs->type;
|
||||
$obj->description = $val->description->body;
|
||||
if($obj->name)
|
||||
{
|
||||
$obj->value = $extra_vals->{$obj->name};
|
||||
}
|
||||
if(strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); }
|
||||
if($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); }
|
||||
|
||||
// 'Select'type obtained from the option list.
|
||||
if($val->options && !is_array($val->options))
|
||||
{
|
||||
$val->options = array($val->options);
|
||||
}
|
||||
|
||||
for($i = 0, $c = count($val->options); $i < $c; $i++)
|
||||
{
|
||||
$obj->options[$i]->title = $val->options[$i]->title->body;
|
||||
$obj->options[$i]->value = $val->options[$i]->attrs->value;
|
||||
}
|
||||
|
||||
$addon_info->extra_vars[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $addonList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns addon list
|
||||
*
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @return array Returns addon list
|
||||
**/
|
||||
function getAddonList($site_srl = 0, $gtype = 'site') {
|
||||
// Wanted to add a list of activated
|
||||
$inserted_addons = $this->getInsertedAddons($site_srl, $gtype);
|
||||
// Downloaded and installed add-on to the list of Wanted
|
||||
$searched_list = FileHandler::readDir('./addons','/^([a-zA-Z0-9-_]+)$/');
|
||||
$searched_count = count($searched_list);
|
||||
if(!$searched_count) return;
|
||||
sort($searched_list);
|
||||
|
||||
$oAddonAdminController = &getAdminController('addon');
|
||||
|
||||
for($i=0;$i<$searched_count;$i++) {
|
||||
// Add the name of
|
||||
$addon_name = $searched_list[$i];
|
||||
if($addon_name == "smartphone") continue;
|
||||
// Add the path (files/addons precedence)
|
||||
$path = $this->getAddonPath($addon_name);
|
||||
// Wanted information on the add-on
|
||||
unset($info);
|
||||
$info = $this->getAddonInfoXml($addon_name, $site_srl, $gtype);
|
||||
|
||||
$info->addon = $addon_name;
|
||||
$info->path = $path;
|
||||
$info->activated = false;
|
||||
$info->mactivated = false;
|
||||
$info->fixed = false;
|
||||
// Check if a permossion is granted entered in DB
|
||||
if(!in_array($addon_name, array_keys($inserted_addons))) {
|
||||
// If not, type in the DB type (model, perhaps because of the hate doing this haneungeo .. ㅡ. ㅜ)
|
||||
$oAddonAdminController->doInsert($addon_name, $site_srl, $type);
|
||||
// Is activated
|
||||
} else {
|
||||
if($inserted_addons[$addon_name]->is_used=='Y') $info->activated = true;
|
||||
if($inserted_addons[$addon_name]->is_used_m=='Y') $info->mactivated = true;
|
||||
if ($gtype == 'global' && $inserted_addons[$addon_name]->is_fixed == 'Y') $info->fixed = true;
|
||||
}
|
||||
|
||||
$list[] = $info;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a information of addon
|
||||
*
|
||||
* @param string $addon Name to get information
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @return object Returns a information
|
||||
**/
|
||||
function getAddonInfoXml($addon, $site_srl = 0, $gtype = 'site') {
|
||||
// Get a path of the requested module. Return if not exists.
|
||||
$addon_path = $this->getAddonPath($addon);
|
||||
if(!$addon_path) return;
|
||||
// Read the xml file for module skin information
|
||||
$xml_file = sprintf("%sconf/info.xml", $addon_path);
|
||||
if(!file_exists($xml_file)) return;
|
||||
|
||||
$oXmlParser = new XmlParser();
|
||||
$tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file);
|
||||
$xml_obj = $tmp_xml_obj->addon;
|
||||
|
||||
if(!$xml_obj) return;
|
||||
|
||||
|
||||
// DB is set to bring history
|
||||
$db_args->addon = $addon;
|
||||
if($gtype == 'global') $output = executeQuery('addon.getAddonInfo',$db_args);
|
||||
else {
|
||||
$db_args->site_srl = $site_srl;
|
||||
$output = executeQuery('addon.getSiteAddonInfo',$db_args);
|
||||
}
|
||||
$extra_vals = unserialize($output->data->extra_vars);
|
||||
|
||||
if($extra_vals->mid_list) {
|
||||
$addon_info->mid_list = $extra_vals->mid_list;
|
||||
} else {
|
||||
$addon_info->mid_list = array();
|
||||
}
|
||||
|
||||
if($extra_vals->xe_run_method)
|
||||
// history
|
||||
if($xml_obj->history)
|
||||
{
|
||||
$addon_info->xe_run_method = $extra_vals->xe_run_method;
|
||||
if(!is_array($xml_obj->history)) $history[] = $xml_obj->history;
|
||||
else $history = $xml_obj->history;
|
||||
|
||||
foreach($history as $item)
|
||||
{
|
||||
unset($obj);
|
||||
|
||||
if($item->author)
|
||||
{
|
||||
(!is_array($item->author)) ? $obj->author_list[] = $item->author : $obj->author_list = $item->author;
|
||||
|
||||
foreach($obj->author_list as $author)
|
||||
{
|
||||
unset($author_obj);
|
||||
$author_obj->name = $author->name->body;
|
||||
$author_obj->email_address = $author->attrs->email_address;
|
||||
$author_obj->homepage = $author->attrs->link;
|
||||
$obj->author[] = $author_obj;
|
||||
}
|
||||
}
|
||||
|
||||
$obj->name = $item->name->body;
|
||||
$obj->email_address = $item->attrs->email_address;
|
||||
$obj->homepage = $item->attrs->link;
|
||||
$obj->version = $item->attrs->version;
|
||||
$obj->date = $item->attrs->date;
|
||||
$obj->description = $item->description->body;
|
||||
|
||||
if($item->log)
|
||||
{
|
||||
(!is_array($item->log)) ? $obj->log[] = $item->log : $obj->log = $item->log;
|
||||
|
||||
foreach($obj->log as $log)
|
||||
{
|
||||
unset($log_obj);
|
||||
$log_obj->text = $log->body;
|
||||
$log_obj->link = $log->attrs->link;
|
||||
$obj->logs[] = $log_obj;
|
||||
}
|
||||
}
|
||||
$addon_info->history[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// addon format 0.1
|
||||
$addon_info->addon_name = $addon;
|
||||
$addon_info->title = $xml_obj->title->body;
|
||||
$addon_info->description = trim($xml_obj->author->description->body);
|
||||
$addon_info->version = $xml_obj->attrs->version;
|
||||
sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
$addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
$author_obj->name = $xml_obj->author->name->body;
|
||||
$author_obj->email_address = $xml_obj->author->attrs->email_address;
|
||||
$author_obj->homepage = $xml_obj->author->attrs->link;
|
||||
$addon_info->author[] = $author_obj;
|
||||
|
||||
if($xml_obj->extra_vars)
|
||||
{
|
||||
// Expand the variable order
|
||||
$extra_var_groups = $xml_obj->extra_vars->group;
|
||||
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars;
|
||||
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups);
|
||||
foreach($extra_var_groups as $group)
|
||||
{
|
||||
$extra_vars = $group->var;
|
||||
if(!is_array($group->var)) $extra_vars = array($group->var);
|
||||
|
||||
// Add information
|
||||
if($xml_obj->version && $xml_obj->attrs->version == '0.2') {
|
||||
// addon format v0.2
|
||||
sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
$addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
foreach($extra_vars as $key => $val)
|
||||
{
|
||||
unset($obj);
|
||||
|
||||
$addon_info->addon_name = $addon;
|
||||
$addon_info->title = $xml_obj->title->body;
|
||||
$addon_info->description = trim($xml_obj->description->body);
|
||||
$addon_info->version = $xml_obj->version->body;
|
||||
$addon_info->homepage = $xml_obj->link->body;
|
||||
$addon_info->license = $xml_obj->license->body;
|
||||
$addon_info->license_link = $xml_obj->license->attrs->link;
|
||||
$obj->group = $group->title->body;
|
||||
$obj->name = $val->attrs->name;
|
||||
$obj->title = $val->title->body;
|
||||
$obj->type = $val->type->body ? $val->type->body : 'text';
|
||||
$obj->description = $val->description->body;
|
||||
if($obj->name)
|
||||
{
|
||||
$obj->value = $extra_vals->{$obj->name};
|
||||
}
|
||||
if(strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); }
|
||||
if($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); }
|
||||
// 'Select'type obtained from the option list.
|
||||
if($val->options && !is_array($val->options))
|
||||
{
|
||||
$val->options = array($val->options);
|
||||
}
|
||||
|
||||
if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author;
|
||||
else $author_list = $xml_obj->author;
|
||||
|
||||
foreach($author_list as $author) {
|
||||
unset($author_obj);
|
||||
$author_obj->name = $author->name->body;
|
||||
$author_obj->email_address = $author->attrs->email_address;
|
||||
$author_obj->homepage = $author->attrs->link;
|
||||
$addon_info->author[] = $author_obj;
|
||||
}
|
||||
|
||||
// Expand the variable order
|
||||
if($xml_obj->extra_vars) {
|
||||
$extra_var_groups = $xml_obj->extra_vars->group;
|
||||
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars;
|
||||
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups);
|
||||
|
||||
foreach($extra_var_groups as $group) {
|
||||
$extra_vars = $group->var;
|
||||
if(!is_array($group->var)) $extra_vars = array($group->var);
|
||||
|
||||
foreach($extra_vars as $key => $val) {
|
||||
unset($obj);
|
||||
if(!$val->attrs->type) { $val->attrs->type = 'text'; }
|
||||
|
||||
$obj->group = $group->title->body;
|
||||
$obj->name = $val->attrs->name;
|
||||
$obj->title = $val->title->body;
|
||||
$obj->type = $val->attrs->type;
|
||||
$obj->description = $val->description->body;
|
||||
if($obj->name)
|
||||
{
|
||||
$obj->value = $extra_vals->{$obj->name};
|
||||
}
|
||||
if(strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); }
|
||||
if($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); }
|
||||
|
||||
// 'Select'type obtained from the option list.
|
||||
if($val->options && !is_array($val->options))
|
||||
{
|
||||
$val->options = array($val->options);
|
||||
}
|
||||
|
||||
for($i = 0, $c = count($val->options); $i < $c; $i++) {
|
||||
$obj->options[$i]->title = $val->options[$i]->title->body;
|
||||
$obj->options[$i]->value = $val->options[$i]->attrs->value;
|
||||
}
|
||||
|
||||
$addon_info->extra_vars[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// history
|
||||
if($xml_obj->history) {
|
||||
if(!is_array($xml_obj->history)) $history[] = $xml_obj->history;
|
||||
else $history = $xml_obj->history;
|
||||
|
||||
foreach($history as $item) {
|
||||
unset($obj);
|
||||
|
||||
if($item->author) {
|
||||
(!is_array($item->author)) ? $obj->author_list[] = $item->author : $obj->author_list = $item->author;
|
||||
|
||||
foreach($obj->author_list as $author) {
|
||||
unset($author_obj);
|
||||
$author_obj->name = $author->name->body;
|
||||
$author_obj->email_address = $author->attrs->email_address;
|
||||
$author_obj->homepage = $author->attrs->link;
|
||||
$obj->author[] = $author_obj;
|
||||
}
|
||||
}
|
||||
|
||||
$obj->name = $item->name->body;
|
||||
$obj->email_address = $item->attrs->email_address;
|
||||
$obj->homepage = $item->attrs->link;
|
||||
$obj->version = $item->attrs->version;
|
||||
$obj->date = $item->attrs->date;
|
||||
$obj->description = $item->description->body;
|
||||
|
||||
if($item->log) {
|
||||
(!is_array($item->log)) ? $obj->log[] = $item->log : $obj->log = $item->log;
|
||||
|
||||
foreach($obj->log as $log) {
|
||||
unset($log_obj);
|
||||
$log_obj->text = $log->body;
|
||||
$log_obj->link = $log->attrs->link;
|
||||
$obj->logs[] = $log_obj;
|
||||
}
|
||||
}
|
||||
|
||||
$addon_info->history[] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
// addon format 0.1
|
||||
$addon_info->addon_name = $addon;
|
||||
$addon_info->title = $xml_obj->title->body;
|
||||
$addon_info->description = trim($xml_obj->author->description->body);
|
||||
$addon_info->version = $xml_obj->attrs->version;
|
||||
sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
$addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
|
||||
$author_obj->name = $xml_obj->author->name->body;
|
||||
$author_obj->email_address = $xml_obj->author->attrs->email_address;
|
||||
$author_obj->homepage = $xml_obj->author->attrs->link;
|
||||
$addon_info->author[] = $author_obj;
|
||||
|
||||
if($xml_obj->extra_vars) {
|
||||
// Expand the variable order
|
||||
$extra_var_groups = $xml_obj->extra_vars->group;
|
||||
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars;
|
||||
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups);
|
||||
foreach($extra_var_groups as $group) {
|
||||
$extra_vars = $group->var;
|
||||
if(!is_array($group->var)) $extra_vars = array($group->var);
|
||||
|
||||
foreach($extra_vars as $key => $val) {
|
||||
unset($obj);
|
||||
|
||||
$obj->group = $group->title->body;
|
||||
$obj->name = $val->attrs->name;
|
||||
$obj->title = $val->title->body;
|
||||
$obj->type = $val->type->body ? $val->type->body : 'text';
|
||||
$obj->description = $val->description->body;
|
||||
if($obj->name)
|
||||
{
|
||||
$obj->value = $extra_vals->{$obj->name};
|
||||
}
|
||||
if(strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); }
|
||||
if($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); }
|
||||
// 'Select'type obtained from the option list.
|
||||
if($val->options && !is_array($val->options))
|
||||
{
|
||||
$val->options = array($val->options);
|
||||
}
|
||||
|
||||
for($i = 0, $c = count($val->options); $i < $c; $i++) {
|
||||
$obj->options[$i]->title = $val->options[$i]->title->body;
|
||||
$obj->options[$i]->value = $val->options[$i]->value->body;
|
||||
}
|
||||
|
||||
$addon_info->extra_vars[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $addon_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns activated addon list
|
||||
*
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @return array Returns list
|
||||
**/
|
||||
function getInsertedAddons($site_srl = 0, $gtype = 'site') {
|
||||
$args->list_order = 'addon';
|
||||
if($gtype == 'global') $output = executeQuery('addon.getAddons', $args);
|
||||
else {
|
||||
$args->site_srl = $site_srl;
|
||||
$output = executeQuery('addon.getSiteAddons', $args);
|
||||
}
|
||||
if(!$output->data) return array();
|
||||
if(!is_array($output->data)) $output->data = array($output->data);
|
||||
|
||||
$activated_count = count($output->data);
|
||||
for($i=0;$i<$activated_count;$i++) {
|
||||
$addon = $output->data[$i];
|
||||
$addon_list[$addon->addon] = $addon;
|
||||
}
|
||||
return $addon_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether to activate
|
||||
*
|
||||
* @param string $addon Name to check
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $type pc or mobile
|
||||
* @param string $gtype site or global
|
||||
* @return bool If addon is activated returns true. Otherwise returns false.
|
||||
**/
|
||||
function isActivatedAddon($addon, $site_srl = 0, $type = "pc", $gtype = 'site') {
|
||||
$args->addon = $addon;
|
||||
if($gtype == 'global') {
|
||||
if($type == "pc") $output = executeQuery('addon.getAddonIsActivated', $args);
|
||||
else $output = executeQuery('addon.getMAddonIsActivated', $args);
|
||||
for($i = 0, $c = count($val->options); $i < $c; $i++)
|
||||
{
|
||||
$obj->options[$i]->title = $val->options[$i]->title->body;
|
||||
$obj->options[$i]->value = $val->options[$i]->value->body;
|
||||
}
|
||||
$addon_info->extra_vars[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$args->site_srl = $site_srl;
|
||||
if($type == "pc") $output = executeQuery('addon.getSiteAddonIsActivated', $args);
|
||||
else $output = executeQuery('addon.getSiteMAddonIsActivated', $args);
|
||||
}
|
||||
if($output->data->count>0) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $addon_info;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* Returns activated addon list
|
||||
*
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @return array Returns list
|
||||
*/
|
||||
function getInsertedAddons($site_srl = 0, $gtype = 'site')
|
||||
{
|
||||
$args->list_order = 'addon';
|
||||
if($gtype == 'global') $output = executeQuery('addon.getAddons', $args);
|
||||
else
|
||||
{
|
||||
$args->site_srl = $site_srl;
|
||||
$output = executeQuery('addon.getSiteAddons', $args);
|
||||
}
|
||||
if(!$output->data) return array();
|
||||
if(!is_array($output->data)) $output->data = array($output->data);
|
||||
|
||||
$activated_count = count($output->data);
|
||||
for($i=0;$i<$activated_count;$i++)
|
||||
{
|
||||
$addon = $output->data[$i];
|
||||
$addon_list[$addon->addon] = $addon;
|
||||
}
|
||||
return $addon_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether to activate
|
||||
*
|
||||
* @param string $addon Name to check
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $type pc or mobile
|
||||
* @param string $gtype site or global
|
||||
* @return bool If addon is activated returns true. Otherwise returns false.
|
||||
*/
|
||||
function isActivatedAddon($addon, $site_srl = 0, $type = "pc", $gtype = 'site')
|
||||
{
|
||||
$args->addon = $addon;
|
||||
if($gtype == 'global')
|
||||
{
|
||||
if($type == "pc") $output = executeQuery('addon.getAddonIsActivated', $args);
|
||||
else $output = executeQuery('addon.getMAddonIsActivated', $args);
|
||||
}
|
||||
else
|
||||
{
|
||||
$args->site_srl = $site_srl;
|
||||
if($type == "pc") $output = executeQuery('addon.getSiteAddonIsActivated', $args);
|
||||
else $output = executeQuery('addon.getSiteMAddonIsActivated', $args);
|
||||
}
|
||||
if($output->data->count>0) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* End of file addon.admin.model.php */
|
||||
/* Location: ./modules/addon/addon.admin.model.php */
|
||||
|
|
|
|||
|
|
@ -1,115 +1,124 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin view class of addon modules
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
class addonAdminView extends addon {
|
||||
/**
|
||||
* Admin view class of addon modules
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
*/
|
||||
class addonAdminView extends addon
|
||||
{
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function init() {
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
}
|
||||
/**
|
||||
* Add Management main page (showing the list)
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function dispAddonAdminIndex()
|
||||
{
|
||||
$oAdminModel = &getAdminModel('admin');
|
||||
|
||||
/**
|
||||
* Add Management main page (showing the list)
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function dispAddonAdminIndex() {
|
||||
$oAdminModel = &getAdminModel('admin');
|
||||
// Add to the list settings
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
$addon_list = $oAddonModel->getAddonListForSuperAdmin();
|
||||
|
||||
// Add to the list settings
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
$addon_list = $oAddonModel->getAddonListForSuperAdmin();
|
||||
$security = new Security($addon_list);
|
||||
$addon_list = $security->encodeHTML('..', '..author..');
|
||||
|
||||
$security = new Security($addon_list);
|
||||
$addon_list = $security->encodeHTML('..', '..author..');
|
||||
foreach($addon_list as $no => $addon_info)
|
||||
{
|
||||
$addon_list[$no]->description = nl2br(trim($addon_info->description));
|
||||
}
|
||||
|
||||
foreach($addon_list as $no => $addon_info)
|
||||
Context::set('addon_list', $addon_list);
|
||||
Context::set('addon_count', count($addon_list));
|
||||
// Template specifies the path and file
|
||||
$this->setTemplateFile('addon_list');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display setup page
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function dispAddonAdminSetup()
|
||||
{
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
// Wanted to add the requested
|
||||
$selected_addon = Context::get('selected_addon');
|
||||
// Wanted to add the requested information
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
$addon_info = $oAddonModel->getAddonInfoXml($selected_addon, $site_module_info->site_srl, 'site');
|
||||
Context::set('addon_info', $addon_info);
|
||||
// Get a mid list
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleAdminModel = &getAdminModel('module');
|
||||
|
||||
if($site_module_info->site_srl) $args->site_srl = $site_module_info->site_srl;
|
||||
$columnList = array('module_srl', 'module_category_srl', 'mid', 'browser_title');
|
||||
$mid_list = $oModuleModel->getMidList($args, $columnList);
|
||||
// module_category and module combination
|
||||
if(!$site_module_info->site_srl)
|
||||
{
|
||||
// Get a list of module categories
|
||||
$module_categories = $oModuleModel->getModuleCategories();
|
||||
|
||||
if(is_array($mid_list))
|
||||
{
|
||||
$addon_list[$no]->description = nl2br(trim($addon_info->description));
|
||||
foreach($mid_list as $module_srl => $module)
|
||||
{
|
||||
$module_categories[$module->module_category_srl]->list[$module_srl] = $module;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$module_categories[0]->list = $mid_list;
|
||||
}
|
||||
|
||||
Context::set('addon_list', $addon_list);
|
||||
Context::set('addon_count', count($addon_list));
|
||||
// Template specifies the path and file
|
||||
$this->setTemplateFile('addon_list');
|
||||
}
|
||||
Context::set('mid_list',$module_categories);
|
||||
|
||||
/**
|
||||
* Display setup page
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function dispAddonAdminSetup() {
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
// Wanted to add the requested
|
||||
$selected_addon = Context::get('selected_addon');
|
||||
// Wanted to add the requested information
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
$addon_info = $oAddonModel->getAddonInfoXml($selected_addon, $site_module_info->site_srl, 'site');
|
||||
Context::set('addon_info', $addon_info);
|
||||
// Get a mid list
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleAdminModel = &getAdminModel('module');
|
||||
// Template specifies the path and file
|
||||
$this->setTemplateFile('setup_addon');
|
||||
|
||||
if($site_module_info->site_srl) $args->site_srl = $site_module_info->site_srl;
|
||||
$columnList = array('module_srl', 'module_category_srl', 'mid', 'browser_title');
|
||||
$mid_list = $oModuleModel->getMidList($args, $columnList);
|
||||
// module_category and module combination
|
||||
if(!$site_module_info->site_srl) {
|
||||
// Get a list of module categories
|
||||
$module_categories = $oModuleModel->getModuleCategories();
|
||||
if(Context::get('module') != 'admin')
|
||||
{
|
||||
$this->setLayoutPath('./common/tpl');
|
||||
$this->setLayoutFile('popup_layout');
|
||||
}
|
||||
|
||||
if(is_array($mid_list)) {
|
||||
foreach($mid_list as $module_srl => $module) {
|
||||
$module_categories[$module->module_category_srl]->list[$module_srl] = $module;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$module_categories[0]->list = $mid_list;
|
||||
}
|
||||
$security = new Security();
|
||||
$security->encodeHTML('addon_info.', 'addon_info.author..', 'mid_list....');
|
||||
}
|
||||
|
||||
Context::set('mid_list',$module_categories);
|
||||
/**
|
||||
* Display information
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function dispAddonAdminInfo()
|
||||
{
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
// Wanted to add the requested
|
||||
$selected_addon = Context::get('selected_addon');
|
||||
// Wanted to add the requested information
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
$addon_info = $oAddonModel->getAddonInfoXml($selected_addon, $site_module_info->site_srl);
|
||||
Context::set('addon_info', $addon_info);
|
||||
// Set the layout to be pop-up
|
||||
$this->setLayoutFile('popup_layout');
|
||||
// Template specifies the path and file
|
||||
$this->setTemplateFile('addon_info');
|
||||
|
||||
// Template specifies the path and file
|
||||
$this->setTemplateFile('setup_addon');
|
||||
|
||||
if(Context::get('module') != 'admin')
|
||||
{
|
||||
$this->setLayoutPath('./common/tpl');
|
||||
$this->setLayoutFile('popup_layout');
|
||||
}
|
||||
|
||||
$security = new Security();
|
||||
$security->encodeHTML('addon_info.', 'addon_info.author..', 'mid_list....');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display information
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function dispAddonAdminInfo() {
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
// Wanted to add the requested
|
||||
$selected_addon = Context::get('selected_addon');
|
||||
// Wanted to add the requested information
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
$addon_info = $oAddonModel->getAddonInfoXml($selected_addon, $site_module_info->site_srl);
|
||||
Context::set('addon_info', $addon_info);
|
||||
// Set the layout to be pop-up
|
||||
$this->setLayoutFile('popup_layout');
|
||||
// Template specifies the path and file
|
||||
$this->setTemplateFile('addon_info');
|
||||
|
||||
$security = new Security();
|
||||
$security->encodeHTML('addon_info.', 'addon_info.author..');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
$security = new Security();
|
||||
$security->encodeHTML('addon_info.', 'addon_info.author..');
|
||||
}
|
||||
}
|
||||
/* End of file addon.admin.view.php */
|
||||
/* Location: ./modules/addon/addon.admin.view.php */
|
||||
|
|
|
|||
|
|
@ -1,93 +1,100 @@
|
|||
<?php
|
||||
/**
|
||||
* High class of addon modules
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
class addon extends ModuleObject {
|
||||
/**
|
||||
* High class of addon modules
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
*/
|
||||
class addon extends ModuleObject
|
||||
{
|
||||
/**
|
||||
* Implement if additional tasks are necessary when installing
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function moduleInstall()
|
||||
{
|
||||
// Register to add a few
|
||||
$oAddonController = &getAdminController('addon');
|
||||
$oAddonController->doInsert('autolink', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('blogapi');
|
||||
$oAddonController->doInsert('counter', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('member_communication', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('member_extra_info', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('mobile', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('resize_image', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('openid_delegation_id');
|
||||
$oAddonController->doInsert('point_level_icon');
|
||||
|
||||
/**
|
||||
* Implement if additional tasks are necessary when installing
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function moduleInstall() {
|
||||
// Register to add a few
|
||||
$oAddonController = &getAdminController('addon');
|
||||
$oAddonController->doInsert('autolink', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('blogapi');
|
||||
$oAddonController->doInsert('counter', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('member_communication', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('member_extra_info', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('mobile', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('resize_image', 0, 'site', 'Y');
|
||||
$oAddonController->doInsert('openid_delegation_id');
|
||||
$oAddonController->doInsert('point_level_icon');
|
||||
$oAddonController->makeCacheFile(0);
|
||||
return new Object();
|
||||
}
|
||||
|
||||
$oAddonController->makeCacheFile(0);
|
||||
return new Object();
|
||||
}
|
||||
/**
|
||||
* A method to check if successfully installed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function checkUpdate()
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
if(!$oDB->isColumnExists("addons", "is_used_m")) return true;
|
||||
if(!$oDB->isColumnExists("addons_site", "is_used_m")) return true;
|
||||
|
||||
/**
|
||||
* A method to check if successfully installed
|
||||
*
|
||||
* @return bool
|
||||
**/
|
||||
function checkUpdate() {
|
||||
$oDB = &DB::getInstance();
|
||||
if(!$oDB->isColumnExists("addons", "is_used_m")) return true;
|
||||
if(!$oDB->isColumnExists("addons_site", "is_used_m")) return true;
|
||||
// 2011. 7. 29. add is_fixed column
|
||||
if(!$oDB->isColumnExists('addons', 'is_fixed')) return true;
|
||||
|
||||
// 2011. 7. 29. add is_fixed column
|
||||
if (!$oDB->isColumnExists('addons', 'is_fixed')) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Execute update
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function moduleUpdate()
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
if(!$oDB->isColumnExists("addons", "is_used_m"))
|
||||
{
|
||||
$oDB->addColumn("addons", "is_used_m", "char", 1, "N", true);
|
||||
}
|
||||
if(!$oDB->isColumnExists("addons_site", "is_used_m"))
|
||||
{
|
||||
$oDB->addColumn("addons_site", "is_used_m", "char", 1, "N", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute update
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function moduleUpdate() {
|
||||
$oDB = &DB::getInstance();
|
||||
if(!$oDB->isColumnExists("addons", "is_used_m")) {
|
||||
$oDB->addColumn("addons", "is_used_m", "char", 1, "N", true);
|
||||
}
|
||||
if(!$oDB->isColumnExists("addons_site", "is_used_m")) {
|
||||
$oDB->addColumn("addons_site", "is_used_m", "char", 1, "N", true);
|
||||
}
|
||||
// 2011. 7. 29. add is_fixed column
|
||||
if(!$oDB->isColumnExists('addons', 'is_fixed'))
|
||||
{
|
||||
$oDB->addColumn('addons', 'is_fixed', 'char', 1, 'N', true);
|
||||
|
||||
// 2011. 7. 29. add is_fixed column
|
||||
if (!$oDB->isColumnExists('addons', 'is_fixed'))
|
||||
// move addon info to addon_site table
|
||||
$output = executeQueryArray('addon.getAddons');
|
||||
if($output->data)
|
||||
{
|
||||
$oDB->addColumn('addons', 'is_fixed', 'char', 1, 'N', true);
|
||||
|
||||
// move addon info to addon_site table
|
||||
$output = executeQueryArray('addon.getAddons');
|
||||
if ($output->data)
|
||||
foreach($output->data as $row)
|
||||
{
|
||||
foreach($output->data as $row)
|
||||
{
|
||||
$args->site_srl = 0;
|
||||
$args->addon = $row->addon;
|
||||
$args->is_used = $row->is_used;
|
||||
$args->is_used_m = $row->is_used_m;
|
||||
$args->extra_vars = $row->extra_vars;
|
||||
executeQuery('addon.insertSiteAddon', $args);
|
||||
}
|
||||
$args->site_srl = 0;
|
||||
$args->addon = $row->addon;
|
||||
$args->is_used = $row->is_used;
|
||||
$args->is_used_m = $row->is_used_m;
|
||||
$args->extra_vars = $row->extra_vars;
|
||||
executeQuery('addon.insertSiteAddon', $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Object(0, 'success_updated');
|
||||
}
|
||||
return new Object(0, 'success_updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-generate the cache file
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function recompileCache() {
|
||||
}
|
||||
/**
|
||||
* Re-generate the cache file
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function recompileCache()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
}
|
||||
/* End of file addon.class.php */
|
||||
/* Location: ./modules/addon/addon.class.php */
|
||||
|
|
|
|||
|
|
@ -1,244 +1,251 @@
|
|||
<?php
|
||||
/**
|
||||
* Addon module's controller class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
class addonController extends addon {
|
||||
/**
|
||||
* Addon module's controller class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
*/
|
||||
class addonController extends addon
|
||||
{
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
/**
|
||||
* Returns a cache file path
|
||||
*
|
||||
* @param $type pc or mobile
|
||||
* @return string Returns a path
|
||||
*/
|
||||
function getCacheFilePath($type = "pc")
|
||||
{
|
||||
static $addon_file;
|
||||
if(isset($addon_file)) return $addon_file;
|
||||
|
||||
/**
|
||||
* Returns a cache file path
|
||||
*
|
||||
* @param $type pc or mobile
|
||||
* @return string Returns a path
|
||||
**/
|
||||
function getCacheFilePath($type = "pc") {
|
||||
static $addon_file;
|
||||
if(isset($addon_file)) return $addon_file;
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
$site_srl = $site_module_info->site_srl;
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
$site_srl = $site_module_info->site_srl;
|
||||
$addon_path = _XE_PATH_.'files/cache/addons/';
|
||||
|
||||
$addon_path = _XE_PATH_.'files/cache/addons/';
|
||||
$addon_file = $addon_path.$site_srl.$type.'.acivated_addons.cache.php';
|
||||
|
||||
$addon_file = $addon_path.$site_srl.$type.'.acivated_addons.cache.php';
|
||||
if($this->addon_file_called) return $addon_file;
|
||||
$this->addon_file_called = true;
|
||||
|
||||
if($this->addon_file_called) return $addon_file;
|
||||
$this->addon_file_called = true;
|
||||
if(!is_dir($addon_path)) FileHandler::makeDir($addon_path);
|
||||
if(!file_exists($addon_file)) $this->makeCacheFile($site_srl, $type);
|
||||
return $addon_file;
|
||||
}
|
||||
|
||||
if(!is_dir($addon_path)) FileHandler::makeDir($addon_path);
|
||||
if(!file_exists($addon_file)) $this->makeCacheFile($site_srl, $type);
|
||||
return $addon_file;
|
||||
}
|
||||
/**
|
||||
* Returns mid list that addons is run
|
||||
*
|
||||
* @param string $selected_addon Name to get list
|
||||
* @param int $site_srl Site srl
|
||||
* @return string[] Returns list that contain mid
|
||||
*/
|
||||
function _getMidList($selected_addon, $site_srl = 0)
|
||||
{
|
||||
$oAddonAdminModel = &getAdminModel('addon');
|
||||
$addon_info = $oAddonAdminModel->getAddonInfoXml($selected_addon, $site_srl);
|
||||
return $addon_info->mid_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mid into running mid list
|
||||
*
|
||||
* @param string $selected_addon Addon name to add mid
|
||||
* @param string $mid Module id to add
|
||||
* @param int $site_srl Site srl
|
||||
* @return void
|
||||
*/
|
||||
function _setAddMid($selected_addon,$mid, $site_srl=0)
|
||||
{
|
||||
// Wanted to add the requested information
|
||||
$mid_list = $this->_getMidList($selected_addon, $site_srl);
|
||||
|
||||
/**
|
||||
* Returns mid list that addons is run
|
||||
*
|
||||
* @param string $selected_addon Name to get list
|
||||
* @param int $site_srl Site srl
|
||||
* @return string[] Returns list that contain mid
|
||||
**/
|
||||
function _getMidList($selected_addon, $site_srl = 0) {
|
||||
$mid_list[] = $mid;
|
||||
$new_mid_list = array_unique($mid_list);
|
||||
$this->_setMid($selected_addon,$new_mid_list, $site_srl);
|
||||
}
|
||||
|
||||
$oAddonAdminModel = &getAdminModel('addon');
|
||||
$addon_info = $oAddonAdminModel->getAddonInfoXml($selected_addon, $site_srl);
|
||||
return $addon_info->mid_list;
|
||||
}
|
||||
/**
|
||||
* Deletes mid from running mid list
|
||||
*
|
||||
* @param string $selected_addon Addon name to delete mid
|
||||
* @param string $mid Module id to delete
|
||||
* @param int $site_srl Site srl
|
||||
* @return void
|
||||
*/
|
||||
function _setDelMid($selected_addon,$mid,$site_srl=0)
|
||||
{
|
||||
// Wanted to add the requested information
|
||||
$mid_list = $this->_getMidList($selected_addon,$site_srl);
|
||||
|
||||
$new_mid_list = array();
|
||||
if(is_array($mid_list))
|
||||
{
|
||||
for($i=0,$c=count($mid_list);$i<$c;$i++)
|
||||
{
|
||||
if($mid_list[$i] != $mid) $new_mid_list[] = $mid_list[$i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_mid_list[] = $mid;
|
||||
}
|
||||
|
||||
$this->_setMid($selected_addon,$new_mid_list,$site_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mid into running mid list
|
||||
*
|
||||
* @param string $selected_addon Addon name to add mid
|
||||
* @param string $mid Module id to add
|
||||
* @param int $site_srl Site srl
|
||||
* @return void
|
||||
**/
|
||||
function _setAddMid($selected_addon,$mid, $site_srl=0) {
|
||||
// Wanted to add the requested information
|
||||
$mid_list = $this->_getMidList($selected_addon, $site_srl);
|
||||
/**
|
||||
* Set running mid list
|
||||
*
|
||||
* @param string $selected_addon Addon name to set
|
||||
* @param string[] $mid_list List to set
|
||||
* @param int $site_srl Site srl
|
||||
* @return void
|
||||
*/
|
||||
function _setMid($selected_addon,$mid_list,$site_srl=0)
|
||||
{
|
||||
$args->mid_list = join('|@|',$mid_list);
|
||||
$this->doSetup($selected_addon, $args,$site_srl);
|
||||
$this->makeCacheFile($site_srl);
|
||||
}
|
||||
|
||||
$mid_list[] = $mid;
|
||||
$new_mid_list = array_unique($mid_list);
|
||||
$this->_setMid($selected_addon,$new_mid_list, $site_srl);
|
||||
}
|
||||
/**
|
||||
* Adds mid into running mid list
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function procAddonSetupAddonAddMid()
|
||||
{
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
$args = Context::getRequestVars();
|
||||
$addon_name = $args->addon_name;
|
||||
$mid = $args->mid;
|
||||
$this->_setAddMid($addon_name,$mid,$site_module_info->site_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes mid from running mid list
|
||||
*
|
||||
* @param string $selected_addon Addon name to delete mid
|
||||
* @param string $mid Module id to delete
|
||||
* @param int $site_srl Site srl
|
||||
* @return void
|
||||
**/
|
||||
function _setDelMid($selected_addon,$mid,$site_srl=0) {
|
||||
// Wanted to add the requested information
|
||||
$mid_list = $this->_getMidList($selected_addon,$site_srl);
|
||||
/**
|
||||
* Deletes mid from running mid list
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
function procAddonSetupAddonDelMid()
|
||||
{
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
$new_mid_list = array();
|
||||
if(is_array($mid_list)){
|
||||
for($i=0,$c=count($mid_list);$i<$c;$i++){
|
||||
if($mid_list[$i] != $mid) $new_mid_list[] = $mid_list[$i];
|
||||
}
|
||||
}else{
|
||||
$new_mid_list[] = $mid;
|
||||
}
|
||||
$args = Context::getRequestVars();
|
||||
$addon_name = $args->addon_name;
|
||||
$mid = $args->mid;
|
||||
|
||||
$this->_setDelMid($addon_name,$mid,$site_module_info->site_srl);
|
||||
}
|
||||
|
||||
$this->_setMid($selected_addon,$new_mid_list,$site_srl);
|
||||
}
|
||||
/**
|
||||
* Re-generate the cache file
|
||||
*
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $type pc or mobile
|
||||
* @param string $gtype site or global
|
||||
* @return void
|
||||
*/
|
||||
function makeCacheFile($site_srl = 0, $type = "pc", $gtype = 'site')
|
||||
{
|
||||
// Add-on module for use in creating the cache file
|
||||
$buff = "";
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
$addon_list = $oAddonModel->getInsertedAddons($site_srl, $gtype);
|
||||
foreach($addon_list as $addon => $val)
|
||||
{
|
||||
if($val->addon == "smartphone") continue;
|
||||
if(!is_dir(_XE_PATH_.'addons/'.$addon)) continue;
|
||||
if(($type == "pc" && $val->is_used != 'Y') || ($type == "mobile" && $val->is_used_m != 'Y') || ($gtype == 'global' && $val->is_fixed != 'Y')) continue;
|
||||
|
||||
/**
|
||||
* Set running mid list
|
||||
*
|
||||
* @param string $selected_addon Addon name to set
|
||||
* @param string[] $mid_list List to set
|
||||
* @param int $site_srl Site srl
|
||||
* @return void
|
||||
**/
|
||||
function _setMid($selected_addon,$mid_list,$site_srl=0) {
|
||||
$args->mid_list = join('|@|',$mid_list);
|
||||
$this->doSetup($selected_addon, $args,$site_srl);
|
||||
$this->makeCacheFile($site_srl);
|
||||
}
|
||||
$extra_vars = unserialize($val->extra_vars);
|
||||
$mid_list = $extra_vars->mid_list;
|
||||
if(!is_array($mid_list)||!count($mid_list)) $mid_list = null;
|
||||
|
||||
|
||||
/**
|
||||
* Adds mid into running mid list
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function procAddonSetupAddonAddMid() {
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
$args = Context::getRequestVars();
|
||||
$addon_name = $args->addon_name;
|
||||
$mid = $args->mid;
|
||||
$this->_setAddMid($addon_name,$mid,$site_module_info->site_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes mid from running mid list
|
||||
*
|
||||
* @return Object
|
||||
**/
|
||||
function procAddonSetupAddonDelMid() {
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
$args = Context::getRequestVars();
|
||||
$addon_name = $args->addon_name;
|
||||
$mid = $args->mid;
|
||||
|
||||
$this->_setDelMid($addon_name,$mid,$site_module_info->site_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-generate the cache file
|
||||
*
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $type pc or mobile
|
||||
* @param string $gtype site or global
|
||||
* @return void
|
||||
**/
|
||||
function makeCacheFile($site_srl = 0, $type = "pc", $gtype = 'site') {
|
||||
// Add-on module for use in creating the cache file
|
||||
$buff = "";
|
||||
$oAddonModel = &getAdminModel('addon');
|
||||
$addon_list = $oAddonModel->getInsertedAddons($site_srl, $gtype);
|
||||
foreach($addon_list as $addon => $val) {
|
||||
if($val->addon == "smartphone") continue;
|
||||
if(!is_dir(_XE_PATH_.'addons/'.$addon)) continue;
|
||||
if(($type == "pc" && $val->is_used != 'Y') || ($type == "mobile" && $val->is_used_m != 'Y') || ($gtype == 'global' && $val->is_fixed != 'Y')) continue;
|
||||
|
||||
$extra_vars = unserialize($val->extra_vars);
|
||||
$mid_list = $extra_vars->mid_list;
|
||||
if(!is_array($mid_list)||!count($mid_list)) $mid_list = null;
|
||||
|
||||
$buff .= '$rm = \'' . $extra_vars->xe_run_method . "';";
|
||||
$buff .= '$ml = array(';
|
||||
if($mid_list)
|
||||
$buff .= '$rm = \'' . $extra_vars->xe_run_method . "';";
|
||||
$buff .= '$ml = array(';
|
||||
if($mid_list)
|
||||
{
|
||||
foreach($mid_list as $mid)
|
||||
{
|
||||
foreach($mid_list as $mid)
|
||||
{
|
||||
$buff .= "'$mid' => 1,";
|
||||
}
|
||||
$buff .= "'$mid' => 1,";
|
||||
}
|
||||
$buff .= ');';
|
||||
$buff .= sprintf('$addon_file = \'./addons/%s/%s.addon.php\';', $addon, $addon);
|
||||
}
|
||||
$buff .= ');';
|
||||
$buff .= sprintf('$addon_file = \'./addons/%s/%s.addon.php\';', $addon, $addon);
|
||||
|
||||
if($val->extra_vars) {
|
||||
unset($extra_vars);
|
||||
$extra_vars = base64_encode($val->extra_vars);
|
||||
}
|
||||
$addon_include = sprintf('unset($addon_info); $addon_info = unserialize(base64_decode(\'%s\')); @include($addon_file);', $extra_vars);
|
||||
if($val->extra_vars)
|
||||
{
|
||||
unset($extra_vars);
|
||||
$extra_vars = base64_encode($val->extra_vars);
|
||||
}
|
||||
$addon_include = sprintf('unset($addon_info); $addon_info = unserialize(base64_decode(\'%s\')); @include($addon_file);', $extra_vars);
|
||||
|
||||
$buff .= 'if(file_exists($addon_file)){';
|
||||
$buff .= 'if($rm === \'no_run_selected\'){';
|
||||
$buff .= 'if(!isset($ml[$_m])){';
|
||||
$buff .= $addon_include;
|
||||
$buff .= '}}else{';
|
||||
$buff .= 'if(isset($ml[$_m]) || count($ml) === 0){';
|
||||
$buff .= $addon_include;
|
||||
$buff .= '}}}';
|
||||
}
|
||||
$buff .= 'if(file_exists($addon_file)){';
|
||||
$buff .= 'if($rm === \'no_run_selected\'){';
|
||||
$buff .= 'if(!isset($ml[$_m])){';
|
||||
$buff .= $addon_include;
|
||||
$buff .= '}}else{';
|
||||
$buff .= 'if(isset($ml[$_m]) || count($ml) === 0){';
|
||||
$buff .= $addon_include;
|
||||
$buff .= '}}}';
|
||||
}
|
||||
|
||||
$buff = sprintf('<?php if(!defined("__XE__")) exit(); $_m = Context::get(\'mid\'); %s ?>', $buff);
|
||||
$buff = sprintf('<?php if(!defined("__XE__")) exit(); $_m = Context::get(\'mid\'); %s ?>', $buff);
|
||||
|
||||
$addon_path = _XE_PATH_.'files/cache/addons/';
|
||||
if(!is_dir($addon_path)) FileHandler::makeDir($addon_path);
|
||||
$addon_path = _XE_PATH_.'files/cache/addons/';
|
||||
if(!is_dir($addon_path)) FileHandler::makeDir($addon_path);
|
||||
|
||||
if($gtype == 'site') $addon_file = $addon_path.$site_srl.$type.'.acivated_addons.cache.php';
|
||||
else $addon_file = $addon_path.$type.'.acivated_addons.cache.php';
|
||||
if($gtype == 'site') $addon_file = $addon_path.$site_srl.$type.'.acivated_addons.cache.php';
|
||||
else $addon_file = $addon_path.$type.'.acivated_addons.cache.php';
|
||||
|
||||
FileHandler::writeFile($addon_file, $buff);
|
||||
}
|
||||
FileHandler::writeFile($addon_file, $buff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save setup
|
||||
*
|
||||
* @param string $addon Addon name
|
||||
* @param object $extra_vars Extra variables
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @return Object
|
||||
**/
|
||||
function doSetup($addon, $extra_vars,$site_srl=0, $gtype = 'site') {
|
||||
if(!is_array($extra_vars->mid_list)) unset($extra_vars->mid_list);
|
||||
/**
|
||||
* Save setup
|
||||
*
|
||||
* @param string $addon Addon name
|
||||
* @param object $extra_vars Extra variables
|
||||
* @param int $site_srl Site srl
|
||||
* @param string $gtype site or global
|
||||
* @return Object
|
||||
*/
|
||||
function doSetup($addon, $extra_vars,$site_srl=0, $gtype = 'site')
|
||||
{
|
||||
if(!is_array($extra_vars->mid_list)) unset($extra_vars->mid_list);
|
||||
|
||||
$args->addon = $addon;
|
||||
$args->extra_vars = serialize($extra_vars);
|
||||
if($gtype == 'global') return executeQuery('addon.updateAddon', $args);
|
||||
$args->site_srl = $site_srl;
|
||||
return executeQuery('addon.updateSiteAddon', $args);
|
||||
}
|
||||
$args->addon = $addon;
|
||||
$args->extra_vars = serialize($extra_vars);
|
||||
if($gtype == 'global') return executeQuery('addon.updateAddon', $args);
|
||||
$args->site_srl = $site_srl;
|
||||
return executeQuery('addon.updateSiteAddon', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove add-on information in the virtual site
|
||||
*
|
||||
* @param int $site_srl Site srl
|
||||
* @return void
|
||||
**/
|
||||
function removeAddonConfig($site_srl) {
|
||||
$addon_path = _XE_PATH_.'files/cache/addons/';
|
||||
$addon_file = $addon_path.$site_srl.'.acivated_addons.cache.php';
|
||||
if(file_exists($addon_file)) FileHandler::removeFile($addon_file);
|
||||
/**
|
||||
* Remove add-on information in the virtual site
|
||||
*
|
||||
* @param int $site_srl Site srl
|
||||
* @return void
|
||||
*/
|
||||
function removeAddonConfig($site_srl)
|
||||
{
|
||||
$addon_path = _XE_PATH_.'files/cache/addons/';
|
||||
$addon_file = $addon_path.$site_srl.'.acivated_addons.cache.php';
|
||||
if(file_exists($addon_file)) FileHandler::removeFile($addon_file);
|
||||
|
||||
$args->site_srl = $site_srl;
|
||||
executeQuery('addon.deleteSiteAddons', $args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
$args->site_srl = $site_srl;
|
||||
executeQuery('addon.deleteSiteAddons', $args);
|
||||
}
|
||||
}
|
||||
/* End of file addon.controller.php */
|
||||
/* Location: ./modules/addon/addon.controller.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue