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


PHP XmlWriter::outputMemory方法代码示例

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


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

示例1: outputSitemap

 public function outputSitemap(Kwf_Component_Data $page)
 {
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('urlset');
     $xml->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     foreach (array_unique($this->_getSitemap($page)) as $url) {
         $xml->startElement('url');
         $xml->writeElement('loc', $url);
         $xml->endElement();
     }
     $xml->endElement();
     $xml->endDocument();
     header('Content-Type: text/xml; charset=utf-8');
     echo $xml->outputMemory(true);
     exit;
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:18,代码来源:Sitemap.php

示例2: objectSerialize

 /** 
  * Serialize an object with specified root element name. 
  * 
  * @param object $targetObject The target object. 
  * @param string $rootName     The name of the root element. 
  * 
  * @return string
  */
 public static function objectSerialize($targetObject, $rootName)
 {
     Validate::notNull($targetObject, 'targetObject');
     Validate::isString($rootName, 'rootName');
     $xmlWriter = new \XmlWriter();
     $xmlWriter->openMemory();
     $xmlWriter->setIndent(true);
     $reflectionClass = new \ReflectionClass($targetObject);
     $methodArray = $reflectionClass->getMethods();
     $attributes = self::_getInstanceAttributes($targetObject, $methodArray);
     $xmlWriter->startElement($rootName);
     if (!is_null($attributes)) {
         foreach (array_keys($attributes) as $attributeKey) {
             $xmlWriter->writeAttribute($attributeKey, $attributes[$attributeKey]);
         }
     }
     foreach ($methodArray as $method) {
         if (strpos($method->name, 'get') === 0 && $method->isPublic() && $method->name != 'getAttributes') {
             $variableName = substr($method->name, 3);
             $variableValue = $method->invoke($targetObject);
             if (!empty($variableValue)) {
                 if (gettype($variableValue) === 'object') {
                     $xmlWriter->writeRaw(XmlSerializer::objectSerialize($variableValue, $variableName));
                 } else {
                     $xmlWriter->writeElement($variableName, $variableValue);
                 }
             }
         }
     }
     $xmlWriter->endElement();
     return $xmlWriter->outputMemory(true);
 }
开发者ID:bitmovin,项目名称:azure-sdk-for-php,代码行数:40,代码来源:XmlSerializer.php

示例3: show

 public function show()
 {
     echo $this->writer->outputMemory();
 }
开发者ID:JoshBour,项目名称:karolina,代码行数:4,代码来源:SitemapXmlParser.php

示例4: _get_incidents


//.........这里部分代码省略.........
                 } else {
                     $xml->startElement('comment');
                     $xml->writeElement('id', $comment_item['id']);
                     $xml->writeElement('comment_author', $comment_item['comment_author']);
                     $xml->writeElement('comment_email', $comment_item['comment_email']);
                     $xml->writeElement('comment_description', $comment_item['comment_description']);
                     $xml->writeElement('comment_rating', $comment_item['comment_rating']);
                     $xml->writeElement('comment_date', $comment_item['comment_date']);
                     $xml->endElement();
                 }
             }
         }
         // End comments
         $xml->endElement();
         $json_report_media[$item->incident_id] = array();
         if (count($media_items) > 0) {
             if (isset($media_items[$item->incident_id]) and count($media_items[$item->incident_id]) > 0) {
                 $xml->startElement('mediaItems');
                 foreach ($media_items[$item->incident_id] as $media_item) {
                     $url_prefix = url::base() . Kohana::config('upload.relative_directory') . '/';
                     // If our media is not an image, we don't need to show an upload path
                     if ($media_item['mediatype'] != 1) {
                         $upload_path = '';
                     } elseif ($media_item['mediatype'] == 1 and valid::url($media_item['medialink']) == TRUE) {
                         // If our media is an img and is a valid URL, don't show the upload path or prefix
                         $upload_path = '';
                         $url_prefix = '';
                     }
                     if ($this->response_type == 'json') {
                         $json_report_media[$item->incident_id][] = array("id" => $media_item['mediaid'], "type" => $media_item['mediatype'], "link" => $upload_path . $media_item['medialink'], "thumb" => $upload_path . $media_item['mediathumb']);
                         // If we are look at certain types of media, add some fields
                         if ($media_item['mediatype'] == 1) {
                             // Grab that last key up there
                             $add_to_key = key($json_report_media[$item->incident_id]) + 1;
                             // Give a full absolute URL to the image
                             $json_report_media[$item->incident_id][$add_to_key]["thumb_url"] = $url_prefix . $upload_path . $media_item['mediathumb'];
                             $json_report_media[$item->incident_id][$add_to_key]["link_url"] = $url_prefix . $upload_path . $media_item['medialink'];
                         }
                     } else {
                         $xml->startElement('media');
                         if ($media_item['mediaid'] != "") {
                             $xml->writeElement('id', $media_item['mediaid']);
                         }
                         if ($media_item['mediatitle'] != "") {
                             $xml->writeElement('title', $media_item['mediatitle']);
                         }
                         if ($media_item['mediatype'] != "") {
                             $xml->writeElement('type', $media_item['mediatype']);
                         }
                         if ($media_item['medialink'] != "") {
                             $xml->writeElement('link', $upload_path . $media_item['medialink']);
                         }
                         if ($media_item['mediathumb'] != "") {
                             $xml->writeElement('thumb', $upload_path . $media_item['mediathumb']);
                         }
                         if ($media_item['mediathumb'] != "" and $media_item['mediatype'] == 1) {
                             $add_to_key = key($json_report_media[$item->incident_id]) + 1;
                             $xml->writeElement('thumb_url', $url_prefix . $upload_path . $media_item['mediathumb']);
                             $xml->writeElement('link_url', $url_prefix . $upload_path . $media_item['medialink']);
                         }
                         $xml->endElement();
                     }
                 }
                 $xml->endElement();
                 // Media
             }
         }
         $xml->endElement();
         // End incident
         // Check for response type
         if ($this->response_type == 'json') {
             $json_reports[] = array("incident" => array("incidentid" => $item->incident_id, "incidenttitle" => $item->incident_title, "incidentdescription" => $item->incident_description, "incidentdate" => $item->incident_date, "incidentmode" => $item->incident_mode, "incidentactive" => $item->incident_active, "incidentverified" => $item->incident_verified, "locationid" => $item->location_id, "locationname" => $item->location_name, "locationlatitude" => $item->latitude, "locationlongitude" => $item->longitude, "incidenthasended" => $this->incidentHasEnded($item->incident_id)), "categories" => $json_report_categories[$item->incident_id], "media" => $json_report_media[$item->incident_id], "comments" => $json_report_comments[$item->incident_id]);
         }
     }
     // Get the default decayimage icon
     $decayimage_default_icon = ORM::factory('decayimage', 1);
     if ($decayimage_default_icon->decayimage_thumb == $this->default_decayimage_thumb) {
         $decayimage_default_icon = url::site() . '/plugins/decayimage/images/' . $decayimage_default_icon->decayimage_thumb;
     } else {
         $decayimage_default_icon = $prefix . '/' . $decayimage_default_icon->decayimage_thumb;
     }
     // Create the JSON array
     $data = array("payload" => array("domain" => $this->domain, "incidents" => $json_reports, "decayimage_default_icon" => $decayimage_default_icon), "error" => $this->api_service->get_error_msg(0));
     if ($this->response_type == 'json') {
         return $this->array_as_json($data);
     } else {
         $xml->endElement();
         //end incidents
         $xml->endElement();
         // end payload
         $xml->startElement('error');
         $xml->writeElement('code', 0);
         $xml->writeElement('message', 'No Error');
         $xml->endElement();
         //end error
         $xml->endElement();
         // end response
         return $xml->outputMemory(true);
     }
 }
