Exemplo n.º 1
0
Arquivo: info.php Projeto: anqh/anqh
 /**
  * Render content.
  *
  * @return  string
  */
 public function content()
 {
     ob_start();
     // Cover
     if (Valid::url($this->track->cover)) {
         echo HTML::image($this->track->cover, array('class' => 'cover img-responsive', 'alt' => __('Cover')));
     }
     // Time
     if ($this->track->size_time) {
         echo '<i class="fa fa-fw fa-clock-o"></i> ' . $this->track->size_time . '<br />';
     }
     // Listen count
     if ($this->track->listen_count > 1) {
         echo '<i class="fa fa-fw fa-play"></i> ' . ($this->track->listen_count == 1 ? __(':count play', array(':count' => $this->track->listen_count)) : __(':count plays', array(':count' => $this->track->listen_count))) . '<br />';
     }
     // Tags
     if ($tags = $this->track->tags()) {
         echo '<i class="fa fa-fw fa-music"></i> ' . implode(', ', $tags) . '<br />';
     } elseif (!empty($this->track->music)) {
         echo '<i class="fa fa-fw fa-music"></i> ' . $this->track->music . '<br />';
     }
     // Meta
     echo '<footer class="meta text-muted">';
     echo __('Added :date', array(':date' => HTML::time(Date::format(Date::DMY_SHORT, $this->track->created), $this->track->created)));
     echo '</footer>';
     return ob_get_clean();
 }
Exemplo n.º 2
0
Arquivo: charts.php Projeto: anqh/anqh
 /**
  * Build charts list.
  *
  * @return  Model_Music_Track[]
  */
 protected function _charts()
 {
     $tracks = array();
     foreach ($this->tracks['this'] as $rank => $track_id) {
         $track = Model_Music_Track::factory($track_id);
         if (!$track->loaded()) {
             continue;
         }
         $tracks[] = array('rank' => $rank, 'last' => array_search($track_id, $this->tracks['last']), 'track' => $track);
     }
     return $tracks;
 }
Exemplo n.º 3
0
Arquivo: music.php Projeto: anqh/anqh
 /**
  * Get anchor to newsfeed item target.
  *
  * @static
  * @param   Model_NewsfeedItem  $item
  * @return  string
  */
 public static function get_link(Model_NewsfeedItem $item)
 {
     $text = '';
     switch ($item->type) {
         case self::TYPE_MIX:
         case self::TYPE_TRACK:
             $track = Model_Music_Track::factory($item->data['track_id']);
             if ($track->loaded()) {
                 $text = HTML::anchor(Route::model($track), '<i class="fa fa-music"></i> ' . HTML::chars($track->name), array('title' => $track->name));
             }
             break;
     }
     return $text;
 }
