Esempio n. 1
0
	function formatValue( $name, $value ) {
		global $wgLang, $wgScriptPath;
		$critical = Xml::element( 'img', array( 
			'src' => "$wgScriptPath/extensions/SecurePoll/resources/critical-32.png" ) 
		);
		$voter = SecurePoll_Voter::newFromId( 
			$this->listPage->context, 
			$this->mCurrentRow->vote_voter
		);

		switch ( $name ) {
		case 'vote_timestamp':
			return $wgLang->timeanddate( $value );
		case 'vote_ip':
			return IP::formatHex( $value );
		case 'vote_cookie_dup':
			$value = !$value;
			// fall through
		case 'vote_token_match':
			if ( $value ) {
				return '';
			} else {
				return $critical;
			}
		case 'details':
			$voteId = intval( $this->mCurrentRow->vote_id );
			$title = $this->listPage->parent->getTitle( "details/$voteId" );
			return Xml::element( 'a', 
				array( 'href' => $title->getLocalUrl() ),
				wfMsg( 'securepoll-details-link' )
			);
			break;
		case 'strike':
			$voteId = intval( $this->mCurrentRow->vote_id );
			if ( $this->mCurrentRow->vote_struck ) {
				$label = wfMsg( 'securepoll-unstrike-button' );
				$action = "'unstrike'";
			} else {
				$label = wfMsg( 'securepoll-strike-button' );
				$action = "'strike'";
			}
			$id = 'securepoll-popup-' . $voteId;
			return Xml::element( 'input', 
				array( 
					'type' => 'button', 
					'id' => $id, 
					'value' => $label,
					'onclick' => "securepoll_strike_popup(event, $action, $voteId)"
				) );
		case 'vote_voter_name':
			$msg = $voter->isRemote()
				? 'securepoll-voter-name-remote'
				: 'securepoll-voter-name-local';
			return wfMsgExt(
				$msg,
				'parseinline',
				array( $value )
			);
		default:
			return htmlspecialchars( $value );
		}
	}
Esempio n. 2
0
	/**
	 * Create a voter object from the database
	 * @return SecurePoll_Voter or false if the ID is not valid
	 */
	function getVoter( $id ) {
		return SecurePoll_Voter::newFromId( $this, $id );
	}