Exemple #1
0
 /**
  * @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;
 }
Exemple #2
0
 public function edit($akID = 0)
 {
     if ($this->post('akID')) {
         $akID = $this->post('akID');
     }
     $key = FileAttributeKey::getByID($akID);
     if (!is_object($key) || $key->isAttributeKeyInternal()) {
         $this->redirect('/dashboard/files/attributes');
     }
     $type = $key->getAttributeType();
     $this->set('key', $key);
     $this->set('type', $type);
     if ($this->isPost()) {
         $cnt = $type->getController();
         $cnt->setAttributeKey($key);
         $e = $cnt->validateKey($this->post());
         if ($e->has()) {
             $this->set('error', $e);
         } else {
             $type = AttributeType::getByID($this->post('atID'));
             $key->update($this->post());
             $this->redirect('/dashboard/files/attributes', 'attribute_updated');
         }
     }
 }
Exemple #3
0
 public function run()
 {
     Cache::disableAll();
     $is = new IndexedSearch();
     if ($_GET['force'] == 1) {
         $attributes = \CollectionAttributeKey::getList();
         $attributes = array_merge($attributes, \FileAttributeKey::getList());
         $attributes = array_merge($attributes, \UserAttributeKey::getList());
         foreach ($attributes as $ak) {
             $ak->updateSearchIndex();
         }
         $result = $is->reindexAll(true);
     } else {
         $result = $is->reindexAll();
     }
     if ($result->count == 0) {
         return t('Indexing complete. Index is up to date');
     } else {
         if ($result->count == $is->searchBatchSize) {
             return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count);
         } else {
             return t('Index updated.') . ' ' . t2('%d page required reindexing.', '%d pages required reindexing.', $result->count, $result->count);
         }
     }
 }
Exemple #4
0
	public function run() {
		Cache::disableCache();

		Loader::library('database_indexed_search');
		$is = new IndexedSearch();
		if ($_GET['force'] == 1) {
			Loader::model('attribute/categories/collection');
			Loader::model('attribute/categories/file');
			Loader::model('attribute/categories/user');
			$attributes = CollectionAttributeKey::getList();
			$attributes = array_merge($attributes, FileAttributeKey::getList());
			$attributes = array_merge($attributes, UserAttributeKey::getList());
			foreach($attributes as $ak) {
				$ak->updateSearchIndex();
			}

			$result = $is->reindexAll(true);
		} else {
			$result = $is->reindexAll();
		}
		if ($result->count == 0) {
			return t('Indexing complete. Index is up to date');
		} else {
			if ($result->count == $is->searchBatchSize) {
				return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count);
			} else {
				return t('Index updated. %s %s required reindexing.', $result->count, $result->count == 1 ? t('page') : t('pages'));
			}
		}
	}
Exemple #5
0
	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);
				
	}
Exemple #6
0
 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')));
 }
Exemple #7
0
	public function reindex() {
		Loader::model('attribute/categories/file');
		$attribs = FileAttributeKey::getAttributes($this->getFileID(), $this->getFileVersionID(), 'getSearchIndexValue');
		$db = Loader::db();

		$db->Execute('delete from FileSearchIndexAttributes where fID = ?', array($this->getFileID()));
		$searchableAttributes = array('fID' => $this->getFileID());
		$rs = $db->Execute('select * from FileSearchIndexAttributes where fID = -1');
		AttributeKey::reindex('FileSearchIndexAttributes', $searchableAttributes, $attribs, $rs);
	}
Exemple #8
0
	/** 
	 * Filters by "keywords" (which searches everything including filenames, title, tags, users who uploaded the file, tags)
	 */
	public function filterByKeywords($keywords) {
		$db = Loader::db();
		$keywordsExact = $db->quote($keywords);
		$qkeywords = $db->quote('%' . $keywords . '%');
		$keys = FileAttributeKey::getSearchableIndexedList();
		$attribsStr = '';
		foreach ($keys as $ak) {
			$cnt = $ak->getController();			
			$attribsStr.=' OR ' . $cnt->searchKeywords($keywords);
		}
		$this->filter(false, '(fvFilename like ' . $qkeywords . ' or fvDescription like ' . $qkeywords . ' or fvTitle like ' . $qkeywords . ' or fvTags like ' . $qkeywords . ' or u.uName = ' . $keywordsExact . $attribsStr . ')');
	}
Exemple #9
0
	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;
	
	}
