File manager - Edit - /home/jardides/www/Jardi-design/administrator/components/com_templateck/views/templateinfos/tmpl/export.php
Back
<?php /** * @name Template Creator CK 3 * @package com_templateck * @copyright Copyright (C) 2013. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - http://www.template-creator.com - http://www.joomlack.fr */ // No direct access to this file defined('_JEXEC') or die('Restricted access'); jimport('joomla.filesystem.file'); include_once JPATH_COMPONENT . '/helpers/ZipArchiver.php'; JHtml::_('behavior.formvalidation'); JHtml::_('stylesheet', 'administrator/components/com_templateck/assets/templateck_template.css'); ?> <script type="text/javascript"> Joomla.submitbutton = function(task) { if (task == 'template.cancel' || document.formvalidator.isValid(document.id('exportGabarit'))) { Joomla.submitform(task, document.getElementById('exportGabarit')); } else { alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')); ?>'); } } </script> <?php $path = JPATH_ROOT . '/components/com_templateck/projects'; $exportfiledest = $path . '/' . $this->item->name . '.tck3'; $this->item->htmlcode = str_replace(JUri::root(true), "|URIBASE|", $this->item->htmlcode); $exportfiletext = json_encode($this->item); // delete the gabarit folder and recreate it, so it is empty if (JFolder::exists($path . '/' . $this->item->name . '_gabarit/')) { JFolder::delete($path . '/' . $this->item->name . '_gabarit/'); } JFolder::create($path . '/' . $this->item->name . '_gabarit/'); // replace the path for imageurl data preg_match_all('/imageurl=\\\"(.*?)\\\"/i', $exportfiletext, $files); preg_match_all('/customimage.?=\\\"(.*?)\\\"/i', $exportfiletext, $files2); $allimgs = array_merge($files[1], $files2[1]); foreach ($allimgs as $i => $file) { if (! $file) continue; $filename = explode('/', $file); $filename = end($filename); $exportfiletext = str_replace('imageurl=\"' . $file, 'imageurl=\"|IMPORTFOLDER|\/' . $filename , $exportfiletext); $exportfiletext = str_replace('<img src=\"\/' . $file, '<img src=\"|URIBASE|\/|IMPORTFOLDER|\/' . $filename , $exportfiletext); $exportfiletext = str_replace("url('\/" . $file, "url('|URIBASE|\/|IMPORTFOLDER|\/" . $filename , $exportfiletext); $file = str_replace('|URIBASE|\/', '', $file); $exportfiletext = str_replace($file, '|IMPORTFOLDER|\/' . $filename , $exportfiletext); // save the images $localfile = trim(stripslashes(str_replace('|URIBASE|', '', $file)), '/'); if (! JFile::copy(JPATH_ROOT . '/' . $localfile, $path . '/' . $this->item->name . '_gabarit/' . $filename) ) { $msg = '<p class="errorck">' . JText::_('CK_ERROR_COPY_IMAGE') . ' : ' . JPATH_ROOT . '/' . $localfile . '</p>'; } else { $msg = '<p class="successck">' . JText::_('CK_SUCCESS_COPY_IMAGE') . ' : ' . JPATH_ROOT . '/' . $localfile . '</p>'; } echo $msg; } // replace the path for <img /> tags preg_match_all('/ <img src=\\\"(.*?)\\\"/i', $exportfiletext, $imgs); foreach ($imgs[1] as $i => $file) { $filename = explode('/', $file); $filename = end($filename); $exportfiletext = str_replace($file, '|URIBASE|\/|IMPORTFOLDER|\/' . $filename , $exportfiletext); } // create the file .tck3 $exportfiletext = str_replace("administrator/components/com_templateck", "|TCK_ADMIN_COMPONENT|", $exportfiletext); $exportfiletext = str_replace("components/com_templateck", "|TCK_COMPONENT|", $exportfiletext); if (!JFile::write($exportfiledest, $exportfiletext)) { $msg = '<p class="errorck">' . JText::_('CK_ERROR_CREATE_GABARIT') . '</p>'; } else { $msg = '<p class="successck">' . JText::_('CK_SUCCESS_CREATE_GABARIT') . '</p>'; } echo $msg; // save the gabarit file if (! JFile::copy($exportfiledest, $path . '/' . $this->item->name . '_gabarit/' . $this->item->name . '.tck3' ) ) { $msg = '<p class="errorck">' . JText::_('CK_ERROR_COPY_GABARIT') . '</p>'; } else { $msg = '<p class="successck">' . JText::_('CK_SUCCESS_COPY_GABARIT') . '</p>'; } echo $msg; // save the html folder if (JFolder::exists( $path . '/' . $this->item->name . '/html' ) ) { JFolder::create($path . '/' . $this->item->name . '_gabarit/html'); JFolder::copy($path . '/' . $this->item->name . '/html', $path . '/' . $this->item->name . '_gabarit/html/', '', true); } // save the custom.css file if (JFile::exists($path . '/' . $this->item->name . '/css/custom.css') ) { JFile::copy($path . '/' . $this->item->name . '/css/custom.css', $path . '/' . $this->item->name . '_gabarit/custom.css' ); } // save the customheader.php file if (JFile::exists($path . '/' . $this->item->name . '/customheader.php') ) { JFile::copy($path . '/' . $this->item->name . '/customheader.php', $path . '/' . $this->item->name . '_gabarit/customheader.php' ); } // save the custom js file if (JFile::exists($path . '/' . $this->item->name . '/js/custom.js') ) { JFile::copy($path . '/' . $this->item->name . '/js/custom.js', $path . '/' . $this->item->name . '_gabarit/custom.js' ); } //save the modules data if (! empty($this->item->modules)) { $modules = explode(',', $this->item->modules); $modulesdata = ""; $db = JFactory::getDbo(); foreach($modules as $module) { $query = "SELECT * FROM #__modules WHERE position='" . $module . "' AND published='1' AND client_id='0'"; $db->setQuery($query); $moduleObj = $db->loadObjectList(); if ( $moduleObj) { $modulesdata .= serialize($moduleObj) . "\n"; } else { // var_dump($moduleObj); // add the SQL field to the main table // $db->setQuery('ALTER TABLE `#__templateck_fonts` ADD `alternatives` text NOT NULL;'); // if (!$db->query()) { // echo '<p class="alert alert-danger">Error during export of module ID ' . $moduleObj->id .'</p>'; // } else { // echo '<p class="alert alert-success">Table alternatives updated !</p>'; // } } } file_put_contents($path . '/' . $this->item->name . '_gabarit/modules.txt', $modulesdata); } // save the template into zip $templatePath = JPATH_ROOT . '/templates/' . $this->item->name; if (JFolder::exists($templatePath)) { $files = JFolder::files($templatePath, false, true, true); $exporter = new ZipArchiver(); $isSuccess = $exporter->create($files, '.zip', $templatePath , true); JFile::copy(JPATH_ROOT . '/templates/' . $this->item->name . '.zip', $path . '/' . $this->item->name . '_gabarit/' . $this->item->name . '.zip'); // return message after creating the zip archive if (!$isSuccess && $exporter->getError()) { $msg = '<p class="errorck">' . JText::_('CK_ERROR_CREATING_ARCHIVE') . '</p>'; } else { $msg = '<p class="successck">' . JText::_('CK_SUCCESS_CREATING_ARCHIVE') . '</p>'; } } echo $msg; $files = JFolder::files($path . '/' . $this->item->name . '_gabarit/', false, true, true); $exporter = new ZipArchiver(); $isSuccess = $exporter->create($files, '.tck3z', $path . '/' . $this->item->name . '_gabarit', true); ?> <form action="<?php echo JRoute::_('index.php'); ?>" enctype="multipart/form-data" method="post" name="adminForm" id="exportGabarit" class="form-validate"> <?php // create button to download the package echo '<p style="padding: 15px;"><a class="ckdownload" style="background: #3D3D3D;border-radius: 3px;color: #E1E1E1;cursor: pointer;margin: 3px;padding: 2px 5px;text-decoration: none;" target="_blank" href="' . JURI::root() . 'components/com_templateck/projects/' . $this->item->name . '_gabarit.tck3z">' . JText::_('CK_DOWNLOAD_GABARIT') . '</a></p>'; ?> <input type="hidden" name="option" value="com_templateck" /> <input type="hidden" name="id" value="" /> <input type="hidden" name="task" value="" /> <input type="hidden" name="controller" value="template" /> <?php echo JHtml::_('form.token'); ?> </form>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings