| @@ 29-191 (lines=163) @@ | ||
| 26 | /** |
|
| 27 | * Class UserSearch. |
|
| 28 | */ |
|
| 29 | class UserSearch extends TDMCreateFile |
|
| 30 | { |
|
| 31 | /* |
|
| 32 | * @public function constructor |
|
| 33 | * @param null |
|
| 34 | */ |
|
| 35 | /** |
|
| 36 | * |
|
| 37 | */ |
|
| 38 | public function __construct() |
|
| 39 | { |
|
| 40 | parent::__construct(); |
|
| 41 | $this->xoopscode = TDMCreateXoopsCode::getInstance(); |
|
| 42 | $this->phpcode = TDMCreatePhpCode::getInstance(); |
|
| 43 | $this->usercode = UserXoopsCode::getInstance(); |
|
| 44 | } |
|
| 45 | ||
| 46 | /* |
|
| 47 | * @static function &getInstance |
|
| 48 | * @param null |
|
| 49 | */ |
|
| 50 | /** |
|
| 51 | * @return UserSearch |
|
| 52 | */ |
|
| 53 | public static function &getInstance() |
|
| 54 | { |
|
| 55 | static $instance = false; |
|
| 56 | if (!$instance) { |
|
| 57 | $instance = new self(); |
|
| 58 | } |
|
| 59 | ||
| 60 | return $instance; |
|
| 61 | } |
|
| 62 | ||
| 63 | /* |
|
| 64 | * @public function write |
|
| 65 | * @param string $module |
|
| 66 | * @param mixed $table |
|
| 67 | * @param string $filename |
|
| 68 | */ |
|
| 69 | /** |
|
| 70 | * @param $module |
|
| 71 | * @param $table |
|
| 72 | * @param $filename |
|
| 73 | */ |
|
| 74 | public function write($module, $table, $filename) |
|
| 75 | { |
|
| 76 | $this->setModule($module); |
|
| 77 | $this->setTable($table); |
|
| 78 | $this->setFileName($filename); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @private function getUserSearchHeader |
|
| 83 | * |
|
| 84 | * @param $moduleDirname |
|
| 85 | * |
|
| 86 | * @return string |
|
| 87 | */ |
|
| 88 | private function getUserSearchHeader($moduleDirname, $table, $fields) |
|
| 89 | { |
|
| 90 | $ret = $this->getInclude(); |
|
| 91 | foreach (array_keys($fields) as $f) { |
|
| 92 | $fieldName = $fields[$f]->getVar('field_name'); |
|
| 93 | if (0 == $f) { |
|
| 94 | $fieldId = $fieldName; |
|
| 95 | } |
|
| 96 | if (1 == $fields[$f]->getVar('field_parent')) { |
|
| 97 | $fieldPid = $fieldName; |
|
| 98 | } |
|
| 99 | } |
|
| 100 | if ($table->getVar('table_category') == 1) { |
|
| 101 | $ccFieldPid = $this->getCamelCase($fieldPid, false, true); |
|
| 102 | $ret .= $this->xoopscode->getXoopsCodeXoopsRequest("{$ccFieldPid}", "{$fieldPid}", '0', 'Int'); |
|
| 103 | } |
|
| 104 | $ccFieldId = $this->getCamelCase($fieldId, false, true); |
|
| 105 | $ret .= $this->xoopscode->getXoopsCodeXoopsRequest("{$ccFieldId}", "{$fieldId}", '0', 'Int'); |
|
| 106 | $ret .= $this->usercode->getUserTplMain($moduleDirname); |
|
| 107 | $ret .= $this->phpcode->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true); |
|
| 108 | $ret .= $this->getCommentLine('Define Stylesheet'); |
|
| 109 | $ret .= $this->xoopscode->getXoopsCodeAddStylesheet(); |
|
| 110 | ||
| 111 | return $ret; |
|
| 112 | } |
|
| 113 | ||
| 114 | /* |
|
| 115 | * @public function getAdminPagesList |
|
| 116 | * @param string $tableName |
|
| 117 | * @param string $language |
|
| 118 | */ |
|
| 119 | /** |
|
| 120 | * @param $module |
|
| 121 | * @param $tableName |
|
| 122 | * @param $language |
|
| 123 | * |
|
| 124 | * @return string |
|
| 125 | */ |
|
| 126 | public function getUserSearch($moduleDirname, $tableName, $language) |
|
| 127 | { |
|
| 128 | $ret = <<<EOT |
|
| 129 | ||
| 130 | EOT; |
|
| 131 | $ret .= $this->getSimpleString('$keywords = array();'); |
|
| 132 | ||
| 133 | return $ret; |
|
| 134 | } |
|
| 135 | ||
| 136 | /** |
|
| 137 | * @private function getUserSearchFooter |
|
| 138 | * |
|
| 139 | * @param $moduleDirname |
|
| 140 | * @param $tableName |
|
| 141 | * @param $language |
|
| 142 | * |
|
| 143 | * @return string |
|
| 144 | */ |
|
| 145 | private function getUserSearchFooter($moduleDirname, $tableName, $language) |
|
| 146 | { |
|
| 147 | $stuModuleDirname = strtoupper($moduleDirname); |
|
| 148 | $stuTableName = strtoupper($tableName); |
|
| 149 | $ret = $this->getCommentLine('Breadcrumbs'); |
|
| 150 | $ret .= $this->usercode->getUserBreadcrumbs("{$stuTableName}", $language); |
|
| 151 | $ret .= $this->getCommentLine('Keywords'); |
|
| 152 | $ret .= $this->usercode->getUserMetaKeywords($moduleDirname); |
|
| 153 | $ret .= $this->phpcode->getPhpCodeUnset('keywords'); |
|
| 154 | $ret .= $this->getCommentLine('Description'); |
|
| 155 | $ret .= $this->usercode->getUserMetaDesc($moduleDirname, 'DESC', $language); |
|
| 156 | $ret .= $this->xoopscode->getXoopsCodeTplAssign('xoops_mpageurl', "{$stuModuleDirname}_URL.'/index.php'"); |
|
| 157 | $ret .= $this->xoopscode->getXoopsCodeTplAssign('xoops_icons32_url', 'XOOPS_ICONS32_URL'); |
|
| 158 | $ret .= $this->xoopscode->getXoopsCodeTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL"); |
|
| 159 | $ret .= $this->getInclude('footer'); |
|
| 160 | ||
| 161 | return $ret; |
|
| 162 | } |
|
| 163 | ||
| 164 | /* |
|
| 165 | * @public function render |
|
| 166 | * @param null |
|
| 167 | */ |
|
| 168 | /** |
|
| 169 | * @return bool|string |
|
| 170 | */ |
|
| 171 | public function render() |
|
| 172 | { |
|
| 173 | $module = $this->getModule(); |
|
| 174 | $table = $this->getTable(); |
|
| 175 | $filename = $this->getFileName(); |
|
| 176 | $moduleDirname = $module->getVar('mod_dirname'); |
|
| 177 | $tableId = $table->getVar('table_id'); |
|
| 178 | $tableMid = $table->getVar('table_mid'); |
|
| 179 | $tableName = $table->getVar('table_name'); |
|
| 180 | $fields = $this->getTableFields($tableMid, $tableId); |
|
| 181 | $language = $this->getLanguage($moduleDirname, 'MA'); |
|
| 182 | $content = $this->getHeaderFilesComments($module, $filename); |
|
| 183 | $content .= $this->getUserSearchHeader($moduleDirname, $table, $fields); |
|
| 184 | $content .= $this->getUserSearch($moduleDirname, $tableName, $language); |
|
| 185 | $content .= $this->getUserSearchFooter($moduleDirname, $tableName, $language); |
|
| 186 | ||
| 187 | $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
| 188 | ||
| 189 | return $this->renderFile(); |
|
| 190 | } |
|
| 191 | } |
|
| 192 | ||
| @@ 29-190 (lines=162) @@ | ||
| 26 | /** |
|
| 27 | * Class UserSingle. |
|
| 28 | */ |
|
| 29 | class UserSingle extends TDMCreateFile |
|
| 30 | { |
|
| 31 | /* |
|
| 32 | * @public function constructor |
|
| 33 | * @param null |
|
| 34 | */ |
|
| 35 | /** |
|
| 36 | * |
|
| 37 | */ |
|
| 38 | public function __construct() |
|
| 39 | { |
|
| 40 | parent::__construct(); |
|
| 41 | $this->xoopscode = TDMCreateXoopsCode::getInstance(); |
|
| 42 | $this->phpcode = TDMCreatePhpCode::getInstance(); |
|
| 43 | $this->usercode = UserXoopsCode::getInstance(); |
|
| 44 | } |
|
| 45 | ||
| 46 | /* |
|
| 47 | * @static function &getInstance |
|
| 48 | * @param null |
|
| 49 | */ |
|
| 50 | /** |
|
| 51 | * @return UserSingle |
|
| 52 | */ |
|
| 53 | public static function &getInstance() |
|
| 54 | { |
|
| 55 | static $instance = false; |
|
| 56 | if (!$instance) { |
|
| 57 | $instance = new self(); |
|
| 58 | } |
|
| 59 | ||
| 60 | return $instance; |
|
| 61 | } |
|
| 62 | ||
| 63 | /* |
|
| 64 | * @public function write |
|
| 65 | * @param string $module |
|
| 66 | * @param mixed $table |
|
| 67 | * @param string $filename |
|
| 68 | */ |
|
| 69 | /** |
|
| 70 | * @param $module |
|
| 71 | * @param $table |
|
| 72 | * @param $filename |
|
| 73 | */ |
|
| 74 | public function write($module, $table, $filename) |
|
| 75 | { |
|
| 76 | $this->setModule($module); |
|
| 77 | $this->setTable($table); |
|
| 78 | $this->setFileName($filename); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @private function getUserSingleHeader |
|
| 83 | * |
|
| 84 | * @param $moduleDirname |
|
| 85 | * |
|
| 86 | * @return string |
|
| 87 | */ |
|
| 88 | private function getUserSingleHeader($moduleDirname, $table, $fields) |
|
| 89 | { |
|
| 90 | $ret = $this->getInclude(); |
|
| 91 | foreach (array_keys($fields) as $f) { |
|
| 92 | $fieldName = $fields[$f]->getVar('field_name'); |
|
| 93 | if (0 == $f) { |
|
| 94 | $fieldId = $fieldName; |
|
| 95 | } |
|
| 96 | if (1 == $fields[$f]->getVar('field_parent')) { |
|
| 97 | $fieldPid = $fieldName; |
|
| 98 | } |
|
| 99 | } |
|
| 100 | if ($table->getVar('table_category') == 1) { |
|
| 101 | $ccFieldPid = $this->getCamelCase($fieldPid, false, true); |
|
| 102 | $ret .= $this->xoopscode->getXoopsCodeXoopsRequest("{$ccFieldPid}", "{$fieldPid}", '0', 'Int'); |
|
| 103 | } |
|
| 104 | $ccFieldId = $this->getCamelCase($fieldId, false, true); |
|
| 105 | $ret .= $this->xoopscode->getXoopsCodeXoopsRequest("{$ccFieldId}", "{$fieldId}", '0', 'Int'); |
|
| 106 | $ret .= $this->usercode->getUserTplMain($moduleDirname); |
|
| 107 | $ret .= $this->phpcode->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true); |
|
| 108 | $ret .= $this->getCommentLine('Define Stylesheet'); |
|
| 109 | $ret .= $this->xoopscode->getXoopsCodeAddStylesheet(); |
|
| 110 | ||
| 111 | return $ret; |
|
| 112 | } |
|
| 113 | ||
| 114 | /* |
|
| 115 | * @public function getAdminPagesList |
|
| 116 | * @param string $tableName |
|
| 117 | * @param string $language |
|
| 118 | */ |
|
| 119 | /** |
|
| 120 | * @param $module |
|
| 121 | * @param $tableName |
|
| 122 | * @param $language |
|
| 123 | * |
|
| 124 | * @return string |
|
| 125 | */ |
|
| 126 | public function getUserSingle($moduleDirname, $tableName, $language) |
|
| 127 | { |
|
| 128 | $ret = <<<EOT |
|
| 129 | ||
| 130 | EOT; |
|
| 131 | $ret .= $this->getSimpleString('$keywords = array();'); |
|
| 132 | ||
| 133 | return $ret; |
|
| 134 | } |
|
| 135 | ||
| 136 | /** |
|
| 137 | * @private function getUserSingleFooter |
|
| 138 | * |
|
| 139 | * @param $moduleDirname |
|
| 140 | * @param $tableName |
|
| 141 | * @param $language |
|
| 142 | * |
|
| 143 | * @return string |
|
| 144 | */ |
|
| 145 | private function getUserSingleFooter($moduleDirname, $tableName, $language) |
|
| 146 | { |
|
| 147 | $stuModuleDirname = strtoupper($moduleDirname); |
|
| 148 | $stuTableName = strtoupper($tableName); |
|
| 149 | $ret = $this->getCommentLine('Breadcrumbs'); |
|
| 150 | $ret .= $this->usercode->getUserBreadcrumbs("{$stuTableName}", $language); |
|
| 151 | $ret .= $this->getCommentLine('Keywords'); |
|
| 152 | $ret .= $this->usercode->getUserMetaKeywords($moduleDirname); |
|
| 153 | $ret .= $this->phpcode->getPhpCodeUnset('keywords'); |
|
| 154 | $ret .= $this->getCommentLine('Description'); |
|
| 155 | $ret .= $this->usercode->getUserMetaDesc($moduleDirname, 'DESC', $language); |
|
| 156 | $ret .= $this->xoopscode->getXoopsCodeTplAssign('xoops_mpageurl', "{$stuModuleDirname}_URL.'/index.php'"); |
|
| 157 | $ret .= $this->xoopscode->getXoopsCodeTplAssign('xoops_icons32_url', 'XOOPS_ICONS32_URL'); |
|
| 158 | $ret .= $this->xoopscode->getXoopsCodeTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL"); |
|
| 159 | $ret .= $this->getInclude('footer'); |
|
| 160 | ||
| 161 | return $ret; |
|
| 162 | } |
|
| 163 | ||
| 164 | /* |
|
| 165 | * @public function render |
|
| 166 | * @param null |
|
| 167 | */ |
|
| 168 | /** |
|
| 169 | * @return bool|string |
|
| 170 | */ |
|
| 171 | public function render() |
|
| 172 | { |
|
| 173 | $module = $this->getModule(); |
|
| 174 | $table = $this->getTable(); |
|
| 175 | $filename = $this->getFileName(); |
|
| 176 | $moduleDirname = $module->getVar('mod_dirname'); |
|
| 177 | $tableId = $table->getVar('table_id'); |
|
| 178 | $tableMid = $table->getVar('table_mid'); |
|
| 179 | $tableName = $table->getVar('table_name'); |
|
| 180 | $fields = $this->getTableFields($tableMid, $tableId); |
|
| 181 | $language = $this->getLanguage($moduleDirname, 'MA'); |
|
| 182 | $content = $this->getHeaderFilesComments($module, $filename); |
|
| 183 | $content .= $this->getUserSingleHeader($moduleDirname, $table, $fields); |
|
| 184 | $content .= $this->getUserSingle($module, $tableName, $language); |
|
| 185 | $content .= $this->getUserSingleFooter($moduleDirname, $tableName, $language); |
|
| 186 | $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
| 187 | ||
| 188 | return $this->renderFile(); |
|
| 189 | } |
|
| 190 | } |
|
| 191 | ||