本文整理汇总了PHP中fn_set_hook函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_set_hook函数的具体用法?PHP fn_set_hook怎么用?PHP fn_set_hook使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fn_set_hook函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fn_twg_exim_get_product_mobile_url
/**
* Gets mobile product url
*
* @param $product_id
* @param string $lang_code
* @return bool
*/
function fn_twg_exim_get_product_mobile_url($product_id, $lang_code = '')
{
$company_id = 0;
$company_url = '';
if (fn_allowed_for('ULTIMATE')) {
if (Registry::get('runtime.company_id')) {
$company_id = Registry::get('runtime.company_id');
} else {
$company_id = db_get_field('SELECT company_id FROM ?:products WHERE product_id = ?i', $product_id);
}
$company_url = '&company_id=' . $company_id;
} else {
$company_url = '';
}
$settings = TwigmoSettings::get('customer_connections.' . $company_id);
$use_twg = !empty($settings['access_id']) && ($settings['use_for_phones'] == 'Y' || $settings['use_for_tablets'] == 'Y');
if ($use_twg && fn_twg_use_https_for_customer($company_id)) {
$protocol = 'https';
} else {
$protocol = 'http';
}
$url = fn_url('products.view?product_id=' . $product_id . $company_url, 'C', $protocol, $lang_code);
fn_set_hook('exim_get_product_url', $url, $product_id, $options, $lang_code);
return $url;
}
示例2: smarty_block_styles
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
function smarty_block_styles($params, $content, &$smarty, &$repeat)
{
if ($repeat == true) {
return;
}
$prepend_prefix = Embedded::isEnabled() ? 'html#tygh_html body#tygh_body .tygh' : '';
$styles = array();
$internal_styles = '';
//if (preg_match_all('/\<link(.*?href ?= ?"([^"]+)")?[^\>]*\>/is', $content, $m)) {
if (preg_match_all('/\\<link(.*?href\\s?=\\s?(?:"|\')([^"]+)(?:"|\'))?[^\\>]*\\>/is', $content, $m)) {
foreach ($m[2] as $k => $v) {
$v = preg_replace('/\\?.*?$/', '', $v);
$media = '';
if (strpos($m[1][$k], 'media=') !== false && preg_match('/media="(.*?)"/', $m[1][$k], $_m)) {
$media = $_m[1];
}
$styles[] = array('file' => str_replace(Registry::get('config.current_location'), Registry::get('config.dir.root'), $v), 'relative' => str_replace(Registry::get('config.current_location') . '/', '', $v), 'media' => $media);
}
}
if (preg_match_all('/\\<style.*\\>(.*)\\<\\/style\\>/isU', $content, $m)) {
$internal_styles = implode("\n\n", $m[1]);
}
if (!empty($styles) || !empty($internal_styles)) {
fn_set_hook('styles_block_files', $styles);
list($_area) = Registry::get('view')->getArea();
$filename = fn_merge_styles($styles, $internal_styles, $prepend_prefix, $params, $_area);
$content = '<link type="text/css" rel="stylesheet" href="' . $filename . '" />';
}
return $content;
}
示例3: generate
/**
* Generates menu items from scheme
* @param array $request request params
* @return array menu items
*/
public function generate($request)
{
$menu = fn_get_schema('menu', 'menu', 'php');
$this->_request = $request;
$actions = array();
foreach ($menu as $group => &$menu_data) {
// Get static section
foreach ($menu_data as $root => &$items) {
$items['items'] = $this->_processItems($items['items'], $root, '');
if (empty($items['items'])) {
unset($menu[$group][$root]);
continue;
}
}
}
unset($items, $menu_data);
$menu['top'] = $this->_sort($menu['top']);
$menu['central'] = $this->_sort($menu['central']);
$menu = $this->_getSettingsSections($menu);
fn_preload_lang_vars($this->_lang_cache);
$selected = $this->_selected;
/**
* Changes generated menu items
*
* @param array $request request params
* @param array $menu items
* @param array $actions items Action value, if exists. See: fn_get_route
* @param array $this->selected Menu item, selected by the dispatch
*/
fn_set_hook('backend_menu_generate_post', $request, $menu, $actions, $this->_selected);
return array($menu, $actions, $this->_selected);
}
示例4: fn_image_zoom_check_image
/**
* Check detail image sizes ration
*
* @param array $image_data Image data
* @param array $images Array with initial images
*/
function fn_image_zoom_check_image(&$image_data, &$images)
{
$precision = 80;
$ratio_detailed = round(round($images['detailed']['image_x'] / $images['detailed']['image_y'] * $precision) / $precision, 2);
$ratio_original = round(round($image_data['width'] / $image_data['height'] * $precision) / $precision, 2);
if ($ratio_detailed != $ratio_original) {
if ($ratio_detailed < $ratio_original) {
$new_x = ceil($images['detailed']['image_y'] / $image_data['height'] * $image_data['width']);
$new_y = $images['detailed']['image_y'];
} else {
$new_y = ceil($images['detailed']['image_x'] / $image_data['width'] * $image_data['height']);
$new_x = $images['detailed']['image_x'];
}
$file_path = fn_generate_thumbnail($images['detailed']['relative_path'], $new_x, $new_y, false, true);
/**
* Post hook for check detail image sizes ration
* @param string $file_path File path
* @param array $image_data Image data
* @param array $images Array with initial images
*/
fn_set_hook('image_zoom_check_image_post', $file_path, $image_data, $images);
if ($file_path) {
$image_data['detailed_image_path'] = \Tygh\Storage::instance('images')->getUrl($file_path);
}
}
}
示例5: getPath
protected function getPath()
{
$path = Registry::get('config.dir.root');
if ($this->default) {
$path .= '/var';
}
$path .= '/robots.txt';
fn_set_hook('robots_get_path', $this, $path);
return $path;
}
示例6: fn_get_tag_objects
function fn_get_tag_objects()
{
$types = array();
if (Registry::get('addons.tags.tags_for_products') == 'Y') {
$types['P'] = array('name' => 'products', 'url' => 'products.manage');
}
if (Registry::get('addons.tags.tags_for_pages') == 'Y') {
$types['A'] = array('name' => 'pages', 'url' => 'pages.manage');
}
fn_set_hook('get_tag_objects', $types);
return $types;
}
示例7: getPath
/**
* Gets patterns absolute path
* @param string $style_id style ID
* @return string patterns absolute path
*/
public function getPath($style_id)
{
$path = fn_get_theme_path('[themes]/[theme]/media/images/patterns/', 'C');
/**
* Modifies path to patterns
*
* @param object $this Patterns object
* @param string $path current path
* @param string $style_id style to get path for
*/
fn_set_hook('patterns_get_path', $this, $path, $style_id);
return $path . fn_basename($style_id);
}
示例8: addLink
/**
* Adds new node the breadcrumbs
*
* @param string $lang_value name of language variable
* @param string $link breadcrumb URL
* @param boolean $nofollow Include or not "nofollow" attribute
* @param boolean $is_first Flag that defines if parameter should be added to the beging (default false)
* @return boolean True if breadcrumbs were added, false otherwise
*/
public function addLink($title, $link = '', $nofollow = false, $is_first = false)
{
if ($this->_area == 'A' && !fn_check_view_permissions($link, 'GET')) {
return false;
}
fn_set_hook('add_breadcrumb', $title, $link);
$item = array('title' => $title, 'link' => $link, 'nofollow' => $nofollow);
if ($is_first) {
array_unshift($this->_links, $item);
} else {
$this->_links[] = $item;
}
return true;
}
示例9: fn_get_status_params_definition
function fn_get_status_params_definition($type)
{
$status_params = array();
if ($type == STATUSES_ORDER) {
$status_params = array('color' => array('type' => 'color', 'label' => 'color'), 'notify' => array('type' => 'checkbox', 'label' => 'notify_customer', 'default_value' => 'Y'), 'notify_department' => array('type' => 'checkbox', 'label' => 'notify_orders_department'), 'notify_vendor' => array('type' => 'checkbox', 'label' => 'notify_vendor'), 'inventory' => array('type' => 'select', 'label' => 'inventory', 'variants' => array('I' => 'increase', 'D' => 'decrease')), 'remove_cc_info' => array('type' => 'checkbox', 'label' => 'remove_cc_info', 'default_value' => 'Y'), 'repay' => array('type' => 'checkbox', 'label' => 'pay_order_again'), 'appearance_type' => array('type' => 'select', 'label' => 'invoice_credit_memo', 'variants' => array('D' => 'default', 'I' => 'invoice', 'C' => 'credit_memo', 'O' => 'order')));
if (fn_allowed_for('ULTIMATE:FREE')) {
unset($status_params['notify_vendor']);
} elseif (fn_allowed_for('MULTIVENDOR')) {
$status_params['calculate_for_payouts'] = array('type' => 'checkbox', 'label' => 'charge_to_vendor_account');
} elseif (fn_allowed_for('ULTIMATE')) {
unset($status_params['notify_vendor']);
}
}
fn_set_hook('get_status_params_definition', $status_params, $type);
return $status_params;
}
示例10: smarty_block_styles
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
function smarty_block_styles($params, $content, &$smarty, &$repeat)
{
if ($repeat == true) {
return;
}
$prepend_prefix = Embedded::isEnabled() ? 'html#tygh_html body#tygh_body .tygh' : '';
$current_location = Registry::get('config.current_location');
$styles = array();
$inline_styles = '';
$external_styles = array();
//if (preg_match_all('/\<link(.*?href ?= ?"([^"]+)")?[^\>]*\>/is', $content, $m)) {
if (preg_match_all('/\\<link(.*?href\\s?=\\s?(?:"|\')([^"]+)(?:"|\'))?[^\\>]*\\>/is', $content, $m)) {
foreach ($m[2] as $k => $v) {
$v = preg_replace('/\\?.*?$/', '', $v);
$media = '';
if (strpos($m[1][$k], 'media=') !== false && preg_match('/media="(.*?)"/', $m[1][$k], $_m)) {
$media = $_m[1];
}
if (strpos($v, $current_location) === false || strpos($m[1][$k], 'data-ca-external') !== false) {
// Location is different OR style is skipped for minification
$external_styles[] = str_replace(' data-ca-external="Y"', '', $m[0][$k]);
} else {
$styles[] = array('file' => str_replace($current_location, Registry::get('config.dir.root'), $v), 'relative' => str_replace($current_location . '/', '', $v), 'media' => $media);
}
}
}
if (preg_match_all('/\\<style.*\\>(.*)\\<\\/style\\>/isU', $content, $m)) {
$inline_styles = implode("\n\n", $m[1]);
}
if (!empty($styles) || !empty($inline_styles)) {
fn_set_hook('styles_block_files', $styles);
list($_area) = Tygh::$app['view']->getArea();
$params['compressed'] = true;
$filename = fn_merge_styles($styles, $inline_styles, $prepend_prefix, $params, $_area);
$content = '<link type="text/css" rel="stylesheet" href="' . $filename . '" />';
if (!empty($external_styles)) {
$content .= PHP_EOL . implode(PHP_EOL, $external_styles);
}
}
return $content;
}
示例11: backupFiles
/**
* Makes store files backup
*
* @param array $params Extra params
* backup_files - array List of files/folders to be added to backup
* pack_name - string name of result pack. Will be stored in Registry::get('config.dir.backups') . 'files/' . $pack_name
* fs_compress - bool Compress result dir
* @return string Path to backuped files/archve
*/
public static function backupFiles($params = array())
{
$backup_files = array('app', 'design', 'js', '.htaccess', 'api.php', 'config.local.php', 'config.php', 'index.php', 'init.php', 'robots.txt', 'var/themes_repository', 'var/snapshots');
$backup_files[] = Registry::get('config.admin_index');
if (fn_allowed_for('MULTIVENDOR')) {
$backup_files[] = Registry::get('config.vendor_index');
}
if (!empty($params['backup_files'])) {
$backup_files = $params['backup_files'];
}
if (!empty($params['extra_folders'])) {
$params['extra_folders'] = array_map(function ($path) {
return fn_normalize_path($path);
}, $params['extra_folders']);
$backup_files = array_merge($backup_files, $params['extra_folders']);
}
fn_set_hook('data_keeper_backup_files', $backup_files);
$pack_name = !empty($params['pack_name']) ? $params['pack_name'] : 'backup_' . date('dMY_His', TIME);
$destination_path = fn_get_cache_path(false) . 'tmp/backup/_files/' . $pack_name;
$source_path = Registry::get('config.dir.root' . '/');
fn_set_progress('step_scale', (sizeof($backup_files) + 1) * 2);
fn_set_progress('echo', __('backup_files'), false);
fn_rm($destination_path);
fn_mkdir($destination_path);
foreach ($backup_files as $file) {
fn_set_progress('echo', __('uc_copy_files') . ': <b>' . $file . '</b>', true);
fn_copy($source_path . $file, $destination_path . '/' . $file);
}
if (!empty($params['fs_compress'])) {
fn_set_progress('echo', __('compressing_backup'), true);
$ext = $params['fs_compress'] == 'tgz' ? '.tgz' : '.zip';
$result = fn_compress_files($pack_name . $ext, $pack_name, fn_get_cache_path(false) . 'tmp/backup/_files/');
$destination_path = rtrim($destination_path, '/');
if ($result) {
fn_rename($destination_path . $ext, Registry::get('config.dir.backups') . $pack_name . $ext);
}
fn_rm($destination_path);
$destination_path .= $ext;
}
return $destination_path;
}
示例12: fn_amazon_validate_cart_data
function fn_amazon_validate_cart_data($cart, $request)
{
$items = array();
$_items = $request->CallbackOrderCart->CallbackOrderCartItems;
if (empty($_items)) {
$_items = $request->ProcessedOrder->ProcessedOrderItems;
foreach ($_items->ProcessedOrderItem as $item) {
$items[] = $item;
}
} else {
foreach ($_items->CallbackOrderCartItem as $item) {
$items[] = $item;
}
}
$cart_items_amount = count($cart['products']);
fn_set_hook('amazon_validate_cart', $items, $cart, $cart_items_amount);
if (count($items) == $cart_items_amount || count($items) - 1 == $cart_items_amount) {
foreach ($items as $item) {
$sku = (string) $item->Item->SKU;
if (empty($sku)) {
$sku = (string) $item->SKU;
$qty = (string) $item->Quantity;
$cart_id = (string) $item->ItemCustomData->CartID;
} else {
$qty = (string) $item->Item->Quantity;
$cart_id = (string) $item->Item->ItemCustomData->CartID;
}
$is_valid = false;
fn_set_hook('amazon_validate_cart_item', $cart, $sku, $qty, $cart_id, $is_valid);
if ($is_valid || $sku == 'taxes' && empty($cart_id)) {
continue;
} elseif (!isset($cart['products'][$cart_id]) || $cart['products'][$cart_id]['amount'] != $qty) {
return false;
}
}
} else {
return false;
}
return true;
}
示例13: preloadLangVars
/**
* Loads received language variables into language cache
*
* @param array $var_names Language variable that to be loaded
* @param string $lang_code 2-letter language code
*
* @return boolean True if any of received language variables were added into cache; false otherwise
*/
public static function preloadLangVars($var_names, $lang_code = CART_LANGUAGE)
{
Registry::registerCache('lang_cache', array('language_values', 'ult_language_values'), Registry::cacheLevel('dispatch'), true);
$values = Registry::get('lang_cache.' . $lang_code);
if (empty($values)) {
$values = array();
}
$var_names = array_diff($var_names, array_keys($values));
if ($var_names) {
foreach ($var_names as $index => $var_name) {
$var_names[$index] = strtolower($var_name);
if (isset($values[$var_name])) {
unset($var_names[$index]);
}
}
if (empty($var_names)) {
return true;
}
$fields = array('lang.name' => true, 'lang.value' => true);
$tables = array('?:language_values lang');
$left_join = array();
$condition = array(db_quote('lang.lang_code = ?s', $lang_code), db_quote('lang.name IN (?a)', $var_names));
$params = array();
fn_set_hook('get_lang_var', $fields, $tables, $left_join, $condition, $params);
$joins = !empty($left_join) ? ' LEFT JOIN ' . implode(', ', $left_join) : '';
$new_values = db_get_hash_single_array('SELECT ' . implode(', ', array_keys($fields)) . ' FROM ' . implode(', ', $tables) . $joins . ' WHERE ' . implode(' AND ', $condition), array('name', 'value'));
foreach ($var_names as $var_name) {
if (!isset($new_values[$var_name])) {
$new_values[$var_name] = '_' . $var_name;
}
}
$values = fn_array_merge($values, $new_values);
Registry::set('lang_cache.' . $lang_code, $values);
return true;
}
return false;
}
示例14: fn_rssf_get_items
function fn_rssf_get_items($params, $lang_code = CART_LANGUAGE)
{
$items_data = $additional_data = $block_data = array();
if (!empty($params['bid']) && !empty($params['sid']) && empty($params['category_id'])) {
$block_data = Block::instance()->getById($params['bid'], $params['sid'], array(), $lang_code);
if (!empty($block_data['content']['filling']) && $block_data['content']['filling'] == 'products') {
$_params = array('sort_by' => $block_data['properties']['filling']['products']['rss_sort_by'] == 'U' ? 'updated_timestamp' : 'timestamp', 'sort_order' => 'desc');
$max_items = !empty($block_data['properties']['max_item']) ? $block_data['properties']['max_item'] : 5;
list($products) = fn_get_products($_params, $max_items, $lang_code);
fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_options' => false, 'get_discounts' => false));
$additional_data['title'] = !empty($block_data['properties']['feed_title']) ? $block_data['properties']['feed_title'] : __('products') . '::' . __('page_title', '', $lang_code);
$additional_data['description'] = !empty($block_data['properties']['feed_description']) ? $block_data['properties']['feed_description'] : $additional_data['title'];
$additional_data['link'] = fn_url('', 'C', 'http', $lang_code);
$additional_data['language'] = $lang_code;
$additional_data['lastBuildDate'] = !empty($products[0]['updated_timestamp']) ? $products[0]['updated_timestamp'] : TIME;
$items_data = fn_format_products_items($products, $block_data['properties']['filling']['products'], $lang_code);
}
} else {
//show rss feed for categories page
list($items_data, $additional_data) = fn_format_categories_items($params, $lang_code);
}
fn_set_hook('generate_rss_feed', $items_data, $additional_data, $block_data, $lang_code);
return array($items_data, $additional_data);
}
示例15: fn_get_banners
function fn_get_banners($params, $lang_code = CART_LANGUAGE)
{
$default_params = array('items_per_page' => 0, 'sort_by' => 'name');
$params = array_merge($default_params, $params);
$sortings = array('timestamp' => '?:banners.timestamp', 'name' => '?:banner_descriptions.banner');
$directions = array('asc' => 'asc', 'desc' => 'desc');
$condition = $limit = '';
if (!empty($params['limit'])) {
$limit = db_quote(' LIMIT 0, ?i', $params['limit']);
}
if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
$params['sort_order'] = 'asc';
}
if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
$params['sort_by'] = 'name';
}
$sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
$condition = AREA == 'A' ? '' : " AND ?:banners.status = 'A' ";
$condition .= fn_get_localizations_condition('?:banners.localization');
if (!empty($params['item_ids'])) {
$condition .= db_quote(' AND ?:banners.banner_id IN (?n)', explode(',', $params['item_ids']));
}
if (!empty($params['period']) && $params['period'] != 'A') {
list($params['time_from'], $params['time_to']) = fn_create_periods($params);
$condition .= db_quote(" AND (?:banners.timestamp >= ?i AND ?:banners.timestamp <= ?i)", $params['time_from'], $params['time_to']);
}
$banners = db_get_array("SELECT ?:banners.banner_id, ?:banners.type, ?:banners.target, ?:banners.status, ?:banners.url, ?:banner_descriptions.banner, ?:banner_descriptions.description FROM ?:banners LEFT JOIN ?:banner_descriptions ON ?:banner_descriptions.banner_id = ?:banners.banner_id AND ?:banner_descriptions.lang_code = ?s WHERE 1 ?p ORDER BY ?p ?p", $lang_code, $condition, $sorting, $limit);
foreach ($banners as $k => $v) {
$banners[$k]['main_pair'] = fn_get_image_pairs($v['banner_id'], 'banner', 'M', true, false, $lang_code);
}
if (!empty($params['item_ids'])) {
$banners = fn_sort_by_ids($banners, explode(',', $params['item_ids']), 'banner_id');
}
fn_set_hook('get_banners', $banners);
return array($banners, $params);
}