当前位置: 首页>>代码示例>>PHP>>正文


PHP DataObject::create方法代码示例

本文整理汇总了PHP中DataObject::create方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::create方法的具体用法?PHP DataObject::create怎么用?PHP DataObject::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataObject的用法示例。


在下文中一共展示了DataObject::create方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Field

 /**
  * Creates a rendered Programme Crawler Field using the .ss template
  * @param type $properties an array of values to decorate the field
  * @return type a rendered template
  */
 function Field($properties = array())
 {
     $obj = $properties ? $this->customise($properties) : $this;
     $obj->Options = ArrayList::create();
     $dobj = DataObject::create();
     $dobj->MyTitle = 'No Color';
     $dobj->Value = '';
     $dobj->CSSRGB = '255 255 255';
     $dobj->CSSHex = '#ffffff';
     $dobj->CSSCMYK = '0 0 0 0';
     $obj->Options->push($dobj);
     $source = ColourSchemes::get()->sort('ID');
     if ($source) {
         foreach ($source as $value) {
             $mobj = DataObject::create();
             $mobj->MyTitle = $value->OPColor;
             $mobj->Value = $value->CSSColor;
             $mobj->CSSRGB = $value->CSSRGB;
             $mobj->CSSHex = $value->CSSHex;
             $mobj->CSSCMYK = $value->CSSCMYK;
             $obj->Options->push($mobj);
         }
     }
     // directly point to the template file
     $tmp = $obj->renderWith(BASE_PATH . '/' . OPCOLORWORKINGFOLDER . "/templates/OpColorField.ss");
     return $tmp;
 }
开发者ID:helpfulrobot,项目名称:otago-opcolor,代码行数:32,代码来源:OpColorField.php

示例2: parseobject

 /**
  * Recursivity creates the SilverStripe dataobject representation of content
  * @param mixed $array
  * @return \DataObject|\DataList|null
  */
 private function parseobject($array)
 {
     if (is_object($array)) {
         if (get_class($array) == 'DataObject') {
             return $array;
         }
         $do = DataObject::create();
         foreach (get_object_vars($array) as $key => $obj) {
             if ($key == '__Type') {
                 $do->setField('Title', $obj);
             } else {
                 if (is_array($obj) || is_object($obj)) {
                     $do->setField($key, $this->parseobject($obj));
                 } else {
                     $do->setField($key, $obj);
                 }
             }
         }
         return $do;
     } else {
         if (is_array($array)) {
             $dataList = ArrayList::create();
             foreach ($array as $key => $obj) {
                 $dataList->push($this->parseobject($obj));
             }
             return $dataList;
         }
     }
     return null;
 }
开发者ID:otago,项目名称:ebs,代码行数:35,代码来源:EBSResponse.php

示例3: Field

 /**
  * Creates a rendered Programme Crawler Field using the .ss template
  * @param type $properties an array of values to decorate the field
  * @return type a rendered template
  */
 function Field($properties = array())
 {
     $obj = $properties ? $this->customise($properties) : $this;
     $obj->Options = ArrayList::create();
     $dobj = DataObject::create(array('MyTitle' => 'No Color', 'Value' => '', 'CSSRGB' => '255 255 255', 'CSSHex' => '#ffffff', 'CSSCMYK' => '0 0 0 0'));
     $obj->Options->push($dobj);
     //go through source, if object it is a custom color, if not, get data from ColourSchemes
     foreach ($this->getSource() as $value) {
         $mobj = DataObject::create();
         if ($value instanceof Object) {
             $mobj->MyTitle = $value->OPColor;
             $mobj->Value = $value->CSSColor;
             $mobj->CSSRGB = $value->CSSRGB;
             $mobj->CSSHex = $value->CSSHex;
             $mobj->CSSCMYK = $value->CSSCMYK;
         } else {
             $cs = ColourSchemes::get()->filter('OPColor', $value)->first();
             if (!empty($cs)) {
                 $mobj->MyTitle = $cs->OPColor;
                 $mobj->Value = $cs->CSSColor;
                 $mobj->CSSRGB = $cs->CSSRGB;
                 $mobj->CSSHex = $cs->CSSHex;
                 $mobj->CSSCMYK = $cs->CSSCMYK;
             }
         }
         $obj->Options->push($mobj);
     }
     // directly point to the template file
     $tmp = $obj->renderWith(BASE_PATH . '/' . OPCOLORWORKINGFOLDER . "/templates/OpColorField.ss");
     return $tmp;
 }
开发者ID:otago,项目名称:opcolor,代码行数:36,代码来源:OpColorField.php

示例4: notify

