歡迎光臨, 訪客. 請先 登入註冊一個帳號.
五月 03, 2024, 10:05:58 上午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  外掛程式  |  讓 LifeType 使用 TinyMCE 的 g2image plugin 來選取 Gallery2 的照片 « 上篇主題 下篇主題 »
頁: [1]
作者 主題: 讓 LifeType 使用 TinyMCE 的 g2image plugin 來選取 Gallery2 的照片  (閱讀 7597 次)
twu2
初級會員
**
文章: 61



檢視個人資料 個人網站
« 於: 三月 03, 2006, 08:44:22 下午 »

把 Gallery2 與 LifeType 做了初步的整合後, 我們可以在 LifeType 顯示 Gallery 的 ImageBlock 了. 不過, 如果要在文章內貼上一張 Gallery2 的相片時, 能不能像 LifeType 內建的檔案中心那樣的方便, 直接在 TinyMCE 中就使用類似 insertresource 的功能那樣的方便嗎?

在 Google 找了一下, 我們可以找到一個 TinyMCE 的 plugin: g2image, 透過這個 plugin, 可以讓 TinyMCE 搭配 WordPress 有一個直接選取 Gallery2 相片的功能. 而我們是使用 LifeType, 是否也能用呢?

看了一下這個軟體的說明, 並非只能在 WordPress 中使用, 應該只要 TinyMCE 能用, 這個軟體就可以使用. 二話不說, 先抓回來裝看看. 在做一些簡單的修改之後, 果然可以搭配使用, 方便了不少.

首先是修改 tinymce 的 tinymce-plog.js 檔案, 在 plugins 的設定加上 g2image, 然後在 theme_advanced_buttons2 中, 自己找個位置加上 g2image.

然後把下載的檔案中的 g2image 目錄, 搬到 tinymce 的 plugins 目錄中.

接著, 修改 g2image 目錄中的  config.php, 修改下列的設定:
程式碼:
# 設定使用中文
$g2ic_language = 'zh_TW';

# gallery2 安裝的路徑
$g2ic_gallery2_path = '/usr/share/gallery2/';

# 後面這兩個設定是原本沒有的, 為了配合 LifeType 加上的
# gallery2 的 URL, 注意一定要有 http, 且, 後頭要有 / 字元.
$g2ic_gallery2_url = 'http://gallery.teatime.com.tw/';

# 你的 LifeType 的路徑,
# 如果 URL 是 http://blog.teatime.com.tw/ 就是用 /
# 如果 URL 是 http://www.teatime.com.tw/blog/ 就是用 /blog/
$g2ic_gallery2_embed_uri = '/';
然後把 g2image 目錄下的 init.php 先改成 init.old.php, 再把下頭的程式存成 init.php:
程式碼:
<?php
//  Initialization File for Gallery 2 Image Chooser for TinyMCE
//  Version 2.0
//  By Kirk Steffensen - http://g2image.steffensenfamily.com/
//  Released under the GPL version 2.
//  A copy of the license is in the root folder of this plugin.

// ====( Initialize Variables )=================================
$g2ic_current_page 1;
$g2ic_rel_path '/';
$g2ic_embedded_mode FALSE;
$g2ic_wpg2_valid FALSE;
$g2ic_dirs null;
$g2ic_wp_rel_path '';
$g2ic_base_path str_repeat("../"substr_count(dirname($_SERVER['PHP_SELF']), "/"));
if(isset(
$_SESSION['g2ic_last_album_visited'])) {
        
$g2ic_last_album $_SESSION['g2ic_last_album_visited'];
}
else {
        
$g2ic_last_album '/';
}

// ==============================================================
// Native embedded mode
// ==============================================================

// Else use the native Gallery2 functions
if (!$g2ic_embedded_mode){
        if(
file_exists($g2ic_gallery2_path.'embed.php')) {
                
$g2ic_option['gallery2_url'] = $g2ic_gallery2_url;
                
$g2ic_option['embedUri'] = $g2ic_gallery2_embed_uri;
                require_once(
$g2ic_gallery2_path.'embed.php');
                
g2ic_init($g2ic_option,$g2ic_embedded_mode);
        }
        
// Else die on a fatal error
        
else {
                print 
g2ic_make_html_header();
                print 
$g2ic_lang['g2_embedded_error'];
                print 
"</body>\n\n";
                print 
"</html>";
                die;
        }
}

