Contribute information to the system module and integrate it with the rest of the application.
More...
List of all members.
Static Public Member Functions |
static | fetchMd5 ($path, $stripFilenames=false) |
| Fetches the contents of a file containing one or more md5 calculations, and the filenames for which they have been calculated.
|
static | getGeneralInformation ($systemInformation) |
| General P4CMS info (version, active site, sites available, etc.)
|
static | getModuleInformation ($systemInformation) |
| Optional/contributed Modules installed / enabled / disabled / MD5 checksums.
|
static | getPerforceInformation ($systemInformation) |
| Perforce Client Application p4 or p4php version p4port Perforce Server (p4 info) (some client* entries removed) License info number of licenses & expiration date number of users.
|
static | getPhpInformation ($systemInformation) |
| PHP info Version Modules in use phpinfo() ???
|
static | getThemeInformation ($systemInformation) |
| Themes installed / enabled / disabled / MD5 checksums (?)
|
static | getWebserverInformation ($systemInformation) |
| Web server info Which one being used (Apache, etc.) Version Modules in use (can we detect this? Not right now.
|
static | init () |
| Perform early integration work (before load).
|
Detailed Description
Contribute information to the system module and integrate it with the rest of the application.
- Copyright:
- 2011-2012 Perforce Software. All rights reserved
- License:
- Please see LICENSE.txt in top-level folder of this distribution.
- Version:
- 2012.2/486814
Member Function Documentation
static System_Module::fetchMd5 |
( |
$ |
path, |
|
|
$ |
stripFilenames = false |
|
) |
| [static] |
Fetches the contents of a file containing one or more md5 calculations, and the filenames for which they have been calculated.
Optionally, strips the filenames from the lines in the file, leaving only the md5 calculations.
- Parameters:
-
string | $path | The full path to the file. |
bool | $stripFilenames | Whether or not to strip the filenames. |
- Returns:
- string The fetched file contents, or empty string if file cannot be read.
{
$md5 = is_readable($path) ? trim(file_get_contents($path)) : '';
if ($stripFilenames) {
$md5 = preg_replace('/^(\w*).*$/m', '\\1', $md5);
}
return $md5;
}
static System_Module::getGeneralInformation |
( |
$ |
systemInformation | ) |
[static] |
General P4CMS info (version, active site, sites available, etc.)
- Parameters:
-
{
$sysinfo = new System_Model_Info();
$sysinfo->setId('p4cms');
$sysinfo->title = 'General';
$sysinfo->order = -10;
$sysinfo->view = APPLICATION_PATH . '/system/views/scripts/general-info.phtml';
$supportData = array();
$supportData['version'] = P4CMS_VERSION;
$report = '';
$userCount = P4Cms_User::count();
$plural = $userCount != 1 ? 's' : '';
$report .= "$userCount user$plural";
$roleCount = P4Cms_Acl_Role::count();
$plural = $roleCount != 1 ? 's' : '';
$report .= ", $roleCount role$plural";
$contentCount = P4Cms_Content::count();
$plural = $contentCount != 1 ? 'ies' : 'y';
$report .= ", $contentCount content entr$plural";
$typeCount = P4Cms_Content_Type::count();
$plural = $typeCount != 1 ? 's' : '';
$report .= ", $typeCount content type$plural";
$categoryCount = count(Category_Model_Category::fetchAll());
$plural = $categoryCount != 1 ? 'ies' : 'y';
$report .= " and $categoryCount categor$plural.";
$activeSite = P4Cms_Site::fetchActive();
$supportData['Active Site'] = array(
'site' => $activeSite,
'details' => $report
);
$siteList = P4Cms_Site::fetchAll();
$siteInfo = array();
foreach ($siteList as $site) {
$title = $site->getConfig()->getTitle();
if (!array_key_exists($title, $siteInfo)) {
$siteInfo[$title] = array();
}
$stream = $site->getStream()->getName();
$siteInfo[$title][] = $stream;
}
$supportData['All Sites'] = $siteInfo;
$directoryHandle = dir(LIBRARY_PATH);
while (false != ($entry = $directoryHandle->read())) {
if (strpos($entry, '.') !== 0) {
$supportData['libraries'][] = $entry;
}
}
$directoryHandle->close();
$originalMd5 = static::fetchMd5(BASE_PATH . '/index.php.md5', true);
$currentMd5 = md5_file(BASE_PATH . '/index.php');
$supportData['index.php'] = array(
'displayClass' => $originalMd5 == $currentMd5
? 'good'
: 'bad',
'status' => $originalMd5 == $currentMd5
? 'Ok'
: 'Failed',
'details' => $currentMd5
);
$originalMd5 = static::fetchMd5(APPLICATION_PATH . '/Bootstrap.php.md5', true);
$currentMd5 = md5_file(APPLICATION_PATH . '/Bootstrap.php');
$supportData['Bootstrap.php'] = array(
'displayClass' => $originalMd5 == $currentMd5
? 'good'
: 'bad',
'status' => $originalMd5 == $currentMd5
? 'Ok'
: 'Failed',
'details' => $currentMd5
);
$sysinfo->content = $supportData;
$systemInformation[] = $sysinfo;
}
static System_Module::getModuleInformation |
( |
$ |
systemInformation | ) |
[static] |
Optional/contributed Modules installed / enabled / disabled / MD5 checksums.
- Parameters:
-
static System_Module::getPerforceInformation |
( |
$ |
systemInformation | ) |
[static] |
Perforce Client Application p4 or p4php version p4port Perforce Server (p4 info) (some client* entries removed) License info number of licenses & expiration date number of users.
- Parameters:
-
{
$sysinfo = new System_Model_Info();
$sysinfo->setId('support');
$sysinfo->title = 'Perforce';
$sysinfo->order = 0;
$p4 = P4_Connection::getDefaultConnection();
$identity = $p4->getConnectionIdentity();
$minVersion = strtolower(Setup_IndexController::MIN_P4_VERSION);
$ourVersion = strtolower($identity['version']);
$p4Valid = version_compare($ourVersion, $minVersion) >= 0;
$p4Version = $identity['original'];
$content['Client Version'] = array(
'displayClass' => $p4Valid ? 'good' : 'bad',
'details' => $p4Version
);
$p4Port = $p4->getPort();
$isPortRsh = false;
if (preg_match('/^rsh:/', $p4Port)) {
$isPortRsh = true;
$content['P4PORT'] = $p4Port . ' (local)';
} else {
$content['P4PORT'] = $p4Port;
}
foreach ($p4->getInfo() as $key => $value) {
if (preg_match('/^client(Cwd|Name|Root)/', $key)) {
continue;
}
if ($isPortRsh && $key === 'serverUptime') {
continue;
}
$newKey = preg_replace('/([a-z])([A-Z])/', '$1 $2', $key);
$newKey = ucfirst($newKey);
if ($isPortRsh && $key === 'serverAddress') {
$content[$newKey] = $value . ' (local)';
} else {
$content[$newKey] = $value;
}
}
$license = $p4->run('license', array('-u'))->getData(0);
$content['Is Licensed'] = $license['isLicensed'];
$formatLimit = function($limit, $softMessage) use ($license)
{
$message = '';
$license += array($limit . "SoftLimit" => null);
if (is_numeric($license[$limit . 'Count'])) {
$message .= 'Used '. $license[$limit . 'Count'] .' out of ';
}
$message .= $license[$limit . 'SoftLimit'] ?: $license[$limit . 'Limit'];
if ($license[$limit . 'SoftLimit']) {
$message .= ' (' . $license[$limit . 'Limit'] . ' if '
. $softMessage . ' not exceeded)';
}
return $message;
};
$content['User Limit'] = $formatLimit('user', 'File Limit is');
$content['Client Limit'] = $formatLimit('client', 'File Limit is');
$content['File Limit'] = $formatLimit('file', 'User and Client Limits are');
$sysinfo->content = $content;
$systemInformation[] = $sysinfo;
}
static System_Module::getPhpInformation |
( |
$ |
systemInformation | ) |
[static] |
PHP info Version Modules in use phpinfo() ???
- Parameters:
-
{
$sysinfo = new System_Model_Info();
$sysinfo->setId('php');
$sysinfo->title = 'PHP';
$sysinfo->order = 30;
$supportData = array();
$supportData['version'] = array(
'displayClass' => (version_compare(PHP_VERSION, Setup_IndexController::MIN_PHP_VERSION) >= 0)
? 'good'
: 'bad',
'status' => PHP_VERSION
);
$supportData['modules'] = implode(', ', get_loaded_extensions());
ob_start();
phpinfo();
$supportData['phpinfo'] = trim(ob_get_clean());
$sysinfo->content = $supportData;
$sysinfo->view = APPLICATION_PATH . '/system/views/scripts/php-info.phtml';
$systemInformation[] = $sysinfo;
}
static System_Module::getThemeInformation |
( |
$ |
systemInformation | ) |
[static] |
Themes installed / enabled / disabled / MD5 checksums (?)
- Parameters:
-
{
$sysinfo = new System_Model_Info();
$sysinfo->setId('themes');
$sysinfo->title = 'Themes';
$sysinfo->order = 140;
$sysinfo->view = APPLICATION_PATH . '/system/views/scripts/packages-info.phtml';
$sysinfo->content = P4Cms_Theme::fetchAll();
$systemInformation[] = $sysinfo;
}
static System_Module::getWebserverInformation |
( |
$ |
systemInformation | ) |
[static] |
Web server info Which one being used (Apache, etc.) Version Modules in use (can we detect this? Not right now.
- Parameters:
-
{
$sysinfo = new System_Model_Info();
$sysinfo->setId('webserver');
$sysinfo->title = 'Webserver';
$sysinfo->order = 40;
$supportData = array();
$supportData['server'] = (array_key_exists('SERVER_SOFTWARE', $_SERVER))
? $_SERVER['SERVER_SOFTWARE']
: 'Unavailable';
$sysinfo->content = $supportData;
$systemInformation[] = $sysinfo;
}
static System_Module::init |
( |
| ) |
[static] |
Perform early integration work (before load).
Reimplemented from P4Cms_Module_Integration.
{
P4Cms_PubSub::subscribe('p4cms.system.info', 'System_Module', 'getGeneralInformation');
P4Cms_PubSub::subscribe('p4cms.system.info', 'System_Module', 'getPerforceInformation');
P4Cms_PubSub::subscribe('p4cms.system.info', 'System_Module', 'getWebserverInformation');
P4Cms_PubSub::subscribe('p4cms.system.info', 'System_Module', 'getPhpInformation');
P4Cms_PubSub::subscribe('p4cms.system.info', 'System_Module', 'getModuleInformation');
P4Cms_PubSub::subscribe('p4cms.system.info', 'System_Module', 'getThemeInformation');
}
The documentation for this class was generated from the following file:
- application/system/Module.php