function smarty_function_mtblogarchiveurl($args, &$ctx)
{
    if (isset($args['id']) && is_numeric($args['id'])) {
        require_once 'class.mt_blog.php';
        $blog = new Blog();
        $ret = $blog->Load('blog_id = ' . $args['id']);
        if (!$ret) {
            $blog = null;
        }
    }
    if (empty($blog)) {
        $blog = $ctx->stash('blog');
    }
    if (empty($blog)) {
        return '';
    }
    $url = $blog->archive_url();
    if ($url == '') {
        $url = $blog->site_url();
    }
    if (!preg_match('/\\/$/', $url)) {
        $url .= '/';
    }
    return $url;
}
function smarty_function_mtwebsiterelativeurl($args, &$ctx)
{
    // status: complete
    // parameters: none
    if (isset($args['id']) && is_numeric($args['id'])) {
        require_once 'class.mt_website.php';
        $website = new Blog();
        $ret = $website->Load('blog_id = ' . $args['id']);
        if (!$ret) {
            $website = null;
        }
    } else {
        $blog = $ctx->stash('blog');
        if (empty($blog)) {
            return '';
        }
        $website = $blog->is_blog() ? $blog->website() : $blog;
    }
    if (empty($website)) {
        return '';
    }
    $host = $website->site_url();
    if (!preg_match('!/$!', $host)) {
        $host .= '/';
    }
    if (preg_match('!^https?://[^/]+(/.*)$!', $host, $matches)) {
        return $matches[1];
    } else {
        return '';
    }
}
function smarty_function_mtwebsitepath($args, &$ctx)
{
    if (isset($args['id']) && is_numeric($args['id'])) {
        require_once 'class.mt_website.php';
        $blog = new Blog();
        $ret = $blog->Load('blog_id = ' . $args['id']);
        if (!$ret) {
            $blog = null;
        }
    }
    if (empty($blog)) {
        $blog = $ctx->stash('blog');
    }
    if (empty($blog)) {
        return '';
    }
    $website = $blog->is_blog() ? $blog->website() : $blog;
    if (empty($website)) {
        return '';
    }
    $path = $website->site_path();
    if (!preg_match('!/$!', $path)) {
        $path .= '/';
    }
    return $path;
}
function smarty_function_mtwebsiteurl($args, &$ctx)
{
    // status: complete
    // parameters: none
    if (isset($args['id']) && is_numeric($args['id'])) {
        require_once 'class.mt_website.php';
        $blog = new Blog();
        $ret = $blog->Load('blog_id = ' . $args['id']);
        if (!$ret) {
            $blog = null;
        }
    }
    if (empty($blog)) {
        $blog = $ctx->stash('blog');
    }
    if (empty($blog)) {
        return '';
    }
    $website = $blog->is_blog() ? $blog->website() : $blog;
    if (empty($website)) {
        return '';
    }
    $url = $website->site_url();
    if (!preg_match('!/$!', $url)) {
        $url .= '/';
    }
    return $url;
}
Exemplo n.º 5
0
 public function fetch_blog($blog_id)
 {
     if (!empty($this->_blog_id_cache) && isset($this->_blog_id_cache[$blog_id])) {
         return $this->_blog_id_cache[$blog_id];
     }
     require_once 'class.mt_blog.php';
     $blog = new Blog();
     $blog->Load("blog_id = {$blog_id}");
     $this->_blog_id_cache[$blog_id] = $blog;
     return $blog;
 }
 public function blog()
 {
     $col_name = $this->_prefix . "blog_id";
     $blog = null;
     if (isset($this->{$col_name}) && is_numeric($this->{$col_name})) {
         $blog_id = $this->{$col_name};
         $blog = $this->load_cache($this->_prefix . ":" . $this->id . ":blog:" . $blog_id);
         if (empty($blog)) {
             require_once 'class.mt_blog.php';
             $blog = new Blog();
             $blog->Load("blog_id = {$blog_id}");
         }
     }
     if ($blog->class == 'website') {
         require_once 'class.mt_website.php';
         $blog = new Website();
         $blog->Load("blog_id = {$blog_id}");
     }
     if (!empty($blog)) {
         $this->cache($this->_prefix . ":" . $this->id . ":blog:" . $blog->id, $blog);
     }
     return $blog;
 }