diff options
Diffstat (limited to 'library/epub-meta/util.php')
-rw-r--r-- | library/epub-meta/util.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/library/epub-meta/util.php b/library/epub-meta/util.php new file mode 100644 index 000000000..75cb8a829 --- /dev/null +++ b/library/epub-meta/util.php @@ -0,0 +1,30 @@ +<?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>'; +} |