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


PHP Site::getInstance方法代码示例

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


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

示例1: getVariables

 private static function getVariables()
 {
     ObjectCache::getInstance();
     $site = Site::getInstance();
     define('GUEST_ROLE_ID', (int) $site->getGuestRoleID()->getValue());
     define('SITE_EMAIL', $site->getEmail());
     define('SITE_TITLE', $site->getTitle());
     date_default_timezone_set($site->getTimeZone());
     if ($site->isInMaintenanceMode()) {
         if (!PermissionEngine::getInstance()->currentUserCanDo('bypasssMaintenanceMode')) {
             return;
         }
     }
     $blockEngine = BlockEngine::getInstance();
     $user = CurrentUser::getUserSession();
     $hookEngine = HookEngine::getInstance();
     $router = Router::getInstance();
     $hookEngine->runAction('addStaticRoutes');
     $moduleInCharge = $router->whichModuleHandlesRequest();
     $response = self::getResponse($moduleInCharge);
     http_response_code($response->getResponseCode());
     $headers = $response->getHeaders();
     foreach ($headers as $header => $value) {
         header($header . ": " . $value, true);
     }
     define('PAGE_TYPE', $response->getPageType());
     $blocks = $blockEngine->getBlocks($site->getTheme(), PAGE_TYPE, $user->getRoleID());
     if ($blocks === null) {
         $blocks = array();
     }
     self::render($site, $response, $blocks);
 }
开发者ID:educask,项目名称:EducaskCore,代码行数:32,代码来源:Bootstrap.php

示例2: run

 public function run()
 {
     if (!isset($this->cronToken)) {
         return;
     }
     if ($this->cronToken === "") {
         return;
     }
     if ($this->cronToken !== Config::getInstance()->getCronToken()) {
         return;
     }
     $database = Database::getInstance();
     if (!$database->isConnected()) {
         return;
     }
     $site = Site::getInstance();
     if (!$site->doesCronNeedToRun()) {
         return;
     }
     if ($site->isCronRunning()) {
         return;
     }
     $site->setCronRunning(true);
     $site->setLastCronRun(new DateTime());
     $hookEngine = HookEngine::getInstance();
     $hookEngine->runAction('cronRun');
     $logger = Logger::getInstance();
     $logger->logIt(new LogEntry(1, logEntryType::info, "Cron ran.", 0, new DateTime()));
     $site->setCronRunning(false);
 }
开发者ID:educask,项目名称:EducaskCore,代码行数:30,代码来源:cron.php

示例3: path2url

 /**
  * Converts a filesystem path to a URL if possible.
  *
  * @param string $path
  */
 public static function path2url($path)
 {
     // see if the root path exists in $path
     if (strpos($path, Site::getInstance()->getRoot()) === FALSE) {
         return null;
     }
     $img = str_replace(Site::getInstance()->getRoot(), self::getBase(), $path);
     return str_replace("pub/", '', $img);
 }
开发者ID:jmdeldin,项目名称:missoulaadoptables,代码行数:14,代码来源:Url.php

示例4: approveAction

 function approveAction()
 {
     $user = $this->getRequest()->getParam('user');
     $cashout = Cashout_Models_Cashout::getUsersLastPendingCashout($user);
     if ($cashout != null) {
         $cashout->completionDate = date('Y-m-d');
         $cashout->approve();
         $user = User_Models_User::getUser($user);
         $pay[$user->paymentEmail] = $cashout->amount;
         //now send the payment to the user
         $paymentGateway = Site::getInstance(Site::getResource('payment_gateway'));
         $paymentGateway->pay($pay);
     }
     $this->getResponse()->setRedirect('/cashout/admin/requests');
 }
开发者ID:kakarot1991,项目名称:paid-to-click-cms,代码行数:15,代码来源:AdminController.php

示例5: __construct

 public function __construct($id, $entryDate, $dateRecorded, $name, $description, $breed, $sex, $fixed, $age, $color, $commonName, $shelter)
 {
     $this->id = $id;
     $this->entryDate = $entryDate;
     $this->dateRecorded = $dateRecorded;
     $this->name = $name;
     $this->description = $description;
     $this->breed = $breed;
     $this->sex = $sex;
     $this->fixed = $fixed;
     $this->age = $age;
     $this->color = $color;
     $this->commonName = $commonName;
     $this->shelter = $shelter;
     $this->image = Site::getInstance()->getUploadPath() . "/{$this->id}.jpg";
 }
