Skip to content
This repository has been archived by the owner on Jun 26, 2022. It is now read-only.

Commit

Permalink
Update to keywords, Sitepages show current hits and backlinks total
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Byrne authored and Alan Byrne committed Apr 25, 2020
1 parent 8c1e73e commit a58829c
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 41 deletions.
9 changes: 9 additions & 0 deletions src/Controller/KeywordsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function KeywordView($id, Request $request)

// Repos
$knotesrepo = $this->getDoctrine()->getRepository(KeywordsNotes::class);
$blrepo = $this->getDoctrine()->getRepository(Backlinks::class);

$keyword = $this->getDoctrine()->getRepository(Keywords::class)->find($id);
$site = $this->getDoctrine()->getRepository(Sites::class)->find($keyword->getSiteId());
Expand All @@ -46,12 +47,20 @@ public function KeywordView($id, Request $request)
$knotestasks = $knotesrepo->findBy(['keywordid' => $keyword->getId(), 'status' => 'Unread', 'type' => 'Task'], ['id' => 'DESC']);
$knotesissues = $knotesrepo->findBy(['keywordid' => $keyword->getId(), 'status' => 'Unread', 'type' => 'Issue'], ['id' => 'DESC']);

// Latest Backlinks
$backlinks = $blrepo->findBy(['keywordid' => $id],['id' => 'DESC'], $limit = 5);
# Count Backlinks
$getbl = $blrepo->findBy(['keywordid' => $id]);
$totalbacklinks = count($getbl);

return $this->render('keywords/view.html.twig',
[
'site' => $site,
'keyword' => $keyword,
'knotestasks' => $knotestasks,
'knotesissues' => $knotesissues,
'backlinks' => $backlinks,
'totalbacklinks' => $totalbacklinks,
]
);
}
Expand Down
24 changes: 24 additions & 0 deletions src/Controller/SitepagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use App\Entity\Sitepages;
use App\Entity\System\DataSettings;
use App\Entity\Notes\SitepagesNotes;
use App\Entity\Linktracking\TrackingUrls;
use App\Entity\Linktracking\TrackingCampaigns;
use App\Form\Sitepages\AddNoteType;

use Symfony\Component\HttpFoundation\JsonResponse;
Expand All @@ -38,6 +40,8 @@ public function SitepageView($id, Request $request)
}

$spnotesrepo = $this->getDoctrine()->getRepository(SitepagesNotes::class);
$blrepo = $this->getDoctrine()->getRepository(Backlinks::class);
$turls = $this->getDoctrine()->getRepository(TrackingUrls::class);

$spage = $this->getDoctrine()->getRepository(Sitepages::class)->find($id);
$site = $this->getDoctrine()->getRepository(Sites::class)->find($spage->getSiteId());
Expand All @@ -46,12 +50,32 @@ public function SitepageView($id, Request $request)
$spnotestasks = $spnotesrepo->findBy(['spageid' => $spage->getId(), 'status' => 'Unread', 'type' => 'Task'], ['id' => 'DESC']);
$spnotesissues = $spnotesrepo->findBy(['spageid' => $spage->getId(), 'status' => 'Unread', 'type' => 'Issue'], ['id' => 'DESC']);

// Latest Backlinks
$backlinks = $blrepo->findBy(['spageid' => $id],['id' => 'DESC'], $limit = 5);
# Count Backlinks
$getbl = $blrepo->findBy(['spageid' => $id]);
$totalbacklinks = count($getbl);

$pageturls = $turls->findBy(['spageid' => $id]);

$counthits = 0;
foreach ($pageturls as $key=>$value)
{
$counthits+= $value->getUrlHits();
}

$totalhits = $counthits;


return $this->render('sitepages/view.html.twig',
[
'site' => $site,
'spage' => $spage,
'spnotestasks' => $spnotestasks,
'spnotesissues' => $spnotesissues,
'backlinks' => $backlinks,
'totalbacklinks' => $totalbacklinks,
'totalhits' => $totalhits
]
);
}
Expand Down
37 changes: 35 additions & 2 deletions src/Controller/SitesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public function SiteKeywords($id, Request $request)
// Repos
$datasettings = $this->getDoctrine()->getRepository(DataSettings::class)->find(1);
$sitekeywords = $this->getDoctrine()->getRepository(Keywords::class);

$backlinks = $this->getDoctrine()->getRepository(Backlinks::class);

$site = $this->getDoctrine()->getRepository(Sites::class)->find($id);

Expand Down Expand Up @@ -391,6 +391,15 @@ public function SiteKeywords($id, Request $request)
if ($page){
$offset = ($page - 1) * $limit;
$sitekeywords = $sitekeywords->findBy(['siteid' => $id], ['id' => 'DESC'], $limit, $offset);

$countbls = 0;
foreach ($sitekeywords as $keyword)
{
$keywordid = $keyword->getId();
$getbls = $backlinks->findBy(['keywordid' => $keywordid]);
$countbls = count($getbls);
}
$totalbacklinks = $countbls;
}

