Summary of common classes in joomla2.5 and joomla2.5

Source: Internet
Author: User

Summary of common classes in joomla2.5 and joomla2.5

The previous article only studied the JImage class. Today, we continue to use other commonly used joomla built-in classes. I write them from the perspective of common use. If PHP functions are more convenient to use than Joomla built-in classes, if you really want to use it, check it yourself. I personally think that no matter how good the methods are, it can be well solved if PHP comes with functions, so using PHP built-in functions is the best. Learning PHP is to learn built-in functions first. Well, I will explain in detail the frequently used classes and methods.

1. Document class, used to take the header of the current page element as the main operation.

$ Document = JFactory: getDocument (); $ document-> addScript ('1. js'); // Add the js File $ document-> addScriptDeclaration ('alert (1) '); // Add the js Code $ document-> addStyleDeclaration (); // css $ document-> addStyleSheet('1.css '); $ document-> setMetaData ('description', 'key '); // set the description or keyword $ document-> setCharset ('utf-8'); $ document-> setTitle ('title ');

2. For file operations, you need to import jimport ('joomla. filesystem. file ');

$ J = new JFile (); getExt ($ file) // get the extension not included. getName ($ file) // get the file name exists ($ file) // check whether the file exists delete ($ file) // delete the file copy ($ old, $ new) // copy upload ($ src) // upload write ($ file) // write the file read ($ file) // read the file move ($ old, $ new) // move the file

These methods are useful in file read/write, Image File Upload, and so on.

3. folder operations, jimport ('joomla. filesystem. folder'); generally, we import all the file folders during import, which are often used

JFolder: create ($ path, 777) // create a folder. multiple layers of JFolder: delete ($ path) // delete a folder, including JFolder :: exists ($ path) // check whether the folder has JFolder: copy ($ pathold, $ pathnew) // copy the folder JFolder: files ($ path) // list the arrays of files in the folder: folders ($ path) // list the arrays of the folders in the folder

Here we will talk about: static methods. Many classes support static methods;

4. Icon generation class, which is used to generate small icons in the background.

JToolBarHelper: title (JText: _ ('add personal information'), 'weblinks.png '); // title JToolBarHelper: addNew ('info. add'); // add JToolBarHelper: apply ('info. apply '); // save JToolBarHelper: save ('info. save '); // save and close JToolBarHelper: editList ('info. edit '); // edit JToolBarHelper: cancel ('info. cancel '); // cancel JToolBarHelper: deleteList ('info. delete '); // delete JToolBarHelper: trash ('info. trash '); // recycle bin JToolBarHelper: divider (); // split line JToolBarHelper: publish ('weblinks. publish ', 'jtoolbar _ PUBLISH', true); // publish JToolBarHelper: unpublish ('weblinks. unpublish ', 'jtoolbar _ UNPUBLISH', true); // cancel JToolBarHelper: back (); // return JToolBarHelper: help ('jhelp _ COMPONENTS_WEBLINKS_LINKS '); // help

5. Other common methods

JString: transcode ('China', 'utf-8', 'gb2312'); // The conversion encoding JUtility: getToken (); // The user session ID is equivalent to JHtml:: _ ('form. token'); JUtility: isWinos (); // whether the win system outputs 1 JUtility: sendmail ('logove # qq.com ', 'yoby', 'logoove # foxmail.com ', 'topic ', 'this is content'); // The JUtility: gethash ($ var) to be configured for sending emails; // 32-bit random character JUtility :: return_bytes ('1k'); // The number of converted nodes supports g m kJRequest: getURI (); // get the current url JRequest: getMethod (); // The submission method is POST or GET JRequest: getbool ('I'); // convert it to a Boolean JRequest: getint ('I'); // obtain the entire JRequest :: getfloat ('I'); // convert it to a floating point JRequest: getString ('I'); // convert it to a string JRequest: getvar ('var ', null, 'default', 'array'); // common. The second is the default value, and the third is the method, GET // post files cookie env server last data type has array int string float JRequest: setVar ('var', $ arr); // set, can be an array or character JURI: base (); // contains administrator absolute path parameter 1 is relative path JURI: root (); // root directory, parameter 1 is relative path

6. arrays are commonly used. This is the most commonly used

JArrayHelper: arrayUnique ($ arr2); // remove the duplicate element $ obj = new stdClass (); $ obj-> qq = '000000'; JArrayHelper :: fromObject ($ obj); // The object conversion array JArrayHelper: getValue ($ arr, 1); // obtain the second value of the array, which can also be the subscript JArrayHelper :: toObject ($ arr); // conversion object JArrayHelper: toString ($ arr, '=', ''); // convert it to a string separated by spaces. key = value JArrayHelper on the left:: toInteger ($ cid); // convert the variable to an integer.

There are many other methods, such as databases, xml, and form generation. These methods are very important, but there are too many contents. I will discuss these methods later, basically, it is very common. To learn more about the api content, or read the core code, I will summarize it here to reduce your reading time, the comment below is very detailed. If you don't understand it, you can leave a message below. joomla is a very good CMS, but it is not popular in China. dedecms and discuz have a large number of users, I will study it later. If you like cms, don't miss it.

(Yoby original)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.