本文整理汇总了PHP中TemplateHandler::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplateHandler::parse方法的具体用法?PHP TemplateHandler::parse怎么用?PHP TemplateHandler::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateHandler
的用法示例。
在下文中一共展示了TemplateHandler::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tag_CheckoutForm
//.........这里部分代码省略.........
$bad_fields = array();
$info_available = false;
// grab user information
if (!is_null($stage)) {
// get payment method
$payment_method = $this->getPaymentMethod($tag_params);
if (is_null($payment_method)) {
throw new PaymentMethodError('No payment method selected!');
}
// get billing information
$billing_information = $this->getBillingInformation($payment_method);
$billing_required = array('billing_full_name', 'billing_card_type', 'billing_credit_card', 'billing_expire_month', 'billing_expire_year', 'billing_cvv');
$bad_fields = $this->checkFields($billing_information, $billing_required, $bad_fields);
// get shipping information
if ($include_shipping && $stage == 'set_info') {
$shipping_information = $this->getShippingInformation();
$shipping_required = array('name', 'email', 'street', 'city', 'zip', 'country');
$bad_fields = $this->checkFields($shipping_information, $shipping_required, $bad_fields);
}
}
$info_available = count($bad_fields) == 0 && !is_null($payment_method);
if ($info_available) {
$address_manager = ShopDeliveryAddressManager::getInstance();
$currency_manager = ShopCurrenciesManager::getInstance();
// get fields for payment method
$return_url = url_Make('checkout_completed', 'shop', array('payment_method', $payment_method->get_name()));
$cancel_url = url_Make('checkout_canceled', 'shop', array('payment_method', $payment_method->get_name()));
// get currency info
$currency = $this->settings['default_currency'];
$currency_item = $currency_manager->getSingleItem(array('id'), array('currency' => $currency));
if (is_object($currency_item)) {
$transaction_data['currency'] = $currency_item->id;
}
// get buyer
$buyer = $this->getUserAccount();
if ($include_shipping) {
$address = $this->getAddress($buyer, $shipping_information);
} else {
$address = null;
}
// update transaction
$transaction_type = $recurring ? TransactionType::SUBSCRIPTION : TransactionType::SHOPPING_CART;
$summary = $this->updateTransaction($transaction_type, $payment_method, '', $buyer, $address);
// emit signal and return if handled
if ($stage == 'set_info') {
Events::trigger('shop', 'before-checkout', $payment_method->get_name(), $return_url, $cancel_url);
foreach ($result_list as $result) {
if ($result) {
$this->showCheckoutRedirect();
return;
}
}
}
// create new payment
if ($recurring) {
// recurring payment
$checkout_fields = $payment_method->new_recurring_payment($_SESSION['recurring_plan'], $billing_information, $return_url, $cancel_url);
} else {
// regular payment
$checkout_fields = $payment_method->new_payment($transaction_data, $billing_information, $summary['items_for_checkout'], $return_url, $cancel_url);
}
// load template
$template = $this->loadTemplate($tag_params, 'checkout_form.xml');
$template->registerTagHandler('cms:checkout_items', $this, 'tag_CheckoutItems');
$template->registerTagHandler('cms:delivery_methods', $this, 'tag_DeliveryMethodsList');
// parse template
$params = array('checkout_url' => $payment_method->get_url(), 'checkout_fields' => $checkout_fields, 'checkout_name' => $payment_method->get_title(), 'currency' => $this->getDefaultCurrency(), 'recurring' => $recurring, 'include_shipping' => $include_shipping);
// for recurring plans add additional params
if ($recurring) {
$plans = $payment_method->get_recurring_plans();
$plan_name = $_SESSION['recurring_plan'];
$plan = $plans[$plan_name];
$params['plan_name'] = $plan['name'];
$params['plan_description'] = $this->formatRecurring(array('price' => $plan['price'], 'period' => $plan['interval_count'], 'period' => $plan['interval_count'], 'unit' => $plan['interval'], 'setup' => $plan['setup_price'], 'trial_period' => $plan['trial_count'], 'trial_unit' => $plan['trial']));
} else {
$params['sub-total'] = number_format($summary['total'], 2);
$params['shipping'] = number_format($summary['shipping'], 2);
$params['handling'] = number_format($summary['handling'], 2);
$params['total_weight'] = number_format($summary['weight'], 2);
$params['total'] = number_format($summary['total'] + $summary['shipping'] + $summary['handling'], 2);
}
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
} else {
// no information available, show form
$template = new TemplateHandler('buyer_information.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$template->registerTagHandler('cms:card_type', $this, 'tag_CardType');
// get fixed country if set
$fixed_country = '';
if (isset($this->settings['fixed_country'])) {
$fixed_country = $this->settings['fixed_country'];
}
$params = array('include_shipping' => $include_shipping, 'fixed_country' => $fixed_country, 'bad_fields' => $bad_fields, 'recurring' => $recurring);
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
示例2: parse
/**
* Parse loaded template
*
* @param integer $level Current level of parsing
* @param array $tags Leave blank, used for recursion
* @param boolean $parent_block If parent tag is block element
*/
public function parse($tags = array())
{
global $section, $action, $language, $template_path, $system_template_path;
if (!$this->active && empty($tags)) {
return;
}
// get language handler for later
$language_handler = MainLanguageHandler::getInstance();
// take the tag list for parsing
$tag_array = empty($tags) ? $this->engine->document->tagChildren : $tags;
// start parsing tags
$count = count($tag_array);
for ($i = 0; $i < $count; $i++) {
$tag = $tag_array[$i];
// if tag has eval set
if (isset($tag->tagAttrs['cms:eval']) || isset($tag->tagAttrs['eval'])) {
// get evaluation values
if (isset($tag->tagAttrs['eval'])) {
$value = $tag->tagAttrs['eval'];
} else {
$value = $tag->tagAttrs['cms:eval'];
}
$eval_params = explode(',', $value);
foreach ($eval_params as $param) {
// prepare module includes for evaluation
$settings = array();
if (!is_null($this->module)) {
$settings = $this->module->settings;
}
$params = $this->params;
$to_eval = $tag->tagAttrs[$param];
$tag->tagAttrs[$param] = eval('global $section, $action, $language, $language_rtl, $language_handler; return ' . $to_eval . ';');
}
// unset param
unset($tag->tagAttrs['cms:eval']);
}
if (isset($tag->tagAttrs['cms:optional'])) {
// get evaluation values
$optional_params = explode(',', $tag->tagAttrs['cms:optional']);
foreach ($optional_params as $param) {
// prepare module includes for evaluation
$settings = array();
if (!is_null($this->module)) {
$settings = $this->module->settings;
}
$params = $this->params;
$to_eval = $tag->tagAttrs[$param];
$value = eval('global $section, $action, $language, $language_rtl, $language_handler; return ' . $to_eval . ';');
if ($value == false) {
unset($tag->tagAttrs[$param]);
} else {
$tag->tagAttrs[$param] = $value;
}
}
// unset param
unset($tag->tagAttrs['cms:optional']);
}
// implement tooltip
if (isset($tag->tagAttrs['cms:tooltip'])) {
if (!is_null($this->module)) {
$value = $this->module->getLanguageConstant($tag->tagAttrs['cms:tooltip']);
} else {
$value = $language_handler->getText($tag->tagAttrs['cms:tooltip']);
}
$tag->tagAttrs['data-tooltip'] = $value;
unset($tag->tagAttrs['cms:tooltip']);
}
// implement constants
if (isset($tag->tagAttrs['cms:constant'])) {
$params = explode(',', $tag->tagAttrs['cms:constant']);
if (count($params) > 0) {
foreach ($params as $param) {
if (!is_null($this->module)) {
$tag->tagAttrs[$param] = $this->module->getLanguageConstant($tag->tagAttrs[$param]);
} else {
$tag->tagAttrs[$param] = $language_handler->getText($tag->tagAttrs[$param]);
}
}
}
unset($tag->tagAttrs['cms:constant']);
}
// check if specified tag shouldn't be cached
$skip_cache = false;
if (isset($tag->tagAttrs['skip_cache'])) {
// unset param
unset($tag->tagAttrs['skip_cache']);
// get cache handler
$cache = CacheHandler::getInstance();
// only if current URL is being cached, we start dirty area
if ($cache->isCaching()) {
$cache->startDirtyArea();
$skip_cache = true;
// reconstruct template for cache,
//.........这里部分代码省略.........
示例3: saveSettings
/**
* Save settings.
*/
private function saveSettings()
{
// grab parameters
$account_id = fix_chars($_REQUEST['account_id']);
$account_key = fix_chars($_REQUEST['account_key']);
$account_secret = fix_chars($_REQUEST['account_secret']);
$include_code = isset($_REQUEST['include_code']) && ($_REQUEST['include_code'] == 'on' || $_REQUEST['include_code'] == '1') ? 1 : 0;
$this->saveSetting('account_id', $account_id);
$this->saveSetting('account_key', $account_key);
$this->saveSetting('account_secret', $account_secret);
$this->saveSetting('include_code', $include_code);
// show message
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->getLanguageConstant('message_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('callbox_settings'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例4: deleteManufacturer_Commit
/**
* Perform manufacturer removal
*/
private function deleteManufacturer_Commit()
{
$id = fix_id($_REQUEST['id']);
$manager = ShopManufacturerManager::getInstance();
$item_manager = ShopItemManager::getInstance();
$manager->deleteData(array('id' => $id));
$item_manager->updateData(array('manufacturer' => 0), array('manufacturer' => $id));
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->_parent->getLanguageConstant("message_manufacturer_deleted"), 'button' => $this->_parent->getLanguageConstant("close"), 'action' => window_Close('shop_manufacturer_delete') . ";" . window_ReloadContent('shop_manufacturers'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例5: pageItems_Delete_Commit
/**
* Perform item removal from specified page
*/
private function pageItems_Delete_Commit()
{
$id = fix_id($_REQUEST['id']);
$manager = UserPageItemsManager::getInstance();
// remove item from database
$manager->deleteData(array('id' => $id));
// show message
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->getLanguageConstant('message_page_item_deleted'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('user_pages_items_delete') . ';' . window_ReloadContent('user_pages_items'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例6: deleteField_Commit
/**
* Perfrom field removal.
*/
private function deleteField_Commit()
{
$id = fix_id($_REQUEST['id']);
$manager = ContactForm_FormFieldManager::getInstance();
$form = $manager->getItemValue('form', array('id' => $id));
$manager->deleteData(array('id' => $id));
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->getLanguageConstant('message_field_deleted'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('contact_form_fields_delete') . ';' . window_ReloadContent('contact_form_fields_' . $form));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例7: deleteTip_Commit
/**
* Perform tip removal
*/
private function deleteTip_Commit()
{
$id = fix_id(fix_chars($_REQUEST['id']));
$manager = TipManager::getInstance();
$manager->deleteData(array('id' => $id));
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->getLanguageConstant("message_tip_deleted"), 'button' => $this->getLanguageConstant("close"), 'action' => window_Close('tips_delete') . ";" . window_ReloadContent('tips'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例8: deleteCategory_Commit
/**
* Perform category removal
*/
private function deleteCategory_Commit()
{
$id = fix_id($_REQUEST['id']);
$manager = ShopCategoryManager::getInstance();
$manager->deleteData(array('id' => $id));
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->_parent->getLanguageConstant('message_category_deleted'), 'button' => $this->_parent->getLanguageConstant('close'), 'action' => window_Close('shop_category_delete') . ";" . window_ReloadContent('shop_categories'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例9: printCache
/**
* Print cached page
*/
public function printCache()
{
global $cache_path;
if (file_exists($this->cache_file)) {
// get data from file and prepare for parsing
$data = file_get_contents($this->cache_file);
$template = new TemplateHandler();
$pattern = '/' . self::TAG_OPEN . '(.*?)' . self::TAG_CLOSE . '/u';
// get all dirty areas
preg_match_all($pattern, $data, $matches);
if (count($matches) >= 2 && count($matches[1]) > 0) {
foreach ($matches[1] as $match) {
// give template to handler
$template->setXML('<document>' . $match . '</document>');
// start output buffer and get data
ob_start();
$template->parse();
$result = ob_get_contents();
ob_end_clean();
// replace output buffer with new data
$data = preg_replace($pattern, $result, $data, 1);
}
}
// make sure we have specified cache type
if (!_AJAX_REQUEST) {
header('Content-Type: text/html; charset=UTF-8');
}
print $data;
// validate or expire cache entry
$this->validateCache();
}
}
示例10: tag_GroupList
/**
* Tag handler for printing link groups
*
* @param array $tag_params
* @param array $children
*/
public function tag_GroupList($tag_params, $children)
{
$manager = LinkGroupsManager::getInstance();
$link_manager = LinksManager::getInstance();
$membership_manager = LinkMembershipManager::getInstance();
// save some CPU time by getting this early
if (class_exists('gallery')) {
$use_images = true;
$gallery = gallery::getInstance();
$gallery_manager = GalleryManager::getInstance();
} else {
$use_images = false;
}
$conditions = array();
if (isset($tag_params['sponsored']) && $tag_params['sponsored'] == '1') {
$conditions['sponsored'] = 1;
}
$items = $manager->getItems($manager->getFieldNames(), $conditions, array('id'));
if (isset($tag_params['template'])) {
if (isset($tag_params['local']) && $tag_params['local'] == 1) {
$template = new TemplateHandler($tag_params['template'], $this->path . 'templates/');
} else {
$template = new TemplateHandler($tag_params['template']);
}
} else {
$template = new TemplateHandler('groups_item.xml', $this->path . 'templates/');
}
$template->setMappedModule($this->name);
$template->registerTagHandler('_link', $this, 'tag_Link');
$template->registerTagHandler('_link_list', $this, 'tag_LinkList');
if (count($items) > 0) {
foreach ($items as $item) {
$thumbnail = '';
if ($use_images) {
$first_link_id = $membership_manager->getItemValue('link', array('group' => $item->id));
// we have some links assigned to the group, get thumbnail
if (!empty($first_link_id)) {
$image_id = $link_manager->getItemValue('image', array('id' => $first_link_id));
if (!empty($image_id)) {
$image = $gallery_manager->getSingleItem($gallery_manager->getFieldNames(), array('id' => $image_id));
$thumbnail = $gallery->getThumbnailURL($image);
}
}
}
$params = array('id' => $item->id, 'name' => $item->name, 'text_id' => $item->text_id, 'thumbnail' => $thumbnail, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('groups_change', 400, $this->getLanguageConstant('title_groups_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'groups_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('groups_delete', 400, $this->getLanguageConstant('title_groups_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'groups_delete'), array('id', $item->id)))), 'item_links' => url_MakeHyperlink($this->getLanguageConstant('links'), window_Open('groups_links', 400, $this->getLanguageConstant('title_groups_links'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'groups_links'), array('id', $item->id)))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
示例11: tag_IsoCurrencyList
/**
* Handle displaying list of ISO defined currencies
*
* @param array $tag_params
* @param array $children
*/
public function tag_IsoCurrencyList($tag_params, $children)
{
// whether to to print only unique currencies
$only_unique = isset($tag_params['unique']) && $tag_params['unique'] == '1';
if (isset($tag_params['template'])) {
if (isset($tag_params['local']) && $tag_params['local'] == 1) {
$template = new TemplateHandler($tag_params['template'], $this->path . 'templates/');
} else {
$template = new TemplateHandler($tag_params['template']);
}
} else {
$template = new TemplateHandler('iso_currency.xml', $this->path . 'templates/');
}
// update cache
$this->__update_cache();
$displayed = array();
foreach ($this->_cache as $currency_data) {
if ($only_unique && in_array($currency_data['numeric_code'], $displayed)) {
continue;
}
// store displayed currency
$displayed[] = $currency_data['numeric_code'];
// parse template
$template->restoreXML();
$template->setLocalParams($currency_data);
$template->parse();
}
}
示例12: showTransactionDetails
/**
* Show details for specified transaction
*/
private function showTransactionDetails()
{
$manager = ShopTransactionsManager::getInstance();
$buyer_manager = ShopBuyersManager::getInstance();
$address_manager = ShopDeliveryAddressManager::getInstance();
$id = fix_id($_REQUEST['id']);
$transaction = $manager->getSingleItem($manager->getFieldNames(), array('id' => $id));
$buyer = $buyer_manager->getSingleItem($buyer_manager->getFieldNames(), array('id' => $transaction->buyer));
$address = $address_manager->getSingleItem($address_manager->getFieldNames(), array('id' => $transaction->address));
$full_address = "{$address->name}\n\n{$address->street}\n";
$full_address .= "{$address->zip} {$address->city}\n";
if (empty($address->state)) {
$full_address .= $address->country;
} else {
$full_address .= "{$address->state}, {$address->country}";
}
$params = array('id' => $transaction->id, 'uid' => $transaction->uid, 'type' => $transaction->type, 'type_string' => '', 'status' => $transaction->status, 'currency' => $transaction->currency, 'handling' => $transaction->handling, 'shipping' => $transaction->shipping, 'timestamp' => $transaction->timestamp, 'delivery_method' => $transaction->delivery_method, 'remark' => $transaction->remark, 'total' => $transaction->total, 'first_name' => $buyer->first_name, 'last_name' => $buyer->last_name, 'email' => $buyer->email, 'address_name' => $address->name, 'address_street' => $address->street, 'address_city' => $address->city, 'address_zip' => $address->zip, 'address_state' => $address->state, 'address_country' => $address->country, 'full_address' => $full_address);
$template = new TemplateHandler('transaction_details.xml', $this->path . 'templates/');
// register tag handler
$template->registerTagHandler('_item_list', $this, 'tag_TransactionItemList');
$template->registerTagHandler('_transaction_status', $this, 'tag_TransactionStatus');
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例13: embedSWF
/**
* Embed flash player with specified parameters
*
* @param string $url
* @param string $target_id
* @param integer $width
* @param integer $height
* @param array $flash_vars
* @param array $params
*/
public function embedSWF($url, $target_id, $width, $height, $flash_vars = array(), $params = array())
{
$template = new TemplateHandler('embed.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$p_flashvars = json_encode($flash_vars);
$p_params = json_encode($params);
$script = "swfobject.embedSWF('{$url}', '{$target_id}', '{$width}', '{$height}', '{$this->flash_version}', null, {$p_flashvars}, {$p_params});";
$params = array('params' => $p_params, 'flash_vars' => $p_flashvars, 'url' => $url, 'id' => $target_id, 'width' => $width, 'height' => $height, 'version' => $this->flash_version, 'script' => $script);
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例14: saveApiKey
/**
* Save new or changed API key.
*/
private function saveApiKey()
{
$api_key = fix_chars($_REQUEST['api_key']);
$this->saveSetting('api_key', $api_key);
// prepare and parse result message
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->getLanguageConstant('message_api_key_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('page_speed_set_api_key'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例15: showAffiliateInformation
/**
* Show affiliate information.
*/
private function showAffiliateInformation()
{
global $url_rewrite;
$manager = AffiliatesManager::getInstance();
$user_id = $_SESSION['uid'];
$affiliate = $manager->getSingleItem($manager->getFieldNames(), array('user' => $user_id));
if (is_object($affiliate)) {
$template = new TemplateHandler('information.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
if ($affiliate->clicks > 0) {
$rate = round(100 * $affiliate->conversions / $affiliate->clicks, 2);
} else {
$rate = 0;
}
$params = array('uid' => $affiliate->uid, 'name' => $affiliate->name, 'clicks' => $affiliate->clicks, 'conversions' => $affiliate->conversions, 'rate' => $rate, 'url_rewrite' => $url_rewrite ? 'true' : 'false', 'cancel_action' => window_Close('affiliate_information'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}