本文整理汇总了PHP中Wikia::setProps方法的典型用法代码示例。如果您正苦于以下问题:PHP Wikia::setProps方法的具体用法?PHP Wikia::setProps怎么用?PHP Wikia::setProps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikia
的用法示例。
在下文中一共展示了Wikia::setProps方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: classifyTemplate
/**
* Performs all actions required to log all information required to have a given template
* classified and have them stored in an accessible way.
* @param string $type A type that you want to classify the template as.
* @param bool $value Value of the classification. If false, the type will be set to unclassified.
* @param int $actor Specifies if the recognition was made by a machine or a human
* @return bool
* @throws MWException
*/
public function classifyTemplate($type, $value, $actor = self::CLASSIFICATION_ACTOR_HUMAN)
{
/**
* Check if the fetched $type is valid
* and if the user is permitted to perform templatedraft related actions.
*/
$prop = self::getClassificationProp($type);
if (!$prop || !$this->title->userCan('templatedraft')) {
return false;
}
/**
* SET THE PRIMARY PAGE PROPERTY
*
* If the $value equals false it means somebody has just made a negative recognition
* (e.g. the template is NOT an infobox). In this case, we set the primary property to
* unclassified to mark that the template has been reviewed, but we do not have a definite
* information on its type.
*/
if (!$value) {
$type = self::TEMPLATE_UNCLASSIFIED;
}
Wikia::setProps($this->title->getArticleID(), [self::TEMPLATE_CLASSIFICATION_MAIN_PROP => $type]);
/**
* SET THE SECONDARY PAGE PROPERTY
*
* This property is used to log more detailed information on the performed action.
*/
$data = ['value' => (bool) $value, 'actor' => $actor, 'actor-id' => $this->wg->User->getId(), 'timestamp' => wfTimestamp()];
Wikia::setProps($this->title->getArticleID(), [$prop => json_encode($data)]);
/**
* Since Wikia::setProps fails silently we can return true at this point.
*/
return true;
}
示例2: insertImage
//.........这里部分代码省略.........
// Test if this violates the size requirements we've been given
if ($msg = $this->invalidSize($file)) {
header('X-screen-type: error');
return $msg;
}
$ns_img = $wgContLang->getFormattedNsText(NS_IMAGE);
if (-2 == $gallery && !$ck) {
// this went in from the single placeholder...
$name = $title->getText();
$size = $wgRequest->getVal('size');
$width = $wgRequest->getVal('width');
$layout = $wgRequest->getVal('layout');
// clear the old caption for upload
$caption = $wgRequest->getVal('caption');
$slider = $wgRequest->getVal('slider');
$title_obj = Title::newFromText($title_main, $ns);
$article_obj = new Article($title_obj);
$text = $article_obj->getContent();
wfRunHooks('WikiaMiniUpload::fetchTextForImagePlaceholder', array(&$title_obj, &$text));
$box = $wgRequest->getVal('box', '');
$placeholder = MediaPlaceholderMatch($text, $box);
$success = false;
if ($placeholder) {
$our_gallery = $placeholder[0];
$gallery_split = explode(':', $our_gallery);
$thumb = false;
$tag = $gallery_split[0] . ":" . $name;
if ($size != 'full') {
$tag .= '|thumb';
$thumb = true;
}
if (isset($width)) {
$tag .= '|' . $width;
}
$tag .= '|' . $layout;
if ($link != '') {
$tag .= '|link=' . $link;
}
if ($caption != '') {
$tag .= '|' . $caption;
}
$tag .= "]]";
$text = substr_replace($text, $tag, $placeholder[1], strlen($our_gallery));
// return the proper embed code with all fancies around it
$embed_code = $this->generateImage($file, $name, $title_obj, $thumb, (int) str_replace('px', '', $width), $layout, $caption);
$message = wfMsg('wmu-success');
Wikia::setVar('EditFromViewMode', true);
$summary = wfMsg('wmu-added-from-plc');
$success = $article_obj->doEdit($text, $summary);
}
if ($success) {
header('X-screen-type: summary');
} else {
// failure signal opens js alert (BugId:4935)
header('X-screen-type: error');
return;
}
} else {
header('X-screen-type: summary');
$size = $wgRequest->getVal('size');
$width = $wgRequest->getVal('width');
$layout = $wgRequest->getVal('layout');
$caption = $wgRequest->getVal('caption');
$slider = $wgRequest->getVal('slider');
$tag = '[[' . $ns_img . ':' . $title->getDBkey();
if ($size != 'full' && ($file->getMediaType() == 'BITMAP' || $file->getMediaType() == 'DRAWING')) {
$tag .= '|thumb';
if ($layout != 'right') {
$tag .= '|' . $layout;
}
if ($slider == 'true') {
$tag .= '|' . $width;
}
}
if ($link != '' && $size == 'full') {
$tag .= '|link=' . $link;
}
if ($caption != '') {
if ($size == 'full') {
$tag .= '|frame';
if ($layout != 'right') {
$tag .= '|' . $layout;
}
}
$tag .= '|' . $caption . ']]';
} else {
if ($size == 'full') {
$tag .= '|' . $layout;
}
$tag .= ']]';
}
}
$message = wfMsg('wmu-success');
if ($wgRequest->getVal('update_caption') == 'on') {
Wikia::setProps($title->getArticleID(), array('default_caption' => $caption));
}
$tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
$tmpl->set_vars(array('tag' => $tag, 'filename' => $ns_img . ':' . $title->getDBkey(), 'message' => $message, 'code' => isset($embed_code) ? $embed_code : ''));
return $tmpl->render('summary');
}
示例3: executeUpload
/**
* This method hacks the normal nirvana dispatcher chain because of AIM and application/json mimetype incompatibility
* Talk to Hyun or Inez
*/
public function executeUpload($params) {
wfProfileIn(__METHOD__);
global $wgRequest, $wgUser;
if(!$wgUser->isLoggedIn()) {
echo 'Not logged in';
exit();
}
$this->watchthis = $wgRequest->getBool('wpWatchthis') && $wgUser->isLoggedIn();
$this->license = $wgRequest->getText('wpLicense');
$this->copyrightstatus = $wgRequest->getText('wpUploadCopyStatus');
$this->copyrightsource = $wgRequest->getText('wpUploadSource');
$this->ignorewarning = $wgRequest->getCheck('wpIgnoreWarning');
$this->overwritefile = $wgRequest->getCheck('wpDestFileWarningAck');
$this->defaultcaption = $wgRequest->getText('wpUploadDescription');
$details = null;
$up = new UploadFromFile();
$up->initializeFromRequest($wgRequest);
$permErrors = $up->verifyPermissions($wgUser);
if ( $permErrors !== true ) {
$this->status = self::UPLOAD_PERMISSION_ERROR;
$this->statusMessage = $this->uploadMessage( $this->status, null );
} else if (empty($this->wg->EnableUploads)) {
// BugId:6122
$this->statusMessage = wfMsg('uploaddisabled');
} else {
$details = $up->verifyUpload();
$this->status = (is_array($details) ? $details['status'] : UploadBase::UPLOAD_VERIFICATION_ERROR);
$this->statusMessage = '';
if ($this->status > 0) {
$this->statusMessage = $this->uploadMessage($this->status, $details);
} else {
$warnings = array();
if(!$this->ignorewarning) {
$warnings = $up->checkWarnings();
// BugId:3325 - add handling for "Overwrite File" checkbox
if ($this->overwritefile && !empty($warnings['exists'])) {
unset($warnings['exists']);
}
if(!empty($warnings)) {
$this->status = self::UPLOAD_WARNING;
$this->statusMessage .= $this->uploadWarning($warnings);
}
}
if(empty($warnings)) {
$pageText = SpecialUpload::getInitialPageText( $this->defaultcaption, $this->license,
$this->copyrightstatus, $this->copyrightsource );
$status = $up->performUpload( $this->defaultcaption, $pageText, $this->watchthis, $wgUser );
if ($status->isGood()) {
$aPageProps = array ( 'default_caption' => $this->defaultcaption );
Wikia::setProps( $up->getTitle()->getArticleID(), $aPageProps );
} else {
$this->statusMessage .= "something is wrong with upload";
}
}
}
}
echo json_encode($this->getResponse()->getData());
header('content-type: text/plain; charset=utf-8');
wfProfileOut(__METHOD__);
exit(); //end hack
}