PHP Classes

File: engine/modules/core/message/message.hook.inc

Recommend this page to a friend!
  Classes of Aldo Tripiciano   Quanta CMS   engine/modules/core/message/message.hook.inc   Download  
File: engine/modules/core/message/message.hook.inc
Role: Example script
Content type: text/plain
Description: Example script
Class: Quanta CMS
Manage content that works without a database
Author: By
Last change:
Date: 5 years ago
Size: 1,013 bytes
 

Contents

Class file image Download
<?php

/**
 * Implements hook_page_after_build().
 *
 * @param Environment $env
 * The Environment.
 * @param array $vars
 * An array of variables.
 */
function message_page_after_build($env, $vars) {
 
$messages = $env->getData('message');
 
// Check if there are messages to be added to the system log file.
 
if (!empty($messages)) {
    foreach (
$messages as $message) {
      if (
$message->type == MESSAGE_TYPE_LOG) {
     
$username = UserFactory::current($env)->name;
       
$fh = fopen($env->dir['log'] . '/log.txt', 'a+') or die("error");
       
fwrite($fh, '[' . date('Y-m-d h:i:s') . '] ' . str_replace('!username', $username, $message->body) . '
  '
);
       
fclose($fh);
      }
    }
  }
}

/**
 * Implements hook_load_includes().
 *
 * @param Environment $env
 * The Environment.
 *
 * @param array $vars
 * An array of variables.
 */
function message_load_includes($env, $vars) {
 
$module_path = $env->getModulePath('message');
 
$env->addInclude($module_path . '/css/message.css');
}