64 public function loadBox($max = 5, $cachedelay = 3600)
68 $langs->load(
"boxes");
74 if (!empty($this->paramdef)) {
75 $sql =
"SELECT value FROM ".MAIN_DB_PREFIX.
"const";
76 $sql .=
" WHERE name like '%SOCIAL_NETWORKS_DATA_".$this->db->escape($this->paramdef).
"%'";
78 $resql = $this->db->query($sql);
79 $num = $this->db->num_rows($resql);
81 $socialNetworkTitle =
'';
82 $socialNetworkUrl =
'';
85 $obj = $this->db->fetch_row($resql);
86 $socialNetworkData = json_decode($obj[0],
true);
87 $socialNetworkTitle = $socialNetworkData[
'title'];
88 $socialNetworkUrl = $socialNetworkData[
'url'];
90 foreach ($socialNetworkData as $key => $value) {
91 if ($key !==
'title' && $key !==
'url') {
92 $authParams[$key] = $value;
98 $path_fediverse = DOL_DATA_ROOT.
'/fediverse/temp/'.$socialNetworkTitle;
100 $result = $fediverseParser->fetchPosts($socialNetworkUrl, $this->max, $cachedelay, $path_fediverse);
102 $title = $langs->trans(
"BoxTitleLastFediverseInfos", $max,
dol_escape_htmltag($socialNetworkTitle));
103 if ($result < 0 || !empty($fediverseParser->error)) {
104 $errormessage = $langs->trans(
"FailedToRefreshDataInfoNotUpToDate", ($fediverseParser->getLastFetchDate() ?
dol_print_date($fediverseParser->getLastFetchDate(),
"dayhourtext") : $langs->trans(
"Unknown")));
105 if ($fediverseParser->error) {
106 $errormessage .=
" - ".$fediverseParser->error;
108 $title .=
" ".img_error($errormessage);
109 $this->info_box_head = array(
'text' => $title,
'limit' => 0);
111 $this->info_box_head = array(
113 'sublink' => $socialNetworkUrl,
114 'subtext' => $langs->trans(
"LastRefreshDate").
': '.($fediverseParser->getLastFetchDate() ?
dol_print_date($fediverseParser->getLastFetchDate(),
"dayhourtext") : $langs->trans(
"Unknown")),
115 'subpicto' =>
'globe',
116 'target' =>
'_blank',
120 $posts = $fediverseParser->getPosts();
122 $nbitems = count($posts);
124 for ($line = 0; $line < $max && $line < $nbitems; $line++) {
125 $post = $posts[$line];
131 $this->info_box_contents[$line][0] = array(
132 'td' =>
'class="left" width="16"',
135 'tooltip' => $tooltip,
136 'target' =>
'newfediverse',
139 $this->info_box_contents[$line][1] = array(
140 'td' =>
'class="tdoverflowmax300"',
143 'tooltip' => $tooltip,
145 'target' =>
'newfediverse',
148 $this->info_box_contents[$line][2] = array(
149 'td' =>
'class="right nowraponall"',