search
Homephp教程php手册Summary research on commonly used classes in joomla2.5, summary of joomla2.5 classes

Summary study of commonly used classes in joomla2.5, summary of joomla2.5 classes

The previous article only studied the JImage class. Today we will continue with other commonly used joomla built-in classes. Personally, I started with the commonly used classes. It is written from the perspective of using PHP itself. If PHP’s own functions are more convenient to use than Joomla’s built-in classes, I will not filter it out. If you really want to use it, check it out yourself. Personally, I feel that no matter how excellent the method is, if PHP’s own functions It can also be solved easily with functions, so it is best to use PHP built-in functions. The first thing to learn PHP is to learn the built-in functions well. Okay, let’s explain in detail the commonly used classes and methods.

1. Document class, used as the main operation on the head of the current page element.

<span>$document</span> = JFactory::<span>getDocument();
</span><span>$document</span>->addScript('1.js');<span>//</span><span>添加js文件</span>
<span>$document</span>->addScriptDeclaration('alert(1)');<span>//</span><span>添加js代码</span>
<span>$document</span>->addStyleDeclaration(); <span>//</span><span>css</span>
<span>$document</span>->addStyleSheet('1.css'<span>);
</span><span>$document</span>->setMetaData('description','关键字');<span>//</span><span>设置描述或关键字</span>
<span>$document</span>->setCharset('utf-8'<span>);
</span><span>$document</span>->setTitle('标题');

2. File operation requires importing jimport('joomla.filesystem.file');

<span>$j</span> = <span>new</span><span> JFile();
getExt(</span><span>$file</span>) <span>//</span><span>获取扩展名不含.</span>
getName(<span>$file</span>) <span>//</span><span>获得文件名</span>
exists(<span>$file</span>) <span>//</span><span>文件是否存在</span>
delete(<span>$file</span>) <span>//</span><span>删除文件</span>
<span>copy</span>(<span>$old</span>,<span>$new</span>) <span>//</span><span>复制</span>
upload(<span>$src</span>) <span>//</span><span>上传</span>
write(<span>$file</span>) <span>//</span><span>写文件</span>
read(<span>$file</span>)  <span>//</span><span>读文件</span>
move(<span>$old</span>,<span>$new</span>) <span>//</span><span>移动文件</span>

These methods are useful in file reading and writing, image file uploading, etc.

3. Folder operation, jimport('joomla.filesystem.folder'); Generally when we import, we import all files and folders, and we often use it

JFolder::create(<span>$path</span>,777) <span>//</span><span>创建文件夹,支持多层</span>
JFolder::delete(<span>$path</span>)  <span>//</span><span>删除文件夹,可以包含文件</span>
JFolder::exists(<span>$path</span>)  <span>//</span><span>检测文件夹是否存在</span>
JFolder::<span>copy</span>(<span>$pathold</span>,<span>$pathnew</span>) <span>//</span><span>复制文件夹</span>
JFolder::files(<span>$path</span>) <span>//</span><span>列出文件夹下面文件的数组</span>
JFolder::folders(<span>$path</span>) <span>//</span><span>列出文件夹下面文件夹的数组</span>

Let me talk about it here:: It is a static method, and there are many classes that support static methods;

4. Icon generation class, used to generate small icons in the background. One of the commonly used saves is one.

JToolBarHelper::title(JText::_('添加个人信息'), 'weblinks.png');<span>//</span><span>标题</span>
JToolBarHelper::addNew('info.add');<span>//</span><span>添加</span>
JToolBarHelper::apply('info.apply');<span>//</span><span>保存</span>
JToolBarHelper::save('info.save');<span>//</span><span>保存关闭</span>
JToolBarHelper::editList('info.edit');<span>//</span><span>编辑</span>
JToolBarHelper::cancel('info.cancel');<span>//</span><span>取消</span>
JToolBarHelper::deleteList('info.delete');<span>//</span><span>删除</span>
JToolBarHelper::trash('info.trash');<span>//</span><span>回收站</span>
JToolBarHelper::divider();<span>//</span><span>分割线</span>
JToolBarHelper::publish('weblinks.publish', 'JTOOLBAR_PUBLISH', <span>true</span>);<span>//</span><span>发布</span>
JToolBarHelper::unpublish('weblinks.unpublish', 'JTOOLBAR_UNPUBLISH', <span>true</span>);<span>//</span><span>取消发布</span>
JToolBarHelper::back();<span>//</span><span>返回</span>
JToolBarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS');<span>//</span><span>帮助</span>

