本文整理汇总了PHP中Folder::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::save方法的具体用法?PHP Folder::save怎么用?PHP Folder::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNotDeletableForUser
/**
* @param sfGuardUser $user
* @param $type
* @param $create_if_not_exists
* @return mixed
*/
public function getNotDeletableForUser(sfGuardUser $user, $type, $create_if_not_exists = true)
{
$folder = $this->createQuery('f')->whereIn('f.user_id', sfGuardUserTable::getInstance()->getUsersInTeamIDs($user))->andWhere('f.deletable = ?', 0)->andWhere('f.type = ?', $type)->fetchOne();
if (!$folder && $create_if_not_exists) {
$folder = new Folder();
$folder->setName('Default');
$folder->setUserId($user->getId());
$folder->setDeletable(0);
$folder->setType($type);
$folder->save();
}
return $folder;
}
示例2: save
/**
* @description Apply settings
*/
public function save()
{
if ($this->isset == false) {
// If the file does not exist check his way, create a folder that does not exist
$folder = new Folder(dirname($this->path));
$folder->save();
}
$mode = self::MODE_ADD_CONTENT;
if ($this->newContentReplace) {
$mode = self::MODE_REPLACE_CONTENT;
}
$this->write($mode);
// and set configs to file
$this->update();
}
示例3: executeNewFolder
public function executeNewFolder(sfWebRequest $request)
{
$this->forward404Unless($request->isXmlHttpRequest());
$folder = new Folder();
$folder->setName('New ' . InterfaceLabelTable::getInstance()->get($this->getuser()->getGuardUser(), InterfaceLabelTable::FOLDER_TYPE));
$folder->setUser($this->getUser()->getGuardUser());
$folder->setType(Folder::TYPE_ROADMAP);
if (!Folder::getInstance()->getNotDeletableForUser($this->getUser()->getGuardUser(), Folder::TYPE_ROADMAP, false)) {
$folder->setDeletable(false);
}
$folder->save();
// Create log
$log = new Log();
$log->injectDataAndPersist($folder, $this->getUser()->getGuardUser(), array('action' => 'new'));
return $this->renderText(json_encode($folder->getRowData()));
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$data = Input::except(array('_token', '_method'));
$trimmedData = $this->trimData($data, array());
$folder = Folder::where('name', $trimmedData['name'])->get()->first();
if (!empty($folder)) {
Session::flash('flash_error', trans('message.folder.error.already_exist'));
return Redirect::route('secured.folder.create')->withInput();
}
$currentUser = $this->getCurrentUser();
$folder = new Folder();
$folder->fill($trimmedData);
$folder->owner_id = $currentUser->id;
if (!$folder->save()) {
$errors = $folder->errors();
return Redirect::route('secured.folder.create')->withInput()->withErrors($errors);
}
return Redirect::route('secured.folder.index');
}
示例5: handleRoadmaps
public function handleRoadmaps()
{
$default_folders = array();
$conn = Doctrine_Manager::getInstance()->connection();
$roadmaps = $conn->execute("SELECT id, user_id from `roadmap` WHERE folder_id is NULL")->fetchAll();
foreach ($roadmaps as $roadmap) {
if (!array_key_exists($roadmap['user_id'], $default_folders)) {
$folder = $conn->execute("SELECT id from `folder` WHERE `user_id` = :user_id and `type` = '" . Folder::TYPE_ROADMAP . "' and `deletable` = 0 LIMIT 1;", array(':user_id' => $roadmap['user_id']))->fetchAll();
if (count($folder)) {
$default_folders[$roadmap['user_id']] = $folder[0]['id'];
} else {
$folder = new Folder();
$folder->setName('Default');
$folder->setUserId($roadmap['user_id']);
$folder->setDeletable(0);
$folder->setType(Folder::TYPE_ROADMAP);
$folder->save();
$default_folders[$roadmap['user_id']] = $folder->getId();
}
}
$conn->execute("UPDATE `roadmap` SET `folder_id` = :folder_id WHERE id = :id", array(':folder_id' => $default_folders[$roadmap['user_id']], ':id' => $roadmap['id']));
}
}
示例6: User
$userManager->create();
$admin = new User();
$admin->setLogin($_['login']);
$admin->setPassword($_['password'], $cryptographicSalt);
$admin->save();
$_SESSION['currentUser'] = serialize($admin);
// DOSSIERS DE FLUX, RECRÉE LE DOSSIER GÉNÉRAL SI NÉCESSAIRE
$folderManager = new Folder();
$folderManager->create();
if ($folderManager->rowCount() == 0) {
//Création du dossier général
$folder = new Folder();
$folder->setName(_t('GENERAL_FOLDER'));
$folder->setParent(-1);
$folder->setIsopen(1);
$folder->save();
}
// REMET À ZÉRO LA CONFIGURATION
$configurationManager = new Configuration();
if ($configurationManager->tableExists()) {
$configurationManager->truncate();
}
$configurationManager->create();
$configurationManager->add('articleDisplayAnonymous', '0');
$configurationManager->add('articleDisplayAuthor', '1');
$configurationManager->add('articleDisplayDate', '1');
$configurationManager->add('articleDisplayFolderSort', '1');
$configurationManager->add('articleDisplayHomeSort', '1');
$configurationManager->add('articleDisplayLink', '1');
$configurationManager->add('articleDisplayMode', 'summary');
$configurationManager->add('articlePerPages', '5');
示例7: executeAccountCreate
//.........这里部分代码省略.........
}
////////// GET SAVE FOLDERS //////////////
$userFolders = array();
$mediaFolders = array();
$alphaFolder = false;
$mediaAlphaFolder = false;
$rootfolderUser = Rootfolder::getRootfolderByModule('user');
$rootfolderMedia = Rootfolder::getRootfolderByModule('media');
if ($rootfolderUser) {
$folders = Document::getChildrenOf($rootfolderUser->getId(), 'Folder');
}
if ($rootfolderMedia) {
$foldersMedia = Document::getChildrenOf($rootfolderMedia->getId(), 'Folder');
}
foreach ($folders as $folder) {
$userFolders[$folder->getLabel()] = $folder->getId();
}
foreach ($foldersMedia as $folder) {
$mediaFolders[$folder->getLabel()] = $folder->getId();
}
$title = @str_replace($search, $replace, $firstname);
$title = trim(@str_replace(' ', ' ', $title));
$title = mb_strtoupper($title);
$firstLetter = mb_substr($title, 0, 1);
if (array_key_exists($firstLetter, $userFolders)) {
$alphaFolder = Document::getDocumentInstance($userFolders[$firstLetter]);
}
if (array_key_exists($firstLetter, $mediaFolders)) {
$mediaAlphaFolder = Document::getDocumentInstance($mediaFolders[$firstLetter]);
}
if (!$alphaFolder) {
$alphaFolder = new Folder();
$alphaFolder->setLabel($firstLetter);
$alphaFolder->save(null, $rootfolderUser);
}
if (!$mediaAlphaFolder) {
$mediaAlphaFolder = new Folder();
$mediaAlphaFolder->setLabel($firstLetter);
$mediaAlphaFolder->save(null, $rootfolderMedia);
}
////////////////////////////////////////
if ($this->type == "user") {
if ($this->media) {
$this->user->setCv($this->media->getId());
}
$this->user->setEducation($education);
$jobtypes = "";
foreach ($job_types as $jt) {
$jobtypes .= "|";
$jobtypes .= $jt;
}
$this->user->setJobType($jobtypes);
$saved = $this->user->save(null, $alphaFolder);
} elseif ($this->type == "company") {
if (!$this->company) {
$this->company = new Company();
}
$company_folder = Document::getDocumentByExclusiveTag("company_folder_" . $accountType);
$this->company->setLabel($label);
$this->company->setAccountType($accountType);
$this->company->setDescription($description);
$this->company->setCountry($country);
$this->company->setCity($city);
$this->company->setAddress($address);
$this->company->setZip($xip);
$this->company->setWeb($web);
示例8: testQuoting
public function testQuoting()
{
$this->assertEmpty(Folder::model()->findByPk("'"));
$this->assertEmpty(Folder::model()->ancestorsOf("'")->findAll());
$this->assertEmpty(Folder::model()->childrenOf("'")->findAll());
$this->assertEmpty(Folder::model()->parentOf("'")->findAll());
$this->assertEmpty(Folder::model()->deleteNode("'"));
$this->assertEmpty(Folder::model()->descendantsOf("'")->findAll());
$this->assertEmpty(Folder::model()->fullPathOf("'")->findAll());
$this->assertEmpty(Folder::model()->pathOf("'")->findAll());
$this->assertEmpty(Folder::model()->unorderedPathOf("'")->findAll());
/** @var Folder $folder5 */
$folder5 = Folder::model()->findByPk(5);
try {
$folder5->moveTo("'");
$this->fail();
} catch (CDbException $e) {
$this->assertEquals(201, $e->getCode());
}
$newFolder = new Folder();
$newFolder->name = 'Folder';
$this->assertTrue($newFolder->save());
$this->assertEquals(1, $newFolder->appendTo("'"));
try {
Folder::model()->markAsRoot("'");
$this->fail();
} catch (CDbException $e) {
// http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
$this->assertEquals('1452', $e->errorInfo[1]);
}
}
示例9: saveFolder
private function saveFolder(\Request $request)
{
$folder_id = $request->getVar('folder_id');
if ($folder_id) {
$folder = new Folder($folder_id);
} else {
$folder = new Folder();
$folder->setFtype($request->getVar('ftype'));
}
$folder->setTitle($request->getVar('title'));
if (empty($folder->title)) {
$this->sendErrorHeader('<div class="alert alert-danger"><i class="fa fa-times fa-lg"></i> May not use an empty folder name.</div>');
return;
}
$db = \Database::newDB();
$db->addTable('folders')->addFieldConditional('title', $folder->title);
$result = $db->selectOneRow();
// if a duplicate row is found (with a different id) then force an error
if (!empty($result) && $result['id'] != $folder_id) {
$this->sendErrorHeader('<div class="alert alert-danger"><i class="fa fa-times fa-lg"></i> A folder with this name already exists</div>');
} else {
$folder->save();
echo $folder->id;
}
}
示例10: InitData
function InitData($project_name)
{
$listPageType = 'list_types';
$c = new Criteria();
$c->add(ListsPeer::LIST_ID, $listPageType);
$listExist = ListsPeer::doSelectOne($c);
if (!$listExist) {
echo "Creating list 'list_type'...\n";
$newList = new Lists();
$newList->setLabel('List Types');
$newList->setListid($listPageType);
$newList->setListtype('system');
$newList->save();
$newItem = new Listitem();
$newItem->setLabel('System list');
$newItem->setValue('system');
$newItem->save(null, $newList);
$newItem = new Listitem();
$newItem->setLabel('Static list');
$newItem->setValue('static');
$newItem->save(null, $newList);
$newItem = new Listitem();
$newItem->setLabel('Editable list');
$newItem->setValue('editable');
$newItem->save(null, $newList);
}
$listPageType = 'page_types';
$c = new Criteria();
$c->add(ListsPeer::LIST_ID, $listPageType);
$listExist = ListsPeer::doSelectOne($c);
if (!$listExist) {
echo "Creating list 'page_types'...\n";
$newList = new Lists();
$newList->setLabel('Page Types');
$newList->setListid($listPageType);
$newList->setListtype('system');
$newList->save();
$newItem = new Listitem();
$newItem->setLabel('Content page');
$newItem->setValue('CONTENT');
$newItem->save(null, $newList);
$newItem = new Listitem();
$newItem->setLabel('Page reference');
$newItem->setValue('REFERENCE');
$newItem->save(null, $newList);
$newItem = new Listitem();
$newItem->setLabel('External page');
$newItem->setValue('EXTERNAL');
$newItem->save(null, $newList);
}
$cultureType = 'culture';
$c = new Criteria();
$c->add(ListsPeer::LIST_ID, $cultureType);
$listExist = ListsPeer::doSelectOne($c);
if (!$listExist) {
echo "Creating list 'culture'...\n";
$newList = new Lists();
$newList->setLabel('Culture');
$newList->setListid($cultureType);
$newList->setListtype('system');
$newList->save();
$newItem = new Listitem();
$newItem->setLabel('english');
$newItem->setValue('en');
$newItem->save(null, $newList);
/* $newItem = new Listitem();
$newItem->setLabel('български');
$newItem->setValue('bg');
$newItem->save(null, $newList);*/
}
$userType = 'usertype';
$c = new Criteria();
$c->add(ListsPeer::LIST_ID, $userType);
$listExist = ListsPeer::doSelectOne($c);
if (!$listExist) {
echo "Creating list 'user types'...\n";
$newList = new Lists();
$newList->setLabel('User Types');
$newList->setListid($userType);
$newList->setListtype('system');
$newList->save();
$newItem = new Listitem();
$newItem->setLabel('Administrator (all rights)');
$newItem->setValue('admin');
$newItem->save(null, $newList);
$newItem = new Listitem();
$newItem->setLabel('Editor (no access to administration modules)');
$newItem->setValue('editor');
$newItem->save(null, $newList);
$newItem = new Listitem();
$newItem->setLabel('Editor (edit and save existing items)');
$newItem->setValue('restricted_editor');
$newItem->save(null, $newList);
}
$Mailinglist_Folder = Document::getDocumentByExclusiveTag('newsletter_folder_mailinglist');
if (!$Mailinglist_Folder) {
$Newsletter_Root = Rootfolder::getRootfolderByModule('Newsletter');
$Mailinglist_Folder = new Folder();
$Mailinglist_Folder->setLabel('Mailing lists');
$Mailinglist_Folder->save(null, $Newsletter_Root);
//.........这里部分代码省略.........
示例11: addFolder
public function addFolder()
{
$parent = $this->getRequestParam('parent_id', NULL);
$name = $this->getRequestParam('name', '');
$response = new AjaxResponse();
if ($parent >= 0 && !empty($name)) {
try {
$folder = new Folder();
$folder->name = $name;
$folder->parent = Folder::find('_id', $parent);
$folder->save();
$response->success = true;
$response->message = System::getLanguage()->_('SuccessAddFolder');
$response->data = $folder->toJSON();
} catch (InvalidFolderNameException $e) {
$response->success = false;
$response->message = System::getLanguage()->_('ErrorInvalidFolderName');
} catch (FolderAlreadyExistsException $e) {
$response->success = false;
$response->message = System::getLanguage()->_('ErrorFolderAlreadyExists');
} catch (Exception $e) {
$response->success = false;
$response->message = System::getLanguage()->_('ErrorInvalidParameter');
}
} else {
if (empty($name)) {
$response->success = false;
$response->message = System::getLanguage()->_('ErrorEmptyFolderName');
} else {
$response->success = false;
$response->message = System::getLanguage()->_('ErrorInvalidParameter');
}
}
$response->send();
}