1: <?php
2:
3: 4: 5: 6: 7:
8:
9: namespace app\controllers;
10:
11: use \mako\http\routing\Controller;
12: use \mako\syringe\ContainerAwareTrait;
13: use app\models\Celebrity;
14: use app\models\Reference;
15:
16: 17: 18: 19: 20:
21: class ReferenceController extends Controller
22: {
23: use ContainerAwareTrait;
24:
25:
26:
27: private function getList($model)
28: {
29: $res = array();
30: $list = json_decode($model::select(['*'])->all());
31: if (!empty($list))
32: {
33:
34: foreach($list as $entry)
35: {
36: if (!empty($entry))
37: {
38:
39:
40: $res[$entry->title] = $entry->url;
41: }
42: }
43: }
44: asort($res);
45: $list = array();
46: foreach ($res as $key=>$value)
47: {
48: $list[] = array("url"=> $value, "title"=>$key);
49: }
50: if(count($list > 0))
51: {
52: $url = $list[0]["url"];
53: $list[0]["dublet"] = "";
54: for($ii = 1; $ii < count($list); $ii++)
55: {
56:
57: if($list[$ii]["url"] == $url)
58: {
59: $list[$ii]["dublet"] = "dublet";
60: $list[$ii-1]["dublet"] = "dublet";
61: }
62: else
63: {
64: $list[$ii]["dublet"] = "";
65: $url = $list[$ii]["url"];
66: }
67: }
68: }
69: return $list;
70: }
71:
72: public function getRefs()
73: {
74:
75: $model = new Reference();
76: $list = $this->getList($model);
77: return $this->view->render('references.references', array("list"=>$list));
78: }
79:
80: }
81: