added views api

This commit is contained in:
arzynik 2013-08-06 10:05:31 -07:00
parent 33d9181865
commit 0ca08deffd
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<?php
class Controller_api_views extends Crunchbutton_Controller_Rest {
public function init() {
foreach (new DirectoryIterator(c::config()->dirs->view.'default/crunchbutton/frontend') as $fileInfo) {
if (!$fileInfo->isDot()) {
$files[] = $fileInfo->getBasename('.phtml');
}
}
echo json_encode($files);
}
}

View File

@ -0,0 +1,14 @@
<?php
class Controller_view extends Cana_Controller {
public function init() {
$file = preg_replace('/\.html/','',c::getPagePiece(1));
$file = preg_replace('/[^a-z]/','',$file);
$file = c::config()->dirs->view.'default/crunchbutton/frontend/'.$file.'.phtml';
if (file_exists($file)) {
echo file_get_contents($file);
}
exit;
}
}