Skip to content

Commit

Permalink
added get*() methods to get the current values
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Aug 15, 2015
1 parent 6fe5da1 commit 9b9c7ae
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 119 deletions.
236 changes: 118 additions & 118 deletions demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,70 @@

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

<title>Social Links</title>

<meta name="viewport" content="width=device-width, initial-scale=1">

<style type="text/css">
body {
max-width: 600px;
margin: 0 auto;
padding: 20px;
font-family: Arial, sans-serif;
}
table {
text-align: left;
border-collapse:collapse;
width: 100%;
}
td, th {
padding: 10px;
border-bottom: solid 1px #DCDCDC;
}
tr:first-child td, tr:first-child th {
border-top: solid 1px #DCDCDC;
}
form {
background: #DCDCDC;
padding: 16px;
margin-top: 30px;
border-radius: 2px;
}
label {
display: block;
padding: 5px 0;
}
label input {
width: calc(100% - 110px);
padding: 0.3em;
box-sizing: border-box;
}
label strong {
display: inline-block;
width: 100px;
margin-right: 10px;
}
input[type="submit"] {
margin-left: 110px;
margin-top: 10px;
}
pre {
background: #DCDCDC;
overflow-x: auto;
padding: 16px;
}
</style>
</head>

<body>
<h1>Social links</h1>

<?php if ($data['url']): ?>

<?php
<head>
<meta charset="utf-8">

<title>Social Links</title>

<meta name="viewport" content="width=device-width, initial-scale=1">

<style type="text/css">
body {
max-width: 600px;
margin: 0 auto;
padding: 20px;
font-family: Arial, sans-serif;
}
table {
text-align: left;
border-collapse:collapse;
width: 100%;
}
td, th {
padding: 10px;
border-bottom: solid 1px #DCDCDC;
}
tr:first-child td, tr:first-child th {
border-top: solid 1px #DCDCDC;
}
form {
background: #DCDCDC;
padding: 16px;
margin-top: 30px;
border-radius: 2px;
}
label {
display: block;
padding: 5px 0;
}
label input {
width: calc(100% - 110px);
padding: 0.3em;
box-sizing: border-box;
}
label strong {
display: inline-block;
width: 100px;
margin-right: 10px;
}
input[type="submit"] {
margin-left: 110px;
margin-top: 10px;
}
pre {
background: #DCDCDC;
overflow-x: auto;
padding: 16px;
}
</style>
</head>

<body>
<h1>Social links</h1>

<?php if ($data['url']): ?>

<?php
$page = new Page($data);
$providers = array(
'twitter',
Expand All @@ -96,58 +96,58 @@
);
?>

<table>
<?php foreach ($providers as $name): ?>
<?php $provider = $page->$name; ?>

<tr>
<th><?php echo ucfirst($name); ?></th>
<td><?php echo $provider->shareCount === null ? 'not available' : $provider->shareCount; ?></td>
<td>
<?php echo $provider->shareUrl ? "<a href='{$provider->shareUrl}'>Share</a>" : 'Cannot be shared'; ?>
</td>
</tr>
<?php endforeach ?>
</table>

<pre><code><?php
foreach ($page->html() as $tag) {
echo htmlspecialchars($tag)."\n";
}
echo "\n";
foreach ($page->openGraph() as $tag) {
echo htmlspecialchars($tag)."\n";
}
echo "\n";
foreach ($page->twitterCard() as $tag) {
echo htmlspecialchars($tag)."\n";
}
?></code></pre>

<?php endif; ?>

<form>
<label>
<strong>Url: </strong><input type="url" name="url" value="<?php echo $data['url']; ?>" required>
</label>
<label>
<strong>Title: </strong><input type="text" name="title" value="<?php echo $data['title']; ?>">
</label>
<label>
<strong>Text: </strong><input type="text" name="text" value="<?php echo $data['text']; ?>">
</label>
<label>
<strong>Image: </strong><input type="url" name="image" value="<?php echo $data['image']; ?>">
</label>
<label>
<strong>Twitter user: </strong><input type="text" name="twitterUser" value="<?php echo $data['twitterUser']; ?>">
</label>

<input type="submit" value="Send">
</form>

<footer>
<p><a href="https://github.com/oscarotero/social-links">View in github</a></p>
</footer>
</body>
<table>
<?php foreach ($providers as $name): ?>
<?php $provider = $page->$name; ?>

<tr>
<th><?php echo ucfirst($name); ?></th>
<td><?php echo $provider->shareCount === null ? 'not available' : $provider->shareCount; ?></td>
<td>
<?php echo $provider->shareUrl ? "<a href='{$provider->shareUrl}'>Share</a>" : 'Cannot be shared'; ?>
</td>
</tr>
<?php endforeach ?>
</table>

<pre><code><?php
foreach ($page->html() as $tag) {
echo htmlspecialchars($tag)."\n";
}
echo "\n";
foreach ($page->openGraph() as $tag) {
echo htmlspecialchars($tag)."\n";
}
echo "\n";
foreach ($page->twitterCard() as $tag) {
echo htmlspecialchars($tag)."\n";
}
?></code></pre>

<?php endif; ?>

<form>
<label>
<strong>Url: </strong><input type="url" name="url" value="<?php echo $data['url']; ?>" required>
</label>
<label>
<strong>Title: </strong><input type="text" name="title" value="<?php echo $data['title']; ?>">
</label>
<label>
<strong>Text: </strong><input type="text" name="text" value="<?php echo $data['text']; ?>">
</label>
<label>
<strong>Image: </strong><input type="url" name="image" value="<?php echo $data['image']; ?>">
</label>
<label>
<strong>Twitter user: </strong><input type="text" name="twitterUser" value="<?php echo $data['twitterUser']; ?>">
</label>

<input type="submit" value="Send">
</form>

<footer>
<p><a href="https://github.com/oscarotero/social-links">View in github</a></p>
</footer>
</body>
</html>
42 changes: 41 additions & 1 deletion src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,53 @@ public function __call($key, $arguments)
/**
* Gets the page url.
*
* @return string
* @return string|null
*/
public function getUrl()
{
return $this->info['url'];
}

/**
* Gets the page title.
*
* @return string|null
*/
public function getTitle()
{
return $this->info['title'];
}

/**
* Gets the page text description.
*
* @return string|null
*/
public function getText()
{
return $this->info['text'];
}

/**
* Gets the page image.
*
* @return string|null
*/
public function getImage()
{
return $this->info['image'];
}

/**
* Gets the page twitterUser.
*
* @return string|null
*/
public function getTwitterUser()
{
return $this->info['twitterUser'];
}

/**
* Gets some page info.
*
Expand Down

0 comments on commit 9b9c7ae

Please sign in to comment.