Skip to content

Commit

Permalink
finished dashboard panel & simplified content page
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed May 27, 2011
1 parent 51d130b commit 4b6e768
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 149 deletions.
177 changes: 39 additions & 138 deletions content/content.directories.php
Expand Up @@ -45,7 +45,7 @@ public function __viewIndex() {
array(__('Full Permissions'), 'col')
);

//This is horrifically awful to look at but it seems to be the only way to change 0777 to xdwrdwrdwr etc
//This is horrifically awful to look at but it seems to be the only way to change 0777 to drwxrwxrwx etc
function info($fileperms) {
// Socket
if (($fileperms & 0xC000) == 0xC000) $info = 's';
Expand Down Expand Up @@ -86,164 +86,65 @@ function info($fileperms) {
(($fileperms & 0x0200) ? 'T' : '-'));

return $info;
}

//manifest/cache
$dir = getcwd() . __('/manifest/cache');
if(is_dir($dir) == true) {
$fileperms = fileperms($dir);
$perms = substr(sprintf("%o", $fileperms), -4);
$col_dir = Widget::TableData(General::sanitize(__('/manifest/cache')));
$col_dir->appendChild(Widget::Input("item['/manifest/cache']",null, 'checkbox'));
$col_perms = Widget::TableData(General::sanitize($perms));
$col_info = Widget::TableData(General::sanitize(info($fileperms)));
if($perms != '0777') {
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
),
'invalid'
);
} else {
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
)
);
}
} else {
$col_dir = Widget::TableData(General::sanitize(__('/manifest/cache')));
$col_dir->appendChild(Widget::Input("item['/manifest/cache']",null, 'checkbox'));
$col_perms = Widget::TableData(General::sanitize(__('WARNING: This directory does not exist.')));
$col_info = Widget::TableData(General::sanitize());
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
),
'invalid'
);
}

//manifest/tmp
$dir = getcwd() . __('/manifest/tmp');
if(is_dir($dir) == true) {
$fileperms = fileperms($dir);
$perms = substr(sprintf("%o", $fileperms), -4);
$col_dir = Widget::TableData(General::sanitize(__('/manifest/tmp')));
$col_dir->appendChild(Widget::Input("item['/manifest/tmp']",null, 'checkbox'));
$col_perms = Widget::TableData(General::sanitize($perms));
$col_info = Widget::TableData(General::sanitize(info($fileperms)));
if($perms != '0777') {
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
),
'invalid'
);
} else {
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
)
);
}

//array_unique didn't work, so run this function instead
function remove_duplicates(array $array){
$tmp_array = array();

foreach($array as $key => $val) {
if (!in_array($val, $tmp_array)) {
$tmp_array[$key] = $val;
}
}
} else {
$col_dir = Widget::TableData(General::sanitize(__('/manifest/tmp')));
$col_dir->appendChild(Widget::Input("item['/manifest/tmp']",null, 'checkbox'));
$col_perms = Widget::TableData(General::sanitize(__('WARNING: This directory does not exist.')));
$col_info = Widget::TableData(General::sanitize());
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
),
'invalid'
);

return $tmp_array;
}

// XML importer
if($extensionManager->fetchStatus('xmlimporter') == EXTENSION_ENABLED) {
$dir = getcwd() . __('/workspace/xml-importers');
if(is_dir($dir) == true) {
$fileperms = fileperms($dir);
$directory = array('/manifest/cache','/manifest/tmp');
if($extensionManager->fetchStatus('xmlimporter') == EXTENSION_ENABLED) $directory[] = '/workspace/xml-importers';
foreach(remove_duplicates($destinations) as $destination) $directory[] = $destination['destination'];

foreach($directory as $dir) {
$d = getcwd() . __($dir);
if(is_dir($d) == true) {
$fileperms = fileperms($d);
$perms = substr(sprintf("%o", $fileperms), -4);
$col_dir = Widget::TableData(General::sanitize('workspace/xml-importers'));
$col_dir->appendChild(Widget::Input("item[/workspace/xml-importers]",null, 'checkbox'));
$col_perms = Widget::TableData(General::sanitize($perms));
$col_info = Widget::TableData(General::sanitize(info($fileperms)));
$td_dir = Widget::TableData(General::sanitize(__($dir)));
$td_dir->appendChild(Widget::Input("item['.$d.']",null, 'checkbox'));
$td_perms = Widget::TableData(General::sanitize($perms));
$td_info = Widget::TableData(General::sanitize(info($fileperms)));
if($perms != '0777') {
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
$td_dir,
$td_perms,
$td_info
),
'invalid'
);
} else {
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
$td_dir,
$td_perms,
$td_info
)
);
}
}
}

