Summary of common classes in joomla2.5, joomla2.5 class summary
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 // 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 New jfile (); Getext ($file// get extension not included. GetName ($file// get filename exists ($file// file exists Delete ( $file // Deleting Files Copy ($old,$new// copy upload ($src// upload Write ($file// Write file read ($file) // Read file move ( $old,$new// move 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// Create folder, support Multilayer Jfolder::d elete ($path) // Delete a folder that can contain files Jfolder::exists ($path) // detect if the folder exists Jfolder::copy($pathold ,$pathnew// Copy folder jfolder::files ($path// Lists the array of files under the folder jfolder::folders ($path// List folder below the folder
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 New StdClass (); $obj->qq= ' 280594236 '; Jarrayhelper:: Fromobject ($obj); // Object Transformation Array Jarrayhelper::getvalue ($arr, 1); // gets the second value of the array, or it can be a subscript Jarrayhelper::toobject ($arr); // Converting Objects Jarrayhelper::tostring ($arr, ' = ', '); // turn into strings, spaces separated, left Key=value Jarrayhelper:: 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)
http://www.bkjia.com/PHPjc/1137012.html www.bkjia.com true http://www.bkjia.com/PHPjc/1137012.html techarticle joomla2.5 Common Class Summary research, JOOMLA2.5 class summary previous article only studies Jimage class, today continues other commonly used Joomla built-in class, the individual is from the common angle to write, if PHP itself function ...