// 2) handle the submit (will only happen on POST)
Expand Down Expand Up @@ -426,6 +435,7 @@ public function SiteKeywords($id, Request $request)
'nextpage' => $nextpage,
'maxpages' => $maxpages,
'form' => $form->createView(),
'totalbacklinks' => $totalbacklinks,
]
);
}
Expand All @@ -443,10 +453,12 @@ public function SitePages($id, Request $request)
// Repos
$datasettings = $this->getDoctrine()->getRepository(DataSettings::class)->find(1);
$sitepages = $this->getDoctrine()->getRepository(SitePages::class);
$backlinks = $this->getDoctrine()->getRepository(Backlinks::class);
$turls = $this->getDoctrine()->getRepository(TrackingUrls::class);

$site = $this->getDoctrine()->getRepository(Sites::class)->find($id);


// Paginition
$page = isset($_GET['page']) ? $_GET['page'] : "1";
$limit = $datasettings->getMaxPageRows();
Expand All @@ -468,6 +480,25 @@ public function SitePages($id, Request $request)
if ($page){
$offset = ($page - 1) * $limit;
$sitepages = $sitepages->findBy(['siteid' => $id], ['id' => 'DESC'], $limit, $offset);

$countbls = 0;
foreach ($sitepages as $page)
{
$pageid = $page->getId();
$getbls = $backlinks->findBy(['spageid' => $pageid]);
$countbls = count($getbls);

$pageturls = $turls->findBy(['spageid' => $pageid]);

$counthits = 0;
foreach ($pageturls as $key=>$value)
{
$counthits+= $value->getUrlHits();
}

$totalhits = $counthits;
}
$totalbacklinks = $countbls;
}

// 1) build the form
Expand Down Expand Up @@ -508,6 +539,8 @@ public function SitePages($id, Request $request)
'nextpage' => $nextpage,
'maxpages' => $maxpages,
'form' => $form->createView(),
'totalbacklinks' => $totalbacklinks,
'totalhits' => $totalhits,
]
);
}
Expand Down
66 changes: 48 additions & 18 deletions templates/keywords/view.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,57 @@
</div>
</div>
</div>
<div class="row mb-1">
<div class="col-6">
<h5 class="m-0 text-dark"></h5>
</div>
<div class="col-6">
<div class="float-sm-right">
<a href="#" class="btn btn-sm btn-dark">View All (coming soon)</a>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card card-dark">
<div class="card-header">
<h3 class="card-title">Extra Features Coming Soon</h3>
<h3 class="card-title">Latest Backlinks</h3>
</div>
<div class="card-body">
<p>
We are working out extra feature that will fill this space,
We are working hard to get as much features in as possible
</p>
<p>
Overtime this space will be filled with extra information as we build the system,
In the meantime if you have any ideas or suggestions please feel free to let us know and we will aim to implement them here
</p>
<div class="card-body p-0">
<table class="table table-sm table-hover text-nowrap">
<thead>
<tr>
<th>Backlink</th>
<th>Last Checked</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{% for a in backlinks %}
<tr>
<td>{{ a.backlink|slice(0,75) ~ '...' }}</td>
<td><div id="blastchecked-{{a.id}}">{% if a.lastchecked %}{{ a.lastchecked|date('d-m-Y / H:i') }}{% else %} Not Checked {% endif %}</div></td>
<td><span class="tag tag-success"><div id="bstatus-{{a.id}}">{{ a.status }}</div></span></td>
<td>
<a href="{{ path('backlink_view', {'id': a.id}) }}" class="btn btn-success btn-sm"><i class="fas fa-eye"></i></a>
<button class="btn btn-warning btn-sm" id="checkisactive-{{a.id}}"><div id="bspin-{{a.id}}"><i class="fas fa-sync"></i></div></button>
<button type="button" class="btn btn-sm btn-info" data-toggle="dropdown">
<i class="fas fa-link"></i>
</button>
<div class="dropdown-menu">
<div id="lostbutton">
<button class="dropdown-item" id="updatestatus-lost-{{a.id}}">Lost Backlink</button>
</div>
<div id="activebutton">
<button class="dropdown-item" id="updatestatus-active-{{a.id}}">Active Backlink</button>
</div>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
Expand All @@ -80,14 +116,8 @@
{{keyword.status}}
</b>
</p>
<p class="text">Backlinks (work in progress)
<b class="d-block">0</b>
</p>
<p class="text">Linked Pages (work in progress)
<b class="d-block">0</b>
</p>
<p class="text">Prospects Sites (work in progress)
<b class="d-block">0</b>
<p class="text">Backlinks
<b class="d-block">{{ totalbacklinks }}</b>
</p>
</div>
</div>
Expand Down
Loading

0 comments on commit a58829c

Please sign in to comment.