public function testBrokenLinkTracking()
 {
     $sitetree = new SiteTree();
     $editor = new HtmlEditorField('Content');
     $this->assertFalse((bool) $sitetree->HasBrokenLink);
     $editor->setValue('<p><a href="[sitetree_link id=0]">Broken Link</a></p>');
     $editor->saveInto($sitetree);
     $this->assertTrue($sitetree->HasBrokenLink);
     $editor->setValue(sprintf('<p><a href="[sitetree_link id=%d]">Working Link</a></p>', $this->idFromFixture('SiteTree', 'home')));
     $sitetree->HasBrokenLink = false;
     $editor->saveInto($sitetree);
     $this->assertFalse((bool) $sitetree->HasBrokenLink);
 }
예제 #2
0
 public function testSavingLinksWithoutHref()
 {
     $obj = $this->objFromFixture('HtmlEditorFieldTest_Object', 'home');
     $editor = new HtmlEditorField('Content');
     $editor->setValue('<p><a name="example-anchor"></a></p>');
     $editor->saveInto($obj);
     $this->assertEquals('<p><a name="example-anchor"></a></p>', $obj->Content, 'Saving a link without a href attribute works');
 }
 public function buildbrokenlinks($request)
 {
     // Protect against CSRF on destructive action
     if (!SecurityToken::inst()->checkRequest($request)) {
         return $this->httpError(400);
     }
     increase_time_limit_to();
     increase_memory_limit_to();
     if ($this->urlParams['ID']) {
         $newPageSet[] = DataObject::get_by_id("Page", $this->urlParams['ID']);
     } else {
         $pages = DataObject::get("Page");
         foreach ($pages as $page) {
             $newPageSet[] = $page;
         }
         $pages = null;
     }
     $content = new HtmlEditorField('Content');
     $download = new HtmlEditorField('Download');
     foreach ($newPageSet as $i => $page) {
         $page->HasBrokenLink = 0;
         $page->HasBrokenFile = 0;
         $content->setValue($page->Content);
         $content->saveInto($page);
         $download->setValue($page->Download);
         $download->saveInto($page);
         echo "<li>{$page->Title} (link:{$page->HasBrokenLink}, file:{$page->HasBrokenFile})";
         $page->writeWithoutVersion();
         $page->destroy();
         $newPageSet[$i] = null;
     }
 }
예제 #4
0
 function buildbrokenlinks()
 {
     if ($this->urlParams['ID']) {
         $newPageSet[] = DataObject::get_by_id("Page", $this->urlParams['ID']);
     } else {
         $pages = DataObject::get("Page");
         foreach ($pages as $page) {
             $newPageSet[] = $page;
         }
         $pages = null;
     }
     $content = new HtmlEditorField('Content');
     $download = new HtmlEditorField('Download');
     foreach ($newPageSet as $i => $page) {
         $page->HasBrokenLink = 0;
         $page->HasBrokenFile = 0;
         $lastUsage = memory_get_usage() - $lastPoint;
         $lastPoint = memory_get_usage();
         $content->setValue($page->Content);
         $content->saveInto($page);
         $download->setValue($page->Download);
         $download->saveInto($page);
         echo "<li>{$page->Title} (link:{$page->HasBrokenLink}, file:{$page->HasBrokenFile})";
         $page->writeWithoutVersion();
         $page->destroy();
         $newPageSet[$i] = null;
     }
 }