예제 #1
0
function getXMLString($name = false, $data, $ret = false, $debug = false)
{
    // given string $data, will return the text string content of the $name attribute content of a given valid xml document.
    if ($debug) {
        ezDebug::writeNotice($name, 'getXMLString:name');
    }
    // get information out of eZXML
    $xml = new eZXML();
    $xmlDoc = $data;
    if ($debug) {
        ezDebug::writeNotice($data, 'getXMLString:data');
    }
    // continue only with content
    if ($xmlDoc != null and $name != null) {
        $dom = $xml->domTree($xmlDoc);
        $element = $dom->elementsByName("{$name}");
        if (is_object($element[0])) {
            $string = $element[0]->textContent();
            $ret = $string;
        } else {
            eZDebug::writeNotice('Key "' . $name . '" does not exist.', 'wrap_operator');
        }
    }
    if ($debug) {
        ezDebug::writeNotice($ret, 'getXMLString:ret');
    }
    return $ret;
}
 function processEditActions(&$validation, $params)
 {
     $http = eZHTTPTool::instance();
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Text') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Text') != $this->Text) {
         $inputXML = $http->postVariable('SurveyQuestion_' . $this->ID . '_Text');
         $xmlData = "<section xmlns:image='http://ez.no/namespaces/ezpublish3/image/' xmlns:xhtml='http://ez.no/namespaces/ezpublish3/xhtml/' xmlns:custom='http://ez.no/namespaces/ezpublish3/custom/' >";
         $xmlData .= "<paragraph>";
         $xmlData .= $inputXML;
         $xmlData .= "</paragraph>";
         $xmlData .= "</section>";
         $xmlObject = new eZXMLText($inputXML, null);
         $inputHandler = $xmlObject->attribute('input');
         $data =& $inputHandler->convertInput($xmlData);
         $domString =& eZXMLTextType::domString($data[0]);
         $domString = preg_replace("#<paragraph> </paragraph>#", "<paragraph>&nbsp;</paragraph>", $domString);
         $domString = str_replace("<paragraph />", "", $domString);
         $domString = str_replace("<line />", "", $domString);
         $domString = str_replace("<paragraph></paragraph>", "", $domString);
         $domString = preg_replace("#<paragraph>&nbsp;</paragraph>#", "<paragraph />", $domString);
         $domString = preg_replace("#<paragraph></paragraph>#", "", $domString);
         $domString = preg_replace("#[\n]+#", "", $domString);
         $domString = preg_replace("#&lt;/line&gt;#", "\n", $domString);
         $domString = preg_replace("#&lt;paragraph&gt;#", "\n\n", $domString);
         $xml = new eZXML();
         $tmpDom = $xml->domTree($domString, array('CharsetConversion' => false));
         $domString = eZXMLTextType::domString($tmpDom);
         $this->setAttribute('text', $domString);
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Text2') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Text2') != $this->Text2) {
         $this->setAttribute('text2', $http->postVariable('SurveyQuestion_' . $this->ID . '_Text2'));
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Text3') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Text3') != $this->Text3) {
         $this->setAttribute('text3', $http->postVariable('SurveyQuestion_' . $this->ID . '_Text3'));
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Num') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Num') != $this->Num) {
         $this->setAttribute('num', $http->postVariable('SurveyQuestion_' . $this->ID . '_Num'));
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Num2') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Num2') != $this->Num2) {
         $this->setAttribute('num2', $http->postVariable('SurveyQuestion_' . $this->ID . '_Num2'));
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Mandatory_Hidden')) {
         if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Mandatory')) {
             $newMandatory = 1;
         } else {
             $newMandatory = 0;
         }
         if ($newMandatory != $this->Mandatory) {
             $this->setAttribute('mandatory', $newMandatory);
         }
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Default') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Default') != $this->Default) {
         $this->setAttribute('default_value', $http->postVariable('SurveyQuestion_' . $this->ID . '_Default'));
     }
 }