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


PHP Versions::add方法代码示例

本文整理汇总了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;
	}
开发者ID:R-J,项目名称:elefant,代码行数:10,代码来源:Post.php

示例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);
开发者ID:Selwyn-b,项目名称:elefant,代码行数:31,代码来源:bgsave.php

示例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');
开发者ID:nathanieltite,项目名称:elefant,代码行数:31,代码来源:edit.php

示例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();
开发者ID:nathanieltite,项目名称:elefant,代码行数:31,代码来源:wordpress.php

示例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);
 }
开发者ID:nathanieltite,项目名称:elefant,代码行数:12,代码来源:VersionsTest.php

示例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>';
开发者ID:Alm001,项目名称:form,代码行数:17,代码来源:add.php

示例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');
 }
开发者ID:Alm001,项目名称:form,代码行数:28,代码来源:API.php

示例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);
开发者ID:Selwyn-b,项目名称:elefant,代码行数:31,代码来源:newuser.php

示例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('/');
开发者ID:Selwyn-b,项目名称:elefant,代码行数:31,代码来源:restore.php

示例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;
					}
				}
			}
开发者ID:R-J,项目名称:elefant,代码行数:31,代码来源:index.php

示例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);
}
开发者ID:Selwyn-b,项目名称:elefant,代码行数:19,代码来源:publish-queue.php


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