<?php
if (isset($this->obj)) {
    $contents = $this->obj->getContents();
    $count = count($contents);
}
?>

<?php if (isset($this->obj)) : ?>
    <div class="inner_editor_title">
        <H2><?php echo(_("Editing "));?>"<span class="title_obj_name"><?php if (isset($this->unsavedName)) echo $this->unsavedName;
            else echo $this->escape($this->obj->getName());?></span>"</H2>
    </div>
    <div class="inner_editor_wrapper">
        <input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/>
        <input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"/>
        <input class='obj_type' type='hidden' value='playlist'/>

        <dl class="zend_form playlist_editor">
            <dt>
                <label><?php echo(_("Name:")); ?></label>
            </dt>
            <dd>
                <input type="text" class="playlist_name_display" contenteditable="true" value="<?php echo $this->escape($this->obj->getName()); ?>">
            </dd>
            <dt id="description-label"><label for="description"><?php echo _("Description:") ?></label></dt>
            <dd id="description-element">
                <textarea cols="24" rows="3" id="description" name="description"><?php echo $this->escape($this->obj->getDescription()); ?></textarea>
            </dd>
        </dl>

        <?php //echo $this->form; ?>

    </div>

    <div class="ui-widget-header fg-toolbar btn-toolbar clearfix">
        <h4 class="obj_length"><?php echo($this->length); ?></h4>
        <h4 class="obj_length_label"><?php echo(_("Duration:"));?></h4>

        <div class='btn-group'>
            <button class="btn toggle-editor-form" title='<?php echo _("Toggle Details") ?>' type="button"><span class="icon-white spl-no-r-margin icon-chevron-up"></span></button>
        </div>

        <div class='btn-group'>
            <button class="btn" title='<?php echo _("Shuffle playlist") ?>' type="button" id="playlist_shuffle_button"><?php echo _("Shuffle") ?></button>
        </div>
        <div class='btn-group'>
            <button id="spl_crossfade" class="btn crossfade-main-button">
                <i class='crossfade-main-icon'></i><span class="ui-button-text"><?php echo _("Playlist crossfade") ?></span>
            </button>
        </div>
        <div class='btn-group'>
            <button class="btn btn-danger" title='<?php echo _("Empty playlist content") ?>' type="button" id="pl-bl-clear-content"><?php echo _("Clear") ?></button>
        </div>
        <div class="clearfix"></div>
    </div>

    <div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
        <span class="ui-icon ui-icon-closethick sp-closethick-center"></span>
        <dl id="spl_editor-main" class="inline-list">
            <dt><?php echo _("Fade in:  "); ?></dt>
            <dd><input class="spl_main_fade_in playlist_main_fade_input" value="0" /><span class='spl_cue_hint'> seconds</span></dd>
            <dd class="edit-error"></dd>
            <dt><?php echo _("Fade out: "); ?></dt>
            <dd><input class="spl_main_fade_out playlist_main_fade_input" value="0" /><span class='spl_cue_hint'> seconds</span></dd>
            <dd class="edit-error"></dd>
        </dl>
    </div>

    <ul class="spl_sortable">
        <?php  $this->contents = $contents;
            echo $this->render('playlist/update.phtml') ?>
    </ul>
    <div class="btn-toolbar clearfix">
        <div class="btn-group pull-right">
            <button class="btn" type="button" id="cancel_button" name="submit"><?php echo _("Cancel") ?></button>
        </div>
        <div class='btn-group pull-right'>
            <button class="btn" title='<?php echo _("Save playlist") ?>' type="button" id="save_button"><?php echo _("Save") ?></button>
        </div>
        <div id='sp-success' class='success' style='display:none'></span></div>


    </div>

<?php else : ?>
    <div><?php echo _("No open playlist") ?></div>
<?php endif; ?>