//array_unique didn't work, so run this function instead
function remove_duplicates(array $array){
$tmp_array = array();

foreach($array as $key => $val) {
if (!in_array($val, $tmp_array)) {
$tmp_array[$key] = $val;
}
}

return $tmp_array;
}

$destinations = remove_duplicates($destinations);

// Upload directories
foreach($destinations as $destination) {
$dir = getcwd() . $destination['destination'];
$fileperms = fileperms($dir);
$perms = substr(sprintf("%o", $fileperms), -4);
$col_dir = Widget::TableData(General::sanitize($destination['destination']));
$col_dir->appendChild(Widget::Input("item[{$destination['destination']}]",null, 'checkbox'));
$col_perms = Widget::TableData(General::sanitize($perms));
$col_info = Widget::TableData(General::sanitize(info($fileperms)));
if($perms != '0777') {
} else {
$td_dir = Widget::TableData(General::sanitize(__($dir)));
$td_dir->appendChild(Widget::Input("item['.$d.']",null, 'checkbox'));
$td_perms = Widget::TableData(General::sanitize(__('WARNING: This directory does not exist.')));
$td_info = Widget::TableData(General::sanitize());
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
$td_dir,
$td_perms,
$td_info
),
'invalid'
);
} else {
$tableBody[] = Widget::TableRow(
array(
$col_dir,
$col_perms,
$col_info
)
);
}
}

Expand Down
39 changes: 28 additions & 11 deletions extension.driver.php
Expand Up @@ -51,9 +51,9 @@ public function getSubscribedDelegates() {

public function initaliseAdminPageHead($context) {
$callback = Symphony::Engine()->getPageCallback();

// Append assets
if($callback['driver'] == 'directories') {
if($callback['driver'] == 'directories' || $callback['classname'] == 'contentExtensionDashboardIndex') {
Symphony::Engine()->Page->addStylesheetToHead(URL . '/extensions/health_check/assets/healthcheck.publish.css', 'screen');
}
}
Expand All @@ -71,15 +71,33 @@ public function dashboard_panel_options($context) {

public function render_panel($context) {
if ($context['type'] != 'health_check_panel') return;

require_once(EXTENSIONS . '/health_check/content/content.directories.php');


$extensionManager = new ExtensionManager($this->_Parent);
if($extensionManager->fetchStatus('uniqueuploadfield') == EXTENSION_ENABLED) {
$destinations = Symphony::Database()->fetch("SELECT destination COLLATE utf8_general_ci AS destination FROM tbl_fields_upload UNION ALL SELECT destination FROM tbl_fields_uniqueupload ORDER BY destination ASC");
} else {
$destinations = Symphony::Database()->fetch("SELECT destination FROM tbl_fields_upload ORDER BY destination ASC");
}

function remove_duplicates(array $array){
$tmp_array = array();

foreach($array as $key => $val) {
if (!in_array($val, $tmp_array)) {
$tmp_array[$key] = $val;
}
}

return $tmp_array;
}

$div = new XMLElement('div');
$table = new XMLElement('table');

//manifest/cache

$dir = array('/manifest/cache','/manifest/tmp');

if($extensionManager->fetchStatus('xmlimporter') == EXTENSION_ENABLED) $dir[] = '/workspace/xml-importers';
foreach(remove_duplicates($destinations) as $destination) $dir[] = $destination['destination'];

foreach($dir as $d) {
$directory = getcwd() . __($d);
if(is_dir($directory) == true) {
Expand All @@ -93,15 +111,14 @@ public function render_panel($context) {
$table->appendChild(Widget::TableRow(array($td_directory, $td_perms)));
}
} else {
$directory = Widget::TableData(General::sanitize(__('/manifest/cache')));
$directory = Widget::TableData(General::sanitize(__($d)));
$perms = Widget::TableData(General::sanitize(__('WARNING: This directory does not exist.')));
$table->appendChild(Widget::TableRow(array($directory, $perms),'invalid'));
}
}


$div->appendChild($table);

$context['panel']->appendChild($div);
}
}
Expand Down

0 comments on commit 4b6e768

Please sign in to comment.