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


PHP XMLWriter::endCData方法代码示例

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


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

示例1: GetProjectDetail

function GetProjectDetail($projId)
{
    //Return metadata about the columns in each table for a given database (table_schema)
    $qry = "SELECT id, p_name, p_details FROM tb_projects where id = " . $projId;
    date_default_timezone_set('Australia/Sydney');
    error_log("In project_get_detail.php...\n" . $qry);
    $dbConn = opendatabase();
    $result = mysqli_query($dbConn, $qry);
    date_default_timezone_set('Australia/Sydney');
    error_log("Records in Projects: " . mysqli_num_rows($result));
    if (!$result || mysqli_num_rows($result) <= 0) {
        echo "Could not obtain metadata information.";
        return false;
    }
    /*****************************************************************/
    $xml = new XMLWriter();
    //$projXml  = new DOMDocument();
    //$xml->openURI("php://output");
    $xml->openMemory();
    $xml->startDocument();
    $xml->setIndent(true);
    $xml->startElement("projects");
    while ($row = mysqli_fetch_assoc($result)) {
        $xml->startElement("project");
        $xml->writeAttribute('id', $projId);
        $xml->writeRaw($row['p_name']);
        $xml->endElement();
        $xml->startElement("project_details");
        $xml->startCData("details");
        $xml->writeRaw($row['p_details']);
        $xml->endCData();
        $xml->endElement();
    }
    $xml->endElement();
    $xml->endDocument();
    $dbConn->close();
    header('Content-type: text/xml');
    $strXML = $xml->outputMemory(TRUE);
    $xml->flush();
    date_default_timezone_set('Australia/Sydney');
    error_log("String XML:\n " . $strXML);
    //$projXml->loadXML($strXML);
    echo $strXML;
    /*****************************************************************
    	$options = array();
    	while ($row = mysqli_fetch_assoc($result)){
    		$options['object_row'][] = $row;
    	}
    	echo json_encode($options);
    	*****************************************************************/
}
开发者ID:vomoir,项目名称:rubricon,代码行数:51,代码来源:project_get_detail.php

示例2: GetProjectRubrics

function GetProjectRubrics($projId)
{
    //Return metadata about the columns in each table for a given database (table_schema)
    $qry = "SELECT r_level, r_text, task_id, tb_tasks.task_text FROM tb_rubrics " . "INNER JOIN tb_tasks ON tb_rubrics.task_id = tb_tasks.id " . "WHERE tb_tasks.project_id = " . $projId . " ORDER BY tb_tasks.id, tb_rubrics.r_level;";
    date_default_timezone_set('Australia/Sydney');
    error_log("In get_project_rubrics.php...\n" . $qry);
    $dbConn = opendatabase();
    $result = mysqli_query($dbConn, $qry);
    date_default_timezone_set('Australia/Sydney');
    error_log("Records in Projects: " . mysqli_num_rows($result));
    $row_cnt = mysqli_num_rows($result);
    $field_cnt = $result->field_count;
    error_log("Fields: " . $field_cnt);
    if (!$result || mysqli_num_rows($result) <= 0) {
        //echo("Could not obtain metadata information.");
        return false;
    }
    /*****************************************************************/
    $xml = new XMLWriter();
    $xml->openMemory();
    $xml->startDocument();
    $xml->setIndent(true);
    $xml->startElement("task_rubrics");
    /* fetch associative array */
    /*
    $row = mysqli_fetch_row($result);
    for($i = 0; $i < $field_cnt; $i++){
    	error_log("Row[". $i . "] = " . $row[$i]);
    	error_log("Row[". $i . "] = " . $row[$i].name);
    }
    */
    /*		
    		$finfo = $result->fetch_fields();
            foreach ($finfo as $val) {
                error_log("Name:      " .   $val->name);
                error_log("Table:     " .   $val->table);
                error_log("Max. Len:  " .   $val->max_length);
                error_log("Length:    " .   $val->length);
                error_log("charsetnr: " .   $val->charsetnr);
                error_log("Flags:     " .   $val->flags);
                error_log("Type:      " .   $val->type);
            }
            $result->free();
    */
    while ($row = mysqli_fetch_assoc($result)) {
        $xml->startElement("task");
        $xml->writeAttribute('id', $row['task_id']);
        $xml->writeRaw($row['task_text']);
        $xml->startElement("rubric_details");
        $xml->writeAttribute('r_level', $row['r_level']);
        $xml->startCData("details");
        $xml->writeRaw($row['r_text']);
        $xml->endCData();
        $xml->endElement();
        $xml->endElement();
    }
    $xml->endElement();
    $xml->endDocument();
    $dbConn->close();
    header('Content-type: text/xml');
    $strXML = $xml->outputMemory(TRUE);
    $xml->flush();
    date_default_timezone_set('Australia/Sydney');
    //error_log("String XML:\n " . $strXML);
    $projXml = new DOMDocument();
    $projXml->loadXML($strXML);
    error_log("loading xsl document...");
    $xsl = new DOMDocument();
    $xsl->load('xsl/proj_rub_html.xsl');
    // Configure the transformer
    $proc = new XSLTProcessor();
    $proc->importStyleSheet($xsl);
    // attach the xsl rules
    $projRubs = $proc->transformToXML($projXml);
    //error_log("XML Transform result\n" . $projRubs);
    echo $proc->transformToXML($projXml);
}
开发者ID:vomoir,项目名称:rubricon,代码行数:77,代码来源:get_project_rubrics.php

