Example #1
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     parent::GardeningBot("smw_wsupdatebot");
 }
/**
 * This method is called, after an article has been saved and if import after
 * modification via Mediawiki API is enabled ($iaigUpdateDependenciesAfterAPIedit). 
 *
 * @param Article $article
 * @param User $user
 * @param strinf $text
 * @return true
 */
function iaifArticleSaveComplete(&$article, &$user, $text)
{
    iaifStartLog("iaifArticleSaveComplete");
    global $iaigUpdateWithBot, $iaigIP;
    $t = $article->getTitle()->getFullText();
    $k = array_search($t, $iaigUpdateWithBot);
    if ($k !== false) {
        GardeningBot::runBot('iai_importbot', "article={$t}");
        unset($iaigUpdateWithBot[$k]);
    }
    global $iaigLog, $iaigStartTime;
    fprintf($iaigLog, "iaifArticleSaveComplete: %f (ms)\n", (microtime(true) - $iaigStartTime) / 1000);
    iaifEndLog("iaifArticleSaveComplete");
    return true;
}
Example #3
0
 function __construct()
 {
     parent::GardeningBot("smw_termimportbot");
 }
Example #4
0
 /**
  * Imports the vocabulary according to the given policies. The content of the
  * wiki is updated. This method starts a bot with the following parameters:
  *
  * @param string $moduleConfig
  * 		This XML structure describes the modules of the TL and DAL that are
  * 		needed for the actual import.
  * 		Example:
  * 		<?xml version="1.0"?>
  *		<ModuleConfiguration xmlns="http://www.ontoprise.de/smwplus#">
  *			  <TLModules>
  *			    <Module>
  *			        <id>ConnectLocal</id>
  *			    </Module>
  *			  </TLModules >
  *			  <DALModules>
  *			    <Module>
  *			        <id>ReadCSV</id>
  *			    </Module>
  *			  </DALModules >
  *			</ModuleConfiguration>
  *
  * @param string $dataSource
  * 		The description of the data source as returned by
  * 		<getSourceSpecification()> and filled with the user's values.
  *
  * @param string $importSet:
  * 		One of the import sets that can be retrieved with getImportSet() or
  * 		empty. The complete XML element <importSet> as specified above is
  * 		passed as it may contain values besides <name> and <desc>.
  *
  * @param string $inputPolicy
  * 		The input policy as an XML structure.
  *		The input policy defines which parts of which terms are imported.
  *
  * 		Specification of terms to import
  *		The set of terms to import can be restricted to a list of given items
  * 		or the terms that match a regular expression or both. Both restrictions
  * 		complement each other i.e. a term is imported if it is part of the
  * 		list or matches the regular expression.
  * 		Example: [Aa]* imports all terms that start with the letter A.
  *
  * 		Specification of the data to import
  * 		The definition of each term consists of several properties. Each property
  * 		of the definition is given as an XML element. A lists of properties
  * 		controls which parts are imported. The list must contain at least
  * 		the <articleName>. If the ontological properties are omitted, the
  * 		term can not be placed correctly in the wiki's ontology.
  *
  * 		Example:
  *		<?xml version="1.0"?>
  *		<InputPolicy xmlns="http://www.ontoprise.de/smwplus#">
  *		    <terms>
  *		        <regex>[Aa]*</regex>
  *		        <regex>[Bb]*</regex>
  *		        <term>Rabbit</term>
  *		        <term>Fox</term>
  *		    </terms>
  *		    <properties>
  *		       <property>articleName</property>
  *		       <property>content</property>
  *		       <property>isSubCategoryOf</property>
  *		    </properties>
  *		</InputPolicy >
  *
  * @param string $mappingPolicy
  * 		The mapping policy is like a template for the articles that are
  * 		created for terms. The policy is stored as a normal page in the wiki.
  * 		The properties of the imported term appear like template parameters
  * 		in a special mapping tag in the page.
  * 		The definition of the mapping policy is defined as XML structure. It
  * 		contains the name of the page with the policy.
  *
  * 		Example:
  *		<?xml version="1.0"?>
  *		<MappingPolicy xmlns="http://www.ontoprise.de/smwplus#">
  *		    <page>TermImport</page>
  *		</MappingPolicy >
  *
  * @param string $conflictPolicy
  * 		Import jobs can be run several times. A conflict occurs when a term
  * 		for an already existing article is imported. The conflict policy
  * 		controls if the article is overwritten or if the new version is
  * 		ignored.
  * 		The definition of the conflict policy is defined as XML structure:
  * 		Example:
  * 		<?xml version="1.0"?>
  * 		<ConflictPolicy xmlns="http://www.ontoprise.de/smwplus#">
  * 		    <overwriteExistingTerms>true</overwriteExistingTerms>
  * 		</ConflictPolicy >
  * 		The allowed values for <overwriteExistingTerms> are true and false.
  *
  * @return string
  * 		An XML structure is returned. Its value is <true>, if the bot was
  * 		successfully started. Otherwise <false> and	an error message are
  * 		returned.
  * 		Example:
  *		<?xml version="1.0"?>
  *		<ReturnValue xmlns="http://www.ontoprise.de/smwplus#">
  *		    <value>true</value>
  *		    <message>The import bot was successfully started.</message>
  *		</ReturnValue >
  */
 public function importTerms($moduleConfig, $dataSource, $importSet, $inputPolicy, $mappingPolicy, $conflictPolicy, $termImportName, $async = true)
 {
     global $smwgDIIP, $wgUploadDirectory;
     require_once "{$smwgDIIP}/specials/TermImport/SMW_TermImportBot.php";
     $result = "true";
     $msg = "";
     $settings = "\n<ImportSettings>\n" . $moduleConfig . "\n" . $dataSource . "\n" . $importSet . "\n" . $inputPolicy . "\n" . $mappingPolicy . "\n" . $conflictPolicy . "\n" . "</ImportSettings>";
     $settings = '<?xml version="1.0"?>' . str_replace('<?xml version="1.0"?>', "", $settings);
     // The parameters for the bot are passed in a temporary file that will
     // be deleted by the bot.
     $filename = "{$wgUploadDirectory}/importSettings_" . microtime(true);
     if (file_put_contents($filename, $settings)) {
         if ($async) {
             $f = rawurlencode($filename);
             $param = "settings={$f},termImportName=" . $termImportName;
             $taskID = GardeningBot::runBot('smw_termimportbot', $param);
             if (is_int($taskID)) {
                 $msg = wfMsg('smw_ti_botstarted');
             } else {
                 $msg = wfMsg('smw_ti_botnotstarted');
                 $result = false;
             }
         } else {
             $param = array("settings" => $filename, "termImportName" => $termImportName);
             global $registeredBots;
             $bot = $registeredBots['smw_termimportbot'];
             $taskID = SGAGardeningLog::getGardeningLogAccess()->addGardeningTask('smw_termimportbot');
             $log = $bot->run($param, false, 0);
             $logPageTitle = $log[1];
             $log = $log[0];
             SGAGardeningLog::getGardeningLogAccess()->markGardeningTaskAsFinished($taskID, $log, $logPageTitle);
             //todo:error handling
             return $log;
         }
     } else {
         $msg = wfMsg('smw_ti_couldnotwritesettings');
         $result = false;
     }
     return '<?xml version="1.0"?>' . "\n" . '<ReturnValue xmlns="http://www.ontoprise.de/smwplus#">' . "\n" . "\t<value>{$result}</value>\n" . "\t<message>{$msg}</message>\n" . '</ReturnValue>';
 }
 function __construct()
 {
     //todo:register termimportupdatebot
     //define('SMWH_FORCE_TS_UPDATE', true);
     parent::GardeningBot("smw_termimportupdatebot");
 }
Example #6
0
 function __construct()
 {
     parent::GardeningBot("iai_importbot");
 }