當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Frontend::instance方法代碼示例

本文整理匯總了PHP中Frontend::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Frontend::instance方法的具體用法?PHP Frontend::instance怎麽用?PHP Frontend::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Frontend的用法示例。


在下文中一共展示了Frontend::instance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: lookup

 public static function lookup($ip)
 {
     $ch = curl_init();
     // Notice: the request back to the Symphony services API includes your domain name
     // and the version of Symphony that you're using
     $version = Frontend::instance()->Configuration->get('version', 'symphony');
     $domain = $_SERVER[SERVER_NAME];
     curl_setopt($ch, CURLOPT_URL, "http://symphony-cms.net/_netspeed/1.0/?symphony=" . $version . "&domain=" . $domain . "&ip=" . $ip);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $speedinfo = curl_exec($ch);
     $info = curl_getinfo($ch);
     curl_close($ch);
     if ($speedinfo === false || $info['http_code'] != 200) {
         return;
     } else {
         $speedinfo = explode(',', $speedinfo);
     }
     $result = new XMLElement("netspeed");
     $included = array('id', 'connection', 'error');
     $i = 0;
     foreach ($included as $netspeed) {
         $result->appendChild(new XMLElement($netspeed, $speedinfo[$i]));
         $i++;
     }
     return $result;
 }
開發者ID:josephdenne,項目名稱:netspeed-service,代碼行數:27,代碼來源:class.netspeed_service.php

示例2: driver

 public static function driver()
 {
     if (class_exists('Administration')) {
         return Administration::instance()->Configuration;
     }
     return Frontend::instance()->Configuration;
 }
開發者ID:bauhouse,項目名稱:library,代碼行數:7,代碼來源:class.configurationaccessor.php

示例3: start

 public static function start($lifetime = 0, $path = '/', $domain = NULL)
 {
     if (!self::$_initialized) {
         ## Crude method of determining if we're in the admin or frontend
         if (class_exists('Frontend')) {
             self::$_db =& Frontend::instance()->Database;
         } elseif (class_exists('Administration')) {
             self::$_db =& Administration::instance()->Database;
         } else {
             return false;
         }
         if (!is_object(self::$_db) || !self::$_db->isConnected()) {
             return false;
         }
         self::$_cache = new Cacheable(self::$_db);
         $installed = self::$_cache->check('_session_config');
         if (!$installed) {
             if (!self::createTable()) {
                 return false;
             }
             self::$_cache->write('_session_config', true);
         }
         ini_set('session.save_handler', 'user');
         session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc'));
         session_set_cookie_params($lifetime, $path, $domain ? $domain : self::getDomain(), false, false);
         self::$_initialized = true;
         if (session_id() == '') {
             session_start();
         }
     }
     return session_id();
 }
開發者ID:bauhouse,項目名稱:sym-fluid960gs,代碼行數:32,代碼來源:class.session.php

示例4: Context

 public function Context()
 {
     if (class_exists('Frontend')) {
         return (object) Frontend::instance();
     }
     return (object) Administration::instance();
 }
開發者ID:klaftertief,項目名稱:entry_versions,代碼行數:7,代碼來源:class.entryversionsmanager.php

示例5: Database

 public static function Database()
 {
     if (class_exists('Frontend')) {
         return Frontend::instance()->Database;
     }
     return Administration::instance()->Database;
 }
開發者ID:bauhouse,項目名稱:sym-spectrum,代碼行數:7,代碼來源:class.symphony.php

示例6: __dbConnectionResource

 private static function __dbConnectionResource()
 {
     if (class_exists('Frontend')) {
         return Frontend::instance()->Database->getConnectionResource();
     }
     return Administration::instance()->Database->getConnectionResource();
 }
開發者ID:bauhouse,項目名稱:sym-spectrum-members,代碼行數:7,代碼來源:class.asdc.php

示例7: renderer

function renderer($mode = 'frontend')
{
    if (!in_array($mode, array('frontend', 'administration'))) {
        throw new Exception('Invalid Symphony Renderer mode specified. Must be either "frontend" or "administration".');
    }
    require_once CORE . "/class.{$mode}.php";
    return $mode == 'administration' ? Administration::instance() : Frontend::instance();
}
開發者ID:nils-werner,項目名稱:symphony-2,代碼行數:8,代碼來源:index.php

