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


PHP System::instance方法代码示例

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


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

示例1: displayCodes

 public function displayCodes()
 {
     $item = $this->getItem();
     $model = $this->getModel()->populateState();
     $view = \Dsc\System::instance()->get('theme');
     $offset = $model->getState('list.offset', 0, 'int');
     if ($offset < 0) {
         $offset = 0;
     }
     $model->setState('list.offset', $offset);
     $size = $model->getState('list.limit', 50, 'int');
     if (empty($size)) {
         $size = 50;
     }
     $model->setState('list.limit', $size);
     $total = count((array) $item->{'codes.list'});
     $pagination = new \Dsc\Pagination($total, $size);
     $origin_codes = array_values((array) $item->{'codes.list'});
     $codes = array_slice($origin_codes, $offset * $size, $size);
     $this->app->set('item', $item);
     $this->app->set('codes', $codes);
     $this->app->set('paginated', $pagination);
     $this->app->set('state', $model->getState());
     $this->app->set('meta.title', 'Coupon Codes | Shop');
     echo $view->render('Shop/Admin/Views::coupons/codes.php');
 }
开发者ID:dioscouri,项目名称:f3-shop,代码行数:26,代码来源:Coupon.php

示例2: index

 public function index()
 {
     $f3 = \Base::instance();
     $path = $this->inputfilter->clean($f3->get('PARAMS.1'), 'string');
     $model = $this->getModel();
     try {
         $category = (new \Blog\Models\Categories())->setState('filter.path', $path)->getItem();
         if (empty($category->id)) {
             throw new \Exception();
         }
         $paginated = $model->populateState()->setState('filter.category.id', $category->id)->setState('filter.publication_status', 'published')->setState('filter.published_today', true)->paginate();
     } catch (\Exception $e) {
         \Dsc\System::instance()->addMessage("Invalid Items", 'error');
         $f3->reroute('/blog');
         return;
     }
     $state = $model->getState();
     \Base::instance()->set('state', $state);
     \Base::instance()->set('paginated', $paginated);
     \Base::instance()->set('category', $category);
     $this->app->set('meta.title', $category->seoTitle() . ' | Blog');
     $this->app->set('meta.description', $category->seoDescription());
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Blog/Site/Views::categories/index.php');
 }
开发者ID:dioscouri,项目名称:f3-blog,代码行数:25,代码来源:Category.php

示例3: displayEdit

 protected function displayEdit()
 {
     $item = $this->getItem();
     if (empty($item) || $item->product_type != 'giftcards') {
         \Dsc\System::addMessage('Item is not a giftcard', 'error');
         $this->app->reroute('/admin/shop/giftcards');
     }
     $f3 = \Base::instance();
     $flash = \Dsc\Flash::instance();
     $variants = array();
     if ($flashed_variants = $flash->old('variants')) {
         foreach ($flashed_variants as $variant) {
             $key = implode("-", (array) $variant['attributes']);
             if (empty($key)) {
                 $key = $variant['id'];
             }
             $variants[$key] = $variant;
         }
     }
     $old = array_merge($flash->get('old'), array('variants' => $variants));
     $flash->store($old);
     $model = new \Shop\Models\Categories();
     $categories = $model->getList();
     \Base::instance()->set('categories', $categories);
     \Base::instance()->set('selected', 'null');
     $all_tags = $this->getModel()->getTags();
     \Base::instance()->set('all_tags', $all_tags);
     $this->app->set('meta.title', 'Edit Gift Card | Shop');
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayShopProductsEdit', array('item' => $this->getItem(), 'tabs' => array(), 'content' => array()));
     echo $view->render('Shop\\Admin\\Views::giftcards/edit.php');
 }
开发者ID:dioscouri,项目名称:f3-shop,代码行数:32,代码来源:GiftCard.php

示例4: index

 public function index()
 {
     $this->app->set('pagetitle', 'Transactions');
     $this->app->set('subtitle', '');
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Finances/Site/Views::transactions/index.php');
 }
