streams/library/epub-meta/util.php
2017-11-21 14:30:26 -08:00

30 lines
883 B
PHP

<?php
function to_file($input){
$input = str_replace(' ','_',$input);
$input = str_replace('__','_',$input);
$input = str_replace(',_',',',$input);
$input = str_replace('_,',',',$input);
$input = str_replace('-_','-',$input);
$input = str_replace('_-','-',$input);
$input = str_replace(',','__',$input);
return $input;
}
function book_output($input){
$input = str_replace('__',',',$input);
$input = str_replace('_',' ',$input);
$input = str_replace(',',', ',$input);
$input = str_replace('-',' - ',$input);
list($author,$title) = explode('-',$input,2);
$author = trim($author);
$title = trim($title);
if(!$title){
$title = $author;
$author = '';
}
return '<span class="title">'.htmlspecialchars($title).'</span>'.
'<span class="author">'.htmlspecialchars($author).'</author>';
}