//---------------------------------------------------------------------
//      Function:       g2ic_init
//      Parameters:     $option,$embedded_mode
//      Returns:        None
//      Purpose:        Initialize the emedded functions of Gallery2.
//      Notes:          Exit on Fatal
//---------------------------------------------------------------------

function g2ic_init($option,$embedded_mode) {

        
// Initialise GalleryAPI
        
$ret GalleryEmbed::init( array(
                
'g2Uri' => $option['gallery2_url'],
                
'embedUri' => $option['embedUri'],
                
'fullInit' => true)
        );
        if (
$ret) {
                print 
g2ic_make_html_header();
                print 
'{$lang_g2image_g2_fatal_error}' .$ret->getAsHtml() . "\n";
                print 
"</body>\n\n";
                print 
"</html>";
                die;
        }

        return;
}
?>
這樣子就應該可以在 TinyMCE 中使用 g2image 來選擇你要顯示的照片了. 另外, 原本的中文檔案有兩個小問題, 如果你要使用中文, 可以把 g2image 目錄下的 langs/zh_TW.php 改成下列這個樣子:
程式碼:
<?php

// Traditional Chinese lang variables - Version 2.0

$g2ic_lang = array(
'about' => '關於 G2Image',
'alignment_class' => '對齊級別:',
'alignment_legend' => '對齊級別(CSS必需支援 g2image classes 級別才能發生效用)>:',
'click_advanced' => '開啟進階設定選單',
'click_image' => '在圖像上按滑鼠會出現圖像選項。',
'click_one_click' => '使用預設方式插入',
'click_options' => '在圖像上按滑鼠鍵的動作:',
'current_album' => '目前相簿:',
'custom_url' => '自定網址:',
'description' => '描述:',
'description_legend' => '圖像或文字鏈接的替代文字說明:',
'display_legend' => '顯示選項',
'drupal_g2_filter' => 'Drupal Gallery2 過濾器',
'empty_album' => '這個相簿中沒有照片。<br /><br />'.
                 
'請在上面的導覽選項中另選一個相簿。',
'filename' => '檔名:',
'filenames' => '檔名:',
'g2_directory_error' => '無法打開 Gallery2 資料目錄。 :-(',
'g2_embedded_error' => '<h2>嚴重 Gallery2 錯誤:</h2><br />'.
                       
'無法啟動 Gallery2 內>嵌功能。<br />'.
                       
'請為 WordPress 安裝 WPG2 外掛模組(位於 http://wpg2.ozgreg.com/)<br />'.
                       
'或確認你的 config.php 中的 Gallery2 路徑。',
'g2_entities_by_id_error' => '<h2>嚴重 Gallery2 錯誤:</h2><br />'.
                             
'無法取得這個 Gallery2 ID 的圖像資訊。<br />'.
                             
'G2 傳回的錯誤:',
'g2_fatal_error' => '<h2>嚴重 Gallery2 錯誤:</h2><br />'.
                    
'G2 傳回的錯誤:',
'g2_id_by_path_error' => '<h2>嚴重 Gallery2 錯誤:</h2><br />'.
                         
'無法取得要求路徑的 Gallery2 ID。<br />'.
                         
'G2 傳回的錯誤:',
'g2_id_not_found_error' => '<h2>嚴重 Gallery2 錯誤:</h2><br />'.
                           
'無法取得這個檔案>的 Gallery2 ID。<br />'.
                           
'G2 傳回的錯誤:',
'g2_image_title' => 'Gallery2 主題:',
'go' => '前往',
'how_insert' => '插入方式:',
'image_title' => 'Title: ',
'img_float_left' => '浮動對左',
'img_float_right' => '浮動對右',
'img_centered' => '對中',
'img_none' => '無',
'img_normal' => '正常',
'insert' => '插入',
'insert_legend' => '按下按鈕以插入圖像:',
'last_modification_new' => '上次更新日期(最新的在前)',
'last_modification_old' => '上次更新日期(最舊的在前)',
'link_album' => '指到上層相簿的文字鏈接',
'link_image' => '指到圖像的文字鏈接',
'name_a_to_z' => '檔案名稱(A-z)',
'name_z_to_a' => '檔案名稱(z-A)',
'page' => '頁數:',
'page_navigation' => '頁面導覽:',
'photo_albums' => '相簿',
'redraw' => '重新顯示',
'sort_error' => '排序方式錯誤',
'sorted_by' => '排序方式:',
'subalbums' => '子相簿:',
'thumbnails' => '縮略圖',
'thumbnail_album' => '指到上層相簿的縮略圖',
'thumbnail_custom_url' => '指到自定網址(在下列文字框中)的縮略圖',
'thumbnail_image' => '指到圖像的縮略圖',
'thumbnail_only' => '只顯示縮略圖:不含鏈接',
'thumbnails_per_page' => '每頁項數:',
'title' => '選取 Gallery 2 圖像',
'title_a_to_z' => 'Gallery 2 主題(A-z)',
'title_z_to_a' => 'Gallery 2 主題(z-A)',
'url' => '網址:',
'wpg2_album_legend' => '插入目前相簿的 WPG2 標籤:',
'wpg2_configuration_error' => '組態設定錯誤:<br />'.
                              
'WPG2 已用,可是並未通過驗証手續。<br />'.
                              
'請在 WordPress 管理面板中設定並驗証 WPG2。<br />'.
                              
'說明可在 http://www.ozgreg.com 網站中找到。',
'wpg2_link_album' => '指到上層相簿的文字鏈接(HTML)',
'wpg2_link_image' => '指到圖像的文字鏈接(HTML)',
'wpg2_tag_image' => '圖像的 WPG2 標籤',
'wpg2_thumbnail_album' => '指到上層相簿的縮略圖(HTML)',
'wpg2_thumbnail_custom_url' => '指到自定網址(在下列文字框中)的縮略圖(HTML)',
'wpg2_thumbnail_image' => '指到圖像的縮略圖(HTML)',
'wpg2_thumbnail_only' => '只顯示縮略圖:不含鏈接(HTML)')
?>
注意: 我的修改適用下列的版本:

    * G2Image 2.0RC2 或之後的版本 http://g2image.steffensenfamily.com/index.php?title=Download
    * Gallery 2.1 RC1 或之後版本
    * LifeType 1.0.3
    * TinyMCE 2.0.1

