


Summary research on commonly used classes in joomla2.5, summary of joomla2.5 classes
Jul 06, 2016 pm 02:24 PMSummary 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','關(guān)鍵字');<span>//</span><span>設(shè)置描述或關(guān)鍵字</span> <span>$document</span>->setCharset('utf-8'<span>); </span><span>$document</span>->setTitle('標(biāo)題');
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>獲取擴(kuò)展名不含.</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>復(fù)制</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>創(chuàng)建文件夾,支持多層</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>復(fù)制文件夾</span> JFolder::files(<span>$path</span>) <span>//</span><span>列出文件夾下面文件的數(shù)組</span> JFolder::folders(<span>$path</span>) <span>//</span><span>列出文件夾下面文件夾的數(shù)組</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>標(biāo)題</span> JToolBarHelper::addNew('info.add');<span>//</span><span>添加</span> JToolBarHelper::apply('info.apply');<span>//</span><span>保存</span> JToolBarHelper::save('info.save');<span>//</span><span>保存關(guān)閉</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>發(fā)布</span> JToolBarHelper::unpublish('weblinks.unpublish', 'JTOOLBAR_UNPUBLISH', <span>true</span>);<span>//</span><span>取消發(fā)布</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>轉(zhuǎn)換編碼</span> JUtility::getToken();<span>//</span><span>用戶session ID 等價于JHtml::_('form.token');</span> JUtility::isWinos();<span>//</span><span>是否win系統(tǒng) 是輸出1</span> JUtility::sendmail('logove#qq.com','yoby','logoove#foxmail.com','主題','這是內(nèi)容');<span>//</span><span>發(fā)送郵件要配置的</span> JUtility::gethash(<span>$var</span>);<span>//</span><span>32位隨機(jī)字符</span> JUtility::return_bytes('1k');<span>//</span><span>轉(zhuǎn)換成字節(jié)數(shù) 支持g m k</span> JRequest::getURI();<span>//</span><span>獲得當(dāng)前url</span> JRequest::getMethod ();<span>//</span><span>提交方式 POST 或GET</span> JRequest::getbool('i');<span>//</span><span>轉(zhuǎn)換成布爾型</span> JRequest::getint('i');<span>//</span><span>取整</span> JRequest::getfloat('i');<span>//</span><span>轉(zhuǎn)換成浮點(diǎn)數(shù)</span> JRequest::getString('i');<span>//</span><span>轉(zhuǎn)成字符串</span> JRequest::getvar('var',<span>null</span>,'default','array');<span>//</span><span>通用,第二個是默認(rèn)值,第三個是方法,有GET //POST FILES COOKIE ENV SERVER 最后一個是數(shù)據(jù)類型 有array int string float</span> JRequest::setVar('var',<span>$arr</span>);<span>//</span><span>設(shè)置,可以數(shù)組或字符</span> JURI::base();<span>//</span><span>包含administrator絕對路徑 參數(shù)1是相對路徑</span> JURI::root();<span>//</span><span>根目錄,參數(shù)1是相對路徑</span>
6. Arrays are commonly used, this is the most commonly used
JArrayHelper::arrayUnique(<span>$arr2</span>);<span>//</span><span>去掉重復(fù)元素</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>對象轉(zhuǎn)換數(shù)組</span> JArrayHelper::getValue(<span>$arr</span>,1);<span>//</span><span>獲得數(shù)組第二個值,也可以是下標(biāo)</span> JArrayHelper::toObject(<span>$arr</span>);<span>//</span><span>轉(zhuǎn)換對象</span> JArrayHelper::toString(<span>$arr</span>,'=',' ');<span>//</span><span>轉(zhuǎn)成字符串,空格隔開,左邊key=value</span> JArrayHelper :: toInteger(<span>$cid</span>);<span>//</span><span>轉(zhuǎn)換變量為整形</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)

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Large-scale language models (LLMs) have demonstrated compelling capabilities in many important tasks, including natural language understanding, language generation, and complex reasoning, and have had a profound impact on society. However, these outstanding capabilities require significant training resources (shown in the left image) and long inference times (shown in the right image). Therefore, researchers need to develop effective technical means to solve their efficiency problems. In addition, as can be seen from the right side of the figure, some efficient LLMs (LanguageModels) such as Mistral-7B have been successfully used in the design and deployment of LLMs. These efficient LLMs can significantly reduce inference memory while maintaining similar accuracy to LLaMA1-33B

