createContributionForm();
if ($editing) {
+ $contribution = new FestivalContribution($obj, $this->language);
// create form
- $description = $obj->get(self::TAG_CONTRIBUTION_DESCRIPTION);
$notes = $obj->get(self::TAG_CONTRIBUTION_NOTES);
$formData = [
- self::FIELD_NAME_NAME => $obj->getAttr(self::ATTR_CONTRIBUTION_NAME),
- self::FIELD_NAME_TITLE => $obj->getAttr(self::ATTR_CONTRIBUTION_TITLE),
- self::FIELD_NAME_CATEGORY => $obj->getAttr(self::ATTR_CONTRIBUTION_CATEGORY),
- self::FIELD_NAME_IMAGE => $obj->getAttr(self::ATTR_CONTRIBUTION_IMAGE),
- self::FIELD_NAME_WEBSITE => $obj->getAttr(self::ATTR_CONTRIBUTION_WEBSITE),
- self::FIELD_NAME_DESCRIPTION => $description ? $description->text() : null,
+ self::FIELD_NAME_NAME => $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_NAME),
+ self::FIELD_NAME_TITLE => $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_TITLE),
+ self::FIELD_NAME_CATEGORY => $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_CATEGORY),
+ self::FIELD_NAME_IMAGE => $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_IMAGE),
+ self::FIELD_NAME_WEBSITE => $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_WEBSITE),
+ self::FIELD_NAME_DESCRIPTION => $contribution->getDescription(),
self::FIELD_NAME_NOTES => $notes ? $notes->text() : null,
];
@@ -738,6 +830,8 @@ protected function contributeView(HyphaRequest $request) {
}
protected function contributeViewrender(HyphaRequest $request, HTMLForm $form, $editing) {
+ $this->html->find('#langList')->append(hypha_indexLanguages($this->pageListNode, $this->language, join('/', $request->getArgs())));
+
// Update the form to include any data
$form->updateDom();
@@ -780,26 +874,26 @@ protected function contributionSaveAction(HyphaRequest $request) {
// get contribution element or create new contribution element
if ($obj->tagName == self::TAG_CONTRIBUTION) {
- $contribution = $obj;
+ $contribution = new FestivalContribution($obj, $this->language);
} else {
- $contribution = $this->xml->createElement(self::TAG_CONTRIBUTION);
- $contribution->generateId();
- $contribution->setAttribute(self::ATTR_CONTRIBUTION_KEY, bin2hex(openssl_random_pseudo_bytes(8)));
+ $node = $this->xml->createElement(self::TAG_CONTRIBUTION);
+ $node->generateId();
+ $node->setAttribute(self::ATTR_CONTRIBUTION_KEY, bin2hex(openssl_random_pseudo_bytes(8)));
if ($obj ->tagName == self::TAG_PARTICIPANT)
- $contribution->setAttribute(self::ATTR_CONTRIBUTION_PARTICIPANT, $obj->getId());
+ $node->setAttribute(self::ATTR_CONTRIBUTION_PARTICIPANT, $obj->getId());
- $this->xml->documentElement->getOrCreate(self::TAG_CONTRIBUTION_CONTAINER)->appendChild($contribution);
+ $this->xml->documentElement->getOrCreate(self::TAG_CONTRIBUTION_CONTAINER)->appendChild($node);
+ $contribution = new FestivalContribution($node, $this->language);
}
// set attributes
- $contribution->setAttribute(self::ATTR_CONTRIBUTION_NAME, $form->dataFor(self::FIELD_NAME_NAME));
- $contribution->setAttribute(self::ATTR_CONTRIBUTION_TITLE, $form->dataFor(self::FIELD_NAME_TITLE));
- $contribution->setAttribute(self::ATTR_CONTRIBUTION_CATEGORY, $form->dataFor(self::FIELD_NAME_CATEGORY));
- $contribution->setAttribute(self::ATTR_CONTRIBUTION_IMAGE, $form->dataFor(self::FIELD_NAME_IMAGE));
- $contribution->setAttribute(self::ATTR_CONTRIBUTION_WEBSITE, $form->dataFor(self::FIELD_NAME_WEBSITE));
+ $contribution->setTranslatedAttribute(self::ATTR_CONTRIBUTION_NAME, $form->dataFor(self::FIELD_NAME_NAME));
+ $contribution->setTranslatedAttribute(self::ATTR_CONTRIBUTION_TITLE, $form->dataFor(self::FIELD_NAME_TITLE));
+ $contribution->setTranslatedAttribute(self::ATTR_CONTRIBUTION_CATEGORY, $form->dataFor(self::FIELD_NAME_CATEGORY));
+ $contribution->setTranslatedAttribute(self::ATTR_CONTRIBUTION_IMAGE, $form->dataFor(self::FIELD_NAME_IMAGE));
+ $contribution->setTranslatedAttribute(self::ATTR_CONTRIBUTION_WEBSITE, $form->dataFor(self::FIELD_NAME_WEBSITE));
- $description = $contribution->getOrCreate(self::TAG_CONTRIBUTION_DESCRIPTION);
- $description->setText($form->dataFor(self::FIELD_NAME_DESCRIPTION, ''));
+ $contribution->setDescription($form->dataFor(self::FIELD_NAME_DESCRIPTION, ''));
$notes = $contribution->getOrCreate(self::TAG_CONTRIBUTION_NOTES);
$notes->setText($form->dataFor(self::FIELD_NAME_NOTES, ''));
@@ -821,7 +915,7 @@ protected function contributionSaveAction(HyphaRequest $request) {
$vars = [
'name' => htmlspecialchars($name),
- 'contribution'=> htmlspecialchars($contribution->getAttribute(self::ATTR_CONTRIBUTION_TITLE) . ' - ' . $contribution->getAttribute(self::ATTR_CONTRIBUTION_NAME)),
+ 'contribution'=> htmlspecialchars($contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_TITLE) . ' - ' . $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_NAME)),
];
if ($editing)
$digest = __('festival-edited-contribution', $vars);
@@ -837,7 +931,7 @@ protected function contributionSaveAction(HyphaRequest $request) {
// Send email
$vars = [
'festival-title' => $this->getConfig(self::CONFIG_ID_TITLE),
- 'title' => $contribution->getAttribute(self::ATTR_CONTRIBUTION_TITLE),
+ 'title' => $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_TITLE),
'editlink' => $edit_url,
];
$this->sendMail($email, 'festival-contribution-added', $vars);
@@ -852,11 +946,23 @@ protected function contributionSaveAction(HyphaRequest $request) {
return ['redirect', $lineup_url];
}
+ protected function aboutView() {
+ $this->html->find('#langList')->append(hypha_indexLanguages($this->pageListNode, $this->language, self::PATH_ABOUT));
+
+ $this->html->find('#pagename')->text($this->getConfig('festival-title'));
+ $content = $this->getConfigElement(self::CONFIG_ID_ABOUT, null, $this->language);
+ if ($content)
+ $this->html->find('#main')->append($content->children());
+ }
protected function lineupView(HyphaRequest $request) {
+ $this->html->find('#langList')->append(hypha_indexLanguages($this->pageListNode, $this->language, self::PATH_LINEUP));
+
$html = '';
- $contributions = $this->xml->documentElement->getOrCreate(self::TAG_CONTRIBUTION_CONTAINER)->children();
- foreach($contributions as $contribution) {
+ $header = $this->getConfigElement(self::CONFIG_ID_LINEUP_HEADER, null, $this->language);
+ if ($header)
+ $html .= '';
+ foreach($this->getContributions() as $contribution) {
$html.= $this->buildContribution($contribution);
$html.= '';
}
@@ -876,14 +982,14 @@ protected function buildContribution($contribution) {
$editurl = $this->constructFullPath($this->pagename.'/' . self::PATH_CONTRIBUTE . '/'.$contribution->getId());
$title = '';
- if ($contribution->getAttribute(self::ATTR_CONTRIBUTION_CATEGORY))
- $title .= $contribution->getAttribute(self::ATTR_CONTRIBUTION_CATEGORY) . ': ';
- if ($contribution->getAttribute(self::ATTR_CONTRIBUTION_NAME))
- $title .= $contribution->getAttribute(self::ATTR_CONTRIBUTION_NAME);
- if ($contribution->getAttribute(self::ATTR_CONTRIBUTION_NAME) && $contribution->getAttribute(self::ATTR_CONTRIBUTION_TITLE))
+ if ($contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_CATEGORY))
+ $title .= $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_CATEGORY) . ': ';
+ if ($contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_NAME))
+ $title .= $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_NAME);
+ if ($contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_NAME) && $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_TITLE))
$title .= ' - ';
- if ($contribution->getAttribute(self::ATTR_CONTRIBUTION_TITLE))
- $title .= $contribution->getAttribute(self::ATTR_CONTRIBUTION_TITLE);
+ if ($contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_TITLE))
+ $title .= $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_TITLE);
$html.= ''.htmlspecialchars($title).'';
if (isUser())
@@ -891,15 +997,15 @@ protected function buildContribution($contribution) {
$html.= '
';
// image and description
- $image_filename = $contribution->getAttribute(self::ATTR_CONTRIBUTION_IMAGE);
+ $image_filename = $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_IMAGE);
if ($image_filename) {
$img_width = 150;
$img_height = 150;
$image = new HyphaImage($image_filename);
$html.= '
';
}
- $description = $contribution->getElementsByTagName(self::TAG_CONTRIBUTION_DESCRIPTION)->Item(0);
- if ($description) $html.= nl2br(htmlspecialchars($description->text()));
+ $description = $contribution->getDescription();
+ if ($description) $html.= nl2br(htmlspecialchars($description));
$days = $this->getConfigElement(self::CONFIG_ID_DAYS, self::CONFIG_TAG_DAYS)->children();
$locations = $this->getConfigElement(self::CONFIG_ID_LOCATIONS, self::CONFIG_TAG_LOCATIONS)->children();
@@ -918,7 +1024,7 @@ protected function buildContribution($contribution) {
}
if ($timesHtml) $html.= ''.htmlspecialchars($day->getAttribute(self::ATTR_DAY_DISPLAY)).'
'.$timesHtml.'
';
}
- $website = htmlspecialchars($contribution->getAttribute(self::ATTR_CONTRIBUTION_WEBSITE));
+ $website = htmlspecialchars($contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_WEBSITE));
if ($website)
$html.= "";
$html.= '';
@@ -927,14 +1033,19 @@ protected function buildContribution($contribution) {
}
protected function timetableView(HyphaRequest $request) {
+ $this->html->find('#langList')->append(hypha_indexLanguages($this->pageListNode, $this->language, self::PATH_TIMETABLE));
+
// Make a list of all days, and per day all
// locations and the begin and end time.
- $contributions = $this->xml->documentElement->getOrCreate(self::TAG_CONTRIBUTION_CONTAINER)->children();
+ $contributions = $this->getContributions();
$days = $this->getConfigElement(self::CONFIG_ID_DAYS, self::CONFIG_TAG_DAYS)->children();
$locations = $this->getConfigElement(self::CONFIG_ID_LOCATIONS, self::CONFIG_TAG_LOCATIONS)->children();
- // iterate over all dates
$html = '';
+ $header = $this->getConfigElement(self::CONFIG_ID_TIMETABLE_HEADER, null, $this->language);
+ if ($header)
+ $html .= '';
+ // iterate over all dates
$d = 0;
foreach($days as $day) {
$daybegin = $day->getAttribute(self::ATTR_DAY_BEGIN);
@@ -980,9 +1091,9 @@ protected function timetableView(HyphaRequest $request) {
$locevents[] = [
$this->timetocols($daybegin, $event->getAttribute(self::ATTR_EVENT_BEGIN)),
$this->timetocols($daybegin, $event->getAttribute(self::ATTR_EVENT_END)),
- $contribution->getAttribute(self::ATTR_CONTRIBUTION_NAME),
+ $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_NAME),
$contribution->getId(),
- $contribution->getAttribute(self::ATTR_CONTRIBUTION_TITLE),
+ $contribution->getTranslatedAttribute(self::ATTR_CONTRIBUTION_TITLE),
];
}
}
@@ -1264,3 +1375,80 @@ protected function constructFullPath($path, $language = null) {
return $rootUrl . $language . $path;
}
}
+
+
+ /**
+ * Helper class to get retrieve (translated) info for
+ * contributions.
+ */
+ class FestivalContribution {
+ private $node;
+ private $language_nodes;
+ private $language;
+
+ public function __construct($node, $language) {
+ $this->node = $node;
+ $this->language = $language;
+ $this->language_nodes = [];
+ foreach ($node->find(festivalpage::TAG_CONTRIBUTION_LANGUAGE) as $node) {
+ if ($node->getAttribute(festivalpage::ATTR_LANGUAGE_ID) == $language)
+ array_unshift($this->language_nodes, $node);
+ else
+ $this->language_nodes[] = $node;
+ }
+ }
+
+ public function getOrCreateLanguage() {
+ if (empty($this->language_nodes) || $this->language_nodes[0]->getAttribute(festivalpage::ATTR_LANGUAGE_ID) != $this->language) {
+ $lang = $this->node->document()->createElement(festivalpage::TAG_CONTRIBUTION_LANGUAGE);
+ $lang->setAttribute(festivalpage::ATTR_LANGUAGE_ID, $this->language);
+ $this->node->appendChild($lang);
+ array_unshift($this->language_nodes, $lang);
+ }
+ return $this->language_nodes[0];
+ }
+
+ public function getTranslatedAttribute($attr) {
+ foreach ($this->language_nodes as $node) {
+ if ($node->hasAttribute($attr))
+ return $node->getAttribute($attr);
+ }
+ return null;
+ }
+
+ public function setTranslatedAttribute($attr, $val) {
+ $lang = $this->getOrCreateLanguage();
+ $lang->setAttribute($attr, $val);
+ }
+
+
+ public function getDescription() {
+ $tag = $this->getTranslated(festivalpage::TAG_CONTRIBUTION_DESCRIPTION);
+ if ($tag === null)
+ return '';
+ return $tag->text();
+ }
+
+ public function setDescription($val) {
+ $lang = $this->getOrCreateLanguage();
+ $description = $lang->getOrCreate(festivalpage::TAG_CONTRIBUTION_DESCRIPTION);
+ $description->setText($val);
+ }
+
+ public function getTranslated($tag) {
+ foreach ($this->language_nodes as $node) {
+ $element = $node->get($tag);
+ if ($element !== null)
+ return $element;
+ }
+ return null;
+ }
+
+
+ /**
+ * Forward any other calls to the underlying node.
+ */
+ public function __call($name, $arguments) {
+ return call_user_func_array([$this->node, $name], $arguments);
+ }
+ }
diff --git a/system/languages/en.php b/system/languages/en.php
index bfc256f2..7a166e56 100644
--- a/system/languages/en.php
+++ b/system/languages/en.php
@@ -288,6 +288,7 @@
"festival-contribution-added-body" => 'Your contribution "[[title]]" has been added and is now shown on the lineup.
To edit your contribution, use this link.
',
// festival - buttons & links
+ "festival-about" => "about",
"festival-modify" => "modify",
"festival-contribute" => "contribute",
"festival-edit-contribution" => "edit contribution",
diff --git a/system/languages/nl.php b/system/languages/nl.php
index 4c3ba3e4..850f4478 100644
--- a/system/languages/nl.php
+++ b/system/languages/nl.php
@@ -255,6 +255,7 @@
"festival-signed-up-for" => " heeft zich ingeschreven voor ",
"festival-failed-to-pay-for" => " kon niet betalen voor ",
"festival-payed-for" => " heeft betaald voor ",
+ "festival-confirmed-for" => " heeft email bevestigd voor ",
// festival - notify & messages
"festival-successful-signup-for" => "Je bent ingeschreven voor ",
@@ -283,6 +284,7 @@
"festival-contribution-added-body" => 'Je bijdrage "[[title]]" is toegevoegd en wordt nu in de lineup weergegeven.
Om je bijdrage te wijzigen, gebruik deze link.
',
// festival - buttons & links
+ "festival-about" => "info",
"festival-modify" => "wijzigen",
"festival-contribute" => "bijdragen",
"festival-edit-contribution" => "wijzig bijdrage",