Changeset 558158
- Timestamp:
- 06/14/2012 08:38:59 PM (14 years ago)
- Location:
- templ33t/branches/01_02_handling_posts
- Files:
-
- 2 edited
-
templ33t.php (modified) (1 diff)
-
templ33t_object.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
templ33t/branches/01_02_handling_posts/templ33t.php
r558108 r558158 101 101 102 102 global $templ33t; 103 103 104 if(Templ33t::$preview_mode) { 105 $value .= '<!-- TEMPL33T_OPTION_PREVIEW: '.$option.' -->'; 106 } 107 104 108 if(array_key_exists($option, $templ33t->option_objects)) { 105 109 return $templ33t->option_objects[$option] instanceOf Templ33tOption ? $templ33t->option_objects[$option]->getValue() : $templ33t->option_objects[$option]->value; -
templ33t/branches/01_02_handling_posts/templ33t_object.php
r558151 r558158 575 575 } 576 576 577 function parseTemplate($template = null, $theme = null ) {577 function parseTemplate($template = null, $theme = null, $orig = array()) { 578 578 579 579 // catch invalid file … … 643 643 if(!is_wp_error($preview)) { 644 644 645 $matches = array(); 646 preg_match_all('/\<\!\-\-\s*TEMPL33T\_BLOCK\_PREVIEW\:\s*(.*)\s*\-\-\>/i', $preview['body'], $matches); 647 648 echo '<pre>'.print_r($matches, true).'</pre>'; 649 650 651 652 die(); 645 $block_matches = array(); 646 preg_match_all('/\<\!\-\-\s*TEMPL33T\_BLOCK\_PREVIEW\:\s*(.*)\s*\-\-\>/i', $preview['body'], $block_matches); 647 648 $option_matches = array(); 649 preg_match_all('/\<\!\-\-\s*TEMPL33T\_OPTION\_PREVIEW\:\s*(.*)\s*\-\-\>/i', $preview['body'], $option_matches); 650 651 652 // handle blocks 653 if(!empty($block_matches[1])) { 654 655 $blocks = array(); 656 657 foreach($block_matches[1] as $slug) { 658 659 $slug = trim(chop(strtolower($slug))); 660 661 if(!array_key_exists($slug, $blocks)) { 662 663 if(!empty($orig) && array_key_exists($slug, $orig['blocks'])) { 664 665 $blocks[$slug] = array_merge( 666 $this->config_defaults, 667 $orig['blocks'][$slug], 668 array( 669 'slug' => $slug, 670 'label' => ucwords(str_replace('_', ' ', str_replace('-', ' ', $slug))) 671 ) 672 ); 673 674 } else { 675 676 $blocks[$slug] = array_merge( 677 $this->config_defaults, 678 array( 679 'slug' => $slug, 680 'label' => ucwords(str_replace('_', ' ', str_replace('-', ' ', $slug))) 681 ) 682 ); 683 684 } 685 686 687 688 } 689 690 } 691 692 } 693 694 // handle options 695 if(!empty($option_matches[1])) { 696 697 $options = array(); 698 699 foreach($option_matches[1] as $slug) { 700 701 $slug = trim(chop(strtolower($slug))); 702 703 if(!array_key_exists($slug, $options)) { 704 705 if(!empty($orig) && array_key_exists($slug, $orig['options'])) { 706 707 $blocks[$slug] = array_merge( 708 $this->config_defaults, 709 $orig['options'][$slug], 710 array( 711 'slug' => $slug, 712 'label' => ucwords(str_replace('_', ' ', str_replace('-', ' ', $slug))) 713 ) 714 ); 715 716 } else { 717 718 $blocks[$slug] = array_merge( 719 $this->config_defaults, 720 array( 721 'slug' => $slug, 722 'label' => ucwords(str_replace('_', ' ', str_replace('-', ' ', $slug))) 723 ) 724 ); 725 726 } 727 728 729 730 } 731 732 } 733 734 } 735 736 if(!empty($blocks) || !empty($options)) { 737 738 $config = array( 739 'main' => (!empty($orig) ? $orig['main'] : 'Page Content'), 740 'description' => (!empty($orig) ? $orig['description'] : ''), 741 'blocks' => $blocks, 742 'options' => $options 743 ); 744 745 echo '<pre>'.print_r($config, true).'</pre>'; 746 747 die(); 748 749 } else { 750 751 return false; 752 753 } 653 754 654 755 } else { … … 1772 1873 1773 1874 // grab templ33t config 1774 $config = $this->parseTemplate($tfile, $temp['theme'] );1875 $config = $this->parseTemplate($tfile, $temp['theme'], unserialize($temp['config'])); 1775 1876 1776 1877 if (!empty($config)) {
Note: See TracChangeset
for help on using the changeset viewer.