开发者ID:ammonitenetworks,项目名称:f3-finances,代码行数:7,代码来源:Transactions.php

示例5: saveAs

 /**
  * Clone an item.  Data from $values takes precedence of data from cloned object.
  *
  * @param unknown_type $mapper
  * @param unknown_type $values
  * @param unknown_type $options
  */
 public function saveAs($document = array(), $options = array())
 {
     $item_data = $this->cast();
     // preserve any key=>values from the original item that are not in the new document array
     $new_values = array_merge($document, array_diff_key($item_data, $document));
     unset($new_values[$this->getItemKey()]);
     if ($existing = $this->pathExists($this->path)) {
         if ($new_values['title'] == $existing->title) {
             //THEY CHANGED THE TITLE SO lets unset slug and path and regenerate
             unset($new_values['slug']);
             unset($new_values['path']);
         } else {
             //Set path to something like string/string-2
             $i = 2;
             do {
                 $new_values['slug'] = $new_values['slug'] . '-' . $i;
                 $new_values['path'] = $this->path . '-' . $i;
                 if ($this->pathExists($new_values['path'])) {
                     $i++;
                 } else {
                     $i = false;
                 }
             } while ($i);
         }
         if ($new_values['details']['url'] == $existing->{'details.url'}) {
             //TODO I am not sure if we should append this as well or just alert them, I assume they would clone it to make a simliar URL so adding text to it could be annoying
             \Dsc\System::instance()->addMessage('Item shares a URL with another menu Item be sure to change it', 'warning');
         }
     }
     $item = new static($new_values);
     return $item->insert(array(), $options);
 }
开发者ID:dioscouri,项目名称:f3-lib,代码行数:39,代码来源:Navigation.php

示例6: runSite

 protected function runSite()
 {
     $f3 = \Base::instance();
     $f3->set('ONERROR', function ($f3) {
         $response = \Redirect\Factory::handleError();
         // Run the response through a Listener event
         $event = \Dsc\System::instance()->trigger('onError', array('response' => $response));
         $response = $event->getArgument('response');
         switch ($response->action) {
             case "handle":
                 $f3->call($response->callable_handle);
                 break;
             case "html":
                 echo $response->html;
                 break;
             case "redirect":
                 $f3->reroute($response->redirect_route);
                 break;
             default:
                 // by returning false, let f3 default error handler handle the error
                 return false;
                 break;
         }
     });
 }
开发者ID:dioscouri,项目名称:f3-redirect,代码行数:25,代码来源:bootstrap.php

示例7: findAsset

 public function findAsset($resource = null)
 {
     if (empty($resource)) {
         return;
     }
     // TODO allow this to be modified, both by an admin interface and via a class::method
     $approved_extensions = array('bmp', 'gif', 'ico', 'jpg', 'jpeg', 'odg', 'png', 'svg', '3gp', 'amv', 'avi', 'divx', 'mov', 'mp4', 'mpg', 'qt', 'rm', 'wmv', 'swf', 'm4a', 'mp3', 'ogg', 'wma', 'wav', 'eot', 'otf', 'ttf', 'woff', 'csv', 'doc', 'odp', 'ods', 'odt', 'pdf', 'ppt', 'txt', 'xcf', 'xls');
     // Is the extension of the requested asset in the list of approved extensions?
     $extension = strtolower(pathinfo($resource, PATHINFO_EXTENSION));
     if (!in_array($extension, $approved_extensions)) {
         \Base::instance()->error(500);
         return;
     }
     $global_app_name = \Base::instance()->get('APP_NAME');
     // Loop through all the registered paths and try to find the requested asset
     // If it is found, send it with \Web::instance()->send($file, null, 0, false);
     $paths = (array) \Base::instance()->get($global_app_name . '.dsc.minify.paths');
     foreach ($paths as $path) {
         $file = realpath($path . $resource);
         if (file_exists($file)) {
             \Base::instance()->set('file', $file);
             $theme = \Dsc\System::instance()->get('theme');
             echo $theme->renderView('Minify\\Views::asset.php');
             return;
         }
     }
     // File not found.
     \Base::instance()->error(500);
     return;
 }
