示例#1
0
文件: objects.php 项目: eokyere/elgg
 /**
  * Construct a new object entity, optionally from a given id value.
  *
  * @param mixed $guid If an int, load that GUID. 
  * 	If a db row then will attempt to load the rest of the data.
  * @throws Exception if there was a problem creating the object. 
  */
 function __construct($guid = null)
 {
     $this->initialise_attributes();
     if (!empty($guid)) {
         // Is $guid is a DB row - either a entity row, or a object table row.
         if ($guid instanceof stdClass) {
             // Load the rest
             if (!$this->load($guid->guid)) {
                 throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid));
             }
         } else {
             if ($guid instanceof ElggObject) {
                 foreach ($guid->attributes as $key => $value) {
                     $this->attributes[$key] = $value;
                 }
             } else {
                 if ($guid instanceof ElggEntity) {
                     throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonElggObject'));
                 } else {
                     if (is_numeric($guid)) {
                         if (!$this->load($guid)) {
                             IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid));
                         }
                     } else {
                         throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue'));
                     }
                 }
             }
         }
     }
 }
示例#2
0
 public function checkFileExists()
 {
     //Get the correct path to asset
     switch ($this->type) {
         case Asset::ASSET_TYPE_CSS:
             $this->assetFolder = $this->paths['css'];
             break;
         case Asset::ASSET_TYPE_JS:
             $this->assetFolder = $this->paths['js'];
             break;
         case Asset::ASSET_TYPE_IMAGE:
             $this->assetFolder = $this->paths['images'];
             break;
         default:
             $folder = '';
     }
     //Path to file
     $file = new PhingFile($this->assetsDir . '/' . $this->assetFolder . $this->file);
     //Check file exists
     if (!$file->exists()) {
         throw new BuildException("Unable to find asset file: " . $file->getAbsolutePath());
     }
     //Check we can read it
     if (!$file->canRead()) {
         throw IOException("Unable to read asset file: " . $file->getPath());
     }
     return $file;
 }
 /**
  * @param string $version
  * @param string $packageRoot path to chosen plugin root in the package
  * @throws IOException
  * @return installation URL
  */
 public function getInstallActionURL($version, $packageRoot)
 {
     $guid = $this->getGUID();
     $path = self::_getPackageBasePath($guid, $version) . 'entity';
     if (!file_exists($path)) {
         throw IOException("Invalid parameter or broken installation package at: {$path}");
     }
     $url = elgg_get_config('wwwroot') . 'action/plugin/install';
     $url = elgg_http_add_url_query_elements($url, array('guid' => $guid, 'version' => $version, 'root' => $packageRoot));
     $url = elgg_add_action_tokens_to_url($url);
     return $url;
 }