17 require_once SQ_CORE_PACKAGE_PATH.
'/page/page_edit_fns.inc';
40 parent::__construct();
57 $types = $asset->attr(
'types');
59 if ($asset->writeAccess(
'attributes')) {
61 asset_type_chooser($prefix.
'_types', TRUE, array_keys($types));
66 echo
'<p class="sq-backend-warning">'.translate(
'js_api_no_asset_types_selected').
'</p>';
68 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($types),
'name');
70 <table
class=
"sq-backend-table">
72 <th><?php echo translate(
'type') ?></th>
75 foreach ($types as $type => $value) {
79 echo get_asset_type_icon($type);
80 echo $type_names[$type];
112 if (isset($_POST[$prefix.
'_types'])) {
114 foreach ($_POST[$prefix.
'_types'] as $type) {
115 if (!empty($type)) $types[$type] = 1;
117 $asset->setAttrValue(
'types', $types);
137 $write_access = $asset->writeAccess(
'links');
138 $curr_list = $asset->getRootNodes();
141 multiple_asset_finder($prefix.
'_roots', $curr_list, Array(
'asset' =>
'D'));
143 if (empty($curr_list)) {
144 echo translate(
'js_api_no_root_nodes_selected');
146 ?><ul style=
"margin:1px 15px;"><?php
147 foreach ($curr_list as $assetid) {
148 echo
'<li>'.get_asset_tag_line($assetid).
'</li>';
154 return $write_access;
171 if (isset($asset->_tmp[
'reverting_to_system_version']) && $asset->_tmp[
'reverting_to_system_version']) {
174 $roots = array_get_index($_POST, $prefix.
'_roots', Array());
175 $root_nodes = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', TRUE,
'major',
'root');
176 $curr_list = Array();
178 foreach ($root_nodes as $node) {
179 $node_id = array_get_index($node,
'minorid', 0);
182 foreach ($roots as $root) {
183 if($node_id !== 0 && in_array($node_id, $root)) {
188 if ($node_id !== 0 && !$found) {
189 $GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($node[
'linkid']);
190 }
else if ($node_id !== 0 && $found) {
191 $curr_list[] = $node_id;
195 foreach ($roots as $root) {
196 if (!empty($root[
'assetid']) && !in_array($root[
'assetid'], $curr_list)) {
197 $node = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($root[
'assetid'],
'', TRUE);
198 if (!is_null($node)) {
199 $new_link = $GLOBALS[
'SQ_SYSTEM']->am->createAssetLink($asset, $node, SQ_LINK_NOTICE,
'root');
200 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($node, TRUE);
223 $write_access = $asset->writeAccess(
'attributes');
226 text_box($prefix.
'_key', $asset->attr(
'api_key'));
228 echo
'<p class="sq-backend-warning">'.translate(
'js_api_api_key_lock').
'</p>';
231 return $write_access;
249 return $asset->setAttrValue(
'api_key', $_POST[$prefix.
'_key']);
266 $types = $asset->attr(
'types_restriction');
268 if ($asset->writeAccess(
'attributes')) {
270 asset_type_chooser($prefix.
'_types_restrict', TRUE, array_keys($types));
275 echo
'<p class="sq-backend-warning">'.translate(
'js_api_no_asset_types_selected').
'</p>';
277 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($types),
'name');
279 <table
class=
"sq-backend-table">
281 <th><?php echo translate(
'type') ?></th>
284 foreach ($types as $type => $value) {
288 echo get_asset_type_icon($type);
289 echo $type_names[$type];
321 if (isset($_POST[$prefix.
'_types_restrict'])) {
323 foreach ($_POST[$prefix.
'_types_restrict'] as $type) {
324 if (!empty($type)) $types[$type] = 1;
326 $asset->setAttrValue(
'types_restriction', $types);