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


PHP sfLogger::getInstance方法代码示例

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


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

示例1: depp_prioritiser

/**
 * Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
 * If the user has already voted, then a message appears
 * 
 * @param  BaseObject  $object   Propel object instance to vote
 * @param  string      $message  a message string to be displayed in the voting-message block
 * @param  array       $options  Array of HTML options to apply on the HTML list
 * @return string
 **/
function depp_prioritiser($object, $message = '', $options = array())
{
    if (is_null($object)) {
        sfLogger::getInstance()->debug('A NULL object cannot be prioritised');
        return '';
    }
    $user_id = sfContext::getInstance()->getUser()->getId();
    try {
        $options = _parse_attributes($options);
        if (!isset($options['id'])) {
            $options = array_merge($options, array('id' => 'prioritising-items'));
        }
        $object_id = $object->getPrioritisableReferenceKey();
        $list_content = '';
        $object_priority = is_null($object->getPriorityValue()) ? 1 : $object->getPriorityValue();
        for ($i = $object->allowsNullPriority() ? 0 : 1; $i <= $object->getMaxPriority(); $i++) {
            if ($object_priority == $i) {
                if ($object->getPriorityLastUser() != 0) {
                    $label = sprintf('Priorit&agrave; impostata da user_id:%d il %s alle %s', $object->getPriorityLastUser(), $object->getPriorityLastUpdate('d/m/Y'), $object->getPriorityLastUpdate('h:i'));
                } else {
                    $label = 'Priorit&agrave; di default';
                }
                $list_content .= content_tag('li', content_tag('span', $i, array('title' => $label)), array('class' => 'current'));
            } else {
                $label = sprintf(__('Set priority to %d'), $i);
                $list_content .= content_tag('li', link_to($i, sprintf('deppPrioritising/prioritise?object_id=%d&object_model=%s&priority=%d', $object->getId(), get_class($object), $i), array('title' => $label, 'post' => true)));
            }
        }
        return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'priority-message'));
    } catch (Exception $e) {
        sfLogger::getInstance()->err('Exception catched from deppPrioritising helper: ' . $e->getMessage());
    }
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:42,代码来源:deppPrioritisingHelper.php

示例2: highlight

 public static function highlight($raw_body)
 {
     $body = sfMarkdown::doConvert($raw_body);
     $matches = array();
     $langs = array();
     preg_match_all("/<pre><code>\\[(\\w*)\\](\\r?\\n)+(.+)(\\r?\\n)+<\\/code><\\/pre>/isU", $body, $matches, PREG_SET_ORDER);
     if (sizeof($matches) > 0) {
         $service = new SnippetServiceClient();
         $cnt = 1;
         foreach ($matches as $match) {
             sfLogger::getInstance()->info("From myUtils: " . $match[3]);
             $languageLower = $match[1];
             $languageUpper = strtoupper($match[1]);
             sfLogger::getInstance()->info("myUtils languages: {$languageLower} {$languageUpper}" . sizeof(self::$languages));
             if (in_array($languageUpper, self::$languages)) {
                 $highlighted = $service->highlight($languageUpper, htmlspecialchars_decode($match[3]));
                 $highlighted['snippet'] = "<div class=\"code-wrapper\">{$highlighted['snippet']}</div>";
                 $body = str_replace($match[0], $highlighted['snippet'], $body, $cnt);
                 $langs[$languageLower] = $langs[$languageLower] ? $langs[$languageLower] + 1 : 1;
             } else {
                 sfLogger::getInstance()->info("myUtils : {$languageLower} is not supported.");
                 $langs[$languageLower] = $langs[$languageLower] ? $langs[$languageLower] + 1 : 1;
                 $body = str_replace($match[0], "<div class=\"code-wrapper\"><pre><code>{$match[3]}</code></pre></div>", $body, $cnt);
             }
         }
     }
     return array('body' => $body, 'langs' => $langs);
 }
开发者ID:hoydaa,项目名称:snippets.hoydaa.org,代码行数:28,代码来源:myUtils.class.php

示例3: depp_omnibus_selector

/**
 * Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
 * If the user has already voted, then a message appears
 * 
 * @param  BaseObject  $object   Propel object instance to vote
 * @param  string      $message  a message string to be displayed in the voting-message block
 * @param  array       $options  Array of HTML options to apply on the HTML list
 * @return string
 **/
