aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2012-04-03 08:29:37 +0200
committerChristian Weiske <cweiske@cweiske.de>2012-04-03 08:29:37 +0200
commit7dcd592544ae0b55d0e205ff83631067a0d0aa6b (patch)
tree634b17274e6efd1c7e8a1aee216cda194f08c1d6
parenta39bd415faa45403247e6af89a32df4dd3560b3e (diff)
downloadphorkie-7dcd592544ae0b55d0e205ff83631067a0d0aa6b.tar.gz
phorkie-7dcd592544ae0b55d0e205ff83631067a0d0aa6b.zip
proper type dropdown for files now
-rw-r--r--data/templates/edit-add.htm4
-rw-r--r--data/templates/edit-file.htm4
-rw-r--r--src/Phorkie/HtmlHelper.php28
-rw-r--r--www/edit.php1
-rw-r--r--www/index.php9
5 files changed, 40 insertions, 6 deletions
diff --git a/data/templates/edit-add.htm b/data/templates/edit-add.htm
index 8435852..19f10cf 100644
--- a/data/templates/edit-add.htm
+++ b/data/templates/edit-add.htm
@@ -5,7 +5,7 @@
</a>
</div>
- {% include 'edit-file.htm' with {'file': '', 'fileid': 'new'} %}
+ {% include 'edit-file.htm' with {'file': null, 'fileid': 'new'} %}
<script type="application/javascript">
$(document).ready(function() {
@@ -13,7 +13,7 @@ $(document).ready(function() {
$('#filegroupnew').hide();
$('#add-button a').bind('click', function() {
$('#add-button').before("{% filter escape('js') %}
- {% include 'edit-file.htm' with {'file': '', 'fileid': '###'} %}
+ {% include 'edit-file.htm' with {'file': null, 'fileid': '###'} %}
{% endfilter %}"
.replace(/###/g, $('.filegroup').length)
);
diff --git a/data/templates/edit-file.htm b/data/templates/edit-file.htm
index ef900ea..37f9253 100644
--- a/data/templates/edit-file.htm
+++ b/data/templates/edit-file.htm
@@ -9,9 +9,7 @@
<label for="type_{{fileid}}">Type</label>
<!-- fixme: preselect -->
<select name="files[{{fileid}}][type]" id="type_{{fileid}}">
- <option value="css">CSS</option>
- <option value="php">PHP</option>
- <option value="xml">XML</option>
+ {{htmlhelper.getLanguageOptions(file)|raw}}
</select>
</div>
</div>
diff --git a/src/Phorkie/HtmlHelper.php b/src/Phorkie/HtmlHelper.php
new file mode 100644
index 0000000..f20add3
--- /dev/null
+++ b/src/Phorkie/HtmlHelper.php
@@ -0,0 +1,28 @@
+<?php
+namespace Phorkie;
+
+class HtmlHelper
+{
+ public function getLanguageOptions(File $file = null)
+ {
+ $html = '';
+ $fileExt = null;
+ if ($file !== null) {
+ $fileExt = $file->getExt();
+ }
+ foreach ($GLOBALS['phorkie']['languages'] as $ext => $arLang) {
+ if (isset($arLang['show']) && !$arLang['show']) {
+ continue;
+ }
+ $html .= sprintf(
+ '<option value="%s"%s>%s</option>',
+ $ext,
+ $fileExt == $ext ? ' selected="selected"' : '',
+ $arLang['title']
+ ) . "\n";
+ }
+ return $html;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/www/edit.php b/www/edit.php
index 9acc1d6..e59bcd1 100644
--- a/www/edit.php
+++ b/www/edit.php
@@ -17,6 +17,7 @@ render(
'edit',
array(
'repo' => $repo,
+ 'htmlhelper' => new HtmlHelper(),
)
);
?>
diff --git a/www/index.php b/www/index.php
index 9a03b77..898c443 100644
--- a/www/index.php
+++ b/www/index.php
@@ -20,5 +20,12 @@ if ($repopo->process($_POST)) {
$phork = array(
'1' => new File(null, null)
);
-render('index', array('files' => $phork, 'description' => ''));
+render(
+ 'index',
+ array(
+ 'files' => $phork,
+ 'description' => '',
+ 'htmlhelper' => new HtmlHelper(),
+ )
+);
?>