Changeset 65479 in spip-zone
- Timestamp:
- Sep 3, 2012, 2:46:30 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/spipdf/spipdf.php
r65476 r65479 117 117 118 118 119 //function spipdf_remplaceSpan($matches) { return str_replace('img', 'img style="padding:5px;" style="float:'.$matches[1].'"', $matches[2]); } 120 function spipdf_remplaceSpan_wfloat($matches){ 121 return str_replace('img', 'img style="padding:5px;" class="pdf_img_float_' . $matches[1] . '"', $matches[2]); 122 } 123 function spipdf_remplaceSpan($matches){ 124 return str_replace('img', 'img style="padding:5px;" align="' . $matches[1] . '"', $matches[2]); 125 } 126 function spipdf_remplaceSpanCenter($matches){ 127 return $matches[1]; 128 } 129 //function spipdf_remplaceDt($matches) { return str_replace('img', 'img style="padding:5px;" style="float:'.$matches[1].'"', $matches[2]); } 130 function spipdf_remplaceDt_wfloat($matches){ 131 return str_replace('img', 'img style="padding:5px;" class="pdf_img_float_' . $matches[1] . '"', $matches[2]); 132 } 133 function spipdf_remplaceDt($matches){ 134 return str_replace('img', 'img style="padding:5px;" align="' . $matches[1] . '"', $matches[2]); 135 } 136 function spipdf_remplaceIdParName($matches){ 137 return str_replace('id=\'', 'name=\'', $matches[0]); 138 } 139 function spipdf_remplaceFloatPuce($matches){ 140 return str_replace('style=\'', 'style=\'float:left;', $matches[0]); 141 } 142 function spipdf_remplaceDtCenter($matches){ 143 return $matches[1]; 144 } 145 function spipdf_remplaceCaption($matches){ 146 $table = '<table style="border:none;"' . $matches[1] . '<tr><td style="text-align: center;border:none;">' . $matches[2] . '</td></tr>'; 147 $table .= '<tr><td style="border:none;">'; 148 $table .= '<table' . $matches[1] . $matches[3] . '</table>'; 149 $table .= '</td></tr></table>'; 150 return $table; 151 } 152 119 153 function spipdf_nettoyer_html($html, $params_pdf = array()){ 120 121 154 // supprimer les spans autour des images et récupérer le placement 122 155 $patterns_float = '/<span class=\'spip_document_.*spip_documents.*float:(.*);.*>(.*)<\/span>/iUms'; 123 if (!empty($params_pdf['float'])){ 124 //function remplaceSpan($matches) { return str_replace('img', 'img style="padding:5px;" style="float:'.$matches[1].'"', $matches[2]); } 125 function remplaceSpan($matches){ 126 return str_replace('img', 'img style="padding:5px;" class="pdf_img_float_' . $matches[1] . '"', $matches[2]); 127 } 128 } else { 129 function remplaceSpan($matches){ 130 return str_replace('img', 'img style="padding:5px;" align="' . $matches[1] . '"', $matches[2]); 131 } 132 } 133 $html = preg_replace_callback($patterns_float, 'remplaceSpan', $html); 156 $html = preg_replace_callback($patterns_float, !empty($params_pdf['float'])?'spipdf_remplaceSpan':'spipdf_remplaceSpan_wfloat', $html); 134 157 135 158 // supprimer les spans autour des images 136 159 $patterns_float = '/<span class=\'spip_document_.*spip_documents.*>(.*)<\/span>/iUms'; 137 function remplaceSpanCenter($matches){ 138 return $matches[1]; 139 } 140 141 $html = preg_replace_callback($patterns_float, 'remplaceSpanCenter', $html); 160 $html = preg_replace_callback($patterns_float, 'spipdf_remplaceSpanCenter', $html); 142 161 143 162 // supprimer les dl autour des images et récupérer le placement 144 163 $patterns_float = '/<dl class=\'spip_document_.*spip_documents.*float:(.*);.*<dt>(.*)<\/dt>.*<\/dl>/iUms'; 145 if (!empty($params_pdf['float'])){ 146 //function remplaceDt($matches) { return str_replace('img', 'img style="padding:5px;" style="float:'.$matches[1].'"', $matches[2]); } 147 function remplaceDt($matches){ 148 return str_replace('img', 'img style="padding:5px;" class="pdf_img_float_' . $matches[1] . '"', $matches[2]); 149 } 150 } else { 151 function remplaceDt($matches){ 152 return str_replace('img', 'img style="padding:5px;" align="' . $matches[1] . '"', $matches[2]); 153 } 154 } 155 $html = preg_replace_callback($patterns_float, 'remplaceDt', $html); 164 $html = preg_replace_callback($patterns_float, !empty($params_pdf['float'])?'spipdf_remplaceDt':'spipdf_remplaceDt_wfloat', $html); 156 165 157 166 // replacer id par name pour les notes 158 167 $patterns_note = '/<a.*href.*class=\'spip_note\'.*>/iUms'; 159 function remplaceIdParName($matches){ 160 return str_replace('id=\'', 'name=\'', $matches[0]); 161 } 162 163 $html = preg_replace_callback($patterns_note, 'remplaceIdParName', $html); 168 $html = preg_replace_callback($patterns_note, 'spipdf_remplaceIdParName', $html); 164 169 165 170 // float sur les puces graphiques TODO 166 171 $patterns_puce = '/<a.*href.*class=\'puce\'.*>/iUms'; 167 function remplaceFloatPuce($matches){ 168 return str_replace('style=\'', 'style=\'float:left;', $matches[0]); 169 } 170 171 //$html = preg_replace_callback($patterns_puce, 'remplaceFloatPuce', $html); 172 //$html = preg_replace_callback($patterns_puce, 'spipdf_remplaceFloatPuce', $html); 172 173 //img src="local/cache-vignettes/L8xH11/puce-32883.gif" class="puce" alt="-" style="height: 11px; width: 8px;" height="11" width="8"> 173 174 174 175 // supprimer les dl autour des images centrer 175 176 $patterns_float = '/<dl class=\'spip_document_.*spip_documents.*<dt>(.*)<\/dt>.*<\/dl>/iUms'; 176 function remplaceDtCenter($matches){ 177 return $matches[1]; 178 } 179 180 $html = preg_replace_callback($patterns_float, 'remplaceDtCenter', $html); 177 $html = preg_replace_callback($patterns_float, 'spipdf_remplaceDtCenter', $html); 181 178 182 179 // remplacer les captions 183 180 if (!empty($params_pdf['caption'])){ 184 181 $patterns_caption = '/<table(.*)<caption>(.*)<\/caption>(.*)<\/table>/iUms'; 185 function remplaceCaption($matches){ 186 $table = '<table style="border:none;"' . $matches[1] . '<tr><td style="text-align: center;border:none;">' . $matches[2] . '</td></tr>'; 187 $table .= '<tr><td style="border:none;">'; 188 $table .= '<table' . $matches[1] . $matches[3] . '</table>'; 189 $table .= '</td></tr></table>'; 190 return $table; 191 } 192 193 $html = preg_replace_callback($patterns_caption, 'remplaceCaption', $html); 182 $html = preg_replace_callback($patterns_caption, 'spipdf_remplaceCaption', $html); 194 183 } 195 184
Note: See TracChangeset
for help on using the changeset viewer.