Skip to content

Instantly share code, notes, and snippets.

@ahomu
Created July 5, 2012 10:28
Show Gist options
  • Save ahomu/3052843 to your computer and use it in GitHub Desktop.
Save ahomu/3052843 to your computer and use it in GitHub Desktop.
#ablogcms モジュールID変更画面に飛ぶボタンをつくるためのHookサンプル
<?php
// php/ACMS/User/Hook.php として作成
// config.server.phpのHOOK_ENABLEを1にしてください
class ACMS_User_Hook extends ACMS_Hook
{
/**
* @param string &$res
* @param ACMS_GET $thisModule
*/
public function beforeGetFire($res, $thisModule)
{
$className = str_replace(array('ACMS_GET_', 'ACMS_User_GET_'), '', get_class($thisModule));
$res = str_replace(array(
'{hook_module_id}',
'{hook_module_bid}',
'{hook_module_name}',
), array(
$thisModule->mid,
$thisModule->mbid,
strtolower(preg_replace('@(?<=[a-zA-Z0-9])([A-Z])@', '-$1', $className)),
), $res);
}
}
/*
<!-- BEGIN_MODULE Touch_SessionWithAdministration -->
<form action="" method="post" class="adminBtn">
<input type="hidden" name="mid" value="{hook_module_id}" />
<input type="hidden" name="query[]" value="mid" />
<input type="hidden" name="admin" value="config_{hook_module_name}" />
<input type="hidden" name="bid" value="{hook_module_bid}" />
<input type="submit" name="ACMS_POST_2GET" value="モジュール設定を変更する" />
</form>
<!-- END_MODULE Touch_SessionWithAdministration -->
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment