Skip to content

Commit

Permalink
MDL-15402: Repository admin: separate operations in three columns, ch…
Browse files Browse the repository at this point in the history
…ange small icons into bigger icon and texts. Change Create instance link as a Create instance button.
  • Loading branch information
jerome committed Sep 4, 2008
1 parent fb7cae3 commit 4d5948f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 27 deletions.
3 changes: 3 additions & 0 deletions lang/en_utf8/repository.php
Expand Up @@ -14,6 +14,7 @@
$string['confirmremove'] = 'Are you sure you want to remove this repository plugin and <strong style=color:red>all of its instances</strong> - $a?';
$string['create'] = 'Create';
$string['createrepository'] = 'Create a repository instance';
$string['createinstance'] = 'Create a repository instance';
$string['date'] = 'Date';
$string['deleterepository'] = 'Delete this repository';
$string['deleted'] = 'Repository deleted';
Expand All @@ -27,6 +28,7 @@
$string['filenotnull'] = 'You must select a file to upload.';
$string['filesaved'] = 'The file has been saved';
$string['getfile'] = 'Select this file';
$string['hiddenshow'] = 'Hide/Show';
$string['instance'] = 'instance';
$string['instancedeleted'] = 'Instance deleted';
$string['instances'] = 'Repository instances';
Expand Down Expand Up @@ -55,6 +57,7 @@
$string['settings'] = 'Settings';
$string['search'] = 'Search ';
$string['searching'] = 'What are you searching for?';
$string['siteinstances'] = 'Repositories instances of the site';
$string['size'] = 'Size';
$string['submit'] = 'Submit';
$string['sync'] = 'Sync';
Expand Down
21 changes: 12 additions & 9 deletions lib/adminlib.php
Expand Up @@ -5580,27 +5580,30 @@ function output_html($data, $query='') {
global $CFG, $USER;
$output = print_box_start('generalbox','',true);
$namestr = get_string('name');
$stropt = get_string('operation', 'repository');
$updown = get_string('updown', 'repository');
$settingsstr = get_string('settings');
$updownstr = get_string('updown', 'repository');
$hiddenstr = get_string('hiddenshow', 'repository');
$deletestr = get_string('delete');
$plugins = get_list_of_plugins('repository');
$instances = repository_get_types();
$instancesnumber = count($instances);
$alreadyplugins = array();
$table = new StdClass;
$table->head = array($namestr, $updown, $stropt);
$table->align = array('left', 'center', 'center');
$table->head = array($namestr, $updownstr, $hiddenstr, $deletestr, $settingsstr);
$table->align = array('left', 'center', 'center','center','center');
$table->data = array();
$updowncount=1;
foreach ($instances as $i) {
$row = '';
$settings = '';
//display edit link only if you can config the type or its instances
if ( repository_static_function($i->get_typename(), 'has_admin_config')
|| repository_static_function($i->get_typename(), 'has_instance_config')
|| repository_static_function($i->get_typename(), 'has_multiple_instances')) {
$row .= '<a href="' . $this->baseurl . '&amp;edit=' . $i->get_typename() . '"><img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . get_string('edit') . '" /></a>' . "\n";
$settings .= '<a href="' . $this->baseurl . '&amp;edit=' . $i->get_typename() . '">'. $settingsstr .'</a>' . "\n";
}
$row .= '<a href="' . $this->baseurl . '&amp;delete=' . $i->get_typename() . '"><img src="' . $CFG->pixpath . '/t/delete.gif" alt="' . get_string('delete') . '" /></a>' . "\n";
$row .= ' <a href="' . $this->baseurl . '&amp;hide=' . $i->get_typename() . '"><img src="' . $CFG->pixpath . '/t/' . ($i->get_visible() ? 'hide' : 'show') . '.gif" alt="' . get_string($i->get_visible() ? 'hide' : 'show') . '" /></a>' . "\n";
$delete = '<a href="' . $this->baseurl . '&amp;delete=' . $i->get_typename() . '">' . $deletestr . '</a>' . "\n";

$hiddenshow = ' <a href="' . $this->baseurl . '&amp;hide=' . $i->get_typename() . '"><img src="' . $CFG->pixpath . '/i/' . ($i->get_visible() ? 'hide' : 'show') . '.gif" alt="' . get_string($i->get_visible() ? 'hide' : 'show') . '" /></a>' . "\n";

// display up/down link
$updown = '';
Expand All @@ -5622,7 +5625,7 @@ function output_html($data, $query='') {

$updowncount++;

$table->data[] = array($i->get_readablename(), $updown,$row);
$table->data[] = array($i->get_readablename(), $updown, $hiddenshow, $delete, $settings);

//display a grey row if the type is defined as not visible
if (!$i->get_visible()){
Expand Down
43 changes: 25 additions & 18 deletions repository/lib.php
Expand Up @@ -1975,7 +1975,7 @@ public function definition() {

$mform =& $this->_form;
$strrequired = get_string('required');

$mform->addElement('hidden', 'edit', ($this->instance) ? $this->instance->get_typename() : 0);
$mform->addElement('hidden', 'new', $this->plugin);
$mform->addElement('hidden', 'plugin', $this->plugin);
Expand Down Expand Up @@ -2027,11 +2027,16 @@ function repository_display_instances_list($context, $admin = false, $typename =

}
$output = print_simple_box_start(true);
$output .= "<div ><h2 style='text-align: center'>" . get_string('instances', 'repository') . "</h2></div>";

if ($admin) {
$output .= "<div ><h2 style='text-align: center'>" . get_string('siteinstances', 'repository') . " ";
}
$output .= "</h2></div>";

$namestr = get_string('name');
$pluginstr = get_string('plugin', 'repository');
$stropt = get_string('operation', 'repository');
$settingsstr = get_string('settings');
$deletestr = get_string('delete');
$updown = get_string('updown', 'repository');
$plugins = get_list_of_plugins('repository');
//retrieve list of instances. In administration context we want to display all
Expand All @@ -2042,17 +2047,18 @@ function repository_display_instances_list($context, $admin = false, $typename =
$instancesnumber = count($instances);
$alreadyplugins = array();
$table = new StdClass;
$table->head = array($namestr, $pluginstr, $stropt);
$table->align = array('left', 'left', 'center');
$table->head = array($namestr, $pluginstr, $deletestr, $settingsstr);
$table->align = array('left', 'left', 'center','center');
$table->data = array();
$updowncount=1;
foreach ($instances as $i) {
$row = '';
$row .= '<a href="' . $baseurl . '&amp;type='.$typename.'&amp;edit=' . $i->id . '"><img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . get_string('edit') . '" /></a>' . "\n";
$row .= '<a href="' . $baseurl . '&amp;type='.$typename.'&amp;delete=' . $i->id . '"><img src="' . $CFG->pixpath . '/t/delete.gif" alt="' . get_string('delete') . '" /></a>' . "\n";
//$row .= ' <a href="' . $baseurl . '&amp;type='.$typename.'&amp;hide=' . $i->id . '"><img src="' . $CFG->pixpath . '/t/' . ($i->visible ? 'hide' : 'show') . '.gif" alt="' . get_string($i->visible ? 'hide' : 'show') . '" /></a>' . "\n";
$settings = '';
$settings .= '<a href="' . $baseurl . '&amp;type='.$typename.'&amp;edit=' . $i->id . '">' . $settingsstr . '</a>' . "\n";
$delete = '<a href="' . $baseurl . '&amp;type='.$typename.'&amp;delete=' . $i->id . '">' . $deletestr . '</a>' . "\n";

$table->data[] = array($i->name, $type->get_readablename(), $delete, $settings);


$table->data[] = array($i->name, $type->get_readablename(),$row);
//display a grey row if the type is defined as not visible
if (isset($type) && !$type->get_visible()){
$table->rowclass[] = 'dimmed_text';
Expand All @@ -2065,14 +2071,14 @@ function repository_display_instances_list($context, $admin = false, $typename =
}
}
$output .= print_table($table, true);
$instancehtml = '<div><h3>';
$addable = 0;
$instancehtml .= get_string('createrepository', 'repository');
$instancehtml .= '</h3><ul>';
$instancehtml = '<div>';
$addable = 0;

//if no type is set, we can create all type of instance
if (!$typename) {
$instancehtml .= '<h3>';
$instancehtml .= get_string('createrepository', 'repository');
$instancehtml .= '</h3><ul>';
foreach ($plugins as $p) {
if (!in_array($p, $alreadyplugins)) {
if (repository_static_function($p->get_typename(), 'has_multiple_instances')){
Expand All @@ -2083,18 +2089,19 @@ function repository_display_instances_list($context, $admin = false, $typename =
}
}
}
$instancehtml .= '</ul>';
}
//create a unique type of instance
else {
if (repository_static_function($typename, 'has_multiple_instances')){
$addable = 1;
$instancehtml .= '<li><a href="'.$baseurl.'&amp;new='.$typename.'">'.get_string('create', 'repository')
.' "'.get_string('repositoryname', 'repository_'.$typename).'" '
.get_string('instance', 'repository').'</a></li>';
$instancehtml .= "<form action='".$baseurl."&amp;new=".$typename."' method='post'>
<p style='text-align:center'><input type='submit' value='".get_string('createinstance', 'repository')."'/></p>
</form>";
}
}

$instancehtml .= '</ul>';


if ($addable) {
$instancehtml .= '</div>';
Expand Down

0 comments on commit 4d5948f

Please sign in to comment.