Skip to content

Instantly share code, notes, and snippets.

View splittingred's full-sized avatar
💭
🚀

Shaun McCormick splittingred

💭
🚀
View GitHub Profile

Keybase proof

I hereby claim:

  • I am splittingred on github.
  • I am splittingred (https://keybase.io/splittingred) on keybase.
  • I have a public key whose fingerprint is DDFF 7D05 78C7 C3BD B1B9 45C5 6D10 B616 3AD3 FC69

To claim this, I am signing this object:

$event= $modx->newObject('modEvent');
$event->fromArray(array (
'name' => 'OnMyEvent',
'service' => 1,
'groupname' => 'MyGroup'
));
$event->save();
/* Then associate it with a plugin: */
if (!empty($options['showBoards'])) {
$c = array(
'board' => 0,
'groups' => $_groups,
);
if (!empty($scriptProperties['category'])) $c['category'] = (int)$scriptProperties['category'];
$cacheKey = 'discuss/board/user/'.$discuss->user->get('id').'/index-'.md5(serialize($c));
$boardIndex = $modx->cacheManager->get($cacheKey);
if (empty($boardIndex)) {
@splittingred
splittingred / gist:970884
Created May 13, 2011 16:56
getTpl snippet
<?php
/**
* Use like so:
* [[!getTpl? &file=`/path/to/my/file`]]
*/
$o = '';
if (file_exists($file)) {
$o = file_get_contents($file);
} else { $o = 'File not found: '.$file; }
return $o;
$thumbUrl = $item->get('thumbnail',array(
'w' => (int)$modx->getOption('imageWidth',$scriptProperties,500),
'h' => (int)$modx->getOption('imageHeight',$scriptProperties,500),
'zc' => (boolean)$modx->getOption('imageZoomCrop',$scriptProperties,0),
'far' => (string)$modx->getOption('imageFar',$scriptProperties,false),
'q' => (int)$modx->getOption('imageQuality',$scriptProperties,90),
));
/* or */
$thumbUrl = $item->get('thumbnail',array(
<?php
$response = array();
switch ($modx->event->name) {
case 'OnDiscussRenderHome':
$response['top'] = 'My custom stuff goes here!';
break;
}
$modx->event->_output = $response;
return;
<?php
$eventName = $modx->event->name;
switch ($eventName) {
case 'OnLoadWebDocument' :
$output = $modx->codeContent = $modx->resource->getContent();
preg_match_all('/<pre.*?>(.*?)<\/pre>/ims', $output, $matches);
$i = 0;
if (empty($matches[1])) return;
if (empty($modx->codeMatches)) $modx->codeMatches = array();
@splittingred
splittingred / gist:1001004
Created May 31, 2011 18:13
Discuss recent improvements
- Q&A thread types, where specific replies can be marked as answers and moved to the top of the thread, and the title appends [Solved]
- Enable FURLs for boards
- Enable FURLs for users
- Enable ability for users to set "Display Name"
- Better post parsing to prevent HTML injection, mistyped tags, etc
- Lots of fixes and improvements to URL parsing, better abstraction on that front
- Add New Replies to Posts page
- Bad words filter
- Solr powered search
- Improved print page
@splittingred
splittingred / gist:1007286
Created June 3, 2011 22:28
Get role of a User in a certain group
<?php
$c = $modx->newQuery('modUserGroupRole');
$c->innerJoin('modUserGroupMember','UserGroupMembers');
$c->innerJoin('modUserGroup','UserGroup','UserGroup.id = UserGroupMembers.user_group');
$c->where(array(
'UserGroupMembers.member' => $userId,
'UserGroup.name' => $userGroupName,
));
$role = $modx->getObject('modUserGroupRole',$c);
@splittingred
splittingred / gist:1014497
Created June 8, 2011 14:19
New class based file edit controller (working demo)
<?php
/**
* Loads the edit file page
*
* @package modx
* @subpackage manager.system.file
*/
class SystemFileEditManagerController extends modManagerController {
/** @var string The basename of the file */
public $filename = '';