示例8: renderer_json

function renderer_json($mode)
{
    if (strtolower($mode) == 'administration') {
        throw new Lib\Exceptions\InvalidModeException('JSON Renderer launcher is only available on the frontend');
    }
    $renderer = Frontend::instance();
    // Check if we should enable exception debug information
    $exceptionDebugEnabled = Symphony::isLoggedIn();
    // Use the JSON exception and error handlers instead of the Symphony one.
    Lib\ExceptionHandler::initialise($exceptionDebugEnabled);
    Lib\ErrorHandler::initialise($exceptionDebugEnabled);
    // #1808
    if (isset($_SERVER['HTTP_MOD_REWRITE'])) {
        throw new Exception("mod_rewrite is required, however is not enabled.");
    }
    $output = $renderer->display(getCurrentPage());
    cleanup_session_cookies();
    if (in_array('JSON', Frontend::Page()->pageData()['type'])) {
        // Load the output into a SimpleXML Container and convert to JSON
        try {
            $xml = new SimpleXMLElement($output, LIBXML_NOCDATA);
            // Convert the XML to a plain array. This step is necessary as we cannot
            // use JSON_PRETTY_PRINT directly on a SimpleXMLElement object
            $outputArray = json_decode(json_encode($xml), true);
            // Get the transforer object ready. Other extensions will
            // add their transormations to this.
            $transformer = new Lib\Transformer();
            /**
             * Allow other extensions to add their own transformers
             */
            Symphony::ExtensionManager()->notifyMembers('APIFrameworkJSONRendererAppendTransformations', '/frontend/', ['transformer' => &$transformer]);
            // Apply transformations
            $outputArray = $transformer->run($outputArray);
            // Now put the array through a json_encode
            $output = json_encode($outputArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        } catch (\Exception $e) {
            // This happened because the input was not valid XML. This could
            // occur for a few reasons, but there are two scenarios
            // we are interested in.
            // 1) This is a devkit page (profile, debug etc). We want the data
            //    to be passed through and displayed rather than converted into
            //    JSON. There is no easy way in Symphony to tell if a devkit has
            //    control over the page, so instead lets inspect the output for
            //    any signs a devkit is rendering the page.
            // 2) It is actually bad XML. In that case we need to let the error
            //    bubble through.
            // Currently the easiest method is to check for the devkit.min.css
            // in the output. This may fail in the furture if this file is
            // renamed or moved.
            if (!preg_match("@\\/symphony\\/assets\\/css\\/devkit.min.css@", $output)) {
                throw $e;
            }
        }
    }
    echo $output;
    return $renderer;
}
開發者ID:pointybeard,項目名稱:api_framework,代碼行數:57,代碼來源:JsonRendererLauncher.php

示例9: __construct

 public function __construct($message)
 {
     parent::__construct($message);
     $this->error = NULL;
     $bFoundFile = false;
     if (XSLProc::getErrors() instanceof MessageStack) {
         foreach (XSLProc::getErrors() as $e) {
             if ($e->type == XSLProc::ERROR_XML) {
                 $this->error = $errors[0];
                 $this->file = XSLProc::lastXML();
                 $this->line = $this->error->line;
                 $bFoundFile = true;
                 break;
             } elseif (strlen(trim($e->file)) == 0) {
                 continue;
             }
             $this->error = $errors[0];
             $this->file = $this->error->file;
             $this->line = $this->error->line;
             $bFoundFile = true;
             break;
         }
         if (is_null($this->error)) {
             foreach (XSLProc::getErrors() as $e) {
                 if (preg_match_all('/(\\/?[^\\/\\s]+\\/.+.xsl) line (\\d+)/i', $e->message, $matches, PREG_SET_ORDER)) {
                     $this->file = $matches[0][1];
                     $this->line = $matches[0][2];
                     $bFoundFile = true;
                     break;
                 } elseif (preg_match_all('/([^:]+): (.+) line (\\d+)/i', $e->message, $matches, PREG_SET_ORDER)) {
                     //throw new Exception("Fix XSLPROC Frontend doesn't have access to Page");
                     $this->line = $matches[0][3];
                     $this->file = VIEWS . '/' . Frontend::instance()->loadedView()->templatePathname();
                     $bFoundFile = true;
                 }
             }
         }
     }
     /*
     			// FIXME: This happens when there is an error in the page XSL. Since it is loaded in to a string then passed to the processor it does not return a file
     			if(!$bFoundFile){
     				$page = Symphony::parent()->Page()->pageData();
     				$this->file = VIEWS . '/' . $page['filelocation'];
     				$this->line = 0;
     
     				// Need to look for a potential line number, since
     				// it will not have been grabbed
     				foreach($errors as $e){
     					if($e->line > 0){
     						$this->line = $e->line;
     						break;
     					}
     				}
     			}
     */
 }
開發者ID:brendo,項目名稱:symphony-3,代碼行數:56,代碼來源:class.xslproc.php

示例10: getSectionId

 public function getSectionId()
 {
     $sectionManager = new SectionManager(Frontend::instance());
     $section_id = $sectionManager->fetchIDFromHandle(General::sanitize($_REQUEST['MUUsource']));
     if (!($section = $sectionManager->fetch($section_id))) {
         return NULL;
     } else {
         return $section_id;
     }
 }
開發者ID:scottkf,項目名稱:massuploadutility,代碼行數:10,代碼來源:content.index.php

示例11: __construct

 function __construct($args)
 {
     require_once 'lib/class.cachelite.php';
     require_once CORE . '/class.frontend.php';
     $this->_Parent =& $args['parent'];
     $this->_frontend = Frontend::instance();
     $this->_lifetime = $this->_get_lifetime();
     $this->_cacheLite = new Cache_Lite(array('cacheDir' => CACHE . '/', 'lifeTime' => $this->_lifetime));
     $this->_url = $_SERVER['REQUEST_URI'];
 }
開發者ID:nickdunn,項目名稱:cachelite,代碼行數:10,代碼來源:extension.driver.php

示例12: __construct

 public function __construct()
 {
     if (class_exists('Frontend')) {
         self::$_context = Frontend::instance();
     } else {
         self::$_context = Administration::instance();
     }
     self::$_entryManager = new EntryManager(self::$_context);
     self::$_sectionManager = self::$_entryManager->sectionManager;
     self::$_fieldManager = self::$_entryManager->fieldManager;
 }
開發者ID:psychoticmeowArchives,項目名稱:symql,代碼行數:11,代碼來源:class.symql.php

示例13: __construct

 /**
  * Construct a new instance of an Entry.
  *
  * @param mixed $parent
  *	The class that created this Entry object, usually the EntryManager,
  *	passed by reference.
  */
 public function __construct(&$parent)
 {
     $this->_Parent =& $parent;
     if (class_exists('Administration')) {
         $this->_engine = Administration::instance();
     } elseif (class_exists('Frontend')) {
         $this->_engine = Frontend::instance();
     } else {
         throw new Exception(__('No suitable engine object found'));
     }
 }
開發者ID:scottkf,項目名稱:keepflippin--on-symphony,代碼行數:18,代碼來源:class.entry.php

示例14: assert

 /**
  * Set up static members
  */
 private function assert()
 {
     $mode = isset($_GET['mode']) && strtolower($_GET['mode']) == 'administration' ? 'administration' : 'frontend';
     self::$_context = $mode == 'administration' ? Administration::instance() : Frontend::instance();
     if (self::$_entry_manager == NULL) {
         self::$_entry_manager = new EntryManager(self::$_context);
     }
     if (self::$_entry_xml_datasource == NULL) {
         self::$_entry_xml_datasource = new EntryXMLDataSource(self::$_context, NULL, FALSE);
     }
 }
開發者ID:TwistedInteractive,項目名稱:search_index,代碼行數:14,代碼來源:class.search_index.php

示例15: grab

 public function grab(&$param_pool)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     $driver = Frontend::instance()->ExtensionManager->create('iplocation_lookup');
     $location = extension_IPLocation_Lookup::lookup();
     if (is_null($location)) {
         $result->appendChild(new XMLElement('error', 'unknown location'));
     } else {
         $result->setValue($location);
     }
     return $result;
 }
開發者ID:pointybeard,項目名稱:iplocation_lookup,代碼行數:12,代碼來源:data.iplocationlookup.php


注:本文中的Frontend::instance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。