开发者ID:rjmackay,项目名称:decayimage,代码行数:101,代码来源:MY_Decayimage_Api_Object.php

示例5: array

 /**
  * do the search via the API
  * @param q - the search string.
  * 
  * @param limit - the value to limit by.
  * 
  * @return the search result.
  */
 function _doSearch($q, $limit)
 {
     /**
      * This is mostly borrowed from the search functionality 
      * see application/controller/search.php
      */
     $search_query = "";
     $keyword_string = "";
     $where_string = "";
     $plus = "";
     $or = "";
     $search_info = "";
     $html = "";
     $json_searches = array();
     // Stop words that we won't search for
     // Add words as needed!!
     $stop_words = array('the', 'and', 'a', 'to', 'of', 'in', 'i', 'is', 'that', 'it', 'on', 'you', 'this', 'for', 'but', 'with', 'are', 'have', 'be', 'at', 'or', 'as', 'was', 'so', 'if', 'out', 'not');
     $retJsonOrXml = '';
     //will hold the json/xml string to return
     $replar = array();
     //assists in proper xml generation
     // Doing this manaully. It was wasting my time trying to modularize it.
     // Will have to visit this again after a good rest. I mean a good rest.
     //XML elements
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('response');
     $xml->startElement('payload');
     $xml->startElement('searches');
     $keywords = explode(' ', $q);
     if (is_array($keywords) && !empty($keywords)) {
         array_change_key_case($keywords, CASE_LOWER);
         $i = 0;
         foreach ($keywords as $value) {
             if (!in_array($value, $stop_words) && !empty($value)) {
                 $chunk = mysql_real_escape_string($value);
                 if ($i > 0) {
                     $plus = ' + ';
                     $or = ' OR ';
                 }
                 // Give relevancy weighting
                 // Title weight = 2
                 // Description weight = 1
                 $keyword_string = $keyword_string . $plus . "(CASE WHEN incident_title LIKE '%{$chunk}%' THEN 2 ELSE 0 END) + (CASE WHEN incident_description LIKE '%{$chunk}%' THEN 1 ELSE 0 END)";
                 $where_string = $where_string . $or . "incident_title LIKE '%{$chunk}%' OR incident_description LIKE '%{$chunk}%'";
                 $i++;
             }
         }
         if (!empty($keyword_string) && !empty($where_string)) {
             $search_query = "SELECT *, (" . $keyword_string . ") AS relevance FROM incident WHERE (" . $where_string . ") ORDER BY relevance DESC ";
         }
     }
     if (!empty($search_query)) {
         if (!empty($limit) && is_numeric($limit)) {
             $l = "LIMIT 0 ," . $limit;
         } else {
             $l = " LIMIT ," . $this->list_limit;
         }
         $total_items = ORM::factory('incident')->where($where_string)->count_all();
         $s = $search_query . $l;
         $query = $this->db->query($s);
         $this->total_records = $total_items;
         // Results Bar
         if ($total_items != 0) {
             if ($this->responseType == 'json') {
                 $json_searches[] = array("total" => $total_items);
             } else {
                 $xml->writeElement('total', $total_items);
             }
         } else {
             $xml->writeElement('total', $total_items);
             //create the json array
             $data = array("payload" => array("searches" => $json_searches), "error" => $this->_getErrorMsg(0));
             if ($this->responseType == 'json') {
                 $retJsonOrXml = $this->_arrayAsJSON($data);
                 return $retJsonOrXml;
             } else {
                 $xml->endElement();
                 //end searches
                 $xml->endElement();
                 // end payload
                 $xml->startElement('error');
                 $xml->writeElement('code', 0);
                 $xml->writeElement('message', 'No Error');
                 $xml->endElement();
                 //end error
                 $xml->endElement();
                 // end response
                 return $xml->outputMemory(true);
             }
         }
//.........这里部分代码省略.........
开发者ID:jetherton,项目名称:Ushahidi_Haiti,代码行数:101,代码来源:api.php

示例6: index

 /**
  * Indexes the document $document using definition $definition
  *
  * @param ezcSearchDocumentDefinition $definition
  * @param mixed $document
  */
 public function index(ezcSearchDocumentDefinition $definition, $document)
 {
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->startElement('add');
     $xml->startElement('doc');
     $xml->startElement('field');
     $xml->writeAttribute('name', 'ezcsearch_type_s');
     $xml->text($definition->documentType);
     $xml->endElement();
     $xml->startElement('field');
     $xml->writeAttribute('name', 'id');
     $xml->text($document[$definition->idProperty]);
     $xml->endElement();
     foreach ($definition->fields as $field) {
         $value = $this->mapFieldValuesForIndex($field, $document[$field->field]);
         foreach ($value as $fieldValue) {
             $xml->startElement('field');
             $xml->writeAttribute('name', $this->mapFieldType($field->field, $field->type));
             $xml->text($fieldValue);
             $xml->endElement();
         }
     }
     $xml->endElement();
     $xml->endElement();
     $doc = $xml->outputMemory(true);
     $r = $this->sendRawPostCommand('update', array('wt' => 'json'), $doc);
     if ($this->inTransaction == 0) {
         $this->runCommit();
     }
 }
开发者ID:zetacomponents,项目名称:search,代码行数:37,代码来源:solr.php

示例7: _get_incidents


//.........这里部分代码省略.........
         if (isset($comment_items[$item->incident_id])) {
             foreach ($comment_items[$item->incident_id] as $comment_item) {
                 if ($this->response_type == 'json' or $this->response_type == 'jsonp') {
                     $json_report_comments[$item->incident_id][] = array("comment" => $comment_item);
                 } else {
                     $xml->startElement('comment');
                     $xml->writeElement('id', $comment_item['id']);
                     $xml->writeElement('comment_author', $comment_item['comment_author']);
                     $xml->writeElement('comment_email', $comment_item['comment_email']);
                     $xml->writeElement('comment_description', $comment_item['comment_description']);
                     $xml->writeElement('comment_date', $comment_item['comment_date']);
                     $xml->endElement();
                 }
             }
         }
         // End comments
         $xml->endElement();
         $json_report_media[$item->incident_id] = array();
         if (count($media_items) > 0) {
             if (isset($media_items[$item->incident_id]) and count($media_items[$item->incident_id]) > 0) {
                 $xml->startElement('mediaItems');
                 foreach ($media_items[$item->incident_id] as $media_item) {
                     if ($this->response_type == 'json' or $this->response_type == 'jsonp') {
                         $json_media_array = array("id" => $media_item['id'], "type" => $media_item['media_type'], "link" => $media_item['media_link'], "thumb" => $media_item['media_thumb']);
                         // If we are look at certain types of media, add some fields
                         if ($media_item['media_type'] == 1 and isset($media_item['media_thumb_url'])) {
                             // Give a full absolute URL to the image
                             $json_media_array["thumb_url"] = $media_item['media_thumb_url'];
                             $json_media_array["link_url"] = $media_item['media_link_url'];
                         }
                         $json_report_media[$item->incident_id][] = $json_media_array;
                     } else {
                         $xml->startElement('media');
                         if ($media_item['id'] != "") {
                             $xml->writeElement('id', $media_item['id']);
                         }
                         if ($media_item['media_title'] != "") {
                             $xml->writeElement('title', $media_item['media_title']);
                         }
                         if ($media_item['media_type'] != "") {
                             $xml->writeElement('type', $media_item['media_type']);
                         }
                         if ($media_item['media_link'] != "") {
                             $xml->writeElement('link', $upload_path . $media_item['media_link']);
                         }
                         if ($media_item['media_thumb'] != "") {
                             $xml->writeElement('thumb', $upload_path . $media_item['media_thumb']);
                         }
                         if ($media_item['media_type'] == 1 and isset($media_item['media_thumb_url'])) {
                             $xml->writeElement('thumb_url', $media_item['media_thumb_url']);
                             $xml->writeElement('link_url', $media_item['media_link_url']);
                         }
                         $xml->endElement();
                     }
                 }
                 $xml->endElement();
                 // Media
             }
         }
         if (count($custom_field_items) > 0 and $this->response_type != 'json' and $this->response_type != 'jsonp') {
             if (isset($custom_field_items[$item->incident_id]) and count($custom_field_items[$item->incident_id]) > 0) {
                 $xml->startElement('customFields');
                 foreach ($custom_field_items[$item->incident_id] as $field_item) {
                     $xml->startElement('field');
                     foreach ($field_item as $fname => $fval) {
                         $xml->writeElement($fname, $fval);
                     }
                     $xml->endElement();
                     // field
                 }
                 $xml->endElement();
                 // customFields
             }
         }
         $xml->endElement();
         // End incident
         // Check for response type
         if ($this->response_type == 'json' or $this->response_type == 'jsonp') {
             $json_reports[] = array("incident" => array("incidentid" => $item->incident_id, "incidenttitle" => $item->incident_title, "incidentdescription" => $item->incident_description, "incidentdate" => $item->incident_date, "incidentmode" => $item->incident_mode, "incidentactive" => $item->incident_active, "incidentverified" => $item->incident_verified, "locationid" => $item->location_id, "locationname" => $item->location_name, "locationlatitude" => $item->latitude, "locationlongitude" => $item->longitude), "categories" => $json_report_categories[$item->incident_id], "media" => $json_report_media[$item->incident_id], "comments" => $json_report_comments[$item->incident_id], "customfields" => isset($custom_field_items[$item->incident_id]) ? $custom_field_items[$item->incident_id] : array());
         }
     }
     // Create the JSON array
     $data = array("payload" => array("domain" => $this->domain, "incidents" => $json_reports), "error" => $this->api_service->get_error_msg(0));
     if ($this->response_type == 'json' or $this->response_type == 'jsonp') {
         return $this->array_as_json($data);
     } else {
         $xml->endElement();
         //end incidents
         $xml->endElement();
         // end payload
         $xml->startElement('error');
         $xml->writeElement('code', 0);
         $xml->writeElement('message', 'No Error');
         $xml->endElement();
         //end error
         $xml->endElement();
         // end response
         return $xml->outputMemory(true);
     }
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:101,代码来源:MY_Incidents_Api_Object.php

示例8: _get_incidents


//.........这里部分代码省略.........
         $xml->writeElement('verified', $item->incidentverified);
         $xml->startElement('location');
         $xml->writeElement('id', $item->locationid);
         $xml->writeElement('name', $item->locationname);
         $xml->writeElement('latitude', $item->locationlatitude);
         $xml->writeElement('longitude', $item->locationlongitude);
         $xml->endElement();
         $xml->startElement('categories');
         // Fetch categories
         $this->query = " SELECT c.category_title AS categorytitle, \n                c.id AS cid " . "FROM " . $this->table_prefix . "category AS c INNER JOIN " . $this->table_prefix . "incident_category AS ic ON " . "ic.category_id = c.id WHERE ic.incident_id =" . $item->incidentid;
         $category_items = $this->db->query($this->query);
         $json_report_categories[$item->incidentid] = array();
         foreach ($category_items as $category_item) {
             if ($this->response_type == 'json') {
                 $json_report_categories[$item->incidentid][] = array("category" => array("id" => $category_item->cid, "title" => $category_item->categorytitle));
             } else {
                 $xml->startElement('category');
                 $xml->writeElement('id', $category_item->cid);
                 $xml->writeElement('title', $category_item->categorytitle);
                 $xml->endElement();
             }
         }
         $xml->endElement();
         //end categories
         //fetch media associated with an incident
         $this->query = "SELECT m.id as mediaid, m.media_title AS \n                mediatitle, " . "m.media_type AS mediatype, m.media_link AS medialink, " . "m.media_thumb AS mediathumb FROM " . $this->table_prefix . "media AS m " . "INNER JOIN " . $this->table_prefix . "incident AS i ON i.id = m.incident_id " . "WHERE i.id =" . $item->incidentid;
         $media_items = $this->db->query($this->query);
         $json_report_media[$item->incidentid] = array();
         if (count($media_items) > 0) {
             $xml->startElement('mediaItems');
             foreach ($media_items as $media_item) {
                 if ($media_item->mediatype != 1) {
                     $upload_path = "";
                 }
                 $url_prefix = url::base() . Kohana::config('upload.relative_directory') . '/';
                 if ($this->response_type == 'json') {
                     $json_report_media[$item->incidentid][] = array("id" => $media_item->mediaid, "type" => $media_item->mediatype, "link" => $upload_path . $media_item->medialink, "thumb" => $upload_path . $media_item->mediathumb);
                     // If we are look at certain types of media, add some fields
                     if ($media_item->mediatype == 1) {
                         // Grab that last key up there
                         $add_to_key = key($json_report_media[$item->incidentid]) + 1;
                         // Give a full absolute URL to the image
                         $json_report_media[$item->incidentid][$add_to_key]["thumb_url"] = $url_prefix . $upload_path . $media_item->mediathumb;
                         $json_report_media[$item->incidentid][$add_to_key]["link_url"] = $url_prefix . $upload_path . $media_item->medialink;
                     }
                 } else {
                     $xml->startElement('media');
                     if ($media_item->mediaid != "") {
                         $xml->writeElement('id', $media_item->mediaid);
                     }
                     if ($media_item->mediatitle != "") {
                         $xml->writeElement('title', $media_item->mediatitle);
                     }
                     if ($media_item->mediatype != "") {
                         $xml->writeElement('type', $media_item->mediatype);
                     }
                     if ($media_item->medialink != "") {
                         $xml->writeElement('link', $upload_path . $media_item->medialink);
                     }
                     if ($media_item->mediathumb != "") {
                         $xml->writeElement('thumb', $upload_path . $media_item->mediathumb);
                     }
                     if ($media_item->mediathumb != "" and $media_item->mediatype == 1) {
                         $add_to_key = key($json_report_media[$item->incidentid]) + 1;
                         $xml->writeElement('thumb_url', $url_prefix . $upload_path . $media_item->mediathumb);
                         $xml->writeElement('link_url', $url_prefix . $upload_path . $media_item->medialink);
                     }
                     $xml->endElement();
                 }
             }
             $xml->endElement();
             // media
         }
         $xml->endElement();
         // end incident
         //needs different treatment depending on the output
         if ($this->response_type == 'json') {
             $json_reports[] = array("incident" => $item, "categories" => $json_report_categories[$item->incidentid], "media" => $json_report_media[$item->incidentid]);
         }
     }
     //create the json array
     $data = array("payload" => array("domain" => $this->domain, "incidents" => $json_reports), "error" => $this->api_service->get_error_msg(0));
     if ($this->response_type == 'json') {
         $ret_json_or_xml = $this->array_as_json($data);
         return $ret_json_or_xml;
     } else {
         $xml->endElement();
         //end incidents
         $xml->endElement();
         // end payload
         $xml->startElement('error');
         $xml->writeElement('code', 0);
         $xml->writeElement('message', 'No Error');
         $xml->endElement();
         //end error
         $xml->endElement();
         // end response
         return $xml->outputMemory(true);
     }
 }
