1: 2008-09-28 (日) 21:50:37 なーお  |
現: 2019-08-17 (土) 07:11:56 なーお  |
- | *picoでxpWikiへのAutoリンク [#l58e4614] | + | *picoでxpWikiへの外部Autoリンク [#l58e4614] |
| + | |(080930変更)&br; クエリパターンを、「(pico)/index.php?subject=ページタイトル」に変更しました。&br; 参考:(XUGJ)[[picoでxpWikiへの外部Autoリンク:http://www.xugj.org/modules/QandA/index.php?post_id=6166]](thx GIJOEさん)| |
| | | |
- | 以前より、とあるサイトでXwordsでxpWikiへのAutoリンクを便利に使っていました。 | + | **タイトルでリンク可能な特殊文字 [#z30b0b96] |
| + | タイトルに使っても大丈夫な文字 : $?\*+-/#@%~^ ()=|!{}[][[]]:; |
| + | その他、Σなどのマルチバイト文字も可能。 |
| + | |
| + | リンクされない文字 (xpWikiのAutoリンクの制約か) : &"'<> |
| + | |
| + | -------- |
| + | |
| + | 以前より、とあるサイトでXwordsでxpWikiへの外部Autoリンクを便利に使っていました。 |
| (参考:[[xpwikiからxwordsへのリンクはできないでしょうか?>http://xoops.hypweb.net/modules/forum/index.php?topic_id=2140]]-XOOPSマニア) | | (参考:[[xpwikiからxwordsへのリンクはできないでしょうか?>http://xoops.hypweb.net/modules/forum/index.php?topic_id=2140]]-XOOPSマニア) |
| | | |
- | 今回、積層スピーカーの会で、スピーカーDBをcosmoDBからpico(1.71系extra-fields)に乗り換えて、Autoリンクに挑戦してみました。 | + | 今回、積層スピーカーの会で、スピーカーDBをcosmoDBからpico(1.71系extra-fields)に乗り換えて、外部Autoリンクに挑戦してみました。 |
| | | |
| **準備 [#x66c9854] | | **準備 [#x66c9854] |
| + | |
| ***Wrapモード=ON [#y6920ac3] | | ***Wrapモード=ON [#y6920ac3] |
| + | &font(Red){(080930変更)Autoリンクの際のアクセスを、}; |
| + | 「(xoops_URL)/modules/(pico)/index.php?subject=ABC」 |
| + | &font(Red){に変更しました。}; 以下、WrapモードONは必須ではなくなりました。 |
| + | |
| Wrapモードにて、仮想パスでアクセス可能にします。 | | Wrapモードにて、仮想パスでアクセス可能にします。 |
- | 具体的には、記事タイトルが「ABC」であれば、「/ABC.htm」という仮想パスを設定することにより、「(xoops_URL/modules/(pico)/index.php/ABC.htm)」でアクセス可能になります。 | + | 具体的には、記事タイトルが |
| + | 「ABC」 |
| + | であれば、 |
| + | 「/ABC.htm」 |
| + | という仮想パスを設定することにより、 |
| + | 「(xoops_URL/modules/(pico)/index.php/ABC.htm)」 |
| + | でアクセス可能になります。 |
| | | |
| ***仮想パスの入力欄を常に表示 [#pf6ff868] | | ***仮想パスの入力欄を常に表示 [#pf6ff868] |
- | defaultの | + | defaultの状態では、仮想パス入力欄が出て来ません。 |
| + | ****main_content_form.html の編集 [#za7695d2] |
| + | 「(trust_path)/modules/pico/templates/main_content_form.html」の、33行目と46行目を以下のようにコメントアウトします。 |
| + | (080930追記)仮想パスでなくてもAutoリンク可能になったので、この変更は必須ではありません。 |
| + | #code(html,32-){{ |
| + | <!-- vpath --> |
| + | <{* if $mod_config.user_wraps_mode || strstr($content.filters,"wraps") *}> |
| + | <tr valign="top" align="left"> |
| + | <th class="head"><label for="vpath"><{$smarty.const._MD_PICO_TH_VIRTUALPATH}></label></th> |
| + | <td class="even"> |
| + | <input type="text" name="vpath" id="vpath" size="70" maxlength="255" value="<{$content.vpath}>" class="pico_ascii_only" /> |
| + | <{if $xoops_isadmin}> |
| + | <br /> |
| + | <select name="wraps_target" onchange="xoopsGetElementById('vpath').value=this.value;"> |
| + | <{html_options options=$content.wraps_files selected=$content.vpath}> |
| + | </select> |
| + | <{/if}> |
| + | </td> |
| + | </tr> |
| + | <{* /if *}> |
| + | }} |
| + | |
| + | **picoにソースを追加 [#v866949b] |
| + | ***X2の場合 [#jaa360f1] |
| + | picoで記事を作成・編集するたびに、ページ名一覧を正規表現でファイルに書き込む必要があります。 まずは、一覧を作成するソース。 |
| + | ****entries_write.php [#mab9018e] |
| + | 「trust/modules/pico/include/entries_write.php」というファイルを以下の内容で作成します。 |
| + | #code(php,1-){{{{ |
| + | <?php |
| + | // xpwikiから picoへの自動リンクを貼るための、アドオン |
| + | // 元ネタ:xpwikiから xwordsへの自動リンクを貼るための、アドオン |
| + | // see http://xoops.hypweb.net/modules/forum/index.php?topic_id=2140 |
| + | // 小文字・大文字を区別しない? (0 or 1) |
| + | define('PAGE_CASE_INSENSITIVE', 0); |
| + | |
| + | global $xoopsDB; |
| + | |
| + | $temp_txt = XOOPS_ROOT_PATH."/uploads/".$this->mydirname."/entries_temp.php"; |
| + | $entries_dat = XOOPS_ROOT_PATH."/uploads/".$this->mydirname."/entries.php"; |
| + | $ent_table = $xoopsDB -> prefix ("{$this->mydirname}_contents") ; |
| + | |
| + | if ($fp1 = fopen($temp_txt, 'wb')) { |
| + | $result_entries = $xoopsDB -> query( "SELECT subject FROM $ent_table" ); |
| + | while ( list( $entry_term ) = $xoopsDB -> fetchrow( $result_entries ) ) { |
| + | if(mb_strlen($entry_term)>2) {fwrite($fp1, $entry_term."\n"); |
| + | } |
| + | } |
| + | fclose($fp1); |
| + | } |
| + | |
| + | $dats = file($temp_txt); |
| + | $dat = get_matcher_regex_safe($dats); |
| + | if ($fp2 = fopen($entries_dat, 'wb')) { |
| + | fwrite($fp2, $dat); |
| + | fclose($fp2); |
| + | } |
| + | |
| + | function get_matcher_regex_safe ($pages, $spliter = "\t", $array_fix = true, $nest = 0) { |
| + | if ($array_fix) { |
| + | $pages = array_map('trim', $pages); |
| + | if (PAGE_CASE_INSENSITIVE) $pages = array_map('strtolower', $pages); |
| + | $pages = array_unique($pages); |
| + | foreach(array_keys($pages, '') as $key) { |
| + | unset($pages[$key]); |
| + | } |
| + | sort($pages, SORT_STRING); |
| + | } |
| + | |
| + | ++$nest; |
| + | $reg = get_matcher_regex_safe_sub($pages); |
| + | $regs = preg_split("/(\d+)\x08/", $reg, -1, PREG_SPLIT_DELIM_CAPTURE); |
| + | $pats = array(); |
| + | $index = 0; |
| + | reset($regs); |
| + | while (list($key, $pat) = each($regs)) { |
| + | list($key, $val) = each($regs); |
| + | if (!$val) $val = count($pages); |
| + | if (@ preg_match('/' . $pat. '/', '') === false) { |
| + | if ($nest <= 10) { |
| + | $count = $val - $index; |
| + | $split = floor(($val - $index) / 2); |
| + | $pages1 = array_slice($pages, $index, $split); |
| + | $pages2 = array_slice($pages, $split, $count - $split); |
| + | $pats[] = get_matcher_regex_safe($pages1, $spliter, false, $nest); |
| + | $pats[] = get_matcher_regex_safe($pages2, $spliter, false, $nest); |
| + | $index = $val; |
| + | } |
| + | } else { |
| + | $pats[] = $pat; |
| + | } |
| + | } |
| + | return join($spliter, $pats); |
| + | } |
| + | |
| + | function get_matcher_regex_safe_sub (& $array, $offset = 0, $sentry = NULL, $pos = 0, $nest = 0) |
| + | { |
| + | static $g_count = 0; |
| + | |
| + | ++$nest; |
| + | $limit = 1024 * 32 - 10; |
| + | |
| + | if (empty($array)) return '(?!)'; // Zero |
| + | if ($sentry === NULL) $sentry = count($array); |
| + | |
| + | // Too short. Skip this |
| + | $skip = ($pos >= mb_strlen($array[$offset])); |
| + | if ($skip) ++$offset; |
| + | |
| + | // Generate regex for each value |
| + | $regex = ''; |
| + | $index = $offset; |
| + | $multi = FALSE; |
| + | $reglen = 0; |
| + | while ($index < $sentry) { |
| + | if ($index != $offset) { |
| + | $multi = TRUE; |
| + | if ($nest === 1 && strlen($regex) - $reglen > $limit) { |
| + | $reglen = strlen($regex); |
| + | $regex .= ')'.($index)."\x08(?:"; |
| + | $g_count = 1; |
| + | } else { |
| + | $regex .= '|'; // OR |
| + | } |
| + | } |
| + | |
| + | // Get one character from left side of the value |
| + | $char = mb_substr($array[$index], $pos, 1); |
| + | |
| + | // How many continuous keys have the same letter |
| + | // at the same position? |
| + | for ($i = $index; $i < $sentry; $i++) |
| + | if (mb_substr($array[$i], $pos, 1) != $char) break; |
| + | |
| + | if ($index < ($i - 1)) { |
| + | // Some more keys found |
| + | // Recurse |
| + | $regex .= str_replace(' ', '\\ ', preg_quote($char, '/')) . |
| + | get_matcher_regex_safe_sub($array, $index, $i, $pos + 1, $nest); |
| + | } else { |
| + | // Not found |
| + | $regex .= str_replace(' ', '\\ ', |
| + | preg_quote(mb_substr($array[$index], $pos), '/')); |
| + | } |
| + | $index = $i; |
| + | } |
| + | |
| + | if ($skip || $multi){ |
| + | $g_count++; |
| + | $regex = '(?:' . $regex . ')'; |
| + | } |
| + | if ($skip) $regex .= '?'; // Match for $pages[$offset - 1] |
| + | return $regex; |
| + | } |
| + | |
| + | ?> |
| + | }}}} |
| + | |
| + | ***pico本体ソースの変更 [#m74828c8] |
| + | 続いて、このソースをインクルードする部分の編集です。 なお、記事は自動承認される場合のみ、有効にしています。 承認が必要な場合は、別に承認処理のソースに手を入れる必要があります。 |
| + | X2の場合はこのフックは必須です。 |
| + | |
| + | ****PicoControllerInsertContent.class.php の編集 [#j6924a28] |
| + | 「(trust)/modules/pico/class/PicoControllerInsertContent.class.php」に下記の76行目の追記。 |
| + | #code(php,75-){{{{ |
| + | if( $cat_data['post_auto_approved'] ) { |
| + | include_once( dirname(dirname(__FILE__)).'/include/entries_write.php' ); //naao |
| + | // Notify for new content 'global' |
| + | pico_main_trigger_event( $this->mydirname , 'global' , 0 , 'newcontent' , $extra_tags , $users2notify , 0 ) ; |
| + | // Notify for new content 'category' of all parental categories |
| + | foreach( array_keys( $cat_data['paths_raw'] ) as $cat_id ) { |
| + | pico_main_trigger_event( $this->mydirname , 'category' , $cat_id , 'newcontent' , $extra_tags , $users2notify , 0 ) ; |
| + | } |
| + | // message "registered" |
| + | redirect_header( $ret_uri4html , 2 , _MD_PICO_MSG_CONTENTMADE ) ; |
| + | } else { |
| + | }}}} |
| + | |
| + | ****PicoControllerUpdateContent.class.php の編集 [#s65b291e] |
| + | 「(trust)/modules/pico/class/PicoControllerUpdateContent.class.php」に下記の75行目の追記。 |
| + | #code(php,74-){{{{ |
| + | if( $cat_data['post_auto_approved'] ) { |
| + | include_once( dirname(dirname(__FILE__)).'/include/entries_write.php' ); //naao |
| + | |
| + | // message "modified" |
| + | redirect_header( $ret_uri4html , 2 , _MD_PICO_MSG_CONTENTUPDATED ) ; |
| + | } else { |
| + | |
| + | }}}} |
| + | |
| + | ****PicoUriMapper.class.php の編集 (080930追記) [#i10016f9] |
| + | (&font(Red){pico-ver1.73以降では、ハック不要。}; pico一般設定の「URIマッピング処理クラス名」にサンプルで同梱されている「PicoUriMapperBySubject」を設定すればOKです。) |
| + | |
| + | 「(trust)/modules/pico/class/PicoUriMapper.class.php」の79行目あたり。下記79~91行目を追記。 |
| + | #code(php,76-){{ |
| + | } else if( @$_GET['cat_id'] !== '0' && ( $this->config['show_menuinmoduletop'] || @$_GET['page'] == 'menu' ) ) { |
| + | $this->request['controller'] = 'menu' ; |
| + | $this->request['view'] = 'menu' ; |
| + | } else if( @$_GET['subject'] ) { |
| + | $xoopsDB =& Database::getInstance() ; |
| + | $content_table = $xoopsDB->prefix($this->mydirname."_contents"); |
| + | $sql = "SELECT content_id FROM ".$content_table." WHERE subject='".addslashes(@$_GET['subject'])."'" ; |
| + | $db_ret = $xoopsDB->query($sql); |
| + | if( $xoopsDB->getRowsNum( $db_ret ) ) { |
| + | list( $content_id ) = $xoopsDB->fetchRow($db_ret); |
| + | $this->request['view'] = 'detail' ; |
| + | } else { |
| + | $this->request['controller'] = 'category' ; |
| + | $this->request['view'] = 'list' ; |
| + | } |
| + | } else { |
| + | $this->request['controller'] = 'category' ; |
| + | $this->request['view'] = 'list' ; |
| + | } |
| + | }} |
| + | |
| + | 以上、変更したソースをサーバーに上書きします。 |
| + | |
| + | |
| + | ***XCLの場合 [#odedbd89] |
| + | XCLではモジュールアップデートで上書きされる危険性を避けるために、PreloadとDeligateを使うことができますので、これでやってみます。 |
| + | (thx GIJOEさん http://www.xugj.org/modules/QandA/index.php?post_id=6217) |
| + | |
| + | **** PicoSubjectRegexHook.class.php [#qd386117] |
| + | 「(html)/preload」内に、「PicoSubjectRegxHook.class.php」として以下のソースを保存してアップするだけでOK! |
| + | #code(php,0-){{{{ |
| + | <?php |
| + | |
| + | if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ; |
| + | |
| + | class PicoSubjectRegexHook extends XCube_ActionFilter |
| + | { |
| + | function preBlockFilter() |
| + | { |
| + | $this->mRoot->mDelegateManager->add( 'ModuleClass.Pico.Contentman.InsertSuccess' , array( &$this , 'hook' ) ) ; |
| + | $this->mRoot->mDelegateManager->add( 'ModuleClass.Pico.Contentman.UpdateSuccess' , array( &$this , 'hook' ) ) ; |
| + | } |
| + | |
| + | function hook( $mydirname , $content_id , $cat_data , $ret_uri4html ) |
| + | { |
| + | // xpwikiから picoへの自動リンクを貼るための、アドオン |
| + | // 元ネタ:xpwikiから xwordsへの自動リンクを貼るための、アドオン |
| + | // see http://xoops.hypweb.net/modules/forum/index.php?topic_id=2140 |
| + | // 小文字・大文字を区別しない? (0 or 1) |
| + | define('PAGE_CASE_INSENSITIVE', 0); |
| + | |
| + | global $xoopsDB; |
| + | |
| + | $temp_txt = XOOPS_ROOT_PATH."/uploads/".$mydirname."/entries_temp.php"; |
| + | $entries_dat = XOOPS_ROOT_PATH."/uploads/".$mydirname."/entries.php"; |
| + | $ent_table = $xoopsDB -> prefix ("{$mydirname}_contents") ; |
| + | |
| + | if ($fp1 = fopen($temp_txt, 'wb')) { |
| + | $result_entries = $xoopsDB -> query( "SELECT subject FROM $ent_table" ); |
| + | while ( list( $entry_term ) = $xoopsDB -> fetchrow( $result_entries ) ) { |
| + | if(mb_strlen($entry_term)>2) {fwrite($fp1, $entry_term."\n"); |
| + | } |
| + | } |
| + | fclose($fp1); |
| + | } |
| + | |
| + | $dats = file($temp_txt); |
| + | $dat = $this->get_matcher_regex_safe($dats); |
| + | if ($fp2 = fopen($entries_dat, 'wb')) { |
| + | fwrite($fp2, $dat); |
| + | fclose($fp2); |
| + | } |
| + | |
| + | } //end of function |
| + | |
| + | function get_matcher_regex_safe ($pages, $spliter = "\t", $array_fix = true, $nest = 0) { |
| + | if ($array_fix) { |
| + | $pages = array_map('trim', $pages); |
| + | if (PAGE_CASE_INSENSITIVE) $pages = array_map('strtolower', $pages); |
| + | $pages = array_unique($pages); |
| + | foreach(array_keys($pages, '') as $key) { |
| + | unset($pages[$key]); |
| + | } |
| + | sort($pages, SORT_STRING); |
| + | } |
| + | |
| + | ++$nest; |
| + | $reg = $this->get_matcher_regex_safe_sub($pages); |
| + | $regs = preg_split("/(\d+)\x08/", $reg, -1, PREG_SPLIT_DELIM_CAPTURE); |
| + | $pats = array(); |
| + | $index = 0; |
| + | reset($regs); |
| + | while (list($key, $pat) = each($regs)) { |
| + | list($key, $val) = each($regs); |
| + | if (!$val) $val = count($pages); |
| + | if (@ preg_match('/' . $pat. '/', '') === false) { |
| + | if ($nest <= 10) { |
| + | $count = $val - $index; |
| + | $split = floor(($val - $index) / 2); |
| + | $pages1 = array_slice($pages, $index, $split); |
| + | $pages2 = array_slice($pages, $split, $count - $split); |
| + | $pats[] = $this->get_matcher_regex_safe($pages1, $spliter, false, $nest); |
| + | $pats[] = $this->get_matcher_regex_safe($pages2, $spliter, false, $nest); |
| + | $index = $val; |
| + | } |
| + | } else { |
| + | $pats[] = $pat; |
| + | } |
| + | } |
| + | return join($spliter, $pats); |
| + | } //end of function |
| + | |
| + | function get_matcher_regex_safe_sub (& $array, $offset = 0, $sentry = NULL, $pos = 0, $nest = 0) |
| + | { |
| + | static $g_count = 0; |
| + | ++$nest; |
| + | $limit = 1024 * 32 - 10; |
| + | |
| + | if (empty($array)) return '(?!)'; // Zero |
| + | if ($sentry === NULL) $sentry = count($array); |
| + | |
| + | // Too short. Skip this |
| + | $skip = ($pos >= mb_strlen($array[$offset])); |
| + | if ($skip) ++$offset; |
| + | |
| + | // Generate regex for each value |
| + | $regex = ''; |
| + | $index = $offset; |
| + | $multi = FALSE; |
| + | $reglen = 0; |
| + | while ($index < $sentry) { |
| + | if ($index != $offset) { |
| + | $multi = TRUE; |
| + | if ($nest === 1 && strlen($regex) - $reglen > $limit) { |
| + | $reglen = strlen($regex); |
| + | $regex .= ')'.($index)."\x08(?:"; |
| + | $g_count = 1; |
| + | } else { |
| + | $regex .= '|'; // OR |
| + | } |
| + | } |
| + | |
| + | // Get one character from left side of the value |
| + | $char = mb_substr($array[$index], $pos, 1); |
| + | |
| + | // How many continuous keys have the same letter |
| + | // at the same position? |
| + | for ($i = $index; $i < $sentry; $i++) |
| + | if (mb_substr($array[$i], $pos, 1) != $char) break; |
| + | |
| + | if ($index < ($i - 1)) { |
| + | // Some more keys found |
| + | // Recurse |
| + | $regex .= str_replace(' ', '\\ ', preg_quote($char, '/')) . |
| + | $this->get_matcher_regex_safe_sub($array, $index, $i, $pos + 1, $nest); |
| + | } else { |
| + | // Not found |
| + | $regex .= str_replace(' ', '\\ ', |
| + | preg_quote(mb_substr($array[$index], $pos), '/')); |
| + | } |
| + | $index = $i; |
| + | } |
| + | |
| + | if ($skip || $multi){ |
| + | $g_count++; |
| + | $regex = '(?:' . $regex . ')'; |
| + | } |
| + | if ($skip) $regex .= '?'; // Match for $pages[$offset - 1] |
| + | return $regex; |
| + | } //end of function |
| + | |
| + | } //end of class |
| + | |
| + | ?> |
| + | }}}} |
| + | |
| + | ****pico-1.72までの場合 [#n3e9c84a] |
| + | [[この上のPicoUriMapper.class.php の編集>./#i10016f9]]修正も必要です。 1.73以上にアップすれば、pico一般設定の「URIマッピング処理クラス名」にサンプルで同梱されている「PicoUriMapperBySubject」を設定すればOKです。 |
| + | |
| + | **ページ一覧ファイルの準備 [#dbf2a418] |
| + | X2,XCL共通 |
| + | |
| + | 「(html)/uploads/(pico)/」ディレクトリを作成し、パーミッションを「707」「777」など書き込み権限を与えます。 |
| + | |
| + | そして、実際にコンテンツページ記事を作成して、「entry.php」の中身にページ名が正規表現で作成されているかを確認できればOKです。 これで準備は完了。 次はxpWiki側の設定です。 |
| + | |
| + | **xpWikiで外部オートリンクを設定 [#f50577b4] |
| + | 「(html/modules/(xpwiki)/private/ini/pukiwiki.ini.php」に(無ければ作成)、以下を編集。(080930変更) |
| + | |
| + | #code(php,1-){{{ |
| + | <?php |
| + | require ( $root->mytrustdirpath."/ini/".basename(__FILE__) ); |
| + | |
| + | // : 中略 |
| + | |
| + | //// picoへのオートリンク |
| + | $root->ext_autolinks[] = array( |
| + | 'target' => '' , // Target pages split with '&' (prefix search) |
| + | 'priority'=> 40 , // Priority (Intenal AutoLink = 50) |
| + | 'url' => XOOPS_URL.'/uploads/pico/entries.php' , // 空白('')で自己xpWiki, 'ディレクトリ名' は自サイト内の別のxpWiki. |
| + | 'urldat'=> 1 , // urlはオートリンクデータそのもの(0:No, 1:Yes) |
| + | 'case_i' => 1 , // Case insensitive |
| + | 'base' => '' , // ベースページ名 (''[空白] ですべてのページ) |
| + | 'len' => 6 , // オートリンクを有効にする文字数 |
| + | 'enc' => 'EUC-JP' , // 相手先の文字エンコーディング |
| + | 'cache' => 10 , //キャッシュする分数 (最小値: 10分) |
| + | 'title' => 'pico:[KEY]' , // <a>タグのtitle属性 ([KEY] は対象語句に置換されます) |
| + | 'pat' => '/modules/pico/index.php?subject=[URL_ENCODE]' , // リンクパターン. ([URL_ENCODE], [WIKI_ENCODE], [EWORDS_ENCODE]が使用可能) |
| + | ); |
| + | |
| + | // : 中略 |
| + | |
| + | ?> |
| + | }}} |
| + | という具合です。 |
| + | これで、xpWikiの記事を作成したとき、「(html)/cache/」ディレクトリ内に「_____.extautolink」というファイルができて、その中身がきちんと正規表現で入っていれば、OKです。 |
| + | |
| + | **補足 [#cf1acc37] |
| + | xpWiki内で外部オートリンクが成功すれば、そのxpWikiがインストールされたサイト内モジュールでxpWikiレンダラーモードを有効にすれば、サイトワイドでこの自動リンクが有効になります。 ちと重くなりますが、使い場所によっては大変便利な機能ですので、お試しください。 |
| + | |
| + | ***検索機能 [#n0db09c8] |
| + | pico-extra_fieldsを使えば、テンプレートを駆使してデータベースの検索機能のようなものが作れます。 |
| + | 参考:(XUGJマニュアル)[[ModuleManuals/pico/extra_fields>http://www.xugj.org/modules/xpwiki/?ModuleManuals%2F%E2%80%8Bpico%2Fextra_fields]] |
| + | |
| + | 実際に検索機能を付加したテンプレートを、参考までに下記に公開しておきます。 |
| + | なお、実装サイトは[[こちら>http://www.sekisou.org/modules/speakerdb/]]になります。 |
| + | |
| + | #code(html,1-){{ |
| + | <{php}> |
| + | $brands = array('Alcone','Alpine','AltecLansing','Aura','Aurum','BontonAcoustic','Celestion','Coral','Daito','Dayton','Davis','Dinaudio','ElectroVoice','Eton',15=>'Focal',16=>'Fostex','Hi-Vi','Infinity','Infinity','JBL','KEF','Kenwood','Leed','MacAudio','Morel','Onkyo','ParcAudio','Peerless','Phillips','Pioneer','Scan-Speak','Seas','TangBand','Tannoy','Technics','Thiel','VIFA','Yamaha') ; |
| + | $type = array('Corn','Flat','Horn','Dome','Ribbon','RingRadiator','HornDriver','その他'); |
| + | $size = array('その他','01','02','02.5','02.8','03','04','05','06','07','08','10','12','13','14','15','16','17','18','20','22','25','28','30','35','40','50','60','70','80'); |
| + | $imp = array('2','4','6','8','16','その他'); |
| + | $magnet = array('フェライト(外磁)','アルニコ(内磁)','リパルジョン(防磁)','ネオジウム','その他','不明'); |
| + | $this->assign( 'brands',$brands ); |
| + | $this->assign( 'type',$type ); |
| + | $this->assign( 'size',$size ); |
| + | $this->assign( 'imp',$imp ); |
| + | $this->assign( 'magnet',$magnet ); |
| + | <{/php}> |
| + | |
| + | <div class="pico_container" id="<{$mydirname}>_container"> |
| + | |
| + | <{include file="db:`$mydirname`_inc_breadcrumbs.html"}> |
| + | |
| + | <!-- controllers --> |
| + | <div class="pico_controllers"> |
| + | |
| + | <!-- link to menu --> |
| + | <a href="<{$mod_url}>/index.php?page=menu">[<{$smarty.const._MD_PICO_MENU}>]</a> |
| + | |
| + | <{if $category.isadminormod}> |
| + | <a href="<{$mod_url}>/index.php?page=categorymanager&cat_id=<{$category.id}>">[<{$smarty.const._MD_PICO_LINK_EDITCATEGORY}>]</a> |
| + | <{/if}> |
| + | |
| + | <{if $xoops_isadmin}> |
| + | <a href="<{$mod_url}>/admin/index.php?page=category_access&cat_id=<{$category.id}>">[<{$smarty.const._MD_PICO_LINK_CATEGORYPERMISSIONS}>]</a> |
| + | <{/if}> |
| + | |
| + | <{if $xoops_isadmin}> |
| + | <a href="<{$mod_url}>/admin/index.php?page=contents&cat_id=<{$category.id}>">[<{$smarty.const._MD_PICO_LINK_BATCHCONTENTS}>]</a> |
| + | <{/if}> |
| + | |
| + | <{if $category.can_makesubcategory}> |
| + | <a href="<{$mod_url}>/index.php?page=makecategory&pid=<{$category.id}>">[<{$smarty.const._MD_PICO_LINK_MAKESUBCATEGORY}>]</a> |
| + | <{/if}> |
| + | |
| + | <{if $category.can_post}> |
| + | <a href="<{$mod_url}>/index.php?page=makecontent&cat_id=<{$category.id}>&ret=mc<{$category.id}>">[<{$smarty.const._MD_PICO_LINK_MAKECONTENT}>]</a> |
| + | <{/if}> |
| + | |
| + | <!-- link to RSS --> |
| + | <a href="<{$mod_url}>/index.php?page=rss&cat_id=<{$category.id}>">[RSS]</a> |
| + | |
| + | </div> |
| + | |
| + | <{if $category.id == 0}><p><{$mod_config.top_message}></p><{/if}> |
| + | |
| + | <h1><{$category.title}></h1> |
| + | <{if $category.isadminormod}> |
| + | <p> |
| + | <{$smarty.const._MD_PICO_CONTENTS_TOTAL}>:<{$category.redundants.contents_total}> |
| + | <{$smarty.const._MD_PICO_SUBCATEGORIES_TOTAL}>:<{$category.redundants.subcategories_total}> |
| + | </p> |
| + | <{/if}> |
| + | |
| + | <p><{$category.desc}></p> |
| + | |
| + | <!-- list subcategories --> |
| + | <{if $subcategories}> |
| + | <h2><{$smarty.const._MD_PICO_SUBCATEGORIES}></h2> |
| + | <{foreach from=$subcategories item="subcategory"}> |
| + | <dl class="pico_subcategory"> |
| + | <dt> |
| + | <a href="<{$mod_url}>/<{$subcategory.link}>"><{$subcategory.title}></a> |
| + | <{if $category.isadminormod}> |
| + | <{$smarty.const._MD_PICO_CONTENTS_TOTAL}>:<{$subcategory.redundants.contents_total}> |
| + | <{$smarty.const._MD_PICO_SUBCATEGORIES_TOTAL}>:<{$subcategory.redundants.subcategories_total}> |
| + | <{/if}> |
| + | </dt> |
| + | <dd> |
| + | <{$subcategory.desc}> |
| + | </dd> |
| + | </dl> |
| + | <{/foreach}> |
| + | <{/if}> |
| + | |
| + | <!-- list contents --> |
| + | <{if $contents}> |
| + | <h2><{$smarty.const._MD_PICO_CONTENTS}></h2> |
| + | |
| + | <{if $category.depth_in_tree==1}> |
| + | <{foreach from=$contents item="content"}> |
| + | <a href="<{$mod_url}>/<{$content.link}>"> |
| + | <{if $content.public}> |
| + | <{$content.subject}> |
| + | <{elseif $category.isadminormod}> |
| + | <em class="pico_notice"><{$content.subject}></em> |
| + | <{if ! $content.approval}> |
| + | (<{$content.poster_uname}> <{$content.created_time_formatted}> ) |
| + | <{/if}> |
| + | <{/if}> |
| + | </a> |
| + | <{if $category.can_edit}> |
| + | <a href="<{$mod_url}>/index.php?page=contentmanager&content_id=<{$content.id}>&ret=mc<{$category.id}>"><img src="<{$mod_imageurl}>/icon_edit.gif" alt="<{$smarty.const._MD_PICO_LINK_EDITCONTENT}>" /></a> |
| + | <{/if}> |
| + | <{/foreach}> |
| + | <{else}> |
| + | |
| + | <table> |
| + | <tr><th>ブランド</th><th>型式</th><th>公称口径(cm)</th><th>インピーダンス(Ω)</th><th>fo(Hz)</th><th>再生周波数帯域</th><th>音圧レベル(dB/W)</th><th>入力定格/music(W)</th><th>標準価格(税抜)</th> |
| + | <{foreach from=$contents item="content"}> |
| + | <{* unserialize *}> |
| + | <{assign var="ef" value=$content.extra_fields|unserialize}> |
| + | <{assign var="content_display" value=false}> |
| + | <{if $smarty.get.and_query==1}> |
| + | <{if (! $smarty.get.brand && ! $smarty.get.size && ! $smarty.get.type && ! $smarty.get.imp && ! $smarty.get.magnet) || (!$smarty.get.brand || ($smarty.get.brand && $smarty.get.brand==$ef.brand|escape)) && (!$smarty.get.type || ($smarty.get.type && $smarty.get.type==$ef.type|escape)) && (!$smarty.get.size || ($smarty.get.size && $smarty.get.size==$ef.size|escape)) && (!$smarty.get.imp || ($smarty.get.imp && $smarty.get.imp==$ef.imp|escape)) && (!$smarty.get.magnet || ($smarty.get.magnet && $smarty.get.magnet==$ef.magnet|escape))}> |
| + | <{assign var="content_display" value=true}> |
| + | <{/if}> |
| + | <{else}> |
| + | <{if (! $smarty.get.brand && ! $smarty.get.size && ! $smarty.get.type && ! $smarty.get.imp && ! $smarty.get.magnet) || ($smarty.get.brand && $smarty.get.brand==$ef.brand|escape) || ($smarty.get.type && $smarty.get.type==$ef.type|escape) || ($smarty.get.size && $smarty.get.size==$ef.size|escape) || ($smarty.get.imp && $smarty.get.imp==$ef.imp|escape) || ($smarty.get.magnet && $smarty.get.magnet==$ef.magnet|escape)}> |
| + | <{assign var="content_display" value=true}> |
| + | <{/if}> |
| + | <{/if}> |
| + | |
| + | <{if ($content_display=="true")}> |
| + | <tr><td><a href="<{$mod_url}>/<{$content.link}>"> |
| + | <{if $content.public}> |
| + | <{$content.subject}> |
| + | <{elseif $category.isadminormod}> |
| + | <em class="pico_notice"><{$content.subject}></em> |
| + | <{if ! $content.approval}> |
| + | (<{$content.poster_uname}> <{$content.created_time_formatted}> ) |
| + | <{/if}> |
| + | <{/if}> |
| + | </a> |
| + | <{if $category.can_edit}> |
| + | <a href="<{$mod_url}>/index.php?page=contentmanager&content_id=<{$content.id}>&ret=mc<{$category.id}>"><img src="<{$mod_imageurl}>/icon_edit.gif" alt="<{$smarty.const._MD_PICO_LINK_EDITCONTENT}>" /></a> |
| + | <{/if}> |
| + | </td> |
| + | <td> <a href="<{$mod_url}>/index.php?cat_id=<{$category.id}>&brand=<{$ef.brand|escape}>"><{$ef.brand|escape}></a></td> |
| + | <td><a href="<{$mod_url}>/index.php?cat_id=<{$category.id}>&size=<{$ef.size|escape}>"><{$ef.size|escape}></a></td> |
| + | <td><a href="<{$mod_url}>/index.php?cat_id=<{$category.id}>&imp=<{$ef.imp|escape}>"><{$ef.imp|escape}></a></td> |
| + | <td><{$ef.f0|escape}></td> |
| + | <td><{$ef.range|escape}></td> |
| + | <td><{$ef.spl|escape}></td> |
| + | <td><{$ef.pwr|escape}></td> |
| + | <td><{$ef.price|escape}></td> |
| + | </tr> |
| + | <{/if}> |
| + | <{/foreach}> |
| + | </table> |
| + | <{/if}> |
| + | <{/if}> |
| + | <!-- end contents --> |
| + | |
| + | <{if $category.id == 0}> |
| + | <h2>検索</h2> |
| + | <form name="or_query" action="./index.php" method="get" > |
| + | <ul> |
| + | <li><{$smarty.const._MD_PICO_SUBCATEGORIES}> |
| + | <select name="cat_id" id="cat_id"> |
| + | <{foreach from=$subcategories item="subcategory"}> |
| + | <option value=<{$subcategory.id}>><{$subcategory.title}></option> |
| + | <{/foreach}> |
| + | </select> |
| + | ※<font color="red">選択必須</font> |
| + | </li> |
| + | <p>絞込み方法 「and」検索を選択しなければ、「or」検索になります。<br /> |
| + | <input type="checkbox" name="and_query" id="and_query" value="1" checked="checked" /> <label for="and_query">「and」検索</label> |
| + | </p> |
| + | |
| + | <p>以下、検索項目</p> |
| + | |
| + | <!-- brand--> |
| + | <li>ブランド:<select id="brand" name="brand"><option value="" selected="selected">未選択</option> |
| + | <{foreach from=$brands item=brand}> |
| + | <option value="<{$brand}>"><{$brand}></option> |
| + | <{/foreach}> |
| + | </select> |
| + | </li> |
| + | |
| + | <!-- type--> |
| + | <li>タイプ:<select id="type" name="type"><option value="" selected="selected">未選択</option> |
| + | <{foreach from=$type item=type}> |
| + | <option value="<{$type}>"><{$type}></option> |
| + | <{/foreach}> |
| + | </select> |
| + | </li> |
| + | |
| + | <!-- size--> |
| + | <li>口径(cm):<select id="size" name="size"><option value="" selected="selected">未選択</option> |
| + | <{foreach from=$size item=size}> |
| + | <option value="<{$size}>"><{$size}></option> |
| + | <{/foreach}> |
| + | </select> |
| + | </li> |
| + | |
| + | <!-- impedance--> |
| + | <li>インピーダンス(Ω):<select id="imp" name="imp"><option value="" selected="selected">未選択</option> |
| + | <{foreach from=$imp item=imp}> |
| + | <option value="<{$imp}>"><{$imp}></option> |
| + | <{/foreach}> |
| + | </select> |
| + | </li> |
| + | |
| + | <!-- magnet--> |
| + | <li>磁気回路:<select id="magnet" name="magnet"><option value="" selected="selected">未選択</option> |
| + | <{foreach from=$magnet item=magnet}> |
| + | <option value="<{$magnet}>"><{$magnet}></option> |
| + | <{/foreach}> |
| + | </select> |
| + | </li> |
| + | |
| + | <input type="submit" value="送信" /> |
| + | </ul> |
| + | </form> |
| + | <{/if}> |
| + | <hr class="notification" /> |
| + | <{include file='db:system_notification_select.html'}> |
| + | |
| + | </div> |
| + | <!-- end module contents --> |
| + | }} |