PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/baser/plugins/blog/views/helpers/blog_baser.php

https://github.com/hashing/basercms
PHP | 95 lines | 49 code | 5 blank | 41 comment | 15 complexity | d93fe39ac976546cd89c575c2852524e MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. /* SVN FILE: $Id$ */
  3. /**
  4. * BlogBaserヘルパー
  5. *
  6. * PHP versions 5
  7. *
  8. * baserCMS : Based Website Development Project <http://basercms.net>
  9. * Copyright 2008 - 2012, baserCMS Users Community <http://sites.google.com/site/baserusers/>
  10. *
  11. * @copyright Copyright 2008 - 2012, baserCMS Users Community
  12. * @link http://basercms.net baserCMS Project
  13. * @package baser.plugins.blog.views.helpers
  14. * @since baserCMS v 0.1.0
  15. * @version $Revision$
  16. * @modifiedby $LastChangedBy$
  17. * @lastmodified $Date$
  18. * @license http://basercms.net/license/index.html
  19. */
  20. /**
  21. * BlogBaserヘルパー
  22. *
  23. * @package baser.plugins.blog.views.helpers
  24. *
  25. */
  26. class BlogBaserHelper extends AppHelper {
  27. /**
  28. * ブログ記事一覧出力
  29. * ページ編集画面等で利用する事ができる。
  30. * 利用例: <?php $bcBaser->blogPosts('news', 3) ?>
  31. * ビュー: app/webroot/themed/{テーマ名}/blog/{コンテンツテンプレート名}/posts.php
  32. *
  33. * @param int $contentsName
  34. * @param int $num
  35. * @param array $options
  36. * @param mixid $mobile '' / boolean
  37. * @return void
  38. * @access public
  39. */
  40. function blogPosts ($contentsName, $num = 5, $options = array()) {
  41. $_options = array(
  42. 'category' => null,
  43. 'tag' => null,
  44. 'year' => null,
  45. 'month' => null,
  46. 'day' => null,
  47. 'id' => null,
  48. 'keyword' => null,
  49. 'template' => null
  50. );
  51. $options = am($_options, $options);
  52. $BlogContent = ClassRegistry::init('Blog.BlogContent');
  53. $id = $BlogContent->field('id', array('BlogContent.name'=>$contentsName));
  54. $url = array('plugin'=>'blog','controller'=>'blog','action'=>'posts');
  55. $settings = Configure::read('BcAgent');
  56. foreach($settings as $key => $setting) {
  57. if(isset($options[$key])) {
  58. $agentOn = $options[$key];
  59. unset($options[$key]);
  60. } else {
  61. $agentOn = (Configure::read('BcRequest.agent') == $key);
  62. }
  63. if($agentOn){
  64. $url['prefix'] = $setting['prefix'];
  65. break;
  66. }
  67. }
  68. if(isset($options['templates'])) {
  69. $templates = $options['templates'];
  70. } else {
  71. $templates = 'posts';
  72. }
  73. unset ($options['templates']);
  74. echo $this->requestAction($url, array('return', 'pass' => array($id, $num, $templates), 'named' => $options));
  75. }
  76. /**
  77. * ブログのトップページ判定
  78. * @return boolean
  79. */
  80. function isBlogHome() {
  81. if(empty($this->params['plugin']) || empty($this->params['controller']) || empty($this->params['action'])) {
  82. return false;
  83. }
  84. if($this->params['plugin'] == 'blog' && $this->params['controller'] == 'blog' && $this->params['action'] == 'index') {
  85. return true;
  86. }
  87. return false;
  88. }
  89. }
  90. ?>