12.cache.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php return '/*
  2. * DESCRIPTION:
  3. * This snippet returns the current year
  4. * It is then styled with a chunk to output a copyright notice which you can adapt to fit your needs.
  5. * You can call this snippet with a startyear for your website.
  6. * If you use a start year it automatically changes when the year passes.
  7. * i.e. 2012 turns into 2012-2013
  8. *
  9. * PARAMETERS:
  10. * @ &startYear (string) optional. Default: Current Year
  11. * @ &separator (string) optional. Default: \'-\'
  12. * @ &static (bool) optional. Default: 0
  13. * @ &tpl (string) optional. Default: \'sc_chunk\'
  14. *
  15. * PLACEHOLDERS:
  16. * @ [[+output]]
  17. *
  18. * The usage defines \'2012\' as the \'current\' year purely for illustration purpose only.
  19. * This is obviously wrong in 2013 or up...
  20. *
  21. * USAGE:
  22. * // Outputs: "&copy; 2012 by [[+site_name]]"
  23. * [[SimpleCopyright]]
  24. *
  25. * // Outputs: "&copy; 2007-2012 by [[+site_name]]"
  26. * // After newyears eve it turns into 2012-2013 automatically
  27. * [[SimpleCopyright? &startYear=`2007`]]
  28. *
  29. * // Outputs: "&copy; 2004 by [[+site_name]]".
  30. * // Always use \'static\' in conjunction with \'startYear\'.
  31. * // If you use \'static\' only it will ignore it\'s setting and resolve to the current year.
  32. * [[SimpleCopyright? &startYear=`2004` &static=`1`]]
  33. *
  34. * You can also set the separator just for fun...
  35. * It defaults to "-"
  36. *
  37. * This outputs "&copy; 2007/2012"
  38. * [[SimpleCopyright? &startYear=`2007` &separator=`/`]]
  39. *
  40. */
  41. // Get the current year
  42. $currentYear = date(\'Y\');
  43. // Check for a starting year, separator, static & chunk
  44. $startYear = (string) $modx->getOption(\'startYear\', $scriptProperties);
  45. $separator = (string) $modx->getOption(\'separator\', $scriptProperties, \'-\');
  46. $static = (bool) $modx->getOption(\'static\', $scriptProperties, 0);
  47. $tpl = (string) $modx->getOption(\'tpl\', $scriptProperties, \'sc_chunk\');
  48. if($static&&!empty($startYear)){
  49. // is static : can be the future too
  50. $construct = $startYear;
  51. } elseif(!empty($startYear)) {
  52. // is semi dynamic : set with a starting year that never exceeds the future
  53. $construct = ($startYear>=$currentYear ? $currentYear : $startYear.$separator.$currentYear);
  54. } else {
  55. // is dynamic : changes with each year
  56. $construct = $currentYear;
  57. }
  58. // Get a chunk to style the output & check if it exists...
  59. $chunk = $modx->getObject(\'modChunk\',array(
  60. \'name\' => $tpl
  61. ));
  62. if (!$chunk){
  63. // If no chunk is found return error & write to log
  64. $modx->log(xPDO::LOG_LEVEL_ERROR, \'No chunk found!\');
  65. return \'No chunk found!\';
  66. } else {
  67. $outputString = $modx->getChunk($tpl,array(
  68. \'output\' => $construct
  69. ));
  70. }
  71. return $outputString;
  72. return;
  73. ';