当前位置: 首页>>代码示例>>PHP>>正文


PHP XML::safe方法代码示例

本文整理汇总了PHP中XML::safe方法的典型用法代码示例。如果您正苦于以下问题:PHP XML::safe方法的具体用法?PHP XML::safe怎么用?PHP XML::safe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML的用法示例。


在下文中一共展示了XML::safe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

 /**
  * Blocks admin function
  */
 public static function main()
 {
     // Init vars
     $blocks_path = STORAGE . DS . 'blocks' . DS;
     $blocks_list = array();
     $errors = array();
     // Check for get actions
     // -------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -------------------------------------
         switch (Request::get('action')) {
             // Add block
             // -------------------------------------
             case "add_block":
                 if (Request::post('add_blocks') || Request::post('add_blocks_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['blocks_empty_name'] = __('Required field', 'blocks');
                         }
                         if (file_exists($blocks_path . Security::safeName(Request::post('name')) . '.block.html')) {
                             $errors['blocks_exists'] = __('This block already exists', 'blocks');
                         }
                         if (count($errors) == 0) {
                             // Save block
                             File::setContent($blocks_path . Security::safeName(Request::post('name')) . '.block.html', XML::safe(Request::post('editor')));
                             Notification::set('success', __('Your changes to the block <i>:name</i> have been saved.', 'blocks', array(':name' => Security::safeName(Request::post('name')))));
                             if (Request::post('add_blocks_and_exit')) {
                                 Request::redirect('index.php?id=blocks');
                             } else {
                                 Request::redirect('index.php?id=blocks&action=edit_block&filename=' . Security::safeName(Request::post('name')));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 // Save fields
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = '';
                 }
                 if (Request::post('editor')) {
                     $content = Request::post('editor');
                 } else {
                     $content = '';
                 }
                 // Display view
                 View::factory('box/blocks/views/backend/add')->assign('content', $content)->assign('name', $name)->assign('errors', $errors)->display();
                 break;
                 // Edit Block
                 // -------------------------------------
             // Edit Block
             // -------------------------------------
             case "edit_block":
                 // Save current block action
                 if (Request::post('edit_blocks') || Request::post('edit_blocks_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['blocks_empty_name'] = __('Required field', 'blocks');
                         }
                         if (file_exists($blocks_path . Security::safeName(Request::post('name')) . '.block.html') and Security::safeName(Request::post('blocks_old_name')) !== Security::safeName(Request::post('name'))) {
                             $errors['blocks_exists'] = __('This block already exists', 'blocks');
                         }
                         // Save fields
                         if (Request::post('editor')) {
                             $content = Request::post('editor');
                         } else {
                             $content = '';
                         }
                         if (count($errors) == 0) {
                             $block_old_filename = $blocks_path . Request::post('blocks_old_name') . '.block.html';
                             $block_new_filename = $blocks_path . Security::safeName(Request::post('name')) . '.block.html';
                             if (!empty($block_old_filename)) {
                                 if ($block_old_filename !== $block_new_filename) {
                                     rename($block_old_filename, $block_new_filename);
                                     $save_filename = $block_new_filename;
                                 } else {
                                     $save_filename = $block_new_filename;
                                 }
                             } else {
                                 $save_filename = $block_new_filename;
                             }
                             // Save block
                             File::setContent($save_filename, XML::safe(Request::post('editor')));
                             Notification::set('success', __('Your changes to the block <i>:name</i> have been saved.', 'blocks', array(':name' => basename($save_filename, '.block.html'))));
                             if (Request::post('edit_blocks_and_exit')) {
                                 Request::redirect('index.php?id=blocks');
                             } else {
                                 Request::redirect('index.php?id=blocks&action=edit_block&filename=' . Security::safeName(Request::post('name')));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:blocks.admin.php

示例2: _updateWhere

 /**
  * _updateWhere
  */
 protected static function _updateWhere($table, $query, $fields = array())
 {
     // Find record to delete
     $xml_arr = Table::_selectOne($table, $query);
     // If its exists then delete it
     if (count($fields) !== 0) {
         foreach ($fields as $key => $value) {
             $xml_arr->{$key} = XML::safe($value, false);
         }
     }
     // Save table
     Table::_save($table);
 }
开发者ID:cmroanirgo,项目名称:monstra,代码行数:16,代码来源:Table.php

示例3: main

 /**
  * Pages admin function
  */
 public static function main()
 {
     $current_theme = Option::get('theme_site_name');
     $site_url = Option::get('siteurl');
     $templates_path = THEMES_SITE;
     $errors = array();
     $pages = new Table('pages');
     PagesAdmin::$pages = $pages;
     $users = new Table('users');
     $user = $users->select('[id=' . Session::get('user_id') . ']', null);
     // Page author
     if (!empty($user['firstname'])) {
         $author = empty($user['lastname']) ? $user['firstname'] : $user['firstname'] . ' ' . $user['lastname'];
     } else {
         $author = Session::get('user_login');
     }
     $author = Html::toText($author);
     // Status array
     $status_array = array('published' => __('Published', 'pages'), 'draft' => __('Draft', 'pages'));
     // Access array
     $access_array = array('public' => __('Public', 'pages'), 'registered' => __('Registered', 'pages'));
     // Check for get actions
     // ---------------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -----------------------------------------
         switch (Request::get('action')) {
             // Clone page
             // -------------------------------------
             case "clone_page":
                 if (Security::check(Request::get('token'))) {
                     // Generate rand page name
                     $rand_page_name = Request::get('name') . '_clone_' . date("Ymd_His");
                     // Get original page
                     $orig_page = $pages->select('[slug="' . Request::get('name') . '"]', null);
                     // Generate rand page title
                     $rand_page_title = $orig_page['title'] . ' [copy]';
                     // Clone page
                     if ($pages->insert(array('slug' => $rand_page_name, 'template' => $orig_page['template'], 'parent' => $orig_page['parent'], 'robots_index' => $orig_page['robots_index'], 'robots_follow' => $orig_page['robots_follow'], 'status' => $orig_page['status'], 'access' => isset($orig_page['access']) ? $orig_page['access'] : 'public', 'expand' => isset($orig_page['expand']) ? $orig_page['expand'] : '0', 'title' => $rand_page_title, 'meta_title' => $orig_page['meta_title'], 'description' => $orig_page['description'], 'keywords' => $orig_page['keywords'], 'tags' => $orig_page['tags'], 'date' => $orig_page['date'], 'author' => $orig_page['author']))) {
                         // Get cloned page ID
                         $last_id = $pages->lastId();
                         // Save cloned page content
                         File::setContent(STORAGE . DS . 'pages' . DS . $last_id . '.page.txt', File::getContent(STORAGE . DS . 'pages' . DS . $orig_page['id'] . '.page.txt'));
                         // Send notification
                         Notification::set('success', __('The page <i>:page</i> cloned.', 'pages', array(':page' => Security::safeName(Request::get('name'), '-', true))));
                     }
                     // Run add extra actions
                     Action::run('admin_pages_action_clone');
                     // Redirect
                     Request::redirect('index.php?id=pages');
                 } else {
                     die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                 }
                 break;
                 // Add page
                 // -------------------------------------
             // Add page
             // -------------------------------------
             case "add_page":
                 // Add page
                 if (Request::post('add_page') || Request::post('add_page_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         // Get parent page
                         if (Request::post('pages') == '0') {
                             $parent_page = '';
                         } else {
                             $parent_page = Request::post('pages');
                         }
                         // Validate
                         //--------------
                         if (trim(Request::post('page_name')) == '') {
                             $errors['pages_empty_name'] = __('Required field', 'pages');
                         }
                         if (trim(Request::post('page_title')) == '') {
                             $errors['pages_empty_title'] = __('Required field', 'pages');
                         }
                         if (count($pages->select('[slug="' . Security::safeName(Request::post('page_name'), '-', true) . '"]')) != 0) {
                             $errors['pages_exists'] = __('This page already exists', 'pages');
                         }
                         // Prepare date
                         if (Valid::date(Request::post('page_date'))) {
                             $date = strtotime(Request::post('page_date'));
                         } else {
                             $date = time();
                         }
                         if (Request::post('robots_index')) {
                             $robots_index = 'noindex';
                         } else {
                             $robots_index = 'index';
                         }
                         if (Request::post('robots_follow')) {
                             $robots_follow = 'nofollow';
                         } else {
                             $robots_follow = 'follow';
                         }
                         // If no errors then try to save
                         if (count($errors) == 0) {
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:pages.admin.php


注:本文中的XML::safe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。