Exemplo n.º 4
0
Arquivo: edit.php Projeto: anqh/anqh
    /**
     * Render content.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        echo Form::open(null, array('id' => 'form-music', 'class' => 'row'));
        ?>

			<div class="col-md-8">
				<fieldset>
					<?php 
        echo Form::input_wrap('name', $this->track->name, array('class' => 'input-lg'), __('Name'), Arr::get($this->errors, 'name'));
        ?>

					<?php 
        echo Form::input_wrap('url', $this->track->url, array('placeholder' => 'http://'), __('URL'), Arr::get($this->errors, 'url'));
        ?>

					<?php 
        echo Form::textarea_wrap('description', $this->track->description, null, true, __('Description'), Arr::get($this->errors, 'description'));
        ?>

					<?php 
        if ($this->track->type == Model_Music_Track::TYPE_MIX) {
            echo Form::textarea_wrap('tracklist', $this->track->tracklist, null, true, __('Tracklist'), Arr::get($this->errors, 'tracklist'));
        }
        ?>
				</fieldset>

				<fieldset class="form-actions">
					<?php 
        echo Form::button('save', __('Save'), array('type' => 'submit', 'class' => 'btn btn-success btn-large'));
        ?>
					<?php 
        echo $this->cancel ? HTML::anchor($this->cancel, __('Cancel'), array('class' => 'cancel')) : '';
        ?>

					<?php 
        echo Form::csrf();
        ?>
				</fieldset>
			</div>

			<div class="col-md-4">
				<fieldset>
					<?php 
        echo Form::input_wrap('cover', $this->track->cover, array('placeholder' => 'http://'), __('Cover'), Arr::get($this->errors, 'cover'));
        ?>

					<?php 
        echo Form::input_wrap('size_time', $this->track->size_time, array('maxlength' => $this->track->type == Model_Music_Track::TYPE_MIX ? 8 : 6, 'placeholder' => $this->track->type == Model_Music_Track::TYPE_MIX ? __('hh:mm:ss') : __('mm:ss')), __('Length'), Arr::get($this->event_errors, 'size_time'), null, 'min');
        ?>
				</fieldset>

				<fieldset id="fields-music">
					<?php 
        echo Form::checkboxes_wrap('tag', $this->tags(), $this->track->tags(), array('class' => 'block-grid three-up'), __('Music'), $this->errors);
        ?>
				</fieldset>
			</div>

<?php 
        echo Form::close();
        return ob_get_clean();
    }
Exemplo n.º 5
0
Arquivo: music.php Projeto: anqh/anqh
 /**
  * Edit track.
  *
  * @param   integer  $track_id
  *
  * @throws  Model_Exception
  */
 protected function _edit_track($track_id = null)
 {
     $this->history = false;
     if ($track_id) {
         // Editing old
         $track = new Model_Music_Track($track_id);
         if (!$track->loaded()) {
             throw new Model_Exception($track, $track_id);
         }
         Permission::required($track, Model_Music_Track::PERMISSION_UPDATE);
         $cancel = Route::model($track);
         $this->view = new View_Page(HTML::chars($track->name));
         // Set actions
         if (Permission::has($track, Model_Music_Track::PERMISSION_DELETE)) {
             $this->view->actions[] = array('link' => Route::model($track, 'delete') . '?token=' . Security::csrf(), 'text' => '<i class="fa fa-trash-o"></i> ' . __('Delete'), 'class' => 'btn-danger music-delete');
         }
     } else {
         // Creating new
         $track = new Model_Music_Track();
         Permission::required($track, Model_Music_Track::PERMISSION_CREATE);
         $cancel = Request::back(Route::url('charts'), true);
         $newsfeed = true;
         $this->view = new View_Page($this->request->param('music') === 'mixtape' ? __('New mixtape') : __('New track'));
         $track->author_id = Visitor::$user->id;
         $track->type = $this->request->param('music') === 'mixtape' ? Model_Music_Track::TYPE_MIX : Model_Music_Track::TYPE_TRACK;
         $track->created = time();
     }
     // Handle post
     $errors = array();
     if ($_POST && Security::csrf_valid()) {
         try {
             $track->set_fields(Arr::intersect($_POST, Model_Music_Track::$editable_fields));
             $track->save();
             // Set tags
             $track->set_tags(Arr::get($_POST, 'tag'));
             // Newsfeed
             if (isset($newsfeed) && $newsfeed) {
                 NewsfeedItem_Music::track(Visitor::$user, $track);
                 // Create forum topic
                 if ($track->add_forum_topic()) {
                     Visitor::$user->post_count++;
                     Visitor::$user->save();
                 }
             }
             $this->request->redirect(Route::model($track));
         } catch (Validation_Exception $e) {
             $errors = $e->array->errors('validation');
         }
     }
     // Form
     $section = $this->section_track_edit($track);
     $section->cancel = $cancel;
     $section->errors = $errors;
     $this->view->add(View_Page::COLUMN_TOP, $section);
 }
Exemplo n.º 6
0
Arquivo: track.php Projeto: anqh/anqh
 /**
  * Render cover.
  *
  * @return  string
  */
 public function cover()
 {
     $icon = $this->track->cover();
     $rank = $this->rank ? '<div class="rank">' . $this->rank . '</div>' : '';
     return HTML::anchor(Route::model($this->track), ($icon ? HTML::image($icon, array('alt' => __('Cover')), null, null, true) : '<i class="fa fa-music"></i>') . $rank);
 }