Example #1
0
 public function __construct($filename, $originalFilename = null, $mimeType = null, $error = null)
 {
     $this->originalFilename = basename($originalFilename);
     $this->mimeType = $mimeType;
     $this->error = $error ?: UPLOAD_ERR_OK;
     return parent::__construct($filename);
 }
Example #2
0
 /**
  * @param Title|string|bool $title
  * @param ForeignApiRepo $repo
  * @param array $info
  * @param bool $exists
  */
 function __construct($title, $repo, $info, $exists = false)
 {
     parent::__construct($title, $repo);
     $this->mInfo = $info;
     $this->mExists = $exists;
     $this->assertRepoDefined();
 }
Example #3
0
 public function __construct($path, $sharedItem, $isLink = false)
 {
     parent::__construct($sharedItem->getPath());
     $this->sharedItem = $sharedItem;
     $this->linkPath = $path;
     $this->isLink = $isLink;
 }
Example #4
0
 /**
  * Constructor
  *
  * @param string $content_id Content id     */
 protected function __construct($content_id)
 {
     $db = AbstractDb::getObject();
     // Init values
     $row = null;
     parent::__construct($content_id);
     $content_id = $db->escapeString($content_id);
     $sql = "SELECT * FROM content_file_image WHERE pictures_id='{$content_id}'";
     $db->execSqlUniqueRes($sql, $row, false);
     if ($row == null) {
         /*
          * Since the parent Content exists, the necessary data in
          * content_group had not yet been created
          */
         $sql = "INSERT INTO content_file_image (pictures_id) VALUES ('{$content_id}')";
         $db->execSqlUpdate($sql, false);
         $sql = "SELECT * FROM content_file_image WHERE pictures_id='{$content_id}'";
         $db->execSqlUniqueRes($sql, $row, false);
         if ($row == null) {
             throw new Exception(_("The content with the following id could not be found in the database: ") . $content_id);
         }
     }
     $this->mBd =& $db;
     $this->pictures_row = $row;
     $this->configEnableEditFilename(false);
     $this->configEnableEditMimeType(false);
 }
Example #5
0
 public function __construct(\stdClass $data)
 {
     parent::__construct($data);
     $this->receiveData("thumb", null, "PhotoSize", true);
     $this->checkData("file_name", false, true);
     $this->checkData("mime_type", false, true);
 }
	/**
	 * Construct a new CSV object for the specified file.
	 *
	 * The specified path needn't exist and can be a relative or an absolute path.
	 * The field separator is set to ',', the char the values are enclosed with is set to '"'.
	 * Excel compatibility mode is turned off by default. Default mode for read and write access is
	 * Unicode.
	 *
	 * FTP fallback is activated automatically for this class.
	 *
	 * @param string Path to a CSV file
	 * @param boolean Shall we read/write header data? true = yes, false = no
	 */
	public function __construct($file, $headers = false) {
		parent::__construct($file, true);
		$this->headers = (boolean) $headers;
		$this->sep = ',';
		$this->quote = '"';
		$this->compat = false;
		$this->setFileMode();
	}
Example #7
0
 /**
  * @param	string	$filename
  * @return	void
  */
 public function __construct($filename)
 {
     parent::__construct($filename);
     // Don't extend all these great directory features to lowly files
     if ($this->isFile()) {
         throw new \Exception("Invalid directory '{$filename}'");
     }
 }
Example #8
0
 /**
  *
  * @param string $path
  * @param string $prefix 
  */
 public function __construct($path = null, $prefix = 'cassea_')
 {
     $path = !is_null($path) & is_writable($path) ? $path : (is_writable($s = sys_get_temp_dir()) ? $s : (is_writable($p = ini_get('upload_tmp_dir')) ? $p : Config::get('root_dir') . Config::get('temp_dir')));
     if (!is_writable($path)) {
         throw new FileSystemException('Temporary directory not writable: ' . $path);
     }
     parent::__construct(tempnam($path, $prefix), true);
 }
Example #9
0
 function __construct($parent, $id, $args = array())
 {
     if (!isset($args['accept_types'])) {
         $args['accept_types'] = array('jpg', 'jpeg', 'png', 'gif');
     }
     $this->special_args('versions', $args, true);
     parent::__construct($parent, $id, $args);
 }
Example #10
0
 public function __construct($path)
 {
     parent::__construct($path);
     //make sure log file and parent directory exists
     if (!$this->exists()) {
         $this->touch(true);
     }
 }
Example #11
0
 protected function __construct($path, $mimetype = null)
 {
     parent::__construct($path, $mimetype);
     $this->set_quality(self::$_DEFAULT_QUALITY);
     $this->_tmp_path = tempnam(sys_get_temp_dir(), 'image');
     $this->_image = imagecreatefromstring(file_get_contents($this->_path));
     $this->_update_temp_file();
 }
