diff --git a/modules/qlocrontaskmanager/README.md b/modules/qlocrontaskmanager/README.md index c27efc9fe..0954dbf58 100644 --- a/modules/qlocrontaskmanager/README.md +++ b/modules/qlocrontaskmanager/README.md @@ -1,20 +1,42 @@ +## Overview + +The **QloApps Cron Task Manager** module enables centralized management and execution of scheduled (cron) tasks within QloApps. It allows developers and administrators to define, register, and execute automated jobs efficiently. + +**QloApps Cron Task Manager 1.0.0** + +- Current version: 1.0.0 + +- Module V1.0.0 compatible with QloApps version 1.7.0 and V1.8.x. + + + +## Usage (QloApps version 1.7.0) + +To register a cron task, add a new hook inside your module's main class file. + +### Step 1: Register Cron Tasks Hook + +```php +public function hookRegisterCronTasks() +{ + return array( + array( + 'name' => 'cron_success_probe', + 'description' => $this->l('Sample cron task for scheduler verification.'), + 'cron' => '* * * * *', + 'callback' => 'cronSuccessProbe', + ) + ); +} + +``` ### Support Policy: https://store.webkul.com/support.html -### Store link: - - -### Explore Modules: - ### Explore Addons: https://qloapps.com/addons/ - -**QloApps Cron Task Manager 1.0.0** - -- Module V1.0.0 compatible with QloApps version V1.8.x. - ### Refund Policy: -https://store.webkul.com/refund-policy.html/ +https://store.webkul.com/refund-policy.html/ \ No newline at end of file diff --git a/modules/qlocrontaskmanager/classes/QctmCronTask.php b/modules/qlocrontaskmanager/classes/QctmCronTask.php index 36f538606..586b2ba0e 100644 --- a/modules/qlocrontaskmanager/classes/QctmCronTask.php +++ b/modules/qlocrontaskmanager/classes/QctmCronTask.php @@ -28,12 +28,13 @@ if (!defined('_PS_VERSION_')) { class QctmCronTask extends ObjectModel { public $id_cron_task; - public $module_name; + public $id_module; public $task_name; public $description; public $cron_expression; public $callback; public $active; + public $is_system; public $date_add; public $date_upd; @@ -41,22 +42,22 @@ class QctmCronTask extends ObjectModel 'table' => 'qctm_cron_task', 'primary' => 'id_cron_task', 'fields' => array( - 'module_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName','size' => 64,'required' => true), - 'task_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName','size' => 128,'required' => true), + 'id_module' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'task_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 128, 'required' => true), 'description' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255, 'required' => true), 'cron_expression' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64, 'required' => true), - 'callback' => array('type' => self::TYPE_STRING,'validate' => 'isGenericName','size' => 128, 'required' => true), - 'active' => array('type' => self::TYPE_BOOL,'validate' => 'isBool'), - 'date_add' => array('type' => self::TYPE_DATE,'validate' => 'isDate'), + 'callback' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 128, 'required' => true), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'is_system' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - public static function getActiveTasks() { return Db::getInstance()->executeS( - 'SELECT `id_cron_task`, `module_name`, `task_name`, `description`, + 'SELECT `id_cron_task`, `id_module`, `task_name`, `description`, `cron_expression`, `callback`, `active` FROM `' . _DB_PREFIX_ . 'qctm_cron_task` WHERE `active` = 1' @@ -64,62 +65,32 @@ class QctmCronTask extends ObjectModel } /** - * Find a task by module name and task name - * - * @param string $moduleName + * @param int $idModule * @param string $taskName * @return int|false */ - public static function getByModuleAndName($moduleName, $taskName) + public static function getByModuleAndName($idModule, $taskName) { return Db::getInstance()->getValue( 'SELECT `id_cron_task` FROM `' . _DB_PREFIX_ . 'qctm_cron_task` - WHERE `module_name` = \'' . pSQL($moduleName) . '\' + WHERE `id_module` = ' . (int) $idModule . ' AND `task_name` = \'' . pSQL($taskName) . '\'' ); } /** - * Delete all tasks belonging to a module + * Delete all tasks belonging to a module. + * Logs are intentionally preserved for history tracking. * - * @param string $moduleName + * @param int $idModule * @return bool */ - public static function deleteByModule($moduleName) + public static function deleteByModule($idModule) { - $taskIds = Db::getInstance()->executeS( - 'SELECT `id_cron_task` - FROM `' . _DB_PREFIX_ . 'qctm_cron_task` - WHERE `module_name` = \'' . pSQL($moduleName) . '\'' + return Db::getInstance()->execute( + 'DELETE FROM `' . _DB_PREFIX_ . 'qctm_cron_task` + WHERE `id_module` = ' . (int) $idModule ); - - $db = Db::getInstance(); - $db->execute('START TRANSACTION'); - - try { - if ($taskIds) { - $ids = array_column($taskIds, 'id_cron_task'); - $idsString = implode(',', array_map('intval', $ids)); - $db->execute( - 'DELETE FROM `' . _DB_PREFIX_ . 'qctm_cron_task_log` - WHERE `id_cron_task` IN (' . $idsString . ')' - ); - } - - $result = $db->execute( - 'DELETE FROM `' . _DB_PREFIX_ . 'qctm_cron_task` - WHERE `module_name` = \'' . pSQL($moduleName) . '\'' - ); - - $db->execute('COMMIT'); - - return $result; - } catch (Exception $e) { - $db->execute('ROLLBACK'); - - return false; - } } - } diff --git a/modules/qlocrontaskmanager/classes/QctmCronTaskManagerDb.php b/modules/qlocrontaskmanager/classes/QctmCronTaskManagerDb.php index 078eadb01..f08ae839e 100644 --- a/modules/qlocrontaskmanager/classes/QctmCronTaskManagerDb.php +++ b/modules/qlocrontaskmanager/classes/QctmCronTaskManagerDb.php @@ -33,16 +33,17 @@ class QctmCronTaskManagerDb $sql = array( 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'qctm_cron_task` ( `id_cron_task` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `module_name` VARCHAR(64) NOT NULL, + `id_module` INT(11) UNSIGNED NOT NULL, `task_name` VARCHAR(128) NOT NULL, `description` VARCHAR(255) NOT NULL, `cron_expression` VARCHAR(64) NOT NULL, `callback` VARCHAR(128) NOT NULL, `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, + `is_system` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, `date_add` DATETIME NOT NULL, `date_upd` DATETIME NOT NULL, PRIMARY KEY (`id_cron_task`), - UNIQUE KEY `module_task` (`module_name`, `task_name`) + UNIQUE KEY `module_task` (`id_module`, `task_name`) ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;', 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'qctm_cron_task_log` ( @@ -87,7 +88,6 @@ class QctmCronTaskManagerDb { Configuration::updateValue('QCTM_CRON_TASK_MANAGER_TOKEN', Tools::passwdGen(32)); Configuration::updateValue('QCTM_CRON_TASK_MANAGER_LOG_RETENTION_DAYS', 30); - Configuration::updateValue('QCTM_LOG_CLEANUP_LAST_RUN', 0); return true; } @@ -96,7 +96,6 @@ class QctmCronTaskManagerDb { Configuration::deleteByName('QCTM_CRON_TASK_MANAGER_TOKEN'); Configuration::deleteByName('QCTM_CRON_TASK_MANAGER_LOG_RETENTION_DAYS'); - Configuration::deleteByName('QCTM_LOG_CLEANUP_LAST_RUN'); return true; } diff --git a/modules/qlocrontaskmanager/classes/QctmRequiredClasses.php b/modules/qlocrontaskmanager/classes/QctmRequiredClasses.php new file mode 100644 index 000000000..e8ec7e004 --- /dev/null +++ b/modules/qlocrontaskmanager/classes/QctmRequiredClasses.php @@ -0,0 +1,27 @@ +bootstrap = true; + $this->list_no_link = true; + $this->table = 'qctm_cron_task_log'; + $this->className = 'QctmCronTaskLog'; + $this->identifier = 'id_cron_task_log'; + + parent::__construct(); + + $this->initLogList(); + } + + public function init() + { + parent::init(); + + $idCronTask = (int) Tools::getValue('id_cron_task'); + $prefix = $this->getCookieFilterPrefix(); + $cookieKey = $prefix . $this->table . 'Filter_ct!task_name'; + + if ($idCronTask > 0) { + $cronTask = new QctmCronTask($idCronTask); + if (Validate::isLoadedObject($cronTask)) { + $this->_where .= ' AND a.`id_cron_task` = ' . $idCronTask; + $this->context->cookie->{$cookieKey} = $cronTask->task_name; + $this->context->cookie->{'submitFilter' . $this->table} = 1; + $this->toolbar_title = $this->l('Logs for: ') . $cronTask->task_name; + } else { + $this->toolbar_title = $this->l('Cron Task Logs'); + } + } else { + unset($this->context->cookie->{$cookieKey}); + $this->context->cookie->{'submitFilter' . $this->table} = 0; + $this->toolbar_title = $this->l('All Cron Task Logs'); + } + + $this->page_header_toolbar_btn['back_to_tasks'] = array( + 'href' => $this->context->link->getAdminLink('AdminCronTaskManager'), + 'icon' => 'process-icon-back', + 'desc' => $this->l('Back to Tasks'), + ); + } + + protected function initLogList() + { + $this->lang = false; + $this->_orderBy = 'id_cron_task_log'; + $this->_orderWay = 'DESC'; + + $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'qctm_cron_task` ct + ON (a.`id_cron_task` = ct.`id_cron_task`) + LEFT JOIN `' . _DB_PREFIX_ . 'module` m + ON (m.`id_module` = ct.`id_module`)'; + + $this->_select = 'm.`name` AS `module_name`, ct.`task_name`, ct.`description` AS task_description'; + + $cronTaskLogStatuses = QctmCronTaskLog::getStatuses(); + + $this->fields_list = array( + 'id_cron_task_log' => array( + 'title' => $this->l('ID'), + 'align' => 'center', + 'class' => 'fixed-width-xs', + ), + 'module_name' => array( + 'title' => $this->l('Module'), + 'filter_key' => 'm!name', + 'order_key' => 'm!name', + 'callback' => 'displayModuleName', + ), + 'task_name' => array( + 'title' => $this->l('Task Name'), + 'filter_key' => 'ct!task_name', + 'search' => true, + ), + 'status' => array( + 'title' => $this->l('Status'), + 'align' => 'center', + 'type' => 'select', + 'list' => $cronTaskLogStatuses, + 'filter_key' => 'a!status', + 'callback' => 'getStatusBadge', + ), + 'error_message' => array( + 'title' => $this->l('Error Message'), + 'maxlength' => 80, + ), + 'execution_time' => array( + 'title' => $this->l('Execution Time'), + 'align' => 'center', + 'suffix' => ' s', + 'class' => 'fixed-width-md', + ), + 'date_add' => array( + 'title' => $this->l('Date'), + 'type' => 'datetime', + 'align' => 'right', + 'filter_key' => 'a!date_add', + ), + ); + } + + public function initToolbar() + { + parent::initToolbar(); + unset($this->toolbar_btn['new']); + } + + public function getStatusBadge($status, $row) + { + $this->context->smarty->assign('status', $status); + return $this->createTemplate('qctm_badge_status.tpl')->fetch(); + } + + public function displayModuleName($moduleName, $row) + { + $cacheKey = 'displayModuleName_' . $moduleName; + + if (!Cache::isStored($cacheKey)) { + $module = Module::getInstanceByName($moduleName); + $displayName = ($module && $module->displayName) ? $module->displayName : $moduleName; + Cache::store($cacheKey, $displayName); + } + + return Cache::retrieve($cacheKey); + } + + public function setMedia() + { + parent::setMedia(); + + $this->addCSS($this->module->getPathUri() . 'views/css/admin/qlo_cron_task_manager_admin.css'); + } +} diff --git a/modules/qlocrontaskmanager/controllers/admin/AdminCronTaskManagerController.php b/modules/qlocrontaskmanager/controllers/admin/AdminCronTaskManagerController.php index 56155d9ec..e37d8c18a 100644 --- a/modules/qlocrontaskmanager/controllers/admin/AdminCronTaskManagerController.php +++ b/modules/qlocrontaskmanager/controllers/admin/AdminCronTaskManagerController.php @@ -27,58 +27,22 @@ if (!defined('_PS_VERSION_')) { class AdminCronTaskManagerController extends ModuleAdminController { - protected $showLogs = false; - - protected function useTaskContext() - { - $this->table = 'qctm_cron_task'; - $this->className = 'QctmCronTask'; - $this->identifier = 'id_cron_task'; - } - public function __construct() { $this->bootstrap = true; - - parent::__construct(); - - if (Tools::getValue('id_cron_task')) { - $this->showLogs = true; - $this->initLogList(); - } else { - $this->initTaskList(); - } - } - - public function init() - { - parent::init(); - if (Tools::getValue('id_cron_task')) { - self::$currentIndex .= '&id_cron_task=' . (int) Tools::getValue('id_cron_task'); - $this->toolbar_title = $this->l('Cron Task Logs'); - $this->page_header_toolbar_btn['back-btn'] = array( - 'href' => $this->getBackButtonLink(), - 'icon' => 'process-icon-back', - 'desc' => $this->l('Back To Tasks'), - ); - } - } - - protected function getBackButtonLink() - { - $backLink = preg_replace('/([&?])id_cron_task=\d+(&)?/', '$1', self::$currentIndex); - $backLink = rtrim($backLink, '&?'); - - return $backLink . '&token=' . $this->token; - } - - protected function initTaskList() - { - $this->useTaskContext(); - $this->lang = false; - $this->_orderBy = 'id_cron_task'; - $this->_orderWay = 'ASC'; $this->list_no_link = true; + $this->table = 'qctm_cron_task'; + $this->className = 'QctmCronTask'; + $this->identifier = 'id_cron_task'; + $this->_orderBy = 'id_cron_task'; + + $this->lang = false; + $this->_orderWay = 'ASC'; + + parent::__construct(); + // Exclude hidden system tasks from the listing + $this->_where = ' AND a.`is_system` = 0'; + $this->_join = 'LEFT JOIN ( SELECT ctl.`id_cron_task`, ctl.`date_add` AS `last_run`, ctl.`status` AS `last_status` FROM `' . _DB_PREFIX_ . 'qctm_cron_task_log` ctl @@ -87,11 +51,14 @@ class AdminCronTaskManagerController extends ModuleAdminController FROM `' . _DB_PREFIX_ . 'qctm_cron_task_log` GROUP BY `id_cron_task` ) latest ON ctl.`id_cron_task_log` = latest.`max_id` - ) AS llog ON (llog.`id_cron_task` = a.`id_cron_task`)'; + ) AS llog ON (llog.`id_cron_task` = a.`id_cron_task`) + LEFT JOIN `' . _DB_PREFIX_ . 'module` m ON (m.`id_module` = a.`id_module`)'; - $this->_select = 'llog.`last_run`, llog.`last_status`'; + $this->_select = 'm.`name` as `module_name`, llog.`last_run`, llog.`last_status`, a.`cron_expression` AS `next_run_expression`'; - $this->addRowAction('view'); + $this->addRowAction('viewLogs'); + $this->addRowAction('edit'); + $this->addRowAction('resetModuleCrons'); $this->bulk_actions = array( 'enableSelection' => array( @@ -111,18 +78,21 @@ class AdminCronTaskManagerController extends ModuleAdminController 'class' => 'fixed-width-xs', ), 'module_name' => array( - 'title' => $this->l('Module'), - 'filter_key' => 'a!module_name', + 'title' => $this->l('Module Name'), + 'filter_key' => 'm!name', + 'order_key' => 'm!name', + 'callback' => 'displayModuleName', ), - 'description' => array( - 'title' => $this->l('Task'), - 'filter_key' => 'a!description', + 'task_name' => array( + 'title' => $this->l('Task Name'), + 'filter_key' => 'a!task_name', ), 'cron_expression' => array( 'title' => $this->l('Cron Expression'), 'align' => 'center', 'class' => 'fixed-width-lg', 'search' => false, + 'callback' => 'getCronWithReadable', ), 'last_run' => array( 'title' => $this->l('Last Run'), @@ -137,6 +107,19 @@ class AdminCronTaskManagerController extends ModuleAdminController 'search' => false, 'callback' => 'getLastStatus', ), + 'next_run_expression' => array( + 'title' => $this->l('Next Run'), + 'align' => 'center', + 'filter' => false, + 'search' => false, + 'callback' => 'getNextRun', + ), + 'date_add' => array( + 'title' => $this->l('Added Time'), + 'align' => 'center', + 'filter' => false, + 'search' => false, + ), 'active' => array( 'title' => $this->l('Active'), 'active' => 'status', @@ -146,127 +129,322 @@ class AdminCronTaskManagerController extends ModuleAdminController 'filter_key' => 'a!active', ), ); + } - protected function initLogList() + public function init() { - $this->table = 'qctm_cron_task_log'; - $this->className = 'QctmCronTaskLog'; - $this->identifier = 'id_cron_task_log'; - $this->lang = false; - $this->_orderBy = 'id_cron_task_log'; - $this->_orderWay = 'DESC'; - $this->list_no_link = true; + parent::init(); - $idCronTask = (int) Tools::getValue('id_cron_task'); - if ($idCronTask) { - $this->_where = ' AND a.`id_cron_task` = ' . $idCronTask; + if(!Validate::isUnsignedInt($idCronTask = Tools::getValue('id_cron_task')) && $this->display == 'edit') { + $this->errors = array($this->l('Invalid Cron Task ID')); + $this->display = 'list'; + }else{ + if (Validate::isUnsignedInt($idCronTask = Tools::getValue('id_cron_task')) && Validate::isLoadedObject($objCronTask = new QctmCronTask($idCronTask)) && $this->display == 'edit' ) { + $this->toolbar_title = $this->l('Edit Cron Task: ') . $objCronTask->task_name; + } } - $this->_select = 'ct.`module_name`, ct.`description` as task_description'; - $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'qctm_cron_task` ct - ON (a.`id_cron_task` = ct.`id_cron_task`)'; - - $cronTaskLogStatuses = QctmCronTaskLog::getStatuses(); - - $this->fields_list = array( - 'id_cron_task_log' => array( - 'title' => $this->l('ID'), - 'align' => 'center', - 'class' => 'fixed-width-xs', - ), - 'module_name' => array( - 'title' => $this->l('Module'), - 'filter_key' => 'ct!module_name', - ), - 'task_description' => array( - 'title' => $this->l('Task'), - 'filter' => false, - 'search' => false, - ), - 'status' => array( - 'title' => $this->l('Status'), - 'align' => 'center', - 'type' => 'select', - 'list' => $cronTaskLogStatuses, - 'filter_key' => 'a!status', - 'callback' => 'getStatusBadge', - ), - 'error_message' => array( - 'title' => $this->l('Error Message'), - 'maxlength' => 80, - ), - 'execution_time' => array( - 'title' => $this->l('Execution Time'), - 'align' => 'center', - 'suffix' => ' s', - 'class' => 'fixed-width-md', - ), - 'date_add' => array( - 'title' => $this->l('Date'), - 'type' => 'datetime', - 'align' => 'right', - 'filter_key' => 'a!date_add', - ), - ); } public function initToolbar() { parent::initToolbar(); - unset($this->toolbar_btn['new']); + + $this->page_header_toolbar_btn['view_all_logs'] = array( + 'href' => $this->context->link->getAdminLink('AdminCronTaskLogs'), + 'desc' => $this->l('View All Logs'), + 'icon' => 'process-icon-list', + ); } + + + public function renderForm() + { + $cronExpression = '* * * * *'; + if(Validate::isLoadedObject($this->object)){ + $cronExpression = $this->object->cron_expression; + } + + $isValidExpression = \Cron\CronExpression::isValidExpression($cronExpression); + if ($isValidExpression) { + try { + $readable = $this->l('Runs ') . \Lorisleiva\CronTranslator\CronTranslator::translate($cronExpression); + } catch (\Exception $e) { + $readable = ''; + } + } else { + $readable = $this->l('Invalid cron expression.'); + } + + $moduleDisplayName = ''; + if (Validate::isLoadedObject($this->object) && $this->object->id_module) { + $module = Module::getInstanceById($this->object->id_module); + $moduleDisplayName = ($module && $module->displayName) ? $module->displayName : '#' . (int) $this->object->id_module; + } + $this->fields_value['module_display_name'] = $moduleDisplayName; + + $this->context->smarty->assign(array( + 'qctmCronExpression' => $cronExpression, + 'qctmCronReadable' => $readable, + 'qctmAjaxUrl' => $this->context->link->getAdminLink($this->controller_name) . '&ajax=1', + )); + + $this->fields_form = array( + 'legend' => array( + 'title' => $this->l('Cron Task'), + 'icon' => 'icon-time', + ), + 'input' => array( + array( + 'type' => 'text', + 'label' => $this->l('Module Name'), + 'name' => 'module_display_name', + 'readonly' => true, + 'col' => 5, + 'desc' => $this->l('The module that owns this task.'), + ), + array( + 'type' => 'text', + 'label' => $this->l('Task Name'), + 'name' => 'task_name', + 'readonly' => true, + 'required' => true, + 'col' => 5, + 'hint' => $this->l('e.g. send_daily_report'), + 'desc' => $this->l('A unique snake_case identifier for this task within the module. Used to detect duplicate registrations.'), + ), + array( + 'type' => 'text', + 'label' => $this->l('Callback Method'), + 'name' => 'callback', + 'required' => true, + 'readonly' => true, + 'col' => 5, + 'hint' => $this->l('e.g. runDailyReport'), + 'desc' => $this->l('The public method name on the module class that will be called when this task fires. Must exist on the module at runtime.'), + ), + array( + 'type' => 'text', + 'label' => $this->l('Description'), + 'name' => 'description', + 'required' => true, + 'col' => 7, + 'hint' => $this->l('e.g. Sends the daily booking summary report'), + 'desc' => $this->l('A short human-readable description of what this task does. Shown in the task list.'), + ), + array( + 'type' => 'text', + 'label' => $this->l('Cron Expression'), + 'name' => 'cron_expression', + 'required' => true, + 'col' => 4, + 'class' => 'qctm-cron-expression', + 'hint' => $this->l('e.g. 0 0 * * *'), + 'desc' => $readable, + ), + array( + 'type' => 'html', + 'name' => 'qctm_cron_helper', + 'html_content' => $this->createTemplate('qctm_cron_expression_helper.tpl')->fetch(), + ), + array( + 'type' => 'switch', + 'label' => $this->l('Active'), + 'name' => 'active', + 'required' => false, + 'desc' => $this->l('Disabled tasks are skipped by the cron dispatcher even if their schedule is due.'), + 'values' => array( + array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), + array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')), + ), + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + ), + ); + return parent::renderForm(); + } + + public function ajaxProcessGetCronReadable() + { + $expression = Tools::getValue('cron_expression'); + $result = array('readable' => $this->l('Invalid cron expression'), 'valid' => false); + + if (\Cron\CronExpression::isValidExpression($expression)) { + $result['valid'] = true; + try { + $result['readable'] = $this->l('Runs ') . \Lorisleiva\CronTranslator\CronTranslator::translate($expression); + } catch (\Exception $e) { + $result['readable'] = $this->l('Invalid cron expression'); + } + } + + die(Tools::jsonEncode($result)); + } + + public function processSave() + { + if (!$this->validateCronExpression()) { + $this->display = 'edit'; + return false; + } + + return parent::processSave(); + } + + protected function validateCronExpression() + { + $cronExpression = Tools::getValue('cron_expression'); + + if (!\Cron\CronExpression::isValidExpression($cronExpression)) { + $this->errors[] = $this->l('Invalid cron expression. Must have exactly 5 parts: minute hour day month weekday. Example: * * * * *'); + return false; + } + + return true; + } public function processStatus() { - $this->showLogs = false; - $this->useTaskContext(); - return parent::processStatus(); } protected function processBulkEnableSelection() { - $this->showLogs = false; - $this->useTaskContext(); - return parent::processBulkEnableSelection(); } protected function processBulkDisableSelection() { - $this->showLogs = false; - $this->useTaskContext(); - return parent::processBulkDisableSelection(); } + public function displayViewLogsLink($token = null, $id = null, $row = array()) + { + $this->context->smarty->assign( + 'viewLogsLink', + $this->context->link->getAdminLink('AdminCronTaskLogs') . '&id_cron_task=' . (int) $id + ); + return $this->createTemplate('qctm_view_logs_link.tpl')->fetch(); + } + + public function displayResetModuleCronsLink($token = null, $id = null, $row = array()) + { + $this->context->smarty->assign( + 'resetLink', + $this->context->link->getAdminLink('AdminCronTaskManager') + . '&action=resetModuleCrons&' . $this->identifier . '=' . (int) $id + ); + return $this->createTemplate('qctm_reset_module_crons_link.tpl')->fetch(); + } + + public function processResetModuleCrons() + { + $idCronTask = (int) Tools::getValue($this->identifier); + $cronTask = new QctmCronTask($idCronTask); + + if (!Validate::isLoadedObject($cronTask)) { + $this->errors[] = $this->l('Cron task not found.'); + return false; + } + + $module = Module::getInstanceById($cronTask->id_module); + + if (!$module) { + $this->errors[] = $this->l('Module not found.'); + return false; + } + + if (!method_exists($module, 'hookRegisterCronTasks')) { + $this->errors[] = $this->l('Module does not define any cron tasks.'); + return false; + } + + $tasks = $module->hookRegisterCronTasks(); + + if (empty($tasks) || !is_array($tasks)) { + $this->errors[] = $this->l('No tasks returned by module.'); + return false; + } + + foreach ($tasks as $task) { + if ($task['name'] === $cronTask->task_name) { + $cronTask->cron_expression = $task['cron']; + $cronTask->description = $task['description']; + $cronTask->callback = $task['callback']; + + if (!$cronTask->save()) { + $this->errors[] = $this->l('Failed to reset cron task.'); + return false; + } + + $this->confirmations[] = $this->l('Cron task reset to module defaults successfully.'); + return true; + } + } + + $this->errors[] = $this->l('Task definition not found in module.'); + return false; + } + + public function getCronWithReadable($cronExpression, $row) + { + try { + $readable = \Lorisleiva\CronTranslator\CronTranslator::translate($cronExpression); + } catch (\Exception $e) { + $readable = $cronExpression; + } + + return '' . htmlspecialchars($cronExpression) . '' + . '
' . htmlspecialchars($readable) . ''; + } + + public function displayModuleName($moduleName, $row) + { + $cacheKey = 'displayModuleName_' . $moduleName; + + if (!Cache::isStored($cacheKey)) { + $module = Module::getInstanceByName($moduleName); + $displayName = ($module && $module->displayName) ? $module->displayName : $moduleName; + Cache::store($cacheKey, $displayName); + } + + return Cache::retrieve($cacheKey); + } + + public function getNextRun($cronExpression, $row) + { + if (!$cronExpression || !\Cron\CronExpression::isValidExpression($cronExpression)) { + return '-'; + } + + try { + $next = \Cron\CronExpression::factory($cronExpression)->getNextRunDate(); + return $next->format('Y-m-d H:i:s'); + } catch (\Exception $e) { + return '-'; + } + } + public function getLastStatus($lastStatus, $row) { $this->context->smarty->assign('status', $lastStatus); return $this->createTemplate('qctm_badge_status.tpl')->fetch(); } - public function getStatusBadge($status, $row) - { - $this->context->smarty->assign('status', $status); - return $this->createTemplate('qctm_badge_status.tpl')->fetch(); - } - - public function displayViewlogsLink($token, $id, $name = null) - { - $logLink = self::$currentIndex.'&id_cron_task=' . (int) $id. '&token=' . $this->token; - - $this->context->smarty->assign('logLink', $logLink); - - return $this->createTemplate('qctm_view_log.tpl')->fetch(); - } public function setMedia() { parent::setMedia(); + Media::addJsDef( + array( + 'INVALID_CRON_EXPRESSION' => $this->l('Invalid cron expression.'), + ) + ); $this->addCSS($this->module->getPathUri() . 'views/css/admin/qlo_cron_task_manager_admin.css'); $this->addJS($this->module->getPathUri() . 'views/js/admin/qlo_cron_task_manager_admin.js'); } diff --git a/modules/qlocrontaskmanager/logo.gif b/modules/qlocrontaskmanager/logo.gif new file mode 100644 index 000000000..1c7f7e0db Binary files /dev/null and b/modules/qlocrontaskmanager/logo.gif differ diff --git a/modules/qlocrontaskmanager/logo.png b/modules/qlocrontaskmanager/logo.png new file mode 100644 index 000000000..908f03fc7 Binary files /dev/null and b/modules/qlocrontaskmanager/logo.png differ diff --git a/modules/qlocrontaskmanager/qlocrontaskmanager.php b/modules/qlocrontaskmanager/qlocrontaskmanager.php index 4da681801..9675cedc8 100644 --- a/modules/qlocrontaskmanager/qlocrontaskmanager.php +++ b/modules/qlocrontaskmanager/qlocrontaskmanager.php @@ -25,7 +25,7 @@ if (!defined('_PS_VERSION_')) { exit; } -include_once 'define.php'; +require_once dirname(__FILE__).'/classes/QctmRequiredClasses.php'; class QloCronTaskManager extends Module { @@ -41,8 +41,8 @@ class QloCronTaskManager extends Module parent::__construct(); $this->displayName = $this->l('Cron Task Manager'); - $this->description = $this->l('Centralized cron scheduling system. One server cron entry manages all module tasks.'); - $this->confirmUninstall = $this->l('Are you sure you want to uninstall? All cron task data will be lost.'); + $this->description = $this->l('A centralized cron scheduling system where a single server cron entry manages all module tasks.'); + $this->confirmUninstall = $this->l('Are you sure you want to uninstall this module? All cron task data will be lost.'); } @@ -59,8 +59,10 @@ class QloCronTaskManager extends Module $output .= $this->displayConfirmation($this->l('Token has been regenerated. Update your server cron entry with the new URL.')); } - $this->context->controller->addCSS($this->_path . 'views/css/admin/qlo_cron_task_manager_admin.css'); - $this->context->controller->addJS($this->_path . 'views/js/admin/qlo_cron_task_manager_admin.js'); + if(Tools::getValue('module_name') === $this->name) { + $this->context->controller->addCSS($this->_path . 'views/css/admin/qlo_cron_task_manager_admin.css'); + $this->context->controller->addJS($this->_path . 'views/js/admin/qlo_cron_task_manager_admin.js'); + } $output .= $this->renderCronCommandPanel(); $output .= $this->renderSettingsForm(); @@ -70,7 +72,11 @@ class QloCronTaskManager extends Module protected function processSaveSettings() { - $logRetention = (int) Tools::getValue('QCTM_CRON_TASK_MANAGER_LOG_RETENTION_DAYS'); + $logRetention = Tools::getValue('QCTM_CRON_TASK_MANAGER_LOG_RETENTION_DAYS'); + + if(!Validate::isUnsignedInt($logRetention)) { + return $this->displayError($this->l('Log retention must be an integer value.')); + } if ($logRetention < 1 || $logRetention > 365) { return $this->displayError($this->l('Log retention must be between 1 and 365 days.')); @@ -124,7 +130,7 @@ class QloCronTaskManager extends Module 'name' => 'QCTM_CRON_TASK_MANAGER_TOKEN', 'readonly' => true, 'col' => 6, - 'desc' => $this->l('This token secures the cron endpoint. Regenerating it will require updating your server cron entry.'), + 'desc' => $this->l('This token secures the cron endpoint. After regenerating it, you will need to update your server cron entry.'), ), array( 'type' => 'text', @@ -132,6 +138,8 @@ class QloCronTaskManager extends Module 'name' => 'QCTM_CRON_TASK_MANAGER_LOG_RETENTION_DAYS', 'col' => 2, 'required' => true, + 'validation' => 'isUnsignedInt', + 'suffix' => $this->l('days'), 'desc' => $this->l('Number of days to keep execution logs.'), ), ), @@ -166,18 +174,18 @@ class QloCronTaskManager extends Module if (method_exists($module, 'hookRegisterCronTasks')) { $tasks = $module->hookRegisterCronTasks(); if (!empty($tasks) && is_array($tasks)) { - $this->registerTasksForModule($module->name, $tasks); + $this->registerTasksForModule($module->id, $tasks); } } } public function hookActionModuleUninstallBefore($params) { - if (!isset($params['object']) || !($params['object'] instanceof Module)) { + if (!isset($params['object']) || !($params['object'] instanceof Module) || $params['object']->id == $this->id) { return; } - QctmCronTask::deleteByModule($params['object']->name); + QctmCronTask::deleteByModule($params['object']->id); } protected function syncAllExistingModules() @@ -187,7 +195,10 @@ class QloCronTaskManager extends Module if (!empty($allTasks) && is_array($allTasks)) { foreach ($allTasks as $moduleName => $tasks) { if (!empty($tasks) && is_array($tasks)) { - $this->registerTasksForModule($moduleName, $tasks); + $module = Module::getInstanceByName($moduleName); + if($module){ + $this->registerTasksForModule($module->id, $tasks); + } } } } @@ -199,27 +210,34 @@ class QloCronTaskManager extends Module * @param string $moduleName * @param array $tasks */ - protected function registerTasksForModule($moduleName, $tasks) + protected function registerTasksForModule($idModule, $tasks) { + $module = Module::getInstanceById($idModule); + if (!$module) { + return; + } + + foreach ($tasks as $task) { - if (!$this->validateTask($moduleName, $task)) { + if (!$this->validateTask($module, $task)) { continue; } - if (QctmCronTask::getByModuleAndName($moduleName, $task['name'])) { + if (QctmCronTask::getByModuleAndName($idModule, $task['name'])) { continue; } $cronTask = new QctmCronTask(); - $cronTask->module_name = $moduleName; + $cronTask->id_module = $idModule; $cronTask->task_name = $task['name']; $cronTask->description = $task['description']; $cronTask->cron_expression = $task['cron']; $cronTask->callback = $task['callback']; $cronTask->active = 1; + $cronTask->is_system = 0; if (!$cronTask->save()) { PrestaShopLogger::addLog( - 'QloCronTaskManager: failed to register task "' . $task['name'] . '" for module "' . $moduleName . '"', + 'QloCronTaskManager: failed to register task "' . $task['name'] . '" for module "' . $module->name . '"', 3 ); } @@ -233,10 +251,10 @@ class QloCronTaskManager extends Module * @param array $task * @return bool */ - protected function validateTask($moduleName, $task) + protected function validateTask(Module $module, $task) { - if (empty($task['name']) || empty($task['description']) - || empty($task['cron']) || empty($task['callback'])) { + if (!Validate::isGenericName($task['name']) || !Validate::isGenericName($task['description']) + || !Validate::isString($task['cron']) || !Validate::isString($task['callback'])) { return false; } @@ -244,8 +262,7 @@ class QloCronTaskManager extends Module return false; } - $module = Module::getInstanceByName($moduleName); - if (!$module || !method_exists($module, $task['callback'])) { + if (!method_exists($module, $task['callback'])) { return false; } @@ -254,23 +271,45 @@ class QloCronTaskManager extends Module public function dispatch() { - $now = new DateTime(); - $tasks = QctmCronTask::getActiveTasks(); + if (!$this->active) { + return; + } + $tasks = QctmCronTask::getActiveTasks(); if (empty($tasks)) { return; } + $now = new DateTime(); + foreach ($tasks as $task) { + if (!\Cron\CronExpression::isValidExpression($task['cron_expression'])) { + QctmCronTaskLog::addLog( + $task['id_cron_task'], + QctmCronTaskLog::QCTM_CRON_TASK_LOG_STATUS_ERROR, + 'Invalid cron expression "' . $task['cron_expression'] . '"' + ); + continue; + } + $cron = \Cron\CronExpression::factory($task['cron_expression']); if (!$cron->isDue($now)) { continue; } - $module = Module::getInstanceByName($task['module_name']); + $module = Module::getInstanceById($task['id_module']); - if (!$module || !$module->active) { + if (!$module) { + QctmCronTaskLog::addLog( + $task['id_cron_task'], + QctmCronTaskLog::QCTM_CRON_TASK_LOG_STATUS_ERROR, + 'Module with ID "' . (int) $task['id_module'] . '" could not be loaded' + ); + continue; + } + + if (!$module->active) { continue; } @@ -280,7 +319,7 @@ class QloCronTaskManager extends Module QctmCronTaskLog::addLog( $task['id_cron_task'], QctmCronTaskLog::QCTM_CRON_TASK_LOG_STATUS_ERROR, - 'Callback method "' . $callback . '" not found on module "' . $task['module_name'] . '"' + 'Callback method "' . $callback . '" not found on module "' . $module->name . '"' ); continue; } @@ -289,43 +328,34 @@ class QloCronTaskManager extends Module try { $module->{$callback}(); - $executionTime = round(microtime(true) - $startTime, 4); QctmCronTaskLog::addLog( $task['id_cron_task'], QctmCronTaskLog::QCTM_CRON_TASK_LOG_STATUS_SUCCESS, null, - $executionTime + round(microtime(true) - $startTime, 4) ); } catch (\Throwable $e) { - $executionTime = round(microtime(true) - $startTime, 4); - QctmCronTaskLog::addLog( $task['id_cron_task'], QctmCronTaskLog::QCTM_CRON_TASK_LOG_STATUS_ERROR, $e->getMessage(), - $executionTime + round(microtime(true) - $startTime, 4) ); } } - - $this->cleanOldLogs(); } - public function cleanOldLogs() + /** + * Called by the system log-cleanup cron task (daily at midnight). + */ + public function runLogCleanup() { - $lastRun = (int) Configuration::get('QCTM_LOG_CLEANUP_LAST_RUN'); - - if ($lastRun && (time() - $lastRun) < 86400) { - return; - } - $days = (int) Configuration::get('QCTM_CRON_TASK_MANAGER_LOG_RETENTION_DAYS'); if ($days > 0) { QctmCronTaskLog::deleteOlderThan($days); } - Configuration::updateValue('QCTM_LOG_CLEANUP_LAST_RUN', time()); } public function install() @@ -333,11 +363,11 @@ class QloCronTaskManager extends Module $db = new QctmCronTaskManagerDb(); if (!parent::install() - || !$this->registerHook('actionModuleInstallAfter') - || !$this->registerHook('actionModuleUninstallBefore') + || !$this->registerHooks() || !$db->createTables() || !$db->installDefaultData() || !$this->installTabs() + || !$this->installDefaultTasks() ) { return false; } @@ -347,6 +377,16 @@ class QloCronTaskManager extends Module return true; } + public function registerHooks() + { + return $this->registerHook( + array( + 'actionModuleInstallAfter', + 'actionModuleUninstallBefore', + ) + ); + } + public function uninstall() { $db = new QctmCronTaskManagerDb(); @@ -362,28 +402,62 @@ class QloCronTaskManager extends Module return true; } - protected function installTabs() + protected function installDefaultTasks() { - $tab = new Tab(); - $tab->class_name = 'AdminCronTaskManager'; - $tab->id_parent = (int) Tab::getIdFromClassName('AdminTools'); - $tab->module = $this->name; - $tab->position = Tab::getNewLastPosition($tab->id_parent); - - foreach (Language::getLanguages(false) as $language) { - $tab->name[$language['id_lang']] = $this->l('Cron Task Manager'); + if (QctmCronTask::getByModuleAndName($this->id, 'log_cleanup')) { + return true; } - return $tab->add(); + $task = new QctmCronTask(); + $task->id_module = (int) $this->id; + $task->task_name = 'log_cleanup'; + $task->description = 'Automatic log cleanup'; + $task->cron_expression = '0 0 * * *'; + $task->callback = 'runLogCleanup'; + $task->active = 1; + $task->is_system = 1; + + return $task->save(); + } + + protected function installTabs() + { + $tabCronTasks = new Tab(); + $tabCronTasks->class_name = 'AdminCronTaskManager'; + $tabCronTasks->id_parent = (int) Tab::getIdFromClassName('AdminTools'); + $tabCronTasks->module = $this->name; + $tabCronTasks->position = Tab::getNewLastPosition($tabCronTasks->id_parent); + + foreach (Language::getLanguages(false) as $language) { + $tabCronTasks->name[$language['id_lang']] = $this->l('Cron Task Manager'); + } + + if (!$tabCronTasks->add()) { + return false; + } + + // Hidden tab — accessible via URL but not shown in navigation menu + $tabLogs = new Tab(); + $tabLogs->class_name = 'AdminCronTaskLogs'; + $tabLogs->id_parent = -1; + $tabLogs->module = $this->name; + + foreach (Language::getLanguages(false) as $language) { + $tabLogs->name[$language['id_lang']] = $this->l('Cron Task Logs'); + } + + return $tabLogs->add(); } protected function uninstallTabs() { - $idTab = (int) Tab::getIdFromClassName('AdminCronTaskManager'); - if ($idTab) { - $tab = new Tab($idTab); - if (!$tab->delete()) { - return false; + foreach (array('AdminCronTaskManager', 'AdminCronTaskLogs') as $className) { + $idTab = (int) Tab::getIdFromClassName($className); + if ($idTab) { + $tab = new Tab($idTab); + if (!$tab->delete()) { + return false; + } } } diff --git a/modules/qlocrontaskmanager/vendor/autoload.php b/modules/qlocrontaskmanager/vendor/autoload.php index 0f90a20bd..947105c29 100644 --- a/modules/qlocrontaskmanager/vendor/autoload.php +++ b/modules/qlocrontaskmanager/vendor/autoload.php @@ -3,8 +3,18 @@ // autoload.php @generated by Composer if (PHP_VERSION_ID < 50600) { - echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; - exit(1); + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, $err); + } elseif (!headers_sent()) { + echo $err; + } + } + throw new RuntimeException($err); } require_once __DIR__ . '/composer/autoload_real.php'; diff --git a/modules/qlocrontaskmanager/vendor/composer/ClassLoader.php b/modules/qlocrontaskmanager/vendor/composer/ClassLoader.php index afef3fa2a..7824d8f7e 100644 --- a/modules/qlocrontaskmanager/vendor/composer/ClassLoader.php +++ b/modules/qlocrontaskmanager/vendor/composer/ClassLoader.php @@ -42,35 +42,37 @@ namespace Composer\Autoload; */ class ClassLoader { - /** @var ?string */ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ private $vendorDir; // PSR-4 /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixLengthsPsr4 = array(); /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixDirsPsr4 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * @var array[] - * @psalm-var array> + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> */ private $prefixesPsr0 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr0 = array(); @@ -78,8 +80,7 @@ class ClassLoader private $useIncludePath = false; /** - * @var string[] - * @psalm-var array + * @var array */ private $classMap = array(); @@ -87,29 +88,29 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var bool[] - * @psalm-var array + * @var array */ private $missingClasses = array(); - /** @var ?string */ + /** @var string|null */ private $apcuPrefix; /** - * @var self[] + * @var array */ private static $registeredLoaders = array(); /** - * @param ?string $vendorDir + * @param string|null $vendorDir */ public function __construct($vendorDir = null) { $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); } /** - * @return string[] + * @return array> */ public function getPrefixes() { @@ -121,8 +122,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array> + * @return array> */ public function getPrefixesPsr4() { @@ -130,8 +130,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirs() { @@ -139,8 +138,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirsPsr4() { @@ -148,8 +146,7 @@ class ClassLoader } /** - * @return string[] Array of classname => path - * @psalm-return array + * @return array Array of classname => path */ public function getClassMap() { @@ -157,8 +154,7 @@ class ClassLoader } /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap + * @param array $classMap Class to filename map * * @return void */ @@ -175,24 +171,25 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - (array) $paths + $paths ); } @@ -201,19 +198,19 @@ class ClassLoader $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; + $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - (array) $paths + $paths ); } } @@ -222,9 +219,9 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -232,17 +229,18 @@ class ClassLoader */ public function addPsr4($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - (array) $paths + $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -252,18 +250,18 @@ class ClassLoader throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; + $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - (array) $paths + $paths ); } } @@ -272,8 +270,8 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories * * @return void */ @@ -290,8 +288,8 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -425,7 +423,8 @@ class ClassLoader public function loadClass($class) { if ($file = $this->findFile($class)) { - includeFile($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } @@ -476,9 +475,9 @@ class ClassLoader } /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. + * Returns the currently registered loaders keyed by their corresponding vendor directories. * - * @return self[] + * @return array */ public static function getRegisteredLoaders() { @@ -555,18 +554,26 @@ class ClassLoader return false; } -} -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - * @private - */ -function includeFile($file) -{ - include $file; + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } } diff --git a/modules/qlocrontaskmanager/vendor/composer/InstalledVersions.php b/modules/qlocrontaskmanager/vendor/composer/InstalledVersions.php index c6b54af7b..2052022fd 100644 --- a/modules/qlocrontaskmanager/vendor/composer/InstalledVersions.php +++ b/modules/qlocrontaskmanager/vendor/composer/InstalledVersions.php @@ -26,12 +26,23 @@ use Composer\Semver\VersionParser; */ class InstalledVersions { + /** + * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to + * @internal + */ + private static $selfDir = null; + /** * @var mixed[]|null * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null */ private static $installed; + /** + * @var bool + */ + private static $installedIsLocalDir; + /** * @var bool|null */ @@ -98,7 +109,7 @@ class InstalledVersions { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; } } @@ -119,7 +130,7 @@ class InstalledVersions */ public static function satisfies(VersionParser $parser, $packageName, $constraint) { - $constraint = $parser->parseConstraints($constraint); + $constraint = $parser->parseConstraints((string) $constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); @@ -309,6 +320,24 @@ class InstalledVersions { self::$installed = $data; self::$installedByVendor = array(); + + // when using reload, we disable the duplicate protection to ensure that self::$installed data is + // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, + // so we have to assume it does not, and that may result in duplicate data being returned when listing + // all installed packages for example + self::$installedIsLocalDir = false; + } + + /** + * @return string + */ + private static function getSelfDir() + { + if (self::$selfDir === null) { + self::$selfDir = strtr(__DIR__, '\\', '/'); + } + + return self::$selfDir; } /** @@ -322,17 +351,27 @@ class InstalledVersions } $installed = array(); + $copiedLocalDir = false; if (self::$canGetVendors) { + $selfDir = self::getSelfDir(); foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + $vendorDir = strtr($vendorDir, '\\', '/'); if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + self::$installedByVendor[$vendorDir] = $required; + $installed[] = $required; + if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { + self::$installed = $required; + self::$installedIsLocalDir = true; } } + if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { + $copiedLocalDir = true; + } } } @@ -340,12 +379,17 @@ class InstalledVersions // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; } else { self::$installed = array(); } } - $installed[] = self::$installed; + + if (self::$installed !== array() && !$copiedLocalDir) { + $installed[] = self::$installed; + } return $installed; } diff --git a/modules/qlocrontaskmanager/vendor/composer/autoload_psr4.php b/modules/qlocrontaskmanager/vendor/composer/autoload_psr4.php index e12811ddf..bc4d7c736 100644 --- a/modules/qlocrontaskmanager/vendor/composer/autoload_psr4.php +++ b/modules/qlocrontaskmanager/vendor/composer/autoload_psr4.php @@ -6,5 +6,6 @@ $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( + 'Lorisleiva\\CronTranslator\\' => array($vendorDir . '/lorisleiva/cron-translator/src'), 'Cron\\' => array($vendorDir . '/dragonmantank/cron-expression/src/Cron'), ); diff --git a/modules/qlocrontaskmanager/vendor/composer/autoload_static.php b/modules/qlocrontaskmanager/vendor/composer/autoload_static.php index e173eaa32..f60e1ecf0 100644 --- a/modules/qlocrontaskmanager/vendor/composer/autoload_static.php +++ b/modules/qlocrontaskmanager/vendor/composer/autoload_static.php @@ -7,6 +7,10 @@ namespace Composer\Autoload; class ComposerStaticInitc2f08a32af23ee5d749fb28358c620b3 { public static $prefixLengthsPsr4 = array ( + 'L' => + array ( + 'Lorisleiva\\CronTranslator\\' => 26, + ), 'C' => array ( 'Cron\\' => 5, @@ -14,6 +18,10 @@ class ComposerStaticInitc2f08a32af23ee5d749fb28358c620b3 ); public static $prefixDirsPsr4 = array ( + 'Lorisleiva\\CronTranslator\\' => + array ( + 0 => __DIR__ . '/..' . '/lorisleiva/cron-translator/src', + ), 'Cron\\' => array ( 0 => __DIR__ . '/..' . '/dragonmantank/cron-expression/src/Cron', diff --git a/modules/qlocrontaskmanager/vendor/composer/installed.json b/modules/qlocrontaskmanager/vendor/composer/installed.json index 9424b69ae..f88a76e51 100644 --- a/modules/qlocrontaskmanager/vendor/composer/installed.json +++ b/modules/qlocrontaskmanager/vendor/composer/installed.json @@ -66,8 +66,67 @@ } ], "install-path": "../dragonmantank/cron-expression" + }, + { + "name": "lorisleiva/cron-translator", + "version": "v0.3.2", + "version_normalized": "0.3.2.0", + "source": { + "type": "git", + "url": "https://github.com/lorisleiva/cron-translator.git", + "reference": "d49dd7732197c2e967a66968c9323c81826c86e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lorisleiva/cron-translator/zipball/d49dd7732197c2e967a66968c9323c81826c86e5", + "reference": "d49dd7732197c2e967a66968c9323c81826c86e5", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.21 || ^9.5" + }, + "time": "2022-06-16T07:37:33+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Lorisleiva\\CronTranslator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Loris LEIVA", + "email": "loris.leiva@gmail.com", + "homepage": "https://lorisleiva.com" + } + ], + "description": "Makes CRON expressions human-readable", + "homepage": "https://github.com/lorisleiva/cron-translator", + "keywords": [ + "cron", + "expression", + "human" + ], + "support": { + "issues": "https://github.com/lorisleiva/cron-translator/issues", + "source": "https://github.com/lorisleiva/cron-translator/tree/v0.3.2" + }, + "funding": [ + { + "url": "https://github.com/lorisleiva", + "type": "github" + } + ], + "install-path": "../lorisleiva/cron-translator" } ], - "dev": false, + "dev": true, "dev-package-names": [] } diff --git a/modules/qlocrontaskmanager/vendor/composer/installed.php b/modules/qlocrontaskmanager/vendor/composer/installed.php index 0dbb6b6de..0833755c0 100644 --- a/modules/qlocrontaskmanager/vendor/composer/installed.php +++ b/modules/qlocrontaskmanager/vendor/composer/installed.php @@ -1,13 +1,13 @@ array( 'name' => 'qloapps/qlocrontaskmanager', - 'pretty_version' => '1.0.0+no-version-set', - 'version' => '1.0.0.0', - 'reference' => NULL, + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', + 'reference' => 'e05c7ad488aaf4098ed194c7ddf0024160987974', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'dev' => false, + 'dev' => true, ), 'versions' => array( 'dragonmantank/cron-expression' => array( @@ -19,6 +19,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'lorisleiva/cron-translator' => array( + 'pretty_version' => 'v0.3.2', + 'version' => '0.3.2.0', + 'reference' => 'd49dd7732197c2e967a66968c9323c81826c86e5', + 'type' => 'library', + 'install_path' => __DIR__ . '/../lorisleiva/cron-translator', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'mtdowling/cron-expression' => array( 'dev_requirement' => false, 'replaced' => array( @@ -26,9 +35,9 @@ ), ), 'qloapps/qlocrontaskmanager' => array( - 'pretty_version' => '1.0.0+no-version-set', - 'version' => '1.0.0.0', - 'reference' => NULL, + 'pretty_version' => 'dev-develop', + 'version' => 'dev-develop', + 'reference' => 'e05c7ad488aaf4098ed194c7ddf0024160987974', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/.gitignore b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/.gitignore new file mode 100644 index 000000000..2825f8dca --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/.gitignore @@ -0,0 +1,5 @@ +vendor +composer.lock +.phpunit.result.cache +build +.idea \ No newline at end of file diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/LICENSE b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/LICENSE new file mode 100644 index 000000000..fdf460a8f --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Loris Leiva + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/README.md b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/README.md new file mode 100644 index 000000000..8fe69121c --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/README.md @@ -0,0 +1,51 @@ +# CRON Translator +⏰️ Makes CRON expressions human-readable + +![intro-rounded](https://user-images.githubusercontent.com/3642397/60768671-7d6c7100-a0be-11e9-8cee-8a8d2780d76f.png) + +## Installation + +```sh +composer require lorisleiva/cron-translator +``` + +## Usage + +```php +use Lorisleiva\CronTranslator\CronTranslator; + +CronTranslator::translate('* * * * *'); // => Every minute +CronTranslator::translate('30 22 * * *'); // => Every day at 10:30pm +CronTranslator::translate('0 16 * * 1'); // => Every Monday at 4:00pm +CronTranslator::translate('0 0 1 1 *'); // => Every year on January the 1st at 12:00am +CronTranslator::translate('0 0 1 * *'); // => The 1st of every month at 12:00am +CronTranslator::translate('0 * * * 1'); // => Once an hour on Mondays +CronTranslator::translate('* 1-20 * * *'); // => Every minute 20 hours a day +CronTranslator::translate('0,30 * * * *'); // => Twice an hour +CronTranslator::translate('0 1-5 * * *'); // => 5 times a day +CronTranslator::translate('0 1 1-5 * *'); // => 5 days a month at 1:00am +CronTranslator::translate('*/2 * * * *'); // => Every 2 minutes +CronTranslator::translate('* 1/3 2 * *'); // => Every minute of every 3 hours on the 2nd of every month +CronTranslator::translate('1-3/5 * * * *'); // => 3 times every 5 minutes +CronTranslator::translate('1,2 0 */2 1,2 *'); // => Twice an hour every 2 days 2 months a year at 12am +``` + +You may also provide a locale as a second argument and whether to format the time using the 24-hour format as a third argument. + + +```php +CronTranslator::translate('30 18 * * *', 'fr'); // => Chaque jour à 6:30pm +CronTranslator::translate('30 18 * * *', 'fr', true); // => Chaque jour à 18:30 +``` + +The following locales are currently supported. Feel free to PR more locales if you need them. 🙂 +- `ar` — Arabic +- `de` — German +- `en` — English +- `es` — Spanish +- `fr` — French +- `lv` — Latvian +- `nl` — Dutch +- `pt` — Portuguese +- `zh` — Chinese +- `sk` - Slovak diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/composer.json b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/composer.json new file mode 100644 index 000000000..1853c3dca --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/composer.json @@ -0,0 +1,34 @@ +{ + "name": "lorisleiva/cron-translator", + "description": "Makes CRON expressions human-readable", + "keywords": [ + "cron", + "expression", + "human" + ], + "homepage": "https://github.com/lorisleiva/cron-translator", + "license": "MIT", + "authors": [ + { + "name": "Loris LEIVA", + "email": "loris.leiva@gmail.com", + "homepage": "https://lorisleiva.com" + } + ], + "require": { + "php" : "^7.4 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit" : "^8.5.21 || ^9.5" + }, + "autoload": { + "psr-4": { + "Lorisleiva\\CronTranslator\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Lorisleiva\\CronTranslator\\Tests\\": "tests" + } + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/CronExpression.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/CronExpression.php new file mode 100644 index 000000000..f129e1116 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/CronExpression.php @@ -0,0 +1,110 @@ +raw = $cron; + $fields = explode(' ', $cron); + $this->minute = new MinutesField($this, $fields[0]); + $this->hour = new HoursField($this, $fields[1]); + $this->day = new DaysOfMonthField($this, $fields[2]); + $this->month = new MonthsField($this, $fields[3]); + $this->weekday = new DaysOfWeekField($this, $fields[4]); + $this->locale = $locale; + $this->timeFormat24hours = $timeFormat24hours; + $this->ensureLocaleExists(); + $this->loadTranslations(); + } + + public function getFields(): array + { + return [ + $this->minute, + $this->hour, + $this->day, + $this->month, + $this->weekday, + ]; + } + + public function langCountable(string $type, int $number) + { + $array = $this->translations[$type]; + + $value = $array[$number] ?? ($array['default'] ?: ''); + + return str_replace(':number', $number, $value); + } + + public function lang(string $key, array $replacements = []) + { + $translation = $this->getArrayDot($this->translations['fields'], $key); + + foreach ($replacements as $key => $value) { + $translation = str_replace(':' . $key, $value, $translation); + } + + return $translation; + } + + protected function ensureLocaleExists(string $fallbackLocale = 'en') + { + if (! is_dir($this->getTranslationDirectory())) { + $this->locale = $fallbackLocale; + } + } + + /** + * @throws TranslationFileMissingException + */ + protected function loadTranslations() + { + $this->translations = [ + 'days' => $this->loadTranslationFile('days'), + 'fields' => $this->loadTranslationFile('fields'), + 'months' => $this->loadTranslationFile('months'), + 'ordinals' => $this->loadTranslationFile('ordinals'), + 'times' => $this->loadTranslationFile('times'), + ]; + } + + protected function loadTranslationFile(string $file) + { + $filename = sprintf('%s/%s.php', $this->getTranslationDirectory(), $file); + + if (! is_file($filename)) { + throw new TranslationFileMissingException($this->locale, $file); + } + + return include $filename; + } + + protected function getTranslationDirectory(): string + { + return __DIR__ . '/lang/' . $this->locale; + } + + protected function getArrayDot(array $array, string $key) + { + $keys = explode('.', $key); + + foreach ($keys as $key) { + $array = $array[$key]; + } + + return $array; + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/CronParsingException.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/CronParsingException.php new file mode 100644 index 000000000..06f8c7335 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/CronParsingException.php @@ -0,0 +1,13 @@ + '0 0 1 1 *', + '@annually' => '0 0 1 1 *', + '@monthly' => '0 0 1 * *', + '@weekly' => '0 0 * * 0', + '@daily' => '0 0 * * *', + '@hourly' => '0 * * * *' + ]; + + public static function translate(string $cron, string $locale = 'en', bool $timeFormat24hours = false): string + { + if (isset(self::$extendedMap[$cron])) { + $cron = self::$extendedMap[$cron]; + } + + try { + $expression = new CronExpression($cron, $locale, $timeFormat24hours); + $orderedFields = static::orderFields($expression->getFields()); + + $translations = array_map(function (Field $field) { + return $field->translate(); + }, $orderedFields); + + return ucfirst(implode(' ', array_filter($translations))); + } catch (Throwable $th) { + throw new CronParsingException($cron); + } + } + + protected static function orderFields(array $fields) + { + // Group fields by CRON types. + $onces = static::filterType($fields, 'Once'); + $everys = static::filterType($fields, 'Every'); + $incrementsAndMultiples = static::filterType($fields, 'Increment', 'Multiple'); + + // Decide whether to keep one or zero CRON type "Every". + $firstEvery = reset($everys)->position ?? PHP_INT_MIN; + $firstIncrementOrMultiple = reset($incrementsAndMultiples)->position ?? PHP_INT_MAX; + $numberOfEverysKept = $firstIncrementOrMultiple < $firstEvery ? 0 : 1; + + // Mark fields that will not be displayed as dropped. + // This allows other fields to check whether some + // information is missing and adapt their translation. + /** @var Field $field */ + foreach (array_slice($everys, $numberOfEverysKept) as $field) { + $field->dropped = true; + } + + return array_merge( + // Place one or zero "Every" field at the beginning. + array_slice($everys, 0, $numberOfEverysKept), + + // Place all "Increment" and "Multiple" fields in the middle. + $incrementsAndMultiples, + + // Finish with the "Once" fields reversed (i.e. from months to minutes). + array_reverse($onces) + ); + } + + protected static function filterType(array $fields, ...$types): array + { + return array_filter($fields, function (Field $field) use ($types) { + return $field->hasType(...$types); + }); + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/CronType.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/CronType.php new file mode 100644 index 000000000..3c4629bed --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/CronType.php @@ -0,0 +1,91 @@ +type = $type; + $this->value = $value; + $this->count = $count; + $this->increment = $increment; + } + + public static function every(): CronType + { + return new static('Every'); + } + + public static function increment(int $increment, int $count = 1): CronType + { + return new static('Increment', null, $count, $increment); + } + + public static function multiple(int $count): CronType + { + return new static('Multiple', null, $count); + } + + public static function once(int $value): CronType + { + return new static('Once', $value); + } + + /** + * @throws CronParsingException + */ + public static function parse(string $expression): CronType + { + // Parse "*". + if ($expression === '*') { + return static::every(); + } + + // Parse fixed values like "1". + if (preg_match("/^[0-9]+$/", $expression)) { + return static::once((int) $expression); + } + + // Parse multiple selected values like "1,2,5". + if (preg_match("/^[0-9]+(,[0-9]+)+$/", $expression)) { + return static::multiple(count(explode(',', $expression))); + } + + // Parse ranges of selected values like "1-5". + if (preg_match("/^([0-9]+)\-([0-9]+)$/", $expression, $matches)) { + $count = $matches[2] - $matches[1] + 1; + return $count > 1 + ? static::multiple($count) + : static::once((int) $matches[1]); + } + + // Parse incremental expressions like "*/2", "1-4/10" or "1,3/4". + if (preg_match("/(.+)\/([0-9]+)$/", $expression, $matches)) { + $range = static::parse($matches[1]); + if ($range->hasType('Once', 'Every')) { + return static::Increment($matches[2]); + } + if ($range->hasType('Multiple')) { + return static::Increment($matches[2], $range->count); + } + } + + // Unsupported expressions throw exceptions. + throw new CronParsingException($expression); + } + + public function hasType(): bool + { + return in_array($this->type, func_get_args()); + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/DaysOfMonthField.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/DaysOfMonthField.php new file mode 100644 index 000000000..16143f204 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/DaysOfMonthField.php @@ -0,0 +1,68 @@ +expression->weekday->hasType('Once')) { + return $this->lang('days_of_week.every', [ + 'weekday' => $this->expression->weekday->format(), + ]); + } + + return $this->lang('days_of_month.every'); + } + + public function translateIncrement() + { + if ($this->getCount() > 1) { + return $this->lang('days_of_month.multiple_per_increment', [ + 'count' => $this->getCount(), + 'increment' => $this->getIncrement(), + ]); + } + + return $this->lang('days_of_month.increment', [ + 'increment' => $this->getIncrement(), + ]); + } + + public function translateMultiple() + { + return $this->lang('days_of_month.multiple_per_month', [ + 'count' => $this->getCount(), + ]); + } + + public function translateOnce(): ?string + { + $month = $this->expression->month; + + if ($month->hasType('Once')) { + return null; // MonthsField adapts to "On January the 1st". + } + + if ($month->hasType('Every') && ! $month->dropped) { + return null; // MonthsField adapts to "The 1st of every month". + } + + if ($month->hasType('Every') && $month->dropped) { + return $this->lang('days_of_month.every_on_day', [ + 'day' => $this->format() + ]); + } + + return $this->lang('days_of_month.once_on_day', [ + 'day' => $this->format() + ]); + } + + public function format() + { + return $this->langCountable('ordinals', $this->getValue()); + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/DaysOfWeekField.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/DaysOfWeekField.php new file mode 100644 index 000000000..60a615a37 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/DaysOfWeekField.php @@ -0,0 +1,56 @@ +lang('years.every'); + } + + public function translateIncrement() + { + if ($this->getCount() > 1) { + return $this->lang('days_of_week.multiple_per_increment', [ + 'count' => $this->getCount(), + 'increment' => $this->getIncrement(), + ]); + } + + return $this->lang('days_of_week.increment', [ + 'increment' => $this->getIncrement(), + ]); + } + + public function translateMultiple() + { + return $this->lang('days_of_week.multiple_days_a_week', [ + 'count' => $this->getCount(), + ]); + } + + public function translateOnce() + { + if ($this->expression->day->hasType('Every') && ! $this->expression->day->dropped) { + return; // DaysOfMonthField adapts to "Every Sunday". + } + + return $this->lang('days_of_week.once_on_day', [ + 'day' => $this->format() + ]); + } + + public function format(): string + { + $weekday = $this->getValue() === 0 ? 7 : $this->getValue(); + + if ($weekday < 1 || $weekday > 7) { + throw new CronParsingException($this->expression->raw); + } + + return $this->langCountable('days', $weekday); + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/Field.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/Field.php new file mode 100644 index 000000000..83470b471 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/Field.php @@ -0,0 +1,63 @@ +expression = $expression; + $this->rawField = $rawField; + $this->type = CronType::parse($rawField); + } + + public function translate() + { + $method = 'translate' . $this->type->type; + + if (method_exists($this, $method)) { + return $this->{$method}(); + } + } + + public function hasType(): bool + { + return $this->type->hasType(...func_get_args()); + } + + public function getValue(): ?int + { + return $this->type->value; + } + + public function getCount(): ?int + { + return $this->type->count; + } + + public function getIncrement(): ?int + { + return $this->type->increment; + } + + public function getTimes() + { + return $this->langCountable('times', $this->getCount()); + } + + protected function langCountable(string $key, int $value) + { + return $this->expression->langCountable($key, $value); + } + + protected function lang(string $key, array $replacements = []) + { + return $this->expression->lang($key, $replacements); + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/HoursField.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/HoursField.php new file mode 100644 index 000000000..7bb91c39e --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/HoursField.php @@ -0,0 +1,85 @@ +expression->minute->hasType('Once')) { + return $this->lang('hours.once_an_hour'); + } + + return $this->lang('hours.every'); + } + + public function translateIncrement() + { + if ($this->expression->minute->hasType('Once')) { + return $this->lang('hours.times_per_increment', [ + 'times' => $this->getTimes(), + 'increment' => $this->getIncrement(), + ]); + } + + if ($this->getCount() > 1) { + return $this->lang('hours.multiple_per_increment', [ + 'count' => $this->getCount(), + 'increment' => $this->getIncrement(), + ]); + } + + if ($this->expression->minute->hasType('Every')) { + return $this->lang('hours.increment_chained', [ + 'increment' => $this->getIncrement(), + ]); + } + + return $this->lang('hours.increment', [ + 'increment' => $this->getIncrement(), + ]); + } + + public function translateMultiple() + { + if ($this->expression->minute->hasType('Once')) { + return $this->lang('hours.times_per_day', [ + 'times' => $this->getTimes(), + ]); + } + + return $this->lang('hours.multiple_per_day', [ + 'count' => $this->getCount(), + ]); + } + + public function translateOnce() + { + $minute = $this->expression->minute->hasType('Once') + ? $this->expression->minute + : null; + + return $this->lang('hours.once_at_time', [ + 'time' => $this->format($minute) + ]); + } + + public function format(?MinutesField $minute = null): string + { + if ($this->expression->timeFormat24hours) { + $hour = $this->getValue(); + + return $minute ? "{$hour}:{$minute->format()}" : "{$hour}:00"; + } + + $amOrPm = $this->getValue() < 12 ? 'am' : 'pm'; + $hour = $this->getValue() % 12; + $hour = $hour === 0 ? 12 : $hour; + + return $minute + ? "{$hour}:{$minute->format()}{$amOrPm}" + : "{$hour}{$amOrPm}"; + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/MinutesField.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/MinutesField.php new file mode 100644 index 000000000..926efb1be --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/MinutesField.php @@ -0,0 +1,39 @@ +lang('minutes.every'); + } + + public function translateIncrement() + { + if ($this->getCount() > 1) { + return $this->lang('minutes.times_per_increment', [ + 'times' => $this->getTimes(), + 'increment' => $this->getIncrement(), + ]); + } + + return $this->lang('minutes.increment', [ + 'increment' => $this->getIncrement(), + ]); + } + + public function translateMultiple() + { + return $this->lang('minutes.multiple', [ + 'times' => $this->getTimes(), + ]); + } + + public function format(): string + { + return ($this->getValue() < 10 ? '0' : '') . $this->getValue(); + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/MonthsField.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/MonthsField.php new file mode 100644 index 000000000..71b54a2b4 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/MonthsField.php @@ -0,0 +1,66 @@ +expression->day->hasType('Once')) { + return $this->lang('months.every_on_day', [ + 'day' => $this->expression->day->format(), + ]); + } + + return $this->lang('months.every'); + } + + public function translateIncrement() + { + if ($this->getCount() > 1) { + return $this->lang('months.multiple_per_increment', [ + 'count' => $this->getCount(), + 'increment' => $this->getCount(), + ]); + } + + return $this->lang('months.increment', [ + 'increment' => $this->getIncrement(), + ]); + } + + public function translateMultiple() + { + return $this->lang('months.multiple_per_year', [ + 'count' => $this->getCount(), + ]); + } + + public function translateOnce() + { + if ($this->expression->day->hasType('Once')) { + return $this->lang('months.once_on_day', [ + 'month' => $this->format(), + 'day' => $this->expression->day->format(), + ]); + } + + return $this->lang('months.once_on_month', [ + 'month' => $this->format() + ]); + } + + /** + * @throws CronParsingException + */ + public function format() + { + if ($this->getValue() < 1 || $this->getValue() > 12) { + throw new CronParsingException($this->expression->raw); + } + + return $this->langCountable('months', $this->getValue()); + } +} diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/TranslationFileMissingException.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/TranslationFileMissingException.php new file mode 100644 index 000000000..541946731 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/TranslationFileMissingException.php @@ -0,0 +1,13 @@ + 'الإثنين', + 2 => 'الثلاثاء', + 3 => 'الأربعاء', + 4 => 'الخميس', + 5 => 'الجمعة', + 6 => 'السبت', + 7 => 'الأحد', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/fields.php new file mode 100644 index 000000000..9bf2551bd --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/fields.php @@ -0,0 +1,48 @@ + [ + 'every' => 'كل دقيقة', + 'increment' => 'كل :increment دقائق', + 'times_per_increment' => ':times كل :increment دقائق', + 'multiple' => ':times ساعات', + ], + 'hours' => [ + 'every' => 'كل ساعة', + 'once_an_hour' => 'مرة في كل ساعة', + 'increment' => 'كل :increment ساعات', + 'multiple_per_increment' => ':count ساعات من :increment', + 'times_per_increment' => ':times كل :increment ساعة', + 'increment_chained' => 'كل :increment ساعة', + 'multiple_per_day' => ':count ساعة كل يوم', + 'times_per_day' => ':times في اليوم', + 'once_at_time' => 'في :time', + ], + 'days_of_month' => [ + 'every' => 'كل يوم', + 'increment' => 'كل :increment يوم', + 'multiple_per_increment' => ':count أيام من :increment', + 'multiple_per_month' => ':count أيام في الشهر', + 'once_on_day' => 'في :day', + 'every_on_day' => 'كل :day من كل شهر', + ], + 'months' => [ + 'every' => 'كل شهر', + 'every_on_day' => ':day من كل شهر', + 'increment' => 'كل :increment شهر', + 'multiple_per_increment' => ':count أشهر من :increment', + 'multiple_per_year' => ':count أشهر في العام', + 'once_on_month' => 'في :month', + 'once_on_day' => 'في :month ال :day', + ], + 'days_of_week' => [ + 'every' => 'كل :weekday', + 'increment' => 'كل :increment أيام في الأسبوع', + 'multiple_per_increment' => ':count أيام الأسبوع من :increment', + 'multiple_days_a_week' => ':count أيام في الأسبوع', + 'once_on_day' => 'في :days', + ], + 'years' => [ + 'every' => 'كل عام', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/months.php new file mode 100644 index 000000000..d2e39e0b8 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/months.php @@ -0,0 +1,16 @@ + 'يناير', + 2 => 'فبراير', + 3 => 'مارس', + 4 => 'ابريل', + 5 => 'مايو', + 6 => 'يونيو', + 7 => 'يوليو', + 8 => 'أغسطس', + 9 => 'سبتمبر', + 10 => 'أكتوبر', + 11 => 'نوفمبر', + 12 => 'ديسمبر', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/ordinals.php new file mode 100644 index 000000000..5196797a6 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/ordinals.php @@ -0,0 +1,12 @@ + ':numberth', + 1 => 'الأول', + 2 => 'الثاني', + 3 => 'الثالث', + 21 => 'الواحد و العشرون', + 22 => 'الثاني و العشرون', + 23 => 'الثالث و العشرون', + 31 => 'الواحد و الثلاثون', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/times.php new file mode 100644 index 000000000..97814a23a --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/ar/times.php @@ -0,0 +1,7 @@ + ':number أوقات', + 1 => 'مرة', + 2 => 'مرتان', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/days.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/days.php new file mode 100644 index 000000000..6fe567556 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/days.php @@ -0,0 +1,11 @@ + 'Montag', + 2 => 'Dienstag', + 3 => 'Mittwoch', + 4 => 'Donnerstag', + 5 => 'Freitag', + 6 => 'Samstag', + 7 => 'Sonntag', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/fields.php new file mode 100644 index 000000000..f82786f81 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/fields.php @@ -0,0 +1,50 @@ + [ + 'every' => 'jede Minute', + 'increment' => 'jede :increment Minute', + 'times_per_increment' => ':times mal alle :increment Minuten', + 'multiple' => ':times mal pro Stunde', + ], + 'hours' => [ + 'every' => 'jede Stunde', + 'once_an_hour' => 'ein mal pro Stunde', + 'increment' => 'jede :increment Stunde', + 'multiple_per_increment' => ':count Stunden aus :increment', + 'times_per_increment' => ':times mal alle :increment Stunden', + 'increment_chained' => 'alle :increment Stunden', + 'multiple_per_day' => ':count Stunden pro Tag', + 'times_per_day' => ':times mal am Tag', + 'once_at_time' => 'um :time', + ], + 'days_of_month' => [ + 'every' => 'jeden Tag', + 'increment' => 'alle :increment Tage', + 'multiple_per_increment' => ':count Tage von :increment', + 'multiple_per_month' => ':count Tage im Monat', + 'once_on_day' => 'am :day', + 'every_on_day' => 'am :day eines jeden Monats', + ], + 'months' => [ + 'every' => 'eines jeden Monat', + 'every_on_day' => 'jeden :day eines jeden Monats', + 'increment' => 'alle :increment Monate', + 'multiple_per_increment' => ':count Monate von :increment', + 'multiple_per_year' => ':count Monate im Jahr', + 'once_on_month' => 'im :month', + 'once_on_day' => 'im :month den :day', + ], + 'days_of_week' => [ + 'every' => 'jeden :weekday', + 'increment' => 'jeden :increment Tag der Woche', + 'multiple_per_increment' => ':count Tage in der Woche aus :increment', + 'multiple_days_a_week' => ':count Tage in der Woche', + #'once_on_day' => 'jeden :days', + #'once_on_day' => 'am :days', + 'once_on_day' => 'des :days', + ], + 'years' => [ + 'every' => 'jedes Jahr', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/months.php new file mode 100644 index 000000000..c27991a1a --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/months.php @@ -0,0 +1,16 @@ + 'Januar', + 2 => 'Februar', + 3 => 'März', + 4 => 'April', + 5 => 'Mai', + 6 => 'Juni', + 7 => 'Juli', + 8 => 'August', + 9 => 'September', + 10 => 'Oktober', + 11 => 'November', + 12 => 'Dezember', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/ordinals.php new file mode 100644 index 000000000..05b089b00 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/ordinals.php @@ -0,0 +1,13 @@ + ':number.', + #'default' => str_pad(':number', 2, 0, STR_PAD_LEFT). '.', + 1 => '1.', + 2 => '2.', + 3 => '3.', + 21 => '21.', + 22 => '22.', + 23 => '23.', + 31 => '31.', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/times.php new file mode 100644 index 000000000..27be24004 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/de/times.php @@ -0,0 +1,7 @@ + ':number', + 1 => 'Ein', + 2 => 'Zwei', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/days.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/days.php new file mode 100644 index 000000000..7df6a9b9f --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/days.php @@ -0,0 +1,11 @@ + 'Monday', + 2 => 'Tuesday', + 3 => 'Wednesday', + 4 => 'Thursday', + 5 => 'Friday', + 6 => 'Saturday', + 7 => 'Sunday', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/fields.php new file mode 100644 index 000000000..28da50251 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/fields.php @@ -0,0 +1,48 @@ + [ + 'every' => 'every minute', + 'increment' => 'every :increment minutes', + 'times_per_increment' => ':times every :increment minutes', + 'multiple' => ':times an hour', + ], + 'hours' => [ + 'every' => 'every hour', + 'once_an_hour' => 'once an hour', + 'increment' => 'every :increment hours', + 'multiple_per_increment' => ':count hours out of :increment', + 'times_per_increment' => ':times every :increment hours', + 'increment_chained' => 'of every :increment hours', + 'multiple_per_day' => ':count hours a day', + 'times_per_day' => ':times a day', + 'once_at_time' => 'at :time', + ], + 'days_of_month' => [ + 'every' => 'every day', + 'increment' => 'every :increment days', + 'multiple_per_increment' => ':count days out of :increment', + 'multiple_per_month' => ':count days a month', + 'once_on_day' => 'on the :day', + 'every_on_day' => 'on the :day of every month', + ], + 'months' => [ + 'every' => 'every month', + 'every_on_day' => 'the :day of every month', + 'increment' => 'every :increment months', + 'multiple_per_increment' => ':count months out of :increment', + 'multiple_per_year' => ':count months a year', + 'once_on_month' => 'on :month', + 'once_on_day' => 'on :month the :day', + ], + 'days_of_week' => [ + 'every' => 'every :weekday', + 'increment' => 'every :increment days of the week', + 'multiple_per_increment' => ':count days of the week out of :increment', + 'multiple_days_a_week' => ':count days a week', + 'once_on_day' => 'on :days', + ], + 'years' => [ + 'every' => 'every year', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/months.php new file mode 100644 index 000000000..159ba1891 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/months.php @@ -0,0 +1,16 @@ + 'January', + 2 => 'February', + 3 => 'March', + 4 => 'April', + 5 => 'May', + 6 => 'June', + 7 => 'July', + 8 => 'August', + 9 => 'September', + 10 => 'October', + 11 => 'November', + 12 => 'December', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/ordinals.php new file mode 100644 index 000000000..47d3f593c --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/ordinals.php @@ -0,0 +1,12 @@ + ':numberth', + 1 => '1st', + 2 => '2nd', + 3 => '3rd', + 21 => '21st', + 22 => '22nd', + 23 => '23rd', + 31 => '31st', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/times.php new file mode 100644 index 000000000..d651e4cba --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/en/times.php @@ -0,0 +1,7 @@ + ':number times', + 1 => 'once', + 2 => 'twice', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/days.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/days.php new file mode 100644 index 000000000..77dd55118 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/days.php @@ -0,0 +1,11 @@ + 'lunes', + 2 => 'martes', + 3 => 'miércoles', + 4 => 'jueves', + 5 => 'viernes', + 6 => 'sábado', + 7 => 'domingo', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/fields.php new file mode 100644 index 000000000..d4bbca445 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/fields.php @@ -0,0 +1,48 @@ + [ + 'every' => 'cada minuto', + 'increment' => 'cada :increment minutos', + 'times_per_increment' => ':times cada :increment minutos', + 'multiple' => ':times cada hora', + ], + 'hours' => [ + 'every' => 'cada hora', + 'once_an_hour' => 'una vez cada hora', + 'increment' => 'cada :increment horas', + 'multiple_per_increment' => ':count horas de cada :increment', + 'times_per_increment' => ':times cada :increment horas', + 'increment_chained' => 'de cada :increment horas', + 'multiple_per_day' => ':count horas al día', + 'times_per_day' => ':times al día', + 'once_at_time' => 'a las :time', + ], + 'days_of_month' => [ + 'every' => 'diario', + 'increment' => 'cada :increment días', + 'multiple_per_increment' => ':count días de :increment', + 'multiple_per_month' => ':count días al mes', + 'once_on_day' => 'el :day', + 'every_on_day' => 'el :day de cada mes', + ], + 'months' => [ + 'every' => 'cada mes', + 'every_on_day' => 'el :day de cada mes', + 'increment' => 'cada :increment meses', + 'multiple_per_increment' => ':count meses de :increment', + 'multiple_per_year' => ':count meses al año', + 'once_on_month' => 'de :month', + 'once_on_day' => 'en :month el :day', + ], + 'days_of_week' => [ + 'every' => 'cada :weekday', + 'increment' => 'cada :increment días de la semana', + 'multiple_per_increment' => ':count días a la semana de :increment', + 'multiple_days_a_week' => ':count días a la semana', + 'once_on_day' => 'los :days', + ], + 'years' => [ + 'every' => 'cada año', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/months.php new file mode 100644 index 000000000..2e988a449 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/months.php @@ -0,0 +1,16 @@ + 'enero', + 2 => 'febrero', + 3 => 'marzo', + 4 => 'abril', + 5 => 'mayo', + 6 => 'junio', + 7 => 'julio', + 8 => 'agosto', + 9 => 'septiembre', + 10 => 'octubre', + 11 => 'noviembre', + 12 => 'diciembre', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/ordinals.php new file mode 100644 index 000000000..1f79960dc --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/ordinals.php @@ -0,0 +1,5 @@ + ':numberº', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/times.php new file mode 100644 index 000000000..868156e00 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/es/times.php @@ -0,0 +1,6 @@ + ':number veces', + 1 => 'una vez', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/days.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/days.php new file mode 100644 index 000000000..2af7be296 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/days.php @@ -0,0 +1,11 @@ + 'lundi', + 2 => 'mardi', + 3 => 'mercredi', + 4 => 'jeudi', + 5 => 'vendredi', + 6 => 'samedi', + 7 => 'dimanche', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/fields.php new file mode 100644 index 000000000..a339c9715 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/fields.php @@ -0,0 +1,48 @@ + [ + 'every' => 'chaque minute', + 'increment' => 'toutes les :increment minutes', + 'times_per_increment' => ':times toutes les :increment minutes', + 'multiple' => ':times par heure', + ], + 'hours' => [ + 'every' => 'chaque heure', + 'once_an_hour' => 'une fois par heure', + 'increment' => 'toutes les :increment heures', + 'multiple_per_increment' => ':count heures au-delà de :increment', + 'times_per_increment' => ':times toutes les :increment heures', + 'increment_chained' => 'toutes les :increment heures', + 'multiple_per_day' => ':count heures par jour', + 'times_per_day' => ':times par jour', + 'once_at_time' => 'à :time', + ], + 'days_of_month' => [ + 'every' => 'chaque jour', + 'increment' => 'tous les :increment jours', + 'multiple_per_increment' => ':count jours sur :increment', + 'multiple_per_month' => ':count jours par mois', + 'once_on_day' => 'le :day', + 'every_on_day' => 'le :day de chaque mois', + ], + 'months' => [ + 'every' => 'chaque mois', + 'every_on_day' => 'le :day de chaque mois', + 'increment' => 'tous les :increment mois', + 'multiple_per_increment' => ':count mois sur :increment', + 'multiple_per_year' => ':count mois par an', + 'once_on_month' => 'en :month', + 'once_on_day' => 'le :day :month', + ], + 'days_of_week' => [ + 'every' => 'chaque :weekday', + 'increment' => 'tous les :increment jours de la semaine', + 'multiple_per_increment' => ':count jours de la semaine sur :increment', + 'multiple_days_a_week' => ':count jours par semaine', + 'once_on_day' => 'les :days', + ], + 'years' => [ + 'every' => 'chaque année', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/months.php new file mode 100644 index 000000000..9b02c93fd --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/months.php @@ -0,0 +1,16 @@ + 'janvier', + 2 => 'février', + 3 => 'mars', + 4 => 'avril', + 5 => 'mai', + 6 => 'juin', + 7 => 'juillet', + 8 => 'août', + 9 => 'septembre', + 10 => 'octobre', + 11 => 'novembre', + 12 => 'décembre', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/ordinals.php new file mode 100644 index 000000000..10a111e78 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/ordinals.php @@ -0,0 +1,6 @@ + ':number', + 1 => '1er', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/times.php new file mode 100644 index 000000000..1d29659b3 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/fr/times.php @@ -0,0 +1,7 @@ + ':number fois', + 1 => 'une fois', + 2 => 'deux fois', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/days.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/days.php new file mode 100644 index 000000000..ee858deff --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/days.php @@ -0,0 +1,11 @@ + 'pirmdien', + 2 => 'otrdien', + 3 => 'trešdien', + 4 => 'ceturtdien', + 5 => 'piektdien', + 6 => 'sestdien', + 7 => 'svētdien', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/fields.php new file mode 100644 index 000000000..2af59e309 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/fields.php @@ -0,0 +1,48 @@ + [ + 'every' => 'katru minūti', + 'increment' => 'ik pēc :increment minūtēm', + 'times_per_increment' => ':times ik pēc :increment minūtēm', + 'multiple' => ':times stundā', + ], + 'hours' => [ + 'every' => 'katru stundu', + 'once_an_hour' => 'vienreiz stundā', + 'increment' => 'katras :increment stundas', + 'multiple_per_increment' => ':count no :increment stundām', + 'times_per_increment' => ':times katras :increment stundas', + 'increment_chained' => 'ik pēc :increment stundām', + 'multiple_per_day' => ':count stundas dienā', + 'times_per_day' => ':times dienā', + 'once_at_time' => 'plkst. :time', + ], + 'days_of_month' => [ + 'every' => 'katru dienu', + 'increment' => 'ik pēc :increment dienām', + 'multiple_per_increment' => ':count dienas no :increment', + 'multiple_per_month' => ':count dienas mēnesī', + 'once_on_day' => ':day. datumā', + 'every_on_day' => 'katra mēneša :day. datumā', + ], + 'months' => [ + 'every' => 'katru mēnesi', + 'every_on_day' => 'katra mēneša :day. datumā', + 'increment' => 'katrus :increment mēnešus', + 'multiple_per_increment' => ':count mēnešus no :increment', + 'multiple_per_year' => ':count mēnešus gadā', + 'once_on_month' => ':month', + 'once_on_day' => ':day. :month', + ], + 'days_of_week' => [ + 'every' => 'katru :weekdayu', + 'increment' => 'ik pēc :increment nedēļas dienām', + 'multiple_per_increment' => ':count nedēļas dienas no :increment', + 'multiple_days_a_week' => ':count dienas nedēļā', + 'once_on_day' => ':dayās', + ], + 'years' => [ + 'every' => 'katru gadu', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/months.php new file mode 100644 index 000000000..23c210f6d --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/months.php @@ -0,0 +1,16 @@ + 'janvārī', + 2 => 'februārī', + 3 => 'martā', + 4 => 'aprīlī', + 5 => 'maijā', + 6 => 'jūnijā', + 7 => 'jūlijā', + 8 => 'augustā', + 9 => 'septembrī', + 10 => 'oktobrī', + 11 => 'novembrī', + 12 => 'decembrī', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/ordinals.php new file mode 100644 index 000000000..e160d8016 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/ordinals.php @@ -0,0 +1,5 @@ + ':number', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/times.php new file mode 100644 index 000000000..9ada98fe3 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/lv/times.php @@ -0,0 +1,7 @@ + ':number reizes', + 1 => 'vienreiz', + 2 => 'divreiz', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/days.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/days.php new file mode 100644 index 000000000..95fa5b769 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/days.php @@ -0,0 +1,11 @@ + 'Maandag', + 2 => 'Dinsdag', + 3 => 'Woensdag', + 4 => 'Donderdag', + 5 => 'Vrijdag', + 6 => 'Zaterdag', + 7 => 'Zondag', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/fields.php new file mode 100644 index 000000000..5a17ce00a --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/fields.php @@ -0,0 +1,48 @@ + [ + 'every' => 'elke minuut', + 'increment' => 'elke :increment minuten', + 'times_per_increment' => ':times elke :increment minuten', + 'multiple' => ':times per uur', + ], + 'hours' => [ + 'every' => 'elk uur', + 'once_an_hour' => 'eens per uur', + 'increment' => 'elke :increment uur', + 'multiple_per_increment' => ':count uur van de :increment', + 'times_per_increment' => ':times elke :increment uur', + 'increment_chained' => 'van elke :increment uur', + 'multiple_per_day' => ':count uur per dag', + 'times_per_day' => ':times per dag', + 'once_at_time' => 'om :time', + ], + 'days_of_month' => [ + 'every' => 'elke dag', + 'increment' => 'elke :increment dagen', + 'multiple_per_increment' => ':count dagen van de :increment', + 'multiple_per_month' => ':count dagen per maand', + 'once_on_day' => 'op de :day', + 'every_on_day' => 'op de :day van elke maand', + ], + 'months' => [ + 'every' => 'elke maand', + 'every_on_day' => 'de :day van elke maand', + 'increment' => 'elke :increment maanden', + 'multiple_per_increment' => ':count maanden van de :increment', + 'multiple_per_year' => ':count maanden per jaar', + 'once_on_month' => 'in :month', + 'once_on_day' => 'in :month de :day', + ], + 'days_of_week' => [ + 'every' => 'elke :weekday', + 'increment' => 'elke :increment dag van de week', + 'multiple_per_increment' => ':count dagen van de week op :increment', + 'multiple_days_a_week' => ':count dagen per week ', + 'once_on_day' => 'op :days', + ], + 'years' => [ + 'every' => 'elk jaar', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/months.php new file mode 100644 index 000000000..0214c8d9f --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/months.php @@ -0,0 +1,16 @@ + 'januari', + 2 => 'februari', + 3 => 'maart', + 4 => 'april', + 5 => 'mei', + 6 => 'juni', + 7 => 'juli', + 8 => 'augustus', + 9 => 'september', + 10 => 'oktober', + 11 => 'november', + 12 => 'december', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/ordinals.php new file mode 100644 index 000000000..89fbe94ef --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/ordinals.php @@ -0,0 +1,5 @@ + ':numbere', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/times.php new file mode 100644 index 000000000..b550e5134 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/nl/times.php @@ -0,0 +1,5 @@ + ':number keer', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/days.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/days.php new file mode 100644 index 000000000..e4a1ca963 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/days.php @@ -0,0 +1,11 @@ + 'Segunda-feira', + 2 => 'Terça-feira', + 3 => 'Quarta-feira', + 4 => 'Quinta-feira', + 5 => 'Sexta-feira', + 6 => 'Sábado', + 7 => 'Domingo', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/fields.php new file mode 100644 index 000000000..d126f4eb3 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/fields.php @@ -0,0 +1,48 @@ + [ + 'every' => 'todos os minutos', + 'increment' => 'cada :increment minutos', + 'times_per_increment' => ':times cada :increment minutos', + 'multiple' => ':times por hora', + ], + 'hours' => [ + 'every' => 'todas as horas', + 'once_an_hour' => 'uma vez por hora', + 'increment' => 'cada :increment horas', + 'multiple_per_increment' => ':count horas cada :increment', + 'times_per_increment' => ':times cada :increment horas', + 'increment_chained' => 'de cada :increment horas', + 'multiple_per_day' => ':count horas por dia', + 'times_per_day' => ':times por dia', + 'once_at_time' => 'às :time', + ], + 'days_of_month' => [ + 'every' => 'todos os dias', + 'increment' => 'cada :increment dias', + 'multiple_per_increment' => ':count dias cada :increment', + 'multiple_per_month' => ':count dias por mês', + 'once_on_day' => 'no :day dia', + 'every_on_day' => 'no :day dia de cada mês', + ], + 'months' => [ + 'every' => 'todos os meses', + 'every_on_day' => 'no :day dia de cada mês', + 'increment' => 'cada :increment meses', + 'multiple_per_increment' => ':count meses cada :increment', + 'multiple_per_year' => ':count meses por ano', + 'once_on_month' => 'em :month', + 'once_on_day' => 'no :day de :month', + ], + 'days_of_week' => [ + 'every' => 'cada :weekday', + 'increment' => 'cada :increment dias da semana', + 'multiple_per_increment' => ':count dias da semana cada :increment', + 'multiple_days_a_week' => ':count dias da semana', + 'once_on_day' => 'nas/nos :days', + ], + 'years' => [ + 'every' => 'todos os anos', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/months.php new file mode 100644 index 000000000..b49d24e61 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/months.php @@ -0,0 +1,16 @@ + 'Janeiro', + 2 => 'Fevereiro', + 3 => 'Março', + 4 => 'Abril', + 5 => 'Maio', + 6 => 'Junho', + 7 => 'Julho', + 8 => 'Agosto', + 9 => 'Setembro', + 10 => 'Outubro', + 11 => 'Novembro', + 12 => 'Dezembro', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/ordinals.php new file mode 100644 index 000000000..1f79960dc --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/ordinals.php @@ -0,0 +1,5 @@ + ':numberº', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/times.php new file mode 100644 index 000000000..e56f6099e --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/pt/times.php @@ -0,0 +1,6 @@ + ':number vezes', + 1 => 'uma vez', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/days.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/days.php new file mode 100644 index 000000000..cb0927418 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/days.php @@ -0,0 +1,11 @@ + 'pondelok', + 2 => 'utorok', + 3 => 'streda', + 4 => 'štvrtok', + 5 => 'piatok', + 6 => 'sobota', + 7 => 'nedeľa', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/fields.php new file mode 100644 index 000000000..6aa909629 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/fields.php @@ -0,0 +1,48 @@ + [ + 'every' => 'každú minútu', + 'increment' => 'každých :increment minút', + 'times_per_increment' => ':times každých :increment minút', + 'multiple' => ':times za hodinu', + ], + 'hours' => [ + 'every' => 'každú hodinu', + 'once_an_hour' => 'raz za hodinu', + 'increment' => 'každých :increment hodín', + 'multiple_per_increment' => ':count hodín z :increment', + 'times_per_increment' => ':times každých :increment hodín', + 'increment_chained' => 'každých :increment hodín', + 'multiple_per_day' => ':count hodín za deň', + 'times_per_day' => ':times za deň', + 'once_at_time' => 'o :time', + ], + 'days_of_month' => [ + 'every' => 'každý deň', + 'increment' => 'každých :increment dní', + 'multiple_per_increment' => ':count dní z :increment', + 'multiple_per_month' => ':count dní v mesiaci', + 'once_on_day' => ':day dňa v mesiaci', + 'every_on_day' => 'na každý :day deň v mesiaci', + ], + 'months' => [ + 'every' => 'každý mesiac', + 'every_on_day' => 'každý :day deň v mesiaci', + 'increment' => 'každých :increment mesiacov', + 'multiple_per_increment' => ':count mesiacov z :increment', + 'multiple_per_year' => ':count mesiacov ročne', + 'once_on_month' => 'v mesiaci :month', + 'once_on_day' => 'na :day deň v mesiaci :month', + ], + 'days_of_week' => [ + 'every' => 'každá/ý :weekday', + 'increment' => 'každých :increment dní v týždni', + 'multiple_per_increment' => ':count dní v týždni z :increment', + 'multiple_days_a_week' => ':count dní v týždni', + 'once_on_day' => 'v :day', + ], + 'years' => [ + 'every' => 'každý rok', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/months.php new file mode 100644 index 000000000..d3be7f015 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/months.php @@ -0,0 +1,16 @@ + 'január', + 2 => 'február', + 3 => 'marec', + 4 => 'apríl', + 5 => 'máj', + 6 => 'jún', + 7 => 'júl', + 8 => 'august', + 9 => 'september', + 10 => 'október', + 11 => 'november', + 12 => 'december', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/ordinals.php new file mode 100644 index 000000000..7194b57a7 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/ordinals.php @@ -0,0 +1,12 @@ + ':number.', + 1 => '1.', + 2 => '2.', + 3 => '3.', + 21 => '21.', + 22 => '22.', + 23 => '23.', + 31 => '31.', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/times.php new file mode 100644 index 000000000..a51eee42a --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/sk/times.php @@ -0,0 +1,7 @@ + ':number-krát', + 1 => 'raz', + 2 => 'dva razy', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/days.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/days.php new file mode 100644 index 000000000..62eb6813f --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/days.php @@ -0,0 +1,11 @@ + '周一', + 2 => '周二', + 3 => '周三', + 4 => '周四', + 5 => '周五', + 6 => '周六', + 7 => '周日', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/fields.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/fields.php new file mode 100644 index 000000000..630ed4769 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/fields.php @@ -0,0 +1,48 @@ + [ + 'every' => '每分钟', + 'increment' => '每:increment分钟', + 'times_per_increment' => '每:increment分钟:times', + 'multiple' => '一小时:times', + ], + 'hours' => [ + 'every' => '每小时', + 'once_an_hour' => '每整点', + 'increment' => '每:increment小时', + 'multiple_per_increment' => '每:increment小时中有:count小时', + 'times_per_increment' => '每:increment小时:times', + 'increment_chained' => '每:increment小时', + 'multiple_per_day' => '每天有:count小时', + 'times_per_day' => '每天:times', + 'once_at_time' => '在:time', + ], + 'days_of_month' => [ + 'every' => '每天', + 'increment' => '每:increment天', + 'multiple_per_increment' => '每:increment天中有:count天', + 'multiple_per_month' => '每月:count天', + 'once_on_day' => '在:day号', + 'every_on_day' => '在每月:day号', + ], + 'months' => [ + 'every' => '每月', + 'every_on_day' => '每月:day号', + 'increment' => '每:increment个月', + 'multiple_per_increment' => '每:increment月中有:count月', + 'multiple_per_year' => '每年:count个月', + 'once_on_month' => '在:month', + 'once_on_day' => '在:month:day号', + ], + 'days_of_week' => [ + 'every' => '每周:weekday', + 'increment' => '每周:increment天', + 'multiple_per_increment' => '每:increment周中有:count天', + 'multiple_days_a_week' => '一周:count天', + 'once_on_day' => '在:day', + ], + 'years' => [ + 'every' => '每年', + ], +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/months.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/months.php new file mode 100644 index 000000000..8451ff176 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/months.php @@ -0,0 +1,16 @@ + '一月', + 2 => '二月', + 3 => '三月', + 4 => '四月', + 5 => '五月', + 6 => '六月', + 7 => '七月', + 8 => '八月', + 9 => '九月', + 10 => '十月', + 11 => '十一月', + 12 => '十二月', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/ordinals.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/ordinals.php new file mode 100644 index 000000000..e160d8016 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/ordinals.php @@ -0,0 +1,5 @@ + ':number', +]; diff --git a/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/times.php b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/times.php new file mode 100644 index 000000000..339427672 --- /dev/null +++ b/modules/qlocrontaskmanager/vendor/lorisleiva/cron-translator/src/lang/zh/times.php @@ -0,0 +1,5 @@ + ':number次', +]; diff --git a/modules/qlocrontaskmanager/views/css/admin/qlo_cron_task_manager_admin.css b/modules/qlocrontaskmanager/views/css/admin/qlo_cron_task_manager_admin.css index 59148e892..c52809b7c 100644 --- a/modules/qlocrontaskmanager/views/css/admin/qlo_cron_task_manager_admin.css +++ b/modules/qlocrontaskmanager/views/css/admin/qlo_cron_task_manager_admin.css @@ -31,3 +31,26 @@ .label-default { background-color: #999; } + + +.qctm-cron-fields-table thead th { + text-align: center; + font-size: 14px; + font-weight: bold; + border: 1px solid #ddd!important; + padding: 8px; +} + +.qctm-cron-fields-table tbody td { + text-align: center; + font-size: 12px; + color: #666; + border: 1px solid #e5e5e5; + padding: 6px; +} +.cron-expression-invalid{ + color: #c33333!important; +} +.cron-expression-valid{ + color: #409bbd !important +} diff --git a/modules/qlocrontaskmanager/views/js/admin/qlo_cron_task_manager_admin.js b/modules/qlocrontaskmanager/views/js/admin/qlo_cron_task_manager_admin.js index c361251e7..05b821077 100644 --- a/modules/qlocrontaskmanager/views/js/admin/qlo_cron_task_manager_admin.js +++ b/modules/qlocrontaskmanager/views/js/admin/qlo_cron_task_manager_admin.js @@ -111,6 +111,59 @@ var QctmAdmin = { }, }; +var QctmCronHelper = { + $input: null, + cronRegex: /^(\*|[\d\/*,\-]+)\s+(\*|[\d\/*,\-]+)\s+(\*|[\d\/*,\-]+)\s+(\*|[\d\/*,\-]+)\s+(\*|[\d\/*,\-]+)$/, + + init: function () { + this.$input = $('.qctm-cron-expression'); + + if (!this.$input.length) { + return; + } + this.$input.on('input keyup', this.onInput.bind(this)); + }, + + onInput: function (e) { + var $input = $(e.currentTarget); + var val = $input.val(); + val = val.replace(/[^0-9*\/,\-\s]/g, ''); + $input.val(val); + var $readable = $input.closest('.col-lg-4').find('.help-block'); + if (this.cronRegex.test(val)) { + this.fetchReadable(val, $readable); + } else { + $readable.removeClass('cron-expression-valid').addClass('cron-expression-invalid').text(INVALID_CRON_EXPRESSION); + } + }, + + fetchReadable: function (val, $readable) { + var ajaxUrl = $('#qctm-ajax-url').val(); + + if (!ajaxUrl || !val) { + return; + } + + $.ajax({ + url: ajaxUrl, + type: 'GET', + data: { + action: 'getCronReadable', + cron_expression: val + }, + dataType: 'json', + success: function (response) { + if (response && response.valid) { + $readable.removeClass('cron-expression-invalid').addClass('cron-expression-valid').text(response.readable ); + } else { + $readable.removeClass('cron-expression-valid').addClass('cron-expression-invalid').text(response.readable); + } + } + }); + } +}; + $(document).ready(function () { QctmAdmin.init(); + QctmCronHelper.init(); }); diff --git a/modules/qlocrontaskmanager/views/templates/admin/configure.tpl b/modules/qlocrontaskmanager/views/templates/admin/configure.tpl index bb2171db3..ad651a980 100644 --- a/modules/qlocrontaskmanager/views/templates/admin/configure.tpl +++ b/modules/qlocrontaskmanager/views/templates/admin/configure.tpl @@ -24,12 +24,12 @@
{l s='Cron Command' mod='qlocrontaskmanager'}
-
+
{l s='Add the following cron entry to your server. This single command will manage all module cron tasks automatically.' mod='qlocrontaskmanager'}
- +
{l s='Success' mod='qlocrontaskmanager'} +{elseif $status == QctmCronTaskLog::QCTM_CRON_TASK_LOG_STATUS_ERROR} + {l s='Error' mod='qlocrontaskmanager'} +{else} + {l s='N/A' mod='qlocrontaskmanager'} +{/if} + diff --git a/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_cron_expression_helper.tpl b/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_cron_expression_helper.tpl new file mode 100644 index 000000000..71fa155cf --- /dev/null +++ b/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_cron_expression_helper.tpl @@ -0,0 +1,48 @@ +{* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/licenses/afl-3.0.php Academic Free License 3.0 +*} + +
+
+

The cron expression is made of five fields. Each field can have the following values.

+ + + + + + + + + + + + + + + + + + + +
*****
{l s='minute (0-59)' mod='qlocrontaskmanager'}{l s='hour (0 - 23)' mod='qlocrontaskmanager'}{l s='day of the month (1 - 31)' mod='qlocrontaskmanager'}{l s='month (1 - 12)' mod='qlocrontaskmanager'}{l s='day of the week (0 - 6)' mod='qlocrontaskmanager'}
+
+
+ \ No newline at end of file diff --git a/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_reset_module_crons_link.tpl b/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_reset_module_crons_link.tpl new file mode 100644 index 000000000..ec588fc96 --- /dev/null +++ b/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_reset_module_crons_link.tpl @@ -0,0 +1,26 @@ +{* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/licenses/afl-3.0.php Academic Free License 3.0 +*} + + + {l s='Reset' mod='qlocrontaskmanager'} + diff --git a/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_view_log.tpl b/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_view_log.tpl index 93adea4ff..25390af48 100644 --- a/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_view_log.tpl +++ b/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_view_log.tpl @@ -20,4 +20,8 @@ * @license https://opensource.org/licenses/afl-3.0.php Academic Free License 3.0 *} -{l s='Logs' mod='qlocrontaskmanager'} + diff --git a/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_view_logs_link.tpl b/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_view_logs_link.tpl new file mode 100644 index 000000000..c81c1bc50 --- /dev/null +++ b/modules/qlocrontaskmanager/views/templates/admin/cron_task_manager/qctm_view_logs_link.tpl @@ -0,0 +1,27 @@ +{* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/licenses/afl-3.0.php Academic Free License 3.0 +*} + + + + {l s='View Logs' mod='qlocrontaskmanager'} + +