$cat
以上
$cat
以上
再インストールした時に起こる問題のようだ。クッキーを削除したら動作するようになった。
なんでもDrupalのSNSモジュールはすごいらしい。
インストールに使用する言語を設定するらしい。
インストールできる状態かチェックしてくれる。自分はファイル(ディレクトリ)のアクセス権の設定をするように注意された。
インストールするデータベースを選択する。1つのデータベースで複数のアプリケーションをインストールする場合は、高度なオプションのテーブルプリフィクスに適切な文字列を指定して、テーブルの名前に任意の文字列を付加することを勧める。これにより他のアプリケーションがテーブルに変更を加えてしまうことを防げる。
「サイトの名前」「管理者名」「管理者パスワード」などを設定する。下の方の「クリーンURL」というのはクエリ形式のURL(?q=about&p=123)を検索エンジンフレンドリーなもの(/about/123)にするというものだ。ちなみに前述の変更したアクセス権をこのフェーズで戻してあげる。
永遠のテーマ!?、CMSは何を選ぶべきなのか?という問題を考えるために今回Joomlaをインストールしてみることにした。
はじめに言語を選択する。ここでは普通に日本語を選択することにする。
サーバの設定がJoomla!のインストールに適しているか確認してくれる。自分の場合は、「configureファイルの書き込み」と「mbstring.language」の設定でエラーが出た。素晴らしいのはphp_value mbstring.language neutralと,htaccessに記述するように教えてくれるところなのだが、サーバによってはphp.iniを変更する必要があることにまで触れてくれればパーフェクトであった。
Joomla! is Free Software released under the GNU/GPL License.要はGNU/GPLライセンスの下で配布されているということ。GPLでライセンスされた著作物は、その派生的著作物に関してもGPLでライセンスされなければならないということだけ覚えておけば問題になることはないだろう。
ユーザ名とパスワード、DB名を入力する必要がある。但し、いくつものアプリケーションを1つのデータベースで運用している場合は、拡張設定をクリックしテーブルプリフィクスを設定し、生成される各テーブル名に特異な文字列を付加した方がイイかもしれない。
Joomla自体がFTPアクセスを使用する場合には設定する必要がある。今は必要ないので「いいえ」を選択した。
基本的には「サイト名」「E-mailアドレス」「管理者パスワード」の設定でOKだ。
これで基本的にはインストールが完了である。数々見てきたCMSの中でも、かなり良くできているグループに入るっといえる。
OpenPNE3では、Webアプリケーションフレームワークであるsymfonyを採用しているため、これがインストールされていないと動かない。更に、symfonyのバージョンは1.2系でなければならない。
wgetでも構わないがクライアントに一旦ダウンロードしてみる。
解凍すると以下のディレクトリとファイルができる。
「web」ディレクトリが公開ディレクトリとなるように設定を各自変更する必要がある。以下の「プログラム側設定ファイル」か「サーバの設定ファイル」のどちらかを変更しなくてはならない。どちらかというと「web」というディレクトリ名で運用しているサーバは少なかった(個人的な経験)。
以下の変更例は、「web」を「public_html」に変更する場合である。
<?php # FROZEN_SF_LIB_DIR: /private/tmp/symfony/lib require_once dirname(__FILE__).'/../lib/symfony/autoload/sfCoreAutoload.class.php'; sfCoreAutoload::register(); class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enableAllPluginsExcept(array('sfCompat10Plugin')); $this->setIncludePath(); } public function setIncludePath() { sfToolkit::addIncludePath(array( //PEAR dirname(__FILE__).'/../lib/vendor/PEAR/', )); } }
上述を以下のように変更する。
<?php # FROZEN_SF_LIB_DIR: /private/tmp/symfony/lib require_once dirname(__FILE__).'/../lib/symfony/autoload/sfCoreAutoload.class.php'; sfCoreAutoload::register(); class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enableAllPluginsExcept(array('sfCompat10Plugin')); $this->setIncludePath(); $this->setWebDir($this->getRootDir() . '/public_html'); } public function setIncludePath() { sfToolkit::addIncludePath(array( //PEAR dirname(__FILE__).'/../lib/vendor/PEAR/', )); } }
追記部分は以下のコードである。
$this->setWebDir($this->getRootDir() . '/public_html');
httpd.confファイルなどに以下のような記述が存在するはずだ。
DocumentRoot /var/www/sample.com/public_html
以下のように変更して、サーバを再起動する。
DocumentRoot /var/www/sample.com/web
「web」ディレクトリが公開ディレクトリとなるようにする。つまり、「web」フォルダの中の「index.php」が(公開ディレクトリの)トップページとなるような配置にしなければならない。
ファイルをアップロードしたディレクトリにある「symfony」と同じ階層までコマンドラインで移動する。そして以下のコマンドを実行する。
./symfony openpne:install
以下の項目について質問される。
足りないパッケージなどなければ通常はこれで上手くいく。
http://sample.com/pc_backend.phpにアクセスして初期パスワード「password」を必ず変更する。
http://example.com/index.phpにアクセスして初期ユーザーのパスワード「password」を必ず変更する。
WordPress MUで、表示中以外のブログを含めたサイト全体の新着ブログを表示するプラグインです。デフォルトのWordPress MUではできませんが、このプラグインを使えば可能になります。
みなさまのお問い合わせやバグの指摘などから「正しい動作の実現」や「機能の追加」ができ、大変ありがたい限りです。是非とも、遠慮なくコメント欄でお問い合わせください。
例えば以下のような記述をテンプレート内にすると、サイト内の新規ブログを新しい順に5個(デフォルト)表示します。x個表示したい場合は、have_posts()の引数をhave_posts(x)と記述すれば、任意の回数だけ表示します。
通常のWordPressタグと同じようなコントロールができます。但し、query_posts関数は使用できません。
<div class="section"> <?php while(JopGlobalBlogIndex::have_posts()): ?> <?php JopGlobalBlogIndex::the_post(); ?> <div class="item"> <h3><a href="<?php print(JopGlobalBlogIndex::the_permalink()); ?>" title="<?php print(JopGlobalBlogIndex::the_title()); ?>"><?php print(JopGlobalBlogIndex::the_title()); ?></a>(<?php print(JopGlobalBlogIndex::the_author()); ?>)<?php print(JopGlobalBlogIndex::the_time('Y/m/d H:i:s')); ?></h3> <p class="item_category">Category: <?php print(JopGlobalBlogIndex::the_category()); ?></p> <?php print(JopGlobalBlogIndex::the_content()); ?> <p class="readmore"><a href="<?php print(JopGlobalBlogIndex::the_permalink()); ?>" title="<?php print(JopGlobalBlogIndex::the_title()); ?>">Read More</a></p> </div> <?php endwhile; ?> </div>
<?php while(JopGlobalBlogIndex::have_posts([int $limit = 5[, array $option = array('allowedId' => array(), 'restrictedId' => array())]])): ?> <?php JopGlobalBlogIndex::the_post(); ?>
から
<?php endwhile; ?>
の部分が記事の個数だけループされる部分です。$option[‘allowedId’]には表示したいブログのIDを配列で指定でき、$option[‘restrictedId’]には表示したくないブログのIDを指定できます。但し、$option[‘allowedId’]か$option[‘restrictedId’]の一方しか使用できず、両方指定してある場合は前者が有効となります。
「/wp-content/mu-plugins/jopGlobalBlogArchive.php」
<?php /* Plugin Name: jopGlobalBlogArchive Plugin URI: http://blog.justoneplanet.info/wp-content/uploads/wordpressmu/jopGlobalBlogArchive/ Description: Prepare the list of some newer posts and categories from WPMU. Author: Mitsuaki Ishimoto Version: 0.1.8 Author URI: http://blog.justoneplanet.info/ */ /* Copyright 2009 Mitsuaki Ishimoto (email : justoneplanet.info) This program is free software; fundamentally, you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. But the Author(:Mitsuaki Ishimoto) can deny for someone evil or immoral to use this plugin. it means someone evil or immoral is the people and organizations to hold a candle to the devil, to harm someone, not to observe various laws, not to contribute society and so on. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //======================================================= //actions add_action('publish_post', 'jopSavePostForArchive'); add_action('publish_page', 'jopSavePostForArchive'); add_action('delete_post', 'jopDeletePostForArchive'); add_action('delete_category', 'jopDeleteCategoryForArchive'); //======================================================= //class class JopGlobalBlogIndex { /* * $global_prefix * (string) : prefix of database not including blog id */ private static $global_prefix; /* * $post * (object) : data of a post at current loop */ private static $post; /* * $posts * (array) : data of posts from the global post's table of database */ private static $posts; /* * $counter * (int) : counter for counting of loop */ private static $counter = 0; /** * __construct * An instantiation is prohibited. */ private function __construct(){ throw new Exception('An instantiation is prohibited.'); } /** * getOptionsByBlogId * get user's option defined by blog id and key * @return (string) maybe_unserialize($_wp_alloptions[$blog_id][$key]) : option's value * @param (string) $key : the key you need * @param (string) maybe_unserialize($_wp_alloptions[$blog_id][$key]) : option's value */ private static function getOptionsByBlogId($key, $id){ global $wpdb; $suppress = $wpdb->suppress_errors(); $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM " . self::$global_prefix . $id . "_options FORCE INDEX(PRIMARY) ORDER BY option_id ASC" ); $wpdb->suppress_errors($suppress); foreach((array)$alloptions_db as $o){ $_wp_alloptions[$blog_id][$o->option_name] = $o->option_value; } wp_cache_set('alloptions', $_wp_alloptions[$blog_id], 'options'); return maybe_unserialize($_wp_alloptions[$blog_id][$key]); } /** * get_page_uri * @return */ private static function get_page_uri(){ global $wpdb; $uri = self::$post->post_name; if(self::$post->post_parent == self::$post->ID){ return $uri; } $id = self::$post->post_parent; while($id != 0){ $sql = "SELECT `ID`,`post_name`,`post_parent` FROM " . self::$global_prefix . self::$post->blog_id . "_posts WHERE `ID` = '{$id}'"; $result = $wpdb->get_results($sql, OBJECT); $result = $result[0]; $id = $result->post_parent; $uri = $result->post_name . "/" . $uri; } return $uri; } /** * _get_page_link * @return (string) * @param boolean $id[optional] * @param boolean $leavename[optional] */ private static function _get_page_link($id = false, $leavename = false){ global $wp_rewrite; $pagestruct = $wp_rewrite->get_page_permastruct(); if($pagestruct != ''){ $link = self::get_page_uri($id); $link = ($leavename)? $pagestruct : str_replace('%pagename%', $link, $pagestruct); $link = trailingslashit(self::getOptionsByBlogId('home', self::$post->blog_id)) . "$link"; $link = user_trailingslashit($link, 'page'); } else{ $link = trailingslashit(self::getOptionsByBlogId('home', self::$post->blog_id)) . "?page_id={$post->post_id}"; } return apply_filters('_get_page_link', $link, $id); } /** * get_page_link * @return (string) page_link */ private static function get_page_link($id = false, $leavename = false){ if('page' == self::getOptionsByBlogId('show_on_front', self::$post->blog_id) && self::$post->post_id == self::getOptionsByBlogId('page_on_front', self::$post->blog_id)){ $link = self::getOptionsByBlogId('home', self::$post->blog_id); } else{ $link = self::_get_page_link($id, $leavename); } return apply_filters('page_link', $link, $id); } /** * get_permalink * get the permalink from current post * @return the permalink * @param (int) $id[optional] * @param (bool?) $leavename[optional] */ private static function get_permalink($id = 0, $leavename = false) { if(empty(self::$post->ID)){ return false; } if(self::$post->post_type == 'page'){ return self::get_page_link(self::$post->ID, $leavename); } elseif(self::$post->post_type == 'attachment'){ return get_attachment_link(self::$post->ID); } $permalink = get_option('permalink_structure'); if('' != $permalink && !in_array(self::$post->post_status, array('draft', 'pending'))){ $unixtime = strtotime(self::$post->post_date); $category = ''; if(strpos($permalink, '%category%') !== false){ $cats = get_the_category(self::$post->ID); if($cats){ usort($cats, '_usort_terms_by_ID'); // order by ID $category = $cats[0]->slug; if($parent = $cats[0]->parent){ $category = get_category_parents($parent, false, '/', true) . $category; } } // show default category in permalinks, without // having to assign it explicitly if(empty($category)) { $default_category = get_category(get_option('default_category')); $category = is_wp_error($default_category) ? '' : $default_category->slug; } } $author = ''; if(strpos($permalink, '%author%') !== false){ $authordata = get_userdata(self::$post->post_author); $author = $authordata->user_nicename; } $date = explode(" ", date('Y m d H i s', $unixtime)); $blog_path = explode('/', self::$post->path); $blog_path = $blog_path[count($blog_path) - 2]; $rewritecode = array( 'blog', '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename? '' : '%postname%', '%post_id%', '%category%', '%author%', $leavename? '' : '%pagename%', ); $rewritereplace = array( (self::$post->blog_id == 1)? 'blog' : $blog_path, $date[0], $date[1], $date[2], $date[3], $date[4], $date[5], self::$post->post_name, self::$post->ID, $category, $author, self::$post->post_name, ); $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink); $permalink = user_trailingslashit($permalink, 'single'); return apply_filters('post_link', $permalink, self::$post, $leavename); } else{ // if they're not using the fancy permalink option $permalink = get_option('home') . '/?p=' . self::$post->ID; return apply_filters('post_link', $permalink, self::$post, $leavename); } } /** * savePost * save post into the table '(prefix_)jop_global_posts' on installing and updating * @return (null) * @param (object) $result * @param (int) $blogid */ public static function savePost($result, $blogid){ global $wpdb; $id = $result['ID']; $sql = "INSERT INTO " . self::getGlobalPrefix() . "jop_global_posts( `blog_id`, `post_id`, `identifier`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count` ) VALUES('" . $blogid . "', '" . $result['ID'] . "', '" . $blogid . "/" . $result['ID'] . "', '" . $wpdb->_real_escape($result['post_author']) . "', '" . $result['post_date'] . "', '" . $result['post_date_gmt'] . "', '" . $wpdb->_real_escape($result['post_content']) . "', '" . $wpdb->_real_escape($result['post_title']) . "', '" . $result['post_category'] . "', '" . $wpdb->_real_escape($result['post_excerpt']) . "', '" . $wpdb->_real_escape($result['post_status']) . "', '" . $wpdb->_real_escape($result['comment_status']) . "', '" . $wpdb->_real_escape($result['ping_status']) . "', '" . $wpdb->_real_escape($result['post_password']) . "', '" . $wpdb->_real_escape($result['post_name']) . "', '" . $wpdb->_real_escape($result['to_ping']) . "', '" . $wpdb->_real_escape($result['pinged']) . "', '" . $result['post_modified'] . "', '" . $result['post_modified_gmt'] . "', '" . $wpdb->_real_escape($result['post_content_filtered']) . "', '" . $result['post_parent'] . "', '" . $wpdb->_real_escape($result['guid']) . "', '" . $result['menu_order'] . "', '" . $wpdb->_real_escape($result['post_type']) . "', '" . $wpdb->_real_escape($result['post_mime_type']) . "', '" . $result['comment_count'] . "' ) ON DUPLICATE KEY UPDATE " . "`post_author` = '" . $wpdb->_real_escape($result['post_author']) . "'," . "`post_date` = '" . $result['post_date'] . "'," . "`post_date_gmt` = '" . $result['post_date_gmt'] . "'," . "`post_content` = '" . $wpdb->_real_escape($result['post_content']) . "'," . "`post_title` = '" . $wpdb->_real_escape($result['post_title']) . "'," . "`post_category` = '" . $result['post_category'] . "'," . "`post_excerpt` = '" . $wpdb->_real_escape($result['post_excerpt']) . "'," . "`post_status` = '" . $wpdb->_real_escape($result['post_status']) . "'," . "`comment_status` = '" . $wpdb->_real_escape($result['comment_status']) . "'," . "`ping_status` = '" . $wpdb->_real_escape($result['ping_status']) . "'," . "`post_password` = '" . $wpdb->_real_escape($result['post_password']) . "'," . "`post_name` = '" . $wpdb->_real_escape($result['post_name']) . "'," . "`to_ping` = '" . $wpdb->_real_escape($result['to_ping']) . "'," . "`pinged` = '" . $wpdb->_real_escape($result['pinged']) . "'," . "`post_modified` = '" . $result['post_modified'] . "'," . "`post_modified_gmt` = '" . $result['post_modified_gmt'] . "'," . "`post_content_filtered` = '" . $wpdb->_real_escape($result['post_content_filtered']) . "'," . "`post_parent` = '" . $result['post_parent'] . "'," . "`guid` = '" . $wpdb->_real_escape($result['guid']) . "'," . "`menu_order` = '" . $result['menu_order'] . "'," . "`post_type` = '" . $wpdb->_real_escape($result['post_type']) . "'," . "`post_mime_type` = '" . $wpdb->_real_escape($result['post_mime_type']) . "'," . "`comment_count` = '" . $result['comment_count'] . "'"; $wpdb->query($sql); /* * pick up the term id for save */ $sql = "SELECT " . self::getGlobalPrefix() . $blogid . "_term_relationships.object_id, " . self::getGlobalPrefix() . $blogid . "_term_taxonomy.term_id FROM " . self::getGlobalPrefix() . $blogid . "_term_relationships LEFT JOIN " . self::getGlobalPrefix() . $blogid . "_term_taxonomy ON " . self::getGlobalPrefix() . $blogid . "_term_relationships.term_taxonomy_id = " . self::getGlobalPrefix() . $blogid . "_term_taxonomy.term_taxonomy_id WHERE " . self::getGlobalPrefix() . $blogid . "_term_relationships.`object_id` = '{$result['ID']}'"; $result = $wpdb->get_results($sql, ARRAY_A); /* * Once deleting for update */ $sql = "DELETE FROM " . self::getGlobalPrefix() . "jop_global_term_relationships WHERE `object_id` = '{$id}' AND `blog_id` = '{$blogid}'"; $wpdb->query($sql); /* * insert */ $values = array(); foreach($result as $key => $value){ $values[] = "'{$value['object_id']}', '{$blogid}', '{$value['term_id']}', '{$blogid}/{$value['object_id']}/{$value['term_id']}'"; } $values = '(' . implode('),(', $values) . ')'; $sql = "INSERT INTO " . self::getGlobalPrefix() . "jop_global_term_relationships( `object_id`, `blog_id`, `cat_ID`, `identifier` ) VALUES $values"; $wpdb->query($sql); } /** * install * 1st query makes the table that keep the posts written by all users. * 2nd query makes the table that keep the terms written by all users. * @return (null) */ private static function install(){ global $wpdb; $table_name = self::$global_prefix . "jop_global_term_relationships"; if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){ $sql = "CREATE TABLE IF NOT EXISTS `$table_name` ( `object_id` bigint(20) NOT NULL DEFAULT '0', `blog_id` int(11) NOT NULL DEFAULT '0', `cat_ID` bigint(20) NOT NULL DEFAULT '0', `identifier` varchar(255) NOT NULL DEFAULT '0/0', UNIQUE KEY `identifier` (`identifier`), KEY `cat_ID` (`cat_ID`), KEY `blog_id` (`blog_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $wpdb->get_results($sql); } $table_name = self::$global_prefix . "jop_global_posts"; if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){ $sql = "CREATE TABLE IF NOT EXISTS `$table_name` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `blog_id` int(11) NOT NULL DEFAULT '0', `post_id` int(11) NOT NULL DEFAULT '0', `identifier` varchar(255) NOT NULL, `post_author` bigint(20) NOT NULL DEFAULT '0', `post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_content` longtext NOT NULL, `post_title` text NOT NULL, `post_category` int(4) NOT NULL DEFAULT '0', `post_excerpt` text NOT NULL, `post_status` varchar(20) NOT NULL DEFAULT 'publish', `comment_status` varchar(20) NOT NULL DEFAULT 'open', `ping_status` varchar(20) NOT NULL DEFAULT 'open', `post_password` varchar(20) NOT NULL, `post_name` varchar(200) NOT NULL, `to_ping` text NOT NULL, `pinged` text NOT NULL, `post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_content_filtered` text NOT NULL, `post_parent` bigint(20) NOT NULL DEFAULT '0', `guid` varchar(255) NOT NULL, `menu_order` int(11) NOT NULL DEFAULT '0', `post_type` varchar(20) NOT NULL DEFAULT 'post', `post_mime_type` varchar(100) NOT NULL, `comment_count` bigint(20) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`), UNIQUE KEY `identifier` (`identifier`), KEY `blog_id` (`blog_id`), KEY `post_id` (`post_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $wpdb->get_results($sql); /* * save the posts have been published. */ $tables = $wpdb->get_results("SHOW TABLES LIKE '" . self::$global_prefix . "_\_posts'", ARRAY_N); foreach($tables as $table){ $results = $wpdb->get_results("SELECT * FROM {$table[0]} WHERE `post_status` = 'publish'", ARRAY_A); $blogid = str_replace(array(self::$global_prefix, '_posts'), '', $table[0]); foreach($results as $result){ self::savePost($result, $blogid); } } } } /** * init * @return null */ public static function init(){ global $wpdb; self::$global_prefix = preg_replace("/[0-9]+_/", '', $wpdb->prefix); self::install(); } /** * getGlobalPrefix * method for access to prefix * @return (string) self::$global_prefix : table prefix */ public static function getGlobalPrefix(){ return self::$global_prefix; } /** * have_posts * set the list of newer posts written by all users if self::$posts is not set * judge if the self::$posts of current index exist or not * @return (bool) * @param (int) $limit : define the number of rows. * @param (array) $option : define the option. */ public static function have_posts($limit = 5, $option = array()){ global $wpdb; if(!isset(self::$posts)){ $col = array( 'ID', 'blog_id', 'post_id', 'post_date', 'post_content', 'post_name', 'post_author', 'post_title', 'post_category', 'post_status', 'post_type', 'post_parent', 'guid' ); foreach($col as $key => $value){ $col[$key] = self::$global_prefix . "jop_global_posts." . $value; } $col = implode(',', $col); $sqlForAllowedBlog = ''; if(is_array($option['allowedId'])){ for($i = 0; $i < count($option['allowedId']); $i++){ if(is_int($option['allowedId'][$i]) && $option['allowedId'][$i] > 0){ $sqlForAllowedBlog .= " OR " . self::$global_prefix . "jop_global_posts.`blog_id` = '{$option['allowedId'][$i]}'"; } } $sqlForAllowedBlog = substr($sqlForAllowedBlog, 4); } elseif(is_array($option['restrictedId'])){ for($i = 0; $i < count($option['restrictedId']); $i++){ if(is_int($option['restrictedId'][$i]) && $option['restrictedId'][$i] > 0){ $sqlForAllowedBlog .= " AND " . self::$global_prefix . "jop_global_posts.`blog_id` != '{$option['restrictedId'][$i]}'"; } } $sqlForAllowedBlog = substr($sqlForAllowedBlog, 5); } if($sqlForAllowedBlog !== ''){ $sqlForAllowedBlog = " AND ($sqlForAllowedBlog) "; } $sql = "SELECT {$col}," . self::$global_prefix . "blogs.path FROM " . self::$global_prefix . "jop_global_posts LEFT JOIN " . self::$global_prefix . "blogs ON " . self::$global_prefix . "jop_global_posts.blog_id = " . self::$global_prefix . "blogs.blog_id WHERE " . self::$global_prefix . "jop_global_posts.`post_status` = 'publish' AND " . self::$global_prefix . "jop_global_posts.`post_password` = '' $sqlForAllowedBlog ORDER BY `post_date` DESC LIMIT 0,$limit"; $result = $wpdb->get_results($sql, OBJECT); self::$posts = $result; } if(isset(self::$posts[self::$counter])){ return true; } else{ self::$counter = 0; self::$posts = null;//for multiple loop(in the case of different situation) return false; } } /** * the_post * get the post in a loop and set the counter for the next loop. * @return (array) self::$post */ public static function the_post(){ self::$post = self::$posts[self::$counter]; self::$counter++; return self::$post; } /** * the_title * get the title from the current loop. * @return (string) self::$post->post_title */ public static function the_title(){ return apply_filters('the_title', self::$post->post_title); } /** * the_ID * get the title from the current loop. * @return (string) self::$post->ID */ public static function the_ID(){ return self::$post->ID; } /** * the_permalink * get the title from the current loop. * @return (string) self::$post->guid */ public static function the_permalink(){ return apply_filters('the_permalink', self::get_permalink()); } /** * the_time * get the title from the current loop. * @return (string) self::$post->post_date */ public static function the_time($d = ''){ return apply_filters('the_time', self::get_the_time( $d ), $d); } /** * get_the_time * @return (String) date */ private function get_the_time($d = ''){ if('' == $d){ $the_time = get_post_time(get_option('time_format'), false, self::$post, true); } else{ $the_time = get_post_time($d, false, self::$post, true); } return apply_filters('get_the_time', $the_time, $d, self::$post); } /** * the_author * get the title from the current loop. * @return (string) self::$post->post_author */ public static function the_author(){ global $wpdb; $id = self::$post->post_author; $sql = "SELECT `user_nicename` FROM `" . self::$global_prefix . "users` WHERE `ID` = '$id'"; $result = $wpdb->get_results($sql, ARRAY_N); return $result[0][0]; } /** * the_content * get the body from the current loop. * @return (string) self::$post->post_content */ public static function the_content($stripteaser = false){ $content = self::$post->post_content; if($stripteaser){ list($content) = preg_split('/<!--more(.*?)?-->/', $content); } $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return $content; } /** * the_summary * get the summary form the current loop. * @return (string) self::$post->post_content * @param (int) $limit */ public static function the_summary($limit = 50){ if(!is_int($limit)){ $limit = 50; } $content = self::$post->post_content; $funcs = get_defined_functions(); if(in_array('mb_substr', $funcs['internal'])){ $content = mb_substr(strip_tags($content), 0, $limit); } else{ $content = substr(strip_tags($content), 0, $limit); } $content = str_replace(']]>', ']]>', $content); return $content; } /** * the_category * get the title from the current loop. * @return (string) self::$post->post_category */ public static function the_category(){ global $wpdb; $blog_id = self::$post->blog_id; $post_id = self::$post->post_id; $sql = "SELECT `" . self::$global_prefix . "sitecategories`.`cat_name` FROM `" . self::$global_prefix . "jop_global_term_relationships` LEFT JOIN `" . self::$global_prefix . "sitecategories` ON `" . self::$global_prefix . "jop_global_term_relationships`.`cat_ID` = `" . self::$global_prefix . "sitecategories`.`cat_ID` WHERE `" . self::$global_prefix . "jop_global_term_relationships`.`object_id` = '$post_id' AND `" . self::$global_prefix . "jop_global_term_relationships`.`blog_id` = '$blog_id'"; $tmpAry = array(); $result = $wpdb->get_results($sql, ARRAY_A); foreach($result as $key => $value){ $tmpAry[] = $value['cat_name']; } sort($tmpAry); return implode(', ', $tmpAry); } /*prepare*/ public static function the_tags(){ return self::$post->post_title; } public static function the_title_attribute(){ return self::$post->post_title; } /*categories*/ /** * wp_list_categories * get the title from the current loop. * @return (string) self::$post->post_category */ public static function wp_list_categories($args = ''){ $defaults = array( 'show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'exclude' => '', 'current_category' => 0, 'hierarchical' => true, 'title_li' => __('Categories'), 'echo' => 1, 'depth' => 0 ); $r = wp_parse_args($args, $defaults); if(!isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']){ $r['pad_counts'] = true; } if(isset($r['show_date'])){ $r['include_last_update_time'] = $r['show_date']; } extract($r); $categories = get_categories($r); $output = ''; if($title_li && 'list' == $style){ $output = '<li class="categories">' . $r['title_li'] . '<ul>'; } if(empty($categories)){ if('list' == $style){ $output .= '<li>' . __("No categories") . '</li>'; } else{ $output .= __("No categories"); } } else{ global $wp_query; if(!empty($show_option_all)){ if('list' == $style){ $output .= '<li><a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a></li>'; } else{ $output .= '<a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a>'; } } if(empty($r['current_category']) && is_category()){ $r['current_category'] = $wp_query->get_queried_object_id(); } if($hierarchical){ $depth = $r['depth']; } else{ $depth = -1; // Flat. } $output .= walk_category_tree($categories, $depth, $r); } if($title_li && 'list' == $style){ $output .= '</ul></li>'; } $output = apply_filters('wp_list_categories', $output); if($echo){ echo $output; } else{ return $output; } } } JopGlobalBlogIndex::init(); //======================================================= //functions /** * jopDeleteCategoryForArchive * @return (null) * @param (int) $id */ function jopDeleteCategoryForArchive($id){ global $wpdb; $sql = "DELETE FROM " . JopGlobalBlogIndex::getGlobalPrefix() . "jop_global_term_relationships WHERE `blog_id` = '{$wpdb->blogid}' AND `cat_ID` = '{$id}'"; $wpdb->query($sql); } /** * jopSavePostForArchive * @return (null) * @param (int) $id */ function jopSavePostForArchive($id){ global $wpdb; $sql = "SELECT * FROM " . JopGlobalBlogIndex::getGlobalPrefix() . $wpdb->blogid . "_posts WHERE `ID` = '$id'"; $result = $wpdb->get_results($sql, ARRAY_A); $result = $result[0]; JopGlobalBlogIndex::savePost($result, $wpdb->blogid); } /** * jopDeletePostForArchive * @return (null) * @param (int) $id */ function jopDeletePostForArchive($id){ global $wpdb; $sql = "DELETE FROM " . JopGlobalBlogIndex::getGlobalPrefix() . "jop_global_posts WHERE `identifier` = '" . $wpdb->blogid . '/' . $id . "'"; $wpdb->query($sql); //var_dump($sql); //throw new Exception(); } ?>
GNU General Public Licenseです。但し、法律に従わない組織や個人などの邪悪な(者の)使用は認めません。
そんなときは、公開ディレクトリの「uploads」以下のパーミッションを、すべて「777」にする。
symfonyの公開ディレクトリの設定はデフォルトでは「web/」である。
しかし、これを理解せずに公開ディレクトリを「httpdocs/」などとしインストールを進めると、アップロードした写真が、「web/」配下に保存され、当然ながら公開ディレクトリとは異なるため、写真が表示されなくなる。
公開ディレクトリ名が「httpdocs」の場合
<?php # FROZEN_SF_LIB_DIR: /private/tmp/symfony/lib require_once dirname(__FILE__).'/../lib/symfony/autoload/sfCoreAutoload.class.php'; sfCoreAutoload::register(); class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enableAllPluginsExcept(array('sfCompat10Plugin')); $this->setIncludePath(); } public function setIncludePath() { sfToolkit::addIncludePath(array( //PEAR dirname(__FILE__).'/../lib/vendor/PEAR/', )); } }
上述の「config/ProjectConfiguration.class.php」を以下のように変更する。
<?php # FROZEN_SF_LIB_DIR: /private/tmp/symfony/lib require_once dirname(__FILE__).'/../lib/symfony/autoload/sfCoreAutoload.class.php'; sfCoreAutoload::register(); class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enableAllPluginsExcept(array('sfCompat10Plugin')); $this->setIncludePath(); $this->setWebDir($this->getRootDir() . '/httpdocs'); } public function setIncludePath() { sfToolkit::addIncludePath(array( //PEAR dirname(__FILE__).'/../lib/vendor/PEAR/', )); } }
追記したのは、11行目部分の以下の記述。
$this->setWebDir($this->getRootDir() . '/httpdocs');
そして以下のコマンドでOpenPNEを再インストールする。
./symfony openpne:migrate
どちらかというと美しくない方法ではあるが、サーバ設定で変更する方法も考えられる。
DocumentRoot /var/www/vhosts/「ドメイン」/subdomains/「ドメイン」/httpdocs
<Directory /var/www/vhosts/「ドメイン」/subdomains/「ドメイン」/httpdocs>
httpd.confやhttpd.include(Plesk)ファイルの上述の部分を以下のように編集
DocumentRoot /var/www/vhosts/「ドメイン」/subdomains/「ドメイン」/web
<Directory /var/www/vhosts/「ドメイン」/subdomains/「ドメイン」/web>
symfony側のバグという可能性もある。
・・・できるんですが、パーマリンクの設定を行うとバグが発生するようです。具体的には・・・
デフォルト以外のラジオボタンを選択すると
対処方法としてはパーマリンク設定を変更しない!?「数字ベース」を選択するとブログの表示は出来るようだが、設定画面でエラーがでる。
設定>パーマリンクの設定をクリックすると
言語のアクティベートを解除して、もう一度アクティベートをすると不具合が解消される。ただしパーマリンク設定の変更は現状出来ない。
こちらから行えます
備忘録です。
<%if(blogsetting,bshortname,ブログの名前)%>
<%処理1%>
<%else%>
<%処理2
%>
<%endif%>
<%if(blogsetting,nucleus_blogのカラム名,対象カラムの値)%>
<%処理1%>
<%else%>
<%処理2
%>
<%endif%>
NP_MitasNom.phpの112行目あたり、
if(!$blogid && $itemid){
$blogid = getBlogIDFromItemID($itemid);
}
を
if(/*!$blogid && */$itemid){
$blogid = getBlogIDFromItemID($itemid);
}
と記述する
「常にWYSIWYGエディターを使いますか?」に対して、「はい」を選択した時、一般ユーザーの記事の追加、編集が出来なくなるバグを解消できる。