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


PHP _s函数代码示例

本文整理汇总了PHP中_s函数的典型用法代码示例。如果您正苦于以下问题:PHP _s函数的具体用法?PHP _s怎么用?PHP _s使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: updateRegexp

function updateRegexp(array $regexp, array $expressions)
{
    try {
        $regexpId = $regexp['regexpid'];
        unset($regexp['regexpid']);
        // check existence
        if (!getRegexp($regexpId)) {
            throw new Exception(_('Regular expression does not exist.'));
        }
        // check required fields
        $dbFields = array('name' => null);
        if (!check_db_fields($dbFields, $regexp)) {
            throw new Exception(_('Incorrect arguments passed to function') . ' [updateRegexp]');
        }
        // check duplicate name
        $dbRegexp = DBfetch(DBselect('SELECT re.regexpid' . ' FROM regexps re' . ' WHERE re.name=' . zbx_dbstr($regexp['name']) . andDbNode('re.regexpid')));
        if ($dbRegexp && bccomp($regexpId, $dbRegexp['regexpid']) != 0) {
            throw new Exception(_s('Regular expression "%s" already exists.', $regexp['name']));
        }
        rewriteRegexpExpressions($regexpId, $expressions);
        DB::update('regexps', array('values' => $regexp, 'where' => array('regexpid' => $regexpId)));
    } catch (Exception $e) {
        error($e->getMessage());
        return false;
    }
    return true;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:27,代码来源:regexp.inc.php

示例2: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     // fetch hosts
     $hosts = API::Host()->get(['output' => ['hostid', 'status'], 'selectGraphs' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'selectScreens' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'groupids' => $this->screenitem['resourceid'], 'preservekeys' => true]);
     $hostids = array_keys($hosts);
     $options = ['output' => ['triggerid', 'expression', 'description', 'url', 'value', 'priority', 'lastchange', 'flags'], 'selectHosts' => ['hostid', 'name', 'status'], 'selectItems' => ['itemid', 'hostid', 'name', 'key_', 'value_type'], 'hostids' => $hostids, 'monitored' => true, 'skipDependent' => true, 'sortfield' => 'description', 'preservekeys' => true];
     // application filter
     if ($this->screenitem['application'] !== '') {
         $applications = API::Application()->get(['output' => [], 'hostids' => $hostids, 'search' => ['name' => $this->screenitem['application']], 'preservekeys' => true]);
         $options['applicationids'] = array_keys($applications);
     }
     $triggers = API::Trigger()->get($options);
     $triggers = CMacrosResolverHelper::resolveTriggerUrls($triggers);
     /*
      * Each screen cell with "Triggers overview" depends on one specific group which in this case is 'resourceid'.
      * Pass it as 'groupid' to menu pop-up "Events" link.
      */
     foreach ($triggers as &$trigger) {
         $trigger['groupid'] = $this->screenitem['resourceid'];
     }
     unset($trigger);
     $groups = API::HostGroup()->get(['output' => ['name'], 'groupids' => [$this->screenitem['resourceid']]]);
     $header = (new CDiv([new CTag('h4', true, _('Triggers overview')), (new CList())->addItem([_('Group'), ':', SPACE, $groups[0]['name']])]))->addClass(ZBX_STYLE_DASHBRD_WIDGET_HEAD);
     $table = getTriggersOverview($hosts, $triggers, $this->pageFile, $this->screenitem['style'], $this->screenid);
     $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
     return $this->getOutput(new CUiWidget(uniqid(), [$header, $table, $footer]));
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:32,代码来源:CScreenTriggersOverview.php

示例3: smarty_modifier_prettydate

/**
 * Use words instead of dates where it makes sense (today, tomorrow, yesterday).
 *
 * @package FeM\sPof\template\smartyPlugins
 * @author dangerground
 * @since 1.0
 *
 * @api
 *
 * @param string $string
 * @param string $default_date (optional)
 * @param bool $time (optional)
 *
 * @return string
 */
function smarty_modifier_prettydate($string, $default_date = '', $time = true)
{
    require_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
    if ($string != '') {
        $timestamp = smarty_make_timestamp($string);
    } elseif ($default_date != '') {
        $timestamp = smarty_make_timestamp($default_date);
    } else {
        return '';
    }
    // prepare time
    $pdate = date('Ymd', $timestamp);
    if ($pdate == date('Ymd')) {
        // Today
        return '<strong>' . _s('Heute') . '</strong>' . ($time ? ', ' . date('H:i', $timestamp) : '');
    } elseif ($pdate == date('Ymd', strtotime('+1 day'))) {
        // Tomorrow
        return _s('Morgen') . ($time ? ', ' . date('H:i', $timestamp) : '');
    } elseif ($pdate == date('Ymd', strtotime('-1 day'))) {
        // Yesterday
        return _s('Gestern') . ($time ? ', ' . date('H:i', $timestamp) : '');
    } else {
        // any other day
        return date('d.m.Y' . ($time ? ' H:i' : ''), $timestamp);
    }
}
开发者ID:fem,项目名称:spof,代码行数:41,代码来源:modifier.prettydate.php

示例4: validate

 /**
  * Validate comma-separated IP address ranges.
  *
  * @param string $ranges
  *
  * @return bool
  */
 public function validate($ranges)
 {
     if (!is_string($ranges)) {
         $this->setError(_s('Invalid IP address range "%1$s": must be a string.', $this->stringify($ranges)));
         return false;
     }
     if ($ranges === '') {
         $this->setError(_('IP address range cannot be empty.'));
         return false;
     }
     $this->maxIPCount = 0;
     $this->maxIPRange = '';
     foreach (explode(',', $ranges) as $range) {
         $range = trim($range, " \t\r\n");
         if (!$this->isValidMask($range) && !$this->isValidRange($range)) {
             $this->setError(_s('Invalid IP address range "%1$s".', $range));
             return false;
         }
     }
     if ($this->ipRangeLimit != 0 && bccomp($this->maxIPCount, $this->ipRangeLimit) > 0) {
         $this->setError(_s('IP range "%1$s" exceeds "%2$s" address limit.', $this->maxIPRange, $this->ipRangeLimit));
         return false;
     }
     return true;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:32,代码来源:CIPRangeValidator.php

示例5: validateDateTime

 /**
  * Validate date and time format.
  *
  * @param string $data			import data
  * @param array  $parent_data	data's parent array
  * @param string $path			XML path (for error reporting)
  *
  * @throws Exception			if the date or time is invalid
  */
 public function validateDateTime($data, array $parent_data = null, $path)
 {
     if (!preg_match('/^20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[01])T(2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]Z$/', $data)) {
         throw new Exception(_s('Invalid tag "%1$s": %2$s.', $path, _s('"%1$s" is expected', _x('YYYY-MM-DDThh:mm:ssZ', 'XML date and time format'))));
     }
     return $data;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:16,代码来源:C30XmlValidator.php

示例6: read

 /**
  * Convert string with xml data to php array.
  *
  * @throws Exception
  *
  * @param string $string
  *
  * @return array
  */
 public function read($string)
 {
     libxml_use_internal_errors(true);
     libxml_disable_entity_loader(true);
     $result = simplexml_load_string($string, null, LIBXML_IMPORT_FLAGS);
     if (!$result) {
         $errors = libxml_get_errors();
         libxml_clear_errors();
         foreach ($errors as $error) {
             $text = '';
             switch ($error->level) {
                 case LIBXML_ERR_WARNING:
                     $text .= _s('XML file contains warning %1$s:', $error->code);
                     break;
                 case LIBXML_ERR_ERROR:
                     $text .= _s('XML file contains error %1$s:', $error->code);
                     break;
                 case LIBXML_ERR_FATAL:
                     $text .= _s('XML file contains fatal error %1$s:', $error->code);
                     break;
             }
             $text .= trim($error->message) . ' [ Line: ' . $error->line . ' | Column: ' . $error->column . ' ]';
             throw new Exception($text);
         }
     }
     $xml = new XMLReader();
     $xml->xml($string);
     $array = $this->xmlToArray($xml);
     $xml->close();
     return $array;
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:40,代码来源:CXmlImportReader.php

示例7: gp

function gp($key, $param = '')
{
    if (empty($param)) {
        list($key, $param) = explode(':', $key);
    }
    $val = $_POST[$key];
    return _s($val, $param);
}
开发者ID:huping112004,项目名称:taobaoke,代码行数:8,代码来源:common.php

示例8: read

 /**
  * convert string with data in JSON format to php array.
  *
  * @param string $string
  *
  * @return array
  */
 public function read($string)
 {
     $data = (new CJson())->decode($string, true);
     if ($data === null) {
         throw new Exception(_s('Cannot read JSON: %1$s.', json_last_error_msg()));
     }
     return $data;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:15,代码来源:CJsonImportReader.php

示例9: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     global $page;
     // rewrite page file
     $page['file'] = $this->pageFile;
     $table = make_system_status(['groupids' => null, 'hostids' => null, 'maintenance' => null, 'trigger_name' => '', 'severity' => null, 'limit' => null, 'extAck' => 0], $this->pageFile . '?screenid=' . $this->screenid);
     $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
     return $this->getOutput((new CUiWidget('hat_syssum', [$table, $footer]))->setHeader(_('Status of Zabbix')));
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:14,代码来源:CScreenSystemStatus.php

示例10: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     global $page;
     // rewrite page file
     $page['file'] = $this->pageFile;
     $item = new CUIWidget('hat_syssum', make_system_status(array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => null, 'extAck' => 0, 'screenid' => $this->screenid)));
     $item->setHeader(_('Status of Zabbix'), SPACE);
     $item->setFooter(_s('Updated: %s', zbx_date2str(_('H:i:s'))));
     return $this->getOutput($item);
 }
开发者ID:itnihao,项目名称:Zabbix_,代码行数:15,代码来源:CScreenSystemStatus.php

示例11: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     // if screen is defined in template, then 'real_resourceid' is defined and should be used
     if (!empty($this->screenitem['real_resourceid'])) {
         $this->screenitem['resourceid'] = $this->screenitem['real_resourceid'];
     }
     if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
         $newitemid = get_same_item_for_host($this->screenitem['resourceid'], $this->hostid);
         $this->screenitem['resourceid'] = !empty($newitemid) ? $newitemid : 0;
     }
     if ($this->screenitem['resourceid'] == 0) {
         $table = (new CTableInfo())->setHeader([_('Timestamp'), _('Item')]);
         return $this->getOutput($table);
     }
     $items = CMacrosResolverHelper::resolveItemNames([get_item_by_itemid($this->screenitem['resourceid'])]);
     $item = reset($items);
     switch ($item['value_type']) {
         case ITEM_VALUE_TYPE_TEXT:
         case ITEM_VALUE_TYPE_LOG:
             $orderField = 'id';
             break;
         case ITEM_VALUE_TYPE_FLOAT:
         case ITEM_VALUE_TYPE_UINT64:
         default:
             $orderField = ['itemid', 'clock'];
     }
     $host = get_host_by_itemid($this->screenitem['resourceid']);
     $table = (new CTableInfo())->setHeader([_('Timestamp'), _('Value')]);
     $stime = zbxDateToTime($this->timeline['stime']);
     $histories = API::History()->get(['history' => $item['value_type'], 'itemids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN, 'sortfield' => $orderField, 'limit' => $this->screenitem['elements'], 'time_from' => $stime, 'time_till' => $stime + $this->timeline['period']]);
     foreach ($histories as $history) {
         switch ($item['value_type']) {
             case ITEM_VALUE_TYPE_FLOAT:
                 sscanf($history['value'], '%f', $value);
                 break;
             case ITEM_VALUE_TYPE_TEXT:
             case ITEM_VALUE_TYPE_STR:
             case ITEM_VALUE_TYPE_LOG:
                 $value = $this->screenitem['style'] ? new CJsScript($history['value']) : $history['value'];
                 break;
             default:
                 $value = $history['value'];
                 break;
         }
         if ($item['valuemapid'] > 0) {
             $value = applyValueMap($value, $item['valuemapid']);
         }
         if ($this->screenitem['style'] == 0) {
             $value = new CPre($value);
         }
         $table->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $history['clock']), $value]);
     }
     $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
     return $this->getOutput((new CUiWidget(uniqid(), [$table, $footer]))->setHeader($host['name'] . NAME_DELIMITER . $item['name_expanded']));
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:60,代码来源:CScreenPlainText.php

示例12: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $header = (new CDiv([new CTag('h4', true, _('Triggers info'))]))->addClass(ZBX_STYLE_DASHBRD_WIDGET_HEAD);
     if ($this->screenitem['resourceid'] != 0) {
         $groups = API::HostGroup()->get(['output' => ['name'], 'groupids' => [$this->screenitem['resourceid']]]);
         $header->addItem((new CList())->addItem([_('Host'), ':', SPACE, $groups[0]['name']]));
     }
     $table = (new CTriggersInfo($this->screenitem['resourceid']))->setOrientation($this->screenitem['style']);
     $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
     return $this->getOutput(new CUiWidget(uniqid(), [$header, $table, $footer]));
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:16,代码来源:CScreenTriggersInfo.php

示例13: validate

 /**
  * Base validation function.
  *
  * @param array  $data    import data
  * @param string $format  format of import source
  *
  * @return array		Validator does some manipulation for the incoming data. For example, converts empty tags to
  *						an array, if desired. Converted array is returned.
  */
 public function validate(array $data, $format)
 {
     $rules = ['type' => XML_ARRAY, 'rules' => ['zabbix_export' => ['type' => XML_ARRAY | XML_REQUIRED, 'check_unexpected' => false, 'rules' => ['version' => ['type' => XML_STRING | XML_REQUIRED]]]]];
     $data = (new CXmlValidatorGeneral($rules, $format))->validate($data, '/');
     $version = $data['zabbix_export']['version'];
     if (!array_key_exists($version, $this->versionValidators)) {
         throw new Exception(_s('Invalid tag "%1$s": %2$s.', '/zabbix_export/version', _('unsupported version number')));
     }
     $data['zabbix_export'] = (new $this->versionValidators[$version]($format))->validate($data['zabbix_export'], '/zabbix_export');
     return $data;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:20,代码来源:CXmlValidator.php

示例14: authenticate

 /**
  * Uses the user credentials sent with the HTTP-Header to authenticate the user calling the API.
  *
  * œ@api
  *
  * @throws \FeM\sPof\exception\BasicAuthException
  *
  * @return boolean True, if user with the given password was authenticated successfully, else false.
  */
 public final function authenticate()
 {
     if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
         throw new \FeM\sPof\exception\BasicAuthException(_s('Missing authentication credentials'));
     }
     $user_id = User::getIdByCredentials($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
     if ($user_id === false) {
         throw new \FeM\sPof\exception\BasicAuthException(_s('Wrong user and/or password.'));
     }
     return $user_id;
 }
开发者ID:fem,项目名称:spof,代码行数:20,代码来源:ApiAuthenticationTrait.php

示例15: executeShow

 /**
  * Wrapper for calling the self::$show-method. This wrapper is necessary to call
  *
  * @internal
  *
  * @param string $show
  * @throws \FeM\sPof\exception\NotImplementedException
  * @return mixed content
  */
 public function executeShow($show = null)
 {
     // call show met
     if ($show === null) {
         $show = \FeM\sPof\Router::getShow($show);
     }
     if (!method_exists(get_called_class(), $show)) {
         throw new \FeM\sPof\exception\NotImplementedException(_s('Could not find the show method. "%s::%s"', get_called_class(), $show));
     }
     return $this->{$show}();
 }
开发者ID:fem,项目名称:spof,代码行数:20,代码来源:AbstractJsonView.php


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