开发者ID:mewsop,项目名称:Ushahidi_Web,代码行数:101,代码来源:MY_Incidents_Api_Object.php

示例9: _get_all_forms

 /**
  * Returns all form details in the platform
  *
  */
 private function _get_all_forms()
 {
     //Call to customforms helper to return all forms
     $forms = customforms::get_custom_forms();
     $is_json = $this->_is_json();
     if ($forms->count() == 0) {
         //Nothing was returned
         return $this->response(4);
         //We don't have any forms.
     }
     if ($is_json) {
         $json_item = array();
         $json = array();
     } else {
         $xml = new XmlWriter();
         $xml->openMemory();
         $xml->startDocument('1.0', 'UTF-8');
         $xml->startElement('response');
         $xml->startElement('payload');
         $xml->writeElement('domain', $this->domain);
         $xml->startElement('customforms');
         $xml->startElement('forms');
     }
     foreach ($forms as $form) {
         if ($is_json) {
             //Setup JSON array
             $json_item[] = array("id" => $form->id, "title" => $form->form_title, "description" => $form->form_description);
         } else {
             //Setup XML Elements
             $xml->startElement("form");
             $xml->writeElement("id", $form->id);
             $xml->writeElement("title", $form->form_title);
             $xml->writeElement("description", $form->form_description);
             $xml->endElement();
             //End form
         }
     }
     if ($is_json) {
         $json = array("payload" => array("customforms" => $json_item), "error" => $this->api_service->get_error_msg(0));
         return $this->array_as_json($json);
         //Return array as json
     } else {
         $xml->endElement();
         //End forms
         $xml->endElement();
         //End customforms
         $xml->endElement();
         //End payload
         $xml->startElement('error');
         $xml->writeElement('code', 0);
         $xml->writeElement('message', 'No Error');
         $xml->endElement();
         //end error
         $xml->endElement();
         //End response
         return $xml->outputMemory(true);
         //return XML output
     }
 }
