PageRenderTime 50ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/FSN/mediatheque/zp-core/zp-extensions/tinymce4/plugins/tinyzenpage/tinyzenpage-functions.php

https://gitlab.com/r.collas/site_central
PHP | 680 lines | 552 code | 23 blank | 105 comment | 117 complexity | 00e273c72fb2f80a7002d3508d0ab346 MD5 | raw file
  1. <?php
  2. /**
  3. * tinyZenpage - A TinyMCE plugin for Zenphoto with Zenpage
  4. * @author Malte Müller (acrylian)
  5. * @license GPL v2
  6. */
  7. // sorry about all the inline css but something by TinyMCE's main css seems to override most setting on the css file no matter what I do...Too "lazy" for further investigation...:-)
  8. $host = "http://" . html_encode($_SERVER["HTTP_HOST"]);
  9. /**
  10. * Prints all albums of the Zenphoto gallery as a partial drop down menu (<option></option> parts).
  11. *
  12. * @return string
  13. */
  14. function printFullAlbumsList() {
  15. global $_zp_gallery;
  16. $albumlist = $_zp_gallery->getAlbums();
  17. foreach ($albumlist as $album) {
  18. $albumobj = newAlbum($album);
  19. if ($albumobj->isMyItem(LIST_RIGHTS)) {
  20. echo "<option value='" . pathurlencode($albumobj->name) . "'>" . html_encode($albumobj->getTitle()) . unpublishedZenphotoItemCheck($albumobj) . " (" . $albumobj->getNumImages() . ")</option>";
  21. if (!$albumobj->isDynamic()) {
  22. printSubLevelAlbums($albumobj);
  23. }
  24. }
  25. }
  26. }
  27. /**
  28. * Recursive helper function for printFullAlbumsList() to get all sub albums of each top level album
  29. *
  30. * @return string
  31. */
  32. function printSubLevelAlbums(&$albumobj) {
  33. global $_zp_gallery;
  34. $albumlist = $albumobj->getAlbums();
  35. foreach ($albumlist as $album) {
  36. $subalbumobj = newAlbum($album);
  37. $subalbumname = $subalbumobj->name;
  38. $level = substr_count($subalbumname, "/");
  39. $arrow = "";
  40. for ($count = 1; $count <= $level; $count++) {
  41. $arrow .= "&raquo; ";
  42. }
  43. echo "<option value='" . pathurlencode($subalbumobj->name) . "'>";
  44. echo $arrow . $subalbumobj->getTitle() . unpublishedZenphotoItemCheck($subalbumobj) . " (" . $subalbumobj->getNumImages() . ")</option>";
  45. if (!$subalbumobj->isDynamic()) {
  46. printSubLevelAlbums($subalbumobj);
  47. }
  48. }
  49. }
  50. /**
  51. * checks if a album or image is un-published and returns a '*'
  52. *
  53. * @return string
  54. */
  55. function unpublishedZenphotoItemCheck($obj, $dropdown = true) {
  56. $span1 = "";
  57. $span2 = "";
  58. if ($obj->getShow() != "1") {
  59. if (!$dropdown) {
  60. $span1 = "<span class='unpublisheditem'>";
  61. $span2 = "</span>";
  62. }
  63. $show = $span1 . "*" . $span2;
  64. } else {
  65. $show = "";
  66. }
  67. return $show;
  68. }
  69. /**
  70. * shortens a string, truncate_string() was not exact enough.
  71. *
  72. * @param $title int Title of the image
  73. * @param $length int The desired length
  74. * @return string
  75. */
  76. function shortentitle($title, $length) {
  77. if (strlen($title) > $length) {
  78. return substr($title, 0, $length) . "...";
  79. } else {
  80. return $title;
  81. }
  82. }
  83. /**
  84. * Prints the images and/or albums as thumbnails of the selected album
  85. *
  86. * @param $number int The number of images per page
  87. *
  88. * @return string
  89. */
  90. function printImageslist($number) {
  91. global $_zp_gallery, $host;
  92. $args = array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  93. if (isset($_GET['album']) && ! empty($_GET['album'])) {
  94. $album = urldecode(sanitize($_GET['album']));
  95. $albumobj = newAlbum($album);
  96. echo "<h3>" . gettext("Album:") . " <em>" . html_encode($albumobj->getTitle()) . unpublishedZenphotoItemCheck($albumobj, false) . "</em> / " . gettext("Album folder:") . " <em>" . html_encode($albumobj->name) . "</em><br /><small>" . gettext("(Click on image to include)") . "</small></h3>";
  97. $images_per_page = $number;
  98. if (isset($_GET['page'])) {
  99. $currentpage = sanitize_numeric($_GET['page']);
  100. } else {
  101. $currentpage = 1;
  102. }
  103. $imagecount = $albumobj->getNumImages();
  104. $pagestotal = ceil($imagecount / $images_per_page);
  105. printTinyPageNav($pagestotal, $currentpage, 'images');
  106. // album thumb display;
  107. $albumthumb = $albumobj->getAlbumThumbImage();
  108. $albumthumbalbum = $albumthumb->getAlbum();
  109. $albumdesc = $albumobj->getDesc();
  110. $imagedesc = $albumthumb->getDesc();
  111. $imgurl = getImageProcessorURI($args, $albumthumbalbum->name, $albumthumb->filename);
  112. $fullimage = pathurlencode(addslashes($albumthumb->getFullImage()));
  113. $imageType = getImageType($albumthumb);
  114. if ($imageType) {
  115. // Not a pure image
  116. $backgroundcss = 'albumthumb-image';
  117. $imgurl = $albumthumb->getThumb();
  118. $itemid = $albumthumb->getID();
  119. } else {
  120. $backgroundcss = 'albumthumb-other';
  121. $imgurl = getImageProcessorURI($args, $albumthumbalbum->name, $albumthumb->filename);
  122. $itemid = $albumthumb->getID();
  123. }
  124. $imgsizeurl = $albumthumb->getCustomImage(85, NULL, NULL, 85, 85, NULL, NULL, TRUE);
  125. echo "<div class='thumb'>";
  126. echo "<a href=\"javascript: ZenpageDialog.insert('" . $itemid . "','" . $imgurl . "','" .
  127. $albumobj->getThumb() . "','" .
  128. "','" .
  129. urlencode($albumthumb->filename) . "','" .
  130. js_encode($albumthumb->getTitle()) . "','" .
  131. js_encode($albumobj->getTitle()) . "','" .
  132. $fullimage . "',
  133. 'zenphoto','" .
  134. js_encode(getWatermarkParam($albumthumb, WATERMARK_THUMB)) . "','" .
  135. js_encode(getWatermarkParam($albumthumb, WATERMARK_IMAGE)) . "','" .
  136. $imageType . "',
  137. '" . html_encode(addslashes($imagedesc)) . "',
  138. '" . html_encode(addslashes($albumdesc)) . "');\"" .
  139. " title='" . html_encode($albumthumb->getTitle()) . " (" . html_encode($albumthumb->filename) . ")'>
  140. <img src='" . $imgsizeurl . "' class='" . $backgroundcss . "' /></a>\n";
  141. echo "<a href='../../../../../.." . html_encode($albumthumb->getLink()) .
  142. "' title='Zoom' rel='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a> " .
  143. gettext('<em>Albumthumb</em>') . unpublishedZenphotoItemCheck($albumthumb, false);
  144. echo "</div>";
  145. $images = $albumobj->getImages();
  146. if ($albumobj->getNumImages() != 0) {
  147. for ($nr = 1; $nr <= $pagestotal; $nr++) {
  148. $startimage[$nr] = $nr * $images_per_page - $images_per_page; // get start image number
  149. $endimage[$nr] = $nr * $images_per_page - 1; // get end image number
  150. }
  151. $number = $startimage[$currentpage];
  152. for ($nr = $number; $nr <= $images_per_page * $currentpage; $nr++) {
  153. if ($nr === $imagecount) {
  154. break;
  155. }
  156. if (is_array($images[$nr])) {
  157. $linkalbumobj = newAlbum($images[$nr]['folder']);
  158. $imageobj = newImage($linkalbumobj, $images[$nr]['filename']);
  159. } else {
  160. $linkalbumobj = $albumobj;
  161. $imageobj = newImage($albumobj, $images[$nr]);
  162. }
  163. $imagedesc = $imageobj->getDesc();
  164. $albumdesc = $linkalbumobj->getDesc();
  165. $fullimage = pathurlencode(addslashes($imageobj->getFullImage()));
  166. $imageType = getImageType($imageobj);
  167. $thumburl = $imageobj->getThumb();
  168. $imgurl = $imageobj->getLink(false);
  169. //$sizedimage = $imageobj->getSizedImage(getOption('image_size'));
  170. switch ($imageType) {
  171. case '':
  172. // image photo
  173. $backgroundcss = 'thumb-image';
  174. $imgurl = getImageProcessorURI($args, $linkalbumobj->name, $imageobj->filename);
  175. $sizedimage = $imageobj->getSizedImage(getOption('image_size'));
  176. $sizedimage = '<img src="' . $sizedimage . '" alt="' . $imageobj->getTitle() . '" class="zenpage_sizedimage" />';
  177. $itemid = '';
  178. break;
  179. case 'textobject':
  180. $sizedimage = $imageobj->getSizedImage(getOption('image_size'));
  181. $sizedimage = str_replace('class="textobject"', 'class="textobject zenpage_sizedimage"', $sizedimage);
  182. $imgurl = getImageProcessorURI($args, $linkalbumobj->name, $imageobj->filename);
  183. $backgroundcss = 'thumb-textobject';
  184. $itemid = '';
  185. break;
  186. case 'video':
  187. case 'audio':
  188. $sizedimage = $imageobj->getThumb();
  189. $sizedimage = str_replace('class="flowplayer"', 'class="mediaplayer zenpage_sizedimage"', $sizedimage);
  190. $imgurl = getImageProcessorURI($args, $linkalbumobj->name, $imageobj->filename);
  191. $backgroundcss = 'thumb-multimedia';
  192. $itemid = $imageobj->getID();
  193. break;
  194. default:
  195. $sizedimage = $imageobj->getSizedImage(getOption('image_size'));
  196. $backgroundcss = 'thumb-default';
  197. $itemid = '';
  198. break;
  199. }
  200. $imgsizeurl = $imageobj->getCustomImage(85, NULL, NULL, 85, 85, NULL, NULL, TRUE);
  201. echo "<div class='thumb'>\n";
  202. echo "<a href=\"javascript:ZenpageDialog.insert('" . $itemid . "','" . $imgurl . "','" .
  203. $thumburl . "','" .
  204. html_encode($sizedimage) . "','" .
  205. urlencode($imageobj->filename) . "','" .
  206. js_encode($imageobj->getTitle()) . "','" .
  207. js_encode($linkalbumobj->getTitle()) . "','" .
  208. $fullimage . "',
  209. 'zenphoto','" .
  210. js_encode(getWatermarkParam($imageobj, WATERMARK_THUMB)) . "','" .
  211. js_encode(getWatermarkParam($imageobj, WATERMARK_IMAGE)) . "','" .
  212. $imageType . "',
  213. '" . html_encode(addslashes($imagedesc)) . "',
  214. '" . html_encode(addslashes($albumdesc)) . "');\"" .
  215. " title='" . html_encode($imageobj->getTitle()) . " (" . html_encode($imageobj->filename) . ")'>
  216. <img src='" . $imgsizeurl . "' class='" . $backgroundcss . "' /></a>\n";
  217. echo "<a href='../../../../../.." . html_encode($imageobj->getLink()) .
  218. "' title='Zoom' rel='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a> " .
  219. html_encode(shortentitle($imageobj->getTitle(), 8)) . unpublishedZenphotoItemCheck($imageobj, false);
  220. echo "</div>\n";
  221. if ($nr === $endimage[$currentpage]) {
  222. break;
  223. }
  224. } // for end
  225. } else {
  226. echo "<p class='noimages'>" . gettext("<strong>Note:</strong> This album does not contain any images.") . "</p>";
  227. } // if/else no image end
  228. } // if GET album end
  229. }
  230. /**
  231. * Returns the object "type" of the "image".
  232. *
  233. * Note:
  234. * If the root object is a video object then
  235. * If a mediaplayer is enabled a sub-type of video or audio will
  236. * be determined from the suffix. If it is not one of the
  237. * known suffixes or if the mediaplayer is not enabled then 'other' is
  238. * returned as the object type.
  239. *
  240. * Pure images return empty for an object type.
  241. *
  242. * @return string
  243. */
  244. function getImageType($imageobj) {
  245. $imageType = strtolower(get_class($imageobj));
  246. switch ($imageType) {
  247. case 'video':
  248. $imagesuffix = getSuffix($imageobj->filename);
  249. switch ($imagesuffix) {
  250. case 'flv':
  251. case 'mp4':
  252. case 'm4v':
  253. $imageType = 'video';
  254. break;
  255. case 'mp3':
  256. case 'fla':
  257. case 'm4a':
  258. $imageType = 'audio';
  259. break;
  260. }
  261. break;
  262. case 'image':
  263. $imageType = '';
  264. break;
  265. default:
  266. $parent = strtolower(get_parent_class($imageobj));
  267. if ($parent == 'textobject') {
  268. $imageType = 'textobject';
  269. }
  270. break;
  271. }
  272. return $imageType;
  273. }
  274. /**
  275. * Prints all available articles in Zenpage
  276. *
  277. * @return string
  278. */
  279. function printNewsArticlesList($number) {
  280. global $_zp_zenpage, $_zp_current_zenpage_news, $host;
  281. if (isset($_GET['zenpage']) && $_GET['zenpage'] == "articles") {
  282. echo "<h3>Zenpage: <em>" . gettext('Articles') . "</em> <small>" . gettext("(Click on article title to include a link)") . "</small></h3>";
  283. if (isset($_GET['category'])) {
  284. $cat = sanitize($_GET['category']);
  285. $catobj = new ZenpageCategory($cat);
  286. $items = $catobj->getArticles("", "all");
  287. $newscount = count($catobj->getArticles(0, 'all'));
  288. } else {
  289. $items = $_zp_zenpage->getArticles("", "all");
  290. $newscount = count($_zp_zenpage->getArticles(0, 'all'));
  291. }
  292. $news_per_page = $number;
  293. if (isset($_GET['page'])) {
  294. $currentpage = sanitize_numeric($_GET['page']);
  295. } else {
  296. $currentpage = 1;
  297. }
  298. $pagestotal = ceil($newscount / $news_per_page);
  299. for ($nr = 1; $nr <= $pagestotal; $nr++) {
  300. $startnews[$nr] = $nr * $news_per_page - $news_per_page; // get start image number
  301. $endnews[$nr] = $nr * $news_per_page - 1; // get end image number
  302. }
  303. $count = '';
  304. $number = $startnews[$currentpage];
  305. //category selector here later
  306. printTinyZenpageCategorySelector($currentpage);
  307. if ($newscount != 0) {
  308. printTinyPageNav($pagestotal, $currentpage, 'news');
  309. echo "<ul class='zenpagearticles'>";
  310. for ($nr = $number; $nr <= $news_per_page * $currentpage; $nr++) {
  311. if ($nr == $newscount) {
  312. break;
  313. }
  314. $newsobj = new ZenpageNews($items[$nr]['titlelink']);
  315. $count++;
  316. echo "<li>";
  317. if ($_GET['zenpage'] == "articles") {
  318. echo "<a href=\"javascript:ZenpageDialog.insert('','news/" . $newsobj->getTitlelink() . "','','','" . $newsobj->getTitlelink() . "','" . addslashes($newsobj->getTitle()) . "','','','articles','','','','');\" title='" . html_encode(truncate_string(getBare($newsobj->getContent()), 300)) . "'>" . addslashes($newsobj->getTitle()) . unpublishedZenpageItemCheck($newsobj) . "</a> <small><em>" . $newsobj->getDatetime() . "</em></small>";
  319. echo " <a href='zoom.php?news=" . urlencode($newsobj->getTitlelink()) . "' title='Zoom' class='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a><br />";
  320. echo '<small><em>' . gettext('Categories:');
  321. $cats = $newsobj->getCategories();
  322. $count = '';
  323. foreach ($cats as $cat) {
  324. $count++;
  325. $catobj = new ZenpageCategory($cat['titlelink']);
  326. if ($count == 1) {
  327. echo ' ';
  328. } else {
  329. echo ', ';
  330. }
  331. echo $catobj->getTitle();
  332. }
  333. echo '</em></small>';
  334. }
  335. echo "</li>";
  336. if ($nr === $endnews[$currentpage]) {
  337. break;
  338. }
  339. } // for end
  340. echo "</ul>";
  341. }
  342. }
  343. }
  344. /**
  345. * Checks if an album has images for display on the form
  346. *
  347. * @return bool
  348. */
  349. function checkAlbumForImages() {
  350. global $_zp_gallery;
  351. if (isset($_GET['album']) && ! empty($_GET['album'])) {
  352. $album = urldecode(sanitize($_GET['album']));
  353. if ($album == 'gallery') {
  354. return FALSE;
  355. }
  356. $albumobj = newAlbum($album);
  357. if ($albumobj->getNumImages() != 0) {
  358. return TRUE;
  359. } else {
  360. return FALSE;
  361. }
  362. } else {
  363. return TRUE;
  364. }
  365. }
  366. /**
  367. * Checks if the full Zenphoto include form options should be shown
  368. *
  369. * @return bool
  370. */
  371. function showZenphotoOptions() {
  372. return isset($_GET['album']) && !empty($_GET['album']);
  373. }
  374. /**
  375. * Prints the page navigation for albums or Zenpage news articles
  376. *
  377. * @param $pagestotal int The number page in total
  378. * @param $currentpage int Number of the current page
  379. * @param $mode string 'images' or 'articles'
  380. * @return string
  381. */
  382. function printTinyPageNav($pagestotal = "", $currentpage = "", $mode = 'images') {
  383. $cat = '';
  384. switch ($mode) {
  385. case 'images':
  386. $url = "album=" . pathurlencode(sanitize($_GET['album']));
  387. break;
  388. case 'news':
  389. $url = "zenpage=articles";
  390. if (isset($_GET['category'])) {
  391. $cat = '&amp;' . sanitize($_GET['category']);
  392. }
  393. break;
  394. }
  395. if ($pagestotal > 1) {
  396. echo "<br /><br /><ul class='tinypagenav'>";
  397. if ($currentpage != 1) {
  398. echo "<li class=\"first\"><a href='tinyzenpage.php?" . $url . $cat . "&amp;page=1'>&laquo; first</a></li>";
  399. } else {
  400. echo "<li class=\"first\" class='inactive'>&laquo; first</li>";
  401. }
  402. if ($currentpage != 1) {
  403. echo "<li class=\"prev\"><a href='tinyzenpage.php?" . $url . $cat . "&amp;page=" . ($currentpage - 1) . "'>&laquo; prev</a></li>";
  404. } else {
  405. echo "<li class=\"prev\" class='inactive'>&laquo; prev</li>";
  406. }
  407. $j = max(1, min($currentpage - 3, $pagestotal - 6));
  408. if ($j != 1) {
  409. echo "\n <li>";
  410. echo "<a href=\"tinyzenpage.php?" . $url . $cat . "&amp;page=" . max($j - 4, 1) . "\">...</a>";
  411. echo '</li>';
  412. }
  413. for ($i = $j; $i <= min($pagestotal, $j + 6); $i++) {
  414. if ($i == $currentpage) {
  415. echo "<li>" . $i . "</li>\n";
  416. } else {
  417. echo "<li><a href='tinyzenpage.php?" . $url . $cat . "&amp;page=" . $i . "' title='" . gettext("Page") . " " . $i . "'>" . $i . "</a></li>\n";
  418. }
  419. }
  420. if ($i <= $pagestotal) {
  421. echo "\n <li>";
  422. echo "<a href=\"tinyzenpage.php?" . $url . $cat . "&amp;page=" . min($j + 10, $pagestotal) . "\">...</a>";
  423. echo '</li>';
  424. }
  425. if ($currentpage != $pagestotal) {
  426. echo "<li class=\"next\"><a href='tinyzenpage.php?" . $url . "&amp;page=" . ($currentpage + 1) . "'>next &raquo;</a></li>";
  427. } else {
  428. echo "<li class=\"next\" class='inactive'>next &raquo;</li>";
  429. }
  430. if ($currentpage != $pagestotal) {
  431. echo "<li class=\"last\"><a href='tinyzenpage.php?" . $url . "&amp;page=" . $pagestotal . "'>last &raquo;</a></li>";
  432. } else {
  433. echo "<li class=\"last\" class='inactive'>last &raquo;</li>";
  434. }
  435. echo "</ul>";
  436. }
  437. }
  438. /**
  439. * Prints the Zenpage items as a partial dropdown (pages, news articles, categories)
  440. *
  441. * @return string
  442. */
  443. function printZenpageItems() {
  444. global $_zp_zenpage;
  445. $pages = $_zp_zenpage->getPages(false);
  446. $pagenumber = count($pages);
  447. $categories = $_zp_zenpage->getAllCategories(false);
  448. $catcount = count($categories);
  449. echo "<option value='pages'>" . gettext("pages") . " (" . $pagenumber . ")</option>";
  450. echo "<option value='articles'>" . gettext("articles") . " (" . count($_zp_zenpage->getArticles(0, 'all')) . ")</option>";
  451. echo "<option value='categories'>" . gettext("categories") . " (" . $catcount . ")</option>";
  452. }
  453. /**
  454. * Prints all available pages or categories in Zenpage
  455. *
  456. * @return string
  457. */
  458. function printAllNestedList() {
  459. global $_zp_zenpage, $host;
  460. if (isset($_GET['zenpage']) && ($_GET['zenpage'] == "pages" || $_GET['zenpage'] == "categories")) {
  461. $mode = sanitize($_GET['zenpage']);
  462. switch ($mode) {
  463. case 'pages':
  464. $items = $_zp_zenpage->getPages(false);
  465. $listtitle = gettext('Pages');
  466. break;
  467. case 'categories':
  468. $items = $_zp_zenpage->getAllCategories(false);
  469. $listtitle = gettext('Categories');
  470. break;
  471. }
  472. echo "<h3>Zenpage: <em>" . html_encode($listtitle) . "</em> <small> " . gettext("(Click on article title to include a link)") . "</small></h3>";
  473. echo "<ul class='tinynesteditems'>";
  474. $indent = 1;
  475. $open = array(1 => 0);
  476. $rslt = false;
  477. foreach ($items as $key => $item) {
  478. switch ($mode) {
  479. case 'pages':
  480. $obj = new ZenpagePage($item['titlelink']);
  481. $itemcontent = truncate_string(getBare($obj->getContent()), 300);
  482. $zenpagepage = _PAGES_ . '/' . $item['titlelink'];
  483. $unpublished = unpublishedZenpageItemCheck($obj);
  484. $counter = '';
  485. break;
  486. case 'categories':
  487. $obj = new ZenpageCategory($item['titlelink']);
  488. $itemcontent = $obj->getTitle();
  489. $zenpagepage = "news/category/" . $item['titlelink'];
  490. $unpublished = unpublishedZenpageItemCheck($obj);
  491. $counter = ' (' . count($obj->getArticles()) . ') ';
  492. break;
  493. }
  494. $itemsortorder = $obj->getSortOrder();
  495. $itemtitlelink = $obj->getTitlelink();
  496. $itemtitle = $obj->getTitle();
  497. $itemid = $obj->getID();
  498. $order = explode('-', $itemsortorder);
  499. $level = max(1, count($order));
  500. if ($toodeep = $level > 1 && $order[$level - 1] === '') {
  501. $rslt = true;
  502. }
  503. if ($level > $indent) {
  504. echo "\n" . str_pad("\t", $indent, "\t") . "<ul>\n";
  505. $indent++;
  506. $open[$indent] = 0;
  507. } else if ($level < $indent) {
  508. while ($indent > $level) {
  509. $open[$indent] --;
  510. $indent--;
  511. echo "</li>\n" . str_pad("\t", $indent, "\t") . "</ul>\n";
  512. }
  513. } else { // indent == level
  514. if ($open[$indent]) {
  515. echo str_pad("\t", $indent, "\t") . "</li>\n";
  516. $open[$indent] --;
  517. } else {
  518. echo "\n";
  519. }
  520. }
  521. if ($open[$indent]) {
  522. echo str_pad("\t", $indent, "\t") . "</li>\n";
  523. $open[$indent] --;
  524. }
  525. echo "<li id='" . $itemid . "' class='itemborder'>";
  526. echo "<a href=\"javascript:ZenpageDialog.insert('','" . $zenpagepage . "','','','" . $itemtitlelink . "','" . js_encode($itemtitle) . "','','','" . $mode . "','','','','');\" title='" . html_encode($itemcontent) . "'>" . html_encode($itemtitle) . $unpublished . $counter . "</a> <small><em>" . $obj->getDatetime() . "</em></small>";
  527. if ($mode == 'pages') {
  528. echo " <a href='zoom.php?pages=" . urlencode($itemtitlelink) . "' title='Zoom' class='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a>";
  529. }
  530. $open[$indent] ++;
  531. }
  532. while ($indent > 1) {
  533. echo "</li>\n";
  534. $open[$indent] --;
  535. $indent--;
  536. echo str_pad("\t", $indent, "\t") . "</ul>";
  537. }
  538. if ($open[$indent]) {
  539. echo "</li>\n";
  540. } else {
  541. echo "\n";
  542. }
  543. echo "</ul>\n";
  544. }
  545. }
  546. /**
  547. * checks if a news article or page is un-published and/or protected and returns a '*'
  548. *
  549. * @return string
  550. */
  551. function unpublishedZenpageItemCheck($page) {
  552. $class = get_class($page);
  553. $unpublishednote = '';
  554. $protected = '';
  555. switch ($class) {
  556. case 'ZenpageNews':
  557. case 'ZenpagePage':
  558. if ($page->getShow() === "0") {
  559. $unpublishednote = "<span style='color: red; font-weight: bold'>*</span>";
  560. }
  561. switch ($class) {
  562. case 'ZenpageNews':
  563. if ($page->inProtectedCategory()) {
  564. $protected = "<span style='color: red; font-weight: bold'>+</span>";
  565. }
  566. break;
  567. case 'ZenpagePage':
  568. if ($page->isProtected()) {
  569. $protected = "<span style='color: red; font-weight: bold'>+</span>";
  570. }
  571. break;
  572. }
  573. break;
  574. case 'ZenpageCategory':
  575. if ($page->isProtected()) {
  576. $protected = "<span style='color: red; font-weight: bold'>+</span>";
  577. }
  578. break;
  579. }
  580. return $unpublishednote . $protected;
  581. }
  582. /**
  583. * Set the locale for gettext translation of this plugin. Somehow ZenPhoto's setupDomain() does not work here...
  584. *
  585. */
  586. function setTinyZenpageLocale() {
  587. $encoding = LOCAL_CHARSET;
  588. $locale = ZENPHOTO_LOCALE;
  589. @putenv("LANG=$locale");
  590. $result = setlocale(LC_ALL, $locale);
  591. $domain = 'tinyzenpage';
  592. $domainpath = "locale/";
  593. bindtextdomain($domain, $domainpath);
  594. // function only since php 4.2.0
  595. if (function_exists('bind_textdomain_codeset')) {
  596. bind_textdomain_codeset($domain, $encoding);
  597. }
  598. textdomain($domain);
  599. }
  600. /**
  601. * Prints the dropdown menu for the category selector for the news articles list
  602. *
  603. */
  604. function printTinyZenpageCategorySelector($currentpage = '') {
  605. global $_zp_zenpage;
  606. $result = $_zp_zenpage->getAllCategories(false);
  607. if (isset($_GET['category'])) {
  608. $selected = '';
  609. $category = sanitize($_GET['category']);
  610. } else {
  611. $selected = "selected='selected'";
  612. $category = "";
  613. }
  614. ?>
  615. <form name ="AutoListBox2" id="categorydropdown" style="float:left" action="#" >
  616. <select name="ListBoxURL" size="1" onchange="gotoLink(this.form)">
  617. <?php
  618. echo "<option $selected value='tinyzenpage.php?zenpage=articles&amp;page=" . $currentpage . "'>" . gettext("All categories") . "</option>\n";
  619. foreach ($result as $cat) {
  620. $catobj = new ZenpageCategory($cat['titlelink']);
  621. // check if there are articles in this category. If not don't list the category.
  622. $count = count($catobj->getArticles(0, 'all'));
  623. $count = " (" . $count . ")";
  624. if ($category == $cat['titlelink']) {
  625. $selected = "selected='selected'";
  626. } else {
  627. $selected = "";
  628. }
  629. //This is much easier than hacking the nested list function to work with this
  630. $getparents = $catobj->getParents();
  631. $levelmark = '';
  632. foreach ($getparents as $parent) {
  633. $levelmark .= '&raquo; ';
  634. }
  635. $title = $catobj->getTitle();
  636. if (empty($title)) {
  637. $title = '*' . $catobj->getTitlelink() . '*';
  638. }
  639. if ($count != " (0)") {
  640. echo "<option $selected value='tinyzenpage.php?zenpage=articles&amp;page=" . $currentpage . "&amp;category=" . $catobj->getTitlelink() . "'>" . $levelmark . $title . $count . "</option>\n";
  641. }
  642. }
  643. ?>
  644. </select>
  645. <script type="text/javascript" >
  646. // <!-- <![CDATA[
  647. function gotoLink(form) {
  648. var OptionIndex = form.ListBoxURL.selectedIndex;
  649. this.location = form.ListBoxURL.options[OptionIndex].value;
  650. }
  651. // ]]> -->
  652. </script>
  653. </form>
  654. <br />
  655. <?php
  656. }
  657. ?>