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


PHP midgardmvc_core::get_instance方法代码示例

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


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

示例1: can_view

 public function can_view($user = null)
 {
     if (midgardmvc_core::get_instance()->context->mimetype === 'text/html') {
         return true;
     }
     return false;
 }
开发者ID:bergie,项目名称:midgardmvc_core,代码行数:7,代码来源:uimessages.php

示例2: load_object

 /**
  * Loads a program
  */
 public function load_object(array $args)
 {
     $this->object = com_meego_devprogram_devutils::get_device_by_name($args['device_name']);
     if (is_object($this->object)) {
         midgardmvc_core::get_instance()->head->set_title($this->object->name);
     }
 }
开发者ID:nemein,项目名称:com_meego_devprogram,代码行数:10,代码来源:devices.php

示例3: get_invalidate

 public function get_invalidate(array $args)
 {
     midgardmvc_core::get_instance()->authorization->require_user();
     midgardmvc_core::get_instance()->cache->invalidate_all();
     midgardmvc_core::get_instance()->context->cache_enabled = false;
     midgardmvc_core::get_instance()->head->relocate(midgardmvc_core::get_instance()->dispatcher->generate_url('index', array(), $this->request));
 }
开发者ID:bergie,项目名称:midgardmvc_core,代码行数:7,代码来源:cache.php

示例4: __construct

 /**
  * The constructor will initialize the sessioning, set the output nocacheable
  * and initialize the session data. This might involve creating an empty
  * session array.
  */
 public function __construct()
 {
     static $started = false;
     if ($started) {
         throw new Exception("Midgard MVC Sessioning has already been started, it must not be started twice. Aborting");
     }
     $started = true;
     $this->dispatcher = midgardmvc_core::get_instance()->dispatcher;
     try {
         if (!$this->dispatcher->headers_sent()) {
             $this->dispatcher->session_start();
         }
     } catch (Exception $e) {
         midgardmvc_core::get_instance()->log(__CLASS__, "Couldn't start session: " . $e->getMessage(), 'warn');
         $this->enabled = false;
         return;
     }
     /* Cache disabling made conditional based on domain/key existence */
     // Check for session data and load or initialize it, if necessary
     if ($this->dispatcher->session_has_var(self::ROOT)) {
         $this->data = $this->dispatcher->session_get_var(self::ROOT);
     } else {
         $this->data['midgardmvc_core_services_sessioning'] = array();
         $this->data['midgardmvc_core_services_sessioning']['startup'] = array();
         $this->dispatcher->session_set_var(self::ROOT, $this->data);
     }
 }
开发者ID:piotras,项目名称:midgardmvc_core,代码行数:32,代码来源:midgard.php

示例5: test_singleton

 public function test_singleton()
 {
     $this->_core->newproperty = true;
     $midcom_new = midgardmvc_core::get_instance();
     $this->assertEquals($midcom_new->newproperty, true);
     unset($this->_core->newproperty);
 }
开发者ID:piotras,项目名称:midgardmvc_core,代码行数:7,代码来源:core.php

示例6: get_cache_name

 private function get_cache_name()
 {
     if (!isset(midgardmvc_core::get_instance()->context->host)) {
         return 'MidgardMVC';
     }
     return midgardmvc_core::get_instance()->context->host->name;
 }
开发者ID:piotras,项目名称:midgardmvc_core,代码行数:7,代码来源:sqlite3.php

示例7: get_feed

 public function get_feed(array $args)
 {
     // Read items from Content Repository
     $this->get_items($args);
     // Set up feed
     midgardmvc_core::get_instance()->component->load_library('Feed');
     $feed = new ezcFeed();
     $feed->title = $this->data['title'];
     $feed->description = '';
     $now = new DateTime();
     $feed->published = $now->format(DateTime::RSS);
     $link = $feed->add('link');
     $link->href = midgardmvc_core::get_instance()->dispatcher->generate_url('index', array(), $this->request);
     array_walk($this->data['items'], function ($item) use($feed) {
         $feeditem = $feed->add('item');
         $feeditem->title = $item->title;
         $feeditem->description = $item->content;
         $feeditem->published = $item->published->format(DateTime::RSS);
         $author = $feeditem->add('author');
         $author->name = $item->firstname;
         $link = $feeditem->add('link');
         $link->href = $item->url;
     });
     $this->data['feed'] = $feed;
 }
开发者ID:nemein,项目名称:com_meego_planet,代码行数:25,代码来源:latest.php

