diff --git a/admin/building.php b/admin/building.php index 2d9497d9..cef83af5 100644 --- a/admin/building.php +++ b/admin/building.php @@ -22,10 +22,17 @@ $op = XoopsRequest::getString('op', 'default'); $mid = XoopsRequest::getInt('mod_id'); $moduleObj = $tdmcreate->getHandler('modules')->get($mid); +// Clear cache +$cacheFile1 = TDMC_CLASSES_PATH . '/cache/classpaths.cache'; +$cacheFile2 = TDMC_CLASSES_PATH . '/files/cache/classpaths.cache'; +if (file_exists($cacheFile1) && file_exists($cacheFile2)) { + unlink($cacheFile1); + unlink($cacheFile2); +} // Switch option switch ($op) { case 'build': - $template_main = 'tdmcreate_building.tpl'; + $templateMain = 'tdmcreate_building.tpl'; $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('building.php')); // Get var module dirname $moduleDirname = $moduleObj->getVar('mod_dirname'); @@ -72,7 +79,7 @@ case 'default': default: - $template_main = 'tdmcreate_building.tpl'; + $templateMain = 'tdmcreate_building.tpl'; $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('building.php')); // Redirect if there aren't modules $nbModules = $tdmcreate->getHandler('modules')->getCount(); diff --git a/admin/fields.php b/admin/fields.php index b476a4f4..8def0b5e 100644 --- a/admin/fields.php +++ b/admin/fields.php @@ -34,7 +34,7 @@ $start = XoopsRequest::getInt('start', 0); $limit = XoopsRequest::getInt('limit', $tdmcreate->getConfig('tables_adminpager')); // Define main template - $template_main = 'tdmcreate_fields.tpl'; + $templateMain = 'tdmcreate_fields.tpl'; $GLOBALS['xoTheme']->addStylesheet( 'modules/tdmcreate/assets/css/admin/style.css' ); $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/plugins/jquery.ui.js'); $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); @@ -143,7 +143,7 @@ case 'new': // Define main template - $template_main = 'tdmcreate_fields.tpl'; + $templateMain = 'tdmcreate_fields.tpl'; $GLOBALS['xoTheme']->addStylesheet( 'modules/tdmcreate/assets/css/admin/style.css' ); $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('fields.php')); $adminMenu->addItemButton(_AM_TDMCREATE_TABLES_LIST, 'tables.php', 'list'); @@ -227,7 +227,7 @@ case 'edit': // Define main template - $template_main = 'tdmcreate_fields.tpl'; + $templateMain = 'tdmcreate_fields.tpl'; $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('fields.php')); $adminMenu->addItemButton(_AM_TDMCREATE_ADD_TABLE, 'tables.php?op=new', 'add'); $adminMenu->addItemButton(_AM_TDMCREATE_TABLES_LIST, 'tables.php', 'list'); diff --git a/admin/footer.php b/admin/footer.php index 1d6b7497..4683d2c6 100644 --- a/admin/footer.php +++ b/admin/footer.php @@ -19,7 +19,7 @@ * @version $Id: footer.php 12207 2013-10-23 02:46:52Z beckmi $ */ $GLOBALS['xoopsTpl']->assign('module_name', $GLOBALS['xoopsModule']->getVar('name')); -if (isset($template_main)) { - $GLOBALS['xoopsTpl']->display("db:{$template_main}"); +if (isset($templateMain)) { + $GLOBALS['xoopsTpl']->display("db:{$templateMain}"); } xoops_cp_footer(); diff --git a/admin/index.php b/admin/index.php index 6d9efc71..10bc8a02 100644 --- a/admin/index.php +++ b/admin/index.php @@ -24,7 +24,7 @@ $count_tables = $tdmcreate->getHandler('tables')->getCount($criteria); $count_fields = $tdmcreate->getHandler('fields')->getCount($criteria); unset($criteria); -$template_main = 'tdmcreate_index.tpl'; +$templateMain = 'tdmcreate_index.tpl'; $adminMenu->addInfoBox(_AM_TDMCREATE_ADMIN_NUMMODULES); $adminMenu->addInfoBoxLine(_AM_TDMCREATE_ADMIN_NUMMODULES, '', $count_modules, 'Green'); $adminMenu->addInfoBoxLine(_AM_TDMCREATE_ADMIN_NUMMODULES, '', $count_tables, 'Orange'); diff --git a/admin/modules.php b/admin/modules.php index d8ed80a2..2c05b5e8 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -30,7 +30,7 @@ $start = XoopsRequest::getInt('start', 0); $limit = XoopsRequest::getInt('limit', $tdmcreate->getConfig('modules_adminpager')); // Define main template - $template_main = 'tdmcreate_modules.tpl'; + $templateMain = 'tdmcreate_modules.tpl'; $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); $GLOBALS['xoTheme']->addStylesheet('modules/tdmcreate/assets/css/admin/style.css'); $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('modules.php')); @@ -83,7 +83,7 @@ case 'new': // Define main template - $template_main = 'tdmcreate_modules.tpl'; + $templateMain = 'tdmcreate_modules.tpl'; $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('modules.php')); $adminMenu->addItemButton(_AM_TDMCREATE_MODULES_LIST, 'modules.php', 'list'); @@ -177,7 +177,7 @@ case 'edit': // Define main template - $template_main = 'tdmcreate_modules.tpl'; + $templateMain = 'tdmcreate_modules.tpl'; $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('modules.php')); $adminMenu->addItemButton(_AM_TDMCREATE_ADD_MODULE, 'modules.php?op=new', 'add'); diff --git a/admin/settings.php b/admin/settings.php index 58ded425..7342b8ea 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -22,16 +22,16 @@ // Recovered value of argument op in the URL $ $op = XoopsRequest::getString('op', 'edit'); // -$modId = XoopsRequest::getInt('set_id'); +$setId = XoopsRequest::getInt('set_id'); // switch ($op) { case 'edit': default: // Define main template - $template_main = 'tdmcreate_settings.tpl'; + $templateMain = 'tdmcreate_settings.tpl'; $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('settings.php')); - $settingsObj = $tdmcreate->getHandler('settings')->get($modId); - $form = $settingsObj->getForm(); + $settingsObj = $tdmcreate->getHandler('settings')->get($setId); + $form = $settingsObj->getForm(); $GLOBALS['xoopsTpl']->assign('form', $form->render()); break; @@ -39,8 +39,8 @@ if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('settings.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } - if (isset($modId)) { - $settingsObj =& $tdmcreate->getHandler('settings')->get($modId); + if (isset($setId)) { + $settingsObj =& $tdmcreate->getHandler('settings')->get($setId); } $moduleDirname = preg_replace('/[^a-zA-Z0-9]\s+/', '', strtolower($_POST['set_dirname'])); //Form module save diff --git a/admin/tables.php b/admin/tables.php index 4d30a668..2386cf2e 100644 --- a/admin/tables.php +++ b/admin/tables.php @@ -36,7 +36,7 @@ $start = XoopsRequest::getInt('start', 0); $limit = XoopsRequest::getInt('limit', $tdmcreate->getConfig('modules_adminpager')); // Define main template - $template_main = 'tdmcreate_tables.tpl'; + $templateMain = 'tdmcreate_tables.tpl'; $GLOBALS['xoTheme']->addStylesheet('modules/tdmcreate/assets/css/admin/style.css'); $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/plugins/jquery.ui.js'); $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); @@ -132,7 +132,7 @@ case 'new': // Define main template - $template_main = 'tdmcreate_tables.tpl'; + $templateMain = 'tdmcreate_tables.tpl'; $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('tables.php')); $adminMenu->addItemButton(_AM_TDMCREATE_TABLES_LIST, 'tables.php', 'list'); $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); @@ -230,7 +230,7 @@ case 'edit': // Define main template - $template_main = 'tdmcreate_tables.tpl'; + $templateMain = 'tdmcreate_tables.tpl'; $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('tables.php')); $adminMenu->addItemButton(_AM_TDMCREATE_ADD_TABLE, 'tables.php?op=new', 'add'); $adminMenu->addItemButton(_AM_TDMCREATE_TABLES_LIST, 'tables.php?op=list', 'list'); diff --git a/class/files/TDMCreateArchitecture.php b/class/files/TDMCreateArchitecture.php index 19a89173..919a09a1 100644 --- a/class/files/TDMCreateArchitecture.php +++ b/class/files/TDMCreateArchitecture.php @@ -31,6 +31,7 @@ class TDMCreateArchitecture extends TDMCreateStructure * @var mixed */ private $tdmcreate; + /* * @var mixed */ @@ -46,6 +47,7 @@ class TDMCreateArchitecture extends TDMCreateStructure public function __construct() { $this->tdmcreate = TDMCreateHelper::getInstance(); + $this->tdmcfile = TDMCreateFile::getInstance(); $this->structure = TDMCreateStructure::getInstance(); $this->structure->setUploadPath(TDMC_UPLOAD_REPOSITORY_PATH); } @@ -80,10 +82,7 @@ public function createBaseFoldersFiles($module) $modId = $module->getVar('mod_id'); $language = $GLOBALS['xoopsConfig']['language']; // Id of tables - $criteria = new CriteriaCompo(); - $criteria->add(new Criteria('table_mid', $modId)); - $tables = $this->tdmcreate->getHandler('tables')->getObjects($criteria); - unset($criteria); + $tables = $this->tdmcfile->getTableTables($modId); // $table = null; foreach (array_keys($tables) as $t) { @@ -96,6 +95,8 @@ public function createBaseFoldersFiles($module) } // $indexFile = XOOPS_UPLOAD_PATH . '/index.html'; + $cache1 = TDMC_CLASSES_PATH . '/cache'; + $cache2 = TDMC_CLASSES_PATH . '/files/cache'; $stlModuleAuthor = str_replace(' ', '', strtolower($module->getVar('mod_author'))); $this->structure->setModuleName($module->getVar('mod_dirname')); $uploadPath = $this->structure->getUploadPath(); @@ -173,6 +174,8 @@ public function createBaseFoldersFiles($module) $this->structure->makeDirAndCopyFile('language/english', $indexFile, 'index.html'); // Creation of "language/english/help" folder and index.html file $this->structure->makeDirAndCopyFile('language/english/help', $indexFile, 'index.html'); + // Creation of "preloads" folder and index.html file + $this->structure->makeDirAndCopyFile('preloads', $indexFile, 'index.html'); if (1 == $module->getVar('mod_admin')) { // Creation of "templates" folder and index.html file $this->structure->makeDirAndCopyFile('templates', $indexFile, 'index.html'); @@ -210,16 +213,11 @@ public function createBaseFoldersFiles($module) public function createFilesToBuilding($module) { // Module - $modId = $module->getVar('mod_id'); - $moduleDirname = $module->getVar('mod_dirname'); - $icon32 = 'assets/icons/32'; - // Id of tables - $criteria = new CriteriaCompo(); - $criteria->add(new Criteria('table_mid', $modId)); - $criteria->setSort('table_order'); - $tables = $this->tdmcreate->getHandler('tables')->getObjects($criteria); - unset($criteria); - $ret = array(); + $modId = $module->getVar('mod_id'); + $moduleDirname = $module->getVar('mod_dirname'); + $icon32 = 'assets/icons/32'; + $tables = $this->tdmcfile->getTableTables($modId); + $ret = array(); // $table = array(); foreach (array_keys($tables) as $t) { @@ -353,7 +351,7 @@ public function createFilesToBuilding($module) if (1 == $table->getVar('table_permissions')) { // Admin Permissions File $adminPermissions = AdminPermissions::getInstance(); - $adminPermissions->write($module, $tables, 'permissions.php'); + $adminPermissions->write($module, $table, $tables, 'permissions.php'); $ret[] = $adminPermissions->render(); // Templates Admin Permissions File $adminTemplatesPermissions = TemplatesAdminPermissions::getInstance(); @@ -447,18 +445,90 @@ public function createFilesToBuilding($module) $userNotificationUpdate = UserNotificationUpdate::getInstance(); $userNotificationUpdate->write($module, 'notification_update.php'); $ret[] = $userNotificationUpdate->render(); + } + // User Broken File + if ((1 == $table->getVar('table_broken'))) { + $userBroken = UserBroken::getInstance(); + $userBroken->write($module, $table, 'broken.php'); + $ret[] = $userBroken->render(); + // User Templates Broken File + $userTemplatesBroken = TemplatesUserBroken::getInstance(); + $userTemplatesBroken->write($module, $table); + $ret[] = $userTemplatesBroken->renderFile($moduleDirname . '_broken.tpl'); + } + // User Pdf File + if ((1 == $table->getVar('table_pdf'))) { + $userPdf = UserPrint::getInstance(); + $userPdf->write($module, $table, 'pdf.php'); + $ret[] = $userPdf->render(); + // User Templates Pdf File + $userTemplatesPdf = TemplatesUserPdf::getInstance(); + $userTemplatesPdf->write($module, $table); + $ret[] = $userTemplatesPdf->renderFile($moduleDirname . '_pdf.tpl'); } // User Print File if ((1 == $table->getVar('table_print'))) { $userPrint = UserPrint::getInstance(); $userPrint->write($module, $table, 'print.php'); $ret[] = $userPrint->render(); + // User Templates Print File + $userTemplatesPrint = TemplatesUserPrint::getInstance(); + $userTemplatesPrint->write($module, $table); + $ret[] = $userTemplatesPrint->renderFile($moduleDirname . '_print.tpl'); + } + // User Rate File + if ((1 == $table->getVar('table_rate'))) { + $userRate = UserRate::getInstance(); + $userRate->write($module, $table, 'rate.php'); + $ret[] = $userRate->render(); + // User Templates Rate File + $userTemplatesRate = TemplatesUserRate::getInstance(); + $userTemplatesRate->write($module, $table); + $ret[] = $userTemplatesRate->renderFile($moduleDirname . '_rate.tpl'); } // User Rss File if ((1 == $table->getVar('table_rss'))) { $userRss = UserRss::getInstance(); $userRss->write($module, $table, 'rss.php'); $ret[] = $userRss->render(); + // User Templates Rss File + $userTemplatesRss = TemplatesUserRss::getInstance(); + $userTemplatesRss->write($module, $table); + $ret[] = $userTemplatesRss->renderFile($moduleDirname . '_rss.tpl'); + } + // User Single File + if ((1 == $table->getVar('table_single'))) { + $userSingle = UserSingle::getInstance(); + $userSingle->write($module, $table, 'single.php'); + $ret[] = $userSingle->render(); + // User Templates Single File + $userTemplatesSingle = TemplatesUserSingle::getInstance(); + $userTemplatesSingle->write($module, $table); + $ret[] = $userTemplatesSingle->renderFile($moduleDirname . '_single.tpl'); + } + // User Submit File + if ((1 == $table->getVar('table_submit'))) { + $userSubmit = UserSubmit::getInstance(); + $userSubmit->write($module, $table, 'submit.php'); + $ret[] = $userSubmit->render(); + // User Templates Submit File + $userTemplatesSubmit = TemplatesUserSubmit::getInstance(); + $userTemplatesSubmit->write($module, $table); + $ret[] = $userTemplatesSubmit->renderFile($moduleDirname . '_submit.tpl'); + }// User Visit File + if ((1 == $table->getVar('table_visit'))) { + $userVisit = UserVisit::getInstance(); + $userVisit->write($module, $table, 'visit.php'); + $ret[] = $userVisit->render(); + } + // User Tag Files + if ((1 == $table->getVar('table_tag'))) { + $userListTag = UserListTag::getInstance(); + $userListTag->write($module, 'list.tag.php'); + $ret[] = $userListTag->render(); + $userViewTag = UserViewTag::getInstance(); + $userViewTag->write($module, 'view.tag.php'); + $ret[] = $userViewTag->render(); } // User Index File $userIndex = UserIndex::getInstance(); diff --git a/class/files/TDMCreateTableFields.php b/class/files/TDMCreateTableFields.php index febd8a98..2ddd0276 100644 --- a/class/files/TDMCreateTableFields.php +++ b/class/files/TDMCreateTableFields.php @@ -32,16 +32,34 @@ public function __construct() { $this->tdmcreate = TDMCreateHelper::getInstance(); } + + /** + * @public function getTableTables + * @param $mId + * @return mixed + */ + public function getTableTables($mId) + { + $criteria = new CriteriaCompo(); + $criteria->add(new Criteria('table_mid', $mId)); // $mId = module Id + $criteria->setSort('table_order'); + $tables = $this->tdmcreate->getHandler('tables')->getObjects($criteria); + unset($criteria); + + return $tables; + } /** * @public function getTableFields - * @param $tableId + * @param $mId + * @param $tId * @return mixed */ - public function getTableFields($tableId) + public function getTableFields($mId, $tId) { $criteria = new CriteriaCompo(); - $criteria->add(new Criteria('field_tid', $tableId)); + $criteria->add(new Criteria('field_mid', $mId)); // $mId = module Id + $criteria->add(new Criteria('field_tid', $tId)); // $tId = table Id $criteria->setSort('field_order'); $fields = $this->tdmcreate->getHandler('fields')->getObjects($criteria); unset($criteria); diff --git a/class/files/admin/AdminAbout.php b/class/files/admin/AdminAbout.php index b14c235e..9ffb86ab 100644 --- a/class/files/admin/AdminAbout.php +++ b/class/files/admin/AdminAbout.php @@ -85,7 +85,7 @@ public function render() $content = $this->getHeaderFilesComments($module, $filename); $content .= <<assign('navigation', \$adminMenu->addNavigation('about.php')); \$GLOBALS['xoopsTpl']->assign('about', \$adminMenu->renderAbout('{$moduleDonations}', false)); include __DIR__ . '/footer.php'; diff --git a/class/files/admin/AdminFooter.php b/class/files/admin/AdminFooter.php index 77e8f258..3c7fac8d 100644 --- a/class/files/admin/AdminFooter.php +++ b/class/files/admin/AdminFooter.php @@ -84,7 +84,7 @@ public function render() $moduleDirname = $module->getVar('mod_dirname'); $content = $this->getHeaderFilesComments($module, $filename); $content .= <<display("db:{\$templateMain}"); } xoops_cp_footer(); diff --git a/class/files/admin/AdminObjects.php b/class/files/admin/AdminObjects.php index a9afccbc..a9d33687 100644 --- a/class/files/admin/AdminObjects.php +++ b/class/files/admin/AdminObjects.php @@ -301,8 +301,7 @@ public function getUploadImageGetVar($lpFieldName, $rpFieldName, $tableName, $fi $ret = <<getVar('{$fieldName}'); -\t\t\t\t\$upload_image = \${$fieldName} ? \${$fieldName} : 'blank.gif'; -\t\t\t\t\${$lpFieldName}['{$rpFieldName}'] = \$upload_image;\n +\t\t\t\t\${$lpFieldName}['{$rpFieldName}'] = \${$fieldName} ? \${$fieldName} : 'blank.gif';\n EOT; return $ret; } diff --git a/class/files/admin/AdminPages.php b/class/files/admin/AdminPages.php index 864a1d08..d846146c 100644 --- a/class/files/admin/AdminPages.php +++ b/class/files/admin/AdminPages.php @@ -19,8 +19,6 @@ * @version $Id: pages.php 12258 2014-01-02 09:33:29Z timgno $ */ defined('XOOPS_ROOT_PATH') or die('Restricted access'); -require_once 'AdminObjects.php'; - /** * Class AdminPages */ @@ -83,7 +81,7 @@ public function write($module, $table) public function getAdminPagesHeader($moduleDirname, $tableName, $fieldId) { $ucfModuleDirname = ucfirst($moduleDirname); - $ucfTableName = ucfirst($tableName); + $ucfTableName = ucfirst($tableName); $ret = <<getCount(\$criteria); \${$tableName}All = \${$tableName}Handler->getAll(\$criteria); unset(\$criteria); - \$GLOBALS['xoopsTpl']->assign('{$moduleDirname}_count', \${$tableName}Count); + \$GLOBALS['xoopsTpl']->assign('{$tableName}_count', \${$tableName}Count); \$GLOBALS['xoopsTpl']->assign('{$moduleDirname}_url', {$stuModuleDirname}_URL); \$GLOBALS['xoopsTpl']->assign('{$moduleDirname}_upload_url', {$stuModuleDirname}_UPLOAD_URL); // Table view @@ -248,7 +246,7 @@ public function getAdminPagesNew($moduleDirname, $tableName, $language) $stuTableName = strtoupper($tableName); $ret = <<addItemButton({$language}{$stuTableName}_LIST, '{$tableName}.php', 'list'); \$GLOBALS['xoopsTpl']->assign('navigation', \$adminMenu->addNavigation('{$tableName}.php')); \$GLOBALS['xoopsTpl']->assign('buttons', \$adminMenu->renderButton()); @@ -353,7 +351,7 @@ public function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId) $stuTableFieldname = strtoupper($tableFieldname); $ret = <<addItemButton({$language}ADD_{$stuTableSoleName}, '{$tableName}.php?op=new', 'add'); \$adminMenu->addItemButton({$language}{$stuTableName}_LIST, '{$tableName}.php', 'list'); \$GLOBALS['xoopsTpl']->assign('navigation', \$adminMenu->addNavigation('{$tableName}.php')); @@ -460,7 +458,7 @@ public function renderFile($filename) $moduleDirname = $module->getVar('mod_dirname'); $tableName = $table->getVar('table_name'); $language = $this->tdmcfile->getLanguage($moduleDirname, 'AM'); - $fields = $this->tdmcfile->getTableFields($table->getVar('table_id')); + $fields = $this->tdmcfile->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldInForm = $fields[$f]->getVar('field_inform'); diff --git a/class/files/admin/AdminPermissions.php b/class/files/admin/AdminPermissions.php index 19674e1b..160664f5 100644 --- a/class/files/admin/AdminPermissions.php +++ b/class/files/admin/AdminPermissions.php @@ -66,10 +66,11 @@ public static function &getInstance() * @param $tables * @param $filename */ - public function write($module, $tables, $filename) + public function write($module, $table, $tables, $filename) { $this->setModule($module); - $this->setTables($tables); + $this->setTable($table); + $this->setTables($tables); $this->setFileName($filename); } @@ -83,9 +84,11 @@ public function write($module, $tables, $filename) * @param $language * @return string */ - private function getPermissionsHeader($moduleDirname, $tableName, $language) + private function getPermissionsHeader($moduleDirname, $language) { - $ret = <<getTable(); + $tableName = $table->getVar('table_name'); + $ret = <<getTables(); foreach (array_keys($tables) as $t) { - $tableId = $tables[$t]->getVar('table_id'); + $tableId = $tables[$t]->getVar('table_id'); + $tableMid = $tables[$t]->getVar('table_mid'); if (1 == $tables[$t]->getVar('table_permissions')) { $tableName = $tables[$t]->getVar('table_name'); } } - $fields = $this->getTableFields($tableId); + $fields = $this->getTableFields($tableMid, $tableId); + $fieldId = 'id'; + $fieldMain = 'title'; foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); if (0 == $f) { - $fpif = $fieldName; + $fieldId = $fieldName; } if (1 == $fields[$f]->getVar('field_main')) { - $fpmf = $fieldName; + $fieldMain = $fieldName; } } $ret = << \$perm_name) { \$permform->addItem(\$perm_id, \$perm_name); } - echo \$permform->render(); - echo '

