elkuku / EasyCreator

EasyCreator helps creating extensions for the Joomla! CMS
http://extensions.joomla.org/extensions/miscellaneous/development/5908
50 stars 23 forks source link

package creation - manifest file issue #26

Closed adamjakab closed 6 years ago

adamjakab commented 10 years ago

hi,

I had an issue with package creation and i corrected two things that were wrong when creating the manifest file for the package: 1) when adding id attribute to file element your code uses the element value from the package's manifest file instead of using the comName of the extension to include 2) on adding extensions of type module and plugin it does not add the client/group attribute to the file element

Both of these lead to uninstallation problems because Joomla will not find the extensions (either because of wrong id or because it cannot identify group/client)

to resolve this i modified the method in EcrProjectManifest::processPackageElements() and now it works like a charm. Here is the code if you care to add it to some future release:

/**
 * Process package elements for J! 1.6 packages.
 *
 * @return EcrProjectManifest
 */
private function processPackageElements() {
    if($this->project->type != 'package')
        return $this;

    $filesElement = $this->manifest->addChild('files');

    foreach($this->project->elements as $element => $path) {
        //--Get the project
        $project = EcrProjectHelper::getProject($element);

        $fileElement = $filesElement->addChild('file', $path);
        $fileElement->addAttribute('type', $project->type);
        /*$fileElement->addAttribute('id', $element); this is no good*/
        $fileElement->addAttribute('id', $project->comName);//this is ok

        //JACK'S MOD
        switch($project->type) {
            case 'component':
            case 'cliapp':
            case 'webapp':
                break;
            case 'module':
            case 'template':
                $fileElement->addAttribute('client', ($project->scope == 'admin'?'administrator':'site'));
                break;
            case 'plugin':
                $fileElement->addAttribute('group', $project->scope);
                break;
            case 'library' :
                //not sure about this but probably not
                //$fileElement->addChild('libraryname', $project->comName);
                break;
            case 'package':
                //todo: can we put a package in a package???
                //$fileElement->addChild('packagename', strtolower($project->name));
                break;
            default :
                throw new Exception(__METHOD__.' - unknown project type: '.$project->type);
                break;
        }
    }

    return $this;
}