本文整理汇总了PHP中Content::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::factory方法的具体用法?PHP Content::factory怎么用?PHP Content::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Content
的用法示例。
在下文中一共展示了Content::factory方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$reps = Content::factory()->where_related_contenttype('classname', 'Gallery')->order_by('updated DESC, created DESC')->get();
$this->templatemanager->assign("galleries", $reps);
$this->templatemanager->set_title("Manage Galleries");
$this->templatemanager->show_template("galleries_list");
}
示例2: gallery_add_new
public function gallery_add_new($id, $cname, $pid)
{
$id = (int) $id;
$pid = (int) $pid;
$content = Content::factory()->get_by_id($id);
$this->templatemanager->set_title("Add images");
$this->templatemanager->assign("content", $content);
$this->templatemanager->show_template("gallery_images_upload");
}
示例3: foreach
<thead>
<tr>
<th class="sortCol"><div>ID<span></span></div></th>
<th class="sortCol"><div>Last modified<span></span></div></th>
<th class="">Actions</th>
</tr>
</thead>
<tbody>
<?php
foreach ($divs as $div_id) {
?>
<?php
if ($div_id == $content->div) {
continue;
}
$contentO = Content::factory()->where('div', $div_id)->group_start()->where_related_page('id', $page->id)->or_where('is_global', true)->group_end()->limit(1)->get();
if (!$user->can_edit_content($contentO)) {
continue;
}
?>
<tr class="grade<?php
echo !$contentO->exists() ? 'X' : (!empty($contentO->is_global) ? 'C' : 'A');
?>
">
<td class="center"><?php
echo $div_id;
?>
</td>
<td class="center"><?php
echo empty($contentO->updated) ? "—" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $contentO->updated) . '">' . relative_time($contentO->updated) . '</span> ' . __('by %s', User::factory($contentO->editor_id)->name);
?>
示例4: uri
public function uri()
{
//get request uri
$uri = $path = trim($this->uri->uri_string(), '/');
if ($path == '.htaccess') {
show_404($path);
}
//if uri is empty assign index.html or index.php (if index.html doesn't exist)
if (empty($uri)) {
$uri = $path = "index.htm";
if (!is_file($path)) {
$path = "index-original.htm";
}
if (!is_file($path)) {
$uri = $path = "index.html";
}
if (!is_file($path)) {
$path = "index-original.html";
}
if (!is_file($path)) {
$uri = "index.php";
$path = "index-original.php";
}
} elseif (is_dir($path)) {
$p = rtrim($path, '/') . '/index.htm';
if (!is_file($p)) {
$p = rtrim($path, '/') . '/index.html';
}
if (!is_file($p)) {
$p = rtrim($path, '/') . '/index.php';
}
$uri = $path = $p;
}
//fix for bad linking
/*if (current_url() == site_url())
{
redirect(site_url($uri));
die;
}//*/
//get page
$this->page = $page = Page::factory()->get_by_uri($uri);
//get file obj from db
if (!$page->exists()) {
$file = File::factory()->get_by_path($path);
} else {
$file = $page->file->get();
}
//if file doesn't exists in database, check if it needs to be saved in the
// db and save it (if needed)
if (!$file->exists()) {
$file->path = $path;
//if file doesn't exists on disk either, show 404
if (!is_file($file->path)) {
show_404($path);
}
$file->checksum = md5_file($file->path);
//if user is logged in, add him as last editor
if (!empty($this->user)) {
$file->editor_id = $this->user->id;
}
//if html file, save it to the database
if ($file->mime_type() == 'text/html') {
$file->save();
}
}
//if file exists in the database, check it and push it :)
if ($file->mime_type() !== 'text/html') {
$file->push();
}
$newpage = false;
//if page doesn't exist
if (!$page->exists()) {
if (!$file->exists()) {
//no page and no file!?
show_404($uri);
} else {
$page->title = $file->get_title();
$page->keywords = $file->get_meta('keywords');
$page->description = $file->get_meta('description');
$save2 = array($file);
if (!empty($this->user)) {
$save2[] = $this->user;
}
$page->uri = $uri;
$page->save($save2);
}
//new page!
$newpage = true;
} else {
//check for file
$f = $page->file->get();
if ($f->exists()) {
//if there is a file, assign it;
$file = $f;
} else {
//assign default file
if (is_file($page->uri)) {
$file = new File();
$file->path = $page->uri;
$file->checksum = md5_file($file->path);
//.........这里部分代码省略.........
示例5: remove
public function remove($cid, $back_to = 'pages')
{
$c = Content::factory((int) $cid);
if ($c->exists()) {
$page = $c->page->get();
$name = $c->div;
$revs = $c->contentrevision->get();
$revs->delete_all();
$repeatables = $c->repeatableitem->get();
$repswimg = $c->repeatableitem->where('image !=', null);
foreach ($repswimg as $r) {
$im = new Image($r->image);
$im->remove_thumbnails();
@unlink($r->image);
}
$repeatables->delete_all();
$c->delete();
$this->templatemanager->notify_next("Content \"{$name}\" is successfully removed!", 'success');
if (empty($back_to)) {
redirect('administration/pages/edit/' . $page->uri);
} else {
redirect('administration/' . str_replace('-', '/', $back_to));
}
} else {
$this->templatemanager->notify_next("Content is already deleted!", 'failure');
redirect('administration/' . str_replace('-', '/', $back_to));
}
}
示例6: index
public function index()
{
//get stats
$last15 = Hit::factory()->fetch(time() - 60 * 15)->unique()->cnt();
$last15bymin = Hit::timeflow(time() - 60 * 15, null, 15);
$last4hrs = Hit::factory()->fetch(time() - 3600 * 4)->unique()->cnt();
$last4hrsbymin = Hit::timeflow(time() - 3600 * 4, null, 16);
$today = Hit::factory()->fetch(mktime(0, 0, 0))->unique()->cnt();
$todaybymin = Hit::timeflow(mktime(0, 0, 0), null, 24);
$yesterday = Hit::factory()->fetch(mktime(0, 0, 0) - 3600 * 24, mktime(0, 0, 0))->unique()->cnt();
$yesterdaybymin = Hit::timeflow(mktime(0, 0, 0) - 3600 * 24, mktime(0, 0, 0), 24);
$lastweek = Hit::factory()->fetch(mktime(0, 0, 0) - 3600 * 24 * 7)->unique()->cnt();
$lastweekbymin = Hit::timeflow(mktime(0, 0, 0) - 3600 * 24 * 7, null, 14);
$lastmonth = Hit::factory()->fetch(mktime(0, 0, 0) - 3600 * 24 * 30)->unique()->cnt();
$lastmonthbymin = Hit::timeflow(mktime(0, 0, 0) - 3600 * 24 * 7, null, 30);
$returning = Hit::factory()->fetch(time() - 3600 * 24 * 30)->unique()->where('returning', true)->cnt();
$new_pages = Page::factory()->where('created >=', time() - 3600 * 24 * 30)->get()->result_count();
$countries = Hit::factory()->fetch(time() - 3600 * 24 * 30)->group_by('country')->cnt();
$pagehits = Hit::factory()->select('*,count(page_id) as cnt')->include_related('page', null, TRUE, TRUE)->where('page_id >', 0)->fetch(time() - 3600 * 24 * 7)->group_by('page_id')->limit(1)->get();
$this->templatemanager->assign('pagehits', $pagehits);
$ping = false;
$pingset = Setting::factory('last_ping');
$lastping = (int) $pingset->value;
if (time() - $lastping > 3600 * 24 * 7) {
$ping = true;
}
$pingset->value = time();
$pingset->save();
$this->templatemanager->assign('last15', $last15);
$this->templatemanager->assign('last15bymin', $last15bymin);
$this->templatemanager->assign('last4hrs', $last4hrs);
$this->templatemanager->assign('last4hrsbymin', $last4hrsbymin);
$this->templatemanager->assign('today', $today);
$this->templatemanager->assign('todaybymin', $todaybymin);
$this->templatemanager->assign('yesterday', $yesterday);
$this->templatemanager->assign('yesterdaybymin', $yesterdaybymin);
$this->templatemanager->assign('lastweek', $lastweek);
$this->templatemanager->assign('lastweekbymin', $lastweekbymin);
$this->templatemanager->assign('lastmonth', $lastmonth);
$this->templatemanager->assign('lastmonthbymin', $lastmonthbymin);
$this->templatemanager->assign('returning', $returning);
$this->templatemanager->assign('new_pages', $new_pages);
$this->templatemanager->assign('countries', $countries);
$this->templatemanager->assign('ping', $ping);
//latest repeatables
$last_repeatables = RepeatableItem::factory()->order_by('timestamp DESC')->limit(5)->get();
$this->templatemanager->assign('last_repeatables', $last_repeatables);
//latest contents updated
$last_contents = Content::factory()->where_related_contenttype('classname', 'Html')->order_by('updated DESC, created DESC')->limit(10)->get();
$this->templatemanager->assign('last_contents', $last_contents);
//count content updates (revisions)
$revs = ContentRevision::factory()->count();
$this->templatemanager->assign('revisions', $revs);
//if geoip is old, notify
$geoip_db_filename = './iu-resources/geoip/GeoIP.dat';
if (is_file($geoip_db_filename)) {
$month_earlier = time() - 3600 * 24 * 30;
$filemtime = filemtime($geoip_db_filename);
if ($this->user->can('edit_settings') && $filemtime <= $month_earlier) {
$lnk = site_url('administration/maintenance');
$this->templatemanager->notify(__("Your GeoIP database is now older than one month! Consider <a href='{$lnk}'>updating it</a>!"), 'information');
}
}
//get latest users
$users = User::factory()->order_by('created DESC')->limit(5)->get();
$this->templatemanager->assign('users', $users);
$this->templatemanager->show_template("dashboard");
}
示例7: can_edit_content
public function can_edit_content($content)
{
//admin can edit all
if ($this->is_admin()) {
return true;
}
if (is_numeric($content)) {
$content = Content::factory($content);
}
//if content does not exist, assume we can edit it
if (empty($content) || !$content->exists()) {
return true;
}
//if user can edit page, he can edit all contents
if ($this->can_edit_page($content->page_id)) {
return true;
}
//if user is editor of a content, return true
if ($this->is_related_to('assigned_contents', $content->id)) {
return true;
}
//by default, return false
return false;
}
示例8: save
public function save($id = null)
{
if (empty($id)) {
$item = new RepeatableItem();
} else {
$item = RepeatableItem::factory((int) $id);
}
if ($item->exists() && !$this->user->can_edit_content($item->content->get())) {
$this->templatemanager->notify_next("You don't have enough permissions to edit this item's content!", 'failure');
redirect('administration/dashboard');
}
$item->title = $this->input->post('title');
$item->text = $this->input->post('text');
$uid = (int) $this->input->post('user_id');
if ($this->user->is_admin()) {
$item->user_id = empty($uid) ? $this->user->id : $uid;
} else {
$item->user_id = empty($id) ? $this->user->id : $item->user_id;
}
$date = $this->input->post('date');
$time = $this->input->post('time');
$cid = (int) $this->input->post('cid');
$dateparts = parse_datepicker($date);
$timeparts = explode(':', $time);
$ts = mktime($timeparts[0], $timeparts[1], 0, $dateparts['m'], $dateparts['d'], $dateparts['y']);
$item->timestamp = $ts;
//prepare for upload
$config['upload_path'] = $this->user->assets_path();
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '512';
$config['max_width'] = '1024';
$config['max_height'] = '1024';
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
//upload picture
if (!empty($_FILES['image']['name'])) {
if (!$this->upload->do_upload('image')) {
show_error($this->upload->display_errors());
} else {
$data = $this->upload->data();
$item->image = $config['upload_path'] . $data['file_name'];
}
}
if ($item->exists()) {
$item->save();
} else {
$content = Content::factory($cid);
$item->save(array($content));
}
redirect('administration/repeatables/edit/' . $item->id);
}
示例9: gallery_page
public function gallery_page($pid, $cid, $ppage, $pagenr)
{
$template = $this->input->post('template');
$page = Page::factory((int) $pid);
$content = Content::factory((int) $cid);
$ppage = (int) $ppage;
$tempdom = new htmldom();
$tempdom->load('<html><body>' . $template . '</body></html>');
$domitem = $tempdom->find('.iu-gallery-item', 0);
$content = Content::factory((int) $cid);
$items = GalleryItem::factory()->where_related_content('id', (int) $cid);
if (empty($ppage)) {
$items->get();
} else {
$items->get_paged_iterated($pagenr, $ppage);
}
require_once "./iu-application/libraries/contentprocessor.php";
require_once "./iu-application/libraries/contents/Gallery.php";
$instance =& get_instance();
$cp = new Gallery($instance);
$response = '';
foreach ($items as $i) {
$newdomitem = clone $domitem;
//add new item to placeholder
$response .= $cp->process_template($newdomitem, $i, $page, $content);
}
echo json_encode(array('content' => $content->div, 'html' => $response));
}