@@ -21,21 +21,21 @@ |
||
| 21 | 21 | $moduleDirName = \basename(\dirname(__DIR__, 2)); |
| 22 | 22 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
| 23 | 23 | |
| 24 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE', 'Send a feedback'); |
|
| 25 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT', 'Recipient'); |
|
| 26 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME', 'Name'); |
|
| 27 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER', 'Please enter your name'); |
|
| 28 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE', 'Website'); |
|
| 29 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER', 'Please enter your website'); |
|
| 30 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL', 'Email'); |
|
| 31 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER', 'Please enter your email'); |
|
| 32 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE', 'Type of feedback'); |
|
| 33 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION', 'Suggestions'); |
|
| 34 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS', 'Bugs'); |
|
| 35 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_TESTIMONIAL', 'Testimonials'); |
|
| 36 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_FEATURES', 'Features'); |
|
| 37 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS', 'Misc'); |
|
| 38 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT', 'Feedback content'); |
|
| 39 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_FOR', 'Feedback for module '); |
|
| 40 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_SUCCESS', 'Feedback successfully sent'); |
|
| 41 | -define('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_ERROR', 'An errror occured when feedback was sent!'); |
|
| 24 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_FORM_TITLE', 'Send a feedback'); |
|
| 25 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_RECIPIENT', 'Recipient'); |
|
| 26 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_NAME', 'Name'); |
|
| 27 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_NAME_PLACEHOLER', 'Please enter your name'); |
|
| 28 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_SITE', 'Website'); |
|
| 29 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_SITE_PLACEHOLER', 'Please enter your website'); |
|
| 30 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_MAIL', 'Email'); |
|
| 31 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_MAIL_PLACEHOLER', 'Please enter your email'); |
|
| 32 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE', 'Type of feedback'); |
|
| 33 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_SUGGESTION', 'Suggestions'); |
|
| 34 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_BUGS', 'Bugs'); |
|
| 35 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_TESTIMONIAL', 'Testimonials'); |
|
| 36 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_FEATURES', 'Features'); |
|
| 37 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_OTHERS', 'Misc'); |
|
| 38 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_TYPE_CONTENT', 'Feedback content'); |
|
| 39 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_SEND_FOR', 'Feedback for module '); |
|
| 40 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_SEND_SUCCESS', 'Feedback successfully sent'); |
|
| 41 | +define('CO_'.$moduleDirNameUpper.'_'.'FB_SEND_ERROR', 'An errror occured when feedback was sent!'); |
|
@@ -109,7 +109,7 @@ |
||
| 109 | 109 | //1.14 |
| 110 | 110 | //Help |
| 111 | 111 | define('_MI_SONGLIST_DIRNAME', basename(dirname(__DIR__, 2))); |
| 112 | -define('_MI_SONGLIST_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); |
|
| 112 | +define('_MI_SONGLIST_HELP_HEADER', __DIR__.'/help/helpheader.tpl'); |
|
| 113 | 113 | define('_MI_SONGLIST_BACK_2_ADMIN', 'Back to Administration of '); |
| 114 | 114 | define('_MI_SONGLIST_OVERVIEW', 'Overview'); |
| 115 | 115 | |
@@ -16,138 +16,138 @@ discard block |
||
| 16 | 16 | $moduleDirName = basename(dirname(__DIR__, 2)); |
| 17 | 17 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
| 18 | 18 | |
| 19 | -\define('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS', 'GD library support: '); |
|
| 20 | -\define('CO_' . $moduleDirNameUpper . '_GDLIBVERSION', 'GD Library version: '); |
|
| 21 | -\define('CO_' . $moduleDirNameUpper . '_GDOFF', "<span style='font-weight: bold;'>Disabled</span> (No thumbnails available)"); |
|
| 22 | -\define('CO_' . $moduleDirNameUpper . '_GDON', "<span style='font-weight: bold;'>Enabled</span> (Thumbsnails available)"); |
|
| 23 | -\define('CO_' . $moduleDirNameUpper . '_IMAGEINFO', 'Server status'); |
|
| 24 | -\define('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE', 'Max post size permitted (post_max_size directive in php.ini): '); |
|
| 25 | -\define('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE', 'Max upload size permitted (upload_max_filesize directive in php.ini): '); |
|
| 26 | -\define('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT', 'Memory limit (memory_limit directive in php.ini): '); |
|
| 27 | -\define('CO_' . $moduleDirNameUpper . '_METAVERSION', "<span style='font-weight: bold;'>Downloads meta version:</span> "); |
|
| 28 | -\define('CO_' . $moduleDirNameUpper . '_OFF', "<span style='font-weight: bold;'>OFF</span>"); |
|
| 29 | -\define('CO_' . $moduleDirNameUpper . '_ON', "<span style='font-weight: bold;'>ON</span>"); |
|
| 30 | -\define('CO_' . $moduleDirNameUpper . '_SERVERPATH', 'Server path to XOOPS root: '); |
|
| 31 | -\define('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS', 'Server uploads status: '); |
|
| 32 | -\define('CO_' . $moduleDirNameUpper . '_SPHPINI', "<span style='font-weight: bold;'>Information taken from PHP ini file:</span>"); |
|
| 33 | -\define('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC', 'Note. Upload path *MUST* contain the full server path of your upload folder.'); |
|
| 34 | - |
|
| 35 | -\define('CO_' . $moduleDirNameUpper . '_PRINT', "<span style='font-weight: bold;'>Print</span>"); |
|
| 36 | -\define('CO_' . $moduleDirNameUpper . '_PDF', "<span style='font-weight: bold;'>Create PDF</span>"); |
|
| 37 | - |
|
| 38 | -\define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED0', "Update failed - couldn't rename field '%s'"); |
|
| 39 | -\define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED1', "Update failed - couldn't add new fields"); |
|
| 40 | -\define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED2', "Update failed - couldn't rename table '%s'"); |
|
| 41 | -\define('CO_' . $moduleDirNameUpper . '_ERROR_COLUMN', 'Could not create column in database : %s'); |
|
| 42 | -\define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)'); |
|
| 43 | -\define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)'); |
|
| 44 | -\define('CO_' . $moduleDirNameUpper . '_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); |
|
| 45 | - |
|
| 46 | -\define('CO_' . $moduleDirNameUpper . '_FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); |
|
| 19 | +\define('CO_'.$moduleDirNameUpper.'_GDLIBSTATUS', 'GD library support: '); |
|
| 20 | +\define('CO_'.$moduleDirNameUpper.'_GDLIBVERSION', 'GD Library version: '); |
|
| 21 | +\define('CO_'.$moduleDirNameUpper.'_GDOFF', "<span style='font-weight: bold;'>Disabled</span> (No thumbnails available)"); |
|
| 22 | +\define('CO_'.$moduleDirNameUpper.'_GDON', "<span style='font-weight: bold;'>Enabled</span> (Thumbsnails available)"); |
|
| 23 | +\define('CO_'.$moduleDirNameUpper.'_IMAGEINFO', 'Server status'); |
|
| 24 | +\define('CO_'.$moduleDirNameUpper.'_MAXPOSTSIZE', 'Max post size permitted (post_max_size directive in php.ini): '); |
|
| 25 | +\define('CO_'.$moduleDirNameUpper.'_MAXUPLOADSIZE', 'Max upload size permitted (upload_max_filesize directive in php.ini): '); |
|
| 26 | +\define('CO_'.$moduleDirNameUpper.'_MEMORYLIMIT', 'Memory limit (memory_limit directive in php.ini): '); |
|
| 27 | +\define('CO_'.$moduleDirNameUpper.'_METAVERSION', "<span style='font-weight: bold;'>Downloads meta version:</span> "); |
|
| 28 | +\define('CO_'.$moduleDirNameUpper.'_OFF', "<span style='font-weight: bold;'>OFF</span>"); |
|
| 29 | +\define('CO_'.$moduleDirNameUpper.'_ON', "<span style='font-weight: bold;'>ON</span>"); |
|
| 30 | +\define('CO_'.$moduleDirNameUpper.'_SERVERPATH', 'Server path to XOOPS root: '); |
|
| 31 | +\define('CO_'.$moduleDirNameUpper.'_SERVERUPLOADSTATUS', 'Server uploads status: '); |
|
| 32 | +\define('CO_'.$moduleDirNameUpper.'_SPHPINI', "<span style='font-weight: bold;'>Information taken from PHP ini file:</span>"); |
|
| 33 | +\define('CO_'.$moduleDirNameUpper.'_UPLOADPATHDSC', 'Note. Upload path *MUST* contain the full server path of your upload folder.'); |
|
| 34 | + |
|
| 35 | +\define('CO_'.$moduleDirNameUpper.'_PRINT', "<span style='font-weight: bold;'>Print</span>"); |
|
| 36 | +\define('CO_'.$moduleDirNameUpper.'_PDF', "<span style='font-weight: bold;'>Create PDF</span>"); |
|
| 37 | + |
|
| 38 | +\define('CO_'.$moduleDirNameUpper.'_UPGRADEFAILED0', "Update failed - couldn't rename field '%s'"); |
|
| 39 | +\define('CO_'.$moduleDirNameUpper.'_UPGRADEFAILED1', "Update failed - couldn't add new fields"); |
|
| 40 | +\define('CO_'.$moduleDirNameUpper.'_UPGRADEFAILED2', "Update failed - couldn't rename table '%s'"); |
|
| 41 | +\define('CO_'.$moduleDirNameUpper.'_ERROR_COLUMN', 'Could not create column in database : %s'); |
|
| 42 | +\define('CO_'.$moduleDirNameUpper.'_ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)'); |
|
| 43 | +\define('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)'); |
|
| 44 | +\define('CO_'.$moduleDirNameUpper.'_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); |
|
| 45 | + |
|
| 46 | +\define('CO_'.$moduleDirNameUpper.'_FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); |
|
| 47 | 47 | |
| 48 | 48 | // Error Msgs |
| 49 | -\define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH', 'Could not delete %s directory'); |
|
| 50 | -\define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE', 'Could not delete %s'); |
|
| 51 | -\define('CO_' . $moduleDirNameUpper . '_ERROR_NO_PLUGIN', 'Could not load plugin'); |
|
| 49 | +\define('CO_'.$moduleDirNameUpper.'_ERROR_BAD_DEL_PATH', 'Could not delete %s directory'); |
|
| 50 | +\define('CO_'.$moduleDirNameUpper.'_ERROR_BAD_REMOVE', 'Could not delete %s'); |
|
| 51 | +\define('CO_'.$moduleDirNameUpper.'_ERROR_NO_PLUGIN', 'Could not load plugin'); |
|
| 52 | 52 | |
| 53 | 53 | //Help |
| 54 | -\define('CO_' . $moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__, 2))); |
|
| 55 | -\define('CO_' . $moduleDirNameUpper . '_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); |
|
| 56 | -\define('CO_' . $moduleDirNameUpper . '_BACK_2_ADMIN', 'Back to Administration of '); |
|
| 57 | -\define('CO_' . $moduleDirNameUpper . '_OVERVIEW', 'Overview'); |
|
| 54 | +\define('CO_'.$moduleDirNameUpper.'_DIRNAME', basename(dirname(__DIR__, 2))); |
|
| 55 | +\define('CO_'.$moduleDirNameUpper.'_HELP_HEADER', __DIR__.'/help/helpheader.tpl'); |
|
| 56 | +\define('CO_'.$moduleDirNameUpper.'_BACK_2_ADMIN', 'Back to Administration of '); |
|
| 57 | +\define('CO_'.$moduleDirNameUpper.'_OVERVIEW', 'Overview'); |
|
| 58 | 58 | |
| 59 | 59 | //\define('CO_' . $moduleDirNameUpper . '_HELP_DIR', __DIR__); |
| 60 | 60 | |
| 61 | 61 | //help multi-page |
| 62 | -\define('CO_' . $moduleDirNameUpper . '_DISCLAIMER', 'Disclaimer'); |
|
| 63 | -\define('CO_' . $moduleDirNameUpper . '_LICENSE', 'License'); |
|
| 64 | -\define('CO_' . $moduleDirNameUpper . '_SUPPORT', 'Support'); |
|
| 62 | +\define('CO_'.$moduleDirNameUpper.'_DISCLAIMER', 'Disclaimer'); |
|
| 63 | +\define('CO_'.$moduleDirNameUpper.'_LICENSE', 'License'); |
|
| 64 | +\define('CO_'.$moduleDirNameUpper.'_SUPPORT', 'Support'); |
|
| 65 | 65 | |
| 66 | 66 | //Sample Data |
| 67 | -\define('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA', 'Import Sample Data (will delete ALL current data)'); |
|
| 68 | -\define('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM', 'Are you sure to Import Sample Data? (It will delete ALL current data)'); |
|
| 69 | -\define('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS', 'Sample Date imported successfully'); |
|
| 70 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA', 'Export Tables to YAML'); |
|
| 71 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS', 'Export Tables to YAML successfully'); |
|
| 72 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA', 'Clear the Sample Data'); |
|
| 73 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK', 'The Sample Data has been cleared'); |
|
| 74 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_CONFIRM', 'Are you sure to Clear Sample Data? (It will delete ALL current data)'); |
|
| 75 | -\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA', 'Export DB Schema to YAML'); |
|
| 76 | -\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success'); |
|
| 77 | -\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed'); |
|
| 78 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON', 'Show Sample Button?'); |
|
| 79 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC', 'If yes, the "Add Sample Data" button will be visible to the Admin. It is Yes as a default for first installation.'); |
|
| 80 | -\define('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS', 'Hide the Import buttons)'); |
|
| 81 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS', 'Show the Import buttons)'); |
|
| 82 | - |
|
| 83 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM', 'Confirm'); |
|
| 67 | +\define('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA', 'Import Sample Data (will delete ALL current data)'); |
|
| 68 | +\define('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA_CONFIRM', 'Are you sure to Import Sample Data? (It will delete ALL current data)'); |
|
| 69 | +\define('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA_SUCCESS', 'Sample Date imported successfully'); |
|
| 70 | +\define('CO_'.$moduleDirNameUpper.'_'.'SAVE_SAMPLEDATA', 'Export Tables to YAML'); |
|
| 71 | +\define('CO_'.$moduleDirNameUpper.'_'.'SAVE_SAMPLEDATA_SUCCESS', 'Export Tables to YAML successfully'); |
|
| 72 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA', 'Clear the Sample Data'); |
|
| 73 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA_OK', 'The Sample Data has been cleared'); |
|
| 74 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA_CONFIRM', 'Are you sure to Clear Sample Data? (It will delete ALL current data)'); |
|
| 75 | +\define('CO_'.$moduleDirNameUpper.'_'.'EXPORT_SCHEMA', 'Export DB Schema to YAML'); |
|
| 76 | +\define('CO_'.$moduleDirNameUpper.'_'.'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success'); |
|
| 77 | +\define('CO_'.$moduleDirNameUpper.'_'.'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed'); |
|
| 78 | +\define('CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLE_BUTTON', 'Show Sample Button?'); |
|
| 79 | +\define('CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLE_BUTTON_DESC', 'If yes, the "Add Sample Data" button will be visible to the Admin. It is Yes as a default for first installation.'); |
|
| 80 | +\define('CO_'.$moduleDirNameUpper.'_'.'HIDE_SAMPLEDATA_BUTTONS', 'Hide the Import buttons)'); |
|
| 81 | +\define('CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLEDATA_BUTTONS', 'Show the Import buttons)'); |
|
| 82 | + |
|
| 83 | +\define('CO_'.$moduleDirNameUpper.'_'.'CONFIRM', 'Confirm'); |
|
| 84 | 84 | |
| 85 | 85 | //letter choice |
| 86 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BROWSETOTOPIC', "<span style='font-weight: bold;'>Browse items alphabetically</span>"); |
|
| 87 | -\define('CO_' . $moduleDirNameUpper . '_' . 'OTHER', 'Other'); |
|
| 88 | -\define('CO_' . $moduleDirNameUpper . '_' . 'ALL', 'All'); |
|
| 86 | +\define('CO_'.$moduleDirNameUpper.'_'.'BROWSETOTOPIC', "<span style='font-weight: bold;'>Browse items alphabetically</span>"); |
|
| 87 | +\define('CO_'.$moduleDirNameUpper.'_'.'OTHER', 'Other'); |
|
| 88 | +\define('CO_'.$moduleDirNameUpper.'_'.'ALL', 'All'); |
|
| 89 | 89 | |
| 90 | 90 | // block defines |
| 91 | -\define('CO_' . $moduleDirNameUpper . '_' . 'ACCESSRIGHTS', 'Access Rights'); |
|
| 92 | -\define('CO_' . $moduleDirNameUpper . '_' . 'ACTION', 'Action'); |
|
| 93 | -\define('CO_' . $moduleDirNameUpper . '_' . 'ACTIVERIGHTS', 'Active Rights'); |
|
| 94 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BADMIN', 'Block Administration'); |
|
| 95 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BLKDESC', 'Description'); |
|
| 96 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CBCENTER', 'Center Middle'); |
|
| 97 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CBLEFT', 'Center Left'); |
|
| 98 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CBRIGHT', 'Center Right'); |
|
| 99 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SBLEFT', 'Left'); |
|
| 100 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SBRIGHT', 'Right'); |
|
| 101 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SIDE', 'Alignment'); |
|
| 102 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TITLE', 'Title'); |
|
| 103 | -\define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE', 'Visible'); |
|
| 104 | -\define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLEIN', 'Visible In'); |
|
| 105 | -\define('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT', 'Weight'); |
|
| 106 | - |
|
| 107 | -\define('CO_' . $moduleDirNameUpper . '_' . 'PERMISSIONS', 'Permissions'); |
|
| 108 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS', 'Blocks Admin'); |
|
| 109 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_DESC', 'Blocks/Group Admin'); |
|
| 110 | - |
|
| 111 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_MANAGMENT', 'Manage'); |
|
| 112 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADDBLOCK', 'Add a new block'); |
|
| 113 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK', 'Edit a block'); |
|
| 114 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK', 'Clone a block'); |
|
| 91 | +\define('CO_'.$moduleDirNameUpper.'_'.'ACCESSRIGHTS', 'Access Rights'); |
|
| 92 | +\define('CO_'.$moduleDirNameUpper.'_'.'ACTION', 'Action'); |
|
| 93 | +\define('CO_'.$moduleDirNameUpper.'_'.'ACTIVERIGHTS', 'Active Rights'); |
|
| 94 | +\define('CO_'.$moduleDirNameUpper.'_'.'BADMIN', 'Block Administration'); |
|
| 95 | +\define('CO_'.$moduleDirNameUpper.'_'.'BLKDESC', 'Description'); |
|
| 96 | +\define('CO_'.$moduleDirNameUpper.'_'.'CBCENTER', 'Center Middle'); |
|
| 97 | +\define('CO_'.$moduleDirNameUpper.'_'.'CBLEFT', 'Center Left'); |
|
| 98 | +\define('CO_'.$moduleDirNameUpper.'_'.'CBRIGHT', 'Center Right'); |
|
| 99 | +\define('CO_'.$moduleDirNameUpper.'_'.'SBLEFT', 'Left'); |
|
| 100 | +\define('CO_'.$moduleDirNameUpper.'_'.'SBRIGHT', 'Right'); |
|
| 101 | +\define('CO_'.$moduleDirNameUpper.'_'.'SIDE', 'Alignment'); |
|
| 102 | +\define('CO_'.$moduleDirNameUpper.'_'.'TITLE', 'Title'); |
|
| 103 | +\define('CO_'.$moduleDirNameUpper.'_'.'VISIBLE', 'Visible'); |
|
| 104 | +\define('CO_'.$moduleDirNameUpper.'_'.'VISIBLEIN', 'Visible In'); |
|
| 105 | +\define('CO_'.$moduleDirNameUpper.'_'.'WEIGHT', 'Weight'); |
|
| 106 | + |
|
| 107 | +\define('CO_'.$moduleDirNameUpper.'_'.'PERMISSIONS', 'Permissions'); |
|
| 108 | +\define('CO_'.$moduleDirNameUpper.'_'.'BLOCKS', 'Blocks Admin'); |
|
| 109 | +\define('CO_'.$moduleDirNameUpper.'_'.'BLOCKS_DESC', 'Blocks/Group Admin'); |
|
| 110 | + |
|
| 111 | +\define('CO_'.$moduleDirNameUpper.'_'.'BLOCKS_MANAGMENT', 'Manage'); |
|
| 112 | +\define('CO_'.$moduleDirNameUpper.'_'.'BLOCKS_ADDBLOCK', 'Add a new block'); |
|
| 113 | +\define('CO_'.$moduleDirNameUpper.'_'.'BLOCKS_EDITBLOCK', 'Edit a block'); |
|
| 114 | +\define('CO_'.$moduleDirNameUpper.'_'.'BLOCKS_CLONEBLOCK', 'Clone a block'); |
|
| 115 | 115 | |
| 116 | 116 | //myblocksadmin |
| 117 | -\define('CO_' . $moduleDirNameUpper . '_' . 'AGDS', 'Admin Groups'); |
|
| 118 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BCACHETIME', 'Cache Time'); |
|
| 119 | -\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADMIN', 'Blocks Admin'); |
|
| 120 | -\define('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS', 'Update successful'); |
|
| 117 | +\define('CO_'.$moduleDirNameUpper.'_'.'AGDS', 'Admin Groups'); |
|
| 118 | +\define('CO_'.$moduleDirNameUpper.'_'.'BCACHETIME', 'Cache Time'); |
|
| 119 | +\define('CO_'.$moduleDirNameUpper.'_'.'BLOCKS_ADMIN', 'Blocks Admin'); |
|
| 120 | +\define('CO_'.$moduleDirNameUpper.'_'.'UPDATE_SUCCESS', 'Update successful'); |
|
| 121 | 121 | |
| 122 | 122 | //Template Admin |
| 123 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TPLSETS', 'Template Management'); |
|
| 124 | -\define('CO_' . $moduleDirNameUpper . '_' . 'GENERATE', 'Generate'); |
|
| 125 | -\define('CO_' . $moduleDirNameUpper . '_' . 'FILENAME', 'File Name'); |
|
| 123 | +\define('CO_'.$moduleDirNameUpper.'_'.'TPLSETS', 'Template Management'); |
|
| 124 | +\define('CO_'.$moduleDirNameUpper.'_'.'GENERATE', 'Generate'); |
|
| 125 | +\define('CO_'.$moduleDirNameUpper.'_'.'FILENAME', 'File Name'); |
|
| 126 | 126 | |
| 127 | 127 | //Menu |
| 128 | -\define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); |
|
| 129 | -\define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); |
|
| 130 | -\define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); |
|
| 131 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); |
|
| 132 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); |
|
| 133 | -\define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_FEEDBACK', 'Feedback'); |
|
| 134 | -\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK', 'Database migrated to current schema.'); |
|
| 135 | -\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING', 'Warning! This is intended for developers only. Confirm write schema file from current database.'); |
|
| 136 | -\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK', 'Current schema file written'); |
|
| 128 | +\define('CO_'.$moduleDirNameUpper.'_'.'ADMENU_MIGRATE', 'Migrate'); |
|
| 129 | +\define('CO_'.$moduleDirNameUpper.'_'.'FOLDER_YES', 'Folder "%s" exist'); |
|
| 130 | +\define('CO_'.$moduleDirNameUpper.'_'.'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); |
|
| 131 | +\define('CO_'.$moduleDirNameUpper.'_'.'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); |
|
| 132 | +\define('CO_'.$moduleDirNameUpper.'_'.'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); |
|
| 133 | +\define('CO_'.$moduleDirNameUpper.'_'.'ADMENU_FEEDBACK', 'Feedback'); |
|
| 134 | +\define('CO_'.$moduleDirNameUpper.'_'.'MIGRATE_OK', 'Database migrated to current schema.'); |
|
| 135 | +\define('CO_'.$moduleDirNameUpper.'_'.'MIGRATE_WARNING', 'Warning! This is intended for developers only. Confirm write schema file from current database.'); |
|
| 136 | +\define('CO_'.$moduleDirNameUpper.'_'.'MIGRATE_SCHEMA_OK', 'Current schema file written'); |
|
| 137 | 137 | |
| 138 | 138 | //Latest Version Check |
| 139 | -\define('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION', 'New Version: '); |
|
| 139 | +\define('CO_'.$moduleDirNameUpper.'_'.'NEW_VERSION', 'New Version: '); |
|
| 140 | 140 | |
| 141 | 141 | //DirectoryChecker |
| 142 | -\define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "<span style='color: green;'>Available</span>"); |
|
| 143 | -\define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "<span style='color: red;'>Not available</span>"); |
|
| 144 | -\define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "<span style='color: red;'>Should have permission ( %d ), but it has ( %d )</span>"); |
|
| 145 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEDIR', 'Create it'); |
|
| 146 | -\define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); |
|
| 147 | -\define('CO_' . $moduleDirNameUpper . '_' . 'DIRCREATED', 'The directory has been created'); |
|
| 148 | -\define('CO_' . $moduleDirNameUpper . '_' . 'DIRNOTCREATED', 'The directory cannot be created'); |
|
| 149 | -\define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); |
|
| 150 | -\define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); |
|
| 142 | +\define('CO_'.$moduleDirNameUpper.'_'.'AVAILABLE', "<span style='color: green;'>Available</span>"); |
|
| 143 | +\define('CO_'.$moduleDirNameUpper.'_'.'NOTAVAILABLE', "<span style='color: red;'>Not available</span>"); |
|
| 144 | +\define('CO_'.$moduleDirNameUpper.'_'.'NOTWRITABLE', "<span style='color: red;'>Should have permission ( %d ), but it has ( %d )</span>"); |
|
| 145 | +\define('CO_'.$moduleDirNameUpper.'_'.'CREATETHEDIR', 'Create it'); |
|
| 146 | +\define('CO_'.$moduleDirNameUpper.'_'.'SETMPERM', 'Set the permission'); |
|
| 147 | +\define('CO_'.$moduleDirNameUpper.'_'.'DIRCREATED', 'The directory has been created'); |
|
| 148 | +\define('CO_'.$moduleDirNameUpper.'_'.'DIRNOTCREATED', 'The directory cannot be created'); |
|
| 149 | +\define('CO_'.$moduleDirNameUpper.'_'.'PERMSET', 'The permission has been set'); |
|
| 150 | +\define('CO_'.$moduleDirNameUpper.'_'.'PERMNOTSET', 'The permission cannot be set'); |
|
| 151 | 151 | |
| 152 | 152 | //FileChecker |
| 153 | 153 | //\define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "<span style='color: green;'>Available</span>"); |
@@ -157,70 +157,70 @@ discard block |
||
| 157 | 157 | //\define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEFILE', 'Create it'); |
| 158 | 158 | //\define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); |
| 159 | 159 | |
| 160 | -\define('CO_' . $moduleDirNameUpper . '_' . 'FILECOPIED', 'The file has been copied'); |
|
| 161 | -\define('CO_' . $moduleDirNameUpper . '_' . 'FILENOTCOPIED', 'The file cannot be copied'); |
|
| 160 | +\define('CO_'.$moduleDirNameUpper.'_'.'FILECOPIED', 'The file has been copied'); |
|
| 161 | +\define('CO_'.$moduleDirNameUpper.'_'.'FILENOTCOPIED', 'The file cannot be copied'); |
|
| 162 | 162 | |
| 163 | 163 | //\define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); |
| 164 | 164 | //\define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); |
| 165 | 165 | |
| 166 | 166 | //image config |
| 167 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_EXT_IMAGE', 'EXTERNAL Image configuration'); |
|
| 168 | - |
|
| 169 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_START', '<span style="color: #FF0000; font-size: Small; font-weight: bold;">:: '); |
|
| 170 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_END', ' ::</span> '); |
|
| 171 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_DESC_START', '<span style="color: #FF0000; font-size: Small;">'); |
|
| 172 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_DESC_END', '</span> '); |
|
| 173 | - |
|
| 174 | -\define('CO_' . $moduleDirNameUpper . '_' . 'PREFERENCE_BREAK_CONFIG_IMAGE', constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_START') . constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_EXT_IMAGE') . constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_END')); |
|
| 175 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); |
|
| 176 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); |
|
| 177 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT', 'Image Display Height'); |
|
| 178 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', 'Display height for image'); |
|
| 179 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG', '<span style="color: #FF0000; font-size: Small; font-weight: bold;">--- EXTERNAL Image configuration ---</span> '); |
|
| 180 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); |
|
| 181 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); |
|
| 182 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); |
|
| 183 | - |
|
| 184 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE', 'Image File Size (in Bytes)'); |
|
| 185 | -\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE_DSC','The maximum file size of the image file (in Bytes)'); |
|
| 167 | +\define('CO_'.$moduleDirNameUpper.'_'.'CONFIG_EXT_IMAGE', 'EXTERNAL Image configuration'); |
|
| 168 | + |
|
| 169 | +\define('CO_'.$moduleDirNameUpper.'_'.'CONFIG_STYLING_START', '<span style="color: #FF0000; font-size: Small; font-weight: bold;">:: '); |
|
| 170 | +\define('CO_'.$moduleDirNameUpper.'_'.'CONFIG_STYLING_END', ' ::</span> '); |
|
| 171 | +\define('CO_'.$moduleDirNameUpper.'_'.'CONFIG_STYLING_DESC_START', '<span style="color: #FF0000; font-size: Small;">'); |
|
| 172 | +\define('CO_'.$moduleDirNameUpper.'_'.'CONFIG_STYLING_DESC_END', '</span> '); |
|
| 173 | + |
|
| 174 | +\define('CO_'.$moduleDirNameUpper.'_'.'PREFERENCE_BREAK_CONFIG_IMAGE', constant('CO_'.$moduleDirNameUpper.'_'.'CONFIG_STYLING_START').constant('CO_'.$moduleDirNameUpper.'_'.'CONFIG_EXT_IMAGE').constant('CO_'.$moduleDirNameUpper.'_'.'CONFIG_STYLING_END')); |
|
| 175 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_WIDTH', 'Image Display Width'); |
|
| 176 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_WIDTH_DSC', 'Display width for image'); |
|
| 177 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_HEIGHT', 'Image Display Height'); |
|
| 178 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_HEIGHT_DSC', 'Display height for image'); |
|
| 179 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_CONFIG', '<span style="color: #FF0000; font-size: Small; font-weight: bold;">--- EXTERNAL Image configuration ---</span> '); |
|
| 180 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_CONFIG_DSC', ''); |
|
| 181 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_UPLOAD_PATH', 'Image Upload path'); |
|
| 182 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); |
|
| 183 | + |
|
| 184 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_FILE_SIZE', 'Image File Size (in Bytes)'); |
|
| 185 | +\define('CO_'.$moduleDirNameUpper.'_'.'IMAGE_FILE_SIZE_DSC', 'The maximum file size of the image file (in Bytes)'); |
|
| 186 | 186 | |
| 187 | 187 | //Module Stats |
| 188 | -\define('CO_' . $moduleDirNameUpper . '_' . 'STATS_SUMMARY', 'Module Statistics'); |
|
| 189 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_CATEGORIES', 'Categories:'); |
|
| 190 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_ITEMS', 'Items'); |
|
| 191 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_OFFLINE', 'Offline'); |
|
| 192 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_PUBLISHED', 'Published'); |
|
| 193 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_REJECTED', 'Rejected'); |
|
| 194 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_SUBMITTED', 'Submitted'); |
|
| 188 | +\define('CO_'.$moduleDirNameUpper.'_'.'STATS_SUMMARY', 'Module Statistics'); |
|
| 189 | +\define('CO_'.$moduleDirNameUpper.'_'.'TOTAL_CATEGORIES', 'Categories:'); |
|
| 190 | +\define('CO_'.$moduleDirNameUpper.'_'.'TOTAL_ITEMS', 'Items'); |
|
| 191 | +\define('CO_'.$moduleDirNameUpper.'_'.'TOTAL_OFFLINE', 'Offline'); |
|
| 192 | +\define('CO_'.$moduleDirNameUpper.'_'.'TOTAL_PUBLISHED', 'Published'); |
|
| 193 | +\define('CO_'.$moduleDirNameUpper.'_'.'TOTAL_REJECTED', 'Rejected'); |
|
| 194 | +\define('CO_'.$moduleDirNameUpper.'_'.'TOTAL_SUBMITTED', 'Submitted'); |
|
| 195 | 195 | |
| 196 | -\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR403', 'You are not allowed to view this page!'); |
|
| 196 | +\define('CO_'.$moduleDirNameUpper.'_'.'ERROR403', 'You are not allowed to view this page!'); |
|
| 197 | 197 | |
| 198 | 198 | //Preferences |
| 199 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH', 'Number of Characters to truncate to the long text field'); |
|
| 200 | -\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH_DESC', 'Set the maximum number of characters to truncate the long text fields'); |
|
| 199 | +\define('CO_'.$moduleDirNameUpper.'_'.'TRUNCATE_LENGTH', 'Number of Characters to truncate to the long text field'); |
|
| 200 | +\define('CO_'.$moduleDirNameUpper.'_'.'TRUNCATE_LENGTH_DESC', 'Set the maximum number of characters to truncate the long text fields'); |
|
| 201 | 201 | |
| 202 | -\define('CO_' . $moduleDirNameUpper . '_' . 'DELETE_BLOCK_CONFIRM', 'Are you sure to delete this Block?'); |
|
| 202 | +\define('CO_'.$moduleDirNameUpper.'_'.'DELETE_BLOCK_CONFIRM', 'Are you sure to delete this Block?'); |
|
| 203 | 203 | |
| 204 | 204 | //Cloning |
| 205 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE', 'Clone'); |
|
| 206 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_DSC', 'Cloning a module has never been this easy! Just type in the name you want for it and hit submit button!'); |
|
| 207 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_TITLE', 'Clone %s'); |
|
| 208 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME', 'Choose a name for the new module'); |
|
| 209 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME_DSC', 'Do not use special characters! <br>Do not choose an existing module dirname or database table name!'); |
|
| 210 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_INVALIDNAME', 'ERROR: Invalid module name, please try another one!'); |
|
| 211 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_EXISTS', 'ERROR: Module name already taken, please try another one!'); |
|
| 212 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_CONGRAT', 'Congratulations! %s was sucessfully created!<br>You may want to make changes in language files.'); |
|
| 213 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_IMAGEFAIL', 'Attention, we failed creating the new module logo. Please consider modifying assets/images/logo_module.png manually!'); |
|
| 214 | -\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_FAIL', "Sorry, we failed in creating the new clone. Maybe you need to temporally set write permissions (CHMOD 777) to 'modules' folder and try again."); |
|
| 205 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE', 'Clone'); |
|
| 206 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE_DSC', 'Cloning a module has never been this easy! Just type in the name you want for it and hit submit button!'); |
|
| 207 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE_TITLE', 'Clone %s'); |
|
| 208 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE_NAME', 'Choose a name for the new module'); |
|
| 209 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE_NAME_DSC', 'Do not use special characters! <br>Do not choose an existing module dirname or database table name!'); |
|
| 210 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE_INVALIDNAME', 'ERROR: Invalid module name, please try another one!'); |
|
| 211 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE_EXISTS', 'ERROR: Module name already taken, please try another one!'); |
|
| 212 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE_CONGRAT', 'Congratulations! %s was sucessfully created!<br>You may want to make changes in language files.'); |
|
| 213 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE_IMAGEFAIL', 'Attention, we failed creating the new module logo. Please consider modifying assets/images/logo_module.png manually!'); |
|
| 214 | +\define('CO_'.$moduleDirNameUpper.'_'.'CLONE_FAIL', "Sorry, we failed in creating the new clone. Maybe you need to temporally set write permissions (CHMOD 777) to 'modules' folder and try again."); |
|
| 215 | 215 | |
| 216 | 216 | |
| 217 | 217 | //JSON-LD generation of www.schema.org |
| 218 | -\define('CO_' . $moduleDirNameUpper . '_' . 'GENERATE_JSONLD', 'Generate Schema Markup through JSON LD'); |
|
| 219 | -\define('CO_' . $moduleDirNameUpper . '_' . 'GENERATE_JSONLD_DESC', 'Mark up your module with structured data to help search engines better understand the content of your web page'); |
|
| 218 | +\define('CO_'.$moduleDirNameUpper.'_'.'GENERATE_JSONLD', 'Generate Schema Markup through JSON LD'); |
|
| 219 | +\define('CO_'.$moduleDirNameUpper.'_'.'GENERATE_JSONLD_DESC', 'Mark up your module with structured data to help search engines better understand the content of your web page'); |
|
| 220 | 220 | |
| 221 | 221 | //Repository not found |
| 222 | -\define('CO_' . $moduleDirNameUpper . '_' . 'REPO_NOT_FOUND', 'Repository Not Found: '); |
|
| 222 | +\define('CO_'.$moduleDirNameUpper.'_'.'REPO_NOT_FOUND', 'Repository Not Found: '); |
|
| 223 | 223 | //Release not found |
| 224 | -\define('CO_' . $moduleDirNameUpper . '_' . 'NO_REL_FOUND', 'Released Version Not Found: '); |
|
| 224 | +\define('CO_'.$moduleDirNameUpper.'_'.'NO_REL_FOUND', 'Released Version Not Found: '); |
|
| 225 | 225 | //rename upload folder on uninstall |
| 226 | -\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_FOLDER_RENAME_FAILED', 'Could not rename upload folder, please rename manually'); |
|
| 226 | +\define('CO_'.$moduleDirNameUpper.'_'.'ERROR_FOLDER_RENAME_FAILED', 'Could not rename upload folder, please rename manually'); |
|
@@ -13,12 +13,12 @@ discard block |
||
| 13 | 13 | $criteria_cat = new \CriteriaCompo(); |
| 14 | 14 | $cids = $categoryHandler->GetCatAndSubCat($_SESSION['cid']); |
| 15 | 15 | if ($_SESSION['cid'] > 0) { |
| 16 | - $cids[$_SESSION['cid']] = $_SESSION['cid']; |
|
| 16 | + $cids[$_SESSION['cid']] = $_SESSION['cid']; |
|
| 17 | 17 | } |
| 18 | 18 | if (count($cids) > 0 && 0 != $_SESSION['cid']) { |
| 19 | - $criteria_cat->add(new \Criteria('cid', '(' . implode(',', $cids) . ')', 'IN'), 'OR'); |
|
| 19 | + $criteria_cat->add(new \Criteria('cid', '(' . implode(',', $cids) . ')', 'IN'), 'OR'); |
|
| 20 | 20 | } else { |
| 21 | - $criteria_cat->add(new \Criteria(''), 'OR'); |
|
| 21 | + $criteria_cat->add(new \Criteria(''), 'OR'); |
|
| 22 | 22 | } |
| 23 | 23 | $criteria_cat->setSort('created'); |
| 24 | 24 | $criteria_cat->setOrder('ASC'); |
@@ -32,198 +32,198 @@ discard block |
||
| 32 | 32 | $col = 1; |
| 33 | 33 | $row = 1; |
| 34 | 34 | foreach ($categories as $category) { |
| 35 | - $cat[$row][$col] = $category->toArray(true); |
|
| 36 | - $cat[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 37 | - ++$col; |
|
| 38 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 39 | - ++$row; |
|
| 40 | - $col = 1; |
|
| 41 | - } |
|
| 35 | + $cat[$row][$col] = $category->toArray(true); |
|
| 36 | + $cat[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 37 | + ++$col; |
|
| 38 | + if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 39 | + ++$row; |
|
| 40 | + $col = 1; |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | if (1 != $col) { |
| 44 | - $col--; |
|
| 45 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 46 | - $cat[$row][$j][$categoryHandler->keyName] = 0; |
|
| 47 | - $cat[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 48 | - } |
|
| 44 | + $col--; |
|
| 45 | + for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 46 | + $cat[$row][$j][$categoryHandler->keyName] = 0; |
|
| 47 | + $cat[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 48 | + } |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** @var AlbumsHandler $albumsHandler */ |
| 52 | 52 | $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
| 53 | 53 | switch ($op) { |
| 54 | - default: |
|
| 55 | - case 'item': |
|
| 56 | - switch ($fct) { |
|
| 57 | - default: |
|
| 58 | - case 'list': |
|
| 59 | - $pagenav = new \XoopsPageNav($albumsHandler->getCount($criteria_cat), $limit, $start, 'start', "op=$op&fct=$fct&id=$id&value=$value&limit=$limit"); |
|
| 60 | - |
|
| 61 | - $criteria_cat->setLimit($limit); |
|
| 62 | - $criteria_cat->setStart($start); |
|
| 63 | - |
|
| 64 | - $albums = $albumsHandler->getObjects($criteria_cat, false); |
|
| 65 | - |
|
| 66 | - $ret = []; |
|
| 67 | - $col = 1; |
|
| 68 | - $row = 1; |
|
| 69 | - foreach ($albums as $album) { |
|
| 70 | - $ret[$row][$col] = $album->toArray(true); |
|
| 71 | - $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 72 | - ++$col; |
|
| 73 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 74 | - ++$row; |
|
| 75 | - $col = 1; |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - if (1 != $col) { |
|
| 79 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 80 | - $ret[$row][$j][$albumsHandler->keyName] = 0; |
|
| 81 | - $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - $url = $albumsHandler->getURL(); |
|
| 86 | - if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 87 | - header('HTTP/1.1 301 Moved Permanently'); |
|
| 88 | - header('Location: ' . $url); |
|
| 89 | - exit(0); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - $GLOBALS['xoopsOption']['template_main'] = 'songlist_albums_index.tpl'; |
|
| 93 | - require_once $GLOBALS['xoops']->path('/header.php'); |
|
| 94 | - if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 95 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 96 | - $GLOBALS['loaded_jquery'] = true; |
|
| 97 | - } |
|
| 98 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 99 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 100 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 101 | - $GLOBALS['xoopsTpl']->assign('results', $ret); |
|
| 102 | - $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 103 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 104 | - $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 105 | - if (0 != $_SESSION['cid']) { |
|
| 106 | - $category = $categoryHandler->get($_SESSION['cid']); |
|
| 107 | - $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
|
| 108 | - } |
|
| 109 | - require_once $GLOBALS['xoops']->path('/footer.php'); |
|
| 110 | - break; |
|
| 111 | - case 'item': |
|
| 112 | - $album = $albumsHandler->get($id); |
|
| 113 | - |
|
| 114 | - $url = $album->getURL(true); |
|
| 115 | - if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 116 | - header('HTTP/1.1 301 Moved Permanently'); |
|
| 117 | - header('Location: ' . $url); |
|
| 118 | - exit(0); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $GLOBALS['xoopsOption']['template_main'] = 'songlist_albums_item.tpl'; |
|
| 122 | - require_once $GLOBALS['xoops']->path('/header.php'); |
|
| 123 | - if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 124 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 125 | - $GLOBALS['loaded_jquery'] = true; |
|
| 126 | - } |
|
| 127 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 128 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 129 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 130 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 131 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 132 | - $GLOBALS['xoopsTpl']->assign('songs', false); |
|
| 133 | - $GLOBALS['xoopsTpl']->assign('album', $album->toArray(true)); |
|
| 134 | - $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 135 | - $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 136 | - require_once $GLOBALS['xoops']->path('/footer.php'); |
|
| 137 | - break; |
|
| 138 | - } |
|
| 139 | - break; |
|
| 140 | - case 'browseby': |
|
| 141 | - switch ($fct) { |
|
| 142 | - default: |
|
| 143 | - case 'title': |
|
| 144 | - case 'lyrics': |
|
| 145 | - case 'artist': |
|
| 146 | - case 'album': |
|
| 147 | - $browse_criteria = new \CriteriaCompo(); |
|
| 148 | - switch ($value) { |
|
| 149 | - case '0': |
|
| 150 | - for ($u = 0; $u < 10; ++$u) { |
|
| 151 | - $browse_criteria->add(new \Criteria('title', $u . '%', 'LIKE'), 'OR'); |
|
| 152 | - } |
|
| 153 | - break; |
|
| 154 | - default: |
|
| 155 | - $browse_criteria->add(new \Criteria('title', \mb_strtoupper($value) . '%', 'LIKE'), 'OR'); |
|
| 156 | - $browse_criteria->add(new \Criteria('title', \mb_strtolower($value) . '%', 'LIKE'), 'OR'); |
|
| 157 | - break; |
|
| 158 | - } |
|
| 159 | - $criteria = new \CriteriaCompo($criteria_cat, 'AND'); |
|
| 160 | - $criteria->add($browse_criteria); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - $pagenav = new \XoopsPageNav($albumsHandler->getCount($criteria), $limit, $start, 'start', "op=$op&fct=$fct&id=$id&value=$value&limit=$limit"); |
|
| 164 | - |
|
| 165 | - $criteria->setLimit($limit); |
|
| 166 | - $criteria->setStart($start); |
|
| 167 | - |
|
| 168 | - $albums = $albumsHandler->getObjects($criteria, false); |
|
| 169 | - |
|
| 170 | - $ret = []; |
|
| 171 | - $col = 1; |
|
| 172 | - $row = 1; |
|
| 173 | - foreach ($albums as $album) { |
|
| 174 | - $ret[$row][$col] = $album->toArray(true); |
|
| 175 | - $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 176 | - ++$col; |
|
| 177 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 178 | - ++$row; |
|
| 179 | - $col = 1; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - if (1 != $col) { |
|
| 183 | - $col--; |
|
| 184 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 185 | - $ret[$row][$j][$albumsHandler->keyName] = 0; |
|
| 186 | - $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $url = $albumsHandler->getURL(); |
|
| 191 | - if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 192 | - header('HTTP/1.1 301 Moved Permanently'); |
|
| 193 | - header('Location: ' . $url); |
|
| 194 | - exit(0); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - $GLOBALS['xoopsOption']['template_main'] = 'songlist_albums_index.tpl'; |
|
| 198 | - require_once $GLOBALS['xoops']->path('/header.php'); |
|
| 199 | - if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 200 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 201 | - $GLOBALS['loaded_jquery'] = true; |
|
| 202 | - } |
|
| 203 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 204 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 205 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 206 | - $GLOBALS['xoopsTpl']->assign('results', $ret); |
|
| 207 | - $GLOBALS['xoopsTpl']->assign('songs', false); |
|
| 208 | - $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 209 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 210 | - if (0 != $_SESSION['cid']) { |
|
| 211 | - $category = $categoryHandler->get($_SESSION['cid']); |
|
| 212 | - $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
|
| 213 | - } |
|
| 214 | - $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 215 | - require_once $GLOBALS['xoops']->path('/footer.php'); |
|
| 216 | - break; |
|
| 217 | - break; |
|
| 218 | - case 'category': |
|
| 219 | - switch ($fct) { |
|
| 220 | - default: |
|
| 221 | - case 'set': |
|
| 222 | - $_SESSION['cid'] = $id; |
|
| 223 | - break; |
|
| 224 | - case 'home': |
|
| 225 | - unset($_SESSION['cid']); |
|
| 226 | - break; |
|
| 227 | - } |
|
| 228 | - redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=0&value=%&start=$start&limit=$limit&cid=" . $_SESSION['cid'], 10, _MD_SONGLIST_MSG_CATEGORYCHANGED); |
|
| 54 | + default: |
|
| 55 | + case 'item': |
|
| 56 | + switch ($fct) { |
|
| 57 | + default: |
|
| 58 | + case 'list': |
|
| 59 | + $pagenav = new \XoopsPageNav($albumsHandler->getCount($criteria_cat), $limit, $start, 'start', "op=$op&fct=$fct&id=$id&value=$value&limit=$limit"); |
|
| 60 | + |
|
| 61 | + $criteria_cat->setLimit($limit); |
|
| 62 | + $criteria_cat->setStart($start); |
|
| 63 | + |
|
| 64 | + $albums = $albumsHandler->getObjects($criteria_cat, false); |
|
| 65 | + |
|
| 66 | + $ret = []; |
|
| 67 | + $col = 1; |
|
| 68 | + $row = 1; |
|
| 69 | + foreach ($albums as $album) { |
|
| 70 | + $ret[$row][$col] = $album->toArray(true); |
|
| 71 | + $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 72 | + ++$col; |
|
| 73 | + if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 74 | + ++$row; |
|
| 75 | + $col = 1; |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + if (1 != $col) { |
|
| 79 | + for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 80 | + $ret[$row][$j][$albumsHandler->keyName] = 0; |
|
| 81 | + $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + $url = $albumsHandler->getURL(); |
|
| 86 | + if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 87 | + header('HTTP/1.1 301 Moved Permanently'); |
|
| 88 | + header('Location: ' . $url); |
|
| 89 | + exit(0); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + $GLOBALS['xoopsOption']['template_main'] = 'songlist_albums_index.tpl'; |
|
| 93 | + require_once $GLOBALS['xoops']->path('/header.php'); |
|
| 94 | + if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 95 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 96 | + $GLOBALS['loaded_jquery'] = true; |
|
| 97 | + } |
|
| 98 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 99 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 100 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 101 | + $GLOBALS['xoopsTpl']->assign('results', $ret); |
|
| 102 | + $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 103 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 104 | + $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 105 | + if (0 != $_SESSION['cid']) { |
|
| 106 | + $category = $categoryHandler->get($_SESSION['cid']); |
|
| 107 | + $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
|
| 108 | + } |
|
| 109 | + require_once $GLOBALS['xoops']->path('/footer.php'); |
|
| 110 | + break; |
|
| 111 | + case 'item': |
|
| 112 | + $album = $albumsHandler->get($id); |
|
| 113 | + |
|
| 114 | + $url = $album->getURL(true); |
|
| 115 | + if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 116 | + header('HTTP/1.1 301 Moved Permanently'); |
|
| 117 | + header('Location: ' . $url); |
|
| 118 | + exit(0); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $GLOBALS['xoopsOption']['template_main'] = 'songlist_albums_item.tpl'; |
|
| 122 | + require_once $GLOBALS['xoops']->path('/header.php'); |
|
| 123 | + if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 124 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 125 | + $GLOBALS['loaded_jquery'] = true; |
|
| 126 | + } |
|
| 127 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 128 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 129 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 130 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 131 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 132 | + $GLOBALS['xoopsTpl']->assign('songs', false); |
|
| 133 | + $GLOBALS['xoopsTpl']->assign('album', $album->toArray(true)); |
|
| 134 | + $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 135 | + $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 136 | + require_once $GLOBALS['xoops']->path('/footer.php'); |
|
| 137 | + break; |
|
| 138 | + } |
|
| 139 | + break; |
|
| 140 | + case 'browseby': |
|
| 141 | + switch ($fct) { |
|
| 142 | + default: |
|
| 143 | + case 'title': |
|
| 144 | + case 'lyrics': |
|
| 145 | + case 'artist': |
|
| 146 | + case 'album': |
|
| 147 | + $browse_criteria = new \CriteriaCompo(); |
|
| 148 | + switch ($value) { |
|
| 149 | + case '0': |
|
| 150 | + for ($u = 0; $u < 10; ++$u) { |
|
| 151 | + $browse_criteria->add(new \Criteria('title', $u . '%', 'LIKE'), 'OR'); |
|
| 152 | + } |
|
| 153 | + break; |
|
| 154 | + default: |
|
| 155 | + $browse_criteria->add(new \Criteria('title', \mb_strtoupper($value) . '%', 'LIKE'), 'OR'); |
|
| 156 | + $browse_criteria->add(new \Criteria('title', \mb_strtolower($value) . '%', 'LIKE'), 'OR'); |
|
| 157 | + break; |
|
| 158 | + } |
|
| 159 | + $criteria = new \CriteriaCompo($criteria_cat, 'AND'); |
|
| 160 | + $criteria->add($browse_criteria); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + $pagenav = new \XoopsPageNav($albumsHandler->getCount($criteria), $limit, $start, 'start', "op=$op&fct=$fct&id=$id&value=$value&limit=$limit"); |
|
| 164 | + |
|
| 165 | + $criteria->setLimit($limit); |
|
| 166 | + $criteria->setStart($start); |
|
| 167 | + |
|
| 168 | + $albums = $albumsHandler->getObjects($criteria, false); |
|
| 169 | + |
|
| 170 | + $ret = []; |
|
| 171 | + $col = 1; |
|
| 172 | + $row = 1; |
|
| 173 | + foreach ($albums as $album) { |
|
| 174 | + $ret[$row][$col] = $album->toArray(true); |
|
| 175 | + $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 176 | + ++$col; |
|
| 177 | + if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 178 | + ++$row; |
|
| 179 | + $col = 1; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + if (1 != $col) { |
|
| 183 | + $col--; |
|
| 184 | + for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 185 | + $ret[$row][$j][$albumsHandler->keyName] = 0; |
|
| 186 | + $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $url = $albumsHandler->getURL(); |
|
| 191 | + if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 192 | + header('HTTP/1.1 301 Moved Permanently'); |
|
| 193 | + header('Location: ' . $url); |
|
| 194 | + exit(0); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + $GLOBALS['xoopsOption']['template_main'] = 'songlist_albums_index.tpl'; |
|
| 198 | + require_once $GLOBALS['xoops']->path('/header.php'); |
|
| 199 | + if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 200 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 201 | + $GLOBALS['loaded_jquery'] = true; |
|
| 202 | + } |
|
| 203 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 204 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 205 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 206 | + $GLOBALS['xoopsTpl']->assign('results', $ret); |
|
| 207 | + $GLOBALS['xoopsTpl']->assign('songs', false); |
|
| 208 | + $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 209 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 210 | + if (0 != $_SESSION['cid']) { |
|
| 211 | + $category = $categoryHandler->get($_SESSION['cid']); |
|
| 212 | + $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
|
| 213 | + } |
|
| 214 | + $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 215 | + require_once $GLOBALS['xoops']->path('/footer.php'); |
|
| 216 | + break; |
|
| 217 | + break; |
|
| 218 | + case 'category': |
|
| 219 | + switch ($fct) { |
|
| 220 | + default: |
|
| 221 | + case 'set': |
|
| 222 | + $_SESSION['cid'] = $id; |
|
| 223 | + break; |
|
| 224 | + case 'home': |
|
| 225 | + unset($_SESSION['cid']); |
|
| 226 | + break; |
|
| 227 | + } |
|
| 228 | + redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=0&value=%&start=$start&limit=$limit&cid=" . $_SESSION['cid'], 10, _MD_SONGLIST_MSG_CATEGORYCHANGED); |
|
| 229 | 229 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | use XoopsModules\Songlist\CategoryHandler; |
| 5 | 5 | use XoopsModules\Songlist\AlbumsHandler; |
| 6 | 6 | |
| 7 | -require_once __DIR__ . '/header.php'; |
|
| 7 | +require_once __DIR__.'/header.php'; |
|
| 8 | 8 | |
| 9 | 9 | global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit; |
| 10 | 10 | |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | $categoryHandler = Helper::getInstance()->getHandler('Category'); |
| 13 | 13 | $criteria_cat = new \CriteriaCompo(); |
| 14 | 14 | $cids = $categoryHandler->GetCatAndSubCat($_SESSION['cid']); |
| 15 | -if ($_SESSION['cid'] > 0) { |
|
| 15 | +if ($_SESSION['cid']>0) { |
|
| 16 | 16 | $cids[$_SESSION['cid']] = $_SESSION['cid']; |
| 17 | 17 | } |
| 18 | -if (count($cids) > 0 && 0 != $_SESSION['cid']) { |
|
| 19 | - $criteria_cat->add(new \Criteria('cid', '(' . implode(',', $cids) . ')', 'IN'), 'OR'); |
|
| 18 | +if (count($cids)>0 && 0!=$_SESSION['cid']) { |
|
| 19 | + $criteria_cat->add(new \Criteria('cid', '('.implode(',', $cids).')', 'IN'), 'OR'); |
|
| 20 | 20 | } else { |
| 21 | 21 | $criteria_cat->add(new \Criteria(''), 'OR'); |
| 22 | 22 | } |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | $row = 1; |
| 34 | 34 | foreach ($categories as $category) { |
| 35 | 35 | $cat[$row][$col] = $category->toArray(true); |
| 36 | - $cat[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 36 | + $cat[$row][$col]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 37 | 37 | ++$col; |
| 38 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 38 | + if ($col>$GLOBALS['songlistModuleConfig']['cols']) { |
|
| 39 | 39 | ++$row; |
| 40 | 40 | $col = 1; |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | -if (1 != $col) { |
|
| 43 | +if (1!=$col) { |
|
| 44 | 44 | $col--; |
| 45 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 45 | + for ($j = $col; $j<=$GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 46 | 46 | $cat[$row][$j][$categoryHandler->keyName] = 0; |
| 47 | - $cat[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 47 | + $cat[$row][$j]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -68,41 +68,41 @@ discard block |
||
| 68 | 68 | $row = 1; |
| 69 | 69 | foreach ($albums as $album) { |
| 70 | 70 | $ret[$row][$col] = $album->toArray(true); |
| 71 | - $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 71 | + $ret[$row][$col]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 72 | 72 | ++$col; |
| 73 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 73 | + if ($col>$GLOBALS['songlistModuleConfig']['cols']) { |
|
| 74 | 74 | ++$row; |
| 75 | 75 | $col = 1; |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | - if (1 != $col) { |
|
| 79 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 78 | + if (1!=$col) { |
|
| 79 | + for ($j = $col; $j<=$GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 80 | 80 | $ret[$row][$j][$albumsHandler->keyName] = 0; |
| 81 | - $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 81 | + $ret[$row][$j]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $url = $albumsHandler->getURL(); |
| 86 | 86 | if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
| 87 | 87 | header('HTTP/1.1 301 Moved Permanently'); |
| 88 | - header('Location: ' . $url); |
|
| 88 | + header('Location: '.$url); |
|
| 89 | 89 | exit(0); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $GLOBALS['xoopsOption']['template_main'] = 'songlist_albums_index.tpl'; |
| 93 | 93 | require_once $GLOBALS['xoops']->path('/header.php'); |
| 94 | 94 | if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
| 95 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 95 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL._MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 96 | 96 | $GLOBALS['loaded_jquery'] = true; |
| 97 | 97 | } |
| 98 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 98 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 99 | 99 | $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
| 100 | 100 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
| 101 | 101 | $GLOBALS['xoopsTpl']->assign('results', $ret); |
| 102 | 102 | $GLOBALS['xoopsTpl']->assign('categories', $cat); |
| 103 | 103 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 104 | 104 | $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
| 105 | - if (0 != $_SESSION['cid']) { |
|
| 105 | + if (0!=$_SESSION['cid']) { |
|
| 106 | 106 | $category = $categoryHandler->get($_SESSION['cid']); |
| 107 | 107 | $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
| 108 | 108 | } |
@@ -114,19 +114,19 @@ discard block |
||
| 114 | 114 | $url = $album->getURL(true); |
| 115 | 115 | if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
| 116 | 116 | header('HTTP/1.1 301 Moved Permanently'); |
| 117 | - header('Location: ' . $url); |
|
| 117 | + header('Location: '.$url); |
|
| 118 | 118 | exit(0); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $GLOBALS['xoopsOption']['template_main'] = 'songlist_albums_item.tpl'; |
| 122 | 122 | require_once $GLOBALS['xoops']->path('/header.php'); |
| 123 | 123 | if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
| 124 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 124 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL._MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 125 | 125 | $GLOBALS['loaded_jquery'] = true; |
| 126 | 126 | } |
| 127 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 128 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 129 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 127 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 128 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 129 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 130 | 130 | $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
| 131 | 131 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
| 132 | 132 | $GLOBALS['xoopsTpl']->assign('songs', false); |
@@ -147,13 +147,13 @@ discard block |
||
| 147 | 147 | $browse_criteria = new \CriteriaCompo(); |
| 148 | 148 | switch ($value) { |
| 149 | 149 | case '0': |
| 150 | - for ($u = 0; $u < 10; ++$u) { |
|
| 151 | - $browse_criteria->add(new \Criteria('title', $u . '%', 'LIKE'), 'OR'); |
|
| 150 | + for ($u = 0; $u<10; ++$u) { |
|
| 151 | + $browse_criteria->add(new \Criteria('title', $u.'%', 'LIKE'), 'OR'); |
|
| 152 | 152 | } |
| 153 | 153 | break; |
| 154 | 154 | default: |
| 155 | - $browse_criteria->add(new \Criteria('title', \mb_strtoupper($value) . '%', 'LIKE'), 'OR'); |
|
| 156 | - $browse_criteria->add(new \Criteria('title', \mb_strtolower($value) . '%', 'LIKE'), 'OR'); |
|
| 155 | + $browse_criteria->add(new \Criteria('title', \mb_strtoupper($value).'%', 'LIKE'), 'OR'); |
|
| 156 | + $browse_criteria->add(new \Criteria('title', \mb_strtolower($value).'%', 'LIKE'), 'OR'); |
|
| 157 | 157 | break; |
| 158 | 158 | } |
| 159 | 159 | $criteria = new \CriteriaCompo($criteria_cat, 'AND'); |
@@ -172,42 +172,42 @@ discard block |
||
| 172 | 172 | $row = 1; |
| 173 | 173 | foreach ($albums as $album) { |
| 174 | 174 | $ret[$row][$col] = $album->toArray(true); |
| 175 | - $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 175 | + $ret[$row][$col]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 176 | 176 | ++$col; |
| 177 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 177 | + if ($col>$GLOBALS['songlistModuleConfig']['cols']) { |
|
| 178 | 178 | ++$row; |
| 179 | 179 | $col = 1; |
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | - if (1 != $col) { |
|
| 182 | + if (1!=$col) { |
|
| 183 | 183 | $col--; |
| 184 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 184 | + for ($j = $col; $j<=$GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 185 | 185 | $ret[$row][$j][$albumsHandler->keyName] = 0; |
| 186 | - $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 186 | + $ret[$row][$j]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $url = $albumsHandler->getURL(); |
| 191 | 191 | if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
| 192 | 192 | header('HTTP/1.1 301 Moved Permanently'); |
| 193 | - header('Location: ' . $url); |
|
| 193 | + header('Location: '.$url); |
|
| 194 | 194 | exit(0); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $GLOBALS['xoopsOption']['template_main'] = 'songlist_albums_index.tpl'; |
| 198 | 198 | require_once $GLOBALS['xoops']->path('/header.php'); |
| 199 | 199 | if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
| 200 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 200 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL._MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 201 | 201 | $GLOBALS['loaded_jquery'] = true; |
| 202 | 202 | } |
| 203 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 203 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 204 | 204 | $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
| 205 | 205 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
| 206 | 206 | $GLOBALS['xoopsTpl']->assign('results', $ret); |
| 207 | 207 | $GLOBALS['xoopsTpl']->assign('songs', false); |
| 208 | 208 | $GLOBALS['xoopsTpl']->assign('categories', $cat); |
| 209 | 209 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 210 | - if (0 != $_SESSION['cid']) { |
|
| 210 | + if (0!=$_SESSION['cid']) { |
|
| 211 | 211 | $category = $categoryHandler->get($_SESSION['cid']); |
| 212 | 212 | $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
| 213 | 213 | } |
@@ -225,5 +225,5 @@ discard block |
||
| 225 | 225 | unset($_SESSION['cid']); |
| 226 | 226 | break; |
| 227 | 227 | } |
| 228 | - redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=0&value=%&start=$start&limit=$limit&cid=" . $_SESSION['cid'], 10, _MD_SONGLIST_MSG_CATEGORYCHANGED); |
|
| 228 | + redirect_header($_SERVER['SCRIPT_NAME']."?op=item&fct=list&id=0&value=%&start=$start&limit=$limit&cid=".$_SESSION['cid'], 10, _MD_SONGLIST_MSG_CATEGORYCHANGED); |
|
| 229 | 229 | } |
@@ -13,85 +13,85 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Voice extends XoopsObject |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Voice constructor. |
|
| 18 | - * @param null $fid |
|
| 19 | - */ |
|
| 20 | - public function __construct($fid = null) |
|
| 21 | - { |
|
| 22 | - $this->initVar('vcid', \XOBJ_DTYPE_INT, 0, false); |
|
| 23 | - $this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128); |
|
| 24 | - $this->initVar('artists', \XOBJ_DTYPE_INT, 0, false); |
|
| 25 | - $this->initVar('albums', \XOBJ_DTYPE_INT, 0, false); |
|
| 26 | - $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false); |
|
| 27 | - $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false); |
|
| 28 | - $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false); |
|
| 29 | - $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false); |
|
| 30 | - $this->initVar('created', \XOBJ_DTYPE_INT, 0, false); |
|
| 31 | - $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false); |
|
| 32 | - } |
|
| 16 | + /** |
|
| 17 | + * Voice constructor. |
|
| 18 | + * @param null $fid |
|
| 19 | + */ |
|
| 20 | + public function __construct($fid = null) |
|
| 21 | + { |
|
| 22 | + $this->initVar('vcid', \XOBJ_DTYPE_INT, 0, false); |
|
| 23 | + $this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128); |
|
| 24 | + $this->initVar('artists', \XOBJ_DTYPE_INT, 0, false); |
|
| 25 | + $this->initVar('albums', \XOBJ_DTYPE_INT, 0, false); |
|
| 26 | + $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false); |
|
| 27 | + $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false); |
|
| 28 | + $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false); |
|
| 29 | + $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false); |
|
| 30 | + $this->initVar('created', \XOBJ_DTYPE_INT, 0, false); |
|
| 31 | + $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param bool $as_array |
|
| 36 | - * @return array|string |
|
| 37 | - */ |
|
| 38 | - public function getForm($as_array = false) |
|
| 39 | - { |
|
| 40 | - return FormController::getFormVoice($this, $as_array); |
|
| 41 | - } |
|
| 34 | + /** |
|
| 35 | + * @param bool $as_array |
|
| 36 | + * @return array|string |
|
| 37 | + */ |
|
| 38 | + public function getForm($as_array = false) |
|
| 39 | + { |
|
| 40 | + return FormController::getFormVoice($this, $as_array); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return array |
|
| 45 | - */ |
|
| 46 | - public function toArray(): array |
|
| 47 | - { |
|
| 48 | - $ret = parent::toArray(); |
|
| 49 | - $form = $this->getForm(true); |
|
| 50 | - foreach ($form as $key => $element) { |
|
| 51 | - $ret['form'][$key] = $element->render(); |
|
| 52 | - } |
|
| 53 | - foreach (['created', 'updated'] as $key) { |
|
| 54 | - if ($this->getVar($key) > 0) { |
|
| 55 | - $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key)); |
|
| 56 | - $ret[$key] = \date(_DATESTRING, $this->getVar($key)); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN; |
|
| 43 | + /** |
|
| 44 | + * @return array |
|
| 45 | + */ |
|
| 46 | + public function toArray(): array |
|
| 47 | + { |
|
| 48 | + $ret = parent::toArray(); |
|
| 49 | + $form = $this->getForm(true); |
|
| 50 | + foreach ($form as $key => $element) { |
|
| 51 | + $ret['form'][$key] = $element->render(); |
|
| 52 | + } |
|
| 53 | + foreach (['created', 'updated'] as $key) { |
|
| 54 | + if ($this->getVar($key) > 0) { |
|
| 55 | + $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key)); |
|
| 56 | + $ret[$key] = \date(_DATESTRING, $this->getVar($key)); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN; |
|
| 60 | 60 | |
| 61 | - return $ret; |
|
| 62 | - } |
|
| 61 | + return $ret; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @return string |
|
| 66 | - */ |
|
| 67 | - public function getURL(): string |
|
| 68 | - { |
|
| 69 | - global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit; |
|
| 70 | - if ($GLOBALS['songlistModuleConfig']['htaccess']) { |
|
| 71 | - return XOOPS_URL |
|
| 72 | - . '/' |
|
| 73 | - . $GLOBALS['songlistModuleConfig']['baseurl'] |
|
| 74 | - . '/' |
|
| 75 | - . $file |
|
| 76 | - . '/' |
|
| 77 | - . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('name'))) |
|
| 78 | - . '/' |
|
| 79 | - . $op |
|
| 80 | - . '-' |
|
| 81 | - . $fct |
|
| 82 | - . '-' |
|
| 83 | - . $this->getVar('gid') |
|
| 84 | - . '-' |
|
| 85 | - . \urlencode($value) |
|
| 86 | - . '-' |
|
| 87 | - . $gid |
|
| 88 | - . '-' |
|
| 89 | - . $vid |
|
| 90 | - . '-' |
|
| 91 | - . $cid |
|
| 92 | - . $GLOBALS['songlistModuleConfig']['endofurl']; |
|
| 93 | - } |
|
| 64 | + /** |
|
| 65 | + * @return string |
|
| 66 | + */ |
|
| 67 | + public function getURL(): string |
|
| 68 | + { |
|
| 69 | + global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit; |
|
| 70 | + if ($GLOBALS['songlistModuleConfig']['htaccess']) { |
|
| 71 | + return XOOPS_URL |
|
| 72 | + . '/' |
|
| 73 | + . $GLOBALS['songlistModuleConfig']['baseurl'] |
|
| 74 | + . '/' |
|
| 75 | + . $file |
|
| 76 | + . '/' |
|
| 77 | + . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('name'))) |
|
| 78 | + . '/' |
|
| 79 | + . $op |
|
| 80 | + . '-' |
|
| 81 | + . $fct |
|
| 82 | + . '-' |
|
| 83 | + . $this->getVar('gid') |
|
| 84 | + . '-' |
|
| 85 | + . \urlencode($value) |
|
| 86 | + . '-' |
|
| 87 | + . $gid |
|
| 88 | + . '-' |
|
| 89 | + . $vid |
|
| 90 | + . '-' |
|
| 91 | + . $cid |
|
| 92 | + . $GLOBALS['songlistModuleConfig']['endofurl']; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $this->getVar('gid') . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid; |
|
| 96 | - } |
|
| 95 | + return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $this->getVar('gid') . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid; |
|
| 96 | + } |
|
| 97 | 97 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use XoopsObject; |
| 6 | 6 | |
| 7 | -require_once \dirname(__DIR__) . '/include/songlist.object.php'; |
|
| 7 | +require_once \dirname(__DIR__).'/include/songlist.object.php'; |
|
| 8 | 8 | // require_once \dirname(__DIR__) . '/include/songlist.form.php'; |
| 9 | 9 | use XoopsModules\Songlist\Form\FormController; |
| 10 | 10 | |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | $ret['form'][$key] = $element->render(); |
| 52 | 52 | } |
| 53 | 53 | foreach (['created', 'updated'] as $key) { |
| 54 | - if ($this->getVar($key) > 0) { |
|
| 54 | + if ($this->getVar($key)>0) { |
|
| 55 | 55 | $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key)); |
| 56 | 56 | $ret[$key] = \date(_DATESTRING, $this->getVar($key)); |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | - $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN; |
|
| 59 | + $ret['rank'] = \number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2).\_MI_SONGLIST_OFTEN; |
|
| 60 | 60 | |
| 61 | 61 | return $ret; |
| 62 | 62 | } |
@@ -92,6 +92,6 @@ discard block |
||
| 92 | 92 | . $GLOBALS['songlistModuleConfig']['endofurl']; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $this->getVar('gid') . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid; |
|
| 95 | + return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$this->getVar('gid').'&value='.\urlencode($value ?? '').'&gid='.$gid.'&vid='.$vid.'&cid='.$cid; |
|
| 96 | 96 | } |
| 97 | 97 | } |
@@ -4,11 +4,11 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Xmf\Request; |
| 6 | 6 | use XoopsModules\Songlist\Form\{ |
| 7 | - SelectAlbumForm, |
|
| 8 | - SelectCategoryForm, |
|
| 9 | - SelectGenreForm, |
|
| 10 | - SelectVoiceForm, |
|
| 11 | - SelectSongForm |
|
| 7 | + SelectAlbumForm, |
|
| 8 | + SelectCategoryForm, |
|
| 9 | + SelectGenreForm, |
|
| 10 | + SelectVoiceForm, |
|
| 11 | + SelectSongForm |
|
| 12 | 12 | }; |
| 13 | 13 | |
| 14 | 14 | |
@@ -18,789 +18,789 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Utility extends Common\SysUtility |
| 20 | 20 | { |
| 21 | - //--------------- Custom module methods ----------------------------- |
|
| 22 | - /** |
|
| 23 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
| 24 | - * |
|
| 25 | - * @param string $folder The full path of the directory to check |
|
| 26 | - */ |
|
| 27 | - public static function createFolder($folder): void |
|
| 28 | - { |
|
| 29 | - // try { |
|
| 30 | - // if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) { |
|
| 31 | - // throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
| 32 | - // } else { |
|
| 33 | - // file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
| 34 | - // } |
|
| 35 | - // } |
|
| 36 | - // catch (\Exception $e) { |
|
| 37 | - // echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
| 38 | - // } |
|
| 39 | - try { |
|
| 40 | - if (!\is_dir($folder)) { |
|
| 41 | - if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { |
|
| 42 | - throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); |
|
| 43 | - } |
|
| 44 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
| 45 | - } |
|
| 46 | - } catch (\Throwable $e) { |
|
| 47 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @param string $file |
|
| 53 | - * @param string $folder |
|
| 54 | - * @return bool |
|
| 55 | - */ |
|
| 56 | - public static function copyFile(string $file, string $folder): bool |
|
| 57 | - { |
|
| 58 | - return \copy($file, $folder); |
|
| 59 | - // try { |
|
| 60 | - // if (!is_dir($folder)) { |
|
| 61 | - // throw new \RuntimeException(sprintf('Unable to copy file as: %s ', $folder)); |
|
| 62 | - // } else { |
|
| 63 | - // return copy($file, $folder); |
|
| 64 | - // } |
|
| 65 | - // } catch (\Exception $e) { |
|
| 66 | - // echo 'Caught exception: ', $e->getMessage(), "\n", "<br>"; |
|
| 67 | - // } |
|
| 68 | - // return false; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @param $src |
|
| 73 | - * @param $dst |
|
| 74 | - */ |
|
| 75 | - public static function recurseCopy($src, $dst): void |
|
| 76 | - { |
|
| 77 | - $dir = \opendir($src); |
|
| 78 | - // @mkdir($dst); |
|
| 79 | - while (false !== ($file = \readdir($dir))) { |
|
| 80 | - if (('.' !== $file) && ('..' !== $file)) { |
|
| 81 | - if (\is_dir($src . '/' . $file)) { |
|
| 82 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
| 83 | - } else { |
|
| 84 | - \copy($src . '/' . $file, $dst . '/' . $file); |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - \closedir($dir); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Verifies XOOPS version meets minimum requirements for this module |
|
| 93 | - * @static |
|
| 94 | - * @param \XoopsModule|null $module |
|
| 95 | - * |
|
| 96 | - * @param null|string $requiredVer |
|
| 97 | - * @return bool true if meets requirements, false if not |
|
| 98 | - */ |
|
| 99 | - public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null): bool |
|
| 100 | - { |
|
| 101 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 102 | - if (null === $module) { |
|
| 103 | - $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 104 | - } |
|
| 105 | - \xoops_loadLanguage('admin', $moduleDirName); |
|
| 106 | - \xoops_loadLanguage('common', $moduleDirName); |
|
| 107 | - |
|
| 108 | - //check for minimum XOOPS version |
|
| 109 | - $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string |
|
| 110 | - if (null === $requiredVer) { |
|
| 111 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
| 112 | - } |
|
| 113 | - $success = true; |
|
| 114 | - |
|
| 115 | - if (\version_compare($currentVer, $requiredVer, '<')) { |
|
| 116 | - $success = false; |
|
| 117 | - $module->setErrors(\sprintf(\_AM_SONGLIST_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - return $success; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Verifies PHP version meets minimum requirements for this module |
|
| 125 | - * @static |
|
| 126 | - * @param \XoopsModule|bool|null $module |
|
| 127 | - * |
|
| 128 | - * @return bool true if meets requirements, false if not |
|
| 129 | - */ |
|
| 130 | - public static function checkVerPhp(\XoopsModule $module = null): bool |
|
| 131 | - { |
|
| 132 | - $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
| 133 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 134 | - if (null === $module) { |
|
| 135 | - $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 136 | - } |
|
| 137 | - \xoops_loadLanguage('admin', $moduleDirName); |
|
| 138 | - \xoops_loadLanguage('common', $moduleDirName); |
|
| 139 | - |
|
| 140 | - // check for minimum PHP version |
|
| 141 | - $success = true; |
|
| 142 | - |
|
| 143 | - $verNum = \PHP_VERSION; |
|
| 144 | - $reqVer = &$module->getInfo('min_php'); |
|
| 145 | - |
|
| 146 | - if (false !== $reqVer && '' !== $reqVer) { |
|
| 147 | - if (\version_compare($verNum, $reqVer, '<')) { |
|
| 148 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
| 149 | - $success = false; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - return $success; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * compares current module version with the latest GitHub release |
|
| 158 | - * @static |
|
| 159 | - * |
|
| 160 | - * @return string|array info about the latest module version, if newer |
|
| 161 | - */ |
|
| 162 | - public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array |
|
| 163 | - { |
|
| 164 | - $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
| 165 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 166 | - $update = ''; |
|
| 167 | - $repository = 'XoopsModules25x/' . $moduleDirName; |
|
| 168 | - // $repository = 'XoopsModules25x/publisher'; //for testing only |
|
| 169 | - $ret = null; |
|
| 170 | - $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; |
|
| 171 | - if ('github' === $source) { |
|
| 172 | - if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { |
|
| 173 | - \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); |
|
| 174 | - \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); |
|
| 175 | - \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' |
|
| 176 | - \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); |
|
| 177 | - $curlReturn = \curl_exec($curlHandle); |
|
| 178 | - if (false === $curlReturn) { |
|
| 179 | - \trigger_error(\curl_error($curlHandle)); |
|
| 180 | - } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { |
|
| 181 | - \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
| 182 | - } else { |
|
| 183 | - $file = json_decode($curlReturn, false); |
|
| 184 | - $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); |
|
| 185 | - $latestVersion = $file[0]->tag_name; |
|
| 186 | - $prerelease = $file[0]->prerelease; |
|
| 187 | - if ('master' !== $latestVersionLink) { |
|
| 188 | - $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
| 189 | - } |
|
| 190 | - //"PHP-standardized" version |
|
| 191 | - $latestVersion = \mb_strtolower($latestVersion); |
|
| 192 | - if (false !== mb_strpos($latestVersion, 'final')) { |
|
| 193 | - $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); |
|
| 194 | - $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); |
|
| 195 | - } |
|
| 196 | - $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); |
|
| 197 | - //"PHP-standardized" version |
|
| 198 | - $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); |
|
| 199 | - // $moduleVersion = '1.0'; //for testing only |
|
| 200 | - // $moduleDirName = 'publisher'; //for testing only |
|
| 201 | - if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { |
|
| 202 | - $ret = []; |
|
| 203 | - $ret[] = $update; |
|
| 204 | - $ret[] = $latestVersionLink; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - \curl_close($curlHandle); |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - return $ret; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - //========================================================= |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * @return mixed |
|
| 218 | - */ |
|
| 219 | - public static function getToken() |
|
| 220 | - { |
|
| 221 | - $sql = 'SELECT md5(rand()/rand()*rand()/rand()*rand()*rand()/rand()*rand()) as `salt`'; |
|
| 222 | - $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
| 223 | - [$salt] = $GLOBALS['xoopsDB']->fetchRow($result); |
|
| 224 | - |
|
| 225 | - return $salt; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * @param $string |
|
| 230 | - * @return string |
|
| 231 | - */ |
|
| 232 | - public static function ucword($string): string |
|
| 233 | - { |
|
| 234 | - $ret = []; |
|
| 235 | - foreach (explode(' ', \mb_strtolower($string)) as $part) { |
|
| 236 | - $ret[] = ucfirst($part); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - return implode(' ', $ret); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * @param bool|string $ip |
|
| 244 | - * @return array |
|
| 245 | - */ |
|
| 246 | - public static function getIPData($ip = false): array |
|
| 247 | - { |
|
| 248 | - $ret = []; |
|
| 249 | - if (is_object($GLOBALS['xoopsUser'])) { |
|
| 250 | - $ret['uid'] = $GLOBALS['xoopsUser']->getVar('uid'); |
|
| 251 | - $ret['uname'] = $GLOBALS['xoopsUser']->getVar('uname'); |
|
| 252 | - $ret['email'] = $GLOBALS['xoopsUser']->getVar('email'); |
|
| 253 | - } else { |
|
| 254 | - $ret['uid'] = 0; |
|
| 255 | - $ret['uname'] = ($_REQUEST['uname'] ?? ''); |
|
| 256 | - $ret['email'] = ($_REQUEST['email'] ?? ''); |
|
| 257 | - } |
|
| 258 | - $ret['agent'] = $_SERVER['HTTP_USER_AGENT']; |
|
| 259 | - if ($ip) { |
|
| 260 | - $ret['is_proxied'] = false; |
|
| 261 | - $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 262 | - $ret['long'] = @ip2long($ip); |
|
| 263 | - if (isIpv6($ip)) { |
|
| 264 | - $ret['ip6'] = true; |
|
| 265 | - $ret['ip4'] = false; |
|
| 266 | - } else { |
|
| 267 | - $ret['ip4'] = true; |
|
| 268 | - $ret['ip6'] = false; |
|
| 269 | - } |
|
| 270 | - $ret['ip'] = $ip; |
|
| 271 | - } elseif (Request::hasVar('HTTP_X_FORWARDED_FOR', 'SERVER')) { |
|
| 272 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 273 | - $ret['is_proxied'] = true; |
|
| 274 | - $proxy_ip = $_SERVER['REMOTE_ADDR']; |
|
| 275 | - $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 276 | - $ret['long'] = @ip2long($ip); |
|
| 277 | - if (isIpv6($ip)) { |
|
| 278 | - $ret['ip6'] = true; |
|
| 279 | - $ret['proxy-ip6'] = true; |
|
| 280 | - $ret['ip4'] = false; |
|
| 281 | - $ret['proxy-ip4'] = false; |
|
| 282 | - } else { |
|
| 283 | - $ret['ip4'] = true; |
|
| 284 | - $ret['proxy-ip4'] = true; |
|
| 285 | - $ret['ip6'] = false; |
|
| 286 | - $ret['proxy-ip6'] = false; |
|
| 287 | - } |
|
| 288 | - $ret['ip'] = $ip; |
|
| 289 | - $ret['proxy-ip'] = $proxy_ip; |
|
| 290 | - } else { |
|
| 291 | - $ret['is_proxied'] = false; |
|
| 292 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 293 | - $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 294 | - $ret['long'] = @ip2long($ip); |
|
| 295 | - if (isIpv6($ip)) { |
|
| 296 | - $ret['ip6'] = true; |
|
| 297 | - $ret['ip4'] = false; |
|
| 298 | - } else { |
|
| 299 | - $ret['ip4'] = true; |
|
| 300 | - $ret['ip6'] = false; |
|
| 301 | - } |
|
| 302 | - $ret['ip'] = $ip; |
|
| 303 | - } |
|
| 304 | - $ret['made'] = time(); |
|
| 305 | - |
|
| 306 | - return $ret; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * @param string $ip |
|
| 311 | - * @return bool |
|
| 312 | - */ |
|
| 313 | - public static function isIpv6($ip = ''): bool |
|
| 314 | - { |
|
| 315 | - if ('' == $ip) { |
|
| 316 | - return false; |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - if (mb_substr_count($ip, ':') > 0) { |
|
| 320 | - return true; |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - return false; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * @param $filter |
|
| 328 | - * @param $field |
|
| 329 | - * @param string $sort |
|
| 330 | - * @param string $op |
|
| 331 | - * @param string $fct |
|
| 332 | - * @return bool|\XoopsModules\Songlist\Form\SelectAlbumForm|\XoopsModules\Songlist\Form\SelectArtistForm|\XoopsModules\Songlist\Form\SelectCategoryForm|\XoopsModules\Songlist\Form\SelectGenreForm|\XoopsModules\Songlist\Form\SelectVoiceForm |
|
| 333 | - */ |
|
| 334 | - public static function getFilterElement($filter, $field, $sort = 'created', $op = '', $fct = '') |
|
| 335 | - { |
|
| 336 | - $components = static::getFilterURLComponents($filter, $field, $sort); |
|
| 337 | - $ele = false; |
|
| 338 | - require_once dirname(__DIR__) . '/include/songlist.object.php'; |
|
| 339 | - switch ($field) { |
|
| 340 | - case 'gid': |
|
| 341 | - if ('genre' !== $op) { |
|
| 342 | - $ele = new SelectGenreForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 343 | - $ele->setExtra( |
|
| 344 | - 'onchange="window.open(\'' |
|
| 345 | - . $_SERVER['SCRIPT_NAME'] |
|
| 346 | - . '?' |
|
| 347 | - . $components['extra'] |
|
| 348 | - . '&filter=' |
|
| 349 | - . $components['filter'] |
|
| 350 | - . (!empty($components['filter']) ? '|' : '') |
|
| 351 | - . $field |
|
| 352 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 353 | - . (!empty($components['operator']) ? '+\',' |
|
| 354 | - . $components['operator'] |
|
| 355 | - . '\'' : '') |
|
| 356 | - . ',\'_self\')"' |
|
| 357 | - ); |
|
| 358 | - } |
|
| 359 | - break; |
|
| 360 | - case 'vcid': |
|
| 361 | - if ('voice' !== $op) { |
|
| 362 | - $ele = new SelectVoiceForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 363 | - $ele->setExtra( |
|
| 364 | - 'onchange="window.open(\'' |
|
| 365 | - . $_SERVER['SCRIPT_NAME'] |
|
| 366 | - . '?' |
|
| 367 | - . $components['extra'] |
|
| 368 | - . '&filter=' |
|
| 369 | - . $components['filter'] |
|
| 370 | - . (!empty($components['filter']) ? '|' : '') |
|
| 371 | - . $field |
|
| 372 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 373 | - . (!empty($components['operator']) ? '+\',' |
|
| 374 | - . $components['operator'] |
|
| 375 | - . '\'' : '') |
|
| 376 | - . ',\'_self\')"' |
|
| 377 | - ); |
|
| 378 | - } |
|
| 379 | - break; |
|
| 380 | - case 'cid': |
|
| 381 | - if ('category' !== $op) { |
|
| 382 | - $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 383 | - $ele->setExtra( |
|
| 384 | - 'onchange="window.open(\'' |
|
| 385 | - . $_SERVER['SCRIPT_NAME'] |
|
| 386 | - . '?' |
|
| 387 | - . $components['extra'] |
|
| 388 | - . '&filter=' |
|
| 389 | - . $components['filter'] |
|
| 390 | - . (!empty($components['filter']) ? '|' : '') |
|
| 391 | - . $field |
|
| 392 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 393 | - . (!empty($components['operator']) ? '+\',' |
|
| 394 | - . $components['operator'] |
|
| 395 | - . '\'' : '') |
|
| 396 | - . ',\'_self\')"' |
|
| 397 | - ); |
|
| 398 | - } |
|
| 399 | - break; |
|
| 400 | - case 'pid': |
|
| 401 | - $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 402 | - $ele->setExtra( |
|
| 403 | - 'onchange="window.open(\'' |
|
| 404 | - . $_SERVER['SCRIPT_NAME'] |
|
| 405 | - . '?' |
|
| 406 | - . $components['extra'] |
|
| 407 | - . '&filter=' |
|
| 408 | - . $components['filter'] |
|
| 409 | - . (!empty($components['filter']) ? '|' : '') |
|
| 410 | - . $field |
|
| 411 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 412 | - . (!empty($components['operator']) ? '+\',' |
|
| 413 | - . $components['operator'] |
|
| 414 | - . '\'' : '') |
|
| 415 | - . ',\'_self\')"' |
|
| 416 | - ); |
|
| 417 | - break; |
|
| 418 | - case 'abid': |
|
| 419 | - if ('albums' !== $op) { |
|
| 420 | - $ele = new SelectAlbumForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 421 | - $ele->setExtra( |
|
| 422 | - 'onchange="window.open(\'' |
|
| 423 | - . $_SERVER['SCRIPT_NAME'] |
|
| 424 | - . '?' |
|
| 425 | - . $components['extra'] |
|
| 426 | - . '&filter=' |
|
| 427 | - . $components['filter'] |
|
| 428 | - . (!empty($components['filter']) ? '|' : '') |
|
| 429 | - . $field |
|
| 430 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 431 | - . (!empty($components['operator']) ? '+\',' |
|
| 432 | - . $components['operator'] |
|
| 433 | - . '\'' : '') |
|
| 434 | - . ',\'_self\')"' |
|
| 435 | - ); |
|
| 436 | - } |
|
| 437 | - break; |
|
| 438 | - case 'aid': |
|
| 439 | - if ('artists' !== $op) { |
|
| 440 | - $ele = new SelectArtistForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 441 | - $ele->setExtra( |
|
| 442 | - 'onchange="window.open(\'' |
|
| 443 | - . $_SERVER['SCRIPT_NAME'] |
|
| 444 | - . '?' |
|
| 445 | - . $components['extra'] |
|
| 446 | - . '&filter=' |
|
| 447 | - . $components['filter'] |
|
| 448 | - . (!empty($components['filter']) ? '|' : '') |
|
| 449 | - . $field |
|
| 450 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 451 | - . (!empty($components['operator']) ? '+\',' |
|
| 452 | - . $components['operator'] |
|
| 453 | - . '\'' : '') |
|
| 454 | - . ',\'_self\')"' |
|
| 455 | - ); |
|
| 456 | - } |
|
| 457 | - break; |
|
| 458 | - case 'sid': |
|
| 459 | - if ('songs' !== $op) { |
|
| 460 | - $ele = new SelectSongForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 461 | - $ele->setExtra( |
|
| 462 | - 'onchange="window.open(\'' |
|
| 463 | - . $_SERVER['SCRIPT_NAME'] |
|
| 464 | - . '?' |
|
| 465 | - . $components['extra'] |
|
| 466 | - . '&filter=' |
|
| 467 | - . $components['filter'] |
|
| 468 | - . (!empty($components['filter']) ? '|' : '') |
|
| 469 | - . $field |
|
| 470 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 471 | - . (!empty($components['operator']) ? '+\',' |
|
| 472 | - . $components['operator'] |
|
| 473 | - . '\'' : '') |
|
| 474 | - . ',\'_self\')"' |
|
| 475 | - ); |
|
| 476 | - } |
|
| 477 | - break; |
|
| 478 | - case 'name': |
|
| 479 | - case 'title': |
|
| 480 | - case 'artists': |
|
| 481 | - case 'albums': |
|
| 482 | - case 'songs': |
|
| 483 | - case 'hits': |
|
| 484 | - case 'rank': |
|
| 485 | - case 'votes': |
|
| 486 | - case 'description': |
|
| 487 | - case 'lyrics': |
|
| 488 | - case 'songid': |
|
| 489 | - case 'tags': |
|
| 490 | - $ele = new \XoopsFormElementTray(''); |
|
| 491 | - $ele->addElement(new \XoopsFormText('', 'filter_' . $field . '', 11, 40, $components['value'])); |
|
| 492 | - $button = new \XoopsFormButton('', 'button_' . $field . '', '[+]'); |
|
| 493 | - $button->setExtra( |
|
| 494 | - 'onclick="window.open(\'' |
|
| 495 | - . $_SERVER['SCRIPT_NAME'] |
|
| 496 | - . '?' |
|
| 497 | - . $components['extra'] |
|
| 498 | - . '&filter=' |
|
| 499 | - . $components['filter'] |
|
| 500 | - . (!empty($components['filter']) ? '|' : '') |
|
| 501 | - . $field |
|
| 502 | - . ',\'+$(\'#filter_' |
|
| 503 | - . $field |
|
| 504 | - . '\').val()' |
|
| 505 | - . (!empty($components['operator']) ? '+\',' |
|
| 506 | - . $components['operator'] |
|
| 507 | - . '\'' : '') |
|
| 508 | - . ',\'_self\')"' |
|
| 509 | - ); |
|
| 510 | - $ele->addElement($button); |
|
| 511 | - break; |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - return $ele; |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - /** |
|
| 518 | - * @param $filter |
|
| 519 | - * @param $field |
|
| 520 | - * @param string $sort |
|
| 521 | - * @return array |
|
| 522 | - */ |
|
| 523 | - public static function getFilterURLComponents($filter, $field, $sort = 'created'): array |
|
| 524 | - { |
|
| 525 | - $parts = explode('|', $filter); |
|
| 526 | - $ret = []; |
|
| 527 | - $value = ''; |
|
| 528 | - $ele_value = ''; |
|
| 529 | - $operator = ''; |
|
| 530 | - foreach ($parts as $part) { |
|
| 531 | - $var = explode(',', $part); |
|
| 532 | - if (count($var) > 1) { |
|
| 533 | - if ($var[0] == $field) { |
|
| 534 | - $ele_value = $var[1]; |
|
| 535 | - if (isset($var[2])) { |
|
| 536 | - $operator = $var[2]; |
|
| 537 | - } |
|
| 538 | - } elseif (1 != $var[0]) { |
|
| 539 | - $ret[] = implode(',', $var); |
|
| 540 | - } |
|
| 541 | - } |
|
| 542 | - } |
|
| 543 | - $pagenav = []; |
|
| 544 | - $pagenav['op'] = $_REQUEST['op'] ?? 'videos'; |
|
| 545 | - $pagenav['fct'] = $_REQUEST['fct'] ?? 'list'; |
|
| 546 | - $pagenav['limit'] = Request::getInt('limit', 30, 'REQUEST'); |
|
| 547 | - $pagenav['start'] = 0; |
|
| 548 | - $pagenav['order'] = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
|
| 549 | - $pagenav['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : $sort; |
|
| 550 | - $retb = []; |
|
| 551 | - foreach ($pagenav as $key => $value) { |
|
| 552 | - $retb[] = "$key=$value"; |
|
| 553 | - } |
|
| 554 | - |
|
| 555 | - return ['value' => $ele_value, 'field' => $field, 'operator' => $operator, 'filter' => implode('|', $ret), 'extra' => implode('&', $retb)]; |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - /** |
|
| 559 | - * @param $objects |
|
| 560 | - * @return array |
|
| 561 | - */ |
|
| 562 | - public static function obj2array($objects): array |
|
| 563 | - { |
|
| 564 | - $ret = []; |
|
| 565 | - foreach ((array)$objects as $key => $value) { |
|
| 566 | - if (is_a($value, 'stdClass')) { |
|
| 567 | - $ret[$key] = static::obj2array($value); |
|
| 568 | - } elseif (is_array($value)) { |
|
| 569 | - $ret[$key] = static::obj2array($value); |
|
| 570 | - } else { |
|
| 571 | - $ret[$key] = $value; |
|
| 572 | - } |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - return $ret; |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - /** |
|
| 579 | - * @param $url |
|
| 580 | - * @return mixed |
|
| 581 | - */ |
|
| 582 | - public static function shortenUrl($url) |
|
| 583 | - { |
|
| 584 | - /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 585 | - $moduleHandler = xoops_getHandler('module'); |
|
| 586 | - /** @var \XoopsConfigHandler $configHandler */ |
|
| 587 | - $configHandler = xoops_getHandler('config'); |
|
| 588 | - $GLOBALS['songlistModule'] = $moduleHandler->getByDirname('songlist'); |
|
| 589 | - $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
|
| 590 | - |
|
| 591 | - if (!empty($GLOBALS['songlistModuleConfig']['bitly_username']) && !empty($GLOBALS['songlistModuleConfig']['bitly_apikey'])) { |
|
| 592 | - $source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'] . '/shorten?login=' . $GLOBALS['songlistModuleConfig']['bitly_username'] . '&apiKey=' . $GLOBALS['songlistModuleConfig']['bitly_apikey'] . '&format=json&longUrl=' . urlencode($url); |
|
| 593 | - $cookies = XOOPS_ROOT_PATH . '/uploads/songlist_' . md5($GLOBALS['songlistModuleConfig']['bitly_apikey']) . '.cookie'; |
|
| 594 | - if (!$ch = curl_init($source_url)) { |
|
| 595 | - return $url; |
|
| 596 | - } |
|
| 597 | - curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); |
|
| 598 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 599 | - curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['songlistModuleConfig']['user_agent']); |
|
| 600 | - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $GLOBALS['songlistModuleConfig']['curl_connect_timeout']); |
|
| 601 | - curl_setopt($ch, CURLOPT_TIMEOUT, $GLOBALS['songlistModuleConfig']['curl_timeout']); |
|
| 602 | - $data = curl_exec($ch); |
|
| 603 | - curl_close($ch); |
|
| 604 | - $result = songlist_object2array(json_decode($data)); |
|
| 605 | - $result['status_code'] = 200; |
|
| 606 | - if ($result['status_code']) { |
|
| 607 | - if (!empty($result['data']['url'])) { |
|
| 608 | - return $result['data']['url']; |
|
| 609 | - } |
|
| 610 | - |
|
| 611 | - return $url; |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - return $url; |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - return $url; |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * @param $contents |
|
| 622 | - * @param int $get_attributes |
|
| 623 | - * @param string $priority |
|
| 624 | - * @return array|void |
|
| 625 | - */ |
|
| 626 | - public static function xml2array($contents, $get_attributes = 1, $priority = 'tag') |
|
| 627 | - { |
|
| 628 | - if (!$contents) { |
|
| 629 | - return []; |
|
| 630 | - } |
|
| 631 | - |
|
| 632 | - if (!function_exists('xml_parser_create')) { |
|
| 633 | - return []; |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - //Get the XML parser of PHP - PHP must have this module for the parser to work |
|
| 637 | - $parser = xml_parser_create(''); |
|
| 638 | - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); # https://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
| 639 | - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 640 | - xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
| 641 | - xml_parse_into_struct($parser, trim($contents), $xml_values); |
|
| 642 | - xml_parser_free($parser); |
|
| 643 | - |
|
| 644 | - if (!$xml_values) { |
|
| 645 | - return; |
|
| 646 | - }//Hmm... |
|
| 647 | - |
|
| 648 | - //Initializations |
|
| 649 | - $xml_array = []; |
|
| 650 | - $parents = []; |
|
| 651 | - $opened_tags = []; |
|
| 652 | - $arr = []; |
|
| 653 | - |
|
| 654 | - $current = &$xml_array; //Refference |
|
| 655 | - |
|
| 656 | - //Go through the tags. |
|
| 657 | - $repeated_tag_index = []; //Multiple tags with same name will be turned into an array |
|
| 658 | - foreach ($xml_values as $data) { |
|
| 659 | - unset($attributes, $value); //Remove existing values, or there will be trouble |
|
| 660 | - |
|
| 661 | - //This command will extract these variables into the foreach scope |
|
| 662 | - // tag(string), type(string), level(int), attributes(array). |
|
| 663 | - extract($data); //We could use the array by itself, but this cooler. |
|
| 664 | - |
|
| 665 | - $result = []; |
|
| 666 | - $attributes_data = []; |
|
| 667 | - |
|
| 668 | - if (isset($value)) { |
|
| 669 | - if ('tag' === $priority) { |
|
| 670 | - $result = $value; |
|
| 671 | - } else { |
|
| 672 | - $result['value'] = $value; |
|
| 673 | - } //Put the value in a assoc array if we are in the 'Attribute' mode |
|
| 674 | - } |
|
| 675 | - |
|
| 676 | - //Set the attributes too. |
|
| 677 | - if (isset($attributes) and $get_attributes) { |
|
| 678 | - foreach ($attributes as $attr => $val) { |
|
| 679 | - if ('tag' === $priority) { |
|
| 680 | - $attributes_data[$attr] = $val; |
|
| 681 | - } else { |
|
| 682 | - $result['attr'][$attr] = $val; |
|
| 683 | - } //Set all the attributes in a array called 'attr' |
|
| 684 | - } |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - //See tag status and do the needed. |
|
| 688 | - if ('open' === $type) {//The starting of the tag '<tag>' |
|
| 689 | - $parent[$level - 1] = &$current; |
|
| 690 | - if (!is_array($current) or (!array_key_exists($tag, $current))) { //Insert New tag |
|
| 691 | - $current[$tag] = $result; |
|
| 692 | - if ($attributes_data) { |
|
| 693 | - $current[$tag . '_attr'] = $attributes_data; |
|
| 694 | - } |
|
| 695 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 696 | - |
|
| 697 | - $current = &$current[$tag]; |
|
| 698 | - } else { //There was another element with the same tag name |
|
| 699 | - if (isset($current[$tag][0])) {//If there is a 0th element it is already an array |
|
| 700 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 701 | - $repeated_tag_index[$tag . '_' . $level]++; |
|
| 702 | - } else {//This section will make the value an array if multiple tags with the same name appear together |
|
| 703 | - $current[$tag] = [$current[$tag], $result]; //This will combine the existing item and the new item together to make an array |
|
| 704 | - $repeated_tag_index[$tag . '_' . $level] = 2; |
|
| 705 | - |
|
| 706 | - if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 707 | - $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 708 | - unset($current[$tag . '_attr']); |
|
| 709 | - } |
|
| 710 | - } |
|
| 711 | - $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; |
|
| 712 | - $current = &$current[$tag][$last_item_index]; |
|
| 713 | - } |
|
| 714 | - } elseif ('complete' === $type) { //Tags that ends in 1 line '<tag>' |
|
| 715 | - //See if the key is already taken. |
|
| 716 | - if (isset($current[$tag])) { //If taken, put all things inside a list(array) |
|
| 717 | - if (isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... |
|
| 718 | - // ...push the new element into that array. |
|
| 719 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 720 | - |
|
| 721 | - if ('tag' === $priority and $get_attributes and $attributes_data) { |
|
| 722 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 723 | - } |
|
| 724 | - $repeated_tag_index[$tag . '_' . $level]++; |
|
| 725 | - } else { //If it is not an array... |
|
| 726 | - $current[$tag] = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value |
|
| 727 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 728 | - if ('tag' === $priority and $get_attributes) { |
|
| 729 | - if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 730 | - $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 731 | - unset($current[$tag . '_attr']); |
|
| 732 | - } |
|
| 733 | - |
|
| 734 | - if ($attributes_data) { |
|
| 735 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 736 | - } |
|
| 737 | - } |
|
| 738 | - $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken |
|
| 739 | - } |
|
| 740 | - } else { //New Key |
|
| 741 | - $current[$tag] = $result; |
|
| 742 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 743 | - if ('tag' === $priority and $attributes_data) { |
|
| 744 | - $current[$tag . '_attr'] = $attributes_data; |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - } elseif ('close' === $type) { //End of tag '</tag>' |
|
| 748 | - $current = &$parent[$level - 1]; |
|
| 749 | - } |
|
| 750 | - } |
|
| 751 | - |
|
| 752 | - return $xml_array; |
|
| 753 | - } |
|
| 754 | - |
|
| 755 | - /** |
|
| 756 | - * @param $array |
|
| 757 | - * @param $name |
|
| 758 | - * @param $standalone |
|
| 759 | - * @param $beginning |
|
| 760 | - * @param $nested |
|
| 761 | - * @return string |
|
| 762 | - */ |
|
| 763 | - public static function toXml($array, $name, $standalone, $beginning, $nested): string |
|
| 764 | - { |
|
| 765 | - $output = ''; |
|
| 766 | - if ($beginning) { |
|
| 767 | - if ($standalone) { |
|
| 768 | - header('content-type:text/xml;charset=' . _CHARSET); |
|
| 769 | - } |
|
| 770 | - $output .= '<' . '?' . 'xml version="1.0" encoding="' . _CHARSET . '"' . '?' . '>' . "\n"; |
|
| 771 | - $output .= '<' . $name . '>' . "\n"; |
|
| 772 | - $nested = 0; |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - if (is_array($array)) { |
|
| 776 | - foreach ($array as $key => $value) { |
|
| 777 | - ++$nested; |
|
| 778 | - if (is_array($value)) { |
|
| 779 | - $output .= str_repeat("\t", (int)$nested) . '<' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 780 | - ++$nested; |
|
| 781 | - $output .= static::toXml($value, $name, false, false, $nested); |
|
| 782 | - $nested--; |
|
| 783 | - $output .= str_repeat("\t", (int)$nested) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 784 | - } elseif ('' != $value) { |
|
| 785 | - ++$nested; |
|
| 786 | - $output .= str_repeat("\t", (int)$nested) . ' <' . (is_string($key) ? $key : $name . '_' . $key) . '>' . trim($value) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 787 | - $nested--; |
|
| 788 | - } |
|
| 789 | - $nested--; |
|
| 790 | - } |
|
| 791 | - } elseif ('' != $array) { |
|
| 792 | - ++$nested; |
|
| 793 | - $output .= str_repeat("\t", (int)$nested) . trim($array) . "\n"; |
|
| 794 | - $nested--; |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - if ($beginning) { |
|
| 798 | - $output .= '</' . $name . '>'; |
|
| 799 | - |
|
| 800 | - return $output; |
|
| 801 | - } |
|
| 802 | - |
|
| 803 | - return $output; |
|
| 804 | - } |
|
| 21 | + //--------------- Custom module methods ----------------------------- |
|
| 22 | + /** |
|
| 23 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
| 24 | + * |
|
| 25 | + * @param string $folder The full path of the directory to check |
|
| 26 | + */ |
|
| 27 | + public static function createFolder($folder): void |
|
| 28 | + { |
|
| 29 | + // try { |
|
| 30 | + // if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) { |
|
| 31 | + // throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
| 32 | + // } else { |
|
| 33 | + // file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
| 34 | + // } |
|
| 35 | + // } |
|
| 36 | + // catch (\Exception $e) { |
|
| 37 | + // echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
| 38 | + // } |
|
| 39 | + try { |
|
| 40 | + if (!\is_dir($folder)) { |
|
| 41 | + if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { |
|
| 42 | + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); |
|
| 43 | + } |
|
| 44 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
| 45 | + } |
|
| 46 | + } catch (\Throwable $e) { |
|
| 47 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @param string $file |
|
| 53 | + * @param string $folder |
|
| 54 | + * @return bool |
|
| 55 | + */ |
|
| 56 | + public static function copyFile(string $file, string $folder): bool |
|
| 57 | + { |
|
| 58 | + return \copy($file, $folder); |
|
| 59 | + // try { |
|
| 60 | + // if (!is_dir($folder)) { |
|
| 61 | + // throw new \RuntimeException(sprintf('Unable to copy file as: %s ', $folder)); |
|
| 62 | + // } else { |
|
| 63 | + // return copy($file, $folder); |
|
| 64 | + // } |
|
| 65 | + // } catch (\Exception $e) { |
|
| 66 | + // echo 'Caught exception: ', $e->getMessage(), "\n", "<br>"; |
|
| 67 | + // } |
|
| 68 | + // return false; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param $src |
|
| 73 | + * @param $dst |
|
| 74 | + */ |
|
| 75 | + public static function recurseCopy($src, $dst): void |
|
| 76 | + { |
|
| 77 | + $dir = \opendir($src); |
|
| 78 | + // @mkdir($dst); |
|
| 79 | + while (false !== ($file = \readdir($dir))) { |
|
| 80 | + if (('.' !== $file) && ('..' !== $file)) { |
|
| 81 | + if (\is_dir($src . '/' . $file)) { |
|
| 82 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
| 83 | + } else { |
|
| 84 | + \copy($src . '/' . $file, $dst . '/' . $file); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + \closedir($dir); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Verifies XOOPS version meets minimum requirements for this module |
|
| 93 | + * @static |
|
| 94 | + * @param \XoopsModule|null $module |
|
| 95 | + * |
|
| 96 | + * @param null|string $requiredVer |
|
| 97 | + * @return bool true if meets requirements, false if not |
|
| 98 | + */ |
|
| 99 | + public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null): bool |
|
| 100 | + { |
|
| 101 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 102 | + if (null === $module) { |
|
| 103 | + $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 104 | + } |
|
| 105 | + \xoops_loadLanguage('admin', $moduleDirName); |
|
| 106 | + \xoops_loadLanguage('common', $moduleDirName); |
|
| 107 | + |
|
| 108 | + //check for minimum XOOPS version |
|
| 109 | + $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string |
|
| 110 | + if (null === $requiredVer) { |
|
| 111 | + $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
| 112 | + } |
|
| 113 | + $success = true; |
|
| 114 | + |
|
| 115 | + if (\version_compare($currentVer, $requiredVer, '<')) { |
|
| 116 | + $success = false; |
|
| 117 | + $module->setErrors(\sprintf(\_AM_SONGLIST_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + return $success; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Verifies PHP version meets minimum requirements for this module |
|
| 125 | + * @static |
|
| 126 | + * @param \XoopsModule|bool|null $module |
|
| 127 | + * |
|
| 128 | + * @return bool true if meets requirements, false if not |
|
| 129 | + */ |
|
| 130 | + public static function checkVerPhp(\XoopsModule $module = null): bool |
|
| 131 | + { |
|
| 132 | + $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
| 133 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 134 | + if (null === $module) { |
|
| 135 | + $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 136 | + } |
|
| 137 | + \xoops_loadLanguage('admin', $moduleDirName); |
|
| 138 | + \xoops_loadLanguage('common', $moduleDirName); |
|
| 139 | + |
|
| 140 | + // check for minimum PHP version |
|
| 141 | + $success = true; |
|
| 142 | + |
|
| 143 | + $verNum = \PHP_VERSION; |
|
| 144 | + $reqVer = &$module->getInfo('min_php'); |
|
| 145 | + |
|
| 146 | + if (false !== $reqVer && '' !== $reqVer) { |
|
| 147 | + if (\version_compare($verNum, $reqVer, '<')) { |
|
| 148 | + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
| 149 | + $success = false; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return $success; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * compares current module version with the latest GitHub release |
|
| 158 | + * @static |
|
| 159 | + * |
|
| 160 | + * @return string|array info about the latest module version, if newer |
|
| 161 | + */ |
|
| 162 | + public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array |
|
| 163 | + { |
|
| 164 | + $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
| 165 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 166 | + $update = ''; |
|
| 167 | + $repository = 'XoopsModules25x/' . $moduleDirName; |
|
| 168 | + // $repository = 'XoopsModules25x/publisher'; //for testing only |
|
| 169 | + $ret = null; |
|
| 170 | + $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; |
|
| 171 | + if ('github' === $source) { |
|
| 172 | + if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { |
|
| 173 | + \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); |
|
| 174 | + \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); |
|
| 175 | + \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' |
|
| 176 | + \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); |
|
| 177 | + $curlReturn = \curl_exec($curlHandle); |
|
| 178 | + if (false === $curlReturn) { |
|
| 179 | + \trigger_error(\curl_error($curlHandle)); |
|
| 180 | + } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { |
|
| 181 | + \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
| 182 | + } else { |
|
| 183 | + $file = json_decode($curlReturn, false); |
|
| 184 | + $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); |
|
| 185 | + $latestVersion = $file[0]->tag_name; |
|
| 186 | + $prerelease = $file[0]->prerelease; |
|
| 187 | + if ('master' !== $latestVersionLink) { |
|
| 188 | + $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
| 189 | + } |
|
| 190 | + //"PHP-standardized" version |
|
| 191 | + $latestVersion = \mb_strtolower($latestVersion); |
|
| 192 | + if (false !== mb_strpos($latestVersion, 'final')) { |
|
| 193 | + $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); |
|
| 194 | + $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); |
|
| 195 | + } |
|
| 196 | + $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); |
|
| 197 | + //"PHP-standardized" version |
|
| 198 | + $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); |
|
| 199 | + // $moduleVersion = '1.0'; //for testing only |
|
| 200 | + // $moduleDirName = 'publisher'; //for testing only |
|
| 201 | + if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { |
|
| 202 | + $ret = []; |
|
| 203 | + $ret[] = $update; |
|
| 204 | + $ret[] = $latestVersionLink; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + \curl_close($curlHandle); |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + return $ret; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + //========================================================= |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * @return mixed |
|
| 218 | + */ |
|
| 219 | + public static function getToken() |
|
| 220 | + { |
|
| 221 | + $sql = 'SELECT md5(rand()/rand()*rand()/rand()*rand()*rand()/rand()*rand()) as `salt`'; |
|
| 222 | + $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
| 223 | + [$salt] = $GLOBALS['xoopsDB']->fetchRow($result); |
|
| 224 | + |
|
| 225 | + return $salt; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * @param $string |
|
| 230 | + * @return string |
|
| 231 | + */ |
|
| 232 | + public static function ucword($string): string |
|
| 233 | + { |
|
| 234 | + $ret = []; |
|
| 235 | + foreach (explode(' ', \mb_strtolower($string)) as $part) { |
|
| 236 | + $ret[] = ucfirst($part); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + return implode(' ', $ret); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * @param bool|string $ip |
|
| 244 | + * @return array |
|
| 245 | + */ |
|
| 246 | + public static function getIPData($ip = false): array |
|
| 247 | + { |
|
| 248 | + $ret = []; |
|
| 249 | + if (is_object($GLOBALS['xoopsUser'])) { |
|
| 250 | + $ret['uid'] = $GLOBALS['xoopsUser']->getVar('uid'); |
|
| 251 | + $ret['uname'] = $GLOBALS['xoopsUser']->getVar('uname'); |
|
| 252 | + $ret['email'] = $GLOBALS['xoopsUser']->getVar('email'); |
|
| 253 | + } else { |
|
| 254 | + $ret['uid'] = 0; |
|
| 255 | + $ret['uname'] = ($_REQUEST['uname'] ?? ''); |
|
| 256 | + $ret['email'] = ($_REQUEST['email'] ?? ''); |
|
| 257 | + } |
|
| 258 | + $ret['agent'] = $_SERVER['HTTP_USER_AGENT']; |
|
| 259 | + if ($ip) { |
|
| 260 | + $ret['is_proxied'] = false; |
|
| 261 | + $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 262 | + $ret['long'] = @ip2long($ip); |
|
| 263 | + if (isIpv6($ip)) { |
|
| 264 | + $ret['ip6'] = true; |
|
| 265 | + $ret['ip4'] = false; |
|
| 266 | + } else { |
|
| 267 | + $ret['ip4'] = true; |
|
| 268 | + $ret['ip6'] = false; |
|
| 269 | + } |
|
| 270 | + $ret['ip'] = $ip; |
|
| 271 | + } elseif (Request::hasVar('HTTP_X_FORWARDED_FOR', 'SERVER')) { |
|
| 272 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 273 | + $ret['is_proxied'] = true; |
|
| 274 | + $proxy_ip = $_SERVER['REMOTE_ADDR']; |
|
| 275 | + $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 276 | + $ret['long'] = @ip2long($ip); |
|
| 277 | + if (isIpv6($ip)) { |
|
| 278 | + $ret['ip6'] = true; |
|
| 279 | + $ret['proxy-ip6'] = true; |
|
| 280 | + $ret['ip4'] = false; |
|
| 281 | + $ret['proxy-ip4'] = false; |
|
| 282 | + } else { |
|
| 283 | + $ret['ip4'] = true; |
|
| 284 | + $ret['proxy-ip4'] = true; |
|
| 285 | + $ret['ip6'] = false; |
|
| 286 | + $ret['proxy-ip6'] = false; |
|
| 287 | + } |
|
| 288 | + $ret['ip'] = $ip; |
|
| 289 | + $ret['proxy-ip'] = $proxy_ip; |
|
| 290 | + } else { |
|
| 291 | + $ret['is_proxied'] = false; |
|
| 292 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 293 | + $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 294 | + $ret['long'] = @ip2long($ip); |
|
| 295 | + if (isIpv6($ip)) { |
|
| 296 | + $ret['ip6'] = true; |
|
| 297 | + $ret['ip4'] = false; |
|
| 298 | + } else { |
|
| 299 | + $ret['ip4'] = true; |
|
| 300 | + $ret['ip6'] = false; |
|
| 301 | + } |
|
| 302 | + $ret['ip'] = $ip; |
|
| 303 | + } |
|
| 304 | + $ret['made'] = time(); |
|
| 305 | + |
|
| 306 | + return $ret; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * @param string $ip |
|
| 311 | + * @return bool |
|
| 312 | + */ |
|
| 313 | + public static function isIpv6($ip = ''): bool |
|
| 314 | + { |
|
| 315 | + if ('' == $ip) { |
|
| 316 | + return false; |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + if (mb_substr_count($ip, ':') > 0) { |
|
| 320 | + return true; |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + return false; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * @param $filter |
|
| 328 | + * @param $field |
|
| 329 | + * @param string $sort |
|
| 330 | + * @param string $op |
|
| 331 | + * @param string $fct |
|
| 332 | + * @return bool|\XoopsModules\Songlist\Form\SelectAlbumForm|\XoopsModules\Songlist\Form\SelectArtistForm|\XoopsModules\Songlist\Form\SelectCategoryForm|\XoopsModules\Songlist\Form\SelectGenreForm|\XoopsModules\Songlist\Form\SelectVoiceForm |
|
| 333 | + */ |
|
| 334 | + public static function getFilterElement($filter, $field, $sort = 'created', $op = '', $fct = '') |
|
| 335 | + { |
|
| 336 | + $components = static::getFilterURLComponents($filter, $field, $sort); |
|
| 337 | + $ele = false; |
|
| 338 | + require_once dirname(__DIR__) . '/include/songlist.object.php'; |
|
| 339 | + switch ($field) { |
|
| 340 | + case 'gid': |
|
| 341 | + if ('genre' !== $op) { |
|
| 342 | + $ele = new SelectGenreForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 343 | + $ele->setExtra( |
|
| 344 | + 'onchange="window.open(\'' |
|
| 345 | + . $_SERVER['SCRIPT_NAME'] |
|
| 346 | + . '?' |
|
| 347 | + . $components['extra'] |
|
| 348 | + . '&filter=' |
|
| 349 | + . $components['filter'] |
|
| 350 | + . (!empty($components['filter']) ? '|' : '') |
|
| 351 | + . $field |
|
| 352 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 353 | + . (!empty($components['operator']) ? '+\',' |
|
| 354 | + . $components['operator'] |
|
| 355 | + . '\'' : '') |
|
| 356 | + . ',\'_self\')"' |
|
| 357 | + ); |
|
| 358 | + } |
|
| 359 | + break; |
|
| 360 | + case 'vcid': |
|
| 361 | + if ('voice' !== $op) { |
|
| 362 | + $ele = new SelectVoiceForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 363 | + $ele->setExtra( |
|
| 364 | + 'onchange="window.open(\'' |
|
| 365 | + . $_SERVER['SCRIPT_NAME'] |
|
| 366 | + . '?' |
|
| 367 | + . $components['extra'] |
|
| 368 | + . '&filter=' |
|
| 369 | + . $components['filter'] |
|
| 370 | + . (!empty($components['filter']) ? '|' : '') |
|
| 371 | + . $field |
|
| 372 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 373 | + . (!empty($components['operator']) ? '+\',' |
|
| 374 | + . $components['operator'] |
|
| 375 | + . '\'' : '') |
|
| 376 | + . ',\'_self\')"' |
|
| 377 | + ); |
|
| 378 | + } |
|
| 379 | + break; |
|
| 380 | + case 'cid': |
|
| 381 | + if ('category' !== $op) { |
|
| 382 | + $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 383 | + $ele->setExtra( |
|
| 384 | + 'onchange="window.open(\'' |
|
| 385 | + . $_SERVER['SCRIPT_NAME'] |
|
| 386 | + . '?' |
|
| 387 | + . $components['extra'] |
|
| 388 | + . '&filter=' |
|
| 389 | + . $components['filter'] |
|
| 390 | + . (!empty($components['filter']) ? '|' : '') |
|
| 391 | + . $field |
|
| 392 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 393 | + . (!empty($components['operator']) ? '+\',' |
|
| 394 | + . $components['operator'] |
|
| 395 | + . '\'' : '') |
|
| 396 | + . ',\'_self\')"' |
|
| 397 | + ); |
|
| 398 | + } |
|
| 399 | + break; |
|
| 400 | + case 'pid': |
|
| 401 | + $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 402 | + $ele->setExtra( |
|
| 403 | + 'onchange="window.open(\'' |
|
| 404 | + . $_SERVER['SCRIPT_NAME'] |
|
| 405 | + . '?' |
|
| 406 | + . $components['extra'] |
|
| 407 | + . '&filter=' |
|
| 408 | + . $components['filter'] |
|
| 409 | + . (!empty($components['filter']) ? '|' : '') |
|
| 410 | + . $field |
|
| 411 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 412 | + . (!empty($components['operator']) ? '+\',' |
|
| 413 | + . $components['operator'] |
|
| 414 | + . '\'' : '') |
|
| 415 | + . ',\'_self\')"' |
|
| 416 | + ); |
|
| 417 | + break; |
|
| 418 | + case 'abid': |
|
| 419 | + if ('albums' !== $op) { |
|
| 420 | + $ele = new SelectAlbumForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 421 | + $ele->setExtra( |
|
| 422 | + 'onchange="window.open(\'' |
|
| 423 | + . $_SERVER['SCRIPT_NAME'] |
|
| 424 | + . '?' |
|
| 425 | + . $components['extra'] |
|
| 426 | + . '&filter=' |
|
| 427 | + . $components['filter'] |
|
| 428 | + . (!empty($components['filter']) ? '|' : '') |
|
| 429 | + . $field |
|
| 430 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 431 | + . (!empty($components['operator']) ? '+\',' |
|
| 432 | + . $components['operator'] |
|
| 433 | + . '\'' : '') |
|
| 434 | + . ',\'_self\')"' |
|
| 435 | + ); |
|
| 436 | + } |
|
| 437 | + break; |
|
| 438 | + case 'aid': |
|
| 439 | + if ('artists' !== $op) { |
|
| 440 | + $ele = new SelectArtistForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 441 | + $ele->setExtra( |
|
| 442 | + 'onchange="window.open(\'' |
|
| 443 | + . $_SERVER['SCRIPT_NAME'] |
|
| 444 | + . '?' |
|
| 445 | + . $components['extra'] |
|
| 446 | + . '&filter=' |
|
| 447 | + . $components['filter'] |
|
| 448 | + . (!empty($components['filter']) ? '|' : '') |
|
| 449 | + . $field |
|
| 450 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 451 | + . (!empty($components['operator']) ? '+\',' |
|
| 452 | + . $components['operator'] |
|
| 453 | + . '\'' : '') |
|
| 454 | + . ',\'_self\')"' |
|
| 455 | + ); |
|
| 456 | + } |
|
| 457 | + break; |
|
| 458 | + case 'sid': |
|
| 459 | + if ('songs' !== $op) { |
|
| 460 | + $ele = new SelectSongForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 461 | + $ele->setExtra( |
|
| 462 | + 'onchange="window.open(\'' |
|
| 463 | + . $_SERVER['SCRIPT_NAME'] |
|
| 464 | + . '?' |
|
| 465 | + . $components['extra'] |
|
| 466 | + . '&filter=' |
|
| 467 | + . $components['filter'] |
|
| 468 | + . (!empty($components['filter']) ? '|' : '') |
|
| 469 | + . $field |
|
| 470 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 471 | + . (!empty($components['operator']) ? '+\',' |
|
| 472 | + . $components['operator'] |
|
| 473 | + . '\'' : '') |
|
| 474 | + . ',\'_self\')"' |
|
| 475 | + ); |
|
| 476 | + } |
|
| 477 | + break; |
|
| 478 | + case 'name': |
|
| 479 | + case 'title': |
|
| 480 | + case 'artists': |
|
| 481 | + case 'albums': |
|
| 482 | + case 'songs': |
|
| 483 | + case 'hits': |
|
| 484 | + case 'rank': |
|
| 485 | + case 'votes': |
|
| 486 | + case 'description': |
|
| 487 | + case 'lyrics': |
|
| 488 | + case 'songid': |
|
| 489 | + case 'tags': |
|
| 490 | + $ele = new \XoopsFormElementTray(''); |
|
| 491 | + $ele->addElement(new \XoopsFormText('', 'filter_' . $field . '', 11, 40, $components['value'])); |
|
| 492 | + $button = new \XoopsFormButton('', 'button_' . $field . '', '[+]'); |
|
| 493 | + $button->setExtra( |
|
| 494 | + 'onclick="window.open(\'' |
|
| 495 | + . $_SERVER['SCRIPT_NAME'] |
|
| 496 | + . '?' |
|
| 497 | + . $components['extra'] |
|
| 498 | + . '&filter=' |
|
| 499 | + . $components['filter'] |
|
| 500 | + . (!empty($components['filter']) ? '|' : '') |
|
| 501 | + . $field |
|
| 502 | + . ',\'+$(\'#filter_' |
|
| 503 | + . $field |
|
| 504 | + . '\').val()' |
|
| 505 | + . (!empty($components['operator']) ? '+\',' |
|
| 506 | + . $components['operator'] |
|
| 507 | + . '\'' : '') |
|
| 508 | + . ',\'_self\')"' |
|
| 509 | + ); |
|
| 510 | + $ele->addElement($button); |
|
| 511 | + break; |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + return $ele; |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + /** |
|
| 518 | + * @param $filter |
|
| 519 | + * @param $field |
|
| 520 | + * @param string $sort |
|
| 521 | + * @return array |
|
| 522 | + */ |
|
| 523 | + public static function getFilterURLComponents($filter, $field, $sort = 'created'): array |
|
| 524 | + { |
|
| 525 | + $parts = explode('|', $filter); |
|
| 526 | + $ret = []; |
|
| 527 | + $value = ''; |
|
| 528 | + $ele_value = ''; |
|
| 529 | + $operator = ''; |
|
| 530 | + foreach ($parts as $part) { |
|
| 531 | + $var = explode(',', $part); |
|
| 532 | + if (count($var) > 1) { |
|
| 533 | + if ($var[0] == $field) { |
|
| 534 | + $ele_value = $var[1]; |
|
| 535 | + if (isset($var[2])) { |
|
| 536 | + $operator = $var[2]; |
|
| 537 | + } |
|
| 538 | + } elseif (1 != $var[0]) { |
|
| 539 | + $ret[] = implode(',', $var); |
|
| 540 | + } |
|
| 541 | + } |
|
| 542 | + } |
|
| 543 | + $pagenav = []; |
|
| 544 | + $pagenav['op'] = $_REQUEST['op'] ?? 'videos'; |
|
| 545 | + $pagenav['fct'] = $_REQUEST['fct'] ?? 'list'; |
|
| 546 | + $pagenav['limit'] = Request::getInt('limit', 30, 'REQUEST'); |
|
| 547 | + $pagenav['start'] = 0; |
|
| 548 | + $pagenav['order'] = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
|
| 549 | + $pagenav['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : $sort; |
|
| 550 | + $retb = []; |
|
| 551 | + foreach ($pagenav as $key => $value) { |
|
| 552 | + $retb[] = "$key=$value"; |
|
| 553 | + } |
|
| 554 | + |
|
| 555 | + return ['value' => $ele_value, 'field' => $field, 'operator' => $operator, 'filter' => implode('|', $ret), 'extra' => implode('&', $retb)]; |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + /** |
|
| 559 | + * @param $objects |
|
| 560 | + * @return array |
|
| 561 | + */ |
|
| 562 | + public static function obj2array($objects): array |
|
| 563 | + { |
|
| 564 | + $ret = []; |
|
| 565 | + foreach ((array)$objects as $key => $value) { |
|
| 566 | + if (is_a($value, 'stdClass')) { |
|
| 567 | + $ret[$key] = static::obj2array($value); |
|
| 568 | + } elseif (is_array($value)) { |
|
| 569 | + $ret[$key] = static::obj2array($value); |
|
| 570 | + } else { |
|
| 571 | + $ret[$key] = $value; |
|
| 572 | + } |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + return $ret; |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + /** |
|
| 579 | + * @param $url |
|
| 580 | + * @return mixed |
|
| 581 | + */ |
|
| 582 | + public static function shortenUrl($url) |
|
| 583 | + { |
|
| 584 | + /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 585 | + $moduleHandler = xoops_getHandler('module'); |
|
| 586 | + /** @var \XoopsConfigHandler $configHandler */ |
|
| 587 | + $configHandler = xoops_getHandler('config'); |
|
| 588 | + $GLOBALS['songlistModule'] = $moduleHandler->getByDirname('songlist'); |
|
| 589 | + $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
|
| 590 | + |
|
| 591 | + if (!empty($GLOBALS['songlistModuleConfig']['bitly_username']) && !empty($GLOBALS['songlistModuleConfig']['bitly_apikey'])) { |
|
| 592 | + $source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'] . '/shorten?login=' . $GLOBALS['songlistModuleConfig']['bitly_username'] . '&apiKey=' . $GLOBALS['songlistModuleConfig']['bitly_apikey'] . '&format=json&longUrl=' . urlencode($url); |
|
| 593 | + $cookies = XOOPS_ROOT_PATH . '/uploads/songlist_' . md5($GLOBALS['songlistModuleConfig']['bitly_apikey']) . '.cookie'; |
|
| 594 | + if (!$ch = curl_init($source_url)) { |
|
| 595 | + return $url; |
|
| 596 | + } |
|
| 597 | + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); |
|
| 598 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 599 | + curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['songlistModuleConfig']['user_agent']); |
|
| 600 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $GLOBALS['songlistModuleConfig']['curl_connect_timeout']); |
|
| 601 | + curl_setopt($ch, CURLOPT_TIMEOUT, $GLOBALS['songlistModuleConfig']['curl_timeout']); |
|
| 602 | + $data = curl_exec($ch); |
|
| 603 | + curl_close($ch); |
|
| 604 | + $result = songlist_object2array(json_decode($data)); |
|
| 605 | + $result['status_code'] = 200; |
|
| 606 | + if ($result['status_code']) { |
|
| 607 | + if (!empty($result['data']['url'])) { |
|
| 608 | + return $result['data']['url']; |
|
| 609 | + } |
|
| 610 | + |
|
| 611 | + return $url; |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + return $url; |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + return $url; |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + /** |
|
| 621 | + * @param $contents |
|
| 622 | + * @param int $get_attributes |
|
| 623 | + * @param string $priority |
|
| 624 | + * @return array|void |
|
| 625 | + */ |
|
| 626 | + public static function xml2array($contents, $get_attributes = 1, $priority = 'tag') |
|
| 627 | + { |
|
| 628 | + if (!$contents) { |
|
| 629 | + return []; |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | + if (!function_exists('xml_parser_create')) { |
|
| 633 | + return []; |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + //Get the XML parser of PHP - PHP must have this module for the parser to work |
|
| 637 | + $parser = xml_parser_create(''); |
|
| 638 | + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); # https://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
| 639 | + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 640 | + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
| 641 | + xml_parse_into_struct($parser, trim($contents), $xml_values); |
|
| 642 | + xml_parser_free($parser); |
|
| 643 | + |
|
| 644 | + if (!$xml_values) { |
|
| 645 | + return; |
|
| 646 | + }//Hmm... |
|
| 647 | + |
|
| 648 | + //Initializations |
|
| 649 | + $xml_array = []; |
|
| 650 | + $parents = []; |
|
| 651 | + $opened_tags = []; |
|
| 652 | + $arr = []; |
|
| 653 | + |
|
| 654 | + $current = &$xml_array; //Refference |
|
| 655 | + |
|
| 656 | + //Go through the tags. |
|
| 657 | + $repeated_tag_index = []; //Multiple tags with same name will be turned into an array |
|
| 658 | + foreach ($xml_values as $data) { |
|
| 659 | + unset($attributes, $value); //Remove existing values, or there will be trouble |
|
| 660 | + |
|
| 661 | + //This command will extract these variables into the foreach scope |
|
| 662 | + // tag(string), type(string), level(int), attributes(array). |
|
| 663 | + extract($data); //We could use the array by itself, but this cooler. |
|
| 664 | + |
|
| 665 | + $result = []; |
|
| 666 | + $attributes_data = []; |
|
| 667 | + |
|
| 668 | + if (isset($value)) { |
|
| 669 | + if ('tag' === $priority) { |
|
| 670 | + $result = $value; |
|
| 671 | + } else { |
|
| 672 | + $result['value'] = $value; |
|
| 673 | + } //Put the value in a assoc array if we are in the 'Attribute' mode |
|
| 674 | + } |
|
| 675 | + |
|
| 676 | + //Set the attributes too. |
|
| 677 | + if (isset($attributes) and $get_attributes) { |
|
| 678 | + foreach ($attributes as $attr => $val) { |
|
| 679 | + if ('tag' === $priority) { |
|
| 680 | + $attributes_data[$attr] = $val; |
|
| 681 | + } else { |
|
| 682 | + $result['attr'][$attr] = $val; |
|
| 683 | + } //Set all the attributes in a array called 'attr' |
|
| 684 | + } |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + //See tag status and do the needed. |
|
| 688 | + if ('open' === $type) {//The starting of the tag '<tag>' |
|
| 689 | + $parent[$level - 1] = &$current; |
|
| 690 | + if (!is_array($current) or (!array_key_exists($tag, $current))) { //Insert New tag |
|
| 691 | + $current[$tag] = $result; |
|
| 692 | + if ($attributes_data) { |
|
| 693 | + $current[$tag . '_attr'] = $attributes_data; |
|
| 694 | + } |
|
| 695 | + $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 696 | + |
|
| 697 | + $current = &$current[$tag]; |
|
| 698 | + } else { //There was another element with the same tag name |
|
| 699 | + if (isset($current[$tag][0])) {//If there is a 0th element it is already an array |
|
| 700 | + $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 701 | + $repeated_tag_index[$tag . '_' . $level]++; |
|
| 702 | + } else {//This section will make the value an array if multiple tags with the same name appear together |
|
| 703 | + $current[$tag] = [$current[$tag], $result]; //This will combine the existing item and the new item together to make an array |
|
| 704 | + $repeated_tag_index[$tag . '_' . $level] = 2; |
|
| 705 | + |
|
| 706 | + if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 707 | + $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 708 | + unset($current[$tag . '_attr']); |
|
| 709 | + } |
|
| 710 | + } |
|
| 711 | + $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; |
|
| 712 | + $current = &$current[$tag][$last_item_index]; |
|
| 713 | + } |
|
| 714 | + } elseif ('complete' === $type) { //Tags that ends in 1 line '<tag>' |
|
| 715 | + //See if the key is already taken. |
|
| 716 | + if (isset($current[$tag])) { //If taken, put all things inside a list(array) |
|
| 717 | + if (isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... |
|
| 718 | + // ...push the new element into that array. |
|
| 719 | + $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 720 | + |
|
| 721 | + if ('tag' === $priority and $get_attributes and $attributes_data) { |
|
| 722 | + $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 723 | + } |
|
| 724 | + $repeated_tag_index[$tag . '_' . $level]++; |
|
| 725 | + } else { //If it is not an array... |
|
| 726 | + $current[$tag] = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value |
|
| 727 | + $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 728 | + if ('tag' === $priority and $get_attributes) { |
|
| 729 | + if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 730 | + $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 731 | + unset($current[$tag . '_attr']); |
|
| 732 | + } |
|
| 733 | + |
|
| 734 | + if ($attributes_data) { |
|
| 735 | + $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 736 | + } |
|
| 737 | + } |
|
| 738 | + $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken |
|
| 739 | + } |
|
| 740 | + } else { //New Key |
|
| 741 | + $current[$tag] = $result; |
|
| 742 | + $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 743 | + if ('tag' === $priority and $attributes_data) { |
|
| 744 | + $current[$tag . '_attr'] = $attributes_data; |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + } elseif ('close' === $type) { //End of tag '</tag>' |
|
| 748 | + $current = &$parent[$level - 1]; |
|
| 749 | + } |
|
| 750 | + } |
|
| 751 | + |
|
| 752 | + return $xml_array; |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + /** |
|
| 756 | + * @param $array |
|
| 757 | + * @param $name |
|
| 758 | + * @param $standalone |
|
| 759 | + * @param $beginning |
|
| 760 | + * @param $nested |
|
| 761 | + * @return string |
|
| 762 | + */ |
|
| 763 | + public static function toXml($array, $name, $standalone, $beginning, $nested): string |
|
| 764 | + { |
|
| 765 | + $output = ''; |
|
| 766 | + if ($beginning) { |
|
| 767 | + if ($standalone) { |
|
| 768 | + header('content-type:text/xml;charset=' . _CHARSET); |
|
| 769 | + } |
|
| 770 | + $output .= '<' . '?' . 'xml version="1.0" encoding="' . _CHARSET . '"' . '?' . '>' . "\n"; |
|
| 771 | + $output .= '<' . $name . '>' . "\n"; |
|
| 772 | + $nested = 0; |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + if (is_array($array)) { |
|
| 776 | + foreach ($array as $key => $value) { |
|
| 777 | + ++$nested; |
|
| 778 | + if (is_array($value)) { |
|
| 779 | + $output .= str_repeat("\t", (int)$nested) . '<' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 780 | + ++$nested; |
|
| 781 | + $output .= static::toXml($value, $name, false, false, $nested); |
|
| 782 | + $nested--; |
|
| 783 | + $output .= str_repeat("\t", (int)$nested) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 784 | + } elseif ('' != $value) { |
|
| 785 | + ++$nested; |
|
| 786 | + $output .= str_repeat("\t", (int)$nested) . ' <' . (is_string($key) ? $key : $name . '_' . $key) . '>' . trim($value) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 787 | + $nested--; |
|
| 788 | + } |
|
| 789 | + $nested--; |
|
| 790 | + } |
|
| 791 | + } elseif ('' != $array) { |
|
| 792 | + ++$nested; |
|
| 793 | + $output .= str_repeat("\t", (int)$nested) . trim($array) . "\n"; |
|
| 794 | + $nested--; |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + if ($beginning) { |
|
| 798 | + $output .= '</' . $name . '>'; |
|
| 799 | + |
|
| 800 | + return $output; |
|
| 801 | + } |
|
| 802 | + |
|
| 803 | + return $output; |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | 806 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { |
| 42 | 42 | throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); |
| 43 | 43 | } |
| 44 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
| 44 | + file_put_contents($folder.'/index.html', '<script>history.go(-1);</script>'); |
|
| 45 | 45 | } |
| 46 | 46 | } catch (\Throwable $e) { |
| 47 | 47 | echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $dir = \opendir($src); |
| 78 | 78 | // @mkdir($dst); |
| 79 | - while (false !== ($file = \readdir($dir))) { |
|
| 80 | - if (('.' !== $file) && ('..' !== $file)) { |
|
| 81 | - if (\is_dir($src . '/' . $file)) { |
|
| 82 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
| 79 | + while (false!==($file = \readdir($dir))) { |
|
| 80 | + if (('.'!==$file) && ('..'!==$file)) { |
|
| 81 | + if (\is_dir($src.'/'.$file)) { |
|
| 82 | + self::recurseCopy($src.'/'.$file, $dst.'/'.$file); |
|
| 83 | 83 | } else { |
| 84 | - \copy($src . '/' . $file, $dst . '/' . $file); |
|
| 84 | + \copy($src.'/'.$file, $dst.'/'.$file); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null): bool |
| 100 | 100 | { |
| 101 | 101 | $moduleDirName = \basename(\dirname(__DIR__)); |
| 102 | - if (null === $module) { |
|
| 102 | + if (null===$module) { |
|
| 103 | 103 | $module = \XoopsModule::getByDirname($moduleDirName); |
| 104 | 104 | } |
| 105 | 105 | \xoops_loadLanguage('admin', $moduleDirName); |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | //check for minimum XOOPS version |
| 109 | 109 | $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string |
| 110 | - if (null === $requiredVer) { |
|
| 111 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
| 110 | + if (null===$requiredVer) { |
|
| 111 | + $requiredVer = ''.$module->getInfo('min_xoops'); //making sure it's a string |
|
| 112 | 112 | } |
| 113 | 113 | $success = true; |
| 114 | 114 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | $moduleDirName = \basename(\dirname(__DIR__, 2)); |
| 133 | 133 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
| 134 | - if (null === $module) { |
|
| 134 | + if (null===$module) { |
|
| 135 | 135 | $module = \XoopsModule::getByDirname($moduleDirName); |
| 136 | 136 | } |
| 137 | 137 | \xoops_loadLanguage('admin', $moduleDirName); |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | $verNum = \PHP_VERSION; |
| 144 | 144 | $reqVer = &$module->getInfo('min_php'); |
| 145 | 145 | |
| 146 | - if (false !== $reqVer && '' !== $reqVer) { |
|
| 146 | + if (false!==$reqVer && ''!==$reqVer) { |
|
| 147 | 147 | if (\version_compare($verNum, $reqVer, '<')) { |
| 148 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
| 148 | + $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
| 149 | 149 | $success = false; |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -164,36 +164,36 @@ discard block |
||
| 164 | 164 | $moduleDirName = \basename(\dirname(__DIR__, 2)); |
| 165 | 165 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
| 166 | 166 | $update = ''; |
| 167 | - $repository = 'XoopsModules25x/' . $moduleDirName; |
|
| 167 | + $repository = 'XoopsModules25x/'.$moduleDirName; |
|
| 168 | 168 | // $repository = 'XoopsModules25x/publisher'; //for testing only |
| 169 | 169 | $ret = null; |
| 170 | 170 | $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; |
| 171 | - if ('github' === $source) { |
|
| 172 | - if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { |
|
| 171 | + if ('github'===$source) { |
|
| 172 | + if (\function_exists('curl_init') && false!==($curlHandle = \curl_init())) { |
|
| 173 | 173 | \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); |
| 174 | 174 | \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); |
| 175 | 175 | \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' |
| 176 | 176 | \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); |
| 177 | 177 | $curlReturn = \curl_exec($curlHandle); |
| 178 | - if (false === $curlReturn) { |
|
| 178 | + if (false===$curlReturn) { |
|
| 179 | 179 | \trigger_error(\curl_error($curlHandle)); |
| 180 | - } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { |
|
| 181 | - \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
| 180 | + } elseif (false!==\mb_strpos($curlReturn, 'Not Found')) { |
|
| 181 | + \trigger_error('Repository Not Found: '.$infoReleasesUrl); |
|
| 182 | 182 | } else { |
| 183 | 183 | $file = json_decode($curlReturn, false); |
| 184 | 184 | $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); |
| 185 | 185 | $latestVersion = $file[0]->tag_name; |
| 186 | 186 | $prerelease = $file[0]->prerelease; |
| 187 | - if ('master' !== $latestVersionLink) { |
|
| 188 | - $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
| 187 | + if ('master'!==$latestVersionLink) { |
|
| 188 | + $update = \constant('CO_'.$moduleDirNameUpper.'_'.'NEW_VERSION').$latestVersion; |
|
| 189 | 189 | } |
| 190 | 190 | //"PHP-standardized" version |
| 191 | 191 | $latestVersion = \mb_strtolower($latestVersion); |
| 192 | - if (false !== mb_strpos($latestVersion, 'final')) { |
|
| 192 | + if (false!==mb_strpos($latestVersion, 'final')) { |
|
| 193 | 193 | $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); |
| 194 | 194 | $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); |
| 195 | 195 | } |
| 196 | - $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); |
|
| 196 | + $moduleVersion = ($helper->getModule()->getInfo('version').'_'.$helper->getModule()->getInfo('module_status')); |
|
| 197 | 197 | //"PHP-standardized" version |
| 198 | 198 | $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); |
| 199 | 199 | // $moduleVersion = '1.0'; //for testing only |
@@ -312,11 +312,11 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | public static function isIpv6($ip = ''): bool |
| 314 | 314 | { |
| 315 | - if ('' == $ip) { |
|
| 315 | + if (''==$ip) { |
|
| 316 | 316 | return false; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - if (mb_substr_count($ip, ':') > 0) { |
|
| 319 | + if (mb_substr_count($ip, ':')>0) { |
|
| 320 | 320 | return true; |
| 321 | 321 | } |
| 322 | 322 | |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | { |
| 336 | 336 | $components = static::getFilterURLComponents($filter, $field, $sort); |
| 337 | 337 | $ele = false; |
| 338 | - require_once dirname(__DIR__) . '/include/songlist.object.php'; |
|
| 338 | + require_once dirname(__DIR__).'/include/songlist.object.php'; |
|
| 339 | 339 | switch ($field) { |
| 340 | 340 | case 'gid': |
| 341 | - if ('genre' !== $op) { |
|
| 342 | - $ele = new SelectGenreForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 341 | + if ('genre'!==$op) { |
|
| 342 | + $ele = new SelectGenreForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 343 | 343 | $ele->setExtra( |
| 344 | 344 | 'onchange="window.open(\'' |
| 345 | 345 | . $_SERVER['SCRIPT_NAME'] |
@@ -358,8 +358,8 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | break; |
| 360 | 360 | case 'vcid': |
| 361 | - if ('voice' !== $op) { |
|
| 362 | - $ele = new SelectVoiceForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 361 | + if ('voice'!==$op) { |
|
| 362 | + $ele = new SelectVoiceForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 363 | 363 | $ele->setExtra( |
| 364 | 364 | 'onchange="window.open(\'' |
| 365 | 365 | . $_SERVER['SCRIPT_NAME'] |
@@ -378,8 +378,8 @@ discard block |
||
| 378 | 378 | } |
| 379 | 379 | break; |
| 380 | 380 | case 'cid': |
| 381 | - if ('category' !== $op) { |
|
| 382 | - $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 381 | + if ('category'!==$op) { |
|
| 382 | + $ele = new SelectCategoryForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 383 | 383 | $ele->setExtra( |
| 384 | 384 | 'onchange="window.open(\'' |
| 385 | 385 | . $_SERVER['SCRIPT_NAME'] |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | } |
| 399 | 399 | break; |
| 400 | 400 | case 'pid': |
| 401 | - $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 401 | + $ele = new SelectCategoryForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 402 | 402 | $ele->setExtra( |
| 403 | 403 | 'onchange="window.open(\'' |
| 404 | 404 | . $_SERVER['SCRIPT_NAME'] |
@@ -416,8 +416,8 @@ discard block |
||
| 416 | 416 | ); |
| 417 | 417 | break; |
| 418 | 418 | case 'abid': |
| 419 | - if ('albums' !== $op) { |
|
| 420 | - $ele = new SelectAlbumForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 419 | + if ('albums'!==$op) { |
|
| 420 | + $ele = new SelectAlbumForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 421 | 421 | $ele->setExtra( |
| 422 | 422 | 'onchange="window.open(\'' |
| 423 | 423 | . $_SERVER['SCRIPT_NAME'] |
@@ -436,8 +436,8 @@ discard block |
||
| 436 | 436 | } |
| 437 | 437 | break; |
| 438 | 438 | case 'aid': |
| 439 | - if ('artists' !== $op) { |
|
| 440 | - $ele = new SelectArtistForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 439 | + if ('artists'!==$op) { |
|
| 440 | + $ele = new SelectArtistForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 441 | 441 | $ele->setExtra( |
| 442 | 442 | 'onchange="window.open(\'' |
| 443 | 443 | . $_SERVER['SCRIPT_NAME'] |
@@ -456,8 +456,8 @@ discard block |
||
| 456 | 456 | } |
| 457 | 457 | break; |
| 458 | 458 | case 'sid': |
| 459 | - if ('songs' !== $op) { |
|
| 460 | - $ele = new SelectSongForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 459 | + if ('songs'!==$op) { |
|
| 460 | + $ele = new SelectSongForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 461 | 461 | $ele->setExtra( |
| 462 | 462 | 'onchange="window.open(\'' |
| 463 | 463 | . $_SERVER['SCRIPT_NAME'] |
@@ -488,8 +488,8 @@ discard block |
||
| 488 | 488 | case 'songid': |
| 489 | 489 | case 'tags': |
| 490 | 490 | $ele = new \XoopsFormElementTray(''); |
| 491 | - $ele->addElement(new \XoopsFormText('', 'filter_' . $field . '', 11, 40, $components['value'])); |
|
| 492 | - $button = new \XoopsFormButton('', 'button_' . $field . '', '[+]'); |
|
| 491 | + $ele->addElement(new \XoopsFormText('', 'filter_'.$field.'', 11, 40, $components['value'])); |
|
| 492 | + $button = new \XoopsFormButton('', 'button_'.$field.'', '[+]'); |
|
| 493 | 493 | $button->setExtra( |
| 494 | 494 | 'onclick="window.open(\'' |
| 495 | 495 | . $_SERVER['SCRIPT_NAME'] |
@@ -529,13 +529,13 @@ discard block |
||
| 529 | 529 | $operator = ''; |
| 530 | 530 | foreach ($parts as $part) { |
| 531 | 531 | $var = explode(',', $part); |
| 532 | - if (count($var) > 1) { |
|
| 533 | - if ($var[0] == $field) { |
|
| 532 | + if (count($var)>1) { |
|
| 533 | + if ($var[0]==$field) { |
|
| 534 | 534 | $ele_value = $var[1]; |
| 535 | 535 | if (isset($var[2])) { |
| 536 | 536 | $operator = $var[2]; |
| 537 | 537 | } |
| 538 | - } elseif (1 != $var[0]) { |
|
| 538 | + } elseif (1!=$var[0]) { |
|
| 539 | 539 | $ret[] = implode(',', $var); |
| 540 | 540 | } |
| 541 | 541 | } |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | $pagenav['limit'] = Request::getInt('limit', 30, 'REQUEST'); |
| 547 | 547 | $pagenav['start'] = 0; |
| 548 | 548 | $pagenav['order'] = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
| 549 | - $pagenav['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : $sort; |
|
| 549 | + $pagenav['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : $sort; |
|
| 550 | 550 | $retb = []; |
| 551 | 551 | foreach ($pagenav as $key => $value) { |
| 552 | 552 | $retb[] = "$key=$value"; |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | public static function obj2array($objects): array |
| 563 | 563 | { |
| 564 | 564 | $ret = []; |
| 565 | - foreach ((array)$objects as $key => $value) { |
|
| 565 | + foreach ((array) $objects as $key => $value) { |
|
| 566 | 566 | if (is_a($value, 'stdClass')) { |
| 567 | 567 | $ret[$key] = static::obj2array($value); |
| 568 | 568 | } elseif (is_array($value)) { |
@@ -589,8 +589,8 @@ discard block |
||
| 589 | 589 | $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
| 590 | 590 | |
| 591 | 591 | if (!empty($GLOBALS['songlistModuleConfig']['bitly_username']) && !empty($GLOBALS['songlistModuleConfig']['bitly_apikey'])) { |
| 592 | - $source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'] . '/shorten?login=' . $GLOBALS['songlistModuleConfig']['bitly_username'] . '&apiKey=' . $GLOBALS['songlistModuleConfig']['bitly_apikey'] . '&format=json&longUrl=' . urlencode($url); |
|
| 593 | - $cookies = XOOPS_ROOT_PATH . '/uploads/songlist_' . md5($GLOBALS['songlistModuleConfig']['bitly_apikey']) . '.cookie'; |
|
| 592 | + $source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'].'/shorten?login='.$GLOBALS['songlistModuleConfig']['bitly_username'].'&apiKey='.$GLOBALS['songlistModuleConfig']['bitly_apikey'].'&format=json&longUrl='.urlencode($url); |
|
| 593 | + $cookies = XOOPS_ROOT_PATH.'/uploads/songlist_'.md5($GLOBALS['songlistModuleConfig']['bitly_apikey']).'.cookie'; |
|
| 594 | 594 | if (!$ch = curl_init($source_url)) { |
| 595 | 595 | return $url; |
| 596 | 596 | } |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | $attributes_data = []; |
| 667 | 667 | |
| 668 | 668 | if (isset($value)) { |
| 669 | - if ('tag' === $priority) { |
|
| 669 | + if ('tag'===$priority) { |
|
| 670 | 670 | $result = $value; |
| 671 | 671 | } else { |
| 672 | 672 | $result['value'] = $value; |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | //Set the attributes too. |
| 677 | 677 | if (isset($attributes) and $get_attributes) { |
| 678 | 678 | foreach ($attributes as $attr => $val) { |
| 679 | - if ('tag' === $priority) { |
|
| 679 | + if ('tag'===$priority) { |
|
| 680 | 680 | $attributes_data[$attr] = $val; |
| 681 | 681 | } else { |
| 682 | 682 | $result['attr'][$attr] = $val; |
@@ -685,67 +685,67 @@ discard block |
||
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | //See tag status and do the needed. |
| 688 | - if ('open' === $type) {//The starting of the tag '<tag>' |
|
| 689 | - $parent[$level - 1] = &$current; |
|
| 688 | + if ('open'===$type) {//The starting of the tag '<tag>' |
|
| 689 | + $parent[$level-1] = &$current; |
|
| 690 | 690 | if (!is_array($current) or (!array_key_exists($tag, $current))) { //Insert New tag |
| 691 | 691 | $current[$tag] = $result; |
| 692 | 692 | if ($attributes_data) { |
| 693 | - $current[$tag . '_attr'] = $attributes_data; |
|
| 693 | + $current[$tag.'_attr'] = $attributes_data; |
|
| 694 | 694 | } |
| 695 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 695 | + $repeated_tag_index[$tag.'_'.$level] = 1; |
|
| 696 | 696 | |
| 697 | 697 | $current = &$current[$tag]; |
| 698 | 698 | } else { //There was another element with the same tag name |
| 699 | 699 | if (isset($current[$tag][0])) {//If there is a 0th element it is already an array |
| 700 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 701 | - $repeated_tag_index[$tag . '_' . $level]++; |
|
| 700 | + $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; |
|
| 701 | + $repeated_tag_index[$tag.'_'.$level]++; |
|
| 702 | 702 | } else {//This section will make the value an array if multiple tags with the same name appear together |
| 703 | 703 | $current[$tag] = [$current[$tag], $result]; //This will combine the existing item and the new item together to make an array |
| 704 | - $repeated_tag_index[$tag . '_' . $level] = 2; |
|
| 704 | + $repeated_tag_index[$tag.'_'.$level] = 2; |
|
| 705 | 705 | |
| 706 | - if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 707 | - $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 708 | - unset($current[$tag . '_attr']); |
|
| 706 | + if (isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 707 | + $current[$tag]['0_attr'] = $current[$tag.'_attr']; |
|
| 708 | + unset($current[$tag.'_attr']); |
|
| 709 | 709 | } |
| 710 | 710 | } |
| 711 | - $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; |
|
| 711 | + $last_item_index = $repeated_tag_index[$tag.'_'.$level]-1; |
|
| 712 | 712 | $current = &$current[$tag][$last_item_index]; |
| 713 | 713 | } |
| 714 | - } elseif ('complete' === $type) { //Tags that ends in 1 line '<tag>' |
|
| 714 | + } elseif ('complete'===$type) { //Tags that ends in 1 line '<tag>' |
|
| 715 | 715 | //See if the key is already taken. |
| 716 | 716 | if (isset($current[$tag])) { //If taken, put all things inside a list(array) |
| 717 | 717 | if (isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... |
| 718 | 718 | // ...push the new element into that array. |
| 719 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 719 | + $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; |
|
| 720 | 720 | |
| 721 | - if ('tag' === $priority and $get_attributes and $attributes_data) { |
|
| 722 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 721 | + if ('tag'===$priority and $get_attributes and $attributes_data) { |
|
| 722 | + $current[$tag][$repeated_tag_index[$tag.'_'.$level].'_attr'] = $attributes_data; |
|
| 723 | 723 | } |
| 724 | - $repeated_tag_index[$tag . '_' . $level]++; |
|
| 724 | + $repeated_tag_index[$tag.'_'.$level]++; |
|
| 725 | 725 | } else { //If it is not an array... |
| 726 | 726 | $current[$tag] = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value |
| 727 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 728 | - if ('tag' === $priority and $get_attributes) { |
|
| 729 | - if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 730 | - $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 731 | - unset($current[$tag . '_attr']); |
|
| 727 | + $repeated_tag_index[$tag.'_'.$level] = 1; |
|
| 728 | + if ('tag'===$priority and $get_attributes) { |
|
| 729 | + if (isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 730 | + $current[$tag]['0_attr'] = $current[$tag.'_attr']; |
|
| 731 | + unset($current[$tag.'_attr']); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | if ($attributes_data) { |
| 735 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 735 | + $current[$tag][$repeated_tag_index[$tag.'_'.$level].'_attr'] = $attributes_data; |
|
| 736 | 736 | } |
| 737 | 737 | } |
| 738 | - $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken |
|
| 738 | + $repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken |
|
| 739 | 739 | } |
| 740 | 740 | } else { //New Key |
| 741 | 741 | $current[$tag] = $result; |
| 742 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 743 | - if ('tag' === $priority and $attributes_data) { |
|
| 744 | - $current[$tag . '_attr'] = $attributes_data; |
|
| 742 | + $repeated_tag_index[$tag.'_'.$level] = 1; |
|
| 743 | + if ('tag'===$priority and $attributes_data) { |
|
| 744 | + $current[$tag.'_attr'] = $attributes_data; |
|
| 745 | 745 | } |
| 746 | 746 | } |
| 747 | - } elseif ('close' === $type) { //End of tag '</tag>' |
|
| 748 | - $current = &$parent[$level - 1]; |
|
| 747 | + } elseif ('close'===$type) { //End of tag '</tag>' |
|
| 748 | + $current = &$parent[$level-1]; |
|
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | |
@@ -765,10 +765,10 @@ discard block |
||
| 765 | 765 | $output = ''; |
| 766 | 766 | if ($beginning) { |
| 767 | 767 | if ($standalone) { |
| 768 | - header('content-type:text/xml;charset=' . _CHARSET); |
|
| 768 | + header('content-type:text/xml;charset='._CHARSET); |
|
| 769 | 769 | } |
| 770 | - $output .= '<' . '?' . 'xml version="1.0" encoding="' . _CHARSET . '"' . '?' . '>' . "\n"; |
|
| 771 | - $output .= '<' . $name . '>' . "\n"; |
|
| 770 | + $output .= '<'.'?'.'xml version="1.0" encoding="'._CHARSET.'"'.'?'.'>'."\n"; |
|
| 771 | + $output .= '<'.$name.'>'."\n"; |
|
| 772 | 772 | $nested = 0; |
| 773 | 773 | } |
| 774 | 774 | |
@@ -776,26 +776,26 @@ discard block |
||
| 776 | 776 | foreach ($array as $key => $value) { |
| 777 | 777 | ++$nested; |
| 778 | 778 | if (is_array($value)) { |
| 779 | - $output .= str_repeat("\t", (int)$nested) . '<' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 779 | + $output .= str_repeat("\t", (int) $nested).'<'.(is_string($key) ? $key : $name.'_'.$key).'>'."\n"; |
|
| 780 | 780 | ++$nested; |
| 781 | 781 | $output .= static::toXml($value, $name, false, false, $nested); |
| 782 | 782 | $nested--; |
| 783 | - $output .= str_repeat("\t", (int)$nested) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 784 | - } elseif ('' != $value) { |
|
| 783 | + $output .= str_repeat("\t", (int) $nested).'</'.(is_string($key) ? $key : $name.'_'.$key).'>'."\n"; |
|
| 784 | + } elseif (''!=$value) { |
|
| 785 | 785 | ++$nested; |
| 786 | - $output .= str_repeat("\t", (int)$nested) . ' <' . (is_string($key) ? $key : $name . '_' . $key) . '>' . trim($value) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 786 | + $output .= str_repeat("\t", (int) $nested).' <'.(is_string($key) ? $key : $name.'_'.$key).'>'.trim($value).'</'.(is_string($key) ? $key : $name.'_'.$key).'>'."\n"; |
|
| 787 | 787 | $nested--; |
| 788 | 788 | } |
| 789 | 789 | $nested--; |
| 790 | 790 | } |
| 791 | - } elseif ('' != $array) { |
|
| 791 | + } elseif (''!=$array) { |
|
| 792 | 792 | ++$nested; |
| 793 | - $output .= str_repeat("\t", (int)$nested) . trim($array) . "\n"; |
|
| 793 | + $output .= str_repeat("\t", (int) $nested).trim($array)."\n"; |
|
| 794 | 794 | $nested--; |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | if ($beginning) { |
| 798 | - $output .= '</' . $name . '>'; |
|
| 798 | + $output .= '</'.$name.'>'; |
|
| 799 | 799 | |
| 800 | 800 | return $output; |
| 801 | 801 | } |
@@ -11,121 +11,121 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | class GenreHandler extends \XoopsPersistableObjectHandler |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * GenreHandler constructor. |
|
| 16 | - * @param \XoopsDatabase $db |
|
| 17 | - */ |
|
| 18 | - public function __construct(\XoopsDatabase $db) |
|
| 19 | - { |
|
| 20 | - parent::__construct($db, 'songlist_genre', Genre::class, 'gid', 'name'); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * @return array |
|
| 25 | - */ |
|
| 26 | - public function filterFields(): array |
|
| 27 | - { |
|
| 28 | - return ['gid', 'name', 'artists', 'albums', 'songs', 'hits', 'rank', 'votes', 'created', 'updated']; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @param $filter |
|
| 33 | - * @return \CriteriaCompo |
|
| 34 | - */ |
|
| 35 | - public function getFilterCriteria($filter): \CriteriaCompo |
|
| 36 | - { |
|
| 37 | - $parts = \explode('|', $filter); |
|
| 38 | - $criteria = new \CriteriaCompo(); |
|
| 39 | - foreach ($parts as $part) { |
|
| 40 | - $var = \explode(',', $part); |
|
| 41 | - if (!empty($var[1]) && !\is_numeric($var[0])) { |
|
| 42 | - $object = $this->create(); |
|
| 43 | - if (\XOBJ_DTYPE_TXTBOX == $object->vars[$var[0]]['data_type'] |
|
| 44 | - || \XOBJ_DTYPE_TXTAREA == $object->vars[$var[0]]['data_type']) { |
|
| 45 | - $criteria->add(new \Criteria('`' . $var[0] . '`', '%' . $var[1] . '%', ($var[2] ?? 'LIKE'))); |
|
| 46 | - } elseif (in_array($object->vars[$var[0]]['data_type'], [XOBJ_DTYPE_INT, XOBJ_DTYPE_DECIMAL, XOBJ_DTYPE_FLOAT])) { |
|
| 47 | - $criteria->add(new \Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '='))); |
|
| 48 | - } elseif (\XOBJ_DTYPE_ENUM == $object->vars[$var[0]]['data_type']) { |
|
| 49 | - $criteria->add(new \Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '='))); |
|
| 50 | - } elseif (\XOBJ_DTYPE_ARRAY == $object->vars[$var[0]]['data_type']) { |
|
| 51 | - $criteria->add(new \Criteria('`' . $var[0] . '`', '%"' . $var[1] . '";%', ($var[2] ?? 'LIKE'))); |
|
| 52 | - } |
|
| 53 | - } elseif (!empty($var[1]) && \is_numeric($var[0])) { |
|
| 54 | - $criteria->add(new \Criteria($var[0], $var[1])); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - return $criteria; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @param $filter |
|
| 63 | - * @param $field |
|
| 64 | - * @param string $sort |
|
| 65 | - * @param string $op |
|
| 66 | - * @param string $fct |
|
| 67 | - * @return string |
|
| 68 | - */ |
|
| 69 | - public function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list'): string |
|
| 70 | - { |
|
| 71 | - $ele = Utility::getFilterElement($filter, $field, $sort, $op, $fct); |
|
| 72 | - if (\is_object($ele)) { |
|
| 73 | - return $ele->render(); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - return ' '; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @param bool $force |
|
| 81 | - * @return bool|mixed |
|
| 82 | - */ |
|
| 83 | - public function insert(\XoopsObject $obj, $force = true) |
|
| 84 | - { |
|
| 85 | - if ($obj->isNew()) { |
|
| 86 | - $obj->setVar('created', \time()); |
|
| 87 | - } else { |
|
| 88 | - $obj->setVar('updated', \time()); |
|
| 89 | - } |
|
| 90 | - if ('' == $obj->getVar('name')) { |
|
| 91 | - return false; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - return parent::insert($obj, $force); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - public $_objects = ['object' => [], 'array' => []]; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @param null $id |
|
| 101 | - * @param null $fields |
|
| 102 | - * @return \XoopsObject |
|
| 103 | - */ |
|
| 104 | - public function get($id = null, $fields = null): \XoopsObject//get($id, $fields = '*') |
|
| 105 | - { |
|
| 106 | - $fields = $fields ?: '*'; |
|
| 107 | - if (!isset($this->_objects['object'][$id])) { |
|
| 108 | - $this->_objects['object'][$id] = parent::get($id, $fields); |
|
| 109 | - if (!isset($GLOBALS['songlistAdmin']) && \is_object($this->_objects['object'][$id])) { |
|
| 110 | - $sql = 'UPDATE `' . $this->table . '` set hits=hits+1 where `' . $this->keyName . '` = ' . $this->_objects['object'][$id]->getVar($this->keyName); |
|
| 111 | - $GLOBALS['xoopsDB']->queryF($sql); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - return $this->_objects['object'][$id]; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @param \CriteriaElement|\CriteriaCompo $criteria |
|
| 120 | - * @param bool $id_as_key |
|
| 121 | - * @param bool $as_object |
|
| 122 | - * @return array |
|
| 123 | - */ |
|
| 124 | - public function &getObjects($criteria = null, $id_as_key = false, $as_object = true): array |
|
| 125 | - { |
|
| 126 | - $ret = parent::getObjects($criteria, $id_as_key, $as_object); |
|
| 127 | - |
|
| 128 | - /*if (!isset($GLOBALS['songlistAdmin'])) { |
|
| 14 | + /** |
|
| 15 | + * GenreHandler constructor. |
|
| 16 | + * @param \XoopsDatabase $db |
|
| 17 | + */ |
|
| 18 | + public function __construct(\XoopsDatabase $db) |
|
| 19 | + { |
|
| 20 | + parent::__construct($db, 'songlist_genre', Genre::class, 'gid', 'name'); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * @return array |
|
| 25 | + */ |
|
| 26 | + public function filterFields(): array |
|
| 27 | + { |
|
| 28 | + return ['gid', 'name', 'artists', 'albums', 'songs', 'hits', 'rank', 'votes', 'created', 'updated']; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @param $filter |
|
| 33 | + * @return \CriteriaCompo |
|
| 34 | + */ |
|
| 35 | + public function getFilterCriteria($filter): \CriteriaCompo |
|
| 36 | + { |
|
| 37 | + $parts = \explode('|', $filter); |
|
| 38 | + $criteria = new \CriteriaCompo(); |
|
| 39 | + foreach ($parts as $part) { |
|
| 40 | + $var = \explode(',', $part); |
|
| 41 | + if (!empty($var[1]) && !\is_numeric($var[0])) { |
|
| 42 | + $object = $this->create(); |
|
| 43 | + if (\XOBJ_DTYPE_TXTBOX == $object->vars[$var[0]]['data_type'] |
|
| 44 | + || \XOBJ_DTYPE_TXTAREA == $object->vars[$var[0]]['data_type']) { |
|
| 45 | + $criteria->add(new \Criteria('`' . $var[0] . '`', '%' . $var[1] . '%', ($var[2] ?? 'LIKE'))); |
|
| 46 | + } elseif (in_array($object->vars[$var[0]]['data_type'], [XOBJ_DTYPE_INT, XOBJ_DTYPE_DECIMAL, XOBJ_DTYPE_FLOAT])) { |
|
| 47 | + $criteria->add(new \Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '='))); |
|
| 48 | + } elseif (\XOBJ_DTYPE_ENUM == $object->vars[$var[0]]['data_type']) { |
|
| 49 | + $criteria->add(new \Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '='))); |
|
| 50 | + } elseif (\XOBJ_DTYPE_ARRAY == $object->vars[$var[0]]['data_type']) { |
|
| 51 | + $criteria->add(new \Criteria('`' . $var[0] . '`', '%"' . $var[1] . '";%', ($var[2] ?? 'LIKE'))); |
|
| 52 | + } |
|
| 53 | + } elseif (!empty($var[1]) && \is_numeric($var[0])) { |
|
| 54 | + $criteria->add(new \Criteria($var[0], $var[1])); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + return $criteria; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @param $filter |
|
| 63 | + * @param $field |
|
| 64 | + * @param string $sort |
|
| 65 | + * @param string $op |
|
| 66 | + * @param string $fct |
|
| 67 | + * @return string |
|
| 68 | + */ |
|
| 69 | + public function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list'): string |
|
| 70 | + { |
|
| 71 | + $ele = Utility::getFilterElement($filter, $field, $sort, $op, $fct); |
|
| 72 | + if (\is_object($ele)) { |
|
| 73 | + return $ele->render(); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + return ' '; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @param bool $force |
|
| 81 | + * @return bool|mixed |
|
| 82 | + */ |
|
| 83 | + public function insert(\XoopsObject $obj, $force = true) |
|
| 84 | + { |
|
| 85 | + if ($obj->isNew()) { |
|
| 86 | + $obj->setVar('created', \time()); |
|
| 87 | + } else { |
|
| 88 | + $obj->setVar('updated', \time()); |
|
| 89 | + } |
|
| 90 | + if ('' == $obj->getVar('name')) { |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + return parent::insert($obj, $force); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + public $_objects = ['object' => [], 'array' => []]; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @param null $id |
|
| 101 | + * @param null $fields |
|
| 102 | + * @return \XoopsObject |
|
| 103 | + */ |
|
| 104 | + public function get($id = null, $fields = null): \XoopsObject//get($id, $fields = '*') |
|
| 105 | + { |
|
| 106 | + $fields = $fields ?: '*'; |
|
| 107 | + if (!isset($this->_objects['object'][$id])) { |
|
| 108 | + $this->_objects['object'][$id] = parent::get($id, $fields); |
|
| 109 | + if (!isset($GLOBALS['songlistAdmin']) && \is_object($this->_objects['object'][$id])) { |
|
| 110 | + $sql = 'UPDATE `' . $this->table . '` set hits=hits+1 where `' . $this->keyName . '` = ' . $this->_objects['object'][$id]->getVar($this->keyName); |
|
| 111 | + $GLOBALS['xoopsDB']->queryF($sql); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + return $this->_objects['object'][$id]; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @param \CriteriaElement|\CriteriaCompo $criteria |
|
| 120 | + * @param bool $id_as_key |
|
| 121 | + * @param bool $as_object |
|
| 122 | + * @return array |
|
| 123 | + */ |
|
| 124 | + public function &getObjects($criteria = null, $id_as_key = false, $as_object = true): array |
|
| 125 | + { |
|
| 126 | + $ret = parent::getObjects($criteria, $id_as_key, $as_object); |
|
| 127 | + |
|
| 128 | + /*if (!isset($GLOBALS['songlistAdmin'])) { |
|
| 129 | 129 | $id = []; |
| 130 | 130 | foreach($ret as $data) { |
| 131 | 131 | if ($as_object==true) { |
@@ -146,51 +146,51 @@ discard block |
||
| 146 | 146 | $GLOBALS['xoopsDB']->queryF($sql); |
| 147 | 147 | }*/ |
| 148 | 148 | |
| 149 | - return $ret; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * @return string |
|
| 154 | - */ |
|
| 155 | - public function getURL(): string |
|
| 156 | - { |
|
| 157 | - global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit; |
|
| 158 | - if ($GLOBALS['songlistModuleConfig']['htaccess']) { |
|
| 159 | - return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseurl'] . '/' . $file . '/' . $start . '-' . $op . '-' . $fct . '-' . $id . '-' . \urlencode($value) . '-' . $gid . '-' . $cid . $GLOBALS['songlistModuleConfig']['endofurl']; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&cid=' . $cid . '&start=' . $start; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * @param int $limit |
|
| 167 | - * @return array |
|
| 168 | - */ |
|
| 169 | - public function getTop($limit = 1): array |
|
| 170 | - { |
|
| 171 | - $sql = 'SELECT * FROM `' . $this->table . '` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT ' . $limit; |
|
| 172 | - $results = $GLOBALS['xoopsDB']->queryF($sql); |
|
| 173 | - $ret = []; |
|
| 174 | - $i = 0; |
|
| 175 | - while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($results))) { |
|
| 176 | - $ret[$i] = $this->create(); |
|
| 177 | - $ret[$i]->assignVars($row); |
|
| 178 | - ++$i; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - return $ret; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * @param \XoopsObject $object |
|
| 186 | - * @param bool $force |
|
| 187 | - * @return bool |
|
| 188 | - */ |
|
| 189 | - public function delete(\XoopsObject $object, $force = true): bool |
|
| 190 | - { |
|
| 191 | - parent::delete($object, $force); |
|
| 192 | - $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `gid` = 0 WHERE `gid` = ' . $object->getVar('gid'); |
|
| 193 | - |
|
| 194 | - return $GLOBALS['xoopsDB']->queryF($sql); |
|
| 195 | - } |
|
| 149 | + return $ret; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * @return string |
|
| 154 | + */ |
|
| 155 | + public function getURL(): string |
|
| 156 | + { |
|
| 157 | + global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit; |
|
| 158 | + if ($GLOBALS['songlistModuleConfig']['htaccess']) { |
|
| 159 | + return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseurl'] . '/' . $file . '/' . $start . '-' . $op . '-' . $fct . '-' . $id . '-' . \urlencode($value) . '-' . $gid . '-' . $cid . $GLOBALS['songlistModuleConfig']['endofurl']; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&cid=' . $cid . '&start=' . $start; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * @param int $limit |
|
| 167 | + * @return array |
|
| 168 | + */ |
|
| 169 | + public function getTop($limit = 1): array |
|
| 170 | + { |
|
| 171 | + $sql = 'SELECT * FROM `' . $this->table . '` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT ' . $limit; |
|
| 172 | + $results = $GLOBALS['xoopsDB']->queryF($sql); |
|
| 173 | + $ret = []; |
|
| 174 | + $i = 0; |
|
| 175 | + while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($results))) { |
|
| 176 | + $ret[$i] = $this->create(); |
|
| 177 | + $ret[$i]->assignVars($row); |
|
| 178 | + ++$i; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + return $ret; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * @param \XoopsObject $object |
|
| 186 | + * @param bool $force |
|
| 187 | + * @return bool |
|
| 188 | + */ |
|
| 189 | + public function delete(\XoopsObject $object, $force = true): bool |
|
| 190 | + { |
|
| 191 | + parent::delete($object, $force); |
|
| 192 | + $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `gid` = 0 WHERE `gid` = ' . $object->getVar('gid'); |
|
| 193 | + |
|
| 194 | + return $GLOBALS['xoopsDB']->queryF($sql); |
|
| 195 | + } |
|
| 196 | 196 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace XoopsModules\Songlist; |
| 4 | 4 | |
| 5 | -require_once \dirname(__DIR__) . '/include/songlist.object.php'; |
|
| 5 | +require_once \dirname(__DIR__).'/include/songlist.object.php'; |
|
| 6 | 6 | // require_once \dirname(__DIR__) . '/include/songlist.form.php'; |
| 7 | 7 | use XoopsModules\Songlist\Form\FormController; |
| 8 | 8 | |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | $var = \explode(',', $part); |
| 41 | 41 | if (!empty($var[1]) && !\is_numeric($var[0])) { |
| 42 | 42 | $object = $this->create(); |
| 43 | - if (\XOBJ_DTYPE_TXTBOX == $object->vars[$var[0]]['data_type'] |
|
| 44 | - || \XOBJ_DTYPE_TXTAREA == $object->vars[$var[0]]['data_type']) { |
|
| 45 | - $criteria->add(new \Criteria('`' . $var[0] . '`', '%' . $var[1] . '%', ($var[2] ?? 'LIKE'))); |
|
| 43 | + if (\XOBJ_DTYPE_TXTBOX==$object->vars[$var[0]]['data_type'] |
|
| 44 | + || \XOBJ_DTYPE_TXTAREA==$object->vars[$var[0]]['data_type']) { |
|
| 45 | + $criteria->add(new \Criteria('`'.$var[0].'`', '%'.$var[1].'%', ($var[2] ?? 'LIKE'))); |
|
| 46 | 46 | } elseif (in_array($object->vars[$var[0]]['data_type'], [XOBJ_DTYPE_INT, XOBJ_DTYPE_DECIMAL, XOBJ_DTYPE_FLOAT])) { |
| 47 | - $criteria->add(new \Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '='))); |
|
| 48 | - } elseif (\XOBJ_DTYPE_ENUM == $object->vars[$var[0]]['data_type']) { |
|
| 49 | - $criteria->add(new \Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '='))); |
|
| 50 | - } elseif (\XOBJ_DTYPE_ARRAY == $object->vars[$var[0]]['data_type']) { |
|
| 51 | - $criteria->add(new \Criteria('`' . $var[0] . '`', '%"' . $var[1] . '";%', ($var[2] ?? 'LIKE'))); |
|
| 47 | + $criteria->add(new \Criteria('`'.$var[0].'`', $var[1], ($var[2] ?? '='))); |
|
| 48 | + } elseif (\XOBJ_DTYPE_ENUM==$object->vars[$var[0]]['data_type']) { |
|
| 49 | + $criteria->add(new \Criteria('`'.$var[0].'`', $var[1], ($var[2] ?? '='))); |
|
| 50 | + } elseif (\XOBJ_DTYPE_ARRAY==$object->vars[$var[0]]['data_type']) { |
|
| 51 | + $criteria->add(new \Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', ($var[2] ?? 'LIKE'))); |
|
| 52 | 52 | } |
| 53 | 53 | } elseif (!empty($var[1]) && \is_numeric($var[0])) { |
| 54 | 54 | $criteria->add(new \Criteria($var[0], $var[1])); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } else { |
| 88 | 88 | $obj->setVar('updated', \time()); |
| 89 | 89 | } |
| 90 | - if ('' == $obj->getVar('name')) { |
|
| 90 | + if (''==$obj->getVar('name')) { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | if (!isset($this->_objects['object'][$id])) { |
| 108 | 108 | $this->_objects['object'][$id] = parent::get($id, $fields); |
| 109 | 109 | if (!isset($GLOBALS['songlistAdmin']) && \is_object($this->_objects['object'][$id])) { |
| 110 | - $sql = 'UPDATE `' . $this->table . '` set hits=hits+1 where `' . $this->keyName . '` = ' . $this->_objects['object'][$id]->getVar($this->keyName); |
|
| 110 | + $sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName); |
|
| 111 | 111 | $GLOBALS['xoopsDB']->queryF($sql); |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -156,10 +156,10 @@ discard block |
||
| 156 | 156 | { |
| 157 | 157 | global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit; |
| 158 | 158 | if ($GLOBALS['songlistModuleConfig']['htaccess']) { |
| 159 | - return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseurl'] . '/' . $file . '/' . $start . '-' . $op . '-' . $fct . '-' . $id . '-' . \urlencode($value) . '-' . $gid . '-' . $cid . $GLOBALS['songlistModuleConfig']['endofurl']; |
|
| 159 | + return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseurl'].'/'.$file.'/'.$start.'-'.$op.'-'.$fct.'-'.$id.'-'.\urlencode($value).'-'.$gid.'-'.$cid.$GLOBALS['songlistModuleConfig']['endofurl']; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&cid=' . $cid . '&start=' . $start; |
|
| 162 | + return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.\urlencode($value ?? '').'&gid='.$gid.'&cid='.$cid.'&start='.$start; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function getTop($limit = 1): array |
| 170 | 170 | { |
| 171 | - $sql = 'SELECT * FROM `' . $this->table . '` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT ' . $limit; |
|
| 171 | + $sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit; |
|
| 172 | 172 | $results = $GLOBALS['xoopsDB']->queryF($sql); |
| 173 | 173 | $ret = []; |
| 174 | 174 | $i = 0; |
| 175 | - while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($results))) { |
|
| 175 | + while (false!==($row = $GLOBALS['xoopsDB']->fetchArray($results))) { |
|
| 176 | 176 | $ret[$i] = $this->create(); |
| 177 | 177 | $ret[$i]->assignVars($row); |
| 178 | 178 | ++$i; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | public function delete(\XoopsObject $object, $force = true): bool |
| 190 | 190 | { |
| 191 | 191 | parent::delete($object, $force); |
| 192 | - $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `gid` = 0 WHERE `gid` = ' . $object->getVar('gid'); |
|
| 192 | + $sql = 'UPDATE '.$GLOBALS['xoopsDB']->prefix('songlist_songs').' SET `gid` = 0 WHERE `gid` = '.$object->getVar('gid'); |
|
| 193 | 193 | |
| 194 | 194 | return $GLOBALS['xoopsDB']->queryF($sql); |
| 195 | 195 | } |
@@ -11,39 +11,39 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | class Uploader |
| 13 | 13 | {
|
| 14 | - public $mediaName; |
|
| 15 | - public $mediaType; |
|
| 16 | - public $mediaSize; |
|
| 17 | - public $mediaTmpName; |
|
| 18 | - public $mediaError; |
|
| 19 | - public $uploadDir = ''; |
|
| 20 | - public $allowedMimeTypes = []; |
|
| 21 | - public $allowedExtensions = []; |
|
| 22 | - public $maxFileSize = 3299999999; |
|
| 23 | - public $maxWidth; |
|
| 24 | - public $maxHeight; |
|
| 25 | - public $targetFileName; |
|
| 26 | - public $prefix; |
|
| 27 | - public $errors = []; |
|
| 28 | - public $savedDestination; |
|
| 29 | - public $savedFileName; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Constructor |
|
| 33 | - * |
|
| 34 | - * @param string $uploadDir |
|
| 35 | - * @param array $allowedMimeTypes |
|
| 36 | - * @param int $maxFileSize |
|
| 37 | - * @param int $maxWidth |
|
| 38 | - * @param int $maxHeight |
|
| 39 | - * @param array $allowedExtensions |
|
| 40 | - * @internal param int $cmodvalue |
|
| 41 | - */ |
|
| 42 | - public function __construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth = null, $maxHeight = null, $allowedExtensions = null) |
|
| 43 | - {
|
|
| 44 | - if (\is_array($allowedMimeTypes)) {
|
|
| 45 | - $this->allowedMimeTypes = &$allowedMimeTypes; |
|
| 46 | - } |
|
| 14 | + public $mediaName; |
|
| 15 | + public $mediaType; |
|
| 16 | + public $mediaSize; |
|
| 17 | + public $mediaTmpName; |
|
| 18 | + public $mediaError; |
|
| 19 | + public $uploadDir = ''; |
|
| 20 | + public $allowedMimeTypes = []; |
|
| 21 | + public $allowedExtensions = []; |
|
| 22 | + public $maxFileSize = 3299999999; |
|
| 23 | + public $maxWidth; |
|
| 24 | + public $maxHeight; |
|
| 25 | + public $targetFileName; |
|
| 26 | + public $prefix; |
|
| 27 | + public $errors = []; |
|
| 28 | + public $savedDestination; |
|
| 29 | + public $savedFileName; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Constructor |
|
| 33 | + * |
|
| 34 | + * @param string $uploadDir |
|
| 35 | + * @param array $allowedMimeTypes |
|
| 36 | + * @param int $maxFileSize |
|
| 37 | + * @param int $maxWidth |
|
| 38 | + * @param int $maxHeight |
|
| 39 | + * @param array $allowedExtensions |
|
| 40 | + * @internal param int $cmodvalue |
|
| 41 | + */ |
|
| 42 | + public function __construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth = null, $maxHeight = null, $allowedExtensions = null) |
|
| 43 | + {
|
|
| 44 | + if (\is_array($allowedMimeTypes)) {
|
|
| 45 | + $this->allowedMimeTypes = &$allowedMimeTypes; |
|
| 46 | + } |
|
| 47 | 47 | // $this->uploadDir = $uploadDir . (DS != mb_substr($uploadDir, mb_strlen($uploadDir) - 1, 1) ? DS : ''); |
| 48 | 48 | // if (\is_dir($uploadDir)) {
|
| 49 | 49 | // foreach (\explode(DS, $uploadDir) as $folder) {
|
@@ -53,352 +53,352 @@ discard block |
||
| 53 | 53 | // } |
| 54 | 54 | // } |
| 55 | 55 | // } |
| 56 | - $this->uploadDir = $uploadDir; |
|
| 57 | - $this->maxFileSize = (int)$maxFileSize; |
|
| 58 | - if (isset($maxWidth)) {
|
|
| 59 | - $this->maxWidth = (int)$maxWidth; |
|
| 60 | - } |
|
| 61 | - if (isset($maxHeight)) {
|
|
| 62 | - $this->maxHeight = (int)$maxHeight; |
|
| 63 | - } |
|
| 64 | - if (isset($allowedExtensions) && \is_array($allowedExtensions)) {
|
|
| 65 | - $this->allowedExtensions = &$allowedExtensions; |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Fetch the uploaded file |
|
| 71 | - * |
|
| 72 | - * @param $index_name |
|
| 73 | - * @param int $index Index of the file (if more than one uploaded under that name) |
|
| 74 | - * @return bool |
|
| 75 | - * @internal param string $media_name Name of the file field |
|
| 76 | - */ |
|
| 77 | - public function fetchMedia($index_name, $index = null): bool |
|
| 78 | - {
|
|
| 79 | - if (!isset($_FILES[$index_name])) {
|
|
| 80 | - $this->setErrors('File not found');
|
|
| 81 | - |
|
| 82 | - return false; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - if (\is_array($_FILES[$index_name]['name'][$index]) && isset($index)) {
|
|
| 86 | - $this->mediaName = $_FILES[$index_name]['name'][$index]; |
|
| 87 | - $this->mediaType = $_FILES[$index_name]['type'][$index]; |
|
| 88 | - $this->mediaSize = $_FILES[$index_name]['size'][$index]; |
|
| 89 | - $this->mediaTmpName = $_FILES[$index_name]['tmp_name'][$index]; |
|
| 90 | - $this->mediaError = !empty($_FILES[$index_name]['error'][$index]) ? $_FILES[$index_name]['errir'][$index] : 0; |
|
| 91 | - } else {
|
|
| 92 | - $this->mediaName = $_FILES[$index_name]['name']; |
|
| 93 | - $this->mediaType = $_FILES[$index_name]['type']; |
|
| 94 | - $this->mediaSize = $_FILES[$index_name]['size']; |
|
| 95 | - $this->mediaTmpName = $_FILES[$index_name]['tmp_name']; |
|
| 96 | - $this->mediaError = !empty($_FILES[$index_name]['error']) ? $_FILES[$index_name]['error'] : 0; |
|
| 97 | - } |
|
| 98 | - $this->errors = []; |
|
| 99 | - if ((int)$this->mediaSize < 0) {
|
|
| 100 | - $this->setErrors('Invalid File Size');
|
|
| 101 | - |
|
| 102 | - return false; |
|
| 103 | - } |
|
| 104 | - if ('' == $this->mediaName) {
|
|
| 105 | - $this->setErrors('Filename Is Empty');
|
|
| 106 | - |
|
| 107 | - return false; |
|
| 108 | - } |
|
| 109 | - if ('none' === $this->mediaTmpName || !\is_uploaded_file($this->mediaTmpName) || 0 == $this->mediaSize) {
|
|
| 110 | - $this->setErrors('No file uploaded');
|
|
| 111 | - |
|
| 112 | - return false; |
|
| 113 | - } |
|
| 114 | - if ($this->mediaError > 0) {
|
|
| 115 | - $this->setErrors('Error occurred: Error #' . $this->mediaError);
|
|
| 116 | - |
|
| 117 | - return false; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - return true; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Set the target filename |
|
| 125 | - * |
|
| 126 | - * @param string $value |
|
| 127 | - **/ |
|
| 128 | - public function setTargetFileName(string $value): void |
|
| 129 | - {
|
|
| 130 | - $this->targetFileName = \trim($value); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Set the prefix |
|
| 135 | - * |
|
| 136 | - * @param string $value |
|
| 137 | - **/ |
|
| 138 | - public function setPrefix($value): void |
|
| 139 | - {
|
|
| 140 | - $this->prefix = \trim($value); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Get the uploaded filename |
|
| 145 | - * |
|
| 146 | - * @return string |
|
| 147 | - **/ |
|
| 148 | - public function getMediaName(): string |
|
| 149 | - {
|
|
| 150 | - return $this->mediaName; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Get the type of the uploaded file |
|
| 155 | - * |
|
| 156 | - * @return string |
|
| 157 | - **/ |
|
| 158 | - public function getMediaType(): string |
|
| 159 | - {
|
|
| 160 | - return $this->mediaType; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Get the size of the uploaded file |
|
| 165 | - * |
|
| 166 | - * @return int |
|
| 167 | - **/ |
|
| 168 | - public function getMediaSize(): int |
|
| 169 | - {
|
|
| 170 | - return $this->mediaSize; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Get the temporary name that the uploaded file was stored under |
|
| 175 | - * |
|
| 176 | - * @return string |
|
| 177 | - **/ |
|
| 178 | - public function getMediaTmpName(): string |
|
| 179 | - {
|
|
| 180 | - return $this->mediaTmpName; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * Get the saved filename |
|
| 185 | - * |
|
| 186 | - * @return string |
|
| 187 | - **/ |
|
| 188 | - public function getSavedFileName(): string |
|
| 189 | - {
|
|
| 190 | - return $this->savedFileName; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Get the destination the file is saved to |
|
| 195 | - * |
|
| 196 | - * @return string |
|
| 197 | - **/ |
|
| 198 | - public function getSavedDestination(): string |
|
| 199 | - {
|
|
| 200 | - return $this->savedDestination; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Check the file and copy it to the destination |
|
| 205 | - * |
|
| 206 | - * @param int $chmod |
|
| 207 | - * @return bool |
|
| 208 | - */ |
|
| 209 | - public function upload($chmod = 0644): bool |
|
| 210 | - {
|
|
| 211 | - if ('' == $this->uploadDir) {
|
|
| 212 | - $this->setErrors('Upload directory not set');
|
|
| 213 | - |
|
| 214 | - return false; |
|
| 215 | - } |
|
| 216 | - if (!\is_dir($this->uploadDir)) {
|
|
| 217 | - $this->setErrors('Failed opening directory: ' . $this->uploadDir);
|
|
| 218 | - |
|
| 219 | - return false; |
|
| 220 | - } |
|
| 221 | - if (!\is_writable($this->uploadDir)) {
|
|
| 222 | - $this->setErrors('Failed opening directory with write permission: ' . $this->uploadDir);
|
|
| 223 | - |
|
| 224 | - return false; |
|
| 225 | - } |
|
| 226 | - if (!$this->checkMimeType()) {
|
|
| 227 | - $this->setErrors('MIME type not allowed: ' . $this->mediaType);
|
|
| 228 | - |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 231 | - if (!$this->checkExtension()) {
|
|
| 232 | - $this->setErrors('Extension not allowed');
|
|
| 233 | - |
|
| 234 | - return false; |
|
| 235 | - } |
|
| 236 | - if (!$this->checkMaxFileSize()) {
|
|
| 237 | - $this->setErrors('File size too large: ' . $this->mediaSize);
|
|
| 238 | - } |
|
| 239 | - if (!$this->checkMaxWidth()) {
|
|
| 240 | - $this->setErrors(\sprintf('File width must be smaller than %u', $this->maxWidth));
|
|
| 241 | - } |
|
| 242 | - if (!$this->checkMaxHeight()) {
|
|
| 243 | - $this->setErrors(\sprintf('File height must be smaller than %u', $this->maxHeight));
|
|
| 244 | - } |
|
| 245 | - if (\count($this->errors) > 0) {
|
|
| 246 | - return false; |
|
| 247 | - } |
|
| 248 | - if (!$this->_copyFile($chmod)) {
|
|
| 249 | - $this->setErrors('Failed uploading file: ' . $this->mediaName);
|
|
| 250 | - |
|
| 251 | - return false; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - return true; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * Copy the file to its destination |
|
| 259 | - * |
|
| 260 | - * @param $chmod |
|
| 261 | - * @return bool |
|
| 262 | - */ |
|
| 263 | - public function _copyFile($chmod): bool |
|
| 264 | - {
|
|
| 265 | - $matched = []; |
|
| 266 | - if (!\preg_match('/\.([a-zA-Z0-9]+)$/', $this->mediaName, $matched)) {
|
|
| 267 | - return false; |
|
| 268 | - } |
|
| 269 | - if (isset($this->targetFileName)) {
|
|
| 270 | - $this->savedFileName = $this->targetFileName; |
|
| 271 | - } elseif (isset($this->prefix)) {
|
|
| 272 | - $this->savedFileName = \uniqid($this->prefix, true) . '.' . \mb_strtolower($matched[1]); |
|
| 273 | - } else {
|
|
| 274 | - $this->savedFileName = \mb_strtolower($this->mediaName); |
|
| 275 | - } |
|
| 276 | - $this->savedDestination = $this->uploadDir . '/' . $this->savedFileName; |
|
| 277 | - if (!\move_uploaded_file($this->mediaTmpName, $this->savedDestination)) {
|
|
| 278 | - return false; |
|
| 279 | - } |
|
| 280 | - @\chmod($this->savedDestination, $chmod); |
|
| 281 | - |
|
| 282 | - return true; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * Is the file the right size? |
|
| 287 | - * |
|
| 288 | - * @return bool |
|
| 289 | - **/ |
|
| 290 | - public function checkMaxFileSize(): bool |
|
| 291 | - {
|
|
| 292 | - if ($this->mediaSize > $this->maxFileSize) {
|
|
| 293 | - return false; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - return true; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * Is the picture the right width? |
|
| 301 | - * |
|
| 302 | - * @return bool |
|
| 303 | - **/ |
|
| 304 | - public function checkMaxWidth(): bool |
|
| 305 | - {
|
|
| 306 | - if (!isset($this->maxWidth) || $this->maxWidth < 1) {
|
|
| 307 | - return true; |
|
| 308 | - } |
|
| 309 | - if (false !== $dimension = \getimagesize($this->mediaTmpName)) {
|
|
| 310 | - if ($dimension[0] > $this->maxWidth) {
|
|
| 311 | - return false; |
|
| 312 | - } |
|
| 313 | - } else {
|
|
| 314 | - \trigger_error(\sprintf('Failed fetching image size of %s, skipping max width check..', $this->mediaTmpName), \E_USER_WARNING);
|
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - return true; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - /** |
|
| 321 | - * Is the picture the right height? |
|
| 322 | - * |
|
| 323 | - * @return bool |
|
| 324 | - **/ |
|
| 325 | - public function checkMaxHeight(): bool |
|
| 326 | - {
|
|
| 327 | - if (!isset($this->maxHeight) || $this->maxHeight < 1) {
|
|
| 328 | - return true; |
|
| 329 | - } |
|
| 330 | - if (false !== $dimension = \getimagesize($this->mediaTmpName)) {
|
|
| 331 | - if ($dimension[1] > $this->maxHeight) {
|
|
| 332 | - return false; |
|
| 333 | - } |
|
| 334 | - } else {
|
|
| 335 | - \trigger_error(\sprintf('Failed fetching image size of %s, skipping max height check..', $this->mediaTmpName), \E_USER_WARNING);
|
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - return true; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * Is the file the right Mime type |
|
| 343 | - * |
|
| 344 | - * (is there a right type of mime? ;-) |
|
| 345 | - * |
|
| 346 | - * @return bool |
|
| 347 | - **/ |
|
| 348 | - public function checkMimeType(): bool |
|
| 349 | - {
|
|
| 350 | - if (\count($this->allowedMimeTypes) > 0 && !\in_array($this->mediaType, $this->allowedMimeTypes, true)) {
|
|
| 351 | - return false; |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - return true; |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * Is the file the right extension |
|
| 359 | - * |
|
| 360 | - * @return bool |
|
| 361 | - **/ |
|
| 362 | - public function checkExtension(): bool |
|
| 363 | - {
|
|
| 364 | - $ext = mb_substr(mb_strrchr($this->mediaName, '.'), 1); |
|
| 365 | - if (!empty($this->allowedExtensions) && !\in_array(mb_strtolower($ext), $this->allowedExtensions, true)) {
|
|
| 366 | - return false; |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - return true; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Add an error |
|
| 374 | - * |
|
| 375 | - * @param string $error |
|
| 376 | - **/ |
|
| 377 | - public function setErrors($error): void |
|
| 378 | - {
|
|
| 379 | - $this->errors[] = \trim($error); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * Get generated errors |
|
| 384 | - * |
|
| 385 | - * @param bool $ashtml Format using HTML? |
|
| 386 | - * |
|
| 387 | - * @return array|string Array of array messages OR HTML string |
|
| 388 | - */ |
|
| 389 | - public function &getErrors($ashtml = true) |
|
| 390 | - {
|
|
| 391 | - if (!$ashtml) {
|
|
| 392 | - return $this->errors; |
|
| 393 | - } |
|
| 394 | - $ret = ''; |
|
| 395 | - if (\count($this->errors) > 0) {
|
|
| 396 | - $ret = '<h4>Errors Returned While Uploading</h4>'; |
|
| 397 | - foreach ($this->errors as $error) {
|
|
| 398 | - $ret .= $error . '<br>'; |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - return $ret; |
|
| 403 | - } |
|
| 56 | + $this->uploadDir = $uploadDir; |
|
| 57 | + $this->maxFileSize = (int)$maxFileSize; |
|
| 58 | + if (isset($maxWidth)) {
|
|
| 59 | + $this->maxWidth = (int)$maxWidth; |
|
| 60 | + } |
|
| 61 | + if (isset($maxHeight)) {
|
|
| 62 | + $this->maxHeight = (int)$maxHeight; |
|
| 63 | + } |
|
| 64 | + if (isset($allowedExtensions) && \is_array($allowedExtensions)) {
|
|
| 65 | + $this->allowedExtensions = &$allowedExtensions; |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Fetch the uploaded file |
|
| 71 | + * |
|
| 72 | + * @param $index_name |
|
| 73 | + * @param int $index Index of the file (if more than one uploaded under that name) |
|
| 74 | + * @return bool |
|
| 75 | + * @internal param string $media_name Name of the file field |
|
| 76 | + */ |
|
| 77 | + public function fetchMedia($index_name, $index = null): bool |
|
| 78 | + {
|
|
| 79 | + if (!isset($_FILES[$index_name])) {
|
|
| 80 | + $this->setErrors('File not found');
|
|
| 81 | + |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + if (\is_array($_FILES[$index_name]['name'][$index]) && isset($index)) {
|
|
| 86 | + $this->mediaName = $_FILES[$index_name]['name'][$index]; |
|
| 87 | + $this->mediaType = $_FILES[$index_name]['type'][$index]; |
|
| 88 | + $this->mediaSize = $_FILES[$index_name]['size'][$index]; |
|
| 89 | + $this->mediaTmpName = $_FILES[$index_name]['tmp_name'][$index]; |
|
| 90 | + $this->mediaError = !empty($_FILES[$index_name]['error'][$index]) ? $_FILES[$index_name]['errir'][$index] : 0; |
|
| 91 | + } else {
|
|
| 92 | + $this->mediaName = $_FILES[$index_name]['name']; |
|
| 93 | + $this->mediaType = $_FILES[$index_name]['type']; |
|
| 94 | + $this->mediaSize = $_FILES[$index_name]['size']; |
|
| 95 | + $this->mediaTmpName = $_FILES[$index_name]['tmp_name']; |
|
| 96 | + $this->mediaError = !empty($_FILES[$index_name]['error']) ? $_FILES[$index_name]['error'] : 0; |
|
| 97 | + } |
|
| 98 | + $this->errors = []; |
|
| 99 | + if ((int)$this->mediaSize < 0) {
|
|
| 100 | + $this->setErrors('Invalid File Size');
|
|
| 101 | + |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 104 | + if ('' == $this->mediaName) {
|
|
| 105 | + $this->setErrors('Filename Is Empty');
|
|
| 106 | + |
|
| 107 | + return false; |
|
| 108 | + } |
|
| 109 | + if ('none' === $this->mediaTmpName || !\is_uploaded_file($this->mediaTmpName) || 0 == $this->mediaSize) {
|
|
| 110 | + $this->setErrors('No file uploaded');
|
|
| 111 | + |
|
| 112 | + return false; |
|
| 113 | + } |
|
| 114 | + if ($this->mediaError > 0) {
|
|
| 115 | + $this->setErrors('Error occurred: Error #' . $this->mediaError);
|
|
| 116 | + |
|
| 117 | + return false; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + return true; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Set the target filename |
|
| 125 | + * |
|
| 126 | + * @param string $value |
|
| 127 | + **/ |
|
| 128 | + public function setTargetFileName(string $value): void |
|
| 129 | + {
|
|
| 130 | + $this->targetFileName = \trim($value); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Set the prefix |
|
| 135 | + * |
|
| 136 | + * @param string $value |
|
| 137 | + **/ |
|
| 138 | + public function setPrefix($value): void |
|
| 139 | + {
|
|
| 140 | + $this->prefix = \trim($value); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Get the uploaded filename |
|
| 145 | + * |
|
| 146 | + * @return string |
|
| 147 | + **/ |
|
| 148 | + public function getMediaName(): string |
|
| 149 | + {
|
|
| 150 | + return $this->mediaName; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Get the type of the uploaded file |
|
| 155 | + * |
|
| 156 | + * @return string |
|
| 157 | + **/ |
|
| 158 | + public function getMediaType(): string |
|
| 159 | + {
|
|
| 160 | + return $this->mediaType; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Get the size of the uploaded file |
|
| 165 | + * |
|
| 166 | + * @return int |
|
| 167 | + **/ |
|
| 168 | + public function getMediaSize(): int |
|
| 169 | + {
|
|
| 170 | + return $this->mediaSize; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Get the temporary name that the uploaded file was stored under |
|
| 175 | + * |
|
| 176 | + * @return string |
|
| 177 | + **/ |
|
| 178 | + public function getMediaTmpName(): string |
|
| 179 | + {
|
|
| 180 | + return $this->mediaTmpName; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * Get the saved filename |
|
| 185 | + * |
|
| 186 | + * @return string |
|
| 187 | + **/ |
|
| 188 | + public function getSavedFileName(): string |
|
| 189 | + {
|
|
| 190 | + return $this->savedFileName; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Get the destination the file is saved to |
|
| 195 | + * |
|
| 196 | + * @return string |
|
| 197 | + **/ |
|
| 198 | + public function getSavedDestination(): string |
|
| 199 | + {
|
|
| 200 | + return $this->savedDestination; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Check the file and copy it to the destination |
|
| 205 | + * |
|
| 206 | + * @param int $chmod |
|
| 207 | + * @return bool |
|
| 208 | + */ |
|
| 209 | + public function upload($chmod = 0644): bool |
|
| 210 | + {
|
|
| 211 | + if ('' == $this->uploadDir) {
|
|
| 212 | + $this->setErrors('Upload directory not set');
|
|
| 213 | + |
|
| 214 | + return false; |
|
| 215 | + } |
|
| 216 | + if (!\is_dir($this->uploadDir)) {
|
|
| 217 | + $this->setErrors('Failed opening directory: ' . $this->uploadDir);
|
|
| 218 | + |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 221 | + if (!\is_writable($this->uploadDir)) {
|
|
| 222 | + $this->setErrors('Failed opening directory with write permission: ' . $this->uploadDir);
|
|
| 223 | + |
|
| 224 | + return false; |
|
| 225 | + } |
|
| 226 | + if (!$this->checkMimeType()) {
|
|
| 227 | + $this->setErrors('MIME type not allowed: ' . $this->mediaType);
|
|
| 228 | + |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | + if (!$this->checkExtension()) {
|
|
| 232 | + $this->setErrors('Extension not allowed');
|
|
| 233 | + |
|
| 234 | + return false; |
|
| 235 | + } |
|
| 236 | + if (!$this->checkMaxFileSize()) {
|
|
| 237 | + $this->setErrors('File size too large: ' . $this->mediaSize);
|
|
| 238 | + } |
|
| 239 | + if (!$this->checkMaxWidth()) {
|
|
| 240 | + $this->setErrors(\sprintf('File width must be smaller than %u', $this->maxWidth));
|
|
| 241 | + } |
|
| 242 | + if (!$this->checkMaxHeight()) {
|
|
| 243 | + $this->setErrors(\sprintf('File height must be smaller than %u', $this->maxHeight));
|
|
| 244 | + } |
|
| 245 | + if (\count($this->errors) > 0) {
|
|
| 246 | + return false; |
|
| 247 | + } |
|
| 248 | + if (!$this->_copyFile($chmod)) {
|
|
| 249 | + $this->setErrors('Failed uploading file: ' . $this->mediaName);
|
|
| 250 | + |
|
| 251 | + return false; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + return true; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * Copy the file to its destination |
|
| 259 | + * |
|
| 260 | + * @param $chmod |
|
| 261 | + * @return bool |
|
| 262 | + */ |
|
| 263 | + public function _copyFile($chmod): bool |
|
| 264 | + {
|
|
| 265 | + $matched = []; |
|
| 266 | + if (!\preg_match('/\.([a-zA-Z0-9]+)$/', $this->mediaName, $matched)) {
|
|
| 267 | + return false; |
|
| 268 | + } |
|
| 269 | + if (isset($this->targetFileName)) {
|
|
| 270 | + $this->savedFileName = $this->targetFileName; |
|
| 271 | + } elseif (isset($this->prefix)) {
|
|
| 272 | + $this->savedFileName = \uniqid($this->prefix, true) . '.' . \mb_strtolower($matched[1]); |
|
| 273 | + } else {
|
|
| 274 | + $this->savedFileName = \mb_strtolower($this->mediaName); |
|
| 275 | + } |
|
| 276 | + $this->savedDestination = $this->uploadDir . '/' . $this->savedFileName; |
|
| 277 | + if (!\move_uploaded_file($this->mediaTmpName, $this->savedDestination)) {
|
|
| 278 | + return false; |
|
| 279 | + } |
|
| 280 | + @\chmod($this->savedDestination, $chmod); |
|
| 281 | + |
|
| 282 | + return true; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * Is the file the right size? |
|
| 287 | + * |
|
| 288 | + * @return bool |
|
| 289 | + **/ |
|
| 290 | + public function checkMaxFileSize(): bool |
|
| 291 | + {
|
|
| 292 | + if ($this->mediaSize > $this->maxFileSize) {
|
|
| 293 | + return false; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + return true; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * Is the picture the right width? |
|
| 301 | + * |
|
| 302 | + * @return bool |
|
| 303 | + **/ |
|
| 304 | + public function checkMaxWidth(): bool |
|
| 305 | + {
|
|
| 306 | + if (!isset($this->maxWidth) || $this->maxWidth < 1) {
|
|
| 307 | + return true; |
|
| 308 | + } |
|
| 309 | + if (false !== $dimension = \getimagesize($this->mediaTmpName)) {
|
|
| 310 | + if ($dimension[0] > $this->maxWidth) {
|
|
| 311 | + return false; |
|
| 312 | + } |
|
| 313 | + } else {
|
|
| 314 | + \trigger_error(\sprintf('Failed fetching image size of %s, skipping max width check..', $this->mediaTmpName), \E_USER_WARNING);
|
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + return true; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + /** |
|
| 321 | + * Is the picture the right height? |
|
| 322 | + * |
|
| 323 | + * @return bool |
|
| 324 | + **/ |
|
| 325 | + public function checkMaxHeight(): bool |
|
| 326 | + {
|
|
| 327 | + if (!isset($this->maxHeight) || $this->maxHeight < 1) {
|
|
| 328 | + return true; |
|
| 329 | + } |
|
| 330 | + if (false !== $dimension = \getimagesize($this->mediaTmpName)) {
|
|
| 331 | + if ($dimension[1] > $this->maxHeight) {
|
|
| 332 | + return false; |
|
| 333 | + } |
|
| 334 | + } else {
|
|
| 335 | + \trigger_error(\sprintf('Failed fetching image size of %s, skipping max height check..', $this->mediaTmpName), \E_USER_WARNING);
|
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + return true; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * Is the file the right Mime type |
|
| 343 | + * |
|
| 344 | + * (is there a right type of mime? ;-) |
|
| 345 | + * |
|
| 346 | + * @return bool |
|
| 347 | + **/ |
|
| 348 | + public function checkMimeType(): bool |
|
| 349 | + {
|
|
| 350 | + if (\count($this->allowedMimeTypes) > 0 && !\in_array($this->mediaType, $this->allowedMimeTypes, true)) {
|
|
| 351 | + return false; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + return true; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * Is the file the right extension |
|
| 359 | + * |
|
| 360 | + * @return bool |
|
| 361 | + **/ |
|
| 362 | + public function checkExtension(): bool |
|
| 363 | + {
|
|
| 364 | + $ext = mb_substr(mb_strrchr($this->mediaName, '.'), 1); |
|
| 365 | + if (!empty($this->allowedExtensions) && !\in_array(mb_strtolower($ext), $this->allowedExtensions, true)) {
|
|
| 366 | + return false; |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + return true; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * Add an error |
|
| 374 | + * |
|
| 375 | + * @param string $error |
|
| 376 | + **/ |
|
| 377 | + public function setErrors($error): void |
|
| 378 | + {
|
|
| 379 | + $this->errors[] = \trim($error); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * Get generated errors |
|
| 384 | + * |
|
| 385 | + * @param bool $ashtml Format using HTML? |
|
| 386 | + * |
|
| 387 | + * @return array|string Array of array messages OR HTML string |
|
| 388 | + */ |
|
| 389 | + public function &getErrors($ashtml = true) |
|
| 390 | + {
|
|
| 391 | + if (!$ashtml) {
|
|
| 392 | + return $this->errors; |
|
| 393 | + } |
|
| 394 | + $ret = ''; |
|
| 395 | + if (\count($this->errors) > 0) {
|
|
| 396 | + $ret = '<h4>Errors Returned While Uploading</h4>'; |
|
| 397 | + foreach ($this->errors as $error) {
|
|
| 398 | + $ret .= $error . '<br>'; |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + return $ret; |
|
| 403 | + } |
|
| 404 | 404 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | public $maxHeight; |
| 25 | 25 | public $targetFileName; |
| 26 | 26 | public $prefix; |
| 27 | - public $errors = []; |
|
| 27 | + public $errors = []; |
|
| 28 | 28 | public $savedDestination; |
| 29 | 29 | public $savedFileName; |
| 30 | 30 | |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | // } |
| 55 | 55 | // } |
| 56 | 56 | $this->uploadDir = $uploadDir; |
| 57 | - $this->maxFileSize = (int)$maxFileSize; |
|
| 57 | + $this->maxFileSize = (int) $maxFileSize; |
|
| 58 | 58 | if (isset($maxWidth)) {
|
| 59 | - $this->maxWidth = (int)$maxWidth; |
|
| 59 | + $this->maxWidth = (int) $maxWidth; |
|
| 60 | 60 | } |
| 61 | 61 | if (isset($maxHeight)) {
|
| 62 | - $this->maxHeight = (int)$maxHeight; |
|
| 62 | + $this->maxHeight = (int) $maxHeight; |
|
| 63 | 63 | } |
| 64 | 64 | if (isset($allowedExtensions) && \is_array($allowedExtensions)) {
|
| 65 | 65 | $this->allowedExtensions = &$allowedExtensions; |
@@ -96,23 +96,23 @@ discard block |
||
| 96 | 96 | $this->mediaError = !empty($_FILES[$index_name]['error']) ? $_FILES[$index_name]['error'] : 0; |
| 97 | 97 | } |
| 98 | 98 | $this->errors = []; |
| 99 | - if ((int)$this->mediaSize < 0) {
|
|
| 99 | + if ((int) $this->mediaSize<0) {
|
|
| 100 | 100 | $this->setErrors('Invalid File Size');
|
| 101 | 101 | |
| 102 | 102 | return false; |
| 103 | 103 | } |
| 104 | - if ('' == $this->mediaName) {
|
|
| 104 | + if (''==$this->mediaName) {
|
|
| 105 | 105 | $this->setErrors('Filename Is Empty');
|
| 106 | 106 | |
| 107 | 107 | return false; |
| 108 | 108 | } |
| 109 | - if ('none' === $this->mediaTmpName || !\is_uploaded_file($this->mediaTmpName) || 0 == $this->mediaSize) {
|
|
| 109 | + if ('none'===$this->mediaTmpName || !\is_uploaded_file($this->mediaTmpName) || 0==$this->mediaSize) {
|
|
| 110 | 110 | $this->setErrors('No file uploaded');
|
| 111 | 111 | |
| 112 | 112 | return false; |
| 113 | 113 | } |
| 114 | - if ($this->mediaError > 0) {
|
|
| 115 | - $this->setErrors('Error occurred: Error #' . $this->mediaError);
|
|
| 114 | + if ($this->mediaError>0) {
|
|
| 115 | + $this->setErrors('Error occurred: Error #'.$this->mediaError);
|
|
| 116 | 116 | |
| 117 | 117 | return false; |
| 118 | 118 | } |
@@ -208,23 +208,23 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function upload($chmod = 0644): bool |
| 210 | 210 | {
|
| 211 | - if ('' == $this->uploadDir) {
|
|
| 211 | + if (''==$this->uploadDir) {
|
|
| 212 | 212 | $this->setErrors('Upload directory not set');
|
| 213 | 213 | |
| 214 | 214 | return false; |
| 215 | 215 | } |
| 216 | 216 | if (!\is_dir($this->uploadDir)) {
|
| 217 | - $this->setErrors('Failed opening directory: ' . $this->uploadDir);
|
|
| 217 | + $this->setErrors('Failed opening directory: '.$this->uploadDir);
|
|
| 218 | 218 | |
| 219 | 219 | return false; |
| 220 | 220 | } |
| 221 | 221 | if (!\is_writable($this->uploadDir)) {
|
| 222 | - $this->setErrors('Failed opening directory with write permission: ' . $this->uploadDir);
|
|
| 222 | + $this->setErrors('Failed opening directory with write permission: '.$this->uploadDir);
|
|
| 223 | 223 | |
| 224 | 224 | return false; |
| 225 | 225 | } |
| 226 | 226 | if (!$this->checkMimeType()) {
|
| 227 | - $this->setErrors('MIME type not allowed: ' . $this->mediaType);
|
|
| 227 | + $this->setErrors('MIME type not allowed: '.$this->mediaType);
|
|
| 228 | 228 | |
| 229 | 229 | return false; |
| 230 | 230 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | if (!$this->checkMaxFileSize()) {
|
| 237 | - $this->setErrors('File size too large: ' . $this->mediaSize);
|
|
| 237 | + $this->setErrors('File size too large: '.$this->mediaSize);
|
|
| 238 | 238 | } |
| 239 | 239 | if (!$this->checkMaxWidth()) {
|
| 240 | 240 | $this->setErrors(\sprintf('File width must be smaller than %u', $this->maxWidth));
|
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | if (!$this->checkMaxHeight()) {
|
| 243 | 243 | $this->setErrors(\sprintf('File height must be smaller than %u', $this->maxHeight));
|
| 244 | 244 | } |
| 245 | - if (\count($this->errors) > 0) {
|
|
| 245 | + if (\count($this->errors)>0) {
|
|
| 246 | 246 | return false; |
| 247 | 247 | } |
| 248 | 248 | if (!$this->_copyFile($chmod)) {
|
| 249 | - $this->setErrors('Failed uploading file: ' . $this->mediaName);
|
|
| 249 | + $this->setErrors('Failed uploading file: '.$this->mediaName);
|
|
| 250 | 250 | |
| 251 | 251 | return false; |
| 252 | 252 | } |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | if (isset($this->targetFileName)) {
|
| 270 | 270 | $this->savedFileName = $this->targetFileName; |
| 271 | 271 | } elseif (isset($this->prefix)) {
|
| 272 | - $this->savedFileName = \uniqid($this->prefix, true) . '.' . \mb_strtolower($matched[1]); |
|
| 272 | + $this->savedFileName = \uniqid($this->prefix, true).'.'.\mb_strtolower($matched[1]); |
|
| 273 | 273 | } else {
|
| 274 | 274 | $this->savedFileName = \mb_strtolower($this->mediaName); |
| 275 | 275 | } |
| 276 | - $this->savedDestination = $this->uploadDir . '/' . $this->savedFileName; |
|
| 276 | + $this->savedDestination = $this->uploadDir.'/'.$this->savedFileName; |
|
| 277 | 277 | if (!\move_uploaded_file($this->mediaTmpName, $this->savedDestination)) {
|
| 278 | 278 | return false; |
| 279 | 279 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | **/ |
| 290 | 290 | public function checkMaxFileSize(): bool |
| 291 | 291 | {
|
| 292 | - if ($this->mediaSize > $this->maxFileSize) {
|
|
| 292 | + if ($this->mediaSize>$this->maxFileSize) {
|
|
| 293 | 293 | return false; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -303,11 +303,11 @@ discard block |
||
| 303 | 303 | **/ |
| 304 | 304 | public function checkMaxWidth(): bool |
| 305 | 305 | {
|
| 306 | - if (!isset($this->maxWidth) || $this->maxWidth < 1) {
|
|
| 306 | + if (!isset($this->maxWidth) || $this->maxWidth<1) {
|
|
| 307 | 307 | return true; |
| 308 | 308 | } |
| 309 | - if (false !== $dimension = \getimagesize($this->mediaTmpName)) {
|
|
| 310 | - if ($dimension[0] > $this->maxWidth) {
|
|
| 309 | + if (false!==$dimension = \getimagesize($this->mediaTmpName)) {
|
|
| 310 | + if ($dimension[0]>$this->maxWidth) {
|
|
| 311 | 311 | return false; |
| 312 | 312 | } |
| 313 | 313 | } else {
|
@@ -324,11 +324,11 @@ discard block |
||
| 324 | 324 | **/ |
| 325 | 325 | public function checkMaxHeight(): bool |
| 326 | 326 | {
|
| 327 | - if (!isset($this->maxHeight) || $this->maxHeight < 1) {
|
|
| 327 | + if (!isset($this->maxHeight) || $this->maxHeight<1) {
|
|
| 328 | 328 | return true; |
| 329 | 329 | } |
| 330 | - if (false !== $dimension = \getimagesize($this->mediaTmpName)) {
|
|
| 331 | - if ($dimension[1] > $this->maxHeight) {
|
|
| 330 | + if (false!==$dimension = \getimagesize($this->mediaTmpName)) {
|
|
| 331 | + if ($dimension[1]>$this->maxHeight) {
|
|
| 332 | 332 | return false; |
| 333 | 333 | } |
| 334 | 334 | } else {
|
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | **/ |
| 348 | 348 | public function checkMimeType(): bool |
| 349 | 349 | {
|
| 350 | - if (\count($this->allowedMimeTypes) > 0 && !\in_array($this->mediaType, $this->allowedMimeTypes, true)) {
|
|
| 350 | + if (\count($this->allowedMimeTypes)>0 && !\in_array($this->mediaType, $this->allowedMimeTypes, true)) {
|
|
| 351 | 351 | return false; |
| 352 | 352 | } |
| 353 | 353 | |
@@ -392,10 +392,10 @@ discard block |
||
| 392 | 392 | return $this->errors; |
| 393 | 393 | } |
| 394 | 394 | $ret = ''; |
| 395 | - if (\count($this->errors) > 0) {
|
|
| 395 | + if (\count($this->errors)>0) {
|
|
| 396 | 396 | $ret = '<h4>Errors Returned While Uploading</h4>'; |
| 397 | 397 | foreach ($this->errors as $error) {
|
| 398 | - $ret .= $error . '<br>'; |
|
| 398 | + $ret .= $error.'<br>'; |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
@@ -23,57 +23,57 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Helper extends \Xmf\Module\Helper |
| 25 | 25 | { |
| 26 | - public $debug; |
|
| 26 | + public $debug; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @param bool $debug |
|
| 30 | - */ |
|
| 31 | - public function __construct($debug = false) |
|
| 32 | - { |
|
| 33 | - $this->debug = $debug; |
|
| 34 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 35 | - parent::__construct($moduleDirName); |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * @param bool $debug |
|
| 30 | + */ |
|
| 31 | + public function __construct($debug = false) |
|
| 32 | + { |
|
| 33 | + $this->debug = $debug; |
|
| 34 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 35 | + parent::__construct($moduleDirName); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public static function getInstance(bool $debug = false): self |
|
| 39 | - { |
|
| 40 | - static $instance; |
|
| 41 | - if (null === $instance) { |
|
| 42 | - $instance = new static($debug); |
|
| 43 | - } |
|
| 38 | + public static function getInstance(bool $debug = false): self |
|
| 39 | + { |
|
| 40 | + static $instance; |
|
| 41 | + if (null === $instance) { |
|
| 42 | + $instance = new static($debug); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return $instance; |
|
| 46 | - } |
|
| 45 | + return $instance; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - public function getDirname(): string |
|
| 52 | - { |
|
| 53 | - return $this->dirname; |
|
| 54 | - } |
|
| 48 | + /** |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + public function getDirname(): string |
|
| 52 | + { |
|
| 53 | + return $this->dirname; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Get an Object Handler |
|
| 58 | - * |
|
| 59 | - * @param string $name name of handler to load |
|
| 60 | - * |
|
| 61 | - * @return \XoopsPersistableObjectHandler |
|
| 62 | - */ |
|
| 63 | - public function getHandler($name): ?\XoopsPersistableObjectHandler |
|
| 64 | - { |
|
| 65 | - $ret = null; |
|
| 56 | + /** |
|
| 57 | + * Get an Object Handler |
|
| 58 | + * |
|
| 59 | + * @param string $name name of handler to load |
|
| 60 | + * |
|
| 61 | + * @return \XoopsPersistableObjectHandler |
|
| 62 | + */ |
|
| 63 | + public function getHandler($name): ?\XoopsPersistableObjectHandler |
|
| 64 | + { |
|
| 65 | + $ret = null; |
|
| 66 | 66 | |
| 67 | - $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; |
|
| 68 | - if (!\class_exists($class)) { |
|
| 69 | - throw new \RuntimeException("Class '$class' not found"); |
|
| 70 | - } |
|
| 71 | - /** @var \XoopsMySQLDatabase $db */ |
|
| 72 | - $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 73 | - $helper = self::getInstance(); |
|
| 74 | - $ret = new $class($db, $helper); |
|
| 75 | - $this->addLog("Getting handler '$name'"); |
|
| 76 | - return $ret; |
|
| 77 | - } |
|
| 67 | + $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; |
|
| 68 | + if (!\class_exists($class)) { |
|
| 69 | + throw new \RuntimeException("Class '$class' not found"); |
|
| 70 | + } |
|
| 71 | + /** @var \XoopsMySQLDatabase $db */ |
|
| 72 | + $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 73 | + $helper = self::getInstance(); |
|
| 74 | + $ret = new $class($db, $helper); |
|
| 75 | + $this->addLog("Getting handler '$name'"); |
|
| 76 | + return $ret; |
|
| 77 | + } |
|
| 78 | 78 | } |
| 79 | 79 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | public static function getInstance(bool $debug = false): self |
| 39 | 39 | { |
| 40 | 40 | static $instance; |
| 41 | - if (null === $instance) { |
|
| 41 | + if (null===$instance) { |
|
| 42 | 42 | $instance = new static($debug); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $ret = null; |
| 66 | 66 | |
| 67 | - $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; |
|
| 67 | + $class = __NAMESPACE__.'\\'.\ucfirst($name).'Handler'; |
|
| 68 | 68 | if (!\class_exists($class)) { |
| 69 | 69 | throw new \RuntimeException("Class '$class' not found"); |
| 70 | 70 | } |