本文整理汇总了PHP中Hook类的典型用法代码示例。如果您正苦于以下问题:PHP Hook类的具体用法?PHP Hook怎么用?PHP Hook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hook类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: install
function install()
{
if (Hook::get('orderAddressVerification') == false) {
$hook = new Hook();
$hook->name = 'orderAddressVerification';
$hook->title = 'Order address verificatio';
$hook->description = 'Allows modules to verify delivery and billing address in an order, e.g. require them to be in the same country';
$hook->add();
}
if (parent::install() == false) {
return false;
}
return true;
}
示例4: 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;
}
示例5: hookFooter
public function hookFooter($params)
{
if (!$this->isCached('blockmyaccountfooter.tpl', $this->getCacheId())) {
$this->smarty->assign(array('voucherAllowed' => CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN'), 'HOOK_BLOCK_MY_ACCOUNT' => Hook::exec('displayMyAccountBlockfooter')));
}
return $this->display(__FILE__, 'blockmyaccountfooter.tpl', $this->getCacheId());
}
示例6: run
/**
* 运行框架
*/
public static function run()
{
try {
self::init();
Hook::init(BASE_PATH);
Hook::listen('appBegin');
Hook::listen('routeParseUrl', array(Config::get('REWRITE_RULE'), Config::get('REWRITE_ON')));
//default route
if (!defined('APP_NAME') || !defined('CONTROLLER_NAME') || !defined('ACTION_NAME')) {
Route::parseUrl(Config::get('REWRITE_RULE'), Config::get('REWRITE_ON'));
}
//execute action
$controller = '\\app\\' . APP_NAME . '\\controller\\' . CONTROLLER_NAME . 'Controller';
$action = ACTION_NAME;
if (!class_exists($controller)) {
throw new \Exception("Controller '{$controller}' not found", 404);
}
$obj = new $controller();
if (!method_exists($obj, $action)) {
throw new \Exception("Action '{$controller}::{$action}()' not found", 404);
}
Hook::listen('actionBefore', array($obj, $action));
$obj->{$action}();
Hook::listen('actionAfter', array($obj, $action));
} catch (\Exception $e) {
Hook::listen('appError', array($e));
}
Hook::listen('appEnd');
}
示例7: create
/**
* Create page
*
* @param array $val
* @return \App\Models\Page
*/
public function create($val)
{
$expected = ['title', 'description', 'website', 'url' => '', 'category'];
/**
* @var $title
* @var $description
* @var $website
* @var $category
* @var $url
*/
extract(array_merge($expected, $val));
if (!empty($title) and !empty($category)) {
$page = $this->model->newInstance();
$page->title = sanitizeText($title, 130);
$page->slug = sanitizeText($url);
$page->user_id = \Auth::user()->id;
$page->description = \Hook::fire('filter-text', sanitizeText($description));
$page->category_id = sanitizeText($category);
$page->website = sanitizeText($website);
$page->save();
$page->save();
$this->event->fire('page.add', [$page]);
return $page;
}
return false;
}
示例8: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$this->addJS(_THEME_JS_DIR_ . 'index.js');
$this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'), 'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'), 'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent')));
$this->setTemplate(_PS_THEME_DIR_ . 'index.tpl');
}
示例9: builder
public function builder()
{
$this->load->model('admin/admin_menu');
$this->load->add_package_path(APPPATH . 'third_party/scrud/');
$var = array();
$_GET['crud_components'] = 'crud_components';
$var['main_menu'] = $this->admin_menu->fetch('tool');
$conf = array();
if (!file_exists(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/crud_components.php')) {
exit;
} else {
require __DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/crud_components.php';
}
$hook = Hook::singleton();
$hook->addFunction('SCRUD_ADD_FORM', 'addTableElement');
$hook->addFunction('SCRUD_EDIT_FORM', 'addTableElement');
$hook->addFunction('SCRUD_ADD_CONFIRM', 'addTableElement');
$hook->addFunction('SCRUD_EDIT_CONFIRM', 'addTableElement');
$hook->addFunction('SCRUD_VIEW_FORM', 'addTableElement');
$hook->addFunction('SCRUD_CONFRIM_DELETE_FORM', 'addTableElement');
$hook->addFunction('SCRUD_BEFORE_UPDATE', 'removeConfig');
$hook->addFunction('SCRUD_BEFORE_SAVE', 'checkGroup');
$hook->addFunction('SCRUD_COMPLETE_DELETE', 'completeDelete');
$conf['theme_path'] = FCPATH . 'application/views/admin/component/templates/builder';
$this->load->library('crud', array('table' => 'crud_components', 'conf' => $conf));
$var['main_content'] = $this->load->view('admin/component/builder', array('content' => $this->crud->process()), true);
$this->load->model('admin/admin_footer');
$var['main_footer'] = $this->admin_footer->fetch();
$this->load->view('layouts/admin/scrud/browse', $var);
}
示例10: setDeliveryNumber
public function setDeliveryNumber($order_invoice_id, $id_shop)
{
if (!$order_invoice_id)
return false;
$number = Configuration::get('PS_DELIVERY_NUMBER', null, null, $id_shop);
// If invoice start number has been set, you clean the value of this configuration
if ($number)
Configuration::updateValue('PS_DELIVERY_NUMBER', false, false, null, $id_shop);
$order_invoice = new OrderInvoice($order_invoice_id);
$order = new Order($order_invoice->id_order);
$cart = new Cart($order->id_cart);
if($ref = Hook::exec('actionBeforeAddDeliveryNumber', array('order'=>$order,'cart'=>$cart,'number'=>$number)))
$number = $ref;
$sql = 'UPDATE `'._DB_PREFIX_.'order_invoice` SET delivery_number =';
if ($number)
$sql .= (int)$number;
else
$sql .= '(SELECT new_number FROM (SELECT (MAX(`delivery_number`) + 1) AS new_number
FROM `'._DB_PREFIX_.'order_invoice`) AS result)';
$sql .=' WHERE `id_order_invoice` = '.(int)$order_invoice_id;
return Db::getInstance()->execute($sql);
}
示例11: 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'))));
}
}
示例12: index
public function index()
{
$this->load->model('crud_auth');
$this->load->model('admin/admin_menu');
$this->load->model('user/user_menu');
$this->load->add_package_path(APPPATH . 'third_party/scrud/');
$crudAuth = $this->session->userdata('CRUD_AUTH');
$var = array();
$conf = array();
$var['main_menu'] = $this->admin_menu->fetch('account');
$hook = Hook::singleton();
$hook->addFunction('SCRUD_EDIT_FORM', 'removeElement');
$hook->addFunction('SCRUD_EDIT_CONFIRM', 'removeElement');
$hook->addFunction('SCRUD_BEFORE_VALIDATE', 'removeValidate');
$hook->addFunction('SCRUD_COMPLETE_UPDATE', 'completeUpdate');
$hook->addFunction('SCRUD_BEFORE_SAVE', 'removeElementData');
if (!isset($_GET['xtype'])) {
$_GET['xtype'] = 'form';
}
$_GET['table'] = 'crud_users';
$_GET['key']['crud_users.id'] = $crudAuth['id'];
$_SERVER['QUERY_STRING'] = $_SERVER['QUERY_STRING'] . '&key[crud_users.id]=' . $crudAuth['id'];
if (!file_exists(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/' . $this->input->get('table') . '.php')) {
exit;
} else {
require __DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/' . $this->input->get('table') . '.php';
}
$conf['theme_path'] = FCPATH . 'application/views/user/profile/crud';
$this->load->library('crud', array('table' => $this->input->get('table'), 'conf' => $conf));
$var['main_content'] = $this->load->view('user/profile/profile', array('content' => $this->crud->process(), 'user_menu' => $this->user_menu->fetch('profile')), true);
$this->load->model('admin/admin_footer');
$var['main_footer'] = $this->admin_footer->fetch();
$this->load->view('layouts/user/default', $var);
}
示例13: init
/**
* Initialize a cURL session.
*
* @return Recipe_HTTP_Session_Curl
*/
protected function init()
{
$this->resource = @curl_init();
if (!$this->resource) {
throw new Recipe_Exception_Generic("Connection faild via cURL request.");
}
Hook::event("HttpRequestInitFirst", array($this));
@curl_setopt($this->resource, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($this->resource, CURLOPT_TIMEOUT, self::TIMEOUT);
$url = $this->webpage;
if (count($this->getGetArgs()) > 0) {
$url .= "?" . $this->getGetArgs(false);
}
@curl_setopt($this->resource, CURLOPT_URL, $url);
if ($this->getRequestType() == "GET") {
@curl_setopt($this->resource, CURLOPT_HTTPGET, true);
} else {
if ($this->getRequestType() == "POST") {
@curl_setopt($this->resource, CURLOPT_POST, true);
@curl_setopt($this->resource, CURLOPT_POSTFIELDS, $this->getPostArgs(false));
} else {
if ($this->getRequestType() == "PUT") {
@curl_setopt($this->resource, CURLOPT_PUT, true);
}
}
}
$this->response = curl_exec($this->resource);
$this->errorNo = curl_errno($this->resource);
if ($this->errorNo) {
$this->error = curl_error($this->resource);
throw new Recipe_Exception_Generic("There is an error occured in cURL session (" . $this->errorNo . "): " . $this->error);
}
Hook::event("HttpRequestInitLast", array($this));
return $this;
}
示例14: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$this->productSort();
// Override default configuration values: cause the new products page must display latest products first.
if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
$this->orderBy = 'date_add';
$this->orderWay = 'DESC';
}
$nbProducts = (int) Product::getNewProducts($this->context->language->id, null, null, true);
$this->pagination($nbProducts);
$products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay);
$this->addColorsToProductList($products);
$this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
if ($this->ajax) {
$product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
$pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl');
$nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products));
$nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100;
echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage));
die;
} else {
$this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
}
}
示例15: index
public function index()
{
$this->load->model('admin/admin_menu');
$this->load->add_package_path(APPPATH . 'third_party/scrud/');
$_GET['table'] = 'crud_languages';
$var = array();
$conf = array();
$var['main_menu'] = $this->admin_menu->fetch('tool');
if (!file_exists(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/' . $_GET['table'] . '.php')) {
exit;
} else {
require __DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/' . $_GET['table'] . '.php';
}
$hook = Hook::singleton();
$hook->addFunction('SCRUD_EDIT_FORM', 'edit_form');
$hook->addFunction('SCRUD_VALIDATE', 'validate_language_code');
$hook->addFunction('SCRUD_BEFORE_UPDATE', 'before_update');
$hook->addFunction('SCRUD_COMPLETE_SAVE', 'complete_save');
$hook->addFunction('SCRUD_COMPLETE_DELETE', 'complete_delete');
$conf['theme_path'] = FCPATH . 'application/views/admin/language/templates';
$this->load->library('crud', array('table' => $_GET['table'], 'conf' => $conf));
$var['main_content'] = $this->load->view('admin/language/index', array('content' => $this->crud->process()), true);
$this->load->model('admin/admin_footer');
$var['main_footer'] = $this->admin_footer->fetch();
$this->load->view('layouts/admin/user/default', $var);
}