示例#1
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new BlogTemplatesModel();
     }
     return self::$instance;
 }
示例#2
0
 /**
  * テンプレートの切り替え
  */
 public function switchTemplate($blog_template, $blog_id)
 {
     $device_type = $blog_template['device_type'];
     // 使用テンプレートを更新
     $data = array();
     $data[Config::get('BLOG_TEMPLATE_COLUMN.' . $device_type)] = $blog_template['id'];
     // コメントの表示タイプをテンプレートから判断
     $reply_type = strstr($blog_template['html'], '<%comment_reply_body>') ? Config::get('BLOG_TEMPLATE.COMMENT_TYPE.REPLY') : Config::get('BLOG_TEMPLATE.COMMENT_TYPE.AFTER');
     // コメントの表示タイプを更新
     Model::load('BlogSettings')->updateReplyType($device_type, $reply_type, $blog_id);
     $ret = $this->updateById($data, $blog_id);
     if ($ret) {
         // 更新に成功した場合 現在のテンプレートを削除
         Model::load('BlogTemplates');
         $template_path = BlogTemplatesModel::getTemplateFilePath($blog_id, $device_type);
         is_file($template_path) && unlink($template_path);
         $css_path = BlogTemplatesModel::getCssFilePath($blog_id, $device_type);
         is_file($css_path) && unlink($css_path);
     }
     return $ret;
 }
示例#3
0
 /**
  * テンプレートを作成
  */
 public static function createPlugin($html, $blog_id, $id = 'preview')
 {
     // フォルダが存在しない場合作成
     $plugin_path = App::getPluginFilePath($blog_id, $id);
     $plugin_dir = dirname($plugin_path);
     if (!file_exists($plugin_dir)) {
         mkdir($plugin_dir, 0777, true);
     }
     // HTMLをPHPテンプレートに変換してテンプレートファイルの作成
     Model::load('BlogTemplates');
     $html = BlogTemplatesModel::convertFC2Template($html);
     file_put_contents($plugin_path, $html);
     chmod($plugin_path, 0777);
 }
示例#4
0
 /**
  * FC2用のテンプレートで表示処理を行う
  */
 private function fc2template($blog_id, $html = null, $css = null)
 {
     $device_type = $this->getDeviceType();
     Model::load('BlogTemplates');
     $templateFilePath = BlogTemplatesModel::getTemplateFilePath($blog_id, $device_type, $html);
     Debug::log('Blog Template[' . $templateFilePath . ']', false, 'log', __FILE__, __LINE__);
     if (!is_file($templateFilePath)) {
         // テンプレートファイルが生成されていなければ作成(CSSも同時に)
         Debug::log('Template does not exist! Create', false, 'log', __FILE__, __LINE__);
         $blog = $this->getBlog($blog_id);
         $templateId = $blog[Config::get('BLOG_TEMPLATE_COLUMN.' . $device_type)];
         BlogTemplatesModel::createTemplate($templateId, $blog_id, $device_type, $html, $css);
         Debug::log('Template generation completion', false, 'log', __FILE__, __LINE__);
     }
     // CSSのURL
     $this->set('css_link', BlogTemplatesModel::getCssUrl($blog_id, $device_type, $html));
     $this->layout = 'fc2_template.html';
     return $templateFilePath;
 }