Added sharing of snippets option and started adding get snippets custom admin view gh-92. Fixed gh-153 published settings for categories.
This commit is contained in:
@ -87,7 +87,7 @@ class Compiler extends Infusion
|
||||
$this->removeFolder($this->componentPath . '/site');
|
||||
// clear form component xml
|
||||
$xmlPath = $this->componentPath . '/'. $this->fileContentStatic['###component###']. '.xml';
|
||||
$componentXML = file_get_contents($xmlPath);
|
||||
$componentXML = ComponentbuilderHelper::getFileContents($xmlPath);
|
||||
$textToSite = ComponentbuilderHelper::getBetween($componentXML,'<files folder="site">','</files>');
|
||||
$textToSiteLang = ComponentbuilderHelper::getBetween($componentXML,'<languages folder="site">','</languages>');
|
||||
$componentXML = str_replace(array('<files folder="site">'.$textToSite."</files>", '<languages folder="site">'.$textToSiteLang."</languages>"), array('',''), $componentXML);
|
||||
@ -183,7 +183,7 @@ class Compiler extends Infusion
|
||||
if (isset($this->newFiles['static']) && ComponentbuilderHelper::checkArray($this->newFiles['static']) && isset($this->newFiles['dynamic']) && ComponentbuilderHelper::checkArray($this->newFiles['dynamic']))
|
||||
{
|
||||
// get the bom file
|
||||
$bom = file_get_contents($this->bomPath);
|
||||
$bom = ComponentbuilderHelper::getFileContents($this->bomPath);
|
||||
// first we do the static files
|
||||
foreach ($this->newFiles['static'] as $static)
|
||||
{
|
||||
@ -195,7 +195,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
$php = "<?php\n";
|
||||
}
|
||||
$string = file_get_contents($static['path']);
|
||||
$string = ComponentbuilderHelper::getFileContents($static['path']);
|
||||
if (strpos($string,'###BOM###') !== false)
|
||||
{
|
||||
list($wast,$code) = explode('###BOM###',$string);
|
||||
@ -232,7 +232,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
$php = "<?php\n";
|
||||
}
|
||||
$string = file_get_contents($file['path']);
|
||||
$string = ComponentbuilderHelper::getFileContents($file['path']);
|
||||
if (strpos($string,'###BOM###') !== false)
|
||||
{
|
||||
list($bin,$code) = explode('###BOM###',$string);
|
||||
@ -385,7 +385,7 @@ class Compiler extends Infusion
|
||||
$this->buildReadMeData();
|
||||
}
|
||||
// get the file
|
||||
$string = file_get_contents($path);
|
||||
$string = ComponentbuilderHelper::getFileContents($path);
|
||||
// update the file
|
||||
$answer = $this->setPlaceholders($string, $this->fileContentStatic);
|
||||
// add to zip array
|
||||
|
@ -2881,6 +2881,7 @@ class Get
|
||||
}
|
||||
$gets = array();
|
||||
$keys = array();
|
||||
// first load all options
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
if (strpos($line,'AS') !== false)
|
||||
@ -2896,13 +2897,16 @@ class Get
|
||||
$get = $line;
|
||||
$key = null;
|
||||
}
|
||||
// set the get and key
|
||||
$get = trim($get);
|
||||
$key = trim($key);
|
||||
// only add the view
|
||||
if ('a' != $as && 1 == $row_type && 'view' === $type && strpos('#'.$key,'#'.$view.'_') === false)
|
||||
// only add the view (we must adapt this)
|
||||
if (isset($this->getAsLookup[$method_key][$get]) && 'a' != $as && 1 == $row_type && 'view' === $type && strpos('#'.$key,'#'.$view.'_') === false)
|
||||
{
|
||||
// this is a problem (TODO) since we may want to not add the view name.
|
||||
$key = $view.'_'.trim($key);
|
||||
}
|
||||
// continue only if we have get
|
||||
if (ComponentbuilderHelper::checkString($get))
|
||||
{
|
||||
$gets[] = $this->db->quote($get);
|
||||
|
@ -910,7 +910,7 @@ class Structure extends Get
|
||||
private function setJoomlaVersionData()
|
||||
{
|
||||
// set the version data
|
||||
$versionData = json_decode(file_get_contents($this->templatePath.'/settings.json'));
|
||||
$versionData = json_decode(ComponentbuilderHelper::getFileContents($this->templatePath.'/settings.json'));
|
||||
// add custom folders
|
||||
if ((isset($this->componentData->folders) && ComponentbuilderHelper::checkArray($this->componentData->folders)) || $this->addEximport || $this->uikit || $this->footable)
|
||||
{
|
||||
|
@ -3742,7 +3742,7 @@ class Interpretation extends Fields
|
||||
{
|
||||
if (JFile::exists($file['path']))
|
||||
{
|
||||
$string = file_get_contents($file['path']);
|
||||
$string = ComponentbuilderHelper::getFileContents($file['path']);
|
||||
$buket['static'][] = $this->getInbetweenStrings($string);
|
||||
}
|
||||
}
|
||||
@ -3754,7 +3754,7 @@ class Interpretation extends Fields
|
||||
{
|
||||
if (JFile::exists($doc['path']))
|
||||
{
|
||||
$string = file_get_contents($doc['path']);
|
||||
$string = ComponentbuilderHelper::getFileContents($doc['path']);
|
||||
$buket[$view][] = $this->getInbetweenStrings($string);
|
||||
}
|
||||
}
|
||||
|
@ -1305,7 +1305,7 @@ class Infusion extends Interpretation
|
||||
// build xml path
|
||||
$xmlPath = $this->componentPath . '/'. $this->fileContentStatic['###component###']. '.xml';
|
||||
// get the content in xml
|
||||
$componentXML = file_get_contents($xmlPath);
|
||||
$componentXML = ComponentbuilderHelper::getFileContents($xmlPath);
|
||||
// update the xml content
|
||||
$componentXML = $this->setPlaceholders($componentXML, $replace);
|
||||
// store the values back to xml
|
||||
|
@ -250,7 +250,7 @@ abstract class ComponentbuilderHelper
|
||||
**/
|
||||
protected static $params = false;
|
||||
|
||||
/*
|
||||
/**
|
||||
* get all component IDs
|
||||
*/
|
||||
public static function getComponentIDs()
|
||||
@ -271,7 +271,7 @@ abstract class ComponentbuilderHelper
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Autoloader
|
||||
*/
|
||||
public static function autoLoader($type = 'compiler')
|
||||
@ -384,14 +384,14 @@ abstract class ComponentbuilderHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* The zipper method
|
||||
*
|
||||
* @param string $workingDIR The directory where the items must be zipped
|
||||
* @param string $filepath The path to where the zip file must be placed
|
||||
*
|
||||
* @return bool true On success
|
||||
*
|
||||
*/
|
||||
* The zipper method
|
||||
*
|
||||
* @param string $workingDIR The directory where the items must be zipped
|
||||
* @param string $filepath The path to where the zip file must be placed
|
||||
*
|
||||
* @return bool true On success
|
||||
*
|
||||
*/
|
||||
public static function zip($workingDIR, &$filepath)
|
||||
{
|
||||
// store the current joomla working directory
|
||||
@ -435,14 +435,14 @@ abstract class ComponentbuilderHelper
|
||||
|
||||
|
||||
/**
|
||||
* Write a file to the server
|
||||
*
|
||||
* @param string $path The path and file name where to safe the data
|
||||
* @param string $data The data to safe
|
||||
*
|
||||
* @return bool true On success
|
||||
*
|
||||
*/
|
||||
* Write a file to the server
|
||||
*
|
||||
* @param string $path The path and file name where to safe the data
|
||||
* @param string $data The data to safe
|
||||
*
|
||||
* @return bool true On success
|
||||
*
|
||||
*/
|
||||
public static function writeFile($path, $data)
|
||||
{
|
||||
$klaar = false;
|
||||
@ -1398,7 +1398,7 @@ abstract class ComponentbuilderHelper
|
||||
// first get the file path
|
||||
$path_filename = self::getFilePath('path', $name.$type, $fileType, $key, JPATH_COMPONENT_ADMINISTRATOR);
|
||||
// set as read if not already set
|
||||
if (($content = @file_get_contents($path_filename)) !== FALSE)
|
||||
if ($content = self::getFileContents($path_filename, false))
|
||||
{
|
||||
if ($hash == $content)
|
||||
{
|
||||
@ -1412,18 +1412,18 @@ abstract class ComponentbuilderHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file path or url
|
||||
*
|
||||
* @param string $type The (url/path) type to return
|
||||
* @param string $target The Params Target name (if set)
|
||||
* @param string $fileType The kind of filename to generate (if not set no file name is generated)
|
||||
* @param string $key The key to adjust the filename (if not set ignored)
|
||||
* @param string $default The default path if not set in Params (fallback path)
|
||||
* @param bool $createIfNotSet The switch to create the folder if not found
|
||||
*
|
||||
* @return string On success the path or url is returned based on the type requested
|
||||
*
|
||||
*/
|
||||
* Get the file path or url
|
||||
*
|
||||
* @param string $type The (url/path) type to return
|
||||
* @param string $target The Params Target name (if set)
|
||||
* @param string $fileType The kind of filename to generate (if not set no file name is generated)
|
||||
* @param string $key The key to adjust the filename (if not set ignored)
|
||||
* @param string $default The default path if not set in Params (fallback path)
|
||||
* @param bool $createIfNotSet The switch to create the folder if not found
|
||||
*
|
||||
* @return string On success the path or url is returned based on the type requested
|
||||
*
|
||||
*/
|
||||
public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = JPATH_SITE . '/images/', $createIfNotSet = true)
|
||||
{
|
||||
// get the global settings
|
||||
@ -1480,7 +1480,94 @@ abstract class ComponentbuilderHelper
|
||||
// sanitize the path
|
||||
return '/' . trim( $filePath, '/' ) . '/' . $fileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the file path or url
|
||||
*
|
||||
* @param string $type The (url/path) type to return
|
||||
* @param string $target The Params Target name (if set)
|
||||
* @param string $default The default path if not set in Params (fallback path)
|
||||
* @param bool $createIfNotSet The switch to create the folder if not found
|
||||
*
|
||||
* @return string On success the path or url is returned based on the type requested
|
||||
*
|
||||
*/
|
||||
public static function getFolderPath($type = 'path', $target = 'folderpath', $default = JPATH_SITE . '/images/', $createIfNotSet = true)
|
||||
{
|
||||
// get the global settings
|
||||
if (!self::checkObject(self::$params))
|
||||
{
|
||||
self::$params = JComponentHelper::getParams('com_componentbuilder');
|
||||
}
|
||||
$folderPath = self::$params->get($target, $default);
|
||||
jimport('joomla.filesystem.folder');
|
||||
// create the folder if it does not exist
|
||||
if ($createIfNotSet && !JFolder::exists($folderPath))
|
||||
{
|
||||
JFolder::create($folderPath);
|
||||
}
|
||||
// return the url
|
||||
if ('url' === $type)
|
||||
{
|
||||
if (strpos($folderPath, JPATH_SITE) !== false)
|
||||
{
|
||||
$folderPath = trim( str_replace( JPATH_SITE, '', $folderPath), '/');
|
||||
return JURI::root() . $folderPath . '/';
|
||||
}
|
||||
// since the path is behind the root folder of the site, return only the root url (may be used to build the link)
|
||||
return JURI::root();
|
||||
}
|
||||
// sanitize the path
|
||||
return '/' . trim( $folderPath, '/' ) . '/';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the content of a file
|
||||
*
|
||||
* @param string $path The path to the file
|
||||
* @param string/bool $none The return value if no content was found
|
||||
*
|
||||
* @return string On success
|
||||
*
|
||||
*/
|
||||
public static function getFileContents($path, $none = '')
|
||||
{
|
||||
if (self::checkString($path))
|
||||
{
|
||||
// use basic file get content for now
|
||||
if (($content = @file_get_contents($path)) !== FALSE)
|
||||
{
|
||||
return $content;
|
||||
}
|
||||
// use curl if available
|
||||
elseif (function_exists('curl_version'))
|
||||
{
|
||||
// start curl
|
||||
$ch = curl_init();
|
||||
// set the options
|
||||
$options = array();
|
||||
$options[CURLOPT_URL] = $path;
|
||||
$options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12';
|
||||
$options[CURLOPT_RETURNTRANSFER] = TRUE;
|
||||
$options[CURLOPT_SSL_VERIFYPEER] = FALSE;
|
||||
// load the options
|
||||
curl_setopt_array($ch, $options);
|
||||
// get the content
|
||||
$content = curl_exec($ch);
|
||||
// close the connection
|
||||
curl_close($ch);
|
||||
// return if found
|
||||
if (self::checkString($content))
|
||||
{
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Component xml manifest.
|
||||
**/
|
||||
|
Reference in New Issue
Block a user