| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: |
|
| 19: | defined('XOOPS_ROOT_PATH') || exit('Restricted access');
|
| 20: |
|
| 21: | include_once XOOPS_ROOT_PATH . '/class/xml/saxparser.php';
|
| 22: | include_once XOOPS_ROOT_PATH . '/class/xml/xmltaghandler.php';
|
| 23: |
|
| 24: | |
| 25: | |
| 26: |
|
| 27: | class XoopsThemeSetParser extends SaxParser
|
| 28: | {
|
| 29: | public $tempArr = array();
|
| 30: | public $themeSetData = array();
|
| 31: | public $imagesData = array();
|
| 32: | public $templatesData = array();
|
| 33: |
|
| 34: | |
| 35: | |
| 36: |
|
| 37: | public function __construct(&$input)
|
| 38: | {
|
| 39: | parent::__construct($input);
|
| 40: | $this->addTagHandler(new ThemeSetThemeNameHandler());
|
| 41: | $this->addTagHandler(new ThemeSetDateCreatedHandler());
|
| 42: | $this->addTagHandler(new ThemeSetAuthorHandler());
|
| 43: | $this->addTagHandler(new ThemeSetDescriptionHandler());
|
| 44: | $this->addTagHandler(new ThemeSetGeneratorHandler());
|
| 45: | $this->addTagHandler(new ThemeSetNameHandler());
|
| 46: | $this->addTagHandler(new ThemeSetEmailHandler());
|
| 47: | $this->addTagHandler(new ThemeSetLinkHandler());
|
| 48: | $this->addTagHandler(new ThemeSetTemplateHandler());
|
| 49: | $this->addTagHandler(new ThemeSetImageHandler());
|
| 50: | $this->addTagHandler(new ThemeSetModuleHandler());
|
| 51: | $this->addTagHandler(new ThemeSetFileTypeHandler());
|
| 52: | $this->addTagHandler(new ThemeSetTagHandler());
|
| 53: | }
|
| 54: |
|
| 55: | |
| 56: | |
| 57: | |
| 58: |
|
| 59: | public function setThemeSetData($name, &$value)
|
| 60: | {
|
| 61: | $this->themeSetData[$name] = &$value;
|
| 62: | }
|
| 63: |
|
| 64: | |
| 65: | |
| 66: | |
| 67: | |
| 68: |
|
| 69: | public function &getThemeSetData($name = null)
|
| 70: | {
|
| 71: | if (isset($name)) {
|
| 72: | if (isset($this->themeSetData[$name])) {
|
| 73: | return $this->themeSetData[$name];
|
| 74: | }
|
| 75: |
|
| 76: | return false;
|
| 77: | }
|
| 78: |
|
| 79: | return $this->themeSetData;
|
| 80: | }
|
| 81: |
|
| 82: | |
| 83: | |
| 84: |
|
| 85: | public function setImagesData(&$imagearr)
|
| 86: | {
|
| 87: | $this->imagesData[] = &$imagearr;
|
| 88: | }
|
| 89: |
|
| 90: | |
| 91: | |
| 92: |
|
| 93: | public function &getImagesData()
|
| 94: | {
|
| 95: | return $this->imagesData;
|
| 96: | }
|
| 97: |
|
| 98: | |
| 99: | |
| 100: |
|
| 101: | public function setTemplatesData(&$tplarr)
|
| 102: | {
|
| 103: | $this->templatesData[] = &$tplarr;
|
| 104: | }
|
| 105: |
|
| 106: | |
| 107: | |
| 108: |
|
| 109: | public function &getTemplatesData()
|
| 110: | {
|
| 111: | return $this->templatesData;
|
| 112: | }
|
| 113: |
|
| 114: | |
| 115: | |
| 116: | |
| 117: | |
| 118: |
|
| 119: | public function setTempArr($name, &$value, $delim = '')
|
| 120: | {
|
| 121: | if (!isset($this->tempArr[$name])) {
|
| 122: | $this->tempArr[$name] = &$value;
|
| 123: | } else {
|
| 124: | $this->tempArr[$name] .= $delim . $value;
|
| 125: | }
|
| 126: | }
|
| 127: |
|
| 128: | |
| 129: | |
| 130: |
|
| 131: | public function getTempArr()
|
| 132: | {
|
| 133: | return $this->tempArr;
|
| 134: | }
|
| 135: |
|
| 136: | public function resetTempArr()
|
| 137: | {
|
| 138: | unset($this->tempArr);
|
| 139: | $this->tempArr = array();
|
| 140: | }
|
| 141: | }
|
| 142: |
|
| 143: | |
| 144: | |
| 145: |
|
| 146: | class ThemeSetDateCreatedHandler extends XmlTagHandler
|
| 147: | {
|
| 148: | |
| 149: | |
| 150: |
|
| 151: | public function __construct()
|
| 152: | {
|
| 153: | }
|
| 154: |
|
| 155: | |
| 156: | |
| 157: |
|
| 158: | public function getName()
|
| 159: | {
|
| 160: | return 'dateCreated';
|
| 161: | }
|
| 162: |
|
| 163: | |
| 164: | |
| 165: | |
| 166: |
|
| 167: | public function handleCharacterData($parser, &$data)
|
| 168: | {
|
| 169: | switch ($parser->getParentTag()) {
|
| 170: | case 'themeset':
|
| 171: | $parser->setThemeSetData('date', $data);
|
| 172: | break;
|
| 173: | default:
|
| 174: | break;
|
| 175: | }
|
| 176: | }
|
| 177: | }
|
| 178: |
|
| 179: | |
| 180: | |
| 181: |
|
| 182: | class ThemeSetAuthorHandler extends XmlTagHandler
|
| 183: | {
|
| 184: | |
| 185: | |
| 186: |
|
| 187: | public function __construct()
|
| 188: | {
|
| 189: | }
|
| 190: |
|
| 191: | |
| 192: | |
| 193: |
|
| 194: | public function getName()
|
| 195: | {
|
| 196: | return 'author';
|
| 197: | }
|
| 198: |
|
| 199: | |
| 200: | |
| 201: | |
| 202: |
|
| 203: | public function handleBeginElement($parser, &$attributes)
|
| 204: | {
|
| 205: | $parser->resetTempArr();
|
| 206: | }
|
| 207: |
|
| 208: | |
| 209: | |
| 210: |
|
| 211: | public function handleEndElement($parser)
|
| 212: | {
|
| 213: | $parser->setCreditsData($parser->getTempArr());
|
| 214: | }
|
| 215: | }
|
| 216: |
|
| 217: | |
| 218: | |
| 219: |
|
| 220: | class ThemeSetDescriptionHandler extends XmlTagHandler
|
| 221: | {
|
| 222: | |
| 223: | |
| 224: |
|
| 225: | public function __construct()
|
| 226: | {
|
| 227: | }
|
| 228: |
|
| 229: | |
| 230: | |
| 231: |
|
| 232: | public function getName()
|
| 233: | {
|
| 234: | return 'description';
|
| 235: | }
|
| 236: |
|
| 237: | |
| 238: | |
| 239: | |
| 240: |
|
| 241: | public function handleCharacterData($parser, &$data)
|
| 242: | {
|
| 243: | switch ($parser->getParentTag()) {
|
| 244: | case 'template':
|
| 245: | $parser->setTempArr('description', $data);
|
| 246: | break;
|
| 247: | case 'image':
|
| 248: | $parser->setTempArr('description', $data);
|
| 249: | break;
|
| 250: | default:
|
| 251: | break;
|
| 252: | }
|
| 253: | }
|
| 254: | }
|
| 255: |
|
| 256: | |
| 257: | |
| 258: |
|
| 259: | class ThemeSetGeneratorHandler extends XmlTagHandler
|
| 260: | {
|
| 261: | |
| 262: | |
| 263: |
|
| 264: | public function __construct()
|
| 265: | {
|
| 266: | }
|
| 267: |
|
| 268: | |
| 269: | |
| 270: |
|
| 271: | public function getName()
|
| 272: | {
|
| 273: | return 'generator';
|
| 274: | }
|
| 275: |
|
| 276: | |
| 277: | |
| 278: | |
| 279: |
|
| 280: | public function handleCharacterData($parser, &$data)
|
| 281: | {
|
| 282: | switch ($parser->getParentTag()) {
|
| 283: | case 'themeset':
|
| 284: | $parser->setThemeSetData('generator', $data);
|
| 285: | break;
|
| 286: | default:
|
| 287: | break;
|
| 288: | }
|
| 289: | }
|
| 290: | }
|
| 291: |
|
| 292: | |
| 293: | |
| 294: |
|
| 295: | class ThemeSetNameHandler extends XmlTagHandler
|
| 296: | {
|
| 297: | |
| 298: | |
| 299: |
|
| 300: | public function __construct()
|
| 301: | {
|
| 302: | }
|
| 303: |
|
| 304: | |
| 305: | |
| 306: |
|
| 307: | public function getName()
|
| 308: | {
|
| 309: | return 'name';
|
| 310: | }
|
| 311: |
|
| 312: | |
| 313: | |
| 314: | |
| 315: |
|
| 316: | public function handleCharacterData($parser, &$data)
|
| 317: | {
|
| 318: | switch ($parser->getParentTag()) {
|
| 319: | case 'themeset':
|
| 320: | $parser->setThemeSetData('name', $data);
|
| 321: | break;
|
| 322: | case 'author':
|
| 323: | $parser->setTempArr('name', $data);
|
| 324: | break;
|
| 325: | default:
|
| 326: | break;
|
| 327: | }
|
| 328: | }
|
| 329: | }
|
| 330: |
|
| 331: | |
| 332: | |
| 333: |
|
| 334: | class ThemeSetEmailHandler extends XmlTagHandler
|
| 335: | {
|
| 336: | |
| 337: | |
| 338: |
|
| 339: | public function __construct()
|
| 340: | {
|
| 341: | }
|
| 342: |
|
| 343: | |
| 344: | |
| 345: |
|
| 346: | public function getName()
|
| 347: | {
|
| 348: | return 'email';
|
| 349: | }
|
| 350: |
|
| 351: | |
| 352: | |
| 353: | |
| 354: |
|
| 355: | public function handleCharacterData($parser, &$data)
|
| 356: | {
|
| 357: | switch ($parser->getParentTag()) {
|
| 358: | case 'author':
|
| 359: | $parser->setTempArr('email', $data);
|
| 360: | break;
|
| 361: | default:
|
| 362: | break;
|
| 363: | }
|
| 364: | }
|
| 365: | }
|
| 366: |
|
| 367: | |
| 368: | |
| 369: |
|
| 370: | class ThemeSetLinkHandler extends XmlTagHandler
|
| 371: | {
|
| 372: | |
| 373: | |
| 374: |
|
| 375: | public function __construct()
|
| 376: | {
|
| 377: | }
|
| 378: |
|
| 379: | |
| 380: | |
| 381: |
|
| 382: | public function getName()
|
| 383: | {
|
| 384: | return 'link';
|
| 385: | }
|
| 386: |
|
| 387: | |
| 388: | |
| 389: | |
| 390: |
|
| 391: | public function handleCharacterData($parser, &$data)
|
| 392: | {
|
| 393: | switch ($parser->getParentTag()) {
|
| 394: | case 'author':
|
| 395: | $parser->setTempArr('link', $data);
|
| 396: | break;
|
| 397: | default:
|
| 398: | break;
|
| 399: | }
|
| 400: | }
|
| 401: | }
|
| 402: |
|
| 403: | |
| 404: | |
| 405: |
|
| 406: | class ThemeSetTemplateHandler extends XmlTagHandler
|
| 407: | {
|
| 408: | |
| 409: | |
| 410: |
|
| 411: | public function __construct()
|
| 412: | {
|
| 413: | }
|
| 414: |
|
| 415: | |
| 416: | |
| 417: |
|
| 418: | public function getName()
|
| 419: | {
|
| 420: | return 'template';
|
| 421: | }
|
| 422: |
|
| 423: | |
| 424: | |
| 425: | |
| 426: |
|
| 427: | public function handleBeginElement($parser, &$attributes)
|
| 428: | {
|
| 429: | $parser->resetTempArr();
|
| 430: | $parser->setTempArr('name', $attributes['name']);
|
| 431: | }
|
| 432: |
|
| 433: | |
| 434: | |
| 435: |
|
| 436: | public function handleEndElement($parser)
|
| 437: | {
|
| 438: | $parser->setTemplatesData($parser->getTempArr());
|
| 439: | }
|
| 440: | }
|
| 441: |
|
| 442: | |
| 443: | |
| 444: |
|
| 445: | class ThemeSetImageHandler extends XmlTagHandler
|
| 446: | {
|
| 447: | |
| 448: | |
| 449: |
|
| 450: | public function __construct()
|
| 451: | {
|
| 452: | }
|
| 453: |
|
| 454: | |
| 455: | |
| 456: |
|
| 457: | public function getName()
|
| 458: | {
|
| 459: | return 'image';
|
| 460: | }
|
| 461: |
|
| 462: | |
| 463: | |
| 464: | |
| 465: |
|
| 466: | public function handleBeginElement($parser, &$attributes)
|
| 467: | {
|
| 468: | $parser->resetTempArr();
|
| 469: | $parser->setTempArr('name', $attributes[0]);
|
| 470: | }
|
| 471: |
|
| 472: | |
| 473: | |
| 474: |
|
| 475: | public function handleEndElement($parser)
|
| 476: | {
|
| 477: | $parser->setImagesData($parser->getTempArr());
|
| 478: | }
|
| 479: | }
|
| 480: |
|
| 481: | |
| 482: | |
| 483: |
|
| 484: | class ThemeSetModuleHandler extends XmlTagHandler
|
| 485: | {
|
| 486: | |
| 487: | |
| 488: |
|
| 489: | public function __construct()
|
| 490: | {
|
| 491: | }
|
| 492: |
|
| 493: | |
| 494: | |
| 495: |
|
| 496: | public function getName()
|
| 497: | {
|
| 498: | return 'module';
|
| 499: | }
|
| 500: |
|
| 501: | |
| 502: | |
| 503: | |
| 504: |
|
| 505: | public function handleCharacterData($parser, &$data)
|
| 506: | {
|
| 507: | switch ($parser->getParentTag()) {
|
| 508: | case 'template':
|
| 509: | case 'image':
|
| 510: | $parser->setTempArr('module', $data);
|
| 511: | break;
|
| 512: | default:
|
| 513: | break;
|
| 514: | }
|
| 515: | }
|
| 516: | }
|
| 517: |
|
| 518: | |
| 519: | |
| 520: |
|
| 521: | class ThemeSetFileTypeHandler extends XmlTagHandler
|
| 522: | {
|
| 523: | |
| 524: | |
| 525: |
|
| 526: | public function __construct()
|
| 527: | {
|
| 528: | }
|
| 529: |
|
| 530: | |
| 531: | |
| 532: |
|
| 533: | public function getName()
|
| 534: | {
|
| 535: | return 'fileType';
|
| 536: | }
|
| 537: |
|
| 538: | |
| 539: | |
| 540: | |
| 541: |
|
| 542: | public function handleCharacterData($parser, &$data)
|
| 543: | {
|
| 544: | switch ($parser->getParentTag()) {
|
| 545: | case 'template':
|
| 546: | $parser->setTempArr('type', $data);
|
| 547: | break;
|
| 548: | default:
|
| 549: | break;
|
| 550: | }
|
| 551: | }
|
| 552: | }
|
| 553: |
|
| 554: | |
| 555: | |
| 556: |
|
| 557: | class ThemeSetTagHandler extends XmlTagHandler
|
| 558: | {
|
| 559: | |
| 560: | |
| 561: |
|
| 562: | public function __construct()
|
| 563: | {
|
| 564: | }
|
| 565: |
|
| 566: | |
| 567: | |
| 568: |
|
| 569: | public function getName()
|
| 570: | {
|
| 571: | return 'tag';
|
| 572: | }
|
| 573: |
|
| 574: | |
| 575: | |
| 576: | |
| 577: |
|
| 578: | public function handleCharacterData($parser, &$data)
|
| 579: | {
|
| 580: | switch ($parser->getParentTag()) {
|
| 581: | case 'image':
|
| 582: | $parser->setTempArr('tag', $data);
|
| 583: | break;
|
| 584: | default:
|
| 585: | break;
|
| 586: | }
|
| 587: | }
|
| 588: | }
|
| 589: | |