Summary of common classes in joomla2.5

Source: Internet
Author: User
Tags learn php

The previous article only studied the Jimage class, today continue to other commonly used Joomla built-in class, the individual is from the common point of view to write, if PHP itself is more convenient than the built-in class of Joomla, I have filtered not to say, if you really want to use, yourself to check it, personally feel, no matter how excellent method, If PHP comes with a function can also be solved well, then PHP built-in function is the best, learn PHP first is to learn the built-in function, well, then detailed the common classes and methods.

1. The document class, which is used as the primary operation for the head of the current page element.

$document= Jfactory::getdocument ();$document->addscript (' 1.js ');//Add JS file$document->addscriptdeclaration (' Alert (1) ');//Add JS code$document->addstyledeclaration ();//CSS$document->addstylesheet (' 1.css ');$document->setmetadata (' description ', ' keywords ');//set a description or keyword$document->setcharset (' Utf-8 ');$document->settitle (' title ');

2. File operation, need to import jimport (' Joomla.filesystem.file ');

$j=Newjfile (); Getext ($file)//get extension does not contain.GetName ($file)//Get file nameExists$file)//whether the file existsDelete$file)//Deleting FilesCopy($old,$new)//CopyUpload$src)//UploadWrite$file)//Write a fileRead$file)//Read the fileMove$old,$new)//Moving Files

These methods are useful in reading and writing files, uploading image files, and so on.

3. Folder operation, Jimport (' joomla.filesystem.folder '); Generally, when we import the file folders are imported, many times will use

 jfolder::create ( $path , 777) // Span style= "color: #008000;" > Create a folder that supports multiple layers of  Jfolder::d elete ( $path ) //   Delete folder, can include file  jfolder::exists ( $path ) //  detects if a folder exists  Jfolder::copy  ( $pathold ,  $pathnew ) //  copy folder  Jfolder::files ( $path ) //  Jfolder::folders ( $path ) //  List of folders under Folders  

Here is a: static method, there are many classes are supported by static methods;

4. Icon Generation class, used to generate small background icons, commonly used to save is one.

Jtoolbarhelper::title (jtext::_ (' Add personal information '), ' weblinks.png ');//titleJtoolbarhelper::addnew (' Info.add ');//AddJtoolbarhelper::apply (' info.apply ');//SaveJtoolbarhelper::save (' Info.save ');//Save CloseJtoolbarhelper::editlist (' Info.edit ');//EditJtoolbarhelper::cancel (' Info.cancel ');//CancelJtoolbarhelper::d eletelist (' Info.delete ');//DeleteJtoolbarhelper::trash (' Info.trash ');//Recycling StationJtoolbarhelper::d ivider ();//Split LineJtoolbarhelper::p ublish (' weblinks.publish ', ' jtoolbar_publish ',true);//PublishJtoolbarhelper::unpublish (' weblinks.unpublish ', ' jtoolbar_unpublish ',true);//Cancel PublicationJtoolbarhelper::back ();//returnJtoolbarhelper::help (' jhelp_components_weblinks_links ');//Help

5. Other common methods

Jstring::transcode (' China ', ' utf-8 ', ' gb2312 ');//Conversion EncodingJutility::gettoken ();//the user session ID is equivalent to Jhtml::_ (' Form.token ');Jutility::iswinos ();//whether the win system is output 1Jutility::sendmail (' logove#qq.com ', ' yoby ', ' logoove#foxmail.com ', ' theme ', ' This is content ');//send the message to be configuredJutility::gethash ($var);//32-bit random charactersJutility::return_bytes (' 1k ');//Convert to bytes support g M KJrequest::geturi ();//Get current URLJrequest::getmethod ();//Submit mode POST or getJrequest::getbool (' i ');//Convert to Boolean typeJrequest::getint (' i ');//take the wholeJrequest::getfloat (' i ');//convert to floating pointJrequest::getstring (' i ');//turn into a stringJrequest::getvar (' var ',NULL, ' Default ', ' array ');//generic, the second is the default, the third is the method, there is a get//post FILES COOKIE ENV SERVER The last is the data type has an array int string floatJrequest::setvar (' var ',$arr);//set, can array or characterJuri::base ();//contains administrator absolute path parameter 1 is a relative pathJuri::root ();//root directory, parameter 1 is a relative path

6. Arrays are commonly used, this is the most commonly used

Jarrayhelper::arrayunique ($arr 2);//Remove duplicate elements    $obj=NewStdClass (); $obj->qq= ' 280594236 '; Jarrayhelper:: Fromobject ($obj);//Object Transformation ArrayJarrayhelper::getvalue ($arr, 1);//gets the second value of the array, or it can be a subscriptJarrayhelper::toobject ($arr);//Converting ObjectsJarrayhelper::tostring ($arr, ' = ', ');//turn into strings, spaces separated, left Key=valueJarrayhelper:: Tointeger ($cid);//transform variable to reshape

There are many other methods, such as database, XML, form generation and so on, these are important, but the content is too much, in the back there is a chance to say, today's methods are basically very common, need to know more you need to study the API content yourself, or read the core code yourself, I summed up here , you can reduce the time you go to read, behind the note description is very detailed, do not understand can leave a message below, Joomla is a very good CMS, but the domestic is not popular, dedecms and Discuz users, the next time I will go to research, like CMS do not miss.

(Yoby original)

Summary of common classes in joomla2.5

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.