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


PHP Utility类代码示例

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


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

示例1: renderHead

 public function renderHead()
 {
     $page = $this->plugin->getData('page');
     if ($page !== 'photos' && $page !== 'photo-detail' && $page !== 'albums') {
         return;
     }
     $photo = null;
     if ($page === 'photos') {
         $photo = array_shift($this->plugin->getData('photos'));
     } elseif ($page === 'photo-detail') {
         $photo = $this->plugin->getData('photo');
     } elseif ($page === 'albums') {
         $albums = $this->plugin->getData('albums');
         if (count($albums) > 0 && !empty($albums[0]['cover'])) {
             $photo = $albums[0]['cover'];
         }
     }
     if (empty($photo)) {
         return;
     }
     $utility = new Utility();
     $tags = '';
     $title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on Trovebox";
     $tags .= $this->addTag('og:site_name', sprintf('%s Trovebox site', ucwords($utility->posessive($utility->getEmailHandle($this->config->user->email, false), false))));
     $tags .= $this->addTag('og:title', $photo['title']);
     $tags .= $this->addTag('og:url', $photo['url']);
     $tags .= $this->addTag('og:image', $photo['pathBase']);
     return $tags;
 }
开发者ID:gg1977,项目名称:frontend,代码行数:29,代码来源:FacebookLikePlugin.php

示例2: getAvatarFromEmail

 /**
  * Get an avatar given an email address
  * See http://en.gravatar.com/site/implement/images/ and http://en.gravatar.com/site/implement/hash/
  *
  * @return string
  */
 public function getAvatarFromEmail($size = 50, $email = null)
 {
     if ($email === null) {
         $email = $this->session->get('email');
     }
     // TODO return standard avatar
     if (empty($email)) {
         return;
     }
     $user = $this->getUserByEmail($email);
     if (isset($user['attrprofilePhoto']) && !empty($user['attrprofilePhoto'])) {
         return $user['attrprofilePhoto'];
     }
     $utilityObj = new Utility();
     if (empty($this->config->site->cdnPrefix)) {
         $hostAndProtocol = sprintf('%s://%s', $utilityObj->getProtocol(false), $utilityObj->getHost(false));
     } else {
         $hostAndProtocol = sprintf('%s%s', $utilityObj->getProtocol(false), $this->config->site->cdnPrefix);
     }
     if (!$this->themeObj) {
         $this->themeObj = getTheme();
     }
     $defaultUrl = sprintf('%s%s', $hostAndProtocol, $this->themeObj->asset('image', 'profile-default.png', false));
     $hash = md5(strtolower(trim($email)));
     return sprintf("http://www.gravatar.com/avatar/%s?s=%s&d=%s", $hash, $size, urlencode($defaultUrl));
 }
开发者ID:hfiguiere,项目名称:frontend,代码行数:32,代码来源:User.php

示例3: renderHead

 public function renderHead()
 {
     $page = $this->plugin->getData('page');
     if ($page !== 'photos' && $page !== 'photo-detail' && $page !== 'albums') {
         return;
     }
     $photo = null;
     if ($page === 'photos') {
         $photo = array_shift($this->plugin->getData('photos'));
     } elseif ($page === 'photo-detail') {
         $photo = $this->plugin->getData('photo');
     } elseif ($page === 'albums') {
         $albums = $this->plugin->getData('albums');
         if (count($albums) > 0 && !empty($albums[0]['cover'])) {
             $photo = $albums[0]['cover'];
         }
     }
     if (empty($photo)) {
         return;
     }
     $utility = new Utility();
     $tags = '';
     $title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on Trovebox";
     $tags .= $this->addTag('twitter:card', 'photo');
     $tags .= $this->addTag('twitter:site', '@openphoto');
     $tags .= $this->addTag('twitter:url', sprintf('%s://%s%s', $utility->getProtocol(false), $utility->getHost(), $utility->getPath()));
     $tags .= $this->addTag('twitter:title', $title);
     $tags .= $this->addTag('twitter:description', 'Trovebox lets you keep all your photos from different services and mobile devices safe in one spot.');
     $tags .= $this->addTag('twitter:image', $photo['pathBase']);
     $tags .= $this->addTag('twitter:image:width', '1280');
     return $tags;
 }
开发者ID:hfiguiere,项目名称:frontend,代码行数:32,代码来源:TwitterCardPlugin.php

示例4: update_groups

/**
* Update the groups for this user
* @param none
*/
function update_groups($memberid, $to_add)
{
    $util = new Utility();
    $user = new User($memberid);
    $orig = array_keys($user->groups);
    $groups_to_add = $util->getAddedItems($orig, $to_add);
    $groups_to_remove = $util->getRemovedItems($orig, $to_add);
    $user->add_groups($groups_to_add);
    $user->remove_groups($groups_to_remove);
    close_window();
}
开发者ID:razagilani,项目名称:srrs,代码行数:15,代码来源:group_edit.php

