當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DomDocument::SaveHTML方法代碼示例

本文整理匯總了PHP中DomDocument::SaveHTML方法的典型用法代碼示例。如果您正苦於以下問題:PHP DomDocument::SaveHTML方法的具體用法?PHP DomDocument::SaveHTML怎麽用?PHP DomDocument::SaveHTML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DomDocument的用法示例。


在下文中一共展示了DomDocument::SaveHTML方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_field_content


//.........這裏部分代碼省略.........
                     break;
                     // break datefield
             }
             // end switch
             break;
             // break date
         // break date
         case 'time':
             // process time hour
             if ($process_placeholders && isset($field['placeholderTimeHour']) && !empty($field['placeholderTimeHour'])) {
                 if ($input = ($result = $xpath->query("//input[@id='{$field_uid}_1']")) ? $result->item(0) : null) {
                     $input->setAttribute('placeholder', esc_attr($field['placeholderTimeHour']));
                 }
             }
             if (isset($field['labelTimeHour'])) {
                 if ($label = ($result = $xpath->query("//label[@for='{$field_uid}_1']")) ? $result->item(0) : null) {
                     $label->nodeValue = esc_html($field['labelTimeHour']);
                 }
             }
             if (isset($field['labelTimeHourVisible']) && $field['labelTimeHourVisible'] == false) {
                 if ($label = ($result = $xpath->query("//label[@for='{$field_uid}_1']")) ? $result->item(0) : null) {
                     $styles = $label->getAttribute('style');
                     $label->setAttribute('style', trim("{$styles} display:none;"));
                 }
             }
             // process time minute
             if ($process_placeholders && isset($field['placeholderTimeMinute']) && !empty($field['placeholderTimeMinute'])) {
                 if ($input = ($result = $xpath->query("//input[@id='{$field_uid}_2']")) ? $result->item(0) : null) {
                     $input->setAttribute('placeholder', esc_attr($field['placeholderTimeMinute']));
                 }
             }
             if (isset($field['labelTimeMinute'])) {
                 if ($label = ($result = $xpath->query("//label[@for='{$field_uid}_2']")) ? $result->item(0) : null) {
                     $label->nodeValue = esc_html($field['labelTimeMinute']);
                 }
             }
             if (isset($field['labelTimeMinuteVisible']) && $field['labelTimeMinuteVisible'] == false) {
                 if ($label = ($result = $xpath->query("//label[@for='{$field_uid}_2']")) ? $result->item(0) : null) {
                     $styles = $label->getAttribute('style');
                     $label->setAttribute('style', trim("{$styles} display:none;"));
                 }
             }
             break;
             // break time
         // break time
         case 'product':
         case 'singleproduct':
         case 'calculation':
             $product_disable_quantity = isset($field['disableQuantity']) && $field['disableQuantity'];
             if ($process_placeholders && !$product_disable_quantity && isset($field['placeholder']) && !empty($field['placeholder'])) {
                 if ($this->is_form_editor()) {
                     if ($input = ($result = $xpath->query("//input[@name='{$field_uid}.3']")) ? $result->item(0) : null) {
                         $input->setAttribute('placeholder', esc_attr($field['placeholder']));
                     }
                 } else {
                     if ($input = ($result = $xpath->query("//input[@name='input_{$field_id}.3']")) ? $result->item(0) : null) {
                         $input->setAttribute('placeholder', esc_attr($field['placeholder']));
                     }
                 }
             }
             break;
             // break product, singleproduct & caclulation
         // break product, singleproduct & caclulation
         case 'quantity':
             $quantity_type = isset($field['inputType']) && !empty($field['inputType']) ? $field['inputType'] : 'number';
             switch ($quantity_type) {
                 case 'number':
                     // Process Product Amount
                     if ($process_placeholders && isset($field['placeholder']) && !empty($field['placeholder'])) {
                         if ($input = ($result = $xpath->query("//input[@id='{$field_uid}']")) ? $result->item(0) : null) {
                             $input->setAttribute('placeholder', esc_attr($field['placeholder']));
                         }
                     }
                     break;
                     // break number
             }
             break;
             // break quantity
     }
     $field_content = $doc->SaveHTML();
     // remove our html wrapper from processed field
     $field_content = str_replace(array('<html>', '</html>', '<head>', '</head>', "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", '<body>', '</body>'), array('', '', '', '', '', '', ''), $field_content);
     $field_content = trim(preg_replace('/^<!DOCTYPE.+?>/', '', $field_content));
     // check if we are currently on ajax and fix double quotes to single.
     if (defined('RG_CURRENT_PAGE') && RG_CURRENT_PAGE == 'admin-ajax.php') {
         // replace non escaped double quotes with single quotes for ajax support
         $matches = array();
         preg_match_all('/"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"/s', $field_content, $matches);
         if (count($matches[0]) > 0) {
             foreach ($matches[0] as $match) {
                 $replace = "'" . substr($match, 1, strlen($match) - 2) . "'";
                 $field_content = str_replace($match, $replace, $field_content);
             }
         }
     }
     $this->log("processed field content", $field_content);
     // renable libxml error handling
     libxml_use_internal_errors($use_errors);
     return $field_content;
 }
開發者ID:bself,項目名稱:nuimage-wp,代碼行數:101,代碼來源:gravityforms-html5-placeholders.php


注:本文中的DomDocument::SaveHTML方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。