Example #1
0
 public static function init($name, $extension, $params)
 {
     // Init
     $name_date = $params->get('filename_date', '');
     $tmp_path = JFactory::getConfig()->get('tmp_path');
     $tmp_dir = uniqid('cck_');
     // Set
     $output = new stdClass();
     $output->name = $name;
     $output->suffix = $name_date != '' ? '_' . JFactory::getDate()->format($name_date) : '';
     $output->path = $tmp_path . '/' . $tmp_dir;
     $output->root = $output->path . '/' . $extension;
     $output->output = $params->get('output', 0);
     $output->output_path = $params->get('output_path', '');
     $output->compression = $params->get('compression', 'zip');
     if ($output->output == 2 && $output->output_path != '' && JFolder::exists($output->output_path)) {
         $output->output_path = $output->output_path;
     } elseif ($output->output_path != '' && $output->output_path != 'tmp/') {
         $output->output_path = JPATH_SITE . '/' . $output->output_path;
         if (!JFolder::exists($output->output_path)) {
             jimport('cck.base.install.export');
             CCK_Export::createDir($output->output_path);
         }
     } else {
         $output->output_path = $tmp_path;
     }
     return $output;
 }
Example #2
0
File: app.php Project: hamby/SEBLOD
 protected static function _exportCategories($value, $glue, &$data)
 {
     $values = JCckDev::fromSTRING($value, $glue);
     $value = array();
     foreach ($values as $v) {
         $table = JTable::getInstance('category');
         if ($v > 0) {
             $table->load($v);
         }
         $table->name = $data['root_category'] . '_' . str_replace('-', '_', $table->alias);
         $value[] = $table->name;
         CCK_Export::exportContent('joomla_category', $table, $data, $extensions, 0);
     }
     return implode($glue, $value);
 }
