cvs: peardoc /en/package tools.xml /en/package/tools mime-type.xml /en/package/tools/mime-type detecting.xml editing.xml information.xml

From: Date: Sun, 25 Mar 2007 06:10:29 +0000
Subject: cvs: peardoc /en/package tools.xml /en/package/tools mime-type.xml /en/package/tools/mime-type detecting.xml editing.xml information.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-9548@lists.php.net to get a copy of this message
cweiske Sun Mar 25 06:10:29 2007 UTC Added files: /peardoc/en/package/tools mime-type.xml /peardoc/en/package/tools/mime-type detecting.xml editing.xml information.xml Modified files: /peardoc/en/package tools.xml Log: Adding documentation for MIME_Type

http://cvs.php.net/viewvc.cgi/peardoc/en/package/tools.xml?r1=1.4&r2=1.5&diff_format=u Index: peardoc/en/package/tools.xml diff -u peardoc/en/package/tools.xml:1.4 peardoc/en/package/tools.xml:1.5 --- peardoc/en/package/tools.xml:1.4 Thu Dec 7 11:30:46 2006 +++ peardoc/en/package/tools.xml Sun Mar 25 06:10:29 2007 @@ -1,9 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <chapter id="package.tools"> <title>Tools and Utilities</title> &blankpagehack; + &package.tools.mime-type; &package.tools.versioncontrol-svn; </chapter> http://cvs.php.net/viewvc.cgi/peardoc/en/package/tools/mime-type.xml?view=markup&rev=1.1 Index: peardoc/en/package/tools/mime-type.xml +++ peardoc/en/package/tools/mime-type.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <sect1 id="package.tools.mime-type"> <title>MIME_Type</title> <para> Utility class for dealing with MIME types. </para> <para> <classname>MIME_Type</classname> provides methods to detect the MIME (Multipurpose Internet Mail Extension) type of files, retrieving information about MIME types and parsing them. </para> &package.tools.mime-type.detecting; &package.tools.mime-type.information; &package.tools.mime-type.editing; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/peardoc/en/package/tools/mime-type/detecting.xml?view=markup&rev=1.1 Index: peardoc/en/package/tools/mime-type/detecting.xml +++ peardoc/en/package/tools/mime-type/detecting.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.tools.mime-type.detecting"> <refnamediv> <refname>Detecting MIME types</refname> <refpurpose>How to determine the MIME type of a file</refpurpose> </refnamediv> <refsect1> <title>Detecting the MIME type of a file</title> <para> The most simple way to detect the MIME type of any file is to use <classname>MIME_Type</classname>'s static <function>autoDetect</function> method. It will try to determine the file's type and return it as a string. If an error occurs, a <classname>PEAR_Error</classname> object is returned. </para> <para> By default, only the plain MIME type will be returned, without any comments or parameters. If you pass <literal>true</literal> as second parameter to the method, all available MIME parameters will be appended to the returned type. </para> <example> <title>Detecting the MIME type of a file</title> <programlisting role="php"><![CDATA[ <?php require_once 'MIME/Type.php'; $filename = '/path/to/some/file.jpg'; echo MIME_Type::autoDetect($filename); ?> ]]></programlisting> <para> The MIME type of the given file will be echoed. </para> </example> </refsect1> <refsect1> <title>Matching a MIME type</title> <para> If you want to check if a certain MIME type matches a wildcard type, use the static <function>wildcardMatch</function>. It takes the wildcard as first, and the type to be checked as second parameter. It returns <literal>true</literal> if the wildcard matches the MIME type, <literal>false</literal> if not. </para> <example> <title>Matching a wildcard type</title> <programlisting role="php"><![CDATA[ <?php require_once 'MIME/Type.php'; $filename = '/path/to/some/file.jpg'; $type = MIME_Type::autoDetect($filename); if (MIME_Type::wildcardMatch('image/*', $type)) { echo 'File ' . $filename . ' is an image.'; } else { echo 'File is no image.'; } ?> ]]></programlisting> </example> </refsect1> </refentry> http://cvs.php.net/viewvc.cgi/peardoc/en/package/tools/mime-type/editing.xml?view=markup&rev=1.1 Index: peardoc/en/package/tools/mime-type/editing.xml +++ peardoc/en/package/tools/mime-type/editing.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.tools.mime-type.editing"> <refnamediv> <refname>Editing MIME types</refname> <refpurpose>How to change things</refpurpose> </refnamediv> <refsect1> <title>Editing a MIME type</title> <para> With <classname>MIME_Type</classname>, you can edit existing MIME types or create new ones from scratch. Just create a new instance of <classname>MIME_Type</classname> - with the MIME type string as only parameter, if you have one - or no parameter if you want to begin a new one. </para> <para> To set or retrieve the media type (part before the slash), use the object's <varname>$media</varname> property. The same applies to the subtype, the property name is <varname>$subType</varname>. </para> <para> If you are done editing your MIME type, use <function>get</function> to retrieve the MIME type's string representation. </para> </refsect1> <refsect1> <title>Working with parameters</title> <para> To retrieve parameters, use the <varname>$parameters</varname> property. It is an array consisting of <classname>MIME_Type_Parameter</classname> objects if there are any. </para> <para> You can remove any parameter by calling <function>removeParameter</function> and passing the parameter's name as only parameter. </para> <para> Parameters are added with <function>addParameter</function>. It takes the <varname>$name</varname>, <varname>$value</varname> and an optional <varname>$comment</varname> as parameters. </para> <para> Again: If you are done editing the parameters, use <function>get</function> to retrieve the MIME type's string representation. </para> <para> There are three static methods that help you working with parameters: </para> <itemizedlist> <listitem> <para> <function>hasParameters</function> checks if the passed MIME type string has any parameters in it. </para> </listitem> <listitem> <para> <function>getParameters</function> returns an array of <classname>MIME_Type_Parameter</classname> objects if there are any parameters in the passed type string. </para> </listitem> <listitem> <para> <function>stripParameters</function> removes all parameters and comments from the given type string. </para> </listitem> </itemizedlist> </refsect1> </refentry> http://cvs.php.net/viewvc.cgi/peardoc/en/package/tools/mime-type/information.xml?view=markup&rev=1.1 Index: peardoc/en/package/tools/mime-type/information.xml +++ peardoc/en/package/tools/mime-type/information.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.tools.mime-type.information"> <refnamediv> <refname>Getting infos about a MIME type</refname> <refpurpose>How to get more information about a MIME type</refpurpose> </refnamediv> <refsect1> <title>What a MIME type can be</title> <para> Using <classname>MIME_Type</classname> you can get different data about a MIME type. All methods mentioned here can be called statically. </para> <itemizedlist> <listitem> <para> <function>getMedia</function> returns the main part (media part, portion before the slash) of a MIME type. It would return <literal>image</literal> for <literal>image/png</literal>. </para> </listitem> <listitem> <para> <function>getSubType</function> returns the subtype of the given type. For <literal>image/png</literal>, it returns <literal>png</literal>. </para> </listitem> <listitem> <para> <function>isExperimental</function> checks if a given MIME type is experimental. It returns <literal>true</literal> or <literal>false</literal> (e.g. <literal>text/x-vcard</literal>). </para> </listitem> <listitem> <para> <function>isVendor</function> determines if the given type is a vendor specific MIME type (e.g. as in <literal>application/vnd.mozilla.xul+xml</literal>). </para> </listitem> <listitem> <para> <function>isWildcard</function> tells you if the passed type is a wildcard type (is either <literal>*/*</literal> or <literal>something/*</literal>). </para> </listitem> </itemizedlist> </refsect1> </refentry>
« previous php.pear.doc (#9548) next »