PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/baser/models/site_config.php

https://github.com/hashing/basercms
PHP | 145 lines | 68 code | 7 blank | 70 comment | 3 complexity | e55d81ea867e0ff182251771a0fa9983 MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. /* SVN FILE: $Id$ */
  3. /**
  4. * システム設定モデル
  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.models
  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. * Include files
  22. */
  23. /**
  24. * システム設定モデル
  25. *
  26. * @package baser.models
  27. */
  28. class SiteConfig extends AppModel {
  29. /**
  30. * クラス名
  31. *
  32. * @var string
  33. * @access public
  34. */
  35. var $name = 'SiteConfig';
  36. /**
  37. * ビヘイビア
  38. *
  39. * @var array
  40. * @access public
  41. */
  42. var $actsAs = array('BcCache');
  43. /**
  44. * データベース接続
  45. *
  46. * @var string
  47. * @access public
  48. */
  49. var $useDbConfig = 'baser';
  50. /**
  51. * バリデーション
  52. *
  53. * @var array
  54. * @access public
  55. */
  56. var $validate = array(
  57. 'formal_name' => array(
  58. 'rule' => array('notEmpty'),
  59. 'message' => 'Webサイト名を入力してください。',
  60. 'required' => true
  61. ),
  62. 'name' => array(
  63. 'rule' => array('notEmpty'),
  64. 'message' => 'Webサイトタイトルを入力してください。',
  65. 'required' => true
  66. ),
  67. 'email' => array(
  68. array( 'rule' => array('emails'),
  69. 'message' => '管理者メールアドレスの形式が不正です。'),
  70. array( 'rule' => array('notEmpty'),
  71. 'message' => '管理者メールアドレスを入力してください。')
  72. ),
  73. 'mail_encode' => array(
  74. 'rule' => array('notEmpty'),
  75. 'message' => "メール送信文字コードを入力してください。初期値は「ISO-2022-JP」です。",
  76. 'required' => true
  77. ),
  78. 'site_url' => array(
  79. 'rule' => array('notEmpty'),
  80. 'message' => "WebサイトURLを入力してください。",
  81. 'required' => true
  82. ),
  83. 'admin_ssl' => array(
  84. 'rule' => array('sslUrlExists'),
  85. 'message' => "管理画面をSSLで利用するには、SSL用のWebサイトURLを入力してください。"
  86. )
  87. );
  88. /**
  89. * テーマの一覧を取得する
  90. *
  91. * @return array
  92. * @access public
  93. */
  94. function getThemes() {
  95. $themes = array();
  96. $themedFolder = new Folder(VIEWS.'themed'.DS);
  97. $_themes = $themedFolder->read(true,true);
  98. foreach($_themes[0] as $theme) {
  99. $themes[$theme] = Inflector::camelize($theme);
  100. }
  101. $themedFolder = new Folder(WWW_ROOT.'themed'.DS);
  102. $_themes = array_merge($themes,$themedFolder->read(true,true));
  103. foreach($_themes[0] as $theme) {
  104. $themes[$theme] = Inflector::camelize($theme);
  105. }
  106. return $themes;
  107. }
  108. /**
  109. * コントロールソースを取得する
  110. *
  111. * @param string $field
  112. * @return mixed array | false
  113. * @access public
  114. */
  115. function getControlSource($field=null) {
  116. $controlSources['mode'] = array(-1=>'インストールモード',0=>'ノーマルモード',1=>'デバッグモード1',2=>'デバッグモード2',3=>'デバッグモード3');
  117. if(isset($controlSources[$field])) {
  118. return $controlSources[$field];
  119. }else {
  120. return false;
  121. }
  122. }
  123. /**
  124. * SSL用のURLが設定されているかチェックする
  125. *
  126. * @param mixed $check
  127. * @return boolean
  128. * @access public
  129. */
  130. function sslUrlExists($check) {
  131. $sslOn = $check[key($check)];
  132. if($sslOn && empty($this->data['SiteConfig']['ssl_url'])) {
  133. return false;
  134. }
  135. return true;
  136. }
  137. }
  138. ?>