OSDN Git Service

WordPressテンプレート機能更新。
authornaoki hirata <naoki@magic3.org>
Sun, 18 Jun 2017 03:52:17 +0000 (12:52 +0900)
committernaoki hirata <naoki@magic3.org>
Sun, 18 Jun 2017 03:52:17 +0000 (12:52 +0900)
include/container/baseFrameContainer.php
include/wp/contentApi.php
include/wp/wp-includes/link-template.php
include/wp/wp-includes/template.php

index 0f3f890..9f1804b 100644 (file)
@@ -630,6 +630,8 @@ class BaseFrameContainer extends Core
         */
        function _createPage($request, $curTemplate, $subTemplateId = '')
        {
+               $defaultIndexFile = 'index.php';                        // テンプレートの起動ファイル
+               
                $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);               // 実行コマンドを取得
                
                // カレントのテンプレートIDを設定
@@ -750,6 +752,41 @@ class BaseFrameContainer extends Core
                        do_action('after_setup_theme');
                        do_action('wp_loaded');
                        wp();
+                       
+                       // ##### 起動ページを設定 #####
+                       // URLパラメータからコンテンツ形式を取得し、ページを選択
+                       $params = $this->gRequest->getQueryArray();
+                       $paramCount = count($params);
+                       reset($params);
+                       $firstKey = key($params);
+                       $firstValue = $params[$firstKey];
+                       
+                       $contentType = $GLOBALS['gContentApi']->getContentType();
+                       switch ($contentType){
+                       case M3_VIEW_TYPE_CONTENT:              // 汎用コンテンツ
+                               if ($firstKey == M3_REQUEST_PARAM_CONTENT_ID || $firstKey == M3_REQUEST_PARAM_CONTENT_ID_SHORT){        // コンテンツIDのとき
+                                       $defaultIndexFile = get_page_template();
+                               }
+                               break;
+                       case M3_VIEW_TYPE_PRODUCT:      // 製品
+                               break;
+                       case M3_VIEW_TYPE_BBS:  // BBS
+                               break;
+                       case M3_VIEW_TYPE_BLOG: // ブログ
+                               if ($firstKey == M3_REQUEST_PARAM_BLOG_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ID_SHORT ||                     // ブログIDのとき
+                                       $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT){              // ブログ記事IDのとき
+                                       $defaultIndexFile = get_page_template();
+                               }
+                               break;
+                       case M3_VIEW_TYPE_WIKI: // Wiki
+                               break;
+                       case M3_VIEW_TYPE_USER: // ユーザ作成コンテンツ
+                               break;
+                       case M3_VIEW_TYPE_EVENT:        // イベント
+                               break;
+                       case M3_VIEW_TYPE_PHOTO:        // フォトギャラリー
+                               break;
+                       }
                } else if ($convType >= 1){             // Joomla!v1.5,v2.5テンプレートのとき
                        global $mainframe;
                        require_once($this->gEnv->getJoomlaRootPath() . '/mosDef.php');// Joomla定義読み込み
@@ -816,7 +853,8 @@ class BaseFrameContainer extends Core
 
                // ################### テンプレート読み込み ###################
                // テンプレートのポジションタグからウィジェットが実行される
-               $templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplate . '/index.php';
+               //$templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplate . '/index.php';
+               $templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplate . '/' . $defaultIndexFile;
                if (file_exists($templateIndexFile)){
                        require_once($templateIndexFile);
                } else {                // テンプレートが存在しないとき
index e154a26..d8e2b0e 100644 (file)
@@ -389,5 +389,14 @@ class ContentApi
                $url = $linkInfoObj->getContentUrl($gEnvManager->getAccessDir()/*アクセスポイント*/, $this->contentType, $id, $this->langId);
                return $url;
        }
+       /**
+        * コンテンツタイプを取得
+        *
+        * @return string                                               コンテンツタイプ
+        */
+       function getContentType()
+       {
+               return $this->contentType;
+       }
 }
 ?>
index 4ca7b89..aaba35e 100644 (file)
@@ -223,7 +223,9 @@ function get_permalink( $post = 0, $leavename = false ) {
                $permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) );
                $permalink = user_trailingslashit($permalink, 'single');
        } else { // if they're not using the fancy permalink option
-               $permalink = home_url('?p=' . $post->ID);
+//             $permalink = home_url('?p=' . $post->ID);
+               // 詳細画面へのURL
+               $permalink = $post->guid;
        }
 
        /**
index 636cb90..d61a90e 100644 (file)
@@ -38,7 +38,7 @@ function get_query_template( $type, $templates = array() ) {
         *
         * @param array $templates A list of template candidates, in descending order of priority.
         */
-       $templates = apply_filters( "{$type}_template_hierarchy", $templates );
+//     $templates = apply_filters( "{$type}_template_hierarchy", $templates );
 
        $template = locate_template( $templates );
 
@@ -627,7 +627,7 @@ function locate_template($template_names, $load = false, $require_once = true )
        foreach ( (array) $template_names as $template_name ) {
                if ( !$template_name )
                        continue;
-               if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
+/*             if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
                        $located = STYLESHEETPATH . '/' . $template_name;
                        break;
                } elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
@@ -636,13 +636,18 @@ function locate_template($template_names, $load = false, $require_once = true )
                } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {
                        $located = ABSPATH . WPINC . '/theme-compat/' . $template_name;
                        break;
+               }*/
+               if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
+                       $located = TEMPLATEPATH . '/' . $template_name;
+                       break;
                }
        }
 
        if ( $load && '' != $located )
                load_template( $located, $require_once );
 
-       return $located;
+//     return $located;
+       return basename($located);                              // Magic3仕様変更
 }
 
 /**