示例5: renderHead

 public function renderHead()
 {
     $utility = new Utility();
     $photo = $this->plugin->getData('photo');
     $tags = '';
     $title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on OpenPhoto";
     $tags .= $this->addTag('og:site_name', sprintf('%s OpenPhoto site', ucwords($utility->posessive($utility->getEmailHandle($this->config->user->email, false), false))));
     $tags .= $this->addTag('og:title', $photo['title']);
     $tags .= $this->addTag('og:url', $photo['url']);
     $tags .= $this->addTag('og:image', $photo['pathBase']);
     return $tags;
 }
开发者ID:nicolargo,项目名称:frontend,代码行数:12,代码来源:FacebookLikePlugin.php

示例6: diagnostics

 /**
  * Gets diagnostic information for debugging.
  *
  * @return array
  */
 public function diagnostics()
 {
     $utilityObj = new Utility();
     $diagnostics = array();
     $aclCheck = $this->fs->get_bucket_acl($this->bucket);
     if ((int) $aclCheck->status == 200) {
         $storageSize = $this->fs->get_bucket_filesize($this->bucket, true);
         $diagnostics[] = $utilityObj->diagnosticLine(true, sprintf('Connection to bucket "%s" is okay.', $this->bucket));
         $diagnostics[] = $utilityObj->diagnosticLine(true, sprintf('Total space used in bucket "%s" is %s.', $this->bucket, $storageSize));
     } else {
         $diagnostics[] = $utilityObj->diagnosticLine(false, sprintf('Connection to bucket "%s" is NOT okay.', $this->bucket));
     }
     return $diagnostics;
 }
开发者ID:nicolargo,项目名称:frontend,代码行数:19,代码来源:FileSystemS3.php

