本文整理汇总了PHP中TemplateHandler::restoreXML方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplateHandler::restoreXML方法的具体用法?PHP TemplateHandler::restoreXML怎么用?PHP TemplateHandler::restoreXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateHandler
的用法示例。
在下文中一共展示了TemplateHandler::restoreXML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: showFeedback
/**
* Show content of feedback form in backend.
*/
private function showFeedback()
{
$template = new TemplateHandler('list.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$template->registerTagHandler('cms:list', $this, 'tag_FeedbackList');
$params = array();
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例4: 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();
}
示例5: parse
//.........这里部分代码省略.........
} else {
$content = limit_words($content, $char_count, $end_with);
}
}
echo $content;
break;
// call section specific data
// call section specific data
case '_section_data':
case 'cms:section_data':
if (!is_null($this->module)) {
$file = $this->module->getSectionFile($section, $action, $language);
$new = new TemplateHandler(basename($file), dirname($file) . '/');
$new->setLocalParams($this->params);
$new->setMappedModule($this->module);
$new->parse();
} else {
// log error
trigger_error('Mapped module is not loaded! File: ' . $this->file, E_USER_WARNING);
}
break;
// print multilanguage data
// print multilanguage data
case '_language_data':
case 'cms:language_data':
$name = isset($tag->tagAttrs['param']) ? $tag->tagAttrs['param'] : null;
if (!isset($this->params[$name]) || !is_array($this->params[$name]) || is_null($name)) {
break;
}
$template = new TemplateHandler('language_data.xml', $system_template_path);
$template->setMappedModule($this->module);
foreach ($this->params[$name] as $lang => $data) {
$params = array('param' => $name, 'language' => $lang, 'data' => $data);
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
break;
// replace tag data string with matching params
// replace tag data string with matching params
case '_replace':
case 'cms:replace':
$pool = isset($tag->tagAttrs['param']) ? $this->params[$tag->tagAttrs['param']] : $this->params;
$keys = array_keys($pool);
$values = array_values($pool);
foreach ($keys as $i => $key) {
$keys[$i] = "%{$key}%";
}
// we can't replact string with array, only matching data types
foreach ($values as $i => $value) {
if (is_array($value)) {
unset($keys[$i]);
unset($values[$i]);
}
}
echo str_replace($keys, $values, $tag->tagData);
break;
// conditional tag
// conditional tag
case '_if':
case 'cms:if':
$settings = !is_null($this->module) ? $this->module->settings : array();
$params = $this->params;
$condition = true;
// check if section is specified and matches
if (isset($tag->tagAttrs['section'])) {
示例6: 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();
}
示例7: tag_Level
/**
* Print level option
*/
public function tag_Level($tag_params, $children)
{
$max_level = 10;
if ($_SESSION['level'] < 10) {
$max_level = $_SESSION['level'] - 1;
}
$selected = -1;
if (isset($tag_params['selected'])) {
$selected = $tag_params['selected'];
}
// create template
if (isset($tag_params['template'])) {
if (isset($tag_params['local']) && $tag_params['local'] == 1) {
$template = new TemplateHandler($tag_params['template'], $this->parent->path . 'templates/');
} else {
$template = new TemplateHandler($tag_params['template']);
}
} else {
$template = new TemplateHandler('users_level.xml', $this->parent->path . 'templates/');
}
$template->setMappedModule($this->parent->name);
for ($i = 0; $i <= $max_level; $i++) {
$params = array('level' => $i, 'selected' => $selected);
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
示例8: tag_CodeList
/**
* Tag handler for printing code lists
*
* @param array $params
* @param array $children
*/
public function tag_CodeList($params, $children)
{
$manager = CodeManager::getInstance();
$conditions = array();
$items = $manager->getItems($manager->getFieldNames(), $conditions, array('id'));
$template = new TemplateHandler('list_item.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
if (count($items) > 0) {
foreach ($items as $item) {
$params = array('id' => $item->id, 'code' => $item->code, 'url' => $item->url, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('codes_change', 400, $this->getLanguageConstant('title_codes_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'codes_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('codes_delete', 400, $this->getLanguageConstant('title_codes_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'codes_delete'), array('id', $item->id)))), 'item_open' => url_MakeHyperlink($this->getLanguageConstant('open'), $item->url, '', '', '_blank'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
示例9: tag_FeedList
/**
* Tag handler for feed list
*
* @param array $params
* @param array $children
*/
public function tag_FeedList($params, $children)
{
$manager = NewsFeedManager::getInstance();
$group_manager = NewsGroupManager::getInstance();
$items = $manager->getItems($manager->getFieldNames(), array());
// create template parser
$template = new TemplateHandler('feed_list_item.xml', $this->path . 'templates/');
if (count($items) > 0) {
foreach ($items as $item) {
$group = $group_manager->getSingleItem(array('title'), array('id' => $item->group));
$params = array('id' => $item->id, 'group' => $item->group, 'news_count' => $item->news_count, 'title' => $item->title, 'group_title' => $group->title, 'description' => $item->description, 'active' => $item->active, 'active_char' => $item->active ? CHAR_CHECKED : CHAR_UNCHECKED, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('news_feeds_change', 390, $this->getLanguageConstant('title_news_feed_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'feed_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('news_feeds_delete', 390, $this->getLanguageConstant('title_news_feed_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'feed_delete'), array('id', $item->id)))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
示例10: 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();
}
}
示例11: 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();
}
}
}
示例12: 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();
}
示例13: 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();
}
}
示例14: saveSettings
/**
* Save settings
*/
private function saveSettings()
{
$secret_key = fix_chars($_REQUEST['secret_key']);
$public_key = fix_chars($_REQUEST['public_key']);
$this->saveSetting('secret_key', $secret_key);
$this->saveSetting('public_key', $public_key);
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->getLanguageConstant('message_settings_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('stripe'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例15: deletePrice_Commit
/**
* Perform price removal
*/
private function deletePrice_Commit()
{
$manager = ShopDeliveryMethodPricesManager::getInstance();
$relations_manager = ShopDeliveryItemRelationsManager::getInstance();
$id = fix_id($_REQUEST['id']);
$manager->deleteData(array('id' => $id));
$relations_manager->deleteData(array('price' => $id));
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->_parent->name);
$params = array('message' => $this->_parent->getLanguageConstant("message_delivery_price_deleted"), 'button' => $this->_parent->getLanguageConstant("close"), 'action' => window_Close('shop_delivery_price_delete') . ";" . window_ReloadContent('shop_delivery_method_prices'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}