function notify($dao, $user_id, $notif_title, $notif_message, $link_to_content)
{
    $notification = DataObject::create($dao, "notification", array("user_id" => $user_id, "notif_title" => $notif_title, "notif_message" => $notif_message, "notif_link" => $link_to_content, "notif_departure" => date("Y-m-d H:i:s", time() + 60 * 60)));
    if ($notification) {
        return $notification->commit();
    } else {
        return false;
    }
}
开发者ID:ThisIsGJ,项目名称:unify,代码行数:9,代码来源:add.php

示例5: create

 /**
  * Create log entry with initialisers and write it to the database.
  *
  * If $task or $action left out will do possibly expensive call to debug_backtrace to get calling class and function .
  *
  * SideEffects:
  *  Writes object to the database.
  *
  * @param $action - what the task action is
  * @param $task - what task is logging progress
  * @param string $message defaults to 'Started'
  * @param null $info any additional info on create
  * @return ProgressLogEntry
  */
 public static function create($task = null, $action = null, $message = ProgressLogEntry::ResultMessageStarted, $info = null)
 {
     if (is_null($task) || is_null($action)) {
         $callerInfo = self::get_caller_info();
         if (!$task) {
             $task = $callerInfo[0];
         }
         if (!$action) {
             $action = $callerInfo[1];
         }
     }
     $logEntry = parent::create(array('Task' => $task, 'Action' => $action, 'ResultMessage' => $message, 'ResultInfo' => $info));
     $logEntry->write();
     return $logEntry;
 }
开发者ID:helpfulrobot,项目名称:govtnz-progresslogentry,代码行数:29,代码来源:ProgressLogEntry.php