function depp_omnibus_selector($object, $message = '', $options = array())
{
    if (is_null($object)) {
        sfLogger::getInstance()->debug('A NULL object cannot be flagged as Omnibus');
        return '';
    }
    $user_id = sfContext::getInstance()->getUser()->getId();
    try {
        $options = _parse_attributes($options);
        if (!isset($options['id'])) {
            $options = array_merge($options, array('id' => 'omnibus-flag'));
        }
        $object_is_omnibus = $object->getIsOmnibus();
        $object_will_be_omnibus = !$object_is_omnibus;
        $selector = '';
        if ($object_is_omnibus) {
            $status = "Questo atto &egrave; Omnibus";
            $label = "Marcalo come non-Omnibus";
        } else {
            $status = "Questo atto non &egrave; Omnibus";
            $label = "Marcalo come Omnibus";
        }
        $selector .= link_to($label, sprintf('atto/setOmnibusStatus?id=%d&status=%d', $object->getId(), $object_will_be_omnibus), array('post' => true));
        return content_tag('div', $status) . content_tag('div', $selector, $options);
    } catch (Exception $e) {
        sfLogger::getInstance()->err('Exception catched from deppOmnibus helper: ' . $e->getMessage());
    }
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:37,代码来源:deppOmnibusHelper.php

示例4: execute

 public function execute($filterChain)
 {
     $filterChain->execute();
     $response = $this->getContext()->getResponse();
     $request = $this->getContext()->getRequest();
     $controller = $this->getContext()->getController();
     // don't highlight:
     // * for XHR requests
     // * if 304
     // * if not rendering to the client
     // * if HTTP headers only
     if ($request->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $controller->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) {
         return;
     }
     $timer = sfTimerManager::getTimer('Highlight Filter');
     try {
         if (!$this->highlight()) {
             $this->removeNotice();
         }
     } catch (sfSolrHighlighterException $e) {
         sfLogger::getInstance()->err('{sfSolrHighlightFilter} silently ignoring exception: ' . $e->getMessage());
         if ($this->testMode) {
             $timer->addTime();
             throw $e;
         }
     } catch (Exception $e) {
         $timer->addTime();
         throw $e;
     }
     $timer->addTime();
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:31,代码来源:sfSolrHighlightFilter.class.php

示例5: executePrioritise

 /**
  * <p>Vote a propel object, un-ajax style</p>
  * 
  * @see  deppPropelActAsVotableBehavior API
  */
 public function executePrioritise()
 {
     try {
         if ($this->getRequest()->getMethod() !== sfRequest::POST) {
             $this->setError($this->messages['post_only']);
         }
         // Retrieve parameters from request
         $object_id = $this->getRequestParameter('object_id');
         $object_model = $this->getRequestParameter('object_model');
         $priority = $this->getRequestParameter('priority');
         // Retrieve ratable propel object
         if (is_null($priority) || is_null($object_id) || is_null($object_model)) {
             $this->setError($this->messages['missing_params']);
         }
         $object = deppPropelActAsPrioritisableBehaviorToolkit::retrievePrioritisableObject($object_model, $object_id);
         if (is_null($object)) {
             $this->setError($this->message['prioritisable_error']);
         }
         // User retrieval
         $user_id = sfContext::getInstance()->getUser()->getId();
         if (!$object->allowsNullPriority() && $priority == 0) {
             $msg = $this->messages['null_not_allowed'];
             sfLogger::getInstance()->warning($msg);
             $this->setError($msg);
         } else {
             $object->setPriorityValue((int) $priority, $user_id);
             $message = $this->messages['thank_you'];
         }
         $this->setFlash('depp_prioritising_message', $message);
         $this->redirect($this->getRequest()->getReferer());
     } catch (Exception $e) {
         $this->setError($e->getMessage());
     }
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:39,代码来源:actions.class.php

示例6: signIn

 /**
  * uses information in the $xml_user SimpleXML object to give attributes and permissions to the user
  * also sets remember or sso cookie, depending on the value of the $remember parameter
  *
  * @param $xml_user - SimpleXMLObject
  * @param $cookie - boolean
  * @return void
  * @author Guglielmo Celata
  **/
 public function signIn($xml_user, $cookie = 'none')
 {
     // legge i permission dall'xml user
     $permissions = array();
     foreach ($xml_user->permissions->permission as $perm) {
         $permissions[] = $perm;
     }
     $this->setAttribute('subscriber_id', (string) $xml_user->subscriber_id, 'subscriber');
     $this->setAuthenticated(true);
     $expiration_age = sfConfig::get('app_cookies_remember_key_expiration_age', 15 * 24 * 3600);
     $cookie_remember_name = sfConfig::get('app_cookies_remember_name', 'sfRemember');
     $cookie_sso_name = sfConfig::get('app_cookies_sso_name', 'sfSSO');
     $cookie_path = sfConfig::get('app_cookies_path', '/');
     $cookie_domain = sfConfig::get('app_cookies_domain', 'sfDomain.it');
     // if cookie argument was set to 'remember' or 'session' a cookie is set
     // this MUST only happen with signin invoked from validator (form)
     sfContext::getInstance()->getLogger()->info('xxx - signIn - cookie: ' . $cookie);
     if ($cookie == 'remember') {
         //save the key to the remember cookie
         sfContext::getInstance()->getLogger()->info('xxx - setting remember cookie: ' . (string) $xml_user->remember_key);
         sfContext::getInstance()->getResponse()->setCookie($cookie_remember_name, (string) $xml_user->remember_key, time() + $expiration_age, $cookie_path, $cookie_domain);
     } elseif ($cookie == 'session') {
         // save the hash to the sso cookie
         sfContext::getInstance()->getLogger()->info('xxx - setting sso cookie: ' . (string) $xml_user->remember_key);
         sfContext::getInstance()->getResponse()->setCookie($cookie_sso_name, (string) $xml_user->remember_key, 0, $cookie_path, $cookie_domain);
     }
     $this->addCredential('subscriber');
     if (in_array('moderatore', $permissions)) {
         $this->addCredential('moderator');
     }
     if (in_array('amministratore', $permissions)) {
         $this->addCredential('moderator');
         $this->addCredential('administrator');
     }
     // add all credentials from groups and direct permissions
     foreach ($permissions as $perm) {
         $this->addCredential((string) $perm);
     }
     $this->setAttribute('name', (string) $xml_user->name, 'subscriber');
     $this->setAttribute('firstname', (string) $xml_user->firstname, 'subscriber');
     $this->setAttribute('hash', (string) $xml_user->hash, 'subscriber');
     // read the last_login ts from the xml (it comes from the DB)
     $this->setAttribute('last_login', (string) $xml_user->last_login, 'subscriber');
     // store the new last_login ts (now) in the DB
     $remote_guard_host = sfConfig::get('sf_remote_guard_host', 'op_accesso.openpolis.it');
     $script = str_replace('fe', 'be', sfContext::getInstance()->getRequest()->getScriptName());
     if ($script == '/be.php') {
         $script = '/index.php';
     }
     $apikey = sfConfig::get('sf_internal_api_key', 'xxx');
     $last_login_url = sprintf("http://%s%s/setLastLogin/%s/%s/%s", $remote_guard_host, $script, $apikey, (string) $xml_user->hash, urlencode(date('Y-m-d H:i:s')));
     sfLogger::getInstance()->info('xxx: last_login_call: ' . $last_login_url);
     $xml = simplexml_load_file($last_login_url);
     if (!$xml->ok instanceof SimpleXMLElement) {
         sfLogger::getInstance()->info('xxx: error while setting last login: %s' . (string) $xml->error);
     }
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:66,代码来源:sfRemoteGuardSecurityUser.class.php

示例7: getPreference

 public function getPreference($preference)
 {
     if ($item = $this->getAttribute("app_preference_{$preference}")) {
         return $item;
     }
     $item = sfConfig::get("app_preference_{$preference}");
     sfLogger::getInstance()->info("Sending default preference for app_preference_{$preference}={$item}");
     return $item;
 }
开发者ID:hoydaa,项目名称:snippets.hoydaa.org,代码行数:9,代码来源:myUser.class.php

示例8: __construct

 /**
  * Class constructor.
  *
  * @param string The error message
  * @param int    The error code
  */
 public function __construct($message = null, $code = 0)
 {
     if ($this->getName() === null) {
         $this->setName('sfException');
     }
     parent::__construct($message, $code);
     if (sfConfig::get('sf_logging_enabled') && $this->getName() != 'sfStopException') {
         sfLogger::getInstance()->err('{' . $this->getName() . '} ' . $message);
     }
 }
开发者ID:taryono,项目名称:school,代码行数:16,代码来源:sfException.class.php

示例9: getLogger

 private static function getLogger()
 {
     if (!self::$logger) {
         if (class_exists('sfLogger')) {
             self::$logger = sfLogger::getInstance();
         } else {
             self::$logger = KalturaLog::getInstance();
         }
     }
     return self::$logger;
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:11,代码来源:kLog.class.php

示例10: initialize

 /**
  * Initializes the cache.
  *
  * @param array An array of options
  * Available options:
  *  - database:                database name
  *  - automaticCleaningFactor: disable / tune automatic cleaning process (int)
  *
  */
 public function initialize($options = array())
 {
     if (isset($options['database'])) {
         $this->setDatabase($options['database']);
         unset($options['database']);
     }
     $availableOptions = array('automaticCleaningFactor');
     foreach ($options as $key => $value) {
         if (!in_array($key, $availableOptions) && sfConfig::get('sf_logging_enabled')) {
             sfLogger::getInstance()->err(sprintf('sfSQLiteCache cannot take "%s" as an option', $key));
         }
         $this->{$key} = $value;
     }
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:23,代码来源:sfSQLiteCache.class.php

示例11: depp_voter

/**
 * Return the HTML code for an unordered list showing opinions that can be voted
 * If the user has already voted, then a message appears
 * 
 * @param  BaseObject  $object   Propel object instance to vote
 * @param  string      $domid    unique css identifier for the block (div) containing the voter tool
 * @param  string      $message  a message string to be displayed in the voting-message block
 * @param  array       $options  Array of HTML options to apply on the HTML list
 * @return string
 **/
function depp_voter($object, $domid = 'depp-voter-block', $message = '', $options = array())
{
    if (is_null($object)) {
        sfLogger::getInstance()->debug('A NULL object cannot be voted');
        return '';
    }
    $user_id = deppPropelActAsVotableBehaviorToolkit::getUserId();
    // anonymous votes
    if ((is_null($user_id) || $user_id == '') && !$object->allowsAnonymousVoting()) {
        return __('Anonymous voting is not allowed') . ", " . __('please') . " " . link_to('login', '/login');
    }
    try {
        $voting_range = $object->getVotingRange();
        $options = _parse_attributes($options);
        if (!isset($options['id'])) {
            $options = array_merge($options, array('id' => 'voting-items'));
        }
        if ($object instanceof sfOutputEscaperObjectDecorator) {
            $object_class = get_class($object->getRawValue());
        } else {
            $object_class = get_class($object);
        }
        $object_id = $object->getReferenceKey();
        $token = deppPropelActAsVotableBehaviorToolkit::addTokenToSession($object_class, $object_id);
        // already voted
        if ($object->hasBeenVotedByUser($user_id)) {
            $message .= "&nbsp;" . link_to_remote(__('Take your vote back'), array('url' => sprintf('deppVoting/unvote?domid=%s&token=%s', $domid, $token), 'update' => $domid, 'script' => true, 'complete' => visual_effect('appear', $domid) . visual_effect('highlight', $domid)));
        }
        $list_content = '';
        for ($i = -1 * $voting_range; $i <= $voting_range; $i++) {
            if ($i == 0 && !$object->allowsNeutralPosition()) {
                continue;
            }
            $text = sprintf("[%d]", $i);
            $label = sprintf(__('Vote %d!'), $i);
            if ($object->hasBeenVotedByUser($user_id) && $object->getUserVoting($user_id) == $i) {
                $list_content .= content_tag('li', $text);
            } else {
                $list_content .= '  <li>' . link_to_remote($text, array('url' => sprintf('deppVoting/vote?domid=%s&token=%s&voting=%d', $domid, $token, $i), 'update' => $domid, 'script' => true, 'complete' => visual_effect('appear', $domid) . visual_effect('highlight', $domid)), array('title' => $label)) . '</li>';
            }
        }
        $results = get_component('deppVoting', 'votingDetails', array('object' => $object));
        return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'voting-message')) . content_tag('div', $results, array('id' => 'voting-results'));
    } catch (Exception $e) {
        sfLogger::getInstance()->err('Exception catched from sf_rater helper: ' . $e->getMessage());
    }
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:57,代码来源:deppVotingHelper.php

示例12: initialize

 protected function initialize()
 {
     $this->logger = sfLogger::getInstance();
     if (sfConfig::get('sf_logging_enabled')) {
         $this->logger->info('{sfContext} initialization');
     }
     if (sfConfig::get('sf_use_database')) {
         // setup our database connections
         $this->databaseManager = new sfDatabaseManager();
         $this->databaseManager->initialize();
     }
     // create a new action stack
     $this->actionStack = new sfActionStack();
     // include the factories configuration
     require sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name') . '/factories.yml');
     // register our shutdown function
     register_shutdown_function(array($this, 'shutdown'));
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:18,代码来源:sfContext.class.php

示例13: sf_rater

/**
 * Return the HTML code for a unordered list showing rating stars
 * 
 * @param  BaseObject  $object  Propel object instance
 * @param  array       $options        Array of HTML options to apply on the HTML list
 * @throws sfPropelActAsRatableException
 * @return string
 **/
function sf_rater($object, $options = array())
{
    if (is_null($object)) {
        sfLogger::getInstance()->debug('A NULL object cannot be rated');
    }
    if (!isset($options['star-width'])) {
        $star_width = sfConfig::get('app_rating_star_width', 25);
    } else {
        $star_width = $options['star-width'];
        unset($options['star-width']);
    }
    try {
        $max_rating = $object->getMaxRating();
        $actual_rating = $object->getRating();
        $bar_width = $actual_rating * $star_width;
        $options = _parse_attributes($options);
        if (!isset($options['class'])) {
            $options = array_merge($options, array('class' => 'star-rating'));
        }
        if (!isset($options['style']) or !preg_match('/width:/i', $options['style'])) {
            $full_bar_width = $max_rating * $star_width;
            $options = array_merge($options, array('style' => 'width:' . $full_bar_width . 'px'));
        }
        if ($object instanceof sfOutputEscaperObjectDecorator) {
            $object_class = get_class($object->getRawValue());
        } else {
            $object_class = get_class($object);
        }
        $object_id = $object->getReferenceKey();
        $token = sfPropelActAsRatableBehaviorToolkit::addTokenToSession($object_class, $object_id);
        $msg_domid = sprintf('rating_message_%s', $token);
        $bar_domid = sprintf('current_rating_%s', $token);
        $list_content = '  <li class="current-rating" id="' . $bar_domid . '" style="width:' . $bar_width . 'px;">';
        $list_content .= sprintf(__('Currently rated %d star(s) on %d'), $object->getRating(), $max_rating);
        $list_content .= '  </li>';
        for ($i = 1; $i <= $max_rating; $i++) {
            $label = sprintf(__('Rate it %d stars'), $i);
            $list_content .= '  <li>' . link_to_remote($label, array('url' => sprintf('sfRating/rate?token=%s&rating=%d&star_width=%d', $token, $i, $star_width), 'update' => $msg_domid, 'script' => true, 'complete' => visual_effect('appear', $msg_domid) . visual_effect('highlight', $msg_domid)), array('class' => 'r' . $i . 'stars', 'title' => $label)) . '</li>';
        }
        return content_tag('ul', $list_content, $options) . content_tag('div', null, array('id' => $msg_domid));
    } catch (Exception $e) {
        sfLogger::getInstance()->err('Exception catched from sf_rater helper: ' . $e->getMessage());
    }
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:52,代码来源:sfRatingHelper.php

示例14: getResponseXML

 /**
  * Returns response as XML
  *
  * If reponse is not a valid XML it is being created from
  * a DOM document which is being created from a text response
  * (this is the case for not valid HTML documents).
  *
  * @return SimpleXMLElement
  */
 public function getResponseXML()
 {
     try {
         $this->responseXml = parent::getResponseXML();
     } catch (Exception $exception) {
         $doc = new DOMDocument();
         $resp_str = $this->getResponseText();
         // suppress error output
         libxml_use_internal_errors(true);
         $doc->loadHTML($resp_str);
         $this->responseXml = simplexml_import_dom($doc);
         // send errors to logger
         $errors = libxml_get_errors();
         foreach ($errors as $error) {
             sfLogger::getInstance()->warning('{zWebBrowser::getResponseXML} ' . $this->displayXMLError($error));
         }
         libxml_clear_errors();
     }
     return $this->responseXml;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:29,代码来源:zWebBrowser.class.php

示例15: propagateTagsToRelatedAttos

 /**
  * propagate all tags assigned to an OppEmendamento object
  * to the related OppAtto objects
  *
  * @param string $object 
  * @param string $con 
  * @param string $affected_rows 
  * @return void
  * @author Guglielmo Celata
  */
 public function propagateTagsToRelatedAttos($object, $con, $affected_rows)
 {
     $taggable_model = $object->getTaggableModel();
     if ($taggable_model != 'OppEmendamento') {
         return;
     }
     $taggable_id = $object->getTaggableId();
     $tagged_obj = call_user_func_array(array($taggable_model . 'Peer', 'retrieveByPK'), array($taggable_id));
     $relatedAttos = $tagged_obj->getOppAttoHasEmendamentosJoinOppAtto();
     foreach ($relatedAttos as $cnt => $atto_em) {
         $atto = $atto_em->getOppAtto();
         $tags_objs = $tagged_obj->getTagsAsObjects();
         $names = array();
         foreach ($tags_objs as $cnt => $tag_obj) {
             $names[] = $tag_obj->getName();
         }
         $atto->addTag($names);
         $atto->save();
         sfLogger::getInstance()->info('{OppTaggingExtension::propagateTagsToRelatedAttos}' . sprintf('atto with id %d received the following tags: %s', $atto->getId(), implode(",", $names)));
     }
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:31,代码来源:OppTaggingExtension.class.php


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