示例3: buildSearchIndexDocumentPMOS2


//.........这里部分代码省略.........
                             case 'date':
                                 $newdate = false;
                                 $withHour = true;
                                 // try to convert string to date
                                 // TODO convert to php 5.2 format
                                 /*
                                  * $newdate = date_create_from_format ( 'Y-m-d H:i:s', $value
                                  * ); if (! $newdate) { $newdate = date_create_from_format (
                                  * 'Y-m-d', $value ); $withHour = false; } if (! $newdate) {
                                  * $newdate = date_create_from_format ( 'd/m/Y', $value );
                                  * $withHour = false; } if (! $newdate) { $newdate =
                                  * date_create_from_format ( 'j/m/Y', $value ); $withHour =
                                  * false; }
                                  */
                                 $newdate = strtotime($value);
                                 if (!$newdate) {
                                     $typeSufix = '*';
                                     // not store field
                                 } else {
                                     $typeSufix = '_tdt';
                                     /*
                                      * if ($withHour) //$value = gmdate ( "Y-m-d\TH:i:s\Z",
                                      * $newdate->getTimestamp () ); $value = gmdate (
                                      * "Y-m-d\TH:i:s\Z", $newdate ); else { $value = gmdate (
                                      * "Y-m-d\T00:00:00\Z", $newdate ); }
                                      */
                                     $value = gmdate("Y-m-d\\T00:00:00\\Z", $newdate);
                                 }
                                 break;
                             case 'dropdown':
                                 $typeSufix = '_t';
                                 break;
                             case 'textarea':
                                 $typeSufix = '_t';
                                 break;
                             case 'currency':
                                 $typeSufix = '_td';
                                 $value = floatval($value);
                                 break;
                             case 'percentage':
                                 $typeSufix = '_t';
                                 break;
                             case 'password':
                                 $typeSufix = '_t';
                                 break;
                             case 'suggest':
                                 $typeSufix = '_t';
                                 break;
                             case 'yesno':
                                 $typeSufix = '_t';
                                 break;
                             case 'listbox':
                                 $typeSufix = '_t';
                                 break;
                             case 'checkbox':
                                 $typeSufix = '_t';
                                 break;
                             case 'checkgroup':
                                 $typeSufix = '_t';
                                 break;
                             case 'radiogroup':
                                 $typeSufix = '_t';
                                 break;
                             case 'hidden':
                                 $typeSufix = '_t';
                                 break;
                         }
                         if ($typeSufix != '*') {
                             $value = trim($value);
                             $pairs = array("" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "-" => "", "\t" => "", "" => "", "" => "", "-" => "", "" => "", "" => "");
                             $value = strtr($value, $pairs);
                             $writer->startElement("field");
                             $writer->writeAttribute('name', trim($k) . $typeSufix);
                             $writer->startCData();
                             $writer->text($value);
                             $writer->endCData();
                             $writer->endElement();
                         }
                     } else {
                         $value = trim($value);
                         $pairs = array("" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "-" => "", "\t" => "", "" => "", "" => "", "-" => "", "" => "", "" => "");
                         $value = strtr($value, $pairs);
                         $writer->startElement("field");
                         $writer->writeAttribute('name', trim($k) . '_t');
                         $writer->startCData();
                         $writer->text($value);
                         $writer->endCData();
                         $writer->endElement();
                     }
                 }
             }
             // foreach unserialized data
         }
         // else unserialize APP_DATA
     }
     // empty APP_DATA
     $writer->endElement();
     // end /doc
     return $writer->outputMemory(true);
 }