开发者ID:jmdeldin,项目名称:missoulaadoptables,代码行数:16,代码来源:Animal.php

示例6: scrape

 /**
  * Run the scrapers.
  */
 public function scrape()
 {
     // TODO: This should be read from the ``shelter_pages'' table
     $mhsDog = new MhsDogScraper("http://montanapets.org/mhs/residentdog.html");
     $mhsCat = new MhsCatScraper("http://montanapets.org/mhs/residentcat.html");
     $packer = new Packer();
     $packer->pack($mhsDog->scrape());
     $packer->pack($mhsCat->scrape());
     $loader = new Loader($packer->getPackedPets());
     $loader->checkActive();
     $loader->load();
     // temporary fix for the slashes in some breeds
     // @todo: this should be done in the scraper
     $db = new Database(Site::getInstance()->getDbConf());
     $db->execute("update animals set breed = replace(breed, '/', '-')");
 }
开发者ID:jmdeldin,项目名称:missoulaadoptables,代码行数:19,代码来源:CronController.php

示例7: start

 public static function start()
 {
     $sessionProvider = Config::getInstance()->getSessionProvider();
     $sessionProvider = str_replace(".", "", $sessionProvider);
     $sessionProviderFile = EDUCASK_ROOT . '/core/providers/sessions/' . $sessionProvider . '.php';
     if (!is_readable($sessionProviderFile)) {
         return;
     }
     require_once $sessionProviderFile;
     if (!class_exists($sessionProvider)) {
         return;
     }
     $implementations = class_implements($sessionProvider);
     if (!in_array('ISession', $implementations)) {
         return;
     }
     if (!in_array('SessionHandlerInterface', $implementations)) {
         return;
     }
     session_set_save_handler(new $sessionProvider());
     session_name("educask");
     session_start();
     if (!isset($_SESSION['lastSessionGenerationTime'])) {
         $_SESSION['lastSessionGenerationTime'] = time();
         return;
     }
     $maxSessionAgeAgo = (int) Site::getInstance()->getMaxSessionIdAge()->getValue();
     $maxSessionIdAge = time() - $maxSessionAgeAgo;
     if ($_SESSION['lastSessionGenerationTime'] > $maxSessionIdAge) {
         return;
     }
     $randomPerformSessionIdRegeneration = rand(0, 1000) % 6 === 0;
     if (!$randomPerformSessionIdRegeneration) {
         return;
     }
     session_regenerate_id(true);
     $_SESSION['lastSessionGenerationTime'] = time();
 }
开发者ID:educask,项目名称:EducaskCore,代码行数:38,代码来源:Session.php

示例8: buildMinifiedCSS

 private function buildMinifiedCSS()
 {
     $siteObject = Site::getInstance();
     $minifiedSoFar = "";
     $themesCssFiles = glob(EDUCASK_ROOT . "/site/themes/{$siteObject->getTheme()}/css/*.css");
     foreach ($themesCssFiles as $cssFile) {
         if (!is_readable($cssFile)) {
             continue;
         }
         $rawFile = file_get_contents($cssFile);
         $rawFile = $this->minifyCssString($rawFile);
         $minifiedSoFar .= $rawFile;
     }
     $minifiedSoFar .= $this->getOtherCssFiles();
     $minifiedSoFar .= $this->getRawCss();
     $objectCache = ObjectCache::getInstance();
     $objectCache->setObject('minifiedCSS', $minifiedSoFar, true);
     $response = Response::fiveHundred();
     $response->setRawContent($minifiedSoFar);
     $response->setHeader('Content-Type', "text/css");
     $response->setResponseCode(200);
     return $response;
 }
开发者ID:educask,项目名称:EducaskCore,代码行数:23,代码来源:css.php

示例9: indexAction

 function indexAction()
 {
     $session = new Zend_Session_Namespace('user');
     $form = new Fund_Models_Forms_Fund();
     $minimum = Site::getResource('fund_minimum');
     $maximum = Site::getResource('fund_maximum');
     if ($this->getRequest()->isPost() && $form->isValid($_POST)) {
         $fund = Fund_Models_FundAccount::getUsersLastFundAccount('pending');
         if ($fund == NULL) {
             $args = array('ownerID' => $session->user->accountID, 'startDate' => date('Y-m-d'), 'status' => 'pending', 'amount' => $form->getValue('amount'));
             $fund = new Fund_Models_FundAccount($args);
         }
         $fund->amount = $form->getValue('amount');
         $fund->save();
         $session->user->lastFundTransaction = $fund;
         //display pay button
         $paymentGateway = Site::getInstance(Site::getResource('payment_gateway'));
         $paymentGateway->returnUrl = 'http://www.project.supersaid.net/fund/complete';
         $paymentGateway->cancelUrl = 'http://www.project.supersaid.net/fund/cancel';
         $this->view->form = $paymentGateway->getForm($fund);
     } else {
         $this->view->form = $form;
     }
 }
