}
if ($data['data']['mode'] !== 'import') {
- $xmlData = array_merge($data, $data['data']);
- unset($xmlData['data'], $xmlData['mode']);
- $packageXmlWriter = new DevtoolsPackageXmlWriter($project, $xmlData);
- $packageXmlWriter->write();
+ $this->writePackageXml($project, $data);
}
$this->saved();
WCF::getTPL()->assign('success', true);
}
+
+ /**
+ * Writes the updated `package.xml` file for the given project using the given data.
+ *
+ * @param DevtoolsProject $project
+ * @param array $data
+ */
+ protected function writePackageXml(DevtoolsProject $project, array $data) {
+ $xmlData = array_merge($data, $data['data']);
+ unset($xmlData['data'], $xmlData['mode']);
+ $packageXmlWriter = new DevtoolsPackageXmlWriter($project, $xmlData);
+ $packageXmlWriter->write();
+ }
}
namespace wcf\acp\form;
use wcf\data\devtools\project\DevtoolsProject;
use wcf\system\exception\IllegalLinkException;
+use wcf\system\form\builder\container\TabMenuFormContainer;
+use wcf\system\form\builder\container\TabTabMenuFormContainer;
use wcf\system\form\builder\field\BooleanFormField;
use wcf\system\form\builder\field\devtools\project\DevtoolsProjectExcludedPackagesFormField;
use wcf\system\form\builder\field\devtools\project\DevtoolsProjectInstructionsFormField;
use wcf\system\form\builder\field\MultipleSelectionFormField;
use wcf\system\form\builder\field\TextFormField;
use wcf\system\language\LanguageFactory;
+use wcf\system\WCF;
/**
* Shows the devtools project edit form.
*/
public $activeMenuItem = 'wcf.acp.menu.link.devtools.project.list';
+ /**
+ * @var bool
+ */
+ public $hasBrokenPath = false;
+
/**
* @inheritDoc
*/
public $formAction = 'edit';
+ /**
+ * @inheritDoc
+ */
+ public function assignVariables() {
+ parent::assignVariables();
+
+ WCF::getTPL()->assign([
+ 'hasBrokenPath' => $this->hasBrokenPath
+ ]);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function buildForm() {
+ parent::buildForm();
+
+ // only show `name` and `path` field which are stored in database if path to
+ // `package.xml` file is broken
+ if ($this->hasBrokenPath) {
+ $this->tooglePackageXmlFieldAvailabilty(false);
+ }
+ }
+
/**
* @inheritDoc
*/
if (!$this->formObject->projectID) {
throw new IllegalLinkException();
}
+
+ if (!file_exists($this->formObject->getPackageXmlPath())) {
+ $this->hasBrokenPath = true;
+ }
+ }
+ }
+
+ /**
+ * @inheritDoc
+ * @since 5.2
+ */
+ public function saved() {
+ parent::saved();
+
+ if ($this->hasBrokenPath) {
+ $this->tooglePackageXmlFieldAvailabilty(true);
+
+ $this->hasBrokenPath = false;
}
}
protected function setFormObjectData() {
parent::setFormObjectData();
+ if ($this->hasBrokenPath) {
+ return;
+ }
+
// set additional data based on `package.xml` file
$packageArchive = $this->formObject->getPackageArchive();
$instructionsField = $this->form->getNodeById('instructions');
$instructionsField->value($instructions);
}
+
+ protected function tooglePackageXmlFieldAvailabilty($available) {
+ /** @var TabMenuFormContainer $tabMenu */
+ $tabMenu = $this->form->getNodeById('project');
+
+ /** @var TabTabMenuFormContainer $tab */
+ foreach ($tabMenu->children() as $tab) {
+ if ($tab->getId() !== 'dataTab') {
+ $tab->available($available);
+ }
+ else {
+ foreach ($tab->children() as $section) {
+ if ($section->getId() !== 'data') {
+ $section->available($available);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ protected function writePackageXml(DevtoolsProject $project, array $data) {
+ if (!$this->hasBrokenPath) {
+ parent::writePackageXml($project, $data);
+ }
+ }
}
<item name="wcf.acp.devtools.project.pip.entry.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den Eintrag wirklich löschen?]]></item>
<item name="wcf.acp.devtools.project.pip.entry.delete.addDeleteInstruction"><![CDATA[Löschanweisung hinzufügen]]></item>
<item name="wcf.acp.devtools.project.pip.entry.delete.addDeleteInstruction.description"><![CDATA[Der Eintrag wird nicht nur aus der Datenbank gelöscht und und die Installationsanweisung entfernt, sondern es wird auch explizit eine Löschanweisung hinzugefügt.]]></item>
+ <item name="wcf.acp.devtools.project.edit.error.brokenPath"><![CDATA[Es existiert keine <kbd>package.xml</kbd> im angegebenen Pfad. Die Paket-Dateien wurden entweder gelöscht oder verschoben.]]></item>
</category>
<category name="wcf.acp.email">
<item name="wcf.acp.email.smtp.test"><![CDATA[SMTP-Verbindungstest]]></item>