Example #1
0
 public static function init()
 {
     if (self::$_isInit === true) {
         return;
     }
     self::$_isInit = true;
 }
Example #2
0
 public function view()
 {
     Extension_Cron::init();
     try {
         $task = (new Lib\CronTask(Symphony::Database()))->load(realpath(MANIFEST . '/cron') . '/' . $this->_context[0]);
     } catch (Exception $e) {
         throw new \SymphonyErrorPage('The cron task <code>' . $this->_context[0] . '</code> could not be found.', 'Task Not Found');
     }
     header('Content-Type: text/plain');
     echo "Log for task `" . $task->name . "`:" . PHP_EOL . "------------------------------------" . PHP_EOL . PHP_EOL;
     echo $task->getLog();
     exit;
 }
Example #3
0
 public function view()
 {
     $this->setPageType('table');
     $this->setTitle('Symphony &ndash; Cron');
     $this->appendSubheading('Cron Tasks', [Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a cron task'), 'create button', null, ['accesskey' => 'c'])]);
     Extension_Cron::init();
     $iterator = new Lib\CronTaskIterator(realpath(MANIFEST . '/cron'), Symphony::Database());
     $aTableHead = [['Name', 'col'], ['Description', 'col'], ['Enabled', 'col'], ['Last Executed', 'col'], ['Next Execution', 'col'], ['Last Output', 'col']];
     $aTableBody = [];
     if ($iterator->count() == 0) {
         $aTableBody = [Widget::TableRow([Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))], 'odd')];
     } else {
         foreach ($iterator as $ii => $task) {
             $td1 = Widget::TableData(Widget::Anchor($task->name, sprintf('%sedit/%s/', Administration::instance()->getCurrentPageURL(), $task->filename)));
             $td1->appendChild(Widget::Label(__('Select Task %s', [$task->filename]), null, 'accessible', null, array('for' => 'task-' . $ii)));
             $td1->appendChild(Widget::Input('items[' . $task->filename . ']', 'on', 'checkbox', array('id' => 'task-' . $ii)));
             $td2 = Widget::TableData(is_null($task->description) ? 'None' : $task->description);
             if (is_null($task->description)) {
                 $td2->setAttribute('class', 'inactive');
             }
             $td3 = Widget::TableData($task->enabledReal() == true ? 'Yes' : 'No');
             if ($task->enabled == false) {
                 $td3->setAttribute('class', 'inactive');
             }
             $td4 = Widget::TableData(!is_null($task->getLastExecutionTimestamp()) ? DateTimeObj::get(__SYM_DATETIME_FORMAT__, $task->getLastExecutionTimestamp()) : 'Unknown');
             if (is_null($task->getLastExecutionTimestamp())) {
                 $td4->setAttribute('class', 'inactive');
             }
             $td5 = Widget::TableData(!is_null($task->nextExecution()) ? self::__minutesToHumanReadable(ceil($task->nextExecution() * (1 / 60))) : 'Unknown');
             if (is_null($task->nextExecution()) || $task->enabledReal() == false) {
                 $td5->setAttribute('class', 'inactive');
             }
             if (is_null($task->getLog())) {
                 $td6 = Widget::TableData('None', 'inactive');
             } else {
                 $td6 = Widget::TableData(Widget::Anchor('view', sprintf('%slog/%s/', Administration::instance()->getCurrentPageURL(), $task->filename)));
             }
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5, $td6));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = [[null, false, __('With Selected...')], ['enable', false, __('Enable')], ['disable', false, __('Disable')], ['delete', false, __('Delete'), 'confirm', null, ['data-message' => __('Are you sure you want to delete the selected tasks?')]]];
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
 }