示例8: extend_provider

 /**
  * Adds some handy properties to provider object
  *
  * @param object com_meego_devprogram_provider object
  * @return object extended com_meego_devprogram_provider object
  */
 private function extend_provider($object = null)
 {
     // q->toggle_readonly(false) does not work so we need a new object
     $provider = new com_meego_devprogram_provider($object->guid);
     $provider->read_url = com_meego_devprogram_utils::get_url('provider_read', array('provider_name' => $provider->name));
     $provider->update_url = com_meego_devprogram_utils::get_url('provider_update', array('provider_name' => $provider->name));
     $provider->delete_url = com_meego_devprogram_utils::get_url('provider_delete', array('provider_name' => $provider->name));
     $provider->join_url = com_meego_devprogram_utils::get_url('my_membership_create', array('provider_name' => $provider->name));
     // if current user is owner then we can add more goodies
     $user = com_meego_devprogram_utils::get_current_user();
     $provider->number_of_members = false;
     $mvc = midgardmvc_core::get_instance();
     // set the can join flag to true by default
     $provider->can_join = true;
     // set management fflag to false by default
     $provider->can_manage = false;
     // can current user manage the provider
     if (com_meego_devprogram_utils::is_current_user_creator_or_admin($object) || com_meego_devprogram_membutils::is_current_user_member_of_provider($object->id)) {
         $provider->can_manage = true;
         $provider->can_join = false;
         // set the url for the membership list page
         $provider->list_memberships_url = com_meego_devprogram_utils::get_url('provider_members', array('provider_name' => $provider->name));
         // set the approved number of members (all but the cancelled ones) of this provider
         $provider->number_of_members = count(com_meego_devprogram_membutils::get_memberships_by_provider($provider->id));
         // set the number of pending membership requests
         $provider->number_of_members = count(com_meego_devprogram_membutils::get_memberships_by_provider($provider->id));
     }
     // can the provider be deleted; ie. check if provider has devices that belong to open programs
     $provider->can_not_delete = com_meego_devprogram_provutils::has_provider_devices($object->id);
     return $provider;
 }
开发者ID:nemein,项目名称:com_meego_devprogram,代码行数:37,代码来源:provutils.php

示例9: __construct

 public function __construct(array $local_configuration = null)
 {
     if (!is_null($local_configuration)) {
         $this->local_configuration = $local_configuration;
     }
     $this->mvc = midgardmvc_core::get_instance();
 }
开发者ID:bergie,项目名称:midgardmvc_core,代码行数:7,代码来源:chain.php

