Beispiel #1
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $source = $pl->getParameterValue("source");
     $mode = $pl->getParameterValue("mode");
     $site = $runData->getTemp("site");
     $pageId = $pl->getParameterValue("pageId");
     if ($pageId) {
         $runData->setTemp("pageId", $pageId);
         $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
         if ($page == null || $page->getSiteId() != $site->getSiteId()) {
             throw new ProcessException(_("Error selecting the page."));
         }
         $runData->setTemp("page", $page);
     }
     $wt = new WikiTransformation();
     $wt->setPageUnixName($pl->getParameterValue("page_unix_name"));
     /*	if($mode == "append"){
     			// combine current source and submitted source
     			$pageId = $pl->getParameterValue("page_id");
     			$page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
     			$source = $page->getSource()."\n\n[[div id=\"append-preview-div\"]]\n".$source."\n[[/div]]\n";
     		}
     		*/
     /* Get the category and apply the "live template" to the source. */
     $pageUnixName = $pl->getParameterValue("page_unix_name");
     if (strpos($pageUnixName, ":") != false) {
         $tmp0 = explode(':', $pageUnixName);
         $categoryName = $tmp0[0];
     } else {
         $categoryName = "_default";
     }
     $category = DB_CategoryPeer::instance()->selectByName($categoryName, $site->getSiteId());
     /* Look for the template (if any). */
     if (!preg_match(';(:|^)_;', $pageUnixName)) {
         $templatePage = DB_PagePeer::instance()->selectByName($site->getSiteId(), ($categoryName == '_default' ? '' : $categoryName . ':') . '_template');
         if ($templatePage) {
             $source = $wt->assemblyTemplate($source, $templatePage->getSource());
         }
     }
     $result = $wt->processSource($source);
     $body = $result;
     $runData->contextAdd("body", $body);
     $runData->ajaxResponseAdd("title", $pl->getParameterValue("title"));
 }
Beispiel #2
0
 private function assemblySource($source, $templateSource, $page = null)
 {
     $t = new WikiTransformation(false);
     return $t->assemblyTemplate($source, $templateSource, $page);
 }