开发者ID:huslage,项目名称:Ushahidi_Web,代码行数:63,代码来源:MY_Customforms_Api_Object.php

示例10: createUpdates

 /**
  * Create document(s) update XML
  *
  * @param array $documents
  *
  * @return string
  */
 protected function createUpdates(array $documents)
 {
     $xml = new \XmlWriter();
     $xml->openMemory();
     $xml->startElement('add');
     foreach ($documents as $document) {
         $xml->startElement('doc');
         foreach ($document as $field) {
             foreach ((array) $this->fieldValueMapper->map($field) as $value) {
                 $xml->startElement('field');
                 $xml->writeAttribute('name', $this->nameGenerator->getTypedName($field->name, $field->type));
                 $xml->text($value);
                 $xml->endElement();
             }
         }
         $xml->endElement();
     }
     $xml->endElement();
     return $xml->outputMemory(true);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:27,代码来源:Native.php

示例11: generate

 /**
  * Generates the XML output and saves it to a file or returns it as a string
  *
  * @return null|int Returns the number of bytes written to a local file or false on failure
  */
 protected function generate()
 {
     $w = new \XmlWriter();
     $w->openMemory();
     $w->setIndent(true);
     $w->setIndentString("    ");
     $w->startDocument('1.0', 'utf-8');
     $w->startElement($this->rootname);
     $row = $this->getRow();
     $keys = array_keys($row);
     foreach ($keys as $key) {
         $this->isValidName($key);
     }
     do {
         $w->startElement($this->rowname);
         foreach ($row as $key => $value) {
             if ($this->suppress && in_array($key, $this->suppress)) {
                 continue;
             }
             if ($this->hasChildren && in_array($key, $this->hasChildren)) {
                 $stripped = $this->stripHtml($value);
                 $w->startElement($key);
                 foreach ($stripped as $para) {
                     $w->writeElement('p', $para);
                 }
                 $w->endElement();
             } else {
                 $w->writeElement($key, $value);
             }
         }
         $w->endElement();
     } while ($row = $this->getRow());
     $w->endElement();
     $w->endDocument();
     $this->xml = $w->outputMemory();
     // write to file
     if (isset($this->filename) && $this->local) {
         $success = file_put_contents($this->filename, $this->xml);
         return $success;
     } elseif (isset($this->filename) && $this->download) {
         $this->outputHeaders();
         file_put_contents('php://output', $this->xml);
         exit;
     }
 }
开发者ID:sbogdanov108,项目名称:db_to_text,代码行数:50,代码来源:Xml.php

示例12: XmlWriter

        $msg = '';
        $sch = '';
        continue;
    } else {
        $msg = $feed->SMSCONTENT;
        $sch = $feed->TIME;
        if (!empty($msg) && $sch > $older_sch) {
            $older_sch = $sch;
        } else {
            continue;
        }
    }
    $xml = new XmlWriter();
    echo $msg;
    $xml->openMemory();
    $xml->startDocument('1.0', 'UTF-8');
    $xml->startElement('content');
    $xml->writeElement('updTime', gmdate('Y-m-d\\TH:i:s\\Z', strtotime($older_sch)));
    $xml->startElement('body');
    $xml->writeCData($msg);
    $xml->endElement();
    $xml->startElement('preview');
    $xml->writeCData(stripslashes($msg));
    $xml->endElement();
    $xml->endElement();
    echo 'yes4<br>';
    $file = "serieaweekly.xml";
    echo $file;
    file_put_contents("rss/" . $file, $xml->outputMemory(true));
}
echo '<br>done!';
开发者ID:hiroyalty,项目名称:sdpsports,代码行数:31,代码来源:xml.php

