PageRenderTime 62ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/app/cms/boxes/nav/index.php

https://github.com/olegiv/sitellite
PHP | 293 lines | 219 code | 21 blank | 53 comment | 28 complexity | 4290d59de4c40b370d0fe023b2ffccdb MD5 | raw file
  1. <?php
  2. global $cgi;
  3. $data = array ();
  4. $content_types = array ();
  5. $GLOBALS['_content_weights'] = array ();
  6. $applications = parse_ini_file ('inc/conf/auth/applications/index.php');
  7. loader_import ('saf.File.Directory');
  8. $files = Dir::find ('*.php', 'inc/app/cms/conf/collections', false);
  9. foreach ($files as $file) {
  10. if (strstr ($file, '/.')) {
  11. continue;
  12. }
  13. $data = ini_parse ($file);
  14. $GLOBALS['_content_weights'][$data['Collection']['name']] = $data['Collection']['list_weight'];
  15. if (! isset ($data['Collection']['visible']) || $data['Collection']['visible'] != false) {
  16. if (session_is_resource ($data['Collection']['name']) && ! session_allowed ($data['Collection']['name'], 'rw', 'resource')) {
  17. continue;
  18. }
  19. if (isset ($data['Collection']['app']) && isset ($applications[$data['Collection']['app']]) && ! $applications[$data['Collection']['app']]) {
  20. continue;
  21. }
  22. $content_types[$data['Collection']['name']] = intl_get ($data['Collection']['display']);
  23. }
  24. }
  25. function cms_collection_sort ($a, $b) {
  26. global $_content_weights, $_content_types;
  27. if ($a == $b) {
  28. return 0;
  29. }
  30. if (! isset ($_content_weights[$a]) && ! isset ($_content_weights[$b])) {
  31. return ($_content_types[$a] > $_content_types[$b]) ? 1 : -1;
  32. }
  33. return ($_content_weights[$a] > $_content_weights[$b]) ? -1 : 1;
  34. }
  35. $GLOBALS['_content_types'] = $content_types;
  36. uksort ($content_types, 'cms_collection_sort');
  37. foreach ($content_types as $k => $v) {
  38. $content_types[site_prefix () . '/index/cms-browse-action?collection=' . $k] = $v;
  39. unset ($content_types[$k]);
  40. }
  41. //asort ($content_types);
  42. $split = ceil (count ($content_types) / 2);
  43. $one = array_slice ($content_types, 0, $split);
  44. $two = array_slice ($content_types, $split);
  45. $data['content_panel'] = array (
  46. 'name' => 'content',
  47. 'caption' => intl_get ('Content'),
  48. 'action' => '',
  49. 'method' => 'get',
  50. 'select' => 'collection',
  51. 'selected' => $cgi->collection,
  52. 'options' => array ($one, $two),
  53. 'icons' => array (
  54. // hashes w/ href, src, & alt
  55. /*
  56. array (
  57. 'href' => 'javascript: document.forms[\'content\'].action = \'' . site_prefix () . '/index/cms-browse-action\'; document.forms[\'content\'].submit ()',
  58. 'src' => site_prefix () . '/inc/app/cms/pix/icons/browse.gif',
  59. 'alt' => intl_get ('Browse'),
  60. ),
  61. array (
  62. 'href' => 'javascript: document.forms[\'content\'].action = \'' . site_prefix () . '/index/cms-add-form?_return=' . site_prefix () . '/index/cms-browse-action' . urlencode ('?collection=' . $cgi->collection . $data['facet_url']) . '\'; document.forms[\'content\'].submit ()',
  63. 'src' => site_prefix () . '/inc/app/cms/pix/icons/add-larger.gif',
  64. 'alt' => intl_get ('Add'),
  65. ),
  66. array (
  67. 'href' => 'javascript: document.forms[\'content\'].action = \'' . site_prefix () . '/index/cms-deleted-items-action\'; document.forms[\'content\'].submit ()',
  68. 'src' => site_prefix () . '/inc/app/cms/pix/icons/deleted-items.gif',
  69. 'alt' => intl_get ('Deleted'),
  70. ),
  71. */
  72. ),
  73. );
  74. loader_import ('cms.Versioning.Rex');
  75. $c = 0;
  76. foreach ($one as $k => $v) {
  77. $ct = str_replace (site_prefix () . '/index/cms-browse-action?collection=', '', $k);
  78. $r = new Rex ($ct);
  79. if ($r->info['Collection']['icon']) {
  80. $icon = site_prefix () . '/' . $r->info['Collection']['icon'];
  81. } else {
  82. $icon = site_prefix () . '/inc/app/cms/pix/icons/content-type.gif';
  83. }
  84. $data['content_panel']['icons'][] = array (
  85. 'href' => $k,
  86. 'src' => $icon,
  87. 'alt' => $v,
  88. );
  89. $c++;
  90. if ($c >= 3) {
  91. break;
  92. }
  93. }
  94. if (session_is_resource ('app_usradm') && ! session_allowed ('app_usradm', 'rw', 'resource')) {
  95. $data['admin_panel'] = array (
  96. 'name' => 'admin',
  97. 'caption' => intl_get ('Admin'),
  98. 'action' => '#',
  99. 'method' => 'get',
  100. 'select' => 'list',
  101. 'selected' => '',
  102. 'select-extra' => 'disabled="disabled"',
  103. 'disabled' => 'yes',
  104. 'options' => array (
  105. // key/value
  106. array (),
  107. /*'users' => intl_get ('Users'),
  108. 'roles' => intl_get ('Roles'),
  109. 'teams' => intl_get ('Teams'),
  110. 'resources' => intl_get ('Resources'),
  111. 'statuses' => intl_get ('Statuses'),
  112. 'accesslevels' => intl_get ('Access Levels'),
  113. 'prefs' => intl_get ('Preferences'),*/
  114. ),
  115. 'icons' => array (
  116. // hashes w/ href, src, & alt
  117. array (
  118. 'href' => '#', //site_prefix () . '/index/usradm-browse-action?list=users',
  119. 'src' => site_prefix () . '/inc/app/cms/pix/icons/users_disabled.gif',
  120. 'alt' => intl_get ('Users'),
  121. ),
  122. array (
  123. 'href' => '#', //site_prefix () . '/index/usradm-browse-action?list=roles',
  124. 'src' => site_prefix () . '/inc/app/cms/pix/icons/roles_disabled.gif',
  125. 'alt' => intl_get ('Roles'),
  126. ),
  127. array (
  128. 'href' => '#', //site_prefix () . '/index/usradm-browse-action?list=teams',
  129. 'src' => site_prefix () . '/inc/app/cms/pix/icons/teams_disabled.gif',
  130. 'alt' => intl_get ('Teams'),
  131. ),
  132. ),
  133. );
  134. if (! appconf ('panels_show_disabled')) {
  135. $data['admin_panel']['icons'] = array ();
  136. $data['admin_panel']['show_disabled'] = 'yes';
  137. }
  138. } else {
  139. $data['admin_panel'] = array (
  140. 'name' => 'admin',
  141. 'caption' => intl_get ('Admin'),
  142. 'action' => site_prefix () . '/index/usradm-browse-action',
  143. 'method' => 'get',
  144. 'select' => 'list',
  145. 'selected' => '',
  146. 'select-extra' => 'onchange="this.form.submit ()"',
  147. 'options' => array (
  148. // key/value
  149. array (
  150. site_prefix () . '/index/usradm-browse-action?list=accesslevels' => intl_get ('Access Levels'),
  151. site_prefix () . '/index/usradm-browse-action?list=log' => intl_get ('Activity Log'),
  152. site_prefix () . '/index/usradm-applications-action' => intl_get ('Applications'),
  153. site_prefix () . '/index/usradm-cache-form' => intl_get ('Cache Settings'),
  154. site_prefix () . '/index/usradm-browse-action?list=prefs' => intl_get ('Preferences'),
  155. site_prefix () . '/index/usradm-browse-action?list=resources' => intl_get ('Resources'),
  156. ),
  157. array (
  158. site_prefix () . '/index/usradm-browse-action?list=roles' => intl_get ('Roles'),
  159. site_prefix () . '/index/usradm-settings-form' => intl_get ('Site Settings'),
  160. site_prefix () . '/index/usradm-browse-action?list=statuses' => intl_get ('Statuses'),
  161. site_prefix () . '/index/usradm-browse-action?list=teams' => intl_get ('Teams'),
  162. site_prefix () . '/index/usradm-browse-action?list=users' => intl_get ('Users'),
  163. site_prefix () . '/index/usradm-workflow-action' => intl_get ('Workflow Services'),
  164. )
  165. ),
  166. 'icons' => array (
  167. // hashes w/ href, src, & alt
  168. array (
  169. 'href' => site_prefix () . '/index/usradm-browse-action?list=users',
  170. 'src' => site_prefix () . '/inc/app/cms/pix/icons/users.gif',
  171. 'alt' => intl_get ('Users'),
  172. ),
  173. array (
  174. 'href' => site_prefix () . '/index/usradm-browse-action?list=roles',
  175. 'src' => site_prefix () . '/inc/app/cms/pix/icons/roles.gif',
  176. 'alt' => intl_get ('Roles'),
  177. ),
  178. array (
  179. 'href' => site_prefix () . '/index/usradm-browse-action?list=teams',
  180. 'src' => site_prefix () . '/inc/app/cms/pix/icons/teams.gif',
  181. 'alt' => intl_get ('Teams'),
  182. ),
  183. ),
  184. );
  185. }
  186. $apps = loader_box ('cms/admintools');
  187. $apps = explode (NEWLINE, $apps);
  188. $c = 0;
  189. foreach ($apps as $k => $v) {
  190. if (empty ($v)) {
  191. unset ($apps[$k]);
  192. continue;
  193. }
  194. list ($name, $link) = explode (TAB, $v);
  195. $apps[$link] = intl_get ($name);
  196. unset ($apps[$k]);
  197. if ($c == 0) {
  198. $short = array_shift (explode ('-', $link));
  199. $first_icon = array (
  200. 'href' => site_prefix () . '/index/' . $link,
  201. 'src' => site_prefix () . '/inc/app/' . $short . '/pix/icon.gif',
  202. 'alt' => intl_get ($name),
  203. );
  204. if (! @file_exists ('inc/app/' . $short . '/pix/icon.gif')) {
  205. $first_icon['src'] = site_prefix () . '/inc/app/cms/pix/default_icon.gif';
  206. }
  207. } elseif ($c == 1) {
  208. $short = array_shift (explode ('-', $link));
  209. $second_icon = array (
  210. 'href' => site_prefix () . '/index/' . $link,
  211. 'src' => site_prefix () . '/inc/app/' . $short . '/pix/icon.gif',
  212. 'alt' => intl_get ($name),
  213. );
  214. if (! @file_exists ('inc/app/' . $short . '/pix/icon.gif')) {
  215. $second_icon['src'] = site_prefix () . '/inc/app/cms/pix/default_icon.gif';
  216. }
  217. }
  218. $c++;
  219. }
  220. //$apps = array_merge (array ('' => '- ' . intl_get ('Choose') . ' -'), $apps);
  221. $split = ceil (count ($apps) / 2);
  222. $one = array_slice ($apps, 0, $split);
  223. $two = array_slice ($apps, $split);
  224. $data['app_panel'] = array (
  225. 'name' => 'app',
  226. 'caption' => intl_get ('Tools'),
  227. 'action' => '',
  228. 'method' => 'get',
  229. 'select' => 'list',
  230. 'selected' => '',
  231. 'select-extra' => 'onchange="this.form.action = \'' . site_prefix () . '/index/\' + this.options[this.selectedIndex].value; this.form.submit ()"',
  232. 'options' => array ($one, $two),
  233. 'icons' => array (
  234. // hashes w/ href, src, & alt
  235. $first_icon,
  236. $second_icon,
  237. /*array (
  238. 'href' => site_prefix () . '/index/sitetracker-app',
  239. 'src' => site_prefix () . '/inc/app/sitetracker/pix/icon.gif',
  240. 'alt' => intl_get ('SiteTracker'),
  241. ),
  242. array (
  243. 'href' => site_prefix () . '/index/sitemailer-app',
  244. 'src' => site_prefix () . '/inc/app/sitemailer/pix/icon.gif',
  245. 'alt' => intl_get ('SiteMailer'),
  246. ),*/
  247. array (
  248. 'href' => site_prefix () . '/index/cms-admintools-icons-action',
  249. 'src' => site_prefix () . '/inc/app/cms/pix/icons/more.gif',
  250. 'alt' => intl_get ('More'),
  251. ),
  252. /*array (
  253. 'href' => site_prefix () . '/index/devnotes-app',
  254. 'src' => site_prefix () . '/inc/app/devnotes/pix/icon.gif',
  255. 'alt' => intl_get ('DevNotes'),
  256. ),
  257. array (
  258. 'href' => site_prefix () . '/index/myadm-app',
  259. 'src' => site_prefix () . '/inc/app/myadm/pix/icon.gif',
  260. 'alt' => intl_get ('Database Manager'),
  261. ),*/
  262. ),
  263. );
  264. if (! appconf ('panels_show_disabled') && count ($apps) < 2) {
  265. array_pop ($data['app_panel']['icons']);
  266. }
  267. //loader_import ('saf.HTML');
  268. page_add_script (site_prefix () . '/js/dropmenu.js');
  269. template_bind ('/html/body', template_simple ('layout/panels.spt', $data));
  270. echo '<br clear="both" />
  271. <p style="padding-bottom: 60px">&nbsp;</p>';
  272. ?>