Example #12
0
 public function __construct()
 {
     $handle = tmpfile();
     $metaDatas = stream_get_meta_data($handle);
     $tmpFilename = $metaDatas['uri'];
     parent::__construct($tmpFilename);
     $this->handle = $handle;
 }
Example #13
0
 /**
  * Accepts the information of the uploaded file as provided by the PHP global $_FILES.
  *
  * The file object is only created when the uploaded file is valid (i.e. when the
  * isValid() method returns true). Otherwise the only methods that could be called
  * on an UploadedFile instance are:
  *
  *   * getClientOriginalName,
  *   * getClientMimeType,
  *   * isValid,
  *   * getError.
  *
  * Calling any other method on an non-valid instance will cause an unpredictable result.
  *
  * @param string $path         The full temporary path to the file
  * @param string $originalName The original file name
  * @param string $mimeType     The type of the file as provided by PHP
  * @param int    $size         The file size
  * @param int    $error        The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants)
  * @param bool   $test         Whether the test mode is active
  *
  * @throws FileException         If file_uploads is disabled
  * @throws FileNotFoundException If the file does not exist
  */
 public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false)
 {
     $this->originalName = $this->getName($originalName);
     $this->mimeType = $mimeType ?: 'application/octet-stream';
     $this->size = $size;
     $this->error = $error ?: UPLOAD_ERR_OK;
     $this->test = (bool) $test;
     parent::__construct($path, UPLOAD_ERR_OK === $this->error);
 }
Example #14
0
 /**
  * TemporaryFile constructor.
  *
  * @param string $folderPath テンポラリフォルダを作成するフォルダパス。指定されなければテンポラリフォルダを作成する
  */
 public function __construct($folderPath = null)
 {
     if ($folderPath === null) {
         $this->_tmpFolder = new TemporaryFolder();
         $folderPath = $this->_tmpFolder->path;
     }
     $fileName = Security::hash(mt_rand() . microtime(), 'md5');
     register_shutdown_function(array($this, 'delete'));
     parent::__construct($folderPath . DS . $fileName, true);
 }
Example #15
0
 public function __construct(array $data)
 {
     if (!isset($data['name'])) {
         throw new \InvalidArgumentException("Input array does not contain the 'name' key");
     }
     if (!isset($data['tmp_name'])) {
         throw new \InvalidArgumentException("Input array does not contain the 'tmp_name' key");
     }
     parent::__construct($data['name'], $data['tmp_name']);
 }
Example #16
0
 /**
  * Redirects to File::__construct()
  * @see File#__construct()
  */
 function __construct($fullpath = false, $parent = false)
 {
     parent::__construct($fullpath, $parent);
     $this->icon = 'small/folder_picture';
     global $Controller;
     if (!$this->isRoot()) {
         $this->editable['FileMover'] = EDIT;
         $this->editable['Delete'] = DELETE;
         $this->alias = 'fileRoot';
     }
 }
Example #17
0
 /**
  * Constructor
  *
  * @param   string  $extension  CMS Extension to load asset from
  * @param   string  $name       Asset name (optional)
  * @return  void
  */
 public function __construct($extension, $name = null)
 {
     parent::__construct($extension, $name);
     // Try to detect if the asset is a declaration
     if (!$extension || strstr($name, '(') || strstr($name, ';')) {
         $this->declaration = true;
         // Reset the name in case any parsing/modification
         // happened in the parent constructor.
         $this->name = $name;
     }
 }
Example #18
0
 /**
  * Constructor.
  * Do not call this except from inside a repo class.
  */
 function __construct($title, $repo)
 {
     if (!is_object($title)) {
         throw new MWException(__CLASS__ . ' constructor given bogus title.');
     }
     parent::__construct($title, $repo);
     $this->metadata = '';
     $this->historyLine = 0;
     $this->historyRes = null;
     $this->dataLoaded = false;
 }
Example #19
0
 public function __construct(array $file)
 {
     //Check if provided input is a valid $_FILES array
     if (!isset($file['name'])) {
         throw new \InvalidArgumentException("Input file array does not contain the 'name' key");
     }
     if (!isset($file['tmp_name'])) {
         throw new \InvalidArgumentException("Input array does not contain the 'tmp_name' key");
     }
     //Execute parent constructor and create File object
     parent::__construct($file['name'], $file['tmp_name']);
 }
Example #20
0
 public function __construct($filenameOrWidth, $height = null)
 {
     if (is_int($filenameOrWidth)) {
         $this->width = $filenameOrWidth;
         $this->height = $height;
     } else {
         parent::__construct($filenameOrWidth);
         $imginfo = getimagesize($filenameOrWidth);
         $this->width = $imginfo[0];
         $this->height = $imginfo[1];
     }
 }
