This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// The Resource ID to test | |
$id = (int) $modx->getOption('id', $scriptProperties, $modx->resource->get('id'), true); | |
// Option to return early if Current Resource matches $id | |
$matchCurrent = $modx->getOption('matchCurrent', $scriptProperties, true); | |
// IDs of Resources deemed as "sections", against which to test | |
$sectionIds = array_filter(array_map('trim', explode(',', $modx->getOption('sectionIds', $scriptProperties, '')))); | |
// IDs of parent Resources, the direct children of which will be added to $sectionIds | |
$sectionParentIds = array_filter(array_map('trim', explode(',', $modx->getOption('sectionParentIds', $scriptProperties, '')))); | |
// If the test passes, meaning the Resource has a $sectionId as an ancestor, output this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// In case the wrong event is enabled | |
if ($modx->context->key !== 'mgr' || $modx->event->name !== 'OnDocFormSave') return; | |
// We really need a resource object and the pthumb snippet | |
if (!is_object($resource) || $modx->getCount('modSnippet', array('name' => 'phpthumbof')) !== 1) { | |
$modx->log(modX::LOG_LEVEL_ERROR, 'ResourceImageThumbnails plugin requires phpthumbof and a valid resource object.'); | |
return; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* DateToTimestamp Plugin for MODX Revolution | |
* @code @theboxer | |
* @comments @sepiariver | |
* | |
* DateToTimestamp 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add content types for fonts | |
AddType application/x-font-ttf .ttf | |
AddType application/x-font-opentype .otf | |
AddType application/x-font-woff .woff | |
ExpiresActive On | |
ExpiresByType image/gif A2592000 | |
ExpiresByType image/jpeg A2592000 | |
ExpiresByType image/png A2592000 | |
ExpiresByType image/x-icon A2592000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* getProps | |
* Snippet to access MODX Resource properties. | |
* @author @sepiariver | |
* | |
* @package ResourceProperties | |
* GPL+, no warranties express nor implied. | |
* | |
**/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Use the cbGetFieldContent snippet to get the content of a particular field. | |
* | |
* For example, this can be useful if you need to get a bit of content | |
* in a getResources call | |
* | |
* Example usage: | |
* | |
* [[cbGetFieldContent? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$success = false; | |
if (!empty($value)) { | |
$re = "/^((((\+[\d\-.]{1,5})?[ \-.]?\d{3})|(\+[\d\-.]{1,5})?[ \-.]?\((\d{3}\)))?[ \-.]?\d{3}[ \-.]?\d{4}\s?(e?x?t?\.?\s?\d{1,7})?)?$/i"; | |
if (preg_match($re, $value) === 1) $success = true; | |
} | |
if (!$success) { | |
$validator->addError($key, 'Please enter a valid phone number.'); | |
return false; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Steps to implement | |
* 1. Set HTML content-type default suffix to '/' | |
* 2. Ensure Resources have isFolder = 1 as default | |
* 3. If you still have issues with Resources being routed to the URI without a trailing slash, | |
* create this Plugin and enable it 'OnWebPageInit'. | |
**/ | |
if ($modx->event->name !== 'OnWebPageInit') return; | |
if (substr($_SERVER['REQUEST_URI'], -1) !== '/') $modx->sendRedirect($_SERVER['REQUEST_URI'] . '/', array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* getter function for resource properties. sets placeholders with all values. | |
* optionally allows direct return of one element within the namespaced properties sub-array | |
* @author @sepiariver | |
* | |
**/ | |
// OPTIONS | |
$id = (int) $modx->getOption('id', $scriptProperties, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @author @sepiariver | |
* | |
**/ | |
if ($modx->context->get('key') !== 'mgr' || $modx->event->name !== 'OnDocFormSave') return; | |
if (!($resource instanceof modResource)) { | |
$modx->log(modX::LOG_LEVEL_ERROR, 'setResourceProps Plugin did not have access to a valid resource object on line: ' . __LINE__); | |
return; |