Skip to content

Instantly share code, notes, and snippets.

@gartes
gartes / $layout->render
Created July 27, 2018 20:08
JLayoutFile
$basePath = VMPATH_MY_PLUGIN_GLAVPUNKT . DS . 'layouts' ;
$data = array('name' => 'Dmitry');
$layout = new JLayoutFile('glavpunkt.sspb', $basePath);
$html = $layout->render($data); // $displayData
@gartes
gartes / ->load
Last active July 27, 2018 12:08
JF:getLanguage()
$language = JFactory::getLanguage();
$language->load('lib_ukcpu' , UKCPU_LANGUAGE_PATH , $language->getTag(), true);
// Загрузака яыка для плагина
$lang = JFactory::getLanguage();
$extension = 'plg_vmextended_account_ext';
$base_dir = JPATH_PLUGINS . DS . 'plg_vmextended_account_ext' ;
$language_tag = $lang->getTag() ;
$reload = true;
@gartes
gartes / JPATH_
Last active July 27, 2018 11:28
Основные коснтанты Joomla
JPATH_ADMINISTRATOR // Путь к каталогу администратора (/administrator)
JPATH_BASE // Путь к установленному сайту Joomla
JPATH_CACHE // Путь к каталогу, содержащему кэш
JPATH_COMPONENT // Путь к компоненту, который в данный момент исполняется
JPATH_COMPONENT_ADMINISTRATOR // Путь к административному каталогу компонента, который исполняется
JPATH_COMPONENT_SITE // Путь к каталогу сайта того компонента, который исполняется
JPATH_CONFIGURATION // Путь к каталогу, содержащему файл конфигурации configuration.php
JPATH_INSTALLATION // Путь к каталогу установки Joomla
JPATH_LIBRARIES // Путь к каталогу, содержащему библиотеки Joomla
JPATH_PLUGINS // Путь к каталогу, содержащему плагины Joomla
@gartes
gartes / $jinput
Last active July 31, 2018 23:22
getApplication()
$jinput = JFactory::getApplication()->input;
$id = $jinput->get('id', null, 'int'); // int(-123) INT, INTEGER – первое целое число
$text = $jinput->get('text' , null , 'BOOL' ); // bool(true)
$text = $jinput->get('text' , null , 'WORD' ); // string(35) "AaBb_metacontentJoomlanamegenerator"
$phone = $jinput->get('phone_1' , null , 'BASE64' ); // string(42) "123AaBb=+metacontent=Joomlaname=generator/"
$phone = $jinput->get('phone_1' , null , 'STRING' ); // string(42) "string(43) "..-123 AaBb ДдГг = [] () + ^ * _ . % - ""
$text = $jinput->get('text' , null , 'RAW' ); // RAW – фильтрация не применяется. Доступен начиная с Joomla 3.
// Применяем тип фильтра "INT"
try{
throw new Exception( 'Error_Text' );
}catch (Exception $e){
JFactory::getApplication()->enqueueMessage( $e->getMessage() , 'error');
}
// $e->getCode()
// $e->getMessage()
@gartes
gartes / ChromePhp
Last active July 29, 2018 11:02
FirePHP
ChromePhp::log('Hello console!');
ChromePhp::log($_SERVER);
ChromePhp::warn('something went wrong!');
@gartes
gartes / errors.php
Created July 25, 2018 14:22
Обработка ошибок. Исключения
<?php
echo "Файл с ошибками. Начало<br><br>";
/*
* перехватываемые ошибки (ловятся функцией set_error_handler())
*/
// NONFATAL - E_NOTICE
// echo $undefined_var;
// NONFATAL - E_WARNING
// array_key_exists('key', NULL);
// NONFATAL - E_DEPRECATED
@gartes
gartes / jimport
Created July 24, 2018 12:16
jimport
jimport('ukcpu.user.libuser');
@gartes
gartes / getModel('product')
Created July 16, 2018 08:04
VmModel-product
$productModel = VmModel::getModel('product');
JLog::addLogger(
array(
// Sets file name
'text_file' => 'com_helloworld.log.php'
),
// Sets messages of all log levels to be sent to the file
JLog::ALL,
// The log category/categories which should be recorded in this file
// In this case, it's just the one category from our extension, still
// we need to put it inside an array