Example #21
0
 /**
  * TemporaryUploadFile constructor.
  *
  * アップロードファイルは、自動的に作成されたテンポラリフォルダに配置される。
  * インスタンス破棄時にテンポラリフォルダ毎ファイルも削除される
  * ファイル名は自動的にハッシュしたものに書き換わる。
  *
  * @param array $file アップロードファイルの配列
  * @throws InternalErrorException
  */
 public function __construct($file)
 {
     $this->temporaryFolder = new TemporaryFolder();
     $path = $file['tmp_name'];
     $this->originalName = $file['name'];
     $destFileName = Security::hash(mt_rand() . microtime(), 'md5') . '.' . pathinfo($file['name'], PATHINFO_EXTENSION);
     $result = $this->_moveFile($path, $this->temporaryFolder->path . DS . $destFileName);
     if ($result === false) {
         throw new InternalErrorException('move_uploaded_file failed');
     }
     $this->error = $file['error'];
     parent::__construct($this->temporaryFolder->path . DS . $destFileName);
 }
Example #22
0
 public function __construct($extension = '')
 {
     $dir = CACHE_DIR;
     $rand = uniqid(time() . getmypid());
     if (!is_dir($dir)) {
         // may still fail, silently ignore
         @mkdir($dir, 0700);
     }
     do {
         $name = sprintf("%s/%s-%04d%s", $dir, $rand, self::$ctr++, $extension);
     } while (is_file($name));
     register_shutdown_function(array($this, 'shutdown'));
     parent::__construct($name, true);
 }
Example #23
0
 /**
  * Initialize Element with xml array
  *
  * @param array $xmlArr
  * @return void
  */
 function __construct(&$xmlArr, $formObj)
 {
     parent::__construct($xmlArr, $formObj);
     $this->readMetaData($xmlArr);
     if (defined("PUBLIC_UPLOAD_PATH")) {
         $this->m_UploadRoot = constant("PUBLIC_UPLOAD_PATH");
     } else {
         $this->m_UploadRoot = APP_HOME . "/files/upload";
     }
     if (defined("PUBLIC_UPLOAD_URL")) {
         $this->m_UploadRootURL = constant("PUBLIC_UPLOAD_URL");
     } else {
         $this->m_UploadRootURL = "/files/upload";
     }
 }
Example #24
0
	function __construct($name, $alt = "") {
		if (!file_exists(PATH."htdocs/assets/$name"))
			$name = "imagenotfound.jpg";
		$this->alt = $alt;
		parent::__construct($name);
		if (!($size = getimagesize($this->path))) {
			throw new ECommerceException('Could not get the stats for $image');
			return false;
		}
		$this->width = $size[0];
		$this->height = $size[1];
		$this->ratio = ($this->width / $this->height);
		$this->bits = $size["bits"];
		$this->mime = $size["mime"];
	}
Example #25
0
 public function __construct($file)
 {
     parent::__construct($file);
     switch ($this->extension) {
         case 'png':
             $this->img = imagecreatefrompng($this->tempName);
             break;
         case 'gif':
             $this->img = imagecreatefromgif($this->tempName);
             break;
         case 'jpg':
         case 'jpeg':
             $this->img = imagecreatefromjpeg($this->tempName);
             break;
     }
     if ($this->img) {
         $this->width = imagesx($this->img);
         $this->height = imagesy($this->img);
     }
 }
 /**
  * ImageFile constructor.
  *
  * @param string $fileName
  * @param string $contentType
  * @param string $url
  * @param int    $size
  * @param int    $width
  * @param int    $height
  */
 public function __construct($fileName, $contentType, $url, $size, $width, $height)
 {
     parent::__construct($fileName, $contentType, $url, $size);
     $this->width = $width;
     $this->height = $height;
 }
Example #27
0
 function __construct($title, $repo, $info, $exists = false)
 {
     parent::__construct($title, $repo);
     $this->mInfo = $info;
     $this->mExists = $exists;
 }
 public function __construct($strFile, $blnDoNotCreate = false)
 {
     $strFile = $strFile . '.' . self::$hashExtension;
     parent::__construct($strFile, $blnDoNotCreate);
 }
Example #29
0
 /**
  * Constructor method; sets the component data.
  *
  * @param $component_name
  *   The identifier for the component.
  * @param $component_data
  *   An array of data for the component. Valid properties are:
  *    - 'routing_items': A numeric array of router items. Each item is an
  *      array with the properties:
  *      - 'path': The path for the item, without the initial '/'.
  */
 function __construct($component_name, $component_data = array())
 {
     parent::__construct($component_name, $component_data);
 }
Example #30
0
 /**
  * Constructor.
  * Do not call this except from inside a repo class.
  */
 function __construct($title, $repo)
 {
     parent::__construct($title, $repo);
     $this->metadata = '';
     $this->historyLine = 0;
     $this->historyRes = null;
     $this->dataLoaded = false;
     $this->extraDataLoaded = false;
     $this->assertRepoDefined();
     $this->assertTitleDefined();
 }