Example #1
0
 /**
  * update_label_list
  * Update the labels list based on commated list (ex. label1,label2,label3,..)
  */
 public static function update_label_list($labels_comma, $artist_id, $overwrite)
 {
     debug_event('label.class', 'Updating labels for values {' . $labels_comma . '} artist {' . $artist_id . '}', '5');
     $clabels = Label::get_labels($artist_id);
     $editedLabels = explode(",", $labels_comma);
     if (is_array($clabels)) {
         foreach ($clabels as $clid => $clv) {
             if ($clid) {
                 $clabel = new Label($clid);
                 debug_event('label.class', 'Processing label {' . $clabel->name . '}...', '5');
                 $found = false;
                 foreach ($editedLabels as $lk => $lv) {
                     if ($clabel->name == $lv) {
                         $found = true;
                         break;
                     }
                 }
                 if ($found) {
                     debug_event('label.class', 'Already found. Do nothing.', '5');
                     unset($editedLabels[$lk]);
                 } else {
                     if ($overwrite) {
                         debug_event('label.class', 'Not found in the new list. Delete it.', '5');
                         $clabel->remove_artist_assoc($artist_id);
                     }
                 }
             }
         }
     }
     // Look if we need to add some new labels
     foreach ($editedLabels as $lk => $lv) {
         if ($lv != '') {
             debug_event('label.class', 'Adding new label {' . $lv . '}', '5');
             $label_id = Label::lookup(array('name' => $lv));
             if ($label_id === 0) {
                 debug_event('label.class', 'Creating a label directly from artist editing is not allowed.', '5');
                 //$label_id = Label::create(array('name' => $lv));
             }
             if ($label_id > 0) {
                 $clabel = new Label($label_id);
                 $clabel->add_artist_assoc($artist_id);
             }
         }
     }
     return true;
 }
Example #2
0
             if ($past_concerts) {
                 foreach ($past_concerts->children() as $item) {
                     if ($item->getName() == 'event') {
                         $concerts[] = $item;
                     }
                 }
             }
         }
         ob_start();
         require_once AmpConfig::get('prefix') . UI::find_template('show_concerts.inc.php');
         $results['concerts'] = ob_get_clean();
     }
     break;
 case 'labels':
     if (AmpConfig::get('label') && isset($_REQUEST['artist'])) {
         $labels = Label::get_labels($_REQUEST['artist']);
         $object_ids = array();
         if (count($labels) > 0) {
             foreach ($labels as $id => $label) {
                 $object_ids[] = $id;
             }
         }
         $browse = new Browse();
         $browse->set_type('label');
         $browse->set_simple_browse(false);
         $browse->save_objects($object_ids);
         $browse->store();
         ob_start();
         require_once AmpConfig::get('prefix') . UI::find_template('show_labels.inc.php');
         $results['labels'] = ob_get_clean();
     }
Example #3
0
 /**
  * format
  * this function takes an array of artist
  * information and reformats the relevent values
  * so they can be displayed in a table for example
  * it changes the title into a full link.
  * @return boolean
  */
 public function format($details = true, $limit_threshold = '')
 {
     /* Combine prefix and name, trim then add ... if needed */
     $name = trim($this->prefix . " " . $this->name);
     $this->f_name = $name;
     $this->f_full_name = trim(trim($this->prefix) . ' ' . trim($this->name));
     // If this is a memory-only object, we're done here
     if (!$this->id) {
         return true;
     }
     if ($this->catalog_id) {
         $this->link = AmpConfig::get('web_path') . '/artists.php?action=show&catalog=' . $this->catalog_id . '&artist=' . $this->id;
         $this->f_link = "<a href=\"" . $this->link . "\" title=\"" . $this->f_full_name . "\">" . $name . "</a>";
     } else {
         $this->link = AmpConfig::get('web_path') . '/artists.php?action=show&artist=' . $this->id;
         $this->f_link = "<a href=\"" . $this->link . "\" title=\"" . $this->f_full_name . "\">" . $name . "</a>";
     }
     if ($details) {
         // Get the counts
         $extra_info = $this->_get_extra_info($this->catalog_id, $limit_threshold);
         //Format the new time thingy that we just got
         $min = sprintf("%02d", floor($extra_info['time'] / 60) % 60);
         $sec = sprintf("%02d", $extra_info['time'] % 60);
         $hours = floor($extra_info['time'] / 3600);
         $this->f_time = ltrim($hours . ':' . $min . ':' . $sec, '0:');
         $this->tags = Tag::get_top_tags('artist', $this->id);
         $this->f_tags = Tag::get_display($this->tags, true, 'artist');
         if (AmpConfig::get('label')) {
             $this->labels = Label::get_labels($this->id);
             $this->f_labels = Label::get_display($this->labels, true);
         }
         $this->object_cnt = $extra_info['object_cnt'];
     }
     return true;
 }