示例10: handle_exception

 public function handle_exception(Exception $exception)
 {
     if (!(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) && isset($_SERVER['HTTP_AUTHORIZATION'])) {
         $auth_params = explode(":", base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
         $_SERVER['PHP_AUTH_USER'] = $auth_params[0];
         unset($auth_params[0]);
         $_SERVER['PHP_AUTH_PW'] = implode('', $auth_params);
     }
     if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
         $app = midgardmvc_core::get_instance();
         $app->dispatcher->header("WWW-Authenticate: Basic realm=\"MidgardMVC\"");
         $app->dispatcher->header('HTTP/1.0 401 Unauthorized');
         // TODO: more fancy 401 output ?
         echo "<h1>Authorization required</h1>\n";
         // Clean up the context
         $app->context->delete();
         $app->dispatcher->end_request();
     }
     $tokens = array('login' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']);
     if (!$this->login($tokens)) {
         // Wrong password: Recurse until auth ok or user gives up
         unset($_SERVER['HTTP_AUTHORIZATION'], $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
         $this->handle_exception($exception);
     }
 }
开发者ID:bergie,项目名称:midgardmvc_core,代码行数:25,代码来源:basic.php

示例11: start

 private function start()
 {
     if (self::$started) {
         return;
     }
     self::$started = true;
     $this->dispatcher = midgardmvc_core::get_instance()->dispatcher;
     try {
         if (!$this->dispatcher->headers_sent()) {
             $this->dispatcher->session_start();
         }
     } catch (Exception $e) {
         midgardmvc_core::get_instance()->log(__CLASS__, "Couldn't start session: " . $e->getMessage(), 'warning');
         $this->enabled = false;
         return;
     }
     /* Cache disabling made conditional based on domain/key existence */
     // Check for session data and load or initialize it, if necessary
     if ($this->dispatcher->session_has_var(self::ROOT)) {
         $this->data = $this->dispatcher->session_get_var(self::ROOT);
     } else {
         $this->data['midgardmvc_core_services_sessioning'] = array();
         $this->data['midgardmvc_core_services_sessioning']['startup'] = array();
         $this->dispatcher->session_set_var(self::ROOT, $this->data);
     }
 }
开发者ID:bergie,项目名称:midgardmvc_core,代码行数:26,代码来源:midgard.php

示例12: action_messages

 public function action_messages($route_id, &$data, $args)
 {
     if (!midgardmvc_core::get_instance()->uimessages->supports('comet') || !midgardmvc_core::get_instance()->uimessages->can_view()) {
         return;
     }
     $type = null;
     $name = null;
     if (isset(midgardmvc_core::get_instance()->dispatcher->get["cometType"])) {
         $type = midgardmvc_core::get_instance()->dispatcher->get["cometType"];
     }
     if (isset(midgardmvc_core::get_instance()->dispatcher->get["cometName"])) {
         $name = midgardmvc_core::get_instance()->dispatcher->get["cometName"];
     }
     if ($type == null && $name == null) {
         throw new midgardmvc_exception_notfound("No comet name or type defined");
     }
     if (ob_get_level() == 0) {
         ob_start();
     }
     while (true) {
         $messages = '';
         if (midgardmvc_core::get_instance()->uimessages->has_messages()) {
             $messages = midgardmvc_core::get_instance()->uimessages->render_as('comet');
         } else {
             midgardmvc_core::get_instance()->uimessages->add(array('title' => 'Otsikko from comet', 'message' => 'viesti from comet...'));
         }
         midgardmvc_core_helpers_comet::pushdata($messages, $type, $name);
         ob_flush();
         flush();
         sleep(5);
     }
     // $data['messages'] = $messages;
 }
开发者ID:piotras,项目名称:midgardmvc_core,代码行数:33,代码来源:comet.php

示例13: get_avatar

 public function get_avatar(array $args)
 {
     $storage = new midgard_query_storage('midgard_user');
     $q = new midgard_query_select($storage);
     $cnstr1 = new midgard_query_constraint(new midgard_query_property('username', $storage), 'LIKE', new midgard_query_value('%' . $args['username'] . '%'));
     $q->execute();
     $cnt = $q->get_results_count();
     if ($cnt > 0) {
         $user = $q->list_objects();
         if ($user[0]) {
             $attachments = $user[0]->list_attachments();
             //Check if attachement exists
             if (count($attachments) == 0) {
                 //fetch avatar from meego.com
                 $employeenumber = $user[0]->get_person()->get_parameter('midgardmvc_core_services_authentication_ldap', 'employeenumber');
                 $attachment = $user[0]->create_attachment('meego:avatar', 'meego:avatar', 'image/png');
                 midgardmvc_helper_attachmentserver::copy_file_to_attachment('http://meego.com/sites/all/files/imagecache/user_pics/user_pics/picture-' . $employeenumber . '.png', $attachment);
                 $attachments[0] = $attachment;
             }
             if (count($attachments) > 0) {
                 //serve attachment
                 $this->serve_attachement($attachments[0]);
                 return;
             }
         }
     }
     //redirect to default avatar
     midgardmvc_core::get_instance()->head->relocate('http://meego.com/sites/all/themes/meego/images/peep_skate.png');
 }
开发者ID:nemein,项目名称:com_meego_website,代码行数:29,代码来源:avatar.php

示例14: post_start_package_instance

 /**
  *
  */
 public function post_start_package_instance(array $args)
 {
     $this->mvc->log(__CLASS__, 'Posted start QA', 'info');
     $this->package = self::load_package_instance($args);
     if (!$this->package->metadata->hidden) {
         $workflow_class = self::load_workflow($args);
         $this->mvc->component->load_library('Workflow');
         $workflow = new $workflow_class();
         $values = $workflow->start($this->package);
         if (isset($values['execution'])) {
             // Workflow suspended and needs input, redirect to workflow page
             $formurl = $this->mvc->dispatcher->generate_url('package_instance_workflow_resume', array('package' => $this->package->name, 'version' => $this->package->version, 'project' => $args['project'], 'repository' => $args['repository'], 'arch' => $args['arch'], 'workflow' => $args['workflow'], 'execution' => $values['execution']), $this->request);
             $this->mvc->head->relocate($formurl);
         }
     }
     // Workflow completed, redirect to package instance
     if ($this->request->isset_data_item('redirect_link')) {
         $redirect_link = $this->request->get_data_item('redirect_link');
     } elseif (isset($_POST['redirect_link'])) {
         $redirect_link = $_POST['redirect_link'];
     } else {
         $redirect_link = midgardmvc_core::get_instance()->dispatcher->generate_url('package_instance', array('package' => $this->package->name, 'version' => $this->package->version, 'project' => $args['project'], 'repository' => $args['repository'], 'arch' => $args['arch']), $this->request);
     }
     $this->mvc->log(__CLASS__, 'Posted start QA finished', 'info');
     // Workflow completed, redirect to package instance
     midgardmvc_core::get_instance()->head->relocate($redirect_link);
 }
开发者ID:nemein,项目名称:com_meego_packages,代码行数:30,代码来源:workflow.php

示例15: inject_template

 /**
  * Add our own stuff to the templates
  */
 public function inject_template(midgardmvc_core_request $request)
 {
     // Replace the default MeeGo sidebar with our own
     $route = $request->get_route();
     $route->template_aliases['content-sidebar'] = 'cmp-show-sidebar';
     $route->template_aliases['main-menu'] = 'cmp-show-main_menu';
     midgardmvc_core::get_instance()->head->add_link(array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => MIDGARDMVC_STATIC_URL . '/com_meego_planet/planet.css'));
 }
开发者ID:nemein,项目名称:com_meego_planet,代码行数:11,代码来源:injector.php


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