api.taskbar.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. <?php
  2. /**
  3. * Taskbar loading and rendering class
  4. */
  5. class UbillingTaskbar {
  6. /**
  7. * Contains system alter config as key=>value
  8. *
  9. * @var array
  10. */
  11. protected $altCfg = array();
  12. /**
  13. * Contains system billing config as key=>value
  14. *
  15. * @var array
  16. */
  17. protected $billCfg = array();
  18. /**
  19. * Message helper object placeholder
  20. *
  21. * @var object
  22. */
  23. protected $messages = '';
  24. /**
  25. * Contains currently loaded categories as dir=>name
  26. *
  27. * @var array
  28. */
  29. protected $categories = array();
  30. /**
  31. * Contains available icon sizes as size=>name
  32. *
  33. * @var array
  34. */
  35. protected $iconSizes = array();
  36. /**
  37. * Contains current run alerts if available
  38. *
  39. * @var string
  40. */
  41. protected $currentAlerts = '';
  42. /**
  43. * Contains full list of loaded taskbar elements
  44. *
  45. * @var array
  46. */
  47. protected $loadedElements = array();
  48. /**
  49. * Taskbar elements rendered content
  50. *
  51. * @var string
  52. */
  53. protected $taskbarContent = '';
  54. /**
  55. * Contains current instance administrator login
  56. *
  57. * @var string
  58. */
  59. protected $myLogin = '';
  60. /**
  61. * Contains default taskbar elements path
  62. */
  63. const BASE_PATH = 'config/taskbar.d/';
  64. /**
  65. * Contains path to widgets code
  66. */
  67. const WIDGETS_CODEPATH = 'config/taskbar.d/widgets/';
  68. /**
  69. * Contains default module URL
  70. */
  71. const URL_ME = '?module=taskbar';
  72. /**
  73. * Some other predefined stuff
  74. */
  75. const ROUTE_WS = 'welcomescreen';
  76. const ROUTE_DISABLE_WS = 'disablewelcomescreen';
  77. /**
  78. * Creates new taskbar instance
  79. */
  80. public function __construct() {
  81. $this->loadConfigs();
  82. $this->initMessages();
  83. $this->setCategories();
  84. $this->setIconSizes();
  85. }
  86. /**
  87. * Loads system alter and billing configs into protected properties
  88. *
  89. * @global object $ubillingConfig
  90. *
  91. * @return void
  92. */
  93. protected function loadConfigs() {
  94. global $ubillingConfig;
  95. $this->altCfg = $ubillingConfig->getAlter();
  96. $this->billCfg = $ubillingConfig->getBilling();
  97. }
  98. /**
  99. * Inits system message helper object
  100. *
  101. * @return void
  102. */
  103. protected function initMessages() {
  104. $this->messages = new UbillingMessageHelper();
  105. }
  106. /**
  107. * Sets available taskbar element categories
  108. *
  109. * @return void
  110. */
  111. protected function setCategories() {
  112. $this->categories['widgets'] = '';
  113. $this->categories['iusers'] = __('Subscribers');
  114. $this->categories['instruments'] = __('Instruments');
  115. $this->categories['equipment'] = __('Equipment');
  116. $this->categories['maps'] = __('Maps');
  117. $this->categories['reports'] = __('Reports');
  118. $this->categories['directories'] = __('Directories');
  119. $this->categories['system'] = __('System');
  120. }
  121. /**
  122. * Sets available icon sizes
  123. *
  124. * @return void
  125. */
  126. protected function setIconSizes() {
  127. $this->iconSizes = array(
  128. '128' => __('Normal icons'),
  129. '96' => __('Lesser'),
  130. '64' => __('Macro'),
  131. '48' => __('Micro'),
  132. '32' => __('Nano')
  133. );
  134. }
  135. /**
  136. * Sets current administrators login into protected prof for further usage
  137. *
  138. * @return void
  139. */
  140. protected function setLogin() {
  141. $this->myLogin = whoami();
  142. }
  143. /**
  144. * Renders taskbar icon element
  145. *
  146. * @param string $url
  147. * @param string $elementName
  148. * @param string $elementIcon
  149. * @param string $elementTarget
  150. *
  151. * @return string
  152. */
  153. protected function renderIconElement($url, $elementName, $elementIcon, $elementTarget = '') {
  154. $result = '';
  155. $name = __($elementName);
  156. $iconPath = CUR_SKIN_PATH . 'taskbar/';
  157. $icon = $iconPath . $elementIcon;
  158. $elemQsId = 'ubtbelcont_' . $name . '_' . $elementName;
  159. $linkOpts = '';
  160. if (!empty($elementTarget)) {
  161. $linkOpts .= 'target="' . $elementTarget . '"';
  162. }
  163. if (!file_exists($icon)) {
  164. $icon = 'skins/taskbar/' . $elementIcon;
  165. }
  166. if (isset($_COOKIE['tb_iconsize'])) {
  167. //is icon customize enabled?
  168. if ($this->altCfg['TB_ICONCUSTOMSIZE']) {
  169. $iconsize = vf($_COOKIE['tb_iconsize'], 3);
  170. } else {
  171. $iconsize = $this->billCfg['TASKBAR_ICON_SIZE'];
  172. }
  173. } else {
  174. $iconsize = $this->billCfg['TASKBAR_ICON_SIZE'];
  175. }
  176. if ($this->altCfg['TB_LABELED']) {
  177. if ($iconsize > 63) {
  178. $result = '<div class="dashtask" id="' . $elemQsId . '" style="height:' . ($iconsize + 30) . 'px; width:' . ($iconsize + 30) . 'px;"> <a href="' . $url . '" ' . $linkOpts . '><img src="' . $icon . '" border="0" width="' . $iconsize . '" height="' . $iconsize . '" alt="' . $name . '" title="' . $name . '"></a> <br><br>' . $name . ' </div>';
  179. } else {
  180. $result = '<div class="dashtask" id="' . $elemQsId . '" style="height:' . ($iconsize + 10) . 'px; width:' . ($iconsize + 10) . 'px;"> <a href="' . $url . '" ' . $linkOpts . '><img src="' . $icon . '" border="0" width="' . $iconsize . '" height="' . $iconsize . '" alt="' . $name . '" title="' . $name . '"></a></div>';
  181. }
  182. } else {
  183. $result = '<a href="' . $url . '" ' . $linkOpts . '><img src="' . $icon . '" border="0" width="' . $iconsize . '" height="' . $iconsize . '" alt="' . $name . '" title="' . $name . '"></a><img src="skins/taskbar/spacer.gif"> ';
  184. }
  185. return ($result);
  186. }
  187. /**
  188. * Checks element required rights, options and returns element content
  189. *
  190. * @param array $elementData
  191. *
  192. * @return string
  193. */
  194. protected function buildElement($elementData) {
  195. $result = '';
  196. $elementId = (isset($elementData['ID'])) ? $elementData['ID'] : '';
  197. $elementType = (!empty($elementData['TYPE'])) ? $elementData['TYPE'] : '';
  198. //basic taskbar icon
  199. if ($elementType == 'icon') {
  200. $accesCheck = false;
  201. $elementRight = (!empty($elementData['NEED_RIGHT'])) ? $elementData['NEED_RIGHT'] : '';
  202. if (!empty($elementRight)) {
  203. if (cfr($elementRight)) {
  204. $accesCheck = true;
  205. }
  206. } else {
  207. $accesCheck = true;
  208. }
  209. //basic rights check
  210. if ($accesCheck) {
  211. $elementOption = (!empty($elementData['NEED_OPTION'])) ? $elementData['NEED_OPTION'] : '';
  212. $optionCheck = false;
  213. if (!empty($elementOption)) {
  214. if (isset($this->altCfg[$elementOption])) {
  215. if ($this->altCfg[$elementOption]) {
  216. $optionCheck = true;
  217. }
  218. } else {
  219. if (!isset($elementData['UNIMPORTANT'])) {
  220. $this->currentAlerts .= $this->messages->getStyledMessage(__('Missed config option') . ': ' . $elementOption . ' ' . __('required by') . ' ' . $elementId, 'error');
  221. }
  222. }
  223. } else {
  224. $optionCheck = true;
  225. }
  226. if ($optionCheck) {
  227. $elementName = (!empty($elementData['NAME'])) ? $elementData['NAME'] : '';
  228. $elementUrl = (!empty($elementData['URL'])) ? $elementData['URL'] : '';
  229. $elementIcon = (!empty($elementData['ICON'])) ? $elementData['ICON'] : '';
  230. $elementTarget = (!empty($elementData['LINK_TARGET'])) ? $elementData['LINK_TARGET'] : '';
  231. $result .= $this->renderIconElement($elementUrl, $elementName, $elementIcon, $elementTarget);
  232. }
  233. }
  234. }
  235. //widgets loading
  236. if ($elementType == 'widget') {
  237. $accesCheck = false;
  238. $elementRight = (!empty($elementData['NEED_RIGHT'])) ? $elementData['NEED_RIGHT'] : '';
  239. if (!empty($elementRight)) {
  240. if (cfr($elementRight)) {
  241. $accesCheck = true;
  242. }
  243. } else {
  244. $accesCheck = true;
  245. }
  246. //basic rights check
  247. if ($accesCheck) {
  248. $elementOption = (!empty($elementData['NEED_OPTION'])) ? $elementData['NEED_OPTION'] : '';
  249. $optionCheck = false;
  250. if (!empty($elementOption)) {
  251. if (isset($this->altCfg[$elementOption])) {
  252. if ($this->altCfg[$elementOption]) {
  253. $optionCheck = true;
  254. }
  255. } else {
  256. if (!isset($elementData['UNIMPORTANT'])) {
  257. $this->currentAlerts .= $this->messages->getStyledMessage(__('Missed config option') . ': ' . $elementOption . ' ' . __('required by') . ' ' . $elementId, 'error');
  258. }
  259. }
  260. } else {
  261. $optionCheck = true;
  262. }
  263. /**
  264. * It's gonna take a lot to drag me away from you
  265. * There's nothing that a hundred men or more could ever do
  266. * I bless the rains down in Africa
  267. * Gonna take some time to do the things we never had
  268. */
  269. if ($optionCheck) {
  270. //run widget code
  271. if (isset($elementData['CODEFILE'])) {
  272. if (file_exists(self::WIDGETS_CODEPATH . $elementData['CODEFILE'])) {
  273. require_once(self::WIDGETS_CODEPATH . $elementData['CODEFILE']);
  274. if (class_exists($elementData['ID'])) {
  275. $widget = new $elementData['ID']();
  276. $result .= $widget->render();
  277. } else {
  278. $this->currentAlerts .= $this->messages->getStyledMessage(__('Widget class not exists') . ': ' . $elementData['ID'], 'error');
  279. }
  280. } else {
  281. $this->currentAlerts .= $this->messages->getStyledMessage(__('File not exist') . ': ' . self::WIDGETS_CODEPATH . $elementData['CODEFILE'], 'warning');
  282. }
  283. } else {
  284. $this->currentAlerts .= $this->messages->getStyledMessage(__('Wrong element format') . ': ' . $elementData['ID'], 'warning');
  285. }
  286. }
  287. }
  288. }
  289. return ($result);
  290. }
  291. /**
  292. * Loads and returns category taskbar elements
  293. *
  294. * @param string $category
  295. *
  296. * @return string
  297. */
  298. protected function loadCategoryElements($category) {
  299. $result = '';
  300. $elementsPath = self::BASE_PATH . $category . '/';
  301. $allElements = rcms_scandir($elementsPath, '*.ini');
  302. $categoryContent = '';
  303. if (!empty($allElements)) {
  304. $categoryName = (isset($this->categories[$category])) ? $this->categories[$category] : '';
  305. foreach ($allElements as $io => $eachfilename) {
  306. $elementData = parse_ini_file($elementsPath . $eachfilename);
  307. if ((isset($elementData['TYPE'])) and (isset($elementData['ID']))) {
  308. if (!isset($this->loadedElements[$elementData['ID']])) {
  309. $this->loadedElements[$elementData['ID']] = $elementData;
  310. $categoryContent .= $this->buildElement($elementData);
  311. } else {
  312. $this->currentAlerts .= $this->messages->getStyledMessage(__('Duplicate element ID') . ': ' . $elementData['ID'] . ' -> ' . $eachfilename, 'warning');
  313. }
  314. } else {
  315. $this->currentAlerts .= $this->messages->getStyledMessage(__('Wrong element format') . ': ' . $eachfilename, 'warning');
  316. }
  317. }
  318. //injecting optional ReportMaster reports here
  319. if ($category == 'reports') {
  320. if (@$this->altCfg['TB_REPORTMASTER']) {
  321. $reportMaster = new ReportMaster();
  322. $availableReports = $reportMaster->getTaskBarReports();
  323. if (!empty($availableReports)) {
  324. foreach ($availableReports as $eachReportId => $eachReportElement) {
  325. $categoryContent .= $this->buildElement($eachReportElement);
  326. }
  327. }
  328. }
  329. }
  330. if (!empty($categoryContent)) {
  331. $result .= wf_tag('p') . wf_tag('h3') . wf_tag('u') . $categoryName . wf_tag('u', true) . wf_tag('h3', true) . wf_tag('p', true);
  332. $result .= wf_tag('div', false, 'dashboard');
  333. $result .= $categoryContent;
  334. $result .= wf_tag('div', true);
  335. $result .= wf_CleanDiv();
  336. }
  337. }
  338. return ($result);
  339. }
  340. /**
  341. * Loads and try to render all of available taskbar categories
  342. *
  343. * @return string
  344. */
  345. protected function loadAllCategories() {
  346. $result = '';
  347. if (!empty($this->categories)) {
  348. foreach ($this->categories as $category => $categoryname) {
  349. $result .= $this->loadCategoryElements($category);
  350. }
  351. }
  352. return ($result);
  353. }
  354. /**
  355. * Returns icon resize form if enabled
  356. *
  357. * @return string
  358. */
  359. protected function renderResizeForm() {
  360. $result = '';
  361. if ($this->altCfg['TB_ICONCUSTOMSIZE']) {
  362. if (isset($_COOKIE['tb_iconsize'])) {
  363. $currentsize = vf($_COOKIE['tb_iconsize'], 3);
  364. } else {
  365. $currentsize = $this->billCfg['TASKBAR_ICON_SIZE'];
  366. }
  367. $resizeinputs = wf_SelectorAC('iconsize', $this->iconSizes, '', $currentsize, false);
  368. $result .= wf_tag('br');
  369. $result .= wf_Form('', 'POST', $resizeinputs);
  370. }
  371. return ($result);
  372. }
  373. /**
  374. * Catches and applies icon resize event
  375. *
  376. * @return void
  377. */
  378. protected function catchIconsizeChange() {
  379. if (isset($_POST['iconsize'])) {
  380. $iconsize = vf($_POST['iconsize'], 3);
  381. setcookie("tb_iconsize", $iconsize, time() + 2592000);
  382. rcms_redirect(self::URL_ME);
  383. }
  384. }
  385. /**
  386. * Returs available sticky notes if enabled
  387. *
  388. * @return string
  389. */
  390. protected function loadStickyNotes() {
  391. $result = '';
  392. if (isset($this->altCfg['STICKY_NOTES_ENABLED'])) {
  393. if ($this->altCfg['STICKY_NOTES_ENABLED']) {
  394. $stickyNotes = new StickyNotes(true);
  395. $result = $stickyNotes->renderTaskbarNotify();
  396. }
  397. }
  398. return ($result);
  399. }
  400. /**
  401. * Checks for default password usage, etc.
  402. *
  403. * @return void
  404. */
  405. protected function checkSecurity() {
  406. if (@!$this->altCfg['TB_DISABLE_SECURITY_CHECK']) {
  407. global $system;
  408. $controlLogin = 'admin';
  409. $badPasswords = file_get_contents(DATA_PATH . 'shitpass.dat');
  410. $badPasswords = trim($badPasswords);
  411. $badPasswords = explodeRows($badPasswords);
  412. $defaultPassOffset = 0;
  413. if (isset($_COOKIE['ubilling_user'])) {
  414. if (!file_exists('DEMO_MODE') and !file_exists('exports/FIRST_INSTALL')) {
  415. //am i using default account?
  416. if ($_COOKIE['ubilling_user'] == $controlLogin . ':' . $badPasswords[$defaultPassOffset]) {
  417. $notice = __('You are using the default login and password') . '. ' . __('Dont do this') . '.';
  418. // ugly hack to prevent elements autofocusing
  419. $label = wf_TextInput('dontfocusonlinks', '', '', false, '', '', '', '', 'style="width: 0; height: 0; top: -100px; position: absolute;"');
  420. $label .= wf_tag('div', false, '', 'style="min-width:550px;"') . $this->messages->getStyledMessage($notice, 'error') . wf_tag('div', true);
  421. $label .= wf_tag('br');
  422. $imagesPath = 'skins/changepass/';
  423. $allImgs = rcms_scandir($imagesPath);
  424. if (!empty($allImgs)) {
  425. $imageRnd = array_rand($allImgs);
  426. $randomImage = $allImgs[$imageRnd];
  427. $label .= wf_tag('center') . wf_img_sized($imagesPath . $randomImage, '', '', '300') . wf_tag('center' . true);
  428. $label .= wf_delimiter(1);
  429. }
  430. $label .= wf_Link('?module=adminreg&editadministrator=admin', __('Change admin user password'), true, 'confirmagree');
  431. $this->currentAlerts .= wf_modalOpenedAuto(__('Oh no') . '!' . ' ' . __('Danger') . '!', $label);
  432. } else {
  433. //fast check for few shitty passwords
  434. if (file_exists(USERS_PATH . $controlLogin)) {
  435. $adminData = $system->getUserData($controlLogin);
  436. if (!empty($adminData)) {
  437. $adminHash = trim($adminData['password']);
  438. foreach ($badPasswords as $passIdx => $eachHash) {
  439. if (!empty($eachHash)) {
  440. $eachHash = trim($eachHash);
  441. if (strpos($adminHash, $eachHash) !== false) {
  442. $this->currentAlerts .= $this->messages->getStyledMessage(__('For administrator') . ' «' . $controlLogin . '» ' . __('a very fucked up password is used') . '. ' . __('Dont do this') . '.', 'error');
  443. }
  444. }
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. }
  452. }
  453. /**
  454. * Renders some welcome screen for newly installed Ubilling
  455. *
  456. * @return void
  457. */
  458. protected function renderWelcome() {
  459. if (@!$this->altCfg['TB_DISABLE_WELCOME_SCREEN']) {
  460. $newInstallFlag = 'exports/FIRST_INSTALL';
  461. if (!ubRouting::checkGet(self::ROUTE_DISABLE_WS)) {
  462. if (file_exists($newInstallFlag) or ubRouting::checkGet(self::ROUTE_WS)) {
  463. $urlsList = array(
  464. 'https://ubilling.net.ua/rds/defense/' => __('Donate to Armed Forces of Ukraine'),
  465. 'https://wiki.ubilling.net.ua/' => __('Read documentation'),
  466. '?module=adminreg&editadministrator=admin' => __('Change admin user password'),
  467. 'https://t.me/ubilling' => __('Join our community chat'),
  468. );
  469. //render content
  470. $welcomeLabel = '<!--ugly hack to prevent elements autofocusing --> <input type="text" name="dontfocusonlinks" style="width: 0; height: 0; top: -100px; position: absolute;"/>';
  471. $welcomeLabel .= wf_tag('h2') . __('Welcome to your new billing system') . '!' . wf_tag('h2', true);
  472. $welcomeLabel .= __('On behalf of the development team and everyone involved in the project, we would like to thank you for choosing Ubilling.');
  473. $welcomeLabel .= wf_tag('br');
  474. $welcomeLabel .= __('We hope you enjoy using it as much as we enjoyed working on it.');
  475. $welcomeLabel .= wf_delimiter(1);
  476. $welcomeLabel .= __('Here`s what you should do first') . ':';
  477. if (!empty($urlsList)) {
  478. $welcomeLabel .= wf_tag('ul');
  479. foreach ($urlsList as $eachUrl => $eachLabel) {
  480. $welcomeLabel .= wf_tag('li') . wf_Link($eachUrl, $eachLabel, false, '', 'target="_BLANK"') . wf_tag('li', true);
  481. }
  482. $welcomeLabel .= wf_tag('ul', true);
  483. }
  484. if (file_exists($newInstallFlag)) {
  485. $welcomeLabel .= wf_Link(self::URL_ME . '&' . self::ROUTE_DISABLE_WS . '=true', wf_img('skins/hide16.png') . ' ' . __('Dont show me this anymore'), true, 'ubButton');
  486. }
  487. $this->currentAlerts .= wf_modalOpenedAuto(__('Welcome to Ubilling') . '!', $welcomeLabel);
  488. }
  489. } else {
  490. @unlink($newInstallFlag);
  491. if (file_exists($newInstallFlag)) {
  492. log_register('WELCOME DISABLE FAIL');
  493. }
  494. ubRouting::nav(self::URL_ME);
  495. }
  496. }
  497. }
  498. /**
  499. * Renders administrators announcements if some unread is present/sets read some of them
  500. *
  501. * @return string
  502. */
  503. protected function loadAnnouncements() {
  504. $result = '';
  505. if (isset($this->altCfg['ANNOUNCEMENTS'])) {
  506. if ($this->altCfg['ANNOUNCEMENTS']) {
  507. $admAnnouncements = new AdminAnnouncements();
  508. if (wf_CheckGet(array('setacquainted'))) {
  509. $admAnnouncements->setAcquainted($_GET['setacquainted']);
  510. rcms_redirect(self::URL_ME);
  511. }
  512. $result .= $admAnnouncements->showAnnouncements();
  513. }
  514. }
  515. return ($result);
  516. }
  517. /**
  518. * Renders administrators voting poll form
  519. *
  520. * @return string
  521. */
  522. protected function loadPollVoteAdmin() {
  523. $result = '';
  524. if (isset($this->altCfg['POLLS_ENABLED'])) {
  525. if ($this->altCfg['POLLS_ENABLED']) {
  526. $poll = new PollVoteAdmin();
  527. if (wf_CheckPost(array('vote', 'poll_id'))) {
  528. $poll->createAdminVoteOnDB(vf($_POST['vote'], 3), vf($_POST['poll_id'], 3));
  529. }
  530. $result .= $poll->renderVotingForm();
  531. }
  532. }
  533. return ($result);
  534. }
  535. /**
  536. * Returns touch devices hotfix for draggable and other JQuery UI things
  537. *
  538. * @return string
  539. */
  540. protected function loadTouchFix() {
  541. $result = '';
  542. if (@$this->altCfg['TOUCH_FIX']) {
  543. $result .= '<!-- jQuery UI Touch Punch -->';
  544. $result .= wf_tag('script', false, '', 'type="text/javascript" language="javascript" src="modules/jsc/jquery.ui.touch-punch.min.js"');
  545. $result .= wf_tag('script', true);
  546. }
  547. return ($result);
  548. }
  549. /**
  550. * Renders the search form and frontend controller for taskbar elements
  551. *
  552. * @return string
  553. */
  554. protected function renderQuickSearchForm() {
  555. $result = '';
  556. if (@$this->altCfg['TB_QUICKSEARCH_ENABLED']) {
  557. $result .= web_TaskBarQuickSearchForm();
  558. }
  559. return ($result);
  560. }
  561. /**
  562. * Renders quick search form as modal dialog
  563. *
  564. * @return string
  565. */
  566. public function renderQuickSearchModal() {
  567. $result = '';
  568. if (@$this->altCfg['TB_QUICKSEARCH_ENABLED'] and !@$this->altCfg['TB_QUICKSEARCH_INLINE']) {
  569. $result .= ' ' . wf_modalAuto(web_icon_search(), __('Search'), $this->renderQuickSearchForm());
  570. }
  571. return ($result);
  572. }
  573. /**
  574. * Returns rendered taskbar elements and services content
  575. *
  576. * @return string
  577. */
  578. public function renderTaskbar() {
  579. $result = '';
  580. $this->checkSecurity();
  581. $this->renderWelcome();
  582. $this->catchIconsizeChange();
  583. $this->taskbarContent = $this->loadAllCategories();
  584. if (!empty($this->currentAlerts)) {
  585. $result .= $this->currentAlerts;
  586. }
  587. if (@$this->altCfg['TB_QUICKSEARCH_INLINE'] == 2) {
  588. $result .= $this->renderQuickSearchForm();
  589. }
  590. $result .= wf_AjaxContainer('ubtbqsstatus');
  591. $result .= $this->taskbarContent;
  592. $result .= $this->renderResizeForm();
  593. $result .= $this->loadStickyNotes();
  594. $result .= $this->loadAnnouncements();
  595. $result .= $this->loadPollVoteAdmin();
  596. $result .= $this->loadTouchFix();
  597. return ($result);
  598. }
  599. }
  600. /**
  601. * Basic taskbar widgets class.
  602. */
  603. class TaskbarWidget {
  604. /**
  605. * Creates new instance of taskbar widget
  606. */
  607. public function __construct() {
  608. }
  609. /**
  610. * Returns content in default taskbar dashtask coontainer
  611. *
  612. * @param string $content
  613. * @param string $options
  614. *
  615. * @return string
  616. */
  617. protected function widgetContainer($content, $options = '') {
  618. $result = wf_tag('div', false, 'dashtask', $options);
  619. $result .= $content;
  620. $result .= wf_tag('div', true);
  621. return ($result);
  622. }
  623. /**
  624. * Returns result that directly embeds into taskbar
  625. *
  626. * @return string
  627. */
  628. public function render() {
  629. $result = 'EMPTY_WIDGET';
  630. return ($result);
  631. }
  632. }