public function transform($item, $parent, $strategy) { $page = new WordpressPage(); $params = $this->importer->getParams(); $exists = DataObject::get_one('WordpressPage', sprintf('"WordpressID" = %d AND "ParentID" = %d', $item->WordpressID, $parent->ID)); if ($exists) { switch ($strategy) { case ExternalContentTransformer::DS_OVERWRITE: $page = $exists; break; case ExternalContentTransformer::DS_DUPLICATE: break; case ExternalContentTransformer::DS_SKIP: return; } } $page->Title = $item->Title; $page->MenuTitle = $item->Title; $page->Content = $item->Description; $page->Content = HTTP::urlRewriter($page->Content, ' WordpressPageTransformer::transform_url($URL) '); $page->URLSegment = $item->Slug; $page->ParentID = $parent->ID; $page->ProvideComments = $item->AllowComments; $page->WordpressID = $item->WordpressID; $properties = $item->getRemoteProperties(); $page->OriginalData = serialize($properties); $page->OriginalLink = isset($properties['Link']) ? $properties['Link'] : null; $page->write(); if (isset($params['ImportMedia'])) { $this->importMedia($item, $page); } return new TransformResult($page, $item->stageChildren()); }
/** * Turn all relative URLs in the content to absolute URLs */ public static function absoluteURLs($html) { $html = str_replace('$CurrentPageURL', $_SERVER['REQUEST_URI'], $html); return HTTP::urlRewriter($html, function ($url) { //no need to rewrite, if uri has a protocol (determined here by existence of reserved URI character ":") if (preg_match('/^\\w+:/', $url)) { return $url; } return Director::absoluteURL($url, true); }); }
/** * Turn all relative URLs in the content to absolute URLs */ static function absoluteURLs($html) { $html = str_replace('$CurrentPageURL', $_SERVER['REQUEST_URI'], $html); return HTTP::urlRewriter($html, '(substr($URL,0,1) == "/") ? ( Director::protocolAndHost() . $URL ) : ( (ereg("^[A-Za-z]+:", $URL)) ? $URL : Director::absoluteBaseURL() . $URL )'); }