我的環境是使用 rewrite 的簡短路徑功能, 不確定是否別的環境也適用, 不過應該是可以用才對.

可參考 http://blog.teatime.com.tw/post/1/29 的說明與使用的結果.
« 最後編輯時間: 三月 03, 2006, 09:59:35 下午 由 twu2 » 已記錄

sunkit
初級會員
**
文章: 79


檢視個人資料
« 回覆文章 #1 於: 三月 04, 2006, 10:27:51 上午 »

twu2大兄,

又是我這個問題青年,

照你的方法setup下,出現這個error

引用
{$lang_g2image_g2_fatal_error}Error (GALLERY_SUCCESS)
in at line 0

我想應該是G2的path出現問題,
網址及檔案位置
LT: http://hkplog.com                /home/hkplogadmin/lifetype-1.0.2
G2: http://gallery.hkplog.com   /home/hkplogadmin/gallery2

會否影響到$g2ic_gallery2_embed_uri = '/';的設定呢?

thx
已記錄
twu2
初級會員
**
文章: 61



檢視個人資料 個人網站
« 回覆文章 #2 於: 三月 04, 2006, 01:24:04 下午 »

先把你的 gallery plugin 的問題解決再說吧. 至少能看到圖片後裝這個才有用吧.

可以看一下你在 lifetype 中顯示出來的 gallery 的畫面的 html source code.
基本上, 所有 gallery 裡頭出現的 image 的 link, 都應該是用原本 gallery 所使用的 URL (如 http://gallery.teatime.com.tw/d/xxx/xxx.jpg). 而其他的 Gallery 功能 link, 都是用 lifetype 的 URL (如 http://blog.teatime.com.tw/v/xx/xxx.htm).

如果那個 image 的 URL 確定是 gallery 所用的. 但要看不到.... 那... 我想不出為什麼, 你確定單純使用 Gallery 時是可以運作的嗎? 因為直接看那個 image 與是否使用 lifetype 沒什麼關係.
已記錄

頁: [1]
LifeType 中文開發論壇  |  開發  |  外掛程式  |  讓 LifeType 使用 TinyMCE 的 g2image plugin 來選取 Gallery2 的照片 « 上篇主題 下篇主題 »
    前往: