Skip to content

Adds microformats2 export format #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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