diff options
author | Michael Göhler <somebody.here@gmx.de> | 2014-07-21 00:11:33 +0400 |
---|---|---|
committer | Michael Göhler <somebody.here@gmx.de> | 2014-07-21 00:11:33 +0400 |
commit | b12ec85ee58a52cb66d3d295b60f7cf00284a755 (patch) | |
tree | 9f8747fdda9ae51cf3f061bd25f58109c0893d56 /external | |
parent | 1c303fa2802cdac852f43ba5c5b3e1f1fa6ce649 (diff) |
configurable icons for app external
Diffstat (limited to 'external')
-rw-r--r-- | external/ajax/setsites.php | 2 | ||||
-rw-r--r-- | external/appinfo/app.php | 13 | ||||
-rw-r--r-- | external/css/style.css | 2 | ||||
-rw-r--r-- | external/js/admin.js | 10 | ||||
-rw-r--r-- | external/settings.php | 2 | ||||
-rw-r--r-- | external/templates/settings.php | 35 |
6 files changed, 50 insertions, 14 deletions
diff --git a/external/ajax/setsites.php b/external/ajax/setsites.php index 479eabfd2..5ac1f2cfa 100644 --- a/external/ajax/setsites.php +++ b/external/ajax/setsites.php @@ -14,7 +14,7 @@ OCP\JSON::callCheck(); $sites = array(); for ($i = 0; $i < sizeof($_POST['site_name']); $i++) { if (!empty($_POST['site_name'][$i]) && !empty($_POST['site_url'][$i])) { - array_push($sites, array(strip_tags($_POST['site_name'][$i]), strip_tags($_POST['site_url'][$i]))); + array_push($sites, array(strip_tags($_POST['site_name'][$i]), strip_tags($_POST['site_url'][$i]), strip_tags($_POST['site_icon'][$i]))); } } diff --git a/external/appinfo/app.php b/external/appinfo/app.php index 656ca2710..10788dada 100644 --- a/external/appinfo/app.php +++ b/external/appinfo/app.php @@ -29,9 +29,12 @@ OCP\App::registerAdmin('external', 'settings'); $sites = External::getSites(); for ($i = 0; $i < sizeof($sites); $i++) { OCP\App::addNavigationEntry( - array( - 'id' => 'external_index' . ($i + 1), 'order' => 80 + $i, - 'href' => OCP\Util::linkTo('external', 'index.php') . '?id=' . ($i + 1), - 'icon' => OCP\Util::imagePath('external', 'external.png'), - 'name' => $sites[$i][0])); + array( + 'id' => 'external_index' . ($i + 1), + 'order' => 80 + $i, + 'href' => OCP\Util::linkTo('external', 'index.php') . '?id=' . ($i + 1), + 'icon' => OCP\Util::imagePath('external', !empty($sites[$i][2]) ? $sites[$i][2] : 'external.png'), + 'name' => $sites[$i][0] + ) + ); } diff --git a/external/css/style.css b/external/css/style.css index f891cb4bc..bbf8b2ea3 100644 --- a/external/css/style.css +++ b/external/css/style.css @@ -10,5 +10,5 @@ } .external_sites { - width: 450px; + width: 470px; } diff --git a/external/js/admin.js b/external/js/admin.js index 10f57734f..1cede33dd 100644 --- a/external/js/admin.js +++ b/external/js/admin.js @@ -1,8 +1,4 @@ $(document).ready(function(){ - var newSiteHtml = '<li><input type="text" class="site_name" name="site_name[]" value="" placeholder="Name" />\n' + - '<input type="text" name="site_url[]" class="site_url" value="" placeholder="URL" />' + - '<img class="svg action delete_button" src="' + - OC.imagePath("core", "actions/delete") +'" title="Remove site" /></li>'; // Handler functions function addSiteEventHandler(event) { @@ -38,6 +34,7 @@ $(document).ready(function(){ // Initialize events $('input[name^=site_]').change(addSiteEventHandler); + $('select[name^=site_]').change(addSiteEventHandler); $('img.delete_button').click(deleteButtonEventHandler); $('img.delete_button').tipsy(); @@ -45,7 +42,10 @@ $(document).ready(function(){ $('#add_external_site').click(function(event) { event.preventDefault(); - $('#external ul').append(newSiteHtml); + + $('#external ul li:last').clone().appendTo('#external ul'); + $('#external ul li:last input').val(''); + $('#external ul li:last select').val(''); $('input.site_url:last').prev('input.site_name').andSelf().change(addSiteEventHandler); $('img.delete_button').click(deleteButtonEventHandler); diff --git a/external/settings.php b/external/settings.php index d1b055c65..3b0823339 100644 --- a/external/settings.php +++ b/external/settings.php @@ -7,4 +7,6 @@ OCP\Util::addscript( "external", "admin" ); $tmpl = new OCP\Template( 'external', 'settings'); +$tmpl->assign('images', glob(\OC_App::getAppPath('external') . '/img/*.*')); + return $tmpl->fetchPage(); diff --git a/external/templates/settings.php b/external/templates/settings.php index c93fa2dd6..7115c1137 100644 --- a/external/templates/settings.php +++ b/external/templates/settings.php @@ -13,11 +13,42 @@ <?php $sites = \OCA\External\External::getSites(); for($i = 0; $i < sizeof($sites); $i++) { - print_unescaped('<li><input type="text" name="site_name[]" class="site_name" value="'.OCP\Util::sanitizeHTML($sites[$i][0]).'" placeholder="'.$l->t('Name').'" /> - <input type="text" class="site_url" name="site_url[]" value="'.OCP\Util::sanitizeHTML($sites[$i][1]).'" placeholder="'.$l->t('URL').'" /> + print_unescaped('<li> + <input type="text" class="site_name" name="site_name[]" value="'.OCP\Util::sanitizeHTML($sites[$i][0]).'" placeholder="'.$l->t('Name').'" /> + <input type="text" class="site_url" name="site_url[]" value="'.OCP\Util::sanitizeHTML($sites[$i][1]).'" placeholder="'.$l->t('URL').'" /> + <select class="site_icon" name="site_icon[]">'); + $nf = true; + foreach($_['images'] as $image) { + if (basename($image) == $sites[$i][2]) { + print_unescaped('<option value="'.basename($image).'" selected>'.basename($image).'</option>'); + $nf = false; + } else { + print_unescaped('<option value="'.basename($image).'">'.basename($image).'</option>'); + } + } + if($nf) { + print_unescaped('<option value="" selected>'.$l->t('Select an icon').'</option>'); + } else { + print_unescaped('<option value="">'.$l->t('Select an icon').'</option>'); + } + print_unescaped('</select> <img class="svg action delete_button" src="'.OCP\image_path("", "actions/delete.svg") .'" title="'.$l->t("Remove site").'" /> </li>'); } + if(sizeof($sites) === 0) { + print_unescaped('<li> + <input type="text" class="site_name" name="site_name[]" value="" placeholder="'.$l->t('Name').'" /> + <input type="text" class="site_url" name="site_url[]" value="" placeholder="'.$l->t('URL').'" /> + <select class="site_icon" name="site_icon[]">'); + foreach($_['images'] as $image) { + print_unescaped('<option value="'.basename($image).'">'.basename($image).'</option>'); + } + print_unescaped('<option value="" selected>'.$l->t('Select an icon').'</option> + </select> + <img class="svg action delete_button" src="'.OCP\image_path("", "actions/delete.svg") .'" title="'.$l->t("Remove site").'" /> + </li>'); + } + ?> </ul> |