Ejemplo n.º 1
0
 /**
 Object constructor.
 
 @param	core		<b>dcCore</b>		dcCore instance
 @param	type		<b>string</b>		Media type filter
 */
 public function __construct($core, $type = '')
 {
     $this->core =& $core;
     $this->con =& $core->con;
     $this->postmedia = new dcPostMedia($core);
     if ($this->core->blog == null) {
         throw new Exception(__('No blog defined.'));
     }
     $this->table = $this->core->prefix . 'media';
     $root = $this->core->blog->public_path;
     if (preg_match('#^http(s)?://#', $this->core->blog->settings->system->public_url)) {
         $root_url = rawurldecode($this->core->blog->settings->system->public_url);
     } else {
         $root_url = rawurldecode($this->core->blog->host . path::clean($this->core->blog->settings->system->public_url));
     }
     if (!is_dir($root)) {
         # Check public directory
         if ($core->auth->isSuperAdmin()) {
             throw new Exception(__("There is no writable directory /public/ at the location set in about:config \"public_path\". You must create this directory with sufficient rights (or change this setting)."));
         } else {
             throw new Exception(__("There is no writable root directory for the media manager. You should contact your administrator."));
         }
     }
     $this->type = $type;
     parent::__construct($root, $root_url);
     $this->chdir('');
     $this->path = $this->core->blog->settings->system->public_path;
     $this->addExclusion(DC_RC_PATH);
     $this->addExclusion(dirname(__FILE__) . '/../');
     $this->exclude_pattern = $core->blog->settings->system->media_exclusion;
     # Event handlers
     $this->addFileHandler('image/jpeg', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/gif', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/jpeg', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/gif', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/png', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/jpeg', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/gif', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/jpeg', 'create', array($this, 'imageMetaCreate'));
     $this->addFileHandler('image/jpeg', 'recreate', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'recreate', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/gif', 'recreate', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/jpeg', 'recreate', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'recreate', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/gif', 'recreate', array($this, 'imageThumbCreate'));
     # Thumbnails sizes
     $this->thumb_sizes['m'][0] = abs($core->blog->settings->system->media_img_m_size);
     $this->thumb_sizes['s'][0] = abs($core->blog->settings->system->media_img_s_size);
     $this->thumb_sizes['t'][0] = abs($core->blog->settings->system->media_img_t_size);
     # Thumbnails sizes names
     $this->thumb_sizes['m'][2] = __($this->thumb_sizes['m'][2]);
     $this->thumb_sizes['s'][2] = __($this->thumb_sizes['s'][2]);
     $this->thumb_sizes['t'][2] = __($this->thumb_sizes['t'][2]);
     $this->thumb_sizes['sq'][2] = __($this->thumb_sizes['sq'][2]);
     # --BEHAVIOR-- coreMediaConstruct
     $this->core->callBehavior('coreMediaConstruct', $this);
 }
Ejemplo n.º 2
0
 /**
  * Object constructor.
  *
  * @param object $core oktCore instance
  * @param string $type Media type filter
  * @return void
  */
 public function __construct($okt, $type = '')
 {
     $this->okt = $okt;
     $this->db = $okt->db;
     $this->config = $okt->media_manager->config;
     $this->t_media = $this->db->prefix . 'mod_media';
     $this->t_users = $this->db->prefix . 'core_users';
     $this->icon_img = OKT_PUBLIC_URL . '/img/media/%s.png';
     $root = OKT_UPLOAD_PATH . '/media_manager/';
     if (!is_dir($root)) {
         files::makeDir($root, true);
     }
     if (preg_match('#^http(s)?://#', OKT_UPLOAD_URL . '/media_manager/')) {
         $root_url = rawurldecode(OKT_UPLOAD_URL . '/media_manager/');
     } else {
         $root_url = rawurldecode($this->okt->config->app_host . path::clean(OKT_UPLOAD_URL . '/media_manager/'));
     }
     if (!is_dir($root)) {
         throw new Exception(sprintf(__('Directory %s does not exist.'), $root));
     }
     $this->type = $type;
     parent::__construct($root, $root_url);
     $this->chdir('');
     $this->path = OKT_UPLOAD_URL . '/media_manager/';
     //		$this->addExclusion(DC_RC_PATH);
     //		$this->addExclusion(__DIR__.'/../');
     $this->exclude_pattern = $this->config->media_exclusion;
     # Event handlers
     $this->addFileHandler('image/jpeg', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/gif', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/jpeg', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/gif', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/png', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/jpeg', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/gif', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/jpeg', 'create', array($this, 'imageMetaCreate'));
     # Thumbnails sizes
     $this->thumb_sizes['m'][0] = abs($this->config->media_img_m_size);
     $this->thumb_sizes['s'][0] = abs($this->config->media_img_s_size);
     $this->thumb_sizes['t'][0] = abs($this->config->media_img_t_size);
 }
Ejemplo n.º 3
0
 /**
 Object constructor.
 
 @param	core		<b>dcCore</b>		dcCore instance
 @param	type		<b>string</b>		Media type filter
 */
 public function __construct(&$core, $type = '')
 {
     $this->core =& $core;
     $this->con =& $core->con;
     if ($this->core->blog == null) {
         throw new Exception(__('No blog defined.'));
     }
     $this->table = $this->core->prefix . 'media';
     $this->table_ref = $this->core->prefix . 'post_media';
     $root = $this->core->blog->public_path;
     if (preg_match('#^http(s)?://#', $this->core->blog->settings->public_url)) {
         $root_url = rawurldecode($this->core->blog->settings->public_url);
     } else {
         $root_url = rawurldecode($this->core->blog->host . path::clean($this->core->blog->settings->public_url));
     }
     if (!is_dir($root)) {
         throw new Exception(sprintf(__('Directory %s does not exist.'), $root));
     }
     $this->type = $type;
     parent::__construct($root, $root_url);
     $this->chdir('');
     $this->path = $this->core->blog->settings->public_path;
     $this->addExclusion(DC_RC_PATH);
     $this->addExclusion(dirname(__FILE__) . '/../');
     $this->exclude_pattern = $core->blog->settings->media_exclusion;
     # Event handlers
     $this->addFileHandler('image/jpeg', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/gif', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/jpeg', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/gif', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/png', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/jpeg', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/gif', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/jpeg', 'create', array($this, 'imageMetaCreate'));
     # Thumbnails sizes
     $this->thumb_sizes['m'][0] = abs($core->blog->settings->media_img_m_size);
     $this->thumb_sizes['s'][0] = abs($core->blog->settings->media_img_s_size);
     $this->thumb_sizes['t'][0] = abs($core->blog->settings->media_img_t_size);
 }