开发者ID:dioscouri,项目名称:f3-minify,代码行数:30,代码来源:Controller.php

示例8: index

 public function index()
 {
     $this->app->set('meta.title', 'Dashboard | Pusher');
     // $this->pusher->trigger('my-channel', 'my_event', 'hello world');
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Pusher/Admin/Views::home/index.php');
 }
开发者ID:dioscouri,项目名称:f3-pusher,代码行数:7,代码来源:Home.php

示例9: addMessage

 /**
  * 
  * @param unknown_type $message
  * @param unknown_type $type
  */
 public static function addMessage($message, $type = 'info')
 {
     $messages = \Dsc\System::instance()->session->get('system.messages') ? \Dsc\System::instance()->session->get('system.messages') : array();
     switch (strtolower($type)) {
         case "good":
         case "success":
             $type = "success";
             break;
         case "high":
         case "bad":
         case "danger":
         case "error":
             $type = "danger";
             break;
         case "low":
         case "warn":
         case "warning":
         case "notice":
             $type = "warning";
             break;
         default:
             $type = "info";
             break;
     }
     $messages = array_merge((array) $messages, array(array('message' => $message, 'type' => $type)));
     \Dsc\System::instance()->session->set('system.messages', $messages);
 }
开发者ID:dioscouri,项目名称:f3-lib,代码行数:32,代码来源:System.php

示例10: read

 public function read()
 {
     $f3 = \Base::instance();
     $slug = $this->inputfilter->clean($f3->get('PARAMS.slug'), 'cmd');
     $model = $this->getModel()->populateState()->setState('filter.slug', $slug);
     $preview = $this->input->get("preview", 0, 'int');
     if ($preview) {
         $this->canPreview();
     } else {
         $model->setState('filter.published_today', true)->setState('filter.publication_status', 'published');
     }
     try {
         $item = $model->getItem();
         if (empty($item->id)) {
             throw new \Exception();
         }
         // increase the view count
         $item->hit();
     } catch (\Exception $e) {
         \Dsc\System::instance()->addMessage("Invalid Item", 'error');
         $f3->reroute('/blog');
         return;
     }
     $author = $this->getModel('users')->setState('filter.id', $item->{'author.id'})->getItem();
     $related = $item->getRelatedPosts();
     \Base::instance()->set('item', $item);
     \Base::instance()->set('author', $author);
     \Base::instance()->set('related', $related);
     $this->app->set('meta.title', $item->seoTitle() . ' | Blog');
     $this->app->set('meta.description', $item->seoDescription());
     \Blog\Models\Activities::track('Viewed Blog Post', array('Blog Title' => $item->seoTitle(), 'post_id' => (string) $item->id));
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Blog/Site/Views::posts/view.php');
 }
开发者ID:dioscouri,项目名称:f3-blog,代码行数:34,代码来源:Post.php

示例11: read

 public function read()
 {
     // TODO Check ACL against page.
     $slug = $this->inputfilter->clean($this->app->get('PARAMS.slug'), 'cmd');
     $model = $this->getModel()->populateState()->setState('filter.slug', $slug);
     $preview = $this->input->get("preview", 0, 'int');
     if ($preview) {
         $this->canPreview();
     } else {
         $model->setState('filter.published_today', true)->setState('filter.publication_status', 'published');
     }
     try {
         $item = $model->getItem();
         if (empty($item->id)) {
             throw new \Exception();
         }
     } catch (\Exception $e) {
         \Dsc\System::instance()->addMessage("Invalid Item", 'error');
         $this->app->error('404');
         return;
     }
     $this->app->set('item', $item);
     $this->app->set('meta.title', $item->seoTitle());
     $this->app->set('meta.description', $item->seoDescription());
     $view = \Dsc\System::instance()->get('theme');
     echo $view->renderTheme('Forums/Site/Views::posts/read.php');
 }
开发者ID:ammonitenetworks,项目名称:f3-forums,代码行数:27,代码来源:Post.php

