diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 01:42:27 -0500 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 01:42:52 -0500 |
commit | 80b618ba403d4560938cd1bfbed861994875d6c7 (patch) | |
tree | 9378d37ed6187ab64ab5a5351cb7242759e0153d /lib/class | |
parent | 136f9f58569c6a6b52d6b9589fabf29950178cd7 (diff) | |
download | ampache-80b618ba403d4560938cd1bfbed861994875d6c7.tar.gz ampache-80b618ba403d4560938cd1bfbed861994875d6c7.tar.bz2 ampache-80b618ba403d4560938cd1bfbed861994875d6c7.zip |
Move update_text from ui.lib.php to UI
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/catalog.class.php | 30 | ||||
-rw-r--r-- | lib/class/ui.class.php | 19 |
2 files changed, 34 insertions, 15 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index f0c773b2..9a75a5ea 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -564,8 +564,8 @@ class Catalog extends database_object { $this->count++; $file = str_replace(array('(',')','\''),'',$full_file); if(UI::check_ticker()) { - update_text('add_count_' . $this->id, $this->count); - update_text('add_dir_' . $this->id, scrub_out($file)); + UI::update_text('add_count_' . $this->id, $this->count); + UI::update_text('add_dir_' . $this->id, scrub_out($file)); } // update our current state } // if it's not an m3u @@ -581,8 +581,8 @@ class Catalog extends database_object { // This should only happen on the last run if ($path == $this->path) { - update_text('add_count_' . $this->id, $this->count); - update_text('add_dir_' . $this->id, scrub_out($file)); + UI::update_text('add_count_' . $this->id, $this->count); + UI::update_text('add_dir_' . $this->id, scrub_out($file)); } @@ -681,16 +681,16 @@ class Catalog extends database_object { /* Stupid little cutesie thing */ $search_count++; if (UI::check_ticker()) { - update_text('count_art_' . $this->id, $search_count); - update_text('read_art_' . $this->id, scrub_out($album->name)); + UI::update_text('count_art_' . $this->id, $search_count); + UI::update_text('read_art_' . $this->id, scrub_out($album->name)); } //echos song count unset($found); } // foreach albums // One last time for good measure - update_text('count_art_' . $this->id, $search_count); - update_text('read_art_' . $this->id, scrub_out($album->name)); + UI::update_text('count_art_' . $this->id, $search_count); + UI::update_text('read_art_' . $this->id, scrub_out($album->name)); self::$_art_albums = array(); @@ -715,12 +715,12 @@ class Catalog extends database_object { /* Stupid little cutesie thing */ $thumb_count++; if (UI::check_ticker()) { - update_text('count_thumb_' . $this->id, $search_count); + UI::update_text('count_thumb_' . $this->id, $search_count); } //echos thumb count } // end foreach albums - update_text('count_thumb_' . $this->id, $search_count); + UI::update_text('count_thumb_' . $this->id, $search_count); } // generate_thumbnails @@ -1308,8 +1308,8 @@ class Catalog extends database_object { $count++; if (UI::check_ticker()) { $file = str_replace(array('(',')', '\''), '', $results['file']); - update_text('clean_count_' . $this->id, $count); - update_text('clean_dir_' . $this->id, scrub_out($file)); + UI::update_text('clean_count_' . $this->id, $count); + UI::update_text('clean_dir_' . $this->id, scrub_out($file)); } if($this->catalog_type == 'local') { $file_info = filesize($results['file']); @@ -1419,8 +1419,8 @@ class Catalog extends database_object { $count++; if (UI::check_ticker()) { $file = str_replace(array('(',')','\''), '', $row['file']); - update_text('verify_count_' . $this->id, $count); - update_text('verify_dir_' . $this->id, scrub_out($file)); + UI::update_text('verify_count_' . $this->id, $count); + UI::update_text('verify_dir_' . $this->id, scrub_out($file)); } if (!is_readable($row['file'])) { @@ -1443,7 +1443,7 @@ class Catalog extends database_object { unset($info); } - update_text('verify_count_' . $this->id, $count); + UI::update_text('verify_count_' . $this->id, $count); return $changed; } // _verfiy_chunk diff --git a/lib/class/ui.class.php b/lib/class/ui.class.php index f6a36075..c3d69198 100644 --- a/lib/class/ui.class.php +++ b/lib/class/ui.class.php @@ -170,4 +170,23 @@ class UI { return $text; } + + /** + * update_text + * + * Convenience function that, if the output is going to a browser, + * blarfs JS to do a fancy update. Otherwise it just outputs the text. + */ + public static function update_text($field, $value) { + if (defined('CLI')) { + echo $value . "\n"; + return; + } + + echo '<script type="text/javascript">'; + echo "updateText('$field', '$value');"; + echo "</script>\n"; + ob_flush(); + flush(); + } } |