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


PHP Model::factory方法代码示例

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


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

示例1: getHome

 public function getHome($request, $response, $args)
 {
     $template = $this->twig->loadTemplate('index.twig');
     $posts = \Model::factory('App\\Models\\Post')->find_many();
     $response->setContent($template->render(['posts' => $posts]));
     return $response;
 }
开发者ID:signalfire,项目名称:whatblog,代码行数:7,代码来源:HomeController.php

示例2: action_show

 /**
  * 显示日志详细
  * 
  * @param $blog_id 日志编号
  */
 public function action_show($blog_id)
 {
     $model = Model::factory('blog');
     $view = View::factory('pages/blog/show.php');
     $view->blog_info = $model->get_blog_info($blog_id);
     $this->template->content = $view;
 }
开发者ID:un44444444,项目名称:chenwei,代码行数:12,代码来源:blog.php

示例3: action_index

 public function action_index()
 {
     if (!Auth::instance()->logged_in() && isset($_POST['login'])) {
         $user = ORM::factory('User');
         $status = Auth::instance()->login($_POST['username'], $_POST['password'], true);
         if ($status) {
             HTTP::redirect('/');
         }
     }
     if (Auth::instance()->logged_in() && isset($_POST['logout'])) {
         Auth::instance()->logout();
     }
     if (!Auth::instance()->logged_in()) {
         Guestid::factory()->get_id();
     }
     $templateData['title'] = 'Главная.';
     $templateData['description'] = '';
     $template = View::factory('template')->set('templateData', $templateData);
     $content = View::factory("catalog");
     $content->get = $_GET;
     $content->shopArr = Model::factory('Shop')->getShop();
     $root_page = "index";
     $template->root_page = $root_page;
     $template->content = $content;
     $this->response->body($template);
 }
开发者ID:desc0n,项目名称:teleantenna,代码行数:26,代码来源:Index.php

示例4: action_post

 public function action_post()
 {
     $username = $this->request->post('username');
     $password = $this->request->post('password');
     $captcha = $this->request->post('captcha');
     if ($username and $password) {
         //if(Captcha::valid($captcha)) {
         $passport = $this->getpassport($username, $password);
         if (!is_object($passport)) {
             if ($passport == -1) {
                 $DATA['msg'] = "对不起,你使用的用户名尚未注册!";
             } elseif ($passport == -2) {
                 $DATA['msg'] = "对不起,密码错误,请重新输入。";
             } elseif ($passport == -3) {
                 $DATA['msg'] = "账号已经冻结客服";
             } elseif ($passport == -5) {
                 $DATA['msg'] = "登陆次数过多,请联系客服";
             } else {
                 $DATA['msg'] = '登录失败,请确认用户名或者邮箱正确!';
             }
         } else {
             $user_id = $passport->uid;
             $user = $this->login($user_id);
             Model::factory('Sys')->updateLoginData($user, 3);
             return $this->redirect(ROOTURL . '/admin/main/index');
         }
         //} else {
         //	$DATA['msg'] = '登陆失败,验证码错误!';
         //}
     } else {
         $DATA['msg'] = '用户名或者Email错误!';
     }
     echo View::factory('admin/login/index', $DATA);
 }
开发者ID:rucky2013,项目名称:kohana-php-admin,代码行数:34,代码来源:Login.php

示例5: set_projects

 public function set_projects()
 {
     // cache
     $key = $this->_user_id . '::project_list';
     $data = $this->cache->get($key);
     if (!$data) {
         $project_table = Model::factory('project');
         $tmp = $project_table->select_all_user_projects($this->_user_id);
         $data['_projects'] = array();
         // if there are projects
         if ($tmp->current()) {
             // build the select drop down
             foreach ($tmp as $tmp2) {
                 $data['_projects'][$tmp2->id] = $tmp2->name;
             }
         }
         // set cache for 24 hours
         $this->cache->set($key, $data, NULL, 86400);
     }
     // set the currently selected project_id if it is not set
     if (!isset($_SESSION['project_id_current']) || !isset($data['_projects'][$_SESSION['project_id_current']])) {
         // set it to the first project id in the list
         foreach ($data['_projects'] as $k => $v) {
             $_SESSION['project_id_current'] = $k;
             break;
         }
     }
     // set current project id
     $data['_project_id_selected'] = $_SESSION['project_id_current'];
     $this->_project_id_selected = $data['_project_id_selected'];
     // bind the data the template
     $this->template->bind('data', $data);
 }
