コード例 #1
0
ファイル: flv.php プロジェクト: rii-J/concrete5-de
	public function inspect($fv) {
		
		$path = $fv->getPath();
		$at1 = FileAttributeKey::getByHandle('duration');
		$at2 = FileAttributeKey::getByHandle('width');
		$at3 = FileAttributeKey::getByHandle('height');
		
		$fp = @fopen($path,'r');
		@fseek($fp,27);
		$onMetaData = fread($fp,10);
		
		//if ($onMetaData != 'onMetaData') exit('No meta data available in this file! Fix it using this tool: http://www.buraks.com/flvmdi/');
		
		@fseek($fp,16,SEEK_CUR);
		$duration = array_shift(unpack('d',strrev(fread($fp,8))));
		
		@fseek($fp,8,SEEK_CUR);
		$width = array_shift(unpack('d',strrev(fread($fp,8))));
		
		@fseek($fp,9,SEEK_CUR);
		$height = array_shift(unpack('d',strrev(fread($fp,8))));
		
		$fv->setAttribute($at1, $duration);
		$fv->setAttribute($at2, $width);
		$fv->setAttribute($at3, $height);
				
	}
コード例 #2
0
ファイル: image.php プロジェクト: ojalehto/concrete5-legacy
 /**
  * @param $fv FileVersion
  * @return bool
  */
 public function inspect($fv)
 {
     $result = false;
     $path = $fv->getPath();
     $size = @getimagesize($path);
     if ($size) {
         if ($size[0] > 0) {
             $atWidth = FileAttributeKey::getByHandle('width');
             if (is_object($atWidth)) {
                 $fv->setAttribute($atWidth, $size[0]);
             }
         }
         if ($size[1] > 0) {
             $atHeight = FileAttributeKey::getByHandle('height');
             if (is_object($atHeight)) {
                 $fv->setAttribute($atHeight, $size[1]);
             }
         }
         // create a level one and a level two thumbnail
         // load up image helper
         $hi = Loader::helper('image');
         /* @var $hi ImageHelper */
         // Use image helper to create thumbnail at the right size
         $fv->createThumbnailDirectories();
         $hi->create($fv->getPath(), $fv->getThumbnailPath(1), AL_THUMBNAIL_WIDTH, AL_THUMBNAIL_HEIGHT);
         $hi->create($fv->getPath(), $fv->getThumbnailPath(2), AL_THUMBNAIL_WIDTH_LEVEL2, AL_THUMBNAIL_HEIGHT_LEVEL2);
         $result = true;
     }
     return $result;
 }
コード例 #3
0
ファイル: php.php プロジェクト: VonUniGE/concrete5-1
 public function inspect($fv)
 {
     $path = $fv->getPath();
     $ft = FileTypeList::getInstance();
     $ft->defineImporterAttribute('lines', t('Lines of Code'), 'NUMBER', false);
     $at1 = FileAttributeKey::getByHandle('lines');
     $fv->setAttribute($at1, trim(exec('/bin/cat \'' . $path . '\' | wc -l')));
 }
コード例 #4
0
ファイル: slideshow.php プロジェクト: nveid/concrete5
	function loadFileSet(){
		if (intval($this->fsID) < 1) {
			return false;
		}
        Loader::helper('concrete/file');
		Loader::model('file_attributes');
		Loader::library('file/types');
		Loader::model('file_list');
		Loader::model('file_set');
		
		$ak = FileAttributeKey::getByHandle('height');

		$fs = FileSet::getByID($this->fsID);
		$fileList = new FileList();		
		$fileList->filterBySet($fs);
		$fileList->filterByType(FileType::T_IMAGE);	
		$fileList->sortByFileSetDisplayOrder();
		
		$files = $fileList->get(1000,0);
		
		
		$image = array();
		$image['duration'] = $this->duration;
		$image['fadeDuration'] = $this->fadeDuration;
		$image['groupSet'] = 0;
		$image['url'] = '';
		$images = array();
		$maxHeight = 0;
		foreach ($files as $f) {
			$fp = new Permissions($f);
			if(!$fp->canViewFile()) { continue; }
			$image['fID'] 			= $f->getFileID();
			$image['fileName'] 		= $f->getFileName();
			$image['fullFilePath'] 	= $f->getPath();
			$image['url']			= $f->getRelativePath();
			
			// find the max height of all the images so slideshow doesn't bounce around while rotating
			$vo = $f->getAttributeValueObject($ak);
			if (is_object($vo)) {
				$image['imgHeight'] = $vo->getValue('height');
			}
			if ($maxHeight == 0 || $image['imgHeight'] > $maxHeight) {
				$maxHeight = $image['imgHeight'];
			}
			$images[] = $image;
		}
		$this->images = $images;
	
	}