开发者ID:emildev35,项目名称:processmaker,代码行数:101,代码来源:class.AppSolr.php

示例4: GetTaskDetails

function GetTaskDetails($taskId)
{
    //Return metadata about the columns in each table for a given database (table_schema)
    $qry = "SELECT r_level, r_text, tb_tasks.task_text FROM tb_rubrics " . "INNER JOIN tb_tasks on tb_rubrics.task_id = tb_tasks.id " . "WHERE task_id = " . $taskId . " ORDER by r_level;";
    date_default_timezone_set('Australia/Sydney');
    error_log("In get_task_details.php...\n" . $qry);
    $dbConn = opendatabase();
    $result = mysqli_query($dbConn, $qry);
    date_default_timezone_set('Australia/Sydney');
    error_log("Records in Projects: " . mysqli_num_rows($result));
    $row_cnt = mysqli_num_rows($result);
    $field_cnt = $result->field_count;
    error_log("Fields: " . $field_cnt);
    if (!$result || mysqli_num_rows($result) <= 0) {
        //echo("Could not obtain metadata information.");
        return false;
    }
    /*****************************************************************/
    $xml = new XMLWriter();
    $xml->openMemory();
    $xml->startDocument();
    $xml->setIndent(true);
    $xml->startElement("task_rubrics");
    /* fetch associative array */
    while ($row = mysqli_fetch_assoc($result)) {
        $xml->startElement("task");
        $xml->writeAttribute('id', $taskId);
        $xml->writeRaw($row['task_text']);
        $xml->startElement("rubric_details");
        $xml->writeAttribute('r_level', $row['r_level']);
        $xml->startCData("details");
        $xml->writeRaw($row['r_text']);
        $xml->endCData();
        $xml->endElement();
        $xml->endElement();
    }
    $xml->endElement();
    $xml->endDocument();
    $dbConn->close();
    header('Content-type: text/xml');
    $strXML = $xml->outputMemory(TRUE);
    $xml->flush();
    date_default_timezone_set('Australia/Sydney');
    error_log("String XML:\n " . $strXML);
    //$projXml->loadXML($strXML);
    //echo $strXML;
    $projXml = new DOMDocument();
    $projXml->loadXML($strXML);
    //error_log($projXml->saveXML());
    error_log("loading xsl document...");
    $xsl = new DOMDocument();
    $xsl->load('xsl/task_rub_html.xsl');
    //error_log($xsl->saveXML());
    // Configure the transformer
    $proc = new XSLTProcessor();
    $proc->importStyleSheet($xsl);
    // attach the xsl rules
    $projRubs = $proc->transformToXML($projXml);
    error_log("XML Transform result\n" . $projRubs);
    echo $proc->transformToXML($projXml);
}
开发者ID:vomoir,项目名称:rubricon,代码行数:61,代码来源:get_task_details.php


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