Reading time: 2 – 4 minutes
Al forum del blogcms trobo una petita modificació del plug-in NP_FancyText. El que fa aquesta modificació és si troba algunes sigles pel nostre text les formateja amb la comanda acronym. Lo guapo seria que encomptes de tenir les definicions dels acronims incrustades al codi això estigues en un taula dels extraskins així podriem modicar els acronims sense haver d’editar el codi cada vegada. De moment no crec que ho programi ja que no uso gaire aquest recurs, suposo que per mandra.
(at line 324)
Codi:
$acronym_list = array( ‘ASP’ => ‘Active Server Pages’, ‘API’ => ‘Application Programming Interface’, ‘CD’ => ‘Compact Disk’, ‘CEO’ => ‘Chief Executive Officer’, ‘CGI’ => ‘Common Gateway Interface’, ‘CMS’ => ‘Content Management System’, ‘CSS’ => ‘Cascading Style Sheets’, ‘CVS’ => ‘Concurrent Versions System’, ‘DNS’ => ‘Domain Name System’, ‘DOM’ => ‘Document Object Model’, ‘DTD’ => ‘Document Type Definition’, ‘DVD’ => ‘Digital Versatile Disc’, ‘FAQ’ => ‘Frequently Asked Question’, ‘GB’ => ‘GigaByte’, ‘GPL’ => ‘GNU General Public License’, ‘GUI’ => ‘Graphical User Interface’, ‘GIF’ => ‘Graphic Interchange Format’, ‘HTML’ => ‘HyperText Markup Language’, ‘HTTP’ => ‘HyperText Transfer Protocol’, ‘IDE’ => ‘Integrated Development Environment / Intergrated Drive Electronics’, ‘IE’ => ‘Internet Explorer’, ‘IIS’ => ‘Internet Infomation Server’, ‘IM’ => ‘Instant Message/Messaging’, ‘IRC’ => ‘Internet Relay Chat’, ‘JSP’ => ‘Java Server Pages’, ‘JPG’ => ‘Joint Photographic experts Group’, ‘JPEG’ => ‘Joint Photographic Experts Group’, ‘KB’ => ‘KiloByte’, ‘MB’ => ‘MegaByte’, ‘MP3’ => ‘MPEG 1 audio layer 3’, ‘MS’ => ‘MicroSoft’, ‘MSDN’ => ‘MicroSoft Developer Network’, ‘MSIE’ => ‘MicroSoft Internet Explorer’, ‘MSN’ => ‘MicroSoft Network’, ‘NNTP’ => ‘Network News Transfer Protocol’, ‘P2P’ => ‘Peer To Peer’, ‘PDF’ => ‘Portable Document Format’, ‘GC’ => ‘Generated Content’, ‘PHP’ => ‘PHP: Hypertext Preprocessor’, ‘PNG’ => ‘Portable Network Graphics’, ‘RSS’ => ‘Really Simple Syndication’, ‘RTF’ => ‘Rich Text Format’, ‘SOAP’ => ‘Search Engine Optimisation’, ‘SOAP’ => ‘Simple Object Access Protocol’, ‘SSL’ => ‘Secured Sockets Layer’, ‘SVG’ => ‘Scalable Vector Graphics’, ‘TCP’ => ‘Transmission Control Protocol’, ‘URI’ => ‘Uniform Resource Identifier’, ‘URL’ => ‘Uniform Resource Locator’, ‘USB’ => ‘Universal Serial Bus’, ‘UI’ => ‘User Interface’, ‘VNC’ => ‘Virtual Network Computing’, ‘W3C’ => ‘World Wide Web Consortium’, ‘WYSIWYG’ => ‘What You See Is What You Get’, ‘XHTML’ => ‘eXtensible HyperText Markup Language’, ‘XML’ => ‘eXtensible Markup Language’, ‘XSL’ => ‘eXtensible Stylesheet Language’, ‘XSLT’ => ‘eXtensible Stylesheet Language Transformation’, ‘XUL’ => ‘XML-based User interface Language’, ‘LI’ => ‘List Item’, ‘DIV’ => ‘DIVision’, ‘ABBR’ => ‘ABBReviation’, ‘P’ => ‘Paragraph’, ‘PRE’ => ‘PREformatted text’, ‘UL’ => ‘Unordered List’, ‘OL’ => ‘Ordered List’, ‘TR’ => ‘Table Row’, ‘TH’ => ‘Table Header cell’, ‘TD’ => ‘Table Data cell’, ‘A’ => ‘Anchor’, ‘IMG’ => ‘IMaGe’, ‘EM’ => ‘EMphasis’, ‘DEL’ => ‘DELeted text’, ‘INS’ => ‘INSerted text’, ‘KBD’ => ‘KeyBoarD input’, ‘IFRAME’ => ‘Inline FRAME’, ‘DIR’ => ‘DIRectory list’, ‘DL’ => ‘Definition List’, ‘DT’ => ‘Definition Term’, ‘DD’ => ‘Definition Description’, ‘EUR’ => ‘EURo’, ‘SAMP’ => ‘SAMPle output’, ‘USD’ => ‘United States Dollars’ ); foreach ($acronym_list as $acronym => $description) { $data = preg_replace("|(?<!<)(?<!:)\b$acronym\b(?!>)|msU" , "<acronym title=\"$description\">$acronym</acronym>" , $data); $data = preg_replace("|(<[A-Za-z]* [^>]*)<acronym title=\"$description\">$acronym</acronym>([^<]*>)|msU", "$1$acronym$2" , $data); $data = preg_replace("|[$]<acronym title=\"$description\">$acronym</acronym>[$]|msU", "$acronym", $data); }