本文整理汇总了PHP中DataObjectSet::find方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectSet::find方法的具体用法?PHP DataObjectSet::find怎么用?PHP DataObjectSet::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectSet
的用法示例。
在下文中一共展示了DataObjectSet::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute()
{
set_error_handler('exception_error_handler');
$results = false;
$msg = array('text' => $this->type() == 'SELECT' ? 'no records' : 'no errors', 'type' => 'good');
try {
$results = DB::getConn()->query($this->query, E_USER_NOTICE);
} catch (Exception $e) {
$msg = array('text' => htmlentities($e->getMessage()), 'type' => 'error');
}
restore_error_handler();
$fields = new DataObjectSet();
$records = new DataObjectSet();
if (isset($results) && $results instanceof SS_Query) {
foreach ($results as $result) {
$record = new DBP_Record();
$data = array();
foreach ($result as $field => $val) {
if (!$fields->find('Label', $field)) {
$fields->push(new DBP_Field($field));
}
$data[$field] = strlen($val) > 64 ? substr($val, 0, 63) . '<span class="truncated">…</span>' : $val;
}
$record->Data($data);
$records->push($record);
}
}
return array('Query' => $this->query, 'Fields' => $fields, 'Records' => $records, 'Message' => $msg);
}
示例2: getContextNav
function getContextNav() {
if($this->ID > 0) {
$pages = new DataObjectSet();
$pages->push($this->Parent());
$pages->merge($this->getPagesBySibling());
$pages->merge($this->getPagesByKeyword());
$pages->merge($this->getPagesByBlogTags());
$pages->merge($this->getPagesByReferer());
$pages->removeDuplicates();
$currentPage = $pages->find('ID', $this->ID);
if($currentPage) $pages->remove($currentPage);
return $pages;
} else {
return false;
}
}
示例3: process
/**
* Process the form that is submitted through the site
*
* @param Array Data
* @param Form Form
* @return Redirection
*/
function process($data, $form)
{
// submitted form object
$submittedForm = new SubmittedForm();
$submittedForm->SubmittedByID = ($id = Member::currentUserID()) ? $id : 0;
$submittedForm->ParentID = $this->ID;
$submittedForm->Recipient = $this->EmailTo;
if (!$this->DisableSaveSubmissions) {
$submittedForm->write();
}
// email values
$values = array();
$recipientAddresses = array();
$sendCopy = false;
$attachments = array();
$submittedFields = new DataObjectSet();
foreach ($this->Fields() as $field) {
// don't show fields that shouldn't be shown
if (!$field->showInReports()) {
continue;
}
$submittedField = $field->getSubmittedFormField();
$submittedField->ParentID = $submittedForm->ID;
$submittedField->Name = $field->Name;
$submittedField->Title = $field->Title;
if ($field->hasMethod('getValueFromData')) {
$submittedField->Value = $field->getValueFromData($data);
} else {
if (isset($data[$field->Name])) {
$submittedField->Value = $data[$field->Name];
}
}
if (!empty($data[$field->Name])) {
if (in_array("EditableFileField", $field->getClassAncestry())) {
if (isset($_FILES[$field->Name])) {
// create the file from post data
$upload = new Upload();
$file = new File();
$upload->loadIntoFile($_FILES[$field->Name], $file);
// write file to form field
$submittedField->UploadedFileID = $file->ID;
// Attach the file if its less than 1MB, provide a link if its over.
if ($file->getAbsoluteSize() < 1024 * 1024 * 1) {
$attachments[] = $file;
}
}
}
}
if (!$this->DisableSaveSubmissions) {
$submittedField->write();
}
$submittedFields->push($submittedField);
}
$emailData = array("Sender" => Member::currentUser(), "Fields" => $submittedFields);
// email users on submit. All have their own custom options.
if ($this->EmailRecipients()) {
$email = new UserDefinedForm_SubmittedFormEmail($submittedFields);
$email->populateTemplate($emailData);
if ($attachments) {
foreach ($attachments as $file) {
// bug with double decorated fields, valid ones should have an ID.
if ($file->ID != 0) {
$email->attachFile($file->Filename, $file->Filename, $file->getFileType());
}
}
}
foreach ($this->EmailRecipients() as $recipient) {
$email->populateTemplate($recipient);
$email->populateTemplate($emailData);
$email->setFrom($recipient->EmailFrom);
$email->setBody($recipient->EmailBody);
$email->setSubject($recipient->EmailSubject);
$email->setTo($recipient->EmailAddress);
// check to see if they are a dynamic sender. eg based on a email field a user selected
if ($recipient->SendEmailFromField()) {
$submittedFormField = $submittedFields->find('Name', $recipient->SendEmailFromField()->Name);
if ($submittedFormField) {
$email->setFrom($submittedFormField->Value);
}
}
// check to see if they are a dynamic reciever eg based on a dropdown field a user selected
if ($recipient->SendEmailToField()) {
$submittedFormField = $submittedFields->find('Name', $recipient->SendEmailToField()->Name);
if ($submittedFormField) {
$email->setTo($submittedFormField->Value);
}
}
if ($recipient->SendPlain) {
$body = strip_tags($recipient->EmailBody) . "\n ";
if (isset($emailData['Fields']) && !$recipient->HideFormData) {
foreach ($emailData['Fields'] as $Field) {
$body .= $Field->Title . ' - ' . $Field->Value . ' \\n';
}
//.........这里部分代码省略.........
示例4: process
/**
* Process the form that is submitted through the site
*
* @param Array Data
* @param Form Form
* @return Redirection
*/
function process($data, $form)
{
Session::set("FormInfo.{$form->FormName()}.data", $data);
Session::clear("FormInfo.{$form->FormName()}.errors");
foreach ($this->Fields() as $field) {
$messages[$field->Name] = $field->getErrorMessage()->HTML();
if ($field->Required) {
if (!isset($data[$field->Name]) || !$data[$field->Name] || !$field->getFormField()->validate($this->validator)) {
$form->addErrorMessage($field->Name, $field->getErrorMessage()->HTML(), 'bad');
}
}
}
if (Session::get("FormInfo.{$form->FormName()}.errors")) {
Director::redirectBack();
return;
}
$submittedForm = Object::create('SubmittedForm');
$submittedForm->SubmittedByID = ($id = Member::currentUserID()) ? $id : 0;
$submittedForm->ParentID = $this->ID;
// if saving is not disabled save now to generate the ID
if (!$this->DisableSaveSubmissions) {
$submittedForm->write();
}
$values = array();
$attachments = array();
$submittedFields = new DataObjectSet();
foreach ($this->Fields() as $field) {
if (!$field->showInReports()) {
continue;
}
$submittedField = $field->getSubmittedFormField();
$submittedField->ParentID = $submittedForm->ID;
$submittedField->Name = $field->Name;
$submittedField->Title = $field->getField('Title');
// save the value from the data
if ($field->hasMethod('getValueFromData')) {
$submittedField->Value = $field->getValueFromData($data);
} else {
if (isset($data[$field->Name])) {
$submittedField->Value = $data[$field->Name];
}
}
if (!empty($data[$field->Name])) {
if (in_array("EditableFileField", $field->getClassAncestry())) {
if (isset($_FILES[$field->Name])) {
// create the file from post data
$upload = new Upload();
$file = new File();
$file->ShowInSearch = 0;
$upload->loadIntoFile($_FILES[$field->Name], $file);
// write file to form field
$submittedField->UploadedFileID = $file->ID;
// attach a file only if lower than 1MB
if ($file->getAbsoluteSize() < 1024 * 1024 * 1) {
$attachments[] = $file;
}
}
}
}
if (!$this->DisableSaveSubmissions) {
$submittedField->write();
}
$submittedFields->push($submittedField);
}
$emailData = array("Sender" => Member::currentUser(), "Fields" => $submittedFields);
// email users on submit.
if ($this->EmailRecipients()) {
$email = new UserDefinedForm_SubmittedFormEmail($submittedFields);
$email->populateTemplate($emailData);
if ($attachments) {
foreach ($attachments as $file) {
if ($file->ID != 0) {
$email->attachFile($file->Filename, $file->Filename, HTTP::getMimeType($file->Filename));
}
}
}
foreach ($this->EmailRecipients() as $recipient) {
$email->populateTemplate($recipient);
$email->populateTemplate($emailData);
$email->setFrom($recipient->EmailFrom);
$email->setBody($recipient->EmailBody);
$email->setSubject($recipient->EmailSubject);
$email->setTo($recipient->EmailAddress);
// check to see if they are a dynamic sender. eg based on a email field a user selected
if ($recipient->SendEmailFromField()) {
$submittedFormField = $submittedFields->find('Name', $recipient->SendEmailFromField()->Name);
if ($submittedFormField) {
$email->setFrom($submittedFormField->Value);
}
}
// check to see if they are a dynamic reciever eg based on a dropdown field a user selected
if ($recipient->SendEmailToField()) {
$submittedFormField = $submittedFields->find('Name', $recipient->SendEmailToField()->Name);
//.........这里部分代码省略.........