Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions formats/mf2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

class MF2Format implements Format {
public $title = 'mf2';
public $mime = 'text/html';
public $ext = 'html';

public function export( $data ) {
$out = '';
foreach( $data['objs'] as $obj ) {
// Skip polygons and lines since they don't have a good microformats representation
if( count($obj['coords']) == 1 ) {
foreach( $obj['coords'] as $coord ) {
$out .= '<p class="h-geo">' . "\n";
if( isset($obj['text']) ) {
$out .= "\t" . '<span class="p-name p-summary">' . htmlspecialchars($obj['text']) . '</span>' . "\n";
}
$out .= "\t" . '<data class="p-latitude">' . $coord[0] . '</data>' . "\n";
$out .= "\t" . '<data class="p-longitude">' . $coord[1] . '</data>' . "\n";
$out .= '</p>' . "\n";
}
}
}
return $out;
}

public function test( $header ) {
return false;
}

public function import( $file ) {
}
}

$formats['mf2'] = new MF2Format();
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
}
}

if( isset($_REQUEST['format']) && preg_match('/^[a-z]+$/', $_REQUEST['format']) ) {
if( isset($_REQUEST['format']) && preg_match('/^[a-z0-9]+$/', $_REQUEST['format']) ) {
$format = $_REQUEST['format'];
header('Access-Control-Allow-Origin: *');
$result = export($format, $title, $bbcode, isset($scodeid) ? $scodeid : '', !isset($_REQUEST['direct']));
Expand Down