OSDN Git Service

WordPressテンプレート機能更新。
authornaoki hirata <naoki@magic3.org>
Sun, 30 Jul 2017 13:25:14 +0000 (22:25 +0900)
committernaoki hirata <naoki@magic3.org>
Sun, 30 Jul 2017 13:25:14 +0000 (22:25 +0900)
include/manager/pageManager.php
include/sql/sample/blog_demo2.sql
include/wp/WPRender.php
include/wp/wp-includes/general-template.php

index a3b0b2c..0d3dd7c 100644 (file)
@@ -4546,7 +4546,12 @@ class PageManager extends Core
                                                        
                                                                // ウィジェット生成
                                                                $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . ($i + 1);                                // ウィジェット識別用ユニークタグ
-                                                               $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
+                                                               
+                                                               if (strcmp($position, 'main') == 0){// メイン部のとき
+                                                                       $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
+                                                               } else {
+                                                                       $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
+                                                               }
                                                        
                                                                // ウィジェット共通のコンテンツ処理
                                                        //      $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
index 4949f32..661d5a5 100644 (file)
@@ -24,9 +24,9 @@ DELETE FROM _site_def WHERE sd_id = 'site_slogan';
 DELETE FROM _site_def WHERE sd_id = 'head_title';
 INSERT INTO _site_def
 (sd_id,                  sd_language_id, sd_value,         sd_name) VALUES
-('site_name',            'ja',           'ブログサンプル',               'サイト名'),
+('site_name',            'ja',           'Magic3ブログサンプル',               'サイト名'),
 ('site_slogan',          'ja',           'WordPressテンプレートテスト中',               'スローガン'),
-('head_title',           'ja',           'ブログサンプル',               'HTMLヘッダtitle');
+('head_title',           'ja',           'Magic3ブログサンプル',               'HTMLヘッダtitle');
 
 -- 管理画面ページデータ(デフォルトを変更)
 UPDATE _page_id SET pg_default_sub_id = 'blog' WHERE pg_id = 'index' AND pg_type = 0;
index 432d876..402faf2 100644 (file)
@@ -26,7 +26,7 @@ class WPRender
        {
        }
        /**
-        * WordPressã\82¦ã\82£ã\82¸ã\82§ã\83\83ã\83\88用コンテンツ取得
+        * WordPressã\83¢ã\82¸ã\83¥ã\83¼ã\83«用コンテンツ取得
         * 
         * @param string $style                 表示スタイル
         * @param string $content               ウィジェット出力
@@ -67,6 +67,35 @@ class WPRender
                 
                return $content;
        }
-
+       /**
+        * WordPressコンポーネント用コンテンツ取得
+        * 
+        * @param string $style                 表示スタイル
+        * @param string $content               ウィジェット出力
+        * @param string $title                 タイトル(空のときはタイトル非表示)
+        * @param array $attribs                その他タグ属性
+        * @param array $paramsOther    その他パラメータ
+        * @param array $pageDefParam   画面定義パラメータ
+        * @param int   $templateVer    テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
+        * @param string $widgetTag             ウィジェット識別用タグ
+        * @return string                               モジュール出力
+        */
+       public function getComponentContents($style, $content, $title = '', $attribs = array(), $paramsOther = array(), $pageDefParam = array(), $templateVer = 0, $widgetTag = '')
+       {
+               global $gEnvManager;
+               
+               // コンポーネント生成用スクリプトパス取得
+               $componentPath = $gEnvManager->getWpComponentPath();
+               if (file_exists($componentPath)){
+                       ob_clean();
+                       require($componentPath);                // 毎回実行する
+                       $content = ob_get_contents();
+                       ob_clean();
+               } else {
+                       // コンポーネント生成用スクリプトがない場合はWordPressモジュール出力を使用
+                       $content = $this->getModuleContents($style, $content, $title, $attribs, $paramsOther, $pageDefParam, $templateVer, $widgetTag);
+               }
+               return $content;
+       }
 }
 ?>
index 1389a65..16b172f 100644 (file)
@@ -161,7 +161,7 @@ function get_template_part( $slug, $name = null ) {
                return;
        }*/
        
-       if ($wp_query->current_post == 0) echo $gPageManager->getWPContents('main-top');
+       if ($wp_query->in_the_loop && $wp_query->current_post == 0) echo $gPageManager->getWPContents('main-top');
        
        /**
         * Fires before the specified template part file is loaded.
@@ -185,7 +185,7 @@ function get_template_part( $slug, $name = null ) {
        // ##### メインエリア生成 #####
        // ページのコンテンツタイプが設定されていない場合はMagic3のレンダリング機能を使用する
        $contentType = $gContentApi->getContentType();
-       if (empty($contentType) && $wp_query->in_the_loop){                     // WordPressのメインループ内にある場合のみメイン部の処理と判断する
+       if ($wp_query->in_the_loop && empty($contentType)){                     // WordPressのメインループ内にある場合のみメイン部の処理と判断する
                $componentPath = locate_template($templates);
                
                // コンポーネント生成用スクリプトファイルを指定して、コンポーネントを生成
@@ -197,7 +197,7 @@ function get_template_part( $slug, $name = null ) {
        }
 
        // 一覧の最後のデータの場合
-       if ($wp_query->lastPostFound) echo $gPageManager->getWPContents('main-bottom');
+       if ($wp_query->in_the_loop && $wp_query->lastPostFound) echo $gPageManager->getWPContents('main-bottom');
 }
 
 /**