code/formatters/SimpleWikiFormatter.php
public function analyseSavedContent($wikiPage) {
		$newPages = $this->parseNewPagesFrom($wikiPage->Content);

		foreach ($newPages as $pageTitle) {
			$trimmedTitle = trim($pageTitle);

			// need to trim the title before doing the search
			$page = DataObject::get_one('WikiPage', '"SiteTree"."Title" = \'' . Convert::raw2sql($trimmedTitle) . '\'');

			if (!$page) {
				// it's a new page, so create that
				$page = new WikiPage();
				$page->Title = $trimmedTitle;
				$page->MenuTitle = $trimmedTitle;
				$page->ParentID = $wikiPage->ID;
				$page->write();

				// publish if we're on autopublish
				if (WikiPage::$auto_publish) {
					$page->doPublish();
				}
			}

			$replacement = '<a href="[sitetree_link id=' . $page->ID . ']">' . $pageTitle . '</a>';
			$wikiPage->Content = str_replace('[[' . $pageTitle . ']]', $replacement, $wikiPage->Content);
		}
	}
public function analyseSavedContent($wikiPage) {
		$newPages = $this->parseNewPagesFrom($wikiPage->Content);

		foreach ($newPages as $pageTitle) {
			$trimmedTitle = trim($pageTitle);

			// need to trim the title before doing the search
			$page = DataObject::get_one('WikiPage', '"SiteTree"."Title" = \'' . Convert::raw2sql($trimmedTitle) . '\'');

			if (!$page) {
				// it's a new page, so create that
				$page = new WikiPage();
				$page->Title = $trimmedTitle;
				$page->MenuTitle = $trimmedTitle;
				$page->ParentID = $wikiPage->ID;
				$page->write();

				// publish if we're on autopublish
				if (WikiPage::$auto_publish) {
					$page->doPublish();
				}
			}

			$replacement = '<a href="[sitetree_link id=' . $page->ID . ']">' . $pageTitle . '</a>';
			$wikiPage->Content = str_replace('[[' . $pageTitle . ']]', $replacement, $wikiPage->Content);
		}
	}
public function analyseSavedContent ( $ wikiPage ) { $ newPages = $ this -> parseNewPagesFrom ( $ wikiPage -> Content ) ; foreach ( $ newPages as $ pageTitle ) { $ trimmedTitle = trim ( $ pageTitle ) ; // need to trim the title before doing the search $ page = DataObject :: get_one ( 'WikiPage' , '"SiteTree"."Title" = \'' . Convert :: raw2sql ( $ trimmedTitle ) . '\'' ) ; if ( ! $ page ) { // it's a new page, so create that $ page = new WikiPage ( ) ; $ page -> Title = $ trimmedTitle ; $ page -> MenuTitle = $ trimmedTitle ; $ page -> ParentID = $ wikiPage -> ID ; $ page -> write ( ) ; // publish if we're on autopublish if ( WikiPage :: $ auto_publish ) { $ page -> doPublish ( ) ; } } $ replacement = '<a href="[sitetree_link id=' . $ page -> ID . ']">' . $ pageTitle . '</a>' ; $ wikiPage -> Content = str_replace ( '[[' . $ pageTitle . ']]' , $ replacement , $ wikiPage -> Content ) ; } }
Analyse content just after it's saved. This is useful for creating
new pages etc where referenced by particular formatting
Analyse content just after it s saved . This is useful for creating new pages etc where referenced by particular formatting