Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using object property instead of getVar everywhere where is possible #744

Merged
merged 5 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions content.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
$contentObj = $content;
break;
}
$clean_content_id = $contentObj->getVar('content_id');
$clean_content_id = $contentObj->content_id;
}

$xoopsOption['template_main'] = 'content_content.html';
Expand All @@ -74,15 +74,15 @@
redirect_header(CONTENT_URL, 3, _NOPERM);
}

if ($contentConfig ['com_rule'] && $contentObj->getVar('content_cancomment')) {
if ($contentConfig ['com_rule'] && $contentObj->content_cancomment) {
$icmsTpl->assign('content_content_comment', true);
include_once ICMS_ROOT_PATH . '/include/comment_view.php';
}

/**
* Generating meta information for this page
*/
$icms_metagen = new icms_ipf_Metagen($contentObj->getVar('content_title'), $contentObj->getVar('meta_keywords', 'n'), $contentObj->getVar('meta_description', 'n'));
$icms_metagen = new icms_ipf_Metagen($contentObj->content_title, $contentObj->getVar('meta_keywords', 'n'), $contentObj->getVar('meta_description', 'n'));
$icms_metagen->createMetaTags();

$xoTheme->addStylesheet(ICMS_URL . '/modules/content/include/content.css');
Expand Down
2 changes: 1 addition & 1 deletion core/Database/Legacy/Updater/DatabaseUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function insertConfig($conf_catid, $conf_name, $conf_title, $conf_value, $conf_d

function moduleUpgrade(&$module, $tables_first = false)
{
$dirname = $module->getVar('dirname');
$dirname = $module->dirname;

// ob_start();

Expand Down
6 changes: 3 additions & 3 deletions core/Extensions/Plugins/PluginRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ public function getPluginsArray($path) {
$tempModulesObj = $module_handler->getObjects($criteria);
$modulesObj = array();
foreach ($tempModulesObj as $moduleObj) {
$modulesObj[$moduleObj->getVar('dirname')] = $moduleObj;
$modulesObj[$moduleObj->dirname] = $moduleObj;
}

$aFiles = str_replace('.php', '', Filesystem::getFileList(ICMS_PLUGINS_PATH . '/' . $path . '/', '', array('php')));
$ret = array();
foreach ($aFiles as $pluginName) {
$module_xoops_version_file = ICMS_MODULES_PATH . "/$pluginName/xoops_version.php";
$module_icms_version_file = ICMS_MODULES_PATH . "/$pluginName/icms_version.php";
if (isset($modulesObj[$pluginName]) && (file_exists($module_xoops_version_file) || file_exists($module_icms_version_file))) {
$ret[$pluginName] = $modulesObj[$pluginName]->getVar('name');
if ((file_exists($module_xoops_version_file) || file_exists($module_icms_version_file)) && isset($modulesObj[$pluginName])) {
$ret[$pluginName] = $modulesObj[$pluginName]->name;
}
}
return $ret;
Expand Down
8 changes: 4 additions & 4 deletions core/Extensions/SetupSteps/Module/Install/BlockSetupStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
if ($blocks !== false) {
$output->info(_MD_AM_BLOCKS_ADDING);
$output->incrIndent();
$dirname = $module->getVar('dirname');
$newmid = $module->getVar('mid');
$dirname = $module->dirname;
$newmid = $module->mid;
$handler = icms::handler('icms_view_block');
foreach ($blocks as $blockkey => $block) {
if (!isset($block['file']) || !isset($block['show_func'])) {
Expand Down Expand Up @@ -97,7 +97,7 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
if (!$tplfile->store()) {
$output->error(_MD_AM_TEMPLATE_INSERT_FAIL, $block['template']);
} else {
$newtplid = $tplfile->getVar('tpl_id');
$newtplid = $tplfile->tpl_id;
$output->success(_MD_AM_TEMPLATE_INSERTED, $block['template'], icms_conv_nr2local($newtplid));
// generate compiled file
if (!Template::template_touch($newtplid)) {
Expand Down Expand Up @@ -146,7 +146,7 @@ protected function updateBlocksPermissions(Module $module, OutputDecorator $outp
{
$groups = $module->getInfo('hasMain') ? [ICMS_GROUP_ADMIN, ICMS_GROUP_USERS, ICMS_GROUP_ANONYMOUS] : [ICMS_GROUP_ADMIN];
$icms_block_handler = icms::handler('icms_view_block');
$newmid = $module->getVar('mid');
$newmid = $module->mid;
$blocks = &$icms_block_handler->getByModule($newmid, false);
$output->info(_MD_AM_PERMS_ADDING);
$output->incrIndent();
Expand Down
10 changes: 5 additions & 5 deletions core/Extensions/SetupSteps/Module/Install/ConfigSetupStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class ConfigSetupStep implements SetupStepInterface
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
$configs = (array)$module->getInfo('config');
if ($module->getVar('hascomments') != 0) {
if ($module->hascomments != 0) {
$this->includeCommentsConfig($configs);
}

if ($module->getVar('hasnotification') != 0) {
if ($module->hasnotification != 0) {
$this->includeNotificationsConfig($module, $configs);
}

Expand All @@ -40,7 +40,7 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
* @var ConfigItem $confobj
*/
$confobj = &$config_handler->createConfig();
$confobj->setVar('conf_modid', $module->getVar('mid'));
$confobj->setVar('conf_modid', $module->mid);
$confobj->setVar('conf_catid', 0);
$confobj->setVar('conf_name', $config['name']);
$confobj->setVar('conf_title', $config['title'], true);
Expand Down Expand Up @@ -134,9 +134,9 @@ protected function includeNotificationsConfig(Module $module, array &$configs)
// Event-specific notification options
$options = [];
$notification_handler = icms::handler('icms_data_notification');
$categories = &$notification_handler->categoryInfo('', $module->getVar('mid'));
$categories = &$notification_handler->categoryInfo('', $module->mid);
foreach ($categories as $category) {
$events = &$notification_handler->categoryEvents($category['name'], false, $module->getVar('mid'));
$events = &$notification_handler->categoryEvents($category['name'], false, $module->mid);
foreach ($events as $event) {
if (!empty($event['invisible'])) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MigrateSetupStep implements SetupStepInterface
*/
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
$migrationsPath = ICMS_MODULES_PATH . '/' . $module->getVar('dirname') . '/migrations/';
$migrationsPath = ICMS_MODULES_PATH . '/' . $module->dirname . '/migrations/';
if (!file_exists($migrationsPath)) {
return true;
}
Expand All @@ -25,7 +25,7 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
$symfonyConsoleApplication->add(new \Phoenix\Command\MigrateCommand());
$symfonyConsoleApplication->run(new \Symfony\Component\Console\Input\ArrayInput([
'command' => 'migrate',
'--dir' => ['module/' . $module->getVar('dirname')],
'--dir' => ['module/' . $module->dirname],
'--config_type' => 'php',
'--config' => ICMS_ROOT_PATH . '/phoenix.php',
]), $output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ScriptSetupStep implements SetupStepInterface
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
$install_script = $module->getInfo('onInstall');
$dirname = $module->getVar('dirname');
$dirname = $module->dirname;
$module_name = ($module->getInfo('modname') !== '') ? trim($module->getInfo('modname')) : $dirname;
if ($install_script === false || empty($install_script = trim($install_script))) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
if (substr(env('DB_TYPE'), 0, 4) == 'pdo.') {
$driver = substr(env('DB_TYPE'), 4);
}
$sql_file_path = ICMS_MODULES_PATH . '/' . $module->getVar('dirname') . '/' . $sqlfile[$driver];
$sql_file_path = ICMS_MODULES_PATH . '/' . $module->dirname . '/' . $sqlfile[$driver];
if (!file_exists($sql_file_path)) {
$output->error(_MD_AM_SQL_NOT_FOUND, $sql_file_path);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class ViewTemplateSetupStep implements SetupStepInterface
*/
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
$newmid = $module->getVar('mid');
$newmid = $module->mid;
$templates = $module->getInfo('templates');
if ($templates === false) {
return true;
}
$output->info(_MD_AM_TEMPLATES_ADDING);
$dirname = $module->getVar('dirname');
$dirname = $module->dirname;
$handler = icms::handler('icms_view_template_file');
$output->incrIndent();
foreach ($templates as $tpl) {
Expand All @@ -45,7 +45,7 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
$tplfile->setVar('tpl_lastimported', 0);
$tplfile->setVar('tpl_type', 'module');
if ($tplfile->store()) {
$newtplid = $tplfile->getVar('tpl_id');
$newtplid = $tplfile->tpl_id;
$output->success(_MD_AM_TEMPLATE_INSERTED, $tpl['file'], $newtplid);

if (Template::template_touch($newtplid)) {
Expand Down
22 changes: 11 additions & 11 deletions core/Extensions/SetupSteps/Module/Uninstall/BlockSetupStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BlockSetupStep implements SetupStepInterface
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
$icms_block_handler = icms::handler('icms_view_block');
$block_arr = $icms_block_handler->getByModule($module->getVar('mid'));
$block_arr = $icms_block_handler->getByModule($module->mid);
if (!is_array($block_arr)) {
return true;
}
Expand All @@ -31,32 +31,32 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
if (!$icms_block_handler->delete($block_arr[$i])) {
$output->error(
_MD_AM_BLOCK_DELETE_FAIL,
$block_arr[$i]->getVar('name'),
icms_conv_nr2local($block_arr[$i]->getVar('bid'))
$block_arr[$i]->name,
icms_conv_nr2local($block_arr[$i]->bid)
);
} else {
$output->success(
_MD_AM_BLOCK_DELETED,
$block_arr[$i]->getVar('name'),
icms_conv_nr2local($block_arr[$i]->getVar('bid'))
$block_arr[$i]->name,
icms_conv_nr2local($block_arr[$i]->bid)
);
}
if ($block_arr[$i]->getVar('template') != '') {
$templates = $tplfile_handler->find(null, 'block', $block_arr[$i]->getVar('bid'));
if ($block_arr[$i]->template != '') {
$templates = $tplfile_handler->find(null, 'block', $block_arr[$i]->bid);
$btcount = count($templates);
if ($btcount > 0) {
for ($j = 0; $j < $btcount; $j++) {
if (!$tplfile_handler->delete($templates[$j])) {
$output->error(
_MD_AM_BLOCK_TMPLT_DELETE_FAILED,
$templates[$j]->getVar('tpl_file'),
icms_conv_nr2local($templates[$j]->getVar('tpl_id'))
$templates[$j]->tpl_file,
icms_conv_nr2local($templates[$j]->tpl_id)
);
} else {
$output->success(
_MD_AM_BLOCK_TMPLT_DELETED,
$templates[$j]->getVar('tpl_file'),
icms_conv_nr2local($templates[$j]->getVar('tpl_id'))
$templates[$j]->tpl_file,
icms_conv_nr2local($templates[$j]->tpl_id)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class CommentsSetupStep implements SetupStepInterface
*/
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
if (!$module->getVar('hascomments')) {
if (!$module->hascomments) {
return true;
}
$output->info(_MD_AM_COMMENTS_DELETE);
$output->incrIndent();
$comment_handler = icms::handler('icms_data_comment');
if (!$comment_handler->deleteByModule($module->getVar('mid'))) {
if (!$comment_handler->deleteByModule($module->mid)) {
$output->error(_MD_AM_COMMENT_DELETE_FAIL);
} else {
$output->success(_MD_AM_COMMENT_DELETED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ConfigSetupStep implements SetupStepInterface
*/
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
if ($module->getVar('hasconfig') == 0 && $module->getVar('hascomments') == 0) {
if ($module->hasconfig == 0 && $module->hascomments == 0) {
return true;
}
$config_handler = icms::handler('icms_config');
Expand All @@ -31,9 +31,9 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
$output->incrIndent();
for ($i = 0; $i < $confcount; $i++) {
if (!$config_handler->deleteConfig($configs[$i])) {
$output->error(_MD_AM_CONFIGOPTION_DELETE_FAIL, icms_conv_nr2local($configs[$i]->getVar('conf_id')));
$output->error(_MD_AM_CONFIGOPTION_DELETE_FAIL, icms_conv_nr2local($configs[$i]->conf_id));
} else {
$output->success(_MD_AM_CONFIGOPTION_DELETED, icms_conv_nr2local($configs[$i]->getVar('conf_id')));
$output->success(_MD_AM_CONFIGOPTION_DELETED, icms_conv_nr2local($configs[$i]->conf_id));
}
}
$output->decrIndent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
$output->incrIndent();
foreach ($pages as $page) {
if ($page_handler->delete($page)) {
$output->success(_MD_AM_SYMLINK_DELETED, $page->getVar('page_title'), $page->getVar('page_id'));
$output->success(_MD_AM_SYMLINK_DELETED, $page->page_title, $page->page_id);
} else {
$output->error(_MD_AM_SYMLINK_DELETE_FAIL, $page->getVar('page_title'), $page->getVar('page_id'));
$output->error(_MD_AM_SYMLINK_DELETE_FAIL, $page->page_title, $page->page_id);
}
}
$output->resetIndent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
// delete files
try {
$file_handler = icms::handler('icms_data_file');
$file_handler->deleteAll(icms_buildCriteria(array('mid' => $module->getVar('mid'))));
$file_handler->deleteAll(icms_buildCriteria(array('mid' => $module->mid)));
} catch (\Exception $ex) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
$output->info(_MD_AM_GROUPPERM_DELETE);
$output->incrIndent();
$gperm_handler = icms::handler('icms_member_groupperm');
if (!$gperm_handler->deleteByModule($module->getVar('mid'))) {
if (!$gperm_handler->deleteByModule($module->mid)) {
$output->error(_MD_AM_GROUPPERM_DELETE_FAIL);
} else {
$output->success(_MD_AM_GROUPPERM_DELETED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MigrateSetupStep implements SetupStepInterface
*/
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
$migrationsPath = ICMS_MODULES_PATH . '/' . $module->getVar('dirname') . '/migrations/';
$migrationsPath = ICMS_MODULES_PATH . '/' . $module->dirname . '/migrations/';
if (!file_exists($migrationsPath)) {
return true;
}
Expand All @@ -26,7 +26,7 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
$symfonyConsoleApplication->add(new \Phoenix\Command\RollbackCommand());
$symfonyConsoleApplication->run(new \Symfony\Component\Console\Input\ArrayInput([
'command' => 'rollback',
'--dir' => ['module/' . $module->getVar('dirname')],
'--dir' => ['module/' . $module->dirname],
'--config_type' => 'php',
'--all' => true,
'--config' => ICMS_ROOT_PATH . '/phoenix.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class NotificationsSetupStep implements SetupStepInterface
*/
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
if (!$module->getVar('hasnotification')) {
if (!$module->hasnotification) {
return true;
}
$output->info(_MD_AM_NOTIFICATIONS_DELETE);
$output->incrIndent();
$notification_handler = icms::handler('icms_data_notification');
if (!$notification_handler->unsubscribeByModule($module->getVar('mid'))) {
if (!$notification_handler->unsubscribeByModule($module->mid)) {
$output->error(_MD_AM_NOTIFICATION_DELETE_FAIL);
} else {
$output->success(_MD_AM_NOTIFICATION_DELETED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ViewTemplateSetupStep implements SetupStepInterface
public function execute(Module $module, OutputDecorator $output, ...$params): bool
{
$tplfile_handler = icms::handler('icms_view_template_file');
$templates = $tplfile_handler->find(null, 'module', $module->getVar('mid'));
$templates = $tplfile_handler->find(null, 'module', $module->mid);
$tcount = count($templates);
if ($tcount === 0) {
return true;
Expand All @@ -31,14 +31,14 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
if (!$tplfile_handler->delete($templates[$i])) {
$output->error(
_MD_AM_TEMPLATE_DELETE_FAIL,
$templates[$i]->getVar('tpl_file'),
icms_conv_nr2local($templates[$i]->getVar('tpl_id'))
$templates[$i]->tpl_file,
icms_conv_nr2local($templates[$i]->tpl_id)
);
} else {
$output->success(
_MD_AM_TEMPLATE_DELETED,
icms_conv_nr2local($templates[$i]->getVar('tpl_file')),
icms_conv_nr2local($templates[$i]->getVar('tpl_id'))
icms_conv_nr2local($templates[$i]->tpl_file),
icms_conv_nr2local($templates[$i]->tpl_id)
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions core/Extensions/SetupSteps/Module/Update/AutotasksSetupStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public function execute(Module $module, OutputDecorator $output, ...$params): bo
$criteria->add(new CriteriaItem('sat_type', 'addon/' . $module->getInfo('dirname')));
$items_atasks = $atasks_handler->getObjects($criteria, false);
foreach ($items_atasks as $task) {
$taskID = (int)$task->getVar('sat_addon_id');
$taskID = (int)$task->sat_addon_id;
if (!isset($atasks[$taskID])) {
$atasks[$taskID] = [];
}
$atasks[$taskID]['enabled'] = $task->getVar('sat_enabled');
$atasks[$taskID]['repeat'] = $task->getVar('sat_repeat');
$atasks[$taskID]['interval'] = $task->getVar('sat_interval');
$atasks[$taskID]['name'] = $task->getVar('sat_name');
$atasks[$taskID]['enabled'] = $task->sat_enabled;
$atasks[$taskID]['repeat'] = $task->sat_repeat;
$atasks[$taskID]['interval'] = $task->sat_interval;
$atasks[$taskID]['name'] = $task->sat_name;
}
$atasks_handler->deleteAll($criteria);
if (is_array($atasks)) {
Expand Down
Loading