示例13: generate

 /**
  * Generates the XML output and saves it to a file or returns it as a string
  *
  * @return null|int Returns the number of bytes written to a local file or false on failure
  */
 protected function generate()
 {
     $w = new \XmlWriter();
     $w->openMemory();
     $w->setIndent(true);
     $w->setIndentString("    ");
     $w->startDocument('1.0', 'utf-8');
     $w->startElement($this->rootname);
     while ($object = $this->getRow()) {
         // Start a new row for each object
         $w->startElement($this->rowname);
         foreach ($object as $key => $value) {
             if ($this->suppress && in_array($key, $this->suppress)) {
                 continue;
             }
             $this->isValidName($key);
             // Check if the key contains another object
             if (is_object($value)) {
                 // Start parent element containing rows of each object
                 $w->startElement($key . "s");
                 // $value is an array of objects
                 foreach ($value as $obj) {
                     $w->startElement($key);
                     foreach ($obj as $field => $val) {
                         $this->isValidName($key);
                         $w->writeElement($field, $val);
                     }
                     $w->endElement();
                 }
                 $w->endElement();
             } else {
                 // Write each object's property->value as <key>value</key>
                 if ($this->hasChildren && in_array($key, $this->hasChildren)) {
                     $stripped = $this->stripHtml($value);
                     $w->startElement($key);
                     foreach ($stripped as $para) {
                         $w->writeElement('p', $para);
                     }
                     $w->endElement();
                 } else {
                     $w->writeElement($key, $value);
                 }
             }
         }
         $w->endElement();
     }
     $w->endElement();
     $w->endDocument();
     $this->xml = $w->outputMemory();
     // write to file
     if (isset($this->filename) && $this->local) {
         $success = file_put_contents($this->filename, $this->xml);
         return $success;
     } elseif (isset($this->filename) && $this->download) {
         $this->outputHeaders();
         file_put_contents('php://output', $this->xml);
         exit;
     }
 }
