E-mail
パスワード
次回から自動ログインする
パスワード紛失
新規登録
ホーム
|
新着情報
|
研究室
|
掲示板
|
ぶろぐ
|
Wiki
|
お問合せ
|
アルバム
|
リンク
|
サイトマップ
|
|
一覧
検索
最新
ヘルプ
ページへ戻る
履歴
リンク元
印刷
inc/pico_autolink
をテンプレートにして作成
xpwiki
:inc/pico_autolink をテンプレートにして作成
開始行:
*picoでxpWikiへの外部Autoリンク
|(080930変更)&br; クエリパターンを、「(pico)/index.php...
**タイトルでリンク可能な特殊文字
タイトルに使っても大丈夫な文字 : $?\*+-/#@%~^ ()=|!{}[...
その他、Σなどのマルチバイト文字も可能。
リンクされない文字 (xpWikiのAutoリンクの制約か) : &"'<>
--------
以前より、とあるサイトでXwordsでxpWikiへの外部Autoリンク...
(参考:[[xpwikiからxwordsへのリンクはできないでしょ...
今回、積層スピーカーの会で、スピーカーDBをcosmoDBからpico...
**準備
***Wrapモード=ON
&font(Red){(080930変更)Autoリンクの際のアクセスを、};
「(xoops_URL)/modules/(pico)/index.php?subject=ABC」
&font(Red){に変更しました。}; 以下、WrapモードONは必須で...
Wrapモードにて、仮想パスでアクセス可能にします。
具体的には、記事タイトルが
「ABC」
であれば、
「/ABC.htm」
という仮想パスを設定することにより、
「(xoops_URL/modules/(pico)/index.php/ABC.htm)」
でアクセス可能になります。
***仮想パスの入力欄を常に表示
defaultの状態では、仮想パス入力欄が出て来ません。
****main_content_form.html の編集
「(trust_path)/modules/pico/templates/main_content_form.h...
(080930追記)仮想パスでなくてもAutoリンク可能になったの...
#code(html,32-){{
<!-- vpath -->
<{* if $mod_config.user_wraps_mode || strstr($content.f...
<tr valign="top" align="left">
<th class="head"><label for="vpath"><{$smarty.const._M...
<td class="even">
<input type="text" name="vpath" id="vpath" size="70" ...
<{if $xoops_isadmin}>
<br />
<select name="wraps_target" onchange="xoopsGetElemen...
<{html_options options=$content.wraps_files selecte...
</select>
<{/if}>
</td>
</tr>
<{* /if *}>
}}
**picoにソースを追加
***X2の場合
picoで記事を作成・編集するたびに、ページ名一覧を正規表現...
****entries_write.php
「trust/modules/pico/include/entries_write.php」というフ...
#code(php,1-){{{{
<?php
// xpwikiから picoへの自動リンクを貼るための、アドオン
// 元ネタ:xpwikiから xwordsへの自動リンクを貼るための、...
// see http://xoops.hypweb.net/modules/forum/index.php?to...
// 小文字・大文字を区別しない? (0 or 1)
define('PAGE_CASE_INSENSITIVE', 0);
global $xoopsDB;
$temp_txt = XOOPS_ROOT_PATH."/uploads/".$this->mydirname....
$entries_dat = XOOPS_ROOT_PATH."/uploads/".$this->mydirna...
$ent_table = $xoopsDB -> prefix ("{$this->mydirname}_cont...
if ($fp1 = fopen($temp_txt, 'wb')) {
$result_entries = $xoopsDB -> query( "SELECT subject ...
while ( list( $entry_term ) = $xoopsDB -> fetchrow( $...
if(mb_strlen($entry_term)>2) {fwrite($fp1, $entry...
}
}
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",...
if ($array_fix) {
$pages = array_map('trim', $pages);
if (PAGE_CASE_INSENSITIVE) $pages = array_map('st...
$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_SPLI...
$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, $sp...
$pages2 = array_slice($pages, $split, $co...
$pats[] = get_matcher_regex_safe($pages1,...
$pats[] = get_matcher_regex_safe($pages2,...
$index = $val;
}
} else {
$pats[] = $pat;
}
}
return join($spliter, $pats);
}
function get_matcher_regex_safe_sub (& $array, $offset = ...
{
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 >...
$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) ...
if ($index < ($i - 1)) {
// Some more keys found
// Recurse
$regex .= str_replace(' ', '\\ ', preg_quote(...
get_matcher_regex_safe_sub($array, $index, $i...
} 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...
return $regex;
}
?>
}}}}
***pico本体ソースの変更
続いて、このソースをインクルードする部分の編集です。 な...
X2の場合はこのフックは必須です。
****PicoControllerInsertContent.class.php の編集
「(trust)/modules/pico/class/PicoControllerInsertContent....
#code(php,75-){{{{
if( $cat_data['post_auto_approved'] ) {
include_once( dirname(dirname(__FILE__)).'/inclu...
// Notify for new content 'global'
pico_main_trigger_event( $this->mydirname , 'global' , ...
// Notify for new content 'category' of all parental ca...
foreach( array_keys( $cat_data['paths_raw'] ) as $cat_i...
pico_main_trigger_event( $this->mydirname , 'category'...
}
// message "registered"
redirect_header( $ret_uri4html , 2 , _MD_PICO_MSG_CONTE...
} else {
}}}}
****PicoControllerUpdateContent.class.php の編集
「(trust)/modules/pico/class/PicoControllerUpdateContent....
#code(php,74-){{{{
if( $cat_data['post_auto_approved'] ) {
include_once( dirname(dirname(__FILE__)).'/inclu...
// message "modified"
redirect_header( $ret_uri4html , 2 , _MD_PICO_MSG_CONTE...
} else {
}}}}
****PicoUriMapper.class.php の編集 (080930追記)
(&font(Red){pico-ver1.73以降では、ハック不要。}; pico一...
「(trust)/modules/pico/class/PicoUriMapper.class.php」の7...
#code(php,76-){{
} else if( @$_GET['cat_id'] !== '0' && ( $this->config['...
$this->request['controller'] = 'menu' ;
$this->request['view'] = 'menu' ;
} else if( @$_GET['subject'] ) {
$xoopsDB =& Database::getInstance() ;
$content_table = $xoopsDB->prefix($this->mydirname."_co...
$sql = "SELECT content_id FROM ".$content_table." WHERE...
$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の場合
XCLではモジュールアップデートで上書きされる危険性を避ける...
(thx GIJOEさん http://www.xugj.org/modules/QandA/ind...
**** PicoSubjectRegexHook.class.php
「(html)/preload」内に、「PicoSubjectRegxHook.class.php」...
#code(php,0-){{{{
<?php
if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
class PicoSubjectRegexHook extends XCube_ActionFilter
{
function preBlockFilter()
{
$this->mRoot->mDelegateManager->add( 'ModuleClass.Pico....
$this->mRoot->mDelegateManager->add( 'ModuleClass.Pico....
}
function hook( $mydirname , $content_id , $cat_data , $r...
{
// xpwikiから picoへの自動リンクを貼るための、アドオン
// 元ネタ:xpwikiから xwordsへの自動リンクを貼るための...
// see http://xoops.hypweb.net/modules/forum/index.php?t...
// 小文字・大文字を区別しない? (0 or 1)
define('PAGE_CASE_INSENSITIVE', 0);
global $xoopsDB;
$temp_txt = XOOPS_ROOT_PATH."/uploads/".$mydirname."/ent...
$entries_dat = XOOPS_ROOT_PATH."/uploads/".$mydirname."/...
$ent_table = $xoopsDB -> prefix ("{$mydirname}_contents"...
if ($fp1 = fopen($temp_txt, 'wb')) {
$result_entries = $xoopsDB -> query( "SELECT subject...
while ( list( $entry_term ) = $xoopsDB -> fetchrow( ...
if(mb_strlen($entry_term)>2) {fwrite($fp1, $entr...
}
}
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"...
if ($array_fix) {
$pages = array_map('trim', $pages);
if (PAGE_CASE_INSENSITIVE) $pages = array_map('s...
$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_SPL...
$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, $s...
$pages2 = array_slice($pages, $split, $c...
$pats[] = $this->get_matcher_regex_safe(...
$pats[] = $this->get_matcher_regex_safe(...
$index = $val;
}
} else {
$pats[] = $pat;
}
}
return join($spliter, $pats);
} //end of function
function get_matcher_regex_safe_sub (& $array, $offset =...
{
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 ...
$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)...
if ($index < ($i - 1)) {
// Some more keys found
// Recurse
$regex .= str_replace(' ', '\\ ', preg_quote...
$this->get_matcher_regex_safe_sub($array, $i...
} 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[$offse...
return $regex;
} //end of function
} //end of class
?>
}}}}
****pico-1.72までの場合
[[この上のPicoUriMapper.class.php の編集>./#i10016f9]]修...
**ページ一覧ファイルの準備
X2,XCL共通
「(html)/uploads/(pico)/」ディレクトリを作成し、パーミッ...
そして、実際にコンテンツページ記事を作成して、「entry.php...
**xpWikiで外部オートリンクを設定
「(html/modules/(xpwiki)/private/ini/pukiwiki.ini.php」に...
#code(php,1-){{{
<?php
require ( $root->mytrustdirpath."/ini/".basename(__FILE__...
// : 中略
//// picoへのオートリンク
$root->ext_autolinks[] = array(
'target' => '' , // Target pages split with '&' (p...
'priority'=> 40 , // Priority (Intenal AutoLink = 50)
'url' => XOOPS_URL.'/uploads/pico/entries.php' , /...
'urldat'=> 1 , // urlはオートリンクデー...
'case_i' => 1 , // Case insensitive
'base' => '' , // ベースページ名 (''[空白] で...
'len' => 6 , // オートリンクを有効に...
'enc' => 'EUC-JP' , // 相手先の文字エンコー...
'cache' => 10 , //キャッシュする分数 (...
'title' => 'pico:[KEY]' , // <a>タグのtitle属性 ([...
'pat' => '/modules/pico/index.php?subject=[URL_ENCO...
);
// : 中略
?>
}}}
という具合です。
これで、xpWikiの記事を作成したとき、「(html)/cache/」ディ...
**補足
xpWiki内で外部オートリンクが成功すれば、そのxpWikiがイ...
***検索機能
pico-extra_fieldsを使えば、テンプレートを駆使してデータ...
参考:(XUGJマニュアル)[[ModuleManuals/pico/extra_fiel...
実際に検索機能を付加したテンプレートを、参考までに下記...
なお、実装サイトは[[こちら>http://www.sekisou.org/modul...
#code(html,1-){{
<{php}>
$brands = array('Alcone','Alpine','AltecLansing','Aura',...
$type = array('Corn','Flat','Horn','Dome','Ribbon','Ring...
$size = array('その他','01','02','02.5','02.8','03','04'...
$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.co...
<{if $category.isadminormod}>
<a href="<{$mod_url}>/index.php?page=categorymanager&...
<{/if}>
<{if $xoops_isadmin}>
<a href="<{$mod_url}>/admin/index.php?page=category_acc...
<{/if}>
<{if $xoops_isadmin}>
<a href="<{$mod_url}>/admin/index.php?page=contents&...
<{/if}>
<{if $category.can_makesubcategory}>
<a href="<{$mod_url}>/index.php?page=makecategory&pi...
<{/if}>
<{if $category.can_post}>
<a href="<{$mod_url}>/index.php?page=makecontent&cat...
<{/if}>
<!-- link to RSS -->
<a href="<{$mod_url}>/index.php?page=rss&cat_id=<{$c...
</div>
<{if $category.id == 0}><p><{$mod_config.top_message}></p...
<h1><{$category.title}></h1>
<{if $category.isadminormod}>
<p>
<{$smarty.const._MD_PICO_CONTENTS_TOTAL}>:<{$category.re...
<{$smarty.const._MD_PICO_SUBCATEGORIES_TOTAL}>:<{$catego...
</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}>"><{$subcat...
<{if $category.isadminormod}>
<{$smarty.const._MD_PICO_CONTENTS_TOTAL}>:<{$subcateg...
<{$smarty.const._MD_PICO_SUBCATEGORIES_TOTAL}>:<{$sub...
<{/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_for...
<{/if}>
<{/if}>
</a>
<{if $category.can_edit}>
<a href="<{$mod_url}>/index.php?page=contentmanager&am...
<{/if}>
<{/foreach}>
<{else}>
<table>
<tr><th>ブランド</th><th>型式</th><th>公称口径(cm)</th><t...
<{foreach from=$contents item="content"}>
<{* unserialize *}>
<{assign var="ef" value=$content.extra_fields|unserializ...
<{assign var="content_display" value=false}>
<{if $smarty.get.and_query==1}>
<{if (! $smarty.get.brand && ! $smarty.get.size && ! $s...
<{assign var="content_display" value=true}>
<{/if}>
<{else}>
<{if (! $smarty.get.brand && ! $smarty.get.size && ! $s...
<{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_for...
<{/if}>
<{/if}>
</a>
<{if $category.can_edit}>
<a href="<{$mod_url}>/index.php?page=contentmanager&am...
<{/if}>
</td>
<td> <a href="<{$mod_url}>/index.php?cat_id=<{$category....
<td><a href="<{$mod_url}>/index.php?cat_id=<{$category.i...
<td><a href="<{$mod_url}>/index.php?cat_id=<{$category.i...
<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...
<{/foreach}>
</select>
※<font color="red">選択必須</font>
</li>
<p>絞込み方法 「and」検索を選択しなければ、「or」検索に...
<input type="checkbox" name="and_query" id="and_query" v...
</p>
<p>以下、検索項目</p>
<!-- brand-->
<li>ブランド:<select id="brand" name="brand"><option va...
<{foreach from=$brands item=brand}>
<option value="<{$brand}>"><{$brand}></option>
<{/foreach}>
</select>
</li>
<!-- type-->
<li>タイプ:<select id="type" name="type"><option value="...
<{foreach from=$type item=type}>
<option value="<{$type}>"><{$type}></option>
<{/foreach}>
</select>
</li>
<!-- size-->
<li>口径(cm):<select id="size" name="size"><option valu...
<{foreach from=$size item=size}>
<option value="<{$size}>"><{$size}></option>
<{/foreach}>
</select>
</li>
<!-- impedance-->
<li>インピーダンス(Ω):<select id="imp" name="imp"><opti...
<{foreach from=$imp item=imp}>
<option value="<{$imp}>"><{$imp}></option>
<{/foreach}>
</select>
</li>
<!-- magnet-->
<li>磁気回路:<select id="magnet" name="magnet"><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 -->
}}
終了行:
*picoでxpWikiへの外部Autoリンク
|(080930変更)&br; クエリパターンを、「(pico)/index.php...
**タイトルでリンク可能な特殊文字
タイトルに使っても大丈夫な文字 : $?\*+-/#@%~^ ()=|!{}[...
その他、Σなどのマルチバイト文字も可能。
リンクされない文字 (xpWikiのAutoリンクの制約か) : &"'<>
--------
以前より、とあるサイトでXwordsでxpWikiへの外部Autoリンク...
(参考:[[xpwikiからxwordsへのリンクはできないでしょ...
今回、積層スピーカーの会で、スピーカーDBをcosmoDBからpico...
**準備
***Wrapモード=ON
&font(Red){(080930変更)Autoリンクの際のアクセスを、};
「(xoops_URL)/modules/(pico)/index.php?subject=ABC」
&font(Red){に変更しました。}; 以下、WrapモードONは必須で...
Wrapモードにて、仮想パスでアクセス可能にします。
具体的には、記事タイトルが
「ABC」
であれば、
「/ABC.htm」
という仮想パスを設定することにより、
「(xoops_URL/modules/(pico)/index.php/ABC.htm)」
でアクセス可能になります。
***仮想パスの入力欄を常に表示
defaultの状態では、仮想パス入力欄が出て来ません。
****main_content_form.html の編集
「(trust_path)/modules/pico/templates/main_content_form.h...
(080930追記)仮想パスでなくてもAutoリンク可能になったの...
#code(html,32-){{
<!-- vpath -->
<{* if $mod_config.user_wraps_mode || strstr($content.f...
<tr valign="top" align="left">
<th class="head"><label for="vpath"><{$smarty.const._M...
<td class="even">
<input type="text" name="vpath" id="vpath" size="70" ...
<{if $xoops_isadmin}>
<br />
<select name="wraps_target" onchange="xoopsGetElemen...
<{html_options options=$content.wraps_files selecte...
</select>
<{/if}>
</td>
</tr>
<{* /if *}>
}}
**picoにソースを追加
***X2の場合
picoで記事を作成・編集するたびに、ページ名一覧を正規表現...
****entries_write.php
「trust/modules/pico/include/entries_write.php」というフ...
#code(php,1-){{{{
<?php
// xpwikiから picoへの自動リンクを貼るための、アドオン
// 元ネタ:xpwikiから xwordsへの自動リンクを貼るための、...
// see http://xoops.hypweb.net/modules/forum/index.php?to...
// 小文字・大文字を区別しない? (0 or 1)
define('PAGE_CASE_INSENSITIVE', 0);
global $xoopsDB;
$temp_txt = XOOPS_ROOT_PATH."/uploads/".$this->mydirname....
$entries_dat = XOOPS_ROOT_PATH."/uploads/".$this->mydirna...
$ent_table = $xoopsDB -> prefix ("{$this->mydirname}_cont...
if ($fp1 = fopen($temp_txt, 'wb')) {
$result_entries = $xoopsDB -> query( "SELECT subject ...
while ( list( $entry_term ) = $xoopsDB -> fetchrow( $...
if(mb_strlen($entry_term)>2) {fwrite($fp1, $entry...
}
}
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",...
if ($array_fix) {
$pages = array_map('trim', $pages);
if (PAGE_CASE_INSENSITIVE) $pages = array_map('st...
$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_SPLI...
$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, $sp...
$pages2 = array_slice($pages, $split, $co...
$pats[] = get_matcher_regex_safe($pages1,...
$pats[] = get_matcher_regex_safe($pages2,...
$index = $val;
}
} else {
$pats[] = $pat;
}
}
return join($spliter, $pats);
}
function get_matcher_regex_safe_sub (& $array, $offset = ...
{
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 >...
$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) ...
if ($index < ($i - 1)) {
// Some more keys found
// Recurse
$regex .= str_replace(' ', '\\ ', preg_quote(...
get_matcher_regex_safe_sub($array, $index, $i...
} 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...
return $regex;
}
?>
}}}}
***pico本体ソースの変更
続いて、このソースをインクルードする部分の編集です。 な...
X2の場合はこのフックは必須です。
****PicoControllerInsertContent.class.php の編集
「(trust)/modules/pico/class/PicoControllerInsertContent....
#code(php,75-){{{{
if( $cat_data['post_auto_approved'] ) {
include_once( dirname(dirname(__FILE__)).'/inclu...
// Notify for new content 'global'
pico_main_trigger_event( $this->mydirname , 'global' , ...
// Notify for new content 'category' of all parental ca...
foreach( array_keys( $cat_data['paths_raw'] ) as $cat_i...
pico_main_trigger_event( $this->mydirname , 'category'...
}
// message "registered"
redirect_header( $ret_uri4html , 2 , _MD_PICO_MSG_CONTE...
} else {
}}}}
****PicoControllerUpdateContent.class.php の編集
「(trust)/modules/pico/class/PicoControllerUpdateContent....
#code(php,74-){{{{
if( $cat_data['post_auto_approved'] ) {
include_once( dirname(dirname(__FILE__)).'/inclu...
// message "modified"
redirect_header( $ret_uri4html , 2 , _MD_PICO_MSG_CONTE...
} else {
}}}}
****PicoUriMapper.class.php の編集 (080930追記)
(&font(Red){pico-ver1.73以降では、ハック不要。}; pico一...
「(trust)/modules/pico/class/PicoUriMapper.class.php」の7...
#code(php,76-){{
} else if( @$_GET['cat_id'] !== '0' && ( $this->config['...
$this->request['controller'] = 'menu' ;
$this->request['view'] = 'menu' ;
} else if( @$_GET['subject'] ) {
$xoopsDB =& Database::getInstance() ;
$content_table = $xoopsDB->prefix($this->mydirname."_co...
$sql = "SELECT content_id FROM ".$content_table." WHERE...
$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の場合
XCLではモジュールアップデートで上書きされる危険性を避ける...
(thx GIJOEさん http://www.xugj.org/modules/QandA/ind...
**** PicoSubjectRegexHook.class.php
「(html)/preload」内に、「PicoSubjectRegxHook.class.php」...
#code(php,0-){{{{
<?php
if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
class PicoSubjectRegexHook extends XCube_ActionFilter
{
function preBlockFilter()
{
$this->mRoot->mDelegateManager->add( 'ModuleClass.Pico....
$this->mRoot->mDelegateManager->add( 'ModuleClass.Pico....
}
function hook( $mydirname , $content_id , $cat_data , $r...
{
// xpwikiから picoへの自動リンクを貼るための、アドオン
// 元ネタ:xpwikiから xwordsへの自動リンクを貼るための...
// see http://xoops.hypweb.net/modules/forum/index.php?t...
// 小文字・大文字を区別しない? (0 or 1)
define('PAGE_CASE_INSENSITIVE', 0);
global $xoopsDB;
$temp_txt = XOOPS_ROOT_PATH."/uploads/".$mydirname."/ent...
$entries_dat = XOOPS_ROOT_PATH."/uploads/".$mydirname."/...
$ent_table = $xoopsDB -> prefix ("{$mydirname}_contents"...
if ($fp1 = fopen($temp_txt, 'wb')) {
$result_entries = $xoopsDB -> query( "SELECT subject...
while ( list( $entry_term ) = $xoopsDB -> fetchrow( ...
if(mb_strlen($entry_term)>2) {fwrite($fp1, $entr...
}
}
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"...
if ($array_fix) {
$pages = array_map('trim', $pages);
if (PAGE_CASE_INSENSITIVE) $pages = array_map('s...
$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_SPL...
$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, $s...
$pages2 = array_slice($pages, $split, $c...
$pats[] = $this->get_matcher_regex_safe(...
$pats[] = $this->get_matcher_regex_safe(...
$index = $val;
}
} else {
$pats[] = $pat;
}
}
return join($spliter, $pats);
} //end of function
function get_matcher_regex_safe_sub (& $array, $offset =...
{
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 ...
$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)...
if ($index < ($i - 1)) {
// Some more keys found
// Recurse
$regex .= str_replace(' ', '\\ ', preg_quote...
$this->get_matcher_regex_safe_sub($array, $i...
} 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[$offse...
return $regex;
} //end of function
} //end of class
?>
}}}}
****pico-1.72までの場合
[[この上のPicoUriMapper.class.php の編集>./#i10016f9]]修...
**ページ一覧ファイルの準備
X2,XCL共通
「(html)/uploads/(pico)/」ディレクトリを作成し、パーミッ...
そして、実際にコンテンツページ記事を作成して、「entry.php...
**xpWikiで外部オートリンクを設定
「(html/modules/(xpwiki)/private/ini/pukiwiki.ini.php」に...
#code(php,1-){{{
<?php
require ( $root->mytrustdirpath."/ini/".basename(__FILE__...
// : 中略
//// picoへのオートリンク
$root->ext_autolinks[] = array(
'target' => '' , // Target pages split with '&' (p...
'priority'=> 40 , // Priority (Intenal AutoLink = 50)
'url' => XOOPS_URL.'/uploads/pico/entries.php' , /...
'urldat'=> 1 , // urlはオートリンクデー...
'case_i' => 1 , // Case insensitive
'base' => '' , // ベースページ名 (''[空白] で...
'len' => 6 , // オートリンクを有効に...
'enc' => 'EUC-JP' , // 相手先の文字エンコー...
'cache' => 10 , //キャッシュする分数 (...
'title' => 'pico:[KEY]' , // <a>タグのtitle属性 ([...
'pat' => '/modules/pico/index.php?subject=[URL_ENCO...
);
// : 中略
?>
}}}
という具合です。
これで、xpWikiの記事を作成したとき、「(html)/cache/」ディ...
**補足
xpWiki内で外部オートリンクが成功すれば、そのxpWikiがイ...
***検索機能
pico-extra_fieldsを使えば、テンプレートを駆使してデータ...
参考:(XUGJマニュアル)[[ModuleManuals/pico/extra_fiel...
実際に検索機能を付加したテンプレートを、参考までに下記...
なお、実装サイトは[[こちら>http://www.sekisou.org/modul...
#code(html,1-){{
<{php}>
$brands = array('Alcone','Alpine','AltecLansing','Aura',...
$type = array('Corn','Flat','Horn','Dome','Ribbon','Ring...
$size = array('その他','01','02','02.5','02.8','03','04'...
$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.co...
<{if $category.isadminormod}>
<a href="<{$mod_url}>/index.php?page=categorymanager&...
<{/if}>
<{if $xoops_isadmin}>
<a href="<{$mod_url}>/admin/index.php?page=category_acc...
<{/if}>
<{if $xoops_isadmin}>
<a href="<{$mod_url}>/admin/index.php?page=contents&...
<{/if}>
<{if $category.can_makesubcategory}>
<a href="<{$mod_url}>/index.php?page=makecategory&pi...
<{/if}>
<{if $category.can_post}>
<a href="<{$mod_url}>/index.php?page=makecontent&cat...
<{/if}>
<!-- link to RSS -->
<a href="<{$mod_url}>/index.php?page=rss&cat_id=<{$c...
</div>
<{if $category.id == 0}><p><{$mod_config.top_message}></p...
<h1><{$category.title}></h1>
<{if $category.isadminormod}>
<p>
<{$smarty.const._MD_PICO_CONTENTS_TOTAL}>:<{$category.re...
<{$smarty.const._MD_PICO_SUBCATEGORIES_TOTAL}>:<{$catego...
</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}>"><{$subcat...
<{if $category.isadminormod}>
<{$smarty.const._MD_PICO_CONTENTS_TOTAL}>:<{$subcateg...
<{$smarty.const._MD_PICO_SUBCATEGORIES_TOTAL}>:<{$sub...
<{/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_for...
<{/if}>
<{/if}>
</a>
<{if $category.can_edit}>
<a href="<{$mod_url}>/index.php?page=contentmanager&am...
<{/if}>
<{/foreach}>
<{else}>
<table>
<tr><th>ブランド</th><th>型式</th><th>公称口径(cm)</th><t...
<{foreach from=$contents item="content"}>
<{* unserialize *}>
<{assign var="ef" value=$content.extra_fields|unserializ...
<{assign var="content_display" value=false}>
<{if $smarty.get.and_query==1}>
<{if (! $smarty.get.brand && ! $smarty.get.size && ! $s...
<{assign var="content_display" value=true}>
<{/if}>
<{else}>
<{if (! $smarty.get.brand && ! $smarty.get.size && ! $s...
<{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_for...
<{/if}>
<{/if}>
</a>
<{if $category.can_edit}>
<a href="<{$mod_url}>/index.php?page=contentmanager&am...
<{/if}>
</td>
<td> <a href="<{$mod_url}>/index.php?cat_id=<{$category....
<td><a href="<{$mod_url}>/index.php?cat_id=<{$category.i...
<td><a href="<{$mod_url}>/index.php?cat_id=<{$category.i...
<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...
<{/foreach}>
</select>
※<font color="red">選択必須</font>
</li>
<p>絞込み方法 「and」検索を選択しなければ、「or」検索に...
<input type="checkbox" name="and_query" id="and_query" v...
</p>
<p>以下、検索項目</p>
<!-- brand-->
<li>ブランド:<select id="brand" name="brand"><option va...
<{foreach from=$brands item=brand}>
<option value="<{$brand}>"><{$brand}></option>
<{/foreach}>
</select>
</li>
<!-- type-->
<li>タイプ:<select id="type" name="type"><option value="...
<{foreach from=$type item=type}>
<option value="<{$type}>"><{$type}></option>
<{/foreach}>
</select>
</li>
<!-- size-->
<li>口径(cm):<select id="size" name="size"><option valu...
<{foreach from=$size item=size}>
<option value="<{$size}>"><{$size}></option>
<{/foreach}>
</select>
</li>
<!-- impedance-->
<li>インピーダンス(Ω):<select id="imp" name="imp"><opti...
<{foreach from=$imp item=imp}>
<option value="<{$imp}>"><{$imp}></option>
<{/foreach}>
</select>
</li>
<!-- magnet-->
<li>磁気回路:<select id="magnet" name="magnet"><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 -->
}}
ページ名:
ぺージ情報
ぺージ名 :
inc/pico_autolink
ページ別名 :
未設定
ページ作成 :
なーお
閲覧可
グループ :
すべての訪問者
ユーザー :
すべての訪問者
編集可
グループ :
なし
ユーザー :
なし
Counter: 0, today: 0, yesterday: 0
Go Page Top
Powered by
XOOPS Cube
2.2 © 2001-2012
XOOPS Cube Project
, theme design by
BCOOL
ログイン
ユーザ名:
パスワード:
IDとパスワードを記憶
パスワード紛失
新規登録
メインメニュー
ホーム
なーお'nぶろぐ
フォーラム
なーお'n研究室
xpwiki
最新ページ一覧
全ページ一覧
ヘルプ
新着情報
マイアルバム
ラン記録
大会リスト
シューズリスト
画像マネージャ
マイフレンド
WEBリンク集