本文整理汇总了PHP中Dsc\System类的典型用法代码示例。如果您正苦于以下问题:PHP System类的具体用法?PHP System怎么用?PHP System使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了System类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: index
public function index()
{
// when ACL is ready
// $this->checkAccess( __CLASS__, __FUNCTION__ );
$model = $this->getModel();
$state = $model->populateState()->getState();
\Base::instance()->set('state', $state);
$paginated = $model->paginate();
\Base::instance()->set('paginated', $paginated);
$categories_db = (array) $this->getModel("categories")->getItems();
$categories = array(array('text' => 'All Categories', 'value' => ' '), array('text' => '- Uncategorized -', 'value' => '--'));
array_walk($categories_db, function ($cat) use(&$categories) {
$categories[] = array('text' => $cat->title, 'value' => (string) $cat->slug);
});
\Base::instance()->set('categories', $categories);
$all_tags = array(array('text' => 'All Tags', 'value' => ' '), array('text' => '- Untagged -', 'value' => '--'));
$tags = (array) $this->getModel()->getTags();
array_walk($tags, function ($tag) use(&$all_tags) {
$all_tags[] = array('text' => $tag, 'value' => $tag);
});
\Base::instance()->set('all_tags', $all_tags);
$this->app->set('meta.title', 'Posts | Blog');
$this->app->set('allow_preview', $this->canPreview(true));
$view = \Dsc\System::instance()->get('theme');
echo $view->render('Blog/Admin/Views::posts/list.php');
}
示例3: html
public function html()
{
\Base::instance()->set('module', $this);
\Dsc\System::instance()->get('theme')->registerViewPath(__DIR__ . '/Views/', 'Modules/Html/Views');
$string = \Dsc\System::instance()->get('theme')->renderLayout('Modules/Html/Views::default.php');
return $string;
}
示例4: restore
public function restore()
{
//TODO try catch here
$this->getItem()->restore();
\Dsc\System::instance()->addMessage("Item was restored", 'success');
$this->app->reroute($this->list_route);
}
示例5: saveAsk
public function saveAsk()
{
$this->app->set('pagetitle', 'About');
$this->app->set('subtitle', '');
$view = \Dsc\System::instance()->get('theme');
echo $view->render('Faq/Site/Views::faq/index.php');
}
示例6: 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;
}
示例7: update
public function update()
{
$id = $this->inputfilter->clean($this->app->get('PARAMS.id'), 'cmd');
try {
$item = (new \Shop\Models\PaymentMethods())->setState('filter.identifier', $id)->getItem();
if (empty($item->id)) {
throw new \Exception('Payment Method not found');
}
$enabled = $this->app->get('POST.enabled');
if (strlen($enabled)) {
$item->enabled = false;
if (!empty($enabled)) {
$item->enabled = true;
}
}
if ($settings_array = (array) $this->inputfilter->clean($this->app->get('POST.settings'), 'array')) {
$item->settings = $settings_array;
}
$item->save();
\Dsc\System::addMessage('Settings updated', 'success');
$this->app->reroute('/admin/shop/payment-method/edit/' . $id);
} catch (\Exception $e) {
\Dsc\System::addMessage("Invalid Payment Method", 'error');
\Dsc\System::addMessage($e->getMessage(), 'error');
$this->app->reroute('/admin/shop/payment-methods');
return;
}
}
示例8: passes
public static function passes(\Modules\Models\Modules $module, $route = null, $options = array())
{
// if this ruleset is ignored, return null
if (!in_array($module->{'assignment.login_status.method'}, array('include', 'exclude'))) {
return null;
}
$user = \Dsc\System::instance()->get('auth')->getIdentity();
$is_logged_in = empty($user->id) ? false : true;
$match = false;
switch ($module->{'assignment.login_status.value'}) {
case "1":
if ($is_logged_in) {
$match = true;
}
break;
case "0":
default:
if (!$is_logged_in) {
$match = true;
}
break;
}
switch ($module->{'assignment.login_status.method'}) {
case "exclude":
$passes = $match ? false : true;
break;
default:
$passes = $match;
break;
}
return $passes;
}
示例9: 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.type', true)->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());
\Pages\Models\Activities::track('Viewed Page', array('Page Title' => $item->seoTitle(), 'page_id' => (string) $item->id));
$view = \Dsc\System::instance()->get('theme');
$view_file = 'view.php';
if ($item->{'display.view'} && $view->findViewFile('Pages/Site/Views::pages/view/' . $item->{'display.view'})) {
$view_file = 'view/' . $item->{'display.view'};
}
echo $view->renderTheme('Pages/Site/Views::pages/' . $view_file);
}
示例10: 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);
}
示例11: isShippingMethodEnabled
public function isShippingMethodEnabled($method = null)
{
$result = false;
switch ($method) {
case 'ups':
$result = $this->{'shipping.ups.enabled'} && $this->{'shipping.ups.key'} && $this->{'shipping.ups.password'};
break;
case 'usps':
$result = $this->{'shipping.usps.enabled'} && $this->{'shipping.usps.key'};
break;
case 'fedex':
$result = $this->{'shipping.fedex.enabled'};
break;
case 'stamps':
$result = $this->{'shipping.stamps.enabled'};
break;
case 'dhl':
$result = $this->{'shipping.dhl.enabled'};
break;
case null:
// are ANY of the social providers enabled?
$enabled = $this->enabledShippingMethods();
if (!empty($enabled)) {
$result = true;
}
break;
default:
$event = \Dsc\System::instance()->trigger('onShippingMethodEnabled', array('method' => $provider, 'result' => null));
$result = $event->getArgument('result');
break;
}
return $result;
}
示例12: 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');
}
示例13: 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');
}
示例14: 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');
}
示例15: 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;
}
});
}