5. Other commonly used methods

JString::transcode('中国','utf-8','gb2312');<span>//</span><span>转换编码</span>
JUtility::getToken();<span>//</span><span>用户session ID 等价于JHtml::_('form.token');</span>
JUtility::isWinos();<span>//</span><span>是否win系统 是输出1</span>
JUtility::sendmail('logove#qq.com','yoby','logoove#foxmail.com','主题','这是内容');<span>//</span><span>发送邮件要配置的</span>
JUtility::gethash(<span>$var</span>);<span>//</span><span>32位随机字符</span>
JUtility::return_bytes('1k');<span>//</span><span>转换成字节数 支持g m k</span>
JRequest::getURI();<span>//</span><span>获得当前url</span>
    JRequest::getMethod ();<span>//</span><span>提交方式 POST 或GET</span>
    JRequest::getbool('i');<span>//</span><span>转换成布尔型</span>
    JRequest::getint('i');<span>//</span><span>取整</span>
    JRequest::getfloat('i');<span>//</span><span>转换成浮点数</span>
    JRequest::getString('i');<span>//</span><span>转成字符串</span>
    JRequest::getvar('var',<span>null</span>,'default','array');<span>//</span><span>通用,第二个是默认值,第三个是方法,有GET
    //POST FILES COOKIE ENV SERVER  最后一个是数据类型 有array int string float</span>
    JRequest::setVar('var',<span>$arr</span>);<span>//</span><span>设置,可以数组或字符</span>
    JURI::base();<span>//</span><span>包含administrator绝对路径 参数1是相对路径</span>
    JURI::root();<span>//</span><span>根目录,参数1是相对路径</span>

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

JArrayHelper::arrayUnique(<span>$arr2</span>);<span>//</span><span>去掉重复元素</span>
    <span>$obj</span> = <span>new</span><span> stdClass();
    </span><span>$obj</span>->qq='280594236'<span>;
    JArrayHelper</span>::fromObject(<span>$obj</span>);<span>//</span><span>对象转换数组</span>
    JArrayHelper::getValue(<span>$arr</span>,1);<span>//</span><span>获得数组第二个值,也可以是下标</span>
    JArrayHelper::toObject(<span>$arr</span>);<span>//</span><span>转换对象</span>
    JArrayHelper::toString(<span>$arr</span>,'=',' ');<span>//</span><span>转成字符串,空格隔开,左边key=value</span>
    JArrayHelper :: toInteger(<span>$cid</span>);<span>//</span><span>转换变量为整形</span>

There are many other methods, such as database, xml, form generation, etc. These are all important, but there is too much content. I will talk about it later when I have the opportunity. Basically, these methods today are all commonly used. , if you need to know more, you need to study the API content yourself, or read the core code yourself. I have summarized it here, which can reduce your reading time. The comments at the back are very detailed. If you don’t understand, you can leave a message below. Joomla is A very excellent CMS, but it is not popular in China. Dedecms and discuz have more users. I will study it next time I have time. If you like CMS, don’t miss it.

(yoby original)

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP报错:无法重复声明类,解决方法!PHP报错:无法重复声明类,解决方法!Aug 25, 2023 pm 04:13 PM

PHP报错:无法重复声明类,解决方法!对开发者而言,遇到问题是常有的事情。而在PHP开发中,经常会遇到一个常见的错误:无法重复声明类。这个问题看似简单,但如果不及时解决,会导致代码无法正确执行。本文将介绍这个问题的原因,并提供解决方法,以供参考。当我们在PHP代码中定义一个类时,如果在同一个文件或多个文件中多次定义同一个类,就会出现无法重复声明类的错误。这是

PHP中的命名规范:如何使用驼峰命名法命名类、方法和变量PHP中的命名规范:如何使用驼峰命名法命名类、方法和变量Jul 30, 2023 pm 02:43 PM

