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


PHP Article::find方法代码示例

本文整理汇总了PHP中Article::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::find方法的具体用法?PHP Article::find怎么用?PHP Article::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Article的用法示例。


在下文中一共展示了Article::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: article

 public function article($id)
 {
     if (!($id && ($article = Article::find('one', array('include' => array('sources'), 'conditions' => array('id = ? AND is_visibled = ? AND destroy_user_id IS NULL', $id, Article::IS_VISIBLED)))))) {
         return array();
     }
     if ($article->tags) {
         usort($article->tags, function ($a, $b) {
             return count($a->mappings) < count($b->mappings);
         });
     }
     if ($article->tags && ($article_ids = column_array(ArticleTagMapping::find('all', array('select' => 'article_id', 'order' => 'RAND()', 'limit' => 5, 'conditions' => array('article_id != ? AND article_tag_id = ?', $article->id, $article->tags[0]->id))), 'article_id'))) {
         Article::addConditions($conditions, 'id IN (?)', $article_ids);
     } else {
         Article::addConditions($conditions, 'id != ?', $article->id);
     }
     Article::addConditions($conditions, 'is_visibled = ? AND destroy_user_id IS NULL', Article::IS_VISIBLED);
     $others = Article::find('all', array('select' => 'id, title', 'limit' => 5, 'conditions' => $conditions));
     return array('article' => array_merge($article->to_array(array('only' => array('id', 'title', 'content', 'pv'), 'methods' => array('site_show_page_last_uri'))), array('mini_content' => array('150' => $article->mini_content(150), '300' => $article->mini_content(300)), 'cover_url' => array('1200x630c' => $article->cover->url('1200x630c')), 'updated_at' => array('c' => $article->updated_at->format('c'), 'Y-m-d H:i:s' => $article->updated_at->format('Y-m-d H:i:s')), 'created_at' => array('c' => $article->created_at->format('c'), 'Y-m-d H:i:s' => $article->created_at->format('Y-m-d H:i:s')))), 'tags' => array_map(function ($tag) {
         return $tag->to_array(array('only' => array('id', 'name')));
     }, $article->tags), 'others' => array_map(function ($article) {
         return $article->to_array(array('only' => array(), 'methods' => array('site_show_page_last_uri')));
     }, $others), 'sources' => array_map(function ($source) {
         return $source->to_array(array('only' => array('title', 'href'), 'methods' => array('mini_href')));
     }, $article->sources), 'user' => $article->user->to_array(array('only' => array('name'), 'methods' => array('facebook_link'))));
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:25,代码来源:site_cache_cell.php

示例2: sitmap

 public function sitmap()
 {
     $this->load->library('Sitemap');
     // 基礎設定
     $domain = 'http://www.zeusdesign.com.tw';
     $sit_map = new Sitemap($domain);
     $sit_map->setPath(FCPATH . 'sitemap' . DIRECTORY_SEPARATOR);
     $sit_map->setDomain($domain);
     // main pages
     $sit_map->addItem('/', '0.5', 'weekly', date('c'));
     $sit_map->addItem('/abouts/', '0.5', 'weekly', date('c'));
     $sit_map->addItem('/contacts/', '0.5', 'weekly', date('c'));
     $sit_map->addItem('/works/', '0.8', 'daily', date('c'));
     $sit_map->addItem('/articles/', '0.8', 'daily', date('c'));
     // all articles
     foreach (Article::find('all', array('select' => 'id, title, updated_at', 'order' => 'id DESC', 'conditions' => array('is_visibled = ? AND destroy_user_id IS NULL', Article::IS_VISIBLED))) as $article) {
         $sit_map->addItem('/article/' . $article->site_show_page_last_uri(), '1', 'daily', $article->updated_at->format('c'));
     }
     // all article tags
     foreach (ArticleTag::all(array('select' => 'id')) as $tag) {
         $sit_map->addItem('/article-tag/' . $tag->id . '/articles/', '0.8', 'daily', date('c'));
     }
     // all works
     foreach (Work::find('all', array('select' => 'id, title, updated_at', 'order' => 'id DESC', 'conditions' => array('is_enabled = ? AND destroy_user_id IS NULL', Work::ENABLE_YES))) as $work) {
         $sit_map->addItem('/work/' . $work->site_show_page_last_uri(), '1', 'daily', $work->updated_at->format('c'));
     }
     // all work tags
     foreach (WorkTag::all(array('select' => 'id')) as $tag) {
         $sit_map->addItem('/work-tag/' . $tag->id . '/works/', '0.8', 'daily', date('c'));
     }
     $sit_map->createSitemapIndex($domain . '/sitemap/', date('c'));
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:32,代码来源:cli.php

示例3: index

 public function index($tag_id, $offset = 0)
 {
     $columns = array();
     $configs = array('article-tag', $this->tag->id, 'articles', '%s');
     $conditions = conditions($columns, $configs);
     ArticleTagMapping::addConditions($conditions, 'article_tag_id = ?', $this->tag->id);
     $limit = 7;
     $total = ArticleTagMapping::count(array('conditions' => $conditions));
     $offset = $offset < $total ? $offset : 0;
     $this->load->library('pagination');
     $pagination = $this->pagination->initialize(array_merge(array('total_rows' => $total, 'num_links' => 3, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li class="f">', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li class="p">', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li class="n">', 'next_tag_close' => '</li>', 'last_tag_open' => '<li class="l">', 'last_tag_close' => '</li>'), $configs))->create_links();
     $article_ids = column_array(ArticleTagMapping::find('all', array('select' => 'article_id', 'offset' => $offset, 'limit' => $limit, 'order' => 'article_id DESC', 'conditions' => $conditions)), 'article_id');
     $articles = $article_ids ? Article::find('all', array('order' => 'FIELD(id,' . implode(',', $article_ids) . ')', 'conditions' => array('is_visibled = ? AND id IN (?) AND destroy_user_id IS NULL', Article::IS_VISIBLED, $article_ids))) : array();
     if ($articles) {
         $this->add_meta(array('name' => 'keywords', 'content' => implode(',', column_array($articles, 'title')) . ',' . implode(',', Cfg::setting('site', 'site', 'keywords'))))->add_meta(array('name' => 'description', 'content' => $articles[0]->mini_content(150)))->add_meta(array('property' => 'og:title', 'content' => $this->tag->name . '文章' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:description', 'content' => $articles[0]->mini_content(300)))->add_meta(array('property' => 'og:image', 'tag' => 'larger', 'content' => $img = $articles[0]->cover->url('1200x630c'), 'alt' => $this->tag->name . '文章' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:image:type', 'tag' => 'larger', 'content' => 'image/' . pathinfo($img, PATHINFO_EXTENSION)))->add_meta(array('property' => 'og:image:width', 'tag' => 'larger', 'content' => '1200'))->add_meta(array('property' => 'og:image:height', 'tag' => 'larger', 'content' => '630'))->add_meta(array('property' => 'article:modified_time', 'content' => $articles[0]->updated_at->format('c')))->add_meta(array('property' => 'article:published_time', 'content' => $articles[0]->created_at->format('c')));
         if (($tags = column_array($articles[0]->tags, 'name')) || ($tags = Cfg::setting('site', 'site', 'keywords'))) {
             foreach ($tags as $i => $tag) {
                 if (!$i) {
                     $this->add_meta(array('property' => 'article:section', 'content' => $tag))->add_meta(array('property' => 'article:tag', 'content' => $tag));
                 } else {
                     $this->add_meta(array('property' => 'article:tag', 'content' => $tag));
                 }
             }
         }
     }
     return $this->set_title($this->tag->name . '文章' . ' - ' . Cfg::setting('site', 'site', 'title'))->set_class('articles')->set_method('index')->load_view(array('tag' => $this->tag, 'articles' => $articles, 'pagination' => $pagination, 'columns' => $columns));
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:27,代码来源:tag_articles.php

示例4: post

 /**
  * Affiche l'article
  *
  * @access public
  * @return post.post
  */
 public function post($slug, $id)
 {
     // Find de right post
     $article = Article::find($id);
     // Get comments on this post
     $comments = $article->comments()->orderBy('created_at', 'DESC')->get();
     return View::make('article.article', array('article' => $article, 'comments' => $comments));
 }
开发者ID:raphaeljorge,项目名称:tor,代码行数:14,代码来源:ArticleController.php

示例5: eventBeforeDelete

 public function eventBeforeDelete($event)
 {
     $items = Article::find()->where(['cat_id' => $this->id])->all();
     if (count($items) > 0) {
         $this->addError('id', 'Diese Kategorie wird noch von einem oder mehreren Terminen benutzt und kann nicht gelöscht werden.');
         $event->isValid = false;
         return;
     }
     $event->isValid = true;
 }
开发者ID:efueger,项目名称:luya,代码行数:10,代码来源:Cat.php

示例6: index

 public function index()
 {
     $result = Test::first();
     echo "<pre>";
     // var_dump($result);
     $first = Article::find(1);
     var_dump($first->content);
     echo '<h1>this is index</h1>';
     $this->view = View::make('home')->with('article', Article::first())->withTitle('MFFC :-D')->withFuck('Ok!');
 }
开发者ID:jceee,项目名称:MFFC,代码行数:10,代码来源:IndexController.php

示例7: seedComment

 /**
  * 填充评论数据
  * @return void
  */
 private function seedComment()
 {
     Comment::truncate();
     // 清空表
     for ($i = 1; $i < 30; $i++) {
         Comment::create(array('user_id' => $i, 'article_id' => 1 + $i % 5 + 28, 'content' => '评论内容' . $i));
         Article::find(1 + $i % 5 + 28)->increment('comments_count');
     }
     $this->command->info('随机评论数据填充完毕');
 }
开发者ID:ningcaichen,项目名称:laravel-4.1-simple-blog,代码行数:14,代码来源:BlogTablesSeeder.php

示例8: show

/**
 * Print the content of an article specified by its id
 * 
 * @param {Int} $id
 */
function show($id)
{
    //retrive article from db
    $article = Article::find($id);
    //check if id correspond to an existing article
    if ($article) {
    } else {
        //retrive article author
        $author = User::findOrFail($article->author_id);
    }
}
开发者ID:ziedmahdi,项目名称:sies-internship-demo,代码行数:16,代码来源:hello-world-ikhlass.php

示例9: postAdd

 public function postAdd()
 {
     $input = Input::all();
     $title = 'Agregar a carrito';
     $article = Article::find($input['id']);
     $cantidad = $input['cantidad'];
     self::addToCart($article, $cantidad);
     return Redirect::back();
     /*return View::make('carts.index')
     		//->with(compact('title'));*/
 }
开发者ID:heromdn,项目名称:inventarios,代码行数:11,代码来源:CartController.php

示例10: test_multilingual_setting_by_reference

 public function test_multilingual_setting_by_reference()
 {
     $Article = new Article();
     $Article->set('headline', array('en' => 'New PHP Framework re-released', 'es' => 'Se ha re-liberado un nuevo Framework para PHP'));
     $Article->set('body', array('en' => 'The Akelos Framework has been re-released...', 'es' => 'Un equipo de programadores españoles ha re-lanzado un entorno de desarrollo para PHP...'));
     $Article->set('excerpt_limit', array('en' => 7, 'es' => 3));
     $this->assertTrue($Article->save());
     $Article =& $Article->find($Article->getId());
     $this->assertEqual($Article->get('en_headline'), 'New PHP Framework re-released');
     $this->assertEqual($Article->get('es_body'), 'Un equipo de programadores españoles ha re-lanzado un entorno de desarrollo para PHP...');
     $this->assertEqual($Article->get('en_excerpt_limit'), 7);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:12,代码来源:_AkActiveRecord_i18n.php

示例11: createComment

 public function createComment($article_id, Request $request)
 {
     $article_id = Article::find($article_id);
     $newcomment = new Comment();
     $message = $request->message;
     $newcomment->article_id = $article_id;
     $newcomment->message = $message;
     $newcomment->save();
     // $allcomments =Comment::where('article_id', $article_id)->get();
     // return view('articleviews.show', compact('article', 'allcomments'));
     return redirect('/article/' . $article_id);
 }
开发者ID:nikitasahai,项目名称:laravel,代码行数:12,代码来源:CommentController.php

示例12: get_index

 public function get_index($category, $title, $id, $idparent = null)
 {
     $id = !is_null($idparent) ? $idparent : $id;
     $article = Article::find($id);
     // || strcmp($title,$article->title)!=0
     if (is_null($article)) {
         return Redirect::error(404);
     }
     $article->categoryName = $article->Category()->first()->getCategoryFullName();
     $article->categoryUrl = $article->Category()->first()->getCategoryUrl();
     return View::make('visitor.article_content', array('article' => $article));
 }
开发者ID:gischen,项目名称:PHP-CMS,代码行数:12,代码来源:articlecontent.php

示例13: getRead

 public function getRead($id)
 {
     $article = Article::find($id);
     if ($article) {
         $article = DB::table('articles')->where('articles.id', '=', $id)->leftJoin('users', 'articles.user_id', '=', 'users.id')->leftJoin('nodes', 'articles.node_id', '=', 'nodes.id')->select('articles.*', 'users.name as user_name', 'nodes.name as node_name')->get();
         return view('layouts.home.read')->with('articles', $articles);
     } else {
         $returnInf = [];
         array_push($returnInf, '您查看的记录不存在');
         Session::flash('operationResult', 'am-alert-warning');
         Session::flash('returnInf', $returnInf);
         return redirect(url('home'));
     }
 }
开发者ID:xiaoxielaine,项目名称:hilaravel,代码行数:14,代码来源:HomeController.php

示例14: index_onDelete

 /**
  * Deleted checked articles.
  */
 public function index_onDelete()
 {
     if (($checkedIds = article('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $articleId) {
             if (!($article = Article::find($articleId))) {
                 continue;
             }
             $article->delete();
         }
         Flash::success(Lang::get('abnmt.theaterpress::lang.articles.delete_selected_success'));
     } else {
         Flash::error(Lang::get('abnmt.theaterpress::lang.articles.delete_selected_empty'));
     }
     return $this->listRefresh();
 }
开发者ID:abnmt,项目名称:oc-theaterpress-plugin,代码行数:18,代码来源:Articles.php

示例15: index_put

 function index_put()
 {
     $data = $this->put();
     $article = Article::find($data['id']);
     if ($this->put('request') == 'update') {
         $article->title = $data['title'];
         $article->type = $data['type'];
         $article->body = $data['body'];
         $article->save();
         $this->response($article);
     } else {
         if ($this->put('request') == 'delete') {
             $article->forceDelete();
         }
     }
 }
开发者ID:karsanrichard,项目名称:nqcl,代码行数:16,代码来源:news.php


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