'; + \$GLOBALS['xoopsTpl']->assign('form', \$permform->render()); } else { \$criteria = new CriteriaCompo(); - \$criteria->setSort('{$fpmf}'); + \$criteria->setSort('{$fieldMain}'); \$criteria->setOrder('ASC'); \${$tableName}_count = \${$tableName}Handler->getCount(\$criteria); \${$tableName}_arr = \${$tableName}Handler->getObjects(\$criteria); unset(\$criteria); foreach (array_keys(\${$tableName}_arr) as \$i) { - \$permform->addItem(\${$tableName}_arr[\$i]->getVar('{$fpif}'), \${$tableName}_arr[\$i]->getVar('{$fpmf}')); + \$permform->addItem(\${$tableName}_arr[\$i]->getVar('{$fieldId}'), \${$tableName}_arr[\$i]->getVar('{$fieldMain}')); } // Check if {$tableName} exist before rendering the form and redirect, if there aren't {$tableName} if (\${$tableName}_count > 0) { - echo \$permform->render(); - echo '

'; + \$GLOBALS['xoopsTpl']->assign('form', \$permform->render()); } else { redirect_header ( '{$tableName}.php?op=new', 3, {$language}NOPERMSSET ); exit (); @@ -252,13 +256,11 @@ private function getPermissionsFooter() public function render() { $module = $this->getModule(); - $table = $this->getTable(); $filename = $this->getFileName(); $moduleDirname = $module->getVar('mod_dirname'); - $tableName = $module->getVar('table_name'); $language = $this->getLanguage($moduleDirname, 'AM'); $content = $this->getHeaderFilesComments($module, $filename); - $content .= $this->getPermissionsHeader($moduleDirname, $tableName, $language); + $content .= $this->getPermissionsHeader($moduleDirname, $language); $content .= $this->getPermissionsSwitch($moduleDirname, $language); $content .= $this->getPermissionsBody($moduleDirname, $language); $content .= $this->getPermissionsFooter(); diff --git a/class/files/blocks/BlocksFiles.php b/class/files/blocks/BlocksFiles.php index 9be69743..41e09406 100644 --- a/class/files/blocks/BlocksFiles.php +++ b/class/files/blocks/BlocksFiles.php @@ -218,7 +218,7 @@ public function renderFile($filename) $tableFieldname = $table->getVar('table_fieldname'); $tableCategory = $table->getVar('table_category'); $language = $this->getLanguage($moduleDirname, 'MB'); - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { if (0 == $f) { $fpif = $fields[$f]->getVar('field_name'); diff --git a/class/files/cache/classpaths.cache b/class/files/cache/classpaths.cache index 32733afd..ba2c247d 100644 --- a/class/files/cache/classpaths.cache +++ b/class/files/cache/classpaths.cache @@ -1 +1 @@ -a:50:{s:18:"TDMCreateStructure";s:101:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\TDMCreateStructure.php";s:10:"AdminPages";s:99:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminPages.php";s:19:"TemplatesAdminPages";s:118:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminPages.php";s:11:"BlocksFiles";s:101:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\blocks\BlocksFiles.php";s:15:"TemplatesBlocks";s:115:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\blocks\TemplatesBlocks.php";s:10:"ClassFiles";s:101:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\classes\ClassFiles.php";s:9:"UserPages";s:97:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserPages.php";s:18:"TemplatesUserPages";s:116:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserPages.php";s:15:"LanguageModinfo";s:107:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageModinfo.php";s:11:"AdminHeader";s:100:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminHeader.php";s:10:"AdminIndex";s:99:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminIndex.php";s:9:"AdminMenu";s:98:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminMenu.php";s:10:"AdminAbout";s:99:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminAbout.php";s:11:"AdminFooter";s:100:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminFooter.php";s:19:"TemplatesAdminAbout";s:118:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminAbout.php";s:19:"TemplatesAdminIndex";s:118:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminIndex.php";s:20:"TemplatesAdminFooter";s:119:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminFooter.php";s:20:"TemplatesAdminHeader";s:119:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminHeader.php";s:13:"LanguageAdmin";s:105:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageAdmin.php";s:11:"ClassHelper";s:102:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\classes\ClassHelper.php";s:16:"IncludeFunctions";s:107:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeFunctions.php";s:14:"IncludeInstall";s:105:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeInstall.php";s:7:"SqlFile";s:94:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\sql\SqlFile.php";s:13:"IncludeUpdate";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeUpdate.php";s:18:"TemplatesUserIndex";s:116:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserIndex.php";s:19:"TemplatesUserFooter";s:117:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserFooter.php";s:19:"TemplatesUserHeader";s:117:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserHeader.php";s:10:"UserFooter";s:98:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserFooter.php";s:10:"UserHeader";s:98:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserHeader.php";s:22:"UserNotificationUpdate";s:110:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserNotificationUpdate.php";s:9:"UserIndex";s:97:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserIndex.php";s:12:"LanguageMain";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageMain.php";s:9:"CssStyles";s:96:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\css\CssStyles.php";s:13:"IncludeCommon";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeCommon.php";s:13:"DocsChangelog";s:101:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\docs\DocsChangelog.php";s:12:"LanguageHelp";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageHelp.php";s:13:"IncludeJquery";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeJquery.php";s:16:"UserXoopsVersion";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserXoopsVersion.php";s:16:"AdminPermissions";s:105:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminPermissions.php";s:25:"TemplatesAdminPermissions";s:124:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminPermissions.php";s:14:"LanguageBlocks";s:106:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageBlocks.php";s:20:"IncludeNotifications";s:111:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeNotifications.php";s:15:"LanguageMailTpl";s:107:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageMailTpl.php";s:13:"IncludeSearch";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeSearch.php";s:15:"IncludeComments";s:106:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeComments.php";s:23:"IncludeCommentFunctions";s:114:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeCommentFunctions.php";s:9:"UserPrint";s:97:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserPrint.php";s:13:"TDMCreateFile";s:96:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\TDMCreateFile.php";s:20:"TDMCreateTableFields";s:103:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\TDMCreateTableFields.php";s:7:"UserRss";s:95:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserRss.php";} \ No newline at end of file +a:58:{s:18:"TDMCreateStructure";s:101:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\TDMCreateStructure.php";s:13:"TDMCreateFile";s:96:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\TDMCreateFile.php";s:10:"AdminPages";s:99:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminPages.php";s:12:"AdminObjects";s:101:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminObjects.php";s:19:"TemplatesAdminPages";s:118:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminPages.php";s:11:"BlocksFiles";s:101:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\blocks\BlocksFiles.php";s:15:"TemplatesBlocks";s:115:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\blocks\TemplatesBlocks.php";s:10:"ClassFiles";s:101:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\classes\ClassFiles.php";s:9:"UserPages";s:97:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserPages.php";s:18:"TemplatesUserPages";s:116:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserPages.php";s:15:"LanguageModinfo";s:107:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageModinfo.php";s:11:"AdminHeader";s:100:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminHeader.php";s:10:"AdminIndex";s:99:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminIndex.php";s:9:"AdminMenu";s:98:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminMenu.php";s:10:"AdminAbout";s:99:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminAbout.php";s:11:"AdminFooter";s:100:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminFooter.php";s:19:"TemplatesAdminAbout";s:118:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminAbout.php";s:19:"TemplatesAdminIndex";s:118:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminIndex.php";s:20:"TemplatesAdminFooter";s:119:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminFooter.php";s:20:"TemplatesAdminHeader";s:119:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminHeader.php";s:13:"LanguageAdmin";s:105:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageAdmin.php";s:11:"ClassHelper";s:102:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\classes\ClassHelper.php";s:16:"IncludeFunctions";s:107:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeFunctions.php";s:14:"IncludeInstall";s:105:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeInstall.php";s:14:"LanguageBlocks";s:106:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageBlocks.php";s:16:"AdminPermissions";s:105:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\admin\AdminPermissions.php";s:25:"TemplatesAdminPermissions";s:124:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\admin\TemplatesAdminPermissions.php";s:20:"IncludeNotifications";s:111:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeNotifications.php";s:15:"LanguageMailTpl";s:107:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageMailTpl.php";s:7:"SqlFile";s:94:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\sql\SqlFile.php";s:13:"IncludeUpdate";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeUpdate.php";s:13:"IncludeSearch";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeSearch.php";s:15:"IncludeComments";s:106:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeComments.php";s:23:"IncludeCommentFunctions";s:114:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeCommentFunctions.php";s:18:"TemplatesUserIndex";s:116:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserIndex.php";s:19:"TemplatesUserFooter";s:117:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserFooter.php";s:19:"TemplatesUserHeader";s:117:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserHeader.php";s:10:"UserFooter";s:98:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserFooter.php";s:10:"UserHeader";s:98:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserHeader.php";s:22:"UserNotificationUpdate";s:110:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserNotificationUpdate.php";s:10:"UserBroken";s:98:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserBroken.php";s:19:"TemplatesUserBroken";s:117:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserBroken.php";s:9:"UserPrint";s:97:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserPrint.php";s:18:"TemplatesUserPrint";s:116:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserPrint.php";s:8:"UserRate";s:96:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserRate.php";s:17:"TemplatesUserRate";s:115:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserRate.php";s:10:"UserSubmit";s:98:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserSubmit.php";s:19:"TemplatesUserSubmit";s:117:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\templates\user\TemplatesUserSubmit.php";s:11:"UserListTag";s:99:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserListTag.php";s:11:"UserViewTag";s:99:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserViewTag.php";s:9:"UserIndex";s:97:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserIndex.php";s:12:"LanguageMain";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageMain.php";s:9:"CssStyles";s:96:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\css\CssStyles.php";s:13:"IncludeCommon";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeCommon.php";s:13:"DocsChangelog";s:101:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\docs\DocsChangelog.php";s:12:"LanguageHelp";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\language\LanguageHelp.php";s:13:"IncludeJquery";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\include\IncludeJquery.php";s:16:"UserXoopsVersion";s:104:"D:\UwAmp\www\xoops-2.5.7testTDMCreate1.91\htdocs\modules\tdmcreate\class\files\user\UserXoopsVersion.php";} \ No newline at end of file diff --git a/class/files/classes/ClassFiles.php b/class/files/classes/ClassFiles.php index 19b0a3d2..ac766898 100644 --- a/class/files/classes/ClassFiles.php +++ b/class/files/classes/ClassFiles.php @@ -16,10 +16,9 @@ * @package tdmcreate * @since 2.5.0 * @author Txmod Xoops http://www.txmodxoops.org - * @version $Id: class_files.php 12258 2014-01-02 09:33:29Z timgno $ + * @version $Id: ClassFiles.php 12258 2014-01-02 09:33:29Z timgno $ */ defined('XOOPS_ROOT_PATH') or die('Restricted access'); -require_once 'ClassFormElements.php'; /** * Class ClassFiles @@ -255,16 +254,16 @@ public function getForm(\$action = false) $ret .= <<getGroups() : XOOPS_GROUP_ANONYMOUS; if (\$xoopsUser) { if ( !\$xoopsUser->isAdmin(\$xoopsModule->mid()) ) { - \$perm_upload = (\$gperm_handler->checkRight('{$moduleDirname}_ac', 32, \$groups, \$xoopsModule->getVar('mid'))) ? true : false ; + \$perm_upload = (\$gpermHandler->checkRight('{$moduleDirname}_ac', 32, \$groups, \$xoopsModule->getVar('mid'))) ? true : false ; }else{ \$perm_upload = true; } }else{ - \$perm_upload = (\$gperm_handler->checkRight('{$moduleDirname}_ac', 32, \$groups, \$xoopsModule->getVar('mid'))) ? true : false ; + \$perm_upload = (\$gpermHandler->checkRight('{$moduleDirname}_ac', 32, \$groups, \$xoopsModule->getVar('mid'))) ? true : false ; } EOT; } @@ -276,7 +275,7 @@ public function getForm(\$action = false) \$form = new XoopsThemeForm(\$title, 'form', \$action, 'post', true); \$form->setExtra('enctype="multipart/form-data"'); // {$ucfTableName} handler - \${$tableName}Handler =& \$this->{$moduleDirname}->getHandler('{$tableName}'); + //\${$tableName}Handler =& \$this->{$moduleDirname}->getHandler('{$tableName}'); {$this->formelements->renderElements()} EOT; @@ -300,35 +299,35 @@ private function getPermissionsInForm($moduleDirname, $fieldId) $permissionView = $this->getLanguage($moduleDirname, 'AM', 'PERMISSIONS_VIEW'); $ret = <<getGroupList(); - \$gperm_handler = &xoops_gethandler ( 'groupperm' ); - \$full_list = array_keys ( \$group_list ); + \$memberHandler = & xoops_gethandler ( 'member' ); + \$groupList = &\$memberHandler->getGroupList(); + \$gpermHandler = &xoops_gethandler ( 'groupperm' ); + \$fullList = array_keys ( \$groupList ); global \$xoopsModule; if ( !\$this->isNew() ) { - \$groups_ids_approve = \$gperm_handler->getGroupIds ( '{$moduleDirname}_approve', \$this->getVar ( '{$fieldId}' ), \$xoopsModule->getVar ( 'mid' ) ); - \$groups_ids_submit = \$gperm_handler->getGroupIds ( '{$moduleDirname}_submit', \$this->getVar ( '{$fieldId}' ), \$xoopsModule->getVar ( 'mid' ) ); - \$groups_ids_view = \$gperm_handler->getGroupIds ( '{$moduleDirname}_view', \$this->getVar ( '{$fieldId}' ), \$xoopsModule->getVar ( 'mid' ) ); - \$groups_ids_approve = array_values ( \$groups_ids_approve ); - \$groups_can_approve_checkbox = new XoopsFormCheckBox ( {$permissionApprove}, 'groups_approve[]', \$groups_ids_approve ); - \$groups_ids_submit = array_values ( \$groups_ids_submit ); - \$groups_can_submit_checkbox = new XoopsFormCheckBox ( {$permissionSubmit}, 'groups_submit[]', \$groups_ids_submit ); - \$groups_ids_view = array_values ( \$groups_ids_view ); - \$groups_can_view_checkbox = new XoopsFormCheckBox ( {$permissionView}, 'groups_view[]', \$groups_ids_view ); + \$groupsIdsApprove = \$gpermHandler->getGroupIds ( '{$moduleDirname}_approve', \$this->getVar ( '{$fieldId}' ), \$xoopsModule->getVar ( 'mid' ) ); + \$groupsIdsSubmit = \$gpermHandler->getGroupIds ( '{$moduleDirname}_submit', \$this->getVar ( '{$fieldId}' ), \$xoopsModule->getVar ( 'mid' ) ); + \$groupsIdsView = \$gpermHandler->getGroupIds ( '{$moduleDirname}_view', \$this->getVar ( '{$fieldId}' ), \$xoopsModule->getVar ( 'mid' ) ); + \$groupsIdsApprove = array_values ( \$groupsIdsApprove ); + \$groupsCanApproveCheckbox = new XoopsFormCheckBox ( {$permissionApprove}, 'groups_approve[]', \$groupsIdsApprove ); + \$groupsIdsSubmit = array_values ( \$groupsIdsSubmit ); + \$groupsCanSubmitCheckbox = new XoopsFormCheckBox ( {$permissionSubmit}, 'groups_submit[]', \$groupsIdsSubmit ); + \$groupsIdsView = array_values ( \$groupsIdsView ); + \$groupsCanViewCheckbox = new XoopsFormCheckBox ( {$permissionView}, 'groups_view[]', \$groupsIdsView ); } else { - \$groups_can_approve_checkbox = new XoopsFormCheckBox ( {$permissionApprove}, 'groups_approve[]', \$full_list ); - \$groups_can_submit_checkbox = new XoopsFormCheckBox ( {$permissionSubmit}, 'groups_submit[]', \$full_list ); - \$groups_can_view_checkbox = new XoopsFormCheckBox ( {$permissionView}, 'groups_view[]', \$full_list ); + \$groupsCanApproveCheckbox = new XoopsFormCheckBox ( {$permissionApprove}, 'groups_approve[]', \$fullList ); + \$groupsCanSubmitCheckbox = new XoopsFormCheckBox ( {$permissionSubmit}, 'groups_submit[]', \$fullList ); + \$groupsCanViewCheckbox = new XoopsFormCheckBox ( {$permissionView}, 'groups_view[]', \$fullList ); } // For approve - \$groups_can_approve_checkbox->addOptionArray ( \$group_list ); - \$form->addElement ( \$groups_can_approve_checkbox ); + \$groupsCanApproveCheckbox->addOptionArray ( \$groupList ); + \$form->addElement ( \$groupsCanApproveCheckbox ); // For submit - \$groups_can_submit_checkbox->addOptionArray ( \$group_list ); - \$form->addElement ( \$groups_can_submit_checkbox ); + \$groupsCanSubmitCheckbox->addOptionArray ( \$groupList ); + \$form->addElement ( \$groupsCanSubmitCheckbox ); // For view - \$groups_can_view_checkbox->addOptionArray ( \$group_list ); - \$form->addElement ( \$groups_can_view_checkbox );\n + \$groupsCanViewCheckbox->addOptionArray ( \$groupList ); + \$form->addElement ( \$groupsCanViewCheckbox );\n EOT; return $ret; @@ -533,7 +532,7 @@ public function renderFile($filename) $table = $this->getTable(); $tableName = $table->getVar('table_name'); $moduleDirname = $module->getVar('mod_dirname'); - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldInForm = $fields[$f]->getVar('field_inform'); diff --git a/class/files/classes/ClassFormElements.php b/class/files/classes/ClassFormElements.php index 13242f36..783a4faa 100644 --- a/class/files/classes/ClassFormElements.php +++ b/class/files/classes/ClassFormElements.php @@ -210,14 +210,17 @@ private function getXoopsFormHidden($fieldName) * @param $language * @param $moduleDirname * @param $tableName + * @param $tableSoleName * @param $fieldName * @param string $required * @return string */ - private function getXoopsFormImageList($language, $moduleDirname, $tableName, $fieldName, $required = 'false') + private function getXoopsFormImageList($language, $moduleDirname, $tableName, $tableSoleName, $fieldName, $required = 'false') { $stuTableName = strtoupper($tableName); $stuFieldName = strtoupper($fieldName); + $rpFieldName = $this->tdmcfile->getRightString($fieldName); + $stuSoleName = strtoupper($tableSoleName .'_'. $rpFieldName); $ret = <<getVar('{$fieldName}'); @@ -226,7 +229,7 @@ private function getXoopsFormImageList($language, $moduleDirname, $tableName, $f \$uploads_dir = '/uploads/'.\$GLOBALS['xoopsModule']->dirname().'/images/{$tableName}'; \$iconsdirectory = is_dir(XOOPS_ROOT_PATH . \$iconsdir) ? \$iconsdir : \$uploads_dir; // - \$imgtray1 = new XoopsFormElementTray({$language}{$stuFieldName},'
'); + \$imgtray1 = new XoopsFormElementTray({$language}{$stuSoleName},'
'); \$imgpath = is_dir(XOOPS_ROOT_PATH . \$iconsdir) ? sprintf({$language}FORMIMAGE_PATH, ".{\$iconsdir}/") : sprintf({$language}FORMIMAGE_PATH, \$uploads_dir); //\$imgpath1 = sprintf({$language}FORMIMAGE_PATH, ".{\$iconsdirectory}/"); \$imageselect1 = new XoopsFormSelect(\$imgpath, '{$fieldName}', \${$fieldName}, 10); @@ -554,33 +557,23 @@ private function getXoopsFormTable($language, $moduleDirname, $tableName, $field * @param string $required * @return string */ - private function getXoopsFormTopic($language, $moduleDirname, $table, $fields, $required = 'false') - { - $tableName = $table->getVar('table_name'); - $ucfTableName = ucfirst($tableName); - foreach (array_keys($fields) as $f) { - $fieldName = $fields[$f]->getVar('field_name'); - if ((0 == $f) && (1 == $table->getVar('table_autoincrement'))) { - $fieldId = $fieldName; - } - if (1 == $fields[$f]->getVar('field_parent')) { - $fieldPid = $fieldName; - } - if (1 == $fields[$f]->getVar('field_main')) { - $fieldMain = $fieldName; - } - } + private function getXoopsFormTopic($language, $moduleDirname, $topicTableName, $fieldId, $fieldPid, $fieldMain, $required = 'false') + { + $ucfTopicTableName = ucfirst($topicTableName); + $stlTopicTableName = strtolower($topicTableName); $ret = <<{$moduleDirname}->getHandler('{$tableName}'); + // Form Topic {$ucfTopicTableName} + \${$stlTopicTableName}Handler = \$this->{$moduleDirname}->getHandler('{$stlTopicTableName}'); \$criteria = new CriteriaCompo(); - \${$tableName} = \${$tableName}Handler->getObjects( \$criteria ); - if(\${$tableName}) { + \${$stlTopicTableName}Count = \${$stlTopicTableName}Handler->getCount( \$criteria ); + if(\${$stlTopicTableName}Count) { include_once(XOOPS_ROOT_PATH . '/class/tree.php'); - \${$tableName}_tree = new XoopsObjectTree( \${$tableName}, '{$fieldId}', '{$fieldPid}' ); - \${$fieldPid} = \${$tableName}_tree->makeSelBox( '{$fieldPid}', '{$fieldMain}', '--', \$this->getVar('{$fieldPid}', 'e' ), true ); + \${$stlTopicTableName}All = \${$stlTopicTableName}Handler->getAll(\$criteria); + \${$stlTopicTableName}Tree = new XoopsObjectTree( \${$stlTopicTableName}All, '{$fieldId}', '{$fieldPid}' ); + \${$fieldPid} = \${$stlTopicTableName}Tree->makeSelBox( '{$fieldPid}', '{$fieldMain}', '--', \$this->getVar('{$fieldPid}', 'e' ), true ); \$form->addElement( new XoopsFormLabel ( {$language}, \${$fieldPid} ){$required} ); }\n + unset(\$criteria); EOT; return $ret; @@ -603,7 +596,7 @@ public function renderElements() $language_funct = $this->getLanguage($moduleDirname, 'AM'); //$language_table = $language_funct . strtoupper($tableName); $ret = ''; - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldDefault = $fields[$f]->getVar('field_default'); @@ -653,7 +646,7 @@ public function renderElements() $ret .= $this->getXoopsFormColorPicker($language, $moduleDirname, $fieldName, $required); break; case 10: - $ret .= $this->getXoopsFormImageList($language_funct, $moduleDirname, $tableName, $fieldName, $required); + $ret .= $this->getXoopsFormImageList($language_funct, $moduleDirname, $tableName, $tableSoleName, $fieldName, $required); break; case 11: $ret .= $this->getXoopsFormSelectFile($language, $moduleDirname, $fieldName, $fieldElement, $required); @@ -678,9 +671,28 @@ public function renderElements() break; } if ($fieldElement > 15) { - if ((1 == $fieldParent) || 1 == $table->getVar('table_category')) { - $ret .= $this->getXoopsFormTopic($language, $moduleDirname, $table, $fields, $required); - } else { + if (1 == $table->getVar('table_category')) { + $fieldElements = $this->tdmcreate->getHandler('fieldelements')->get($fieldElement); + $fieldElementMid = $fieldElements->getVar('fieldelement_mid'); + $fieldElementTid = $fieldElements->getVar('fieldelement_tid'); + $fieldElementName = $fieldElements->getVar('fieldelement_name'); + $fieldNameDesc = substr($fieldElementName, strrpos($fieldElementName, ':'), strlen($fieldElementName)); + $topicTableName = str_replace(': ', '', $fieldNameDesc); + $fieldsTopics = $this->getTableFields($fieldElementMid, $fieldElementTid); + foreach (array_keys($fieldsTopics) as $f) { + $fieldNameTopic = $fieldsTopics[$f]->getVar('field_name'); + if ((0 == $f) && (1 == $table->getVar('table_autoincrement'))) { + $fieldIdTopic = $fieldNameTopic; + } + if (1 == $fieldsTopics[$f]->getVar('field_parent')) { + $fieldPidTopic = $fieldNameTopic; + } + if (1 == $fieldsTopics[$f]->getVar('field_main')) { + $fieldMainTopic = $fieldNameTopic; + } + } + $ret .= $this->getXoopsFormTopic($language, $moduleDirname, $topicTableName, $fieldIdTopic, $fieldPidTopic, $fieldMainTopic, $required); + } elseif (1 == $fieldParent) { $ret .= $this->getXoopsFormTable($language, $moduleDirname, $tableName, $fieldName, $fieldElement, $required); } } diff --git a/class/files/include/IncludeComments.php b/class/files/include/IncludeComments.php index c7899369..b2abf10e 100644 --- a/class/files/include/IncludeComments.php +++ b/class/files/include/IncludeComments.php @@ -108,7 +108,7 @@ public function renderCommentsNew($module, $filename) $table = $this->getTable(); $moduleDirname = strtolower($module->getVar('mod_dirname')); $tableName = $table->getVar('table_name'); - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { if (1 == $fields[$f]->getVar('field_main')) { $fpmf = $fields[$f]->getVar('field_name'); diff --git a/class/files/include/IncludeInstall.php b/class/files/include/IncludeInstall.php index 85197d72..321dfc12 100644 --- a/class/files/include/IncludeInstall.php +++ b/class/files/include/IncludeInstall.php @@ -248,7 +248,7 @@ public function render() $filename = $this->getFileName(); $content = $this->getHeaderFilesComments($module, $filename); $content .= $this->getInstallModuleFolder($moduleDirname); - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldElement = $fields[$f]->getVar('field_element'); // All fields elements selected diff --git a/class/files/include/IncludeNotifications.php b/class/files/include/IncludeNotifications.php index 1e975406..292dca0e 100644 --- a/class/files/include/IncludeNotifications.php +++ b/class/files/include/IncludeNotifications.php @@ -87,17 +87,26 @@ public function getNotificationsFunction($moduleDirname) $table = $this->getTable(); $tableName = $table->getVar('table_name'); $tableFieldname = $table->getVar('table_fieldname'); - $fields = $this->getTableFields($table->getVar('table_id')); - foreach (array_keys($fields) as $f) { + $tableSolename = $table->getVar('table_solename'); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + $fieldParent = 'cid'; + foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); if ((0 == $f) && (1 == $table->getVar('table_autoincrement'))) { - $fpif = $fieldName; + $fieldId = $fieldName; } - if (1 == $fields[$f]->getVar('field_main')) { - $fpmf = $fieldName; + if (1 == $fields[$f]->getVar('field_parent')) { + $fieldParent = $fieldName; + } + if (1 == $fields[$f]->getVar('field_main')) { + $fieldMain = $fieldName; } } - + if(1 == $table->getVar('table_single')) { + $tableSingle = 'single'; + } else { + $tableSingle = $tableName; + } $ret = <<prefix('{$moduleDirname}_{$tableName}') . ' WHERE {$fpif} = '. \$item_id; + \$sql = 'SELECT {$fieldMain} FROM ' . \$xoopsDB->prefix('{$moduleDirname}_{$tableName}') . ' WHERE {$fieldId} = '. \$item_id; \$result = \$xoopsDB->query(\$sql); // TODO: error check \$result_array = \$xoopsDB->fetchArray(\$result); - \$item['name'] = \$result_array['{$fpmf}']; - \$item['url'] = {$stuModuleDirname}_URL . '/{$tableName}.php?{$fpif}=' . \$item_id; + \$item['name'] = \$result_array['{$fieldMain}']; + \$item['url'] = {$stuModuleDirname}_URL . '/{$tableName}.php?{$fieldId}=' . \$item_id; return \$item; break; - case '{$tableFieldname}': + case '{$tableSolename}': // Assume we have a valid link id - \$sql = 'SELECT {$fpif}, {$fpmf} FROM '.\$xoopsDB->prefix('{$moduleDirname}_{$tableName}') . ' WHERE {$fpif} = ' . \$item_id; + \$sql = 'SELECT {$fieldId}, {$fieldMain} FROM '.\$xoopsDB->prefix('{$moduleDirname}_{$tableName}') . ' WHERE {$fieldId} = ' . \$item_id; \$result = \$xoopsDB->query(\$sql); // TODO: error check \$result_array = \$xoopsDB->fetchArray(\$result); - \$item['name'] = \$result_array['{$fpmf}']; - \$item['url'] = {$stuModuleDirname}_URL . '/{$tableName}.php?{$fieldName}=' . \$result_array['{$fieldName}'] . '&{$fpif}=' . \$item_id; - return \$item; + \$item['name'] = \$result_array['{$fieldMain}'];\n +EOT; + if ($fieldParent) { + $ret .= <<getTable(); $tableName = $table->getVar('table_name'); $tableFieldname = $table->getVar('table_fieldname'); - $fpif = ''; - $fpsf = null; - $fields = $this->getTableFields($table->getVar('table_id')); + $fieldId = ''; + $fieldSearch = null; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); if ((0 == $f) && (1 == $table->getVar('table_autoincrement'))) { - $fpif = $fieldName; + $fieldId = $fieldName; } if (1 == $fields[$f]->getVar('field_main')) { - $fpmf = $fieldName; + $fieldMain = $fieldName; } if (1 == $fields[$f]->getVar('field_search')) { - $fpsf = $fieldName; + $fieldSearch = $fieldName; } } $img_search = 'blank.gif'; @@ -137,7 +137,7 @@ public function getSearchFunction($moduleDirname) function {$moduleDirname}_search(\$queryarray, \$andor, \$limit, \$offset, \$userid) { global \$xoopsDB; - \$sql = "SELECT '{$fpif}', '{$fpmf}' FROM ".\$xoopsDB->prefix('mod_{$moduleDirname}_{$tableName}')." WHERE {$fpif} != 0"; + \$sql = "SELECT '{$fieldId}', '{$fieldMain}' FROM ".\$xoopsDB->prefix('{$moduleDirname}_{$tableName}')." WHERE {$fieldId} != 0"; if ( \$userid != 0 ) { \$sql .= " AND {$tableFieldname}_submitter=".(int) (\$userid); } @@ -145,25 +145,25 @@ function {$moduleDirname}_search(\$queryarray, \$andor, \$limit, \$offset, \$use { \$sql .= " AND ( EOT; - $ret .= $this->getSearchField($fpsf, 0) . '"'; + $ret .= $this->getSearchField($fieldSearch, 0) . '";'; $ret .= <<query(\$sql,\$limit,\$offset); \$ret = array(); \$i = 0; while(\$myrow = \$xoopsDB->fetchArray(\$result)) { - \$ret[\$i]['image'] = 'assets/images/icons/32/{$img_search}'; - \$ret[\$i]['link'] = '{$tableName}.php?{$fpif}='.\$myrow['{$fpif}']; - \$ret[\$i]['title'] = \$myrow['{$fpmf}']; + \$ret[\$i]['image'] = 'assets/icons/32/{$img_search}'; + \$ret[\$i]['link'] = '{$tableName}.php?{$fieldId}='.\$myrow['{$fieldId}']; + \$ret[\$i]['title'] = \$myrow['{$fieldMain}']; ++\$i; } unset(\$i); diff --git a/class/files/language/LanguageAdmin.php b/class/files/language/LanguageAdmin.php index 3c355891..965a344e 100644 --- a/class/files/language/LanguageAdmin.php +++ b/class/files/language/LanguageAdmin.php @@ -153,11 +153,12 @@ public function getLanguageAdminClass($language, $tables) // foreach (array_keys($tables) as $t) { $tableId = $tables[$t]->getVar('table_id'); + $tableMid = $tables[$t]->getVar('table_mid'); $tableName = $tables[$t]->getVar('table_name'); $tableSoleName = $tables[$t]->getVar('table_solename'); $ucfTableSoleName = ucfirst($tableSoleName); // - $fields = $this->getTableFields($tableId); + $fields = $this->getTableFields($tableMid, $tableId); foreach (array_keys($fields) as $f) { $fieldInForm = $fields[$f]->getVar('field_inform'); } diff --git a/class/files/language/LanguageBlocks.php b/class/files/language/LanguageBlocks.php index 153f89e8..6dff46f2 100644 --- a/class/files/language/LanguageBlocks.php +++ b/class/files/language/LanguageBlocks.php @@ -102,7 +102,7 @@ private function getLanguageBlock($module, $language) $tableName = $tables[$t]->getVar('table_name'); $ucfTableName = ucfirst($tableName); $ret .= $this->defines->getAboveDefines($ucfTableName); - $fields = $this->getTableFields($tables[$t]->getVar('table_id')); + $fields = $this->getTableFields($tables[$t]->getVar('table_mid'), $tables[$t]->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $stuFieldName = strtoupper($fieldName); diff --git a/class/files/language/LanguageMain.php b/class/files/language/LanguageMain.php index 56e969fd..e0e4e0c7 100644 --- a/class/files/language/LanguageMain.php +++ b/class/files/language/LanguageMain.php @@ -108,7 +108,7 @@ private function geLanguagetMain($module, $language) $ret .= $this->defines->getDefine($language, $stuTableName, $ucfTableName); $ret .= $this->defines->getDefine($language, "{$stuTableName}_DESC", "{$ucfTableName} description"); $ret .= $this->defines->getAboveDefines("Caption of {$ucfTableName}"); - $fields = $this->getTableFields($tables[$i]->getVar('table_id')); + $fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $stuFieldName = strtoupper($fieldName); diff --git a/class/files/sql/SqlFile.php b/class/files/sql/SqlFile.php index 0e8db691..060c3dd2 100644 --- a/class/files/sql/SqlFile.php +++ b/class/files/sql/SqlFile.php @@ -135,10 +135,11 @@ private function getDatabaseTables($moduleDirname) $tables = $this->getTables(); foreach (array_keys($tables) as $t) { $tableId = $tables[$t]->getVar('table_id'); + $tableMid = $tables[$t]->getVar('table_mid'); $tableName = $tables[$t]->getVar('table_name'); $tableAutoincrement = $tables[$t]->getVar('table_autoincrement'); $fieldsNumb = $tables[$t]->getVar('table_nbfields'); - $ret .= $this->getDatabaseFields($moduleDirname, $tableId, $tableName, $tableAutoincrement, $fieldsNumb); + $ret .= $this->getDatabaseFields($moduleDirname, $tableMid, $tableId, $tableName, $tableAutoincrement, $fieldsNumb); } return $ret; @@ -152,13 +153,13 @@ private function getDatabaseTables($moduleDirname) * @param $fieldsNumb * @return null|string */ - private function getDatabaseFields($moduleDirname, $tableId, $tableName, $tableAutoincrement, $fieldsNumb) + private function getDatabaseFields($moduleDirname, $tableMid, $tableId, $tableName, $tableAutoincrement, $fieldsNumb) { $ret = null; $j = 0; $comma = array(); $row = array(); - $fields = $this->getTableFields($tableId); + $fields = $this->getTableFields($tableMid, $tableId); foreach (array_keys($fields) as $f) { // Creation of database table $ret = $this->getHeadDatabaseTable($moduleDirname, $tableName, $fieldsNumb); diff --git a/class/files/templates/admin/TemplatesAdminPages.php b/class/files/templates/admin/TemplatesAdminPages.php index a147b395..d870713d 100644 --- a/class/files/templates/admin/TemplatesAdminPages.php +++ b/class/files/templates/admin/TemplatesAdminPages.php @@ -81,7 +81,6 @@ private function getTemplatesAdminPagesHeader($moduleDirname, $table, $fields, $ $tableSoleName = $table->getVar('table_solename'); $ret = << -<{if {$tableName}_count}> \n @@ -118,6 +117,7 @@ private function getTemplatesAdminPagesBody($moduleDirname, $table, $fields, $la $tableName = $table->getVar('table_name'); $ret = << + <{if {$tableName}_count}> <{foreach item=list from=\${$tableName}_list}> \n EOT; @@ -164,6 +164,7 @@ private function getTemplatesAdminPagesBody($moduleDirname, $table, $fields, $la <{/foreach}> + <{/if}>
\n EOT; @@ -184,6 +185,7 @@ private function getTemplatesAdminPagesBodyFieldnameEmpty($moduleDirname, $table $tableName = $table->getVar('table_name'); $ret = << + <{if {$tableName}_count}> <{foreach item=list from=\${$tableName}_list}> \n EOT; @@ -229,6 +231,7 @@ private function getTemplatesAdminPagesBodyFieldnameEmpty($moduleDirname, $table <{/foreach}> + <{/if}> \n EOT; @@ -249,7 +252,6 @@ private function getTemplatesAdminPagesFooter($moduleDirname)
<{\$pagenav}>
<{/if}> -<{/if}> <{if \$form}>
<{\$form}>
@@ -279,7 +281,7 @@ public function renderFile($filename) $moduleDirname = $module->getVar('mod_dirname'); $tableFieldname = $table->getVar('table_fieldname'); $language = $this->getLanguage($moduleDirname, 'AM'); - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); $content = $this->getTemplatesAdminPagesHeader($moduleDirname, $table, $fields, $language); // Verify if table_fieldname is not empty if (!empty($tableFieldname)) { diff --git a/class/files/templates/admin/TemplatesAdminPermissions.php b/class/files/templates/admin/TemplatesAdminPermissions.php index 4c3a80b4..c0535631 100644 --- a/class/files/templates/admin/TemplatesAdminPermissions.php +++ b/class/files/templates/admin/TemplatesAdminPermissions.php @@ -71,14 +71,14 @@ public function write($module, $filename) } /* - * @private function getTemplatesAdminPagesHeader + * @private function getTemplatesAdminPermissionsHeader * @param string $moduleDirname */ /** * @param $moduleDirname * @return string */ - private function getTemplatesAdminPermissions($moduleDirname) + private function getTemplatesAdminPermissionsHeader($moduleDirname) { $ret = <<\n @@ -86,6 +86,42 @@ private function getTemplatesAdminPermissions($moduleDirname) return $ret; } + + /* + * @private function getTemplatesAdminPermissions + * @param null + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesAdminPermissions() + { + $ret = <<<{\$form}> +

\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesAdminPermissionsFooter + * @param string $moduleDirname + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesAdminPermissionsFooter($moduleDirname) + { + $ret = <<\n +EOT; + + return $ret; + } + /* * @public function render @@ -100,7 +136,9 @@ public function render() $filename = $this->getFileName(); $moduleDirname = $module->getVar('mod_dirname'); $language = $this->getLanguage($moduleDirname, 'AM'); - $content = $this->getTemplatesAdminPermissions($moduleDirname); + $content = $this->getTemplatesAdminPermissionsHeader($moduleDirname); + $content .= $this->getTemplatesAdminPermissions(); + $content .= $this->getTemplatesAdminPermissionsFooter($moduleDirname); // $this->tdmcfile->create($moduleDirname, 'templates/admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); diff --git a/class/files/templates/blocks/TemplatesBlocks.php b/class/files/templates/blocks/TemplatesBlocks.php index 0cd52631..498bf7c4 100644 --- a/class/files/templates/blocks/TemplatesBlocks.php +++ b/class/files/templates/blocks/TemplatesBlocks.php @@ -90,7 +90,7 @@ private function getTemplatesBlocksHeader($moduleDirname, $table, $language) \n EOT; - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $lang_stu_field_name = $language . strtoupper($fieldName); @@ -126,7 +126,7 @@ private function getTemplatesBlocksBody($moduleDirname, $table, $language) <{foreach item=list from=\${$tableName}}> \n EOT; - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldElement = $fields[$f]->getVar('field_element'); @@ -188,7 +188,7 @@ private function getTemplatesBlocksBodyFieldnameEmpty($moduleDirname, $table, $l <{foreach item=list from=\${$tableName}}> \n EOT; - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldElement = $fields[$f]->getVar('field_element'); diff --git a/class/files/templates/user/TemplatesUserBroken.php b/class/files/templates/user/TemplatesUserBroken.php new file mode 100644 index 00000000..de45e1dc --- /dev/null +++ b/class/files/templates/user/TemplatesUserBroken.php @@ -0,0 +1,271 @@ +tdmcfile = TDMCreateFile::getInstance(); + } + + /* + * @static function &getInstance + * @param null + */ + /** + * @return TemplatesUserBroken + */ + public static function &getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + + return $instance; + } + + /* + * @public function write + * @param string $module + * @param string $table + * @param string $filename + */ + /** + * @param $module + * @param $table + */ + public function write($module, $table) + { + $this->setModule($module); + $this->setTable($table); + } + + /* + * @private function getTemplatesUserBrokenHeader + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserBrokenHeader($moduleDirname, $table, $language) + { + $ret = << + + + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $langStuFieldName = $language . strtoupper($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + $ret .= <<<{\$smarty.const.{$langStuFieldName}}>\n +EOT; + } + } + $ret .= << + \n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserBrokenBody + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserBrokenBody($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + $rpFieldName = $this->tdmcfile->getRightString($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\t\t\n +EOT; + break; + case 10: + $ret .= <<{$tableName}\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$rpFieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +
\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserBrokenBodyFieldnameEmpty + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserBrokenBodyFieldnameEmpty($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$fieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserBrokenFooter + * @param string $moduleDirname + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesUserBrokenFooter($moduleDirname) + { + $ret = << +EOT; + + return $ret; + } + + /* + * @public function renderFile + * @param string $filename + */ + /** + * @param $filename + * @return bool|string + */ + public function renderFile($filename) + { + $module = $this->getModule(); + $table = $this->getTable(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableFieldname = $table->getVar('table_fieldname'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getTemplatesUserBrokenHeader($moduleDirname, $table, $language); + // Verify if table_fieldname is not empty + if (!empty($tableFieldname)) { + $content .= $this->getTemplatesUserBrokenBody($moduleDirname, $table, $language); + } else { + $content .= $this->getTemplatesUserBrokenBodyFieldnameEmpty($moduleDirname, $table, $language); + } + $content .= $this->getTemplatesUserBrokenFooter($moduleDirname); + // + $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + + return $this->tdmcfile->renderFile(); + } +} diff --git a/class/files/templates/user/TemplatesUserPages.php b/class/files/templates/user/TemplatesUserPages.php index 28b7a7ef..b2639ee4 100644 --- a/class/files/templates/user/TemplatesUserPages.php +++ b/class/files/templates/user/TemplatesUserPages.php @@ -91,7 +91,7 @@ private function getTemplatesUserPagesHeader($moduleDirname, $table, $language) \n EOT; - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $langStuFieldName = $language . strtoupper($fieldName); @@ -129,7 +129,7 @@ private function getTemplatesUserPagesBody($moduleDirname, $table, $language) <{foreach item=list from=\${$tableName}}> \n EOT; - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldElement = $fields[$f]->getVar('field_element'); @@ -189,7 +189,7 @@ private function getTemplatesUserPagesBodyFieldnameEmpty($moduleDirname, $table, <{foreach item=list from=\${$tableName}}> \n EOT; - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldElement = $fields[$f]->getVar('field_element'); diff --git a/class/files/templates/user/TemplatesUserPdf.php b/class/files/templates/user/TemplatesUserPdf.php new file mode 100644 index 00000000..eca6566f --- /dev/null +++ b/class/files/templates/user/TemplatesUserPdf.php @@ -0,0 +1,271 @@ +tdmcfile = TDMCreateFile::getInstance(); + } + + /* + * @static function &getInstance + * @param null + */ + /** + * @return TemplatesUserPdf + */ + public static function &getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + + return $instance; + } + + /* + * @public function write + * @param string $module + * @param string $table + * @param string $filename + */ + /** + * @param $module + * @param $table + */ + public function write($module, $table) + { + $this->setModule($module); + $this->setTable($table); + } + + /* + * @private function getTemplatesUserPdfHeader + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserPdfHeader($moduleDirname, $table, $language) + { + $ret = << + + + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $langStuFieldName = $language . strtoupper($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + $ret .= <<<{\$smarty.const.{$langStuFieldName}}>\n +EOT; + } + } + $ret .= << + \n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserPdfBody + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserPdfBody($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + $rpFieldName = $this->tdmcfile->getRightString($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\t\t\n +EOT; + break; + case 10: + $ret .= <<{$tableName}\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$rpFieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +
\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserPdfBodyFieldnameEmpty + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserPdfBodyFieldnameEmpty($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$fieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserPdfFooter + * @param string $moduleDirname + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesUserPdfFooter($moduleDirname) + { + $ret = << +EOT; + + return $ret; + } + + /* + * @public function renderFile + * @param string $filename + */ + /** + * @param $filename + * @return bool|string + */ + public function renderFile($filename) + { + $module = $this->getModule(); + $table = $this->getTable(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableFieldname = $table->getVar('table_fieldname'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getTemplatesUserPdfHeader($moduleDirname, $table, $language); + // Verify if table_fieldname is not empty + if (!empty($tableFieldname)) { + $content .= $this->getTemplatesUserPdfBody($moduleDirname, $table, $language); + } else { + $content .= $this->getTemplatesUserPdfBodyFieldnameEmpty($moduleDirname, $table, $language); + } + $content .= $this->getTemplatesUserPdfFooter($moduleDirname); + // + $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + + return $this->tdmcfile->renderFile(); + } +} diff --git a/class/files/templates/user/TemplatesUserPrint.php b/class/files/templates/user/TemplatesUserPrint.php new file mode 100644 index 00000000..124766d8 --- /dev/null +++ b/class/files/templates/user/TemplatesUserPrint.php @@ -0,0 +1,271 @@ +tdmcfile = TDMCreateFile::getInstance(); + } + + /* + * @static function &getInstance + * @param null + */ + /** + * @return TemplatesUserPrint + */ + public static function &getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + + return $instance; + } + + /* + * @public function write + * @param string $module + * @param string $table + * @param string $filename + */ + /** + * @param $module + * @param $table + */ + public function write($module, $table) + { + $this->setModule($module); + $this->setTable($table); + } + + /* + * @private function getTemplatesUserPrintHeader + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserPrintHeader($moduleDirname, $table, $language) + { + $ret = << + + + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $langStuFieldName = $language . strtoupper($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + $ret .= <<<{\$smarty.const.{$langStuFieldName}}>\n +EOT; + } + } + $ret .= << + \n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserPrintBody + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserPrintBody($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + $rpFieldName = $this->tdmcfile->getRightString($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\t\t\n +EOT; + break; + case 10: + $ret .= <<{$tableName}\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$rpFieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +
\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserPrintBodyFieldnameEmpty + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserPrintBodyFieldnameEmpty($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$fieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserPrintFooter + * @param string $moduleDirname + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesUserPrintFooter($moduleDirname) + { + $ret = << +EOT; + + return $ret; + } + + /* + * @public function renderFile + * @param string $filename + */ + /** + * @param $filename + * @return bool|string + */ + public function renderFile($filename) + { + $module = $this->getModule(); + $table = $this->getTable(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableFieldname = $table->getVar('table_fieldname'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getTemplatesUserPrintHeader($moduleDirname, $table, $language); + // Verify if table_fieldname is not empty + if (!empty($tableFieldname)) { + $content .= $this->getTemplatesUserPrintBody($moduleDirname, $table, $language); + } else { + $content .= $this->getTemplatesUserPrintBodyFieldnameEmpty($moduleDirname, $table, $language); + } + $content .= $this->getTemplatesUserPrintFooter($moduleDirname); + // + $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + + return $this->tdmcfile->renderFile(); + } +} diff --git a/class/files/templates/user/TemplatesUserRate.php b/class/files/templates/user/TemplatesUserRate.php new file mode 100644 index 00000000..d7b8b9d4 --- /dev/null +++ b/class/files/templates/user/TemplatesUserRate.php @@ -0,0 +1,271 @@ +tdmcfile = TDMCreateFile::getInstance(); + } + + /* + * @static function &getInstance + * @param null + */ + /** + * @return TemplatesUserRate + */ + public static function &getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + + return $instance; + } + + /* + * @public function write + * @param string $module + * @param string $table + * @param string $filename + */ + /** + * @param $module + * @param $table + */ + public function write($module, $table) + { + $this->setModule($module); + $this->setTable($table); + } + + /* + * @private function getTemplatesUserRateHeader + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserRateHeader($moduleDirname, $table, $language) + { + $ret = << + + + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $langStuFieldName = $language . strtoupper($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + $ret .= <<<{\$smarty.const.{$langStuFieldName}}>\n +EOT; + } + } + $ret .= << + \n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserRateBody + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserRateBody($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + $rpFieldName = $this->tdmcfile->getRightString($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\t\t\n +EOT; + break; + case 10: + $ret .= <<{$tableName}\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$rpFieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +
\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserRateBodyFieldnameEmpty + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserRateBodyFieldnameEmpty($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$fieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserRateFooter + * @param string $moduleDirname + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesUserRateFooter($moduleDirname) + { + $ret = << +EOT; + + return $ret; + } + + /* + * @public function renderFile + * @param string $filename + */ + /** + * @param $filename + * @return bool|string + */ + public function renderFile($filename) + { + $module = $this->getModule(); + $table = $this->getTable(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableFieldname = $table->getVar('table_fieldname'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getTemplatesUserRateHeader($moduleDirname, $table, $language); + // Verify if table_fieldname is not empty + if (!empty($tableFieldname)) { + $content .= $this->getTemplatesUserRateBody($moduleDirname, $table, $language); + } else { + $content .= $this->getTemplatesUserRateBodyFieldnameEmpty($moduleDirname, $table, $language); + } + $content .= $this->getTemplatesUserRateFooter($moduleDirname); + // + $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + + return $this->tdmcfile->renderFile(); + } +} diff --git a/class/files/templates/user/TemplatesUserRss.php b/class/files/templates/user/TemplatesUserRss.php new file mode 100644 index 00000000..fe5e6dfa --- /dev/null +++ b/class/files/templates/user/TemplatesUserRss.php @@ -0,0 +1,271 @@ +tdmcfile = TDMCreateFile::getInstance(); + } + + /* + * @static function &getInstance + * @param null + */ + /** + * @return TemplatesUserRss + */ + public static function &getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + + return $instance; + } + + /* + * @public function write + * @param string $module + * @param string $table + * @param string $filename + */ + /** + * @param $module + * @param $table + */ + public function write($module, $table) + { + $this->setModule($module); + $this->setTable($table); + } + + /* + * @private function getTemplatesUserRssHeader + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserRssHeader($moduleDirname, $table, $language) + { + $ret = << + + + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $langStuFieldName = $language . strtoupper($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + $ret .= <<<{\$smarty.const.{$langStuFieldName}}>\n +EOT; + } + } + $ret .= << + \n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserRssBody + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserRssBody($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + $rpFieldName = $this->tdmcfile->getRightString($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\t\t\n +EOT; + break; + case 10: + $ret .= <<{$tableName}\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$rpFieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +
\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserRssBodyFieldnameEmpty + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserRssBodyFieldnameEmpty($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$fieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserRssFooter + * @param string $moduleDirname + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesUserRssFooter($moduleDirname) + { + $ret = << +EOT; + + return $ret; + } + + /* + * @public function renderFile + * @param string $filename + */ + /** + * @param $filename + * @return bool|string + */ + public function renderFile($filename) + { + $module = $this->getModule(); + $table = $this->getTable(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableFieldname = $table->getVar('table_fieldname'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getTemplatesUserRssHeader($moduleDirname, $table, $language); + // Verify if table_fieldname is not empty + if (!empty($tableFieldname)) { + $content .= $this->getTemplatesUserRssBody($moduleDirname, $table, $language); + } else { + $content .= $this->getTemplatesUserRssBodyFieldnameEmpty($moduleDirname, $table, $language); + } + $content .= $this->getTemplatesUserRssFooter($moduleDirname); + // + $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + + return $this->tdmcfile->renderFile(); + } +} diff --git a/class/files/templates/user/TemplatesUserSearch.php b/class/files/templates/user/TemplatesUserSearch.php new file mode 100644 index 00000000..68893b11 --- /dev/null +++ b/class/files/templates/user/TemplatesUserSearch.php @@ -0,0 +1,271 @@ +tdmcfile = TDMCreateFile::getInstance(); + } + + /* + * @static function &getInstance + * @param null + */ + /** + * @return TemplatesUserSearch + */ + public static function &getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + + return $instance; + } + + /* + * @public function write + * @param string $module + * @param string $table + * @param string $filename + */ + /** + * @param $module + * @param $table + */ + public function write($module, $table) + { + $this->setModule($module); + $this->setTable($table); + } + + /* + * @private function getTemplatesUserSearchHeader + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserSearchHeader($moduleDirname, $table, $language) + { + $ret = << + + + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $langStuFieldName = $language . strtoupper($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + $ret .= <<<{\$smarty.const.{$langStuFieldName}}>\n +EOT; + } + } + $ret .= << + \n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserSearchBody + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserSearchBody($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + $rpFieldName = $this->tdmcfile->getRightString($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\t\t\n +EOT; + break; + case 10: + $ret .= <<{$tableName}\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$rpFieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +
\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserSearchBodyFieldnameEmpty + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserSearchBodyFieldnameEmpty($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$fieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserSearchFooter + * @param string $moduleDirname + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesUserSearchFooter($moduleDirname) + { + $ret = << +EOT; + + return $ret; + } + + /* + * @public function renderFile + * @param string $filename + */ + /** + * @param $filename + * @return bool|string + */ + public function renderFile($filename) + { + $module = $this->getModule(); + $table = $this->getTable(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableFieldname = $table->getVar('table_fieldname'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getTemplatesUserSearchHeader($moduleDirname, $table, $language); + // Verify if table_fieldname is not empty + if (!empty($tableFieldname)) { + $content .= $this->getTemplatesUserSearchBody($moduleDirname, $table, $language); + } else { + $content .= $this->getTemplatesUserSearchBodyFieldnameEmpty($moduleDirname, $table, $language); + } + $content .= $this->getTemplatesUserSearchFooter($moduleDirname); + // + $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + + return $this->tdmcfile->renderFile(); + } +} diff --git a/class/files/templates/user/TemplatesUserSingle.php b/class/files/templates/user/TemplatesUserSingle.php new file mode 100644 index 00000000..9ee217b9 --- /dev/null +++ b/class/files/templates/user/TemplatesUserSingle.php @@ -0,0 +1,271 @@ +tdmcfile = TDMCreateFile::getInstance(); + } + + /* + * @static function &getInstance + * @param null + */ + /** + * @return TemplatesUserSingle + */ + public static function &getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + + return $instance; + } + + /* + * @public function write + * @param string $module + * @param string $table + * @param string $filename + */ + /** + * @param $module + * @param $table + */ + public function write($module, $table) + { + $this->setModule($module); + $this->setTable($table); + } + + /* + * @private function getTemplatesUserSingleHeader + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserSingleHeader($moduleDirname, $table, $language) + { + $ret = << + + + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $langStuFieldName = $language . strtoupper($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + $ret .= <<<{\$smarty.const.{$langStuFieldName}}>\n +EOT; + } + } + $ret .= << + \n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserSingleBody + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserSingleBody($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + $rpFieldName = $this->tdmcfile->getRightString($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\t\t\n +EOT; + break; + case 10: + $ret .= <<{$tableName}\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$rpFieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +
\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserSingleBodyFieldnameEmpty + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserSingleBodyFieldnameEmpty($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$fieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserSingleFooter + * @param string $moduleDirname + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesUserSingleFooter($moduleDirname) + { + $ret = << +EOT; + + return $ret; + } + + /* + * @public function renderFile + * @param string $filename + */ + /** + * @param $filename + * @return bool|string + */ + public function renderFile($filename) + { + $module = $this->getModule(); + $table = $this->getTable(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableFieldname = $table->getVar('table_fieldname'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getTemplatesUserSingleHeader($moduleDirname, $table, $language); + // Verify if table_fieldname is not empty + if (!empty($tableFieldname)) { + $content .= $this->getTemplatesUserSingleBody($moduleDirname, $table, $language); + } else { + $content .= $this->getTemplatesUserSingleBodyFieldnameEmpty($moduleDirname, $table, $language); + } + $content .= $this->getTemplatesUserSingleFooter($moduleDirname); + // + $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + + return $this->tdmcfile->renderFile(); + } +} diff --git a/class/files/templates/user/TemplatesUserSubmit.php b/class/files/templates/user/TemplatesUserSubmit.php new file mode 100644 index 00000000..98115a63 --- /dev/null +++ b/class/files/templates/user/TemplatesUserSubmit.php @@ -0,0 +1,271 @@ +tdmcfile = TDMCreateFile::getInstance(); + } + + /* + * @static function &getInstance + * @param null + */ + /** + * @return TemplatesUserSubmit + */ + public static function &getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + + return $instance; + } + + /* + * @public function write + * @param string $module + * @param string $table + * @param string $filename + */ + /** + * @param $module + * @param $table + */ + public function write($module, $table) + { + $this->setModule($module); + $this->setTable($table); + } + + /* + * @private function getTemplatesUserSubmitHeader + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserSubmitHeader($moduleDirname, $table, $language) + { + $ret = << + + + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $langStuFieldName = $language . strtoupper($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + $ret .= <<<{\$smarty.const.{$langStuFieldName}}>\n +EOT; + } + } + $ret .= << + \n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserSubmitBody + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserSubmitBody($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + $rpFieldName = $this->tdmcfile->getRightString($fieldName); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\t\t\n +EOT; + break; + case 10: + $ret .= <<{$tableName}\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$rpFieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +
\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserSubmitBodyFieldnameEmpty + * @param string $moduleDirname + * @param string $table + * @param string $language + */ + /** + * @param $moduleDirname + * @param $table + * @param $language + * @return string + */ + private function getTemplatesUserSubmitBodyFieldnameEmpty($moduleDirname, $table, $language) + { + $tableName = $table->getVar('table_name'); + $ret = << + <{foreach item=list from=\${$tableName}}> + \n +EOT; + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if ((1 == $table->getVar('table_autoincrement')) || (1 == $fields[$f]->getVar('field_user'))) { + switch ($fieldElement) { + case 9: + $ret .= <<\n +EOT; + break; + case 13: + $ret .= <<{$tableName}\n +EOT; + break; + default: + $ret .= <<<{\$list.{$fieldName}}>\n +EOT; + break; + } + } + } + $ret .= << + <{/foreach}> + +\n +EOT; + + return $ret; + } + + /* + * @private function getTemplatesUserSubmitFooter + * @param string $moduleDirname + */ + /** + * @param $moduleDirname + * @return string + */ + private function getTemplatesUserSubmitFooter($moduleDirname) + { + $ret = << +EOT; + + return $ret; + } + + /* + * @public function renderFile + * @param string $filename + */ + /** + * @param $filename + * @return bool|string + */ + public function renderFile($filename) + { + $module = $this->getModule(); + $table = $this->getTable(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableFieldname = $table->getVar('table_fieldname'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getTemplatesUserSubmitHeader($moduleDirname, $table, $language); + // Verify if table_fieldname is not empty + if (!empty($tableFieldname)) { + $content .= $this->getTemplatesUserSubmitBody($moduleDirname, $table, $language); + } else { + $content .= $this->getTemplatesUserSubmitBodyFieldnameEmpty($moduleDirname, $table, $language); + } + $content .= $this->getTemplatesUserSubmitFooter($moduleDirname); + // + $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + + return $this->tdmcfile->renderFile(); + } +} diff --git a/class/files/user/UserBroken.php b/class/files/user/UserBroken.php index 0f17d932..055d0e3c 100644 --- a/class/files/user/UserBroken.php +++ b/class/files/user/UserBroken.php @@ -23,7 +23,7 @@ /** * Class UserBroken */ -class UserBroken extends TDMCreateFile +class UserBroken extends UserObjects { /* * @public function constructor @@ -34,7 +34,9 @@ class UserBroken extends TDMCreateFile */ public function __construct() { - $this->tdmcfile = TDMCreateFile::getInstance(); + parent::__construct(); + $this->tdmcfile = TDMCreateFile::getInstance(); + $this->userobjects = UserObjects::getInstance(); } /* @@ -153,36 +155,21 @@ public function getUserBrokenForm($module, $tableName, $language) * @param $tableName * @return string */ - public function getUserBrokenSave($moduleDirname, $table_id, $tableName) + public function getUserBrokenSave($moduleDirname, $fields, $tableName, $language) { - $ret = <<userobjects->getUserSaveFieldId($fields); + $ret = <<check() ) { redirect_header('{$tableName}.php', 3, implode(',', \$GLOBALS['xoopsSecurity']->getErrors())); } - if (isset(\$_REQUEST['{$fpif}'])) { - \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fpif}']); + if (isset(\$_REQUEST['{$fieldId}'])) { + \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fieldId}']); } else { \${$tableName}Obj =& \${$tableName}Handler->create(); } EOT; - $fields = $this->getTableFields($table_id); - foreach (array_keys($fields) as $f) { - $fieldName = $fields[$f]->getVar('field_name'); - $fieldElement = $fields[$f]->getVar('field_element'); - if ((5 == $fieldElement) || (6 == $fieldElement)) { - $ret .= $this->adminobjects->getCheckBoxOrRadioYN($tableName, $fieldName); - } elseif (13 == $fieldElement) { - $ret .= $this->adminobjects->getUploadImage($moduleDirname, $tableName, $fieldName); - } elseif (14 == $fieldElement) { - $ret .= $this->adminobjects->getUploadFile($moduleDirname, $tableName, $fieldName); - } elseif (15 == $fieldElement) { - $ret .= $this->adminobjects->getTextDateSelect($tableName, $fieldName); - } else { - $ret .= $this->adminobjects->getSimpleSetVar($tableName, $fieldName); - } - } - + $ret .= $this->userobjects->getUserSaveElements($moduleDirname, $tableName, $fields); $ret .= <<insert(\${$tableName}Obj)) { redirect_header('index.php', 2, {$language}FORMOK); @@ -226,13 +213,15 @@ public function render() $table = $this->getTable(); $filename = $this->getFileName(); $moduleDirname = $module->getVar('mod_dirname'); - $table_id = $table->getVar('table_id'); + $tableId = $table->getVar('table_id'); + $tableMid = $table->getVar('table_mid'); $tableName = $table->getVar('table_name'); + $fields = $this->tdmcfile->getTableFields($tableMid, $tableId); $language = $this->getLanguage($moduleDirname, 'MA'); $content = $this->getHeaderFilesComments($module, $filename); $content .= $this->getUserBrokenHeader($moduleDirname); $content .= $this->getUserBrokenForm($module, $tableName, $language); - $content .= $this->getUserBrokenSave($moduleDirname, $table_id, $tableName); + $content .= $this->getUserBrokenSave($moduleDirname, $fields, $tableName, $language); $content .= $this->getUserBrokenFooter(); $this->tdmcfile->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); diff --git a/class/files/user/UserObjects.php b/class/files/user/UserObjects.php index 4ec7c767..26aaecde 100644 --- a/class/files/user/UserObjects.php +++ b/class/files/user/UserObjects.php @@ -23,9 +23,27 @@ /** * Class UserObjects */ -class UserObjects +class UserObjects extends TDMCreateFile { /* + * @var string + */ + protected $userobjects; + + /* + * @public function constructor + * @param null + */ + /** + * + */ + public function __construct() + { + parent::__construct(); + $this->tdmcfile = TDMCreateFile::getInstance(); + } + + /* * @static function &getInstance * @param null */ @@ -87,7 +105,228 @@ public function getUserFooter() EOT; return $ret; } + + /* + * @public function getSimpleSetVar + * @param string $tableName + * @param string $fieldName + * @return string + */ + public function getSimpleSetVar($tableName, $fieldName) + { + $ret = <<setVar('{$fieldName}', \$_POST['{$fieldName}']);\n +EOT; + return $ret; + } + /* + * @public function getTextDateSelectSetVar + * @param string $tableName + * @param string $fieldName + * @return string + */ + public function getTextDateSelectSetVar($tableName, $fieldName) + { + $ret = <<setVar('{$fieldName}', strtotime(\$_POST['{$fieldName}']));\n +EOT; + return $ret; + } + + /* + * @public function getCheckBoxOrRadioYNSetVar + * @param string $tableName + * @param string $fieldName + * @return string + */ + public function getCheckBoxOrRadioYNSetVar($tableName, $fieldName) + { + $ret = <<setVar('{$fieldName}', ((1 == \$_REQUEST['{$fieldName}']) ? '1' : '0'));\n +EOT; + return $ret; + } + + /* + * @public function getUrlFileSetVar + * @param $moduleDirname + * @param $tableName + * @param $fieldName + * @return string + */ + public function getUrlFileSetVar($moduleDirname, $tableName, $fieldName) + { + $stuModuleDirname = strtoupper($moduleDirname); + $ret = <<setVar('{$fieldName}', formatUrl(\$_REQUEST['{$fieldName}']));\n + // Set Var {$fieldName} + include_once XOOPS_ROOT_PATH.'/class/uploader.php'; + \$uploaddir = {$stuModuleDirname}_UPLOAD_PATH.'/files/{$tableName}'; + \$uploader = new XoopsMediaUploader(\$uploaddir, \${$moduleDirname}->getConfig('mimetypes'), + \${$moduleDirname}->getConfig('maxsize'), null, null); + if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][])) { + \$uploader->fetchMedia(\$_POST['xoops_upload_file'][]); + if (!\$uploader->upload()) { + \$errors = \$uploader->getErrors(); + redirect_header('javascript:history.go(-1)', 3, \$errors); + } else { + \${$tableName}Obj->setVar('{$fieldName}', \$uploader->getSavedFileName()); + } + }\n +EOT; + + return $ret; + } + + /* + * @public function getImageListSetVar + * @param string $moduleDirname + * @param string $tableName + * @param string $fieldName + * @return string + */ + public function getImageListSetVar($moduleDirname, $tableName, $fieldName) + { + $ret = <<getConfig('mimetypes'), + \${$moduleDirname}->getConfig('maxsize'), null, null); + if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][])) { + //\$uploader->setPrefix('{$fieldName}_'); + //\$uploader->fetchMedia(\$_POST['xoops_upload_file'][]); + if (!\$uploader->upload()) { + \$errors = \$uploader->getErrors(); + redirect_header('javascript:history.go(-1)', 3, \$errors); + } else { + \${$tableName}Obj->setVar('{$fieldName}', \$uploader->getSavedFileName()); + } + } else { + \${$tableName}Obj->setVar('{$fieldName}', \$_POST['{$fieldName}']); + }\n +EOT; + return $ret; + } + + /* + * @public function getUploadImageSetVar + * @param string $moduleDirname + * @param string $tableName + * @param string $fieldName + * @return string + */ + public function getUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fpmf) + { + $stuModuleDirname = strtoupper($moduleDirname); + $ret = <<getConfig('mimetypes'), + \${$moduleDirname}->getConfig('maxsize'), null, null); + if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][0])) { + \$extension = preg_replace( '/^.+\.([^.]+)$/sU' , '' , \$_FILES['attachedfile']['name']); + \$imgName = str_replace(' ', '', \$_POST['{$fpmf}']).'.'.\$extension; + \$uploader->setPrefix(\$imgName); + \$uploader->fetchMedia(\$_POST['xoops_upload_file'][0]); + if (!\$uploader->upload()) { + \$errors = \$uploader->getErrors(); + redirect_header('javascript:history.go(-1)', 3, \$errors); + } else { + \${$tableName}Obj->setVar('{$fieldName}', \$uploader->getSavedFileName()); + } + } else { + \${$tableName}Obj->setVar('{$fieldName}', \$_POST['{$fieldName}']); + }\n +EOT; + return $ret; + } + + /* + * @public function getUploadFileSetVar + * @param string $moduleDirname + * @param string $tableName + * @param string $fieldName + * @return string + */ + public function getUploadFileSetVar($moduleDirname, $tableName, $fieldName) + { + $stuModuleDirname = strtoupper($moduleDirname); + $ret = <<getConfig('mimetypes'), + \${$moduleDirname}->getConfig('maxsize'), null, null); + if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][])) { + //\$uploader->setPrefix('{$fieldName}_') ; + //\$uploader->fetchMedia(\$_POST['xoops_upload_file'][]); + if (!\$uploader->upload()) { + \$errors = \$uploader->getErrors(); + redirect_header('javascript:history.go(-1)', 3, \$errors); + } else { + \${$tableName}Obj->setVar('{$fieldName}', \$uploader->getSavedFileName()); + } + }\n +EOT; + return $ret; + } + + /** + * @public function getUserSaveElements + * + * @param $fields + * @return string + */ + public function getUserSaveFieldId($fields) + { + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + if (0 == $f) { + $fieldId = $fieldName; + } + } + return $fieldId; + } + + /** + * @public function getUserSaveElements + * + * @param $moduleDirname + * @param $tableName + * @param $fields + * @return string + */ + public function getUserSaveElements($moduleDirname, $tableName, $fields) + { + $ret = ''; + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if(1 == $fields[$f]->getVar('field_main')) { + $fieldMain = $fieldName; + } + if ((5 == $fieldElement) || (6 == $fieldElement)) { + $ret .= $this->getCheckBoxOrRadioYNSetVar($tableName, $fieldName); + } elseif (13 == $fieldElement) { + $ret .= $this->getUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fieldMain); + } elseif (14 == $fieldElement) { + $ret .= $this->getUploadFileSetVar($moduleDirname, $tableName, $fieldName); + } elseif (15 == $fieldElement) { + $ret .= $this->getTextDateSelectSetVar($tableName, $fieldName); + } else { + $ret .= $this->getSimpleSetVar($tableName, $fieldName); + } + } + return $ret; + } + /* * @public function getSimpleGetVar * @param string $lpFieldName diff --git a/class/files/user/UserPages.php b/class/files/user/UserPages.php index f5d8df0b..12305be3 100644 --- a/class/files/user/UserPages.php +++ b/class/files/user/UserPages.php @@ -19,18 +19,12 @@ * @version $Id: pages.php 12258 2014-01-02 09:33:29Z timgno $ */ defined('XOOPS_ROOT_PATH') or die('Restricted access'); -require_once 'UserObjects.php'; /** * Class UserPages */ -class UserPages extends TDMCreateFile +class UserPages extends UserObjects { - /* - * @var string - */ - private $userobjects; - /* * @public function constructor * @param null @@ -120,7 +114,7 @@ private function getUserPages($moduleDirname, $language) {\n EOT; // Fields - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldParent = $fields[$f]->getVar('field_parent'); diff --git a/class/files/user/UserPdf.php b/class/files/user/UserPdf.php index 85cf71eb..b0d99809 100644 --- a/class/files/user/UserPdf.php +++ b/class/files/user/UserPdf.php @@ -23,7 +23,7 @@ /** * Class UserPdf */ -class UserPdf extends TDMCreateFile +class UserPdf extends UserObjects { /* * @public function constructor @@ -34,7 +34,9 @@ class UserPdf extends TDMCreateFile */ public function __construct() { - $this->tdmcfile = TDMCreateFile::getInstance(); + parent::__construct(); + $this->tdmcfile = TDMCreateFile::getInstance(); + $this->userobjects = UserObjects::getInstance(); } /* @@ -150,40 +152,26 @@ public function getUserPdfForm($module, $tableName, $language) */ /** * @param $moduleDirname - * @param $table_id + * @param $fields * @param $tableName + * @param $language * @return string */ - public function getUserPdfSave($moduleDirname, $table_id, $tableName) + public function getUserPdfSave($moduleDirname, $fields, $tableName, $language) { - $ret = <<userobjects->getUserSaveFieldId($fields); + $ret = <<check() ) { redirect_header('{$tableName}.php', 3, implode(',', \$GLOBALS['xoopsSecurity']->getErrors())); } - if (isset(\$_REQUEST['{$fpif}'])) { - \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fpif}']); + if (isset(\$_REQUEST['{$fieldId}'])) { + \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fieldId}']); } else { \${$tableName}Obj =& \${$tableName}Handler->create(); } EOT; - $fields = $this->getTableFields($table_id); - foreach (array_keys($fields) as $f) { - $fieldName = $fields[$f]->getVar('field_name'); - $fieldElement = $fields[$f]->getVar('field_element'); - if ((5 == $fieldElement) || (6 == $fieldElement)) { - $ret .= $this->adminobjects->getCheckBoxOrRadioYN($tableName, $fieldName); - } elseif (13 == $fieldElement) { - $ret .= $this->adminobjects->getUploadImage($moduleDirname, $tableName, $fieldName); - } elseif (14 == $fieldElement) { - $ret .= $this->adminobjects->getUploadFile($moduleDirname, $tableName, $fieldName); - } elseif (15 == $fieldElement) { - $ret .= $this->adminobjects->getTextDateSelect($tableName, $fieldName); - } else { - $ret .= $this->adminobjects->getSimpleSetVar($tableName, $fieldName); - } - } - + $ret .= $this->userobjects->getUserSaveElements($moduleDirname, $tableName, $fields); $ret .= <<insert(\${$tableName}Obj)) { redirect_header('index.php', 2, {$language}FORMOK); @@ -227,13 +215,15 @@ public function render() $table = $this->getTable(); $filename = $this->getFileName(); $moduleDirname = $module->getVar('mod_dirname'); - $table_id = $table->getVar('table_id'); + $tableId = $table->getVar('table_id'); + $tableMid = $table->getVar('table_mid'); $tableName = $table->getVar('table_name'); + $fields = $this->tdmcfile->getTableFields($tableMid, $tableId); $language = $this->getLanguage($moduleDirname, 'MA'); $content = $this->getHeaderFilesComments($module, $filename); $content .= $this->getUserPdfHeader($moduleDirname); $content .= $this->getUserPdfForm($module, $tableName, $language); - $content .= $this->getUserPdfSave($moduleDirname, $table_id, $tableName); + $content .= $this->getUserPdfSave($moduleDirname, $fields, $tableName, $language); $content .= $this->getUserPdfFooter(); $this->tdmcfile->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); diff --git a/class/files/user/UserPrint.php b/class/files/user/UserPrint.php index 38467113..b77b0f21 100644 --- a/class/files/user/UserPrint.php +++ b/class/files/user/UserPrint.php @@ -89,7 +89,7 @@ public function getUserPrint($moduleDirname, $language) $tableName = $table->getVar('table_name'); $ucfModuleDirname = ucfirst($moduleDirname); $ucfTableName = ucfirst($tableName); - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->tdmcfile->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $fieldName; @@ -101,25 +101,25 @@ public function getUserPrint($moduleDirname, $language) } $lpFieldName = substr($fieldName, 0, strpos($fieldName, '_')); if ((0 == $f) && (1 == $this->table->getVar('table_autoincrement'))) { - $fpif = $fieldName; + $fieldId = $fieldName; } else { if (1 == $fields[$f]->getVar('field_main')) { - $fpmf = $fieldName; // fpmf = fields parameters main field + $fieldMain = $fieldName; // fieldMain = fields parameters main field } } } $stuLpFieldName = strtoupper($lpFieldName); $ret = <<getVar('{$lpFieldName}_published') == 0 || {$lpFieldName}->getVar('{$lpFieldName}_published') > time() ) { redirect_header({$stuModuleDirname}_URL . '/index.php', 2, {$language}NO{$stuLpFieldName}); @@ -130,7 +130,7 @@ public function getUserPrint($moduleDirname, $language) if ($fieldName == 'published') { $ret .= <<getVar('published') == 0 || {$lpFieldName}->getVar('published') > time() ) { redirect_header({$stuModuleDirname}_URL . '/index.php', 2, {$language}NO{$stuLpFieldName}); @@ -165,7 +165,7 @@ public function getUserPrint($moduleDirname, $language) } else { \$groups = XOOPS_GROUP_ANONYMOUS; } -if (!\$gperm_handler->checkRight('{$moduleDirname}_view', {$lpFieldName}->getVat('{$fpif}'), \$groups, \$xoopsModule->getVar('mid'))) { +if (!\$gperm_handler->checkRight('{$moduleDirname}_view', {$lpFieldName}->getVat('{$fieldId}'), \$groups, \$xoopsModule->getVar('mid'))) { redirect_header({$stuModuleDirname}_URL . '/index.php', 3, _NOPERM); exit(); } diff --git a/class/files/user/UserRate.php b/class/files/user/UserRate.php index b0a820f6..60fadc0a 100644 --- a/class/files/user/UserRate.php +++ b/class/files/user/UserRate.php @@ -23,7 +23,7 @@ /** * Class UserRate */ -class UserRate extends TDMCreateFile +class UserRate extends UserObjects { /* * @public function constructor @@ -34,7 +34,9 @@ class UserRate extends TDMCreateFile */ public function __construct() { - $this->tdmcfile = TDMCreateFile::getInstance(); + parent::__construct(); + $this->tdmcfile = TDMCreateFile::getInstance(); + $this->userobjects = UserObjects::getInstance(); } /* @@ -150,40 +152,26 @@ public function getUserRateForm($module, $tableName, $language) */ /** * @param $moduleDirname - * @param $table_id - * @param $tableName + * @param $fields + * @param $tableName + * @param $language * @return string */ - public function getUserRateSave($moduleDirname, $table_id, $tableName) + public function getUserRateSave($moduleDirname, $fields, $tableName, $language) { - $ret = <<userobjects->getUserSaveFieldId($fields); + $ret = <<check() ) { redirect_header('{$tableName}.php', 3, implode(',', \$GLOBALS['xoopsSecurity']->getErrors())); } - if (isset(\$_REQUEST['{$fpif}'])) { - \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fpif}']); + if (isset(\$_REQUEST['{$fieldId}'])) { + \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fieldId}']); } else { \${$tableName}Obj =& \${$tableName}Handler->create(); } EOT; - $fields = $this->getTableFields($table_id); - foreach (array_keys($fields) as $f) { - $fieldName = $fields[$f]->getVar('field_name'); - $fieldElement = $fields[$f]->getVar('field_element'); - if ((5 == $fieldElement) || (6 == $fieldElement)) { - $ret .= $this->adminobjects->getCheckBoxOrRadioYN($tableName, $fieldName); - } elseif (13 == $fieldElement) { - $ret .= $this->adminobjects->getUploadImage($moduleDirname, $tableName, $fieldName); - } elseif (14 == $fieldElement) { - $ret .= $this->adminobjects->getUploadFile($moduleDirname, $tableName, $fieldName); - } elseif (15 == $fieldElement) { - $ret .= $this->adminobjects->getTextDateSelect($tableName, $fieldName); - } else { - $ret .= $this->adminobjects->getSimpleSetVar($tableName, $fieldName); - } - } - + $ret .= $this->userobjects->getUserSaveElements($moduleDirname, $tableName, $fields); $ret .= <<insert(\${$tableName}Obj)) { redirect_header('index.php', 2, {$language}FORMOK); @@ -227,13 +215,15 @@ public function render() $table = $this->getTable(); $filename = $this->getFileName(); $moduleDirname = $module->getVar('mod_dirname'); - $table_id = $table->getVar('table_id'); + $tableId = $table->getVar('table_id'); + $tableMid = $table->getVar('table_mid'); $tableName = $table->getVar('table_name'); + $fields = $this->tdmcfile->getTableFields($tableMid, $tableId); $language = $this->getLanguage($moduleDirname, 'MA'); $content = $this->getHeaderFilesComments($module, $filename); $content .= $this->getUserRateHeader($moduleDirname); $content .= $this->getUserRateForm($module, $tableName, $language); - $content .= $this->getUserRateSave($moduleDirname, $table_id, $tableName); + $content .= $this->getUserRateSave($moduleDirname, $fields, $tableName, $language); $content .= $this->getUserRateFooter(); $this->tdmcfile->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); diff --git a/class/files/user/UserRss.php b/class/files/user/UserRss.php index 29381506..20cff355 100644 --- a/class/files/user/UserRss.php +++ b/class/files/user/UserRss.php @@ -86,7 +86,7 @@ public function getUserRss($moduleDirname, $language) { $table = $this->getTable(); $tableName = $table->getVar('table_name'); - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $fieldName; diff --git a/class/files/user/UserSearch.php b/class/files/user/UserSearch.php new file mode 100644 index 00000000..a6353d18 --- /dev/null +++ b/class/files/user/UserSearch.php @@ -0,0 +1,232 @@ +tdmcfile = TDMCreateFile::getInstance(); + $this->userobjects = UserObjects::getInstance(); + } + + /* + * @static function &getInstance + * @param null + */ + /** + * @return UserSearch + */ + public static function &getInstance() + { + static $instance = false; + if (!$instance) { + $instance = new self(); + } + + return $instance; + } + + /* + * @public function write + * @param string $module + * @param mixed $table + * @param string $filename + */ + /** + * @param $module + * @param $table + * @param $filename + */ + public function write($module, $table, $filename) + { + $this->setModule($module); + $this->setTable($table); + $this->setFileName($filename); + } + + /* + * @public function getUserSearchHeader + * @param null + */ + /** + * @param $moduleDirname + * @return string + */ + public function getUserSearchHeader($moduleDirname) + { + $ret = <<addStylesheet( XOOPS_URL . '/modules/' . \$xoopsModule->getVar('dirname', 'n') . '/assets/css/style.css', null ); +// redirection if not permissions +if (\$perm_submit == false) { + redirect_header('index.php', 2, _NOPERM); + exit(); +} +// +switch (\$op) +{\n +EOT; + + return $ret; + } + + /* + * @public function getAdminPagesList + * @param string $tableName + * @param string $language + */ + /** + * @param $module + * @param $tableName + * @param $language + * @return string + */ + public function getUserSearchForm($module, $tableName, $language) + { + $stuModuleName = strtoupper($module->getVar('mod_name')); + $ret = <<assign('navigation', \$navigation); + // reference + // title of page + \$title = _MD_{$stuModuleName}_SUBMIT_PROPOSER . ' - '; + \$title .= \$GLOBALS['xoopsModule']->name(); + \$GLOBALS['xoopsTpl']->assign('xoops_pagetitle', \$title); + //description + \$GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MD_{$stuModuleName}_SUBMIT_PROPOSER)); + // Description + \$GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags({$language}SUBMIT)); + + // Create + \${$tableName}Obj =& \${$tableName}Handler->create(); + \$form = \${$tableName}Obj->getForm(); + \$xoopsTpl->assign('form', \$form->render());\n +EOT; + + return $ret; + } + + /* + * @public function getUserSearchSave + * @param string $moduleDirname + * @param string $tableName + */ + /** + * @param $moduleDirname + * @param $table_id + * @param $tableName + * @return string + */ + public function getUserSearchSave($moduleDirname, $fields, $tableName, $language) + { + $fieldId = $this->userobjects->getUserSaveFieldId($fields); + $ret = <<check() ) { + redirect_header('{$tableName}.php', 3, implode(',', \$GLOBALS['xoopsSecurity']->getErrors())); + } + if (isset(\$_REQUEST['{$fieldId}'])) { + \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fieldId}']); + } else { + \${$tableName}Obj =& \${$tableName}Handler->create(); + } +EOT; + $ret .= $this->userobjects->getUserSaveElements($moduleDirname, $tableName, $fields); + $ret .= <<insert(\${$tableName}Obj)) { + redirect_header('index.php', 2, {$language}FORMOK); + } + + echo \${$tableName}Obj->getHtmlErrors(); + \$form =& \${$tableName}Obj->getForm(); + \$form->display(); + break;\n +EOT; + + return $ret; + } + + /* + * @public function getUserSearchFooter + * @param null + */ + /** + * @return string + */ + public function getUserSearchFooter() + { + $ret = <<getModule(); + $table = $this->getTable(); + $filename = $this->getFileName(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableId = $table->getVar('table_id'); + $tableMid = $table->getVar('table_mid'); + $tableName = $table->getVar('table_name'); + $fields = $this->tdmcfile->getTableFields($tableMid, $tableId); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getHeaderFilesComments($module, $filename); + $content .= $this->getUserSearchHeader($moduleDirname); + $content .= $this->getUserSearchForm($module, $tableName, $language); + $content .= $this->getUserSearchSave($moduleDirname, $fields, $tableName, $language); + $content .= $this->getUserSearchFooter(); + $this->tdmcfile->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + + return $this->tdmcfile->renderFile(); + } +} diff --git a/class/files/user/UserSingle.php b/class/files/user/UserSingle.php index 1b92d7ef..cef03e95 100644 --- a/class/files/user/UserSingle.php +++ b/class/files/user/UserSingle.php @@ -23,7 +23,7 @@ /** * Class UserSingle */ -class UserSingle extends TDMCreateFile +class UserSingle extends UserObjects { /* * @public function constructor @@ -34,7 +34,9 @@ class UserSingle extends TDMCreateFile */ public function __construct() { - $this->tdmcfile = TDMCreateFile::getInstance(); + parent::__construct(); + $this->tdmcfile = TDMCreateFile::getInstance(); + $this->userobjects = UserObjects::getInstance(); } /* @@ -83,13 +85,15 @@ public function write($module, $table, $filename) public function getUserSingleHeader($moduleDirname) { $ret = <<addStylesheet( XOOPS_URL . '/modules/' . \$xoopsModule->getVar('dirname', 'n') . '/assets/css/style.css', null ); -//On recupere la valeur de l'argument op dans l'URL$ // redirection if not permissions if (\$perm_submit == false) { redirect_header('index.php', 2, _NOPERM); @@ -153,36 +157,21 @@ public function getUserSingleForm($module, $tableName, $language) * @param $tableName * @return string */ - public function getUserSingleSave($moduleDirname, $table_id, $tableName) + public function getUserSingleSave($moduleDirname, $fields, $tableName, $language) { - $ret = <<userobjects->getUserSaveFieldId($fields); + $ret = <<check() ) { redirect_header('{$tableName}.php', 3, implode(',', \$GLOBALS['xoopsSecurity']->getErrors())); } - if (isset(\$_REQUEST['{$fpif}'])) { - \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fpif}']); + if (isset(\$_REQUEST['{$fieldId}'])) { + \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fieldId}']); } else { \${$tableName}Obj =& \${$tableName}Handler->create(); } EOT; - $fields = $this->getTableFields($table_id); - foreach (array_keys($fields) as $f) { - $fieldName = $fields[$f]->getVar('field_name'); - $fieldElement = $fields[$f]->getVar('field_element'); - if ((5 == $fieldElement) || (6 == $fieldElement)) { - $ret .= $this->adminobjects->getCheckBoxOrRadioYN($tableName, $fieldName); - } elseif (13 == $fieldElement) { - $ret .= $this->adminobjects->getUploadImage($moduleDirname, $tableName, $fieldName); - } elseif (14 == $fieldElement) { - $ret .= $this->adminobjects->getUploadFile($moduleDirname, $tableName, $fieldName); - } elseif (15 == $fieldElement) { - $ret .= $this->adminobjects->getTextDateSelect($tableName, $fieldName); - } else { - $ret .= $this->adminobjects->getSimpleSetVar($tableName, $fieldName); - } - } - + $ret .= $this->userobjects->getUserSaveElements($moduleDirname, $tableName, $fields); $ret .= <<insert(\${$tableName}Obj)) { redirect_header('index.php', 2, {$language}FORMOK); @@ -226,13 +215,15 @@ public function render() $table = $this->getTable(); $filename = $this->getFileName(); $moduleDirname = $module->getVar('mod_dirname'); - $table_id = $table->getVar('table_id'); + $tableId = $table->getVar('table_id'); + $tableMid = $table->getVar('table_mid'); $tableName = $table->getVar('table_name'); + $fields = $this->tdmcfile->getTableFields($tableMid, $tableId); $language = $this->getLanguage($moduleDirname, 'MA'); $content = $this->getHeaderFilesComments($module, $filename); $content .= $this->getUserSingleHeader($moduleDirname); $content .= $this->getUserSingleForm($module, $tableName, $language); - $content .= $this->getUserSingleSave($moduleDirname, $table_id, $tableName); + $content .= $this->getUserSingleSave($moduleDirname, $fields, $tableName, $language); $content .= $this->getUserSingleFooter(); $this->tdmcfile->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); diff --git a/class/files/user/UserSubmit.php b/class/files/user/UserSubmit.php index f66ee2df..42dec966 100644 --- a/class/files/user/UserSubmit.php +++ b/class/files/user/UserSubmit.php @@ -23,7 +23,7 @@ /** * Class UserSubmit */ -class UserSubmit extends TDMCreateFile +class UserSubmit extends UserObjects { /* * @public function constructor @@ -34,7 +34,9 @@ class UserSubmit extends TDMCreateFile */ public function __construct() { - $this->tdmcfile = TDMCreateFile::getInstance(); + parent::__construct(); + $this->tdmcfile = TDMCreateFile::getInstance(); + $this->userobjects = UserObjects::getInstance(); } /* @@ -88,14 +90,13 @@ public function getUserSubmitHeader($moduleDirname) // Template \$xoopsOption['template_main'] = '{$moduleDirname}_submit.tpl'; include_once XOOPS_ROOT_PATH.'/header.php'; -\$xoTheme->addStylesheet( XOOPS_URL . '/modules/' . \$xoopsModule->getVar('dirname', 'n') . '/assets/css/style.css', null ); +\$xoTheme->addStylesheet( XOOPS_URL . '/modules/' . \$GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/assets/css/style.css', null ); //On recupere la valeur de l'argument op dans l'URL$ // redirection if not permissions if (\$perm_submit == false) { redirect_header('index.php', 2, _NOPERM); exit(); } - // switch (\$op) {\n @@ -154,36 +155,21 @@ public function getUserSubmitForm($module, $tableName, $language) * @param $tableName * @return string */ - public function getUserSubmitSave($moduleDirname, $table_id, $tableName) + public function getUserSubmitSave($moduleDirname, $fields, $tableName, $language) { - $ret = <<userobjects->getUserSaveFieldId($fields); + $ret = <<check() ) { redirect_header('{$tableName}.php', 3, implode(',', \$GLOBALS['xoopsSecurity']->getErrors())); } - if (isset(\$_REQUEST['{$fpif}'])) { - \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fpif}']); + if (isset(\$_REQUEST['{$fieldId}'])) { + \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fieldId}']); } else { \${$tableName}Obj =& \${$tableName}Handler->create(); } EOT; - $fields = $this->getTableFields($table_id); - foreach (array_keys($fields) as $f) { - $fieldName = $fields[$f]->getVar('field_name'); - $fieldElement = $fields[$f]->getVar('field_element'); - if ((5 == $fieldElement) || (6 == $fieldElement)) { - $ret .= $this->adminobjects->getCheckBoxOrRadioYN($tableName, $fieldName); - } elseif (13 == $fieldElement) { - $ret .= $this->adminobjects->getUploadImage($moduleDirname, $tableName, $fieldName); - } elseif (14 == $fieldElement) { - $ret .= $this->adminobjects->getUploadFile($moduleDirname, $tableName, $fieldName); - } elseif (15 == $fieldElement) { - $ret .= $this->adminobjects->getTextDateSelect($tableName, $fieldName); - } else { - $ret .= $this->adminobjects->getSimpleSetVar($tableName, $fieldName); - } - } - + $ret .= $this->userobjects->getUserSaveElements($moduleDirname, $tableName, $fields); $ret .= <<insert(\${$tableName}Obj)) { redirect_header('index.php', 2, {$language}FORMOK); @@ -191,7 +177,7 @@ public function getUserSubmitSave($moduleDirname, $table_id, $tableName) echo \${$tableName}Obj->getHtmlErrors(); \$form =& \${$tableName}Obj->getForm(); - \$form->display(); + \$xoopsTpl->assign('form', \$form->display()); break;\n EOT; @@ -227,13 +213,15 @@ public function render() $table = $this->getTable(); $filename = $this->getFileName(); $moduleDirname = $module->getVar('mod_dirname'); - $table_id = $table->getVar('table_id'); + $tableId = $table->getVar('table_id'); + $tableMid = $table->getVar('table_mid'); $tableName = $table->getVar('table_name'); + $fields = $this->tdmcfile->getTableFields($tableMid, $tableId); $language = $this->getLanguage($moduleDirname, 'MA'); $content = $this->getHeaderFilesComments($module, $filename); $content .= $this->getUserSubmitHeader($moduleDirname); $content .= $this->getUserSubmitForm($module, $tableName, $language); - $content .= $this->getUserSubmitSave($moduleDirname, $table_id, $tableName); + $content .= $this->getUserSubmitSave($moduleDirname, $fields, $tableName, $language); $content .= $this->getUserSubmitFooter(); $this->tdmcfile->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); diff --git a/class/files/user/UserViewTag.php b/class/files/user/UserViewTag.php index 394f9a95..e653399f 100644 --- a/class/files/user/UserViewTag.php +++ b/class/files/user/UserViewTag.php @@ -79,7 +79,7 @@ public function write($module, $filename) * @param $moduleDirname * @return string */ - public function getUserViewTag($moduleDirname) + public function getUserViewTag() { $ret = <<tdmcfile = TDMCreateFile::getInstance(); + parent::__construct(); + $this->tdmcfile = TDMCreateFile::getInstance(); + $this->userobjects = UserObjects::getInstance(); } /* @@ -46,30 +48,30 @@ public function __construct() */ public static function &getInstance() { - static \$instance = false; - if (!\$instance) { - \$instance = new self(); + static $instance = false; + if (!$instance) { + $instance = new self(); } - return \$instance; + return $instance; } /* * @public function write - * @param string \$module - * @param mixed \$table - * @param string \$filename + * @param string $module + * @param mixed $table + * @param string $filename */ /** - * @param \$module - * @param \$table - * @param \$filename + * @param $module + * @param $table + * @param $filename */ - public function write(\$module, \$table, \$filename) + public function write($module, $table, $filename) { - \$this->setModule(\$module); - \$this->setTable(\$table); - \$this->setFileName(\$filename); + $this->setModule($module); + $this->setTable($table); + $this->setFileName($filename); } /* @@ -77,12 +79,12 @@ public function write(\$module, \$table, \$filename) * @param null */ /** - * @param \$moduleDirname + * @param $moduleDirname * @return string */ - public function getUserVisitHeader(\$moduleDirname, $language) + public function getUserVisitHeader($moduleDirname, $language) { - \$ret = <<getVar('mod_name')); - \$ret = <<getVar('mod_name')); + $ret = <<assign('navigation', \\$navigation); + \$navigation = {$language}SUBMIT_PROPOSER; + \$GLOBALS['xoopsTpl']->assign('navigation', \$navigation); // reference // title of page - \\$title = {$language}SUBMIT_PROPOSER . ' - '; - \\$title .= \\$GLOBALS['xoopsModule']->name(); - \\$GLOBALS['xoopsTpl']->assign('xoops_pagetitle', \\$title); + \$title = {$language}SUBMIT_PROPOSER . ' - '; + \$title .= \$GLOBALS['xoopsModule']->name(); + \$GLOBALS['xoopsTpl']->assign('xoops_pagetitle', \$title); //description - \\$GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags({$language}SUBMIT_PROPOSER)); + \$GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags({$language}SUBMIT_PROPOSER)); // Description - \\$GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags({$language}SUBMIT)); + \$GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags({$language}SUBMIT)); // Create - \\${$tableName}Obj =& \\${$tableName}Handler->create(); - \\$form = \\${$tableName}Obj->getForm(); - \\$xoopsTpl->assign('form', \\$form->render());\n + \${$tableName}Obj =& \${$tableName}Handler->create(); + \$form = \${$tableName}Obj->getForm(); + \$xoopsTpl->assign('form', \$form->render());\n EOT; - return \$ret; + return $ret; } /* * @public function getUserVisitSave - * @param string \$moduleDirname - * @param string \$tableName + * @param string $moduleDirname + * @param string $tableName */ /** - * @param \$moduleDirname - * @param \$table_id - * @param \$tableName + * @param $moduleDirname + * @param $table_id + * @param $tableName * @return string */ - public function getUserVisitSave(\$moduleDirname, \$table_id, \$tableName) + public function getUserVisitSave($moduleDirname, $tableId, $tableMid, $tableName) { - \$ret = <<tdmcfile->getTableFields($tableMid, $tableId); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + if (0 == $f) { + $fieldId = $fieldName; + } + } + $ret = <<check() ) { - redirect_header('{$tableName}.php', 3, implode(',', \\$GLOBALS['xoopsSecurity']->getErrors())); + if ( !\$GLOBALS['xoopsSecurity']->check() ) { + redirect_header('{$tableName}.php', 3, implode(',', \$GLOBALS['xoopsSecurity']->getErrors())); } - if (isset(\\$_REQUEST['{$fpif}'])) { - \\${$tableName}Obj =& \\${$tableName}Handler->get(\\$_REQUEST['{$fpif}']); + if (isset(\$_REQUEST['{$fieldId}'])) { + \${$tableName}Obj =& \${$tableName}Handler->get(\$_REQUEST['{$fieldId}']); } else { - \\${$tableName}Obj =& \\${$tableName}Handler->create(); + \${$tableName}Obj =& \${$tableName}Handler->create(); } EOT; - \$fields = \$this->getTableFields(\$table_id); - foreach (array_keys(\$fields) as \$f) { - \$fieldName = \$fields[\$f]->getVar('field_name'); - \$fieldElement = \$fields[\$f]->getVar('field_element'); - if ((5 == \$fieldElement) || (6 == \$fieldElement)) { - \$ret .= \$this->adminobjects->getCheckBoxOrRadioYN(\$tableName, \$fieldName); - } elseif (13 == \$fieldElement) { - \$ret .= \$this->adminobjects->getUploadImage(\$moduleDirname, \$tableName, \$fieldName); - } elseif (14 == \$fieldElement) { - \$ret .= \$this->adminobjects->getUploadFile(\$moduleDirname, \$tableName, \$fieldName); - } elseif (15 == \$fieldElement) { - \$ret .= \$this->adminobjects->getTextDateSelect(\$tableName, \$fieldName); + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if ((5 == $fieldElement) || (6 == $fieldElement)) { + $ret .= $this->userobjects->getCheckBoxOrRadioYNSetVar($tableName, $fieldName); + } elseif (13 == $fieldElement) { + if(1 == $fields[$f]->getVar('field_main')) { + $fieldMain = $fieldName; + } + $ret .= $this->userobjects->getUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fieldMain); + } elseif (14 == $fieldElement) { + $ret .= $this->userobjects->getUploadFileSetVar($moduleDirname, $tableName, $fieldName); + } elseif (15 == $fieldElement) { + $ret .= $this->userobjects->getTextDateSelectSetVar($tableName, $fieldName); } else { - \$ret .= \$this->adminobjects->getSimpleSetVar(\$tableName, \$fieldName); + $ret .= $this->userobjects->getSimpleSetVar($tableName, $fieldName); } } - \$ret .= <<insert(\\${$tableName}Obj)) { + $ret .= <<insert(\${$tableName}Obj)) { redirect_header('index.php', 2, {$language}FORMOK); } - echo \\${$tableName}Obj->getHtmlErrors(); - \\$form =& \\${$tableName}Obj->getForm(); - \\$form->display(); + echo \${$tableName}Obj->getHtmlErrors(); + \$form =& \${$tableName}Obj->getForm(); + \$form->display(); break;\n EOT; - return \$ret; + return $ret; } /* @@ -223,11 +234,11 @@ public function getUserVisitSave(\$moduleDirname, \$table_id, \$tableName) */ public function getUserVisitFooter() { - \$ret = <<getModule(); - \$table = \$this->getTable(); - \$filename = \$this->getFileName(); - \$moduleDirname = \$module->getVar('mod_dirname'); - \$table_id = \$table->getVar('table_id'); - \$tableName = \$table->getVar('table_name'); - \$language = \$this->getLanguage(\$moduleDirname, 'MA'); - \$content = \$this->getHeaderFilesComments(\$module, \$filename); - \$content .= \$this->getUserVisitHeader(\$moduleDirname); - \$content .= \$this->getUserVisitForm(\$module, \$tableName, \$language); - \$content .= \$this->getUserVisitSave(\$moduleDirname, \$table_id, \$tableName); - \$content .= \$this->getUserVisitFooter(); - \$this->tdmcfile->create(\$moduleDirname, '/', \$filename, \$content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); + $module = $this->getModule(); + $table = $this->getTable(); + $filename = $this->getFileName(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableId = $table->getVar('table_id'); + $tableMid = $table->getVar('table_mid'); + $tableName = $table->getVar('table_name'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getHeaderFilesComments($module, $filename); + $content .= $this->getUserVisitHeader($moduleDirname); + $content .= $this->getUserVisitForm($module, $tableName, $language); + $content .= $this->getUserVisitSave($moduleDirname, $tableId, $tableMid, $tableName); + $content .= $this->getUserVisitFooter(); + $this->tdmcfile->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); - return \$this->tdmcfile->renderFile(); + return $this->tdmcfile->renderFile(); } } diff --git a/class/files/user/UserXoopsVersion.php b/class/files/user/UserXoopsVersion.php index c8f9dda7..bf0591bd 100644 --- a/class/files/user/UserXoopsVersion.php +++ b/class/files/user/UserXoopsVersion.php @@ -125,7 +125,7 @@ public function getKeywords() */ private function getXoopsVersionHeader($module, $table, $language) { - //$dateString = preg_replace('/[^0-9]/', '/', _DBDATESTRING); + //$dateString = preg_replace('/[^0-9]/', '/', _DBDATESTRING); $date = date(_DBDATESTRING); // _DBDATESTRING $ret = <<getTable(); + $ret = << '{$moduleDirname}_header.tpl', 'description' => ''); \$modversion['templates'][] = array('file' => '{$moduleDirname}_index.tpl', 'description' => '');\n @@ -341,8 +345,48 @@ private function getXoopsVersionTemplatesUser($moduleDirname, $tables) \$modversion['templates'][] = array('file' => '{$moduleDirname}_{$tables[$t]->getVar('table_name')}.tpl', 'description' => '');\n EOT; } + if(1 == $table->getVar('table_broken')) { + $ret .= << '{$moduleDirname}_broken.tpl', 'description' => '');\n +EOT; + } + if(1 == $table->getVar('table_pdf')) { + $ret .= << '{$moduleDirname}_pdf.tpl', 'description' => '');\n +EOT; + } + if(1 == $table->getVar('table_print')) { + $ret .= << '{$moduleDirname}_print.tpl', 'description' => '');\n +EOT; + } + if(1 == $table->getVar('table_rate')) { + $ret .= << '{$moduleDirname}_rate.tpl', 'description' => '');\n +EOT; + } + if(1 == $table->getVar('table_rss')) { + $ret .= << '{$moduleDirname}_rss.tpl', 'description' => '');\n +EOT; + } + if(1 == $table->getVar('table_search')) { + $ret .= << '{$moduleDirname}_search.tpl', 'description' => '');\n +EOT; + } + if(1 == $table->getVar('table_single')) { + $ret .= << '{$moduleDirname}_single.tpl', 'description' => '');\n +EOT; + } + if(1 == $table->getVar('table_submit')) { + $ret .= << '{$moduleDirname}_submit.tpl', 'description' => '');\n +EOT; + } $ret .= << '{$moduleDirname}_footer.tpl', 'description' => '');\n +\$modversion['templates'][] = array('file' => '{$moduleDirname}_footer.tpl', 'description' => '');\n\n EOT; return $ret; @@ -374,7 +418,9 @@ private function getXoopsVersionSubmenu($language, $tables) ++$i; } unset($i); - + $ret .= << "b_{$moduleDirname}_{$tableName}_show", 'edit_func' => "b_{$moduleDirname}_{$tableName}_edit", 'options' => "{$tables[$i]->getVar('table_fieldname')}|5|25|0", - 'template' => "'{$moduleDirname}_block_{$tableName}.tpl");\n + 'template' => "'{$moduleDirname}_block_{$tableName}.tpl");\n\n EOT; } } @@ -431,7 +477,7 @@ private function getXoopsVersionConfig($module, $table, $language) // ------------------- Config ------------------- //\n EOT; if (is_object($table)) { - $fields = $this->getTableFields($table->getVar('table_id')); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); foreach (array_keys($fields) as $f) { if ($fields[$f]->getVar('field_element') == 4) { $ret .= <<getVar('table_name'); + $tableId = $tables[$t]->getVar('table_id'); + $tableMid = $tables[$t]->getVar('table_mid'); + $tableName = $tables[$t]->getVar('table_name'); + $tableName = $tables[$t]->getVar('table_name'); + $tableCategory = $tables[$t]->getVar('table_category'); + $tableBroken = $tables[$t]->getVar('table_broken'); + $tableSubmit = $tables[$t]->getVar('table_submit'); if (1 == $tables[$t]->getVar('table_notifications')) { - if ($t < count($tableName)) { - $notify_file .= "'" . $tableName . ".php', "; - } else { - $notify_file .= "'" . $tableName . ".php'"; + if ($t <= count($tableName)) { + /*$notifyFiles[] = "'" . $tableName . ".php', "; + } else {*/ + $notifyFiles[] = "'" . $tableName . ".php'"; } + } + if (1 == $tables[$t]->getVar('table_single')) { + $single = $tableName; + } + } + $fields = $this->tdmcfile->getTableFields($tableMid, $tableId); + $fieldParamId = null; + $fieldParent = null; + foreach (array_keys($fields) as $f) { + $fieldId = $fields[$f]->getVar('field_id'); + $fieldMid = $fields[$f]->getVar('field_mid'); + $fieldTid = $fields[$f]->getVar('field_tid'); + $fieldName = $fields[$f]->getVar('field_name'); + if (0 == $fields[$f]->getVar('field_id')) { + $fieldParamId = $fieldName; + } + if (1 == $fields[$f]->getVar('field_parent')) { + $fieldParent = $fieldName; } } $ret = <<getXoopsVersionNotificationCodeShort($language, 'category', 'global', 'global', $notifyFiles); + if(1 == $tableCategory) { + $ret .= $this->getXoopsVersionNotificationCodeItem($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1'); + } + $ret .= $this->getXoopsVersionNotificationCodeItem($language, 'category', 'file', 'file', $single.'.php', $fieldParamId, 1); + if(1 == $tableCategory) { + $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'global', 0, 'global', 'newcategory', 'global_newcategory_notify'); + } + $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_modify', 'global', 1, 'global', 'filemodify', 'global_filemodify_notify'); + if(1 == $tableBroken) { + $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_broken', 'global', 1, 'global', 'filebroken', 'global_filebroken_notify'); + } + if(1 == $tableSubmit) { + $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_submit', 'global', 1, 'global', 'filesubmit', 'global_filesubmit_notify'); + } + $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_file', 'global', 0, 'global', 'newfile', 'global_newfile_notify'); + if(1 == $tableCategory) { + $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_submit', 'category', 1, 'category', 'filesubmit', 'category_filesubmit_notify'); + $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_file', 'category', 0, 'category', 'newfile', 'category_newfile_notify'); + } + $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'approve', 'file', 1, 'file', 'approve', 'file_approve_notify'); + return $ret; + } + + /* + * @private function getXoopsVersionNotificationCodeShort + */ + /** + * @param $language + * @param $type + * @param $name + * @param $title + * @param $from + * @return string + */ + private function getXoopsVersionNotificationCodeShort($language, $type, $name, $title, $from) + { + $title = strtoupper($title); + $from = implode(', ', $from); + $ret = << "{$name}", + 'title' => {$language}{$title}_NOTIFY, + 'description' => {$language}{$title}_NOTIFY_DESC, + 'subscribe_from' => array('index.php', {$from}));\n\n +EOT; -\$modversion['notification']['category'][] = array( - 'name' => "global", - 'title' => {$language}GLOBAL_NOTIFY, - 'description' => {$language}GLOBAL_NOTIFY_DESC, - 'subscribe_from' => array('index.php', {$notify_file})); + return $ret; + } + + /* + * @private function getXoopsVersionNotifications + */ + /** + * @param $language + * @param $type + * @param $name + * @param $title + * @param $from + * @param $item + * @param $allow + * @return string + */ + private function getXoopsVersionNotificationCodeItem($language, $type, $name, $title, $from, $item = 'cid', $allow = 1) + { + $title = strtoupper($title); + $ret = << "{$name}", + 'title' => {$language}{$title}_NOTIFY, + 'description' => {$language}{$title}_NOTIFY_DESC, + 'subscribe_from' => "{$from}", + 'item_name' => "{$item}", + 'allow_bookmark' => {$allow});\n\n +EOT; -\$modversion['notification']['category'][] = array( - 'name' => "category", - 'title' => {$language}CATEGORY_NOTIFY, - 'description' => {$language}CATEGORY_NOTIFY_DESC, - 'subscribe_from' => array({$notify_file}), - 'item_name' => "cid", - 'allow_bookmark' => 1); - -\$modversion['notification']['category'][] = array( - 'name' => "file", - 'title' => {$language}FILE_NOTIFY, - 'description' => {$language}FILE_NOTIFY_DESC, - 'subscribe_from' => "singlefile.php", - 'item_name' => "lid", - 'allow_bookmark' => 1); - -\$modversion['notification']['event'][] = array( - 'name' => "new_category", - 'category' => "global", - 'title' => {$language}GLOBAL_NEWCATEGORY_NOTIFY, - 'caption' => {$language}GLOBAL_NEWCATEGORY_NOTIFY_CAPTION, - 'description' => {$language}GLOBAL_NEWCATEGORY_NOTIFY_DESC, - 'mail_template' => "global_newcategory_notify", - 'mail_subject' => {$language}GLOBAL_NEWCATEGORY_NOTIFY_SUBJECT); - -\$modversion['notification']['event'][] = array( - 'name' => "file_modify", - 'category' => "global", - 'admin_only' => 1, - 'title' => {$language}GLOBAL_FILEMODIFY_NOTIFY, - 'caption' => {$language}GLOBAL_FILEMODIFY_NOTIFY_CAPTION, - 'description' => {$language}GLOBAL_FILEMODIFY_NOTIFY_DESC, - 'mail_template' => "global_filemodify_notify", - 'mail_subject' => {$language}GLOBAL_FILEMODIFY_NOTIFY_SUBJECT); - -\$modversion['notification']['event'][] = array( - 'name' => "file_broken", - 'category' => "global", - 'admin_only' => 1, - 'title' => {$language}GLOBAL_FILEBROKEN_NOTIFY, - 'caption' => {$language}GLOBAL_FILEBROKEN_NOTIFY_CAPTION, - 'description' => {$language}GLOBAL_FILEBROKEN_NOTIFY_DESC, - 'mail_template' => "global_filebroken_notify", - 'mail_subject' => {$language}GLOBAL_FILEBROKEN_NOTIFY_SUBJECT); - -\$modversion['notification']['event'][] = array( - 'name' => "file_submit", - 'category' => "global", - 'admin_only' => 1, - 'title' => {$language}GLOBAL_FILESUBMIT_NOTIFY, - 'caption' => {$language}GLOBAL_FILESUBMIT_NOTIFY_CAPTION, - 'description' => {$language}GLOBAL_FILESUBMIT_NOTIFY_DESC, - 'mail_template' => "global_filesubmit_notify", - 'mail_subject' => {$language}GLOBAL_FILESUBMIT_NOTIFY_SUBJECT); - -\$modversion['notification']['event'][] = array( - 'name' => "new_file", - 'category' => "global", - 'title' => {$language}GLOBAL_NEWFILE_NOTIFY, - 'caption' => {$language}GLOBAL_NEWFILE_NOTIFY_CAPTION, - 'description' => {$language}GLOBAL_NEWFILE_NOTIFY_DESC, - 'mail_template' => "global_newfile_notify", - 'mail_subject' => {$language}GLOBAL_NEWFILE_NOTIFY_SUBJECT); - -\$modversion['notification']['event'][] = array( - 'name' => "file_submit", - 'category' => "category", - 'admin_only' => 1, - 'title' => {$language}CATEGORY_FILESUBMIT_NOTIFY, - 'caption' => {$language}CATEGORY_FILESUBMIT_NOTIFY_CAPTION, - 'description' => {$language}CATEGORY_FILESUBMIT_NOTIFY_DESC, - 'mail_template' => "category_filesubmit_notify", - 'mail_subject' => {$language}CATEGORY_FILESUBMIT_NOTIFY_SUBJECT); - -\$modversion['notification']['event'][] = array( - 'name' => "new_file", - 'category' => "category", - 'title' => {$language}CATEGORY_NEWFILE_NOTIFY, - 'caption' => {$language}CATEGORY_NEWFILE_NOTIFY_CAPTION, - 'description' => {$language}CATEGORY_NEWFILE_NOTIFY_DESC, - 'mail_template' => "category_newfile_notify", - 'mail_subject' => {$language}CATEGORY_NEWFILE_NOTIFY_SUBJECT); - -\$modversion['notification']['event'][] = array( - 'name' => "approve", - 'category' => "file", - 'admin_only' => 1, - 'title' => {$language}FILE_APPROVE_NOTIFY, - 'caption' => {$language}FILE_APPROVE_NOTIFY_CAPTION, - 'description' => {$language}FILE_APPROVE_NOTIFY_DESC, - 'mail_template' => "file_approve_notify", - 'mail_subject' => {$language}FILE_APPROVE_NOTIFY_SUBJECT); + return $ret; + } + + /* + * @private function getXoopsVersionNotifications + */ + /** + * @param $language + * @param $type + * @param $name + * @param $title + * @param $from + * @param $item + * @param $mail + * @return string + */ + private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin = 1, $title, $table, $mail) + { + $title = strtoupper($title); + $table = strtoupper($table); + $ret = << "{$name}", + 'category' => "{$category}", + 'admin_only' => {$admin}, + 'title' => {$language}{$title}_{$table}_NOTIFY, + 'caption' => {$language}{$title}_{$table}_NOTIFY_CAPTION, + 'description' => {$language}{$title}_{$table}_NOTIFY_DESC, + 'mail_template' => "{$mail}", + 'mail_subject' => {$language}{$title}_{$table}_NOTIFY_SUBJECT);\n\n EOT; return $ret; @@ -806,7 +885,7 @@ public function render() } if (1 == $table->getVar('table_submenu')) { - $content .= $this->getXoopsVersionSubmenu($language); + $content .= $this->getXoopsVersionSubmenu($language, $tables); } if (1 == $table->getVar('table_blocks')) { $content .= $this->getXoopsVersionBlocks($moduleDirname, $tables, $language); @@ -814,8 +893,7 @@ public function render() } $content .= $this->getXoopsVersionConfig($module, $table, $language); if (is_object($table) && 1 == $table->getVar('table_notifications')) { - $content .= $this->getXoopsVersionNotifications($moduleDirname, $tables, $language, $filename); - + $content .= $this->getXoopsVersionNotifications($moduleDirname, $tables, $language, $filename); } $this->tdmcfile->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); diff --git a/class/settings.php b/class/settings.php index efebbfea..1467208e 100644 --- a/class/settings.php +++ b/class/settings.php @@ -134,11 +134,14 @@ public function getForm($action = false) $action = $_SERVER['REQUEST_URI']; } $isNew = $this->isNew(); + // include_once(XOOPS_ROOT_PATH . '/class/xoopsformloader.php'); // - $form = new XoopsThemeForm(_AM_TDMCREATE_SETTING_EDIT, 'settingform', $action, 'post'); + $form = new XoopsThemeForm(_AM_TDMCREATE_SETTING_EDIT, 'settingform', $action, 'post'); $form->setExtra('enctype="multipart/form-data"'); + + $form->addElement(new XoopsFormHidden('set_id', $this->getVar('set_id'))); $form->addElement(new XoopsFormText(_AM_TDMCREATE_SETTING_NAME, 'set_name', 50, 255, $this->getVar('set_name'))); $form->addElement(new XoopsFormText(_AM_TDMCREATE_SETTING_DIRNAME, 'set_dirname', 25, 255, $this->getVar('set_dirname'))); $form->addElement(new XoopsFormText(_AM_TDMCREATE_SETTING_VERSION, 'set_version', 10, 25, $this->getVar('set_version'))); @@ -207,8 +210,9 @@ public function getForm($action = false) $form->addElement(new XoopsFormText(_AM_TDMCREATE_SETTING_RELEASE, 'set_release', 50, 255, $this->getVar('set_release'))); $form->addElement(new XoopsFormText(_AM_TDMCREATE_SETTING_STATUS, 'set_status', 50, 255, $this->getVar('set_status'))); $form->addElement(new XoopsFormText(_AM_TDMCREATE_SETTING_PAYPAL_BUTTON, 'set_donations', 50, 255, $this->getVar('set_donations'))); - $form->addElement(new XoopsFormText(_AM_TDMCREATE_SETTING_SUBVERSION, 'set_subversion', 50, 255, $this->getVar('set_subversion'))); - $form->addElement(new XoopsFormHidden('op', 'save')); + $form->addElement(new XoopsFormText(_AM_TDMCREATE_SETTING_SUBVERSION, 'set_subversion', 50, 255, $this->getVar('set_subversion'))); + + $form->addElement(new XoopsFormHidden('op', 'save')); $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); return $form; diff --git a/sql/mysql.sql b/sql/mysql.sql index 7fa57803..9fe8875a 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -54,7 +54,7 @@ CREATE TABLE `tdmcreate_settings` ( PRIMARY KEY (`set_id`) )ENGINE =InnoDB; -INSERT INTO `tdmcreate_settings` (null, `set_name`, `set_dirname`, `set_version`, `set_since`, `set_min_php`, `set_min_xoops`, `set_min_admin`, `set_min_mysql`, `set_description`, `set_author`, `set_author_mail`, `set_author_website_url`, `set_author_website_name`, `set_credits`, `set_license`, `set_release_info`, `set_release_file`, `set_manual`, `set_manual_file`, `set_image`, `set_demo_site_url`, `set_demo_site_name`, `set_support_url`, `set_support_name`, `set_website_url`, `set_website_name`, `set_release`, `set_status`, `set_admin`, `set_user`, `set_blocks`, `set_search`, `set_comments`, `set_notifications`, `set_permissions`, `set_inroot_copy`, `set_donations`, `set_subversion`) VALUES (1, 'My Module', 'mymoduledirname', '1.0', '1.0', '5.3', '2.5.7', '1.1', '5.0.7', 'This module is for doing following...', 'TDM XOOPS', 'info@email.com', 'http://xoops.org', 'XOOPS Project', 'XOOPS Development Team', 'GPL 2.0 or later', 'release_info', 'release_info file', 'link to manual file', 'install.txt', 'empty.png', 'http://www.xoops.org', 'XOOPS Demo Site', 'http://xoops.org/modules/newbb', 'Support Forum', 'www.xoops.org', 'XOOPS Project', '2015-05-02', 'Beta 1', '1', '1', '1', '0', '0', '0', '0', '0', '6KJ7RW5DR3VTJ', '13070'); +INSERT INTO `tdmcreate_settings` (`set_id`, `set_name`, `set_dirname`, `set_version`, `set_since`, `set_min_php`, `set_min_xoops`, `set_min_admin`, `set_min_mysql`, `set_description`, `set_author`, `set_author_mail`, `set_author_website_url`, `set_author_website_name`, `set_credits`, `set_license`, `set_release_info`, `set_release_file`, `set_manual`, `set_manual_file`, `set_image`, `set_demo_site_url`, `set_demo_site_name`, `set_support_url`, `set_support_name`, `set_website_url`, `set_website_name`, `set_release`, `set_status`, `set_admin`, `set_user`, `set_blocks`, `set_search`, `set_comments`, `set_notifications`, `set_permissions`, `set_inroot_copy`, `set_donations`, `set_subversion`) VALUES (1, 'My Module', 'mymoduledirname', '1.0', '1.0', '5.3', '2.5.7', '1.1', '5.0.7', 'This module is for doing following...', 'TDM XOOPS', 'info@email.com', 'http://xoops.org', 'XOOPS Project', 'XOOPS Development Team', 'GPL 2.0 or later', 'release_info', 'release_info file', 'link to manual file', 'install.txt', 'empty.png', 'http://www.xoops.org', 'XOOPS Demo Site', 'http://xoops.org/modules/newbb', 'Support Forum', 'www.xoops.org', 'XOOPS Project', '2015-05-02', 'Beta 1', '1', '1', '1', '0', '0', '0', '0', '0', '6KJ7RW5DR3VTJ', '13070'); # # Table structure for table `tdmcreate_modules` 39 diff --git a/templates/admin/tdmcreate_fields_item.tpl b/templates/admin/tdmcreate_fields_item.tpl index 2395e9b0..7f39b7af 100644 --- a/templates/admin/tdmcreate_fields_item.tpl +++ b/templates/admin/tdmcreate_fields_item.tpl @@ -1,8 +1,8 @@ - <{foreach item=field from=$table.fields}> + <{foreach item=field from=$table.fields key=field_id}> <{if $field.id > 0}> - + diff --git a/templates/admin/tdmcreate_modules.tpl b/templates/admin/tdmcreate_modules.tpl index c129b551..2eb8aece 100644 --- a/templates/admin/tdmcreate_modules.tpl +++ b/templates/admin/tdmcreate_modules.tpl @@ -19,7 +19,7 @@ - <{foreach item=module from=$modules_list}> + <{foreach item=module from=$modules_list key=mod_id}> diff --git a/templates/admin/tdmcreate_tables_item.tpl b/templates/admin/tdmcreate_tables_item.tpl index fe30be8a..6ea54290 100644 --- a/templates/admin/tdmcreate_tables_item.tpl +++ b/templates/admin/tdmcreate_tables_item.tpl @@ -1,6 +1,6 @@
[<{$field.lid}>] <{$field.name}> <{$field.name}> Empty<{$smarty.const._AM_TDMCREATE_MODULE_PERMISSIONS_LIST}> <{$smarty.const._AM_TDMCREATE_FORMACTION}>
<{$module.id}> <{$module.name}>
- <{foreach item=table from=$module.tables}> + <{foreach item=table from=$module.tables key=table_id}> <{if $table.id > 0}>
[<{$table.lid}>] <{$table.name}>