Exemple #10
0
 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);
 }
Exemple #11
0
 /**
  * @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;
 }
 public function start(Zend_Queue $q)
 {
     Loader::library('database_indexed_search');
     $this->is = new IndexedSearch();
     Loader::model('attribute/categories/collection');
     Loader::model('attribute/categories/file');
     Loader::model('attribute/categories/user');
     $attributes = CollectionAttributeKey::getList();
     $attributes = array_merge($attributes, FileAttributeKey::getList());
     $attributes = array_merge($attributes, UserAttributeKey::getList());
     foreach ($attributes as $ak) {
         $ak->updateSearchIndex();
     }
     $db = Loader::db();
     $db->Execute('truncate table PageSearchIndex');
     $r = $db->Execute('select Pages.cID from Pages left join CollectionSearchIndexAttributes csia on Pages.cID = csia.cID where (ak_exclude_search_index is null or ak_exclude_search_index = 0) and cIsActive = 1');
     while ($row = $r->FetchRow()) {
         $q->send($row['cID']);
     }
 }
Exemple #13
0
 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);
         }
     }
 }
Exemple #14
0
 /**
  * @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;
 }
Exemple #15
0
 public function edit($akID = 0)
 {
     if ($this->post('akID')) {
         $akID = $this->post('akID');
     }
     $key = FileAttributeKey::getByID($akID);
     $type = $key->getAttributeType();
     $this->set('key', $key);
     $this->set('type', $type);
     if ($this->isPost()) {
         $cnt = $type->getController();
         $cnt->setAttributeKey($key);
         $e = $cnt->validateKey($this->post());
         if ($e->has()) {
             $this->set('error', $e);
         } else {
             $type = AttributeType::getByID($this->post('atID'));
             $args = array('akHandle' => $this->post('akHandle'), 'akName' => $this->post('akName'), 'akIsSearchable' => $this->post('akIsSearchable'), 'akIsSearchableIndexed' => $this->post('akIsSearchableIndexed'), 'akIsAutoCreated' => 0, 'akIsEditable' => 1);
             $key->update($this->post());
             $this->redirect('/dashboard/files/attributes', 'attribute_updated');
         }
     }
 }
 public function install()
 {
     Loader::library('mootools/attribute', FRONTEND_DEVELOPER_PACKAGE_HANDLE);
     $pkg = parent::install();
     Loader::model('single_page');
     Loader::model('attribute/categories/user');
     Loader::model('attribute/categories/file');
     $singlePages = array("/dashboard/mootools" => array('cName' => t('Mootools Plugin Developer'), 'cDescription' => t('Management of mootools plugin')), "/dashboard/mootools/plugin" => array('cName' => t('plugin'), 'cDescription' => t('Management of Mootools Plugin that does import')), "/dashboard/mootools/importer" => array('cName' => t('import'), 'cDescription' => t('Import from repository')));
     foreach ($singlePages as $key => $page) {
         $collection = SinglePage::add($key, $pkg);
         if (!empty($collection)) {
             $collection->update($page);
         }
     }
     //The name of the user of github is added to the attribute.
     $values = array("akHandle" => MOOTOOLS_GITHUB_USER, "akName" => t("Name of user of github"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true);
     $key = UserAttributeKey::add("text", $values, $pkg);
     $fileAttributes = array(array("type" => "boolean", "values" => array("akHandle" => MOOTOOLS_PLUGIN, "akName" => t("This file is a plugin of Mootools"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "text", "values" => array("akHandle" => MOOTOOLS_COMPONENT_NAME, "akName" => t("Component name of Mootools"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "text", "values" => array("akHandle" => MOOTOOLS_PLUGIN_LICENSE, "akName" => t("License of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "text", "values" => array("akHandle" => MOOTOOLS_PLUGIN_AUTHORS, "akName" => t("Authors of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "select", "values" => array("akHandle" => MOOTOOLS_PLUGIN_DEPENDENCES, "akName" => t("Dependence of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "number", "values" => array("akHandle" => MOOTOOLS_PLUGIN_DISPLAY_ORDER, "akName" => t("The order of display of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)));
     $attributesKeys = array();
     foreach ($fileAttributes as $key => $attr) {
         $type = $attr["type"];
         $values = $attr["values"];
         $handle = $values["akHandle"];
         $attributesKeys[$handle] = FileAttributeKey::add($type, $values, $pkg);
     }
     if (!empty($attributesKeys[MOOTOOLS_PLUGIN_DEPENDENCES])) {
         $key = $attributesKeys[MOOTOOLS_PLUGIN_DEPENDENCES];
         $db = Loader::db();
         $db->Replace('atSelectSettings', array('akID' => $key->getAttributeKeyID(), 'akSelectAllowMultipleValues' => true), array('akID'), true);
     }
     BlockType::installBlockTypeFromPackage("mootools_plugin_build_form", $pkg);
     BlockType::installBlockTypeFromPackage("github_tags", $pkg);
     BlockType::installBlockTypeFromPackage("github_issues", $pkg);
     BlockType::installBlockTypeFromPackage("github_repository", $pkg);
     PageTheme::add('small_project', $pkg);
 }
Exemple #17
0
	protected function upgradeFileAttributes() {
		$messages = array();
		$db = Loader::db();
		$r = $db->Execute('select _FileAttributeKeys.* from _FileAttributeKeys order by fakID asc');
		while ($row = $r->FetchRow()) {
			$cleanHandle = preg_replace("/[^A-Za-z0-9\_]/",'',$row['akHandle']); // remove spaces, chars that'll mess up our index tables
			$existingAKID = $db->GetOne('select akID from AttributeKeys where akHandle = ?',  array($cleanHandle) );
			if ($existingAKID < 1) {
				$args = array(
					'akHandle' => $cleanHandle,
					'akIsSearchable' => $row['akSearchable'],
					'akIsAutoCreated' => $row['akIsImporterAttribute'],
					'akIsEditable' => $row['akIsEditable'],
					'akName' => $row['akName']			
				);
				$sttype = $row['akType'];
				switch($row['akType']) {
					case 'SELECT':
					case 'SELECT_ADD':
						if ($row['akAllowOtherValues']) {
							$args['akSelectAllowMultipleValues'] = 1;
						}
						$sttype = 'SELECT';
						break;
					case 'SELECT_MULTIPLE':
						$sttype = 'SELECT';
						$args['akSelectAllowMultipleValues'] = 1;
						if ($row['akAllowOtherValues']) {
							$args['akSelectAllowMultipleValues'] = 1;
						}
						break;
				}
				
				$type = AttributeType::getByHandle(strtolower($sttype));
				$ak = FileAttributeKey::add($type, $args);
				if ($sttype == 'SELECT') {
					$selectOptions = explode("\n", $row['akValues']);
					foreach($selectOptions as $so) {
						if ($so != '') {
							SelectAttributeTypeOption::add($ak, $so);
						}
					}
				}
			} else {
				$ak = FileAttributeKey::getByID($existingAKID);
			}
			
			$r2 = $db->Execute('select * from _FileAttributeValues where fakID = ? and isImported = 0', $row['fakID']);
			while ($row2 = $r2->FetchRow()) {
				$f = File::getByID($row2['fID']);
				$fv = $f->getVersion($row2['fvID']);
				$value = $row2['value'];
				if ($row['akType'] == 'SELECT' || $row['akType'] == 'SELECT_MULTIPLE' || $row['akType'] == 'SELECT_ADD') {
					$value = explode("\n", $value);					
				}
				$fv->setAttribute($ak, $value);
				unset($f);
				unset($fv);

				$db->Execute('update _FileAttributeValues set isImported = 1 where fakID = ? and fvID = ? and fID = ?', array($row['fakID'], $row2['fvID'], $row2['fID']));
				$this->incrementImported();
			}
			
			unset($ak);
			unset($row2);
			$r2->Close();
			unset($r2);
		}
		
		unset($row);
		$r->Close();
		unset($r);
		return $messages;
	}
Exemple #18
0
	/** 
	 * @access private 
	 */
	public function get($akID) {
		return FileAttributeKey::getByID($akID);
	}