Summary of the system() function under Linux In the Linux system, the system() function is a very commonly used function, which can be used to execute command line commands. This article will introduce the system() function in detail and provide some specific code examples. 1. Basic usage of the system() function. The declaration of the system() function is as follows: intsystem(constchar*command); where the command parameter is a character.

SPDIFOUT connection line sequence on the motherboard. Recently, I encountered a problem regarding the wiring sequence of the wires. I checked online. Some information says that 1, 2, and 4 correspond to out, +5V, and ground; while other information says that 1, 2, and 4 correspond to out, ground, and +5V. The best way is to check your motherboard manual. If you can't find the manual, you can use a multimeter to measure it. Find the ground first, then you can determine the order of the rest of the wiring. How to connect motherboard VDG wiring When connecting the VDG wiring of the motherboard, you need to plug one end of the VGA cable into the VGA interface of the monitor and the other end into the VGA interface of the computer's graphics card. Please be careful not to plug it into the motherboard's VGA port. Once connected, you can

The most comprehensive review of multimodal large models is here! Written by 7 Chinese researchers at Microsoft, it has 119 pages. It starts from two types of multi-modal large model research directions that have been completed and are still at the forefront, and comprehensively summarizes five specific research topics: visual understanding and visual generation. The multi-modal large-model multi-modal agent supported by the unified visual model LLM focuses on a phenomenon: the multi-modal basic model has moved from specialized to universal. Ps. This is why the author directly drew an image of Doraemon at the beginning of the paper. Who should read this review (report)? In the original words of Microsoft: As long as you are interested in learning the basic knowledge and latest progress of multi-modal basic models, whether you are a professional researcher or a student, this content is very suitable for you to come together.

3nm process, performance surpasses H100! Recently, foreign media DigiTimes broke the news that Nvidia is developing the next-generation GPU, the B100, code-named "Blackwell". It is said that as a product for artificial intelligence (AI) and high-performance computing (HPC) applications, the B100 will use TSMC's 3nm process process, as well as more complex multi-chip module (MCM) design, and will appear in the fourth quarter of 2024. For Nvidia, which monopolizes more than 80% of the artificial intelligence GPU market, it can use the B100 to strike while the iron is hot and further attack challengers such as AMD and Intel in this wave of AI deployment. According to NVIDIA estimates, by 2027, the output value of this field is expected to reach approximately

Explore the Canvas framework: To understand what are the commonly used Canvas frameworks, specific code examples are required. Introduction: Canvas is a drawing API provided in HTML5, through which we can achieve rich graphics and animation effects. In order to improve the efficiency and convenience of drawing, many developers have developed different Canvas frameworks. This article will introduce some commonly used Canvas frameworks and provide specific code examples to help readers gain a deeper understanding of how to use these frameworks. 1. EaselJS framework Ea

This work of EfficientSAM was included in CVPR2024 with a perfect score of 5/5/5! The author shared the result on a social media, as shown in the picture below: The LeCun Turing Award winner also strongly recommended this work! In recent research, Meta researchers have proposed a new improved method, namely mask image pre-training (SAMI) using SAM. This method combines MAE pre-training technology and SAM models to achieve high-quality pre-trained ViT encoders. Through SAMI, researchers try to improve the performance and efficiency of the model and provide better solutions for vision tasks. The proposal of this method brings new ideas and opportunities to further explore and develop the fields of computer vision and deep learning. by combining different

PHP error: Unable to declare class repeatedly, solution! It is common for developers to encounter problems. In PHP development, we often encounter a common error: the class cannot be declared repeatedly. This problem seems simple, but if not solved in time, the code will not execute correctly. This article will introduce the cause of this problem and provide a solution for your reference. When we define a class in PHP code, if the same class is defined multiple times in the same file or multiple files, an error that the class cannot be declared repeatedly will occur. This is
