本文整理汇总了PHP中r::data方法的典型用法代码示例。如果您正苦于以下问题:PHP r::data方法的具体用法?PHP r::data怎么用?PHP r::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r
的用法示例。
在下文中一共展示了r::data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: values
public function values($values = null)
{
if (is_null($values)) {
return array_merge($this->values, r::data());
}
$this->values = array_merge($this->values, $values);
return $this;
}
示例2: handle
/**
* Handle an incomming request.
*/
public static function handle($pageId, $lang)
{
if (r::data('token') != c::get('slack.verify')) {
return response::error('Forbidden', 403);
}
$history = static::api('channels.history', ['channel' => r::data('channel_id')]);
if (!empty($history['error'])) {
// Something went wrong ... maybe:
$msg = ['channel_not_found' => ':lock: Sorry, but this is a private channel'];
$err = $history['error'];
return response::json(isset($msg[$err]) ? $msg[$err] : $err);
}
$messages = $history['messages'];
if (!empty(r::data('text'))) {
$messages = array_values(array_filter($messages, function ($m) {
return stristr($m['text'], r::data('text'));
}));
}
if (empty($messages)) {
return response::json(":mag: Sorry, I couldn't find the post you're looking for");
}
$m = $messages[0];
$a = @$m['attachments'][0];
$img = @$a['image_url'];
if (empty($img)) {
$img = @$a['thumb_url'];
}
if (empty($img)) {
return response::json(":warning: I'll only publish posts with images");
}
$page = site()->visit($pageId, $lang);
$dir = $page->root();
$ext = preg_replace('/.+?(\\.\\w+)($|[#?].*)/', '$1', $img);
$file = $dir . DS . $m['ts'] . $ext;
// Output success message early because of short slackbot timeouts
$msg = ':metal: *' . r::data('text', 'last') . '* post is now live' . ' on <' . $page->url() . '>';
echo $msg;
flush();
error_log($msg);
$user = static::api('users.info', ['user' => $m['user']]);
$meta = ['title' => $a['title'], 'date' => date('d.m.Y', $m['ts']), 'description' => @$a['text'], 'linkurl' => $a['from_url'], 'author' => $user['user']['profile']['real_name'], 'avatar' => $m['user'] . '.jpg', 'comment' => static::format(@$m['text']), 'slack' => '1'];
data::write($file . '.txt', $meta, 'kd');
// Download the avatar image
$avatar = $dir . DS . $meta['avatar'];
static::download($user['user']['profile']['image_72'], $avatar);
// Download the image
static::download($img, $file);
// Response has already been sent
return false;
}
示例3: get
/**
* Shortcut for r::get()
*
* @param mixed $key The key to look for. Pass false or null to return the entire request array.
* @param mixed $default Optional default value, which should be returned if no element has been found
* @return mixed
*/
function get($key = null, $default = null)
{
return r::data($key, $default);
}
示例4: fromInput
/**
* Create a new model instance from the $_POST input.
*
* @return static
*/
public static function fromInput()
{
$model = new static();
return $model->fill(r::data());
}
示例5: update
/**
* Update the specified comment entry in the database.
*
* @param string $hash Unique hash value of the parent page.
* @param integer $id Id of the comment to retrieve.
*
* @return Response
*/
public function update($hash, $id)
{
$page = $this->findPageByHash($hash);
$comment = comment::find($id);
if (!$comment) {
$msg = l('comments.error.notfound', 'Comment not found');
return $this->error($msg, 400, array('id' => $id, 'hash' => $hash));
}
$data = r::data();
$comment->fill($data);
if ($comment->save()) {
$msg = l('comments.success.saved', 'Comment saved');
return $this->success($msg, 200, array('id' => $comment->id()));
} else {
$msg = l('comments.error.save', 'Could not save comment');
return $this->error($msg, 400, array('input' => $comment->toArray(), 'errors' => $comment->errors()->toArray()));
}
}
示例6: updateFileinfo
static function updateFileinfo($file, $destination)
{
global $panel, $settings;
$fields = $settings->filefields;
$data = array();
$input = r::data();
if (empty($fields)) {
false;
}
foreach ($fields as $key => $value) {
$v = a::get($input, $key);
if (is_array($v)) {
$data[$key] = implode(', ', $v);
} else {
$data[$key] = trim($v);
}
}
return self::write($destination, $data);
}
示例7: launch
/**
* Run the wizard dialog.
*
* @param integer $index
* @return string
*/
public function launch($index = 0)
{
// Retrieve active view
if (!($view = $this->nth($index))) {
return false;
}
// Trigger submit event
if (get('token') && csfr(get('token'))) {
$form = r::data();
$validator = new Validator($form, $view->rules());
$valid = $validator->passes();
// Goto next wizard step or display validation errors
if ($valid && $view->trigger('submit', compact('form'))) {
$next = $view->index() + 1;
redirect::to($this->url($next));
} else {
if (!$valid) {
$view->errors($validator->errors());
}
}
}
// Generate view and return the contents
return $this->with(array('url' => $this->url(), 'content' => $view->content()));
}
示例8: testData
public function testData()
{
$this->assertTrue(is_array(r::data()));
}