本文整理汇总了PHP中kString::xmlEncode方法的典型用法代码示例。如果您正苦于以下问题:PHP kString::xmlEncode方法的具体用法?PHP kString::xmlEncode怎么用?PHP kString::xmlEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kString
的用法示例。
在下文中一共展示了kString::xmlEncode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stringToSafeXml
/**
* @param string $string
* @return string
*/
private static function stringToSafeXml($string)
{
$string = @iconv('utf-8', 'utf-8', $string);
$partially_safe = kString::xmlEncode($string);
$safe = str_replace(array('*', '/', '[', ']'), '', $partially_safe);
return $safe;
}
示例2: writeFullXmlNode
protected function writeFullXmlNode($nodeName, $value, $level, $attributes = array())
{
$res = '';
$res .= $this->writeOpenXmlNode($nodeName, $level, $attributes, false);
$res .= kString::xmlEncode(kString::xmlDecode("{$value}"));
//to create a valid XML (without unescaped special chars)
//we decode before encoding to avoid breaking an xml which its special chars had already been escaped
$res .= $this->writeClosingXmlNode($nodeName, 0);
return $res;
}
示例3: rebuildUsersListXml
public static function rebuildUsersListXml($users)
{
//"<contributor uid='$puser_id' name='$name' pic='$pic' sex='$sex'/>";
$data = "";
foreach ($users as $user) {
$puser_id = $user['uid'];
$name = $user['name'];
$pic = $user['pic'];
$sex = $user['sex'];
$data .= "<contributor uid='{$puser_id}' name='" . kString::xmlEncode($name) . "' pic='{$pic}' sex='{$sex}'/>";
}
return $data;
}
示例4: serializePrimitive
function serializePrimitive($object)
{
$this->_serializedString .= kString::xmlEncode($object);
}
示例5: addEntryToMetadata
//.........这里部分代码省略.........
$entry_id = $entry->getId();
// if the entry has an error - remove the pending
if ($entry->getStatus() == entryStatus::ERROR_CONVERTING) {
// return the XML - new if modified and the original if not
if ($current_kshow_version != null) {
// $entry->setUpdateWhenReady ( $current_kshow_version );
$should_save = self::updatePending($xml_doc, $entry_id, false);
// increment the count on the show entry
}
if ($should_save) {
return $xml_doc->saveXML();
}
// this is if the host has been added
return $content;
}
if ($entry->getStatus() != entryStatus::READY) {
// return the XML - new if modified and the original if not
if ($current_kshow_version != null) {
$entry->setUpdateWhenReady($current_kshow_version);
$should_save = self::updatePending($xml_doc, $entry_id, true);
// increment the count on the show entry
$show_entry = $entry->getKshow()->getShowEntry();
if ($show_entry) {
$show_entry->incInCustomData("pending_entries");
$show_entry->incInCustomData("moderated_entries");
$show_entry->save();
}
}
if ($should_save) {
return $xml_doc->saveXML();
}
// this is if the host has been added
return $content;
}
if ($vidAssets_count >= self::MAX_ENTRIES_IN_METADATA) {
KalturaLog::log("Exceeded number of entries in metadata [" . self::MAX_ENTRIES_IN_METADATA . "]. Will not add entry [{$entry_id}] to file.");
$should_save = false;
return null;
}
// staart at the beginning of the asset
$startTime = 0;
if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO) {
$isVideo = true;
$media_type_str = 'VIDEO';
$real_length = $entry->getLengthInMsecs() / 1000;
if ($real_length <= 0) {
$lenTime = 10;
// hard-coded first 10 seconds
} else {
$lenTime = $real_length;
}
} else {
if ($media_type == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$isVideo = false;
$media_type_str = 'IMAGE';
$lenTime = 4;
} else {
return $content;
// leave untouched
}
}
$addLastFadeoutTime = 1;
$media_name = $entry->getName();
$media_url = $entry->getDataUrl();
$relMedia_url = strstr($media_url, "/content");
if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO) {
// for video - change the URL of the asset to use the clipper
/* http://www6.localhost.com/index.php/keditorservices/flvclipper?entry_id=12353 */
$clipper_path = $host_name . "/index.php/keditorservices/flvclipper?entry_id={$entry_id}";
$media_url = $clipper_path;
}
$transition_duration = 1;
$host_id = 1 + $media_url % 7;
// make sure that the media_url is formated properly otherwize the editor wrongly modifies the URL
$media_url = str_replace("/localhost/", "/www{$host_id}.localhost.com/", $media_url);
$transition_type = "dissolve";
// the dissolve transition is from the cross family. It should not be used with the simple editor
$fixed_media_name = kString::xmlEncode($media_name);
$newVidasset = "\n" . ' <vidAsset k_id="' . $entry_id . '" type="' . $media_type_str . '" name="' . $fixed_media_name . '" url="' . $media_url . '">' . "\n" . ' <StreamInfo file_name="' . $relMedia_url . '" start_time="' . $startTime . '" len_time="' . $lenTime . '"
posX="0" posY="0" start_byte="-1" end_byte="-1" total_bytes="-1" real_seek_time="-1" volume="1"
pan="0" isSingleFrame="0" real_start_byte="-1" real_end_byte="-1" Clipped_Start="0" Clipped_Len="' . $lenTime . '"/>' . "\n" . ' <EndTransition cross="0" type="' . $transition_type . '" StartTime="' . ($lenTime - $transition_duration) . '" length="' . $transition_duration . '">' . "\n" . ' <arguments>' . "\n" . ' <name>' . $transition_type . '</name>' . "\n" . ' <version>1.00</version>' . "\n" . ' <arguments/>' . "\n" . ' </arguments>' . "\n" . ' </EndTransition>' . "\n" . ' </vidAsset>' . "\n";
// if there is a transition for the previous asset - calculate it's length
$totalTime = $totalTime + $lenTime - $prev_transition_duration;
// update the pending element if needed
$should_save = self::updatePending($xml_doc, $entry_id, true);
KalturaLog::log("Will append to xml\n{$newVidasset}");
$temp_xml_doc = new DOMDocument();
$temp_xml_doc->loadXML($newVidasset);
// echo $temp_xml_doc->saveXML( );
$new_node = $temp_xml_doc->documentElement;
$new_vid_asset = $xml_doc->importNode($new_node, true);
if (!$vidAsset_parentNode) {
KalturaLog::log("No VideoAssets parent node for entry [{$entry_id}] content [{$content}].");
return null;
}
// insert the new video asset as the last one in the "vidAssets" element
$vidAsset_parentNode->appendChild($new_vid_asset);
$one_and_only_seqDuaration->nodeValue = $totalTime;
return $xml_doc->saveXML();
}
示例6: objToXml
/**
* param_names is the list of fields to add as attributes to the xml node.
* each element in the array can either be a field name or a pair of name=>alias.
* if name - the name will be used as the attribute name.
* if name=>alias - the 'alias' will be used as the attribute name instead.
*/
public static function objToXml(BaseObject $obj, array $param_names, $xml_element_name = NULL, $close_xml_element = true, $map_to_add = NULL, $envoke_method = false)
{
if ($obj == NULL) {
return NULL;
}
if (!$obj instanceof BaseObject) {
throw new Exception("objToXml should have the first parameter an object of type BaseObject");
}
$res = $xml_element_name == NULL ? "" : "<" . $xml_element_name . " ";
foreach ($param_names as $param_name => $param_alias) {
// this is to be compatible both for flat arrays & associative ones
// it ASSUMEs there are no fields that are numbers in a BaseObject
$name = is_numeric($param_name) ? $param_alias : $param_name;
if ($envoke_method) {
//
$raw_value = myBaseObject::envokeMethod($obj, $name);
} else {
$raw_value = $obj->getByName($name, BasePeer::TYPE_FIELDNAME);
}
// escape the value of the attribute
$value = kString::xmlEncode($raw_value);
$res .= ' ' . $param_alias . '="' . $value . '"';
}
if ($map_to_add != NULL) {
foreach ($map_to_add as $attr => $val) {
$res .= ' ' . $attr . '="' . kString::xmlEncode($val) . '"';
}
}
$res .= $xml_element_name == NULL ? "" : $close_xml_element ? "/>\n" : ">\n";
return $res;
}
示例7: stringToSafeXml
/**
* @param string $string
* @return string
*/
private static function stringToSafeXml($string)
{
$string = @iconv('utf-8', 'utf-8', $string);
$safe = kString::xmlEncode($string);
return $safe;
}
示例8: renderMrssFeed
public function renderMrssFeed($list, $page = null, $result_count = null)
{
//print_r ( $list );
$str = $this->startMrss();
$str .= "<channel>";
$str .= "<description>Kaltura's mRss" . ($page ? ", page: {$page}" : "") . ($result_count ? ", results: {$result_count}" : "") . "</description>" . "<title>Kaltura's mRss</title>" . "<link>" . kString::xmlEncode($_SERVER["REQUEST_URI"]) . "</link>";
$str .= $this->recursiveRenderMrssFeed($list, 3);
$str .= "</channel>";
$str .= $this->endMrss();
return $str;
}
示例9: array2xmlImpl
protected function array2xmlImpl($array, $num_prefix = "num_", $depth = 0)
{
$depth++;
// echo ( "[$depth]array2xmlImpl:" . print_r ( $array , true ) . "<br>");
// echo ( "[$depth]--array2xmlImpl: $num_prefix <br>");
$result = "";
if ($array instanceof myBaseObject) {
/*
* $obj = objectWrapperBase::toArrayImpl ( $array );
$result.= self::array2xmlImpl( $array, $num_prefix , $depth);
*/
$result = null;
$fields = $array->getFieldNames();
foreach ($fields as $key) {
if (empty($key)) {
continue;
}
$val = $array->get($key);
// TODO - think if want to compare to === null -
// this will return 0 and empty strings (doesn't happen now)
//if ( empty ( $val ) && ( $val !== 0 ) ) continue;
if (!self::shouldDisplayValue($val)) {
continue;
}
try {
$key = self::tagNameFromField($key, $num_prefix);
// fix key if needed
$result .= "<" . $key . ">" . self::array2xmlImpl($val, $num_prefix, $depth) . "</" . $key . ">";
} catch (Exception $ex) {
$result .= "<" . $key . ">ERROR</" . $key . ">";
}
}
} else {
if ($array instanceof objectWrapperBase) {
/*
$obj = $array->toArray();
$result.= self::array2xmlImpl( $array, $num_prefix , $depth);
*/
$result = "";
$fields = $array->getFieldNames();
$i = 0;
foreach ($fields as $key) {
if (empty($key)) {
continue;
}
$val = $array->get($key);
if (!self::shouldDisplayValue($val)) {
continue;
}
try {
$key = self::tagNameFromField($key, $num_prefix);
// fix key if needed
$result .= "<" . $key . ">" . self::array2xmlImpl($val, $num_prefix, $depth) . "</" . $key . ">";
} catch (Exception $ex) {
$result .= "<" . $key . ">ERROR</" . $key . ">";
}
}
} elseif (is_array($array)) {
$result = "";
if (kArray::array_is_associative($array)) {
foreach ($array as $key => $val) {
try {
$key = self::tagNameFromField($key, $num_prefix);
// fix key if needed
$result .= "<" . $key . ">" . self::array2xmlImpl($val, $num_prefix, $depth) . "</" . $key . ">";
} catch (Exception $ex) {
$result .= "<" . $key . ">ERROR</" . $key . ">";
}
}
} else {
$array_size = count($array);
for ($i = 0; $i < $array_size; ++$i) {
if (key_exists($i, $array)) {
$val = $array[$i];
} else {
}
try {
$key = self::tagNameFromField($i, $num_prefix);
// fix key if needed
$result .= "<" . $key . ">" . self::array2xmlImpl($val, $num_prefix, $depth) . "</" . $key . ">";
} catch (Exception $ex) {
$result .= "<" . $key . ">ERROR</" . $key . ">";
}
}
}
} elseif (is_object($array)) {
return "ERROR fromating object of type [" . get_class($array) . "]";
//echo ( "[$depth]array2xmlImpl:is_object " . get_class ( $array ) . "<br>" );
} else {
//cho ( "[$depth]array2xmlImpl: " . get_class ( $array ) . "<br>");
//return htmlentities ( $array );
if ($this->escape_text) {
// TODO - decide whether to encode or cdata or nothing - according to the name of the field
$escaped = kString::xmlEncode($array);
return $escaped;
/*
if ( $escaped != $array )
{
return "<![CDATA[$array]]>";
}
//.........这里部分代码省略.........
示例10:
&entry_id=<?php
echo $entry_id;
?>
">investigate</a>
<br>
<?php
if (!empty($metadata)) {
?>
Pending string: <input type="input" id="pending" name="pending" value="<?php
echo $pending;
?>
"/>
Remove Pending all together: <input type="checkbox" id="remove_pending" name="remove_pending" />
<?php
}
?>
<input type="submit" id="Go" name="Go" value="Go"/>
</form>
</div>
<pre style="background-color: lightyellow; width: 80%;">
<?php
echo kString::xmlEncode($metadata);
?>
</pre>
示例11: serializeObject
function serializeObject($object)
{
if ($object instanceof Exception) {
echo '<error>';
$this->writeTag('code', kString::xmlEncode($object->getCode()));
$this->writeTag('message', kString::xmlEncode($object->getMessage()));
$this->writeTag('objectType', get_class($object));
$this->writeKalturaAPIExceptionArgsTag($object);
echo '</error>';
} else {
// get object class
$reflectObject = new ReflectionObject($object);
$class = $reflectObject->getName();
// write the object type
$this->writeTag('objectType', $class);
// load class reflection
$typeReflector = KalturaTypeReflectorCacher::get($class);
if (!$typeReflector) {
echo '<error>';
$this->writeTag('message', 'Type reflector not found');
echo '</error>';
return;
}
$properties = $typeReflector->getProperties();
foreach ($properties as $property) {
$name = $property->getName();
$value = $object->{$name};
if ($this->_ignoreNull === true && $value === null) {
continue;
}
echo '<' . $name . '>';
$this->serializeByType($value);
echo '</' . $name . '>';
}
}
}
示例12: serializePrimitive
function serializePrimitive($object)
{
echo kString::xmlEncode($object);
}