<div id="source<?PHP echo isset($this->source) ? $this->source['id'] : ''; ?>" 
        class="source <?PHP 
                        echo isset($this->source)===false ? 'source-new' : ''; 
                        echo (isset($this->source) && isset($this->source['error']) && strlen($this->source['error'] > 0)) ? 'error' : ''
                        ?>">
    <div class="source-icon">
        <?PHP if(isset($this->source) && isset($this->source['icon']) && $this->source['icon']!==false && $this->source['icon']!="0") : ?>
        <img src="<?PHP echo 'favicons/'.$this->source['icon']; ?>" alt="<?PHP echo isset($this->source) ? $this->source['title'] : ''; ?>" />
        <?PHP endif; ?>
    </div>
    
    <div class="source-title"><?PHP echo isset($this->source) ? $this->source['title'] : \F3::get('lang_source_new') ; ?></div>
    
    <div class="source-edit-delete"><span class="source-showparams"><?PHP echo \F3::get('lang_source_edit')?></span> &bull; <span class="source-delete"><?PHP echo \F3::get('lang_source_delete')?></span></div>

    <!-- edit -->
    <ul class="source-edit-form">
        <!-- title -->
        <li><label><?PHP echo \F3::get('lang_source_title')?>:</label> <input type="text" name="title" value="<?PHP echo isset($this->source) ? $this->source['title'] : '' ; ?>" placeholder="<?PHP echo F3::get('lang_source_new'); ?>" /></li>
        
        <!-- tags -->
        <li><label><?PHP echo \F3::get('lang_source_tags');?>:</label>
            <input type="text" name="tags" value="<?PHP echo isset($this->source) ? $this->source['tags'] : ''; ?>" /> <span class="source-edit-form-help"> <?PHP echo \F3::get('lang_source_comma')?></span>
        </li>
        
        <!-- type -->
        <li><label><?PHP echo \F3::get('lang_source_type')?>:</label> 
            <select class="source-spout" name="spout">
                <option value=""><?PHP echo \F3::get('lang_source_select')?></option>
                <?PHP foreach($this->spouts as $spouttype=>$spout) : ?>
                <option value="<?PHP echo str_replace("\\", "_", $spouttype); ?>" <?PHP echo isset($this->source) && $spouttype==$this->source['spout'] ? 'selected="selected"' : ''; ?>>
                    <?PHP echo $spout->name; ?>
                </option>
                <?PHP endforeach; ?>
            </select>
        </li>
        
        <!-- settings -->
        <li class="source-params">
        <?PHP
            if(isset($this->source) && isset($this->spouts[$this->source['spout']])) {
                if($this->spouts[$this->source['spout']]->params!==false) {
                    $this->spout = $this->spouts[$this->source['spout']];
                    $this->params = json_decode(html_entity_decode($this->source['params']), true);
                    echo $this->render('templates/source_params.phtml');
                }
            }
        ?>
        </li>
        
        <!-- error messages -->
        <?PHP if(isset($this->source) && isset($this->source['error'])) : ?>
        <li class="source-error">
            <?PHP echo $this->source['error']; ?>
        </li>
        <?PHP endif; ?>
        
        <!-- save/delete -->
        <li class="source-action">
            <span class="source-save"><?PHP echo \F3::get('lang_source_save')?></span> &bull; <span class="source-cancel"><?PHP echo \F3::get('lang_source_cancel')?></span>
        </li>
    </ul>


</div>