开发者ID:jonnyjon,项目名称:Task-Queue,代码行数:33,代码来源:application.php

示例6: action_allposts

 public function action_allposts()
 {
     $post_model = Model::factory('Post');
     $post_model->query_posts();
     $view = View::factory('site')->set('posts', $post_model->posts);
     $this->response->body($view);
 }
开发者ID:GlennCr,项目名称:Blog,代码行数:7,代码来源:front.php

示例7: __construct

 public function __construct(Request $request, Response $response)
 {
     parent::__construct($request, $response);
     $this->contentModel = Model::factory('Content');
     $this->newsModel = Model::factory('News');
     $this->template = $this->contentModel->getTemplate();
 }
开发者ID:desc0n,项目名称:ideal-city,代码行数:7,代码来源:Index.php

示例8: insert

 public function insert($file, array $callback, $scan_info)
 {
     $class = $callback[0];
     $method = $callback[1];
     $class = Model::factory($class);
     $this->_handle = fopen($file, 'r');
     $headers = fgetcsv($this->_handle, $file);
     $scan_data = array();
     $file = new SplFileObject($file);
     $file->setFlags(SplFileObject::SKIP_EMPTY);
     $file->setFlags(SplFileObject::READ_AHEAD);
     $file->setFlags(SplFileObject::READ_CSV);
     $file->setCsvControl(",", '"', "\"");
     $c = 0;
     foreach ($file as $row) {
         $c++;
         if (count($row) === count($headers)) {
             $scan_data[] = array_combine($headers, $row);
             $row = array();
         }
         if ($c % $this->insert_threshold == 0) {
             Logger::msg('info', array('message' => 'flushing ' . $this->insert_threshold . ' rows', "class" => $callback[0], "method" => $callback[1], 'rows_inserted' => $c));
             Logger::msg('info', array('memory_usage' => $this->file_size(memory_get_usage())));
             $flush = $class->{$method}($scan_data, $scan_info);
             $scan_data = array();
         }
     }
     $flush = $class->{$method}($scan_data, $scan_info);
     $scan_data = array();
     Logger::msg('info', array('memory_usage' => $this->file_size(memory_get_usage())));
     return $c;
 }
开发者ID:pombredanne,项目名称:vulnDB,代码行数:32,代码来源:csv.php

示例9: mainView

 public function mainView($file, $data)
 {
     $role_id = $this->isAdmin();
     if ($role_id < 1) {
         return $this->redirect('admin/login/index');
     }
     $functions = Model::factory('Sys')->userFunction($role_id);
     $menus = array();
     $market = false;
     foreach ($functions as $func) {
         $menus[$func->app_id]['title'] = $func->app_name;
         $menus[$func->app_id]['code'] = $func->app_ename;
         $menus[$func->app_id]['img'] = $func->app_img;
         if ($func->func_ename == 'PersonalSetting') {
             $market = true;
         }
         $menus[$func->app_id]['children'][$func->func_id]['title'] = $func->func_name;
         $menus[$func->app_id]['children'][$func->func_id]['code'] = $func->func_ename;
         $menus[$func->app_id]['children'][$func->func_id]['url'] = $func->func_url;
         $menus[$func->app_id]['children'][$func->func_id]['img'] = $func->func_img;
     }
     $data['admin_menus'] = $menus;
     $data['main_content'] = View::factory($file, $data);
     $data['market'] = $market;
     echo View::factory('admin/main', $data);
 }
