Submitted by gouki on 2010, June 10, 11:53 AM
有几次遇到这个bug了。不过。说来也不算太大的BUG
重现:发表博客,选择附件。
OK,你发现附件选错了,然后删除,重选附件,并插入内容,这时候应该是 localfile=2 了。
这时候发表后,你会发现附件并没有被正确的在内容中替换。而是当成附件了。
让我们重试一下吧:
[localfile=2]
图片附件(缩略图):

Tags: sablog, bug, 上传附件
PHP | 评论:1
| 阅读:19785
Submitted by gouki on 2010, June 9, 10:30 AM
手册中介绍PHP生成PDF用的是fpdf,网上也有一些代码其于Fpdf的看起来好象都不错,但是前提是有fpdf。。因此后来都放弃了。
这一个php class我没有试过,但是看上去好象不错,因为:1开源2原生PHP,不用组件(听说,没试过。)主要是看它可以直接把网页生成PDF,因为他支持html,xhtml,css。所以感觉不错
TCPDF is an Open Source PHP class for generating PDF documents.
TCPDF project was started in 2002 and now it is freely used all over the world by millions of people. TCPDF is a Free Libre Open Source Software (FLOSS).
官方的说明也很详细:
Main Features:
- no external libraries are required for the basic functions;(看来也只是针对基本功能,不过我想应该够了。)
- all ISO page formats, custom page formats, custom margins and units of measure;
- UTF-8 Unicode and Right-To-Left languages;
- TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;
- Font subsetting;
- methods to publish some XHTML + CSS code, Javascript and Forms;
- images, graphic (geometric figures) and transformation methods;
- native support for JPEG, PNG and SVG images;
- 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, QR-Code, PDF417;
- Grayscale, RGB, CMYK, Spot Colors and Transparencies;
- automatic page header and footer management;
- document encryption and digital signature certifications;
- transactions to UNDO commands;
- PDF annotations, including links, text and file attachments;
- text rendering modes (fill, stroke and clipping);
- multiple columns mode;
- bookmarks and table of content;
- text hyphenation;
- automatic page break, line break and text alignments including justification;
- automatic page numbering and page groups;
- move and delete pages;
- page compression.
这里也还有一些例子,有61个之多:
- Simple PDF with default Header and Footer: [PHP] [PDF]
- Simple PDF without Header and Footer: [PHP] [PDF]
- Custom Header and Footer: [PHP] [PDF]
- Cell stretching: [PHP] [PDF]
- Multicell: [PHP] [PDF]
- WriteHTML and RTL support: [PHP] [PDF]
- Independent columns with WriteHTMLCell: [PHP] [PDF]
- External UTF-8 text file: [PHP] [PDF]
- Image: [PHP] [PDF]
- Multiple columns: [PHP] [PDF]
- Colored Tables: [PHP] [PDF]
- Graphic Functions: [PHP] [PDF]
- Graphic Transformations: [PHP] [PDF]
- Javascript and Forms: [PHP] [PDF]
- Bookmarks (Table of Content): [PHP] [PDF]
- Document Encryption: [PHP] [PDF]
- Independent columns with MultiCell: [PHP] [PDF]
- Persian and Arabic language on RTL document: [PHP] [PDF]
- Non unicode / Alternative config file: [PHP] [PDF]
- Multicell complex alignment: [PHP] [PDF]
- writeHTML alignment: [PHP] [PDF]
- CMYK colors: [PHP] [PDF]
- Page Groups: [PHP] [PDF]
- Object Visibility: [PHP] [PDF]
- Object Transparency: [PHP] [PDF]
- Text Clipping: [PHP] [PDF]
- Barcodes: [PHP] [PDF]
- Multiple page formats: [PHP] [PDF]
- Set PDF viewer display preferences: [PHP] [PDF]
- Colour gradients: [PHP] [PDF]
- Pie Chart Graphic: [PHP] [PDF]
- EPS/AI vectorial image: [PHP] [PDF]
- Mixed font types (TrueType Unicode, core, CID-0): [PHP] [PDF]
- Clipping masks: [PHP] [PDF]
- Line styles with cells and multicells: [PHP] [PDF]
- Text Annotations: [PHP] [PDF]
- Spot Colors: [PHP] [PDF]
- NON-embedded CID-0 CJK font: [PHP] [PDF]
- HTML Justification: [PHP] [PDF]
- Booklet (double-sided pages): [PHP] [PDF]
- File attachment: [PHP] [PDF]
- Image with Alpha Channel Transparency: [PHP] [PDF]
- Disk caching: [PHP] [PDF]
- Move, Copy and delete page: [PHP] [PDF]
- Table Of Content with Bookmarks: [PHP] [PDF]
- Text hyphenation: [PHP] [PDF]
- Transactions and UNDO: [PHP] [PDF]
- Table header and rowspan: [PHP] [PDF]
- TCPDF methods in HTML: [PHP] [PDF]
- 2D Barcode (QR Code): [PHP] [PDF]
- Full page background: [PHP] [PDF]
- Digital Signature Certification: [PHP] [PDF]
- Javascript functions: [PHP] [PDF]
- XHTML Form: [PHP] [PDF]
- Font Dump: [PHP] [PDF]
- Crop Marks and Registration Marks: [PHP] [PDF]
- Cell vertical alignments: [PHP] [PDF]
- SVG Image: [PHP] [PDF]
- Table Of Content with HTML templates: [PHP] [PDF]
- Advanced page settings: [PHP] [PDF]
- XHTML + CSS: [PHP] [PDF]
可以尝试试用一下吧。
Tags: tcpdf, fpdf, pdf
PHP | 评论:0
| 阅读:20348
Submitted by gouki on 2010, June 8, 10:11 AM
前段时间我推荐了zen coding,并为此用上了notepad++,感觉在作网页的时候还行。而且,我的同事用dreamweaver的,也用上了它,感觉同样很爽。比如他输入:
XML/HTML代码
- div#page>(div#header>ul#nav>li*4>a)+(div#page>(h1>span)+p*2)+div#footer
生成如下页面:
XML/HTML代码
- <div id="page">
- <div id="header">
- <ul id="nav">
- <li><a href=""></a></li>
- <li><a href=""></a></li>
- <li><a href=""></a></li>
- <li><a href=""></a></li>
- </ul>
- </div>
- <div id="page">
- <h1><span></span></h1>
- <p></p>
- <p></p>
- </div>
- <div id="footer"></div>
- </div>
早上推荐给
小茗时,他说,Zen coding有for editplus的了。欣欣下载下来。运行后却发现,生成后的代码与官方不一样,看来还是有待改进啊,zen coding for editplus生成的代码是:
XML/HTML代码
- <div id="page"></div>
- <div id="header">
- <ul id="nav">
- <li>
- <a href=""></a><div id="page"></div>
- <h1>
- <span></span><p></p>
- <p></p>
- <div id="footer"></div>
- </h1>
- </li>
- <li>
- <a href=""></a><div id="page"></div>
- <h1>
- <span></span><p></p>
- <p></p>
- <div id="footer"></div>
- </h1>
- </li>
- <li>
- <a href=""></a><div id="page"></div>
- <h1>
- <span></span><p></p>
- <p></p>
- <div id="footer"></div>
- </h1>
- </li>
- <li>
- <a href=""></a><div id="page"></div>
- <h1>
- <span></span><p></p>
- <p></p>
- <div id="footer"></div>
- </h1>
- </li>
- </ul>
- </div>
这个与标准的偏 差实在是太大了。。。不过。在简单的情况下,还是可以使用的。将就着喽。总比没有的好。
下载地址为:http://www.vfresh.org/w3c/914
Tags: zencoding, editplus, notepad++
PHP | 评论:0
| 阅读:21329
Submitted by gouki on 2010, June 7, 4:01 PM
为了测试phprpc_client for SAE,到小菜鸟的app网站上把他的API全部复制到SAE的空间里,做了一点测试。有不少功能呢。每个例子最后我都用highlight_file把当前文件全部打印出来。可以,写的时候就可以做参考了。
事实上也没有什么 好参考的,小菜鸟的网上有的是代码,还有演示,我这里只是仅仅作了COPY而己。
对于最后的页面显示时间,这个就涉及到网络关系了,和实际执行时间并没有太大的联系,纯粹一看。
很多例子都在:
小菜鸟的APP网站是:MYWS,对了。小菜鸟还做了一个Ecshop的皮肤,仿凡客,也不错,演示在:http://shop.17kaixin8.com/,如果觉得好,也可以向他购买哦。
Tags: phprpc, 17kaixin8, ecshop
PHP | 评论:1
| 阅读:19619
Submitted by gouki on 2010, June 6, 10:59 PM
在setting sun的博客上发现一篇 文章,他认为:
PHP代码
- $p = "/^(?<ip>.*) (?<time>.*)$/";
- $s = "10.4.0.111 2009-09-09";
- preg_match($p, $s, $m);
- print_r($m);
输出:
XML/HTML代码
- Array ( [0] => 10.4.0.111 2009-09-09 [ip] => 10.4.0.111 [1] => 10.4.0.111 [time] => 2009-09-09 [2] => 2009-09-09 )
这个数组中有ip,time的key,他认为这是PHP5.3的功能。回复中echo说没什么特别。
事实上,这个还真不是php5.3的功能,它是PHP4.3开始就有的功能。详情可以看手册:
Pattern Syntax -- Describes PCRE regex syntax这一章。其中有一段就是:
XML/HTML代码
- It is possible to name the subpattern with (?P<name>pattern) since PHP 4.3.3. Array with matches will contain the match indexed by the string alongside the match indexed by a number, then.
所以,这还真不是啥新功能,只是我们很少用到而已。顺便说一句,今天的lamp分享中,祁宏还真的提到了这一点(关于分享内容我写了博客,但祁宏讲的内容,我没有详细记录
参加lamp聚会有感 ),所以我才特别有印象。
本想回复到setting sun的博客上的,但。。。后来打不开了,原文网址为:http://www.setting.cc/blog/archives/2.html
Tags: perl, preg_match, php, pattern
PHP | 评论:3
| 阅读:21230