18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page.inc';
19 require_once SQ_FUDGE_PATH.
'/general/text.inc';
20 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
21 require_once SQ_FUDGE_PATH.
'/mollom/mollom.inc';
46 var $_current_state =
'';
52 var $_errors = Array();
58 var $_replacements = Array();
64 var $_default_state =
'create';
75 $this->_ser_attrs = TRUE;
76 parent::__construct($assetid);
93 if (!parent::_createAdditional($link))
return FALSE;
96 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
97 $copy_link = Array(
'asset' => &$this,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1,
'value' =>
'');
101 $bodycopy->setAttrValue(
'name', $details[
'name']);
102 $copy_link[
'value'] = $value;
103 unset($details[
'name']);
104 if (!$bodycopy->create($copy_link, $details)) {
125 if (!parent::saveAttributes($dont_run_updated)) {
133 if ($this->
id && !$GLOBALS[
'SQ_SYSTEM']->am->assetInTrash($this->id, TRUE)) {
134 $custom_types = $this->
attr(
'create_form_customisations');
135 $current_layout_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'layout', TRUE);
136 $current_layouts = Array();
137 foreach ($current_layout_links as $link) {
138 if (in_array($link[
'value'], $custom_types)) {
139 $current_layouts[] = $link[
'value'];
141 $GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($link[
'linkid']);
144 $types_needing_layouts = array_diff($custom_types, $current_layouts);
145 if (!empty($types_needing_layouts)) {
146 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($types_needing_layouts,
'name');
147 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'layout');
148 foreach ($types_needing_layouts as $type_code) {
150 $layout->setAttrValue(
'name', translate(
'cms_asset_builder_create_form_layout_for_type', $type_names[$type_code]));
153 'link_type' => SQ_LINK_TYPE_2,
154 'is_dependant' => TRUE,
155 'is_exclusive' => TRUE,
156 'value' => $type_code,
158 $layout->create($link);
187 function prepareLink(&$asset, $side_of_link, &$link_type, &$value, &$sort_order, &$dependant, &$exclusive)
190 if ($side_of_link ==
'major' && ($asset instanceof
Bodycopy) && $dependant !=
'1') {
211 $bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'bodycopy', TRUE,
'major', NULL,
'1',
'1');
213 if ($bodycopy_link[0][
'linkid'] == $linkid && !$GLOBALS[
'SQ_PURGING_TRASH']) {
214 return translate(
'cms_cannot_delete_link', $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->type(),
'name'));
217 return parent::isDeletableLink($linkid);
231 $page_links = parent::_getAllowedLinks();
232 $page_links[SQ_LINK_TYPE_2][
'bodycopy'] = Array(
'card' =>
'M',
'exclusive' => TRUE);
233 $page_links[SQ_LINK_NOTICE][
'metadata_schema'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
247 if (isset($_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION'])) {
248 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
251 $this->_current_state =
'';
252 $current_user = $GLOBALS[
'SQ_SYSTEM']->user;
253 set_error_handler(Array(&$this,
'_errorHandler'));
255 restore_error_handler();
258 if (isset($_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION']) && !$success) {
259 $this->_replacements[strtolower($_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION']).
'_error'] = $this->
attr(strtolower($_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION']).
'_error');
261 if (!empty($this->_errors)) {
263 foreach ($this->_errors as $text) {
264 $errors .=
'<li>'.$text.
'</li>';
266 $this->_replacements[strtolower($_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION']).
'_error'] .=
'<ul>'.$errors.
'</ul>';
271 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this,
'printBody');
276 if (isset($this->_tmp[
'created_asset'])) {
278 unset($this->_tmp[
'created_asset']);
281 if (empty($this->_current_state)) {
282 if (is_null($current_user) || ($current_user instanceof
Public_User)) {
284 $this->_current_state =
'not_logged_in';
288 $this->_current_state =
'logged_in';
292 $fn =
'_load'.$this->_default_state.
'Replacements';
297 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this,
'printBody');
299 if (isset($_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION'])) {
300 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
314 if ($this->_current_state ==
'created'){
317 $submission_url = $this->
attr(
'submit_to_page_url') ? replace_query_string_vars(Array(), $this->
getURL()) : replace_query_string_vars(Array());
319 <form
id=
"<?php echo $this->getPrefix() ?>" method=
"post" action=
"<?php echo htmlentities($submission_url); ?>" enctype=
"multipart/form-data" onsubmit=
"return form_on_submit()">
321 hidden_field(
'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION', $this->_default_state);
323 if (($additional_locs = $parameter_map->getParameterValue(
'additional_locations')) != NULL) {
324 hidden_field(
'AB_'.$this->
id.
'_ASSET_BUILDER_ADDITIONAL_LOCATIONS', $additional_locs);
325 }
else if (isset($_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ADDITIONAL_LOCATIONS'])) {
326 hidden_field(
'AB_'.$this->
id.
'_ASSET_BUILDER_ADDITIONAL_LOCATIONS', $_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ADDITIONAL_LOCATIONS']);
346 if (!$this->
attr(
'captcha_ttf') ==
'') {
347 $font = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->
attr(
'captcha_ttf'));
348 $file_path = $font->data_path.
'/'.$font->attr(
'name');
355 $this->
attr(
'captcha_length'),
356 $this->
attr(
'captcha_length'),
357 $this->
attr(
'captcha_zoom'),
359 trim($this->
attr(
'captcha_bgcolour'),
'#'),
360 trim($this->
attr(
'captcha_textcolour'),
'#'),
361 trim($this->
attr(
'captcha_bordercolour'),
'#'),
362 $this->
attr(
'captcha_use_colours'),
363 $this->
attr(
'captcha_usefont'),
365 $this->
attr(
'captcha_font_size'),
366 $this->
attr(
'captcha_min_angle'),
367 $this->
attr(
'captcha_max_angle'),
368 $this->
attr(
'captcha_x_start'),
369 $this->
attr(
'captcha_min_distance'),
370 $this->
attr(
'captcha_max_distance'),
371 $this->
attr(
'captcha_width'),
372 $this->
attr(
'captcha_height'),
373 $this->
attr(
'captcha_arc'),
374 trim($this->
attr(
'captcha_arc_colour'),
'#'),
375 $this->
attr(
'captcha_include_uppercase'),
376 $this->
attr(
'captcha_include_numbers'),
377 $this->
attr(
'provide_accessible_captcha')
379 return ob_get_clean();
392 if (!$this->
attr(
'captcha_ttf') ==
'') {
393 $font = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->
attr(
'captcha_ttf'));
394 $file_path = $font->data_path.
'/'.$font->attr(
'name');
400 security_key_image_box(
401 $this->
attr(
'captcha_length'),
402 $this->
attr(
'captcha_zoom'),
403 trim($this->
attr(
'captcha_bgcolour'),
'#'),
404 trim($this->
attr(
'captcha_textcolour'),
'#'),
405 trim($this->
attr(
'captcha_bordercolour'),
'#'),
406 $this->
attr(
'captcha_use_colours'),
407 $this->
attr(
'captcha_usefont'),
409 $this->
attr(
'captcha_font_size'),
410 $this->
attr(
'captcha_min_angle'),
411 $this->
attr(
'captcha_max_angle'),
412 $this->
attr(
'captcha_x_start'),
413 $this->
attr(
'captcha_min_distance'),
414 $this->
attr(
'captcha_max_distance'),
415 $this->
attr(
'captcha_width'),
416 $this->
attr(
'captcha_height'),
417 $this->
attr(
'captcha_arc'),
418 trim($this->
attr(
'captcha_arc_colour'),
'#'),
419 $this->
attr(
'captcha_include_uppercase'),
420 $this->
attr(
'captcha_include_numbers'),
421 $this->
attr(
'provide_accessible_captcha')
423 return ob_get_clean();
437 security_key_field($this->
attr(
'captcha_length'));
438 return ob_get_clean();
452 security_key_image_link($this->
attr(
'captcha_link_text'));
453 return ob_get_clean();
471 if (isset($_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION'])) {
476 switch (strtolower($_POST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION'])) {
486 $required_error = FALSE;
489 if ($this->
attr(
'require_captcha')) {
490 if (!validate_security_key()) {
491 $error_text = translate(
'security_key_incorrect');
492 trigger_error($error_text, E_USER_NOTICE);
493 $required_error = TRUE;
499 $create_type = $_POST[
'AB_'.$this->id.
'_ASSET_BUILDER_CREATE_TYPE'];
500 $allowed_types = $this->
attr(
'create_type');
501 if(!isset($allowed_types[$create_type])) {
502 trigger_error(
'Create type is not allowed', E_USER_NOTICE);
505 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($create_type);
506 $new_asset =
new $create_type();
507 $prefix = $new_asset->getPrefix();
514 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this,
'checkRequiredFields');
516 $required_fields = $this->
attr(
'required_fields');
517 if (!empty($required_fields[$new_asset->type()])) {
519 foreach ($required_fields[$new_asset->type()] as $attr => $error_text) {
520 $pos = strpos($attr, $this->
getPrefix().
'_metadata_');
521 if ($pos !== FALSE) {
523 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
524 $am = $GLOBALS[
'SQ_SYSTEM']->am;
525 $metadata_values = Array();
526 $cascade_values_asset_ids = Array();
527 $metadata_schemas = Array();
528 $metadata_schema_list = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'schema_to_apply');
529 foreach ($metadata_schema_list as $metadata_schema) {
530 $metadata_schemas[] = $metadata_schema[
'minorid'];
532 if (!empty($metadata_schemas)) {
534 $metadata_field = substr($attr, strlen($this->
getPrefix().
'_metadata_'));
535 $mf_asset = $am->getAsset($metadata_field);
540 if (!is_null($mf_asset)) {
541 $edit_fns = $mf_asset->getEditFns();
543 $did_process = $edit_fns->processInlineValueInterface($mf_asset, $result_value, $cascade, $create_type);
546 if ($mf_asset->type() ==
'metadata_field_date' && $result_value ==
'---------- --:--:--') {
551 $valid_value = FALSE;
553 if (empty($result_value)) {
555 if (!is_null($result_value)) {
556 $empty_value = FALSE;
563 if (empty($error_text)) {
564 $error_text = translate(
'cms_asset_builder_invalid_attr_value', $mf_asset->name);
566 trigger_error($error_text, E_USER_NOTICE);
567 $required_error = TRUE;
568 }
else if (!$empty_value) {
569 if (empty($error_text)) {
570 $error_text = translate(
'cms_asset_builder_missing_attr', $mf_asset->name);
572 trigger_error($error_text, E_USER_NOTICE);
573 $required_error = TRUE;
577 $am->forgetAsset($schema);
578 $am->forgetAsset($mf_asset);
579 $am->forgetAsset($temp_asset);
585 $real_attribute = $new_asset->getAttribute($attr, TRUE);
586 if (is_null($real_attribute))
continue;
588 $attribute = clone $real_attribute;
589 $attribute->process($prefix.
'_'.$attribute->id);
594 if (empty($attribute->value)) {
595 $attribute->process($prefix.
'_'.$attribute->name);
598 if (!$attribute->processed) {
599 if (empty($error_text)) {
600 $error_text = translate(
'cms_asset_builder_invalid_attr_value', $attribute->name);
602 trigger_error($error_text, E_USER_NOTICE);
603 $required_error = TRUE;
604 }
else if (empty($attribute->value)) {
605 if (empty($error_text)) {
606 $error_text = translate(
'cms_asset_builder_missing_attr', $attribute->name);
608 trigger_error($error_text, E_USER_NOTICE);
609 $required_error = TRUE;
612 unset($real_attribute);
621 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this,
'checkRequiredFields');
622 if ($required_error)
break;
628 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this,
'getCreateLocations');
633 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this,
'getCreateLocations');
638 if (empty($create_locations)) {
639 trigger_localised_error(
'CMS0033', E_USER_WARNING, $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($new_asset->type(),
'name'));
648 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this,
'createAsset');
651 require_once SQ_INCLUDE_PATH.
'/limbo_outputter.inc';
653 $create_location_key = array_keys($create_locations);
654 $create_parentid = $create_location_key[0];
655 $create_location_value = array_values($create_locations);
656 $link_type = $create_location_value[0];
657 $parent = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($create_parentid);
658 if (is_null($parent)) {
664 $grab_link_value = $this->
attr(
'link_value');
665 if (!empty($grab_link_value)) {
666 $link_value = trim($grab_link_value);
674 'link_type' => $create_locations[$create_parentid],
675 'value' => $link_value,
681 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
682 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
686 if ($this->
attr(
'allow_public_user')) {
687 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
697 $new_asset->fastTrack( Array(
698 'metadata_manager_generate_content_file',
699 'search_manager_reindex_metadata',
700 'trigger_event_metadata_updated',
703 $create_success = $new_asset->processBackend($o, $link);
704 $new_asset_linkid = FALSE;
705 if ($create_success && ($_REQUEST[
'asset_action'] !=
'create')) {
706 $new_asset_linkid = $new_asset->create($link);
707 $create_success = $create_success && $new_asset_linkid;
708 }
else if ($create_success) {
709 $new_asset_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkByAsset($parent->id, $new_asset->id);
710 $new_asset_linkid = array_get_index($new_asset_link,
'linkid', FALSE);
713 if (!$create_success) {
714 $this->_tmp[
'new_asset_created_'.$create_type] =& $new_asset;
715 $this->_abortAssetCreate($new_asset_linkid);
718 $attr_to_verify_assets = $this->
attr(
'mollom_attributes_to_check');
719 $attr_to_verify = isset($attr_to_verify_assets[$create_type]) ? $attr_to_verify_assets[$create_type] : Array();
720 $mollom_parameters = Array();
723 foreach ($new_asset->vars as $attr_name => $attr_info) {
725 $attr_value = array_get_index($attr_info,
'value',
'');
727 $attr_content_type = array_get_index($attr_to_verify, $attr_name, -1);
728 if ($attr_content_type >= 0) {
729 $mollom_parameters[$attr_content_type] = $attr_value;
733 if ($attr_info[
'type'] ==
'text') {
734 if ($attr_name ==
'name' || $attr_name ==
'short_name') {
735 $attr_name_value = htmlspecialchars($attr_info[
'value'], ENT_NOQUOTES);
736 $attr_name_value = str_replace(
'&',
'&', $attr_name_value);
737 $new_asset->setAttrValue($attr_name, $attr_name_value);
739 $attr_name_value = htmlspecialchars($attr_info[
'value']);
740 $attr_name_value = str_replace(
'&',
'&', $attr_name_value);
741 $new_asset->setAttrValue($attr_name, $attr_name_value);
749 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($new_asset->id,
'attributes');
750 $new_asset->saveAttributes();
751 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($new_asset->id,
'attributes');
754 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this,
'createAsset');
757 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this,
'processMetadata');
760 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
761 $metadata_values = Array();
763 $cascade_values_asset_ids = Array();
764 if (!empty($schemaids)) {
765 $metadata_run_level_changed = FALSE;
766 if ($GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_PERMISSIONS)) {
767 $GLOBALS[
'SQ_SYSTEM']->setRunLevel($GLOBALS[
'SQ_SYSTEM']->getRunLevel() - SQ_SECURITY_PERMISSIONS);
768 $metadata_run_level_changed = TRUE;
770 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($new_asset->id,
'metadata');
771 foreach ($schemaids as $schemaid) {
772 $schema = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($schemaid);
773 $mm->setSchema($new_asset->id, $schema->id, TRUE);
774 if (!is_null($schema)) {
775 $edit_fns = $schema->getEditFns();
776 $edit_fns->processInlineValueInterface($schema, $metadata_values, $cascade_values_asset_ids, $create_type);
781 $mm->setMetadata($new_asset->id, $metadata_values);
784 $new_asset->unFastTrack( Array(
785 'metadata_manager_generate_content_file',
786 'search_manager_reindex_metadata',
787 'trigger_event_metadata_updated',
790 $mm->regenerateMetadata($new_asset->id,
'all');
792 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($new_asset->id,
'metadata');
793 if ($metadata_run_level_changed) {
794 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
798 foreach($metadata_values as $fieldid => $m_data) {
799 $attr_content_type = array_get_index($attr_to_verify, $this->
getPrefix().
'_metadata_'.$fieldid, -1);
800 if ($attr_content_type >= 0) {
801 $m_value = array_get_index($m_data[0],
'value',
'');
802 if (!empty($m_value)) {
803 $mollom_parameters[$attr_content_type] = $m_value;
810 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this,
'processMetadata');
813 if ($this->
attr(
'use_mollom') && !empty($mollom_parameters)) {
815 switch ($mollom_result) {
818 $error_text = $this->
attr(
'mollom_spam_submission_text');
820 $this->_errors[] = $error_text;
822 $this->_errors[] = translate(
'cms_asset_builder_mollom_spam_submission_message');
826 case SQ_MOLLOM_UNSURE:
828 $error_text = $this->
attr(
'mollom_unsure_submission_text');
830 $this->_errors[] = $error_text;
832 $this->_errors[] = translate(
'cms_asset_builder_mollom_unsure_spam_submission_message');
840 case SQ_MOLLOM_UNKNOWN:
844 case SQ_MOLLOM_INCORRECT_CAPTCHA:
845 $error_text = $this->
attr(
'mollom_captcha_incorrect_text');
847 $this->_errors[] = $error_text;
849 $this->_errors[] = translate(
'cms_asset_builder_mollom_invalid_captcha_message');
856 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this,
'processLayouts');
859 $layouts[
'paint_layout::system::frontend'] = $this->
attr(
'layout_to_apply');
860 $layouts[
'override::paint_layout::system::frontend'] = $this->
attr(
'override_layout_to_apply');
861 $new_asset->setPaintLayouts($layouts);
864 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this,
'processLayouts');
867 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this,
'linkMultipleLocations');
871 if (is_array($create_locations)) {
872 foreach ($create_locations as $link_parentid => $link_type) {
875 if ($link_parentid == $parent->id)
continue;
877 $link_parent = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_parentid,
'', TRUE);
878 if (is_null($link_parent)) {
879 trigger_localised_error(
'CMS0034', E_USER_WARNING, $link_parentid);
882 if (!$GLOBALS[
'SQ_SYSTEM']->am->createAssetLink($link_parent, $new_asset, $link_type, $link_value)) {
883 trigger_localised_error(
'CMS0035', E_USER_WARNING, $link_parent->id);
887 $current_paths = $new_asset->getWebPaths();
890 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
891 $valid_paths = make_valid_web_paths($current_paths, $new_asset->id);
892 $valid_paths = $GLOBALS[
'SQ_SYSTEM']->am->webPathsInUse($link_parent, $valid_paths, $new_asset->id, TRUE);
894 if (!$new_asset->saveWebPaths($valid_paths, FALSE)) {
895 $this->_errors[] = translate(
'cms_asset_builder_cannot_save_web_path', $new_asset->name, $link_parent->name);
899 if (!array_diff_assoc($valid_paths, $current_paths) && !array_diff_assoc($current_paths, $valid_paths)) {
900 $new_asset->updateLookups();
906 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this,
'linkMultipleLocations');
909 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this,
'setCreateStatus');
911 if (empty($this->_errors)) {
912 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
913 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
914 $this->_current_state =
'created';
917 $this->_tmp[
'created_asset'] = $new_asset;
921 $GLOBALS[
'SQ_SYSTEM']->broadcastTriggerEvent(
'trigger_event_after_asset_built', $new_asset);
923 $this->_abortAssetCreate($new_asset_linkid);
927 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this,
'setCreateStatus');
930 if ($this->
attr(
'allow_public_user')) {
931 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
959 function _abortAssetCreate($linkid=0)
961 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
962 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
966 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db3');
970 FROM sq_ast_lnk_tree t INNER JOIN sq_ast_lnk l ON t.linkid = l.linkid
971 WHERE l.linkid = :linkid';
978 }
catch (Exception $e) {
979 throw new Exception(
'Unable to get treeid for linkid: '.$linkid.
' due to database error: '.$e->getMessage());
982 if (!empty($treeid)) {
985 FROM sq_ast_lnk_tree t
987 t.treeid LIKE :treeid';
993 }
catch (Exception $e) {
994 throw new Exception(
'Unable to get linkids like treeid: '.$treeid.
' due to database error: '.$e->getMessage());
997 $result[][
'linkid'] =
'';
998 $to_delete_links = Array();
999 foreach($result as $row) {
1000 if (isset($row[
'linkid']) && $row[
'linkid']) {
1001 $to_delete_links[] = $row[
'linkid'];
1006 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1009 DELETE FROM sq_ast_lnk
1010 WHERE linkid IN ('.implode(
', ',$to_delete_links).
')';
1015 }
catch (Exception $e) {
1016 throw new Exception(
'Unable to delete redundent links from sq_ast_lnk table due to database error: '.$e->getMessage());
1020 DELETE FROM sq_ast_lnk_tree
1021 WHERE linkid IN ('.implode(
', ',$to_delete_links).
')';
1026 }
catch (Exception $e) {
1027 throw new Exception(
'Unable to delete redundent links from sq_ast_lnk_tree table due to database error: '.$e->getMessage());
1030 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1033 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1048 $all_selected_locations = Array();
1049 foreach ($this->
attr(
'create_location_optional') as $set_name => $details) {
1050 $selected_locations = Array();
1052 if (isset($_POST[$code_name])) {
1053 if ($details[
'allow_multiple'] && is_array($_POST[$code_name])) {
1054 foreach ($_POST[$code_name] as $location_id) {
1056 $selected_locations[] = $location_id;
1059 $selected_locations = array_intersect($selected_locations, array_keys($details[
'locations']));
1061 foreach ($selected_locations as $location_id) {
1062 $all_selected_locations[$location_id] = (int)$details[
'link_type'];
1066 if (in_array($_POST[$code_name], array_keys($details[
'locations']))) {
1067 $all_selected_locations[$_POST[$code_name]] = (int)$details[
'link_type'];
1070 }
else if (!$details[
'allow_empty']) {
1071 trigger_localised_error(
'CMS0036', E_USER_WARNING, $set_name);
1075 return $all_selected_locations;
1089 $selectable_sets = $this->
attr(
'create_location_optional');
1090 if (is_array($selectable_sets)) {
1091 foreach ($selectable_sets as $set_name => $set_details) {
1092 foreach ($set_details[
'locations'] as $loc => $name) {
1093 if (isset($res[$loc])) {
1094 $res[$loc] = min($res[$loc], $set_details[
'link_type']);
1096 $res[$loc] = $set_details[
'link_type'];
1114 if (empty($this->
id))
return Array();
1115 $schema_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_NOTICE,
'metadata_schema', FALSE,
'major',
'schema_to_apply');
1117 foreach ($schema_links as $link) {
1118 $res[] = $link[
'minorid'];
1135 return $this->
attr(
'create_location');
1151 $all_rule_match_locations = Array();
1152 if (empty($attributes)) {
1153 $create_type = $_POST[
'AB_'.$this->id.
'_ASSET_BUILDER_CREATE_TYPE'];
1154 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($create_type);
1155 $temp_asset =
new $create_type();
1156 $prefix = $temp_asset->getPrefix();
1161 $location_rules = $this->
attr(
'create_location_rules');
1162 $attributeids = ($GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes($create_type, Array(
'name',
'attrid')));
1163 if (!empty($location_rules[$create_type])) {
1164 foreach ($location_rules[$create_type] as $i => $rule) {
1167 while ($j < count($rule[
'attributes'])) {
1168 if (empty($attributes)) {
1169 $attr_value = isset($_POST[$prefix.
'_'.$attributeids[$rule[
'attributes'][$j]][
'attrid']]) ? trim(strtolower($_POST[$prefix.
'_'.$attributeids[$rule[
'attributes'][$j]][
'attrid']])) :
'';
1171 $attr_value = isset($attributes[$rule[
'attributes'][$j]]) ? trim(strtolower($attributes[$rule[
'attributes'][$j]])) :
'';
1174 switch ($rule[
'comparators'][$j]) {
1176 if ($attr_value != $rule[
'values'][$j]) $pass = FALSE;
1180 if (!preg_match(
'|^'.$rule[
'values'][$j].
'.*$|', $attr_value)) {
1186 if (!preg_match(
'|^.*'.$rule[
'values'][$j].
'$|', $attr_value)) {
1192 if (strpos($attr_value, $rule[
'values'][$j]) === FALSE) {
1201 foreach ($rule[
'locations'] as $index => $assetid) {
1202 $all_rule_match_locations[$assetid] = $rule[
'link_types'][$index];
1207 return $all_rule_match_locations;
1230 $details = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($res), Array(), TRUE,
'name');
1231 foreach ($res as $i => $v) {
1232 if (empty($details[$i])) {
1258 $additional_locs =
'';
1261 if (isset($_REQUEST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ADDITIONAL_LOCATIONS']) && !empty($_REQUEST[
'AB_'.$this->
id.
'_ASSET_BUILDER_ADDITIONAL_LOCATIONS'])) {
1262 $additional_locs = $_REQUEST[
'AB_'.$this->id.
'_ASSET_BUILDER_ADDITIONAL_LOCATIONS'];
1263 }
else if ($parameter_map->getParameterValue(
'additional_locations') != NULL) {
1266 $additional_locs = $parameter_map->getParameterValue(
'additional_locations');
1269 if (!empty($additional_locs)) {
1271 foreach (explode(
';', $additional_locs) as $loc_code) {
1272 if (FALSE === strpos($loc_code,
'-')) {
1274 $link_type = $this->
attr(
'additional_location_default_link_type');
1275 $loc_id = $loc_code;
1277 list($loc_id, $link_type) = explode(
'-', $loc_code);
1279 if (!isset($res[$loc_id]) || ($res[$loc_id] > $link_type)) {
1280 $res[$loc_id] = $link_type;
1284 $infos = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($res));
1285 $valid_types = $this->
attr(
'additional_location_types');
1286 $valid_parents = $this->
attr(
'additional_location_parents');
1287 foreach ($infos as $assetid => $info) {
1288 if (!in_array($info[
'type_code'], $valid_types)) {
1289 $matches = array_intersect($GLOBALS[
'SQ_SYSTEM']->am->getTypeAncestors($info[
'type_code']), $valid_types);
1290 if (empty($matches)) {
1291 unset($res[$assetid]);
1294 $valid_types[] = $info[
'type_code'];
1297 if (!in_array($assetid, $valid_parents)) {
1298 $matches = array_intersect(array_keys($GLOBALS[
'SQ_SYSTEM']->am->getParents($assetid)), $valid_parents);
1299 if (empty($matches)) unset($res[$assetid]);
1316 $all_selected_locations = Array();
1317 foreach ($this->
attr(
'create_location_dynamic') as $set_name => $details) {
1319 if (isset($_POST[$code_name]) && !empty($_POST[$code_name])) {
1320 $locations = $_POST[$code_name];
1321 if (!is_array($locations)) {
1322 $locations = Array($_POST[$code_name]);
1325 foreach ($locations as $location_id) {
1326 $all_selected_locations[$location_id] = $details[
'link_type'];
1327 if (!$details[
'allow_multiple'])
break;
1329 }
else if (!$details[
'allow_empty']) {
1330 trigger_localised_error(
'CMS0036', E_USER_WARNING, $set_name);
1335 return $all_selected_locations;
1350 return str_replace(Array(
' ',
'\''),
'_', strtolower($set_name));
1380 $create_status = $this->
attr(
'create_status');
1381 if ($create_status != 0) {
1382 if ($new_asset->status != $create_status) {
1383 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
1384 $vars = Array(
'assetid' => $new_asset->id,
'new_status' => $create_status);
1385 $status_errors = $hh->freestyleHipo(
'hipo_job_edit_status', $vars);
1389 foreach ($status_errors as $error) {
1390 if(is_array($error) && array_key_exists(
'message',$error)) {
1391 $message []= $error[
'message'];
1398 $this->_errors = array_merge($this->_errors, $message);
1399 return empty($this->_errors);
1417 $this->_replacements[
'created_asset_short_name'] = $this->
getKeywordReplacement(
'created_asset_short_name');
1420 $this->_replacements[
'created_asset_backend'] = $this->
getKeywordReplacement(
'created_asset_backend');
1443 $regen_link_text = $this->
attr(
'mollom_captcha_regen_link_text');
1444 if (empty($regen_link_text)) {
1445 $regen_link_text = translate(
'cms_asset_builder_mollom_regen_link_text');
1467 foreach ($this->
attr(
'create_location_optional') as $name => $data) {
1471 $options = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($data[
'locations']), Array(), TRUE,
'name');
1473 if (!$this->
attr(
'allow_public_user')) {
1474 $remaining_options = Array();
1475 $user_groups = $GLOBALS[
'SQ_SYSTEM']->user->getUserGroups();
1476 $user_groups[] = $GLOBALS[
'SQ_SYSTEM']->user->id;
1477 $user_groups[] = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAssetid(
'public_user');
1478 foreach ($options as $key => $value) {
1479 $allowed_user_groups = $GLOBALS[
'SQ_SYSTEM']->am->getPermission($key,SQ_PERMISSION_WRITE,TRUE);
1482 if (array_intersect($user_groups,$allowed_user_groups)) {
1483 $remaining_options[$key] = $value;
1484 }
else if (($GLOBALS[
'SQ_SYSTEM']->userRoot() || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin())) {
1485 $remaining_options[$key] = $value;
1488 $options = $remaining_options;
1491 switch ($data[
'input_style']) {
1493 if ($data[
'allow_empty'] && !$data[
'allow_multiple']) {
1494 $options = Array(
''=>
'') + $options;
1496 $default = $data[
'allow_empty'] ? Array() : key($options);
1497 $height = $data[
'allow_multiple'] ? 4 : 1;
1498 combo_box($code_name, $options, $data[
'allow_multiple'], $default, $height);
1501 if ($data[
'allow_multiple']) {
1503 $checked = !$data[
'allow_empty'];
1505 foreach ($data[
'locations'] as $id => $name) {
1506 check_box($code_name.
"[$i]", $id, $checked);
1507 label(str_replace(
' ',
' ',$options[$id]), $code_name.
"[$i]");
1513 $checked = !$data[
'allow_empty'];
1515 foreach ($data[
'locations'] as $id => $name) {
1516 radio_button($code_name, $id, $checked);
1517 label(str_replace(
' ',
' ',$options[$id]), $code_name.
'_'.$id);
1525 echo
'('.translate(
'cms_asset_builder_undefined_input_style', $data[
'input_style']).
')';
1528 $this->_replacements[$code_name.
'_field'] = ob_get_contents();
1532 foreach ($this->
attr(
'create_location_dynamic') as $name => $data) {
1537 if (is_array($new_types = $data[
'types'])) {
1538 if (isset($new_types[
'type_code']) && isset($new_types[
'inherit'])) {
1539 if (count($new_types[
'type_code']) == count($new_types[
'inherit'])) {
1540 $new_types_keys = array_keys($new_types[
'type_code']);
1542 for ($ii = reset($new_types_keys); $ii < count($new_types_keys); $ii++) {
1543 if (empty($new_types[
'type_code'][$ii]))
continue;
1544 if ($new_types[
'inherit'][$ii] ==
'1') {
1546 $descendant_types = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($new_types[
'type_code'][$ii], TRUE);
1547 foreach ($descendant_types as $type_code) {
1548 if (!isset($types[$type_code])) {
1549 $types[$type_code] =
'';
1553 $types[$new_types[
'type_code'][$ii]] =
'';
1560 $types = array_keys($types);
1562 structured_drop_down($code_name, $data[
'root'], $types, Array(), 0, $data[
'allow_multiple'] ? 5 : 1, $data[
'depth'], $data[
'allow_multiple'],
'-', FALSE,
'', $data[
'input_style'] ==
'radio', Array(), $data[
'display_structured'], array_keys($data[
'filter_link_type']), $data[
'allow_empty'], $this->
attr(
'allow_public_user') ? NULL : SQ_PERMISSION_WRITE);
1563 $this->_replacements[$code_name.
'_field'] = ob_get_contents();
1568 replace_keywords($this->_replacements[
'create_form'], $this->_replacements);
1582 $bodycopy_data = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $this->_current_state,
'major',
'1');
1583 if (empty($bodycopy_data))
return;
1584 $bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($bodycopy_data[
'minorid'], $bodycopy_data[
'minor_type_code']);
1585 if (is_null($bodycopy))
return;
1587 $keywords = $bodycopy->getKeywords();
1588 foreach($keywords as $word) {
1591 if ($word ==
'create_form' && isset($this->_replacements[
'create_form'])){
1592 $create_form_keywords = extract_keywords($this->_replacements[
'create_form']);
1593 $captcha_keywords = Array(
'form_captcha',
'form_captcha_image',
'form_captcha_field',
'form_captcha_link');
1594 $captcha_replacements = Array();
1595 foreach ($captcha_keywords as $captcha_word){
1596 if (in_array($captcha_word, $create_form_keywords)){
1600 replace_keywords($this->_replacements[
'create_form'], $captcha_replacements);
1603 if ((strpos($word,
'form_captcha') === 0)){
1608 if(!isset($this->_replacements[$word]) && (strpos($word,
'globals_') === 0 )){
1613 replace_global_keywords($this->_replacements[$word]);
1619 foreach($keywords as $full_keyword) {
1620 $keyword = parse_keyword($full_keyword, $modifiers);
1621 if (!empty($modifiers) && isset($this->_replacements[$keyword])) {
1622 $this->_replacements[$full_keyword] = $this->_replacements[$keyword];
1623 apply_keyword_modifiers($this->_replacements[$full_keyword], $modifiers);
1627 $bodycopy->setKeywordReplacements($this->_replacements);
1629 $bodycopy->printBody();
1648 $terminate = ((E_USER_ERROR | E_ERROR) & $err_no);
1651 if (defined(
'E_RECOVERABLE_ERROR') && ($err_no == E_RECOVERABLE_ERROR)) {
1657 if ((error_reporting() & $err_no) || $terminate) {
1659 $bt = debug_backtrace();
1660 if (count($bt) > 1) {
1662 while (($real_bt_index < count($bt)-1) && ((FALSE !== strpos(strtolower(array_get_index($bt[$real_bt_index],
'class')),
'locale_manager')) || (FALSE !== strpos(strtolower(array_get_index($bt[$real_bt_index],
'file')),
'locale_manager')) || (strtolower($bt[$real_bt_index][
'function']) ==
'_errorhandler'))) {
1665 $err_file = hide_system_root($bt[$real_bt_index][
'file']);
1666 $err_line = $bt[$real_bt_index][
'line'];
1667 $err_msg = hide_system_root($err_msg);
1670 $text_msg = strip_tags(preg_replace(Array(
'/<br\\/?>/i',
'/<p[^>]*>/i'), Array(
"\n",
"\n\n"), $err_msg));
1673 if (ini_get(
'log_errors')) {
1674 log_error($text_msg, $err_no, $err_file, $err_line);
1677 $this->_errors[] = $text_msg;
1681 if ($terminate) exit(1);
1695 $res[
'not_logged_in']= Array(
1696 'name' => translate(
'not_logged_in'),
1697 'content' =>
'%login_error%
1701 $res[
'logged_in']= Array(
1702 'name' => translate(
'logged_in'),
1703 'content' =>
'%create_error%
1707 $res[
'created']= Array(
1708 'name' => translate(
'created'),
1709 'content' => translate(
'cms_asset_builder_default_created_message'),
1731 if (!isset($vars[
'keywords']))
return;
1734 $parents = $GLOBALS[
'SQ_SYSTEM']->am->getParents($broadcaster->id,
'bodycopy', TRUE);
1735 $type_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'bodycopy');
1736 $bodycopy_type =
'';
1737 foreach ($type_links as $link_info) {
1738 if (isset($parents[$link_info[
'minorid']])) {
1739 $bodycopy_type = $link_info[
'value'];
1743 switch ($bodycopy_type) {
1744 case 'not_logged_in' :
1769 $keywords = Array();
1771 $keywords[
'login_invite'] = translate(
'cms_asset_builder_keyword_login_invite');
1772 $keywords[
'login_form'] = translate(
'cms_asset_builder_keyword_login_form');
1773 $keywords[
'login_error'] = translate(
'cms_asset_builder_keyword_login_error');
1774 $keywords[
'create_invite'] = translate(
'cms_asset_builder_keyword_create_invite');
1775 $keywords[
'create_form'] = translate(
'cms_asset_builder_keyword_create_form');
1776 $keywords[
'create_error'] = translate(
'cms_asset_builder_keyword_create_error');
1778 if ($this->
attr(
'require_captcha')) {
1779 $keywords[
'form_captcha'] = translate(
'cms_asset_builder_keyword_form_captcha');
1780 $keywords[
'form_captcha_image'] = translate(
'cms_asset_builder_keyword_form_captcha_image');
1781 $keywords[
'form_captcha_field'] = translate(
'cms_asset_builder_keyword_form_captcha_field');
1782 $keywords[
'form_captcha_link'] = translate(
'cms_asset_builder_keyword_form_captcha_link');
1785 if ($this->
attr(
'use_mollom')) {
1786 $keywords[
'asset_builder_mollom_captcha'] = translate(
'cms_asset_builder_mollom_captcha');
1787 $keywords[
'asset_builder_mollom_captcha_image'] = translate(
'cms_asset_builder_mollom_captcha_image');
1788 $keywords[
'asset_builder_mollom_captcha_audio'] = translate(
'cms_asset_builder_mollom_captcha_audio');
1789 $keywords[
'asset_builder_mollom_captcha_field'] = translate(
'cms_asset_builder_mollom_captcha_field');
1790 $keywords[
'asset_builder_mollom_captcha_regen_link'] = translate(
'cms_asset_builder_mollom_captcha_link');
1806 $keywords = Array();
1807 $keywords[
'create_invite'] = translate(
'cms_asset_builder_keyword_create_invite');
1808 $keywords[
'create_form'] = translate(
'cms_asset_builder_keyword_create_form');
1809 $keywords[
'create_error'] = translate(
'cms_asset_builder_keyword_create_error');
1811 if ($this->
attr(
'require_captcha')) {
1812 $keywords[
'form_captcha'] = translate(
'cms_asset_builder_keyword_form_captcha');
1813 $keywords[
'form_captcha_image'] = translate(
'cms_asset_builder_keyword_form_captcha_image');
1814 $keywords[
'form_captcha_field'] = translate(
'cms_asset_builder_keyword_form_captcha_field');
1815 $keywords[
'form_captcha_link'] = translate(
'cms_asset_builder_keyword_form_captcha_link');
1818 if ($this->
attr(
'use_mollom')) {
1819 $keywords[
'asset_builder_mollom_captcha'] = translate(
'cms_asset_builder_mollom_captcha');
1820 $keywords[
'asset_builder_mollom_captcha_image'] = translate(
'cms_asset_builder_mollom_captcha_image');
1821 $keywords[
'asset_builder_mollom_captcha_audio'] = translate(
'cms_asset_builder_mollom_captcha_audio');
1822 $keywords[
'asset_builder_mollom_captcha_field'] = translate(
'cms_asset_builder_mollom_captcha_field');
1823 $keywords[
'asset_builder_mollom_captcha_regen_link'] = translate(
'cms_asset_builder_mollom_captcha_link');
1839 $keywords = Array();
1841 $keywords[
'created_assetid'] = translate(
'cms_asset_builder_created_assetid');
1842 $keywords[
'created_asset_name'] = translate(
'cms_asset_builder_created_asset_name');
1843 $keywords[
'created_asset_short_name'] = translate(
'cms_asset_builder_created_asset_short_name');
1844 $keywords[
'created_asset_url'] = translate(
'cms_asset_builder_created_asset_url');
1845 $keywords[
'created_asset_edit'] = translate(
'cms_asset_builder_created_asset_edit');
1846 $keywords[
'created_asset_backend'] = translate(
'cms_asset_builder_created_asset_backend');
1861 $keywords = Array();
1862 foreach ($this->
attr(
'create_location_optional') as $name => $data) {
1864 $keywords[$keyword_name] = translate(
'cms_asset_builder_field_keyword', $name);
1879 $keywords = Array();
1880 foreach ($this->
attr(
'create_location_dynamic') as $name => $data) {
1882 $keywords[$keyword_name] = translate(
'cms_asset_builder_field_keyword', $name);
1900 return $this->
attr(
'login_invite');
1913 return $this->
attr(
'login_error');
1928 <input
type=
"hidden" name=
"SQ_LOGIN_KEY" value=
"<?php echo $GLOBALS['SQ_SYSTEM']->generateLoginKey(); ?>" />
1929 <input type=
"hidden" name=
"SQ_LOGIN_REFERER" value=
"" />
1933 <td valign=
"top"><?php echo translate(
'username'); ?></td>
1934 <td valign=
"top"><?php echo text_box(
'SQ_LOGIN_USERNAME', (isset($_POST[
'SQ_LOGIN_USERNAME'])) ? $_POST[
'SQ_LOGIN_USERNAME'] :
'Enter your username here', 25, 0, (isset($_POST[
'SQ_LOGIN_USERNAME'])) ? FALSE : TRUE,
'title="Username"'); ?></td>
1937 <td valign=
"top"><?php echo translate(
'password'); ?></td>
1938 <td valign=
"top"><?php echo password_box(
'SQ_LOGIN_PASSWORD',
'', 25, 0,
'title="Password"'); ?></td>
1941 <td valign=
"top"> </td>
1943 <input type=
"hidden" name=
"SQ_ACTION" value=
"" id=
"SQ_ACTION" />
1944 <?php echo submit_button(
'SQ_LOGIN_SUBMIT',
'Login',
'document.getElementById(\'SQ_ACTION\').value = \'login\'; document.getElementById(\'AB_'.$this->
id.
'_ASSET_BUILDER_ACTION\').value = \'login\';'); ?>
1950 $login_form = ob_get_contents();
1965 if(isset($this->_replacements[
'created_assetid'] )) {
1966 return $this->_replacements[
'created_assetid'];
1968 else if (isset($this->_tmp[
'created_asset'])) {
1969 return $this->_tmp[
'created_asset']->id;
1983 if(isset($this->_replacements[
'created_asset_name'] )) {
1984 return $this->_replacements[
'created_asset_name'];
1986 else if (isset($this->_tmp[
'created_asset'])) {
1987 return $this->_tmp[
'created_asset']->name;
2002 if(isset($this->_replacements[
'created_asset_short_name'] )) {
2003 return $this->_replacements[
'created_asset_short_name'];
2005 else if (isset($this->_tmp[
'created_asset'])) {
2006 return $this->_tmp[
'created_asset']->short_name;
2020 if(isset($this->_replacements[
'created_asset_url'] )) {
2021 return $this->_replacements[
'created_asset_url'];
2023 else if (isset($this->_tmp[
'created_asset'])) {
2024 return $this->_tmp[
'created_asset']->getURL();
2038 if(isset($this->_replacements[
'created_asset_edit'] )) {
2039 return $this->_replacements[
'created_asset_edit'];
2041 else if (isset($this->_tmp[
'created_asset'])) {
2042 return $this->_tmp[
'created_asset']->getURL().
'/'.SQ_CONF_LIMBO_SUFFIX;
2056 if(isset($this->_replacements[
'created_asset_backend'] )) {
2057 return $this->_replacements[
'created_asset_backend'];
2059 else if (isset($this->_tmp[
'created_asset'])) {
2060 return sq_web_path(
'root_url').
'/'.$this->_tmp[
'created_asset']->getBackendHref(
'contents');
2074 return $this->
attr(
'create_error');
2087 return $this->
attr(
'create_invite');
2101 $create_types = $this->
attr(
'create_type');
2102 if (!is_array($create_types)) {
2103 $create_types = Array($create_types =>
'');
2106 require_once SQ_INCLUDE_PATH.
'/limbo_outputter.inc';
2108 $o->addHiddenField(
'AB_'.$this->
id.
'_ASSET_BUILDER_CREATE_TYPE', key($create_types));
2109 if (count($create_types) > 1) $o->addOnSubmit(
'disableHiddenInputs();');
2113 $metadata_edit_fns = NULL;
2118 foreach ($create_types as $create_type => $value) {
2119 $prefix = $this->
type().
'_'.$this->
id.
'_type_'.$create_type;
2120 echo
'<div class="sq-asset-builder-tab-content" id="'.$prefix.
'" style="display: '.$display.
'">';
2121 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($create_type);
2123 if (isset($this->_tmp[
'new_asset_created_'.$create_type])) {
2124 $asset =& $this->_tmp[
'new_asset_created_'.$create_type];
2126 $asset =
new $create_type();
2130 $ei = $asset->getEI();
2131 $ei->paintLayout($asset, $o, $layout);
2132 $o->addHiddenField(
'asset_action',
'create_custom');
2134 unset($GLOBALS[
'painted_inline_value_interface']);
2135 foreach ($metadata_schemas as $schemaid) {
2136 $schema = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($schemaid);
2137 if (is_null($metadata_edit_fns)) {
2138 $metadata_edit_fns = $schema->getEditFns();
2140 $metadata_edit_fns->paintInlineValueInterface($schema, $o, Array(), TRUE, FALSE, $create_type);
2142 $asset->paintBackend($o);
2143 $o->addHiddenField(
'asset_action',
'create');
2145 $o->paintSections();
2146 $o->_contents = Array();
2153 <script
type=
"text/javascript">
2155 foreach ($asset->vars as $attr_name => $attr_details) {
2156 foreach ($_POST as $post_var => $post_var_value) {
2157 $pos = strpos($post_var, $create_type);
2158 if (($pos !== FALSE) && ($pos == 0)) {
2160 $idlength = strlen($attr_details[
'attrid']);
2161 if (substr($post_var, -$idlength) == $attr_details[
'attrid']) {
2164 document.getElementById(
'<?php echo htmlspecialchars($post_var, ENT_QUOTES); ?>').value =
'<?php echo htmlspecialchars($post_var_value, ENT_QUOTES); ?>';
2176 $create_form = ob_get_contents();
2182 $o->_paintInlineHeader();
2185 if (count($create_types) > 1) {
2186 reset($create_types);
2188 <script
type=
"text/javascript"><!--
2190 var current_option =
'<?php echo $this->type().'_
'.$this->id.'_type_
'.key($create_types) ?>';
2192 function showAssetBuilderTab(type_code)
2194 document.getElementById(current_option).style.display =
'none';
2195 document.getElementById(current_option+
"_tab").className =
'sq-asset-builder-tab';
2196 current_option =
'<?php echo $this->type().'_
'.$this->id.'_type_
' ?>' + type_code;
2197 document.getElementById(current_option).style.display =
'block';
2198 document.getElementById(current_option+
"_tab").className =
'sq-asset-builder-tab-active';
2199 document.getElementById(
'AB_<?php echo $this->id ?>_ASSET_BUILDER_CREATE_TYPE').value = type_code;
2203 function disableHiddenInputs()
2205 var divs = document.getElementsByTagName(
'DIV');
2206 for (var i=0; i < divs.length; i++) {
2207 if (divs[i].className ==
'sq-asset-builder-tab-content') {
2208 if (divs[i].style.display ==
'none') {
2209 var inputs = divs[i].getElementsByTagName(
'INPUT');
2210 for (var j=0; j < inputs.length; j++) {
2211 inputs[j].disabled =
true;
2213 inputs = divs[i].getElementsByTagName(
'TEXTAREA');
2214 for (var j=0; j < inputs.length; j++) {
2215 inputs[j].disabled =
true;
2217 inputs = divs[i].getElementsByTagName(
'SELECT');
2218 for (var j=0; j < inputs.length; j++) {
2219 inputs[j].disabled =
true;
2230 <div
id=
"sq-asset-builder-header">
2233 $active =
'-active';
2234 foreach ($create_types as $create_type => $value) {
2235 $prefix = $this->
type().
'_'.$this->
id.
'_type_'.$create_type;
2236 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($create_type,
'name');
2238 <li
class=
"sq-asset-builder-tab<?php echo $active; ?>" id=
"<?php echo $prefix; ?>_tab">
2239 <a href=
"#" onclick=
"showAssetBuilderTab('<?php echo $create_type ?>'); return false;">
2240 <?php echo $type_name; ?>
2251 $create_form = ob_get_contents().$create_form;
2254 return $create_form;
2270 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_TYPE_2,
'layout', TRUE, $type_code);
2271 if (!empty($link)) {
2272 $res = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'],
'layout');