コード例 #1
0
ファイル: blogBlog.class.php プロジェクト: Lazary/webasyst
 static function getUrl($blog = null, $absolute = false)
 {
     $params = array();
     $blog_id = isset($blog['id']) ? $blog['id'] : null;
     if ($blog && isset($blog['url']) && $blog['url']) {
         $params['blog_url'] = $blog['url'];
     } elseif ($blog) {
         $params['blog_url'] = '%blog_url%';
     }
     return blogHelper::getUrl($blog_id, 'blog/frontend', $params, $absolute);
 }
コード例 #2
0
ファイル: blogPost.class.php プロジェクト: Lazary/webasyst
 static function getUrl($post, $type = 'post')
 {
     if ($type == 'post' && !empty($post['album_id']) && $post['album_link_type'] == 'photos') {
         wa('photos');
         if (empty($post['album']['full_url'])) {
             $album_full_url = photosCollection::frontendAlbumHashToUrl('album/' . $post['album_id']);
         } else {
             $album_full_url = $post['album']['full_url'];
         }
         $url = photosFrontendAlbum::getLink($album_full_url);
         if (wa()->getEnv() == 'backend') {
             return array($url);
         } else {
             return $url;
         }
     }
     static $blog_urls = array();
     $params = array();
     $fields = array('blog_url', 'year', 'month', 'day');
     foreach ($fields as $field) {
         if (isset($post[$field])) {
             $params[$field] = $post[$field];
         }
     }
     if (isset($post['id']) && $post['id'] && isset($post['url']) && $post['url']) {
         $params['post_url'] = $post['url'];
     } elseif ($type != 'timeline') {
         $params['post_url'] = '%post_url%';
     }
     $blog_id = null;
     if ($type != 'author') {
         if (isset($post['datetime']) && $post['datetime'] && ($time = date_parse($post['datetime']))) {
             $params['post_year'] = sprintf('%04d', $time['year']);
             $params['post_month'] = sprintf('%02d', $time['month']);
             $params['post_day'] = sprintf('%02d', $time['day']);
         } elseif ($type != 'timeline') {
             $params['post_year'] = '%year%';
             $params['post_month'] = '%month%';
             $params['post_day'] = '%day%';
         }
         if (!isset($params['blog_url']) && isset($post['blog_id'])) {
             $blog_id = $post['blog_id'];
             if (!isset($blog_urls[$blog_id])) {
                 $blog_urls[$blog_id] = false;
                 $blog_model = new blogBlogModel();
                 if ($blog_data = $blog_model->getById($blog_id)) {
                     if ($blog_data['status'] == blogBlogModel::STATUS_PUBLIC) {
                         if (strlen($blog_data['url'])) {
                             $blog_urls[$blog_id] = $blog_data['url'];
                         } else {
                             $blog_urls[$blog_id] = $blog_id;
                         }
                     }
                 }
             }
             $params['blog_url'] = $blog_urls[$blog_id];
         } elseif (isset($params['blog_url']) && isset($post['blog_id'])) {
             $blog_id = $post['blog_id'];
         }
     }
     $route = false;
     if (!isset($params['blog_url']) || $params['blog_url'] !== false) {
         switch ($type) {
             case 'comment':
                 $route = 'blog/frontend/comment';
                 break;
             case 'timeline':
                 $route = 'blog/frontend';
                 break;
             case 'author':
                 if ($params['contact_id'] = $post['contact_id']) {
                     $route = 'blog/frontend';
                 }
                 break;
             case 'post':
             default:
                 $route = 'blog/frontend/post';
                 break;
         }
     }
     return $route ? blogHelper::getUrl($blog_id, $route, $params) : array();
 }
コード例 #3
0
 static function getUrl($post, $type = 'post')
 {
     static $blog_urls = array();
     $params = array();
     $fields = array('blog_url', 'year', 'month', 'day');
     foreach ($fields as $field) {
         if (isset($post[$field])) {
             $params[$field] = $post[$field];
         }
     }
     if (isset($post['id']) && $post['id'] && isset($post['url']) && $post['url']) {
         $params['post_url'] = $post['url'];
     } elseif ($type != 'timeline') {
         $params['post_url'] = '%post_url%';
     }
     $blog_id = null;
     if ($type != 'author') {
         if (isset($post['datetime']) && $post['datetime'] && ($time = date_parse($post['datetime']))) {
             $params['post_year'] = sprintf('%04d', $time['year']);
             $params['post_month'] = sprintf('%02d', $time['month']);
             $params['post_day'] = sprintf('%02d', $time['day']);
         } elseif ($type != 'timeline') {
             $params['post_year'] = '%year%';
             $params['post_month'] = '%month%';
             $params['post_day'] = '%day%';
         }
         if (!isset($params['blog_url']) && isset($post['blog_id'])) {
             $blog_id = $post['blog_id'];
             if (!isset($blog_urls[$blog_id])) {
                 $blog_urls[$blog_id] = false;
                 $blog_model = new blogBlogModel();
                 if ($blog_data = $blog_model->getById($blog_id)) {
                     if ($blog_data['status'] == blogBlogModel::STATUS_PUBLIC) {
                         if (strlen($blog_data['url'])) {
                             $blog_urls[$blog_id] = $blog_data['url'];
                         } else {
                             $blog_urls[$blog_id] = $blog_id;
                         }
                     }
                 }
             }
             $params['blog_url'] = $blog_urls[$blog_id];
         } elseif (isset($params['blog_url']) && isset($post['blog_id'])) {
             $blog_id = $post['blog_id'];
         }
     }
     $route = false;
     if (!isset($params['blog_url']) || $params['blog_url'] !== false) {
         switch ($type) {
             case 'comment':
                 $route = 'blog/frontend/comment';
                 break;
             case 'timeline':
                 $route = 'blog/frontend';
                 break;
             case 'author':
                 if ($params['contact_id'] = $post['contact_id']) {
                     $route = 'blog/frontend';
                 }
                 break;
             case 'post':
             default:
                 $route = 'blog/frontend/post';
                 break;
         }
     }
     return $route ? blogHelper::getUrl($blog_id, $route, $params) : array();
 }