Пример #1
0
 if ($input['name'] !== null) {
     if (!($post = GBPost::findByName($input['name'], $input['version']))) {
         gb_admin::error_rsp('Post ' . r($input['name']) . ' not found');
     }
 } else {
     $post = new GBPost();
     $created = true;
 }
 # set post state
 $modified_state = array();
 foreach ($state_fields as $k => $discard) {
     $v = $input[$k];
     if ($v !== null && $post->{$k} !== $v) {
         if ($k === 'body') {
             $post->setRawBody($v);
             $modified_state[$k] = $post->rawBody();
         } else {
             $post->{$k} = $v;
             $v = $post->{$k};
             if ($v instanceof GBDateTime || $v instanceof GBAuthor) {
                 $v = strval($v);
             }
             $modified_state[$k] = $v;
         }
     }
 }
 # post-process checks before saving
 if ($modified_state) {
     $post->modified = new GBDateTime();
     if (!$post->title && !$post->slug) {
         throw new UnexpectedValueException('Both title and slug can not both be empty. Please choose a title for this post.');
Пример #2
0
 />
				<input type="button" id="publish-button" class="commit publish" value="Publish"
					title="Make this post appear on your site (after the time specified by 'Publish date')."
					<?php 
echo $post->isTracked() ? 'style="display:none"' : '';
?>
 />
			</p>
		</div>
		<div class="breaker"></div>
	</div>
	<!-- body -->
	<div class="section body">
		<div class="component body">
			<textarea name="body" class="dep-save"><?php 
echo h($post->rawBody());
?>
</textarea>
		</div>
		<div class="breaker"></div>
	</div>
	<!-- tags and categories -->
	<div class="section">
		<div class="component tags c2a">
			<h4>Tags <small>(comma separated)</small></h4>
			<p>
				<input type="text" class="dep-save transform-csv" name="tags" value="<?php 
echo implode(', ', array_map('h', $post->tags));
?>
" />
			</p>