コード例 #5
0
ファイル: image.php プロジェクト: Mihail9575/concrete5
 public function inspect($fv)
 {
     $path = $fv->getPath();
     $size = getimagesize($path);
     // sets an attribute - these file attribute keys should be added
     // by the system and "reserved"
     $at1 = FileAttributeKey::getByHandle('width');
     $at2 = FileAttributeKey::getByHandle('height');
     $fv->setAttribute($at1, $size[0]);
     $fv->setAttribute($at2, $size[1]);
     // create a level one and a level two thumbnail
     // load up image helper
     $hi = Loader::helper('image');
     // Use image helper to create thumbnail at the right size
     $fv->createThumbnailDirectories();
     $hi->create($fv->getPath(), $fv->getThumbnailPath(1), AL_THUMBNAIL_WIDTH, AL_THUMBNAIL_HEIGHT);
     $hi->create($fv->getPath(), $fv->getThumbnailPath(2), AL_THUMBNAIL_WIDTH_LEVEL2, AL_THUMBNAIL_HEIGHT_LEVEL2);
 }
コード例 #6
0
ファイル: video.php プロジェクト: ojalehto/concrete5-legacy
 /**
  * @param $fv FileVersion
  */
 public function inspect($fv)
 {
     $result = false;
     try {
         Loader::library('3rdparty/getid3/getid3');
         $gi3 = new getID3();
         $info = $gi3->analyze($fv->getPath());
         if (is_array($info) && empty($info['error'])) {
             $duration = $this->getNumber($info, 'playtime_seconds');
             if (!is_null($duration) && $duration > 0) {
                 $atDuration = FileAttributeKey::getByHandle('duration');
                 if (is_object($atDuration)) {
                     $fv->setAttribute($atDuration, $duration);
                 }
                 $result = true;
             }
             $width = $this->getNumber($info, array('video', 'display_x'));
             if (is_null($width) || $width <= 0 || $info['video']['display_unit'] !== 'pixels') {
                 $width = $this->getNumber($info, array('video', 'resolution_x'));
             }
             if (!is_null($width) && $width > 0) {
                 $atWidth = FileAttributeKey::getByHandle('width');
                 if (is_object($atWidth)) {
                     $fv->setAttribute($atWidth, $width);
                 }
                 $result = true;
             }
             $height = $this->getNumber($info, array('video', 'display_y'));
             if (is_null($height) || $height <= 0 || $info['video']['display_unit'] !== 'pixels') {
                 $height = $this->getNumber($info, array('video', 'resolution_y'));
             }
             if (!is_null($height) && $height > 0) {
                 $atHeight = FileAttributeKey::getByHandle('height');
                 if (is_object($atHeight)) {
                     $fv->setAttribute($atHeight, $height);
                 }
                 $result = true;
             }
         }
     } catch (Exception $x) {
     }
     return $result;
 }
コード例 #7
0
ファイル: controller.php プロジェクト: robchenski/ids
 private function installPageLinkAttribute(&$pkg)
 {
     $at = AttributeType::getByHandle('page_selector');
     if ($at && intval($at->getAttributeTypeID())) {
         //Associate with "file" category (if not done alrady)
         Loader::model('attribute/categories/collection');
         $akc = AttributeKeyCategory::getByHandle('file');
         $sql = 'SELECT COUNT(*) FROM AttributeTypeCategories WHERE atID = ? AND akCategoryID = ?';
         $vals = array($at->getAttributeTypeID(), $akc->akCategoryID);
         $existsInCategory = Loader::db()->GetOne($sql, $vals);
         if (!$existsInCategory) {
             $akc->associateAttributeKeyType($at);
         }
         //Install the link-to-page attribute (if not done already)
         Loader::model('file_attributes');
         $akHandle = 'gallery_link_to_cid';
         $akGalleryLinkToCID = FileAttributeKey::getByHandle($akHandle);
         if (!is_object($akGalleryLinkToCID) || !intval($akGalleryLinkToCID->getAttributeKeyID())) {
             $akGalleryLinkToCID = FileAttributeKey::add($at, array('akHandle' => $akHandle, 'akName' => t('Gallery Link To Page')), $pkg);
         }
     }
 }
