本文整理汇总了PHP中Hook::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Hook::add方法的具体用法?PHP Hook::add怎么用?PHP Hook::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hook
的用法示例。
在下文中一共展示了Hook::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SmartHookInsert
public function SmartHookInsert()
{
$hookvalue = array();
require_once dirname(__FILE__) . '/sql/addhook.php';
foreach ($hookvalue as $hkv) {
$hookid = Hook::getIdByName($hkv['name']);
if (!$hookid) {
$add_hook = new Hook();
$add_hook->name = pSQL($hkv['name']);
$add_hook->title = pSQL($hkv['title']);
$add_hook->description = pSQL($hkv['description']);
$add_hook->position = pSQL($hkv['position']);
$add_hook->live_edit = $hkv['live_edit'];
$add_hook->add();
$hookid = $add_hook->id;
if (!$hookid) {
return false;
}
} else {
$up_hook = new Hook($hookid);
$up_hook->update();
}
}
return true;
}
示例2: install
public static function install(array $options = array())
{
$toret = parent::install($options);
$toret = Hook::add('update', 'post', __CLASS__, array('global' => true, 'description' => 'Create the following revision of a post after the content has been updated.')) && $toret;
$toret = Hook::add('create', 'post', __CLASS__, array('global' => true, 'description' => 'Add the first revision of the content after the content has been created.')) && $toret;
return $toret;
}
示例3: loadAddons
private function loadAddons()
{
$data = S('hooks');
if (!$data) {
$hooks = M('hooks')->getField('name,addons', true);
foreach ($hooks as $key => $value) {
if ($value) {
$map['status'] = 1;
$names = explode(',', $value);
$map['name'] = array('IN', $names);
$data = M('Addons')->where($map)->getField('id,name');
if ($data) {
$addons = array_intersect($names, $data);
Hook::add($key, $addons);
}
}
}
S('hooks', Hook::get());
//插件标签
$tpl_tags = array();
$data = M('addons')->getField('id,name');
if ($data) {
foreach ($data as $addon) {
if (is_file("HDCMS/Addons/{$addon}/Tag/{$addon}Tag.class.php")) {
$tpl_tags[] = "@.Addons.{$addon}.Tag.{$addon}Tag";
}
}
}
S('HookTag', array_unique($tpl_tags));
} else {
Hook::import($data, false);
C('TPL_TAGS', array_unique(array_merge(C('TPL_TAGS'), S('HookTag'))));
}
}
示例4: install
public static function install(array $options = array())
{
$toret = parent::install($options);
$toret = Hook::add('output', 'pre', get_called_class(), array('global' => 1)) && $toret;
$toret = Permission::add('anonymous', 'add', get_called_class()) && $toret;
$toret = Permission::add('authenticated', 'add', get_called_class()) && $toret;
return $toret;
}
示例5: __construct
/**
@param key cookie key to use
@param data if present, this is used as $this->data, otherise, key is used to find cookie for data
*/
function __construct($key, $data = null, $options = null)
{
$this->key = $key;
if ($data) {
$this->data = $data;
} else {
$this->data = self::get($key);
}
self::$cookies[$key] =& $this->data;
$this->options = $options;
Hook::add('preHTTPMessageBody', array($this, 'out'), array('deleteAfter' => 1));
}
示例6: upgrade_module_1_5_1
function upgrade_module_1_5_1($module)
{
if (Hook::getIdByName('displayPaymentEu')) {
return true;
}
$new_hook = new Hook();
$new_hook->name = 'displayPaymentEu';
$new_hook->title = 'Display EU payment options (helper)';
$new_hook->description = 'Hook to display payment options';
$new_hook->position = true;
$new_hook->live_edit = false;
return (bool) $new_hook->add() && (bool) $module->registerModulesBackwardCompatHook();
}
示例7: install
function install()
{
if (Hook::get('orderPriceAdjustment') == false) {
$hook = new Hook();
$hook->name = 'orderPriceAdjustment';
$hook->title = 'Order price adjustment';
$hook->description = 'Allows modules to adjust prices in an order after the user has logged in and registered an address, e.g. allows prices based on group memberships and the like.';
$hook->add();
}
if (parent::install() == false) {
return false;
}
return true;
}
示例8: checkOwnerHooks
private function checkOwnerHooks()
{
$hookspos = array('displayTop', 'displayHeaderRight', 'displaySlideshow', 'topNavigation', 'displayPromoteTop', 'displayRightColumn', 'displayLeftColumn', 'displayHome', 'displayFooter', 'displayBottom', 'displayContentBottom', 'displayFootNav', 'displayFooterTop', 'displayFooterBottom');
foreach ($hookspos as $hook) {
if (Hook::getIdByName($hook)) {
} else {
$new_hook = new Hook();
$new_hook->name = pSQL($hook);
$new_hook->title = pSQL($hook);
$new_hook->add();
}
}
return true;
}
示例9: install
function install()
{
if (Hook::get('orderPages') == false) {
$hook = new Hook();
$hook->name = 'orderPages';
$hook->title = 'Order process pages';
$hook->description = 'Adds new pages in the order process';
$hook->add();
}
if (parent::install() == false or $this->registerHook('orderPages') == false) {
return false;
}
return true;
}
示例10: install
function install()
{
if (Hook::get('extraCarrierDetails') == false) {
$hook = new Hook();
$hook->name = 'extraCarrierDetails';
$hook->title = 'Extra carrier dietails';
$hook->description = 'Extra carrier dietails display part';
$hook->add();
}
if (Hook::get('extraCarrierDetailsProcess') == false) {
$hook = new Hook();
$hook->name = 'extraCarrierDetailsProcess';
$hook->title = 'Extra carrier dietails';
$hook->description = 'Extra carrier dietails processing part';
$hook->add();
}
return parent::install();
}
示例11: Config
function __construct($admin_path)
{
$this->check_magic_quotes();
require $admin_path . '/core/library/config.php';
$config = $this->config = new Config($admin_path);
require $config->library_path . '/string.php';
require $config->library_path . '/file.php';
spl_autoload_register(array($this, 'autoload'));
$is_config_loaded = $this->config->load();
$this->setup_error_reporting();
if (!$is_config_loaded) {
$router = new Router($config, null, '/setup/install/');
} else {
$router = new Router($config);
}
$hook = new Hook();
$admin_script = new Admin\Scripts($router->admin_url, $router, $config);
$admin_style = new Admin\Styles($router->admin_url, $router, $config);
$hook->add('admin_head', array($admin_style, 'do_items'), 0, 10);
$hook->add('admin_head', array($admin_script, 'do_head_items'), 0, 10);
$hook->add('admin_footer', array($admin_script, 'do_footer_items'), 0, 100);
$settings = new Settings($config);
$router->settings = $settings;
$active_template = $settings->get_template_about();
$template_script = new Template\Scripts('', $router, $config, $active_template['version']);
$template_style = new Template\Styles('', $router, $config, $active_template['version']);
$hook->add('head', array($template_style, 'do_items'), 0, 10);
$hook->add('head', array($template_script, 'do_head_items'), 0, 10);
$hook->add('footer', array($template_script, 'do_footer_items'), 0, 100);
$user = new User($config, $router);
$view = new View($config, $router, $hook);
if ($settings->get('connection', 'type') && 'direct' != $settings->get('connection', 'type')) {
$class_name = Filesystem::get_class_name($settings->get('connection', 'type'));
$filesystem = new $class_name($config, array('connection_type' => $settings->get('connection', 'type'), 'hostname' => $settings->get('connection', 'hostname'), 'username' => $settings->get('connection', 'username'), 'password' => $settings->get('connection', 'password')));
} else {
$filesystem = new Filesystem\Direct($config);
}
$addon = new Addon($config, $settings, $hook, $admin_script, $admin_style, $template_script, $template_style, $filesystem, $router);
$addon->load_active();
$content = new Content($config, $filesystem, $router, $settings, $hook);
$template = new Template($config, $filesystem, $router, $settings, $hook, $template_script, $template_style, $content);
$router->parse_request_url();
$router->set_controller_class();
$controller_class = $router->controller_class;
$controller = new $controller_class($router, $view, $filesystem, $config, $user, $template, $settings, $hook, $content, $addon);
if (!$user->is_logged_in() && !$controller->is_no_auth_action()) {
Router::redirect($router->admin_url('/user/login/'));
exit;
}
$controller->call_action();
}
示例12: install
public function install()
{
$this->clearCache();
if (!parent::install() || !$this->registerHook('displayHome') || !$this->registerHook('header')) {
return false;
}
$res = $this->createTables();
if ($res) {
$this->installSamples();
}
$hookspos = array('displayTop', 'displayHeaderRight', 'displaySlideshow', 'topNavigation', 'displayPromoteTop', 'displayRightColumn', 'displayLeftColumn', 'displayHome', 'displayFooter', 'displayBottom', 'displayContentBottom', 'displayFootNav', 'displayFooterTop', 'displayFooterBottom');
foreach ($hookspos as $hook) {
if (!Hook::getIdByName($hook)) {
$new_hook = new Hook();
$new_hook->name = pSQL($hook);
$new_hook->title = pSQL($hook);
$new_hook->add();
}
}
return true;
}
示例13: upgrade_module_1_4
function upgrade_module_1_4($object, $install = false)
{
// First uninstall old override
try {
$object->uninstallOldOverrides();
} catch (Exception $e) {
$object->add_error(sprintf(Tools::displayError('Unable to uninstall old override: %s'), $e->getMessage()));
//$this->uninstallOverrides(); remove this line because if module a install an override, then module b install same override, this line will remove override of module a (if you find a bug related to this line please don't forget what i say before)
return false;
}
// Install overrides
try {
$object->installOverrides();
} catch (Exception $e) {
$object->add_error(sprintf(Tools::displayError('Unable to install override: %s'), $e->getMessage()));
//$this->uninstallOverrides(); remove this line because if module a install an override, then module b install same override, this line will remove override of module a (if you find a bug related to this line please don't forget what i say before)
return false;
}
if (!Hook::getIdByName('actionBeforeAddOrder')) {
$hook = new Hook();
$hook->name = 'actionBeforeAddOrder';
$hook->title = 'New orders before order is added';
$hook->description = 'Custom hook for PaymentModule ValidateOrder function';
$hook->position = true;
$hook->live_edit = false;
$hook->add();
}
$id_new_hook = Hook::getIdByName('actionBeforeAddOrder');
$id_old_hook = Hook::getIdByName('actionValidateOrder');
$mod_new_hook = Hook::getModulesFromHook($id_new_hook, $object->id);
$mod_old_hook = Hook::getModulesFromHook($id_old_hook, $object->id);
if (empty($mod_new_hook)) {
$object->registerHook('actionBeforeAddOrder');
}
if (!empty($mod_old_hook)) {
$object->unregisterHook('actionValidateOrder');
}
return true;
}
示例14: run
public function run(&$content)
{
$data = S('hooks');
if (!$data) {
$hooks = M('Hooks')->getField('name,plugins');
foreach ($hooks as $key => $value) {
if ($value) {
$map['status'] = 1;
$names = explode(',', $value);
$map['name'] = array('IN', $names);
$data = M('Plugins')->where($map)->getField('id,name');
if ($data) {
$plugins = array_intersect($names, $data);
Hook::add($key, $plugins);
}
}
}
S('hooks', Hook::get());
} else {
Hook::import($data, false);
}
}
示例15: install
public function install()
{
if (!parent::install() || !$this->registerHook('displayHeader') || !$this->registerHook('displayFooter')) {
return false;
}
$langs = Language::getLanguages(false);
$des = array();
foreach ($langs as $lang) {
$des[$lang['id_lang']] = '';
}
Configuration::updateValue($this->getConfigName('height'), 500);
Configuration::updateValue($this->getConfigName('description'), $des, true);
$hookspos = array('displayTop', 'displayHeaderRight', 'displaySlideshow', 'topNavigation', 'displayPromoteTop', 'displayRightColumn', 'displayLeftColumn', 'displayHome', 'displayFooter', 'displayBottom', 'displayContentBottom', 'displayFootNav', 'displayFooterTop', 'displayMapLocal', 'displayFooterBottom');
foreach ($hookspos as $hook) {
if (!Hook::getIdByName($hook)) {
$new_hook = new Hook();
$new_hook->name = pSQL($hook);
$new_hook->title = pSQL($hook);
$new_hook->add();
}
}
return true;
}