示例7: hasOpenSession

 public function hasOpenSession()
 {
     $util = new Utility();
     $config = new Configuration();
     $dbName = $config->settings->authDatabaseName;
     $sessionID = $util->getSessionCookie();
     $query = "SELECT DISTINCT sessionID FROM " . $dbName . ".Session WHERE loginID = '" . $this->loginID . "' AND sessionID='" . $sessionID . "'";
     $result = $this->db->processQuery($query, 'assoc');
     if (isset($result['sessionID'])) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:ualbertalib,项目名称:organizations,代码行数:14,代码来源:User.php

示例8: UpdateById

 protected function UpdateById($args)
 {
     $object_id = $args[0];
     $metas = $args[1];
     $old_data = Utility::AssColumn($this->GetById(array($object_id)), 'meta_key');
     foreach ($metas as $k => $v) {
         if ($v && $v !== $old_data[$k]['meta_value']) {
             $m = array();
             if ($old_data[$k]) {
                 $m['id'] = $old_data[$k]['id'];
             }
             $m[$this->_fetch_id_name] = $object_id;
             $m['meta_key'] = $k;
             $m['meta_value'] = $v;
             $new_data[] = $m;
         }
     }
     if (!$new_data) {
         return;
     }
     $mm = D($this->_table_name);
     foreach ($new_data as $d) {
         $mm->create($d);
         $mm->saveOrUpdate();
     }
     return;
 }
开发者ID:Germey,项目名称:yinxingpm,代码行数:27,代码来源:MetasModel.class.php

示例9: showPrice

 /**
  * [price description]
  * @param  [float or array] $arg [it could be float or an array, if its array you can put
  *         'amount' to display,'discount' that it already has, 'thousandSuffix' if you wanna use that format ]
  *         if you use 'discount' the return is gonna be something like that 'The final value is USD 7.50 (after a 25% discount)'
  *         this function works with config('app.payment_method') then there could be Points or Currency
  * @return [String]      [Formated number or explaint of discount]
  */
 public static function showPrice($arg)
 {
     $options = ['amount' => '', 'discount' => 0, 'thousandSuffix' => 1];
     if (is_array($arg)) {
         $options = $arg + $options;
         if (isset($options['price'])) {
             $options['amount'] = $options['price'];
         }
     } else {
         $options['amount'] = $arg;
     }
     switch (config('app.payment_method')) {
         case 'Points':
             $points = Utility::thousandSuffix($options['amount']);
             if ($options['thousandSuffix']) {
                 $points .= " <small>" . trans('store.points') . "</small>";
             }
             return $points;
         default:
             setlocale(LC_MONETARY, config('app.lc_monetary'));
             $format = '%i';
             if ($options['discount']) {
                 $format = str_replace('##', $options['discount'], trans('product.globals.price_after_discount'));
             }
             return self::money_format($format, $options['amount']);
     }
 }
开发者ID:masterpowers,项目名称:antVel,代码行数:35,代码来源:Utility.php

示例10: __construct

 public function __construct($data)
 {
     $this->name = isset($data['name']) ? $data['name'] : '';
     $this->tag = isset($data['tag']) ? $data['tag'] : '';
     $this->tag_type = isset($data['tag_type']) ? $data['tag_type'] : '';
     $this->content = isset($data['content']) ? $data['content'] : '';
     $this->before = isset($data['before']) ? $data['before'] : '';
     $this->after = isset($data['after']) ? $data['after'] : '';
     $this->attributes = isset($data['attributes']) ? $data['attributes'] : array();
     $this->hide = isset($data['hide']) ? $data['hide'] : false;
     $this->suppress_filters = isset($data['suppress_filters']) ? $data['suppress_filters'] : true;
     $this->markup = '';
     if (isset($data['post'])) {
         $this->post_object = $data['post'];
     } else {
         $this->post_object = get_post();
     }
     // Ensures that the 'class' attribute is set if it wasn't passed in with attributes.
     if (!isset($this->attributes['class'])) {
         $this->attributes['class'] = array();
     }
     // Add the Atom name as a class
     $this->attributes['class'][] = $this->name;
     if (!empty($data['class'])) {
         $classes_arr = Utility::parse_classes_as_array($data['class']);
         if (!empty($classes_arr)) {
             $this->attributes['class'] = array_merge($this->attributes['class'], $classes_arr);
         }
     }
     unset($this->class);
     // Filter the Atom properties.
     $atom_structure_filter = $this->name . '_properties_filter';
     apply_filters($atom_structure_filter, $this, $data);
     Atom::add_debug_entry('Filter', $atom_structure_filter);
 }
开发者ID:Clark-Nikdel-Powell,项目名称:Pattern-Library,代码行数:35,代码来源:class.atom-template.php

示例11: sync_event_users

function sync_event_users()
{
    $current_users = OutboundUsers::GetPartnerUsers(1);
    $current_users_by_mobile = Utility::AssColumn($current_users, 'mobile');
    $users = Users::GetUsers(NULL, 0, 50000);
    global $g_user_type;
    global $g_active_status;
    foreach ($users as $i => $eu) {
        if (!$current_users_by_mobile[$eu['mobile']]) {
            $new_id = OutboundUsers::AddCommonUser(1, $eu);
            $new_ids[] = $new_id;
            //添加默认标签
            if ($eu['user_type'] && $eu['user_type'] !== 'other') {
                $gid = OutboundUserGroups::AddGroup(1, $g_user_type[$eu['user_type']]);
                OutboundUserGroups::AddMap($new_id, $gid);
            }
            if ($eu['active_status']) {
                $gid = OutboundUserGroups::AddGroup(1, $g_active_status[$eu['active_status']]);
                OutboundUserGroups::AddMap($new_id, $gid);
            }
            $current_users_by_mobile[$eu['mobile']] = 1;
        }
    }
    return $new_ids;
}
开发者ID:Germey,项目名称:yinxingpm,代码行数:25,代码来源:mail.php

示例12: handleGET

 /**
  * Handles a GET request
  *
  * @return none, but populates $this->JSON
  */
 public function handleGET()
 {
     if (!empty($this->JSON)) {
         return;
     }
     $config = $this->Factory->config();
     $useProjects = $config->getSetting("useProjects");
     $useEDC = $config->getSetting("useEDC");
     if ($useEDC === '1' || $useEDC === 'true') {
         $useEDC = true;
     } else {
         $useEDC = false;
     }
     $PSCID = $config->getSetting("PSCID");
     $PSCIDFormat = \Utility::structureToPCRE($PSCID['structure'], "SITE");
     $type = $PSCID['generation'] == 'sequential' ? 'auto' : 'prompt';
     $settings = ["useEDC" => $useEDC, "PSCID" => ["Type" => $type, "Regex" => $PSCIDFormat]];
     if ($useProjects && $useProjects !== "false" && $useProjects !== "0") {
         $projects = \Utility::getProjectList();
         $projArray = [];
         foreach ($projects as $project) {
             $projArray[$project] = $settings;
         }
         $this->JSON = ["Projects" => $projArray];
     } else {
         $this->JSON = ["Projects" => array("loris" => $settings)];
     }
 }
开发者ID:frankbiospective,项目名称:Loris,代码行数:33,代码来源:Projects.php

示例13: execute

 /**
  * Send the HTTP request, with optional parameters
  * $params and $header. First parameter $requestURL
  * is also optional, if the URL already been set by
  * the getRequestURL() method.
  *
  * @param   string  The request url.
  * @param   array   Optional. Parameters to post.
  * @param   array   Optional. Http header.
  * @return  array | string
  */
 public function execute($requestURL = NULL, $params = NULL, $header = NULL)
 {
     if ($requestURL === NULL) {
         $requestURL = $this->getRequestURL();
     }
     $curlHandle = curl_init();
     // Default curl options array
     $curlOptions = array(CURLOPT_URL => $requestURL, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_TIMEOUT => 30, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_HEADER => 0, CURLOPT_POST => $this->getHttpMethod() === 'POST');
     curl_setopt_array($curlHandle, $curlOptions);
     // The parameters array must be turned into an URL-encoded query string.
     if ($params !== NULL && $this->getHttpMethod() === 'POST') {
         // The access token should not be included in the post data.
         if (array_key_exists("oauth_token", $params)) {
             unset($params['oauth_token']);
         }
         curl_setopt($curlHandle, CURLOPT_POSTFIELDS, http_build_query($params));
     }
     if ($header !== NULL) {
         curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $header);
     }
     $response = curl_exec($curlHandle);
     // Save the received http code.
     $this->setLastHttpCode(curl_getinfo($curlHandle, CURLINFO_HTTP_CODE));
     curl_close($curlHandle);
     // If the response is in JSON, convert it to an array
     $response = Utility::convertJSON($response);
     return $response;
 }