示例12: read

 public function read()
 {
     $slug = $this->inputfilter->clean($this->app->get('PARAMS.slug'), 'PATH');
     $flash = \Dsc\Flash::instance();
     $this->app->set('flash', $flash);
     $height = $this->app->get('PARAMS.height');
     $width = $this->app->get('PARAMS.width');
     if ($height && $width) {
         $this->app->set('height', $height);
         $this->app->set('width', $width);
     }
     $model = $this->getModel();
     $item = $this->getItem();
     if (empty($item->id)) {
         return $this->app->error(404, 'Invalid Item');
     }
     $this->app->set('model', $model);
     $this->app->set('item', $item);
     // $flash->store((array) $item->cast());
     switch ($item->storage) {
         case "s3":
         case "cloudfiles":
         case "cdn":
             $this->app->reroute($item->url);
             break;
         case "gridfs":
         default:
             $this->app->set('meta.title', $item->slug);
             $view = \Dsc\System::instance()->get('theme');
             echo $view->renderLayout('Assets/Site/Views::assets/view.php');
             break;
     }
 }
开发者ID:dioscouri,项目名称:f3-assets,代码行数:33,代码来源:Asset.php

示例13: index

 public function index()
 {
     $f3 = \Base::instance();
     $id = $this->inputfilter->clean($f3->get('PARAMS.id'), 'alnum');
     $safemode_user = \Base::instance()->get('safemode.username');
     // slug contaings safeuser username ==> redirect to blog home page
     if ($safemode_user == $id) {
         \Dsc\System::instance()->addMessage("Unknown Author", 'error');
         $f3->reroute('/blog');
         return;
     }
     try {
         $author = $this->getModel('users')->setState('filter.username', $id)->getItem();
         if (empty($author->id)) {
             throw new \Exception();
         }
     } catch (\Exception $e) {
         \Dsc\System::instance()->addMessage("Unknown Author", 'error');
         $f3->reroute('/blog');
         return;
     }
     $model_posts = $this->getModel('posts')->populateState()->setState('filter.author.username', $id)->setState('filter.published_today', true)->setState('filter.publication_status', 'published');
     try {
         $paginated = $model_posts->paginate();
     } catch (\Exception $e) {
         $paginated = null;
     }
     $state = $model_posts->getState();
     \Base::instance()->set('state', $state);
     \Base::instance()->set('paginated', $paginated);
     \Base::instance()->set('author', $author);
     $this->app->set('meta.title', $author->fullName() . ' | Blog');
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Blog/Site/Views::author/index.php');
 }
开发者ID:dioscouri,项目名称:f3-blog,代码行数:35,代码来源:Author.php

示例14: index

 public function index()
 {
     if ($tags = \Shop\Models\Products::getTags()) {
         sort($tags);
     } else {
         $tags = array();
     }
     $model = (new \Shop\Models\Tags())->populateState();
     $state = $model->getState();
     $needle = $model->getState('filter.keyword');
     if (!empty($needle)) {
         $tags = array_filter($tags, function ($tags) use($needle) {
             return stripos($tags, $needle) !== false;
         });
     }
     if (!empty($tags)) {
         $tags = array_map(function ($el) {
             return new \Shop\Models\Tags(array('title' => $el));
         }, $tags);
     }
     \Base::instance()->set('state', $state);
     \Base::instance()->set('tags', $tags);
     $this->app->set('meta.title', 'Tags | Shop');
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Shop/Admin/Views::tags/index.php');
 }
开发者ID:dioscouri,项目名称:f3-shop,代码行数:26,代码来源:Tags.php

示例15: html

 public function html()
 {
     $f3 = \Base::instance();
     \Dsc\System::instance()->get('theme')->registerViewPath(__DIR__ . '/Views/', 'Blog/Modules/Posts/Views');
     $string = \Dsc\System::instance()->get('theme')->renderLayout('Blog/Modules/Posts/Views::default.php');
     return $string;
 }
开发者ID:dioscouri,项目名称:f3-blog,代码行数:7,代码来源:Module.php


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