开发者ID:kakarot1991,项目名称:paid-to-click-cms,代码行数:24,代码来源:IndexController.php

示例10: view

 public function view($params = NULL)
 {
     // valid categories to search
     $categories = array("common_name_id" => "Common Name", "breed" => "Breed", "sex" => "Sex", "shelter_id" => "Shelter");
     $v = new View("animal_index");
     $v->title = "Browse";
     $v->showBrowser = true;
     $animalModel = new AnimalModel();
     // common name browser
     $commonModel = new CommonNameModel();
     $v->commonNames = $commonModel->getAll();
     // breed browser
     $breedModel = new BreedModel();
     $v->breeds = $breedModel->getAll();
     // shelter browser
     $shelterModel = new ShelterModel();
     $v->shelters = $shelterModel->getAll();
     $v->animals = array();
     // default page
     if (!$params) {
         $v->animals = $animalModel->getLatestAnimals(Site::getInstance()->getNumAnimals());
         return $v->render();
     }
     // check params
     if (!isset($categories[$params[0]])) {
         $e = new NotFoundError("Invalid criteria");
         return $e->serve();
     }
     // sanitize the params
     for ($i = 0; $i < count($params); $i++) {
         $params[$i] = filter_var($params[$i], FILTER_SANITIZE_STRING);
     }
     $v->title = "Browsing by {$categories[$params[0]]}";
     $v->animals = $animalModel->getByCategory($params[0], $params[1]);
     $v->render();
 }
开发者ID:jmdeldin,项目名称:missoulaadoptables,代码行数:36,代码来源:BrowseController.php

示例11: setFile

 public function setFile($name)
 {
     $this->file = Site::getInstance()->getAppRoot() . "/views/{$name}.php";
 }
开发者ID:jmdeldin,项目名称:missoulaadoptables,代码行数:4,代码来源:View.php

示例12: __construct

 public function __construct()
 {
     $this->db = new Database(Site::getInstance()->getDbConf());
 }
开发者ID:jmdeldin,项目名称:missoulaadoptables,代码行数:4,代码来源:ShelterModel.php

示例13: dirname

<?php

require dirname(dirname(__FILE__)) . "/app/lib/Site.php";
Site::getInstance();
// bootstrap the application
$router = new Router();
$router->delegate();
开发者ID:jmdeldin,项目名称:missoulaadoptables,代码行数:7,代码来源:index.php

示例14:

    <link href="<?php 
echo Url::route2url("animal/feed");
?>
" rel="self" />
    <link href="<?php 
echo Url::getBase();
?>
" />
    <updated><!-- TODO: Last scrape date --></updated>
    <author>
        <name><?php 
echo Site::getInstance()->getName();
?>
</name>
        <email><?php 
echo Site::getInstance()->getEmail();
?>
</email>
    </author>

    <?php 
foreach ($animals as $animal) {
    ?>
        <entry>
            <link href="<?php 
    $url = Url::route2url("animal/view/{$animal->getId()}");
    echo $url;
    ?>
"/>
            <id><?php 
    echo $url;
开发者ID:jmdeldin,项目名称:missoulaadoptables,代码行数:31,代码来源:atom.php

示例15: saveImage

 /**
  * Saves a remote image to the local disk.
  *
  * @param string $impoundNum Impound # for finding the image
  * @param int    $id         Animal ID from the animals table
  */
 private function saveImage($impoundNum, $id)
 {
     $url = "http://montanapets.org/mhs/pictures/{$impoundNum}.jpg";
     $jpg = file_get_contents($url);
     if ($jpg) {
         file_put_contents(Site::getInstance()->getUploadPath() . "/{$id}.jpg", $jpg);
     }
 }
开发者ID:jmdeldin,项目名称:missoulaadoptables,代码行数:14,代码来源:loader.php


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