PHP中的命名规范:如何使用驼峰命名法命名类、方法和变量在PHP编程中,良好的命名规范是一种重要的编码实践。它可以提高代码的可读性和可维护性,并且使团队合作更加顺畅。在本文中,我们将探讨一个常见的命名规范:驼峰命名法,并提供一些示例来说明如何在PHP中使用它来命名类、方法和变量。一、什么是驼峰命名法?驼峰命名法是一种常用的命名约定,其中每个单词的首字母大写,

PHP中的封装技术及应用PHP中的封装技术及应用Oct 12, 2023 pm 01:43 PM

PHP中的封装技术及应用封装是面向对象编程中的一个重要概念,它指的是将数据和对数据的操作封装在一起,以便提供对外部程序的统一访问接口。在PHP中,封装可以通过访问控制修饰符和类的定义来实现。本文将介绍PHP中的封装技术及其应用场景,并提供一些具体的代码示例。一、封装的访问控制修饰符在PHP中,封装主要通过访问控制修饰符来实现。PHP提供了三个访问控制修饰符,

Java中找不到类——java.lang.ClassNotFoundException如何解决?Java中找不到类——java.lang.ClassNotFoundException如何解决?Jun 25, 2023 am 10:37 AM

在Java开发过程中,有时候会遇到一个错误:java.lang.ClassNotFoundException。它表示在Java虚拟机(JVM)中找不到所需的类文件。这个错误会导致程序不能正常运行,如果不及时解决,会延误开发进度。本文将介绍Java中找不到类的原因和解决方法。一、原因1.类的路径错误在Java中,包路径和类路径很重要。如果类路径设置错误或者类文

学习canvas框架 详解常用的canvas框架学习canvas框架 详解常用的canvas框架Jan 17, 2024 am 11:03 AM

探索Canvas框架:了解常用的Canvas框架有哪些,需要具体代码示例引言:Canvas是HTML5中提供的一个绘图API,通过它我们可以实现丰富的图形和动画效果。为了提高绘图的效率和便捷性,许多开发者开发了不同的Canvas框架。本文将介绍一些常用的Canvas框架,并提供具体代码示例,以帮助读者更深入地了解这些框架的使用方法。一、EaselJS框架Ea

Spring注解大揭秘:常用注解解析Spring注解大揭秘:常用注解解析Dec 30, 2023 am 11:28 AM

Spring是一个开源框架,提供了许多注解来简化和增强Java开发。本文将详细解释常用的Spring注解,并提供具体的代码示例。@Autowired:自动装配@Autowired注解可以用于自动装配Spring容器中的Bean。当我们在需要依赖的地方使用@Autowired注解时,Spring将会在容器中查找匹配的Bean并自动注入。示例代码如下:@Auto

PHP8中如何使用Attributes为类添加自定义注解?PHP8中如何使用Attributes为类添加自定义注解?Oct 18, 2023 am 10:16 AM

PHP8中如何使用Attributes为类添加自定义注解?自定义注解是一种在类或方法上添加元数据的方式,它可以帮助我们在运行时获取和处理特定的类或方法上的附加信息。在PHP8中,引入了Attributes的概念,它使我们可以轻松地为类添加自定义注解。本文将介绍如何在PHP8中使用Attributes来实现类的自定义注解,并提供具体的代码示例。在PHP8中,自

15个常用的币圈逃顶指标技术分析15个常用的币圈逃顶指标技术分析Mar 03, 2025 pm 05:48 PM

十五大比特币逃顶指标深度解析:2025年市场展望本文深入分析了十五个常用的比特币逃顶指标,其中比特币Rhodl比率、USDT活期理财和山寨币季节指数已于2024年触及逃顶区间,引发市场关注。面对潜在风险,投资者该如何应对?让我们逐一解读这些指标,并探讨合理的应对策略。一、关键指标详解AHR999囤币指标:由ahr999创建,辅助比特币定投策略。当前值为1.21,处于观望区间,建议谨慎。链接AHR999逃顶指标:AHR999囤币指标的补充,用于识别市场顶部。当前值为2.48,本周

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),