3 * WordPressウィジェットHTML作成クラス
7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
9 * @package Magic3 Framework
10 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11 * @copyright Copyright 2006-2017 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
14 * @link http://www.magic3.org
19 const DEFAULT_POSITION = 'sidebar-1';
24 function __construct()
28 * WordPressモジュール用コンテンツ取得
30 * @param string $style 表示スタイル
31 * @param string $content ウィジェット出力
32 * @param string $title タイトル(空のときはタイトル非表示)
33 * @param array $attribs その他タグ属性
34 * @param array $paramsOther その他パラメータ
35 * @param array $pageDefParam 画面定義パラメータ
36 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
37 * @param string $widgetTag ウィジェット識別用タグ
38 * @return string モジュール出力
40 public function getModuleContents($style, $content, $title = '', $attribs = array(), $paramsOther = array(), $pageDefParam = array(), $templateVer = 0, $widgetTag = '')
42 global $wp_registered_sidebars;
45 $position = $pageDefParam['pd_position_id'];
48 $blockParam = $wp_registered_sidebars[$position];
49 if (empty($blockParam)) $blockParam = $wp_registered_sidebars[self::DEFAULT_POSITION]; // 存在しない場合はデフォルトを取得
51 // WordPress側から初期パラメータを取得できない場合は終了
52 if (empty($blockParam)) return $content;
55 if ($style == PageManager::WIDGET_STYLE_WORDPRESS){ // タイトルありの場合
56 if (!empty($title)) $content = $blockParam['before_title'] . convertToHtmlEntity($title) . $blockParam['after_title'] . $content;
60 // $content = $pageDefParam['pd_top_content'] . $content . $pageDefParam['pd_bottom_content'];
62 // if ($pageDefParam['pd_show_readmore']) $content = $this->addReadMore($content, $pageDefParam['pd_readmore_title'], $pageDefParam['pd_readmore_url']);
64 // コンテンツ全体をウィジェット用タグで囲む
65 $widgetClass = 'm3widget_' . $pageDefParam['pd_widget_id']; // ウィジェットIDからクラス名作成
66 $blockParam['before_widget'] = sprintf($blockParam['before_widget'], $widgetTag, $widgetClass); // ウィジェット識別用IDとウィジェットクラス名
67 $content = $blockParam['before_widget'] . $content . $blockParam['after_widget'];
72 * WordPressコンポーネント用コンテンツ取得
74 * @param string $style 表示スタイル
75 * @param string $content ウィジェット出力
76 * @param string $title タイトル(空のときはタイトル非表示)
77 * @param array $attribs その他タグ属性
78 * @param array $paramsOther その他パラメータ
79 * @param array $pageDefParam 画面定義パラメータ
80 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
81 * @param string $widgetTag ウィジェット識別用タグ
82 * @return string モジュール出力
84 public function getComponentContents($style, $content, $title = '', $attribs = array(), $paramsOther = array(), $pageDefParam = array(), $templateVer = 0, $widgetTag = '')
89 // コンポーネント生成用スクリプトパス取得
90 $componentPath = $gEnvManager->getWpComponentPath();
91 if (file_exists($componentPath)){
92 // ウィジェットで生成されたデータでWordPressコンポーネント用のデータを更新
93 $gContentApi->updateComponentContent($content);
96 require($componentPath); // 毎回実行する
97 $content = ob_get_contents();
100 // コンポーネント生成用スクリプトがない場合はWordPressモジュール出力を使用
101 $content = $this->getModuleContents($style, $content, $title, $attribs, $paramsOther, $pageDefParam, $templateVer, $widgetTag);