本文整理汇总了PHP中CDataXML::Load方法的典型用法代码示例。如果您正苦于以下问题:PHP CDataXML::Load方法的具体用法?PHP CDataXML::Load怎么用?PHP CDataXML::Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDataXML
的用法示例。
在下文中一共展示了CDataXML::Load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _MakeItems
protected function _MakeItems($TITLE, $TYPE, $RES_ID, $PARENT_ID)
{
global $APPLICATION;
if ($PARENT_ID === 0) {
$linkToParentLessonId = CCourse::CourseGetLinkedLesson($this->COURSE_ID);
} else {
$linkToParentLessonId = (int) $PARENT_ID;
}
$createUnilesson = false;
if ($TYPE == "LES") {
$arFields = array('NAME' => $TITLE);
$createUnilesson = true;
} elseif ($TYPE == "CHA") {
$arFields = array('NAME' => $TITLE);
$createUnilesson = true;
} elseif ($TYPE == "QUE") {
$arFields = array("NAME" => $TITLE, "LESSON_ID" => $linkToParentLessonId);
$cl = new CLQuestion();
} elseif ($TYPE == "TES") {
$arFields = array("NAME" => $TITLE, "COURSE_ID" => $this->COURSE_ID);
$cl = new CTest();
} elseif ($TYPE === 'TMK') {
$arFields = array();
$cl = new CLTestMark();
} else {
return $PARENT_ID;
}
$r = new CDataXML();
if (!$r->Load($this->package_dir . "/" . strtolower($RES_ID) . ".xml")) {
$r = false;
}
if ($r !== false) {
if ($TYPE == "QUE") {
if (($data = $r->SelectNodes("/questestinterop/item/presentation/")) && ($resp = $r->SelectNodes("/questestinterop/item/resprocessing/"))) {
$arQ = array();
$arData = $data->__toArray();
$arResp = $resp->__toArray();
if (is_set($arData["#"]["material"][0]["#"], "mattext")) {
$arQ["NAME"] = $arData["#"]["material"][0]["#"]["mattext"][0]["#"];
}
if (is_set($arData["#"]["material"][0]["#"], "matimage")) {
$imageDescription = '';
if (is_set($arData["#"]["material"][0]["#"], 'image_description')) {
$imageDescription = $arData["#"]["material"][0]["#"]['image_description'][0]['#'];
}
$arQ["FILE_ID"] = array("MODULE_ID" => "learning", "name" => basename($arData["#"]["material"][0]["#"]["matimage"][0]["@"]["uri"]), "tmp_name" => $this->package_dir . "/" . $arData["#"]["material"][0]["#"]["matimage"][0]["@"]["uri"], "size" => @filesize($this->package_dir . "/" . $arData["#"]["material"][0]["#"]["matimage"][0]["@"]["uri"]), "type" => $arData["#"]["material"][0]["#"]["matimage"][0]["@"]["imagtype"], 'description' => $imageDescription);
}
if (is_set($arData["#"]["response_lid"][0]["@"], "rcardinality")) {
switch ($arData["#"]["response_lid"][0]["@"]["rcardinality"]) {
case "Multiple":
$arQ["QUESTION_TYPE"] = 'M';
break;
case "Text":
$arQ["QUESTION_TYPE"] = 'T';
break;
case "Sort":
$arQ["QUESTION_TYPE"] = 'R';
break;
default:
$arQ["QUESTION_TYPE"] = 'S';
break;
}
}
if (is_set($arResp["#"]["respcondition"][0]["#"], "setvar")) {
$arQ["POINT"] = $arResp["#"]["respcondition"][0]["#"]["setvar"][0]['#'];
}
//Additional
if ($bx = $r->SelectNodes("/questestinterop/item/bitrix/")) {
$arQ = array_merge($arQ, $this->_MakeFields($bx->__toArray(), $TYPE));
unset($bx);
}
$arFields = array_merge($arFields, $arQ);
$cl = new CLQuestion();
$ID = $cl->Add($arFields);
if ($ID > 0) {
$PARENT_ID = $ID;
$arCorrect = array();
if (is_set($arResp["#"]["respcondition"][0]["#"], "conditionvar") && is_set($arResp["#"]["respcondition"][0]["#"]["conditionvar"][0]["#"], "varequal")) {
foreach ($arResp["#"]["respcondition"][0]["#"]["conditionvar"][0]["#"]["varequal"] as $ar) {
$arCorrect[] = $ar["#"];
}
}
if (is_set($arData["#"]["response_lid"][0]["#"], "render_choice") && is_set($arData["#"]["response_lid"][0]["#"]["render_choice"][0]["#"], "response_label")) {
$i = 0;
foreach ($arData["#"]["response_lid"][0]["#"]["render_choice"][0]["#"]["response_label"] as $ar) {
$i += 10;
$cl = new CLAnswer();
$arFields = array("QUESTION_ID" => $PARENT_ID, "SORT" => $i, "CORRECT" => in_array($ar["@"]["ident"], $arCorrect) ? "Y" : "N", "ANSWER" => $ar["#"]["material"][0]["#"]["mattext"][0]["#"]);
$AswerID = $cl->Add($arFields);
$res = $AswerID > 0;
if (!$res) {
if ($e = $APPLICATION->GetException()) {
$this->arWarnings[$TYPE][] = array("TITLE" => $TITLE, "TEXT" => $e->GetString());
}
}
}
}
} else {
if ($e = $APPLICATION->GetException()) {
$this->arWarnings[$TYPE][] = array("TITLE" => $TITLE, "TEXT" => $e->GetString());
//.........这里部分代码省略.........
示例2: fopen
require_once($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/classes/general/xml.php");
$bIncorrectFormat = false;
$handle = fopen($abs_path, "r");
$size = filesize($abs_path);
if ($size > 20)
{
$contents = fread($handle, 20);
if (strtolower(substr($contents, 0, 5)) != "<?xml")
$bIncorrectFormat = true;
}
if (!$bIncorrectFormat)
{
$objXML = new CDataXML();
$objXML->Load($abs_path);
$arTree = $objXML->GetTree();
$arTracks = Array();
$bIncorrectFormat = true;
$ch = $arTree->children;
if (count($ch) > 0 && strtolower($ch[0]->name) == 'playlist')
{
$pl = $ch[0];
$tls = $pl->children;
for ($i_ = 0, $l_ = count($tls); $i_ < $l_; $i_++)
{
if (strtolower($tls[$i_]->name) != 'tracklist')
continue;
$tracks = $tls[$i_]->children;
for ($i = 0, $l = count($tracks); $i < $l; $i++)
示例3: ImportPropsFromXML
public static function ImportPropsFromXML($BID, $xmlPath, &$arOldNewID)
{
if (file_exists($xmlPath) && $BID && CModule::IncludeModule('iblock')) {
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/classes/general/xml.php';
$arExistProps = array();
$rsProp = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $BID));
while ($arProp = $rsProp->Fetch()) {
$arExistProps[$arProp['CODE']] = $arProp;
}
$arExistEnums = array();
$rsEnum = CIBlockPropertyEnum::GetList(array(), array('IBLOCK_ID' => $BID));
while ($arEnum = $rsEnum->Fetch()) {
$arExistEnums[$arEnum['PROPERTY_ID'] . '_' . $arEnum['XML_ID']] = $arEnum;
}
$arOldNewID = array();
$xml = new CDataXML();
$ep = new CIBlockProperty();
$en = new CIBlockPropertyEnum();
if ($xml->Load($xmlPath)) {
if ($node = $xml->SelectNodes('/asd_iblock_props/props/')) {
foreach ($node->children() as $child) {
$arProp = array_pop($child->__toArray());
$arFields = array('IBLOCK_ID' => $BID);
foreach ($arProp as $code => $v) {
$arFields[strtoupper($code)] = is_array($v[0]['#']['cdata-section']) ? $v[0]['#']['cdata-section'][0]['#'] : $v[0]['#'];
}
if (isset($arExistProps[$arFields['CODE']])) {
$arOldNewID[$arFields['OLD_ID']] = $arExistProps[$arFields['CODE']]['ID'];
$ep->Update($arExistProps[$arFields['CODE']]['ID'], $arFields);
} else {
$arOldNewID[$arFields['OLD_ID']] = $arFields['ID'] = $ep->Add($arFields);
$arExistProps[$arFields['CODE']] = $arFields;
}
}
}
if ($node = $xml->SelectNodes('/asd_iblock_props/enums/')) {
foreach ($node->children() as $child) {
$arProp = array_pop($child->__toArray());
$arFields = array('IBLOCK_ID' => $BID);
foreach ($arProp as $code => $v) {
$arFields[strtoupper($code)] = is_array($v[0]['#']['cdata-section']) ? $v[0]['#']['cdata-section'][0]['#'] : $v[0]['#'];
}
$arFields['PROPERTY_ID'] = $arExistProps[$arFields['PROPERTY_CODE']]['ID'];
if (isset($arExistEnums[$arFields['PROPERTY_ID'] . '_' . $arFields['XML_ID']])) {
$en->Update($arExistEnums[$arFields['PROPERTY_ID'] . '_' . $arFields['XML_ID']]['ID'], $arFields);
} else {
$en->Add($arFields);
}
}
}
}
}
}