CMSimple_XH 開発者ドキュメント
PageDataView.php
1 <?php
15 namespace XH;
16 
28 {
34  private $page;
35 
41  private $tabs;
42 
49  public function __construct(array $page, array $tabs = null)
50  {
51  $this->page = $page;
52  $this->tabs = $tabs;
53  }
54 
64  public function tab($title, $filename, $cssClass)
65  {
66  $parts = explode('.', basename($filename), 2);
67  $function = $parts[0];
68  // TODO: use something more appropriate than an anchor
69  return "\n\t" . '<a class="xh_inactive_tab" id="xh_tab_' . $function
70  . '"><span class="'
71  . $cssClass . '">' . $title . '</span></a>';
72  }
73 
79  public function tabs()
80  {
81  $o = "\n" . '<div id="xh_pdtabs">';
82  foreach ($this->tabs as $title => $array) {
83  list($file, $cssClass) = $array;
84  $o .= $this->tab($title, $file, $cssClass);
85  }
86  $o .= "\n</div>";
87  return $o;
88  }
89 
100  public function view($filename)
101  {
102  global $pth, $_XH_csrfProtection;
103 
104  $parts = explode('.', basename($filename), 2);
105  $function = $parts[0];
106  // TODO: use something more appropriate than an anchor
107  $o = "\n" . '<div id="xh_view_' . $function
108  . '" class="xh_inactive_view">'
109  . "\n\t" . '<a class="xh_view_toggle">&nbsp;</a>';
110  if (file_exists($filename)) {
111  include_once $filename;
112  $o .= preg_replace(
113  '/<(?:input|button)[^>]+name\s*=\s*([\'"])save_page_data\1/',
114  $_XH_csrfProtection->tokenInput() . '$0',
115  $function($this->page)
116  );
117  } else {
118  // TODO: i18n; or probably better: use $e/e()
119  $o .= "Could not find " . $filename;
120  }
121  $o .= '<div class="xh_view_status">'
122  . '<img src="' . $pth['folder']['corestyle']
123  . 'ajax-loader-bar.gif" style="display:none" alt="loading">'
124  . '<div></div>'
125  . '</div>';
126  $o .= "\n" . "</div>\n";
127  return $o;
128  }
129 
135  public function views()
136  {
137  $o = "\n" . '<div id="xh_pdviews">';
138  foreach ($this->tabs as $array) {
139  $file = $array[0];
140  $o .= $this->view($file);
141  }
142  $o .= "\n" . '</div>';
143  return $o;
144  }
145 }
tab($title, $filename, $cssClass)
$function
Definition: cms.php:473
view($filename)
$title
Definition: cms.php:100
$file
Definition: cms.php:640
$o
Definition: cms.php:113
foreach(XH_plugins() as $plugin) $_XH_csrfProtection
Definition: cms.php:879
$pth
Definition: cms.php:230
__construct(array $page, array $tabs=null)