Manual:Title.php

From mediawiki.org
This page is a translated version of the page Manual:Title.php and the translation is 29% complete.
Outdated translations are marked like this.

Before 1.40:

MediaWiki yazılımının Title sınıfı $3 ve $4 arayüzlerini uygular.

  • Title implements the following interfaces: LinkTarget , PageIdentity , IDBAccessObject
  • Sınıf, bu biçimlerden biriyle başlatılır.
  • Bir kez başlatıldığında, başlık başka biçimlerde alınabilir veya öznitelikleri için sorgulanabilir. Bir kez başlatıldığında, getText(), getDBKey(), getNamespace() vb. gibi statik olmayan diğer erişimci yöntemleri kullanılabilir. Bu işlevlerin çoğu Manual:CoreParserFunctions.php tarafından sihirli kelimeleri oluşturmak için kullanılır.
  • $1 değerinin değişmez bir "value" sınıfı olması amaçlanmıştır, bu nedenle herhangi bir mutasyon işlevi yoktur.[1][2]

Retrieval

Methods for accessing an instance of Title include :

Public methods

Instantiation methods

Title örneğini oluşturmak için statik fabrika yöntemlerinden birini çağırın:

  • Title::newFromDBKey( $key )
  • Title::newFromID( ($id, $flags=0) ). Note that an alternative method, Title::newFromIDs( $ids ), is deprecated in favour of using a PageStore QueryBuilder.
  • Title::newFromText( $text, $defaultNamespace=NS_MAIN )
  • Title::newFromURL( $url ) - Bu istediğiniz işlev değil. Title::newFromText() kullanın.
  • Title::makeTitleSafe( $ns, $title, $fragment= '', $interwiki= '') - Bir ad alanı dizininden ve bir DB anahtarından yeni bir Başlık oluşturun. Hata durumunda null değerini döndürür.
  • Title::newFromRow( $row )
  • Title::newMainPage() - create a new Title for the Main Page.

Örnek

Belirli bir sayfanın zaten mevcut olup olmadığını kontrol etmek ve görmek için:

$titleObject = Title::newFromText( 'Talk:Your desired title here' );
if ( !$titleObject->exists() ) echo "There is no page with that name.";

Bir bağlantıda ne bulacağı gibi metinden yeni bir Başlık oluşturun. Metindeki tüm HTML varlıklarının kodunu çözer. Boşluklar, önekler ve ana ad alanını belirten bir baş harf ':' kabul edilir. Sayfa yoksa, bunun onu oluşturmayacağını unutmayın. Bunun için Manual:Article.php sayfasına bakın.

Relating to page titles

  • getDBKey() - Alt çizgili ana bölümü (yani ad alanı hariç başlık) alın.
  • getText() - Ana bölümün metin biçimini (alt çizgi olmayan boşluklar), yani ad alanı hariç, ancak eğik çizgi ve sonraki her şeyi içeren başlığı alır. {{PAGENAME }} sihirli kelimesine bakın.
  • Prefixed with namespace and interwiki prefixes, if any:
    • getPrefixedDBkey() - Alt çizgili önekli veritabanı anahtarı formunu alın.
    • getPrefixedText() - Boşluk içeren önekli başlığı alın. Bu, genellikle görüntüleme için kullanılan formdur. {{FULLPAGENAME }} sihirli kelimesine bakın.
      • __toString() - return a string representation of the current title.
    • getFullText() - Boşluklarla birlikte önekli başlığı ve herhangi bir parçayı ('#' ile başlayan kısım) alın.
  • getRootText() - get the root page name text without a namespace, i.e. the leftmost part before any slashes.
  • getRootTitle() - get the root page name title, i.e. the leftmost part before any slashes.
  • getBaseText() - Boşlukları alt çizgilere dönüştürmeden temel sayfa adını, yani ad alanı hariç en soldaki kısım ve eğik çizgilerden önce alın. {{BASEPAGENAME }} ve {{BASEPAGENAMEE }} sihirli kelimelerine bakın.
  • getBaseTitle() - get the base page name title, i.e. the part before the subpage name.

