/** * @param string $value * @return string */ private function createListSelection($value) { $code = '<select name="tx_scheduler[listId]" id="listId">'; $code .= '<option value=""></option>'; foreach ($this->mailChimp->getLists() as $list) { $selected = $list['id'] == $value ? ' selected="selected"' : ''; $code .= '<option value="' . $list['id'] . '"' . $selected . '>' . htmlentities($list['name']) . '</option>'; } $code .= '</select>'; $code .= "<script type='text/javascript'>\n \$('listId').observe('change', function() {\n alert('You need to save and reopen the task to continue with the configuration');\n });\n </script>"; return $code; }
/** * Gets additional fields to render in the form to add/edit a task * * @param array $taskInfo Values of the fields from the add/edit task form * @param SyncBackFromMailChimpTask $task The task object being eddited. Null when adding a task! * @param SchedulerModuleController $schedulerModule Reference to the scheduler backend module * @return array A two dimensional array, array('Identifier' => array('fieldId' => array('code' => '', 'label' => '', 'cshKey' => '', 'cshLabel' => '')) */ public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule) { $codeListId = '<select name="tx_scheduler[listId]">'; foreach ($this->mailChimp->getLists() as $list) { $selected = $task != NULL && $list['id'] == $task->getListId() ? ' selected="selected"' : ''; $codeListId .= '<option value="' . $list['id'] . '"' . $selected . '>' . htmlentities($list['name']) . '</option>'; } $codeListId .= '</select>'; $codeMailField = '<select name="tx_scheduler[emailField]">'; foreach ($GLOBALS['TCA']['fe_users']['columns'] as $column => $config) { $label = $GLOBALS['LANG']->sL($config['label']); if (strlen($label) == 0) { $label = $column; } else { $label = substr($label, 0, strlen($label) - 1); } $selected = $task != NULL && $column == $task->getEmailField() ? ' selected="selected"' : ''; $codeMailField .= '<option value="' . $column . '"' . $selected . '>' . $label . ' (' . $column . ')</option>'; } $codeMailField .= '</select>'; return array('listId' => array('code' => $codeListId, 'label' => 'LLL:EXT:t3chimp/Resources/Private/Language/locallang_backend.xlf:syncBackFromMailChimpTask_label_listId'), 'emailField' => array('code' => $codeMailField, 'label' => 'LLL:EXT:t3chimp/Resources/Private/Language/locallang_backend.xlf:syncBackFromMailChimpTask_label_emailField')); }