开发者ID:rucky2013,项目名称:kohana-php-admin,代码行数:26,代码来源:AdminController.php

示例10: create_new

 public function create_new($post, $discussion_id, $reply_comment_id = NULL)
 {
     $comment = NULL;
     if (isset($post['text']) && isset($discussion_id)) {
         $user = Auth::instance()->get_user();
         $comment = Model::factory('Comment');
         $values = array();
         $values["text"] = $post['text'];
         $values["discussion_id"] = $discussion_id;
         if ($user) {
             $values["user_id"] = $user->id;
         } else {
             if ($post['author_visitor'] != "") {
                 $values["author_visitor"] = $post['author_visitor'];
             }
         }
         $values["reply_comment_id"] = $reply_comment_id;
         $comment->values($values, array_keys($values));
         try {
             $comment->save();
             Notifications::factory()->new_comment($comment->reload());
         } catch (ORM_Validation_Exception $e) {
             $errors = $e->errors('models');
         }
     }
     return $comment;
 }
开发者ID:Workhaven,项目名称:workhaven,代码行数:27,代码来源:Comment.php

示例11: getSeriesPinyin

 public static function getSeriesPinyin()
 {
     $redis = Cache::instance('redis');
     $cache_key = '_ALL_SERIES_PINYIN_';
     $data = $redis->get($cache_key);
     if (empty($data)) {
         $m_brand = Model::factory('auto_series');
         $data = $m_brand->getAll('', 'id,pinyin')->as_array();
         $data = array_column($data, 'pinyin', 'id');
         $data = array_map(function ($v) {
             return preg_replace('/[^0-9a-z]/', '', strtolower($v));
         }, $data);
         $tmp = array();
         foreach ($data as $id => $pinyin) {
             if (isset($tmp[$pinyin])) {
                 $tmp[$pinyin] += 1;
                 $data[$id] = $pinyin . $tmp[$pinyin];
             } else {
                 $tmp[$pinyin] = 1;
             }
         }
         $redis->setex($cache_key, 86400, json_encode($data));
     } else {
         $data = json_decode($data, true);
     }
     return $data;
 }
开发者ID:andygoo,项目名称:cms,代码行数:27,代码来源:SEO.php

示例12: saveTree

 static function saveTree($meanings, $lexem)
 {
     $seenMeaningIds = array();
     // Keep track of the previous meaning ID at each level. This allows us to populate the parentId field
     $meaningStack = array();
     $displayOrder = 1;
     foreach ($meanings as $tuple) {
         $m = $tuple->id ? self::get_by_id($tuple->id) : Model::factory('Meaning')->create();
         $m->parentId = $tuple->level ? $meaningStack[$tuple->level - 1] : 0;
         $m->displayOrder = $displayOrder++;
         $m->breadcrumb = $tuple->breadcrumb;
         $m->userId = session_getUserId();
         $m->lexemId = $lexem->id;
         $m->internalRep = $tuple->internalRep;
         $m->htmlRep = AdminStringUtil::htmlize($m->internalRep, 0);
         $m->internalComment = $tuple->internalComment;
         $m->htmlComment = AdminStringUtil::htmlize($m->internalComment, 0);
         $m->save();
         $meaningStack[$tuple->level] = $m->id;
         $sourceIds = StringUtil::explode(',', $tuple->sourceIds);
         MeaningSource::updateList(array('meaningId' => $m->id), 'sourceId', $sourceIds);
         $meaningTagIds = StringUtil::explode(',', $tuple->meaningTagIds);
         MeaningTagMap::updateList(array('meaningId' => $m->id), 'meaningTagId', $meaningTagIds);
         foreach ($tuple->relationIds as $type => $lexemIdString) {
             if ($type) {
                 $lexemIds = StringUtil::explode(',', $lexemIdString);
                 Relation::updateList(array('meaningId' => $m->id, 'type' => $type), 'lexemId', $lexemIds);
             }
         }
         $seenMeaningIds[] = $m->id;
     }
     self::deleteNotInSet($seenMeaningIds, $lexem->id);
 }
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:33,代码来源:Meaning.php

