1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868: 869: 870: 871: 872: 873: 874: 875: 876: 877: 878: 879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896: 897: 898: 899: 900: 901: 902: 903: 904: 905: 906: 907: 908: 909: 910: 911: 912: 913: 914: 915: 916: 917: 918: 919: 920: 921: 922: 923: 924: 925: 926: 927: 928: 929: 930: 931: 932: 933: 934: 935: 936: 937: 938: 939: 940: 941: 942: 943: 944: 945: 946: 947: 948: 949: 950: 951: 952: 953: 954: 955: 956: 957: 958: 959: 960: 961: 962: 963: 964: 965: 966: 967: 968: 969: 970: 971: 972: 973: 974: 975: 976: 977: 978: 979: 980: 981: 982: 983: 984: 985: 986: 987: 988: 989: 990: 991: 992: 993: 994: 995: 996: 997: 998: 999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290: 1291: 1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318: 1319: 1320: 1321: 1322: 1323: 1324: 1325: 1326: 1327: 1328: 1329: 1330: 1331: 1332: 1333: 1334: 1335: 1336: 1337: 1338: 1339: 1340: 1341: 1342: 1343: 1344: 1345: 1346: 1347: 1348: 1349: 1350: 1351: 1352: 1353: 1354: 1355: 1356: 1357: 1358: 1359: 1360: 1361: 1362: 1363: 1364: 1365: 1366: 1367: 1368: 1369: 1370: 1371: 1372: 1373: 1374: 1375: 1376: 1377: 1378: 1379: 1380: 1381: 1382: 1383: 1384: 1385: 1386: 1387: 1388: 1389: 1390: 1391: 1392: 1393: 1394: 1395: 1396: 1397: 1398: 1399: 1400: 1401: 1402: 1403: 1404: 1405: 1406: 1407: 1408: 1409: 1410: 1411: 1412: 1413: 1414: 1415: 1416: 1417: 1418: 1419: 1420: 1421: 1422: 1423: 1424: 1425: 1426: 1427: 1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442: 1443: 1444: 1445: 1446: 1447: 1448: 1449: 1450: 1451: 1452: 1453: 1454: 1455: 1456: 1457: 1458: 1459: 1460: 1461: 1462: 1463: 1464: 1465: 1466: 1467: 1468: 1469: 1470: 1471: 1472: 1473: 1474: 1475: 1476: 1477: 1478: 1479: 1480: 1481: 1482: 1483: 1484: 1485: 1486: 1487: 1488: 1489: 1490: 1491: 1492: 1493: 1494: 1495: 1496: 1497: 1498: 1499: 1500: 1501: 1502: 1503: 1504: 1505: 1506: 1507: 1508: 1509: 1510: 1511: 1512: 1513: 1514: 1515: 1516: 1517: 1518: 1519: 1520: 1521: 1522: 1523: 1524: 1525: 1526: 1527: 1528: 1529: 1530: 1531: 1532: 1533: 1534: 1535: 1536: 1537: 1538: 1539: 1540: 1541: 1542: 1543: 1544: 1545: 1546: 1547: 1548: 1549: 1550: 1551: 1552: 1553: 1554: 1555: 1556: 1557: 1558: 1559: 1560: 1561: 1562: 1563: 1564: 1565: 1566: 1567: 1568: 1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576: 1577: 1578: 1579: 1580: 1581: 1582: 1583: 1584: 1585: 1586: 1587: 1588: 1589: 1590: 1591: 1592: 1593: 1594: 1595: 1596: 1597: 1598: 1599: 1600: 1601: 1602: 1603: 1604: 1605: 1606: 1607: 1608: 1609: 1610: 1611: 1612: 1613: 1614: 1615: 1616: 1617: 1618: 1619: 1620: 1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630: 1631: 1632: 1633: 1634: 1635: 1636: 1637: 1638: 1639: 1640: 1641: 1642: 1643: 1644: 1645: 1646: 1647: 1648: 1649: 1650: 1651: 1652: 1653: 1654: 1655: 1656: 1657: 1658: 1659: 1660: 1661: 1662: 1663: 1664: 1665: 1666: 1667: 1668: 1669: 1670: 1671: 1672: 1673: 1674: 1675: 1676: 1677: 1678: 1679: 1680: 1681: 1682: 1683: 1684: 1685: 1686: 1687: 1688: 1689: 1690: 1691: 1692: 1693: 1694: 1695: 1696: 1697: 1698: 1699: 1700: 1701: 1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709: 1710: 1711: 1712: 1713: 1714: 1715: 1716: 1717: 1718: 1719: 1720: 1721: 1722: 1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734: 1735: 1736: 1737: 1738: 1739: 1740: 1741: 1742: 1743: 1744: 1745: 1746: 1747: 1748: 1749: 1750: 1751: 1752: 1753: 1754: 1755: 1756: 1757: 1758: 1759: 1760: 1761: 1762: 1763: 1764: 1765: 1766: 1767: 1768: 1769: 1770: 1771: 1772: 1773: 1774: 1775: 1776: 1777: 1778: 1779: 1780: 1781: 1782: 1783: 1784: 1785: 1786: 1787: 1788: 1789: 1790: 1791: 1792: 1793: 1794: 1795: 1796: 1797: 1798: 1799: 1800: 1801: 1802: 1803: 1804: 1805: 1806: 1807: 1808: 1809: 1810: 1811: 1812: 1813: 1814: 1815: 1816: 1817: 1818: 1819: 1820: 1821: 1822: 1823:
<?php
global $_zp_zenpage, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_current_category;
Zenpage::expiry();
function getExpiryDatePost() {
$expiredate = sanitize($_POST['expiredate']);
if ($expiredate > date(date('Y-m-d H:i:s')))
return $expiredate;
return NULL;
}
function processTags($object) {
$tagsprefix = 'tags_';
$tags = array();
$l = strlen($tagsprefix);
foreach ($_POST as $key => $value) {
$key = postIndexDecode($key);
if (substr($key, 0, $l) == $tagsprefix) {
if ($value) {
$tags[] = substr($key, $l);
}
}
}
$tags = array_unique($tags);
$object->setTags(sanitize($tags, 3));
}
function updatePage(&$reports, $newpage = false) {
global $_zp_zenpage, $_zp_current_admin_obj;
$title = process_language_string_save("title", 2);
$author = sanitize($_POST['author']);
$content = updateImageProcessorLink(process_language_string_save("content", EDITOR_SANITIZE_LEVEL));
$extracontent = updateImageProcessorLink(process_language_string_save("extracontent", EDITOR_SANITIZE_LEVEL));
$custom = process_language_string_save("custom_data", 1);
$show = getcheckboxState('show');
$date = sanitize($_POST['date']);
$expiredate = getExpiryDatePost();
$commentson = getcheckboxState('commentson');
$permalink = getcheckboxState('permalink');
if (zp_loggedin(CODEBLOCK_RIGHTS)) {
$codeblock = processCodeblockSave(0);
}
$locked = getcheckboxState('locked');
if ($newpage) {
$titlelink = createTitlelink($title, $date);
if(getOption('zenpage_titlelinkdate_pages')) {
$titlelink = addDateToTitlelink($titlelink);
}
$duplicate = checkTitlelinkDuplicate($titlelink, 'page');
if ($duplicate) {
$titlelink = addDateToTitlelink($titlelink);
$reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate page title') . '</p>';
}
$oldtitlelink = $titlelink;
} else {
$titlelink = $oldtitlelink = sanitize($_POST['titlelink-old']);
}
if (getcheckboxState('edittitlelink')) {
$titlelink = sanitize($_POST['titlelink'], 3);
if (empty($titlelink)) {
$titlelink = createTitlelink($title, $date);
}
} else {
if (!$permalink) {
$link = seoFriendly(get_language_string($title));
if (!empty($link)) {
$titlelink = $link;
}
}
}
$id = sanitize($_POST['id']);
$rslt = true;
if ($titlelink != $oldtitlelink) {
$rslt = query('UPDATE ' . prefix('pages') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
if (!$rslt) {
$titlelink = $oldtitlelink;
} else {
SearchEngine::clearSearchCache();
}
}
$page = new ZenpagePage($titlelink, true);
$notice = processCredentials($page);
$page->setTitle($title);
$page->setContent($content);
$page->setExtracontent($extracontent);
$page->setCustomData(zp_apply_filter('save_page_custom_data', $custom, $page));
$page->setShow($show);
$page->setDateTime($date);
$page->setLastChange($date);
$page->setCommentsAllowed($commentson);
if (zp_loggedin(CODEBLOCK_RIGHTS)) {
$page->setCodeblock($codeblock);
}
$page->setAuthor($author);
$page->setPermalink($permalink);
$page->setLocked($locked);
$page->setExpiredate($expiredate);
if (getcheckboxState('resethitcounter')) {
$page->set('hitcounter', 0);
}
if (getcheckboxState('reset_rating')) {
$page->set('total_value', 0);
$page->set('total_votes', 0);
$page->set('used_ips', 0);
}
processTags($page);
if ($newpage) {
$page->setDefaultSortorder();
$msg = zp_apply_filter('new_page', '', $page);
if (empty($title)) {
$reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Page <em>%s</em> added but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
} else if ($notice == '?mismatch=user') {
$reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Page user') . '</p>';
} else if ($notice) {
$reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
} else {
$reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Page <em>%s</em> added"), $titlelink) . '</p>';
}
} else {
$page->setLastchangeUser($_zp_current_admin_obj->getUser());
$msg = zp_apply_filter('update_page', '', $page, $oldtitlelink);
if (!$rslt) {
$reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("A page with the title/titlelink <em>%s</em> already exists!"), $titlelink) . '</p>';
} else if (empty($title)) {
$reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Page <em>%s</em> updated but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
} else if ($notice == '?mismatch=user') {
$reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Page user') . '</p>';
} else if ($notice) {
echo "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
} else {
$reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Page <em>%s</em> updated"), $titlelink) . '</p>';
}
}
$checkupdates = true;
if ($newpage) {
$checkupdates = false;
}
$page->save($checkupdates);
if ($msg) {
$reports[] = $msg;
}
return $page;
}
function deletePage($titlelink) {
if (is_object($titlelink)) {
$obj = $titlelink;
} else {
$obj = new ZenpagePage($titlelink);
}
$result = $obj->remove();
if ($result) {
if (is_object($titlelink)) {
redirectURL(FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/admin-pages.php?deleted');
}
SearchEngine::clearSearchCache();
return "<p class='messagebox fade-message'>" . gettext("Page successfully deleted!") . "</p>";
}
return "<p class='errorbox fade-message'>" . gettext("Page delete failed!") . "</p>";
}
function printPagesListTable($page, $flag) {
if ($flag) {
$img = '../../images/drag_handle_flag.png';
} else {
$img = '../../images/drag_handle.png';
}
?>
<div class='page-list_row'>
<div class="page-list_title">
<?php
if (checkIfLockedPage($page)) {
echo "<a href='admin-edit.php?page&titlelink=" . urlencode($page->getTitlelink()) . "'> ";
checkForEmptyTitle($page->getTitle(), "page");
echo "</a>" . checkHitcounterDisplay($page->getHitcounter());
} else {
checkForEmptyTitle($page->getTitle(), "page");
checkHitcounterDisplay($page->isPublished());
}
?>
</div>
<div class="page-list_extra">
<span>
<?php echo html_encode($page->getAuthor()); ?>
</span>
</div>
<div class="page-list_extra">
<?php printPublished($page); ?>
</div>
<div class="page-list_extra">
<?php printExpired($page); ?>
</div>
<div class="page-list_iconwrapper">
<div class="page-list_icon">
<?php
if ($page->getPassword()) {
echo '<img src="../../images/lock.png" style="border: 0px;" alt="' . gettext('Password protected') . '" title="' . gettext('Password protected') . '" />';
}
?>
</div>
<?php if (checkIfLockedPage($page)) { ?>
<div class="page-list_icon">
<?php printPublishIconLink($page, "page"); ?>
</div>
<?php if(extensionEnabled('comment_form')) { ?>
<div class="page-list_icon">
<?php
if ($page->getCommentsAllowed()) {
?>
<a href="?commentson=0&titlelink=<?php echo html_encode($page->getTitlelink()); ?>&XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo gettext('Disable comments'); ?>">
<img src="../../images/comments-on.png" alt="" title="<?php echo gettext("Comments on"); ?>" style="border: 0px;"/>
</a>
<?php
} else {
?>
<a href="?commentson=1&titlelink=<?php echo html_encode($page->getTitlelink()); ?>&XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo gettext('Enable comments'); ?>">
<img src="../../images/comments-off.png" alt="" title="<?php echo gettext("Comments off"); ?>" style="border: 0px;"/>
</a>
<?php
}
?>
</div>
<?php } ?>
<?php } else { ?>
<div class="page-list_icon">
<img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
</div>
<div class="page-list_icon">
<img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
</div>
<?php } ?>
<div class="page-list_icon">
<a href="../../../index.php?p=pages&title=<?php echo js_encode($page->getTitlelink()); ?>" title="<?php echo gettext("View page"); ?>">
<img src="images/view.png" alt="" title="<?php echo gettext("view"); ?>" />
</a>
</div>
<?php
if (checkIfLockedPage($page)) {
if (extensionEnabled('hitcounter')) {
?>
<div class="page-list_icon">
<a href="?hitcounter=1&titlelink=<?php echo html_encode($page->getTitlelink()); ?>&add&XSRFToken=<?php echo getXSRFToken('hitcounter') ?>" title="<?php echo gettext("Reset hitcounter"); ?>">
<img src="../../images/reset.png" alt="" title="<?php echo gettext("Reset hitcounter"); ?>" /></a>
</div>
<?php
}
?>
<div class="page-list_icon">
<a href="javascript:confirmDelete('admin-pages.php?delete=<?php echo $page->getTitlelink(); ?>&add&XSRFToken=<?php echo getXSRFToken('delete') ?>',deletePage)" title="<?php echo gettext("Delete page"); ?>">
<img src="../../images/fail.png" alt="" title="<?php echo gettext("delete"); ?>" /></a>
</div>
<div class="page-list_icon">
<input class="checkbox" type="checkbox" name="ids[]" value="<?php echo $page->getTitlelink(); ?>" onclick="triggerAllBox(this.form, 'ids[]', this.form.allbox);" />
</div>
<?php } else { ?>
<div class="page-list_icon">
<img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
</div>
<div class="page-list_icon">
<img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
</div>
<div class="page-list_icon">
<img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
</div>
<?php } ?>
</div><!-- icon wrapper end -->
</div>
<?php
}
function updateArticle(&$reports, $newarticle = false) {
global $_zp_current_admin_obj;
$date = date('Y-m-d_H-i-s');
$title = process_language_string_save("title", 2);
$author = sanitize($_POST['author']);
$content = updateImageProcessorLink(process_language_string_save("content", EDITOR_SANITIZE_LEVEL));
$extracontent = updateImageProcessorLink(process_language_string_save("extracontent", EDITOR_SANITIZE_LEVEL));
$custom = process_language_string_save("custom_data", 1);
$show = getcheckboxState('show');
$date = sanitize($_POST['date']);
$expiredate = getExpiryDatePost();
$permalink = getcheckboxState('permalink');
$commentson = getcheckboxState('commentson');
if (zp_loggedin(CODEBLOCK_RIGHTS)) {
$codeblock = processCodeblockSave(0);
}
$locked = getcheckboxState('locked');
if ($newarticle) {
$titlelink = createTitlelink($title, $date);
if(getOption('zenpage_titlelinkdate_articles')) {
$titlelink = addDateToTitlelink($titlelink);
}
$duplicate = checkTitlelinkDuplicate($titlelink, 'article');
if ($duplicate) {
$titlelink = addDateToTitlelink($titlelink);
$reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate article title') . '</p>';
}
$oldtitlelink = $titlelink;
$id = 0;
} else {
$titlelink = $oldtitlelink = sanitize($_POST['titlelink-old'], 3);
$id = sanitize($_POST['id']);
}
if (getcheckboxState('edittitlelink')) {
$titlelink = sanitize($_POST['titlelink'], 3);
if (empty($titlelink)) {
$titlelink = createTitlelink($title, $date);
}
} else {
if (!$permalink) {
$link = seoFriendly(get_language_string($title));
if (!empty($link)) {
$titlelink = $link;
}
}
}
$rslt = true;
if ($titlelink != $oldtitlelink) {
$rslt = query('UPDATE ' . prefix('news') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
if (!$rslt) {
$titlelink = $oldtitlelink;
} else {
SearchEngine::clearSearchCache();
}
}
$article = new ZenpageNews($titlelink, true);
$article->setTitle($title);
$article->setContent($content);
$article->setExtracontent($extracontent);
$article->setCustomData(zp_apply_filter('save_article_custom_data', $custom, $article));
$article->setShow($show);
$article->setDateTime($date);
$article->setLastChange($date);
$article->setCommentsAllowed($commentson);
if (zp_loggedin(CODEBLOCK_RIGHTS)) {
$article->setCodeblock($codeblock);
}
$article->setAuthor($author);
$article->setPermalink($permalink);
$article->setLocked($locked);
$article->setExpiredate($expiredate);
$article->setSticky(sanitize_numeric($_POST['sticky']));
if (getcheckboxState('resethitcounter')) {
$article->set('hitcounter', 0);
}
if (getcheckboxState('reset_rating')) {
$article->set('total_value', 0);
$article->set('total_votes', 0);
$article->set('used_ips', 0);
}
$article->setTruncation(getcheckboxState('truncation'));
processTags($article);
$categories = array();
$result2 = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER BY titlelink");
foreach ($result2 as $cat) {
if (isset($_POST["cat" . $cat['id']])) {
$categories[] = $cat['titlelink'];
}
}
$article->setCategories($categories);
if (!$newarticle) {
$article->setLastchangeUser($_zp_current_admin_obj->getUser());
}
if ($newarticle) {
$msg = zp_apply_filter('new_article', '', $article);
if (empty($title)) {
$reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Article <em>%s</em> added but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
} else {
$reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Article <em>%s</em> added"), $titlelink) . '</p>';
}
} else {
$msg = zp_apply_filter('update_article', '', $article, $oldtitlelink);
if (!$rslt) {
$reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("An article with the title/titlelink <em>%s</em> already exists!"), $titlelink) . '</p>';
} else if (empty($title)) {
$reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Article <em>%s</em> updated but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
} else {
$reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Article <em>%s</em> updated"), $titlelink) . '</p>';
}
}
$checkupdates = true;
if($newarticle) {
$checkupdates = false;
}
$article->save($checkupdates);
if ($msg) {
$reports[] = $msg;
}
return $article;
}
function deleteArticle($titlelink) {
if (is_object($titlelink)) {
$obj = $titlelink;
} else {
$obj = new ZenpageNews($titlelink);
}
$result = $obj->remove();
if ($result) {
if (is_object($titlelink)) {
redirectURL(FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/admin-news-articles.php?deleted');
}
SearchEngine::clearSearchCache();
return "<p class='messagebox fade-message'>" . gettext("Article successfully deleted!") . "</p>";
}
return "<p class='errorbox fade-message'>" . gettext("Article delete failed!") . "</p>";
}
function printArticleCategories($obj) {
$cat = $obj->getCategories();
$number = 0;
foreach ($cat as $cats) {
$number++;
if ($number != 1) {
echo ", ";
}
echo get_language_string($cats['title']);
}
}
function printPageArticleTags($obj) {
$tags = $obj->getTags();
$number = 0;
foreach ($tags as $tag) {
$number++;
if ($number != 1) {
echo ", ";
}
echo get_language_string($tag);
}
}
function printCategorySelection($id = '', $option = '') {
global $_zp_zenpage;
$selected = '';
echo "<ul class='zenpagechecklist'>\n";
$all_cats = $_zp_zenpage->getAllCategories(false);
foreach ($all_cats as $cats) {
$catobj = new ZenpageCategory($cats['titlelink']);
if ($option != "all") {
$cat2news = query_single_row("SELECT cat_id FROM " . prefix('news2cat') . " WHERE news_id = " . $id . " AND cat_id = " . $catobj->getID());
if (isset($cat2news['cat_id']) && !empty($cat2news['cat_id'])) {
$selected = "checked ='checked'";
}
}
$catname = $catobj->getTitle();
$catlink = $catobj->getTitlelink();
if ($catobj->getPassword()) {
$protected = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/lock.png" alt="' . gettext('password protected') . '" />';
} else {
$protected = '';
}
$catid = $catobj->getID();
echo "<li class=\"hasimage\" ><label for='cat" . $catid . "'><input name='cat" . $catid . "' id='cat" . $catid . "' type='checkbox' value='" . $catid . "' " . $selected . " />" . $catname . " " . $protected . "</label></li>\n";
}
echo "</ul>\n";
}
function printArticleDatesDropdown() {
global $_zp_zenpage, $subpage;
$datecount = $_zp_zenpage->getAllArticleDates();
$lastyear = "";
$nr = "";
$option = getNewsAdminOption(array('category' => 0, 'published' => 0, 'sortorder' => 0, 'articles_page' => 1, 'author' => 0));
if (!isset($_GET['date'])) {
$selected = 'selected="selected"';
} else {
$selected = "";
}
?>
<form name="articledatesdropdown" id="articledatesdropdown" style="float:left; margin-left: 10px;" action="#" >
<select name="ListBoxURL" size="1" onchange="zp_gotoLink(this.form)">
<?php
echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('' => ''), $option)) . "'>" . gettext("View all months") . "</option>";
foreach($datecount as $key => $val) {
$nr++;
if ($key == '0000-00-01') {
$year = "no date";
$month = "";
} else {
$dt = strftime('%Y-%B', strtotime($key));
$year = substr($dt, 0, 4);
$month = substr($dt, 5);
}
if (isset($_GET['category'])) {
$catlink = "&category=" . sanitize($_GET['category']);
} else {
$catlink = "";
}
$check = $month . "-" . $year;
if (isset($_GET['date']) AND $_GET['date'] == substr($key, 0, 7)) {
$selected = "selected='selected'";
} else {
$selected = "";
}
echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('date' => substr($key, 0, 7)), $option)) . "'>$month $year ($val)</option>\n";
}
?>
</select>
</form>
<?php
}
function getNewsAdminOption($test) {
$list = array();
foreach ($test as $item => $type) {
if (isset($_GET[$item])) {
if ($type) {
$list[$item] = (int) sanitize_numeric($_GET[$item]);
} else {
$list[$item] = sanitize($_GET[$item]);
}
}
}
return $list;
}
function getNewsAdminOptionPath($list) {
$optionpath = '';
$char = '?';
foreach ($list as $p => $q) {
if ($q) {
$optionpath .= $char . $p . '=' . $q;
} else {
$optionpath .= $char . $p;
}
$char = '&';
}
return $optionpath;
}
function printUnpublishedDropdown() {
global $_zp_zenpage;
?>
<form name="unpublisheddropdown" id="unpublisheddropdown" style="float: left; margin-left: 10px;" action="#">
<select name="ListBoxURL" size="1" onchange="zp_gotoLink(this.form)">
<?php
$all = "";
$published = "";
$unpublished = "";
$sticky = '';
if (isset($_GET['published'])) {
switch ($_GET['published']) {
case "no":
$unpublished = "selected='selected'";
break;
case "yes":
$published = "selected='selected'";
break;
case 'sticky':
$sticky = "selected='selected'";
break;
}
} else {
$all = "selected='selected'";
}
$option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'sortorder' => 0, 'articles_page' => 1, 'author' => 0));
echo "<option $all value='admin-news-articles.php" . getNewsAdminOptionPath($option) . "'>" . gettext("All articles") . "</option>\n";
echo "<option $published value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('published' => 'yes'), $option)) . "'>" . gettext("Published") . "</option>\n";
echo "<option $unpublished value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('published' => 'no'), $option)) . "'>" . gettext("Un-published") . "</option>\n";
echo "<option $sticky value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('published' => 'sticky'), $option)) . "'>" . gettext("Sticky") . "</option>\n";
?>
</select>
</form>
<?php
}
function printSortOrderDropdown() {
global $_zp_zenpage;
?>
<form name="sortorderdropdown" id="sortorderdropdown" style="float: left; margin-left: 10px;" action="#">
<select name="ListBoxURL" size="1" onchange="zp_gotoLink(this.form)">
<?php
$orderdate_desc = '';
$orderdate_asc = '';
$ordertitle_desc = '';
$ordertitle_asc = '';
$orderlastchange_desc = '';
$orderlastchange_asc = '';
if (isset($_GET['sortorder'])) {
switch ($_GET['sortorder']) {
case "date-desc":
$orderdate_desc = "selected='selected'";
break;
case "date-asc":
$orderdate_asc = "selected='selected'";
break;
case "title-desc":
$ordertitle_desc = "selected='selected'";
break;
case "title-asc":
$ordertitle_asc = "selected='selected'";
break;
case "lastchange-desc":
$orderlastchange_desc = "selected='selected'";
break;
case "lastchange-asc":
$orderlastchange_asc = "selected='selected'";
break;
}
} else {
$orderdate_desc = "selected='selected'";
}
$option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'published' => 0, 'articles_page' => 1, 'author' => 0));
echo "<option $orderdate_desc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'date-desc'), $option)) . "'>" . gettext("Order by date descending") . "</option>\n";
echo "<option $orderdate_asc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'date-asc'), $option)) . "'>" . gettext("Order by date ascending") . "</option>\n";
echo "<option $ordertitle_desc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'title-desc'), $option)) . "'>" . gettext("Order by title descending") . "</option>\n";
echo "<option $ordertitle_asc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'title-asc'), $option)) . "'>" . gettext("Order by title ascending") . "</option>\n";
echo "<option $orderlastchange_desc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'lastchange-desc'), $option)) . "'>" . gettext("Order by last change date descending") . "</option>\n";
echo "<option $orderlastchange_asc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'lastchange-asc'), $option)) . "'>" . gettext("Order by last change date ascending") . "</option>\n";
?>
</select>
</form>
<?php
}
function printCategoryDropdown() {
global $_zp_zenpage;
$result = $_zp_zenpage->getAllCategories(false);
if (isset($_GET['date'])) {
$datelink = "&date=" . sanitize($_GET['date']);
$datelinkall = "?date=" . sanitize($_GET['date']);
} else {
$datelink = "";
$datelinkall = "";
}
if (isset($_GET['category'])) {
$selected = '';
$category = sanitize($_GET['category']);
} else {
$selected = "selected='selected'";
$category = "";
}
?>
<form name ="categorydropdown" id="categorydropdown" style="float:left" action="#" >
<select name="ListBoxURL" size="1" onchange="zp_gotoLink(this.form)">
<?php
$option = getNewsAdminOption(array('date' => 0, 'published' => 0, 'sortorder' => 0, 'articles_page' => 1, 'author' => 0));
echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath($option) . "'>" . gettext("All categories") . "</option>\n";
foreach ($result as $cat) {
$catobj = new ZenpageCategory($cat['titlelink']);
$count = count($catobj->getArticles(0, 'all'));
$count = " (" . $count . ")";
if ($category == $cat['titlelink']) {
$selected = "selected='selected'";
} else {
$selected = "";
}
$getparents = $catobj->getParents();
$levelmark = '';
foreach ($getparents as $parent) {
$levelmark .= '» ';
}
$title = $catobj->getTitle();
if (empty($title)) {
$title = '*' . $catobj->getTitlelink() . '*';
}
if ($count != " (0)") {
echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('category' => $catobj->getTitlelink()), $option)) . "'>" . $levelmark . $title . $count . "</option>\n";
}
}
?>
</select>
</form>
<?php
}
function printArticlesPerPageDropdown($subpage, $articles_page) {
global $_zp_zenpage;
?>
<form name="articlesperpagedropdown" id="articlesperpagedropdown" method="POST" style="float: left; margin-left: 10px;" action="#">
<select name="ListBoxURL" size="1" onchange="zp_gotoLink(this.form)">
<?php
$option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'published' => 0, 'sortorder' => 0, 'author' => 0));
$list = array_unique(array(15, 30, 60, max(1, getOption('articles_per_page'))));
sort($list);
foreach ($list as $count) {
?>
<option <?php if ($articles_page == $count) echo 'selected="selected"'; ?> value="admin-news-articles.php<?php echo getNewsAdminOptionPath(array_merge(array('articles_page' => $count, 'subpage' => (int) ($subpage * $articles_page / $count)), $option)); ?>"><?php printf(gettext('%u per page'), $count); ?></option>
<?php
}
?>
<option <?php if ($articles_page == 0) echo 'selected="selected"'; ?> value="admin-news-articles.php<?php echo getNewsAdminOptionPath(array_merge(array('articles_page' => 'all'), $option)); ?>"><?php echo gettext("All"); ?></option>
</select>
</form>
<?php
}
function printAuthorDropdown() {
$authors = Zenpage::getAllAuthors();
$selected = "selected='selected'";
if (isset($_GET['author'])) {
$current_author = sanitize($_GET['author']);
} else {
$current_author = "";
}
?>
<form name="newssauthorsdropdown" id="newssauthorsdropdown" method="POST" style="float: left; margin-left: 10px;" action="#">
<select name="ListBoxURL" size="1" onchange="zp_gotoLink(this.form)">
<?php
$option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'published' => 0, 'articles_page' => 1, 'sortorder' => 0));
foreach ($authors as $author) {
?>
<option <?php if ($current_author == $author) echo $selected; ?>value="admin-news-articles.php<?php echo getNewsAdminOptionPath(array_merge(array('author' => $author), $option)); ?>"><?php echo $author; ?></option>
<?php
}
?>
<option <?php if ($current_author == 'all') echo $selected; ?>value="admin-news-articles.php<?php echo getNewsAdminOptionPath(array_merge(array('author' => 'all'), $option)); ?>"><?php echo gettext("All authors"); ?></option>
</select>
</form>
<?php
}
function updateCategory(&$reports, $newcategory = false) {
global $_zp_zenpage, $_zp_current_admin_obj;
$date = date('Y-m-d_H-i-s');
$id = sanitize_numeric($_POST['id']);
$permalink = getcheckboxState('permalink');
$title = process_language_string_save("title", 2);
$desc = process_language_string_save("desc", EDITOR_SANITIZE_LEVEL);
$custom = process_language_string_save("custom_data", 1);
if ($newcategory) {
$titlelink = createTitlelink($title, $date);
if(getOption('zenpage_titlelinkdate_categories')) {
$titlelink = addDateToTitlelink($titlelink);
}
$duplicate = checkTitlelinkDuplicate($titlelink, 'category');
if ($duplicate) {
$titlelink = addDateToTitlelink($titlelink);
$reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate category title') . '</p>';
}
$oldtitlelink = $titlelink;
} else {
$titlelink = $oldtitlelink = sanitize($_POST['titlelink-old'], 3);
if (getcheckboxState('edittitlelink')) {
$titlelink = sanitize($_POST['titlelink'], 3);
if (empty($titlelink)) {
$titlelink = createTitlelink($title, $date);
}
} else {
if (!$permalink) {
$link = seoFriendly(get_language_string($title));
if (!empty($link)) {
$titlelink = $link;
}
}
}
}
$titleok = true;
if ($titlelink != $oldtitlelink) {
$titleok = query('UPDATE ' . prefix('news_categories') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
if (!$titleok) {
$titlelink = $oldtitlelink;
} else {
SearchEngine::clearSearchCache();
}
}
$show = getcheckboxState('show');
$cat = new ZenpageCategory($titlelink, true);
$notice = processCredentials($cat);
$cat->setPermalink(getcheckboxState('permalink'));
$cat->set('title', $title);
$cat->setDesc($desc);
$cat->setLastChange();
$cat->setCustomData(zp_apply_filter('save_category_custom_data', $custom, $cat));
$cat->setShow($show);
if (getcheckboxState('resethitcounter')) {
$cat->set('hitcounter', 0);
}
if (getcheckboxState('reset_rating')) {
$cat->set('total_value', 0);
$cat->set('total_votes', 0);
$cat->set('used_ips', 0);
}
if ($newcategory) {
$cat->setDefaultSortorder();
$msg = zp_apply_filter('new_category', '', $cat);
if (empty($title)) {
$reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Category <em>%s</em> added but you need to give it a <strong>title</strong> before publishing!"), $titlelink) . '</p>';
} else if ($notice == '?mismatch=user') {
$reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Category user') . '</p>';
} else if ($notice) {
$reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
} else {
$reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Category <em>%s</em> added"), $titlelink) . '</p>';
}
} else {
$cat->setLastchangeUser($_zp_current_admin_obj->getUser());
$msg = zp_apply_filter('update_category', '', $cat, $oldtitlelink);
if ($titleok) {
if (empty($titlelink) OR empty($title)) {
$reports[] = "<p class='errorbox fade-message'>" . gettext("You forgot to give your category a <strong>title or titlelink</strong>!") . "</p>";
} else if ($notice == '?mismatch=user') {
$reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Category user') . '</p>';
} else if ($notice) {
$reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
} else {
$reports[] = "<p class='messagebox fade-message'>" . gettext("Category updated!") . "</p>";
}
} else {
$reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("A category with the title/titlelink <em>%s</em> already exists!"), html_encode($cat->getTitle())) . "</p>";
}
}
$checkupdates = true;
if ($newcategory) {
$checkupdates = false;
}
$cat->save($checkupdates);
if ($msg) {
$reports[] = $msg;
}
return $cat;
}
function deleteCategory($titlelink) {
$obj = new ZenpageCategory($titlelink);
$result = $obj->remove();
if ($result) {
SearchEngine::clearSearchCache();
return "<p class='messagebox fade-message'>" . gettext("Category successfully deleted!") . "</p>";
}
return "<p class='errorbox fade-message'>" . gettext("Category delete failed!") . "</p>";
}
function printCategoryListSortableTable($cat, $flag) {
global $_zp_zenpage;
if ($flag) {
$img = '../../images/drag_handle_flag.png';
} else {
$img = '../../images/drag_handle.png';
}
$count = count($cat->getArticles(0, false));
if ($cat->getTitle()) {
$cattitle = $cat->getTitle();
} else {
$cattitle = "<span style='color:red; font-weight: bold'> <strong>*</strong>" . $cat->getTitlelink() . "*</span>";
}
?>
<div class='page-list_row'>
<div class='page-list_title' >
<?php echo "<a href='admin-edit.php?newscategory&titlelink=" . $cat->getTitlelink() . "' title='" . gettext('Edit this category') . "'>" . $cattitle . "</a>" . checkHitcounterDisplay($cat->getHitcounter()); ?>
</div>
<div class="page-list_extra">
<?php echo $count; ?>
<?php echo gettext("articles"); ?>
</div>
<div class="page-list_iconwrapper">
<div class="page-list_icon"><?php
$password = $cat->getPassword();
if (!empty($password)) {
echo '<img src="../../images/lock.png" style="border: 0px;" alt="' . gettext('Password protected') . '" title="' . gettext('Password protected') . '" />';
}
?>
</div>
<div class="page-list_icon">
<?php
if ($cat->isPublished()) {
$title = gettext("Un-publish");
?>
<a href="?publish=0&titlelink=<?php echo html_encode($cat->getTitlelink()); ?>&XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo $title; ?>">
<img src="../../images/pass.png" alt="<?php gettext("Scheduled for published"); ?>" title="<?php echo $title; ?>" /></a>
<?php
} else {
$title = gettext("Publish");
?>
<a href="?publish=1&titlelink=<?php echo html_encode($cat->getTitlelink()); ?>&XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo $title; ?>">
<img src="../../images/action.png" alt="<?php echo gettext("Un-published"); ?>" title="<?php echo $title; ?>" /></a>
<?php
}
?>
</div>
<div class="page-list_icon">
<?php if ($count == 0) { ?>
<img src="../../images/icon_inactive.png" alt="<?php gettext('locked'); ?>" />
<?php
} else {
?>
<a href="../../../index.php?p=news&category=<?php echo js_encode($cat->getTitlelink()); ?>" title="<?php echo gettext("View category"); ?>">
<img src="images/view.png" alt="view" />
</a>
<?php } ?>
</div>
<?php
if (extensionEnabled('hitcounter')) {
?>
<div class="page-list_icon"><a
href="?hitcounter=1&id=<?php echo $cat->getID(); ?>&tab=categories&XSRFToken=<?php echo getXSRFToken('hitcounter') ?>"
title="<?php echo gettext("Reset hitcounter"); ?>"> <img
src="../../images/reset.png"
alt="<?php echo gettext("Reset hitcounter"); ?>" /> </a>
</div>
<?php
}
?>
<div class="page-list_icon"><a
href="javascript:confirmDelete('admin-categories.php?delete=<?php echo js_encode($cat->getTitlelink()); ?>&tab=categories&XSRFToken=<?php echo getXSRFToken('delete_category') ?>',deleteCategory)"
title="<?php echo gettext("Delete Category"); ?>"><img
src="../../images/fail.png" alt="<?php echo gettext("Delete"); ?>"
title="<?php echo gettext("Delete Category"); ?>" /></a>
</div>
<div class="page-list_icon"><input class="checkbox" type="checkbox" name="ids[]" value="<?php echo $cat->getTitlelink(); ?>"
onclick="triggerAllBox(this.form, 'ids[]', this.form.allbox);" />
</div>
</div>
</div>
<?php
}
function printCategoryCheckboxListEntry($cat, $articleid, $option, $class = '') {
$selected = '';
if (($option != "all") && !$cat->transient && !empty($articleid)) {
$cat2news = query_single_row("SELECT cat_id FROM " . prefix('news2cat') . " WHERE news_id = " . $articleid . " AND cat_id = " . $cat->getID());
$selected = "";
if (isset($cat2news['cat_id']) && !empty($cat2news['cat_id'])) {
$selected = "checked ='checked'";
}
}
$catname = $cat->getTitle();
$catlink = $cat->getTitlelink();
if ($cat->getPassword()) {
$protected = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/lock.png" alt="' . gettext('password protected') . '" />';
} else {
$protected = '';
}
$catid = $cat->getID();
echo '<label for="cat' . $catid . '"><input name="cat' . $catid . '" class="' . $class . '" id="cat' . $catid . '" type="checkbox" value="' . $catid . '"' . $selected . ' />' . $catname . ' ' . $protected . "</label>\n";
}
function printNestedItemsList($listtype = 'cats-sortablelist', $articleid = '', $option = '', $class = 'nestedItem') {
global $_zp_zenpage;
switch ($listtype) {
case 'cats-checkboxlist':
default:
$ulclass = "";
break;
case 'cats-sortablelist':
case 'pages-sortablelist':
$ulclass = " class=\"page-list\"";
break;
}
switch ($listtype) {
case 'cats-checkboxlist':
case 'cats-sortablelist':
$_zp_zenpage = new Zenpage();
$items = $_zp_zenpage->getAllCategories(false);
break;
case 'pages-sortablelist':
$items = $_zp_zenpage->getPages(false);
break;
default:
$items = array();
break;
}
$indent = 1;
$open = array(1 => 0);
$rslt = false;
foreach ($items as $item) {
switch ($listtype) {
case 'cats-checkboxlist':
case 'cats-sortablelist':
$itemobj = new ZenpageCategory($item['titlelink']);
$ismypage = $itemobj->isMyItem(ZENPAGE_NEWS_RIGHTS);
break;
case 'pages-sortablelist':
$itemobj = new ZenpagePage($item['titlelink']);
$ismypage = $itemobj->isMyItem(ZENPAGE_PAGES_RIGHTS);
break;
}
$itemsortorder = $itemobj->getSortOrder();
$itemid = $itemobj->getID();
if ($ismypage) {
$order = explode('-', $itemsortorder);
$level = max(1, count($order));
if ($toodeep = $level > 1 && $order[$level - 1] === '') {
$rslt = true;
}
if ($level > $indent) {
echo "\n" . str_pad("\t", $indent, "\t") . "<ul" . $ulclass . ">\n";
$indent++;
$open[$indent] = 0;
} else if ($level < $indent) {
while ($indent > $level) {
$open[$indent] --;
$indent--;
echo "</li>\n" . str_pad("\t", $indent, "\t") . "</ul>\n";
}
} else {
if ($open[$indent]) {
echo str_pad("\t", $indent, "\t") . "</li>\n";
$open[$indent] --;
} else {
echo "\n";
}
}
if ($open[$indent]) {
echo str_pad("\t", $indent, "\t") . "</li>\n";
$open[$indent] --;
}
switch ($listtype) {
case 'cats-checkboxlist':
echo "<li>\n";
printCategoryCheckboxListEntry($itemobj, $articleid, $option, $class);
break;
case 'cats-sortablelist':
echo str_pad("\t", $indent - 1, "\t") . "<li id=\"id_" . $itemid . "\">";
printCategoryListSortableTable($itemobj, $toodeep);
break;
case 'pages-sortablelist':
echo str_pad("\t", $indent - 1, "\t") . "<li id=\"id_" . $itemid . "\">";
printPagesListTable($itemobj, $toodeep);
break;
}
$open[$indent] ++;
}
}
while ($indent > 1) {
echo "</li>\n";
$open[$indent] --;
$indent--;
echo str_pad("\t", $indent, "\t") . "</ul>";
}
if ($open[$indent]) {
echo "</li>\n";
} else {
echo "\n";
}
return $rslt;
}
function updateItemSortorder($mode = 'pages') {
if (!empty($_POST['order'])) {
$order = processOrder($_POST['order']);
$parents = array('NULL');
foreach ($order as $id => $orderlist) {
$id = str_replace('id_', '', $id);
$level = count($orderlist);
$parents[$level] = $id;
$myparent = $parents[$level - 1];
switch ($mode) {
case 'pages':
$dbtable = prefix('pages');
break;
case 'categories':
$dbtable = prefix('news_categories');
break;
}
$sql = "UPDATE " . $dbtable . " SET `sort_order` = " . db_quote(implode('-', $orderlist)) . ", `parentid`= " . $myparent . " WHERE `id`=" . $id;
query($sql);
}
return true;
}
return false;
}
function checkForEmptyTitle($titlefield, $type, $truncate = true) {
switch ($type) {
case "page":
$text = gettext("Untitled page");
break;
case "news":
$text = gettext("Untitled article");
break;
case "category":
$text = gettext("Untitled category");
break;
}
$title = getBare($titlefield);
if ($title) {
if ($truncate) {
$title = truncate_string($title, 40);
}
} else {
$title = "<span style='color:red; font-weight: bold'>" . $text . "</span>";
}
echo $title;
}
function zenpagePublish($obj, $show) {
global $_zp_current_admin_obj;
$obj->setShow((int) ($show && 1));
$obj->setLastchangeUser($_zp_current_admin_obj->getUser());
$obj->save();
}
function skipScheduledPublishing($obj, $type = 'futuredate') {
global $_zp_current_admin_obj;
switch ($type) {
case 'futuredate':
$obj->setDateTime(date('Y-m-d H:i:s'));
$obj->setShow(1);
break;
case 'expiredate':
$obj->setExpiredate(null);
$obj->setShow(1);
break;
}
$obj->setLastchangeUser($_zp_current_admin_obj->getUser());
$obj->save();
}
function checkHitcounterDisplay($item) {
if ($item == 0) {
$hitcount = "";
} else {
if ($item == 1) {
$hits = gettext("hit");
} else {
$hits = gettext("hits");
}
$hitcount = " (" . $item . " " . $hits . ")";
}
return $hitcount;
}
function getNewsPagesStatistic($option) {
global $_zp_zenpage;
switch ($option) {
case "news":
$items = $_zp_zenpage->getArticles();
$type = gettext("Articles");
break;
case "pages":
$items = $_zp_zenpage->getPages(false);
$type = gettext("Pages");
break;
case "categories":
$type = gettext("Categories");
$items = $_zp_zenpage->getAllCategories(false);
break;
}
$total = count($items);
$pub = 0;
foreach ($items as $item) {
switch ($option) {
case "news":
$itemobj = new ZenpageNews($item['titlelink']);
break;
case "pages":
$itemobj = new ZenpagePage($item['titlelink']);
break;
case "categories":
$itemobj = new ZenpageCategory($item['titlelink']);
break;
}
if ($itemobj->isPublished()) {
$pub++;
}
}
$unpub = $total - $pub;
return array($total, $type, $unpub);
}
function printPagesStatistic() {
list($total, $type, $unpub) = getNewsPagesStatistic("pages");
if (empty($unpub)) {
printf(ngettext('<strong>%1$u</strong> page', '<strong>%1$u</strong> pages', $total), $total);
} else {
printf(ngettext('<strong>%1$u</strong> page (<strong>%2$u</strong> un-published)', '<strong>%1$u</strong> pages (<strong>%2$u</strong> un-published)', $total), $total, $unpub);
}
}
function printNewsStatistic() {
list($total, $type, $unpub) = getNewsPagesStatistic("news");
if (empty($unpub)) {
printf(ngettext('<strong>%1$u</strong> article', '<strong>%1$u</strong> articles', $total), $total);
} else {
printf(ngettext('<strong>%1$u</strong> article (<strong>%2$u</strong> un-published)', '<strong>%1$u</strong> articles (<strong>%2$u</strong> un-published)', $total), $total, $unpub);
}
}
function printCategoriesStatistic() {
list($total, $type, $unpub) = getNewsPagesStatistic("categories");
if (empty($unpub)) {
printf(ngettext('<strong>%1$u</strong> category', '<strong>%1$u</strong> categories', $total), $total);
} else {
printf(ngettext('<strong>%1$u</strong> category (<strong>%2$u</strong> un-published)', '<strong>%1$u</strong> categories (<strong>%2$u</strong> un-published)', $total), $total, $unpub);
}
}
function zenpageJSCSS() {
?>
<link rel="stylesheet" href="zenpage.css" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
$("#tip a").click(function() {
$("#tips").toggle("slow");
});
});
</script>
<?php
}
function printZenpageIconLegend() {
?>
<ul class="iconlegend">
<?php
if (GALLERY_SECURITY == 'public') {
?>
<li><img src="../../images/lock.png" alt="" /><?php echo gettext("Has Password"); ?></li>
<li><img src="../../images/pass.png" alt="" /><img src="../../images/action.png" alt="" /><?php echo gettext("Published/Not published"); ?></li>
<li><img src="../../images/clock_futuredate.png" alt="" /><img src="../../images/clock_expiredate.png" alt="" /><img src="../../images/clock_expired.png" alt="" /><?php echo gettext("Scheduled publishing/Scheduled expiration/Expired"); ?></li>
<?php
}
?>
<li><img src="../../images/comments-on.png" alt="" /><img src="../../images/comments-off.png" alt="" /><?php echo gettext("Comments on/off"); ?></li>
<li><img src="../../images/view.png" alt="" /><?php echo gettext("View"); ?></li>
<?php
if (extensionEnabled('hitcounter')) {
?>
<li><img src="../../images/reset.png" alt="" /><?php echo gettext("Reset hitcounter"); ?></li>
<?php
}
?>
<li><img src="../../images/fail.png" alt="" /><?php echo gettext("Delete"); ?></li>
</ul>
<?php
}
function authorSelector($author = NULL) {
global $_zp_authority, $_zp_current_admin_obj;
if (empty($author)) {
$author = $_zp_current_admin_obj->getUser();
}
$authors = array($author => $author);
if (zp_loggedin(MANAGE_ALL_PAGES_RIGHTS | MANAGE_ALL_NEWS_RIGHTS)) {
$admins = $_zp_authority->getAdministrators();
foreach ($admins as $admin) {
if ($admin['rights'] & (ADMIN_RIGHTS | ZENPAGE_PAGES_RIGHTS | ZENPAGE_NEWS_RIGHTS)) {
$authors[$admin['user']] = $admin['user'];
}
}
}
?>
<select size='1' name="author" id="author">
<?php
generateListFromArray(array($author), $authors, false, false);
?>
</select>
<?php
}
function printPublishIconLink($object, $type, $linkback = '') {
$urladd = '';
if ($type == "news") {
if (isset($_GET['subpage'])) {
$urladd .= "&subpage=" . sanitize($_GET['subpage']);
}
if (isset($_GET['date'])) {
$urladd .= "&date=" . sanitize($_GET['date']);
}
if (isset($_GET['category'])) {
$urladd .= "&category=" . sanitize($_GET['category']);
}
if (isset($_GET['sortorder'])) {
$urladd .= "&sortorder=" . sanitize($_GET['sortorder']);
}
if (isset($_GET['articles_page'])) {
$urladd .= "&articles_page=" . sanitize_numeric($_GET['articles_page']);
}
}
if ($object->hasPublishSchedule()) {
$title = gettext("Publish immediately (skip scheduling)");
$alt = gettext("Scheduled for published");
$action = '?skipscheduling=1';
$icon = '../../images/clock_futuredate.png';
} else if ($object->hasExpiration()) {
$title = gettext("Skip scheduled expiration");
$alt = gettext("Scheduled for expiration");
$action = '?skipexpiration=1';
$icon = '../../images/clock_expiredate.png';
} else if ($object->isPublished()) {
$title = gettext("Un-publish");
$alt = gettext("Published");
$action = '?publish=0';
$icon = '../../images/pass.png';
} else if (!$object->isPublished()) {
if ($object->hasExpired()) {
$title = gettext("Publish immediately (skip expiration)");
$alt = gettext("Un-published because expired");
$action = '?skipexpiration=1';
$icon = '../../images/clock_expired.png';
} else {
$title = gettext("Publish");
$alt = gettext("Un-published");
$action = '?publish=1';
$icon = '../../images/action.png';
}
}
?>
<a href="<?php echo $action; ?>&titlelink=<?php echo html_encode($object->getTitlelink()) . $urladd; ?>&XSRFToken=<?php echo getXSRFToken('update') ?>">
<img src="<?php echo $icon; ?>" alt="<?php echo $alt; ?>" title= "<?php echo $title; ?>" />
</a>
<?php
}
function checkIfChecked($field) {
if ($field) {
echo 'checked="checked"';
}
}
function checkIfLockedPage($page) {
global $_zp_current_admin_obj;
if (zp_loggedin(ADMIN_RIGHTS))
return true;
if ($page->getLocked()) {
return $_zp_current_admin_obj->getUser() == $page->getAuthor() && $page->isMyItem(ZENPAGE_PAGES_RIGHTS);
} else {
return true;
}
}
function checkIfLockedNews($news) {
global $_zp_current_admin_obj;
if (zp_loggedin(ADMIN_RIGHTS))
return true;
if ($news->getLocked()) {
return $_zp_current_admin_obj->getUser() == $news->getAuthor() && $news->isMyItem(ZENPAGE_NEWS_RIGHTS);
} else {
return true;
}
}
function is_AdminEditPage($page) {
return isset($_GET[$page]);
}
function processZenpageBulkActions($type) {
global $_zp_zenpage, $_zp_current_admin_obj;
$action = false;
if (isset($_POST['ids'])) {
$action = sanitize($_POST['checkallaction']);
$links = sanitize($_POST['ids']);
$total = count($links);
$message = NULL;
$sql = '';
if ($action != 'noaction') {
if ($total > 0) {
if ($action == 'addtags' || $action == 'alltags') {
$tags = bulkTags();
}
if ($action == 'addcats') {
foreach ($_POST as $key => $value) {
$key = postIndexDecode($key);
if (substr($key, 0, 3) == 'cat') {
if ($value) {
$cats[] = substr($key, 3);
}
}
}
$cats = sanitize($cats, 3);
}
$n = 0;
foreach ($links as $titlelink) {
$class = 'Zenpage' . $type;
$obj = new $class($titlelink);
switch ($action) {
case 'deleteall':
$obj->remove();
SearchEngine::clearSearchCache();
break;
case 'addtags':
$mytags = array_unique(array_merge($tags, $obj->getTags()));
$obj->setTags($mytags);
break;
case 'cleartags':
$obj->setTags(array());
break;
case 'alltags':
$allarticles = $obj->getArticles('', 'all', true);
foreach ($allarticles as $article) {
$newsobj = new ZenpageNews($article['titlelink']);
$mytags = array_unique(array_merge($tags, $newsobj->getTags()));
$newsobj->setTags($mytags);
$newsobj->setLastchangeUser($_zp_current_admin_obj->getUser());
$newsobj->save(true);
}
break;
case 'clearalltags':
$allarticles = $obj->getArticles('', 'all', true);
foreach ($allarticles as $article) {
$newsobj = new ZenpageNews($article['titlelink']);
$newsobj->setTags(array());
$newsobj->setLastchangeUser($_zp_current_admin_obj->getUser());
$newsobj->save(true);
}
break;
case 'addcats':
$catarray = array();
$allcats = $obj->getCategories();
foreach ($cats as $cat) {
$catitem = $_zp_zenpage->getCategory($cat);
$catarray[] = $catitem['titlelink'];
}
$allcatsarray = array();
foreach ($allcats as $allcat) {
$allcatsarray[] = $allcat['titlelink'];
}
$mycats = array_unique(array_merge($catarray, $allcatsarray));
$obj->setCategories($mycats);
break;
case 'clearcats':
$obj->setCategories(array());
break;
case 'showall':
$obj->set('show', 1);
break;
case 'hideall':
$obj->set('show', 0);
break;
case 'commentson':
$obj->set('commentson', 1);
break;
case 'commentsoff':
$obj->set('commentson', 0);
break;
case 'resethitcounter':
$obj->set('hitcounter', 0);
break;
}
$obj->setLastchangeUser($_zp_current_admin_obj->getUser());
$obj->save(true);
}
}
}
}
return $action;
}
function zenpageBulkActionMessage($action) {
switch ($action) {
case 'deleteall':
$message = gettext('Selected items deleted');
break;
case 'showall':
$message = gettext('Selected items published');
break;
case 'hideall':
$message = gettext('Selected items unpublished');
break;
case 'commentson':
$message = gettext('Comments enabled for selected items');
break;
case 'commentsoff':
$message = gettext('Comments disabled for selected items');
break;
case 'resethitcounter':
$message = gettext('Hitcounter for selected items');
break;
case 'addtags':
$message = gettext('Tags added to selected items');
break;
case 'cleartags':
$message = gettext('Tags cleared from selected items');
break;
case 'alltags':
$message = gettext('Tags added to articles of selected items');
break;
case 'clearalltags':
$message = gettext('Tags cleared from articles of selected items');
break;
case 'addcats':
$message = gettext('Categories added to selected items');
break;
case 'clearcats':
$message = gettext('Categories cleared from selected items');
break;
default:
return "<p class='notebox fade-message'>" . gettext('Nothing changed') . "</p>";
}
if (isset($message)) {
return "<p class='messagebox fade-message'>" . $message . "</p>";
}
return false;
}
function createTitlelink($title, $date) {
$titlelink = seoFriendly(get_language_string($title));
if (empty($titlelink)) {
$titlelink = seoFriendly($date);
}
return $titlelink;
}
function checkTitlelinkDuplicate($titlelink, $itemtype) {
switch ($itemtype) {
case 'article':
$table = prefix('news');
break;
case 'category':
$table = prefix('news_categories');
break;
case 'page':
$table = prefix('pages');
break;
}
$sql = 'SELECT `id` FROM ' . $table . ' WHERE `titlelink`=' . db_quote($titlelink);
$rslt = query_single_row($sql, false);
return $rslt;
}
function addDateToTitlelink($titlelink) {
$addwhere = getOption('zenpage_titlelinkdate_location');
$dateformat = getOption('zenpage_titlelinkdate_dateformat');
switch($dateformat) {
case 'Y-m-d':
case 'Ymd':
case 'Y-m-d_H-i-s':
case 'YmdHis':
$date = date($dateformat);
break;
default:
case 'timestamp':
$date = time();
break;
}
switch ($addwhere) {
case 'before':
$titlelink = $date . '-' . $titlelink;
break;
default:
case 'after':
$titlelink = $titlelink . '-' . $date;
break;
}
return $titlelink;
}