コード例 #8
0
ファイル: audio.php プロジェクト: ojalehto/concrete5-legacy
 /**
  * @param $fv FileVersion
  * @return bool
  */
 public function inspect($fv)
 {
     $result = false;
     try {
         Loader::library('3rdparty/getid3/getid3');
         $gi3 = new getID3();
         $info = $gi3->analyze($fv->getPath());
         if (is_array($info) && empty($info['error'])) {
             if (is_int($info['playtime_seconds']) || is_float($info['playtime_seconds']) || is_string($info['playtime_seconds']) && is_numeric($info['playtime_seconds'])) {
                 $duration = floatval($info['playtime_seconds']);
                 if ($duration > 0) {
                     $atDuration = FileAttributeKey::getByHandle('duration');
                     if (is_object($atDuration)) {
                         $fv->setAttribute($atDuration, $duration);
                     }
                     $result = true;
                 }
             }
         }
     } catch (Exception $x) {
     }
     return $result;
 }
コード例 #9
0
ファイル: file_version.php プロジェクト: nbourguig/concrete5
	public function setAttribute($ak, $value) {
		if (!is_object($ak)) {
			$ak = FileAttributeKey::getByHandle($ak);
		}
		$ak->setAttribute($this, $value);
		$fo = $this->getFile();
		$fo->refreshCache();
		$fo->reindex();
		unset($ak);
	}
コード例 #10
0
 public function addFile($file)
 {
     Loader::library("file/importer");
     Loader::library("mootools/plugin_parser", FRONTEND_DEVELOPER_PACKAGE_HANDLE);
     $fi = new FileImporter();
     $fv = $fi->import($file, basename($file), $this->getExistFile(basename($file)));
     if (!$fv instanceof FileVersion) {
         $message = FileImporter::getErrorMessage($result);
         return $message;
     }
     $parser = new MootoolsPluginParser();
     $meta = $parser->parse($file);
     $requireValues = array();
     if (is_array($meta["requires"])) {
         $requires = $meta["requires"];
         foreach ($requires as $module) {
             $option = SelectAttributeTypeOption::getByValue($module);
             if (empty($option)) {
                 $ak = FileAttributeKey::getByHandle(MOOTOOLS_PLUGIN_DEPENDENCES);
                 $type = SelectAttributeTypeOption::add($ak, $module, true);
                 $value = $type->getSelectAttributeOptionValue();
             } else {
                 $value = $option->getSelectAttributeOptionValue();
             }
             $requireValues[$value] = $value;
         }
     }
     $namespaces = explode('.', $meta['name']);
     $packageName = array_shift($namespaces);
     $moduleName = str_replace('.js', '', basename($file));
     $componentName = $packageName . '/' . $moduleName;
     $authors = is_array($meta["authors"]) ? join(",", $meta["authors"]) : $meta["authors"];
     $license = is_array($meta["license"]) ? join(",", $meta["license"]) : $meta["license"];
     $fv->setAttribute(MOOTOOLS_PLUGIN, true);
     $fv->setAttribute(MOOTOOLS_COMPONENT_NAME, $componentName);
     $fv->setAttribute(MOOTOOLS_PLUGIN_LICENSE, $license);
     $fv->setAttribute(MOOTOOLS_PLUGIN_AUTHORS, $authors);
     $fv->setAttribute(MOOTOOLS_PLUGIN_DEPENDENCES, $requireValues);
     $fv->setAttribute(MOOTOOLS_PLUGIN_DISPLAY_ORDER, 0);
     $fv->updateDescription($meta["description"]);
     $fv->updateTags("mootools\nplugin");
     $this->_fileset->addFileToSet($fv);
     return $fv;
 }
コード例 #11
0
ファイル: controller.php プロジェクト: janzenz/c5_boilerplate
 private function installFileAttributes($pkg)
 {
     $fakc = AttributeKeyCategory::getByHandle('file');
     // Multiple means an attribute can be in more than one set, but you
     // can't choose what set they show up in for the gui
     // $fakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_MULTIPLE);
     // $fakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_NONE);
     $fakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
     $bfa = $fakc->addSet('c5_boilerplate_file_attributes', t('Boilerplate File Attributes'), $pkg);
     //add boolean attributes
     $bp_boolean = FileAttributeKey::getByHandle('bp_boolean');
     if (!$bp_boolean instanceof FileAttributeKey) {
         $bp_boolean = FileAttributeKey::add('boolean', array('akHandle' => 'bp_boolean', 'akName' => t('Boolean Name'), 'akIsSearchable' => true, 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($bfa);
     }
     //add text attributes
     $bp_text = FileAttributeKey::getByHandle('bp_text');
     if (!$bp_text instanceof FileAttributeKey) {
         $bp_text = FileAttributeKey::add('text', array('akHandle' => 'bp_text', 'akName' => t('Text Name'), 'akIsSearchable' => true, 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($bfa);
     }
 }