Index: trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php |
— | — | @@ -670,10 +670,12 @@ |
671 | 671 | //try the $sulightData array |
672 | 672 | if(isset($sulightData[ $dbKey ])){ |
673 | 673 | $page_body.= $name . '=' . $sulightData[ $dbKey ]."| \n"; |
674 | | - }else{ |
675 | | - if ( trim( $person->$dbKey ) != '' ) { |
676 | | - if ( $dbKey == 'state' ) $person->state = $states_ary[$person->state]; |
677 | | - $page_body .= "{$name}={$person->$dbKey}| \n"; |
| 674 | + }else{ |
| 675 | + if( isset($person->$dbKey) ){ |
| 676 | + if ( trim( $person->$dbKey ) != '' ) { |
| 677 | + if ( $dbKey == 'state' ) $person->state = $states_ary[$person->state]; |
| 678 | + $page_body .= "{$name}={$person->$dbKey}| \n"; |
| 679 | + } |
678 | 680 | } |
679 | 681 | } |
680 | 682 | } |
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialExport.php |
— | — | @@ -356,7 +356,7 @@ |
357 | 357 | <' . $ns . 'clip id="mvd_' . htmlentities( $mvd->id ) . '" start="npt:' . htmlentities( seconds2ntp( $mvd->start_time ) ) . '" end="npt:' . htmlentities( seconds2ntp( $mvd->end_time ) ) . '"> |
358 | 358 | <' . $ns . 'img src="' . htmlentities( $streamTitle->getFullStreamImageURL( null, seconds2ntp( $mvd->start_time ) ) ) . '"/>'; |
359 | 359 | // output all metadata @@todo we should generalize the semantic properties. |
360 | | - $tracks[$mvd->mvd_type] .= ( isset( $mvd->Speech_by ) && trim( $mvd->Speech_by ) != '' ) ? '<meta name="Speech_by" content="' . htmlentities ( htmlspecialchars( $mvd->Speech_by ) ) . '"/>':''; |
| 360 | + $tracks[$mvd->mvd_type] .= ( isset( $mvd->Speech_by ) && trim( $mvd->Speech_by ) != '' ) ? '<meta name="Speech_by" content="' . htmlentities ( $mvd->Speech_by ) . '"/>':''; |
361 | 361 | $tracks[$mvd->mvd_type] .= ( isset( $mvd->Bill ) && trim( $mvd->Bill ) != '' ) ? '<meta name="Bill" content="' . htmlentities( $mvd->Bill ) . '"/>':''; |
362 | 362 | |
363 | 363 | // add in categories as "keywords" |
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php |
— | — | @@ -1107,6 +1107,10 @@ |
1108 | 1108 | } |
1109 | 1109 | function auto_complete_category( $category, $val, $result_limit = '5', $format = 'ac_line', & $match_count = '' ) { |
1110 | 1110 | $dbr = & wfGetDB( DB_SLAVE ); |
| 1111 | + //do value pre-proccessing if bill type: |
| 1112 | + if($category=='Bill') |
| 1113 | + $val = MV_SpecialMediaSearch::bill_formater( $val ); |
| 1114 | + |
1111 | 1115 | $result = $dbr->select( 'categorylinks', 'cl_sortkey', array ( |
1112 | 1116 | 'cl_to' => $category, |
1113 | 1117 | '`cl_sortkey` LIKE \'%' . mysql_escape_string( $val |
— | — | @@ -1123,37 +1127,39 @@ |
1124 | 1128 | $out .= MV_SpecialMediaSearch :: format_ac_line( $row->cl_sortkey, $val, '', 'no_image', $format ); |
1125 | 1129 | } |
1126 | 1130 | return $out; |
1127 | | - } |
| 1131 | + } |
1128 | 1132 | /*@@todo cache result for given values*/ |
1129 | 1133 | function auto_complete_person( $val, $result_limit = '5', $format = 'ac_line', & $match_count = '', & $person_ary = array() ) { |
1130 | 1134 | $dbr = & wfGetDB( DB_SLAVE ); |
| 1135 | + |
| 1136 | + //first check the nick names: |
| 1137 | + $nick_rows = MV_SpecialMediaSearch::getViaNickname($val, $result_limit); |
| 1138 | + foreach($nick_rows as $person){ |
| 1139 | + $person_ary[$person]=true; |
| 1140 | + } |
| 1141 | + |
1131 | 1142 | $result = $dbr->select( 'categorylinks', 'cl_sortkey', array ( |
1132 | 1143 | 'cl_to' => 'Person', |
1133 | 1144 | '`cl_sortkey` LIKE \'%' . mysql_escape_string( $val |
1134 | 1145 | ) . '%\' COLLATE latin1_general_ci' ), __METHOD__, array ( |
1135 | 1146 | 'LIMIT' => $result_limit |
1136 | | - ) ); |
1137 | | - $match_count = $dbr->numRows( $result ); |
1138 | | - if ( $dbr->numRows( $result ) == 0 ) |
1139 | | - return ''; |
1140 | | - // $out='<ul>'."\n"; |
| 1147 | + ) ); |
1141 | 1148 | $out = ''; |
1142 | 1149 | while ( $row = $dbr->fetchObject( $result ) ) { |
1143 | 1150 | $person_name = $row->cl_sortkey; |
1144 | 1151 | $person_ary[$person_name] = true; |
| 1152 | + } |
| 1153 | + |
| 1154 | + if(count($person_ary)==0) |
| 1155 | + return ''; |
| 1156 | + |
| 1157 | + |
| 1158 | + foreach($person_ary as $person_name=>$na){ |
1145 | 1159 | // make sure the person page exists: |
1146 | 1160 | $personTitle = Title :: makeTitle( NS_MAIN, $person_name ); |
1147 | 1161 | if ( $personTitle->exists() ) { |
1148 | | - // get person full name from semantic table if available |
1149 | | - $person_result = $dbr->select( 'smw_attributes', 'value_xsd', array ( |
1150 | | - 'attribute_title' => 'Full_Name', |
1151 | | - 'subject_title' => $personTitle->getDBkey() ), __METHOD__ ); |
1152 | | - if ( $dbr->numRows( $person_result ) == 0 ) { |
1153 | | - $person_full_name = $person_name; |
1154 | | - } else { |
1155 | | - $pvalue = $dbr->fetchObject( $person_result ); |
1156 | | - $person_full_name = $pvalue->value_xsd; |
1157 | | - } |
| 1162 | + // dont try and get person full name from semantic table if available |
| 1163 | + $person_full_name = $person_name; |
1158 | 1164 | // format and output the line: |
1159 | 1165 | $out .= MV_SpecialMediaSearch :: format_ac_line( $person_full_name, $val, '', MV_SpecialMediaSearch :: getPersonImageURL( $person_name ), $format ); |
1160 | 1166 | } |
— | — | @@ -1162,6 +1168,24 @@ |
1163 | 1169 | // return people people in the Person Category |
1164 | 1170 | return $out; |
1165 | 1171 | } |
| 1172 | + //returns results via nickname via semantic query: |
| 1173 | + function getViaNickname($partname, $limit=5){ |
| 1174 | + $query_string = '[[Nickname::~*'.ucfirst($partname).'*]] OR [[Nickname::'.ucfirst($partname).']]'; |
| 1175 | + $params=array('format' => 'broadtable', |
| 1176 | + 'offset' => 0, |
| 1177 | + 'limit' =>$limit); |
| 1178 | + $results = array(); |
| 1179 | + $queryobj = SMWQueryProcessor::createQuery($query_string, $params, false, '', array()); |
| 1180 | + $queryobj->querymode = SMWQuery::MODE_INSTANCES; |
| 1181 | + $res = smwfGetStore()->getQueryResult($queryobj); |
| 1182 | + |
| 1183 | + for($i=0;$i< $res->getCount();$i++){ |
| 1184 | + $v = $res->getNext(); |
| 1185 | + $v = current(current($v)->getContent()); |
| 1186 | + array_push( $results,$v->getXSDValue()); |
| 1187 | + } |
| 1188 | + return $results; |
| 1189 | + } |
1166 | 1190 | function getPersonImageURL( $person_name ) { |
1167 | 1191 | // make the missing person image ref: |
1168 | 1192 | $imgTitle = Title :: makeTitle( NS_IMAGE, $person_name . '.jpg' ); |
— | — | @@ -1175,6 +1199,12 @@ |
1176 | 1200 | } |
1177 | 1201 | return $img->getURL(); |
1178 | 1202 | } |
| 1203 | + function bill_formater($val){ |
| 1204 | + $val = preg_replace('/[Ss]\.?\s?([0-9])/','S._$1',$val); |
| 1205 | + $val = preg_replace('/[Hh]\.?[Rr]\.?\s?([0-9])/','H.R._$1',$val); |
| 1206 | + $val = preg_replace('/[Hh][Rr][Ee][Ss]\.?\s?([0-9])/','HRes._$1',$val); |
| 1207 | + return $val; |
| 1208 | + } |
1179 | 1209 | function format_ac_line( & $page_title, $val, $prefix = '', $img_link = 'no_image', $format = 'ac_line' ) { |
1180 | 1210 | // no underscores in display title: |
1181 | 1211 | $page_title_disp = str_replace( '_', ' ', $page_title ); |