Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64
User : palandch ( 1163)
PHP Version : 7.1.33
Disable Function : NONE
Directory :  /home/palandch/public_html/core/cache/includes/elements/modsnippet/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/palandch/public_html/core/cache/includes/elements/modsnippet/13.include.cache.php
<?php
function elements_modsnippet_13($scriptProperties= array()) {
global $modx;
if (is_array($scriptProperties)) {
extract($scriptProperties, EXTR_SKIP);
}
/**
 *
 * getResourceField
 *
 * A snippet to grab a value from a resource field or a TV
 *
 * @ author Paul Merchant
 * @ author Shaun McCormick
 * @ copyright 2011 Paul Merchant
 * @ version 1.0.3 - August 8, 2011
 * @ MIT License
 *
 * OPTIONS
 * id - The resource ID
 * field - (Opt) The field or template variable name, defaults to pagetitle
 * isTV - (Opt) Set as true to return a raw template variable
 * processTV - (Opt) Set as true to return a rendered template variable
 * default - (Opt) The value returned if no field is found
 *
 * Exmaple1: [[getResourceField? &id=`123`]]
 * Example2: [[getResourceField? &id=`[[UltimateParent?]]` &field=`myTV` &isTV=`1`]]
 * Example3: [[getResourceField? &id=`[[*parent]]` &field=`myTV` &processTV=`1`]]
 *
**/

// set defaults
$id = $modx->getOption('id',$scriptProperties,$modx->resource->get('id'));
$field = $modx->getOption('field',$scriptProperties,'pagetitle');
$isTV = $modx->getOption('isTV',$scriptProperties,false);
$processTV = $modx->getOption('processTV',$scriptProperties,false);
$output = $modx->getOption('default',$scriptProperties,'');

if ($isTV || $processTV) {
    // get the tv object
    $tv = $modx->getObject('modTemplateVar',array('name'=>$field));
    if (empty($tv)) return $output;
    if ($processTV) {
        // get rendered tv value
        $tvValue = $tv->renderOutput($id);
    } else {
        // get raw tv value
        $tvValue = $tv->getValue($id);
    }
    if ($tvValue !== null) {
        $output = $tvValue;
    }
} else {
    if ($id == $modx->resource->get('id')) {
        // use the current resource
        $resource =& $modx->resource;
        // current resource can infinite loop if pulling content field into itself
        if ($field == 'content') {
            return $output;
        }
    } else {
        // grab only the columns we need
        $criteria = $modx->newQuery('modResource');
        $criteria->select($modx->getSelectColumns('modResource','modResource','',array('id',$field)));
        $criteria->where(array('id'=>$id,));
        $resource = $modx->getObject('modResource',$criteria);
        if (empty($resource)) return $output;
    }
    $fieldValue = $resource->get($field);
    if ($fieldValue !== null) {
        $output = $fieldValue;
    }
}

return $output;
}

Spamworldpro Mini