当前位置: 首页>>代码示例>>PHP>>正文


PHP Job::batchInsert方法代码示例

本文整理汇总了PHP中Job::batchInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP Job::batchInsert方法的具体用法?PHP Job::batchInsert怎么用?PHP Job::batchInsert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Job的用法示例。


在下文中一共展示了Job::batchInsert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insertJobs

 function insertJobs(ResultWrapper $res)
 {
     $numRows = $res->numRows();
     $numBatches = ceil($numRows / $this->mRowsPerJob);
     $realBatchSize = $numRows / $numBatches;
     $boundaries = array();
     $start = false;
     $jobs = array();
     do {
         for ($i = 0; $i < $realBatchSize - 1; $i++) {
             $row = $res->fetchRow();
             if ($row) {
                 $id = $row[0];
             } else {
                 $id = false;
                 break;
             }
         }
         if ($id !== false) {
             // One less on the end to avoid duplicating the boundary
             $job = new HTMLCacheUpdateJob($this->mTitle, $this->mTable, $start, $id - 1);
         } else {
             $job = new HTMLCacheUpdateJob($this->mTitle, $this->mTable, $start, false);
         }
         $jobs[] = $job;
         $start = $id;
     } while ($start);
     Job::batchInsert($jobs);
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:29,代码来源:HTMLCacheUpdate.php

示例2: addPage

 /**
  *
  * Add/update a page to wiki
  * @param string $pagename
  * @param string $text
  * @param boolean $hasSemanticInternal whether this text contains semanticInternal Object.
  * SemanticInternal Object needs some special handling. First there is a bug in current
  * SemanticInternal Object implemenattion: the semantic internal properties can not be
  * saved in the very first time. Second, if the semantic internal object saving is not from
  * a special page action, but a regular page saving action, the semantic internal object
  * is confused about the "CURRENT" page. So asynchronous saving through a task is needed.
  *
  * @param $summary
  */
 public static function addPage($pagename, $text, $force = true, $astask = false, $hasSemanticInternal = false, $summary = "Auto generation")
 {
     global $wgUser;
     $title = str_replace(' ', '_', $pagename);
     $t = Title::makeTitleSafe(NS_MAIN, $title);
     $article = new Article($t);
     if ($article->exists() && !$force) {
         return false;
     }
     if (!$astask) {
         $e = $article->exists();
         //do adding inline
         $article->doEdit($text, $summary);
         if ($hasSemanticInternal && !$e) {
             //one more time
             $article->doEdit($text, $summary);
         }
         return true;
     } else {
         //add article asynchronously.
         $jobs = array();
         $job_params = array();
         $job_params['user_id'] = $wgUser->getId();
         $job_params['edit_summary'] = $summary;
         $job_params['text'] = $text;
         $jobs[] = new DTImportJob($t, $job_params);
         if ($hasSemanticInternal && !$article->exists()) {
             $jobs[] = new DTImportJob($t, $job_params);
         }
         Job::batchInsert($jobs);
     }
 }
开发者ID:kghbln,项目名称:semanticaccesscontrol,代码行数:46,代码来源:MWUtil.php

示例3: insertJobs

 protected function insertJobs()
 {
     $batches = $this->mCache->partition($this->mTable, $this->mRowsPerJob);
     if (!$batches) {
         return;
     }
     foreach ($batches as $batch) {
         $params = array('table' => $this->mTable, 'start' => $batch[0], 'end' => $batch[1]);
         $jobs[] = new HTMLCacheUpdateJob($this->mTitle, $params);
     }
     Job::batchInsert($jobs);
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:12,代码来源:HTMLCacheUpdate.php

示例4: insertJobs

 protected function insertJobs(ResultWrapper $res)
 {
     $numRows = $res->numRows();
     if (!$numRows) {
         return;
         // sanity check
     }
     $numBatches = ceil($numRows / $this->mRowsPerJob);
     $realBatchSize = ceil($numRows / $numBatches);
     $jobs = array();
     do {
         $first = $last = false;
         // first/last page_id of this batch
         # Get $realBatchSize items (or less if not enough)...
         for ($i = 0; $i < $realBatchSize; $i++) {
             $row = $res->fetchRow();
             # Is there another row?
             if ($row) {
                 $id = $row[0];
                 $last = $id;
                 // $id is the last page_id of this batch
                 if ($first === false) {
                     $first = $id;
                 }
                 // set first page_id of this batch
                 # Out of rows?
             } else {
                 $id = false;
                 break;
             }
         }
         # Insert batch into the queue if there is anything there
         if ($first) {
             $params = array('table' => $this->mTable, 'start' => $first, 'end' => $last);
             $jobs[] = new FRExtraCacheUpdateJob($this->mTitle, $params);
         }
         $start = $id;
         // Where the last ID left off
     } while ($start);
     Job::batchInsert($jobs);
 }
开发者ID:crippsy14,项目名称:orange-smorange,代码行数:41,代码来源:FRExtraCacheUpdate.php

示例5: modifyPages

 function modifyPages($source, $editSummary, $forPagesThatExist)
 {
     $text = "";
     $xml_parser = new DTXMLParser($source);
     $xml_parser->doParse();
     $jobs = array();
     $job_params = array();
     global $wgUser;
     $job_params['user_id'] = $wgUser->getId();
     $job_params['edit_summary'] = $editSummary;
     $job_params['for_pages_that_exist'] = $forPagesThatExist;
     foreach ($xml_parser->mPages as $page) {
         $title = Title::newFromText($page->getName());
         $job_params['text'] = $page->createText();
         $jobs[] = new DTImportJob($title, $job_params);
     }
     Job::batchInsert($jobs);
     global $wgLang;
     $text .= wfMsgExt('dt_import_success', array('parse'), $wgLang->formatNum(count($jobs)), 'XML');
     return $text;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:21,代码来源:DT_ImportXML.php

示例6: fixRedirects

 /** 
  * Insert jobs into the job queue to fix redirects to the given title
  * @param string $type The reason for the fix, see message double-redirect-fixed-<reason>
  * @param Title $redirTitle The title which has changed, redirects pointing to this title are fixed
  */
 public static function fixRedirects($reason, $redirTitle, $destTitle = false)
 {
     # Need to use the master to get the redirect table updated in the same transaction
     $dbw = wfGetDB(DB_MASTER);
     $res = $dbw->select(array('redirect', 'page'), array('page_namespace', 'page_title'), array('page_id = rd_from', 'rd_namespace' => $redirTitle->getNamespace(), 'rd_title' => $redirTitle->getDBkey()), __METHOD__);
     if (!$res->numRows()) {
         return;
     }
     $jobs = array();
     foreach ($res as $row) {
         $title = Title::makeTitle($row->page_namespace, $row->page_title);
         if (!$title) {
             continue;
         }
         $jobs[] = new self($title, array('reason' => $reason, 'redirTitle' => $redirTitle->getPrefixedDBkey()));
         # Avoid excessive memory usage
         if (count($jobs) > 10000) {
             Job::batchInsert($jobs);
             $jobs = array();
         }
     }
     Job::batchInsert($jobs);
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:28,代码来源:DoubleRedirectJob.php

示例7: insertJobs

 function insertJobs(ResultWrapper $res)
 {
     $numRows = $res->numRows();
     $numBatches = ceil($numRows / $this->mRowsPerJob);
     $realBatchSize = $numRows / $numBatches;
     $start = false;
     $jobs = array();
     do {
         for ($i = 0; $i < $realBatchSize - 1; $i++) {
             $row = $res->fetchRow();
             if ($row) {
                 $id = $row[0];
             } else {
                 $id = false;
                 break;
             }
         }
         $params = array('table' => $this->mTable, 'start' => $start, 'end' => $id !== false ? $id - 1 : false);
         $jobs[] = new HTMLCacheUpdateJob($this->mTitle, $params);
         $start = $id;
     } while ($start);
     Job::batchInsert($jobs);
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:23,代码来源:HTMLCacheUpdate.php

示例8: modifyPages

 function modifyPages($source, $editSummary, $forPagesThatExist)
 {
     $text = "";
     $xml_parser = new DTXMLParser($source);
     $xml_parser->doParse();
     $jobs = array();
     $job_params = array();
     $job_params['user_id'] = $this->getUser()->getId();
     $job_params['edit_summary'] = $editSummary;
     $job_params['for_pages_that_exist'] = $forPagesThatExist;
     foreach ($xml_parser->mPages as $page) {
         $title = Title::newFromText($page->getName());
         $job_params['text'] = $page->createText();
         $jobs[] = new DTImportJob($title, $job_params);
     }
     // MW 1.21+
     if (class_exists('JobQueueGroup')) {
         JobQueueGroup::singleton()->push($jobs);
     } else {
         Job::batchInsert($jobs);
     }
     $text .= $this->msg('dt_import_success')->numParams(count($jobs))->params('XML')->parseAsBlock();
     return $text;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:24,代码来源:DT_ImportXML.php

示例9: createLinkedPage

 /**
  * Automatically creates a page that's red-linked from the page being
  * viewed, if there's a property pointing from anywhere to that page
  * that's defined with the 'Creates pages with form' special property
  */
 static function createLinkedPage($title, $incoming_properties)
 {
     // if we're in a 'special' page, just exit - this is to prevent
     // constant additions being made from the 'Special:RecentChanges'
     // page, which shows pages that were previously deleted as red
     // links, even if they've since been recreated. The same might
     // hold true for other special pages.
     global $wgTitle;
     if (empty($wgTitle)) {
         return false;
     }
     if ($wgTitle->getNamespace() == NS_SPECIAL) {
         return false;
     }
     foreach ($incoming_properties as $property_name) {
         $auto_create_forms = self::getFormsThatPagePointsTo($property_name, SMW_NS_PROPERTY, self::AUTO_CREATE_FORM);
         if (count($auto_create_forms) > 0) {
             global $sfgFormPrinter;
             $form_name = $auto_create_forms[0];
             $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
             $form_definition = SFUtils::getPageText($form_title);
             $preloadContent = null;
             // allow extensions to set/change the preload text
             wfRunHooks('sfEditFormPreloadText', array(&$preloadContent, $title, $form_title));
             list($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) = $sfgFormPrinter->formHTML($form_definition, false, false, null, $preloadContent, 'Some very long page name that will hopefully never get created ABCDEF123', null);
             $params = array();
             // Get user "responsible" for all auto-generated
             // pages from red links.
             $userID = 1;
             global $sfgAutoCreateUser;
             if (!is_null($sfgAutoCreateUser)) {
                 $user = User::newFromName($sfgAutoCreateUser);
                 if (!is_null($user)) {
                     $userID = $user->getId();
                 }
             }
             $params['user_id'] = $userID;
             $params['page_text'] = $data_text;
             $job = new SFCreatePageJob($title, $params);
             Job::batchInsert(array($job));
             return true;
         }
     }
     return false;
 }
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:50,代码来源:SF_FormLinker.php

示例10: generatePages


//.........这里部分代码省略.........
             // Get property for use in either #set_internal
             // or #subobject, defined by either SIO's or
             // SMW's Page Schemas portion. We don't need
             // to record which one it came from, because
             // SF's code to generate the template runs its
             // own, similar check.
             // @TODO - $internalObjProperty should probably
             // have a more generic name.
             if (class_exists('SIOPageSchemas')) {
                 $internalObjProperty = SIOPageSchemas::getInternalObjectPropertyName($psTemplate);
             } elseif (method_exists('SMWPageSchemas', 'getConnectingPropertyName')) {
                 $internalObjProperty = SMWPageSchemas::getConnectingPropertyName($psTemplate);
             } else {
                 $internalObjProperty = null;
             }
             // TODO - actually, the category-setting should be
             // smarter than this: if there's more than one
             // template in the schema, it should probably be only
             // the first non-multiple template that includes the
             // category tag.
             if ($psTemplate->isMultiple()) {
                 $categoryName = null;
             } else {
                 if ($isCategoryNameSet == false) {
                     $categoryName = $pageSchemaObj->getCategoryName();
                     $isCategoryNameSet = true;
                 } else {
                     $categoryName = null;
                 }
             }
             if (method_exists($psTemplate, 'getFormat')) {
                 $templateFormat = $psTemplate->getFormat();
             } else {
                 $templateFormat = null;
             }
             $sfTemplate = new SFTemplate($templateName, $template_fields);
             $sfTemplate->setConnectingProperty($internalObjProperty);
             $sfTemplate->setCategoryName($categoryName);
             $sfTemplate->setFormat($templateFormat);
             // Set Cargo table, if one was set in the schema.
             $cargoArray = $psTemplate->getObject('cargo_TemplateDetails');
             if (!is_null($cargoArray)) {
                 $sfTemplate->mCargoTable = PageSchemas::getValueFromObject($cargoArray, 'Table');
             }
             $templateText = $sfTemplate->createText();
             if (in_array($fullTemplateName, $selectedPages)) {
                 $params = array();
                 $params['user_id'] = $wgUser->getId();
                 $params['page_text'] = $templateText;
                 $jobs[] = new PSCreatePageJob($templateTitle, $params);
                 if (strpos($templateText, '{{!}}') > 0) {
                     $templateHackUsed = true;
                 }
             }
             $templateValues = self::getTemplateValues($psTemplate);
             if (array_key_exists('Label', $templateValues)) {
                 $templateLabel = $templateValues['Label'];
             } else {
                 $templateLabel = null;
             }
             $form_fields = self::getFormFieldInfo($psTemplate, $template_fields);
             // Create template info for form, for use in generating
             // the form (if it will be generated).
             $form_template = SFTemplateInForm::create($templateName, $templateLabel, $psTemplate->isMultiple(), null, $form_fields);
             $form_items[] = array('type' => 'template', 'name' => $form_template->getTemplateName(), 'item' => $form_template);
         } elseif ($psFormItem['type'] == 'Section') {
             $psPageSection = $psFormItem['item'];
             $form_section = self::getPageSection($psPageSection);
             $form_section->setSectionLevel($psPageSection->getSectionLevel());
             $form_items[] = array('type' => 'section', 'name' => $form_section->getSectionName(), 'item' => $form_section);
         }
     }
     // Create the "!" hack template, if it's necessary
     if ($templateHackUsed) {
         $templateTitle = Title::makeTitleSafe(NS_TEMPLATE, '!');
         if (!$templateTitle->exists()) {
             $params = array();
             $params['user_id'] = $wgUser->getId();
             $params['page_text'] = '|';
             $jobs[] = new PSCreatePageJob($templateTitle, $params);
         }
     }
     if (class_exists('JobQueueGroup')) {
         JobQueueGroup::singleton()->push($jobs);
     } else {
         // MW <= 1.20
         Job::batchInsert($jobs);
     }
     // Create form, if it's specified.
     $formName = self::getFormName($pageSchemaObj);
     $categoryName = $pageSchemaObj->getCategoryName();
     if (!empty($formName)) {
         $formInfo = self::getMainFormInfo($pageSchemaObj);
         $formTitle = Title::makeTitleSafe(SF_NS_FORM, $formName);
         $fullFormName = PageSchemas::titleString($formTitle);
         if (in_array($fullFormName, $selectedPages)) {
             self::generateForm($formName, $formTitle, $form_items, $formInfo, $categoryName);
         }
     }
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:101,代码来源:SF_PageSchemas.php

示例11: doSpecialReplaceText

	function doSpecialReplaceText() {
		global $wgOut, $wgRequest, $wgLang;
		$linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;

		$this->target = $wgRequest->getText( 'target' );
		$this->replacement = $wgRequest->getText( 'replacement' );
		$this->use_regex = $wgRequest->getBool( 'use_regex' );
		$this->category = $wgRequest->getText( 'category' );
		$this->prefix = $wgRequest->getText( 'prefix' );
		$this->edit_pages = $wgRequest->getBool( 'edit_pages' );
		$this->move_pages = $wgRequest->getBool( 'move_pages' );
		$this->selected_namespaces = self::getSelectedNamespaces();

		if ( $wgRequest->getCheck( 'continue' ) ) {
			if ( $this->target === '' ) {
				$this->showForm( 'replacetext_givetarget' );
				return;
			}
		}

		if ( $wgRequest->getCheck( 'replace' ) ) {
			$replacement_params = array();
			$replacement_params['user_id'] = $this->user->getId();
			$replacement_params['target_str'] = $this->target;
			$replacement_params['replacement_str'] = $this->replacement;
			$replacement_params['use_regex'] = $this->use_regex;
			$replacement_params['edit_summary'] = wfMsgForContent( 'replacetext_editsummary', $this->target, $this->replacement );
			$replacement_params['create_redirect'] = false;
			$replacement_params['watch_page'] = false;
			foreach ( $wgRequest->getValues() as $key => $value ) {
				if ( $key == 'create-redirect' && $value == '1' ) {
					$replacement_params['create_redirect'] = true;
				} elseif ( $key == 'watch-pages' && $value == '1' ) {
					$replacement_params['watch_page'] = true;
				}
			}
			$jobs = array();
			foreach ( $wgRequest->getValues() as $key => $value ) {
				if ( $value == '1' && $key !== 'replace' ) {
					if ( strpos( $key, 'move-' ) !== false ) {
						$title = Title::newFromID( substr( $key, 5 ) );
						$replacement_params['move_page'] = true;
					} else {
						$title = Title::newFromID( $key );
					}
					if ( $title !== null )
						$jobs[] = new ReplaceTextJob( $title, $replacement_params );
				}
			}
			Job::batchInsert( $jobs );

			$count = $wgLang->formatNum( count( $jobs ) );
			$wgOut->addWikiMsg( 'replacetext_success', "<tt><nowiki>{$this->target}</nowiki></tt>", "<tt><nowiki>{$this->replacement}</nowiki></tt>", $count );

			// Link back
			$wgOut->addHTML( $linker->link( $this->getTitle(), wfMsgHtml( 'replacetext_return' ) ) );
			return;
		} elseif ( $wgRequest->getCheck( 'target' ) ) { // very long elseif, look for "end elseif"
			// first, check that at least one namespace has been
			// picked, and that either editing or moving pages
			// has been selected
			if ( count( $this->selected_namespaces ) == 0 ) {
				$this->showForm( 'replacetext_nonamespace' );
				return;
			}
			if ( ! $this->edit_pages && ! $this->move_pages ) {
				$this->showForm( 'replacetext_editormove' );
				return;
			}

			$jobs = array();
			$titles_for_edit = array();
			$titles_for_move = array();
			$unmoveable_titles = array();

			// if user is replacing text within pages...
			if ( $this->edit_pages ) {
				$res = $this->doSearchQuery( $this->target, $this->selected_namespaces, $this->category, $this->prefix , $this->use_regex );
				foreach ( $res as $row ) {
					$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
					$context = $this->extractContext( $row->old_text, $this->target, $this->use_regex );
					$titles_for_edit[] = array( $title, $context );
				}
			}
			if ( $this->move_pages ) {
				$res = $this->getMatchingTitles( $this->target, $this->selected_namespaces, $this->category, $this->prefix, $this->use_regex );
				foreach ( $res as $row ) {
					$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
					// see if this move can happen
					$cur_page_name = str_replace( '_', ' ', $row->page_title );
					if ( $this->use_regex ) {
						$new_page_name = preg_replace( "/".$this->target."/U", $this->replacement, $cur_page_name );
					} else {
						$new_page_name = str_replace( $this->target, $this->replacement, $cur_page_name );
					}
					$new_title = Title::makeTitleSafe( $row->page_namespace, $new_page_name );
					$err = $title->isValidMoveOperation( $new_title );
					if ( $title->userCan( 'move' ) && !is_array( $err ) ) {
						$titles_for_move[] = $title;
					} else {
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:SpecialReplaceText.php

示例12: generatePages

 /**
  * Generate pages (form and templates) specified in the list.
  */
 public static function generatePages($pageSchemaObj, $selectedPages)
 {
     global $wgUser;
     $psTemplates = $pageSchemaObj->getTemplates();
     $form_templates = array();
     $jobs = array();
     foreach ($psTemplates as $psTemplate) {
         // Generate every specified template
         $templateName = $psTemplate->getName();
         $templateTitle = Title::makeTitleSafe(NS_TEMPLATE, $templateName);
         $fullTemplateName = PageSchemas::titleString($templateTitle);
         $template_fields = self::getFieldsFromTemplateSchema($psTemplate);
         if (class_exists('SIOPageSchemas')) {
             $internalObjProperty = SIOPageSchemas::getInternalObjectPropertyName($psTemplate);
         } else {
             $internalObjProperty = null;
         }
         // TODO - actually, the category-setting should be
         // smarter than this: if there's more than one
         // template in the schema, it should probably be only
         // the first non-multiple template that includes the
         // category tag.
         if ($psTemplate->isMultiple()) {
             $categoryName = null;
         } else {
             $categoryName = $pageSchemaObj->getCategoryName();
         }
         $templateText = SFTemplateField::createTemplateText($templateName, $template_fields, $internalObjProperty, $categoryName, null, null, null);
         if (in_array($fullTemplateName, $selectedPages)) {
             $params = array();
             $params['user_id'] = $wgUser->getId();
             $params['page_text'] = $templateText;
             $jobs[] = new PSCreatePageJob($templateTitle, $params);
         }
         $templateValues = self::getTemplateValues($psTemplate);
         if (array_key_exists('Label', $templateValues)) {
             $templateLabel = $templateValues['Label'];
         } else {
             $templateLabel = null;
         }
         $form_fields = self::getFormFieldInfo($psTemplate, $template_fields);
         // Create template info for form, for use in generating
         // the form (if it will be generated).
         $form_template = SFTemplateInForm::create($templateName, $templateLabel, $psTemplate->isMultiple(), null, $form_fields);
         $form_templates[] = $form_template;
     }
     Job::batchInsert($jobs);
     // Create form, if it's specified.
     $formName = self::getFormName($pageSchemaObj);
     if (!empty($formName)) {
         $formInfo = self::getMainFormInfo($pageSchemaObj);
         $formTitle = Title::makeTitleSafe(SF_NS_FORM, $formName);
         $fullFormName = PageSchemas::titleString($formTitle);
         if (in_array($fullFormName, $selectedPages)) {
             self::generateForm($formName, $formTitle, $form_templates, $formInfo, $categoryName);
         }
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:61,代码来源:SF_PageSchemas.php

示例13: notifyUsers


//.........这里部分代码省略.........
			}
			global $smwgNMHideDiffWhenShowAll;
			if ( !( $smwgNMHideDiffWhenShowAll && $showing_all ) ) {
				$html_msg .= wfMsg( 'smw_nm_hint_notification_html', $this->m_notifyHtmlMsgs[$notify_id] );
				if ( isset( $this->m_notifyHtmlPropMsgs[$notify_id] ) ) {
					$html_msg .= wfMsg( 'smw_nm_hint_nmtable_html', $this->m_notifyHtmlPropMsgs[$notify_id] );
				}
			}
			if ( $showing_all ) {
				$id = $sStore->addNotifyRSS( 'nid', $notify_id, "All current items, " . date( 'Y-m-d H:i:s', time() ), $this->applyStyle( $html_msg ), $link );
			} else {
				$id = $sStore->addNotifyRSS( 'nid', $notify_id, $this->m_title->getText(), $this->applyStyle( $html_msg ) );
			}
		}
		foreach ( $this->m_userMsgs as $user_id => $msg ) {
			// generate RSS items
			$html_msg = $html_style;
			foreach ( array_unique( $this->m_userNMs[$user_id] ) as $showall_nid ) {
				if ( isset( $html_showall[$showall_nid] ) ) {
					$html_msg .= wfMsg( 'smw_nm_hint_item_html', $html_showall[$showall_nid]['name'], $html_showall[$showall_nid]['html'] );
				}
			}

			$html_msg .= wfMsg( 'smw_nm_hint_notification_html', $this->m_userHtmlNMMsgs[$user_id] );
			if ( isset( $this->m_userHtmlPropMsgs[$user_id] ) ) {
				$html_msg .= wfMsg( 'smw_nm_hint_nmtable_html', $this->m_userHtmlPropMsgs[$user_id] );
			}

			global $wgNMReportModifier, $wgUser;
			if ( $wgNMReportModifier ) {
				$userText = $wgUser->getName();
				if ( $wgUser->getId() == 0 ) {
					$page = SpecialPage::getTitleFor( 'Contributions', $userText );
				} else {
					$page = Title::makeTitle( NS_USER, $userText );
				}
				$l = '<a href="' . $page->getFullUrl() . '">' . htmlspecialchars( $userText ) . '</a>';
				$html_msg .= wfMsg( 'smw_nm_hint_modifier_html', $l );
				$msg .= wfMsg( 'smw_nm_hint_modifier', $wgUser->getName() );
			}

			$id = $sStore->addNotifyRSS( 'uid', $user_id, $this->m_title->getText(), $this->applyStyle( $html_msg ) );

			if ( $wgEnotifyMeJob ) {
				// send notifications by mail
				$user_info = $sStore->getUserInfo( $user_id );
				$user = User::newFromRow( $user_info );
				if ( ( $user_info->user_email != '' ) && $user->getOption( 'enotifyme' ) ) {
					$name = ( ( $user_info->user_real_name == '' ) ? $user_info->user_name:$user_info->user_real_name );

					$params = array( 'to' => new MailAddress( $user_info->user_email, $name ),
						'from' => new MailAddress( $wgEmergencyContact, 'Admin' ),
						'subj' => wfMsg( 'smw_nm_hint_mail_title', $this->m_title->getText(), $wgSitename ),
						'body' => wfMsg( 'smw_nm_hint_mail_body', $name, $msg ),
						'replyto' => new MailAddress( $wgEmergencyContact, 'Admin' ) );

					$nm_send_jobs[] = new SMW_NMSendMailJob( $this->m_title, $params );
				}
			}
		}

		if ( $wgEnotifyMeJob ) {
			if ( count( $nm_send_jobs ) ) {
				Job :: batchInsert( $nm_send_jobs );
			}
		} else {
			global $phpInterpreter;
			if ( !isset( $phpInterpreter ) ) {
				// if $phpInterpreter is not set, assume it is in search path
				// if not, starting of bot will FAIL!
				$phpInterpreter = "php";
			}
			// copy from SMW_GardeningBot.php
			ob_start();
			phpinfo();
			$info = ob_get_contents();
			ob_end_clean();
			// Get Systemstring
			preg_match( '!\nSystem(.*?)\n!is', strip_tags( $info ), $ma );
			// Check if it consists 'windows' as string
			preg_match( '/[Ww]indows/', $ma[1], $os );
			global $smwgNMIP ;
			if ( $os[0] == '' && $os[0] == null ) {

				// FIXME: $runCommand must allow whitespaces in paths too
				$runCommand = "$phpInterpreter -q $smwgNMIP/specials/SMWNotifyMe/SMW_NMSendMailAsync.php";
				// TODO: test async code for linux.
				// low prio
				$nullResult = `$runCommand > /dev/null &`;
			}
			else // windowze
			{
				$runCommand = "\"\"$phpInterpreter\" -q \"$smwgNMIP/specials/SMWNotifyMe/SMW_NMSendMailAsync.php\"\"";
				$wshShell = new COM( "WScript.Shell" );
				$runCommand = "cmd /C " . $runCommand;

				$oExec = $wshShell->Run( $runCommand, 7, false );
			}
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:SMW_NotifyProcessor.smw15.php

示例14: updateRedirects

 /**
  * Helper method to write information about some redirect. Various updates
  * can be necessary if redirects are resolved as identities in SMW. The
  * title and namespace of the affected page and of its updated redirect
  * target are given. The target can be empty ('') to delete any redirect.
  * Returns the canonical ID that is now to be used for the subject.
  *
  * This method does not change the ids of the affected pages, and thus it
  * is not concerned with updates of the data that is currently stored for
  * the subject. Normally, a subject that is a redirect will not have other
  * data, but this method does not depend on this.
  *
  * @note Please make sure you fully understand this code before making any
  * changes here. Keeping the redirect structure consistent is important,
  * and errors in this code can go unnoticed for quite some time.
  *
  * @note This method merely handles the addition or deletion of a redirect
  * statement in the wiki. It does not assume that any page contents has
  * been changed (e.g. moved). See changeTitle() for additional handling in
  * this case.
  */
 protected function updateRedirects($subject_t, $subject_ns, $curtarget_t = '', $curtarget_ns = -1)
 {
     global $smwgQEqualitySupport, $smwgEnableUpdateJobs;
     // *** First get id of subject, old redirect target, and current (new) redirect target ***//
     $sid = $this->getSMWPageID($subject_t, $subject_ns, '', '', false);
     // find real id of subject, if any
     /// NOTE: $sid can be 0 here; this is useful to know since it means that fewer table updates are needed
     $new_tid = $curtarget_t ? $this->makeSMWPageID($curtarget_t, $curtarget_ns, '', '', false) : 0;
     // real id of new target, if given
     $db = wfGetDB(DB_SLAVE);
     $row = $db->selectRow(array('smw_redi2'), 'o_id', array('s_title' => $subject_t, 's_namespace' => $subject_ns), __METHOD__);
     $old_tid = $row !== false ? $row->o_id : 0;
     // real id of old target, if any
     /// NOTE: $old_tid and $new_tid both (intentionally) ignore further redirects: no redirect chains
     if ($old_tid == $new_tid) {
         // no change, all happy
         return $new_tid == 0 ? $sid : $new_tid;
     }
     // note that this means $old_tid != $new_tid in all cases below
     // *** Make relevant changes in property tables (don't write the new redirect yet) ***//
     $db = wfGetDB(DB_MASTER);
     // now we need to write something
     if ($old_tid == 0 && $sid != 0 && $smwgQEqualitySupport != SMW_EQ_NONE) {
         // new redirect
         // $smwgQEqualitySupport requires us to change all tables' page references from $sid to $new_tid.
         // Since references must not be 0, we don't have to do this is $sid == 0.
         $this->changeSMWPageID($sid, $new_tid, $subject_ns, $curtarget_ns, false, true);
     } elseif ($old_tid != 0) {
         // existing redirect is changed or deleted
         $db->delete('smw_redi2', array('s_title' => $subject_t, 's_namespace' => $subject_ns), __METHOD__);
         if ($smwgEnableUpdateJobs && $smwgQEqualitySupport != SMW_EQ_NONE) {
             // entries that refer to old target may in fact refer to subject,
             // but we don't know which: schedule affected pages for update
             $jobs = array();
             foreach (self::getPropertyTables() as $proptable) {
                 if ($proptable->name == 'smw_redi2') {
                     continue;
                 }
                 // can safely be skipped
                 if ($proptable->idsubject) {
                     $from = $db->tableName($proptable->name) . ' INNER JOIN ' . $db->tableName('smw_ids') . ' ON s_id=smw_id';
                     $select = 'DISTINCT smw_title AS t,smw_namespace AS ns';
                 } else {
                     $from = $db->tableName($proptable->name);
                     $select = 'DISTINCT s_title AS t,s_namespace AS ns';
                 }
                 if ($subject_ns == SMW_NS_PROPERTY && !$proptable->fixedproperty) {
                     $res = $db->select($from, $select, array('p_id' => $old_tid), __METHOD__);
                     foreach ($res as $row) {
                         $title = Title::makeTitleSafe($row->ns, $row->t);
                         if (!is_null($title)) {
                             $jobs[] = new SMWUpdateJob($title);
                         }
                     }
                     $db->freeResult($res);
                 }
                 foreach ($proptable->objectfields as $fieldname => $type) {
                     if ($type == 'p') {
                         $res = $db->select($from, $select, array($fieldname => $old_tid), __METHOD__);
                         foreach ($res as $row) {
                             $title = Title::makeTitleSafe($row->ns, $row->t);
                             if (!is_null($title)) {
                                 $jobs[] = new SMWUpdateJob($title);
                             }
                         }
                         $db->freeResult($res);
                     }
                 }
             }
             /// NOTE: we do not update the concept cache here; this remains an offline task
             /// NOTE: this only happens if $smwgEnableUpdateJobs was true above:
             Job::batchInsert($jobs);
         }
     }
     // *** Finally, write the new redirect data ***//
     if ($new_tid != 0) {
         // record a new redirect
         // Redirecting done right:
         // (1) make a new ID with iw SMW_SQL2_SMWREDIIW or
//.........这里部分代码省略.........
开发者ID:nischayn22,项目名称:SemanticMediawiki,代码行数:101,代码来源:SMW_SQLStore2.php

示例15: queueJobs

 protected function queueJobs($jobs, $dryrun = false)
 {
     $this->output("Queuing batch of " . count($jobs) . " double redirects.\n");
     Job::batchInsert($dryrun ? array() : $jobs);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:5,代码来源:fixDoubleRedirects.php


注:本文中的Job::batchInsert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。