modHelpers

Библиотека полезных функций для MODX.
Версия 4.0.0-pl
Дата выпуска 30.04.2021
Загрузки 714
Просмотры 15 309
Библиотека полезных функций для MODX для удобной разработки. В данный момент в библиотеке более 70 функций.

Немного примеров

# Проверка существования пользователя по email
if (user_exists(['email'=>'admin@mail.ru']) {
    // Пользователь с таким email существует
}


# Получить данные из кэша
$value = cache('key', 'my_data');
// Альтернативный вариант
$value = cache()->get('key', 'my_data');


# Отправка почты
email('pupsik@mail.ru', 'Тема','Содержание письма');
// Пользователю
email_user('admin', $subject, $content);


# Получить последний ресурс.
$resourceObject = resource()->last(); // Объект ресурса
$resourceArray = resource()->last()->toArray(); // Массив с данными ресурса


# Последние 10 ресурсов.
$resObjects = resources()->last(10);


# Массив с заголовками ресурсов родителя с id=20. Можно использовать для формирования селекта.
$titles= resources()->where(['parent'=>20])->get('pagetitle'); // array('pagetitle 1', 'pagetitle 2', 'pagetitle 3')


# Записать значение в сессию
session('key1.key2', 'value'); // => $_SESSION['key1']['key2'] = $value;
//# Получить значение из сессии
$value = session('key1.key2');  // $value = $_SESSION['key1']['key2']


# Проверить валидность email
if (is_email($email)) {
   // Почта валидная
}

Обсуждение компонента в сообществе MODX.PRO.

4.0.0-pl

  • Added function "build_tree".
  • Added function "reading_time".
  • Added function "sanitize_path".
  • Added function "value".
  • Removed function "faker".
  • Refactored the dump function. Now you can pass multiple agruments.
  • Added the ctx parameter for the login and logout functions.
  • Fixed the attach function of the Mailer class (#2).

3.7.0-pl

  • Added new function "get_exec_args".

3.7.0-beta

  • Added new function "exec_bg_script".
  • Added new function "timer".
  • Added "subDomain" and "subDomains" methods to the Request class.
  • Added "storeAsOriginal" method to the UploadedFile class.

3.6.0-beta

  • Added new function tag_encode.
  • Added new function tag_decode.
  • Added new function array_is_assoc.
  • Added new function is_odd.
  • Added new function is_even.
  • Added some methods to the Str class (used in the "string" function).
  • Added dd() and dump() methods to the Collection class.
  • Updated all composer dependencies.

3.5.1-beta

  • Improved compatibility with PHP 7.2.

3.5.0-beta

  • Added new function "string".
  • Added new function "str_concat".
  • Fixed the bug with the email function.

3.4.0-beta

  • Added new function "first".
  • Added new function "optional".
  • Added new function "html_attributes".
  • Improved the functions css() and script().

3.3.0-beta

  • Added the session manager.
  • The "session" function called without arguments returns the session manager instead of $_SESSION.
  • Added new function "dump".
  • Added new function "dd".
  • Added new function "has_parent".
  • Calling "user(true)" returns the current user.
  • Calling "resource(true)" returns the current resource.
  • Fixed a bug with caching in the "snippet" function.
  • Updated composer libraries.
  • Renamed the system setting "modhelpers_responseManager" to "modhelpers_responseManagerClass".

3.2.1-beta

  • Changed syntax for file elements with the relative path.
  • Fixed the filter method of the Request class.

3.2.0-beta

  • Added a new function "response".
  • Renamed files of the classes.
  • In the functions chunk() and snippet() you can specify the name with a relative path (if you use file elements).
  • Added file "config/config.php" to add custom system settings. Can be helpful in testing mode.

3.1.1-beta

  • Fixed broken compatibility with PHP 5.5.

3.1.0-beta

  • Added method "getCsrfToken" to the Request class.
  • Added method "checkCsrfToken" to the Request class.
  • Added method "isBot" to the Request class.
  • Added "bot_user_agents" system setting.
  • Added a new function "csrf_token".
  • Added a new function "csrf_field".
  • Added a new function "csrf_meta".
  • Changed the priority of the library loading.

3.0.1-beta

  • Fixed bug with loading the ModelColunm class.
  • Removed debug info.
  • Updated the Faker library.

3.0.0-beta

  • IMPORTANT! Added namespace "modHelpers" to the modHelpers' classes.
  • The requirement of the minimum PHP version is changed to 5.5.
  • Added a new function "request".
  • Added a new function "switch_context".
  • Added a new method "object" to the Object class.
  • Added a new method "parent" to the Object class.
  • Added a new method "first" to the Query class.
  • Added a new method "toString" to the Query class.
  • Added a new method "remember" to the CacheManager class.
  • All classes can be extended.

2.1.0-pl

  • Added function "is_tablet".
  • Added function "is_desktop".
  • Added function "app".
  • Added function "filter_data".
  • Added function "null_if".
  • Added the "relogin" parameter to the "logout" function.
  • Improve the "pls" function.
  • Improve the "parse" function.

2.0.0-pl

  • IMPORTANT! Changed the signature of the session() function. To put data to the session use an array.
  • Added function "session_pull".
  • Added function "default_if".
  • Added method "log" to the modHelpersMailer class. It can be helpful for testing.
  • Added method "toArray" to the modHelpersMailer class.
  • Added method "tpl" to the modHelpersMailer class which set a chunk as template for the email content.

1.4.0-beta

  • Added function "is_mobile".
  • Added function "array_empty".
  • Added function "array_notempty".
  • Added functions "array_trim", "array_ltrim" and "array_rtrim".
  • Added functions "explode_trim", "explode_ltrim" and "explode_rtrim".
  • Added function "echo_nl".
  • Added function "print_str".
  • Added function "print_d".
  • Added function "parse".
  • Added function "str_between".
  • Added function "str_limit".
  • Added functions - "str_starts", "str_ends", "str_contains" and "str_match".
  • Added the queue functionality to the mailer class.
  • The log functions can output objects which have the "toArray" method.
  • Code refactoring.

1.3.0-beta

  • Added function "login".
  • Added function "logout".
  • Added function "is_ajax".
  • Fixed some bugs.

1.2.0-beta

  • Added function "load_model" for custom table.
  • Added method "joinGroup" to the collection class for users and resources.
  • Added method "leaveGroup" to the collection class for users and resources.
  • Added method "whereIn" to the collection class for users and resources.
  • Added method "whereNotIn" to the collection class for users and resources.
  • Added method "whereLike" to the collection class for users and resources.
  • Added method "whereNotLike" to the collection class for users and resources.
  • Added method "whereIsNull" to the collection class for users and resources.
  • Added method "whereIsNotNull" to the collection class for users and resources.
  • Added class modHelperMailer which allows to use chains of methods.

1.1.0-beta

  • Added function "faker" that generates fake data.
  • Added function "img".
  • Added method "whereExists" to the collection class.
  • Added method "whereNotExists" to the collection class.
  • Added method "elements" to the collection class.

1.0.2-beta

  • Renamed "esc" function to "escape".
  • Added "memory" function.
  • Added "forward" function.
  • Added "orWhere" method to the collection class.
  • Added "each" method to the collection class.
  • Added "union" method to the collection class.
  • Added "members" method to the collection class.
  • Added an ability to pass a Closure to the collection functions.

1.0.1-beta

  • Rename the log functions.
  • Add withTV method to the collection class.

1.0.0-beta

  • Initial release.

Последние обсуждения в сообществе MODX.pro