protected function runQuery( $params, $contName, $resName, $pageIdName = 'pageid', $cont = true ) {
		$pages = new Pages();
		$negativeId = -1;

		do {
			// Set up continue parameter if it's been set already.
			if ( isset( $result['continue'][$contName] ) ) {
				$params[$contName] = $result['continue'][$contName];
			}

			// Run the actual query.
			$result = $this->api->getRequest( new SimpleRequest( 'query', $params ) );
			if ( !array_key_exists( 'query', $result ) ) {
				return $pages;
			}

			// Add the results to the output page list.
			foreach ( $result['query'][$resName] as $member ) {
				// Assign negative pageid if page is non-existent.
				if ( !array_key_exists( $pageIdName, $member ) ) {
					$member[$pageIdName] = $negativeId;
					$negativeId = $negativeId - 1;
				}

				$pageTitle = new Title( $member['title'], $member['ns'] );
				$page = new Page( new PageIdentifier( $pageTitle, $member[$pageIdName] ) );
				$pages->addPage( $page );
			}

		} while ( $cont && isset( $result['continue'] ) );

		return $pages;
	}