Example #3
0
 public function prepareExport($id = 0, $elements = array(), $dependencies = array(), $options = array())
 {
     $config = JFactory::getConfig();
     $tmp_path = $config->get('tmp_path');
     $tmp_dir = uniqid('cck_');
     $path = $tmp_path . '/' . $tmp_dir;
     $folders = isset($elements['subfolders']) ? Helper_Folder::getBranch($id, ',') : $id;
     $folders = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_folders WHERE id IN (' . (string) $folders . ') ORDER BY lft');
     if (!@$folders[0]) {
         return;
     }
     $isApp = false;
     $isCck = false;
     $name = $folders[0]->name;
     if (!$name) {
         return;
     }
     // Core
     jimport('joomla.filesystem.file');
     jimport('cck.base.install.export');
     $data = array('root' => $path, 'root_content' => $path . '/content', 'root_elements' => $path . '/elements', 'root_extensions' => $path . '/extensions', 'root_sql' => $path . '/sql', 'root_category' => '', 'elements' => array(), 'db_prefix' => $config->get('dbprefix'));
     $extensions = array(0 => (object) array('type' => 'plugin', 'id' => 'plg_system_blank', 'group' => 'system', '_file' => 'plg_system_blank.zip'));
     $data['folders'] = JCckDatabase::loadObjectList('SELECT id, name, path FROM #__cck_core_folders WHERE lft', 'id');
     $data['folders2'] = JCckDatabase::loadObjectList('SELECT id, name, path FROM #__cck_core_folders WHERE lft', 'name');
     $data['plugins'] = CCK_Export::getCorePlugins();
     $data['plugins']['cck_field_live']['stage'] = true;
     $data['processings'] = JCckDatabase::loadObjectList('SELECT * FROM #__cck_more_processings', 'id');
     $data['processings2'] = JCckDatabase::loadObjectList('SELECT folder FROM #__cck_more_processings', 'folder');
     $data['styles'] = JCckDatabase::loadObjectList('SELECT * FROM #__template_styles', 'id');
     $data['tables'] = array_flip(JCckDatabase::loadColumn('SHOW TABLES'));
     $data['tables_excluded'] = CCK_Export::getCoreTables();
     $data['variations'] = array('empty' => true, 'joomla' => true, 'seb_css3' => true, 'seb_css3b' => true);
     // Copyright
     if (JCckDatabase::loadResult('SELECT extension_id FROM #__extensions WHERE type = "component" AND element = "com_cck_packager"') > 0) {
         $params = JComponentHelper::getParams('com_cck_packager');
         $copyright = $params->get('copyright');
     } else {
         $copyright = '';
     }
     CCK_Export::createDir($data['root_content']);
     CCK_Export::createDir($data['root_elements']);
     CCK_Export::createDir($data['root_extensions']);
     CCK_Export::createDir($data['root_sql']);
     if (isset($dependencies['categories'])) {
         $data['root_category'] = CCK_Export::exportRootCategory($folders['0'], $data, $extensions);
     }
     if (isset($dependencies['menu'])) {
         $data['root_menu'] = CCK_Export::exportMenus($dependencies['menu'], $data, $extensions);
     }
     foreach ($folders as $i => $folder) {
         if ($i == 0) {
             if ($folder->path && $folder->path != $folder->name) {
                 $branch = explode('/', $folder->path);
                 array_pop($branch);
                 if (count($branch)) {
                     $parent_id = 2;
                     foreach ($branch as $k => $v) {
                         $elem = JCckDatabase::loadObject('SELECT * FROM #__cck_core_folders WHERE name = "' . (string) $v . '" AND parent_id = ' . (int) $parent_id);
                         $parent_id = $elem->id;
                         CCK_Export::createDir($data['root_elements'] . '/folder' . 's');
                         CCK_Export::exportElement('folder', $elem, $data, $extensions, 0);
                     }
                 }
             }
         }
         CCK_Export::exportElements('folder', $folders, $data, $extensions, 0, $copyright);
         if (isset($elements['fields'])) {
             $fields = JCckDatabase::loadObjectList('SELECT a.* FROM #__cck_core_fields AS a WHERE a.folder = ' . (int) $folder->id);
             CCK_Export::exportElements('field', $fields, $data, $extensions, 500, $copyright);
         }
         if (isset($elements['templates'])) {
             $templates = JCckDatabase::loadObjectList('SELECT a.* FROM #__cck_core_templates AS a WHERE a.folder = ' . (int) $folder->id);
             CCK_Export::exportElements('template', $templates, $data, $extensions, 0, $copyright);
         }
         if (isset($elements['types'])) {
             $types = JCckDatabase::loadObjectList('SELECT a.* FROM #__cck_core_types AS a WHERE a.folder = ' . (int) $folder->id);
             if (count($types)) {
                 $isApp = true;
             }
             CCK_Export::exportElements('type', $types, $data, $extensions, 0, $copyright);
         }
         if (isset($elements['searchs'])) {
             $searchs = JCckDatabase::loadObjectList('SELECT a.* FROM #__cck_core_searchs AS a WHERE a.folder = ' . (int) $folder->id);
             if (count($searchs)) {
                 $isApp = true;
             }
             CCK_Export::exportElements('search', $searchs, $data, $extensions, 0, $copyright);
         }
     }
     if (count($data['elements']['tables'])) {
         CCK_Export::exportTables($data);
     }
     if (count($data['elements']['processings'])) {
         $isCck = true;
         CCK_Export::exportProcessings($data, $extensions);
     }
     // Name & Root
     if ($isApp) {
         $filename = 'app_cck_' . $name;
     } else {
         if ($isCck) {
             $filename = 'cck_' . $name;
         } else {
             $filename = $name;
         }
         if (isset($dependencies['categories']) && file_exists($data['root_content'] . '/joomla_category')) {
             $items = JFolder::files($data['root_content'] . '/joomla_category', '\\.xml$');
             if (count($items) == 1 && isset($items[0]) && $data['root_category'] != '' && JFile::stripExt($items[0]) == $data['root_category']) {
                 JFolder::delete($data['root_content'] . '/joomla_category');
             }
         }
     }
     // Elements
     if ($copyright) {
         CCK_Export::update($data['root_elements'], $copyright);
     }
     // Xml
     $folders[0]->description = 'SEBLOD 3.x ' . $folders[0]->title . ' App - www.seblod.com';
     $folders[0]->name = $filename;
     $folders[0]->title = 'pkg_' . $folders['0']->name;
     $manifest = NULL;
     $xml = CCK_Export::preparePackage($folders[0]);
     if (is_object($xml)) {
         $manifest = JPATH_ADMINISTRATOR . '/manifests/packages/pkg_' . $filename . '.xml';
         if (is_file($manifest)) {
             if ($copyright) {
                 CCK_Export::update($manifest, $copyright);
             }
             $manifest = JCckDev::fromXML($manifest);
             $tags = array('copyright', 'creationDate', 'description', 'packager', 'packageurl', 'version');
             if (is_object($manifest)) {
                 foreach ($tags as $tag) {
                     if (isset($manifest->{$tag}) && isset($xml->{$tag}) && $manifest->{$tag} != $xml->{$tag}) {
                         $xml->{$tag} = (string) $manifest->{$tag};
                     }
                 }
             }
         }
     }
     // Filename
     $path_zip = $tmp_path . '/' . $filename;
     if (isset($options['filename_version']) && $options['filename_version']) {
         $path_zip .= '_' . (isset($manifest->version) ? $manifest->version : '1.0.0');
     }
     if (isset($options['filename_date']) && $options['filename_date']) {
         $path_zip .= '_' . JFactory::getDate()->format('Y_m_d');
     }
     $path_zip .= '.zip';
     // Script
     if (is_file(JPATH_ADMINISTRATOR . '/manifests/packages/' . $name . '/pkg_script.php')) {
         if ($copyright) {
             CCK_Export::update(JPATH_ADMINISTRATOR . '/manifests/packages/' . $name . '/pkg_script.php', $copyright);
         }
     }
     // todo: else
     $script = $xml->addChild('scriptfile', 'pkg_script.php');
     JFile::copy(JPATH_SITE . '/libraries/cck/development/apps/script.php', $path . '/pkg_script.php');
     $buffer = JFile::read($path . '/pkg_script.php');
     $buffer = str_replace('%class%', $filename, $buffer);
     JFile::write($path . '/pkg_script.php', $buffer);
     if ($copyright) {
         CCK_Export::update($path . '/pkg_script.php', $copyright);
     }
     // Extensions
     $files = $xml->addChild('files');
     $files->addAttribute('folder', 'extensions');
     $names = array();
     foreach ($extensions as $ext) {
         $file = $files->addChild('file', $ext->_file);
         $names[$ext->_file] = '';
         foreach ($ext as $k => $v) {
             if ($k != '_file') {
                 $file->addAttribute($k, $v);
             }
         }
     }
     if (isset($manifest->files->file) && count($manifest->files->file)) {
         foreach ($manifest->files->file as $f) {
             $f_name = (string) $f;
             if (!isset($names[$f_name])) {
                 $f_file = array('_' => $f_name);
                 $f_client = (string) $f->attributes()->client;
                 $f_id = (string) $f->attributes()->id;
                 $f_type = (string) $f->attributes()->type;
                 if ($f_type == 'template') {
                     $f_file['lang_root'] = JPATH_SITE;
                     $f_file['src'] = JPATH_SITE . '/templates/' . (strpos($f_id, 'tpl_') !== false && strpos($f_id, 'tpl_') == 0 ? substr($f_id, 4) : $f_id);
                     $f_file['lang_src'] = $f_file['src'] . '/templateDetails.xml';
                 } else {
                     // todo
                 }
                 if (is_array($f_file) && $f_file['src'] != '') {
                     CCK_Export::exportFile($f_type, $data, $f_file, array(), $copyright);
                     $file = $files->addChild('file', $f_name);
                     $file->addAttribute('type', $f_type);
                     $file->addAttribute('id', $f_id);
                     $file->addAttribute('client', $f_client);
                 }
             }
         }
     }
     // Languages
     $dest = CCK_Export::createDir($path . '/languages');
     $languages = JCckDatabase::loadColumn('SELECT element FROM #__extensions WHERE type = "language" AND client_id = 0');
     if (count($languages)) {
         $lang = $xml->addChild('languages');
         $lang->addAttribute('folder', 'languages');
         foreach ($languages as $language) {
             if (is_file(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.ini')) {
                 $l = $lang->addChild('language', $language . '/' . $language . '.pkg_' . $filename . '.ini');
                 $l->addAttribute('tag', $language);
                 CCK_Export::createDir($path . '/languages/' . $language);
                 if ($copyright) {
                     CCK_Export::update(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.ini', $copyright);
                 }
                 JFile::copy(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.ini', $dest . '/' . $language . '/' . $language . '.pkg_' . $filename . '.ini');
             }
             if (is_file(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.sys.ini')) {
                 $l = $lang->addChild('language', $language . '/' . $language . '.pkg_' . $filename . '.sys.ini');
                 $l->addAttribute('tag', $language);
                 CCK_Export::createDir($path . '/languages/' . $language);
                 if ($copyright) {
                     CCK_Export::update(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.sys.ini', $copyright);
                 }
                 JFile::copy(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.sys.ini', $dest . '/' . $language . '/' . $language . '.pkg_' . $filename . '.sys.ini');
             }
         }
     }
     // Media
     if (file_exists(JPATH_SITE . '/media/cck/apps/' . $name)) {
         JFolder::copy(JPATH_SITE . '/media/cck/apps/' . $name, $path . '/media');
     }
     // Manifest
     JFile::copy(JPATH_LIBRARIES . '/cck/base/install/_plg_system_blank.zip', $path . '/extensions/plg_system_blank.zip');
     if (is_object($manifest) && isset($manifest->updateservers)) {
         $servers = $xml->addChild('updateservers');
         if (count($manifest->updateservers->server)) {
             foreach ($manifest->updateservers->server as $server) {
                 $s = $servers->addChild('server', (string) $server);
                 $s->addAttribute('type', (string) $server->attributes()->type);
                 $s->addAttribute('priority', (string) $server->attributes()->priority);
                 $s->addAttribute('name', (string) $server->attributes()->name);
             }
         }
     }
     CCK_Export::clean($path);
     CCK_Export::createFile($path . '/pkg_' . $filename . '.xml', '<?xml version="1.0" encoding="utf-8"?>' . $xml->asIndentedXML());
     if ($copyright) {
         CCK_Export::update($path . '/pkg_' . $filename . '.xml', $copyright);
     }
     return CCK_Export::zip($path, $path_zip);
 }
Example #4
0
 public function prepareExport_Variation($name, $folder)
 {
     $config = JFactory::getConfig();
     $tmp_path = $config->get('tmp_path');
     $tmp_dir = uniqid('cck_');
     $path = $tmp_path . '/' . $tmp_dir;
     $filename = 'var_cck_' . $name;
     $path_zip = $tmp_path . '/' . $filename . '.zip';
     $src = JPATH_SITE . $folder . $name;
     // Variation
     jimport('cck.base.install.export');
     if (JFolder::exists($src)) {
         JFolder::copy($src, $path . '/' . $name);
     }
     // Manifest
     $manifest = JPATH_ADMINISTRATOR . '/manifests/files/' . $filename . '.xml';
     jimport('joomla.filesystem.file');
     if (JFile::exists($manifest)) {
         JFile::copy($manifest, $path . '/' . $filename . '.xml');
     } else {
         $xml = CCK_Export::prepareFile((object) array('title' => $filename));
         $fileset = $xml->addChild('fileset');
         $files = $fileset->addChild('files');
         $files->addAttribute('target', 'libraries/cck/rendering/variations');
         $file = $files->addChild('folder', $name);
         CCK_Export::createFile($path . '/' . $filename . '.xml', '<?xml version="1.0" encoding="utf-8"?>' . $xml->asIndentedXML());
     }
     CCK_Export::clean($path);
     CCK_Export::exportLanguage($path . '/' . $filename . '.xml', JPATH_SITE, $path);
     return CCK_Export::zip($path, $path_zip);
 }
Example #5
0
 public function prepareLanguages($lang)
 {
     $config = JFactory::getConfig();
     $tmp_path = $config->get('tmp_path');
     $tmp_dir = uniqid('cck_');
     $path = $tmp_path . '/' . $tmp_dir;
     $name = 'seblod2';
     $filename = $lang . '_' . $name;
     $path_zip = $tmp_path . '/' . $filename . '.zip';
     if (!$filename) {
         return;
     }
     // Core
     jimport('cck.base.install.export');
     $manifest = JCckDev::fromXML(JPATH_ADMINISTRATOR . '/manifests/packages/pkg_cck.xml');
     $extensions = array();
     if (count(@$manifest->files->file)) {
         foreach ($manifest->files->file as $file) {
             $id = (string) $file;
             $id = str_replace('.zip', '', $id);
             if (strpos($id, 'var_cck_') !== false) {
                 $id = 'files_' . $id;
             }
             $extensions[$id] = '';
         }
     }
     $extensions['com_cck_core'] = '';
     $extensions['com_cck_default'] = '';
     // Admin
     $dest = $path . '/admin';
     CCK_Export::exportLanguages(JPATH_ADMINISTRATOR . '/language/' . $lang, $dest, $lang, 'admin', 'cck', $extensions);
     CCK_Export::zip($dest, $path . '/cck_' . $lang . '_admin.zip');
     // Site
     $dest = $path . '/site';
     CCK_Export::exportLanguages(JPATH_SITE . '/language/' . $lang, $dest, $lang, 'site', 'cck|tpl_seb', $extensions);
     CCK_Export::zip($dest, $path . '/cck_' . $lang . '_site.zip');
     // Manifest
     $package = (object) array('title' => 'SEBLOD ' . $lang, 'name' => 'cck_' . $lang, 'description' => 'SEBLOD 3.x ' . $lang . ' Language Pack - www.seblod.com');
     $xml = CCK_Export::preparePackage($package);
     $files = $xml->addChild('files');
     $file1 = $files->addChild('file', 'cck_' . $lang . '_admin.zip');
     $file1->addAttribute('type', 'file');
     $file1->addAttribute('src', 'administrator/language/' . $lang);
     $file1->addAttribute('id', 'cck_' . $lang . '_admin');
     $file2 = $files->addChild('file', 'cck_' . $lang . '_site.zip');
     $file2->addAttribute('type', 'file');
     $file2->addAttribute('src', 'language/' . $lang);
     $file2->addAttribute('id', 'cck_' . $lang . '_site');
     CCK_Export::clean($path);
     CCK_Export::createFile($path . '/pkg_cck_' . $lang . '.xml', '<?xml version="1.0" encoding="utf-8"?>' . $xml->asIndentedXML());
     return CCK_Export::zip($path, $path_zip);
 }
Example #6
0
 public static function exportLanguages($path, $dest, $lang, $client, $search, $extensions = array())
 {
     CCK_Export::createDir($dest);
     $package = (object) array('name' => 'cck_' . $lang . '_' . $client, 'tag' => $lang, 'description' => 'SEBLOD 3.x ' . $lang . ' Language Pack - www.seblod.com', 'client' => $client == 'admin' ? 'administrator' : $client);
     $xml = CCK_Export::prepareLanguage($package);
     $filelist = $xml->addChild('fileset');
     $list = $filelist->addChild('files');
     $target = $client == 'site' ? 'language/' . $lang : 'administrator/language/' . $lang;
     $list->addAttribute('target', $target);
     $files = JFolder::files($path, $search);
     if (count($extensions)) {
         foreach ($files as $file) {
             $id = str_replace(array($lang . '.', '.sys.ini', '.ini'), array('', '', ''), $file);
             if (isset($extensions[$id])) {
                 JFile::copy($path . '/' . $file, $dest . '/' . $file);
                 $list->addChild('filename', $file);
             }
         }
     } else {
         foreach ($files as $file) {
             JFile::copy($path . '/' . $file, $dest . '/' . $file);
         }
     }
     CCK_Export::createFile($dest . '/' . $package->name . '.xml', '<?xml version="1.0" encoding="utf-8"?>' . $xml->asIndentedXML());
 }