function smarty_modifier_load_block($block) { CODOF\Hook::call($block); if (isset(CODOF\Plugin::$data[$block])) { foreach (CODOF\Plugin::$data[$block] as $op) { echo $op; } } }
* used to modify/add html * can also be used to add js/css by dom manipulation * but it is preferred to add resources using add_* functions * from tpl_before_* hook */ public function body($dom) { $container = $dom->getElementById('codo_login_container'); $container2 = $dom->getElementById('codo_register_form'); $html = <<<EOD <div class="row codo_uni_login" id="codo_uni_login"> <div class="codo_login_btn codo_twitter_login_btn" id="codo_login_with_twitter"><span>Twitter</span></div> <div class="codo_login_btn codo_fb_login_btn" id="codo_login_with_facebook"><span>Facebook</span></div> <div class="codo_login_btn codo_google_login_btn" id="codo_login_with_google"><span>Google</span></div> </div> EOD; //prepend our code if ($container != null) { $container->innertext = $html . $container->innertext; } if ($container2 != null) { $container2->innertext = $html . $container2->innertext; } } } $uni = new uni_login(); CODOF\Hook::add('tpl_before_user_login', array($uni, "head")); CODOF\Hook::add('tpl_after_user_login', array($uni, "body")); CODOF\Hook::add('tpl_before_user_register', array($uni, "head")); CODOF\Hook::add('tpl_after_user_register', array($uni, "body"));
<div id="_codo_sso_client_id">{$sso_client_id}</div> <div id="_codo_sso_get_user_path">{$sso_get_user_path}</div> <div id="_codo_sso_login_user_path">{$sso_login_user_path}</div> EOD; //prepend our code $container->innertext = $html . $container->innertext; $container = $dom->getElementById('codo_navbar_content'); $html = <<<EOD <div class="codo_login_loading"></div> EOD; //prepend our code $container->innertext = $html . $container->innertext; } function add_login_as($dom) { $container = $dom->getElementById('codo_login_container'); $sso_name = CODOF\Util::get_opt('sso_name'); $html = <<<EOD <div class="row codo_sso"> <div class="codo_sso_login_btn codo_sso_login_btn" id="codo_login_with_sso">with <span>{$sso_name}</span></div> </div> EOD; //prepend our code $container->innertext = $html . $container->innertext; } CODOF\Hook::add('tpl_after_user_login', "add_login_as"); //Below hooks are called on all pages CODOF\Hook::add('before_site_head', "add_sso_js"); CODOF\Hook::add('after_site_head', "add_sso_defs");
function get_hooks() { CODOF\Hook::get_hooks(); }