Beispiel #1
0
 public static function cache_dir($pReload = FALSE)
 {
     if (is_null(self::$_cache_dir)) {
         $dir = ZUPAL_ROOT_DIR . DS . Zupal_Bootstrap::$registry->configuration->cache->path . DS . join(DS, array('modules', 'media', 'musicbrainz', 'artists'));
         self::$_cache_dir = $dir;
     }
     if (!is_dir(self::$_cache_dir)) {
         mkdir(self::$_cache_dir, 0775, TRUE);
     }
     return self::$_cache_dir;
 }
 /**
  *
  */
 public function dataAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     switch ($this->_getParam('type')) {
         case 'artist':
             $gid = $this->_getParam('gid');
             $key = str_replace('-', '_', $gid);
             $ac = Zupal_Media_MusicBrainz_Cache_Artists::getInstance();
             if (!$ac->test($key)) {
                 $artist = Zupal_Musicbrainz_Artist::getInstance()->findOne(array('gid' => $gid));
                 $json = $artist->json();
                 // handles caching
             } else {
                 $json = $ac->load($key);
             }
             echo $json;
             break;
     }
 }
Beispiel #3
0
 /**
  *
  * @return string
  */
 public function json($pReload = FALSE)
 {
     $key = str_replace('-', '_', $this->gid);
     $ac = Zupal_Media_MusicBrainz_Cache_Artists::getInstance();
     if ($pReload || !$ac->test($key)) {
         $ac->save(Zend_Json::encode($this->json_data()), $key);
     }
     return $ac->load($key);
 }