本文整理汇总了PHP中Content::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::exists方法的具体用法?PHP Content::exists怎么用?PHP Content::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Content
的用法示例。
在下文中一共展示了Content::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testContent
public function testContent()
{
$content = new Content(null, TEST_ROOT_ETC . DS . 'content' . DS . 'site.txt');
$this->assertEquals(TEST_ROOT_ETC . DS . 'content' . DS . 'site.txt', $content->root);
$this->assertEquals(TEST_ROOT_ETC . DS . 'content' . DS . 'site.txt', $content->root());
$this->assertEquals('site', $content->name());
$this->assertEquals(array_keys($this->dummyData()), $content->fields());
$this->assertEquals($this->dummyData(), $content->toArray());
$this->assertEquals($this->dummyData(), $content->data());
$this->assertTrue($content->exists());
$this->assertEquals(file_get_contents($content->root()), $content->raw());
foreach ($this->dummyData() as $field => $value) {
$this->assertEquals($value, $content->{$field}());
$this->assertEquals($value, $content->get($field));
$this->assertInstanceOf('Field', $content->{$field}());
$this->assertInstanceOf('Field', $content->get($field));
}
}
示例2: move_down
/**
* moves the current content down in it's cell
* return true on success and false on failure
**/
public function move_down()
{
$cont = new Content();
$cont->where('parent_content', $this->parent_content);
//same parent
$cont->where('cell', $this->cell);
// same cell
$cont->where('sort >', $this->sort);
//greater sort
$cont->get();
//get them to process
// if that content object exists then that content is not the last
// and we'll move it down
if ($cont->exists()) {
$this->deattach();
$this->sort++;
$this->attach();
return TRUE;
}
return FALSE;
}
示例3: Content
function move_down()
{
$cont = new Content();
//$cont->where('parent_section',$this->parent_section );//same section
$cont->where('parent_content', $this->parent_content);
//same parent
$cont->where('cell', $this->cell);
// same cell
$cont->where('sort >', $this->sort);
//greater sort
$cont->get();
//get them to process
// if that content object exists then that place is taken
// so we have to get a place for it
if ($cont->exists()) {
$this->deattach();
$this->sort++;
$this->attach();
return TRUE;
}
return FALSE;
}
示例4: Content
<?php
$content_id = $ci->uri->segment(5);
$content_ins = new Content();
$content_ins->get_by_id($content_id);
if (!$content_ins->exists()) {
show_error('content not found');
}
$parent_content = new Content();
$parent_content->get_by_id($content_ins->parent_content);
$parent_section = new Section();
$parent_section->get_by_id($content_ins->parent_section);
$data_table = array('Content ID' => $content_ins->id, 'Content path' => $content_ins->path, 'Section' => empty($parent_section->name) ? 'Index' : $parent_section->name, 'Subsections' => $content_ins->subsection ? 'Yes' : 'No', 'Parent' => $parent_content->path, 'Cell' => $content_ins->cell, 'Sort' => $content_ins->sort);
$ci->load->library('gui');
$ci->app->add_info('Content information and the containers');
echo $ci->gui->form('#', $data_table);
?>
<style>
label{
font-weight: bold;
}
tr{
border-bottom: 1px solid black;
}
</style>
示例5: elseif
<?php
if ($mode == 'config') {
?>
id:
type:number
<?php
} elseif ($mode == 'layout') {
?>
0
<?php
} elseif ($mode == 'view') {
$instance = new Content();
$instance->get_by_id($id);
if ($instance->exists()) {
echo $instance->render();
} else {
$ci->load->library('gui');
echo $ci->gui->error('Content Choosen not found');
}
}
示例6: index
function index()
{
list($params, $id, $slug) = $this->parse_params(func_get_args());
// Create or update
if ($this->method != 'get') {
$c = new Content();
switch ($this->method) {
case 'post':
case 'put':
if ($this->method == 'put') {
// Update
$c->get_by_id($id);
if (!$c->exists()) {
$this->error('404', "Content with ID: {$id} not found.");
return;
}
$c->old_published_on = $c->published_on;
$c->old_captured_on = $c->captured_on;
$c->old_uploaded_on = $c->uploaded_on;
if (isset($_POST['slug'])) {
$c->current_slug = $c->slug;
}
}
if (isset($_REQUEST['name'])) {
if (isset($_REQUEST['upload_session_start'])) {
$s = new Setting();
$s->where('name', 'last_upload')->get();
if ($s->exists() && $s->value != $_REQUEST['upload_session_start']) {
$s->value = $_REQUEST['upload_session_start'];
$s->save();
}
}
$file_name = $c->clean_filename($_REQUEST['name']);
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
$tmp_dir = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
$tmp_path = $tmp_dir . DIRECTORY_SEPARATOR . $file_name;
make_child_dir($tmp_dir);
if ($chunks == 0 || $chunk == $chunks - 1) {
if (isset($_REQUEST['text'])) {
$path = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR;
$internal_id = false;
} else {
if (isset($_REQUEST['plugin'])) {
$info = pathinfo($_REQUEST['name']);
$path = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $_REQUEST['plugin'] . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR;
$file_name = $_REQUEST['basename'] . '.' . $info['extension'];
$internal_id = false;
} else {
list($internal_id, $path) = $c->generate_internal_id();
}
}
if ($path) {
$path .= $file_name;
if ($chunks == 0) {
$tmp_path = $path;
}
} else {
$this->error('500', 'Unable to create directory for upload.');
return;
}
}
// Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
} else {
if (isset($_SERVER["CONTENT_TYPE"])) {
$contentType = $_SERVER["CONTENT_TYPE"];
} else {
$contentType = '';
}
}
if (strpos($contentType, "multipart") !== false) {
if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
$out = fopen($tmp_path, $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen($_FILES['file']['tmp_name'], "rb");
if ($in) {
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
} else {
$this->error('500', 'Unable to read input stream.');
return;
}
fclose($out);
unlink($_FILES['file']['tmp_name']);
} else {
$this->error('500', 'Unable to write to output file.');
return;
}
} else {
$this->error('500', 'Unable to move uploaded file.');
return;
}
} else {
$out = fopen($tmp_path, $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
//.........这里部分代码省略.........
示例7: foreach
function build_autos($items, $data, $user)
{
foreach ($items as $index => &$item) {
if (isset($item['auto'])) {
if (isset($data['urls'][$item['auto']])) {
$item['path'] = $data['urls'][$item['auto']];
} else {
if ($item['auto'] === 'set') {
$item['path'] = '';
}
}
if ($item['auto'] === 'profile') {
switch ($item['id']) {
case 'twitter':
$item['path'] = 'https://twitter.com/' . $user->twitter;
break;
default:
$item['path'] = $user->{$item['id']};
if (empty($item['path'])) {
unset($items[$index]);
continue;
}
break;
}
if (!isset($item['label']) || empty($item['label'])) {
$item['label'] = ucwords($item['id']) . ($item['id'] === 'google' ? '+' : '');
}
} else {
if ($item['auto'] === 'rss') {
$item['path'] = '/feed/' . $item['id'] . ($item['id'] === 'essay' ? 's' : '') . '/recent.rss';
if (!isset($item['label'])) {
$item['label'] = $data['url_data'][$item['id']]['plural'] . ' RSS';
}
} else {
if (preg_match('/s$/', $item['auto']) || $item['auto'] === 'timeline') {
if ($item['auto'] === 'timeline' && isset($item['year'])) {
$item['path'] .= $item['year'] . '/';
if (isset($item['month']) && $item['month'] !== false && $item['month'] !== 'any') {
$m = str_pad($item['month'], 2, '0', STR_PAD_LEFT);
$item['path'] .= $m . '/';
}
}
if (strpos($item['auto'], '_') !== false) {
foreach (array('id', 'slug', 'month', 'year', 'day') as $id) {
if ($id === 'month') {
if (!isset($item['month']) || $item['month'] === 'any' || $item['month'] === false) {
$item['month'] = '';
} else {
$item['month'] = str_pad($item['month'], 2, '0', STR_PAD_LEFT);
}
}
if ($id === 'day' && !isset($item['day'])) {
$item['day'] = '';
}
if ($id === 'slug' && !isset($item['slug']) && isset($item['id'])) {
if (strpos($item['auto'], 'tag_') === 0) {
$item['slug'] = $item['id'];
} else {
$c = new Category();
if (is_numeric($item['id'])) {
$c->select('slug')->get_by_id($item['id']);
$item['slug'] = $c->slug;
} else {
$item['slug'] = $item['id'];
}
}
}
if (isset($item[$id])) {
$item['path'] = str_replace(":{$id}", $item[$id], $item['path']);
}
}
} else {
if (!isset($item['label'])) {
$item['label'] = $data['url_data'][$item['auto'] === 'categories' ? 'category' : rtrim($item['auto'], 's')]['plural'];
}
}
} else {
if ($item['auto'] === 'home') {
if (!isset($item['label'])) {
$item['label'] = $data['url_data']['home'];
}
$item['path'] = '/home/';
} else {
if ($item['auto'] === 'album' || $item['auto'] === 'set') {
$a = new Album();
$a->select('id,slug,created_on,title');
if (is_numeric($item['id'])) {
$a->where('id', $item['id']);
} else {
$a->where('slug', $item['id'])->or_where('internal_id', $item['id']);
}
$a->get();
if (!$a->exists()) {
unset($items[$index]);
continue;
}
$item['path'] = str_replace(':id', $a->id, $item['path']);
$item['path'] = str_replace(':slug', $a->slug, $item['path']);
$item['path'] = str_replace(':year', date('Y', $a->created_on), $item['path']);
$item['path'] = str_replace(':month', date('m', $a->created_on), $item['path']);
//.........这里部分代码省略.........
示例8: Content
<?php
$ci =& get_instance();
$id = $ci->uri->segment(5);
$c = new Content();
$c->get_by_id($id);
if ($c->exists()) {
if ($c->type == 'layout') {
$c = new Layout();
$c->get_by_id($id);
}
if ($c->can_delete()) {
$c->delete();
$ci->app->add_info('Content deleted');
} else {
$ci->app->add_error('permission denied! please check your root adminstrator');
}
} else {
$ci->app->add_error('Content not found');
}
示例9: covers
function covers()
{
list($params, $id) = $this->parse_params(func_get_args());
$params['auth'] = $this->auth;
// Standard add/delete cover
list($id, $content_id) = $id;
if ($this->method === 'get') {
$this->redirect("/albums/{$id}");
}
$a = new Album($id);
$c = new Content();
if (!$a->exists()) {
$this->error('404', 'Album not found.');
return;
}
$cover_count = $a->covers->count();
if ($cover_count > 50) {
$this->error('403', 'Only 50 covers can be added to any one album.');
return;
}
if ($a->album_type == 2 && $cover_count == 0) {
$subs = new Album();
$subs->select('id')->where('right_id <', $a->right_id)->where('left_id >', $a->left_id)->where('visibility', $a->visibility)->get_iterated();
$id_arr = array();
foreach ($subs as $sub) {
$id_arr[] = $sub->id;
}
if (!empty($id_arr)) {
$subc = new Content();
$covers = $subc->query("SELECT DISTINCT cover_id FROM {$a->db_join_prefix}albums_covers WHERE album_id IN (" . join(',', $id_arr) . ") GROUP BY album_id LIMIT " . (3 - $cover_count));
$f_ids = array();
foreach ($covers as $f) {
$f_ids[] = $f->cover_id;
}
if (!empty($f_ids)) {
$subc->query("SELECT id FROM {$subc->table} WHERE id IN(" . join(',', $f_ids) . ") ORDER BY FIELD(id, " . join(',', array_reverse($f_ids)) . ")");
foreach ($subc as $content) {
$a->save_cover($content);
}
}
}
}
if (is_numeric($content_id)) {
if ($this->method == 'delete') {
$c->where_related('covers', 'id', $id)->get_by_id($content_id);
} else {
if ($a->album_type == 2) {
$c->get_by_id($content_id);
} else {
$c->where_related('album', 'id', $id)->get_by_id($content_id);
}
}
if (!$c->exists()) {
$this->error('404', 'Content not found.');
return;
}
if ($this->method == 'delete') {
$a->delete_cover($c);
$a->reset_covers();
} else {
$a->delete_cover($c);
$a->save_cover($c);
}
} else {
$content_id = explode(',', $content_id);
if ($this->method == 'delete') {
$c->where_related('covers', 'id', $id)->where_in('id', $content_id)->get_iterated();
} else {
if ($a->album_type == 2) {
$c->where_in('id', $content_id)->get_iterated();
} else {
$c->where_related('album', 'id', $id)->where_in('id', $content_id)->get_iterated();
}
}
if (!$c->result_count()) {
$this->error('404', 'Content not found.');
return;
}
if ($this->method == 'delete') {
foreach ($c as $cover) {
$a->delete_cover($cover);
}
$a->reset_covers();
} else {
foreach ($c as $cover) {
$a->delete_cover($cover);
}
foreach ($content_id as $cid) {
$a->save_cover($c->get_by_id($cid));
}
}
}
$this->redirect("/albums/{$id}");
}
示例10: index
function index()
{
if (!$this->auth) {
$this->error('403', 'Forbidden');
return;
}
$image_processing = new Setting();
$image_processing->where('name', 'image_processing_library')->get();
include FCPATH . 'app' . DIRECTORY_SEPARATOR . 'koken' . DIRECTORY_SEPARATOR . 'DarkroomUtils.php';
$libs = DarkroomUtils::libraries();
if ($image_processing->exists()) {
if (!isset($libs[$image_processing->value])) {
$top = array_shift(array_keys($libs));
$lib = $libs[$top];
$image_processing->value = $lib['key'];
$image_processing->save();
}
} else {
if (!defined('MAGICK_PATH_FINAL') || (MAGICK_PATH_FINAL === 'convert' || !isset($libs[MAGICK_PATH_FINAL]))) {
$top = array_shift(array_keys($libs));
$lib = $libs[$top];
} else {
$lib = $libs[MAGICK_PATH_FINAL];
}
$image_processing->name = 'image_processing_library';
$image_processing->value = $lib['key'];
$image_processing->save();
}
$last_check = new Setting();
$last_check->where('name', 'last_migration');
$last_check_count = $last_check->count();
if ($last_check_count > 1) {
$last_check->where('name', 'last_migration')->order_by('value ASC')->limit($last_check_count - 1)->get();
$last_check->delete_all();
}
$s = new Setting();
$settings = $s->get_iterated();
$data = array('image_processing_libraries' => array_values($libs));
$bools = array('has_toured', 'site_hidpi', 'retain_image_metadata', 'image_use_defaults', 'use_default_labels_links', 'uploading_publish_on_captured_date');
foreach ($settings as $setting) {
// Don't allow dupes to screw things up
if (isset($data[$setting->name])) {
continue;
}
$value = $setting->value;
if (in_array($setting->name, $bools)) {
$value = $value == 'true';
}
if ($setting->name === 'last_upload') {
$value = $value === 'false' ? false : (int) $value;
}
$data[$setting->name] = $value;
}
if (!isset($data['uploading_publish_on_captured_date'])) {
$data['uploading_publish_on_captured_date'] = false;
}
if (!isset($data['uploading_default_album_visibility'])) {
$data['uploading_default_album_visibility'] = 'public';
}
if (!isset($data['email_handler'])) {
$data['email_handler'] = 'DDI_Email';
}
$data['email_handlers'] = Shutter::get_email_handlers();
$disable_cache_file = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'no-site-cache';
$data['enable_site_cache'] = !file_exists($disable_cache_file);
if ($this->method != 'get') {
if ($this->auth_role !== 'god') {
$this->error('403', 'Forbidden');
return;
}
if (isset($_POST['signin_bg'])) {
$c = new Content();
$c->get_by_id($_POST['signin_bg']);
if ($c->exists()) {
$_c = $c->to_array();
$large = array_pop($_c['presets']);
// TODO: Error checking for permissions reject
$f = $large['url'];
$to = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'wallpaper' . DIRECTORY_SEPARATOR . 'signin.jpg';
if (extension_loaded('curl')) {
$cp = curl_init($f);
$fp = fopen($to, "w+");
if (!$fp) {
curl_close($cp);
} else {
curl_setopt($cp, CURLOPT_FILE, $fp);
curl_exec($cp);
curl_close($cp);
fclose($fp);
}
} elseif (ini_get('allow_url_fopen')) {
copy($f, $to);
}
}
} else {
if (isset($_POST['enable_site_cache'])) {
if ($_POST['enable_site_cache'] === 'true') {
@unlink($disable_cache_file);
} else {
touch($disable_cache_file);
//.........这里部分代码省略.........
示例11: time
$data['content_raw'] = '';
$data['datestamp'] = time();
$data['timestamp'] = time();
$data['original_slug'] = '';
$data['original_datestamp'] = '';
$data['original_timestamp'] = '';
$data['original_numeric'] = '';
if ($type == 'none') {
$data['folder'] = $path;
$data['full_slug'] = $path;
$data['slug'] = 'page';
}
} else {
$page = basename($path);
$folder = substr($path, 0, -1 * strlen($page) - 1);
if (!Content::exists($page, $folder)) {
$app->flash('error', Localization::fetch('content_not_found'));
$url = $app->urlFor('pages');
$app->redirect($url);
return;
}
$data = Statamic::get_content_meta($page, $folder, true);
$data['title'] = isset($data['title']) ? $data['title'] : '';
$data['slug'] = basename($path);
$data['full_slug'] = $folder . "/" . $page;
$data['path'] = $path;
$data['folder'] = $folder;
$data['page'] = $page;
$data['type'] = 'none';
$data['original_slug'] = '';
$data['original_datestamp'] = '';
示例12: attach
function attach($object = '', $parent = '', $cell = '', $sort = '')
{
if (!empty($object)) {
// synchronyze the cell and sort numbers
// to prevent paradox
if (empty($cell)) {
$cell = $object->cell;
} else {
$object->cell = $cell;
}
if (empty($sort)) {
$sort = $object->sort;
} else {
$object->sort = $sort;
}
if (empty($parent)) {
$parent = new Content();
$parent->get_by_id($object->parent_content);
}
// check if that place it took
$cont = new Content();
//$cont->where('parent_section',$this->id);//same section
$cont->where('parent_content', $parent->id);
//same parent
$cont->where('cell', $cell);
// same cell
$cont->where('sort', $sort);
//greater sort
$cont->get();
//get them to process
// if that content object exists then that place is taken
// so we have to get a place for it
if ($cont->exists()) {
// put the content in it's place require change all it's
// sisters that has a greater sort number to be increased
// get all this content belong to this parent and this section
// and the same cell and has a sort number greater that this
// sort number
//$cont->where('parent_section',$this->id);//same section
$cont->where('parent_content', $parent->id);
//same parent
$cont->where('cell', $cell);
// same cell
$cont->where('sort >=', $sort);
//greater sort
$cont->get();
//get them to process
foreach ($cont->all as $item) {
$item->sort++;
$item->save();
}
}
//save the object itself
$object->save();
}
}
示例13: up
public function up($id)
{
$c = new Content($id);
if ($c->exists()) {
if ($c->move_up()) {
$this->add_info(lang('system_content_moved_up'));
} else {
$this->add_info(lang('system_content_already_first'));
}
} else {
show_404();
}
}
示例14: function
})->name('files');
// Delete file
$admin_app->get('/file/delete', function () use($admin_app) {
authenticateForRole('admin');
doStatamicVersionCheck($admin_app);
$result = Addon::getAPI('file')->deleteFile();
$response = $admin_app->response();
$response['Content-Type'] = 'application/json';
$response->status(200);
$response->body(json_encode($result));
})->name('delete_file');
$admin_app->get('/url/unique', function () use($admin_app) {
$folder = Request::get('folder');
$url = Request::get('url');
$path = URL::assemble($folder, $url);
$data = array('exists' => Content::exists(Path::resolve($path)));
$response = $admin_app->response();
$response['Content-Type'] = 'application/json';
$response->body(json_encode($data));
});
/*
|--------------------------------------------------------------------------
| Hook: Add Routes
|--------------------------------------------------------------------------
|
| Allows add-ons to add their own hooks to the control panel.
|
*/
Hook::run('control_panel', 'add_routes');
// GET: 404
// --------------------------------------------------------
示例15: Content
<?php
$ci =& get_instance();
$ci->load->library('gui');
/********************************************
* checking if the page has a ID get paramter
* for edit purposes
********************************************/
$edit = $ci->uri->segment(5);
if ($edit) {
$con = new Content();
$con->get_by_id($edit);
if (!$con->exists()) {
$edit = FALSE;
} else {
$info = json_decode($con->info);
}
}
$hidden = array();
if ($edit === FALSE) {
$hidden['parent_section'] = $ci->input->post("parent_section");
$hidden['parent_content'] = $ci->input->post("parent_content");
$hidden['cell'] = $ci->input->post("cell");
$hidden['sort'] = $ci->input->post("sort");
$hidden['path'] = $ci->input->post("path");
$hidden['info'] = "";
} else {
$hidden['id'] = $con->id;
$hidden['parent_section'] = $con->parent_section;
$hidden['parent_content'] = $con->parent_content;
$hidden['cell'] = $con->cell;