droctoganapus86
New Member
- Messages
- 49
- Reaction score
- 0
- Points
- 0
I have made a script, but it has become so big, that i want to convert it to a class. But I really don't understand how that works with variables and functions.
Basically: How do i make a class out of this?
I have this code :
also, if anyone has suggestions to make this better than you're welcome :smile:
Basically: How do i make a class out of this?
I have this code :
PHP:
<div id="fb-root">
<?php
echo $fb->status;
if ($fbuser):
foreach ($fbhome['data'] as $mkey => $mvalue):
$href = $fbhome['data'][$mkey]['from']['id'];
$name = $fbhome['data'][$mkey]['from']['name'];
$message = $fbhome['data'][$mkey]['message'];
$comments = $fbhome['data'][$mkey]['comments'];
$appname = $fbhome['data'][$mkey]['application']['name'];
$action = $fbhome['data'][$mkey]['actions'][0]['link'];
$likes = $fbhome['data'][$mkey]['likes']
#$date = new datemaker($fbhome['data'][$mkey]['created_time']);
?>
<div class="post">
<a href="http://www.facebook.com/profile.php?id=<?php echo $href; ?>"><?php echo $name; ?></a>
<span class="message">
<?php echo $message;?>
</span>
<span class="links">
<?php if (isset($appname)):
echo $appname;
?>
·
<?php endif; ?>
<a href="<?php echo $action; ?>">Like</a> ·
<a href="<?php echo $action; ?>">Comment</a>
</span>
<ul class="comment">
<?php if (isset($comments['data']) || isset($likes)): ?>
<li class="arrow"> </li>
<?php endif; ?>
<?php if (isset ($likes)): ?>
<li class="links">
<?php if (count($likes['data']) == 1): ?>
<a href="http://www.facebook.com/profile.php?id=<?php echo $likes['data'][0]['id']; ?>"><?php echo $likes['data'][0]['name']; ?></a>
<?if ($likes['count'] > 1): ?>
and <?php echo $likes['count']-1; ?> other like this.
<?php else: ?>
likes this.
<?php endif; ?>
<?php elseif(count($likes['data']) == 2) :
foreach ($likes['data'] as $lkey => $lvalue): ?>
<a href="http://www.facebook.com/profile.php?id=<?php echo $likes['data'][$lkey]['id']; ?>"><?php echo $likes['data'][$lkey]['name']; ?></a>,
<?php endforeach;
if ($likes['count'] > 2): ?>
and <?php echo $likes['count']-2;?> other
<?php endif; ?>
like this.
<?php endif;?>
</li>
<?php endif; ?>
<?php if (isset($comments['data'])):
if ($comments['count'] > 2):?>
<li class="links"><a href="<?php echo $action ?>">View all <?php echo $comments['count']; ?> comments</a></li>
<?php endif;
foreach ($comments['data'] as $ckey => $cvalue):?>
<li><a href="http://www.facebook.com/profile.php?id=<?php echo $comments['data'][$ckey]['from']['id']; ?>"><?php echo $comments['data'][$ckey]['from']['name']; ?></a>
<span><?php echo $comments['data'][$ckey]['message']; ?></span>
<?php endforeach;
endif; ?>
</ul>
</div>
<?php endforeach;
endif; ?>
</div>