本文整理汇总了PHP中WikiPage::selectFields方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::selectFields方法的具体用法?PHP WikiPage::selectFields怎么用?PHP WikiPage::selectFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiPage
的用法示例。
在下文中一共展示了WikiPage::selectFields方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testStaticFunctions
/**
* Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
*/
function testStaticFunctions()
{
$this->assertEquals(WikiPage::selectFields(), Article::selectFields(), "Article static functions");
$this->assertEquals(true, is_callable("Article::onArticleCreate"), "Article static functions");
$this->assertEquals(true, is_callable("Article::onArticleDelete"), "Article static functions");
$this->assertEquals(true, is_callable("ImagePage::onArticleEdit"), "Article static functions");
$this->assertTrue(is_string(CategoryPage::getAutosummary('', '', 0)), "Article static functions");
}
示例2: testStaticFunctions
/**
* Checks for the existence of the backwards compatibility static functions
* (forwarders to WikiPage class)
*
* @covers Article::selectFields
* @covers Article::onArticleCreate
* @covers Article::onArticleDelete
* @covers Article::onArticleEdit
* @covers Article::getAutosummary
*/
public function testStaticFunctions()
{
$this->hideDeprecated('Article::selectFields');
$this->hideDeprecated('Article::getAutosummary');
$this->hideDeprecated('WikiPage::getAutosummary');
$this->hideDeprecated('CategoryPage::getAutosummary');
// Inherited from Article
$this->assertEquals(WikiPage::selectFields(), Article::selectFields(), "Article static functions");
$this->assertEquals(true, is_callable("Article::onArticleCreate"), "Article static functions");
$this->assertEquals(true, is_callable("Article::onArticleDelete"), "Article static functions");
$this->assertEquals(true, is_callable("ImagePage::onArticleEdit"), "Article static functions");
$this->assertTrue(is_string(CategoryPage::getAutosummary('', '', 0)), "Article static functions");
}
示例3: getLinksFrom
/**
* Get an array of Title objects linked from this Title
* Also stores the IDs in the link cache.
*
* WARNING: do not use this function on arbitrary user-supplied titles!
* On heavily-used templates it will max out the memory.
*
* @param array $options May be FOR UPDATE
* @param string $table Table name
* @param string $prefix Fields prefix
* @return array Array of Title objects linking here
*/
public function getLinksFrom($options = array(), $table = 'pagelinks', $prefix = 'pl')
{
$id = $this->getArticleID();
# If the page doesn't exist; there can't be any link from this page
if (!$id) {
return array();
}
if (count($options) > 0) {
$db = wfGetDB(DB_MASTER);
} else {
$db = wfGetDB(DB_SLAVE);
}
$blNamespace = "{$prefix}_namespace";
$blTitle = "{$prefix}_title";
$res = $db->select(array($table, 'page'), array_merge(array($blNamespace, $blTitle), WikiPage::selectFields()), array("{$prefix}_from" => $id), __METHOD__, $options, array('page' => array('LEFT JOIN', array("page_namespace={$blNamespace}", "page_title={$blTitle}"))));
$retVal = array();
$linkCache = LinkCache::singleton();
foreach ($res as $row) {
if ($row->page_id) {
$titleObj = Title::newFromRow($row);
} else {
$titleObj = Title::makeTitle($row->{$blNamespace}, $row->{$blTitle});
$linkCache->addBadLinkObj($titleObj);
}
$retVal[] = $titleObj;
}
return $retVal;
}
示例4: selectFields
/**
* @return array
*
* @deprecated since 1.24, use WikiPage::selectFields() instead
*/
public static function selectFields()
{
wfDeprecated(__METHOD__, '1.24');
return WikiPage::selectFields();
}
示例5: getLinksFrom
/**
* Get an array of Title objects linked from this Title
* Also stores the IDs in the link cache.
*
* WARNING: do not use this function on arbitrary user-supplied titles!
* On heavily-used templates it will max out the memory.
*
* @param array $options Query option to Database::select()
* @param string $table Table name
* @param string $prefix Fields prefix
* @return array Array of Title objects linking here
*/
public function getLinksFrom($options = [], $table = 'pagelinks', $prefix = 'pl')
{
$id = $this->getArticleID();
# If the page doesn't exist; there can't be any link from this page
if (!$id) {
return [];
}
$db = wfGetDB(DB_REPLICA);
$blNamespace = "{$prefix}_namespace";
$blTitle = "{$prefix}_title";
$res = $db->select([$table, 'page'], array_merge([$blNamespace, $blTitle], WikiPage::selectFields()), ["{$prefix}_from" => $id], __METHOD__, $options, ['page' => ['LEFT JOIN', ["page_namespace={$blNamespace}", "page_title={$blTitle}"]]]);
$retVal = [];
$linkCache = LinkCache::singleton();
foreach ($res as $row) {
if ($row->page_id) {
$titleObj = Title::newFromRow($row);
} else {
$titleObj = Title::makeTitle($row->{$blNamespace}, $row->{$blTitle});
$linkCache->addBadLinkObj($titleObj);
}
$retVal[] = $titleObj;
}
return $retVal;
}
示例6: selectFields
/**
* @return array
*/
public static function selectFields()
{
return WikiPage::selectFields();
}
示例7: pageData
/**
* Fetch a page record with the given conditions
* @param $dbr Database object
* @param $conditions Array
* @return mixed Database result resource, or false on failure
*/
protected function pageData($dbr, $conditions)
{
$row = $dbr->selectRow(array('page', 'flaggedpages', 'flaggedpage_config'), array_merge(WikiPage::selectFields(), FRPageConfig::selectFields(), array('fp_pending_since', 'fp_stable', 'fp_reviewed')), $conditions, __METHOD__, array(), array('flaggedpages' => array('LEFT JOIN', 'fp_page_id = page_id'), 'flaggedpage_config' => array('LEFT JOIN', 'fpc_page_id = page_id')));
return $row;
}
示例8: run
/**
* @param ApiPageSet $resultPageSet
* @return
*/
private function run($resultPageSet = null)
{
$params = $this->extractRequestParams();
$exclude = false;
$this->requireOnlyOneParameter($params, 'coord', 'page');
if (isset($params['coord'])) {
$arr = explode('|', $params['coord']);
if (count($arr) != 2 || !GeoData::validateCoord($arr[0], $arr[1], $params['globe'])) {
$this->dieUsage('Invalid coordinate provided', '_invalid-coord');
}
$lat = $arr[0];
$lon = $arr[1];
} elseif (isset($params['page'])) {
$t = Title::newFromText($params['page']);
if (!$t || !$t->canExist()) {
$this->dieUsage("Invalid page title ``{$params['page']}'' provided", '_invalid-page');
}
if (!$t->exists()) {
$this->dieUsage("Page ``{$params['page']}'' does not exist", '_nonexistent-page');
}
$coord = GeoData::getPageCoordinates($t);
if (!$coord) {
$this->dieUsage('Page coordinates unknown', '_no-coordinates');
}
$lat = $coord->lat;
$lon = $coord->lon;
$exclude = $t->getArticleID();
}
$lat = floatval($lat);
$lon = floatval($lon);
$radius = intval($params['radius']);
$rect = GeoMath::rectAround($lat, $lon, $radius);
$dbr = wfGetDB(DB_SLAVE);
$this->addTables(array('page', 'geo_tags'));
$this->addFields(array('gt_lat', 'gt_lon', 'gt_primary'));
// retrieve some fields only if page set needs them
if (is_null($resultPageSet)) {
$this->addFields(array('page_id', 'page_namespace', 'page_title'));
} else {
$this->addFields(WikiPage::selectFields());
}
foreach ($params['prop'] as $prop) {
if (isset(Coord::$fieldMapping[$prop])) {
$this->addFields(Coord::$fieldMapping[$prop]);
}
}
$this->addWhereFld('gt_globe', $params['globe']);
$this->addWhereFld('gt_lat_int', self::intRange($rect["minLat"], $rect["maxLat"]));
$this->addWhereFld('gt_lon_int', self::intRange($rect["minLon"], $rect["maxLon"]));
$this->addWhereRange('gt_lat', 'newer', $rect["minLat"], $rect["maxLat"], false);
if ($rect["minLon"] > $rect["maxLon"]) {
$this->addWhere("gt_lon < {$rect['maxLon']} OR gt_lon > {$rect['minLon']}");
} else {
$this->addWhereRange('gt_lon', 'newer', $rect["minLon"], $rect["maxLon"], false);
}
$this->addWhereFld('page_namespace', $params['namespace']);
$this->addWhere('gt_page_id = page_id');
if ($exclude) {
$this->addWhere("gt_page_id <> {$exclude}");
}
if (isset($params['maxdim'])) {
$this->addWhere('gt_dim < ' . intval($params['maxdim']));
}
$primary = array_flip($params['primary']);
$this->addWhereIf(array('gt_primary' => 1), isset($primary['yes']) && !isset($primary['no']));
$this->addWhereIf(array('gt_primary' => 0), !isset($primary['yes']) && isset($primary['no']));
$this->addOption('USE INDEX', 'gt_spatial');
$limit = $params['limit'];
$res = $this->select(__METHOD__);
$rows = array();
foreach ($res as $row) {
$row->dist = GeoMath::distance($lat, $lon, $row->gt_lat, $row->gt_lon);
$rows[] = $row;
}
// sort in PHP because sorting via SQL involves a filesort
usort($rows, 'ApiQueryGeoSearch::compareRows');
$result = $this->getResult();
foreach ($rows as $row) {
if (!$limit--) {
break;
}
if (is_null($resultPageSet)) {
$title = Title::newFromRow($row);
$vals = array('pageid' => intval($row->page_id), 'ns' => intval($title->getNamespace()), 'title' => $title->getPrefixedText(), 'lat' => floatval($row->gt_lat), 'lon' => floatval($row->gt_lon), 'dist' => round($row->dist, 1));
if ($row->gt_primary) {
$vals['primary'] = '';
}
foreach ($params['prop'] as $prop) {
if (isset(Coord::$fieldMapping[$prop]) && isset($row->{Coord::$fieldMapping[$prop]})) {
$field = Coord::$fieldMapping[$prop];
$vals[$prop] = $row->{$field};
}
}
$fit = $result->addValue(array('query', $this->getModuleName()), null, $vals);
if (!$fit) {
break;
//.........这里部分代码省略.........