@@ -23,50 +23,50 @@ |
||
| 23 | 23 | $moduleDirName = basename(dirname(__DIR__)); |
| 24 | 24 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
| 25 | 25 | return (object)[ |
| 26 | - 'name' => mb_strtoupper($moduleDirName) . ' Module Configurator', |
|
| 27 | - 'paths' => [ |
|
| 28 | - 'dirname' => $moduleDirName, |
|
| 29 | - 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', |
|
| 30 | - 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, |
|
| 31 | - 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, |
|
| 32 | - 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, |
|
| 33 | - 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, |
|
| 34 | - ], |
|
| 35 | - 'uploadFolders' => [ |
|
| 36 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName, |
|
| 37 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/categories', |
|
| 38 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/articles', |
|
| 39 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/testfields', |
|
| 40 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', |
|
| 41 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/categories', |
|
| 42 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/articles', |
|
| 43 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/testfields', |
|
| 44 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/files', |
|
| 45 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/files/categories', |
|
| 46 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/files/articles', |
|
| 47 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/files/testfields', |
|
| 48 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/temp', |
|
| 49 | - ], |
|
| 50 | - 'copyBlankFiles' => [ |
|
| 51 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', |
|
| 52 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/categories', |
|
| 53 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/articles', |
|
| 54 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/testfields', |
|
| 55 | - ], |
|
| 56 | - 'copyTestFolders' => [ |
|
| 57 | - XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/testdata/uploads', |
|
| 58 | - XOOPS_UPLOAD_PATH . '/' . $moduleDirName, |
|
| 59 | - ], |
|
| 60 | - 'templateFolders' => [ |
|
| 61 | - '/templates/', |
|
| 62 | - ], |
|
| 63 | - 'oldFiles' => [ |
|
| 64 | - ], |
|
| 65 | - 'oldFolders' => [ |
|
| 66 | - ], |
|
| 67 | - 'renameTables' => [ |
|
| 68 | - ], |
|
| 69 | - 'moduleStats' => [ |
|
| 70 | - ], |
|
| 71 | - 'modCopyright' => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'><img src='" . XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . "/assets/images/logo/logoModule.png' alt='XOOPS Project'></a>", |
|
| 26 | + 'name' => mb_strtoupper($moduleDirName) . ' Module Configurator', |
|
| 27 | + 'paths' => [ |
|
| 28 | + 'dirname' => $moduleDirName, |
|
| 29 | + 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', |
|
| 30 | + 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, |
|
| 31 | + 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, |
|
| 32 | + 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, |
|
| 33 | + 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, |
|
| 34 | + ], |
|
| 35 | + 'uploadFolders' => [ |
|
| 36 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName, |
|
| 37 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/categories', |
|
| 38 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/articles', |
|
| 39 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/testfields', |
|
| 40 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', |
|
| 41 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/categories', |
|
| 42 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/articles', |
|
| 43 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/testfields', |
|
| 44 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/files', |
|
| 45 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/files/categories', |
|
| 46 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/files/articles', |
|
| 47 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/files/testfields', |
|
| 48 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/temp', |
|
| 49 | + ], |
|
| 50 | + 'copyBlankFiles' => [ |
|
| 51 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', |
|
| 52 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/categories', |
|
| 53 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/articles', |
|
| 54 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images/testfields', |
|
| 55 | + ], |
|
| 56 | + 'copyTestFolders' => [ |
|
| 57 | + XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/testdata/uploads', |
|
| 58 | + XOOPS_UPLOAD_PATH . '/' . $moduleDirName, |
|
| 59 | + ], |
|
| 60 | + 'templateFolders' => [ |
|
| 61 | + '/templates/', |
|
| 62 | + ], |
|
| 63 | + 'oldFiles' => [ |
|
| 64 | + ], |
|
| 65 | + 'oldFolders' => [ |
|
| 66 | + ], |
|
| 67 | + 'renameTables' => [ |
|
| 68 | + ], |
|
| 69 | + 'moduleStats' => [ |
|
| 70 | + ], |
|
| 71 | + 'modCopyright' => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'><img src='" . XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . "/assets/images/logo/logoModule.png' alt='XOOPS Project'></a>", |
|
| 72 | 72 | ]; |
@@ -41,42 +41,42 @@ |
||
| 41 | 41 | array_shift($options); |
| 42 | 42 | array_shift($options); |
| 43 | 43 | array_shift($options); |
| 44 | - switch($typeBlock) |
|
| 45 | - { |
|
| 46 | - // For the block: testfields last |
|
| 47 | - case 'last': |
|
| 48 | - //$criteria->add(new \Criteria('tf_display', 1)); |
|
| 49 | - $criteria->setSort('tf_created'); |
|
| 50 | - $criteria->setOrder('DESC'); |
|
| 51 | - break; |
|
| 52 | - // For the block: testfields new |
|
| 53 | - case 'new': |
|
| 54 | - //$criteria->add(new \Criteria('tf_display', 1)); |
|
| 55 | - $criteria->add(new \Criteria('tf_created', strtotime(date(_SHORTDATESTRING)), '>=')); |
|
| 56 | - $criteria->add(new \Criteria('tf_created', strtotime(date(_SHORTDATESTRING))+86400, '<=')); |
|
| 57 | - $criteria->setSort('tf_created'); |
|
| 58 | - $criteria->setOrder('ASC'); |
|
| 59 | - break; |
|
| 60 | - // For the block: testfields hits |
|
| 61 | - case 'hits': |
|
| 44 | + switch($typeBlock) |
|
| 45 | + { |
|
| 46 | + // For the block: testfields last |
|
| 47 | + case 'last': |
|
| 48 | + //$criteria->add(new \Criteria('tf_display', 1)); |
|
| 49 | + $criteria->setSort('tf_created'); |
|
| 50 | + $criteria->setOrder('DESC'); |
|
| 51 | + break; |
|
| 52 | + // For the block: testfields new |
|
| 53 | + case 'new': |
|
| 54 | + //$criteria->add(new \Criteria('tf_display', 1)); |
|
| 55 | + $criteria->add(new \Criteria('tf_created', strtotime(date(_SHORTDATESTRING)), '>=')); |
|
| 56 | + $criteria->add(new \Criteria('tf_created', strtotime(date(_SHORTDATESTRING))+86400, '<=')); |
|
| 57 | + $criteria->setSort('tf_created'); |
|
| 58 | + $criteria->setOrder('ASC'); |
|
| 59 | + break; |
|
| 60 | + // For the block: testfields hits |
|
| 61 | + case 'hits': |
|
| 62 | 62 | $criteria->setSort('tf_hits'); |
| 63 | 63 | $criteria->setOrder('DESC'); |
| 64 | 64 | break; |
| 65 | - // For the block: testfields top |
|
| 66 | - case 'top': |
|
| 65 | + // For the block: testfields top |
|
| 66 | + case 'top': |
|
| 67 | 67 | $criteria->setSort('tf_top'); |
| 68 | 68 | $criteria->setOrder('ASC'); |
| 69 | 69 | break; |
| 70 | - // For the block: testfields random |
|
| 71 | - case 'random': |
|
| 72 | - //$criteria->add(new \Criteria('tf_display', 1)); |
|
| 73 | - $criteria->setSort('RAND()'); |
|
| 74 | - break; |
|
| 75 | - } |
|
| 70 | + // For the block: testfields random |
|
| 71 | + case 'random': |
|
| 72 | + //$criteria->add(new \Criteria('tf_display', 1)); |
|
| 73 | + $criteria->setSort('RAND()'); |
|
| 74 | + break; |
|
| 75 | + } |
|
| 76 | 76 | $criteria->setLimit($limit); |
| 77 | 77 | $testfieldsAll = $testfieldsHandler->getAll($criteria); |
| 78 | - unset($criteria); |
|
| 79 | - if (count($testfieldsAll) > 0) { |
|
| 78 | + unset($criteria); |
|
| 79 | + if (count($testfieldsAll) > 0) { |
|
| 80 | 80 | foreach(array_keys($testfieldsAll) as $i) |
| 81 | 81 | { |
| 82 | 82 | } |
@@ -41,51 +41,51 @@ |
||
| 41 | 41 | array_shift($options); |
| 42 | 42 | array_shift($options); |
| 43 | 43 | array_shift($options); |
| 44 | - switch($typeBlock) |
|
| 45 | - { |
|
| 46 | - // For the block: articles last |
|
| 47 | - case 'last': |
|
| 48 | - //$criteria->add(new \Criteria('art_display', 1)); |
|
| 49 | - $criteria->setSort('art_created'); |
|
| 50 | - $criteria->setOrder('DESC'); |
|
| 51 | - break; |
|
| 52 | - // For the block: articles new |
|
| 53 | - case 'new': |
|
| 54 | - //$criteria->add(new \Criteria('art_display', 1)); |
|
| 55 | - $criteria->add(new \Criteria('art_created', strtotime(date(_SHORTDATESTRING)), '>=')); |
|
| 56 | - $criteria->add(new \Criteria('art_created', strtotime(date(_SHORTDATESTRING))+86400, '<=')); |
|
| 57 | - $criteria->setSort('art_created'); |
|
| 58 | - $criteria->setOrder('ASC'); |
|
| 59 | - break; |
|
| 60 | - // For the block: articles hits |
|
| 61 | - case 'hits': |
|
| 44 | + switch($typeBlock) |
|
| 45 | + { |
|
| 46 | + // For the block: articles last |
|
| 47 | + case 'last': |
|
| 48 | + //$criteria->add(new \Criteria('art_display', 1)); |
|
| 49 | + $criteria->setSort('art_created'); |
|
| 50 | + $criteria->setOrder('DESC'); |
|
| 51 | + break; |
|
| 52 | + // For the block: articles new |
|
| 53 | + case 'new': |
|
| 54 | + //$criteria->add(new \Criteria('art_display', 1)); |
|
| 55 | + $criteria->add(new \Criteria('art_created', strtotime(date(_SHORTDATESTRING)), '>=')); |
|
| 56 | + $criteria->add(new \Criteria('art_created', strtotime(date(_SHORTDATESTRING))+86400, '<=')); |
|
| 57 | + $criteria->setSort('art_created'); |
|
| 58 | + $criteria->setOrder('ASC'); |
|
| 59 | + break; |
|
| 60 | + // For the block: articles hits |
|
| 61 | + case 'hits': |
|
| 62 | 62 | $criteria->setSort('art_hits'); |
| 63 | 63 | $criteria->setOrder('DESC'); |
| 64 | 64 | break; |
| 65 | - // For the block: articles top |
|
| 66 | - case 'top': |
|
| 65 | + // For the block: articles top |
|
| 66 | + case 'top': |
|
| 67 | 67 | $criteria->setSort('art_top'); |
| 68 | 68 | $criteria->setOrder('ASC'); |
| 69 | 69 | break; |
| 70 | - // For the block: articles random |
|
| 71 | - case 'random': |
|
| 72 | - //$criteria->add(new \Criteria('art_display', 1)); |
|
| 73 | - $criteria->setSort('RAND()'); |
|
| 74 | - break; |
|
| 75 | - } |
|
| 70 | + // For the block: articles random |
|
| 71 | + case 'random': |
|
| 72 | + //$criteria->add(new \Criteria('art_display', 1)); |
|
| 73 | + $criteria->setSort('RAND()'); |
|
| 74 | + break; |
|
| 75 | + } |
|
| 76 | 76 | $criteria->setLimit($limit); |
| 77 | 77 | $articlesAll = $articlesHandler->getAll($criteria); |
| 78 | - unset($criteria); |
|
| 79 | - if (count($articlesAll) > 0) { |
|
| 78 | + unset($criteria); |
|
| 79 | + if (count($articlesAll) > 0) { |
|
| 80 | 80 | foreach(array_keys($articlesAll) as $i) |
| 81 | 81 | { |
| 82 | 82 | $block[$i]['cat'] = $articlesAll[$i]->getVar('art_cat'); |
| 83 | 83 | $block[$i]['title'] = $myts->htmlSpecialChars($articlesAll[$i]->getVar('art_title')); |
| 84 | - $block[$i]['descr'] = strip_tags($articlesAll[$i]->getVar('art_descr')); |
|
| 84 | + $block[$i]['descr'] = strip_tags($articlesAll[$i]->getVar('art_descr')); |
|
| 85 | 85 | $block[$i]['img'] = $articlesAll[$i]->getVar('art_img'); |
| 86 | 86 | $block[$i]['file'] = $articlesAll[$i]->getVar('art_file'); |
| 87 | 87 | $block[$i]['created'] = formatTimeStamp($articlesAll[$i]->getVar('art_created')); |
| 88 | - $block[$i]['submitter'] = \XoopsUser::getUnameFromId($articlesAll[$i]->getVar('art_submitter')); |
|
| 88 | + $block[$i]['submitter'] = \XoopsUser::getUnameFromId($articlesAll[$i]->getVar('art_submitter')); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | return $block; |
@@ -32,25 +32,25 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class Permissions extends \XoopsObject |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Constructor |
|
| 37 | - * |
|
| 38 | - * @param null |
|
| 39 | - */ |
|
| 40 | - public function __construct() |
|
| 41 | - { |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @static function &getInstance |
|
| 46 | - * |
|
| 47 | - * @param null |
|
| 48 | - */ |
|
| 49 | - public static function getInstance() |
|
| 50 | - { |
|
| 51 | - static $instance = false; |
|
| 52 | - if (!$instance) { |
|
| 53 | - $instance = new self(); |
|
| 54 | - } |
|
| 55 | - } |
|
| 35 | + /** |
|
| 36 | + * Constructor |
|
| 37 | + * |
|
| 38 | + * @param null |
|
| 39 | + */ |
|
| 40 | + public function __construct() |
|
| 41 | + { |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @static function &getInstance |
|
| 46 | + * |
|
| 47 | + * @param null |
|
| 48 | + */ |
|
| 49 | + public static function getInstance() |
|
| 50 | + { |
|
| 51 | + static $instance = false; |
|
| 52 | + if (!$instance) { |
|
| 53 | + $instance = new self(); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -32,102 +32,102 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class Categories extends \XoopsObject |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Constructor |
|
| 37 | - * |
|
| 38 | - * @param null |
|
| 39 | - */ |
|
| 40 | - public function __construct() |
|
| 41 | - { |
|
| 42 | - $this->initVar('cat_id', XOBJ_DTYPE_INT); |
|
| 43 | - $this->initVar('cat_name', XOBJ_DTYPE_TXTBOX); |
|
| 44 | - $this->initVar('cat_logo', XOBJ_DTYPE_TXTBOX); |
|
| 45 | - $this->initVar('cat_created', XOBJ_DTYPE_INT); |
|
| 46 | - $this->initVar('cat_submitter', XOBJ_DTYPE_INT); |
|
| 47 | - } |
|
| 35 | + /** |
|
| 36 | + * Constructor |
|
| 37 | + * |
|
| 38 | + * @param null |
|
| 39 | + */ |
|
| 40 | + public function __construct() |
|
| 41 | + { |
|
| 42 | + $this->initVar('cat_id', XOBJ_DTYPE_INT); |
|
| 43 | + $this->initVar('cat_name', XOBJ_DTYPE_TXTBOX); |
|
| 44 | + $this->initVar('cat_logo', XOBJ_DTYPE_TXTBOX); |
|
| 45 | + $this->initVar('cat_created', XOBJ_DTYPE_INT); |
|
| 46 | + $this->initVar('cat_submitter', XOBJ_DTYPE_INT); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @static function &getInstance |
|
| 51 | - * |
|
| 52 | - * @param null |
|
| 53 | - */ |
|
| 54 | - public static function getInstance() |
|
| 55 | - { |
|
| 56 | - static $instance = false; |
|
| 57 | - if (!$instance) { |
|
| 58 | - $instance = new self(); |
|
| 59 | - } |
|
| 60 | - } |
|
| 49 | + /** |
|
| 50 | + * @static function &getInstance |
|
| 51 | + * |
|
| 52 | + * @param null |
|
| 53 | + */ |
|
| 54 | + public static function getInstance() |
|
| 55 | + { |
|
| 56 | + static $instance = false; |
|
| 57 | + if (!$instance) { |
|
| 58 | + $instance = new self(); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * The new inserted $Id |
|
| 64 | - * @return inserted id |
|
| 65 | - */ |
|
| 66 | - public function getNewInsertedIdCategories() |
|
| 67 | - { |
|
| 68 | - $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 69 | - return $newInsertedId; |
|
| 70 | - } |
|
| 62 | + /** |
|
| 63 | + * The new inserted $Id |
|
| 64 | + * @return inserted id |
|
| 65 | + */ |
|
| 66 | + public function getNewInsertedIdCategories() |
|
| 67 | + { |
|
| 68 | + $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 69 | + return $newInsertedId; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @public function getForm |
|
| 74 | - * @param bool $action |
|
| 75 | - * @return XoopsThemeForm |
|
| 76 | - */ |
|
| 77 | - public function getFormCategories($action = false) |
|
| 78 | - { |
|
| 79 | - $helper = \XoopsModules\Mymodule2\Helper::getInstance(); |
|
| 80 | - if (false === $action) { |
|
| 81 | - $action = $_SERVER['REQUEST_URI']; |
|
| 82 | - } |
|
| 83 | - // Title |
|
| 84 | - $title = $this->isNew() ? sprintf(_AM_MYMODULE2_CATEGORY_ADD) : sprintf(_AM_MYMODULE2_CATEGORY_EDIT); |
|
| 85 | - // Get Theme Form |
|
| 86 | - xoops_load('XoopsFormLoader'); |
|
| 87 | - $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
| 88 | - $form->setExtra('enctype="multipart/form-data"'); |
|
| 89 | - // Form Text CatName |
|
| 90 | - $form->addElement(new \XoopsFormText( _AM_MYMODULE2_CATEGORY_NAME, 'cat_name', 50, 255, $this->getVar('cat_name') ), true); |
|
| 91 | - // Form Text Date Select CatCreated |
|
| 92 | - $catCreated = $this->isNew() ? 0 : $this->getVar('cat_created'); |
|
| 93 | - $form->addElement(new \XoopsFormTextDateSelect( _AM_MYMODULE2_CATEGORY_CREATED, 'cat_created', '', $catCreated ), true); |
|
| 94 | - // To Save |
|
| 95 | - $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
| 96 | - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
| 97 | - return $form; |
|
| 98 | - } |
|
| 72 | + /** |
|
| 73 | + * @public function getForm |
|
| 74 | + * @param bool $action |
|
| 75 | + * @return XoopsThemeForm |
|
| 76 | + */ |
|
| 77 | + public function getFormCategories($action = false) |
|
| 78 | + { |
|
| 79 | + $helper = \XoopsModules\Mymodule2\Helper::getInstance(); |
|
| 80 | + if (false === $action) { |
|
| 81 | + $action = $_SERVER['REQUEST_URI']; |
|
| 82 | + } |
|
| 83 | + // Title |
|
| 84 | + $title = $this->isNew() ? sprintf(_AM_MYMODULE2_CATEGORY_ADD) : sprintf(_AM_MYMODULE2_CATEGORY_EDIT); |
|
| 85 | + // Get Theme Form |
|
| 86 | + xoops_load('XoopsFormLoader'); |
|
| 87 | + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
| 88 | + $form->setExtra('enctype="multipart/form-data"'); |
|
| 89 | + // Form Text CatName |
|
| 90 | + $form->addElement(new \XoopsFormText( _AM_MYMODULE2_CATEGORY_NAME, 'cat_name', 50, 255, $this->getVar('cat_name') ), true); |
|
| 91 | + // Form Text Date Select CatCreated |
|
| 92 | + $catCreated = $this->isNew() ? 0 : $this->getVar('cat_created'); |
|
| 93 | + $form->addElement(new \XoopsFormTextDateSelect( _AM_MYMODULE2_CATEGORY_CREATED, 'cat_created', '', $catCreated ), true); |
|
| 94 | + // To Save |
|
| 95 | + $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
| 96 | + $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
| 97 | + return $form; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Get Values |
|
| 102 | - * @param null $keys |
|
| 103 | - * @param null $format |
|
| 104 | - * @param null$maxDepth |
|
| 105 | - * @return array |
|
| 106 | - */ |
|
| 107 | - public function getValuesCategories($keys = null, $format = null, $maxDepth = null) |
|
| 108 | - { |
|
| 109 | - $helper = \XoopsModules\Mymodule2\Helper::getInstance(); |
|
| 110 | - $ret = $this->getValues($keys, $format, $maxDepth); |
|
| 111 | - $ret['id'] = $this->getVar('cat_id'); |
|
| 112 | - $ret['name'] = $this->getVar('cat_name'); |
|
| 113 | - $ret['logo'] = $this->getVar('cat_logo'); |
|
| 114 | - $ret['created'] = formatTimeStamp($this->getVar('cat_created'), 's'); |
|
| 115 | - $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('cat_submitter')); |
|
| 116 | - return $ret; |
|
| 117 | - } |
|
| 100 | + /** |
|
| 101 | + * Get Values |
|
| 102 | + * @param null $keys |
|
| 103 | + * @param null $format |
|
| 104 | + * @param null$maxDepth |
|
| 105 | + * @return array |
|
| 106 | + */ |
|
| 107 | + public function getValuesCategories($keys = null, $format = null, $maxDepth = null) |
|
| 108 | + { |
|
| 109 | + $helper = \XoopsModules\Mymodule2\Helper::getInstance(); |
|
| 110 | + $ret = $this->getValues($keys, $format, $maxDepth); |
|
| 111 | + $ret['id'] = $this->getVar('cat_id'); |
|
| 112 | + $ret['name'] = $this->getVar('cat_name'); |
|
| 113 | + $ret['logo'] = $this->getVar('cat_logo'); |
|
| 114 | + $ret['created'] = formatTimeStamp($this->getVar('cat_created'), 's'); |
|
| 115 | + $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('cat_submitter')); |
|
| 116 | + return $ret; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Returns an array representation of the object |
|
| 121 | - * |
|
| 122 | - * @return array |
|
| 123 | - */ |
|
| 124 | - public function toArrayCategories() |
|
| 125 | - { |
|
| 126 | - $ret = []; |
|
| 127 | - $vars = $this->getVars(); |
|
| 128 | - foreach(array_keys($vars) as $var) { |
|
| 129 | - $ret[$var] = $this->getVar('"{$var}"'); |
|
| 130 | - } |
|
| 131 | - return $ret; |
|
| 132 | - } |
|
| 119 | + /** |
|
| 120 | + * Returns an array representation of the object |
|
| 121 | + * |
|
| 122 | + * @return array |
|
| 123 | + */ |
|
| 124 | + public function toArrayCategories() |
|
| 125 | + { |
|
| 126 | + $ret = []; |
|
| 127 | + $vars = $this->getVars(); |
|
| 128 | + foreach(array_keys($vars) as $var) { |
|
| 129 | + $ret[$var] = $this->getVar('"{$var}"'); |
|
| 130 | + } |
|
| 131 | + return $ret; |
|
| 132 | + } |
|
| 133 | 133 | } |
@@ -32,291 +32,291 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class Testfields extends \XoopsObject |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Constructor |
|
| 37 | - * |
|
| 38 | - * @param null |
|
| 39 | - */ |
|
| 40 | - public function __construct() |
|
| 41 | - { |
|
| 42 | - $this->initVar('tf_id', XOBJ_DTYPE_INT); |
|
| 43 | - $this->initVar('tf_text', XOBJ_DTYPE_TXTBOX); |
|
| 44 | - $this->initVar('tf_textarea', XOBJ_DTYPE_TXTBOX); |
|
| 45 | - $this->initVar('tf_dhtml', XOBJ_DTYPE_TXTBOX); |
|
| 46 | - $this->initVar('tf_checkbox', XOBJ_DTYPE_INT); |
|
| 47 | - $this->initVar('tf_yesno', XOBJ_DTYPE_INT); |
|
| 48 | - $this->initVar('tf_selectbox', XOBJ_DTYPE_TXTBOX); |
|
| 49 | - $this->initVar('tf_user', XOBJ_DTYPE_INT); |
|
| 50 | - $this->initVar('tf_color', XOBJ_DTYPE_TXTBOX); |
|
| 51 | - $this->initVar('tf_imagelist', XOBJ_DTYPE_TXTBOX); |
|
| 52 | - $this->initVar('tf_urlfile', XOBJ_DTYPE_TXTBOX); |
|
| 53 | - $this->initVar('tf_uplimage', XOBJ_DTYPE_TXTBOX); |
|
| 54 | - $this->initVar('tf_uplfile', XOBJ_DTYPE_TXTBOX); |
|
| 55 | - $this->initVar('tf_textdateselect', XOBJ_DTYPE_TXTBOX); |
|
| 56 | - $this->initVar('tf_selectfile', XOBJ_DTYPE_TXTBOX); |
|
| 57 | - $this->initVar('tf_status', XOBJ_DTYPE_INT); |
|
| 58 | - } |
|
| 35 | + /** |
|
| 36 | + * Constructor |
|
| 37 | + * |
|
| 38 | + * @param null |
|
| 39 | + */ |
|
| 40 | + public function __construct() |
|
| 41 | + { |
|
| 42 | + $this->initVar('tf_id', XOBJ_DTYPE_INT); |
|
| 43 | + $this->initVar('tf_text', XOBJ_DTYPE_TXTBOX); |
|
| 44 | + $this->initVar('tf_textarea', XOBJ_DTYPE_TXTBOX); |
|
| 45 | + $this->initVar('tf_dhtml', XOBJ_DTYPE_TXTBOX); |
|
| 46 | + $this->initVar('tf_checkbox', XOBJ_DTYPE_INT); |
|
| 47 | + $this->initVar('tf_yesno', XOBJ_DTYPE_INT); |
|
| 48 | + $this->initVar('tf_selectbox', XOBJ_DTYPE_TXTBOX); |
|
| 49 | + $this->initVar('tf_user', XOBJ_DTYPE_INT); |
|
| 50 | + $this->initVar('tf_color', XOBJ_DTYPE_TXTBOX); |
|
| 51 | + $this->initVar('tf_imagelist', XOBJ_DTYPE_TXTBOX); |
|
| 52 | + $this->initVar('tf_urlfile', XOBJ_DTYPE_TXTBOX); |
|
| 53 | + $this->initVar('tf_uplimage', XOBJ_DTYPE_TXTBOX); |
|
| 54 | + $this->initVar('tf_uplfile', XOBJ_DTYPE_TXTBOX); |
|
| 55 | + $this->initVar('tf_textdateselect', XOBJ_DTYPE_TXTBOX); |
|
| 56 | + $this->initVar('tf_selectfile', XOBJ_DTYPE_TXTBOX); |
|
| 57 | + $this->initVar('tf_status', XOBJ_DTYPE_INT); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @static function &getInstance |
|
| 62 | - * |
|
| 63 | - * @param null |
|
| 64 | - */ |
|
| 65 | - public static function getInstance() |
|
| 66 | - { |
|
| 67 | - static $instance = false; |
|
| 68 | - if (!$instance) { |
|
| 69 | - $instance = new self(); |
|
| 70 | - } |
|
| 71 | - } |
|
| 60 | + /** |
|
| 61 | + * @static function &getInstance |
|
| 62 | + * |
|
| 63 | + * @param null |
|
| 64 | + */ |
|
| 65 | + public static function getInstance() |
|
| 66 | + { |
|
| 67 | + static $instance = false; |
|
| 68 | + if (!$instance) { |
|
| 69 | + $instance = new self(); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * The new inserted $Id |
|
| 75 | - * @return inserted id |
|
| 76 | - */ |
|
| 77 | - public function getNewInsertedIdTestfields() |
|
| 78 | - { |
|
| 79 | - $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 80 | - return $newInsertedId; |
|
| 81 | - } |
|
| 73 | + /** |
|
| 74 | + * The new inserted $Id |
|
| 75 | + * @return inserted id |
|
| 76 | + */ |
|
| 77 | + public function getNewInsertedIdTestfields() |
|
| 78 | + { |
|
| 79 | + $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 80 | + return $newInsertedId; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @public function getForm |
|
| 85 | - * @param bool $action |
|
| 86 | - * @return XoopsThemeForm |
|
| 87 | - */ |
|
| 88 | - public function getFormTestfields($action = false) |
|
| 89 | - { |
|
| 90 | - $helper = \XoopsModules\Mymodule2\Helper::getInstance(); |
|
| 91 | - if (false === $action) { |
|
| 92 | - $action = $_SERVER['REQUEST_URI']; |
|
| 93 | - } |
|
| 94 | - // Permissions for uploader |
|
| 95 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 96 | - $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
|
| 97 | - if ($GLOBALS['xoopsUser']) { |
|
| 98 | - if (!$GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) { |
|
| 99 | - $permissionUpload = $grouppermHandler->checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false; |
|
| 100 | - } else { |
|
| 101 | - $permissionUpload = true; |
|
| 102 | - } |
|
| 103 | - } else { |
|
| 104 | - $permissionUpload = $grouppermHandler->checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false; |
|
| 105 | - } |
|
| 106 | - // Title |
|
| 107 | - $title = $this->isNew() ? sprintf(_AM_MYMODULE2_TESTFIELD_ADD) : sprintf(_AM_MYMODULE2_TESTFIELD_EDIT); |
|
| 108 | - // Get Theme Form |
|
| 109 | - xoops_load('XoopsFormLoader'); |
|
| 110 | - $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
| 111 | - $form->setExtra('enctype="multipart/form-data"'); |
|
| 112 | - // Form Text TfText |
|
| 113 | - $form->addElement(new \XoopsFormText( _AM_MYMODULE2_TESTFIELD_TEXT, 'tf_text', 50, 255, $this->getVar('tf_text') )); |
|
| 114 | - // Form Text Area TfTextarea |
|
| 115 | - $form->addElement(new \XoopsFormTextArea( _AM_MYMODULE2_TESTFIELD_TEXTAREA, 'tf_textarea', $this->getVar('tf_textarea'), 4, 47 )); |
|
| 116 | - // Form editor TfDhtml |
|
| 117 | - $editorConfigs = []; |
|
| 118 | - $editorConfigs['name'] = 'tf_dhtml'; |
|
| 119 | - $editorConfigs['value'] = $this->getVar('tf_dhtml', 'e'); |
|
| 120 | - $editorConfigs['rows'] = 5; |
|
| 121 | - $editorConfigs['cols'] = 40; |
|
| 122 | - $editorConfigs['width'] = '100%'; |
|
| 123 | - $editorConfigs['height'] = '400px'; |
|
| 124 | - $editorConfigs['editor'] = $helper->getConfig('editor_dhtml'); |
|
| 125 | - $form->addElement(new \XoopsFormEditor( _AM_MYMODULE2_TESTFIELD_DHTML, 'tf_dhtml', $editorConfigs)); |
|
| 126 | - // Form Check Box TfCheckbox |
|
| 127 | - $tfCheckbox = $this->isNew() ? 0 : $this->getVar('tf_checkbox'); |
|
| 128 | - $checkTfCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_TESTFIELD_CHECKBOX, 'tf_checkbox', $tfCheckbox); |
|
| 129 | - $checkTfCheckbox->addOption(1, _AM_MYMODULE2_TESTFIELD_CHECKBOX); |
|
| 130 | - $form->addElement($checkTfCheckbox); |
|
| 131 | - // Form Radio Yes/No TfYesno |
|
| 132 | - $tfYesno = $this->isNew() ? 0 : $this->getVar('tf_yesno'); |
|
| 133 | - $form->addElement(new \XoopsFormRadioYN( _AM_MYMODULE2_TESTFIELD_YESNO, 'tf_yesno', $tfYesno)); |
|
| 134 | - // Testfields handler |
|
| 135 | - $testfieldsHandler = $helper->getHandler('testfields'); |
|
| 136 | - // Form Select Testfields |
|
| 137 | - $tfSelectboxSelect = new \XoopsFormSelect( _AM_MYMODULE2_TESTFIELD_SELECTBOX, 'tf_selectbox', $this->getVar('tf_selectbox')); |
|
| 138 | - $tfSelectboxSelect->addOption('Empty'); |
|
| 139 | - $tfSelectboxSelect->addOptionArray($testfieldsHandler->getList()); |
|
| 140 | - $form->addElement($tfSelectboxSelect); |
|
| 141 | - // Form Select User TfUser |
|
| 142 | - $form->addElement(new \XoopsFormSelectUser( _AM_MYMODULE2_TESTFIELD_USER, 'tf_user', false, $this->getVar('tf_user') )); |
|
| 143 | - // Form Color Picker TfColor |
|
| 144 | - $form->addElement(new \XoopsFormColorPicker( _AM_MYMODULE2_TESTFIELD_COLOR, 'tf_color', $this->getVar('tf_color') ), true); |
|
| 145 | - // Form Frameworks Image Files TfImagelist |
|
| 146 | - $getTfImagelist = $this->getVar('tf_imagelist'); |
|
| 147 | - $tfImagelist = $getTfImagelist ? $getTfImagelist : 'blank.gif'; |
|
| 148 | - $imageDirectory = '/Frameworks/moduleclasses/icons/32'; |
|
| 149 | - $imageTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_IMAGELIST, '<br>' ); |
|
| 150 | - $imageSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE2_TESTFIELD_IMAGELIST_UPLOADS, ".{$imageDirectory}/"), 'tf_imagelist', $tfImagelist, 5); |
|
| 151 | - $imageArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $imageDirectory ); |
|
| 152 | - foreach($imageArray as $image1) { |
|
| 153 | - $imageSelect->addOption("{$image1}", $image1); |
|
| 154 | - } |
|
| 155 | - $imageSelect->setExtra("onchange='showImgSelected(\"imglabel_tf_imagelist\", \"tf_imagelist\", \"".$imageDirectory."\", \"\", \"".XOOPS_URL."\")'"); |
|
| 156 | - $imageTray->addElement($imageSelect, false); |
|
| 157 | - $imageTray->addElement(new \XoopsFormLabel('', "<br><img src='".XOOPS_URL."/".$imageDirectory."/".$tfImagelist."' name='imglabel_tf_imagelist' id='imglabel_tf_imagelist' alt='' style='max-width:100px' />")); |
|
| 158 | - // Form File |
|
| 159 | - $fileSelectTray = new \XoopsFormElementTray('', '<br>' ); |
|
| 160 | - $fileSelectTray->addElement(new \XoopsFormFile( _AM_MYMODULE2_FORM_UPLOAD_NEW, 'tf_imagelist', $helper->getConfig('maxsize_image') )); |
|
| 161 | - $fileSelectTray->addElement(new \XoopsFormLabel('')); |
|
| 162 | - $imageTray->addElement($fileSelectTray); |
|
| 163 | - $form->addElement($imageTray); |
|
| 164 | - // Form Url Text File TfUrlfile |
|
| 165 | - $formUrlFile = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_URLFILE, '<br><br>' ); |
|
| 166 | - $formUrl = $this->isNew() ? '' : $this->getVar('tf_urlfile'); |
|
| 167 | - $formText = new \XoopsFormText( _AM_MYMODULE2_TESTFIELD_URLFILE_UPLOADS, 'tf_urlfile', 75, 255, $formUrl ); |
|
| 168 | - $formUrlFile->addElement($formText); |
|
| 169 | - $formUrlFile->addElement(new \XoopsFormFile( _AM_MYMODULE2_FORM_UPLOAD, 'tf_urlfile', $helper->getConfig('maxsize_file') )); |
|
| 170 | - $form->addElement($formUrlFile); |
|
| 171 | - // Form Image TfUplimage |
|
| 172 | - // Form Image TfUplimage: Select Uploaded Image |
|
| 173 | - $getTfUplimage = $this->getVar('tf_uplimage'); |
|
| 174 | - $tfUplimage = $getTfUplimage ? $getTfUplimage : 'blank.gif'; |
|
| 175 | - $imageDirectory = '/uploads/mymodule2/images/testfields'; |
|
| 176 | - $imageTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_UPLIMAGE, '<br>' ); |
|
| 177 | - $imageSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE2_TESTFIELD_UPLIMAGE_UPLOADS, ".{$imageDirectory}/"), 'tf_uplimage', $tfUplimage, 5); |
|
| 178 | - $imageArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $imageDirectory ); |
|
| 179 | - foreach($imageArray as $image1) { |
|
| 180 | - $imageSelect->addOption("{$image1}", $image1); |
|
| 181 | - } |
|
| 182 | - $imageSelect->setExtra("onchange='showImgSelected(\"imglabel_tf_uplimage\", \"tf_uplimage\", \"".$imageDirectory."\", \"\", \"".XOOPS_URL."\")'"); |
|
| 183 | - $imageTray->addElement($imageSelect, false); |
|
| 184 | - $imageTray->addElement(new \XoopsFormLabel('', "<br><img src='".XOOPS_URL."/".$imageDirectory."/".$tfUplimage."' name='imglabel_tf_uplimage' id='imglabel_tf_uplimage' alt='' style='max-width:100px' />")); |
|
| 185 | - // Form Image TfUplimage: Upload new image |
|
| 186 | - if ($permissionUpload) { |
|
| 187 | - $maxsize = $helper->getConfig('maxsize_image'); |
|
| 188 | - $imageTray->addElement(new \XoopsFormFile( '<br>' . _AM_MYMODULE2_FORM_UPLOAD_NEW, 'tf_uplimage', $maxsize )); |
|
| 189 | - $imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . _AM_MYMODULE2_FORM_UPLOAD_SIZE_MB)); |
|
| 190 | - $imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_IMG_WIDTH, $helper->getConfig('maxwidth_image') . ' px')); |
|
| 191 | - $imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_IMG_HEIGHT, $helper->getConfig('maxheight_image') . ' px')); |
|
| 192 | - } else { |
|
| 193 | - $imageTray->addElement(new \XoopsFormHidden( 'tf_uplimage', $tfUplimage )); |
|
| 194 | - } |
|
| 195 | - $form->addElement($imageTray, ); |
|
| 196 | - // Form File TfUplfile |
|
| 197 | - $tfUplfile = $this->isNew() ? '' : $this->getVar('tf_uplfile'); |
|
| 198 | - if ($permissionUpload) { |
|
| 199 | - $fileUploadTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_UPLFILE, '<br>' ); |
|
| 200 | - $fileDirectory = '/uploads/mymodule2/files/testfields'; |
|
| 201 | - if (!$this->isNew()) { |
|
| 202 | - $fileUploadTray->addElement(new \XoopsFormLabel(sprintf(_AM_MYMODULE2_TESTFIELD_UPLFILE_UPLOADS, ".{$fileDirectory}/"), $tfUplfile)); |
|
| 203 | - } |
|
| 204 | - $maxsize = $helper->getConfig('maxsize_file'); |
|
| 205 | - $fileUploadTray->addElement(new \XoopsFormFile( '', 'tf_uplfile', $maxsize )); |
|
| 206 | - $fileUploadTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . _AM_MYMODULE2_FORM_UPLOAD_SIZE_MB)); |
|
| 207 | - $form->addElement($fileUploadTray, ); |
|
| 208 | - } else { |
|
| 209 | - $form->addElement(new \XoopsFormHidden( 'tf_uplfile', $tfUplfile )); |
|
| 210 | - } |
|
| 211 | - // Form Text Date Select TfTextdateselect |
|
| 212 | - $tfTextdateselect = $this->isNew() ? 0 : $this->getVar('tf_textdateselect'); |
|
| 213 | - $form->addElement(new \XoopsFormTextDateSelect( _AM_MYMODULE2_TESTFIELD_TEXTDATESELECT, 'tf_textdateselect', '', $tfTextdateselect )); |
|
| 214 | - // Form File TfSelectfile |
|
| 215 | - // Form File TfSelectfile: Select Uploaded File |
|
| 216 | - $getTfSelectfile = $this->getVar('tf_selectfile'); |
|
| 217 | - $tfSelectfile = $getTfSelectfile ? $getTfSelectfile : 'blank.gif'; |
|
| 218 | - $fileDirectory = '/uploads/mymodule2/files/testfields'; |
|
| 219 | - $fileTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_SELECTFILE, '<br>' ); |
|
| 220 | - $fileSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE2_TESTFIELD_SELECTFILE_UPLOADS, ".{$fileDirectory}/"), 'tf_selectfile', $tfSelectfile, 5); |
|
| 221 | - $fileArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $fileDirectory ); |
|
| 222 | - foreach($fileArray as $file1) { |
|
| 223 | - $fileSelect->addOption("{$file1}", $file1); |
|
| 224 | - } |
|
| 225 | - $fileTray->addElement($fileSelect, false); |
|
| 226 | - // Form File TfSelectfile: Upload new file |
|
| 227 | - if ($permissionUpload) { |
|
| 228 | - $maxsize = $helper->getConfig('maxsize_file'); |
|
| 229 | - $fileTray->addElement(new \XoopsFormFile( '<br>' . _AM_MYMODULE2_FORM_UPLOAD_NEW, 'tf_selectfile', $maxsize )); |
|
| 230 | - $fileTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . _AM_MYMODULE2_FORM_UPLOAD_SIZE_MB)); |
|
| 231 | - } else { |
|
| 232 | - $fileTray->addElement(new \XoopsFormHidden( 'tf_selectfile', $tfSelectfile )); |
|
| 233 | - } |
|
| 234 | - $form->addElement($fileTray, ); |
|
| 235 | - // Form Select Testfields |
|
| 236 | - $tfStatusSelect = new \XoopsFormSelect( _AM_MYMODULE2_TESTFIELD_STATUS, 'tf_status', $this->getVar('tf_status')); |
|
| 237 | - $tfStatusSelect->addOption(Constants::STATUS_NONE, _AM_MYMODULE2_STATUS_NONE); |
|
| 238 | - $tfStatusSelect->addOption(Constants::STATUS_OFFLINE, _AM_MYMODULE2_STATUS_OFFLINE); |
|
| 239 | - $tfStatusSelect->addOption(Constants::STATUS_SUBMITTED, _AM_MYMODULE2_STATUS_SUBMITTED); |
|
| 240 | - $tfStatusSelect->addOption(Constants::STATUS_APPROVED, _AM_MYMODULE2_STATUS_APPROVED); |
|
| 241 | - $form->addElement($tfStatusSelect); |
|
| 242 | - // Permissions |
|
| 243 | - $memberHandler = xoops_getHandler('member'); |
|
| 244 | - $groupList = $memberHandler->getGroupList(); |
|
| 245 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 246 | - $fullList[] = array_keys($groupList); |
|
| 247 | - if (!$this->isNew()) { |
|
| 248 | - $groupsIdsApprove = $grouppermHandler->getGroupIds('mymodule2_approve_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 249 | - $groupsIdsApprove[] = array_values($groupsIdsApprove); |
|
| 250 | - $groupsCanApproveCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_APPROVE, 'groups_approve_testfields[]', $groupsIdsApprove); |
|
| 251 | - $groupsIdsSubmit = $grouppermHandler->getGroupIds('mymodule2_submit_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 252 | - $groupsIdsSubmit[] = array_values($groupsIdsSubmit); |
|
| 253 | - $groupsCanSubmitCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_SUBMIT, 'groups_submit_testfields[]', $groupsIdsSubmit); |
|
| 254 | - $groupsIdsView = $grouppermHandler->getGroupIds('mymodule2_view_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 255 | - $groupsIdsView[] = array_values($groupsIdsView); |
|
| 256 | - $groupsCanViewCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_VIEW, 'groups_view_testfields[]', $groupsIdsView); |
|
| 257 | - } else { |
|
| 258 | - $groupsCanApproveCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_APPROVE, 'groups_approve_testfields[]', $fullList); |
|
| 259 | - $groupsCanSubmitCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_SUBMIT, 'groups_submit_testfields[]', $fullList); |
|
| 260 | - $groupsCanViewCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_VIEW, 'groups_view_testfields[]', $fullList); |
|
| 261 | - } |
|
| 262 | - // To Approve |
|
| 263 | - $groupsCanApproveCheckbox->addOptionArray($groupList); |
|
| 264 | - $form->addElement($groupsCanApproveCheckbox); |
|
| 265 | - // To Submit |
|
| 266 | - $groupsCanSubmitCheckbox->addOptionArray($groupList); |
|
| 267 | - $form->addElement($groupsCanSubmitCheckbox); |
|
| 268 | - // To View |
|
| 269 | - $groupsCanViewCheckbox->addOptionArray($groupList); |
|
| 270 | - $form->addElement($groupsCanViewCheckbox); |
|
| 271 | - // To Save |
|
| 272 | - $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
| 273 | - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
| 274 | - return $form; |
|
| 275 | - } |
|
| 83 | + /** |
|
| 84 | + * @public function getForm |
|
| 85 | + * @param bool $action |
|
| 86 | + * @return XoopsThemeForm |
|
| 87 | + */ |
|
| 88 | + public function getFormTestfields($action = false) |
|
| 89 | + { |
|
| 90 | + $helper = \XoopsModules\Mymodule2\Helper::getInstance(); |
|
| 91 | + if (false === $action) { |
|
| 92 | + $action = $_SERVER['REQUEST_URI']; |
|
| 93 | + } |
|
| 94 | + // Permissions for uploader |
|
| 95 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 96 | + $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
|
| 97 | + if ($GLOBALS['xoopsUser']) { |
|
| 98 | + if (!$GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) { |
|
| 99 | + $permissionUpload = $grouppermHandler->checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false; |
|
| 100 | + } else { |
|
| 101 | + $permissionUpload = true; |
|
| 102 | + } |
|
| 103 | + } else { |
|
| 104 | + $permissionUpload = $grouppermHandler->checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false; |
|
| 105 | + } |
|
| 106 | + // Title |
|
| 107 | + $title = $this->isNew() ? sprintf(_AM_MYMODULE2_TESTFIELD_ADD) : sprintf(_AM_MYMODULE2_TESTFIELD_EDIT); |
|
| 108 | + // Get Theme Form |
|
| 109 | + xoops_load('XoopsFormLoader'); |
|
| 110 | + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
| 111 | + $form->setExtra('enctype="multipart/form-data"'); |
|
| 112 | + // Form Text TfText |
|
| 113 | + $form->addElement(new \XoopsFormText( _AM_MYMODULE2_TESTFIELD_TEXT, 'tf_text', 50, 255, $this->getVar('tf_text') )); |
|
| 114 | + // Form Text Area TfTextarea |
|
| 115 | + $form->addElement(new \XoopsFormTextArea( _AM_MYMODULE2_TESTFIELD_TEXTAREA, 'tf_textarea', $this->getVar('tf_textarea'), 4, 47 )); |
|
| 116 | + // Form editor TfDhtml |
|
| 117 | + $editorConfigs = []; |
|
| 118 | + $editorConfigs['name'] = 'tf_dhtml'; |
|
| 119 | + $editorConfigs['value'] = $this->getVar('tf_dhtml', 'e'); |
|
| 120 | + $editorConfigs['rows'] = 5; |
|
| 121 | + $editorConfigs['cols'] = 40; |
|
| 122 | + $editorConfigs['width'] = '100%'; |
|
| 123 | + $editorConfigs['height'] = '400px'; |
|
| 124 | + $editorConfigs['editor'] = $helper->getConfig('editor_dhtml'); |
|
| 125 | + $form->addElement(new \XoopsFormEditor( _AM_MYMODULE2_TESTFIELD_DHTML, 'tf_dhtml', $editorConfigs)); |
|
| 126 | + // Form Check Box TfCheckbox |
|
| 127 | + $tfCheckbox = $this->isNew() ? 0 : $this->getVar('tf_checkbox'); |
|
| 128 | + $checkTfCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_TESTFIELD_CHECKBOX, 'tf_checkbox', $tfCheckbox); |
|
| 129 | + $checkTfCheckbox->addOption(1, _AM_MYMODULE2_TESTFIELD_CHECKBOX); |
|
| 130 | + $form->addElement($checkTfCheckbox); |
|
| 131 | + // Form Radio Yes/No TfYesno |
|
| 132 | + $tfYesno = $this->isNew() ? 0 : $this->getVar('tf_yesno'); |
|
| 133 | + $form->addElement(new \XoopsFormRadioYN( _AM_MYMODULE2_TESTFIELD_YESNO, 'tf_yesno', $tfYesno)); |
|
| 134 | + // Testfields handler |
|
| 135 | + $testfieldsHandler = $helper->getHandler('testfields'); |
|
| 136 | + // Form Select Testfields |
|
| 137 | + $tfSelectboxSelect = new \XoopsFormSelect( _AM_MYMODULE2_TESTFIELD_SELECTBOX, 'tf_selectbox', $this->getVar('tf_selectbox')); |
|
| 138 | + $tfSelectboxSelect->addOption('Empty'); |
|
| 139 | + $tfSelectboxSelect->addOptionArray($testfieldsHandler->getList()); |
|
| 140 | + $form->addElement($tfSelectboxSelect); |
|
| 141 | + // Form Select User TfUser |
|
| 142 | + $form->addElement(new \XoopsFormSelectUser( _AM_MYMODULE2_TESTFIELD_USER, 'tf_user', false, $this->getVar('tf_user') )); |
|
| 143 | + // Form Color Picker TfColor |
|
| 144 | + $form->addElement(new \XoopsFormColorPicker( _AM_MYMODULE2_TESTFIELD_COLOR, 'tf_color', $this->getVar('tf_color') ), true); |
|
| 145 | + // Form Frameworks Image Files TfImagelist |
|
| 146 | + $getTfImagelist = $this->getVar('tf_imagelist'); |
|
| 147 | + $tfImagelist = $getTfImagelist ? $getTfImagelist : 'blank.gif'; |
|
| 148 | + $imageDirectory = '/Frameworks/moduleclasses/icons/32'; |
|
| 149 | + $imageTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_IMAGELIST, '<br>' ); |
|
| 150 | + $imageSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE2_TESTFIELD_IMAGELIST_UPLOADS, ".{$imageDirectory}/"), 'tf_imagelist', $tfImagelist, 5); |
|
| 151 | + $imageArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $imageDirectory ); |
|
| 152 | + foreach($imageArray as $image1) { |
|
| 153 | + $imageSelect->addOption("{$image1}", $image1); |
|
| 154 | + } |
|
| 155 | + $imageSelect->setExtra("onchange='showImgSelected(\"imglabel_tf_imagelist\", \"tf_imagelist\", \"".$imageDirectory."\", \"\", \"".XOOPS_URL."\")'"); |
|
| 156 | + $imageTray->addElement($imageSelect, false); |
|
| 157 | + $imageTray->addElement(new \XoopsFormLabel('', "<br><img src='".XOOPS_URL."/".$imageDirectory."/".$tfImagelist."' name='imglabel_tf_imagelist' id='imglabel_tf_imagelist' alt='' style='max-width:100px' />")); |
|
| 158 | + // Form File |
|
| 159 | + $fileSelectTray = new \XoopsFormElementTray('', '<br>' ); |
|
| 160 | + $fileSelectTray->addElement(new \XoopsFormFile( _AM_MYMODULE2_FORM_UPLOAD_NEW, 'tf_imagelist', $helper->getConfig('maxsize_image') )); |
|
| 161 | + $fileSelectTray->addElement(new \XoopsFormLabel('')); |
|
| 162 | + $imageTray->addElement($fileSelectTray); |
|
| 163 | + $form->addElement($imageTray); |
|
| 164 | + // Form Url Text File TfUrlfile |
|
| 165 | + $formUrlFile = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_URLFILE, '<br><br>' ); |
|
| 166 | + $formUrl = $this->isNew() ? '' : $this->getVar('tf_urlfile'); |
|
| 167 | + $formText = new \XoopsFormText( _AM_MYMODULE2_TESTFIELD_URLFILE_UPLOADS, 'tf_urlfile', 75, 255, $formUrl ); |
|
| 168 | + $formUrlFile->addElement($formText); |
|
| 169 | + $formUrlFile->addElement(new \XoopsFormFile( _AM_MYMODULE2_FORM_UPLOAD, 'tf_urlfile', $helper->getConfig('maxsize_file') )); |
|
| 170 | + $form->addElement($formUrlFile); |
|
| 171 | + // Form Image TfUplimage |
|
| 172 | + // Form Image TfUplimage: Select Uploaded Image |
|
| 173 | + $getTfUplimage = $this->getVar('tf_uplimage'); |
|
| 174 | + $tfUplimage = $getTfUplimage ? $getTfUplimage : 'blank.gif'; |
|
| 175 | + $imageDirectory = '/uploads/mymodule2/images/testfields'; |
|
| 176 | + $imageTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_UPLIMAGE, '<br>' ); |
|
| 177 | + $imageSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE2_TESTFIELD_UPLIMAGE_UPLOADS, ".{$imageDirectory}/"), 'tf_uplimage', $tfUplimage, 5); |
|
| 178 | + $imageArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $imageDirectory ); |
|
| 179 | + foreach($imageArray as $image1) { |
|
| 180 | + $imageSelect->addOption("{$image1}", $image1); |
|
| 181 | + } |
|
| 182 | + $imageSelect->setExtra("onchange='showImgSelected(\"imglabel_tf_uplimage\", \"tf_uplimage\", \"".$imageDirectory."\", \"\", \"".XOOPS_URL."\")'"); |
|
| 183 | + $imageTray->addElement($imageSelect, false); |
|
| 184 | + $imageTray->addElement(new \XoopsFormLabel('', "<br><img src='".XOOPS_URL."/".$imageDirectory."/".$tfUplimage."' name='imglabel_tf_uplimage' id='imglabel_tf_uplimage' alt='' style='max-width:100px' />")); |
|
| 185 | + // Form Image TfUplimage: Upload new image |
|
| 186 | + if ($permissionUpload) { |
|
| 187 | + $maxsize = $helper->getConfig('maxsize_image'); |
|
| 188 | + $imageTray->addElement(new \XoopsFormFile( '<br>' . _AM_MYMODULE2_FORM_UPLOAD_NEW, 'tf_uplimage', $maxsize )); |
|
| 189 | + $imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . _AM_MYMODULE2_FORM_UPLOAD_SIZE_MB)); |
|
| 190 | + $imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_IMG_WIDTH, $helper->getConfig('maxwidth_image') . ' px')); |
|
| 191 | + $imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_IMG_HEIGHT, $helper->getConfig('maxheight_image') . ' px')); |
|
| 192 | + } else { |
|
| 193 | + $imageTray->addElement(new \XoopsFormHidden( 'tf_uplimage', $tfUplimage )); |
|
| 194 | + } |
|
| 195 | + $form->addElement($imageTray, ); |
|
| 196 | + // Form File TfUplfile |
|
| 197 | + $tfUplfile = $this->isNew() ? '' : $this->getVar('tf_uplfile'); |
|
| 198 | + if ($permissionUpload) { |
|
| 199 | + $fileUploadTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_UPLFILE, '<br>' ); |
|
| 200 | + $fileDirectory = '/uploads/mymodule2/files/testfields'; |
|
| 201 | + if (!$this->isNew()) { |
|
| 202 | + $fileUploadTray->addElement(new \XoopsFormLabel(sprintf(_AM_MYMODULE2_TESTFIELD_UPLFILE_UPLOADS, ".{$fileDirectory}/"), $tfUplfile)); |
|
| 203 | + } |
|
| 204 | + $maxsize = $helper->getConfig('maxsize_file'); |
|
| 205 | + $fileUploadTray->addElement(new \XoopsFormFile( '', 'tf_uplfile', $maxsize )); |
|
| 206 | + $fileUploadTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . _AM_MYMODULE2_FORM_UPLOAD_SIZE_MB)); |
|
| 207 | + $form->addElement($fileUploadTray, ); |
|
| 208 | + } else { |
|
| 209 | + $form->addElement(new \XoopsFormHidden( 'tf_uplfile', $tfUplfile )); |
|
| 210 | + } |
|
| 211 | + // Form Text Date Select TfTextdateselect |
|
| 212 | + $tfTextdateselect = $this->isNew() ? 0 : $this->getVar('tf_textdateselect'); |
|
| 213 | + $form->addElement(new \XoopsFormTextDateSelect( _AM_MYMODULE2_TESTFIELD_TEXTDATESELECT, 'tf_textdateselect', '', $tfTextdateselect )); |
|
| 214 | + // Form File TfSelectfile |
|
| 215 | + // Form File TfSelectfile: Select Uploaded File |
|
| 216 | + $getTfSelectfile = $this->getVar('tf_selectfile'); |
|
| 217 | + $tfSelectfile = $getTfSelectfile ? $getTfSelectfile : 'blank.gif'; |
|
| 218 | + $fileDirectory = '/uploads/mymodule2/files/testfields'; |
|
| 219 | + $fileTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_SELECTFILE, '<br>' ); |
|
| 220 | + $fileSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE2_TESTFIELD_SELECTFILE_UPLOADS, ".{$fileDirectory}/"), 'tf_selectfile', $tfSelectfile, 5); |
|
| 221 | + $fileArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $fileDirectory ); |
|
| 222 | + foreach($fileArray as $file1) { |
|
| 223 | + $fileSelect->addOption("{$file1}", $file1); |
|
| 224 | + } |
|
| 225 | + $fileTray->addElement($fileSelect, false); |
|
| 226 | + // Form File TfSelectfile: Upload new file |
|
| 227 | + if ($permissionUpload) { |
|
| 228 | + $maxsize = $helper->getConfig('maxsize_file'); |
|
| 229 | + $fileTray->addElement(new \XoopsFormFile( '<br>' . _AM_MYMODULE2_FORM_UPLOAD_NEW, 'tf_selectfile', $maxsize )); |
|
| 230 | + $fileTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . _AM_MYMODULE2_FORM_UPLOAD_SIZE_MB)); |
|
| 231 | + } else { |
|
| 232 | + $fileTray->addElement(new \XoopsFormHidden( 'tf_selectfile', $tfSelectfile )); |
|
| 233 | + } |
|
| 234 | + $form->addElement($fileTray, ); |
|
| 235 | + // Form Select Testfields |
|
| 236 | + $tfStatusSelect = new \XoopsFormSelect( _AM_MYMODULE2_TESTFIELD_STATUS, 'tf_status', $this->getVar('tf_status')); |
|
| 237 | + $tfStatusSelect->addOption(Constants::STATUS_NONE, _AM_MYMODULE2_STATUS_NONE); |
|
| 238 | + $tfStatusSelect->addOption(Constants::STATUS_OFFLINE, _AM_MYMODULE2_STATUS_OFFLINE); |
|
| 239 | + $tfStatusSelect->addOption(Constants::STATUS_SUBMITTED, _AM_MYMODULE2_STATUS_SUBMITTED); |
|
| 240 | + $tfStatusSelect->addOption(Constants::STATUS_APPROVED, _AM_MYMODULE2_STATUS_APPROVED); |
|
| 241 | + $form->addElement($tfStatusSelect); |
|
| 242 | + // Permissions |
|
| 243 | + $memberHandler = xoops_getHandler('member'); |
|
| 244 | + $groupList = $memberHandler->getGroupList(); |
|
| 245 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 246 | + $fullList[] = array_keys($groupList); |
|
| 247 | + if (!$this->isNew()) { |
|
| 248 | + $groupsIdsApprove = $grouppermHandler->getGroupIds('mymodule2_approve_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 249 | + $groupsIdsApprove[] = array_values($groupsIdsApprove); |
|
| 250 | + $groupsCanApproveCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_APPROVE, 'groups_approve_testfields[]', $groupsIdsApprove); |
|
| 251 | + $groupsIdsSubmit = $grouppermHandler->getGroupIds('mymodule2_submit_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 252 | + $groupsIdsSubmit[] = array_values($groupsIdsSubmit); |
|
| 253 | + $groupsCanSubmitCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_SUBMIT, 'groups_submit_testfields[]', $groupsIdsSubmit); |
|
| 254 | + $groupsIdsView = $grouppermHandler->getGroupIds('mymodule2_view_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 255 | + $groupsIdsView[] = array_values($groupsIdsView); |
|
| 256 | + $groupsCanViewCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_VIEW, 'groups_view_testfields[]', $groupsIdsView); |
|
| 257 | + } else { |
|
| 258 | + $groupsCanApproveCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_APPROVE, 'groups_approve_testfields[]', $fullList); |
|
| 259 | + $groupsCanSubmitCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_SUBMIT, 'groups_submit_testfields[]', $fullList); |
|
| 260 | + $groupsCanViewCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_VIEW, 'groups_view_testfields[]', $fullList); |
|
| 261 | + } |
|
| 262 | + // To Approve |
|
| 263 | + $groupsCanApproveCheckbox->addOptionArray($groupList); |
|
| 264 | + $form->addElement($groupsCanApproveCheckbox); |
|
| 265 | + // To Submit |
|
| 266 | + $groupsCanSubmitCheckbox->addOptionArray($groupList); |
|
| 267 | + $form->addElement($groupsCanSubmitCheckbox); |
|
| 268 | + // To View |
|
| 269 | + $groupsCanViewCheckbox->addOptionArray($groupList); |
|
| 270 | + $form->addElement($groupsCanViewCheckbox); |
|
| 271 | + // To Save |
|
| 272 | + $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
| 273 | + $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
| 274 | + return $form; |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - /** |
|
| 278 | - * Get Values |
|
| 279 | - * @param null $keys |
|
| 280 | - * @param null $format |
|
| 281 | - * @param null$maxDepth |
|
| 282 | - * @return array |
|
| 283 | - */ |
|
| 284 | - public function getValuesTestfields($keys = null, $format = null, $maxDepth = null) |
|
| 285 | - { |
|
| 286 | - $helper = \XoopsModules\Mymodule2\Helper::getInstance(); |
|
| 287 | - $ret = $this->getValues($keys, $format, $maxDepth); |
|
| 288 | - $ret['id'] = $this->getVar('tf_id'); |
|
| 289 | - $ret['text'] = $this->getVar('tf_text'); |
|
| 290 | - $ret['textarea'] = strip_tags($this->getVar('tf_textarea')); |
|
| 291 | - $ret['dhtml'] = strip_tags($this->getVar('tf_dhtml')); |
|
| 292 | - $ret['checkbox'] = $this->getVar('tf_checkbox'); |
|
| 293 | - $ret['yesno'] = $this->getVar('tf_yesno'); |
|
| 294 | - $ret['yesno_text'] = (int)$this->getVar('tf_yesno') > 0 ? _YES : _NO; |
|
| 295 | - $ret['selectbox'] = $this->getVar('tf_selectbox'); |
|
| 296 | - $ret['user'] = \XoopsUser::getUnameFromId($this->getVar('tf_user')); |
|
| 297 | - $ret['color'] = $this->getVar('tf_color'); |
|
| 298 | - $ret['imagelist'] = $this->getVar('tf_imagelist'); |
|
| 299 | - $ret['urlfile'] = $this->getVar('tf_urlfile'); |
|
| 300 | - $ret['uplimage'] = $this->getVar('tf_uplimage'); |
|
| 301 | - $ret['uplfile'] = $this->getVar('tf_uplfile'); |
|
| 302 | - $ret['textdateselect'] = formatTimeStamp($this->getVar('tf_textdateselect'), 's'); |
|
| 303 | - $ret['selectfile'] = $this->getVar('tf_selectfile'); |
|
| 304 | - $ret['status'] = $this->getVar('tf_status'); |
|
| 305 | - return $ret; |
|
| 306 | - } |
|
| 277 | + /** |
|
| 278 | + * Get Values |
|
| 279 | + * @param null $keys |
|
| 280 | + * @param null $format |
|
| 281 | + * @param null$maxDepth |
|
| 282 | + * @return array |
|
| 283 | + */ |
|
| 284 | + public function getValuesTestfields($keys = null, $format = null, $maxDepth = null) |
|
| 285 | + { |
|
| 286 | + $helper = \XoopsModules\Mymodule2\Helper::getInstance(); |
|
| 287 | + $ret = $this->getValues($keys, $format, $maxDepth); |
|
| 288 | + $ret['id'] = $this->getVar('tf_id'); |
|
| 289 | + $ret['text'] = $this->getVar('tf_text'); |
|
| 290 | + $ret['textarea'] = strip_tags($this->getVar('tf_textarea')); |
|
| 291 | + $ret['dhtml'] = strip_tags($this->getVar('tf_dhtml')); |
|
| 292 | + $ret['checkbox'] = $this->getVar('tf_checkbox'); |
|
| 293 | + $ret['yesno'] = $this->getVar('tf_yesno'); |
|
| 294 | + $ret['yesno_text'] = (int)$this->getVar('tf_yesno') > 0 ? _YES : _NO; |
|
| 295 | + $ret['selectbox'] = $this->getVar('tf_selectbox'); |
|
| 296 | + $ret['user'] = \XoopsUser::getUnameFromId($this->getVar('tf_user')); |
|
| 297 | + $ret['color'] = $this->getVar('tf_color'); |
|
| 298 | + $ret['imagelist'] = $this->getVar('tf_imagelist'); |
|
| 299 | + $ret['urlfile'] = $this->getVar('tf_urlfile'); |
|
| 300 | + $ret['uplimage'] = $this->getVar('tf_uplimage'); |
|
| 301 | + $ret['uplfile'] = $this->getVar('tf_uplfile'); |
|
| 302 | + $ret['textdateselect'] = formatTimeStamp($this->getVar('tf_textdateselect'), 's'); |
|
| 303 | + $ret['selectfile'] = $this->getVar('tf_selectfile'); |
|
| 304 | + $ret['status'] = $this->getVar('tf_status'); |
|
| 305 | + return $ret; |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * Returns an array representation of the object |
|
| 310 | - * |
|
| 311 | - * @return array |
|
| 312 | - */ |
|
| 313 | - public function toArrayTestfields() |
|
| 314 | - { |
|
| 315 | - $ret = []; |
|
| 316 | - $vars = $this->getVars(); |
|
| 317 | - foreach(array_keys($vars) as $var) { |
|
| 318 | - $ret[$var] = $this->getVar('"{$var}"'); |
|
| 319 | - } |
|
| 320 | - return $ret; |
|
| 321 | - } |
|
| 308 | + /** |
|
| 309 | + * Returns an array representation of the object |
|
| 310 | + * |
|
| 311 | + * @return array |
|
| 312 | + */ |
|
| 313 | + public function toArrayTestfields() |
|
| 314 | + { |
|
| 315 | + $ret = []; |
|
| 316 | + $vars = $this->getVars(); |
|
| 317 | + foreach(array_keys($vars) as $var) { |
|
| 318 | + $ret[$var] = $this->getVar('"{$var}"'); |
|
| 319 | + } |
|
| 320 | + return $ret; |
|
| 321 | + } |
|
| 322 | 322 | } |
@@ -31,94 +31,94 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class TestfieldsHandler extends \XoopsPersistableObjectHandler |
| 33 | 33 | { |
| 34 | - /** |
|
| 35 | - * Constructor |
|
| 36 | - * |
|
| 37 | - * @param null|XoopsDatabase $db |
|
| 38 | - */ |
|
| 39 | - public function __construct(\XoopsDatabase $db) |
|
| 40 | - { |
|
| 41 | - parent::__construct($db, 'mymodule2_testfields', Testfields::class, 'tf_id', 'tf_text'); |
|
| 42 | - } |
|
| 34 | + /** |
|
| 35 | + * Constructor |
|
| 36 | + * |
|
| 37 | + * @param null|XoopsDatabase $db |
|
| 38 | + */ |
|
| 39 | + public function __construct(\XoopsDatabase $db) |
|
| 40 | + { |
|
| 41 | + parent::__construct($db, 'mymodule2_testfields', Testfields::class, 'tf_id', 'tf_text'); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param bool $isNew |
|
| 46 | - * |
|
| 47 | - * @return object |
|
| 48 | - */ |
|
| 49 | - public function create($isNew = true) |
|
| 50 | - { |
|
| 51 | - return parent::create($isNew); |
|
| 52 | - } |
|
| 44 | + /** |
|
| 45 | + * @param bool $isNew |
|
| 46 | + * |
|
| 47 | + * @return object |
|
| 48 | + */ |
|
| 49 | + public function create($isNew = true) |
|
| 50 | + { |
|
| 51 | + return parent::create($isNew); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * retrieve a field |
|
| 56 | - * |
|
| 57 | - * @param int $i field id |
|
| 58 | - * @param null fields |
|
| 59 | - * @return mixed reference to the {@link Get} object |
|
| 60 | - */ |
|
| 61 | - public function get($i = null, $fields = null) |
|
| 62 | - { |
|
| 63 | - return parent::get($i, $fields); |
|
| 64 | - } |
|
| 54 | + /** |
|
| 55 | + * retrieve a field |
|
| 56 | + * |
|
| 57 | + * @param int $i field id |
|
| 58 | + * @param null fields |
|
| 59 | + * @return mixed reference to the {@link Get} object |
|
| 60 | + */ |
|
| 61 | + public function get($i = null, $fields = null) |
|
| 62 | + { |
|
| 63 | + return parent::get($i, $fields); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * get inserted id |
|
| 68 | - * |
|
| 69 | - * @param null |
|
| 70 | - * @return integer reference to the {@link Get} object |
|
| 71 | - */ |
|
| 72 | - public function getInsertId() |
|
| 73 | - { |
|
| 74 | - return $this->db->getInsertId(); |
|
| 75 | - } |
|
| 66 | + /** |
|
| 67 | + * get inserted id |
|
| 68 | + * |
|
| 69 | + * @param null |
|
| 70 | + * @return integer reference to the {@link Get} object |
|
| 71 | + */ |
|
| 72 | + public function getInsertId() |
|
| 73 | + { |
|
| 74 | + return $this->db->getInsertId(); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Get Count Testfields in the database |
|
| 79 | - * @param int $start |
|
| 80 | - * @param int $limit |
|
| 81 | - * @param string $sort |
|
| 82 | - * @param string $order |
|
| 83 | - * @return int |
|
| 84 | - */ |
|
| 85 | - public function getCountTestfields($start = 0, $limit = 0, $sort = 'tf_id ASC, tf_text', $order = 'ASC') |
|
| 86 | - { |
|
| 87 | - $crCountTestfields = new \CriteriaCompo(); |
|
| 88 | - $crCountTestfields = $this->getTestfieldsCriteria($crCountTestfields, $start, $limit, $sort, $order); |
|
| 89 | - return parent::getCount($crCountTestfields); |
|
| 90 | - } |
|
| 77 | + /** |
|
| 78 | + * Get Count Testfields in the database |
|
| 79 | + * @param int $start |
|
| 80 | + * @param int $limit |
|
| 81 | + * @param string $sort |
|
| 82 | + * @param string $order |
|
| 83 | + * @return int |
|
| 84 | + */ |
|
| 85 | + public function getCountTestfields($start = 0, $limit = 0, $sort = 'tf_id ASC, tf_text', $order = 'ASC') |
|
| 86 | + { |
|
| 87 | + $crCountTestfields = new \CriteriaCompo(); |
|
| 88 | + $crCountTestfields = $this->getTestfieldsCriteria($crCountTestfields, $start, $limit, $sort, $order); |
|
| 89 | + return parent::getCount($crCountTestfields); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Get All Testfields in the database |
|
| 94 | - * @param int $start |
|
| 95 | - * @param int $limit |
|
| 96 | - * @param string $sort |
|
| 97 | - * @param string $order |
|
| 98 | - * @return array |
|
| 99 | - */ |
|
| 100 | - public function getAllTestfields($start = 0, $limit = 0, $sort = 'tf_id ASC, tf_text', $order = 'ASC') |
|
| 101 | - { |
|
| 102 | - $crAllTestfields = new \CriteriaCompo(); |
|
| 103 | - $crAllTestfields = $this->getTestfieldsCriteria($crAllTestfields, $start, $limit, $sort, $order); |
|
| 104 | - return parent::getAll($crAllTestfields); |
|
| 105 | - } |
|
| 92 | + /** |
|
| 93 | + * Get All Testfields in the database |
|
| 94 | + * @param int $start |
|
| 95 | + * @param int $limit |
|
| 96 | + * @param string $sort |
|
| 97 | + * @param string $order |
|
| 98 | + * @return array |
|
| 99 | + */ |
|
| 100 | + public function getAllTestfields($start = 0, $limit = 0, $sort = 'tf_id ASC, tf_text', $order = 'ASC') |
|
| 101 | + { |
|
| 102 | + $crAllTestfields = new \CriteriaCompo(); |
|
| 103 | + $crAllTestfields = $this->getTestfieldsCriteria($crAllTestfields, $start, $limit, $sort, $order); |
|
| 104 | + return parent::getAll($crAllTestfields); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Get Criteria Testfields |
|
| 109 | - * @param $crTestfields |
|
| 110 | - * @param int $start |
|
| 111 | - * @param int $limit |
|
| 112 | - * @param string $sort |
|
| 113 | - * @param string $order |
|
| 114 | - * @return int |
|
| 115 | - */ |
|
| 116 | - private function getTestfieldsCriteria($crTestfields, $start, $limit, $sort, $order) |
|
| 117 | - { |
|
| 118 | - $crTestfields->setStart( $start ); |
|
| 119 | - $crTestfields->setLimit( $limit ); |
|
| 120 | - $crTestfields->setSort( $sort ); |
|
| 121 | - $crTestfields->setOrder( $order ); |
|
| 122 | - return $crTestfields; |
|
| 123 | - } |
|
| 107 | + /** |
|
| 108 | + * Get Criteria Testfields |
|
| 109 | + * @param $crTestfields |
|
| 110 | + * @param int $start |
|
| 111 | + * @param int $limit |
|
| 112 | + * @param string $sort |
|
| 113 | + * @param string $order |
|
| 114 | + * @return int |
|
| 115 | + */ |
|
| 116 | + private function getTestfieldsCriteria($crTestfields, $start, $limit, $sort, $order) |
|
| 117 | + { |
|
| 118 | + $crTestfields->setStart( $start ); |
|
| 119 | + $crTestfields->setLimit( $limit ); |
|
| 120 | + $crTestfields->setSort( $sort ); |
|
| 121 | + $crTestfields->setOrder( $order ); |
|
| 122 | + return $crTestfields; |
|
| 123 | + } |
|
| 124 | 124 | } |
@@ -189,14 +189,14 @@ |
||
| 189 | 189 | $donationform = [ |
| 190 | 190 | 0 => '<form name="donation" id="donation" action="http://www.txmodxoops.org/modules/xdonations/" method="post" onsubmit="return xoopsFormValidate_donation();">', |
| 191 | 191 | 1 => '<table class="outer" cellspacing="1" width="100%"><tbody><tr><th colspan="2">' |
| 192 | - . _AM_MYMODULE2_ABOUT_MAKE_DONATION |
|
| 193 | - . '</th></tr><tr align="left" valign="top"><td class="head"><div class="xoops-form-element-caption-required"><span class="caption-text">' |
|
| 194 | - . _AM_MYMODULE2_DONATION_AMOUNT |
|
| 195 | - . '</span><span class="caption-marker">*</span></div></td><td class="even"><select size="1" name="item[A][amount]" id="item[A][amount]" title="Donation Amount"><option value="5">5.00 EUR</option><option value="10">10.00 EUR</option><option value="20">20.00 EUR</option><option value="40">40.00 EUR</option><option value="60">60.00 EUR</option><option value="80">80.00 EUR</option><option value="90">90.00 EUR</option><option value="100">100.00 EUR</option><option value="200">200.00 EUR</option></select></td></tr><tr align="left" valign="top"><td class="head"></td><td class="even"><input class="formButton" name="submit" id="submit" value="' |
|
| 196 | - . _SUBMIT |
|
| 197 | - . '" title="' |
|
| 198 | - . _SUBMIT |
|
| 199 | - . '" type="submit"></td></tr></tbody></table>', |
|
| 192 | + . _AM_MYMODULE2_ABOUT_MAKE_DONATION |
|
| 193 | + . '</th></tr><tr align="left" valign="top"><td class="head"><div class="xoops-form-element-caption-required"><span class="caption-text">' |
|
| 194 | + . _AM_MYMODULE2_DONATION_AMOUNT |
|
| 195 | + . '</span><span class="caption-marker">*</span></div></td><td class="even"><select size="1" name="item[A][amount]" id="item[A][amount]" title="Donation Amount"><option value="5">5.00 EUR</option><option value="10">10.00 EUR</option><option value="20">20.00 EUR</option><option value="40">40.00 EUR</option><option value="60">60.00 EUR</option><option value="80">80.00 EUR</option><option value="90">90.00 EUR</option><option value="100">100.00 EUR</option><option value="200">200.00 EUR</option></select></td></tr><tr align="left" valign="top"><td class="head"></td><td class="even"><input class="formButton" name="submit" id="submit" value="' |
|
| 196 | + . _SUBMIT |
|
| 197 | + . '" title="' |
|
| 198 | + . _SUBMIT |
|
| 199 | + . '" type="submit"></td></tr></tbody></table>', |
|
| 200 | 200 | 2 => '<input name="op" id="op" value="createinvoice" type="hidden"><input name="plugin" id="plugin" value="donations" type="hidden"><input name="donation" id="donation" value="1" type="hidden"><input name="drawfor" id="drawfor" value="Chronolabs Co-Operative" type="hidden"><input name="drawto" id="drawto" value="%s" type="hidden"><input name="drawto_email" id="drawto_email" value="%s" type="hidden"><input name="key" id="key" value="%s" type="hidden"><input name="currency" id="currency" value="EUR" type="hidden"><input name="weight_unit" id="weight_unit" value="kgs" type="hidden"><input name="item[A][cat]" id="item[A][cat]" value="XDN%s" type="hidden"><input name="item[A][name]" id="item[A][name]" value="Donation for %s" type="hidden"><input name="item[A][quantity]" id="item[A][quantity]" value="1" type="hidden"><input name="item[A][shipping]" id="item[A][shipping]" value="0" type="hidden"><input name="item[A][handling]" id="item[A][handling]" value="0" type="hidden"><input name="item[A][weight]" id="item[A][weight]" value="0" type="hidden"><input name="item[A][tax]" id="item[A][tax]" value="0" type="hidden"><input name="return" id="return" value="http://www.txmodxoops.org/modules/xdonations/success.php" type="hidden"><input name="cancel" id="cancel" value="http://www.txmodxoops.org/modules/xdonations/success.php" type="hidden"></form>', |
| 201 | 201 | 'D' => '', |
| 202 | 202 | 3 => '', |
@@ -29,16 +29,16 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class Constants |
| 31 | 31 | { |
| 32 | - // Constants for status |
|
| 33 | - const STATUS_NONE = 0; |
|
| 34 | - const STATUS_OFFLINE = 1; |
|
| 35 | - const STATUS_SUBMITTED = 2; |
|
| 36 | - const STATUS_APPROVED = 3; |
|
| 32 | + // Constants for status |
|
| 33 | + const STATUS_NONE = 0; |
|
| 34 | + const STATUS_OFFLINE = 1; |
|
| 35 | + const STATUS_SUBMITTED = 2; |
|
| 36 | + const STATUS_APPROVED = 3; |
|
| 37 | 37 | |
| 38 | - // Constants for permissions |
|
| 39 | - const PERM_GLOBAL_NONE = 0; |
|
| 40 | - const PERM_GLOBAL_VIEW = 1; |
|
| 41 | - const PERM_GLOBAL_SUBMIT = 2; |
|
| 42 | - const PERM_GLOBAL_APPROVE = 3; |
|
| 38 | + // Constants for permissions |
|
| 39 | + const PERM_GLOBAL_NONE = 0; |
|
| 40 | + const PERM_GLOBAL_VIEW = 1; |
|
| 41 | + const PERM_GLOBAL_SUBMIT = 2; |
|
| 42 | + const PERM_GLOBAL_APPROVE = 3; |
|
| 43 | 43 | |
| 44 | 44 | } |