61be958a3ee5f5943dd0a0e0656088bfda070fee

Author: gwoo

Date: 2009-01-27 08:13:18 -0800

some rafctoring and moving around

diff --git a/README b/README index c8d37f8..52ae006 100644 --- a/README +++ b/README @@ -37,4 +37,4 @@ Usage: ----------- cake api_index initdb cake api_index update -visit, http://localohst/api_generator/api_pages/browse_files \ No newline at end of file +visit, http://localohst/api_generator/classes \ No newline at end of file diff --git a/api_generator_app_controller.php b/api_generator_app_controller.php index 0a51648..5ee7f9d 100644 --- a/api_generator_app_controller.php +++ b/api_generator_app_controller.php @@ -27,11 +27,15 @@ */ class ApiGeneratorAppController extends AppController { /** - * Use Api Layout + * theme * - * @var string - **/ - public $layout = 'api'; + **/ + public $theme = 'api'; +/** + * view + * + **/ + public $view = 'Theme'; /** * beforeFilter callback * @@ -46,7 +50,7 @@ class ApiGeneratorAppController extends AppController { $this->ApiConfig->data['paths'][$path] = true; } $path = Folder::slashTerm($path); - $this->path = $path; + $this->path = realpath($path); } /** * Error Generating Page. diff --git a/controllers/api_generator_controller.php b/controllers/api_generator_controller.php index 3355838..0988720 100644 --- a/controllers/api_generator_controller.php +++ b/controllers/api_generator_controller.php @@ -3,7 +3,7 @@ /** * Api Generator Controller * - * + * * * PHP versions 4 and 5 * @@ -20,24 +20,188 @@ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake * @subpackage cake. - * @version - * @modifiedby - * @lastmodified + * @version + * @modifiedby + * @lastmodified * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ class ApiGeneratorController extends ApiGeneratorAppController { /** - * uses + * Name property + * + * @var string + */ + public $name = 'ApiGenerator'; +/** + * Uses array + * + * @var array + */ + public $uses = array('ApiGenerator.ApiFile'); +/** + * Components array * * @var array **/ - public $uses = array(); + public $components = array('RequestHandler'); +/** + * Helpers + * + * @var array + **/ + public $helpers = array('ApiGenerator.ApiDoc', 'ApiGenerator.ApiUtils', 'Html', 'Javascript'); +/** + * Browse application files and find things you would like to generate API docs for. + * + * @return void + **/ + public function index() { + $this->classes(); + if (!empty($this->viewVars['classIndex'])) { + $this->render('classes'); + return; + } + } + +/** + * Browse application files and find things you would like to generate API docs for. + * + * @return void + **/ + public function source() { + $currentPath = implode('/', $this->passedArgs); + $previousPath = implode('/', array_slice($this->passedArgs, 0, count($this->passedArgs) -1)); + list($dirs, $files) = $this->ApiFile->read($this->path . $currentPath); + $this->set(compact('dirs', 'files', 'currentPath', 'previousPath')); + } + +/** + * all_files + * + * Gets a recursive list of all files that match documentor criteria. + * + * @access public + * @return void + */ + public function files() { + $files = $this->ApiFile->fileList($this->path); + $this->set('files', $files); + } + +/** + * Browse the classes in the application / API files. + * + * @return void + **/ + public function classes() { + $this->ApiClass = ClassRegistry::init('ApiGenerator.ApiClass'); + $classIndex = $this->ApiClass->getClassIndex(); + $this->set('classIndex', $classIndex); + } + +/** + * View the API docs for all interesting parts in a file. + * + * @return void + **/ + public function view_file() { + $currentPath = implode('/', $this->passedArgs); + $fullPath = $this->path . $currentPath; + $previousPath = implode('/', array_slice($this->passedArgs, 0, count($this->passedArgs) -1)); + $upOneFolder = implode('/', array_slice($this->passedArgs, 0, count($this->passedArgs) -2)); + + if (!file_exists($fullPath)) { + $this->_notFound(__('No file exists with that name', true)); + } + try { + $docs = $this->ApiFile->loadFile($fullPath); + } catch(Exception $e) { + $this->_notFound($e->getMessage()); + } + + $classIndex = ClassRegistry::init('ApiGenerator.ApiClass')->getClassIndex(); + list($dirs, $files) = $this->ApiFile->read($this->path . $previousPath); + + if (!empty($docs)) { + $this->set('showSidebar', true); + $this->set('sidebarElement', 'sidebar/file_sidebar'); + $this->set(compact('currentPath', 'previousPath', 'upOneFolder', 'docs', 'dirs', 'files', 'classIndex')); + } else { + $this->set('previousPath', $previousPath); + $this->render('no_class'); + } + } + +/** + * View API docs for a single class used with browse_classes + * + * @return void + **/ + public function view_class($classSlug = null) { + if (!$classSlug) { + $this->Session->setFlash(__('No class name was given', true)); + $this->redirect($this->referer()); + } + $this->ApiClass = ClassRegistry::init('ApiGenerator.ApiClass'); + $classInfo = $this->ApiClass->findBySlug($classSlug); + + if (empty($classInfo['ApiClass']['file_name'])) { + $this->_notFound(__('No class exists in the index with that name', true)); + } + try { + $docs = $this->ApiFile->loadFile($classInfo['ApiClass']['file_name']); + $doc = $docs['class'][$classInfo['ApiClass']['name']]; + } catch(Exception $e) { + $this->_notFound($e->getMessage()); + } + + $classIndex = $this->ApiClass->getClassIndex(); + if (!empty($docs)) { + $this->set('showSidebar', true); + $this->set('sidebarElement', 'sidebar/class_sidebar'); + $this->set(compact('doc', 'classIndex')); + } else { + $this->_notFound(__("Oops, seems we couldn't get the documentation for that class.", true)); + } + } +/** + * View the Source for a file. + * + * @return void + **/ + public function view_source($classSlug = null) { + $this->ApiClass = ClassRegistry::init('ApiGenerator.ApiClass'); + $classInfo = $this->ApiClass->findBySlug($classSlug); + + if (empty($classInfo['ApiClass']['file_name'])) { + $this->_notFound(__('No class exists in the index with that name', true)); + } + $fileContents = file_get_contents($classInfo['ApiClass']['file_name']); + $this->set('contents', $fileContents); + $this->set('filename', $classInfo['ApiClass']['file_name']); + } +/** + * Search through the class index. + * + * @return void + **/ + public function search() { + $results = array(); + $this->ApiClass = ClassRegistry::init('ApiGenerator.ApiClass'); + $classIndex = $this->ApiClass->getClassIndex(); + if (isset($this->params['url']['query'])) { + $query = $this->params['url']['query']; + $results = $this->paginate('ApiClass', array('ApiClass.search_index LIKE' => '%' . $query . '%')); + } + $this->set(compact('results', 'classIndex')); + } /** - * Show the 'home page' + * Extract all the useful config info out of the ApiConfig. * * @return void **/ - function index() { - //do nothing! + public function beforeRender() { + $this->set('basePath', $this->path); + $this->set($this->ApiFile->getExclusions()); } } \ No newline at end of file diff --git a/controllers/api_pages_controller.php b/controllers/api_pages_controller.php deleted file mode 100644 index d7aa33f..0000000 --- a/controllers/api_pages_controller.php +++ /dev/null @@ -1,196 +0,0 @@ -<?php -/* SVN FILE: $Id$ */ -/** - * Api Pages Controller - * - * Handles the browsing and API docs generation for all files in an app. - * - * PHP versions 5 - * - * CakePHP : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2006-2008, Cake Software Foundation, Inc. - * 1785 E. Sahara Avenue, Suite 490-204 - * Las Vegas, Nevada 89104 - * - * Licensed under The MIT License - * Redistributions of files must retain the above copyright notice. - * - * @filesource - * @copyright Copyright 2006-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project - * @package cake - * @subpackage cake.api_generator.controllers - * @since - * @version - * @modifiedby - * @lastmodified - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -class ApiPagesController extends ApiGeneratorAppController { -/** - * Name property - * - * @var string - */ - public $name = 'ApiPages'; -/** - * Uses array - * - * @var array - */ - public $uses = array('ApiGenerator.ApiFile'); -/** - * Components array - * - * @var array - **/ - public $components = array('RequestHandler'); -/** - * Helpers - * - * @var array - **/ - public $helpers = array('ApiGenerator.ApiDoc', 'ApiGenerator.ApiUtils', 'Html', 'Javascript'); -/** - * Browse application files and find things you would like to generate API docs for. - * - * @return void - **/ - public function browse_files() { - $currentPath = implode('/', $this->passedArgs); - $previousPath = implode('/', array_slice($this->passedArgs, 0, count($this->passedArgs) -1)); - list($dirs, $files) = $this->ApiFile->read($this->path . $currentPath); - $this->set(compact('dirs', 'files', 'currentPath', 'previousPath')); - } - -/** - * all_files - * - * Gets a recursive list of all files that match documentor criteria. - * - * @access public - * @return void - */ - public function list_files() { - $files = $this->ApiFile->fileList($this->path); - $this->set('files', $files); - } - -/** - * Browse the classes in the application / API files. - * - * @return void - **/ - public function browse_classes() { - $this->ApiClass = ClassRegistry::init('ApiGenerator.ApiClass'); - $classIndex = $this->ApiClass->getClassIndex(); - $this->set('classIndex', $classIndex); - } - -/** - * View the API docs for all interesting parts in a file. - * - * @return void - **/ - public function view_file() { - $currentPath = implode('/', $this->passedArgs); - $fullPath = $this->path . $currentPath; - $previousPath = implode('/', array_slice($this->passedArgs, 0, count($this->passedArgs) -1)); - $upOneFolder = implode('/', array_slice($this->passedArgs, 0, count($this->passedArgs) -2)); - - if (!file_exists($fullPath)) { - $this->_notFound(__('No file exists with that name', true)); - } - try { - $docs = $this->ApiFile->loadFile($fullPath); - } catch(Exception $e) { - $this->_notFound($e->getMessage()); - } - - $classIndex = ClassRegistry::init('ApiGenerator.ApiClass')->getClassIndex(); - list($dirs, $files) = $this->ApiFile->read($this->path . $previousPath); - - if (!empty($docs)) { - $this->set('showSidebar', true); - $this->set('sidebarElement', 'sidebar/file_sidebar'); - $this->set(compact('currentPath', 'previousPath', 'upOneFolder', 'docs', 'dirs', 'files', 'classIndex')); - } else { - $this->set('previousPath', $previousPath); - $this->render('no_class'); - } - } - -/** - * View API docs for a single class used with browse_classes - * - * @return void - **/ - public function view_class($classSlug = null) { - if (!$classSlug) { - $this->Session->setFlash(__('No class name was given', true)); - $this->redirect($this->referer()); - } - $this->ApiClass = ClassRegistry::init('ApiGenerator.ApiClass'); - $classInfo = $this->ApiClass->findBySlug($classSlug); - - if (empty($classInfo['ApiClass']['file_name'])) { - $this->_notFound(__('No class exists in the index with that name', true)); - } - try { - $docs = $this->ApiFile->loadFile($classInfo['ApiClass']['file_name']); - $doc = $docs['class'][$classInfo['ApiClass']['name']]; - } catch(Exception $e) { - $this->_notFound($e->getMessage()); - } - - $classIndex = $this->ApiClass->getClassIndex(); - if (!empty($docs)) { - $this->set('showSidebar', true); - $this->set('sidebarElement', 'sidebar/class_sidebar'); - $this->set(compact('doc', 'classIndex')); - } else { - $this->_notFound(__("Oops, seems we couldn't get the documentation for that class.", true)); - } - } -/** - * View the Source for a file. - * - * @return void - **/ - public function view_source($classSlug = null) { - $this->ApiClass = ClassRegistry::init('ApiGenerator.ApiClass'); - $classInfo = $this->ApiClass->findBySlug($classSlug); - - if (empty($classInfo['ApiClass']['file_name'])) { - $this->_notFound(__('No class exists in the index with that name', true)); - } - $fileContents = file_get_contents($classInfo['ApiClass']['file_name']); - $this->set('contents', $fileContents); - $this->set('filename', $classInfo['ApiClass']['file_name']); - } -/** - * Search through the class index. - * - * @return void - **/ - public function search() { - $results = array(); - $this->ApiClass = ClassRegistry::init('ApiGenerator.ApiClass'); - $classList = $this->ApiClass->getClassIndex(); - if (isset($this->params['url']['query'])) { - $query = $this->params['url']['query']; - $results = $this->paginate('ApiClass', array('ApiClass.search_index LIKE' => '%' . $query . '%')); - } - $this->set(compact('results', 'classList')); - } -/** - * Extract all the useful config info out of the ApiConfig. - * - * @return void - **/ - public function beforeRender() { - $this->set('basePath', $this->path); - $this->set($this->ApiFile->getExclusions()); - } -} -?> \ No newline at end of file diff --git a/tests/cases/helpers/api_doc.test.php b/tests/cases/helpers/api_doc.test.php index d4bbac1..dd48b8c 100644 --- a/tests/cases/helpers/api_doc.test.php +++ b/tests/cases/helpers/api_doc.test.php @@ -80,7 +80,7 @@ class ApiDocHelperTestCase extends CakeTestCase { $result = $this->ApiDoc->fileLink('/cake/tests/my/path'); $expected = array( - 'a' => array('href' => '/api_generator/api_pages/view_file/my/path'), + 'a' => array('href' => '/api_generator/view_file/my/path'), 'my/path', '/a' ); diff --git a/vendors/css/base.css b/vendors/css/base.css index e653abf..9e3ad62 100644 --- a/vendors/css/base.css +++ b/vendors/css/base.css @@ -154,16 +154,16 @@ h3 { #header h1 a { color:#fff; } -#navigation { +.api .navigation { padding: 1em 5% 0; height:36px; clear: both; } -#navigation li { +.api .navigation li { float: left; margin: 0 2px; } -#navigation li a { +.api .navigation li a { padding: 10px 3em; line-height: 16px; font-size: 16px; @@ -171,7 +171,7 @@ h3 { text-decoration: none; color:#fff; } -#navigation li a:hover { +.api .navigation li a:hover { text-decoration:underline; } #header-search { @@ -478,6 +478,15 @@ ol.code li code { color: #c30; } - - +/** +* Search results +****************************/ +#search-results { + margin: 10px; + padding: 4px 0; +} +#search-results li { + margin: 20px 10px; + font-size: 140%; +} diff --git a/views/api_generator/classes.ctp b/views/api_generator/classes.ctp new file mode 100644 index 0000000..c23d32a --- /dev/null +++ b/views/api_generator/classes.ctp @@ -0,0 +1,47 @@ +<?php +/** + * Browse Classes View file + * + */ +$letterIndex = array_flip(range('A', 'Z')); + +foreach ($classIndex as $slug => $name): + $firstLetter = strtoupper(substr($name, 0, 1)); + if (!is_array($letterIndex[$firstLetter])): + $letterIndex[$firstLetter] = array(); + endif; + $letterIndex[$firstLetter][$slug] = $name; +endforeach; +?> +<h1><?php __('Index'); ?></h1> + +<div class="letter-links"> +<?php +foreach (array_keys($letterIndex) as $letter): + if (!is_array($letterIndex[$letter])) { + echo '<span>' . $letter . '</span>'; + } else { + echo $html->link($letter, '#letter-' . $letter); + } +endforeach; +?> +</div> +<?php $letterChunks = array_chunk($letterIndex, floor(count($letterIndex)/3), true); ?> +<?php foreach ($letterChunks as $column => $letterList): ?> + <div class="letter-section"> + <?php foreach ($letterList as $letter => $classes): ?> + <?php if (is_array($classes)): ?> + <h3><a id="letter-<?php echo $letter; ?>"></a><?php echo $letter; ?></h3> + <ul class="class-index"> + <?php foreach ($classes as $slug => $name): ?> + <li><?php + echo $html->link($name, array( + 'plugin' => 'api_generator', 'controller' => 'api_generator', + 'action' => 'view_class', $slug)); + ?></li> + <?php endforeach; ?> + </ul> + <?php endif; ?> + <?php endforeach; ?> + </div> +<?php endforeach; ?> \ No newline at end of file diff --git a/views/api_generator/files.ctp b/views/api_generator/files.ctp new file mode 100644 index 0000000..8176f58 --- /dev/null +++ b/views/api_generator/files.ctp @@ -0,0 +1,20 @@ +<?php +/** + * Recursive Listing of all allowed files. + * + */ +?> +<h1><?php __('All files')?></h1> +<ul id="file-list"> +<?php if (!empty($files)): ?> +<?php foreach ($files as $file): ?> + <li class="file"> + <?php echo $apiDoc->fileLink($file); ?> + </li> +<?php endforeach; ?> +<?php else: ?> + <li class="file"> + <?php __('No files'); ?> + </li> +<?php endif; ?> +</ul> \ No newline at end of file diff --git a/views/api_generator/no_class.ctp b/views/api_generator/no_class.ctp new file mode 100644 index 0000000..3d4ab18 --- /dev/null +++ b/views/api_generator/no_class.ctp @@ -0,0 +1,10 @@ +<?php +/** + * No class view file. Displayed when no class is found. + * + */ +?> +<h2><?php __('No classes were found in the requested file'); ?></h2> +<p class="folder"> + <?php echo $html->link('Up one folder', array('action' => 'browse_files', $previousPath)); ?> +</p> diff --git a/views/api_generator/search.ctp b/views/api_generator/search.ctp new file mode 100644 index 0000000..c937ef7 --- /dev/null +++ b/views/api_generator/search.ctp @@ -0,0 +1,20 @@ +<?php +/** + * Api Search results + * + */ + +$apiDoc->setClassIndex($classIndex); + +?> +<h1><?php __('Search Results'); ?></h1> +<?php if (empty($results)): ?> + <p class="error"><?php __('Your search returned no results'); ?></p> +<?php else: ?> +<ul id="search-results"> + <?php foreach ($results as $result): ?> + <li><?php echo $apiDoc->classLink($result['ApiClass']['name']); ?> + <?php endforeach;?> +</ul> +<?php endif; ?> +<?php echo $this->element('paging'); ?> \ No newline at end of file diff --git a/views/api_generator/source.ctp b/views/api_generator/source.ctp new file mode 100644 index 0000000..7f02930 --- /dev/null +++ b/views/api_generator/source.ctp @@ -0,0 +1,35 @@ +<?php +/* SVN FILE: $Id$ */ +/** + * Browse view. Shows file listings and provides links to obtaining api docs from a file + * Doubles as an ajax view by omitting certain tags when params['isAjax'] is set. + */ +?> +<?php if (!$this->params['isAjax']): ?> +<h1 class="breadcrumb"><?php echo $this->element('breadcrumb'); ?></h1> +<ul id="file-list"> +<?php endif; ?> + + <li class="folder previous-folder"> + <?php echo $html->link('Up one folder', array('action' => 'browse_files', $previousPath)); ?> + </li> +<?php foreach ($dirs as $dir): ?> + <li class="folder"> + <?php echo $html->link($dir, array('action' => 'browse_files', $currentPath . '/' . $dir)); ?> + </li> +<?php endforeach; ?> +<?php if (!empty($files)): ?> +<?php foreach ($files as $file): ?> + <li class="file"> + <?php echo $html->link($file, array('action' => 'view_file', $currentPath . '/' . $file)); ?> + </li> +<?php endforeach; ?> +<?php else: ?> + <li class="file"> + <?php __('No files'); ?> + </li> +<?php endif; ?> + +<?php if (!$this->params['isAjax']): ?> +</ul> +<?php endif; ?> \ No newline at end of file diff --git a/views/api_generator/view_class.ctp b/views/api_generator/view_class.ctp new file mode 100644 index 0000000..f307a1c --- /dev/null +++ b/views/api_generator/view_class.ctp @@ -0,0 +1,12 @@ +<?php +/** + * View a single class + * + */ +$apiDoc->setClassIndex($classIndex); + +echo $this->element('class_info'); +echo $this->element('properties'); +echo $this->element('method_summary'); +echo $this->element('method_detail'); +?> \ No newline at end of file diff --git a/views/api_generator/view_file.ctp b/views/api_generator/view_file.ctp new file mode 100644 index 0000000..5ec4ceb --- /dev/null +++ b/views/api_generator/view_file.ctp @@ -0,0 +1,27 @@ +<?php +/* SVN FILE: $Id$ */ +/** + * View view. Shows generated api docs from a file. + * + */ +$apiDoc->setClassIndex($classIndex); +?> +<h1 class="breadcrumb"><?php echo $this->element('breadcrumb'); ?></h1> +<?php +echo $this->element('element_toc'); + +if (!empty($docs['function'])) : + foreach ($docs['function'] as &$function): + echo $this->element('function_summary', array('doc' => $function)); + endforeach; +endif; + +if (!empty($docs['class'])): + foreach ($docs['class'] as $class): + echo $this->element('class_info', array('doc' => $class)); + echo $this->element('properties', array('doc' => $class)); + echo $this->element('method_summary', array('doc' => $class)); + echo $this->element('method_detail', array('doc' => $class)); + endforeach; +endif; +?> diff --git a/views/api_generator/view_source.ctp b/views/api_generator/view_source.ctp new file mode 100644 index 0000000..37fa9b3 --- /dev/null +++ b/views/api_generator/view_source.ctp @@ -0,0 +1,9 @@ +<?php +/** + * View the source code for a file. + * + */ +?> +<h1><?php echo $filename; ?></h1> + +<?php echo $apiUtils->highlight($contents); ?> diff --git a/views/api_pages/browse_classes.ctp b/views/api_pages/browse_classes.ctp deleted file mode 100644 index e0c8c05..0000000 --- a/views/api_pages/browse_classes.ctp +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/** - * Browse Classes View file - * - */ -$letterIndex = array_flip(range('A', 'Z')); - -foreach ($classIndex as $slug => $name): - $firstLetter = strtoupper(substr($name, 0, 1)); - if (!is_array($letterIndex[$firstLetter])): - $letterIndex[$firstLetter] = array(); - endif; - $letterIndex[$firstLetter][$slug] = $name; -endforeach; -?> -<h1><?php __('Class Index'); ?></h1> - -<div class="letter-links"> -<?php -foreach (array_keys($letterIndex) as $letter): - if (!is_array($letterIndex[$letter])) { - echo '<span>' . $letter . '</span>'; - } else { - echo $html->link($letter, '#letter-' . $letter); - } -endforeach; -?> -</div> -<?php $letterChunks = array_chunk($letterIndex, floor(count($letterIndex)/3), true); ?> -<?php foreach ($letterChunks as $column => $letterList): ?> - <div class="letter-section"> - <?php foreach ($letterList as $letter => $classes): ?> - <?php if (is_array($classes)): ?> - <h3><a id="letter-<?php echo $letter; ?>"></a><?php echo $letter; ?></h3> - <ul class="class-index"> - <?php foreach ($classes as $slug => $name): ?> - <li><?php echo $html->link($name, array('plugin' => 'api_generator', 'controller' => 'api_pages', 'action' => 'view_class', $slug)); ?></li> - <?php endforeach; ?> - </ul> - <?php endif; ?> - <?php endforeach; ?> - </div> -<?php endforeach; ?> \ No newline at end of file diff --git a/views/api_pages/browse_files.ctp b/views/api_pages/browse_files.ctp deleted file mode 100644 index 7f02930..0000000 --- a/views/api_pages/browse_files.ctp +++ /dev/null @@ -1,35 +0,0 @@ -<?php -/* SVN FILE: $Id$ */ -/** - * Browse view. Shows file listings and provides links to obtaining api docs from a file - * Doubles as an ajax view by omitting certain tags when params['isAjax'] is set. - */ -?> -<?php if (!$this->params['isAjax']): ?> -<h1 class="breadcrumb"><?php echo $this->element('breadcrumb'); ?></h1> -<ul id="file-list"> -<?php endif; ?> - - <li class="folder previous-folder"> - <?php echo $html->link('Up one folder', array('action' => 'browse_files', $previousPath)); ?> - </li> -<?php foreach ($dirs as $dir): ?> - <li class="folder"> - <?php echo $html->link($dir, array('action' => 'browse_files', $currentPath . '/' . $dir)); ?> - </li> -<?php endforeach; ?> -<?php if (!empty($files)): ?> -<?php foreach ($files as $file): ?> - <li class="file"> - <?php echo $html->link($file, array('action' => 'view_file', $currentPath . '/' . $file)); ?> - </li> -<?php endforeach; ?> -<?php else: ?> - <li class="file"> - <?php __('No files'); ?> - </li> -<?php endif; ?> - -<?php if (!$this->params['isAjax']): ?> -</ul> -<?php endif; ?> \ No newline at end of file diff --git a/views/api_pages/list_files.ctp b/views/api_pages/list_files.ctp deleted file mode 100644 index 8176f58..0000000 --- a/views/api_pages/list_files.ctp +++ /dev/null @@ -1,20 +0,0 @@ -<?php -/** - * Recursive Listing of all allowed files. - * - */ -?> -<h1><?php __('All files')?></h1> -<ul id="file-list"> -<?php if (!empty($files)): ?> -<?php foreach ($files as $file): ?> - <li class="file"> - <?php echo $apiDoc->fileLink($file); ?> - </li> -<?php endforeach; ?> -<?php else: ?> - <li class="file"> - <?php __('No files'); ?> - </li> -<?php endif; ?> -</ul> \ No newline at end of file diff --git a/views/api_pages/no_class.ctp b/views/api_pages/no_class.ctp deleted file mode 100644 index 3d4ab18..0000000 --- a/views/api_pages/no_class.ctp +++ /dev/null @@ -1,10 +0,0 @@ -<?php -/** - * No class view file. Displayed when no class is found. - * - */ -?> -<h2><?php __('No classes were found in the requested file'); ?></h2> -<p class="folder"> - <?php echo $html->link('Up one folder', array('action' => 'browse_files', $previousPath)); ?> -</p> diff --git a/views/api_pages/search.ctp b/views/api_pages/search.ctp deleted file mode 100644 index 2df4a92..0000000 --- a/views/api_pages/search.ctp +++ /dev/null @@ -1,18 +0,0 @@ -<?php -/** - * Api Search results - * - */ -$apiDoc->setClassIndex($classIndex); -?> -<h1><?php __('Search Results'); ?></h1> -<?php if (empty($results)): ?> - <p class="error"><?php __('Your search returned no results'); ?></p> -<?php else: ?> -<ul id="search-results"> - <?php foreach ($results as $result): ?> - <li><?php echo $apiDoc->classLink($result['ApiClass']['name']); ?> - <?php endforeach;?> -</ul> -<?php endif; ?> -<?php echo $this->element('paging'); ?> \ No newline at end of file diff --git a/views/api_pages/view_class.ctp b/views/api_pages/view_class.ctp deleted file mode 100644 index f307a1c..0000000 --- a/views/api_pages/view_class.ctp +++ /dev/null @@ -1,12 +0,0 @@ -<?php -/** - * View a single class - * - */ -$apiDoc->setClassIndex($classIndex); - -echo $this->element('class_info'); -echo $this->element('properties'); -echo $this->element('method_summary'); -echo $this->element('method_detail'); -?> \ No newline at end of file diff --git a/views/api_pages/view_file.ctp b/views/api_pages/view_file.ctp deleted file mode 100644 index 5ec4ceb..0000000 --- a/views/api_pages/view_file.ctp +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/* SVN FILE: $Id$ */ -/** - * View view. Shows generated api docs from a file. - * - */ -$apiDoc->setClassIndex($classIndex); -?> -<h1 class="breadcrumb"><?php echo $this->element('breadcrumb'); ?></h1> -<?php -echo $this->element('element_toc'); - -if (!empty($docs['function'])) : - foreach ($docs['function'] as &$function): - echo $this->element('function_summary', array('doc' => $function)); - endforeach; -endif; - -if (!empty($docs['class'])): - foreach ($docs['class'] as $class): - echo $this->element('class_info', array('doc' => $class)); - echo $this->element('properties', array('doc' => $class)); - echo $this->element('method_summary', array('doc' => $class)); - echo $this->element('method_detail', array('doc' => $class)); - endforeach; -endif; -?> diff --git a/views/api_pages/view_source.ctp b/views/api_pages/view_source.ctp deleted file mode 100644 index 37fa9b3..0000000 --- a/views/api_pages/view_source.ctp +++ /dev/null @@ -1,9 +0,0 @@ -<?php -/** - * View the source code for a file. - * - */ -?> -<h1><?php echo $filename; ?></h1> - -<?php echo $apiUtils->highlight($contents); ?> diff --git a/views/elements/api_menu.ctp b/views/elements/api_menu.ctp index 3c00900..d202157 100644 --- a/views/elements/api_menu.ctp +++ b/views/elements/api_menu.ctp @@ -1,14 +1,23 @@ -<ul id="navigation"> - <li><?php echo $html->link(__('Api Home', true), - array('plugin' => 'api_generator', 'controller' => 'api_generator', 'action' => 'index')); ?> +<ul class="navigation"> + <li><?php + $class = ($this->action == 'classes') ? array('class' => 'on') : null; + echo $html->link(__('Classes', true), array( + 'plugin' => 'api_generator', + 'controller' => 'api_generator', 'action' => 'classes' + ), $class);?> </li> - <li><?php echo $html->link(__('Browse Files', true), - array('controller' => 'api_pages', 'action' => 'browse_files')); ?> + <li><?php + $class = ($this->action == 'source') ? array('class' => 'on') : null; + echo $html->link(__('Source', true), array( + 'plugin' => 'api_generator', + 'controller' => 'api_generator', 'action' => 'source' + ), $class);?> </li> - <li><?php echo $html->link(__('File List', true), - array('controller' => 'api_pages', 'action' => 'list_files')); ?> - </li> - <li><?php echo $html->link(__('Browse Classes', true), - array('controller' => 'api_pages', 'action' => 'browse_classes')); ?> + <li><?php + $class = ($this->action == 'files') ? array('class' => 'on') : null; + echo $html->link(__('Files', true), array( + 'plugin' => 'api_generator', + 'controller' => 'api_generator', 'action' => 'files' + ), $class);?> </li> </ul> \ No newline at end of file diff --git a/views/elements/header_search.ctp b/views/elements/header_search.ctp index c492c87..26d010d 100644 --- a/views/elements/header_search.ctp +++ b/views/elements/header_search.ctp @@ -4,16 +4,20 @@ * */ ?> +<div id="header-search"> <?php echo $form->create('ApiClass', array( - 'url' => array('controller' => 'api_pages', 'action' => 'search'), + 'url' => array( + 'plugin' => 'api_generator', 'controller' => 'api_generator', + 'action' => 'search' + ), 'type' => 'get', - 'id' => 'header-search' )); ?> <fieldset id="search-bar"> - <?php echo $form->input('Search.query', array( - 'label' => false, - 'div' => false + <?php + echo $form->text('Search.query', array( + 'class' => 'query' )); ?> -<?php echo $form->submit(__('Search', true), array('div' => false)); ?> +<?php echo $form->submit(__('Search', true), array('div' => false, 'class' => 'submit')); ?> </fieldset> -<?php echo $form->end(null); ?> \ No newline at end of file +<?php echo $form->end(null); ?> +</div> \ No newline at end of file diff --git a/views/elements/method_detail.ctp b/views/elements/method_detail.ctp index c941c19..b867037 100644 --- a/views/elements/method_detail.ctp +++ b/views/elements/method_detail.ctp @@ -51,7 +51,7 @@ if ($apiDoc->inClassIndex($method['declaredInClass'])): __(' on line '); echo $html->link($method['startLine'], array( - 'controller' => 'api_pages', + 'controller' => 'api_generator', 'action' => 'view_source', $apiDoc->slugClassName($method['declaredInClass']), '#line-'. $method['startLine'] diff --git a/views/elements/sidebar/class_sidebar.ctp b/views/elements/sidebar/class_sidebar.ctp index 89cc50a..643bdb4 100644 --- a/views/elements/sidebar/class_sidebar.ctp +++ b/views/elements/sidebar/class_sidebar.ctp @@ -9,5 +9,11 @@ <h3><?php __('Class Index'); ?></h3> <ul class="class-index"> <?php foreach ($classIndex as $slug => $name): ?> - <li class="class"><?php echo $html->link($name, array('plugin' => 'api_generator', 'controller' => 'api_pages', 'action' => 'view_class', $slug)); ?></li> + <li class="class"> + <?php + echo $html->link($name, array( + 'plugin' => 'api_generator', 'controller' => 'api_generator', + 'action' => 'view_class', $slug + )); + ?></li> <?php endforeach; ?> \ No newline at end of file diff --git a/views/helpers/api_doc.php b/views/helpers/api_doc.php index a798f1c..466130f 100644 --- a/views/helpers/api_doc.php +++ b/views/helpers/api_doc.php @@ -46,12 +46,12 @@ class ApiDocHelper extends AppHelper { **/ protected $_defaultUrl = array( 'file' => array( - 'controller' => 'api_pages', + 'controller' => 'api_generator', 'action' => 'view_file', 'plugin' => 'api_generator', ), 'class' => array( - 'controller' => 'api_pages', + 'controller' => 'api_generator', 'action' => 'view_class', 'plugin' => 'api_generator', ), diff --git a/views/layouts/api.ctp b/views/layouts/api.ctp deleted file mode 100644 index 25e0bdc..0000000 --- a/views/layouts/api.ctp +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/* SVN FILE: $Id$ */ -/** - * - * PHP versions 5 - * - * CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org) - * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) - * - * Licensed under The MIT License - * Redistributions of files must retain the above copyright notice. - * - * @filesource - * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.api_generator.layouts - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> - <?php echo $html->charset(); ?> - <title> - <?php __('CakePHP: API Generator'); ?> - <?php echo $title_for_layout; ?> - </title> - <?php - echo $html->meta('icon'); - - echo $html->css('/api_generator/css/base.css'); - echo $javascript->link('/api_generator/js/mootools'); - echo $javascript->link('/api_generator/js/showdown'); - echo $javascript->link('/api_generator/js/api_generator'); - - echo $scripts_for_layout; - ?> -</head> -<body> - <?php $bodyClass = (isset($showSidebar) && $showSidebar) ? 'with-sidebar' : 'no-sidebar'; ?> - <div id="wrapper" class="<?php echo $bodyClass; ?>"> - <div id="header" class="clearfix"> - <h1><?php echo $html->link(__('CakePHP: API Generator', true), 'http://cakephp.org'); ?></h1> - <?php echo $this->element('header_search'); ?> - <?php echo $this->element('api_menu');?> - </div> - <div id="content" class="clearfix"> - <?php $session->flash(); ?> - <div id="content-inner"> - <?php echo $content_for_layout; ?> - </div> - <?php if (isset($showSidebar) && $showSidebar): ?> - <div id="sidebar"> - <?php echo $this->element($sidebarElement)?> - </div> - <?php endif; ?> - </div> - <div id="footer"> - <?php echo $html->link( - $html->image('cake.power.gif', array('alt'=> __("CakePHP: the rapid development php framework", true), 'border'=>"0")), - 'http://www.cakephp.org/', - array('target'=>'_blank'), null, false - ); - ?> - </div> - </div> - <?php echo $cakeDebug; ?> -</body> -</html> \ No newline at end of file diff --git a/views/layouts/default.ctp b/views/layouts/default.ctp new file mode 100644 index 0000000..95ce3a9 --- /dev/null +++ b/views/layouts/default.ctp @@ -0,0 +1,73 @@ +<?php +/* SVN FILE: $Id$ */ +/** + * + * PHP versions 5 + * + * CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org) + * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.api_generator.layouts + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <?php echo $html->charset(); ?> + <title> + <?php __('CakePHP: API Generator'); ?> + <?php echo $title_for_layout; ?> + </title> + <?php + echo $html->meta('icon'); + + echo $html->css('/api_generator/css/base.css'); + echo $javascript->link('/api_generator/js/mootools'); + echo $javascript->link('/api_generator/js/showdown'); + echo $javascript->link('/api_generator/js/api_generator'); + + echo $scripts_for_layout; + ?> +</head> +<body class="api"> + <?php $bodyClass = (isset($showSidebar) && $showSidebar) ? 'with-sidebar' : 'no-sidebar'; ?> + <div id="wrapper" class="<?php echo $bodyClass; ?>"> + <div id="header" class="clearfix"> + <h1><?php echo $html->link(__('CakePHP: API Generator', true), 'http://cakephp.org'); ?></h1> + <?php echo $this->element('header_search'); ?> + <?php echo $this->element('api_menu');?> + </div> + <div id="content" class="clearfix"> + <?php $session->flash(); ?> + <div id="content-inner"> + <?php echo $content_for_layout; ?> + </div> + <?php if (isset($showSidebar) && $showSidebar): ?> + <div id="sidebar"> + <?php echo $this->element($sidebarElement)?> + </div> + <?php endif; ?> + </div> + <div id="footer"> + <?php echo $html->link( + $html->image('cake.power.gif', array('alt'=> __("CakePHP: the rapid development php framework", true), 'border'=>"0")), + 'http://www.cakephp.org/', + array('target'=>'_blank'), null, false + ); + ?> + </div> + </div> + <?php echo $cakeDebug; ?> +</body> +</html> \ No newline at end of file