开发者ID:pkrll,项目名称:Philotes,代码行数:39,代码来源:Request.php

示例14: updateDetail

 public function updateDetail($arrPost)
 {
     Utility::pushArrAreaID($arrPost);
     //  区域ID
     if (empty($arrPost['endtime'])) {
         $arrPost['endtime'] = '';
     }
     if (!empty($arrPost['photos']) && stristr($arrPost['photos'], '|')) {
         $arrPost['photos'] = Utility::sortImg($arrPost['photos']);
         // 排序
     }
     // 需要 处理的 数字大小
     $arrParam = array('floor', 'floortotal', 'roomnumber', 'livingnumber', 'houseage', 'toiletnumber');
     Utility::checkMaxNum($arrPost, $arrParam);
     $arrPost['aroundpoint'] = empty($arrPost['aroundpoint']) ? '' : implode(',', $arrPost['aroundpoint']);
     $arrPost['livepoint'] = empty($arrPost['livepoint']) ? '' : implode(',', $arrPost['livepoint']);
     $this->strRequestApi = empty($arrPost['id']) ? $this->arrRequestApi['SECOND_HOUSE_ADD'] : $this->arrRequestApi['SECOND_HOUSE__UPDATE'];
     $this->arrRequest = $arrPost;
     $arrResultList = $this->updateParentDetail();
     // D($arrPost);
     // D($arrResultList);
     // exit();
     // 成功跳转
     if ($arrResultList['errorCode'] === 0 || $arrResultList['errorCode'] === 2) {
         Utility::location('secondHouse.php');
     }
     // Utility::UIWindowAlert( '请填写完整。');
     // Utility::location( null , '填写信息有误,请耐心检查下。');
     Utility::location(null, ACTION_ERROR);
 }
开发者ID:alonexy,项目名称:lea,代码行数:30,代码来源:WalletController.php

示例15: Create

 public static function Create($mobile, $user_id, $secret = null, $enable = false)
 {
     if (!Utility::IsMobile($mobile, true)) {
         return;
     }
     $secret = $secret ? $secret : Utility::VerifyCode();
     $table = new Table('toolsbind', array('user_id' => $user_id, 'tools' => $mobile, 'enable' => $enable ? 'Y' : 'N', 'secret' => $secret));
     $condition = array('user_id' => $user_id, 'tools' => $mobile, 'enable' => 'N');
     $haveone = DB::GetTableRow('toolsbind', $condition);
     if ($haveone) {
         return Table::UpdateCache('toolsbind', $haveone['id'], array('secret' => $secret, 'enable' => 'N'));
     }
     //已经绑定了本号码
     $loginbind = array('user_id' => $user_id, 'tools' => $mobile, 'enable' => 'Y');
     $havebind = DB::GetTableRow('toolsbind', $loginbind);
     if ($havebind) {
         return false;
     }
     //$table->insert(array( 'user_id', 'tools','secret', 'enable'));
     DB::Insert('toolsbind', array('user_id' => $user_id, 'tools' => $mobile, 'secret' => $secret, 'enable' => 'N', 'create_time' => time()));
     $have = Table::Fetch('toolsbind', $mobile, 'tools');
     if ($have && 'Y' == $have['enable']) {
         return true;
     }
 }
开发者ID:norain2050,项目名称:zuituware,代码行数:25,代码来源:ZToolsbind.class.php


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