|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace XoopsModules\Modulebuilder\Files\Templates\User\Defstyle; |
| 4 | + |
| 5 | +use XoopsModules\Modulebuilder; |
| 6 | +use XoopsModules\Modulebuilder\Files; |
| 7 | + |
| 8 | +/* |
| 9 | + You may not change or alter any portion of this comment or credits |
| 10 | + of supporting developers from this source code or any supporting source code |
| 11 | + which is considered copyrighted (c) material of the original comment or credit authors. |
| 12 | +
|
| 13 | + This program is distributed in the hope that it will be useful, |
| 14 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 16 | + */ |
| 17 | +/** |
| 18 | + * modulebuilder module. |
| 19 | + * |
| 20 | + * @copyright XOOPS Project (https://xoops.org) |
| 21 | + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
| 22 | + * |
| 23 | + * @since 2.5.0 |
| 24 | + * |
| 25 | + * @author Txmod Xoops http://www.txmodxoops.org |
| 26 | + * |
| 27 | + */ |
| 28 | + |
| 29 | +/** |
| 30 | + * class PagesItem. |
| 31 | + */ |
| 32 | +class PagesItem extends Files\CreateFile |
| 33 | +{ |
| 34 | + /** |
| 35 | + * @public function constructor |
| 36 | + * @param null |
| 37 | + */ |
| 38 | + public function __construct() |
| 39 | + { |
| 40 | + parent::__construct(); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * @static function getInstance |
| 45 | + * @param null |
| 46 | + * @return PagesItem |
| 47 | + */ |
| 48 | + public static function getInstance() |
| 49 | + { |
| 50 | + static $instance = false; |
| 51 | + if (!$instance) { |
| 52 | + $instance = new self(); |
| 53 | + } |
| 54 | + |
| 55 | + return $instance; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @public function write |
| 60 | + * @param string $module |
| 61 | + * @param string $table |
| 62 | + * @param string $filename |
| 63 | + * @param $tables |
| 64 | + */ |
| 65 | + public function write($module, $table, $tables, $filename) |
| 66 | + { |
| 67 | + $this->setModule($module); |
| 68 | + $this->setTable($table); |
| 69 | + $this->setTables($tables); |
| 70 | + $this->setFileName($filename); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * @private function getTemplatesUserPagesItemPanel |
| 75 | + * @param string $moduleDirname |
| 76 | + * @param $tableId |
| 77 | + * @param $tableMid |
| 78 | + * @param $tableName |
| 79 | + * @param $tableSoleName |
| 80 | + * @param $language |
| 81 | + * @return string |
| 82 | + */ |
| 83 | + private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) |
| 84 | + { |
| 85 | + $hc = Modulebuilder\Files\CreateHtmlCode::getInstance(); |
| 86 | + $sc = Modulebuilder\Files\CreateSmartyCode::getInstance(); |
| 87 | + $fields = $this->getTableFields($tableMid, $tableId); |
| 88 | + $ret = ''; |
| 89 | + $retNumb = ''; |
| 90 | + foreach (array_keys($fields) as $f) { |
| 91 | + $fieldElement = $fields[$f]->getVar('field_element'); |
| 92 | + if (1 == $fields[$f]->getVar('field_user')) { |
| 93 | + if (1 == $fields[$f]->getVar('field_thead')) { |
| 94 | + switch ($fieldElement) { |
| 95 | + default: |
| 96 | + //case 2: |
| 97 | + $fieldName = $fields[$f]->getVar('field_name'); |
| 98 | + $rpFieldName = $this->getRightString($fieldName); |
| 99 | + $doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
| 100 | + $retNumb .= $hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); |
| 101 | + break; |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + $ret .= $hc->getHtmlDiv($retNumb, 'panel-heading'); |
| 107 | + $retElem = ''; |
| 108 | + foreach (array_keys($fields) as $f) { |
| 109 | + $fieldElement = $fields[$f]->getVar('field_element'); |
| 110 | + if (1 == $fields[$f]->getVar('field_user')) { |
| 111 | + if (1 == $fields[$f]->getVar('field_tbody')) { |
| 112 | + switch ($fieldElement) { |
| 113 | + default: |
| 114 | + //case 3: |
| 115 | + //case 4: |
| 116 | + $fieldName = $fields[$f]->getVar('field_name'); |
| 117 | + $rpFieldName = $this->getRightString($fieldName); |
| 118 | + $doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
| 119 | + $retElem .= $hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); |
| 120 | + break; |
| 121 | + case 10: |
| 122 | + $fieldName = $fields[$f]->getVar('field_name'); |
| 123 | + $rpFieldName = $this->getRightString($fieldName); |
| 124 | + $singleVar = $sc->getSmartySingleVar('xoops_icons32_url'); |
| 125 | + $doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
| 126 | + $img = $hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); |
| 127 | + $retElem .= $hc->getHtmlSpan($img, 'col-sm-3', "\t"); |
| 128 | + unset($img); |
| 129 | + break; |
| 130 | + case 13: |
| 131 | + $fieldName = $fields[$f]->getVar('field_name'); |
| 132 | + $rpFieldName = $this->getRightString($fieldName); |
| 133 | + $singleVar = $sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
| 134 | + $doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
| 135 | + $img = $hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); |
| 136 | + $retElem .= $hc->getHtmlSpan($img, 'col-sm-3',"\t"); |
| 137 | + unset($img); |
| 138 | + break; |
| 139 | + } |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | + $ret .= $hc->getHtmlDiv($retElem, 'panel-body'); |
| 144 | + $retFoot = ''; |
| 145 | + foreach (array_keys($fields) as $f) { |
| 146 | + if (1 == $fields[$f]->getVar('field_user')) { |
| 147 | + if (1 == $fields[$f]->getVar('field_tfoot')) { |
| 148 | + $fieldName = $fields[$f]->getVar('field_name'); |
| 149 | + $rpFieldName = $this->getRightString($fieldName); |
| 150 | + $langConst = mb_strtoupper($tableSoleName) . '_' . mb_strtoupper($rpFieldName); |
| 151 | + $lang = $sc->getSmartyConst($language, $langConst); |
| 152 | + $doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
| 153 | + $retFoot .= $hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); |
| 154 | + } |
| 155 | + } |
| 156 | + } |
| 157 | + $ret .= $hc->getHtmlDiv($retFoot, 'panel-foot'); |
| 158 | + |
| 159 | + return $ret; |
| 160 | + } |
| 161 | + |
| 162 | + /** |
| 163 | + * @public function render |
| 164 | + * @param null |
| 165 | + * @return bool|string |
| 166 | + */ |
| 167 | + public function render() |
| 168 | + { |
| 169 | + $module = $this->getModule(); |
| 170 | + $table = $this->getTable(); |
| 171 | + //$tables = $this->getTables(); |
| 172 | + //$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
| 173 | + $moduleDirname = $module->getVar('mod_dirname'); |
| 174 | + $filename = $this->getFileName(); |
| 175 | + $language = $this->getLanguage($moduleDirname, 'MA'); |
| 176 | + $content = ''; |
| 177 | + $tableId = $table->getVar('table_id'); |
| 178 | + $tableMid = $table->getVar('table_mid'); |
| 179 | + $tableName = $table->getVar('table_name'); |
| 180 | + $tableSoleName = $table->getVar('table_solename'); |
| 181 | + $tableCategory[] = $table->getVar('table_category'); |
| 182 | + //$tableIndex = $table->getVar('table_index'); |
| 183 | + if (in_array(0, $tableCategory)) { |
| 184 | + $content .= $this->getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language); |
| 185 | + } |
| 186 | + |
| 187 | + $this->create($moduleDirname, 'templates', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED); |
| 188 | + |
| 189 | + return $this->renderFile(); |
| 190 | + } |
| 191 | +} |
0 commit comments