$table_template_text = get_wiki_text($data['table_template'], NS_TEMPLATE); if ($table_template_text == '' || $page_template_text == '') { $err_msg = "ERROR: Something is missing..."; if ($page_template_text == '') { $err_msg .= "\n\tpage template empty or not found\n"; } if ($table_template_text == '') { $err_msg .= "\n\t table template empty or not found\n"; } echo $err_msg; continue; } # look for the page by name # need to check behavior on alternate namespaces $title = Title::newFromText($data['page_name']); if (!$title->exists() || get_wiki_text($data['page_name']) == '') { # page doesn't exist yet; add a temporary page to create a page_uid echo "adding a page for " . $data['page_name'] . "\n"; $article = new Article($title); if (!$title->exists()) { $article->doEdit('placeholder', 'Added by wikibot to create page id', EDIT_NEW | EDIT_FORCE_BOT); } # make the table $box_text = make_box($data['page_name'], $data['table_template'], $data); # this adds the data too. $new_page = str_replace("{{{" . strtoupper($data['table_template']) . "}}}", $box_text, $page_template_text); $article->doEdit($new_page, 'Added by wikibot', EDIT_UPDATE | EDIT_FORCE_BOT); $change_count++; echo "{$line_count} lines processed: " . $data['page_name'] . " is item {$change_count}\n"; } else { # page already exists. Find the desired box
function edit_the_search_results_topic_page($page_to_open, $to_replace, $replace_with) { $to_replace = str_replace("\\", "", $to_replace); $to_replace = str_replace("_", " ", $to_replace); $to_replace = str_replace("&", "&", $to_replace); $replace_with = str_replace("\\", "", $replace_with); $replace_with = str_replace("_", " ", $replace_with); $replace_with = str_replace("&", "&", $replace_with); echo "\n -- to replace [{$to_replace}]\n"; echo "\n -- replace with [{$replace_with}]\n"; if ($wiki_path = get_wiki_text($page_to_open)) { if (filesize($wiki_path)) { $html = file_get_contents($wiki_path); $html = str_replace($to_replace, $replace_with, $html); //start saving... $temp_write_file = $GLOBALS['doc_root'] . "/eoearth/Custom/temp/write.wiki"; $handle = fopen($temp_write_file, "w"); fwrite($handle, $html); fclose($handle); echo "\n updating links on: [{$page_to_open}]"; shell_exec("php " . $GLOBALS['doc_root'] . "/eoearth/maintenance/edit.php -m " . $page_to_open . " < {$temp_write_file}"); } } }
include 'classes/class.hyperparse.php'; $HyperParse = new HyperParse($langParameters); $wikitext = get_wiki_text($langParameters, $wikiSource, $word); $hyperArray = $HyperParse->get_hyper($wikitext, $count); printResults($hyperArray); break; /***********************************************************************************/ // Include genderparse class and create new object with 3 variables. (Gender) /***********************************************************************************/ /***********************************************************************************/ // Include genderparse class and create new object with 3 variables. (Gender) /***********************************************************************************/ case "gender": include 'classes/class.genderparse.php'; $GenderParse = new GenderParse($langParameters); $wikitext = get_wiki_text($langParameters, $wikiSource, $word); $genderArray = $GenderParse->get_gender($wikitext, $count); printResults($genderArray); break; /***********************************************************************************/ /***********************************************************************************/ default: echo "You must specify a valid query type ('pos', 'def', 'syn', 'hyper', or 'gender')."; break; } /***********************************************************************************/ // Include wikiextract class and create new object with 2 variables. Returns the // contents of the wiktionary entry for a given word. /***********************************************************************************/ function get_wiki_text($langParameters, $wikiSource, $word) {