modChunk Object Cheat Sheet (MODX Revolution 2.x)

Body
modChunk database table fields, schema definitions, and relationships: aggregate, composite, ancestral. Also provides default object values.

Authored on

Framework

Snippet Call

[[viewRevoObjects?objectType=`ALL`]] (caution: over 30 printed pages)
[[viewRevoObjects?objectType=`Chunk`]]
[[viewRevoObjects?objectType=`Plugin`]]
[[viewRevoObjects?objectType=`Resource`]]
[[viewRevoObjects?objectType=`Snippet`]]
[[viewRevoObjects?objectType=`Template`]]
[[viewRevoObjects?objectType=`TemplateVar`]]

Code

<?php

/**
 * File viewRevoObjects.php (requires MODx Revolution 2.1)
 * Created on: 9/17/11 at 9:49 AM
 * Project shawn_wilkerson
 * @elements
 * @version 1.0
 * @category
 * @author W. Shawn Wilkerson
 * @link http://www.shawnWilkerson.com
 * @copyright Copyright (c) 2011, Sanity LLC. All rights reserved.
 * @license
 *
 */
if (!function_exists('retrieveObject')) {
    function retrieveObject($name)
    {
        $rt = '';
        global $modx;
        $tblName = 'mod' . $name;
        $rt .= '<h2>' . $tblName . ' ([[++settings_version]])</h2>';
        $rt .= '<h3>Table Fields</h3>';
        $rt .= '<pre><code>' . print_r($modx->getFields($tblName), true) . '</code></pre>';
        $rt .= '<h3>Validation Rules</h3>';
        $rt .= '<pre><code>' . print_r($modx->getValidationRules($tblName), true) . '</code></pre>';
        $rt .= '<h3>Index Meta</h3>';
        $rt .= '<pre><code>' . print_r($modx->getIndexMeta($tblName), true) . '</code></pre>';
        $rt .= '<h3>Field Aliases</h3>';
        $rt .= '<pre><code>' . print_r($modx->getFieldAliases($tblName), true) . '</code></pre>';
        $rt .= '<h3>Table Construction (meta defined in schema)</h3>';
        $rt .= '<pre><code>' . print_r($modx->getFieldMeta($tblName), true) . '</code></pre>';
        $rt .= '<h3>Aggregate Relations</h3>';
        $rt .= '<pre><code>' . print_r($modx->getAggregates($tblName), true) . '</code></pre>';
        $rt .= '<h3>Composite Relations</h3>';
        $rt .= '<pre><code>' . print_r($modx->getComposites($tblName), true) . '</code></pre>';
        $rt .= '<h3>Ancestors</h3>';
        $rt .= '<pre><code>' . print_r($modx->getAncestry($tblName), true) . '</code></pre>';
        return $rt;
    }
}

$wsw = '';
$modxObjects = array('Chunk', 'Plugin', 'UserProfile', 'Resource', 'Snippet', 'Template', 'TemplateVar', 'User');
$objType = $modx->getOption('objectType', $scriptProperties, 'User');

if ($objType == "ALL") {
    foreach ($modxObjects as $name) {
        $wsw .= retrieveObject($name);
    }
} else {
    if (in_array($objType, $modxObjects)) {
        $wsw = retrieveObject($objType);
    }
}
$wsw = str_replace(array('(', ')', 'Array'), '', $wsw);
return $wsw;

Sample Output

modChunk: MODX Revolution object for HTML Chunks
modPlugin: MODX Revolution object for PHP Plugins
modResource: MODX Revolution base object for weblinks, documents, resources, and static content
modSnippet: MODX Revolution object for PHP code
modTemplate: MODX Revolution object for xhtml, html, html5, and other types of templates
modTemplateVar: MODX Revolution object attaching variables directly to Templates
modUser: MODX Revolution object central to all user specific functionality
modUserProfile: MODX Revolution user object is separate from the user profile.