示例6: create_from_checkfront

 /**
  * Create a model instance and set data using config.checkfront_map paths.
  *
  * @param array $data
  * @param string $forAction
  * @param bool $updateNulls
  * @return CheckfrontModel
  */
 public static function create_from_checkfront(array $data, $forAction = self::DefaultFromAction, $updateNulls = true)
 {
     /** @var CheckfrontModel $model */
     $model = parent::create();
     return $model->fromCheckfront($data, $forAction, $updateNulls);
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-checkfront,代码行数:14,代码来源:Model.php

示例7: array

if (isset($_GET["d"]) && isset($_GET["post_id"])) {
    $direction = $_GET["d"];
    $post_id = $_GET["post_id"];
    $post_vote = DataObject::select_one($dao, "post_vote", array("vote_id"), array("user_id" => $user->user_id, "post_id" => $post_id));
    if ($post_vote) {
        echo Status::json(1, "User has already voted");
    } else {
        $post = DataObject::select_one($dao, "post", array("post_id", "post_rating_up", "post_rating_dn"), array("post_id" => $post_id));
        if ($post) {
            if ($direction == "u") {
                $post->post_rating_up++;
            } else {
                $post->post_rating_dn++;
            }
            if ($post->commit()) {
                $post_vote = DataObject::create($dao, "post_vote", array("user_id" => $user->user_id, "post_id" => $post_id));
                if ($post_vote) {
                    if ($post_vote->commit()) {
                        echo Status::json(0, "Vote added");
                    } else {
                        echo Status::json(2, "Failed to prevent future votes");
                    }
                } else {
                    echo Status::json(3, "Failed to insert post_vote");
                }
            } else {
                echo Status::json(4, "Failed to commit change post rating");
            }
        } else {
            echo Status::json(5, "Failed to select post");
        }
开发者ID:ThisIsGJ,项目名称:unify,代码行数:31,代码来源:vote.php

示例8: DAO

//Add a post to a cohort/user's feed
include "../util/session.php";
include_once "../util/mysql.php";
include "../util/status.php";
include "../notification/add.php";
$group_id = -1;
//For the feed
$dao = new DAO(false);
if (isset($_POST["group_id"])) {
    //For a specific group
    $group_id = $_POST["group_id"];
}
if (isset($_POST["post_content"]) && trim($_POST["post_content"]) != "") {
    $post_content = $_POST["post_content"];
    $post_time = date("Y-m-d H:i:s", time() + 3600);
    $post = DataObject::create($dao, "post", array("user_id" => $user->user_id, "group_id" => $group_id, "post_content" => $post_content, "post_time" => $post_time));
    if ($post) {
        $success = $post->commit();
        if ($success) {
            //Notify the group of students
            if ($group_id != -1) {
                $notification_users = DataObject::select_all($dao, "grouping", array("grouping_id", "user_id"), array("group_id" => $group_id));
                $notification_title = "New post in your group.";
                $notification_message = "{$user->user_name} has posted in your group.";
                $notification_link = "post/" . $post->get_primary_id();
                foreach ($notification_users as $notification_user) {
                    if ($notification_user->user_id != $user->user_id) {
                        echo notify($dao, $notification_user->user_id, $notification_title, $notification_message, $notification_link);
                    }
                }
            }
开发者ID:ThisIsGJ,项目名称:unify,代码行数:31,代码来源:add.php

示例9: array

 $grouping = DataObject::create($dao, "grouping", array("group_id" => $cohort->group_id, "user_id" => $user->get_primary_id()));
 $grouping->commit();
 $dao->myquery("SELECT MAX(conf_id) FROM confirmation;");
 $maxid = $dao->fetch_one();
 if ($maxid) {
     $rnd = salt(",jag,wd873423%Ed.fkug" . $maxid);
 } else {
     $rnd = salt(",jag,wd873423%Ed.fkug" . rand());
 }
 //send rnd to the user and a link which will return rnd to the server for confirmation
 $send_email = false;
 //If the confirmation has already been sent, just resend it. Don't craete a new confimation
 if (NULL != DataObject::select_one($dao, "confirmation", array("conf_id"), array("user_email" => $user_email))) {
     $send_email = true;
 } else {
     $conf = DataObject::create($dao, "confirmation", array("conf_rnd" => $rnd, "user_id" => $user->get_primary_id(), "user_email" => $user_email));
     if ($conf->commit()) {
         $send_email = true;
     } else {
         redirect("../../register/", array_merge(array("m" => "6"), $_POST));
         //This should never happen
     }
 }
 if ($send_email) {
     $subject = "Confirm your account";
     $body = "<p>Hello " . $user_name . ",</p>" . "<p>Thank you for joining Unify! Trust me, this is the best decision you've ever made.</p>" . "<p>Click <a href=\"" . $SITE_URL . "confirm.php?rnd={$rnd}\">CONFIRM</a> to confirm your account and to start using Unify.<br><br>" . "Click <a href=\"" . $SITE_URL . "unconfirm.php?rnd={$rnd}\">UNCONFIRM</a> if you have no idea why you are receiving this email." . " This will prevent this email address being used on Unify.</p>" . "<p>Best Wishes,<br>" . "The Unify Team</p>";
     $success = mail_message($user_email, $subject, $body);
     if (!$success) {
         redirect("../../register/", array_merge(array("m" => "5"), $_POST));
         //Could not send email
     } else {
开发者ID:ThisIsGJ,项目名称:unify,代码行数:31,代码来源:register.php

示例10: sin

     if ($dao->fetch_num_rows() > 0) {
         $row = $dao->fetch_one();
         $req_id = $row["req_id"];
         $lng1 = $row["lng"];
         $lng2 = $my_lng;
         $lat1 = $row["lat"];
         $lat2 = $my_lat;
         $dlng = $lng1 - $lng2;
         $distance = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($dlng));
         $distance = acos($distance);
         $distance = rad2deg($distance);
         $distance = $distance * 60 * 1.1515 * 1.609344;
         $threshold = 0.01 + 0.01;
         //20m!
         if ($distance < $threshold) {
             $new_connection = DataObject::create($dao, "connection", $connection_properties);
             $new_connection->commit();
             echo Status::json(0, "You are now unified!");
         } else {
             echo Status::json(3, "You were not close enough");
         }
         $query = "DELETE FROM friend_request WHERE req_id=\"{$req_id}\";";
         //Whether successful or not
         $dao->myquery($query);
     } else {
         $query = "INSERT INTO friend_request VALUES(NULL,\"{$user->user_id}\",\"{$selected_user->user_id}\",\"{$my_lat}\",\"{$my_lng}\");";
         $dao->myquery($query);
         echo Status::json(0, "Friend request made");
     }
 } else {
     echo Status::json(1, "You are already unified!");
开发者ID:ThisIsGJ,项目名称:unify,代码行数:31,代码来源:request.php

示例11: DAO

include "../util/status.php";
$dao = new DAO(false);
if (isset($_GET["post_id"])) {
    $post_id = $_GET["post_id"];
    $post = DataObject::select_one($dao, "post", array("post_id", "user_id"), array("post_id" => $post_id));
    if ($post) {
        if ($user->user_id == $post->user_id) {
            //User's own post, so delete it
            if ($post->delete()) {
                echo Status::json(0, "Post deleted");
            } else {
                echo Status::json(5, "Failed to delete post");
            }
        } else {
            //Not the user's own post, so hide it from them
            $hidden_post = DataObject::create($dao, "hidden_post", array("user_id" => $user->user_id, "post_id" => $post_id));
            if ($hidden_post) {
                if ($hidden_post->commit()) {
                    echo Status::json(0, "Post hidden");
                } else {
                    echo Status::json(1, "Failed to commit hidden_post");
                }
            } else {
                echo Status::json(2, "Failed to create hidden_post");
            }
        }
    } else {
        echo Status::json(3, "Failed to select post");
    }
} else {
    echo Status::json(4, "post_id not set");
开发者ID:ThisIsGJ,项目名称:unify,代码行数:31,代码来源:delete_hide.php

示例12: DAO

<?php

include "../util/session.php";
include_once "../util/mysql.php";
include "../mail/send.php";
include "../util/status.php";
include "../util/constants.php";
$dao = new DAO(false);
$user_id = $_POST["user_id"];
$group_id = $_POST["group_id"];
$member = DataObject::select_one($dao, "user", array("user_id", "user_email", "user_name"), array("user_id" => $user_id));
$group = DataObject::select_one($dao, "user_group", array("group_id", "group_name"), array("group_id" => $group_id));
if ($group != NULL) {
    if ($member != NULL) {
        if (NULL == DataObject::select_one($dao, "grouping_request", array("gr_id"), array("group_id" => $group_id, "user_id" => $user_id))) {
            $body = "<p>Hello " . $member->user_name . ",</p>\n\t\t\t\t<p>" . $user->user_name . " has asked you to join the group \"" . $group->group_name . "\".\n\t\t\t\t\tIf you would like to join, please click on this link: \n\t\t\t\t\t<a href=\"" . $SITE_URL . "script/grouping/confirm.php?group_id=" . $group_id . "\">Click here to join</a>.</p>\n\t\t\t\t<p>Best Wishes,<br>The Unify Team</p>";
            $request = DataObject::create($dao, "grouping_request", array("group_id" => $group_id, "user_id" => $user_id));
            $request->commit();
            //Put the request in the database. So long as this is here, the user can accept (only when logged in)
            mail_message($member->user_email, "Group Join Request", $body);
            echo Status::json(0, "Request sent :)");
        } else {
            echo Status::json(3, "Member has already been requested to join");
        }
    } else {
        echo Status::json(1, "Member not found");
    }
} else {
    echo Status::json(2, "Group not found");
}
开发者ID:ThisIsGJ,项目名称:unify,代码行数:30,代码来源:request.php

示例13: bulkUploadField

 /**
  * Returned a configured UploadField instance
  * embedded in the gridfield heard.
  *
  * @param GridField $gridField Current GridField
  *
  * @return UploadField Configured UploadField instance
  */
 public function bulkUploadField($gridField)
 {
     $fileRelationName = $this->getFileRelationName($gridField);
     $uploadField = UploadField::create($fileRelationName, '')->setForm($gridField->getForm())->setConfig('previewMaxWidth', 20)->setConfig('previewMaxHeight', 20)->setConfig('changeDetection', false)->setRecord(DataObject::create())->setTemplate('GridFieldBulkUploadField')->setDownloadTemplateName('colymba-bulkuploaddownloadtemplate')->setConfig('url', $gridField->Link('bulkupload/upload'))->setConfig('urlSelectDialog', $gridField->Link('bulkupload/select'))->setConfig('urlAttach', $gridField->Link('bulkupload/attach'))->setConfig('urlFileExists', $gridField->Link('bulkupload/fileexists'));
     //set UploadField config
     foreach ($this->ufConfig as $key => $val) {
         $uploadField->setConfig($key, $val);
     }
     //UploadField setup
     foreach ($this->ufSetup as $fn => $param) {
         $uploadField->{$fn}($param);
     }
     //UploadField Validator setup
     foreach ($this->ufValidatorSetup as $fn => $param) {
         $uploadField->getValidator()->{$fn}($param);
     }
     return $uploadField;
 }
开发者ID:sumitnis,项目名称:GridFieldBulkEditingTools,代码行数:26,代码来源:GridFieldBulkUpload.php

示例14: array

<?php

//Confirm that this user logged in wants to join the group
include "../util/session.php";
include "../util/redirect.php";
include_once "../util/mysql.php";
$group_id = $_GET["group_id"];
if (isset($user)) {
    $new_values = array("group_id" => $group_id, "user_id" => $user->user_id);
    $dao = new DAO(false);
    //Check if the user has already been added:
    $already_grouped = DataObject::select_one($dao, "grouping", array("grouping_id"), $new_values);
    if ($already_grouped == NULL) {
        $grouping = DataObject::create($dao, "grouping", $new_values);
        $request = DataObject::select_one($dao, "grouping_request", array("gr_id", "group_id", "user_id"), array("group_id" => $group_id, "user_id" => $user->user_id));
        if ($request != NULL) {
            $request->delete();
            //Delete the request from the database
            if ($grouping->commit()) {
                redirect("/", array("group_id" => $group_id, "m" => 17));
                //Send them to the new group!
            } else {
                redirect("/?m=11");
            }
        } else {
            redirect("/?m=13");
            //You have not been asked to join this group
        }
    } else {
        redirect("/", array("group_id" => $group_id, "m" => 14));
        //You are already in this group... See!
开发者ID:ThisIsGJ,项目名称:unify,代码行数:31,代码来源:confirm.php


注:本文中的DataObject::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。