本文整理汇总了PHP中FileSet类的典型用法代码示例。如果您正苦于以下问题:PHP FileSet类的具体用法?PHP FileSet怎么用?PHP FileSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_add
public function do_add()
{
extract($this->getHelperObjects());
Loader::model('file_set');
if (!$validation_token->validate("file_sets_add")) {
$this->set('error', array($validation_token->getErrorMessage()));
return;
}
if (!trim($this->post('file_set_name'))) {
$this->set('error', array(t('Please Enter a Name')));
return;
}
$setName = trim($this->post('file_set_name'));
if (preg_match('/[<>;{}?"`]/i', $setName)) {
$this->set('error', array(t('File Set Name cannot contain the characters: %s', Loader::helper('text')->entities('<>;{}?"`'))));
return;
}
//print('<pre>');print_r(get_included_files());print('</pre>');
$u = new User();
$file_set = new FileSet();
//AS: Adodb Active record is complaining a ?/value array mismatch unless
//we explicatly set the primary key ID field to null
$file_set->fsID = null;
$file_set->fsName = $setName;
$file_set->fsType = FileSet::TYPE_PUBLIC;
$file_set->uID = $u->getUserID();
$file_set->fsOverrideGlobalPermissions = $this->post('fsOverrideGlobalPermissions') == 1 ? 1 : 0;
$file_set->save();
$this->redirect('/dashboard/files/sets', 'file_set_added');
}
示例2: schemaConfiguration
protected function schemaConfiguration(Task $task)
{
// Adds schema(s) to task
foreach ($this->schemas as $pair) {
$fileSet = new FileSet();
$fileSet->setDir($pair[0]);
$fileSet->setIncludes($pair[1]);
$task->addSchemaFileset($fileSet);
}
// Sets up output dir, for class, SQL or conf output
$task->setOutputDirectory(new PhingFile($this->outputDir));
}
示例3: file_sets_edit
public function file_sets_edit(){
extract($this->getHelperObjects());
Loader::model('file_set');
//do my editing
if (!$validation_token->validate("file_sets_edit")) {
$this->set('error', array($validation_token->getErrorMessage()));
$this->view();
return;
}
if(!$this->post('fsID')){
$this->set('error', array(t('Invalid ID')));
$this->view();
}
$file_set = new FileSet();
$file_set->Load('fsID = ?', $this->post('fsID'));
$file_set->fsName = $this->post('file_set_name');
$copyPermissionsFromBase = false;
if ($file_set->fsOverrideGlobalPermissions == 0 && $this->post('fsOverrideGlobalPermissions') == 1) {
// we are checking the checkbox for the first time
$copyPermissionsFromBase = true;
}
if ($file_set->fsOverrideGlobalPermissions) {
$permissions = PermissionKey::getList('file_set');
foreach($permissions as $pk) {
$pk->setPermissionObject($file_set);
$pt = $pk->getPermissionAssignmentObject();
$paID = $_POST['pkID'][$pk->getPermissionKeyID()];
$pt->clearPermissionAssignment();
if ($paID > 0) {
$pa = PermissionAccess::getByID($paID, $pk);
if (is_object($pa)) {
$pt->assignPermissionAccess($pa);
}
}
}
}
$file_set->fsOverrideGlobalPermissions = ($this->post('fsOverrideGlobalPermissions') == 1) ? 1 : 0;
$file_set->save();
parse_str($this->post('fsDisplayOrder'));
$file_set->updateFileSetDisplayOrder($fID);
if ($file_set->fsOverrideGlobalPermissions == 0) {
$file_set->resetPermissions();
}
if ($copyPermissionsFromBase) {
$file_set->acquireBaseFileSetPermissions();
}
$this->redirect("/dashboard/files/sets", 'view_detail', $this->post('fsID'), 'file_set_updated');
}
示例4: save
public function save()
{
if (Loader::helper('validation/token')->validate('save_permissions')) {
$fs = FileSet::getGlobal();
$tp = new TaskPermission();
if ($tp->canAccessTaskPermissions()) {
$permissions = PermissionKey::getList('file_set');
foreach ($permissions as $pk) {
$pk->setPermissionObject($fs);
$paID = $_POST['pkID'][$pk->getPermissionKeyID()];
$pt = $pk->getPermissionAssignmentObject();
$pt->clearPermissionAssignment();
if ($paID > 0) {
$pa = PermissionAccess::getByID($paID, $pk);
if (is_object($pa)) {
$pt->assignPermissionAccess($pa);
}
}
}
$this->redirect('/dashboard/system/permissions/files', 'updated');
}
} else {
$this->error->add(Loader::helper("validation/token")->getErrorMessage());
}
}
示例5: on_start
public function on_start()
{
Events::extend('on_file_add', function ($f, $fv) {
$setless_fs = FileSet::getByName('Setless');
$setless_fs->addFileToSet($f);
});
Events::extend('on_file_added_to_set', function ($fID, $fv) {
$setless_fs = FileSet::getByName('Setless');
$file = File::getByID($fID);
$file_sets = $file->getFileSets();
$file_set_ids = array();
foreach ($file_sets as $file_set) {
$file_set_ids[] = $file_set->fsID;
}
// If file is in multiple sets and setless is one of them, remove from setless
if (count($file_set_ids) >= 2 && in_array($setless_fs->fsID, $file_set_ids)) {
$setless_fs->removeFileFromSet($file);
}
});
Events::extend('on_file_removed_from_set', function ($fID, $fv) {
$setless_fs = FileSet::getByName('Setless');
$file = File::getByID($fID);
$file_sets = $file->getFileSets();
// If file is no longer in any sets, add to setless
if (count($file_sets) == 0) {
$setless_fs->addFileToSet($file);
}
});
}
示例6: addFilesForProduct
public static function addFilesForProduct(array $files, StoreProduct $product)
{
self::removeFilesForProduct($product);
//add new ones.
if (!empty($files['dffID'])) {
foreach ($files['dffID'] as $fileID) {
if (!empty($fileID) && $fileID > 0) {
self::add($product->getProductID(), $fileID);
$fileObj = \File::getByID($fileID);
$fs = \FileSet::getByName("Digital Downloads");
$fs->addFileToSet($fileObj);
$fileObj->resetPermissions(1);
$pk = \Concrete\Core\Permission\Key\FileKey::getByHandle('view_file');
$pk->setPermissionObject($fileObj);
$pao = $pk->getPermissionAssignmentObject();
$groupEntity = \Concrete\Core\Permission\Access\Entity\GroupEntity::getOrCreate(\Group::getByID(GUEST_GROUP_ID));
$pa = $pk->getPermissionAccessObject();
if ($pa) {
$pa->removeListItem($groupEntity);
$pao->assignPermissionAccess($pa);
}
}
}
}
}
示例7: main
/**
* Reads the corresponding actions and templates of the cronk (if any) from cronk.xml
* and creates two references "cronkTemplate" and "cronkAction" which can be used to access these files
*/
public function main()
{
$templates = array();
$actionPath = "";
$action = null;
$module = null;
$cronkName = $this->project->getUserProperty("cronkName");
// Setup and load the DOM of the cronk
$DOM = new DOMDocument("1.0", "UTF-8");
$DOM->load($this->getFile());
$DOMSearcher = new DOMXPath($DOM);
$DOMSearcher->registerNamespace("default", "http://agavi.org/agavi/1.0/config");
$DOMSearcher->registerNamespace("ae", "http://agavi.org/agavi/config/global/envelope/1.0");
$cronkTemplates = $DOMSearcher->query("//ae:parameter[@name='" . $cronkName . "']//ae:parameter[@name='template']");
if ($cronkTemplates->length > 0) {
foreach ($cronkTemplates as $template) {
$templates[] = $template->nodeValue;
}
}
// fetch action and module
$action = $DOMSearcher->query("//ae:parameter[@name='" . $cronkName . "']//ae:parameter[@name='action']")->item(0);
$module = $DOMSearcher->query("//ae:parameter[@name='" . $cronkName . "']//ae:parameter[@name='module']")->item(0);
$actionName = str_replace(".", "/", $action->nodeValue);
// add agavi action,validation, view and templates
$cronkFS = new FileSet();
$cronkFS->setDir($this->project->getUserProperty("PATH_Icinga") . "/app/modules/" . $module->nodeValue);
$cronkIncludes = "actions/" . $actionName . "Action.class.php";
$cronkIncludes .= ",templates/" . $actionName . "*.class.php";
$cronkIncludes .= ",validate/" . $actionName . ".xml";
$cronkIncludes .= ",views/" . $actionName . "*.class.php";
$cronkFS->setIncludes($cronkIncludes);
// add templates
$templateFs = new FileSet();
$templateFs->setDir($this->project->getUserProperty("PATH_Icinga") . "/app/modules/Cronks/data/xml/");
$includes = "";
$first = true;
foreach ($templates as $template) {
$includes .= ($first ? '' : ',') . $template . ".xml";
}
// export to phing
$templateFs->setIncludes($includes);
$this->project->addReference("cronkTemplates", $templateFs);
$this->project->addReference("cronkAction", $cronkFS);
}
示例8: setPermissionObject
public function setPermissionObject(FileSet $fs)
{
$this->permissionObject = $fs;
if ($fs->overrideGlobalPermissions()) {
$this->permissionObjectToCheck = $fs;
} else {
$fs = FileSet::getGlobal();
$this->permissionObjectToCheck = $fs;
}
}
示例9: __construct
public function __construct()
{
$fp = new Permissions(\FileSet::getGlobal());
$tp = new Permissions();
$this->assets = ResponseAssetGroup::get();
$this->token = Core::make("token")->generate('editor');
$this->setAllowFileManager($fp->canAccessFileManager());
$this->setAllowSitemap($tp->canAccessSitemap());
$this->pluginManager = new PluginManager();
$this->pluginManager->selectMultiple(\Package::getByHandle('community_ckeditor')->getConfig()->get('plugins', array()));
}
示例10: view
public function view()
{
$fs = FileSet::getByID($this->fsID);
$fileList = new FileList();
$fileList->filterBySet($fs);
$fileList->filterByType(FileType::T_IMAGE);
$fileList->sortByFileSetDisplayOrder();
$images = $fileList->get(1000, 0);
$this->set('images', $images);
$this->set('picture', $this->getPicture());
}
示例11: loadFileSet
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;
}
示例12: filterBySet
public function filterBySet($fs) {
if ($fs != false) {
$this->filteredFileSetIDs[] = intval($fs->getFileSetID());
} else {
$s1 = FileSet::getMySets();
$sets = array();
foreach($s1 as $fs) {
$sets[] = $fs->getFileSetID();
}
if (count($sets) == 0) {
return false;
}
$db = Loader::db();
$setStr = implode(',', $sets);
$this->addToQuery("left join FileSetFiles fsfex on fsfex.fID = f.fID");
$this->filter(false, '(fsfex.fID is null or (select count(fID) from FileSetFiles where fID = fsfex.fID and fsID in (' . $setStr . ')) = 0)');
}
}
示例13: setPermissionObject
public function setPermissionObject(File $f)
{
$this->permissionObject = $f;
if ($f->overrideFileSetPermissions()) {
$this->permissionObjectToCheck = $f;
} else {
$sets = $f->getFileSets();
$permsets = array();
foreach ($sets as $fs) {
if ($fs->overrideGlobalPermissions()) {
$permsets[] = $fs;
}
}
if (count($permsets) > 0) {
$this->permissionObjectToCheck = $permsets;
} else {
$fs = FileSet::getGlobal();
$this->permissionObjectToCheck = $fs;
}
}
}
示例14: getUnsortedPermittedFilesetImages
public static function getUnsortedPermittedFilesetImages($fsID)
{
Loader::model('file_set');
Loader::model('file_list');
$fsHasDisplayOrder = version_compare(APP_VERSION, '5.4.1', '>=');
$fs = FileSet::getByID($fsID);
$fl = new FileList();
$fl->filterBySet($fs);
$fl->filterByType(FileType::T_IMAGE);
if ($fsHasDisplayOrder) {
$fl->sortByFileSetDisplayOrder();
}
$all_files = $fl->get();
$permitted_files = array();
foreach ($all_files as $f) {
$fp = new Permissions($f);
if ($fp->canRead()) {
$permitted_files[] = $f;
}
}
return $permitted_files;
}
示例15: getPermittedFilesetImages
public static function getPermittedFilesetImages($fsID, $use_file_props_for_title_and_caption = false)
{
Loader::model('file_set');
Loader::model('file_list');
$fsHasDisplayOrder = version_compare(APP_VERSION, '5.4.1', '>=');
$fs = FileSet::getByID($fsID);
$fl = new FileList();
$fl->filterBySet($fs);
$fl->filterByType(FileType::T_IMAGE);
if ($fsHasDisplayOrder) {
$fl->sortByFileSetDisplayOrder();
}
$all_files = $fl->get();
$permitted_files = array();
foreach ($all_files as $f) {
$fp = new Permissions($f);
if ($fp->canRead()) {
$fv = $f->getRecentVersion();
$permitted_files[$f->fID] = array('file' => $f, 'fID' => $f->fID, 'position' => $fsHasDisplayOrder ? $f->fsDisplayOrder : 0, 'title' => $use_file_props_for_title_and_caption ? $fv->getTitle() : '', 'caption' => $use_file_props_for_title_and_caption ? $fv->getDescription() : '');
}
}
return $permitted_files;
}