示例13: action_list

 /**
  * 角色列表
  */
 public function action_list()
 {
     $total = Model::factory('Role')->countRoles()->getArray();
     $pagination = Pagination::factory($total);
     $roles = Model::factory('Role')->getRolesByLimit($pagination->offset(), $pagination->number())->getObject();
     $this->_default->content = View::factory('role/list')->set('roles', $roles)->set('pagination', $pagination);
 }
开发者ID:panchao1,项目名称:cronsystem,代码行数:10,代码来源:Role.php

示例14: postPostNew

 public function postPostNew($request, $response, $args)
 {
     if (!$this->app->auth()->isLoggedIn()) {
         $response = new \RedirectResponse('/unauthorised');
         return $response;
     }
     $template = $this->twig->loadTemplate('post/new.twig');
     $validator = new \Valitron\Validator(array('title' => $this->app->input()->post('title'), 'body' => $this->app->input()->post('body'), 'status' => $this->app->input()->post('status')));
     $validator->rule('required', ['title', 'body', 'status']);
     $validator->rule('integer', ['status']);
     if ($validator->validate()) {
         $post = \Model::factory('App\\Models\\Post')->create();
         $post->title = $this->app->input()->post('title');
         $post->body = $this->app->input()->post('body');
         $post->created_at = date('Y-m-d H:i:s');
         $post->updated_at = date('Y-m-d H:i:s');
         $post->status = $this->app->input()->post('status');
         if ($post->save()) {
             $response = new RedirectResponse('/');
             return $response;
         } else {
             $response->setContent($template->render(['errors' => [['Unable to create post']], 'input' => $this->app->input()->all('post')]));
             return $response;
         }
     } else {
         $response->setContent($template->render(['errors' => $validator->errors(), 'input' => $this->app->input()->all('post')]));
         return $response;
     }
 }
开发者ID:signalfire,项目名称:whatblog,代码行数:29,代码来源:PostNewController.php

示例15: indexAction

    public function indexAction()
    {
        $this->_resource->addJs('/js/lib/jquery.js', 1);
        Model::factory('Medialib')->includeScripts();
        $this->_resource->addJs('/js/app/system/designer/lang/' . $this->_config->get('lang') . '.js', 1);
        $this->_resource->addCss('/js/app/system/designer/style.css');
        $this->_resource->addCss('/js/lib/CodeMirror/lib/codemirror.css');
        $this->_resource->addCss('/js/lib/CodeMirror/lib/util/dialog.css');
        $this->_resource->addCss('/js/lib/CodeMirror/lib/util/simple-hint.css');
        $this->_resource->addCss('/js/lib/CodeMirror/theme/eclipse.css');
        $dbConfigs = array();
        foreach ($this->_configMain->get('db_configs') as $k => $v) {
            $dbConfigs[] = array('id' => $k, 'title' => $this->_lang->get($v['title']));
        }
        $componentTemplates = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer_templates.php')->__toArray();
        $this->_resource->addInlineJs('
		      var dbConfigsList = ' . json_encode($dbConfigs) . ';    
		      var componentTemplates = ' . json_encode(array_values($componentTemplates)) . ';  
		');
        $count = 4;
        foreach (self::$_externalScripts as $path) {
            $this->_resource->addJs($path, $count);
            $count++;
        }
        if (!$this->_config->get('development')) {
            $this->_resource->addJs($this->_config->get('compiled_js') . '?v=' . $this->_version, $count);
        } else {
            foreach (self::$_scripts as $path) {
                $this->_resource->addJs($path, $count);
                $count++;
            }
        }
    }
开发者ID:vgrish,项目名称:dvelum,代码行数:33,代码来源:Controller.php


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