미디어위키 문서 정보에 문서ID URL 보여주기

1 개요[ | ]

미디어위키 문서 정보에 문서ID URL 보여주기
  • 미디어위키 1.20부터 사이바의 "문서 정보" 메뉴에서 문서ID(pageid)를 확인할 수 있다.
  • 여기에 미디어위키 문서ID URL을 표시하고 싶다.
  • 미디어위키 폴더 아래 includes/actions/InfoAction.php의 onView() 메소드를 수정하면 된다.
  • 잘못될 수 있으므로 반드시 InfoAction.php의 사본을 만들어두고 해보시라.;;

2 사전 확인[ | ]

  • 먼저 미디어위키 문서ID URL 문서를 참고하여 자신의 위키 사이트에서 문서ID URL 사용이 가능한지 확인[1]
  • 자신의 위키 사이트에서 "문서 정보" 기능이 되는지 확인
https://ko.wikipedia.org/w/index.php?title=태양계&action=info 내용과 유사하게 나오면 OK

3 수정 전[ | ]

		// Get page information
		$pageInfo = $this->pageInfo();
		// Allow extensions to add additional information
		wfRunHooks( 'InfoAction', array( $this->getContext(), &$pageInfo ) );

		// Render page information
		foreach ( $pageInfo as $header => $infoTable ) {
			$content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() ) . "\n";
			$table = "\n";
			foreach ( $infoTable as $infoRow ) {
				$name = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->escaped() : $infoRow[0];
				$value = ( $infoRow[1] instanceof Message ) ? $infoRow[1]->escaped() : $infoRow[1];
				$table = $this->addRow( $table, $name, $value ) . "\n";
			}
			$content = $this->addTable( $content, $table ) . "\n";
		}

4 수정 후[ | ]

		// Get page information
		$pageInfo = $this->pageInfo();
		// Allow extensions to add additional information
		wfRunHooks( 'InfoAction', array( $this->getContext(), &$pageInfo ) );

		// 2013-12-15 added by jmnote
		$url = "http://${_SERVER['SERVER_NAME']}/w/?curid=".$this->page->getID();
		array_unshift($pageInfo['header-basic'], array('문서ID URL', "<a href='$url'>$url</a>"));

		// Render page information
		foreach ( $pageInfo as $header => $infoTable ) {
			$content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() ) . "\n";
			$table = "\n";
			foreach ( $infoTable as $infoRow ) {
				$name = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->escaped() : $infoRow[0];
				$value = ( $infoRow[1] instanceof Message ) ? $infoRow[1]->escaped() : $infoRow[1];
				$table = $this->addRow( $table, $name, $value ) . "\n";
			}
			$content = $this->addTable( $content, $table ) . "\n";
		}
${_SERVER['SERVER_NAME']} 대신 자신의 서버주소(예: jmnote.com)를 그대로 써도 된다.

5 사후 확인[ | ]

  • 자신의 위키 사이트에서 "문서 정보" 메뉴에서 문서ID URL이 나오는지 확인
http://jmnote.com/w/index.php?title=태양계&action=info 처럼 맨 위에 문서ID URL이 나오면 OK

6 같이 보기[ | ]

7 주석[ | ]

  1. 미디어위키 단축 URL 사용이 적용되지 않았다면 안될 가능성이 높음
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}