*/ class CommandPluginExtension_dt extends CommandPluginExtension { function getCachedData($embedding, $params, $paramHash, $content, &$errorMessage) // STATIC { global $conf; // Determine the name of the configuration variable. $configName = 'dtformat'; if(sizeof($params) == 1 && is_string($params[0])) $configName .= '_'.$params[0]; else if(sizeof($params) != 0) { $errorMessage = "_INVALID_DT_PARAMETERS_"; return null; // return value doesn't matter in this case } // Load the css class and the date format from the variable. $cssClass = null; $format = null; $configVal = null; $configVal = @$conf[$configName]; if($configVal != null) { $barPos = strpos($configVal, '|'); if($barPos === false) $format = $configVal; else { $cssClass = substr($configVal, 0, $barPos); // next line works even if there is no format $format = substr($configVal, $barPos + 1); } } // Format the date/time. if(!empty($format)) { if(trim($content) == '') $newDT = date($format); else $newDT = date($format, strtotime($content)); } else $newDT = $content; $newDT = htmlspecialchars($newDT); // Return the newly formatted date/time. if($embedding == 'block') { if($cssClass) return '
'.$newDT.'
'; return '
'.$newDT.'
'; } else if($cssClass) return ''.$newDT.''; return $newDT; } } ?>