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


PHP common_nicknamize函数代码示例

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


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

示例1: onAutoRegister

 /**
  * Internal AutoRegister event handler
  * @param nickname
  * @param provider_name
  * @param user - the newly registered user
  */
 function onAutoRegister($nickname, $provider_name, &$user)
 {
     if ($provider_name == $this->provider_name && $this->autoregistration) {
         $suggested_nickname = $this->suggestNicknameForUsername($nickname);
         $test_user = User::staticGet('nickname', $suggested_nickname);
         if ($test_user) {
             //someone already exists with the suggested nickname, so used the passed nickname
             $suggested_nickname = common_nicknamize($nickname);
         }
         $test_user = User::staticGet('nickname', $suggested_nickname);
         if ($test_user) {
             //someone already exists with the suggested nickname
             //not much else we can do
         } else {
             $user = $this->autoRegister($nickname, $suggested_nickname);
             if ($user) {
                 User_username::register($user, $nickname, $this->provider_name);
                 return false;
             }
         }
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:28,代码来源:authenticationplugin.php

示例2: common_url_to_nickname

function common_url_to_nickname($url)
{
    static $bad = array('query', 'user', 'password', 'port', 'fragment');
    $parts = parse_url($url);
    # If any of these parts exist, this won't work
    foreach ($bad as $badpart) {
        if (array_key_exists($badpart, $parts)) {
            return null;
        }
    }
    # We just have host and/or path
    # If it's just a host...
    if (array_key_exists('host', $parts) && (!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0)) {
        $hostparts = explode('.', $parts['host']);
        # Try to catch common idiom of nickname.service.tld
        if (count($hostparts) > 2 && strlen($hostparts[count($hostparts) - 2]) > 3 && strcmp($hostparts[0], 'www') != 0) {
            return common_nicknamize($hostparts[0]);
        } else {
            # Do the whole hostname
            return common_nicknamize($parts['host']);
        }
    } else {
        if (array_key_exists('path', $parts)) {
            # Strip starting, ending slashes
            $path = preg_replace('@/$@', '', $parts['path']);
            $path = preg_replace('@^/@', '', $path);
            $path = basename($path);
            if ($path) {
                return common_nicknamize($path);
            }
        }
    }
    return null;
}
开发者ID:himmelex,项目名称:NTW,代码行数:34,代码来源:util.php

示例3: getActivityObjectNickname

 public static function getActivityObjectNickname(ActivityObject $object, array $hints = array())
 {
     if ($object->poco) {
         if (!empty($object->poco->preferredUsername)) {
             return common_nicknamize($object->poco->preferredUsername);
         }
     }
     if (!empty($object->nickname)) {
         return common_nicknamize($object->nickname);
     }
     if (array_key_exists('nickname', $hints)) {
         return $hints['nickname'];
     }
     // Try the profile url (like foo.example.com or example.com/user/foo)
     if (!empty($object->link)) {
         $profileUrl = $object->link;
     } else {
         if (!empty($hints['profileurl'])) {
             $profileUrl = $hints['profileurl'];
         }
     }
     if (!empty($profileUrl)) {
         $nickname = self::nicknameFromURI($profileUrl);
     }
     // Try the URI (may be a tag:, http:, acct:, ...
     if (empty($nickname)) {
         $nickname = self::nicknameFromURI($object->id);
     }
     // Try a Webfinger if one was passed (way) down
     if (empty($nickname)) {
         if (array_key_exists('webfinger', $hints)) {
             $nickname = self::nicknameFromURI($hints['webfinger']);
         }
     }
     // Try the name
     if (empty($nickname)) {
         $nickname = common_nicknamize($object->title);
     }
     return $nickname;
 }
开发者ID:faulteh,项目名称:gnu-social,代码行数:40,代码来源:Ostatus_profile.php

示例4: nicknamize

 function nicknamize($str)
 {
     return common_nicknamize($str);
 }
开发者ID:Br3nda,项目名称:StatusNet,代码行数:4,代码来源:finishopenidlogin.php

示例5: common_url_to_nickname

function common_url_to_nickname($url)
{
    static $bad = array('query', 'user', 'password', 'port', 'fragment');
    $parts = parse_url($url);
    // If any of these parts exist, this won't work
    foreach ($bad as $badpart) {
        if (array_key_exists($badpart, $parts)) {
            return null;
        }
    }
    // We just have host and/or path
    // If it's just a host...
    if (array_key_exists('host', $parts) && (!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0)) {
        $hostparts = explode('.', $parts['host']);
        // Try to catch common idiom of nickname.service.tld
        if (count($hostparts) > 2 && strlen($hostparts[count($hostparts) - 2]) > 3 && strcmp($hostparts[0], 'www') != 0) {
            return common_nicknamize($hostparts[0]);
        } else {
            // Do the whole hostname
            return common_nicknamize($parts['host']);
        }
    } else {
        if (array_key_exists('path', $parts)) {
            // Strip starting, ending slashes
            $path = preg_replace('@/$@', '', $parts['path']);
            $path = preg_replace('@^/@', '', $path);
            $path = basename($path);
            // Hack for MediaWiki user pages, in the form:
            // http://example.com/wiki/User:Myname
            // ('User' may be localized.)
            if (strpos($path, ':')) {
                $parts = array_filter(explode(':', $path));
                $path = $parts[count($parts) - 1];
            }
            if ($path) {
                return common_nicknamize($path);
            }
        }
    }
    return null;
}
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:41,代码来源:util.php

示例6: define

 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
$shortoptions = "e:";
$helptext = <<<END_OF_REGISTERBYEMAIL_HELP
USAGE: registerbyemail.php
Registers a new user by email address and sends a confirmation email

  -e email     Email to register

END_OF_REGISTERBYEMAIL_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
$email = get_option_value('e', 'email');
$parts = explode('@', $email);
$nickname = common_nicknamize($parts[0]);
$user = User::getKV('nickname', $nickname);
if (!empty($user)) {
    $confirm = new Confirm_address();
    $confirm->user_id = $user->id;
    $confirm->address_type = 'email';
    if ($confirm->find(true)) {
        $url = common_local_url('confirmfirstemail', array('code' => $confirm->code));
        print "{$url}\n";
    } else {
        print "User not waiting for confirmation.\n";
    }
    exit;
}
$user = User::register(array('nickname' => $nickname, 'password' => null));
$confirm = new Confirm_address();
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:31,代码来源:registerbyemail.php

示例7: xriToNickname

 function xriToNickname($xri)
 {
     $base = $this->xriBase($xri);
     if (!$base) {
         return null;
     } else {
         // =evan.prodromou
         // or @gratis*evan.prodromou
         $parts = explode('*', substr($base, 1));
         return common_nicknamize(array_pop($parts));
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:12,代码来源:finishopenidlogin.php

示例8: suggestNicknameForUsername

 function suggestNicknameForUsername($username)
 {
     $entry = $this->ldapCommon->get_user($username, $this->attributes);
     if (!$entry) {
         //this really shouldn't happen
         $nickname = $username;
     } else {
         $nickname = $entry->getValue($this->attributes['nickname'], 'single');
         if (!$nickname) {
             $nickname = $username;
         }
     }
     return common_nicknamize($nickname);
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:14,代码来源:LdapAuthenticationPlugin.php


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