开发者ID:Hemant-Mann,项目名称:PHPExport,代码行数:64,代码来源:Xml.php

示例14: array


//.........这里部分代码省略.........
     //incident media
     $json_incident_media = array();
     //incident media
     $retJsonOrXml = '';
     //will hold the json/xml string to return
     $replar = array();
     //assists in proper xml generation
     // Doing this manaully. It was wasting my time trying modularize it.
     // Will have to visit this again after a good rest. I mean a good rest.
     //XML elements
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('response');
     $xml->startElement('payload');
     $xml->startElement('incidents');
     //find incidents
     $query = "SELECT i.id AS incidentid,i.incident_title AS incidenttitle," . "i.incident_description AS incidentdescription, i.incident_date AS " . "incidentdate, i.incident_mode AS incidentmode,i.incident_active AS " . "incidentactive, i.incident_verified AS incidentverified, l.id AS " . "locationid,l.location_name AS locationname,l.latitude AS " . "locationlatitude,l.longitude AS locationlongitude FROM incident AS i " . "INNER JOIN location as l on l.id = i.location_id " . "{$where} {$limit}";
     $items = $this->db->query($query);
     $i = 0;
     foreach ($items as $item) {
         if ($this->responseType == 'json') {
             $json_incident_media = array();
         }
         //build xml file
         $xml->startElement('incident');
         $xml->writeElement('id', $item->incidentid);
         $xml->writeElement('title', $item->incidenttitle);
         $xml->writeElement('description', $item->incidentdescription);
         $xml->writeElement('date', $item->incidentdate);
         $xml->writeElement('mode', $item->incidentmode);
         $xml->writeElement('active', $item->incidentactive);
         $xml->writeElement('verified', $item->incidentverified);
         $xml->startElement('location');
         $xml->writeElement('id', $item->locationid);
         $xml->writeElement('name', $item->locationname);
         $xml->writeElement('latitude', $item->locationlatitude);
         $xml->writeElement('longitude', $item->locationlongitude);
         $xml->endElement();
         $xml->startElement('categories');
         //fetch categories
         $query = " SELECT c.category_title AS categorytitle, c.id AS cid " . "FROM category AS c INNER JOIN incident_category AS ic ON " . "ic.category_id = c.id WHERE ic.incident_id =" . $item->incidentid . " LIMIT 0 , 20";
         $category_items = $this->db->query($query);
         foreach ($category_items as $category_item) {
             $xml->startElement('category');
             $xml->writeElement('id', $category_item->cid);
             $xml->writeElement('title', $category_item->categorytitle);
             $xml->endElement();
         }
         $xml->endElement();
         //end categories
         //fetch media associated with an incident
         $query = "SELECT m.id as mediaid, m.media_title AS mediatitle, " . "m.media_type AS mediatype, m.media_link AS medialink, " . "m.media_thumb AS mediathumb FROM media AS m " . "INNER JOIN incident AS i ON i.id = m.incident_id " . "WHERE i.id =" . $item->incidentid . "  LIMIT 0 , 20";
         $media_items = $this->db->query($query);
         if (count($media_items) > 0) {
             $xml->startElement('mediaItems');
             foreach ($media_items as $media_item) {
                 if ($this->responseType == 'json') {
                     $json_incident_media[] = $media_item;
                 } else {
                     $xml->startElement('media');
                     $xml->writeElement('id', $media_item->mediaid);
                     $xml->writeElement('title', $media_item->mediatitle);
                     $xml->writeElement('type', $media_item->mediatype);
                     $xml->writeElement('link', $media_item->medialink);
                     $xml->writeElement('thumb', $media_item->mediathumb);
                     $xml->endElement();
                 }
             }
             $xml->endElement();
             // media
         }
         $xml->endElement();
         // end incident
         //needs different treatment depending on the output
         if ($this->responseType == 'json') {
             $json_incidents[] = array("incident" => $item, "media" => $json_incident_media);
         }
     }
     //create the json array
     $data = array("payload" => array("incidents" => $json_incidents), "error" => $this->_getErrorMsg(0));
     if ($this->responseType == 'json') {
         $retJsonOrXml = $this->_arrayAsJSON($data);
         return $retJsonOrXml;
     } else {
         $xml->endElement();
         //end incidents
         $xml->endElement();
         // end payload
         $xml->startElement('error');
         $xml->writeElement('code', 0);
         $xml->writeElement('message', 'No Error');
         $xml->endElement();
         //end error
         $xml->endElement();
         // end response
         return $xml->outputMemory(true);
     }
     //return $retJsonOrXml;
 }
