17 require_once SQ_CORE_PACKAGE_PATH.
'/folder/folder_edit_fns.inc';
40 parent::__construct();
41 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
42 $this->static_screens[
'details'][
'lock_type'] =
'content';
59 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
60 echo
'<b>Section Name</b> ';
61 text_box($prefix.
'_new_section',
'', 20);
82 if (isset($_POST[$prefix.
'_new_section']) && trim($_POST[$prefix.
'_new_section'])) {
83 $new_section_name = trim($_POST[$prefix.
'_new_section']);
84 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'metadata_section');
86 $schema_link = Array(
'asset' => &$asset,
'link_type' => SQ_LINK_TYPE_2,
'sort_order' => -1,
'is_dependant' => 1);
87 $new_section->setAttrValue(
'name', $new_section_name);
88 if (!$new_section->create($schema_link))
return FALSE;
110 $o->
note(translate(
'metadata_regenerate_for_currently_applied'));
111 check_box($prefix.
'_regenerate');
112 label(translate(
'metadata_regenerate_files'));
114 $o->
note(translate(
'metadata_cannot_regenerate'));
137 if (isset($_POST[$prefix.
'_regenerate']) && $_POST[$prefix.
'_regenerate']) {
138 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
139 $vars = Array(
'schemaids' => Array($asset->id,));
140 $hh->queueHipo(
'hipo_job_regenerate_metadata', $vars);
160 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
163 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_section', FALSE,
'major', NULL, TRUE, FALSE);
164 foreach ($current_links as $link_data) {
165 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_data[
'minorid']);
166 if (is_null($section))
continue;
170 $o->
openField(translate(
'delete_question'));
171 check_box($prefix.
'_delete_sections['.$link_data[
'linkid'].
']');
172 label(translate(
'delete_section-field_question'));
175 $edit_fns = $section->getEditFns();
176 if (!$edit_fns->paintInlineOptionInterface($section, $o)) {
204 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_section', FALSE,
'major', NULL, TRUE, FALSE);
205 foreach ($current_links as $link_data) {
206 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_data[
'minorid']);
207 if (is_null($section))
continue;
208 $edit_fns = $section->getEditFns();
209 if ($edit_fns->processInlineOptionInterface($section, $o)) {
215 if (isset($_POST[$prefix.
'_delete_sections'])) {
216 $delete_sections = $_POST[$prefix.
'_delete_sections'];
217 foreach ($delete_sections as $linkid => $on) {
218 if ($asset->
deleteLink($linkid)) $updated = TRUE;
245 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_section', FALSE,
'major', NULL, TRUE);
247 foreach ($current_links as $link) {
248 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
249 if (is_null($section))
continue;
250 $edit_fns = $section->getEditFns();
251 if ($edit_fns->paintInlineValueInterface($section, $o, $values, $write_access, $print_cascade_values_option, $type_code)) {
277 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_section', FALSE,
'major', NULL, TRUE);
278 foreach ($current_links as $link) {
279 $section_cascade_values_asset_ids = Array();
280 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
281 if (is_null($section))
continue;
282 $edit_fns = $section->getEditFns();
283 if ($edit_fns->processInlineValueInterface($section, $new_values, $section_cascade_values_asset_ids, $type_code)) {
286 foreach($section_cascade_values_asset_ids as $asset_id => $val) {
287 $schema_cascade_values_asset_ids[$asset_id] = 1;
309 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_section', FALSE,
'major', NULL, TRUE);
310 foreach ($current_links as $link) {
311 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
312 if (is_null($section))
continue;
313 $edit_fns = $section->getEditFns();
314 if (!$edit_fns->requiredFieldsComplete($section, $values, $type_code)) {
338 $frontend_option = $asset->
attr(
'frontend');
340 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
345 echo
'<!-- '.$mm->escapeMetadata($asset->name).
' //-->'.
"\n\n";
347 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_section', TRUE,
'major', NULL, TRUE);
348 $valid_sections = Array();
349 foreach ($current_links as $link) {
350 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
351 if (is_null($section))
continue;
352 $valid_sections[] = $section->name;
354 $edit_fns = $section->getEditFns();
356 if (!$edit_fns->generateMetadata($section, $values, $tag_values, $keywords, $type_code)) {
364 $contents = ob_get_clean();
365 if ($frontend_option) echo $contents;
381 $schema_treeids_sql =
'SELECT
382 treeid, assetid, granted, cascades
383 FROM (sq_ast_lnk_tree ta
384 JOIN sq_ast_lnk la ON ta.linkid = la.linkid
385 JOIN sq_ast_mdata ma ON la.minorid = ma.assetid)
386 WHERE ma.schemaid = :schemaid
388 SELECT * FROM (sq_ast_lnk_tree tb
389 JOIN sq_ast_lnk lb ON tb.linkid = lb.linkid
390 JOIN sq_ast_mdata mb ON lb.minorid = mb.assetid)
391 WHERE mb.schemaid = ma.schemaid
392 AND length(ta.treeid) - LENGTH(tb.treeid) = :tree_size AND SUBSTR(ta.treeid, 1, LENGTH(ta.treeid) - :tree_size_1) = tb.treeid
393 AND ma.granted = mb.granted
394 AND ma.cascades = mb.cascades
395 ) ORDER BY length(treeid), treeid';
403 if (count($treeids) > 0) {
406 $num_pages = ceil(count($tree_tops) / $page_size);
407 $page_num = array_get_index($_POST, $prefix.
'_usage_page', 1);
408 $page_num = max($page_num, 1);
409 $page_num = min($page_num, $num_pages);
411 if ($num_pages == 1) {
412 $page_tag = translate(
'page_number', $page_num, $num_pages);
414 $page_tag = translate(
'page_number_with_pager', $page_num, $num_pages, $prefix.
'_usage_page');
416 $asset_count_tag = translate(
'item_range', ($page_num - 1) * $page_size + 1, min(count($tree_tops), $page_num * $page_size), count($tree_tops), strtolower(translate(
'trees')));
418 $tree_tops = array_slice($tree_tops, ($page_num - 1) * $page_size, $page_size);
421 'first' =>
'<<',
422 'previous' =>
'<',
425 'last' =>
'>>',
429 $links[
'first'] =
'<a title="'.translate(
'pagination_go_to_first').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_usage_page\', 1)">'.$links[
'first'].
'</a>';
430 $links[
'previous'] =
'<a title="'.translate(
'pagination_go_to_previous').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_usage_page\', '.($page_num - 1).
')">'.$links[
'previous'].
'</a>';
432 $links[
'first'] =
'<span title="'.translate(
'pagination_cannot_go_further_back').
'." style="color: #333">'.$links[
'first'].
'</span>';
433 $links[
'previous'] =
'<span title="'.translate(
'pagination_cannot_go_further_back').
'." style="color: #333">'.$links[
'previous'].
'</span>';
436 if ($page_num < $num_pages) {
437 $links[
'last'] =
'<a title="'.translate(
'pagination_go_to_last').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_usage_page\', '.$num_pages.
')">'.$links[
'last'].
'</a>';
438 $links[
'next'] =
'<a title="'.translate(
'pagination_go_to_next').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_usage_page\', '.($page_num + 1).
')">'.$links[
'next'].
'</a>';
440 $links[
'last'] =
'<span title="'.translate(
'pagination_cannot_go_further_forward').
'." style="color: #333">'.$links[
'last'].
'</span>';
441 $links[
'next'] =
'<span title="'.translate(
'pagination_cannot_go_further_forward').
'." style="color: #333">'.$links[
'next'].
'</span>';
444 hidden_field($prefix.
'_usage_page', $page_num); ?>
445 <table
class=
"sq-backend-table">
447 <tr
class=
"sq-backend-table-row">
448 <td
class=
"sq-backend-table-header-header"><?php echo implode(
' ', $links) ?></td>
449 <td
class=
"sq-backend-table-header-header" colspan=
"2" style=
"text-align: right; font-weight: normal"><?php echo $asset_count_tag; ?></span></td>
451 <tr
class=
"sq-backend-table-row">
452 <th
class=
"sq-backend-table-cell"><?php echo translate(
'asset'); ?></th>
453 <th style=
"width: 15%" class=
"sq-backend-table-cell"><?php echo translate(
'granted_question') ?></th>
454 <th style=
"width: 15ex" class=
"sq-backend-table-cell"><?php echo translate(
'cascade_question') ?></th>
460 foreach ($tree_tops as $tt_assetid => &$tree_top_info) {
461 $root_tree = $tree_top_info;
462 unset($root_tree[
'sub_trees']);
463 $root_trees = array_merge(Array($root_tree), $tree_top_info[
'sub_trees']);
465 foreach ($root_trees as $root_assetid => &$tree_info) {
467 ?><tr
class=
"sq-backend-table-row">
468 <td
class=
"sq-backend-table-cell">
471 $tag_line = get_asset_tag_line($tree_info[
'assetid'],
'details');
473 echo ($tree_info[
'depth'] === 0 ?
'' :
'<span style="padding-left: '.($tree_info[
'depth']*5).
'ex">');
474 echo translate(
'asset_and_child_count_0', $tag_line);
475 echo ($tree_info[
'depth'] === 0 ?
'' :
'</span>');
478 <td
class=
"sq-backend-table-cell">
479 <strong><span style=
"color: <?php echo (($tree_info['granted'] == '0') ? 'red' : 'green'); ?>"><?php echo (($tree_info[
'granted'] ==
'0') ? translate(
'denied') : translate(
'applied')) ?></span></strong>
481 <td
class=
"sq-backend-table-cell">
482 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo ($tree_info['cascades'] === '1' ? 'tick' : 'cross'); ?>.gif" width=
"15" height=
"15" style=
"vertical-align: middle;" alt=
"<?php echo translate($tree_info['cascades'] === '1' ? 'yes' : 'no'); ?>" />
497 $o->
note(translate(
'core_schema_usage_explanation'));
500 $o->
note(translate(
'core_schema_usage_no_assets'));
528 $used_assetids = Array();
530 $all_treeids = Array();
531 foreach ($treeids as $treeid) {
532 $all_treeids[$treeid[
'treeid']] = $treeid;
537 foreach ($all_treeids as $tree_info) {
538 $treeid = $tree_info[
'treeid'];
539 $treeid_copy = $treeid;
540 $top_parent = $treeid;
542 $used_sub_tree = FALSE;
544 while (empty($treeid_copy) === FALSE) {
545 if (isset($res[$treeid_copy]) === TRUE) {
546 if ($used_sub_tree === FALSE) {
547 $used_sub_tree = TRUE;
551 if (($used_sub_tree === TRUE) && (array_key_exists($treeid_copy, $all_treeids) === TRUE)) {
552 $top_parent = $treeid_copy;
556 $treeid_copy = substr($treeid_copy, 0, -SQ_CONF_ASSET_TREE_SIZE);
559 $res[$treeid] = $tree_info;
560 $res[$treeid][
'top_parent'] = $top_parent;
561 $res[$treeid][
'depth'] = $depth;
562 $res[$treeid][
'sub_trees'] = Array();
566 if (array_search($tree_info[
'assetid'], $used_assetids) === FALSE) {
567 $res[$treeid][
'dupe'] = FALSE;
568 $used_assetids[] = $tree_info[
'assetid'];
570 $res[$treeid][
'dupe'] = TRUE;
574 foreach ($res as $key => &$res_item) {
575 if ($res_item[
'dupe'] === TRUE) {
578 if ($res_item[
'depth'] > 0) {
579 $res[$res_item[
'top_parent']][
'sub_trees'][$res_item[
'treeid']] =& $res_item;
586 foreach ($res as $key => &$res_item) {
587 uksort($res_item[
'sub_trees'], create_function(
'$key1,$key2',
'return strcmp($key1, $key2);'));