Skip to content

Instantly share code, notes, and snippets.

View sottwell's full-sized avatar

Susan Ottwell sottwell

View GitHub Profile
@sottwell
sottwell / hex2rgba.php
Last active July 20, 2017 11:11
Hex2Rgbp Custom Output Modifier Snippet
<?php
# hex2rgba
# converts hex value from ColorPicker TV to rgba value
# NOTE that the ColorPicker TV must use the default output option
# based on function from http://mekshq.com/how-to-convert-hexadecimal-color-code-to-rgb-or-rgba-using-php/
if (!function_exists('hex2rgba')) {
function hex2rgba($color, $opacity = false) {
$default = 'rgb(0,0,0)';
@sottwell
sottwell / PageNotFoundReport
Last active December 21, 2015 07:49
Page Not Found Report Dashboard Widget to work with BobRay's LogPageNotFound extra - MODX Revolution
<?php
/**
* PageNotFoundLogReport
* Copyright 2011-2013 Bob Ray
*
* PageNotFoundLogReport is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any
* later version.
*
@sottwell
sottwell / saveContextCss
Last active February 2, 2016 11:00
saveContextCss Plugin to replace CssSweet's chunk-based saveCustomCss plugin - MODX Revolution
<?php
/**
* saveCustomCss
* @author @sepiariver
* Copyright 2013 - 2015 by YJ Tso <yj@modx.com> <info@sepiariver.com>
*
* saveCustomCss and cssSweet is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any later version.
@sottwell
sottwell / Messages
Last active February 2, 2019 10:27
Dashboard Widget to display the number of internal Manager messages the user has - MODX Revoluition
// Dashboard widget to show number of Manager messages
$id = $modx->user->get('id');
$output = 'No messages.';
$total = $modx->getCount('modUserMessage',array(
'recipient' => $id,
));
if($total) {
$output = 'You have ' . $total . ' messages';
$unread = $modx->getCount('modUserMessage',array(
'recipient' => $id,
@sottwell
sottwell / ErrorLog
Last active August 11, 2017 05:45
Dashboard Widget to report on Manager error log - MODX Revolution
<?php
// Dashboard widget to report on the number of errors in the Error Log
$logfile = MODX_CORE_PATH . 'cache/logs/error.log';
if(!$f = fopen($logfile, 'rb')) return 'Could not open log file.';
$lines = 0;
while (!feof($f)) {
$lines += substr_count(fread($f, 8192), "(ERROR ");
}
@sottwell
sottwell / SiteSummary
Last active May 12, 2017 21:20
Pretty Site Summary dashboard widget - original by W. Shawn Wilkerson - MODX Revolution
<?php
// SiteSummary snippet for Dashboard widget
// W. Shawn Wilkerson
$o = '<table class="classy" style="width:100%;"><thead><tr style="background:#DDE3EA;color:#000;">';
$o .= '<th style="width:50%;padding:8px 0;text-align:center;">Resources</th>';
$o .= '<th style="width:50%;padding:8px 0;text-align:center;">Elements</th>';
$o .= '</tr></thead><tbody><tr><td style="padding:0 1em;">';
$o .= 'Published Resources: ' . $modx->getCount('modResource', array('published' => '1'));
$o .= '<br>Unpublished Resources: ' . $modx->getCount('modResource', array('published' => '0'));