开发者ID:rabble,项目名称:Ushahidi_Web,代码行数:101,代码来源:api.php

示例15: array

 /**
  * Function for returning deleted incident id's only 
  */
 function _getDeletedIncidents($where = '', $limit = '')
 {
     $items = array();
     //will hold the items from the query
     $data = array();
     //items to parse to json
     $json_incidents = array();
     //incidents to parse to json
     $media_items = array();
     //incident media
     $json_incident_media = array();
     //incident media
     $retJsonOrXml = '';
     //will hold the json/xml string to return
     $replar = array();
     //assists in proper xml generation
     // Doing this manually. It was wasting my time trying to modularize it.
     // Will have to visit this again after a good rest. I mean a good rest.
     //XML elements
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('response');
     $xml->startElement('payload');
     $xml->writeElement('domain', $this->domain);
     $xml->startElement('incidents');
     //find incidents
     $query = "SELECT id, " . "incident_dateadd" . " FROM " . $this->table_prefix . "incident" . "{$where} {$limit}";
     $items = $this->db->query($query);
     $i = 0;
     foreach ($items as $item) {
         if ($this->responseType == 'json') {
             $json_incident_media = array();
         }
         //build xml file
         $xml->startElement('incident');
         $xml->writeElement('id', $item->id);
         $xml->writeElement('date', $item->incident_dateadd);
         $xml->endElement();
     }
     $xml->endElement();
     //end incidents
     $xml->endElement();
     // end payload
     $xml->startElement('error');
     $xml->writeElement('code', 0);
     $xml->writeElement('message', 'No Error');
     $xml->endElement();
     //end error
     $xml->endElement();
     // end response
     return $xml->outputMemory(true);
 }
开发者ID:nebogeo,项目名称:borrowed-scenery,代码行数:56,代码来源:api.php


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