本文整理汇总了PHP中OldLocalFile::newFromRow方法的典型用法代码示例。如果您正苦于以下问题:PHP OldLocalFile::newFromRow方法的具体用法?PHP OldLocalFile::newFromRow怎么用?PHP OldLocalFile::newFromRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OldLocalFile
的用法示例。
在下文中一共展示了OldLocalFile::newFromRow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newFileFromRow
function newFileFromRow($row)
{
if (isset($row->img_name)) {
return LocalFile::newFromRow($row, $this);
} elseif (isset($row->oi_name)) {
return OldLocalFile::newFromRow($row, $this);
} else {
throw new MWException(__METHOD__ . ': invalid row');
}
}
示例2: getHistory
/** purgeEverything inherited */
function getHistory($limit = null, $start = null, $end = null, $inc = true)
{
$dbr = $this->repo->getSlaveDB();
$tables = array('oldimage');
$fields = OldLocalFile::selectFields();
$conds = $opts = $join_conds = array();
$eq = $inc ? '=' : '';
$conds[] = "oi_name = " . $dbr->addQuotes($this->title->getDBkey());
if ($start) {
$conds[] = "oi_timestamp <{$eq} " . $dbr->addQuotes($dbr->timestamp($start));
}
if ($end) {
$conds[] = "oi_timestamp >{$eq} " . $dbr->addQuotes($dbr->timestamp($end));
}
if ($limit) {
$opts['LIMIT'] = $limit;
}
// Search backwards for time > x queries
$order = !$start && $end !== null ? 'ASC' : 'DESC';
$opts['ORDER BY'] = "oi_timestamp {$order}";
$opts['USE INDEX'] = array('oldimage' => 'oi_name_timestamp');
wfRunHooks('LocalFile::getHistory', array(&$this, &$tables, &$fields, &$conds, &$opts, &$join_conds));
$res = $dbr->select($tables, $fields, $conds, __METHOD__, $opts, $join_conds);
$r = array();
foreach ($res as $row) {
if ($this->repo->oldFileFromRowFactory) {
$r[] = call_user_func($this->repo->oldFileFromRowFactory, $row, $this->repo);
} else {
$r[] = OldLocalFile::newFromRow($row, $this->repo);
}
}
if ($order == 'ASC') {
$r = array_reverse($r);
// make sure it ends up descending
}
return $r;
}
示例3: getHistory
/** purgeEverything inherited */
function getHistory($limit = null, $start = null, $end = null)
{
$dbr = $this->repo->getSlaveDB();
$conds = $opts = array();
$conds[] = "oi_name = " . $dbr->addQuotes($this->title->getDBKey());
if ($start !== null) {
$conds[] = "oi_timestamp <= " . $dbr->addQuotes($dbr->timestamp($start));
}
if ($end !== null) {
$conds[] = "oi_timestamp >= " . $dbr->addQuotes($dbr->timestamp($end));
}
if ($limit) {
$opts['LIMIT'] = $limit;
}
$opts['ORDER BY'] = 'oi_timestamp DESC';
$res = $dbr->select('oldimage', '*', $conds, __METHOD__, $opts);
$r = array();
while ($row = $dbr->fetchObject($res)) {
$r[] = OldLocalFile::newFromRow($row, $this->repo);
}
return $r;
}
示例4: deletePermanently
function deletePermanently($title)
{
global $wgOut;
$ns = $title->getNamespace();
$t = $title->getDBkey();
$id = $title->getArticleID();
$cats = $title->getParentCategories();
$dbw = wfGetDB(DB_MASTER);
$dbw->begin();
####
## First delete entries, which are in direct relation with the page:
####
# delete redirect...
$dbw->delete('redirect', array('rd_from' => $id), __METHOD__);
# delete external link...
$dbw->delete('externallinks', array('el_from' => $id), __METHOD__);
# delete language link...
$dbw->delete('langlinks', array('ll_from' => $id), __METHOD__);
# delete search index...
$dbw->delete('searchindex', array('si_page' => $id), __METHOD__);
# Delete restrictions for the page
$dbw->delete('page_restrictions', array('pr_page' => $id), __METHOD__);
# Delete page Links
$dbw->delete('pagelinks', array('pl_from' => $id), __METHOD__);
# delete category links
$dbw->delete('categorylinks', array('cl_from' => $id), __METHOD__);
# delete template links
$dbw->delete('templatelinks', array('tl_from' => $id), __METHOD__);
# read text entries for all revisions and delete them.
$res = $dbw->select('revision', 'rev_text_id', "rev_page={$id}");
while ($row = $dbw->fetchObject($res)) {
$value = $row->rev_text_id;
$dbw->delete('text', array('old_id' => $value), __METHOD__);
}
# In the table 'revision' : Delete all the revision of the page where 'rev_page' = $id
$dbw->delete('revision', array('rev_page' => $id), __METHOD__);
# delete image links
$dbw->delete('imagelinks', array('il_from' => $id), __METHOD__);
####
## then delete entries which are not in direct relation with the page:
####
# Clean up recentchanges entries...
$dbw->delete('recentchanges', array('rc_namespace' => $ns, 'rc_title' => $t), __METHOD__);
# read text entries for all archived pages and delete them.
$res = $dbw->select('archive', 'ar_text_id', array('ar_namespace' => $ns, 'ar_title' => $t));
while ($row = $dbw->fetchObject($res)) {
$value = $row->ar_text_id;
$dbw->delete('text', array('old_id' => $value), __METHOD__);
}
# Clean archive entries...
$dbw->delete('archive', array('ar_namespace' => $ns, 'ar_title' => $t), __METHOD__);
# Clean up log entries...
$dbw->delete('logging', array('log_namespace' => $ns, 'log_title' => $t), __METHOD__);
# Clean up watchlist...
$dbw->delete('watchlist', array('wl_namespace' => $ns, 'wl_title' => $t), __METHOD__);
# In the table 'page' : Delete the page entry
$dbw->delete('page', array('page_id' => $id), __METHOD__);
####
## If the article belongs to a category, update category counts
####
if (!empty($cats)) {
foreach ($cats as $parentcat => $currentarticle) {
$catname = split(':', $parentcat, 2);
$cat = Category::newFromName($catname[1]);
$cat->refreshCounts();
}
}
####
## If an image is beeing deleted, some extra work needs to be done
####
if ($ns == NS_IMAGE) {
$file = wfFindFile($t);
if ($file) {
# Get all filenames of old versions:
$fields = OldLocalFile::selectFields();
$res = $dbw->select('oldimage', $fields, array('oi_name' => $t));
while ($row = $dbw->fetchObject($res)) {
$oldLocalFile = OldLocalFile::newFromRow($row, $file->repo);
$path = $oldLocalFile->getArchivePath() . '/' . $oldLocalFile->getArchiveName();
try {
# Using the FileStore to delete the file
$transaction = FileStore::deleteFile($path);
$transaction->commit();
} catch (Exception $e) {
$wgOut->addHTML($e->getMessage());
}
}
$path = $file->getPath();
try {
# Using the FileStore to delete the file itself
$transaction = FileStore::deleteFile($path);
$transaction->commit();
} catch (Exception $e) {
$wgOut->addHTML($e->getMessage());
}
}
# clean the filearchive for the given filename:
$fa_archive_name = array();
$res = $dbw->select('filearchive', 'fa_storage_key', array('fa_name' => $t));
while ($row = $dbw->fetchObject($res)) {
//.........这里部分代码省略.........
示例5: purgeOldImagesSQL
function purgeOldImagesSQL($whereSQL)
{
# Purge files of old version of any images uploaded by this user
# lance.gatlin@gmail.com: tested good 16Jul11
// MW is not adding the JOIN properly
// $oldImagesByUser_rows = $this->dbw->select('oldimage', array('oldimage.*'), array('img_user' => $this->user_id),'DatabaseBase::select',array(),array('image'=> array('LEFT JOIN','oi_name=img_name')));
$oldImages_rows = $this->dbw->query("SELECT * FROM {$this->oldimageTable} JOIN {$this->imageTable} ON oi_name=img_name WHERE {$whereSQL}");
if ($oldImages_rows->numRows() == 0) {
return;
}
foreach ($oldImages_rows as $row) {
# Images that are old versions of an existing image use OldLocalFile path => $IP/images/archive
$oldFile = OldLocalFile::newFromRow($row, $this->repo);
# Purge thumbnails and purge cache for pages using this image
$oldFile->purgeEverything();
# Purge thumbnail directories
// TODO: Mediawiki does not purge the directories used to store thumbnails
$path = $oldFile->getPath();
if ($path !== false && file_exists($path)) {
unlink($path);
}
}
# Purge old version of any images created by this user
# lance.gatlin@gmail.com: tested good 9Jul11
$this->dbw->deleteJoin('oldimage', 'image', 'oi_name', 'img_name', array($whereSQL));
}