Fix multi author

FIx multi author bugs.
This commit is contained in:
Danang Probo Sayekti 2014-01-05 13:48:28 +07:00
commit 9e9ec3883b

View file

@ -405,36 +405,33 @@ function get_author($names, $author){
foreach($names as $index => $v){ foreach($names as $index => $v){
$post = new stdClass; $post = new stdClass;
// Extract the array // Extract the array
$arr = explode('_', $v); $arr = explode('_', $v);
// Replaced string // Replaced string
$replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/'; $replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/';
// Author string // Author string
$str = explode('/', $replaced); $str = explode('/', $replaced);
$profile = $str[count($str)-2]; $profile = $str[count($str)-2];
if($author === $profile){ if($author === $profile){
// Profile URL // Profile URL
$url = str_replace($replaced,'',$arr[0]); $url = str_replace($replaced,'',$arr[0]);
$post->url = site_url() . 'author/' . $profile; $post->url = site_url() . 'author/' . $profile;
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
$content = $md->transformMarkdown(file_get_contents($v)); $content = $md->transformMarkdown(file_get_contents($v));
// Extract the title and body // Extract the title and body
$arr = explode('</h1>', $content); $arr = explode('</h1>', $content);
$post->title = str_replace('<h1>','',$arr[0]); $post->title = str_replace('<h1>','',$arr[0]);
$post->body = $arr[1]; $post->body = $arr[1];
$tmp[] = $post; $tmp[] = $post;
} }
else {
not_found();
}
} }
return $tmp; return $tmp;
@ -450,7 +447,9 @@ function find_author($author){
// Use the get_spage method to return // Use the get_spage method to return
// a properly parsed object // a properly parsed object
$arr = get_author($names, $author); $arr = get_author($names, $author);
return $arr[0]; if (isset($arr[0])) {
return $arr[0];
}
} }
} }