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:
ovclas 2012-11-15 08:26:15 +00:00
parent 7928ad163b
commit da0146a8ae
5 changed files with 982 additions and 926 deletions

View file

@ -1,25 +1,27 @@
<?php <?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 * Admin controller class of addon modules
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
**/ */
class addonAdminController extends addonController { class addonAdminController extends addonController
{
/** /**
* Initialization * Initialization
* *
* @return void * @return void
**/ */
function init() { function init()
{
} }
/** /**
* Set addon activate * Set addon activate
* *
* @return Object * @return Object
**/ */
function procAddonAdminSaveActivate() function procAddonAdminSaveActivate()
{ {
$pcOnList = Context::get('pc_on'); $pcOnList = Context::get('pc_on');
@ -31,13 +33,13 @@
if($site_module_info->site_srl) $site_srl = $site_module_info->site_srl; if($site_module_info->site_srl) $site_srl = $site_module_info->site_srl;
else $site_srl = 0; else $site_srl = 0;
if (!$pcOnList) $pcOnList = array(); if(!$pcOnList) $pcOnList = array();
if (!$mobileOnList) $mobileOnList = array(); if(!$mobileOnList) $mobileOnList = array();
if (!$fixed) $fixed = array(); if(!$fixed) $fixed = array();
if (!is_array($pcOnList)) $pcOnList = array($pcOnList); if(!is_array($pcOnList)) $pcOnList = array($pcOnList);
if (!is_array($mobileOnList)) $pcOnList = array($mobileOnList); if(!is_array($mobileOnList)) $pcOnList = array($mobileOnList);
if (!is_array($fixed)) $pcOnList = array($fixed); if(!is_array($fixed)) $pcOnList = array($fixed);
// get current addon info // get current addon info
$oModel = &getAdminModel('addon'); $oModel = &getAdminModel('addon');
@ -47,19 +49,19 @@
$updateList = array(); $updateList = array();
foreach($currentAddonList as $addon) 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; $updateList[] = $addon->addon_name;
continue; continue;
} }
if ($addon->mactivated !== in_array($addon->addon_name, $mobileOnList)) if($addon->mactivated !== in_array($addon->addon_name, $mobileOnList))
{ {
$updateList[] = $addon->addon_name; $updateList[] = $addon->addon_name;
continue; continue;
} }
if ($addon->fixed !== in_array($addon->addon_name, $fixed)) if($addon->fixed !== in_array($addon->addon_name, $fixed))
{ {
$updateList[] = $addon->addon_name; $updateList[] = $addon->addon_name;
continue; continue;
@ -71,17 +73,17 @@
{ {
unset($args); unset($args);
if (in_array($targetAddon, $pcOnList)) if(in_array($targetAddon, $pcOnList))
$args->is_used = 'Y'; $args->is_used = 'Y';
else else
$args->is_used = 'N'; $args->is_used = 'N';
if (in_array($targetAddon, $mobileOnList)) if(in_array($targetAddon, $mobileOnList))
$args->is_used_m = 'Y'; $args->is_used_m = 'Y';
else else
$args->is_used_m = 'N'; $args->is_used_m = 'N';
if (in_array($targetAddon, $fixed)) if(in_array($targetAddon, $fixed))
$args->fixed = 'Y'; $args->fixed = 'Y';
else else
$args->fixed = 'N'; $args->fixed = 'N';
@ -93,14 +95,14 @@
if (!$output->toBool()) return $output; if (!$output->toBool()) return $output;
} }
if (count($updateList)) if(count($updateList))
{ {
$this->makeCacheFile($site_srl, 'pc', 'site'); $this->makeCacheFile($site_srl, 'pc', 'site');
$this->makeCacheFile($site_srl, 'mobile', 'site'); $this->makeCacheFile($site_srl, 'mobile', 'site');
} }
$this->setMessage('success_updated', 'info'); $this->setMessage('success_updated', 'info');
if (Context::get('success_return_url')) if(Context::get('success_return_url'))
{ {
$this->setRedirectUrl(Context::get('success_return_url')); $this->setRedirectUrl(Context::get('success_return_url'));
} }
@ -114,8 +116,9 @@
* Add active/inactive change * Add active/inactive change
* *
* @return Object * @return Object
**/ */
function procAddonAdminToggleActivate() { function procAddonAdminToggleActivate()
{
$oAddonModel = &getAdminModel('addon'); $oAddonModel = &getAdminModel('addon');
$site_module_info = Context::get('site_module_info'); $site_module_info = Context::get('site_module_info');
@ -123,7 +126,8 @@
$addon = Context::get('addon'); $addon = Context::get('addon');
$type = Context::get('type'); $type = Context::get('type');
if(!$type) $type = "pc"; if(!$type) $type = "pc";
if($addon) { if($addon)
{
// If enabled Disables // If enabled Disables
if($oAddonModel->isActivatedAddon($addon, $site_module_info->site_srl, $type)) $this->doDeactivate($addon, $site_module_info->site_srl, $type); if($oAddonModel->isActivatedAddon($addon, $site_module_info->site_srl, $type)) $this->doDeactivate($addon, $site_module_info->site_srl, $type);
// If it is disabled Activate // If it is disabled Activate
@ -137,8 +141,9 @@
* Add the configuration information input * Add the configuration information input
* *
* @return Object * @return Object
**/ */
function procAddonAdminSetupAddon() { function procAddonAdminSetupAddon()
{
$args = Context::getRequestVars(); $args = Context::getRequestVars();
$module = $args->module; $module = $args->module;
$addon_name = $args->addon_name; $addon_name = $args->addon_name;
@ -159,8 +164,6 @@
$this->setRedirectUrl(getNotEncodedUrl('', 'module', $module, 'act', 'dispAddonAdminSetup', 'selected_addon', $addon_name), $output); $this->setRedirectUrl(getNotEncodedUrl('', 'module', $module, 'act', 'dispAddonAdminSetup', 'selected_addon', $addon_name), $output);
} }
/** /**
* Adds addon to DB * Adds addon to DB
* *
@ -169,8 +172,9 @@
* @param string $gtype site or global * @param string $gtype site or global
* @param string $isUsed Whether to use * @param string $isUsed Whether to use
* @return Object * @return Object
**/ */
function doInsert($addon, $site_srl = 0, $gtype = 'site', $isUsed = 'N') { function doInsert($addon, $site_srl = 0, $gtype = 'site', $isUsed = 'N')
{
$args->addon = $addon; $args->addon = $addon;
$args->is_used = $isUsed; $args->is_used = $isUsed;
if($gtype == 'global') return executeQuery('addon.insertAddon', $args); if($gtype == 'global') return executeQuery('addon.insertAddon', $args);
@ -186,8 +190,9 @@
* @param string $type pc or modile * @param string $type pc or modile
* @param string $gtype site or global * @param string $gtype site or global
* @return Object * @return Object
**/ */
function doActivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site') { function doActivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site')
{
$args->addon = $addon; $args->addon = $addon;
if($type == "pc") $args->is_used = 'Y'; if($type == "pc") $args->is_used = 'Y';
else $args->is_used_m = "Y"; else $args->is_used_m = "Y";
@ -203,8 +208,9 @@
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @param string $type pc or mobile * @param string $type pc or mobile
* @param string $gtype site or global * @param string $gtype site or global
**/ */
function doDeactivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site') { function doDeactivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site')
{
$args->addon = $addon; $args->addon = $addon;
if($type == "pc") $args->is_used = 'N'; if($type == "pc") $args->is_used = 'N';
else $args->is_used_m = 'N'; else $args->is_used_m = 'N';
@ -212,5 +218,6 @@
$args->site_srl = $site_srl; $args->site_srl = $site_srl;
return executeQuery('addon.updateSiteAddon', $args); return executeQuery('addon.updateSiteAddon', $args);
} }
} }
?> /* End of file addon.admin.controller.php */
/* Location: ./modules/addon/addon.admin.controller.php */

View file

@ -1,16 +1,17 @@
<?php <?php
/** /**
* Admin model class of addon module * Admin model class of addon module
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
**/ */
class addonAdminModel extends addon { class addonAdminModel extends addon
{
/** /**
* Initialization * Initialization
* *
* @return void * @return void
**/ */
function init() { function init()
{
} }
/** /**
@ -18,8 +19,9 @@
* *
* @param string $addon_name Name to get path * @param string $addon_name Name to get path
* @return string Returns a path * @return string Returns a path
**/ */
function getAddonPath($addon_name) { function getAddonPath($addon_name)
{
$class_path = sprintf('./addons/%s/', $addon_name); $class_path = sprintf('./addons/%s/', $addon_name);
if(is_dir($class_path)) return $class_path; if(is_dir($class_path)) return $class_path;
return ""; return "";
@ -29,7 +31,7 @@
* Get addon list for super admin * Get addon list for super admin
* *
* @return Object * @return Object
**/ */
function getAddonListForSuperAdmin() function getAddonListForSuperAdmin()
{ {
$addonList = $this->getAddonList(0, 'site'); $addonList = $this->getAddonList(0, 'site');
@ -46,7 +48,7 @@
$addonList[$key]->need_update = $package[$packageSrl]->need_update; $addonList[$key]->need_update = $package[$packageSrl]->need_update;
// get easyinstall update url // get easyinstall update url
if ($addonList[$key]->need_update == 'Y') if($addonList[$key]->need_update == 'Y')
{ {
$addonList[$key]->update_url = $oAutoinstallModel->getUpdateUrlByPackageSrl($packageSrl); $addonList[$key]->update_url = $oAutoinstallModel->getUpdateUrlByPackageSrl($packageSrl);
} }
@ -61,8 +63,9 @@
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @param string $gtype site or global * @param string $gtype site or global
* @return array Returns addon list * @return array Returns addon list
**/ */
function getAddonList($site_srl = 0, $gtype = 'site') { function getAddonList($site_srl = 0, $gtype = 'site')
{
// Wanted to add a list of activated // Wanted to add a list of activated
$inserted_addons = $this->getInsertedAddons($site_srl, $gtype); $inserted_addons = $this->getInsertedAddons($site_srl, $gtype);
// Downloaded and installed add-on to the list of Wanted // Downloaded and installed add-on to the list of Wanted
@ -73,7 +76,8 @@
$oAddonAdminController = &getAdminController('addon'); $oAddonAdminController = &getAdminController('addon');
for($i=0;$i<$searched_count;$i++) { for($i=0;$i<$searched_count;$i++)
{
// Add the name of // Add the name of
$addon_name = $searched_list[$i]; $addon_name = $searched_list[$i];
if($addon_name == "smartphone") continue; if($addon_name == "smartphone") continue;
@ -89,11 +93,14 @@
$info->mactivated = false; $info->mactivated = false;
$info->fixed = false; $info->fixed = false;
// Check if a permossion is granted entered in DB // Check if a permossion is granted entered in DB
if(!in_array($addon_name, array_keys($inserted_addons))) { 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 .. ㅡ. ㅜ) // If not, type in the DB type (model, perhaps because of the hate doing this haneungeo .. ㅡ. ㅜ)
$oAddonAdminController->doInsert($addon_name, $site_srl, $type); $oAddonAdminController->doInsert($addon_name, $site_srl, $type);
// Is activated // Is activated
} else { }
else
{
if($inserted_addons[$addon_name]->is_used=='Y') $info->activated = true; if($inserted_addons[$addon_name]->is_used=='Y') $info->activated = true;
if($inserted_addons[$addon_name]->is_used_m=='Y') $info->mactivated = 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; if ($gtype == 'global' && $inserted_addons[$addon_name]->is_fixed == 'Y') $info->fixed = true;
@ -111,8 +118,9 @@
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @param string $gtype site or global * @param string $gtype site or global
* @return object Returns a information * @return object Returns a information
**/ */
function getAddonInfoXml($addon, $site_srl = 0, $gtype = 'site') { function getAddonInfoXml($addon, $site_srl = 0, $gtype = 'site')
{
// Get a path of the requested module. Return if not exists. // Get a path of the requested module. Return if not exists.
$addon_path = $this->getAddonPath($addon); $addon_path = $this->getAddonPath($addon);
if(!$addon_path) return; if(!$addon_path) return;
@ -126,19 +134,22 @@
if(!$xml_obj) return; if(!$xml_obj) return;
// DB is set to bring history // DB is set to bring history
$db_args->addon = $addon; $db_args->addon = $addon;
if($gtype == 'global') $output = executeQuery('addon.getAddonInfo',$db_args); if($gtype == 'global') $output = executeQuery('addon.getAddonInfo',$db_args);
else { else
{
$db_args->site_srl = $site_srl; $db_args->site_srl = $site_srl;
$output = executeQuery('addon.getSiteAddonInfo',$db_args); $output = executeQuery('addon.getSiteAddonInfo',$db_args);
} }
$extra_vals = unserialize($output->data->extra_vars); $extra_vals = unserialize($output->data->extra_vars);
if($extra_vals->mid_list) { if($extra_vals->mid_list)
{
$addon_info->mid_list = $extra_vals->mid_list; $addon_info->mid_list = $extra_vals->mid_list;
} else { }
else
{
$addon_info->mid_list = array(); $addon_info->mid_list = array();
} }
@ -147,9 +158,9 @@
$addon_info->xe_run_method = $extra_vals->xe_run_method; $addon_info->xe_run_method = $extra_vals->xe_run_method;
} }
// Add information // Add information
if($xml_obj->version && $xml_obj->attrs->version == '0.2') { if($xml_obj->version && $xml_obj->attrs->version == '0.2')
{
// addon format v0.2 // addon format v0.2
sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); 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->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
@ -165,7 +176,8 @@
if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author; if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author;
else $author_list = $xml_obj->author; else $author_list = $xml_obj->author;
foreach($author_list as $author) { foreach($author_list as $author)
{
unset($author_obj); unset($author_obj);
$author_obj->name = $author->name->body; $author_obj->name = $author->name->body;
$author_obj->email_address = $author->attrs->email_address; $author_obj->email_address = $author->attrs->email_address;
@ -174,16 +186,19 @@
} }
// Expand the variable order // Expand the variable order
if($xml_obj->extra_vars) { if($xml_obj->extra_vars)
{
$extra_var_groups = $xml_obj->extra_vars->group; $extra_var_groups = $xml_obj->extra_vars->group;
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars; if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars;
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups); if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups);
foreach($extra_var_groups as $group) { foreach($extra_var_groups as $group)
{
$extra_vars = $group->var; $extra_vars = $group->var;
if(!is_array($group->var)) $extra_vars = array($group->var); if(!is_array($group->var)) $extra_vars = array($group->var);
foreach($extra_vars as $key => $val) { foreach($extra_vars as $key => $val)
{
unset($obj); unset($obj);
if(!$val->attrs->type) { $val->attrs->type = 'text'; } if(!$val->attrs->type) { $val->attrs->type = 'text'; }
@ -205,7 +220,8 @@
$val->options = array($val->options); $val->options = array($val->options);
} }
for($i = 0, $c = count($val->options); $i < $c; $i++) { for($i = 0, $c = count($val->options); $i < $c; $i++)
{
$obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->title = $val->options[$i]->title->body;
$obj->options[$i]->value = $val->options[$i]->attrs->value; $obj->options[$i]->value = $val->options[$i]->attrs->value;
} }
@ -216,17 +232,21 @@
} }
// history // history
if($xml_obj->history) { if($xml_obj->history)
{
if(!is_array($xml_obj->history)) $history[] = $xml_obj->history; if(!is_array($xml_obj->history)) $history[] = $xml_obj->history;
else $history = $xml_obj->history; else $history = $xml_obj->history;
foreach($history as $item) { foreach($history as $item)
{
unset($obj); unset($obj);
if($item->author) { if($item->author)
{
(!is_array($item->author)) ? $obj->author_list[] = $item->author : $obj->author_list = $item->author; (!is_array($item->author)) ? $obj->author_list[] = $item->author : $obj->author_list = $item->author;
foreach($obj->author_list as $author) { foreach($obj->author_list as $author)
{
unset($author_obj); unset($author_obj);
$author_obj->name = $author->name->body; $author_obj->name = $author->name->body;
$author_obj->email_address = $author->attrs->email_address; $author_obj->email_address = $author->attrs->email_address;
@ -242,23 +262,24 @@
$obj->date = $item->attrs->date; $obj->date = $item->attrs->date;
$obj->description = $item->description->body; $obj->description = $item->description->body;
if($item->log) { if($item->log)
{
(!is_array($item->log)) ? $obj->log[] = $item->log : $obj->log = $item->log; (!is_array($item->log)) ? $obj->log[] = $item->log : $obj->log = $item->log;
foreach($obj->log as $log) { foreach($obj->log as $log)
{
unset($log_obj); unset($log_obj);
$log_obj->text = $log->body; $log_obj->text = $log->body;
$log_obj->link = $log->attrs->link; $log_obj->link = $log->attrs->link;
$obj->logs[] = $log_obj; $obj->logs[] = $log_obj;
} }
} }
$addon_info->history[] = $obj; $addon_info->history[] = $obj;
} }
} }
}
else
} else { {
// addon format 0.1 // addon format 0.1
$addon_info->addon_name = $addon; $addon_info->addon_name = $addon;
$addon_info->title = $xml_obj->title->body; $addon_info->title = $xml_obj->title->body;
@ -271,16 +292,19 @@
$author_obj->homepage = $xml_obj->author->attrs->link; $author_obj->homepage = $xml_obj->author->attrs->link;
$addon_info->author[] = $author_obj; $addon_info->author[] = $author_obj;
if($xml_obj->extra_vars) { if($xml_obj->extra_vars)
{
// Expand the variable order // Expand the variable order
$extra_var_groups = $xml_obj->extra_vars->group; $extra_var_groups = $xml_obj->extra_vars->group;
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars; if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars;
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups); if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups);
foreach($extra_var_groups as $group) { foreach($extra_var_groups as $group)
{
$extra_vars = $group->var; $extra_vars = $group->var;
if(!is_array($group->var)) $extra_vars = array($group->var); if(!is_array($group->var)) $extra_vars = array($group->var);
foreach($extra_vars as $key => $val) { foreach($extra_vars as $key => $val)
{
unset($obj); unset($obj);
$obj->group = $group->title->body; $obj->group = $group->title->body;
@ -300,20 +324,16 @@
$val->options = array($val->options); $val->options = array($val->options);
} }
for($i = 0, $c = count($val->options); $i < $c; $i++) { for($i = 0, $c = count($val->options); $i < $c; $i++)
{
$obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->title = $val->options[$i]->title->body;
$obj->options[$i]->value = $val->options[$i]->value->body; $obj->options[$i]->value = $val->options[$i]->value->body;
} }
$addon_info->extra_vars[] = $obj; $addon_info->extra_vars[] = $obj;
} }
} }
} }
} }
return $addon_info; return $addon_info;
} }
@ -323,11 +343,13 @@
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @param string $gtype site or global * @param string $gtype site or global
* @return array Returns list * @return array Returns list
**/ */
function getInsertedAddons($site_srl = 0, $gtype = 'site') { function getInsertedAddons($site_srl = 0, $gtype = 'site')
{
$args->list_order = 'addon'; $args->list_order = 'addon';
if($gtype == 'global') $output = executeQuery('addon.getAddons', $args); if($gtype == 'global') $output = executeQuery('addon.getAddons', $args);
else { else
{
$args->site_srl = $site_srl; $args->site_srl = $site_srl;
$output = executeQuery('addon.getSiteAddons', $args); $output = executeQuery('addon.getSiteAddons', $args);
} }
@ -335,7 +357,8 @@
if(!is_array($output->data)) $output->data = array($output->data); if(!is_array($output->data)) $output->data = array($output->data);
$activated_count = count($output->data); $activated_count = count($output->data);
for($i=0;$i<$activated_count;$i++) { for($i=0;$i<$activated_count;$i++)
{
$addon = $output->data[$i]; $addon = $output->data[$i];
$addon_list[$addon->addon] = $addon; $addon_list[$addon->addon] = $addon;
} }
@ -350,14 +373,17 @@
* @param string $type pc or mobile * @param string $type pc or mobile
* @param string $gtype site or global * @param string $gtype site or global
* @return bool If addon is activated returns true. Otherwise returns false. * @return bool If addon is activated returns true. Otherwise returns false.
**/ */
function isActivatedAddon($addon, $site_srl = 0, $type = "pc", $gtype = 'site') { function isActivatedAddon($addon, $site_srl = 0, $type = "pc", $gtype = 'site')
{
$args->addon = $addon; $args->addon = $addon;
if($gtype == 'global') { if($gtype == 'global')
{
if($type == "pc") $output = executeQuery('addon.getAddonIsActivated', $args); if($type == "pc") $output = executeQuery('addon.getAddonIsActivated', $args);
else $output = executeQuery('addon.getMAddonIsActivated', $args); else $output = executeQuery('addon.getMAddonIsActivated', $args);
} }
else { else
{
$args->site_srl = $site_srl; $args->site_srl = $site_srl;
if($type == "pc") $output = executeQuery('addon.getSiteAddonIsActivated', $args); if($type == "pc") $output = executeQuery('addon.getSiteAddonIsActivated', $args);
else $output = executeQuery('addon.getSiteMAddonIsActivated', $args); else $output = executeQuery('addon.getSiteMAddonIsActivated', $args);
@ -365,6 +391,6 @@
if($output->data->count>0) return true; if($output->data->count>0) return true;
return false; return false;
} }
}
} /* End of file addon.admin.model.php */
?> /* Location: ./modules/addon/addon.admin.model.php */

View file

@ -1,16 +1,17 @@
<?php <?php
/** /**
* Admin view class of addon modules * Admin view class of addon modules
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
**/ */
class addonAdminView extends addon { class addonAdminView extends addon
{
/** /**
* Initialization * Initialization
* *
* @return void * @return void
**/ */
function init() { function init()
{
$this->setTemplatePath($this->module_path.'tpl'); $this->setTemplatePath($this->module_path.'tpl');
} }
@ -18,8 +19,9 @@
* Add Management main page (showing the list) * Add Management main page (showing the list)
* *
* @return Object * @return Object
**/ */
function dispAddonAdminIndex() { function dispAddonAdminIndex()
{
$oAdminModel = &getAdminModel('admin'); $oAdminModel = &getAdminModel('admin');
// Add to the list settings // Add to the list settings
@ -44,8 +46,9 @@
* Display setup page * Display setup page
* *
* @return Object * @return Object
**/ */
function dispAddonAdminSetup() { function dispAddonAdminSetup()
{
$site_module_info = Context::get('site_module_info'); $site_module_info = Context::get('site_module_info');
// Wanted to add the requested // Wanted to add the requested
$selected_addon = Context::get('selected_addon'); $selected_addon = Context::get('selected_addon');
@ -61,16 +64,21 @@
$columnList = array('module_srl', 'module_category_srl', 'mid', 'browser_title'); $columnList = array('module_srl', 'module_category_srl', 'mid', 'browser_title');
$mid_list = $oModuleModel->getMidList($args, $columnList); $mid_list = $oModuleModel->getMidList($args, $columnList);
// module_category and module combination // module_category and module combination
if(!$site_module_info->site_srl) { if(!$site_module_info->site_srl)
{
// Get a list of module categories // Get a list of module categories
$module_categories = $oModuleModel->getModuleCategories(); $module_categories = $oModuleModel->getModuleCategories();
if(is_array($mid_list)) { if(is_array($mid_list))
foreach($mid_list as $module_srl => $module) { {
foreach($mid_list as $module_srl => $module)
{
$module_categories[$module->module_category_srl]->list[$module_srl] = $module; $module_categories[$module->module_category_srl]->list[$module_srl] = $module;
} }
} }
} else { }
else
{
$module_categories[0]->list = $mid_list; $module_categories[0]->list = $mid_list;
} }
@ -93,8 +101,9 @@
* Display information * Display information
* *
* @return Object * @return Object
**/ */
function dispAddonAdminInfo() { function dispAddonAdminInfo()
{
$site_module_info = Context::get('site_module_info'); $site_module_info = Context::get('site_module_info');
// Wanted to add the requested // Wanted to add the requested
$selected_addon = Context::get('selected_addon'); $selected_addon = Context::get('selected_addon');
@ -110,6 +119,6 @@
$security = new Security(); $security = new Security();
$security->encodeHTML('addon_info.', 'addon_info.author..'); $security->encodeHTML('addon_info.', 'addon_info.author..');
} }
}
} /* End of file addon.admin.view.php */
?> /* Location: ./modules/addon/addon.admin.view.php */

View file

@ -1,16 +1,17 @@
<?php <?php
/** /**
* High class of addon modules * High class of addon modules
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
**/ */
class addon extends ModuleObject { class addon extends ModuleObject
{
/** /**
* Implement if additional tasks are necessary when installing * Implement if additional tasks are necessary when installing
* *
* @return Object * @return Object
**/ */
function moduleInstall() { function moduleInstall()
{
// Register to add a few // Register to add a few
$oAddonController = &getAdminController('addon'); $oAddonController = &getAdminController('addon');
$oAddonController->doInsert('autolink', 0, 'site', 'Y'); $oAddonController->doInsert('autolink', 0, 'site', 'Y');
@ -31,14 +32,15 @@
* A method to check if successfully installed * A method to check if successfully installed
* *
* @return bool * @return bool
**/ */
function checkUpdate() { function checkUpdate()
{
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
if(!$oDB->isColumnExists("addons", "is_used_m")) return true; if(!$oDB->isColumnExists("addons", "is_used_m")) return true;
if(!$oDB->isColumnExists("addons_site", "is_used_m")) return true; if(!$oDB->isColumnExists("addons_site", "is_used_m")) return true;
// 2011. 7. 29. add is_fixed column // 2011. 7. 29. add is_fixed column
if (!$oDB->isColumnExists('addons', 'is_fixed')) return true; if(!$oDB->isColumnExists('addons', 'is_fixed')) return true;
return false; return false;
} }
@ -47,24 +49,27 @@
* Execute update * Execute update
* *
* @return Object * @return Object
**/ */
function moduleUpdate() { function moduleUpdate()
{
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
if(!$oDB->isColumnExists("addons", "is_used_m")) { if(!$oDB->isColumnExists("addons", "is_used_m"))
{
$oDB->addColumn("addons", "is_used_m", "char", 1, "N", true); $oDB->addColumn("addons", "is_used_m", "char", 1, "N", true);
} }
if(!$oDB->isColumnExists("addons_site", "is_used_m")) { if(!$oDB->isColumnExists("addons_site", "is_used_m"))
{
$oDB->addColumn("addons_site", "is_used_m", "char", 1, "N", true); $oDB->addColumn("addons_site", "is_used_m", "char", 1, "N", true);
} }
// 2011. 7. 29. add is_fixed column // 2011. 7. 29. add is_fixed column
if (!$oDB->isColumnExists('addons', 'is_fixed')) if(!$oDB->isColumnExists('addons', 'is_fixed'))
{ {
$oDB->addColumn('addons', 'is_fixed', 'char', 1, 'N', true); $oDB->addColumn('addons', 'is_fixed', 'char', 1, 'N', true);
// move addon info to addon_site table // move addon info to addon_site table
$output = executeQueryArray('addon.getAddons'); $output = executeQueryArray('addon.getAddons');
if ($output->data) if($output->data)
{ {
foreach($output->data as $row) foreach($output->data as $row)
{ {
@ -85,9 +90,11 @@
* Re-generate the cache file * Re-generate the cache file
* *
* @return Object * @return Object
**/ */
function recompileCache() { function recompileCache()
{
} }
} }
?> /* End of file addon.class.php */
/* Location: ./modules/addon/addon.class.php */

View file

@ -1,16 +1,17 @@
<?php <?php
/** /**
* Addon module's controller class * Addon module's controller class
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
**/ */
class addonController extends addon { class addonController extends addon
{
/** /**
* Initialization * Initialization
* *
* @return void * @return void
**/ */
function init() { function init()
{
} }
/** /**
@ -18,8 +19,9 @@
* *
* @param $type pc or mobile * @param $type pc or mobile
* @return string Returns a path * @return string Returns a path
**/ */
function getCacheFilePath($type = "pc") { function getCacheFilePath($type = "pc")
{
static $addon_file; static $addon_file;
if(isset($addon_file)) return $addon_file; if(isset($addon_file)) return $addon_file;
@ -38,23 +40,20 @@
return $addon_file; return $addon_file;
} }
/** /**
* Returns mid list that addons is run * Returns mid list that addons is run
* *
* @param string $selected_addon Name to get list * @param string $selected_addon Name to get list
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @return string[] Returns list that contain mid * @return string[] Returns list that contain mid
**/ */
function _getMidList($selected_addon, $site_srl = 0) { function _getMidList($selected_addon, $site_srl = 0)
{
$oAddonAdminModel = &getAdminModel('addon'); $oAddonAdminModel = &getAdminModel('addon');
$addon_info = $oAddonAdminModel->getAddonInfoXml($selected_addon, $site_srl); $addon_info = $oAddonAdminModel->getAddonInfoXml($selected_addon, $site_srl);
return $addon_info->mid_list; return $addon_info->mid_list;
} }
/** /**
* Adds mid into running mid list * Adds mid into running mid list
* *
@ -62,8 +61,9 @@
* @param string $mid Module id to add * @param string $mid Module id to add
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @return void * @return void
**/ */
function _setAddMid($selected_addon,$mid, $site_srl=0) { function _setAddMid($selected_addon,$mid, $site_srl=0)
{
// Wanted to add the requested information // Wanted to add the requested information
$mid_list = $this->_getMidList($selected_addon, $site_srl); $mid_list = $this->_getMidList($selected_addon, $site_srl);
@ -72,7 +72,6 @@
$this->_setMid($selected_addon,$new_mid_list, $site_srl); $this->_setMid($selected_addon,$new_mid_list, $site_srl);
} }
/** /**
* Deletes mid from running mid list * Deletes mid from running mid list
* *
@ -80,21 +79,25 @@
* @param string $mid Module id to delete * @param string $mid Module id to delete
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @return void * @return void
**/ */
function _setDelMid($selected_addon,$mid,$site_srl=0) { function _setDelMid($selected_addon,$mid,$site_srl=0)
{
// Wanted to add the requested information // Wanted to add the requested information
$mid_list = $this->_getMidList($selected_addon,$site_srl); $mid_list = $this->_getMidList($selected_addon,$site_srl);
$new_mid_list = array(); $new_mid_list = array();
if(is_array($mid_list)){ if(is_array($mid_list))
for($i=0,$c=count($mid_list);$i<$c;$i++){ {
for($i=0,$c=count($mid_list);$i<$c;$i++)
{
if($mid_list[$i] != $mid) $new_mid_list[] = $mid_list[$i]; if($mid_list[$i] != $mid) $new_mid_list[] = $mid_list[$i];
} }
}else{ }
else
{
$new_mid_list[] = $mid; $new_mid_list[] = $mid;
} }
$this->_setMid($selected_addon,$new_mid_list,$site_srl); $this->_setMid($selected_addon,$new_mid_list,$site_srl);
} }
@ -105,20 +108,21 @@
* @param string[] $mid_list List to set * @param string[] $mid_list List to set
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @return void * @return void
**/ */
function _setMid($selected_addon,$mid_list,$site_srl=0) { function _setMid($selected_addon,$mid_list,$site_srl=0)
{
$args->mid_list = join('|@|',$mid_list); $args->mid_list = join('|@|',$mid_list);
$this->doSetup($selected_addon, $args,$site_srl); $this->doSetup($selected_addon, $args,$site_srl);
$this->makeCacheFile($site_srl); $this->makeCacheFile($site_srl);
} }
/** /**
* Adds mid into running mid list * Adds mid into running mid list
* *
* @return Object * @return Object
**/ */
function procAddonSetupAddonAddMid() { function procAddonSetupAddonAddMid()
{
$site_module_info = Context::get('site_module_info'); $site_module_info = Context::get('site_module_info');
$args = Context::getRequestVars(); $args = Context::getRequestVars();
@ -131,8 +135,9 @@
* Deletes mid from running mid list * Deletes mid from running mid list
* *
* @return Object * @return Object
**/ */
function procAddonSetupAddonDelMid() { function procAddonSetupAddonDelMid()
{
$site_module_info = Context::get('site_module_info'); $site_module_info = Context::get('site_module_info');
$args = Context::getRequestVars(); $args = Context::getRequestVars();
@ -149,13 +154,15 @@
* @param string $type pc or mobile * @param string $type pc or mobile
* @param string $gtype site or global * @param string $gtype site or global
* @return void * @return void
**/ */
function makeCacheFile($site_srl = 0, $type = "pc", $gtype = 'site') { function makeCacheFile($site_srl = 0, $type = "pc", $gtype = 'site')
{
// Add-on module for use in creating the cache file // Add-on module for use in creating the cache file
$buff = ""; $buff = "";
$oAddonModel = &getAdminModel('addon'); $oAddonModel = &getAdminModel('addon');
$addon_list = $oAddonModel->getInsertedAddons($site_srl, $gtype); $addon_list = $oAddonModel->getInsertedAddons($site_srl, $gtype);
foreach($addon_list as $addon => $val) { foreach($addon_list as $addon => $val)
{
if($val->addon == "smartphone") continue; if($val->addon == "smartphone") continue;
if(!is_dir(_XE_PATH_.'addons/'.$addon)) 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; if(($type == "pc" && $val->is_used != 'Y') || ($type == "mobile" && $val->is_used_m != 'Y') || ($gtype == 'global' && $val->is_fixed != 'Y')) continue;
@ -176,7 +183,8 @@
$buff .= ');'; $buff .= ');';
$buff .= sprintf('$addon_file = \'./addons/%s/%s.addon.php\';', $addon, $addon); $buff .= sprintf('$addon_file = \'./addons/%s/%s.addon.php\';', $addon, $addon);
if($val->extra_vars) { if($val->extra_vars)
{
unset($extra_vars); unset($extra_vars);
$extra_vars = base64_encode($val->extra_vars); $extra_vars = base64_encode($val->extra_vars);
} }
@ -211,8 +219,9 @@
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @param string $gtype site or global * @param string $gtype site or global
* @return Object * @return Object
**/ */
function doSetup($addon, $extra_vars,$site_srl=0, $gtype = 'site') { function doSetup($addon, $extra_vars,$site_srl=0, $gtype = 'site')
{
if(!is_array($extra_vars->mid_list)) unset($extra_vars->mid_list); if(!is_array($extra_vars->mid_list)) unset($extra_vars->mid_list);
$args->addon = $addon; $args->addon = $addon;
@ -227,18 +236,16 @@
* *
* @param int $site_srl Site srl * @param int $site_srl Site srl
* @return void * @return void
**/ */
function removeAddonConfig($site_srl) { function removeAddonConfig($site_srl)
{
$addon_path = _XE_PATH_.'files/cache/addons/'; $addon_path = _XE_PATH_.'files/cache/addons/';
$addon_file = $addon_path.$site_srl.'.acivated_addons.cache.php'; $addon_file = $addon_path.$site_srl.'.acivated_addons.cache.php';
if(file_exists($addon_file)) FileHandler::removeFile($addon_file); if(file_exists($addon_file)) FileHandler::removeFile($addon_file);
$args->site_srl = $site_srl; $args->site_srl = $site_srl;
executeQuery('addon.deleteSiteAddons', $args); executeQuery('addon.deleteSiteAddons', $args);
} }
}
/* End of file addon.controller.php */
} /* Location: ./modules/addon/addon.controller.php */
?>