Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Vanilla Packer
This discussion has been closed.
Comments
replace line 479 and 480 with just
AddScriptaculous();
I will look to that for a better solution when I have time
I should change the error message on the setting page. However, CategoryForm and the Packer should still work.
Thanks, Dinoboff!
Notice: unserialize() [function.unserialize]: Error at offset 872 of 917 bytes in C:\AppServ\www\Vanilla\extensions\VanillaPacker\md5.php on line 2 Warning: Invalid argument supplied for foreach() in C:\AppServ\www\Vanilla\extensions\VanillaPacker\default.php on line 92
Any idea how to fix this?
Thanks
Basically all I've done is gone through the patch and separated out the files that are uploaded that do not touch shipped Vanilla files, from the files that are shipped Vanilla files that are modified.
Then with the modified Vanilla files, I've diff'd the patch versions against the original shipped files. From that I've created a single document that summarises what is needed to patch Vanilla manually.
So the patch step is now split into two:
1) Upload new files
2) Manually modify existing .php files
The manual modifications I've bundled into text files for each significant version of Vanilla, so at the moment I have a text file for 1.1.2 and 1.1.4, though in the future more will appear to keep Packer working.
The differences between Packer for 1.1.2 and 1.1.4, nothing at all. However if you used the original Patch files, those get replaced during the upgrade so it would break but if you follow my text files you'll be able to re-apply the patch manually.
Here's the list of files in the upload folder now (was the Patch folder, just delete anything that isn't one of these from the old Patch folder);
/appg/init_packer.php
/conf/packer.php
/js/packer.php
/js/cache/
/library/Framework/Framework.Class.JSMin.php
/library/Framework/Framework.Class.PackManager.php
/themes/vanilla/styles/default/packer.php
/themes/vanilla/styles/default/cache/
And the readme.txt becomes:
FILE: \appg\database.php FIND: ?> INSERT BEFORE: // HACK : START : PACKER $DatabaseTables['FilesToPack'] = 'FilesToPack'; $DatabaseTables['CssMedia'] = 'CssMedia'; $DatabaseColumns['FilesToPack']['FileID'] = 'FileID'; $DatabaseColumns['FilesToPack']['FilePath'] = 'FilePath'; $DatabaseColumns['CssMedia']['MediaID'] = 'MediaID'; $DatabaseColumns['CssMedia']['MediaName'] = 'MediaName'; // HACK : END : PACKER FILE: \appg\init_people.php FIND: $Head->AddScript('js/global.js'); $Head->AddStyleSheet($Context->StyleUrl.'people.css', 'screen', 100, ''); REPLACE WITH: // HACK : START : PACKER // $Head->AddScript('js/global.js'); // $Head->AddStyleSheet($Context->StyleUrl.'people.css', 'screen', 100, ''); $Head->AddScript('js/global.js', '~', '290', 1, 0); //need a path relative to vanilla root $StylePath = $Context->StyleUrl; $StylePath = ereg_replace("^".$Context->Configuration['WEB_ROOT'], '', $StylePath); $Head->AddStyleSheet($StylePath.'people.css', 'screen', 100, '~', 1); // HACK : END : PACKER FILE: \appg\init_vanilla.php FIND: $Head->AddScript('js/global.js'); $Head->AddScript('js/vanilla.js'); $Head->AddScript('js/ajax.js'); $Head->AddScript('js/ac.js'); $Head->AddStyleSheet($Context->StyleUrl.'vanilla.css', 'screen', 100, ''); $Head->AddStyleSheet($Context->StyleUrl.'vanilla.print.css', 'print', 101, ''); REPLACE WITH: // HACK : START : PACKER //$Head->AddScript('js/global.js'); //$Head->AddScript('js/vanilla.js'); //$Head->AddScript('js/ajax.js'); //$Head->AddScript('js/ac.js'); //$Head->AddStyleSheet($Context->StyleUrl.'vanilla.css', 'screen', 100, ''); //$Head->AddStyleSheet($Context->StyleUrl.'vanilla.print.css', 'print', 101, ''); $Head->AddScript('js/global.js', '~', '290', 1, 0); $Head->AddScript('js/vanilla.js', '~', '291', 1, 0); $Head->AddScript('js/ajax.js', '~', '292', 1, 0); $Head->AddScript('js/ac.js', '~', '293', 1, 0); //need a path relative to vanilla root $StylePath = $Context->StyleUrl; $StylePath = ereg_replace("^".$Context->Configuration['WEB_ROOT'], '', $StylePath); $Head->AddStyleSheet($StylePath.'vanilla.css', 'screen', 100, '~', 1); $Head->AddStyleSheet($StylePath.'vanilla.print.css', 'print', 101, '~', 1); // HACK : END : PACKER FILE: \library\Framework\Framework.Control.Head.php FIND: var $Meta; // An associative array of meta tags/content to be added to the head. INSERT AFTER: // HACK : START : PACKER var $_Scripts; var $_StyleSheets; var $PackManager; // HACK : END : PACKER FIND: function AddScript($ScriptLocation, $ScriptRoot = '~') { if (!is_array($this->Scripts)) $this->Scripts = array(); if ($ScriptRoot == '~') $ScriptRoot = $this->Context->Configuration['WEB_ROOT']; $ScriptPath = $ScriptLocation; if ($ScriptRoot != '') $ScriptPath = ConcatenatePath($ScriptRoot, $ScriptLocation); if (!in_array($ScriptPath, $this->Scripts)) $this->Scripts[] = $ScriptPath; } REPLACE WITH: // HACK : START : PACKER // function AddScript($ScriptLocation, $ScriptRoot = '~') { // if (!is_array($this->Scripts)) $this->Scripts = array(); // if ($ScriptRoot == '~') $ScriptRoot = $this->Context->Configuration['WEB_ROOT']; // $ScriptPath = $ScriptLocation; // if ($ScriptRoot != '') $ScriptPath = ConcatenatePath($ScriptRoot, $ScriptLocation); // if (!in_array($ScriptPath, $this->Scripts)) $this->Scripts[] = $ScriptPath; // } /*$Position: Position in the list of script. You should try to the appropriate: 100-199: for libraries that can't be packed (e.g. YUI hosted on yahoo servers); 200-299: for libraries that can be packed (e.g. jQuery); 300-399: for script that can be pack; 400+: for script that can't be packed. */ function AddScript($ScriptLocation, $ScriptRoot = '~', $Position = '350', $ToPack = 1, $ToMinify = 0) { if (!is_array($this->_Scripts)) $this->_Scripts = array(); if ($ScriptRoot == '~') { $ScriptRoot = $this->Context->Configuration['WEB_ROOT']; } else { //the script need a relative path to the forum to merge it //If you specify you specify a web root it can't be merge $ToPack = 0; } $Location = $ScriptLocation; if ($ScriptRoot != '') $Location = ConcatenatePath($ScriptRoot, $ScriptLocation); $this->InsertItemAt($this->_Scripts, array('Location' => $Location, 'Path' => $ScriptLocation, 'ToPack' => $ToPack, 'ToMinify' => $ToMinify), $Position); } // HACK : END : PACKER FIND: function AddStyleSheet($StyleSheetLocation, $Media = '', $Position = '100', $StyleRoot = '~') { if ($StyleRoot == '~') $StyleRoot = $this->Context->Configuration['WEB_ROOT']; if (!is_array($this->StyleSheets)) $this->StyleSheets = array(); $StylePath = $StyleSheetLocation; if ($StylePath != '') $StylePath = ConcatenatePath($StyleRoot, $StyleSheetLocation); $this->InsertItemAt($this->StyleSheets, array('Sheet' => $StylePath, 'Media' => $Media), $Position); } REPLACE WITH: // HACK : START : PACKER // function AddStyleSheet($StyleSheetLocation, $Media = '', $Position = '100', $StyleRoot = '~') { // if ($StyleRoot == '~') $StyleRoot = $this->Context->Configuration['WEB_ROOT']; // if (!is_array($this->StyleSheets)) $this->StyleSheets = array(); // $StylePath = $StyleSheetLocation; // if ($StylePath != '') $StylePath = ConcatenatePath($StyleRoot, $StyleSheetLocation); // $this->InsertItemAt($this->StyleSheets, // array('Sheet' => $StylePath, 'Media' => $Media), // $Position); // } function AddStyleSheet($StyleSheetLocation, $Media = '', $Position = '100', $StyleRoot = '~', $ToPack = 1) { if (!is_array($this->_StyleSheets)) $this->_StyleSheets = array(); if ($StyleRoot == '~') { $StyleRoot = $this->Context->Configuration['WEB_ROOT']; } else { $ToPack = 0; } $Sheet = $StyleSheetLocation; if ($StyleRoot != '') $Sheet = ConcatenatePath($StyleRoot, $StyleSheetLocation); $Media = strtolower($Media); $this->InsertItemAt($this->_StyleSheets, array('Sheet' => $Sheet, 'Path' => $StyleSheetLocation, 'Media' => $Media, 'ToPack' => $ToPack), $Position); } // HACK : END : PACKER FIND: $this->Meta = array(); INSERT AFTER: // HACK : START : PACKER $this->PackManager = $this->Context->ObjectFactory->NewContextObject($this->Context, 'PackManager'); // HACK : END : PACKER FIND: } ?> INSERT BEFORE: // HACK : START : PACKER function _SortScripts(){ if (is_array($this->_Scripts)) { $Pack = new Pack($this->Context); $Pack->Extension = 'js'; $this->Scripts = array(); ksort($this->_Scripts); if($this->Context->Configuration['PACKER_ON']){ foreach ($this->_Scripts as $Script) { $url = ''; if ($Script['ToPack']){ $Pack->AddFile($Script['Path'], $Script['ToMinify']); } else { if ($url = $this->PackManager->GetPackUrl($Pack)){ $this->Scripts[] = $url; } $Pack->files_to_merge = array(); $this->Scripts[] = $Script['Location']; } } $url = ''; if ($url = $this->PackManager->GetPackUrl($Pack)){ $this->Scripts[] = $url; } } else { foreach ($this->_Scripts as $Script) { $this->Scripts[] = $Script['Location']; } } } } function _SortSheets(){ if(is_array($this->_StyleSheets)){ $Pack = $this->Context->ObjectFactory->NewContextObject($this->Context, 'Pack'); $Pack->Extension = 'css'; $this->StyleSheets = array(); ksort($this->_StyleSheets); if($this->Context->Configuration['PACKER_ON']){ //check if we should pack the sheets foreach ($this->_StyleSheets as $Sheet) { $url = ''; if($Sheet['ToPack']){ //check is this sheet will be packed with the others $Pack->AddFile($Sheet['Path'], $Sheet['Media']); // we just add it to the list of sheets to pack } else { if($url = $this->PackManager->GetPackUrl($Pack)){ // we pack the sheets that need to be packed $this->StyleSheets[] = array('Sheet' => $url, 'Media' => 'all'); } $Pack->files_to_merge = array(); // start a need pack $Pack->files_to_merge_by_id = array(); $this->StyleSheets[] = $Sheet; //add this sheet alone to the head. } } $url = ''; if($url = $this->PackManager->GetPackUrl($Pack)){ // pack the remaining script that need to be pack $this->StyleSheets[] = array('Sheet' => $url, 'Media' => 'all'); } } else { //We don't pack them foreach ($this->_StyleSheets as $Sheet) { $this->StyleSheets[] = $Sheet; } } } } // HACK : END : PACKER FILE: \library\People\People.Control.RoleForm.php FIND: global $Head; $Head->AddScript('js/prototype.js'); $Head->AddScript('js/scriptaculous.js'); REPLACE WITH: // HACK : START : PACKER // global $Head; // $Head->AddScript('js/prototype.js'); // $Head->AddScript('js/scriptaculous.js'); AddScriptaculous(); // HACK : END : PACKER FILE: \library\Vanilla\Vanilla.Control.CategoryForm.php FIND: global $Head; $Head->AddScript('js/prototype.js'); $Head->AddScript('js/scriptaculous.js'); REPLACE WITH: // HACK : START : PACKER // global $Head; // $Head->AddScript('js/prototype.js'); // $Head->AddScript('js/scriptaculous.js'); AddScriptaculous(); // HACK : END : PACKER
It is what doing Low-Cal Vanilla as well. It does try to pack (jspack) or minify the js files (it is the responsability of the extension author to do that). It compress pages , css and js files; and allow js files to be packed together.
It automatically core js files and allow extensions to add their scripts to this package using something like that:
// Check the Low-Cal Vanilla is installed if ($Configuration['LOWCALVANILLA_TOOLS_PATH']) { // Include Low-Cal Vanilla tools file. // Important: Use require_once or include_once to not load it again if it is already done. require_once($Configuration['LOWCALVANILLA_TOOLS_PATH']); // Add your script LowCalVanilla_AddScript($Context, $Head, 'extensions/MyExtension/script.js'); // Add a library // Use the position argument (300 by default) to be sure it will be added first LowCalVanilla_AddScript($Context, $Head, 'extensions/MyExtension/jQuery-min.js', 100); } else { $Head->AddScript('extensions/MyExtension/jQuery-min.js'); $Head->AddScript('extensions/MyExtension/script.js'); }
What i hope for Vanilla 1.2+, is being able to add to the core a new method to Head (AddScriptToPack() or something like that), not a replacement to AddScript().
DavidK, if you email me the hacked files (see my profile), then I'll make them downloadable with a link in this discussion – In the mean time, I should update my extensions to take advantage of Low-Cal...