function execute( $par ) { global $wgOut, $wgUser, $wgRequest; $wgOut->setPageTitle( 'Add Collection' ); if ( !$wgUser->isAllowed( 'addcollection' ) ) { $wgOut->addHTML( 'You do not have permission to add a collection.' ); return false; } $dbr = wfGetDB( DB_MASTER ); if ( $wgRequest->getText( 'collection' ) ) { require_once( 'WikiDataAPI.php' ); require_once( 'Transaction.php' ); $dc = $wgRequest->getText( 'dataset' ); $collectionName = $wgRequest->getText( 'collection' ); startNewTransaction( $wgUser->getID(), wfGetIP(), 'Add collection ' . $collectionName ); bootstrapCollection( $collectionName, $wgRequest->getText( 'language' ), $wgRequest->getText( 'type' ), $dc ); $wgOut->addHTML( wfMsg( 'ow_collection_added', $collectionName ) . "<br />" ); } $datasets = wdGetDatasets(); $datasetarray[''] = wfMsgSc( "none_selected" ); foreach ( $datasets as $datasetid => $dataset ) { $datasetarray[$datasetid] = $dataset->fetchName(); } $wgOut->addHTML( getOptionPanel( array( 'Collection name:' => getTextBox( 'collection' ), 'Language of name:' => getSuggest( 'language', 'language' ), 'Collection type:' => getSelect( 'type', array( '' => 'None', 'RELT' => 'RELT', 'LEVL' => 'LEVL', 'CLAS' => 'CLAS', 'MAPP' => 'MAPP' ) ), 'Dataset:' => getSelect( 'dataset', $datasetarray ) ), '', array( 'create' => wfMsg( 'ow_create' ) ) ) ); }
function execute( $par ) { global $wgOut, $wgUser, $wgRequest; if ( !$wgUser->isAllowed( 'exporttsv' ) ) { $wgOut->addHTML( wfMsg( 'ow_exporttsv_not_allowed' ) ); return false; } $dbr = wfGetDB( DB_SLAVE ); $dc = wdGetDataSetcontext(); if ( $wgRequest->getText( 'collection' ) && $wgRequest->getText( 'languages' ) ) { // render the tsv file require_once( 'WikiDataAPI.php' ); require_once( 'Transaction.php' ); // get the collection to export. Cut off the 'cid' part that we added // to make the keys strings rather than numbers in the array sent to the form. $collectionId = substr( $wgRequest->getText( 'collection' ), 3 ); // get the languages requested, turn into an array, trim for spaces. $isoCodes = explode( ',', $wgRequest->getText( 'languages' ) ); for ( $i = 0; $i < count( $isoCodes ); $i++ ) { $isoCodes[$i] = trim( $isoCodes[$i] ); if ( !getLanguageIdForIso639_3( $isoCodes[$i] ) ) { $wgOut->setPageTitle( wfMsg( 'ow_exporttsv_export_failed' ) ); $wgOut->addHTML( wfMsg( 'ow_impexptsv_unknown_lang', $isoCodes[$i] ) ); return false; } } $wgOut->disable(); $languages = $this->getLanguages( $isoCodes ); $isoLookup = $this->createIsoLookup( $languages ); $downloadFileName = $this->createFileName( $isoCodes ); // Force the browser into a download header( 'Content-Type: text/tab-separated-values;charset=utf-8' ); header( 'Content-Disposition: attachment; filename="' . $downloadFileName . '"' ); // attachment // separator character used. $sc = "\t"; echo( pack( 'CCC', 0xef, 0xbb, 0xbf ) ); // start the first row: column names echo( 'defined meaning id' . $sc . 'defining expression' ); foreach ( $isoCodes as $isoCode ) { echo( $sc . 'definition_' . $isoCode . $sc . 'translations_' . $isoCode ); } echo( "\r\n" ); // get all the defined meanings in the collection $query = "SELECT dm.defined_meaning_id, exp.spelling "; $query .= "FROM {$dc}_collection_contents col, {$dc}_defined_meaning dm, {$dc}_expression exp "; $query .= "WHERE col.collection_id=" . $collectionId . " "; $query .= "AND col.member_mid=dm.defined_meaning_id "; $query .= "AND dm.expression_id = exp.expression_id "; $query .= "AND " . getLatestTransactionRestriction( "col" ); $query .= "AND " . getLatestTransactionRestriction( "dm" ); $query .= "AND " . getLatestTransactionRestriction( "exp" ); $query .= "ORDER BY exp.spelling"; // wfDebug($query."\n"); $queryResult = $dbr->query( $query ); while ( $row = $dbr->fetchRow( $queryResult ) ) { $dm_id = $row['defined_meaning_id']; // echo the defined meaning id and the defining expression echo( $dm_id ); echo( "\t" . $row['spelling'] ); // First we'll fill an associative array with the definitions and // translations. Then we'll use the isoCodes array to put them in the // proper order. // the associative array holding the definitions and translations $data = array(); // **************************** // query to get the definitions // **************************** $qry = 'SELECT txt.text_text, trans.language_id '; $qry .= "FROM {$dc}_text txt, {$dc}_translated_content trans, {$dc}_defined_meaning dm "; $qry .= 'WHERE txt.text_id = trans.text_id '; $qry .= 'AND trans.translated_content_id = dm.meaning_text_tcid '; $qry .= "AND dm.defined_meaning_id = $dm_id "; $qry .= 'AND trans.language_id IN ('; for ( $i = 0; $i < count( $languages ); $i++ ) { $language = $languages[$i]; if ( $i > 0 ) $qry .= ","; $qry .= $language['language_id']; } $qry .= ') AND ' . getLatestTransactionRestriction( 'trans' ); $qry .= 'AND ' . getLatestTransactionRestriction( 'dm' ); // wfDebug($qry."\n"); // uncomment this if you accept having 1700+ queries in the log $definitions = $dbr->query( $qry ); while ( $row = $dbr->fetchRow( $definitions ) ) { // $key becomes something like def_eng $key = 'def_' . $isoLookup['id' . $row['language_id']]; $data[$key] = $row['text_text']; } $dbr->freeResult( $definitions ); // ***************************** // query to get the translations // ***************************** $qry = "SELECT exp.spelling, exp.language_id "; $qry .= "FROM {$dc}_expression exp "; $qry .= "INNER JOIN {$dc}_syntrans trans ON exp.expression_id=trans.expression_id "; $qry .= "WHERE trans.defined_meaning_id=$dm_id "; $qry .= "AND " . getLatestTransactionRestriction( "exp" ); $qry .= "AND " . getLatestTransactionRestriction( "trans" ); // wfDebug($qry."\n"); // uncomment this if you accept having 1700+ queries in the log $translations = $dbr->query( $qry ); while ( $row = $dbr->fetchRow( $translations ) ) { // qry gets all languages, we filter them here. Saves an order // of magnitude execution time. if ( isset( $isoLookup['id' . $row['language_id']] ) ) { // $key becomes something like trans_eng $key = 'trans_' . $isoLookup['id' . $row['language_id']]; if ( !isset( $data[$key] ) ) $data[$key] = $row['spelling']; else $data[$key] = $data[$key] . '|' . $row['spelling']; } } $dbr->freeResult( $translations ); // now that we have everything, output the row. foreach ( $isoCodes as $isoCode ) { // if statements save a bunch of notices in the log about // undefined indices. echo( "\t" ); if ( isset( $data['def_' . $isoCode] ) ) echo( $this->escapeDelimitedValue( $data['def_' . $isoCode] ) ); echo( "\t" ); if ( isset( $data['trans_' . $isoCode] ) ) echo( $data['trans_' . $isoCode] ); } echo( "\r\n" ); } } else { // Get the collections $colQuery = "SELECT col.collection_id, exp.spelling " . "FROM {$dc}_collection col INNER JOIN {$dc}_defined_meaning dm ON col.collection_mid=dm.defined_meaning_id " . "INNER JOIN {$dc}_expression exp ON dm.expression_id=exp.expression_id " . "WHERE " . getLatestTransactionRestriction( 'col' ); $collections = array(); $colResults = $dbr->query( $colQuery ); while ( $row = $dbr->fetchRow( $colResults ) ) { $collections['cid' . $row['collection_id']] = $row['spelling']; } // render the page $wgOut->setPageTitle( wfMsg( 'ow_exporttsv_title' ) ); $wgOut->addHTML( wfMsg( 'ow_exporttsv_header' ) ); $wgOut->addHTML( getOptionPanel( array( wfMsg( 'ow_Collection_colon' ) => getSelect( 'collection', $collections, 'cid376322' ), wfMsg( 'ow_exporttsv_languages' ) => getTextBox( 'languages', 'ita, eng, deu, fra, cat' ), ), '', array( 'create' => wfMsg( 'ow_create' ) ) ) ); } }
function getYcFundingSource($conn) { $lan = $_POST['lan']; if ($lan == 'en-GB') { $ServiceTypeName = 'ServiceTypeName'; $FundingReqSourceName = 'FundingReqSourceName'; } else { $ServiceTypeName = 'ServiceTypeNameFrench'; $FundingReqSourceName = 'FundingReqSourceNameFrench'; } $CountryId = $_POST['country']; $Year = $_POST['year']; $ItemGroupId = $_POST['ItemGroupId']; if (!empty($CountryId) && !empty($Year) && !empty($ItemGroupId)) { $sql_count = "SELECT COUNT(FundingReqId) as M\n FROM t_yearly_funding_requirements\n WHERE CountryId = '" . $CountryId . "' \n AND Year = '" . $Year . "'\n\t\t\t\t\t\tAND ItemGroupId = '" . $ItemGroupId . "';"; // echo $sql_count; $qr_count = mysql_query($sql_count, $conn); $r_count = mysql_fetch_object($qr_count); $re_num = $r_count->M; if ($re_num == 0) { $sql = "INSERT INTO t_yearly_funding_requirements(FundingReqId, CountryId,FundingReqSourceId,\n\t\t\t\tItemGroupId, Year, TotalRequirements)\n\t\t\t\tSELECT NULL,'" . $CountryId . "',FundingReqSourceId,'" . $ItemGroupId . "','" . $Year . "',''\n\t\t\t\tFROM `t_fundingreqsources` WHERE ItemGroupId = '" . $ItemGroupId . "' \n\t\t\t\tORDER BY FundingReqSourceId ASC;"; // echo $sql; mysql_query($sql, $conn); //} } } $sLimit = ""; if (isset($_POST['iDisplayStart'])) { $sLimit = " LIMIT " . mysql_real_escape_string($_POST['iDisplayStart']) . ", " . mysql_real_escape_string($_POST['iDisplayLength']); } $sOrder = ""; if (isset($_POST['iSortCol_0'])) { $sOrder = " ORDER BY "; for ($i = 0; $i < mysql_real_escape_string($_POST['iSortingCols']); $i++) { $sOrder .= fnColumnToField_fundingsource(mysql_real_escape_string($_POST['iSortCol_' . $i])) . "\n\t\t\t\t\t\t\t\t" . mysql_real_escape_string($_POST['sSortDir_' . $i]) . ", "; } $sOrder = substr_replace($sOrder, "", -2); } $sql = "SELECT SQL_CALC_FOUND_ROWS a.FundingReqId, a.TotalRequirements, a.Year, Y1, Y2, Y3,\n\t\t\t\td.{$ServiceTypeName} ServiceTypeName, a.CountryId, a.FormulationId, c.{$FundingReqSourceName} FundingReqSourceName\n\t\t\t\tFROM t_yearly_funding_requirements a\n\t\t\t\tINNER JOIN t_fundingreqsources c ON c.FundingReqSourceId = a.FundingReqSourceId \n\t\t\t\tINNER JOIN t_servicetype d ON d.ServiceTypeId = c.ServiceTypeId\n INNER JOIN t_itemgroup b ON c.ItemGroupId = b.ItemGroupId \n WHERE a.CountryId = '" . $CountryId . "'\n AND a.Year = '" . $Year . "' AND a.ItemGroupId = '" . $ItemGroupId . "'\n\t\t\t\tORDER BY a.FundingReqSourceId ASC\n\t\t\t\t;"; //echo $sql; $result = mysql_query($sql, $conn); $total = mysql_num_rows($result); $sQuery = "SELECT FOUND_ROWS()"; $rResultFilterTotal = mysql_query($sQuery); $aResultFilterTotal = mysql_fetch_array($rResultFilterTotal); $iFilteredTotal = $aResultFilterTotal[0]; $sOutput = '{'; $sOutput .= '"sEcho": ' . intval($_POST['sEcho']) . ', '; $sOutput .= '"iTotalRecords": ' . $iFilteredTotal . ', '; $sOutput .= '"iTotalDisplayRecords": ' . $iFilteredTotal . ', '; $sOutput .= '"aaData": [ '; $serial = $_POST['iDisplayStart'] + 1; $f = 0; while ($aRow = mysql_fetch_array($result)) { if ($f++) { $sOutput .= ','; } $sOutput .= "["; $sOutput .= '"' . $serial++ . '",'; $sOutput .= '"' . $aRow['FundingReqId'] . '",'; $sOutput .= '"' . $aRow['ServiceTypeName'] . '",'; $sOutput .= '"' . $aRow['FundingReqSourceName'] . '",'; $sOutput .= '"' . getTextBox($aRow['Y1'], 'Y1') . '",'; $sOutput .= '"' . getTextBox($aRow['Y2'], 'Y2') . '",'; $sOutput .= '"' . getTextBox($aRow['Y3'], 'Y3') . '",'; $sOutput .= '"<span class=TR-' . $aRow['FundingReqId'] . '>' . $aRow['TotalRequirements'] . '</span>"'; $sOutput .= "]"; } $sOutput .= '] }'; echo $sOutput; }
function search($searchText) { global $wgOut, $wgRequest, $wgFilterLanguageId, $wgSearchWithinWordsDefaultValue, $wgSearchWithinExternalIdentifiersDefaultValue, $wgShowSearchWithinExternalIdentifiersOption, $wgShowSearchWithinWordsOption; $collectionId = $wgRequest->getInt("collection"); $languageId = $wgRequest->getInt("language"); $withinWords = $wgRequest->getBool("within-words"); $withinExternalIdentifiers = $wgRequest->getBool("within-external-identifiers"); if (!$withinWords && !$withinExternalIdentifiers) { $withinWords = $wgSearchWithinWordsDefaultValue; $withinExternalIdentifiers = $wgSearchWithinExternalIdentifiersDefaultValue; } $languageName = languageIdAsText($languageId); $options = array(); $options[wfMsg('datasearch_search_text')] = getTextBox('search-text', $searchText); if ($wgFilterLanguageId == 0) { $options[wfMsg('datasearch_language')] = getSuggest('language', "language", array(), $languageId, $languageName); } else { $languageId = $wgFilterLanguageId; } $options[wfMsg('ow_Collection_colon')] = getSuggest('collection', 'collection', array(), $collectionId, collectionIdAsText($collectionId)); if ($wgShowSearchWithinWordsOption) { $options[wfMsg('datasearch_within_words')] = getCheckBox('within-words', $withinWords); } else { $withinWords = $wgSearchWithinWordsDefaultValue; } if ($wgShowSearchWithinExternalIdentifiersOption) { $options[wfMsg('datasearch_within_ext_ids')] = getCheckBox('within-external-identifiers', $withinExternalIdentifiers); } else { $withinExternalIdentifiers = $wgSearchWithinExternalIdentifiersDefaultValue; } $wgOut->addHTML(getOptionPanel($options)); if ($withinWords) { if ($languageId != 0 && $languageName != "") { $wgOut->addHTML('<h1>' . wfMsg('datasearch_match_words_lang', $languageName, $searchText) . '</h1>'); } else { $wgOut->addHTML('<h1>' . wfMsg('datasearch_match_words', $searchText) . '</h1>'); } $resultCount = $this->searchWordsCount($searchText, $collectionId, $languageId); $wgOut->addHTML('<p>' . wfMsgExt('datasearch_showing_only', 'parsemag', 100, $resultCount) . '</p>'); $wgOut->addHTML($this->searchWords($searchText, $collectionId, $languageId)); } if ($withinExternalIdentifiers) { $wgOut->addHTML('<h1>' . wfMsg('datasearch_match_ext_ids', $searchText) . '</i></h1>'); $wgOut->addHTML('<p>' . wfMsgExt('datasearch_showing_only', 'parsemag', 100) . '</p>'); $wgOut->addHTML($this->searchExternalIdentifiers($searchText, $collectionId)); } }
function execute( $parameter ) { global $wgOut; require_once( "WikiDataTables.php" ); require_once( "OmegaWikiAttributes.php" ); require_once( "OmegaWikiRecordSets.php" ); require_once( "OmegaWikiEditors.php" ); require_once( "RecordSetQueries.php" ); require_once( "Transaction.php" ); require_once( "Editor.php" ); require_once( "Controller.php" ); require_once( "type.php" ); require_once( "ViewInformation.php" ); initializeOmegaWikiAttributes( new ViewInformation() ); initializeAttributes(); @$fromTransactionId = (int) $_GET['from-transaction']; # FIXME - check parameter @$transactionCount = (int) $_GET['transaction-count']; # FIXME - check parameter @$userName = "" . $_GET['user-name']; # FIXME - check parameter @$showRollBackOptions = isset( $_GET['show-roll-back-options'] ); # FIXME - check parameter if ( isset( $_POST['roll-back'] ) ) { $fromTransactionId = (int) $_POST['from-transaction']; $transactionCount = (int) $_POST['transaction-count']; $userName = "" . $_POST['user-name']; if ( $fromTransactionId != 0 ) { $recordSet = getTransactionRecordSet( $fromTransactionId, $transactionCount, $userName ); rollBackTransactions( $recordSet ); $fromTransactionId = 0; $userName = ""; } } if ( $fromTransactionId == 0 ) $fromTransactionId = getLatestTransactionId(); if ( $transactionCount == 0 ) $transactionCount = 10; else $transactionCount = min( $transactionCount, 20 ); $wgOut->setPageTitle( wfMsg( 'recentchanges' ) ); $wgOut->addHTML( getFilterOptionsPanel( $fromTransactionId, $transactionCount, $userName, $showRollBackOptions ) ); if ( $showRollBackOptions ) $wgOut->addHTML( '<form method="post" action="">' . '<input type="hidden" name="from-transaction" value="' . $fromTransactionId . '"/>' . '<input type="hidden" name="transaction-count" value="' . $transactionCount . '"/>' . '<input type="hidden" name="user-name" value="' . $userName . '"/>' ); $recordSet = getTransactionRecordSet( $fromTransactionId, $transactionCount, $userName ); $wgOut->addHTML( getTransactionOverview( $recordSet, $showRollBackOptions ) ); if ( $showRollBackOptions ) $wgOut->addHTML( '<div class="option-panel">' . '<table cellpadding="0" cellspacing="0">' . '<tr>' . '<th>' . wfMsg( "summary" ) . ': </th>' . '<td class="option-field">' . getTextBox( "summary" ) . '</td>' . '</tr>' . '<tr><th/><td>' . getSubmitButton( "roll-back", wfMsg( 'ow_transaction_rollback_button' ) ) . '</td></tr>' . '</table>' . '</div>' . '</form>' ); $wgOut->addHTML( DefaultEditor::getExpansionCss() ); $wgOut->addHTML( "<script language='javascript'>/* <![CDATA[ */\nexpandEditors();\n/* ]]> */</script>" ); }
function getInputFieldForType( $name, $type, $value ) { global $wgDefinedMeaning; switch( $type ) { case "language": return getLanguageSelect( $name ); case "spelling": return getTextBox( $name, $value ); case "boolean": return getCheckBox( $name, $value ); case "$wgDefinedMeaning": case "defining-expression": return getSuggest( $name, $wgDefinedMeaning ); case "relation-type": return getSuggest( $name, "relation-type" ); case "attribute": return getSuggest( $name, "attribute" ); case "collection": return getSuggest( $name, "collection" ); case "short-text": return getTextBox( $name, $value ); case "text": return getTextArea( $name, $value ); } }
protected function outputEditFooter() { global $wgOut; $wgOut->addHTML( '<div class="option-panel">' . '<table cellpadding="0" cellspacing="0"><tr>' . '<th>' . wfMsg( "summary" ) . '</th>' . '<td class="option-field">' . getTextBox( "summary" ) . '</td>' . '</tr></table>' . getSubmitButton( "save", wfMsgSc( "save" ) ) . '</div>' ); $wgOut->addHTML( '</form>' ); $wgOut->addHTML( DefaultEditor::getExpansionCss() ); $wgOut->addHTML( "<script language='javascript'><!--\nexpandEditors();\n--></script>" ); }
protected function getDm( $dataset ) { global $wgRequest; $setname = "set_" . $dataset->getPrefix(); $rq = $wgRequest->getText( $setname ); $html = getTextBox( $setname, $rq ); return $html; }
public function add( IdStack $idPath ) { if ( $this->isAddField ) return getTextBox( $this->addId( $idPath->getId() ), "", $this->onChangeHandler ); else return ""; }