62 public function loadBox($max = 5, $cachedelay = 3600)
65 $langs->load(
"boxes");
71 if (!empty($this->paramdef)) {
72 $sql =
"SELECT value FROM ".MAIN_DB_PREFIX.
"const";
73 $sql .=
" WHERE name like '%SOCIAL_NETWORKS_DATA_".$this->db->escape($this->paramdef).
"%'";
75 $resql = $this->db->query($sql);
76 $num = $this->db->num_rows($resql);
78 $socialNetworkTitle =
'';
79 $socialNetworkUrl =
'';
82 $obj = $this->db->fetch_row($resql);
83 $socialNetworkData = json_decode($obj[0],
true);
84 $socialNetworkTitle = $socialNetworkData[
'title'];
85 $socialNetworkUrl = $socialNetworkData[
'url'];
87 foreach ($socialNetworkData as $key => $value) {
88 if ($key !==
'title' && $key !==
'url') {
89 $authParams[$key] = $value;
95 $path_fediverse = DOL_DATA_ROOT.
'/fediverse/temp/'.$socialNetworkTitle;
97 $result = $fediverseParser->fetchPosts($socialNetworkUrl, $this->max, $cachedelay, $path_fediverse);
99 $title = $langs->trans(
"BoxTitleLastFediverseInfos", $max,
dol_escape_htmltag($socialNetworkTitle));
100 if ($result < 0 || !empty($fediverseParser->error)) {
101 $errormessage = $langs->trans(
"FailedToRefreshDataInfoNotUpToDate", ($fediverseParser->getLastFetchDate() ?
dol_print_date($fediverseParser->getLastFetchDate(),
"dayhourtext") : $langs->trans(
"Unknown")));
102 if ($fediverseParser->error) {
103 $errormessage .=
" - ".$fediverseParser->error;
105 $title .=
" ".img_error($errormessage);
106 $this->info_box_head = array(
'text' => $title,
'limit' => 0);
108 $this->info_box_head = array(
110 'sublink' => $socialNetworkUrl,
111 'subtext' => $langs->trans(
"LastRefreshDate").
': '.($fediverseParser->getLastFetchDate() ?
dol_print_date($fediverseParser->getLastFetchDate(),
"dayhourtext") : $langs->trans(
"Unknown")),
112 'subpicto' =>
'globe',
113 'target' =>
'_blank',
117 $posts = $fediverseParser->getPosts();
118 $nbitems = count($posts);
120 for ($line = 0; $line < $max && $line < $nbitems; $line++) {
121 $post = $posts[$line];
127 $this->info_box_contents[$line][0] = array(
128 'td' =>
'class="left" width="16"',
131 'tooltip' => $tooltip,
132 'target' =>
'newfediverse',
135 $this->info_box_contents[$line][1] = array(
136 'td' =>
'class="tdoverflowmax300"',
139 'tooltip' => $tooltip,
141 'target' =>
'newfediverse',
144 $this->info_box_contents[$line][2] = array(
145 'td' =>
'class="right nowraponall"',