1<?php 2 3 4namespace ComboStrap; 5 6 7class PageTitle extends MetadataText 8{ 9 10 public const PROPERTY_NAME = 'title'; 11 public const TITLE = 'title'; 12 13 public static function createForPage($page): PageTitle 14 { 15 return (new PageTitle()) 16 ->setResource($page); 17 } 18 19 public function getTab(): string 20 { 21 return MetaManagerForm::TAB_PAGE_VALUE; 22 } 23 24 public function getDescription(): string 25 { 26 return "The page title is a description advertised to external application such as search engine and browser."; 27 } 28 29 public function getLabel(): string 30 { 31 return "Title"; 32 } 33 34 static public function getName(): string 35 { 36 return self::PROPERTY_NAME; 37 } 38 39 public function getPersistenceType(): string 40 { 41 return MetadataDokuWikiStore::PERSISTENT_METADATA; 42 } 43 44 public function getMutable(): bool 45 { 46 return true; 47 } 48 49 /** 50 * `title` is created by DokuWiki 51 * in current but not persistent 52 * and hold the heading 1, see {@link p_get_first_heading} 53 */ 54 public function getDefaultValue(): ?string 55 { 56 57 $resource = $this->getResource(); 58 if ($resource instanceof Page) { 59 if ($resource->isRootHomePage() && !empty(Site::getTagLine())) { 60 return Site::getTagLine(); 61 } 62 if (!empty($resource->getH1OrDefault())) { 63 return $resource->getH1OrDefault(); 64 } 65 return $resource->getNameOrDefault(); 66 } 67 return null; 68 69 } 70 71 public function getCanonical(): string 72 { 73 return self::TITLE; 74 } 75 76 77} 78