本文整理汇总了PHP中xml_convert函数的典型用法代码示例。如果您正苦于以下问题:PHP xml_convert函数的具体用法?PHP xml_convert怎么用?PHP xml_convert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xml_convert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rss
public function rss()
{
requirePermission("view");
// HACK FIX: Wipe the output buffer, because something is placing a tab in it.
ob_end_clean();
// Load the XML helper
$this->load->helper('xml');
// Get the articles with the upper limit decided by our config.
$this->news_articles = $this->news_model->getArticles(0, $this->config->item('news_limit'));
// For each key we need to add the special values that we want to print
foreach ($this->news_articles as $key => $article) {
$this->news_articles[$key]['title'] = xml_convert(langColumn($article['headline']));
$this->news_articles[$key]['content'] = xml_convert(langColumn($article['content']));
$this->news_articles[$key]['link'] = base_url() . 'news/view/' . $article['id'];
$this->news_articles[$key]['date'] = date(DATE_RSS, $article['timestamp']);
$this->news_articles[$key]['author'] = $this->user->getNickname($article['author_id']);
$this->news_articles[$key]['tags'] = $this->news_model->getTags($article['id']);
}
$data['link'] = $this->config->site_url();
$data['domain'] = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
$data['feed_url'] = base_url() . 'news/rss';
$data['page_description'] = $this->config->item('rss_description');
$data['page_language'] = $this->config->item('rss_lang');
$data['articles'] = $this->news_articles;
header('Content-Type: text/xml; charset=UTF-8');
echo $this->template->loadPage('rss.tpl', $data);
}
示例2: _build_feed
function _build_feed( $posts = array() )
{
$this->data->rss->encoding = $this->config->item('charset');
$this->data->rss->feed_name = $this->settings->item('site_name');
$this->data->rss->feed_url = base_url();
$this->data->rss->page_description = sprintf($this->lang->line('blog_rss_posts_title'), $this->settings->item('site_name'));
$this->data->rss->page_language = 'en-gb';
$this->data->rss->creator_email = $this->settings->item('contact_email');
if(!empty($posts))
{
foreach($posts as $row)
{
//$row->created_on = human_to_unix($row->created_on);
$row->link = site_url('blog/' .date('Y/m', $row->created_on) .'/'. $row->slug);
$row->created_on = standard_date('DATE_RSS', $row->created_on);
$item = array(
//'author' => $row->author,
'title' => xml_convert($row->title),
'link' => $row->link,
'guid' => $row->link,
'description' => $row->intro,
'date' => $row->created_on
);
$this->data->rss->items[] = (object) $item;
}
}
}
示例3: __construct
/**
* Constructor
*
*/
public function __construct($str = '')
{
$protect_all = ee()->TMPL->fetch_param('protect_entities') === 'yes' ? TRUE : FALSE;
$str = $str == '' ? ee()->TMPL->tagdata : $str;
// Load the XML Helper
ee()->load->helper('xml');
$str = xml_convert(strip_tags($str), $protect_all);
// Strip [email] tags
$str = preg_replace("/\\[email=(.*?)\\](.*?)\\[\\/email\\]/i", '\\2', $str);
$str = preg_replace("/\\[email\\](.*?)\\[\\/email\\]/i", '\\1', $str);
$this->return_data = trim(str_replace(' ', ' ', $str));
}
示例4: Xml_encode
/**
* Constructor
*
*/
function Xml_encode($str = '')
{
$this->EE =& get_instance();
$protect_all = ($this->EE->TMPL->fetch_param('protect_entities') === 'yes') ? TRUE : FALSE;
$str = ($str == '') ? $this->EE->TMPL->tagdata : $str;
// Load the XML Helper
$this->EE->load->helper('xml');
$str = xml_convert(strip_tags($str), $protect_all);
$this->return_data = trim(str_replace(' ', ' ', $str));
}
示例5: index
function index()
{
$board =& $this->board;
$bo_table = $board['bo_table'];
if ($board['bo_read_level'] > 1) {
echo '비회원의 접근이 가능하지 않습니다.';
exit;
}
if (!$board['bo_use_rss']) {
echo 'RSS를 지원하지 않습니다.';
exit;
}
$this->load->helper('xml');
$base_url = $this->config->item('base_url');
$this->db->select('wr_id, mb_id, ca_code, wr_subject, wr_content, wr_datetime');
$qry = $this->db->get_where('ki_write', array('bo_table' => $bo_table), 15);
$result = $qry->result_array();
if ($board['bo_use_category']) {
$CI =& get_instance();
$CI->load->model('Category_model');
$category = $CI->Category_model->get_category('bo_' . $bo_table);
}
header("Content-type: text/xml; charset=" . $this->config->item('charset'));
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
echo "<?xml version=\"1.0\" encoding=\"" . $this->config->item('charset') . "\"?>\n";
echo "<rss version=\"2.0\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\">\n";
echo "<channel>\n";
echo "<title><![CDATA[" . xml_convert($board['bo_subject']) . "]]></title>\n";
echo "<link>" . $base_url . '/board/' . $bo_table . "</link>\n";
echo "<description></description>\n";
echo "<language>ko</language>\n";
echo "<generator>Tested.co.kr</generator>\n";
echo "<pubDate>" . date('r', time()) . "</pubDate>\n";
foreach ($result as $row) {
echo "<item>\n";
echo "<author>" . $row['mb_id'] . "</author>\n";
if ($board['bo_use_category']) {
echo "<category><![CDATA[" . xml_convert($category[$row['ca_code']]) . "]]></category>\n";
}
echo "<title><![CDATA[" . xml_convert($row['wr_subject']) . "]]></title>\n";
echo "<link>" . $base_url . '/board/' . $bo_table . '/view/wr_id/' . $row['wr_id'] . "</link>\n";
echo "<description><![CDATA[" . xml_convert(cut_str(preg_replace("/\\s+ +/", '', strip_tags(htmlspecialchars_decode($row['wr_content']))), 300)) . "]]></description>\n";
echo "<pubDate>" . date('r', strtotime($row['wr_datetime'])) . "</pubDate>\n";
echo "</item>\n";
}
echo "</channel>\n";
echo "</rss>\n";
}
示例6: _build_feed
function _build_feed($posts = array())
{
$this->data->rss->encoding = $this->config->item('charset');
$this->data->rss->feed_name = $this->settings->item('site_name');
$this->data->rss->feed_url = base_url();
$this->data->rss->page_description = 'News articles for ' . $this->settings->item('site_name');
$this->data->rss->page_language = 'en-gb';
$this->data->rss->creator_email = $this->settings->item('contact_email');
if (!empty($posts)) {
foreach ($posts as $row) {
//$row->created_on = human_to_unix($row->created_on);
$row->link = site_url('news/' . date('Y/m', $row->created_on) . '/' . $row->slug);
$row->created_on = standard_date('DATE_RSS', $row->created_on);
$item = array('title' => xml_convert($row->title), 'link' => $row->link, 'guid' => $row->link, 'description' => str_replace('/img/post_resources/', base_url() . 'img/post_resources/', $row->body), 'date' => $row->created_on);
$this->data->rss->items[] = (object) $item;
}
}
}
示例7: xml_from_result_object
function xml_from_result_object($result, $params = array())
{
// Set our default values
foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val) {
if (!isset($params[$key])) {
$params[$key] = $val;
}
}
// Create variables for convenience
extract($params);
// Generate the result
$xml = "<{$root}>" . $newline;
foreach ($result as $row) {
$xml .= $tab . "<{$element}>" . $newline;
foreach ($row as $key => $val) {
$xml .= $tab . $tab . "<{$key}>" . xml_convert($val) . "</{$key}>" . $newline;
}
$xml .= $tab . "</{$element}>" . $newline;
}
$xml .= "</{$root}>" . $newline;
return $xml;
}
示例8: _build_feed
public function _build_feed($posts = array(), $suffix = '')
{
$data = new stdClass();
$data->rss = new stdClass();
$data->rss->encoding = $this->config->item('charset');
$data->rss->feed_name = Settings::get('site_name') . ' ' . $suffix;
$data->rss->feed_url = base_url();
$data->rss->page_description = sprintf($this->lang->line('blog:rss_posts_title'), Settings::get('site_name'));
$data->rss->page_language = 'en-gb';
$data->rss->creator_email = Settings::get('contact_email');
if (!empty($posts)) {
foreach ($posts as $row) {
//$row->created_on = human_to_unix($row->created_on);
$row->link = site_url('blog/' . date('Y/m', $row->created_on) . '/' . $row->slug);
$row->created_on = date(DATE_RSS, $row->created_on);
$intro = isset($row->intro) ? $row->intro : $row->body;
$item = array('title' => xml_convert($row->title), 'link' => $row->link, 'guid' => $row->link, 'description' => $intro, 'date' => $row->created_on, 'category' => $row->category_title);
$data->rss->items[] = (object) $item;
}
}
return $data;
}
示例9: export
function export($datas)
{
//tempname('FCPATH')
$out = "<traspaso>\n";
foreach ($datas as $data) {
if (isset($data['select']) and count($data['select']) > 0) {
$this->ci->db->select($data['select']);
}
if (isset($data['where'])) {
$this->ci->db->where($data['where'], NULL, FALSE);
} else {
$data['where'] = '';
}
if (isset($data['distinc']) and $data['distinc']) {
$this->db->distinct();
}
$this->ci->db->from($data['table']);
$query = $this->ci->db->get();
if ($query->num_rows() > 0) {
$out .= "<esquema>";
$out .= "<tabla>{$data['table']}</tabla>";
$out .= "<where>{$data['where']}</where>";
$out .= "<data>";
foreach ($query->result_array() as $row) {
$out .= " <fila>\n";
foreach ($row as $campo => $valor) {
$out .= "<campo nombre='{$campo}'>" . xml_convert($valor) . "</campo>";
}
$out .= "</fila>";
}
$out .= "</data>";
$out .= "</esquema>\n";
}
}
$out .= "</traspaso>";
return $out;
}
示例10: delimited_to_xml
/** -------------------------------------
/** Convert delimited text to XML
/** -------------------------------------*/
function delimited_to_xml($params, $reduce_null = FALSE)
{
if (!is_array($params)) {
return FALSE;
}
$defaults = array('data' => NULL, 'structure' => array(), 'root' => 'root', 'element' => 'element', 'delimiter' => "\t", 'enclosure' => '');
foreach ($defaults as $key => $val) {
if (!isset($params[$key])) {
$params[$key] = $val;
}
}
extract($params);
/*
$data - string containing delimited data
$structure - array providing a key for $data elements
$root - the root XML document tag name
$element - the tag name for the element used to enclose the tag data
$delimiter - the character delimiting the text, default is \t (tab)
$enclosure - character used to enclose the data, such as " in the case of $data = '"item", "item2", "item3"';
*/
if ($data === NULL or !is_array($structure) or count($structure) == 0) {
return FALSE;
}
/** -------------------------------------
/** Convert delimited text to array
/** -------------------------------------*/
$data_arr = array();
$data = str_replace(array("\r\n", "\r"), "\n", $data);
$lines = explode("\n", $data);
if (empty($lines)) {
$this->errors[] = "No data to work with";
return FALSE;
}
if ($enclosure == '') {
foreach ($lines as $key => $val) {
if (!empty($val)) {
$data_arr[$key] = explode($delimiter, $val);
}
}
} else {
foreach ($lines as $key => $val) {
if (!empty($val)) {
preg_match_all("/" . preg_quote($enclosure) . "(.*?)" . preg_quote($enclosure) . "/si", $val, $matches);
$data_arr[$key] = $matches[1];
if (empty($data_arr[$key])) {
$this->errors[] = 'Structure mismatch, skipping line: ' . $val;
unset($data_arr[$key]);
}
}
}
}
// Construct the XML
$xml = "<{$root}>\n";
foreach ($data_arr as $datum) {
if (!empty($datum) and count($datum) == count($structure)) {
$xml .= "\t<{$element}>\n";
foreach ($datum as $key => $val) {
if ($reduce_null == TRUE && $structure[$key] == '') {
continue;
}
$xml .= "\t\t<{$structure[$key]}>" . xml_convert($val) . "</{$structure[$key]}>\n";
}
$xml .= "\t</{$element}>\n";
} else {
$details = '';
foreach ($datum as $val) {
$details .= "{$val}, ";
}
$this->errors[] = 'Line does not match structure: ' . substr($details, 0, -2);
}
}
$xml .= "</{$root}>\n";
if (!stristr($xml, "<{$element}>")) {
$this->errors[] = "No valid elements to build XML";
return FALSE;
}
return $xml;
}
示例11: getXMLFromResult
/**
* Generate XML data from a query result object
*
* @param object $query Query result object
* @param array $params Any preferences
* @return string
*/
public function getXMLFromResult(ResultInterface $query, $params = array())
{
// Set our default values
foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val) {
if (!isset($params[$key])) {
$params[$key] = $val;
}
}
// Create variables for convenience
extract($params);
// Load the xml helper
// get_instance()->load->helper('xml');
// Generate the result
$xml = '<' . $root . '>' . $newline;
while ($row = $query->getUnbufferedRow()) {
$xml .= $tab . '<' . $element . '>' . $newline;
foreach ($row as $key => $val) {
$xml .= $tab . $tab . '<' . $key . '>' . xml_convert($val) . '</' . $key . '>' . $newline;
}
$xml .= $tab . '</' . $element . '>' . $newline;
}
return $xml . '</' . $root . '>' . $newline;
}
示例12: gmdate
<dc:creator>info@newsporta.com</dc:creator>
<dc:rights>Copyright <?php
echo gmdate("Y", time());
?>
</dc:rights>
<admin:generatorAgent rdf:resource="http://www.newsportal.com/" />
<?php
foreach ($data['news'] as $news) {
?>
<item>
<title><?php
echo xml_convert($news->title);
?>
</title>
<link><?php
echo base_url('news/detail/' . $news->idpost);
?>
</link>
<guid><?php
echo base_url('news/detail/' . $news->idpost);
?>
</guid>
<description><![CDATA[ <?php
echo character_limiter($news->body, 200);
?>
]]></description>
示例13: gmdate
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<dc:rights>Copyright <?php
echo gmdate('Y', strtotime($last_updated));
?>
</dc:rights>
<?php
if (!empty($posts)) {
?>
<?php
foreach ($posts as $post) {
?>
<item>
<title><?php
echo xml_convert($post->title);
?>
</title>
<link><?php
echo $post->url;
?>
</link>
<guid><?php
echo $post->url;
?>
</guid>
<pubDate><?php
echo $post->rss_date;
?>
</pubDate>
<description><![CDATA[
示例14: log_search_terms
/**
* Log Search terms
*
* @access public
* @param string
* @param string
* @return void
*/
public function log_search_terms($terms = '', $type = 'site')
{
if ($terms == '' or ee()->db->table_exists('exp_search_log') === FALSE) {
return;
}
if (ee()->config->item('enable_search_log') == 'n') {
return;
}
ee()->load->helper('xml');
$search_log = array('member_id' => ee()->session->userdata('member_id'), 'screen_name' => ee()->session->userdata('screen_name'), 'ip_address' => ee()->input->ip_address(), 'search_date' => ee()->localize->now, 'search_type' => $type, 'search_terms' => xml_convert(ee()->functions->encode_ee_tags(ee()->security->xss_clean($terms), TRUE)), 'site_id' => ee()->config->item('site_id'));
ee()->db->query(ee()->db->insert_string('exp_search_log', $search_log));
// Prune Database
srand(time());
if (rand() % 100 < 5) {
$max = !is_numeric(ee()->config->item('max_logged_searches')) ? 500 : ee()->config->item('max_logged_searches');
$query = ee()->db->query("SELECT MAX(id) as search_id FROM exp_search_log WHERE site_id = '" . ee()->db->escape_str(ee()->config->item('site_id')) . "'");
$row = $query->row_array();
if (isset($row['search_id']) && $row['search_id'] > $max) {
ee()->db->query("DELETE FROM exp_search_log WHERE site_id = '" . ee()->db->escape_str(ee()->config->item('site_id')) . "' AND id < " . ($row['search_id'] - $max) . "");
}
}
}
示例15: _rss
/**
* RSS method
* @access public
* @param array $url_segments The URL segments
* @return void
*/
public function _rss($url_segments)
{
// Remove the .rss suffix
$url_segments += array(preg_replace('/.rss$/', '', array_pop($url_segments)));
// Fetch this page from the database via cache
$page = $this->cache->model('pages_m', 'get_by_path', array($url_segments));
// If page is missing or not live (and not an admin) show 404
if (empty($page) or $page->status == 'draft' and $this->user->group !== 'admin' or !$page->rss_enabled) {
// Will try the page then try 404 eventually
$this->_page('404');
return;
}
$children = $this->cache->model('pages_m', 'get_many_by', array(array('parent_id' => $page->id, 'status' => 'live')));
$data->rss->title = ($page->meta_title ? $page->meta_title : $page->title) . ' | ' . $this->settings->site_name;
$data->rss->description = $page->meta_description;
$data->rss->link = site_url($url_segments);
$data->rss->creator_email = $this->settings->contact_email;
if (!empty($children)) {
$this->load->helper(array('date', 'xml'));
foreach ($children as &$row) {
$path = $this->pages_m->get_path_by_id($row->id);
$row->link = site_url($path);
$row->created_on = standard_date('DATE_RSS', $row->created_on);
$item = array('title' => xml_convert($row->title), 'link' => $row->link, 'guid' => $row->link, 'description' => $row->meta_description, 'date' => $row->created_on);
$data->rss->items[] = (object) $item;
}
}
$this->load->view('rss', $data);
}