Tommy 碎碎念

Tommy Wu's blog

« 上一篇 | 下一篇 »

LifeType 與 Gallery2 plugin 修改 part 2
post by tommy @ 17 二月, 2006 16:36
到 Gallery 的網站上看了一下 API, 發現有 API 可以把路徑或檔案名轉換成 itemId 來用, 這樣子就算都用 rewrite 來產生可讀性較高的路徑, 一樣可以很輕鬆的在 plugin 中搭配 specificItem 來指定 itemId 了.

把 gallery/class/gallery/galleryhelper.class.php 做一下小修正:

--- galleryhelper.class.php.orig        2006-02-17 16:35:56.557242419 +0800
+++ galleryhelper.class.php 2006-02-17 16:33:29.227243493 +0800
@@ -132,6 +132,9 @@

// Get the image block
if ( $itemid != "" ) {
+ if (is_numeric($itemid) == false) {
+ list($ret, $itemid) = GalleryCoreApi::fetchItemIdByPath($itemid);
+ }
list($ret, $g2data) = GalleryEmbed::getImageBlock( array( 'blocks' => $blocks,
'show' => $show,
'itemId' => $itemid) );

這樣子修正後, 只要你在 Gallery 中看到的相簿路徑像是 v/tommy_baby 就可以在 plugin 設定 itemId 的地方填入 tommy_baby 就會查出該相簿的 itemId 來顯示. 如果是相片如 v/tommy_baby/tommy_baby_200601/DSC_0006.JPG, 就在 plugin 設定 itemId 的地方填入 tommy_baby/tommy_baby_200601/DSC_0006.JPG 就可以了.

這樣子就方便許多了, 也沒有上一篇所說的使用 rewrite 功能後, 很難找出 itemId 的問題了.

不過會有另外一個問題是,  如果你的路徑名稱剛好都是數字, 就會被認為那是一個 itemId, 而不是路徑, 就不會再去轉換一次了. 晚上試了一下, 發現可以在 itemId 前頭加上 / 來避免這個問題. 加上之後, 就不會被認為是數字, 且 Gallery 也接受這樣的方式.

另外, 發現這個 plugin 只能在設定 specificItem 時, 設定 itemId 的值, 如果不是 specificItem 時, 就會自動清除 itemId 的設定值. 但是在 Gallery 的程式中, 並沒有這個限制, 也就是我們可以使用 randomImage  搭配某個相簿的 itemId, 就可以隨機的由這個相簿 (含子相簿) 中選取一張相片來用. 所以順便把這個給改了: 

--- plugingalleryupdateconfigaction.class.php.orig      2006-02-17 17:40:36.363616876 +0800
+++ plugingalleryupdateconfigaction.class.php 2006-02-17 17:41:13.524118432 +0800
@@ -87,7 +87,7 @@
}

if ( $this->_blocks != "specificItem" ) {
- $this->_itemid = "";
+ //$this->_itemid = "";
}

if ( !file_exists( $this->_absolutePath ) ) {
 

上頭的檔案是 gallery/class/action/ 這個路徑裡頭.

這樣子處理之後, 如果我使用 randomImage, 在 itemId 輸入 tommy_baby 時, 就會變成隨機選取 tommy_baby 相簿裡頭的照片了.

Del.icio.us Furl HEMiDEMi Technorati MyShare
迴響
暱稱:
標題:
個人網頁:
電子郵件:
authimage

迴響

  

Bad Behavior 已經阻擋了 139 個過去 7 天試圖闖關的垃圾迴響與引用。
Power by LifeType. Template design by JamesHuang. Valid XHTML and CSS