/** * Hook Callback. Make current language available as page template placeholder and handle * original language copying * * @param $event * @param $args */ function page_template_replacement(&$event, $args) { global $ID; // load orginal content as template? if($this->getConf('copytrans') && $this->helper->istranslatable($ID, false)) { // look for existing translations $translations = $this->helper->getAvailableTranslations($ID); if($translations) { // find original language (might've been provided via parameter or use first translation) $orig = (string) $_REQUEST['fromlang']; if(!$orig) $orig = array_shift(array_keys($translations)); // load file $origfile = $translations[$orig]; $event->data['tpl'] = io_readFile(wikiFN($origfile)); // prefix with warning $warn = io_readFile($this->localFN('totranslate')); if($warn) $warn .= "\n\n"; $event->data['tpl'] = $warn . $event->data['tpl']; // show user a choice of translations if any if(count($translations) > 1) { $links = array(); foreach($translations as $t => $l) { $links[] = '<a href="' . wl($ID, array('do' => 'edit', 'fromlang' => $t)) . '">' . $this->helper->getLocalName($t) . '</a>'; } msg( sprintf( $this->getLang('transloaded'), $this->helper->getLocalName($orig), join(', ', $links) ) ); } } } // apply placeholders $event->data['tpl'] = str_replace('@LANG@', $this->helper->realLC(''), $event->data['tpl']); $event->data['tpl'] = str_replace('@TRANS@', $this->helper->getLangPart($ID), $event->data['tpl']); }