本文整理汇总了PHP中Content::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::find方法的具体用法?PHP Content::find怎么用?PHP Content::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Content
的用法示例。
在下文中一共展示了Content::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSlug
public function createSlug()
{
if ($this->slug) {
return $slug;
} else {
$parent = Content::find($this->tmp_parent_id);
if ($this->title) {
$pageSlug = $this->title;
} else {
if ($this->name) {
$pageSlug = $this->name;
} else {
$pageSlug = uniqid();
}
}
$pageSlug = str_replace(" ", "-", $pageSlug);
//spaces
$pageSlug = urlencode($pageSlug);
//last ditch attempt to sanitise
$wholeSlug = rtrim(@$parent->slug, "/") . "/{$pageSlug}";
//does it already exist?
if (Content::where("slug", "=", $wholeSlug)->first()) {
//it already exists.. find the highest numbered example and increment 1.
$highest = Content::where('slug', 'like', "{$wholeSlug}-%")->orderBy('slug', 'desc')->first();
$num = 1;
if ($highest) {
$num = str_replace("{$wholeSlug}-", "", $highest->slug);
$num++;
}
return "{$wholeSlug}-{$num}";
} else {
return $wholeSlug;
}
}
}
示例2: updateContentMeta
/**
* コンテンツメタ情報を更新する
*
* @param string $contentCategory
* @return boolean
* @access public
*/
public function updateContentMeta(Model $model)
{
$db = ConnectionManager::getDataSource('baser');
$contentCategories = array();
$contentTypes = array();
if ($db->config['datasource'] == 'Database/BcCsv') {
// CSVの場合GROUP BYが利用できない(baserCMS 2.0.2)
$contents = $this->Content->find('all', array('conditions' => array('Content.status' => true)));
foreach ($contents as $content) {
if ($content['Content']['category'] && !in_array($content['Content']['category'], $contentCategories)) {
$contentCategories[$content['Content']['category']] = $content['Content']['category'];
}
if ($content['Content']['type'] && !in_array($content['Content']['type'], $contentTypes)) {
$contentTypes[$content['Content']['type']] = $content['Content']['type'];
}
}
} else {
$contents = $this->Content->find('all', array('fields' => array('Content.category'), 'group' => array('Content.category'), 'conditions' => array('Content.status' => true)));
foreach ($contents as $content) {
if ($content['Content']['category']) {
$contentCategories[$content['Content']['category']] = $content['Content']['category'];
}
}
$contents = $this->Content->find('all', array('fields' => array('Content.type'), 'group' => array('Content.type'), 'conditions' => array('Content.status' => true)));
foreach ($contents as $content) {
if ($content['Content']['type']) {
$contentTypes[$content['Content']['type']] = $content['Content']['type'];
}
}
}
$siteConfigs['SiteConfig']['content_categories'] = BcUtil::serialize($contentCategories);
$siteConfigs['SiteConfig']['content_types'] = BcUtil::serialize($contentTypes);
$SiteConfig = ClassRegistry::init('SiteConfig');
return $SiteConfig->saveKeyValue($siteConfigs);
}
示例3: newDownload
public function newDownload()
{
$download = '';
if (Input::has('id')) {
$download = Content::find(Input::get('id'));
} else {
$download = new Content();
}
return View::make('admin/downloads/new')->withDownloads($download);
}
示例4: editStoreContentEdit
public function editStoreContentEdit($id)
{
$content = Content::find($id);
$t = Input::get('title');
$c = Input::get('content');
if (empty($t) or empty($c)) {
return View::make('admin.contentedit.edit')->withContents($content)->withErrors(['msg' => ['Все поля должны быть заполнены!!!']]);
}
$content->title = $t;
$content->content = $c;
$content->save();
return Redirect::to('/admin/contentedit')->withErrors(['msg' => ['Контент ' . $content->title . ' changed!']]);
}
示例5: realPath
/**
* returns the full path to teh page
*/
public function realPath($pageId)
{
$c = new Content();
$page = $c->find($pageId)->current();
if ($page) {
$parents = $c->getParents($pageId);
if (is_array($parents) && count($parents) > 0) {
$path = implode('/', $parents) . '/';
}
$fullpath = $path . $page->title;
return strtolower($fullpath);
}
}
示例6: control_panel__post_publish
public function control_panel__post_publish($publish_data)
{
// check that caching is turned on
if (!$this->core->isEnabled()) {
return;
}
// we only need one key from the hook's value
$file = $publish_data['file'];
// update the cache
_Cache::update();
ContentService::loadCache(true);
// grab data
$triggers = $this->fetchConfig('publish_invalidation', array(), 'is_array', false, false);
$content = Content::find(Path::tidy(str_replace(Config::getContentRoot(), '/', $file)));
if ($triggers && $content) {
foreach ($triggers as $trigger) {
$folders = Parse::pipeList(array_get($trigger, 'folder', null));
$key = array_get($trigger, 'key', null);
if (!$folders || !$key) {
// not checking this
continue;
}
// check
$invalidate = false;
foreach ($folders as $folder) {
if ($folder === "*" || $folder === "/*") {
// include all
$invalidate = true;
break;
} elseif (substr($folder, -1) === "*") {
// wildcard check
if (strpos($content['_folder'], substr($folder, 0, -1)) === 0) {
$invalidate = true;
break;
}
} else {
// plain check
if ($folder == $content['_folder']) {
$invalidate = true;
break;
}
}
}
// invalidate if needed
if ($invalidate) {
$this->core->deleteByKey(Parse::pipeList($key));
}
}
}
}
示例7: anyDestroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function anyDestroy($id = null)
{
if (!$id) {
$id = \Input::all();
if (@$id['id'] == '#') {
$id = '';
} else {
$id = @$id['id'];
}
}
$this->content->find($id)->delete();
if (!\Request::ajax()) {
return redirect()->action('\\Bootleg\\Cms\\ContentsController@anyIndex');
}
}
示例8: show
/**
* Enter description here...
*
* @param string $token
* @param integer $editMode
* @return string
*/
function show($token = "", $editMode = true)
{
if (empty($token)) {
return '';
}
$out = "";
$id = "";
$ses_LNG = $this->Session->read('User.Lang');
$langId = $ses_LNG['id'];
$objContent = new Content();
$content = $objContent->find('first', array('contain' => array(), 'conditions' => array('token' => $token, 'language_id' => $langId)));
if (!empty($content)) {
$out = $content['Content']['content'];
$id = $content['Content']['id'];
} else {
//Get content for default Language
$content = $objContent->find('first', array('contain' => array(), 'conditions' => array('token' => $token, 'language_id' => DEFAULT_LANG_ID)));
if (!empty($content)) {
$out = $content['Content']['content'];
$id = $content['Content']['id'];
} else {
/*Create New content*/
$defaultContent = array('Content' => array('token' => $token, 'language_id' => DEFAULT_LANG_ID, 'title' => '', 'content' => $token));
//array
$objContent->save($defaultContent);
$id = $objContent->getLastInsertID();
$out = $token;
}
}
//else
if ($editMode) {
$out = '<span class="token">' . '<span class="data" id="token' . $id . '" >' . $out . '</span>' . $this->Html->link($this->Html->image('editable.gif', array('alt' => 'edit')), "/contents/edittoken/{$id}?KeepThis=true&TB_iframe=true&height=500&width=680", array('class' => 'thickbox', 'title' => 'edit'), null, false) . '</span>';
}
//if
return $out;
}
示例9: delete
public function delete(array $input)
{
if (isset($input['id'])) {
$id = $input['id'];
/* @var $content Content */
$content = Content::find($id);
$category = $content->category()->first();
if ($category != null) {
$category_id = $category->id;
$category = Category::find($category_id);
$category->contents()->detach($content->id);
}
return [$content->delete()];
} else {
return [false];
}
}
示例10: content
public function content()
{
$mid = Q('mid', 0, 'intval');
$cid = Q('cid', 0, 'intval');
$aid = Q('aid', 0, 'intval');
if (!$mid || !$cid || !$aid) {
$this->error('参数错误', __ROOT__);
}
$ContentModel = new Content($mid);
$field = $ContentModel->find($aid);
if ($field) {
$field['time'] = date("Y/m/d", $field['addtime']);
$field['date_before'] = date_before($field['addtime']);
$field['commentnum'] = M("comment")->where("cid=" . $cid . " AND aid=" . $aid)->count();
$this->assign('hdcms', $field);
$this->display($field['template']);
}
}
示例11: getTree
/**
* コンテンツリストをツリー構造で取得する
*
* @param $id
* @param null $level
* @param array $options
* @return array
*/
public function getTree($id = 1, $level = null, $options = [])
{
$options = array_merge(['type' => '', 'order' => ['Content.site_id', 'Content.lft']], $options);
$conditions = array_merge($this->_Content->getConditionAllowPublish(), ['Content.id' => $id]);
$content = $this->_Content->find('first', ['conditions' => $conditions, 'cache' => false]);
if (!$content) {
return [];
}
$conditions = array_merge($this->_Content->getConditionAllowPublish(), ['Content.site_root' => false, 'rght <' => $content['Content']['rght'], 'lft >' => $content['Content']['lft']]);
if ($level) {
$level = $level + $content['Content']['level'] + 1;
$conditions['Content.level <'] = $level;
}
if (!empty($options['type'])) {
$conditions['Content.type'] = ['ContentFolder', $options['type']];
}
if (!empty($options['conditions'])) {
$conditions = array_merge($conditions, $options['conditions']);
}
// CAUTION CakePHP2系では、fields を指定すると正常なデータが取得できない
return $this->_Content->find('threaded', ['order' => $options['order'], 'conditions' => $conditions, 'recursive' => 0, 'cache' => false]);
}
示例12: category
public function category($cid, $page = 1)
{
$categoryCache = cache('category');
$cat = $categoryCache[$cid];
$GLOBALS['totalPage'] = 0;
if ($cat['cat_url_type'] == 2 || $cat['cattype'] == 3) {
return true;
}
//单文章
if ($cat['cattype'] == 4) {
$Model = ContentViewModel::getInstance($cat['mid']);
$result = $Model->join()->where("cid={$cat['cid']}")->find();
if ($result) {
$Content = new Content($cat['mid']);
$data = $Content->find($result['aid']);
return $this->content($data);
}
} else {
//普通栏目与封面栏目
$htmlDir = C("HTML_PATH") ? C("HTML_PATH") . '/' : '';
$_REQUEST['page'] = $_GET['page'] = $page;
$_REQUEST['mid'] = $cat['mid'];
$_REQUEST['cid'] = $cat['cid'];
$Model = ContentViewModel::getInstance($cat['mid']);
$catid = getCategory($cat['cid']);
$cat['content_num'] = $Model->join()->where("cid IN(" . implode(',', $catid) . ")")->count();
$cat['comment_num'] = intval(M('comment')->where("cid IN(" . implode(',', $catid) . ")")->count());
$htmlFile = $htmlDir . str_replace(array('{catdir}', '{cid}', '{page}'), array($cat['catdir'], $cat['cid'], $page), $cat['cat_html_url']);
$info = explode('.', $htmlFile);
$this->assign("hdcms", $cat);
$this->createHtml(basename($info[0]), dirname($htmlFile) . '/', $cat['template']);
//第1页时复制index.html
if ($page == 1) {
copy($htmlFile, dirname($htmlFile) . '/index.html');
}
return true;
}
}
示例13: indexAction
public function indexAction()
{
$page = $this->request->get('page', 'int', 0);
if ($page < 1) {
$page = 0;
$this->view->pageType = 1;
$this->view->prepage = 0;
$this->view->nextpage = $this->_pageSize;
} else {
if ($page > $this->_allCount) {
$page = $this->_allCount;
$this->view->pageType = 3;
$this->view->prepage = $this->_allCount - $this->_pageSize;
$this->view->nextpage = $this->_pageSize;
} else {
$this->view->pageType = 2;
$this->view->prepage = $page - $this->_pageSize;
$this->view->nextpage = $page + $this->_pageSize;
}
}
$this->view->number = $page;
$this->view->data = Content::find(array('limit' => $this->_pageSize, 'offset' => $page));
}
示例14: content
public function content()
{
$mid = Q('mid', 0, 'intval');
$cid = Q('cid', 0, 'intval');
$aid = Q('aid', 0, 'intval');
if (!$mid || !$cid || !$aid) {
_404();
}
$ContentAccessModel = K('ContentAccess');
if (!$ContentAccessModel->isShow($cid)) {
$this->error('你没有阅读权限');
}
$CacheTime = C('CACHE_CONTENT') >= 1 ? C('CACHE_CONTENT') : null;
if (!$this->isCache()) {
$ContentModel = new Content($mid);
$field = $ContentModel->find($aid);
if ($field) {
$this->assign('hdcms', $field);
$this->display($field['template'], $CacheTime);
}
} else {
$this->display(null, $CacheTime);
}
}
示例15: index_put
function index_put()
{
$data = $this->put();
// echo '<pre>';print_r($data);die;
if ($this->put('request') == 'update') {
$content = Content::find($data['content'][0]['id']);
// print_r($data['content']);
$content->body = $data['content'][0]['body'];
$content->save();
} else {
if ($this->put('request') == 'delete') {
$content = Menu::find($data['id']);
$content->active = 0;
$content->save();
} else {
if ($this->put('request') == 'enable') {
$content = Menu::find($data['id']);
$content->active = 1;
$content->save();
}
}
}
$this->response($content);
}