本文整理汇总了PHP中Avatar::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Avatar::find方法的具体用法?PHP Avatar::find怎么用?PHP Avatar::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Avatar
的用法示例。
在下文中一共展示了Avatar::find方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Load the database object
* @param array
*/
public function __construct($arrAttributes = null)
{
$GLOBALS['TL_CSS']['avatar_handler'] = 'system/modules/avatar/assets/handler/handler.min.css';
// Include jQuery
$this->addJQuery = true;
parent::__construct($arrAttributes);
// Set the value
if ($this->varValue == '') {
$this->varValue = \Avatar::find($this->getId(), $this->getUploadPath());
}
}
示例2: __construct
/**
* Load the database object
* @param array
*/
public function __construct($arrAttributes = null)
{
// Execute the AJAX actions in front end
if (\Environment::get('isAjaxRequest') && \Input::get('no_ajax') != 1) {
$objHandler = new \Avatar();
$objHandler->executeAjaxActions($this->arrConfiguration);
return;
}
$GLOBALS['TL_CSS']['avatar_fineuploader'] = 'system/modules/avatar/assets/fineuploader/fineuploader-5.0.2.min.css';
parent::__construct($arrAttributes);
// Set the value
if ($this->varValue == '') {
$this->varValue = \Avatar::find($this->getId(), $this->getUploadPath());
}
}
示例3: updateAvatars
function updateAvatars($user)
{
$touched = false;
if (!have_option('q', 'quiet')) {
print "Updating avatars for user '" . $user->nickname . "' (" . $user->id . ")...";
}
$avatar = new Avatar();
$avatar->profile_id = $user->id;
if (!$avatar->find()) {
if (have_option('v', 'verbose')) {
print "(none found)...";
}
} else {
while ($avatar->fetch()) {
if (have_option('v', 'verbose')) {
if ($avatar->original) {
print "original...";
} else {
print $avatar->width . "...";
}
}
$orig_url = $avatar->url;
$avatar->url = Avatar::url($avatar->filename);
if ($avatar->url != $orig_url) {
$sql = "UPDATE avatar SET url = '" . $avatar->url . "' " . "WHERE profile_id = " . $avatar->profile_id . " " . "AND width = " . $avatar->width . " " . "AND height = " . $avatar->height . " ";
if ($avatar->original) {
$sql .= "AND original = 1 ";
}
if (!$avatar->query($sql)) {
throw new Exception("Can't update avatar for user " . $user->nickname . ".");
} else {
$touched = true;
}
}
}
}
if ($touched) {
$profile = $user->getProfile();
common_broadcast_profile($profile);
}
if (have_option('v', 'verbose')) {
print "DONE.";
}
if (!have_option('q', 'quiet') || have_option('v', 'verbose')) {
print "\n";
}
}
示例4: afterLogin
private static function afterLogin()
{
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
$json = $connection->get('users/show', ['user_id' => $_SESSION['twitter-userid']]);
$_SESSION['twitter-avatar'] = isset($json->profile_image_url) ? $json->profile_image_url : '';
Avatar::setUsersAvatar($_SESSION['twitter-userid'], $_SESSION['twitter-username'], $_SESSION['twitter-avatar']);
$oldAvatars = Avatar::find('1=1 order by dateline asc limit 100');
if ($oldAvatars) {
$oldAvatarsIds = Model::pluck($oldAvatars, 'userid');
$json = $connection->get('users/lookup', ['user_id' => implode(',', $oldAvatarsIds)]);
foreach ($json as $userdata) {
$newavatars[$userdata->id_str] = $userdata->profile_image_url;
}
foreach ($oldAvatars as $avatar) {
$avatar->url = $newavatars[$avatar->userid];
$avatar->dateline = time();
}
Model::saveAll($oldAvatars);
}
}
示例5: updateAvatarUrls
function updateAvatarUrls($profile)
{
$avatar = new Avatar();
$avatar->profile_id = $profile->id;
if ($avatar->find()) {
while ($avatar->fetch()) {
$orig_url = $avatar->url;
$avatar->url = Avatar::url($avatar->filename);
if ($avatar->url != $orig_url) {
$sql = "UPDATE avatar SET url = '" . $avatar->url . "' " . "WHERE profile_id = " . $avatar->profile_id . " " . "AND width = " . $avatar->width . " " . "AND height = " . $avatar->height . " ";
if ($avatar->original) {
$sql .= "AND original = 1 ";
}
if (!$avatar->query($sql)) {
throw new Exception("Can't update avatar for user " . $profile->nickname . ".");
} else {
$touched = true;
}
}
}
}
}
示例6: hasGravatar
function hasGravatar($id)
{
$avatar = new Avatar();
$avatar->profile_id = $id;
if ($avatar->find()) {
while ($avatar->fetch()) {
if ($avatar->filename == null) {
return true;
}
}
}
return false;
}
示例7: Avatar
/**
* Delete attached avatars for this user from the database and filesystem.
* This should be used instead of a batch delete() to ensure that files
* get removed correctly.
*
* @param boolean $original true to delete only the original-size file
* @return <type>
*/
function delete_avatars($original = true)
{
$avatar = new Avatar();
$avatar->profile_id = $this->id;
$avatar->find();
while ($avatar->fetch()) {
if ($avatar->original) {
if ($original == false) {
continue;
}
}
$avatar->delete();
}
return true;
}
示例8: testCreateAssocObjectExistingObject
public function testCreateAssocObjectExistingObject()
{
$this->fixtures('users', 'avatars');
$user = User::find($this->users('derek')->id);
$avatar = $user->createAvatar(array('filepath' => 'test.gif'));
$this->assertEquals($avatar, $user->avatar);
// this hasn't saved the associated object yet
$newAvatar = Avatar::find('first', array('conditions' => 'filepath=:nm'), array(':nm' => 'test.gif'));
$this->assertTrue($newAvatar instanceof Avatar);
$this->assertEquals($newAvatar->user_id, $user->id);
// save, and make sure the association object is created
$user->save();
// make sure both were created, and are associated
$user = User::find($this->users('derek')->id);
$avatar = Avatar::find('first', array('conditions' => 'filepath=:nm'), array(':nm' => 'test.gif'));
$this->assertTrue($user instanceof User);
$this->assertTrue($avatar instanceof Avatar);
$this->assertEquals($user->id, $avatar->user_id);
}
示例9: validator
/**
* Return the value
* @param mixed
* @return mixed
*/
protected function validator($varInput)
{
// Check the mandatoriness
if ($varInput == '' && $this->mandatory) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mandatory'], $this->strLabel));
return '';
}
$varReturn = $varInput;
// Delete the file
if ($varInput == '' && $this->varValue != '') {
\Files::getInstance()->delete($this->varValue);
}
// Move file to the destination folder
if (is_file(TL_ROOT . '/' . $varInput) && $this->isTemporaryFile($varInput)) {
$strAvatar = \Avatar::find($this->getId(), $this->getUploadPath());
// Delete the current avatar
if ($strAvatar != '') {
\Files::getInstance()->delete($strAvatar);
}
$strNew = $this->getUploadPath() . '/' . $this->getId() . '-' . md5(uniqid('', true)) . '.' . pathinfo($varInput, PATHINFO_EXTENSION);
if (\Files::getInstance()->rename($varInput, $strNew)) {
$varReturn = $strNew;
}
}
return $varReturn;
}
示例10: show
/**
* @return void
*/
public function show()
{
$matches = Match::find('seasonid = ? and result != 0', [$this->season->seasonid]);
$matches = Model::indexBy($matches, 'matchid');
$teams = Model::indexBy(Team::find('1=1'), 'teamid');
$matchWinner = [];
foreach($matches as $match) {
if ($this->season->weekIsPublished($match->week) && !$match->isDelayed()) {
$matchWinner[$match->matchid] = $match->getWinner();
}
}
$totalBets = [];
$correctBets = [];
$usernames = [];
$avatars = Model::pluck(Avatar::find('1=1'), 'url', 'userid');
foreach(Bet::find('1=1') as $bet) {
if (isset($matchWinner[$bet->matchid])) {
if ($bet->teamid && $matchWinner[$bet->matchid] == $bet->teamid) {
$correctBets[$bet->userid]++;
}
$totalBets[$bet->userid]++;
}
if ($bet->username) {
$usernames[$bet->userid] = $bet->username;
}
}
$tiebreakers = [];
foreach(array_keys($correctBets) as $userid) {
$tiebreakers[$userid] = [-$correctBets[$userid], $totalBets[$userid], strtolower($usernames[$userid])];
}
asort($tiebreakers);
if (TwitterAuth::isLogged()) {
$userid = TwitterAuth::getUserId();
$userBets = Bet::find('userid = ? order by matchid desc', [$userid]);
$userpos = array_search($userid, array_keys($tiebreakers));
$userpos = ($userpos === FALSE) ? 0 : $userpos+1;
?>
<div class="inblock" style="text-align: left; margin-right: 20px">
<h2>Tus estadísticas</h2>
<table>
<thead>
<tr>
<td>Puesto</td>
<td>Nombre</td>
<td>Aciertos</td>
<td>Fallos</td>
</tr>
</thead>
<tr>
<td><?= $userpos ?>º</td>
<td style="text-align: left">
<div class="inblock" style="vertical-align: middle">
<a href="http://twitter.com/<?=htmlentities($usernames[$userid])?>" target="_blank">
<img src="<?= htmlentities($avatars[$userid]) ?>" style="width:40px; height:40px; border-radius: 20px">
</a>
</div>
<div class="inblock" style="vertical-align: middle">
<a href="http://twitter.com/<?=htmlentities($usernames[$userid])?>" target="_blank">
<?= htmlentities($usernames[$userid]) ?>
<? if (!isset($usernames[$userid])) echo "<i>$userid</i>"; ?>
</a>
</div>
</td>
<td><?= $correctBets[$userid] ?></td>
<td><?= $totalBets[$userid]-$correctBets[$userid] ?></td>
</tr>
</table>
<h2>Tus apuestas</h2>
<table>
<thead>
<tr>
<td>Jornada</td>
<td>Enfrentamiento</td>
<td>Acierto</td>
</tr>
</thead>
<? foreach($userBets as $bet) {
if (!isset($matches[$bet->matchid])) continue;
/**
* @var $match Match
*/
$match = $matches[$bet->matchid];
if (!$match->isPublished() || $match->isDelayed()) continue;
$team1 = $teams[$match->team1id];
//.........这里部分代码省略.........
示例11: getProfileAvatars
public static function getProfileAvatars(Profile $target)
{
$avatar = new Avatar();
$avatar->profile_id = $target->id;
if (!$avatar->find()) {
throw new NoAvatarException($target, $avatar);
}
return $avatar->fetchAll();
}