public static function setUpBeforeClass() { // for error reporting (need to run with php5.3 to get no warning) //ini_set('display_errors', 1); //error_reporting(~0); // new pet $new_pet_id = 10005; $new_pet = new Model\Pet(); $new_pet->setId($new_pet_id); $new_pet->setName("PHP Unit Test"); $new_pet->setStatus("available"); // new tag $tag = new Model\Tag(); $tag->setId($new_pet_id); // use the same id as pet $tag->setName("test php tag"); // new category $category = new Model\Category(); $category->setId($new_pet_id); // use the same id as pet $category->setName("test php category"); $new_pet->setTags(array($tag)); $new_pet->setCategory($category); $pet_api = new Api\PetAPI(); // add a new pet (model) $add_response = $pet_api->addPet($new_pet); }
public function install() { parent::install(); $category = new Model\Category(); $category->name = \GO::t('general', 'bookmarks'); $category->save(); $category->acl->addGroup(\GO::config()->group_internal, \GO\Base\Model\Acl::READ_PERMISSION); }
function __construct() { //------------------获取页面传入参数--------------------------------- $categoryId = R::getParams('cid'); $cids = R::getParams('cids'); $act = R::getParams('act'); $category = new \Model\Category(); if ($act == "search") { $search = R::requestParam("seach"); $result = $category->getSearchCategory($search); } elseif ($cids) { $result = $category->getCategoryName($cids); } else { $result = $category->getCategory($categoryId); } }
public function indexAction() { $name = Comm\Arg::post('name'); $alias = Comm\Arg::post('alias'); Model\Category::create($name, $alias); Comm\Response::json(100000, '操作成功', null, false); }
public static function setUpBeforeClass() { // increase memory limit to avoid fatal error due to findPetByStatus // returning a lot of data ini_set('memory_limit', '256M'); // for error reporting (need to run with php5.3 to get no warning) //ini_set('display_errors', 1); //error_reporting(~0); // when running with php5.5, comment out below to skip the warning about // using @ to handle file upload //ini_set('display_startup_errors',1); //ini_set('display_errors',1); //error_reporting(-1); // enable debugging //Configuration::$debug = true; // skip initializing the API client as it should be automatic //$api_client = new ApiClient('http://petstore.swagger.io/v2'); // new pet $new_pet_id = 10005; $new_pet = new Model\Pet(); $new_pet->setId($new_pet_id); $new_pet->setName("PHP Unit Test"); $new_pet->setPhotoUrls(array("http://test_php_unit_test.com")); // new tag $tag = new Model\Tag(); $tag->setId($new_pet_id); // use the same id as pet $tag->setName("test php tag"); // new category $category = new Model\Category(); $category->setId($new_pet_id); // use the same id as pet $category->setName("test php category"); $new_pet->setTags(array($tag)); $new_pet->setCategory($category); $pet_api = new Api\PetApi(); // add a new pet (model) $add_response = $pet_api->addPet($new_pet); }
/** * 生成对应的HTML表单内容 * @param type $field 提交过来的字段 */ public function formList($field) { switch ($field['field_type']) { case 'text': require 'theme/text.php'; break; case 'textarea': require 'theme/textarea.php'; break; case 'editor': /** * 将属于必填项的表单名称写入数组 * 在模板的底部进行一个JS的校验. */ static $checkEditor, $checkEditorName; if ($field['field_required'] == '1') { /* 表单名称 */ $checkEditor[] = $field['field_name']; /* 显示名称 */ $checkEditorName[] = $field['display_name']; } require 'theme/editor.php'; break; case 'date': require 'theme/date.php'; break; case 'radio': require 'theme/radio.php'; break; case 'checkbox': require 'theme/checkbox.php'; break; case 'thumb': require 'theme/thumb.php'; break; case 'category': \Model\Category::$where = 'm.model_name = "' . MODULE . '"'; $tree = \Model\Category::getSelectCate($field['value'] ? array($field['value']) : '', true); require 'theme/category.php'; break; case 'select': require 'theme/select.php'; break; case 'file': require 'theme/file.php'; break; case 'img': require 'theme/img.php'; break; } }
public function show($name) { saveVisitor(); $name = urldecode($name); $category = Model\Category::whereName($name)->firstOrFail(); $paginate = pagination($category->articles, 15, 'category/show/' . $name); $data['category'] = $category; $data['articles'] = $paginate; $data['links'] = $this->Mod_link->read(); $this->template->set('active', $category->id); $this->template->set('railnews', false); $this->template->set('sidebar', false); $this->template->set('single', true); $this->template->set('sidebarCategory', true); $this->template->build('show', $data); }
public function indexAction() { $theme = Comm\Arg::get('theme', FILTER_VALIDATE_INT, ['min_range' => 0], true); $resource = Comm\Arg::get('resource', FILTER_DEFAULT, null, true); Yaf_Registry::set('tpl_id', $theme); switch ($resource) { //预览首页 case 'home': $pager = new Comm\Pager(1000, 20, 1); $articles = Model\Article::showUserList($pager); Model\Publish::home($articles, $pager, null, false); break; //预览分类下的文章列表 //预览分类下的文章列表 case 'article-list': $pager = new Comm\Pager(1000, 20, 1); $articles = Model\Article::showUserList(new Comm\Pager(1, 1, 1)); if (!$articles) { throw new Exception\Msg(_('至少发表一篇文章才可预览')); } $article = reset($articles['result']); $category = Model\Category::show($article['category_id']); $articles = Model\Article::showUserList($pager, false, $category['id']); $articles = isset($articles['result']) ? $articles['result'] : array(); Model\Publish::categoryArticleList($category, $articles, $pager, null, false); break; //预览文章 //预览文章 case 'article': $articles = Model\Article::showUserList(new Comm\Pager(1, 1, 1)); $article = reset($articles['result']); Model\Publish::article($article, false); break; //预览导航 //预览导航 case 'sidebar': Model\Publish::sidebar(false, false); break; default: throw new \Exception\Msg('本资源不支持预览'); } }
public function indexAction() { $last_page = Comm\Arg::get('last_page', FILTER_VALIDATE_INT, ['min_range' => 1]) ?: 0; $page = Comm\Arg::get('p', FILTER_VALIDATE_INT, ['min_range' => 1]) ?: 1; $uid = Yaf_Registry::get('current_uid'); //获取总数 $total = Model\Counter\Article::get(0, $uid); //获取用户的博客配置中的分页设置 $blog = Model\Blog::show(); empty($blog['data']['page_count']) || ($this->_limit = $blog['data']['page_count']); //获取分页参数 $pager = new \Comm\Pager($total, $this->_limit); //获取数据 $articles = Model\Article::showUserList($pager); //获取分类内容 $categorys = Model\Category::showUserAll(); $categorys = Comm\Arr::hashmap($categorys, 'id'); //获取用户博客基本地址 $blog_url = 'http://' . \Model\Github::showDefaultBlogRepoName(); $this->viewDisplay(array('articles' => $articles, 'categorys' => $categorys, 'pager' => $pager, 'blog_url' => $blog_url)); }
/** * 生成对应的HTML表单内容 * @param type $field 提交过来的字段 */ public function formList($field) { switch ($field['field_type']) { case 'text': require 'theme/text.php'; break; case 'textarea': require 'theme/textarea.php'; break; case 'editor': /** * 将属于必填项的表单名称写入数组 * 在模板的底部进行一个JS的校验. */ static $checkEditor, $checkEditorName; if ($field['field_required'] == '1') { /* 表单名称 */ $checkEditor[] = $field['field_name']; /* 显示名称 */ $checkEditorName[] = $field['field_display_name']; } require 'theme/editor.php'; break; case 'date': require 'theme/date.php'; break; case 'radio': require 'theme/radio.php'; break; case 'checkbox': require 'theme/checkbox.php'; break; case 'thumb': require 'theme/thumb.php'; break; case 'category': \Model\Category::$where = 'm.model_name = "' . MODULE . '"'; $tree = \Model\Category::getSelectCate($field['value'] ? array($field['value']) : array(), true); require 'theme/category.php'; break; case 'select': require 'theme/select.php'; break; case 'file': require 'theme/file.php'; break; case 'img': require 'theme/img.php'; break; case 'theme': $themeName = THEME . '/Home/' . \Core\Func\CoreFunc::getThemeName('Home') . '/' . MODULE; $themeList = scandir($themeName); $theme = ['默认模板' => '']; foreach ($themeList as $value) { if ($value != '.' && $value != '..' && $value != '.DS_Store') { $value = str_replace('.php', '', $value); $theme[$value] = $value; } } $field['field_option'] = json_encode($theme); require 'theme/select.php'; break; } }
public function indexAction() { $ids = isset($_POST['ids']) ? $_POST['ids'] : array(); Model\Category::destroyByUserBatch($ids); Comm\Response::json(100000, '操作成功', null, false); }
public function indexAction() { $categorys = Model\Category::showUserAll(); $this->viewDisplay(array('form_action' => Comm\View::path('aj/manage/article/create'), 'categorys' => $categorys), 'manage/article/update'); }
public function indexAction() { $categorys = Model\Category::showUserAll(); $this->viewDisplay(array('categorys' => $categorys), 'manage/article/update'); }
public function indexAction() { $categorys = Model\Category::showUserAll(); $this->viewDisplay(['categorys' => $categorys]); }