Relating to page titles (URL-encoded)

URL-encoded titles, not actual URLs:

  • getPrefixedUrl() - Vikiarası dahil, URL kodlu bir başlık (gerçek bir URL değil) alın. {{FULLPAGENAMEE }} sihirli kelimesine bakın.
  • getPartialURL() - Ana parçanın URL kodlu biçimini alın. {{PAGENAMEE }} sihirli kelimesine bakın.
  • getSubpageUrlForm() - Alt sayfa metninin URL kodlu bir biçimini alın. {{SUBPAGENAMEE }} sihirli kelimesine bakın.

Relating to page URLs

  • getFullURL() - Bu başlığa atıfta bulunan, vikiarası bağlantısı ve parçasıyla gerçek bir URL alın.
  • getFullUrlForRedirect()
  • getLocalURL() - Parça veya sunucu adı olmayan bir URL alın.
  • getLinkURL()
  • getInternalURL()
  • getCanonicalURL() - get the URL for a canonical link, for use in things like IRC and e-mail notifications. Uses $wgCanonicalServer and the GetCanonicalURL hook.
  • getEditURL() - get the edit URL (with action=edit) for this Title

Checking page titles

  • equals() - compare by checking if the namespace prefix, title text and interwiki prefix are the same.
  • isSameLinkAs() - similar to equals(), but additionally compares the fragment part. See also LinkTarget::isSameLinkAs() .

