msgid "Invalid value. Integer value required."
msgstr "Invalid value. Integer value required."
+
+msgid "Resource %s \"%s\" is used in the following resources:"
+msgstr "Resource %s \"%s\" is used in the following resources:"
+
+msgid "Component: %s, Resource: %s \"%s\", Directive: %s"
+msgstr "Component: %s, Resource: %s \"%s\", Directive: %s"
+
+msgid "Are you sure that you want to remove %s resource \"%s\"?"
+msgstr "Are you sure that you want to remove %s resource \"%s\"?"
+
+msgid "Resource %s \"%s\" removed successfully."
+msgstr "Resource %s \"%s\" removed successfully."
+
+msgid "Please unassign resource %s \"%s\" from these resources and try again."
+msgstr "Please unassign resource %s \"%s\" from these resources and try again."
+
msgid "Invalid value. Integer value required."
msgstr "Invalid value. Integer value required."
+
+msgid "Resource %s \"%s\" is used in the following resources:"
+msgstr "Resource %s \"%s\" is used in the following resources:"
+
+msgid "Component: %s, Resource: %s \"%s\", Directive: %s"
+msgstr "Component: %s, Resource: %s \"%s\", Directive: %s"
+
+msgid "Are you sure that you want to remove %s resource \"%s\"?"
+msgstr "Are you sure that you want to remove %s resource \"%s\"?"
+
+msgid "Resource %s \"%s\" removed successfully."
+msgstr "Resource %s \"%s\" removed successfully."
+
+msgid "Please unassign resource %s \"%s\" from these resources and try again."
+msgstr "Please unassign resource %s \"%s\" from these resources and try again."
+
msgid "Invalid value. Integer value required."
msgstr "Niepoprawna wartość. Wymagane jest podanie liczby całkowitej."
+
+msgid "Resource %s \"%s\" is used in the following resources:"
+msgstr "Zasób %s \"%s\" jest użyty w następujących zasobach:"
+
+msgid "Component: %s, Resource: %s \"%s\", Directive: %s"
+msgstr "Komponent: %s, Zasób: %s \"%s\", Dyrektywa: %s"
+
+msgid "Are you sure that you want to remove %s resource \"%s\"?"
+msgstr "Czy jesteś pewien, że chcesz usunąć zasób %s \"%s\"?"
+
+msgid "Resource %s \"%s\" removed successfully."
+msgstr "Zasób %s \"%s\" został usunięty pomyślnie."
+
+msgid "Please unassign resource %s \"%s\" from these resources and try again."
+msgstr "Proszę wypisać zasób %s \"%s\" z tych zasobów i spróbować ponownie."
+
msgid "Invalid value. Integer value required."
msgstr "Invalid value. Integer value required."
+
+msgid "Resource %s \"%s\" is used in the following resources:"
+msgstr "Resource %s \"%s\" is used in the following resources:"
+
+msgid "Component: %s, Resource: %s \"%s\", Directive: %s"
+msgstr "Component: %s, Resource: %s \"%s\", Directive: %s"
+
+msgid "Are you sure that you want to remove %s resource \"%s\"?"
+msgstr "Are you sure that you want to remove %s resource \"%s\"?"
+
+msgid "Resource %s \"%s\" removed successfully."
+msgstr "Resource %s \"%s\" removed successfully."
+
+msgid "Please unassign resource %s \"%s\" from these resources and try again."
+msgstr "Please unassign resource %s \"%s\" from these resources and try again."
+
<!-- data modules -->
<module id="api" class="Application.Web.Class.BaculumAPIClient" />
<module id="data_desc" class="Application.Web.Class.DataDescription" />
+ <module id="data_deps" class="Application.Web.Class.DataDependencies" />
<module id="globalization" class="TGlobalization">
<translation type="gettext" source="Application.Web.Lang" marker="@@" autosave="false" cache="false" DefaultCulture="en" />
</module>
$control->setResourceName($param->Item->DataItem['resource_name']);
$control->setResourceNames($this->resource_names);
}
+ $param->Item->RemoveResource->setCommandParameter($param->Item->DataItem);
}
public function getDirectives($sender, $param) {
$control->raiseEvent('OnDirectiveListLoad', $this, null);
}
}
+
+ /**
+ * Remove resource callback method.
+ *
+ * @return object $sender sender instance
+ * @return mixed $param additional parameters
+ * @return none
+ */
+ public function removeResource($sender, $param) {
+ if (!$this->getPage()->IsCallback) {
+ // removing resource available only by callback
+ return;
+ }
+ $host_params = $param->getCommandParameter();
+ if (!is_array($host_params) || count($host_params) === 0) {
+ return;
+ }
+ $host = $this->getHost();
+ $config = $this->getConfigData($host, $host_params['component_type']);
+ $deps = $this->getModule('data_deps')->checkDependencies(
+ $host_params['component_type'],
+ $host_params['resource_type'],
+ $host_params['resource_name'],
+ $config
+ );
+ if (count($deps) === 0) {
+ // NO DEPENDENCY. Ready to remove.
+ $this->removeResourceFromConfig(
+ $config,
+ $host_params['resource_type'],
+ $host_params['resource_name']
+ );
+ $result = $this->getModule('api')->set(
+ array('config', $host_params['component_type']),
+ array('config' => json_encode($config)),
+ $host,
+ false
+ );
+ if ($result->error === 0) {
+ $this->showRemovedResourceInfo(
+ $host_params['resource_type'],
+ $host_params['resource_name']
+ );
+ } else {
+ $this->showRemovedResourceError($result->output);
+ }
+ } else {
+ // DEPENDENCIES EXIST. List them on the interface.
+ $this->showDependenciesError(
+ $deps,
+ $host_params['resource_type'],
+ $host_params['resource_name']
+ );
+ }
+ }
+
+ /**
+ * Show removed resource information.
+ *
+ * @param string $resource_type removed resource type
+ * @param string $resource_name removed resource name
+ * @return none
+ */
+ private function showRemovedResourceInfo($resource_type, $resource_name) {
+ $msg = Prado::localize('Resource %s "%s" removed successfully.');
+ $msg = sprintf(
+ $msg,
+ $resource_type,
+ $resource_name
+ );
+ $this->RemoveResourceOk->Text = $msg;
+ $this->getPage()->getCallbackClient()->hide($this->RemoveResourceError);
+ $this->getPage()->getCallbackClient()->show($this->RemoveResourceOk);
+ }
+
+ /**
+ * Show removed resource error message.
+ *
+ * @param string $error_message error message
+ * @return none
+ */
+ private function showRemovedResourceError($error_message) {
+ $this->RemoveResourceError->Text = $error_message;
+ $this->getPage()->getCallbackClient()->hide($this->RemoveResourceOk);
+ $this->getPage()->getCallbackClient()->show($this->RemoveResourceError);
+ }
+
+ /**
+ * Show dependencies error message.
+ *
+ * @param array $deps list dependencies for the removing resource
+ * @param string $resource_type resource type of the removing resource
+ * @param string $resource_name resource name of the removing resource
+ * @return none
+ */
+ private function showDependenciesError($deps, $resource_type, $resource_name) {
+ $emsg = Prado::localize('Resource %s "%s" is used in the following resources:');
+ $emsg = sprintf($emsg, $resource_type, $resource_name);
+ $emsg_deps = Prado::localize('Component: %s, Resource: %s "%s", Directive: %s');
+ $dependencies = array();
+ for ($i = 0; $i < count($deps); $i++) {
+ $dependencies[] = sprintf(
+ $emsg_deps,
+ $deps[$i]['component_type'],
+ $deps[$i]['resource_type'],
+ $deps[$i]['resource_name'],
+ $deps[$i]['directive_name']
+ );
+ }
+ $emsg_sum = Prado::localize('Please unassign resource %s "%s" from these resources and try again.');
+ $emsg_sum = sprintf($emsg_sum, $resource_type, $resource_name);
+ $error = array($emsg, implode('<br />', $dependencies), $emsg_sum);
+ $error_message = implode('<br /><br />', $error);
+ $this->showRemovedResourceError($error_message);
+ }
+
+ /**
+ * Remove resource from config.
+ * Note, passing config by reference.
+ *
+ * @param array $config entire config
+ * @param string $resource_type resource type to remove
+ * @param string $resource_name resource name to remove
+ * @return none
+ */
+ private function removeResourceFromConfig(&$config, $resource_type, $resource_name) {
+ for ($i = 0; $i < count($config); $i++) {
+ foreach ($config[$i] as $rtype => $resource) {
+ if (!property_exists($resource, 'Name')) {
+ continue;
+ }
+ if ($rtype === $resource_type && $resource->Name === $resource_name) {
+ // remove resource
+ array_splice($config, $i, 1);
+ break;
+ }
+ }
+ }
+ }
}
?>
<div class="config_resources" style="display: none">
+ <com:TActiveLabel ID="RemoveResourceOk" Display="None" CssClass="validate" />
+ <com:TActiveLabel ID="RemoveResourceError" Display="None" CssClass="validator" />
<com:TActiveRepeater ID="RepeaterResources" OnItemCreated="createResourceListElement">
<prop:ItemTemplate>
<com:TPanel>
- <table class="resource" onmousedown="(event.target||event.srcElement).id != '<%=$this->Resource->ClientID%>' ? $('#<%=$this->Resource->ClientID%>').trigger('click') : '';" onmouseover="$(this).find('a.action_link').addClass('resource_selected');" onmouseout="$(this).find('a.action_link').removeClass('resource_selected');">
+ <script type="text/javascript">
+ <%=$this->Resource->ClientID%>_mousedown = function(event) {
+ var t = (event.target||event.srcElement);
+ var res_id = '<%=$this->Resource->ClientID%>';
+ if (t.id != res_id && !/^<%=$this->RemoveResource->ClientID%>/.test(t.id)) {
+ $('.validate, .validator').hide(); // hide validator messages
+ $('#' + res_id).trigger('click');
+ }
+ };
+ document.getElementById('<%=$this->RemoveResource->ClientID%>').onclick = function(event) {
+ var t = (event.target||event.srcElement);
+ var cmsg = '<%[ Are you sure that you want to remove %s resource "%s"? ]%>';
+ cmsg = cmsg.replace('%s', '<%=$this->DataItem['resource_type']%>');
+ cmsg = cmsg.replace('%s', '<%=$this->DataItem['resource_name']%>');
+ if (/^<%=$this->RemoveResource->ClientID%>/.test(t.id) && confirm(cmsg)) {
+ return true;
+ }
+ return false;
+ };
+ </script>
+ <table class="resource" onmousedown="return <%=$this->Resource->ClientID%>_mousedown(event);" onmouseover="$(this).find('a.action_link').addClass('resource_selected');" onmouseout="$(this).find('a.action_link').removeClass('resource_selected');">
<tr>
<td><com:TActiveLinkButton
ID="Resource"
<img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/ajax-loader-arrows.gif" alt="" style="display: none" />
</td>
<td class="right" style="height: 26px">
- <!--a class="action_link" href="javascript:void(0)"><img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/config.png" alt="<%[ Edit ]%>" /> <%[ Edit ]%></a>
- <a class="action_link" href="javascript:void(0)"><img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/icon_err.png" alt="<%[ Remove ]%>" /> <%[ Remove ]%></a--></td>
+ <!--a class="action_link" href="javascript:void(0)"><img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/config.png" alt="<%[ Edit ]%>" /> <%[ Edit ]%></a -->
+ <com:TActiveLinkButton
+ ID="RemoveResource"
+ OnCommand="SourceTemplateControl.removeResource"
+ CssClass="action_link"
+ >
+ <prop:ClientSide.OnComplete>
+ var vid = '<%=$this->SourceTemplateControl->RemoveResourceError->ClientId%>';
+ if (document.getElementById(vid).style.display === 'none') {
+ var container = $('#<%=$this->RemoveResource->ClientID%>').closest('div')[0];
+ container.parentNode.removeChild(container);
+ }
+ $('html, body').animate({
+ scrollTop: $('#' + vid).closest('div').prev().offset().top
+ }, 500);
+ </prop:ClientSide.OnComplete>
+ <img id="<%=$this->RemoveResource->ClientID%>_img" src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/icon_err.png" alt="<%[ Remove ]%>" /> <%[ Remove ]%>
+ </com:TActiveLinkButton>
+ </td>
</tr>
</table>
<com:Application.Web.Portlets.BaculaConfigDirectives