本文整理汇总了PHP中Versions::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Versions::add方法的具体用法?PHP Versions::add怎么用?PHP Versions::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Versions
的用法示例。
在下文中一共展示了Versions::add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _publish_queued
public static function _publish_queued ($posts) {
foreach (array_keys ($posts) as $k) {
if ($posts[$k]->published === 'que') {
$posts[$k]->published = 'yes';
$posts[$k]->put ();
\Versions::add ($posts[$k]);
}
}
return $posts;
}
示例2: __
$res->error = __('Authorization required.');
echo json_encode($res);
return;
}
$error = false;
$o = new Block($_GET['id']);
if ($o->error) {
$error = $o->error;
} else {
foreach ($_POST as $k => $v) {
if ($k != $o->key && isset($o->data[$k])) {
$o->{$k} = $v;
}
}
if (!$o->put()) {
$error = $o->error;
} else {
Versions::add($o);
$_POST['id'] = $_GET['id'];
$this->hook('blocks/edit', $_POST);
}
}
$res = new StdClass();
if ($error) {
$res->success = false;
$res->error = $error;
} else {
$res->success = true;
$res->data = $_GET['id'];
}
echo json_encode($res);
示例3: Webpage
$wp = new Webpage($_GET['page']);
$f = new Form('post', 'admin/edit');
$f->verify_csrf = false;
if ($f->submit()) {
$wp->id = $_POST['id'];
$wp->title = $_POST['title'];
$wp->menu_title = $_POST['menu_title'];
$wp->window_title = $_POST['window_title'];
$wp->access = $_POST['access'];
$wp->layout = $_POST['layout'];
$wp->description = $_POST['description'];
$wp->keywords = $_POST['keywords'];
$wp->body = $_POST['body'];
$wp->put();
if (!$wp->error) {
Versions::add($wp);
$memcache->delete('_admin_page_' . $_GET['page']);
$this->add_notification(i18n_get('Page saved.'));
$_POST['page'] = $_GET['page'];
$lock->remove();
$this->hook('admin/edit', $_POST);
$this->redirect('/' . $_POST['id']);
}
$page->title = i18n_get('An Error Occurred');
echo i18n_get('Error Message') . ': ' . $wp->error;
} else {
$wp->layouts = admin_get_layouts();
$wp->failed = $f->failed;
$wp = $f->merge_values($wp);
$page->title = i18n_get('Edit Page') . ': ' . $wp->title;
$page->head = $tpl->render('admin/edit/head', $wp) . $tpl->render('admin/wysiwyg');
示例4: SimpleXMLElement
$file = 'cache/blog_' . $_FILES['import_file']['name'];
$imported = 0;
try {
$posts = new SimpleXMLElement(file_get_contents($file));
foreach ($posts->channel->item as $entry) {
$dc = $entry->children('http://purl.org/dc/elements/1.1/');
$content = $entry->children('http://purl.org/rss/1.0/modules/content/');
$post = array('title' => (string) $entry->title, 'author' => (string) $dc->creator, 'ts' => gmdate('Y-m-d H:i:s', strtotime($entry->pubDate)), 'published' => $_POST['published'], 'body' => str_replace("\n", "<br />\n", (string) $content->encoded), 'tags' => '');
$sep = '';
for ($i = 0; $i < count($entry->category); $i++) {
$post['tags'] .= $sep . $entry->category[$i]->attributes()->nicename;
$sep = ', ';
}
$p = new blog\Post($post);
if ($p->put()) {
Versions::add($p);
$imported++;
}
}
echo '<p>' . i18n_getf('Imported %d posts.', $imported) . '</p>';
echo '<p><a href="/blog/admin">' . i18n_get('Continue') . '</a></p>';
} catch (Exception $e) {
echo '<p><strong>' . i18n_get('Error importing file') . ': ' . $e->getMessage() . '</strong></p>';
echo '<p><a href="/blog/admin">' . i18n_get('Back') . '</a></p>';
}
return;
} else {
echo '<p><strong>' . i18n_get('Error uploading file.') . '</strong></p>';
}
}
$o = new StdClass();
示例5: test_restore_deleted
/**
* @depends test_get_classes
*/
function test_restore_deleted()
{
// test restore on deleted item
$foo = new Foobar(array('id' => 5, 'name' => 'Deleted'));
$v = Versions::add($foo);
$foo->remove();
$foo2 = $v->restore();
$this->assertEquals($foo, $foo2);
}
示例6: gmdate
<?php
/**
* Creates a new untitled form and forwards to /form/edit, the form builder.
*/
$page->layout = 'admin';
if (!User::require_admin()) {
$this->redirect('/admin');
}
$f = new form\Form(array('title' => 'Untitled', 'message' => 'Please fill in the following information.', 'ts' => gmdate('Y-m-d H:i:s'), 'fields' => '[]', 'actions' => '[]', 'response_title' => 'Thank you', 'response_body' => 'Your information has been saved.'));
$f->put();
\Versions::add($f);
if (!$f->error) {
$this->redirect('/form/edit?id=' . $f->id);
}
$page->title = i18n_get('An Error Occurred');
echo '<p>' . i18n_get('Unable to create a new form.') . '</p>';
示例7: post_actions
/**
* Update the form actions. Usage:
*
* /form/api/actions/form-id
*
* Expects a single POST item named `actions` containing
* the data structure of the form actions.
*/
public function post_actions($id)
{
$f = new Form($id);
if ($f->error) {
return $this->error(i18n_get('Form not found'));
}
if (!isset($_POST['actions'])) {
$_POST['actions'] = array();
}
if (!is_array($_POST['actions'])) {
return $this->error(i18n_get('Invalid actions parameter'));
}
$f->actions = $_POST['actions'];
$f->put();
if ($f->error) {
return $this->error(i18n_get('Failed to save changes'));
}
\Versions::add($f);
return i18n_get('Form updated');
}
示例8: __
if (!$appconf['Custom Handlers']['user/signup']) {
echo $this->error(404, __('Not found'), __('The page you requested could not be found.'));
return;
}
// Check for a custom handler override
$res = $this->override('user/login/newuser');
if ($res) {
echo $res;
return;
}
$f = new Form('post', 'user/login/newuser');
if ($f->submit()) {
$date = gmdate('Y-m-d H:i:s');
$u = new User(array('name' => $_POST['name'], 'email' => $_POST['email'], 'password' => User::encrypt_pass($_POST['password']), 'expires' => $date, 'type' => Appconf::user('User', 'default_role'), 'signed_up' => $date, 'updated' => $date, 'userdata' => json_encode(array()), 'about' => ''));
$u->put();
Versions::add($u);
if (!$u->error) {
$oid = new User_OpenID(array('token' => $_POST['token'], 'user_id' => $u->id));
$oid->put();
$_POST['username'] = $_POST['email'];
User::require_login();
$this->redirect($_POST['redirect']);
}
// TODO: already have an account
@error_log('Error creating profile: ' . $u->error);
$page->title = 'An Error Occurred';
echo '<p>Please try again later.</p>';
echo '<p><a href="/">' . __('Back') . '</a></p>';
} else {
$u = new User();
$u = $f->merge_values($u);
示例9: Versions
* Restores a previous version of a Model object, replacing the
* current version, and adding a new version to the history
* as well.
*/
$page->layout = 'admin';
if (!User::require_admin()) {
$this->redirect('/admin');
}
$ver = new Versions($_GET['id']);
$lock = new Lock($ver->class, $ver->pkey);
if ($lock->exists()) {
$page->title = __('Editing Locked');
echo $tpl->render('admin/locked', $lock->info());
return;
} else {
$lock->add();
}
$obj = $ver->restore();
$obj->put();
if ($obj->error) {
$page->title = __('An Error Occurred');
echo __('Error Message') . ': ' . $obj->error;
return;
}
Versions::add($obj);
$this->add_notification(__('Item restored.'));
if ($ver->class == 'Webpage') {
$cache->delete('_admin_page_' . $obj->id);
$this->redirect('/' . $obj->id);
}
$this->redirect('/');
示例10: sql_split
$data['error'] = false;
// create the database
$sqldata = sql_split (file_get_contents ('../conf/install_' . $_POST['driver'] . '.sql'));
foreach ($sqldata as $sql) {
if (! DB::execute ($sql)) {
$data['error'] = DB::error ();
DB::execute ('rollback');
break;
}
}
$wp = new Webpage ('index');
Versions::add ($wp);
$b = new Block ('members');
Versions::add ($b);
// write the settings
if (! $data['error']) {
$config = file_get_contents ('../conf/config.php');
// good to replace database settings
$_POST['pass'] = str_replace ('"', '\"', $_POST['pass']);
$dbinfo = $tpl->render ('dbinfo', $_POST);
$config = preg_replace ('/\[Database\].*\[Mongo\]/s', $dbinfo, $config);
if (! file_put_contents ('../conf/config.php', $config)) {
$data['error'] = __ ('Failed to write to conf/config.php');
} else {
$data['ready'] = true;
}
}
}
示例11: die
<?php
/**
* Publish scheduled blog posts. Use via cron like this:
*
* 0,15,30,45 * * * * /var/www/elefant blog/publish-queue
*/
if (!$this->cli) {
die('Must be run from the command line.');
}
$page->layout = false;
// fetch queued posts
$posts = blog\Post::query()->where('published', 'que')->where('ts <= ?', gmdate('Y-m-d H:i:s'))->fetch();
// publish posts
foreach ($posts as $post) {
$post->published = 'yes';
$post->put();
Versions::add($post);
}