Relating to page title fragments

  • getFragment() - Başlık parçasını (yani # işaretinden sonraki bit) metin biçiminde alın.
  • hasFragment()
  • getFragmentForURL()
  • setFragment()
  • createFragmentTarget() - creates a new Title for a different fragment of the same page.

Relating to namespaces

  • getNamespace() - Ad alanı dizinini alın. {{NAMESPACENUMBER }} bakın.
  • getNamespaceKey() - generate strings used for xml id names in monobook tags.

For other options, see NamespaceInfo instead.

Relating to talk pages

  • getTalkPageIfDefined() - Bu maddenin tartışma sayfasıyla ilişkili bir Title nesnesi alın. $1 ve $2 bakın. See {{TALKPAGENAME }} and {{TALKPAGENAMEE }}. getTalkPage() is deprecated since 1.34 (in favour of getTalkPageIfDefined).
  • isTalkPage() - check current page
  • getTalkNsText() - Tartışma sayfasının ad alanı metnini alın. {{TALKSPACE }} ve {{TALKSPACEE }} sihirli kelimelerine bakın.
  • getSubjectNsText() - Konu sayfasının (tartışma yerine) ad alanı metnini alın. {{SUBJECTSPACE }} ve {{SUBJECTSPACEE }} sihirli kelimelerine bakın.
  • getSubjectPage() - Bu tartışma sayfasının konu sayfasıyla ilişkili bir başlık nesnesi alın. $1 sihirli kelimesine bakın. See also the magic word {{SUBJECTPAGENAME }}.

Relating to categories

  • getParentCategories() - get categories to which the current Title belongs.
  • getParentCategoryTree() - get a tree of parent categories.
  • getCategorySortkey() - returns the raw sort key to be used for categories, with the specified prefix. This will be fed to Collation::getSortKey() to get a binary sortkey that can be used for actual sorting.
  • canUseNoindex() - whether the magic words __INDEX__ and __NOINDEX__ function for this page.

Relating to redirects

  • isRedirect() - check if the article is a redirect page
  • getRedirectsHere() - get all extant redirects to the current Title.
  • isValidRedirectTarget() - check if the current Title is a valid redirect target.
  • isSingleRevRedirect() - locks the page row and check if this page is single revision redirect.

Relating to subpages

  • getSubpage() - get the title for a subpage of the current page.
  • getSubpageText() - En düşük düzeydeki alt sayfa adını, yani herhangi bir bölü çizgisinden sonra en sağdaki kısmı alın. {{SUBPAGENAME }} sihirli kelimesine bakın.
  • hasSubpages() - check if the current page has subpages.
  • getSubpages() - get all subpages of this page.
  • isSubpageOf() - check if the current title is a subpage of another title.
  • See also: getSubpageUrlForm().

Relating to incoming and outgoing links

Handle with care:

  • getLinksTo
  • getTemplateLinksTo()
  • getLinksFrom()
  • getTemplateLinksFrom()
  • getBrokenLinksFrom()

Relating to page language

  • getPageLanguage() - get the language in which the content of this page is written in wikitext. Defaults to content language, but in certain cases it can be e.g. $wgLang (such as special pages, which are in the user language).
  • getPageViewLanguage() - get the language in which the content of this page is written when viewed by user. Defaults to content language, but in certain cases it can be e.g. $wgLang (such as special pages, which are in the user language). Will be deprecated in 1.42 in favour of ParserOutput::getLanguage and see also OutputPage::getContLangForJS .

Relating to page revisions , etc.

  • exists() - check if page exists
  • isNewPage() - check if the current page is new.
  • purgeExpiredRestrictions()
  • estimateRevisionCount() - get the approximate revision count of the current page.
  • getDeletedEditsCount - count archived revisions.
  • hasDeletedEdits() - check if there is a version of the current page in the deletion archive.
  • getEditNotices() - get a list of rendered edit notices for this page.

Relating to page_touched/timestamps :

  • invalidateCache() - updates page_touched for the current page. It is called from LinksUpdate.php .
  • touchLinks() - update page_touched timestamps and send CDN purge messages for pages linking to this title. May be sent to the job queue depending on the number of links. Typically called on create and delete.
  • getTouched() - get the latest touched timestamp

Relating to viewability

  • isAlwaysKnown() - semi-deprecated for public use
  • isKnown() - check if the current Title refers to a page that can (or might) be meaningfully viewed?
  • hasSourceText() - check if the current page has any source text.
  • getDefaultMessageText() - Get the default (plain) message contents for an page that overrides an interface message key.

Link cache, page IDs, etc.

  • getArticleID() - Bu Başlık için madde kimliğini bağlantı önbelleğinden alın ve gerekirse ekleyin. "Dahili" maddeler için, makale mevcutsa "page_id" alanını döndürmelidir, madde takdirde 0 döndürür. Tüm harici makaleler için 0 döndürür. Bir istek sırasında oluşturulan tüm Başlık örneklerinin tüm kimlikleri önbelleğe alınır, böylece çok sayıda dahili bağlantı içeren vikimetin oluşturulurken hızlı bir şekilde aranabilir.
  • resetArticleID() - inject a page ID, reset DB-loaded fields, and clear the link cache for the current Title.
  • clearCaches() - clear link cache as well as Title cache.
  • getLatestRevID() - get the page_latest field.
  • getLength() - get page length.
  • pageCond() - get an associative array for selecting the current Title from the page table.
  • getWikiId()
  • getId() - get the page ID.
  • toPageIdentity() - return the page represented by the current Title as a ProperPageIdentity .
  • toPageRecord() - return the page represented by the current Title as a ProperPageRecord .

Using the Title object

In order to create objects or access data, many methods in other MediaWiki PHP classes depend on the availability of a Title object.

Bir Title nesneniz varsa, aşağıdakileri alabilirsiniz:

  • Article::newFromTitle ( $title, IContextSource $context ) kullanarak Article nesne
  • WikiPage::factory ( Title $title ) kullanarak WikiPage nesne

Bu sınıf, veritabanından çeşitli veri türlerini alabilir; ancak bunu verimsiz yapar. Bunun yerine TitleValue nesnesi kullanmayı düşünün. TitleValue daha hafiftir ve küresel duruma veya veritabanına bağlı değildir.

Ayrıca bakınız

Kaynakça

  1. Değişken, bir const nesnesinin bile bu değişkeni değiştirebileceğini söyleyen normun anahtar kelimesidir. Değişken bir özellik özel veya herkese açık olabilir. Nesne sabit bir bağlamda olsa bile her zaman değiştirilebilir.
  2. Mutatör, bir veya daha fazla nesne özel değişkenini dışarıdan değiştirebilen bir üye işlevinin genel adıdır. Özel olarak ayarlamak işe yaramaz.