예제 #1
0
 /**
  * Fetchs a document by id and returns it as an instance of
  * JForg_Dodb_Document
  * 
  * @param scalar $id The document id
  * 
  * @return JForg_Dodb_Document
  * @author Bahtiar Gadimov <*****@*****.**>
  */
 public function fetch($id)
 {
     if ($this->_caching) {
         $doc = $this->_cache->fetch($id);
         if ($doc) {
             return $doc;
         }
     }
     $data = $this->_fetch($id);
     $doc = $this->arrayToDocument($data);
     if ($this->_caching) {
         $this->_cache->add($doc->fetchDocumentId(), $doc);
     }
     return $doc;
 }
예제 #2
0
 /**
  * 
  * Fetches the public key data from TypeKey.
  * 
  * If a cache object was injected at construction time, uses
  * a cached version of the public key instead of hitting the
  * TypeKey server.
  * 
  * The URI used is "http://www.typekey.com/extras/regkeys.txt".
  * 
  * @return array An array with keys 'p', 'q', 'g', and 'pub_key'
  * as extracted from the fetched key string.
  * 
  */
 protected function _fetchKeyData()
 {
     $cache_key = $this->_config['cache_key'];
     if ($this->_cache) {
         $info = $this->_cache->fetch($cache_key);
         if ($info) {
             // cache hit
             return $info;
         }
     }
     // cache miss, or no cache.  get from typekey.
     $src = file_get_contents('http://www.typekey.com/extras/regkeys.txt');
     $lines = explode(' ', trim($src));
     foreach ($lines as $line) {
         $val = explode('=', $line);
         $info[$val[0]] = $val[1];
     }
     // save in the cache?
     if ($this->_cache) {
         $this->_cache->save($cache_key, $info);
     }
     // done
     return $info;
 }