<import>
<cronjob>
<classname>wcf\system\cronjob\GetUpdateInfoCronjob</classname>
- <description>Gets update package information</description>
+ <description><![CDATA[Updates package information]]></description>
+ <description language="de"><![CDATA[Aktualisiert Paket-Informationen]]></description>
<startminute>0</startminute>
<starthour>2</starthour>
<startdom>*/2</startdom>
<cronjob>
<classname>wcf\system\cronjob\RefreshSearchRobotsCronjob</classname>
- <description>Refreshes list of search robots</description>
+ <description><![CDATA[Refreshes list of search robots]]></description>
+ <description language="de"><![CDATA[Aktualisiert die Liste der Suchroboter]]></description>
<startminute>0</startminute>
<starthour>3</starthour>
<startdom>1</startdom>
<cronjob>
<classname>wcf\system\cronjob\DailyCleanUpCronjob</classname>
- <description>Daily Cleanup</description>
+ <description><![CDATA[Executes daily Cleanup]]></description>
+ <description language="de"><![CDATA[Führt tägliche Aufräumarbeiten aus]]></description>
<startminute>0</startminute>
<starthour>1</starthour>
<startdom>*</startdom>
<cronjob>
<classname>wcf\system\cronjob\HourlyCleanUpCronjob</classname>
- <description>Hourly Cleanup</description>
+ <description><![CDATA[Executes hourly Cleanup]]></description>
+ <description language="de"><![CDATA[Führt stündliche Aufräumarbeiten aus]]></description>
<startminute>0</startminute>
<starthour>*</starthour>
<startdom>*</startdom>
<cronjob>
<classname>wcf\system\cronjob\SessionCleanUpCronjob</classname>
- <description>Deletes expired sessions</description>
+ <description><![CDATA[Deletes expired sessions]]></description>
+ <description language="de"><![CDATA[Löscht abgelaufene Sessions]]></description>
<startminute>*/30</startminute>
<starthour>*</starthour>
<startdom>*</startdom>
{include file='header' pageTitle='wcf.acp.cronjob.'|concat:$action}
+{include file='multipleLanguageInputJavascript' elementIdentifier='description'}
+
<header class="boxHeadline">
<hgroup>
<h1>{lang}wcf.acp.cronjob.{$action}{/lang}</h1>
</dd>
</dl>
- <dl>
+ <dl{if $errorField == 'description'} class="formError"{/if}>
<dt><label for="description">{lang}wcf.acp.cronjob.description{/lang}</label></dt>
<dd>
<input type="text" id="description" name="description" value="{$description}" class="long" />
+ {if $errorField == 'description'}
+ <small class="innerError">
+ {if $errorType == 'empty' || $errorType == 'multilingual'}
+ {lang}wcf.global.form.error.{@$errorType}{/lang}
+ {else}
+ {lang}wcf.acp.cronjob.className.error.{@$errorType}{/lang}
+ {/if}
+ </small>
+ {/if}
</dd>
</dl>
<td class="columnDate columnStartDom"><p>{$cronjob->startDom|truncate:30:' ...'}</p></td>
<td class="columnDate columnStartMonth"><p>{$cronjob->startMonth|truncate:30:' ...'}</p></td>
<td class="columnDate columnStartDow"><p>{$cronjob->startDow|truncate:30:' ...'}</p></td>
- <td class="columnText columnDescription" title="{$cronjob->description}">
+ <td class="columnText columnDescription" title="{$cronjob->description|language}">
{if $cronjob->isEditable()}
- <p><a title="{lang}wcf.acp.cronjob.edit{/lang}" href="{link controller='CronjobEdit' id=$cronjob->cronjobID}{/link}">{$cronjob->description|truncate:50:" ..."}</a></p>
+ <p><a title="{lang}wcf.acp.cronjob.edit{/lang}" href="{link controller='CronjobEdit' id=$cronjob->cronjobID}{/link}">{$cronjob->description|language|truncate:50:" …"}</a></p>
{else}
- <p>{$cronjob->description|truncate:50:' ...'}</p>
+ <p>{$cronjob->description|language|truncate:50:' …'}</p>
{/if}
</td>
<td class="columnDate columnNextExec">
<tr>
<td class="columnID columnCronjobID"><p>{@$cronjobLog->cronjobID}</p></td>
<td class="columnTitle columnClassName"><p>{$cronjobLog->className}</p></td>
- <td class="columnText columnDescription"><p>{$cronjobLog->description}</p></td>
+ <td class="columnText columnDescription"><p>{$cronjobLog->description|language}</p></td>
{if $cronjobLog->success}
<td class="columnDate columnExecTime"><p>{@$cronjobLog->execTime|time} {lang}wcf.acp.cronjob.log.success{/lang}</p></td>
{elseif $cronjobLog->error}
{else}
<td class="columnDate columnExecTime"></td>
{/if}
-
+
{event name='columns'}
</tr>
{/foreach}
<?php
namespace wcf\acp\form;
use wcf\data\cronjob\CronjobAction;
+use wcf\data\cronjob\CronjobEditor;
use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
+use wcf\system\language\I18nHandler;
use wcf\system\WCF;
use wcf\util\CronjobUtil;
use wcf\util\StringUtil;
*/
public $startDow = '*';
+ /**
+ * @see wcf\page\IPage::readParameters()
+ */
+ public function readParameters() {
+ parent::readParameters();
+
+ I18nHandler::getInstance()->register('description');
+ }
+
/**
* @see wcf\form\IForm::readFormParameters()
*/
public function readFormParameters() {
parent::readFormParameters();
+ I18nHandler::getInstance()->readValues();
+
if (isset($_POST['className'])) $this->className = StringUtil::trim($_POST['className']);
if (isset($_POST['description'])) $this->description = StringUtil::trim($_POST['description']);
if (isset($_POST['startMinute'])) $this->startMinute = StringUtil::replace(' ', '', $_POST['startMinute']);
throw new UserInputException('className', 'doesNotExist');
}
+ // validate description
+ if (!I18nHandler::getInstance()->validateValue('description')) {
+ if (I18nHandler::getInstance()->isPlainValue('description')) {
+ throw new UserInputException('description');
+ }
+ else {
+ throw new UserInputException('description', 'multilingual');
+ }
+ }
+
try {
CronjobUtil::validate($this->startMinute, $this->startHour, $this->startDom, $this->startMonth, $this->startDow);
}
$this->objectAction = new CronjobAction(array(), 'create', array('data' => $data));
$this->objectAction->executeAction();
+
+ if (!I18nHandler::getInstance()->isPlainValue('description')) {
+ $returnValues = $this->objectAction->getReturnValues();
+ $cronjobID = $returnValues['returnValues']->cronjobID;
+ I18nHandler::getInstance()->save('description', 'wcf.acp.cronjob.description.cronjob'.$cronjobID, 'wcf.acp.cronjob', $this->packageID);
+
+ // update group name
+ $cronjobEditor = new CronjobEditor($returnValues['returnValues']);
+ $cronjobEditor->update(array(
+ 'description' => 'wcf.acp.cronjob.description.cronjob'.$cronjobID
+ ));
+ }
+
$this->saved();
// reset values
public function assignVariables() {
parent::assignVariables();
+ I18nHandler::getInstance()->assignVariables();
+
WCF::getTPL()->assign(array(
'className' => $this->className,
'description' => $this->description,
use wcf\data\cronjob\Cronjob;
use wcf\data\cronjob\CronjobAction;
use wcf\system\exception\IllegalLinkException;
+use wcf\system\language\I18nHandler;
use wcf\system\WCF;
/**
public function save() {
ACPForm::save();
+ $this->description = 'wcf.acp.cronjob.description.cronjob'.$this->cronjob->cronjobID;
+ if (I18nHandler::getInstance()->isPlainValue('description')) {
+ I18nHandler::getInstance()->remove($this->description, 1);
+ $this->description = I18nHandler::getInstance()->getValue('description');
+ }
+ else {
+ I18nHandler::getInstance()->save('description', $this->description, 'wcf.acp.cronjob', $this->cronjob->packageID);
+ }
+
// update cronjob
$data = array(
'className' => $this->className,
parent::readData();
if (empty($_POST)) {
+ I18nHandler::getInstance()->setOptions('description', $this->cronjob->packageID, $this->cronjob->description, 'wcf.acp.cronjob.description.cronjob\d+');
+
$this->className = $this->cronjob->className;
$this->description = $this->cronjob->description;
$this->startMinute = $this->cronjob->startMinute;
public function assignVariables() {
parent::assignVariables();
+ I18nHandler::getInstance()->assignVariables(!empty($_POST));
+
WCF::getTPL()->assign(array(
'cronjobID' => $this->cronjobID,
'action' => 'edit'
<?php
namespace wcf\data\cronjob;
+use wcf\data\language\LanguageList;
use wcf\data\DatabaseObjectEditor;
use wcf\data\IEditableCachedObject;
use wcf\system\cache\CacheHandler;
+use wcf\system\language\LanguageFactory;
+use wcf\system\WCF;
/**
* Provides functions to edit cronjobs.
*
- * @author Alexander Ebert
+ * @author Alexander Ebert, Matthias Schmidt
* @copyright 2001-2012 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
*/
protected static $baseClass = 'wcf\data\cronjob\Cronjob';
+ /**
+ * @see wcf\data\IEditableObject::create()
+ */
+ public static function create(array $parameters = array()) {
+ $descriptions = array();
+ if (isset($parameters['description']) && is_array($parameters['description'])) {
+ if (count($parameters['description']) > 1) {
+ $descriptions = $parameters['description'];
+ $parameters['description'] = '';
+ }
+ else {
+ $parameters['description'] = reset($parameters['description']);
+ }
+ }
+
+ $cronjob = parent::create($parameters);
+
+ // save cronjob description
+ if (!empty($descriptions)) {
+ // set default value
+ if (isset($descriptions[''])) {
+ $defaultValue = $descriptions[''];
+ }
+ else if (isset($descriptions['en'])) {
+ // fallback to English
+ $defaultValue = $descriptions['en'];
+ }
+ else if (isset($descriptions[WCF::getLanguage()->getFixedLanguageCode()])) {
+ // fallback to the language of the current user
+ $defaultValue = $descriptions[WCF::getLanguage()->getFixedLanguageCode()];
+ }
+ else {
+ // fallback to first description
+ $defaultValue = reset($descriptions);
+ }
+
+ // fetch data directly from database during framework installation
+ if (!PACKAGE_ID) {
+ $sql = "SELECT *
+ FROM wcf".WCF_N."_language_category
+ WHERE languageCategory = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array('wcf.acp.cronjob'));
+ $languageCategory = $statement->fetchObject('wcf\data\language\category\LanguageCategory');
+
+ $languages = new LanguageList();
+ $languages->sqlLimit = 0;
+ $languages->readObjects();
+ }
+ else {
+ $languages = LanguageFactory::getInstance()->getLanguages();
+ $languageCategory = LanguageFactory::getInstance()->getCategory('wcf.acp.cronjob');
+ }
+
+ $sql = "INSERT INTO wcf".WCF_N."_language_item
+ (languageID, languageItem, languageItemValue, languageCategoryID, packageID)
+ VALUES (?, ?, ?, ?, ?)";
+ $statement = WCF::getDB()->prepareStatement($sql);
+
+ foreach ($languages as $language) {
+ $value = $defaultValue;
+ if (isset($descriptions[$language->languageCode])) {
+ $value = $descriptions[$language->languageCode];
+ }
+
+ $statement->execute(array(
+ $language->languageID,
+ 'wcf.acp.cronjob.description.cronjob'.$cronjob->cronjobID,
+ $value,
+ $languageCategory->languageCategoryID,
+ $cronjob->packageID
+ ));
+ }
+
+ // update cronjob
+ $cronjobEditor = new CronjobEditor($cronjob);
+ $cronjobEditor->update(array(
+ 'description' => 'wcf.acp.cronjob.description.cronjob'.$cronjob->cronjobID
+ ));
+ }
+
+ return $cronjob;
+ }
+
/**
* @see wcf\data\IEditableCachedObject::resetCache()
*/
*/
public $className = 'wcf\data\cronjob\CronjobEditor';
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::getElement()
+ */
+ protected function getElement(\DOMXpath $xpath, array &$elements, \DOMElement $element) {
+ if ($element->tagName == 'description') {
+ if (!isset($elements['description'])) {
+ $elements['description'] = array();
+ }
+
+ $elements['description'][$element->getAttribute('language')] = $element->nodeValue;
+ }
+ else {
+ parent::getElement($xpath, $elements, $element);
+ }
+ }
+
/**
* @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
*/