Exemple #19
0
?>
</h4>

                <?php 
if ($previewMode) {
    $mode = 'preview';
}
?>
                <?php 
Loader::element('files/properties', array('fv' => $fv, 'mode' => $mode));
?>

            </section>

            <?php 
$attribs = FileAttributeKey::getList();
if (count($attribs) > 0) {
    ?>

                <section>

                    <h4><?php 
    echo t('Attributes');
    ?>
</h4>

                    <?php 
    Loader::element('attribute/editable_list', array('attributes' => $attribs, 'object' => $f, 'saveAction' => $controller->action('update_attribute'), 'clearAction' => $controller->action('clear_attribute'), 'permissionsArguments' => $fp->canEditFileProperties(), 'permissionsCallback' => function ($ak, $permissionsArguments) {
        return $permissionsArguments;
    }));
    ?>
Exemple #20
0
	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);
	}
    $value = '';
    $ak = FileAttributeKey::get($fakID);
    foreach ($files as $f) {
        $fv = $f->getVersionToModify();
        $ak->saveAttributeForm($fv);
    }
    $fv->populateAttributes();
    $val = $fv->getAttributeValueObject($ak);
    print $val->getValue('display');
    exit;
}
if ($_POST['task'] == 'clear_extended_attribute' && $fp->canEditFileProperties() && !$previewMode) {
    $fv = $f->getVersionToModify();
    $fakID = $_REQUEST['fakID'];
    $value = '';
    $ak = FileAttributeKey::get($fakID);
    foreach ($files as $f) {
        $fv = $f->getVersionToModify();
        $fv->clearAttribute($ak);
    }
    $fv->populateAttributes();
    $val = $fv->getAttributeValueObject($ak);
    print '<div class="ccm-attribute-field-none">' . t('None') . '</div>';
    exit;
}
function printCorePropertyRow($title, $field, $value, $formText)
{
    global $previewMode, $f, $fp, $files, $form;
    if ($value == '') {
        $text = '<div class="ccm-attribute-field-none">' . t('None') . '</div>';
    } else {
if ($_POST['task'] == 'update_columns') {
	
	$fdc = new FileManagerColumnSet();
	foreach($_POST['column'] as $key) {
		$fdc->addColumn($fldca->getColumnByKey($key));
	}	
	$sortCol = $fldca->getColumnByKey($_POST['fSearchDefaultSort']);
	$fdc->setDefaultSortColumn($sortCol, $_POST['fSearchDefaultSortDirection']);
	$u->saveConfig('FILE_LIST_DEFAULT_COLUMNS', serialize($fdc));
	
	$fileList = new FileList();
	$fileList->resetSearchRequest();
	exit;
}

$list = FileAttributeKey::getList();

?>
<div class="ccm-ui">

<form method="post" id="ccm-<?php 
echo $searchInstance;
?>
-customize-search-columns-form" action="<?php 
echo REL_DIR_FILES_TOOLS_REQUIRED;
?>
/files/customize_search_columns/">
<?php 
echo $form->hidden('task', 'update_columns');
?>
 public function getRequestedSearchResults()
 {
     $fileList = new FileList();
     $fileList->enableStickySearchRequest();
     Loader::model('file_set');
     if ($_REQUEST['submit_search']) {
         $fileList->resetSearchRequest();
     }
     $req = $fileList->getSearchRequest();
     // first thing, we check to see if a saved search is being used
     if (isset($_REQUEST['fssID'])) {
         $fs = FileSet::getByID($_REQUEST['fssID']);
         if ($fs->getFileSetType() == FileSet::TYPE_SAVED_SEARCH) {
             $req = $fs->getSavedSearchRequest();
             $columns = $fs->getSavedSearchColumns();
             $colsort = $columns->getDefaultSortColumn();
             $fileList->addToSearchRequest('ccm_order_dir', $colsort->getColumnDefaultSortDirection());
             $fileList->addToSearchRequest('ccm_order_by', $colsort->getColumnKey());
         }
     }
     if (!isset($columns)) {
         $columns = FileManagerColumnSet::getCurrent();
     }
     $this->set('searchRequest', $req);
     $this->set('columns', $columns);
     $col = $columns->getDefaultSortColumn();
     $fileList->sortBy($col->getColumnKey(), $col->getColumnDefaultSortDirection());
     $keywords = htmlentities($req['fKeywords'], ENT_QUOTES, APP_CHARSET);
     if ($keywords != '') {
         $fileList->filterByKeywords($keywords);
     }
     if ($req['numResults']) {
         $fileList->setItemsPerPage($req['numResults']);
     }
     if (isset($req['fsIDNone']) && $req['fsIDNone'] == 1 || is_array($req['fsID']) && in_array(-1, $req['fsID'])) {
         $fileList->filterBySet(false);
     } else {
         if (is_array($req['fsID'])) {
             foreach ($req['fsID'] as $fsID) {
                 $fs = FileSet::getByID($fsID);
                 $fileList->filterBySet($fs);
             }
         } else {
             if (isset($req['fsID']) && $req['fsID'] != '' && $req['fsID'] > 0) {
                 $set = $req['fsID'];
                 $fs = FileSet::getByID($set);
                 $fileList->filterBySet($fs);
             }
         }
     }
     if (isset($_GET['fType']) && $_GET['fType'] != '') {
         $type = $_GET['fType'];
         $fileList->filterByType($type);
     }
     if (isset($_GET['fExtension']) && $_GET['fExtension'] != '') {
         $ext = $_GET['fExtension'];
         $fileList->filterByExtension($ext);
     }
     $selectedSets = array();
     if (is_array($req['selectedSearchField'])) {
         foreach ($req['selectedSearchField'] as $i => $item) {
             // due to the way the form is setup, index will always be one more than the arrays
             if ($item != '') {
                 switch ($item) {
                     case "extension":
                         $extension = $req['extension'];
                         $fileList->filterByExtension($extension);
                         break;
                     case "type":
                         $type = $req['type'];
                         $fileList->filterByType($type);
                         break;
                     case "date_added":
                         $dateFrom = $req['date_from'];
                         $dateTo = $req['date_to'];
                         if ($dateFrom != '') {
                             $dateFrom = date('Y-m-d', strtotime($dateFrom));
                             $fileList->filterByDateAdded($dateFrom, '>=');
                             $dateFrom .= ' 00:00:00';
                         }
                         if ($dateTo != '') {
                             $dateTo = date('Y-m-d', strtotime($dateTo));
                             $dateTo .= ' 23:59:59';
                             $fileList->filterByDateAdded($dateTo, '<=');
                         }
                         break;
                     case 'added_to':
                         $ocID = $req['ocIDSearchField'];
                         if ($ocID > 0) {
                             $fileList->filterByOriginalPageID($ocID);
                         }
                         break;
                     case "size":
                         $from = $req['size_from'];
                         $to = $req['size_to'];
                         $fileList->filterBySize($from, $to);
                         break;
                     default:
                         Loader::model('file_attributes');
                         $akID = $item;
                         $fak = FileAttributeKey::get($akID);
                         $type = $fak->getAttributeType();
                         $cnt = $type->getController();
                         $cnt->setRequestArray($req);
                         $cnt->setAttributeKey($fak);
                         $cnt->searchForm($fileList);
                         break;
                 }
             }
         }
     }
     if (isset($req['numResults'])) {
         $fileList->setItemsPerPage($req['numResults']);
     }
     return $fileList;
 }
 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;
 }
defined('C5_EXECUTE') or die("Access Denied.");
?>
 
<?php 
Loader::model('file_set');
$searchFields = array('' => '** ' . t('Fields'), 'size' => t('Size'), 'type' => t('Type'), 'extension' => t('Extension'), 'date_added' => t('Added Between'), 'added_to' => t('Added to Page'));
if ($_REQUEST['fType'] != false) {
    unset($searchFields['type']);
}
if ($_REQUEST['fExtension'] != false) {
    unset($searchFields['extension']);
}
$html = Loader::helper('html');
Loader::model('file_attributes');
$searchFieldAttributes = FileAttributeKey::getSearchableList();
foreach ($searchFieldAttributes as $ak) {
    $searchFields[$ak->getAttributeKeyID()] = $ak->getAttributeKeyDisplayHandle();
}
$ext1 = FileList::getExtensionList();
$extensions = array();
foreach ($ext1 as $value) {
    $extensions[$value] = $value;
}
$t1 = FileList::getTypeList();
$types = array();
foreach ($t1 as $value) {
    $types[$value] = FileType::getGenericTypeText($value);
}
?>
Exemple #26
0
    echo t('%s File Properties', $ft);
    ?>
</h4>
<table border="0" cellspacing="0" cellpadding="0" class="ccm-grid">
<?php 
    foreach ($attribs as $at) {
        printFileAttributeRow($at, $fv);
    }
    ?>
</table>
<?php 
}
?>

<?php 
$attribs = FileAttributeKey::getUserAddedList();
if (count($attribs) > 0) {
    ?>

<br/>

<h4><?php 
    echo t('Other Properties');
    ?>
</h4>
<table border="0" cellspacing="0" cellpadding="0" class="ccm-grid">
<?php 
    foreach ($attribs as $at) {
        printFileAttributeRow($at, $fv);
    }
    ?>
Exemple #27
0
 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);
     }
 }