本文整理汇总了PHP中xml::to_XML方法的典型用法代码示例。如果您正苦于以下问题:PHP xml::to_XML方法的具体用法?PHP xml::to_XML怎么用?PHP xml::to_XML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml
的用法示例。
在下文中一共展示了xml::to_XML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_edit_field
public function action_edit_field()
{
$field_id = $this->request->param('options');
xml::to_XML(array('field' => array('@id' => $field_id, '$content' => User::get_data_field_name($field_id))), $this->xml_content);
if (count($_POST) && isset($_POST['field_name'])) {
$post = new Validation($_POST);
$post->filter('trim');
$post->rule('Valid::not_empty', 'field_name');
if ($post->validate()) {
$post_values = $post->as_array();
if ($post_values['field_name'] != User::get_data_field_name($field_id) && !User::field_name_available($post_values['field_name'])) {
$post->add_error('field_name', 'User::field_name_available');
}
}
// Retry
if ($post->validate()) {
$post_values = $post->as_array();
User::update_field($field_id, $post_values['field_name']);
$this->add_message('Field ' . $post_values['field_name'] . ' updated');
$this->set_formdata(array('field_name' => $post_values['field_name']));
} else {
$this->add_error('Fix errors and try again');
$this->add_form_errors($post->errors());
$this->set_formdata(array_intersect_key($post->as_array(), $_POST));
}
} else {
$this->set_formdata(array('field_name' => User::get_data_field_name($field_id)));
}
}
示例2: list_available_data_fields
private function list_available_data_fields()
{
$fields = array();
foreach (User::get_data_fields() as $field_id => $field_name) {
$fields['field id="' . $field_id . '"'] = $field_name;
}
$this->xml_content_users = $this->xml_content->appendChild($this->dom->createElement('users'));
xml::to_XML($fields, $this->xml_content_users);
}
示例3: action_gallery
public function action_gallery()
{
$this->xslt_stylesheet = 'generic';
$gallery_name = $this->request->param('gallery');
if ($gallery_name == NULL) {
$gallery_name = 'all';
}
xml::to_XML(array('gallery_name' => $gallery_name), $this->xml_content);
}
示例4: action_index
public function action_index()
{
Session::instance();
$this->xslt_stylesheet = 'admin/login';
$user = User::instance();
if ($user->logged_in() && ($user->get_user_data('role') == 'admin' || is_array($user->get_user_data('role')) && in_array('admin', $user->get_user_data('role')))) {
$this->redirect('/admin');
}
if (isset($_SESSION['modules']['pajas']['error'])) {
xml::to_XML(array('error' => $_SESSION['modules']['pajas']['error']), $this->xml_content);
unset($_SESSION['modules']['pajas']['error']);
}
}
示例5: action_edit_customer
public function action_edit_customer()
{
$customer_id = $this->request->param('options');
$customer_model = new Customer($customer_id);
xml::to_XML(array('customer' => $customer_model->get()), $this->xml_content, NULL, 'id');
if (count($_POST)) {
$post = new Validation($_POST);
$post->filter('trim');
if ($post->validate()) {
$customer_model->set($post->as_array());
$this->add_message('Customer "' . $post->get('name') . '" updated');
}
}
$this->set_formdata($customer_model->get());
}
示例6: action_index
public function action_index()
{
// Set the name of the template to use
$this->xslt_stylesheet = empty($_GET['template']) || !isset($_GET['template']) ? 'bills/default' : 'bills/' . $_GET['template'];
if (isset($_GET['billnr'])) {
$bill = new Bill($_GET['billnr']);
}
$bill_data = $bill->data;
foreach ($bill_data['items'] as $nr => $item) {
$bill_data['items'][$nr . 'item'] = $item;
unset($bill_data['items'][$nr]);
}
$bill_data['due_days'] = (strtotime($bill_data['due_date']) - strtotime($bill_data['date'])) / (24 * 60 * 60);
// And round it up
$bill_data['due_days'] += 1;
list($bill_data['due_days']) = explode('.', strval($bill_data['due_days']));
xml::to_XML(array('bill' => $bill_data), $this->xml_content, NULL, array('id', 'artnr'));
/*
if (isset($_GET['billnr']) && $_GET['billnr'] == 1)
{
$bill = array(
'bill id="1"' => array(
'customer id="1"' => array(
'name' => 'Kristoffer Nolgren Firma',
'reference' => 'Kristoffer Nolgren',
'street' => 'Lyckostigen 10',
'zip' => '18356',
'city' => 'Täby',
),
'payment_data' => array(
'date' => '2011-01-24',
'due_date' => '2011-02-13',
'item artnr="-"' => array(
'spec' => 'Webbprogrammering',
'qty' => '1',
'price' => '700',
'delivery_date' => '2010-01-03',
),
),
),
);
}
else die('fail');
xml::to_XML($bill, $this->xml_content);
/**/
}
示例7: action_index
public function action_index()
{
$this->xslt_stylesheet = 'generic';
// Get all categories
$this->xml_content_categories = $this->xml_content->appendChild($this->dom->createElement('categories'));
xml::to_XML(Galleries::get_categories_for_xml(), $this->xml_content_categories, 'category');
// Get all galleries
$this->xml_content_galleries = $this->xml_content->appendChild($this->dom->createElement('galleries'));
xml::to_XML(Galleries::get_for_xml(), $this->xml_content_galleries, 'gallery');
$images = array();
foreach (Content_image::get_images(NULL, array('frontimage' => TRUE)) as $image_name => $image_data) {
$images[] = $image_name;
}
if (count($images)) {
xml::to_XML(array('frontimage' => $images[rand(0, count($images) - 1)]), $this->xml_content);
}
}
示例8: action_index
public function action_index()
{
// Remove an image
if (isset($_GET['rm'])) {
$image = new Content_Image($_GET['rm']);
$image->rm_image();
$this->redirect();
}
// Add image
if (isset($_POST['upload_image'])) {
foreach ($_FILES['image']['name'] as $nr => $name) {
if ($name != '') {
$pathinfo = pathinfo($_FILES['image']['name'][$nr]);
if (strtolower($pathinfo['extension']) == 'jpg' || strtolower($pathinfo['extension']) == 'png') {
$filename = 'frontimage.' . strtolower($pathinfo['extension']);
$new_filename = $filename;
$counter = 1;
while (!Content_Image::image_name_available($new_filename)) {
$new_filename = substr($filename, 0, strlen($filename) - 4) . '_' . $counter . '.' . strtolower($pathinfo['extension']);
$counter++;
}
if (move_uploaded_file($_FILES['image']['tmp_name'][$nr], APPPATH . '/user_content/images/' . $new_filename)) {
if (strtolower($pathinfo['extension']) == 'jpg') {
$gd_img_object = ImageCreateFromJpeg(Kohana::$config->load('user_content.dir') . '/images/' . $new_filename);
} elseif (strtolower($pathinfo['extension']) == 'png') {
$gd_img_object = ImageCreateFromPng(Kohana::$config->load('user_content.dir') . '/images/' . $new_filename);
}
$details = array('width' => array(imagesx($gd_img_object)), 'height' => array(imagesy($gd_img_object)), 'frontimage' => NULL);
Content_Image::new_image($new_filename, $details);
} else {
$this->add_error('Unknown error uploading image(s)');
}
}
}
}
}
// Images
$images = array();
foreach (Content_image::get_images(NULL, array('frontimage' => TRUE)) as $image_name => $image_data) {
$images[] = array('name' => $image_name);
}
$this->xml_content_images = $this->xml_content->appendChild($this->dom->createElement('images'));
xml::to_XML($images, $this->xml_content_images, 'image');
}
示例9: action_entry
public function action_entry()
{
// Set employees node
$employees_node = $this->xml_content->appendChild($this->dom->createElement('employees'));
$employees = array('0option' => array('@value' => '0', 'None'));
$counter = 1;
foreach (Employees::get() as $employee) {
$employees[$counter . 'option'] = array('@value' => $employee['id'], $employee['lastname'] . ', ' . $employee['firstname']);
$counter++;
}
xml::to_XML($employees, $employees_node);
// This is for the select box
if (count($_POST)) {
$post = new Validation($_POST);
$post->filter('trim');
$post->filter('floatval', 'sum');
$post->filter('floatval', 'vat');
$post->rule('strtotime', 'accounting_date');
$post->rule('strtotime', 'transfer_date');
$post->rule('Valid::not_empty', 'description');
if ($post->Validate()) {
$new_transaction_data = array('accounting_date' => $post->get('accounting_date'), 'transfer_date' => $post->get('transfer_date'), 'description' => $post->get('description'), 'journal_id' => $post->get('journal_id'), 'vat' => $post->get('vat'), 'sum' => $post->get('sum'), 'employee_id' => $post->get('employee_id'));
if (!isset($_GET['id'])) {
$transaction = new Transaction(NULL, $new_transaction_data);
$this->add_message('Transaction ' . $transaction->get_id() . ' added');
} else {
$transaction = new Transaction($_GET['id']);
$transaction->set($new_transaction_data);
$this->add_message('Transaction ' . $transaction->get_id() . ' updated');
$this->set_formdata($transaction->get());
}
} else {
$this->add_form_errors($post->errors());
$this->set_formdata($post->as_array());
}
} elseif (isset($_GET['id'])) {
$transaction = new Transaction($_GET['id']);
$this->set_formdata($transaction->get());
} else {
$this->set_formdata(array('accounting_date' => date('Y-m-d', time()), 'transfer_date' => date('Y-m-d', time())));
}
}
示例10: action_index
public function action_index()
{
// Set the name of the template to use
$this->xslt_stylesheet = 'payslip';
if (!isset($_GET['employee_id']) || !isset($_GET['period']) || !preg_match('/^\\d{4}-\\d{1,2}$/', $_GET['period'])) {
throw new Kohana_exception('Invalid parameters');
}
$employee = new Employee($_GET['employee_id']);
xml::to_XML($employee->get(), $this->xml_content->appendChild($this->dom->createElement('employee')), NULL, 'id');
$where = '
employee_id = ' . intval($_GET['employee_id']) . ' AND
(
description = \'Social fees period ' . $_GET['period'] . '\' OR
description = \'Income taxes period ' . $_GET['period'] . '\' OR
(
description = \'Salary payout\' AND
MONTH(transfer_date) = ' . substr($_GET['period'], 5) . ' AND
YEAR(transfer_date) = ' . substr($_GET['period'], 0, 4) . '
)
)';
xml::to_XML(Transactions::get(NULL, 'accounting_date', $where), $this->xml_content->appendChild($this->dom->createElement('transactions')), 'transaction', 'id');
}
示例11: __construct
/**
* Loads URI, and Input into this controller.
*
* @return void
*/
public function __construct(Request $request, Response $response)
{
parent::__construct($request, $response);
if (class_exists('User')) {
/**
* Must be a logged in user with admin role to access the admin pages
*/
$user = User::instance();
if ($user->logged_in()) {
$user_data = array('@id' => $user->get_user_id(), 'username' => $user->get_username(), 'data' => array());
foreach ($user->get_user_data() as $field_name => $field_value) {
$user_data['data']['field name="' . $field_name . '"'] = $field_value;
}
xml::to_XML(array('user_data' => $user_data), $this->xml_meta);
}
}
if ($this->request->controller() != 'login') {
/**
* Build the menu alternatives
*/
// First we need to create the container for the options
$this->menuoptions_node = $this->xml_content->appendChild($this->dom->createElement('menuoptions'));
// First add the default home-alternative
xml::to_XML(array(array('name' => 'Home', '@category' => '', 'description' => 'Admin home page with descriptions of the available admin pages', 'href' => '', 'position' => 0)), $this->menuoptions_node, 'menuoption');
// Then we populate this container with options from the config files, and group them by 'menuoption'
foreach (Kohana::$config->load('admin_menu_options') as $menu_option) {
if (is_array($user->get_role())) {
if (in_array('admin', $user->get_role()) || in_array($menu_option['href'], $user->get_roles_uri())) {
xml::to_XML(array($menu_option), $this->menuoptions_node, 'menuoption');
}
}
}
if (!$user->get_user_id()) {
$this->redirect('admin/login');
}
}
}
示例12: action_role
/**
* Edit Tags
* if id is set, instanciate an edit function
* if not instanciate an add tag function.
*/
public function action_role()
{
$this->xml_content_types = $this->xml_content->appendChild($this->dom->createElement('roles'));
xml::to_XML(Uvtag::get_tags(), $this->xml_content_types, 'role');
if (!empty($_POST)) {
$post = new Validation($_POST);
$post->filter('trim');
$post->rule('Valid::not_empty', 'role');
$post->rule('Valid::not_empty', 'uri');
if (isset($role)) {
$tag->update($post->as_array());
$this->add_message('Role name updated');
} else {
if (Uvtag::add($post->get('role'), $post->get('uri'))) {
$this->add_message('Role "' . $post->get('name') . '" was added');
} else {
$this->add_message('Role "' . $post->get('name') . '" could not be added');
}
}
} elseif (isset($tag)) {
// Set the form input to the tag name.
$this->set_formdata($tag->get());
}
}
示例13: action_employee
public function action_employee()
{
$statuses = array('0option' => array('@value' => 'active', '$content' => 'Active'), '1option' => array('@value' => 'inactive', '$content' => 'Inactive'));
xml::to_XML($statuses, $this->xml_content->appendChild($this->dom->createElement('statuses')));
if (isset($_GET['id'])) {
$employee = new Employee($_GET['id']);
if (count($_POST)) {
$post = new Validation($_POST);
$post->filter('trim');
$employee->set($post->as_array());
$this->add_message('Employee ' . $_GET['id'] . ' information updated');
}
$this->set_formdata($employee->get());
xml::to_XML(array('statuses' => array('1option' => array('@value' => 'active', 'Active'), '2option' => array('@value' => 'inactive', 'Inactive'))), $this->xml_content);
xml::to_XML($employee->get(), $this->xml_content->appendChild($this->dom->createElement('employee')), NULL, 'id');
} elseif (count($_POST)) {
$post = new Validation($_POST);
$post->filter('trim');
$employee_id = Employee::new_employee($post->as_array());
$this->add_message($post->get('firstname') . ' (ID: ' . $employee_id . ') was added as employee');
} else {
$this->redirect();
}
}
示例14: action_bill
public function action_bill()
{
$this->xml_content_customers = $this->xml_content->appendChild($this->dom->createElement('customers'));
xml::to_XML(Customers::get_customers(), $this->xml_content_customers, 'customer', 'id');
$template = array();
foreach (glob(MODPATH . 'larvconomy/xsl/bills/*') as $file) {
$file_paths = explode('/', $file);
$template_file = explode('.', end($file_paths));
$template[] = reset($template_file);
}
$this->xml_content_bill_template = $this->xml_content->appendChild($this->dom->createElement('templates'));
xml::to_XML($template, $this->xml_content_bill_template, 'template');
if (!isset($_SESSION['bills']['items'])) {
$_SESSION['bills']['items']['1item'] = 1;
}
if (count($_POST)) {
$post = new Validation($_POST);
$post->filter('trim');
$post_array = $post->as_array();
if (isset($post_array['add_item'])) {
$_SESSION['bills']['items'][count($_SESSION['bills']['items']) + 1 . 'item'] = count($_SESSION['bills']['items']) + 1;
$this->set_formdata($post_array);
} else {
$items = array();
$sum = 0;
$vat_sum = 0;
foreach ($_SESSION['bills']['items'] as $item_nr) {
$item = array('artnr' => $post->get('artnr_item_' . $item_nr), 'spec' => $post->get('spec_item_' . $item_nr), 'price' => (double) $post->get('price_item_' . $item_nr), 'qty' => (double) $post->get('qty_item_' . $item_nr), 'delivery_date' => date('Y-m-d', time()));
if ($item != array('artnr' => '', 'spec' => '', 'price' => 0, 'qty' => 0, 'delivery_date' => date('Y-m-d', time()))) {
$items[] = $item;
$sum += $item['qty'] * $item['price'] * 1.25;
$vat_sum += $item['qty'] * $item['price'] * 0.25;
}
}
if (count($items) && $post->validate()) {
$bill_id = Bill::new_bill($post->get('customer_id'), strtotime($post->get('due_date')), $post->get('contact'), $items, $post->get('comment'), $post->get('template'), $post->get('mail_body'));
$this->add_message('Created bill nr ' . $bill_id);
unset($_SESSION['bills']['items']);
// Create the transaction
$data = array('accounting_date' => date('Y-m-d', time()), 'transfer_date' => '0000-00-00', 'description' => 'Bill ' . $bill_id, 'vat' => $vat_sum, 'sum' => $sum, 'employee_id' => NULL, 'journal_id' => NULL);
$transaction = new Transaction(NULL, $data);
// End of Create the transaction
// Set new default due date
$this->set_formdata(array('due_date' => date('Y-m-d', time() + 20 * 24 * 60 * 60)));
// Make the PDF
if (Kohana::$config->load('larv.htpassword.password') && Kohana::$config->load('larv.htpassword.username')) {
shell_exec('wkhtmltopdf --ignore-load-errors --username ' . Kohana::$config->load('larv.htpassword.username') . ' --password ' . Kohana::$config->load('larv.htpassword.password') . ' "' . $_SERVER['SERVER_NAME'] . URL::site('bill?billnr=' . $bill_id . '&template=' . $post->get('template')) . '" "' . APPPATH . 'user_content/pdf/bill_' . $bill_id . '.pdf"');
} else {
shell_exec('wkhtmltopdf --ignore-load-errors "' . $_SERVER['SERVER_NAME'] . URL::site('bill?billnr=' . $bill_id . '&template=' . $post->get('template')) . '" "' . APPPATH . 'user_content/pdf/bill_' . $bill_id . '.pdf"');
}
if (isset($_FILES)) {
Bill::upload($_FILES, 'attachments/' . $bill_id);
}
} else {
$this->add_error('Not enough data');
$post->set('due_date', date('Y-m-d', strtotime($post->get('due_date'))));
$post->set('mail_body', Kohana::$config->load('larv.email.bill_message'));
$this->set_formdata($post->as_array());
}
}
} else {
$this->set_formdata(array('due_date' => date('Y-m-d', time() + 20 * 24 * 60 * 60), 'mail_body' => Kohana::$config->load('larv.email.bill_message')));
}
xml::to_XML($_SESSION['bills'], $this->xml_content);
}
示例15: before
public function before()
{
// Set the name of the template to use
$this->xslt_stylesheet = 'admin/images';
xml::to_XML(array('admin_page' => 'Images'), $this->xml_meta);
}