</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() {
$('#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)
);
<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>
--- /dev/null
+<?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
'edit',
array(
'repo' => $repo,
+ 'htmlhelper' => new HtmlHelper(),
)
);
?>
$phork = array(
'1' => new File(null, null)
);
-render('index', array('files' => $phork, 'description' => ''));
+render(
+ 'index',
+ array(
+ 'files' => $phork,
+ 'description' => '',
+ 'htmlhelper' => new HtmlHelper(),
+ )
+);
?>