Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Remove post_processor on multi shortener (use hook instead).
Browse files Browse the repository at this point in the history
Delete shorten.bitly plugin
  • Loading branch information
cdujeu committed May 9, 2016
1 parent 2a27c1a commit ab08fe0
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 344 deletions.
9 changes: 9 additions & 0 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -1416,6 +1416,15 @@ public function createSharedMinisite($httpVars, &$update)
$this->getPublicAccessManager()->initFolder();
$hash = $shareObject->save();
$url = $this->getPublicAccessManager()->buildPublicLink($hash);
$existingShortForm = $shareObject->getShortFormUrl();
if(empty($existingShortForm)){
$shortForm = "";
Controller::applyHook("url.shorten", array($url, &$shortForm));
if(!empty($shortForm)){
$shareObject->setShortFormUrl($shortForm);
$shareObject->save();
}
}

// LOG AND PUBLISH EVENT
$update = isSet($httpVars["repository_id"]);
Expand Down
104 changes: 0 additions & 104 deletions core/src/plugins/shorten.bitly/class.BitlyShortener.php

This file was deleted.

28 changes: 0 additions & 28 deletions core/src/plugins/shorten.bitly/i18n/conf/de.php

This file was deleted.

28 changes: 0 additions & 28 deletions core/src/plugins/shorten.bitly/i18n/conf/en.php

This file was deleted.

28 changes: 0 additions & 28 deletions core/src/plugins/shorten.bitly/i18n/conf/fr.php

This file was deleted.

28 changes: 0 additions & 28 deletions core/src/plugins/shorten.bitly/i18n/conf/it.php

This file was deleted.

29 changes: 0 additions & 29 deletions core/src/plugins/shorten.bitly/i18n/conf/pt.php

This file was deleted.

29 changes: 0 additions & 29 deletions core/src/plugins/shorten.bitly/manifest.xml

This file was deleted.

1 change: 0 additions & 1 deletion core/src/plugins/shorten.bitly/plugin_doc.html

This file was deleted.

62 changes: 1 addition & 61 deletions core/src/plugins/shorten.multi/class.multiShortener.php
Expand Up @@ -28,33 +28,6 @@ public function processShortenHook($url, &$shorten){
$shorten = $this->generateLink($url);
}

/**
* @param $action
* @param $httpVars
* @param $params
*/
public function postProcess($action, $httpVars, $params)
{
$type = $this->getFilteredOption("SHORTEN_TYPE");
if(empty($type)) return;
$jsonData = json_decode($params["ob_output"], true);
$elementId = -1;
if ($jsonData != false) {
$url = $jsonData["publiclet_link"] ;
$elementId = $jsonData["element_id"];
} else {
$url = $params["ob_output"];
}

$res = $this->generateLink($url);
if(!empty($res)){
$this->updateMetaShort($httpVars["file"], $elementId, $res);
print($res);
}else{
print($url);
}
}

protected function generateLink($url){

$type = $this->getFilteredOption("SHORTEN_TYPE");
Expand Down Expand Up @@ -173,38 +146,5 @@ protected function generateLink($url){
return null;

}

protected function updateMetaShort($file, $elementId, $shortUrl)
{
$context = new UserSelection(ConfService::getRepository());
$baseUrl = $context->currentBaseUrl();
$node = new AJXP_Node($baseUrl.$file);
if ($node->hasMetaStore()) {
$metadata = $node->retrieveMetadata(
"ajxp_shared",
true,
AJXP_METADATA_SCOPE_REPOSITORY
);
if ($elementId != -1) {
if (!is_array($metadata["element"][$elementId])) {
$metadata["element"][$elementId] = array();
}
$metadata["element"][$elementId]["short_form_url"] = $shortUrl;
} else {
if(isSet($metadata["shares"])){
$key = array_pop(array_keys($metadata["shares"]));
$metadata["shares"][$key]["short_form_url"] = $shortUrl;
}else{
$metadata['short_form_url'] = $shortUrl;
}
}
$node->setMetadata(
"ajxp_shared",
$metadata,
true,
AJXP_METADATA_SCOPE_REPOSITORY
);
}
}


}
8 changes: 0 additions & 8 deletions core/src/plugins/shorten.multi/manifest.xml
Expand Up @@ -29,14 +29,6 @@
<global_param group_switch_name="shorten_type" group_switch_label="yourls" group_switch_value="yourls" name="YOURLS_USEIDN" type="boolean" label="CONF_MESSAGE[Use IDN]" description="CONF_MESSAGE[Use IDN]" mandatory="false" default="false"/>
</server_settings>
<registry_contributions>
<actions>
<!-- Override share action output / Backward compat -->
<action name="share">
<post_processing>
<serverCallback methodName="postProcess" capture="true" applyCondition="$apply=(!isSet($httpVars['sub_action']) || $httpVars['sub_action'] == 'create_minisite');"/>
</post_processing>
</action>
</actions>
<hooks>
<serverCallback methodName="processShortenHook" hookName="url.shorten"/>
</hooks>
Expand Down

0 comments on commit ab08fe0

Please sign in to comment.