-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 625548d
Showing
70 changed files
with
1,987 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Development Utilities | ||
---------------------- | ||
|
||
DevUtils is een SledgeHammer inspectie systeem. | ||
|
||
* Run UnitTests | ||
* Run Utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Deny from all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
<?php | ||
/** | ||
* | ||
* @package DevUtils | ||
*/ | ||
|
||
class DevUtilsWebsite extends Website { | ||
|
||
public | ||
$project; | ||
|
||
function __construct($projectPath) { | ||
if (file_exists($projectPath.'sledgehammer/core/init_framework.php')) { | ||
$this->project = new Project($projectPath); | ||
} | ||
parent::__construct(); | ||
} | ||
|
||
function index() { | ||
$contents = file_get_contents(URL::info('scheme').'://'.URL::info('host').str_replace('%2F', '/', rawurlencode($this->getPath())).'rewrite_check.html'); | ||
if ($contents != 'Apache Rewrite module is enabled') { // Is het openen van de rewrite_check.html mislukt? | ||
return new HTML('<h1>Error loading "/rewrite_check.html"</h1>"AllowOverride All" is required in your httpd.conf for this <Directory><hr />'); | ||
} | ||
if (!$this->project) { | ||
return new MessageBox('error.gif', 'Geen project gevonden', 'Controleer de stappen in "devutils/docs/installatie.txt"'); | ||
} | ||
// Utilities | ||
$utilityList = array(); | ||
foreach ($this->project->modules as $moduleID => $module) { | ||
foreach ($module->getUtilities() as $utilFilename => $util) { | ||
$utilityList[$moduleID.'/utils/'.$utilFilename] = array('icon' => $util->icon, 'label' => $util->title); | ||
} | ||
} | ||
$utilityList['phpinfo.html'] = array('icon' => 'php.gif', 'label' => 'PHP Info'); | ||
// Documentation | ||
$documentationList = array( | ||
'phpdocs.html' => array('icon' => 'documentation.png', 'label' => 'API Documentation') | ||
); | ||
if (file_exists($this->project->path.'docs/')) { | ||
$documentationList['files/docs/'] = array('icon' => 'documents.png', 'label' => 'Documentation'); | ||
} | ||
// Modules | ||
$moduleList = array(); | ||
foreach ($this->project->modules as $name => $module) { | ||
if ($name != 'application') { | ||
$moduleList[$name.'/'] = array('icon' => '../../module_icons/'.$name.'.png', 'label' => $module->name); | ||
} | ||
} | ||
// Unittests | ||
$tests = $this->project->getUnitTests(); | ||
$unittestList['tests/'] = array('icon' => 'accept.png', 'label' => 'Run TestSuite'); | ||
foreach ($tests as $testfile) { | ||
$unittestList['tests/'.$testfile] = array('icon' => 'test.png', 'label' => substr($testfile, 0, -4)); | ||
} | ||
$template = new Template('project.html', array( | ||
'utilities' => new ActionList($utilityList), | ||
'documentation' => new ActionList($documentationList), | ||
'modules' => new ActionList($moduleList), | ||
'unittests' => new ActionList($unittestList), | ||
)); | ||
return $template; | ||
} | ||
|
||
function phpinfo() { | ||
Breadcrumbs::add('PHP Info'); | ||
$this->document->title = 'PHP info'; | ||
$this->document->stylesheets[] = WEBROOT.'stylesheets/phpinfo.css'; | ||
return new PHPInfo; | ||
} | ||
|
||
function rewrite_check() { | ||
die('Apache Rewrite module is enabled'); | ||
} | ||
|
||
function phpdocs() { | ||
$command = new PhpDocs($this->project); | ||
return $command->execute(); | ||
} | ||
|
||
function project_icon() { | ||
$favicon = $this->project->getFavicon(); | ||
if ($favicon) { | ||
render_file($favicon); | ||
exit; | ||
} | ||
return $this->onFolderNotFound(); | ||
} | ||
|
||
|
||
function flush_phpdocs() { | ||
$count = rmdirs(PATH.'tmp/phpdocs/'); | ||
return new MessageBox('ok.gif', 'Flushing PhpDocumentor files', $count.' files deleted'); | ||
} | ||
|
||
|
||
/** | ||
* Als er geen bestand in de module_icons map staat voor de opgegeven module, geeft dan het standaard icoon weer | ||
*/ | ||
function module_icons_folder() { | ||
render_file(PATH.'application/public/images/icons/module.png'); | ||
} | ||
|
||
function files_folder() { | ||
Breadcrumbs::add('Files', $this->getPath(true)); | ||
$command = new FileBrowser($this->project->path, array('show_fullpath' => true, 'show_hidden_files' => true)); | ||
return $command->execute(); | ||
} | ||
|
||
function tests_folder() { | ||
$folder = new UnitTests($this->project); | ||
return $folder->execute(); | ||
} | ||
|
||
function phpdocs_folder($filename) { | ||
$path = PhpDocs::documentation_path($this->project); | ||
if ($filename === false) { | ||
$filename = substr(rawurldecode($_SERVER['REQUEST_URI']), strlen($this->getPath(true))); | ||
} | ||
render_file($path.$filename); | ||
return $Command->execute(); | ||
} | ||
|
||
function dynamicFoldername($folder) { | ||
if (isset($this->project->modules[$folder])) { | ||
$command = new ModuleFolder($this->project->modules[$folder]); | ||
return $command->execute(); | ||
} | ||
return $this->onFolderNotFound(); | ||
} | ||
|
||
/* | ||
function login() { | ||
if (isset($_SESSION['devutils_login']) && $_SESSION['devutils_login'] == 'LOGGED_IN') { | ||
return true; | ||
} | ||
//Input::build('requiredtext', 'username'); | ||
$Form = new Form(array(), array( | ||
new Fieldset('DevUtils Login', array( | ||
'username' => new FieldLabel('Username', Input::build('required text', 'username', array('class' => 'firstfocus'))), | ||
'password' => new FieldLabel('Password', new Input('password', 'password')), | ||
new Input('submit', NULL, array('value' => 'Login', 'style' => 'float:right;margin-top:10px')), | ||
), array('style' => 'width:310px')) | ||
)); | ||
$values = $Form->import($error); | ||
if ($values) { // Is het formulier succesvol geimporteerd? | ||
$credentials = $values[0]; | ||
if ($credentials['username'] == 'dev' && $credentials['password'] == 'utils') { // Zijn de credentials correct? | ||
$_SESSION['devutils_login'] = 'LOGGED_IN'; | ||
return true; | ||
} | ||
} | ||
$GLOBALS['Document']->javascript(get_public_html().'js/jquery.js'); | ||
$GLOBALS['Document']->javascript(get_public_html().'js/devutils.js'); | ||
$GLOBALS['Viewports']['menu'] = new HTML(' '); | ||
$GLOBALS['Viewport'] = $Form; // Toon het inlog formulier | ||
return false; | ||
} | ||
private function buildMenu() { | ||
$prefix = $this->getPath(); | ||
$menu = array( | ||
'Projects' => array(NULL, 'project.png', 'items' => array()), | ||
'PHPInfo' => array($prefix.'phpinfo.html', 'php.gif'), | ||
); | ||
$projects = $this->get_project_links(); | ||
foreach ($projects as $url => $project) { | ||
$menu['Projects']['items'][$project['label']] = array($url, $project['icon']); | ||
} | ||
if (count($menu['Projects']['items']) == 0) { | ||
unset($menu['Projects']); | ||
} | ||
return new JSCookMenu($menu, 'hbr'); | ||
} | ||
function handlssseFile($filename) { | ||
if ($filename == 'rewrite_check.html') { // Voor de rewrite_check.html is geen inloggen niet nodig | ||
if (!$this->login()) { // Controleer of er is ingelogd of verwerk de log in procedure | ||
return false; // Er is nog niet ingelogd | ||
} | ||
} | ||
} | ||
function handlsseFolder($folder, $filename) { | ||
$Command = new PhpMetaAdmin; | ||
$Command->execute(); | ||
} | ||
*/ | ||
function wrapComponent($component) { | ||
$icon = false; | ||
$properties = false; | ||
if ($this->project) { | ||
if ($this->project->getFavicon()) { | ||
$icon = true; | ||
} | ||
// Properties | ||
if ($this->project->application) { | ||
$properties = new DefinitionList($this->project->getProperties()); | ||
} | ||
} | ||
$template = new Template('layout.html', array( | ||
'icon' => $icon, | ||
'properties' => $properties, | ||
'breadcrumbs' => new Breadcrumbs, | ||
'contents' => $component, | ||
)); | ||
return $template; | ||
} | ||
|
||
function initDocument() { | ||
parent::initDocument(); | ||
$this->document->title = 'DevUtils'; | ||
$this->document->stylesheets[] = WEBROOT.'stylesheets/devutils.css'; | ||
if ($this->project) { | ||
Breadcrumbs::add($this->project->name.' project', $this->getPath()); | ||
} | ||
} | ||
function onSessionStart() { | ||
return false; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* Een Module binnen een Project | ||
* @package DevUtils | ||
*/ | ||
|
||
class Module extends Object { | ||
|
||
public | ||
$name, | ||
$identifier, | ||
$path, | ||
$icon = 'module.png'; | ||
|
||
private | ||
$info = array(); | ||
|
||
function __construct($identifier, $path) { | ||
$this->identifier = $identifier; // De identifier wordt binnen de DevUtils website als bestands -en mapnaam gebruikt | ||
if (substr($path, -1) != '/') { | ||
$path .= '/'; // trailing "/" toevoegen | ||
} | ||
$this->path = $path; | ||
if ($identifier == 'application') { | ||
$this->name = 'Application'; | ||
} else { | ||
// Laad de module.ini of application.ini | ||
$this->info = parse_ini_file($path.'module.ini'); | ||
$this->name = $this->info['name']; | ||
if (isset($this->info['icon'])) { | ||
$this->icon = $this->info['icon']; | ||
} | ||
} | ||
} | ||
|
||
function getProperties() { | ||
$info = array(); | ||
foreach ($this->info as $name => $value) { | ||
if (!in_array($name, array('required_modules', 'optional_modules', 'name'))) { | ||
$info[ucfirst($name)] = $value; | ||
} | ||
} | ||
if (empty($info['Version'])) { | ||
$info['Version'] = VersionControl::get_version($this->path); | ||
} | ||
$info['Revision'] = VersionControl::get_revision($this->path); | ||
return $info; | ||
} | ||
|
||
/** | ||
*/ | ||
function getUtilities() { | ||
Util::$module = $this; | ||
$path = $this->path.'utils/'; | ||
if (file_exists($path)) { | ||
if (file_exists($path.'classes')) { | ||
$GLOBALS['Library']->extract_definitions_from_folder($path.'classes/'); | ||
} | ||
|
||
return include($path.'getUtils.php'); | ||
} | ||
return array(); | ||
} | ||
|
||
function getUnitTests() { | ||
$tests = array(); | ||
$path = $this->path.'tests/'; | ||
if (!file_exists($path)) { | ||
return $tests; | ||
} | ||
$dir = new DirectoryIterator($path); | ||
foreach ($dir as $entry) { | ||
if (!$entry->isFile()) { | ||
continue; | ||
} | ||
$filename = $entry->getFilename(); | ||
if (substr($filename, -4) == '.php' && strpos(file_get_contents($entry->getPathname()), 'function test')) { | ||
if ($filename != 'DatabaseTestCase.php') { | ||
$tests[] = $filename; | ||
} | ||
} | ||
} | ||
ksort($tests); // Sorteer de tests alfabetisch | ||
return $tests; | ||
} | ||
} | ||
?> |
Oops, something went wrong.