本文整理汇总了PHP中JFile::read方法的典型用法代码示例。如果您正苦于以下问题:PHP JFile::read方法的具体用法?PHP JFile::read怎么用?PHP JFile::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFile
的用法示例。
在下文中一共展示了JFile::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply
function apply()
{
$input = JFactory::$application->input;
$filename = $input->getString('filename');
$type = $input->getString('type');
$filedata = $_POST['filedata'];
$dev = $input->getString('dev');
$config['folder_admin'] = "language" . DS . substr($filename, 0, 5);
$urldev = '';
if ($dev) {
$urldev = "&dev=" . $dev;
}
if ($type == "SITE") {
$jpath = JPATH_SITE;
} elseif ($type == "ADMINISTRATOR") {
$jpath = JPATH_ADMINISTRATOR;
}
$openfiledata = JFile::read($jpath . DS . $config['folder_admin'] . DS . $filename);
$checkfiledata = JFile::write($jpath . DS . $config['folder_admin'] . DS . $filename, $filedata);
JFile::write($jpath . DS . $config['folder_admin'] . DS . $filename . '.backup', $filedata);
$app = JFactory::getApplication();
if ($checkfiledata) {
$app->enqueueMessage('Saved successful');
} else {
$app->enqueueMessage('Saved successful', 'error');
}
$this->setRedirect('index.php?option=com_bookpro&view=language&filename=' . $filename . '&type=' . $type . $urldev);
}
示例2: extract
/**
* Extract a ZIP compressed file to a given path
*
* @access public
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
* @param array $options Extraction options [unused]
* @return boolean True if successful
* @since 1.5
*/
function extract($archive, $destination, $options = array())
{
// Initialize variables
$this->_data = null;
$this->_metadata = null;
if (!($this->_data = JFile::read($archive))) {
$this->set('error.message', 'Unable to read archive');
return JError::raiseWarning(100, $this->get('error.message'));
}
if (!$this->_getTarInfo($this->_data)) {
return JError::raiseWarning(100, $this->get('error.message'));
}
for ($i = 0, $n = count($this->_metadata); $i < $n; $i++) {
$type = strtolower($this->_metadata[$i]['type']);
if ($type == 'file' || $type == 'unix file') {
$buffer = $this->_metadata[$i]['data'];
$path = JPath::clean($destination . DS . $this->_metadata[$i]['name']);
// Make sure the destination folder exists
if (!JFolder::create(dirname($path))) {
$this->set('error.message', 'Unable to create destination');
return JError::raiseWarning(100, $this->get('error.message'));
}
if (JFile::write($path, $buffer) === false) {
$this->set('error.message', 'Unable to write entry');
return JError::raiseWarning(100, $this->get('error.message'));
}
}
}
return true;
}
示例3: language
function language()
{
$app = JFactory::getApplication();
$code = JRequest::getString('code');
if (empty($code)) {
$app->enqueueMessage(JText::_('Code not specified', true));
return;
}
$file = new stdClass();
$file->name = $code;
$path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'language' . DS . $code . DS . $code . getBookingExtName() . '.ini';
$file->path = $path;
jimport('joomla.filesystem.file');
$showLatest = true;
$loadLatest = false;
if (JFile::exists($path)) {
$file->content = JFile::read($path);
if (empty($file->content)) {
$app->enqueueMessage('File not found : ' . $path);
}
} else {
$loadLatest = true;
$file->content = JFile::read(JPATH_COMPONENT_ADMINISTRATOR . DS . 'language' . 'en-GB' . DS . 'en-GB.' . getBookingExtName() . '.ini');
}
$this->assignRef('file', $file);
$tpl = "language";
return $tpl;
}
示例4: displayCssEdit
/**
* Check permissions on CSS file
* and display the content via HTML_Joom_AdminCssEdit()
*
*/
function displayCssEdit()
{
// error warning msg for CSS editor
$msg = '';
jimport('joomla.filesystem.file');
$cssfile = $this->cssPath . 'joom_local.css.README';
$editExistingFile = file_exists($this->localCssFile);
if ($editExistingFile) {
$cssfile = $this->localCssFile;
// test by trying to set permissions:
Joom_Chmod($cssfile, 0766);
if (!is_writable($cssfile)) {
$msg = JText::_('JGA_CSS_WARNING_PERMS');
}
} else {
if (!is_writable($this->cssPath)) {
$msg = JText::_('JGA_CSS_WARNING_PERMS');
}
}
if (!($content = JFile::read($cssfile))) {
// output error, overwrite last error (this one is more important)
$msg = JText::_('JGA_CSS_ERROR_READING') . $cssfile;
} else {
$content = htmlspecialchars($content, ENT_QUOTES, 'UTF-8');
}
require_once JPATH_COMPONENT . DS . 'includes' . DS . 'html' . DS . 'admin.cssedit.html.php';
$htmladmincss = new HTML_Joom_AdminCssEdit($content, $this->localCssFile, $editExistingFile, $msg);
}
示例5: _fixManifest
/**
* Fix Joomsef manifest files, to force upgrade method
*
*/
protected function _fixManifest()
{
jimport('joomla.filesystem.file');
// fix original file
$source = $this->parent->getPath('source');
$path = $source . DS . $this->_getElement() . '.xml';
$fileContent = JFile::read($path);
if (!empty($fileContent)) {
$fileContent = str_replace('type="sef_ext"', 'type="sef_ext" method="upgrade"', $fileContent);
$defaults = array();
$remoteConfig = Sh404sefHelperUpdates::getRemoteConfig($forced = false);
$remotes = empty($remoteConfig->config['joomsef_prefixes']) ? array() : $remoteConfig->config['joomsef_prefixes'];
$prefixes = array_unique(array_merge($defaults, $remotes));
foreach ($prefixes as $prefix) {
$fileContent = preg_replace('/function\\s*' . preg_quote($prefix) . '\\s*\\(\\s*\\)\\s*\\{/isU', 'function ' . $prefix . '() { return;', $fileContent);
}
// generic replace
$defaultReplaces = array();
$remoteReplaces = empty($remoteConfig->config['joomsef_prefixes']) ? array() : $remoteConfig->config['joomsef_prefixes'];
$replaces = array_unique(array_merge($defaultReplaces, $remoteReplaces));
foreach ($replaces as $replace) {
$fileContent = preg_replace('/' . $replace['source'] . '/sU', $replace['target'], $fileContent);
}
// group="seo" is of no use for us, so leave it behind
$written = JFile::write($path, $fileContent);
}
// fix in memory object, by killing it, thus prompting recreation
$manifest =& $this->parent->getManifest();
$manifest = null;
$manifest =& $this->parent->getManifest();
$this->manifest =& $manifest->document;
}
示例6: getItem
function getItem()
{
global $mainframe;
jimport('joomla.filesystem.path');
if (!$this->template) {
return JError::raiseWarning(500, 'Template not specified');
}
$tBaseDir = JPath::clean(JPATH_RSGALLERY2_SITE . '/templates');
if (!is_dir($tBaseDir . '/' . $this->template)) {
return JError::raiseWarning(500, 'Template not found');
}
$lang =& JFactory::getLanguage();
$lang->load('tpl_' . $this->template, JPATH_RSGALLERY2_SITE);
$ini = JPATH_RSGALLERY2_SITE . '/templates/' . $this->template . '/params.ini';
$xml = JPATH_RSGALLERY2_SITE . '/templates/' . $this->template . '/templateDetails.xml';
$row = TemplatesHelper::parseXMLTemplateFile($tBaseDir, $this->template);
jimport('joomla.filesystem.file');
// Read the ini file
if (JFile::exists($ini)) {
$content = JFile::read($ini);
} else {
$content = null;
}
$params = new JParameter($content, $xml, 'template');
// Set FTP credentials, if given
jimport('joomla.client.helper');
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$item = new stdClass();
$item->params = $params;
$item->row = $row;
$item->type = $this->_type;
$item->template = $this->template;
return $item;
}
示例7: __construct
function __construct($options = array())
{
static $expiredCacheCleaned;
$this->profile_db = JFactory::getDBO();
$this->db = clone $this->profile_db;
$this->_language = isset($options['language']) ? $options['language'] : 'en-GB';
$this->_lifetime = isset($options['lifetime']) ? $options['lifetime'] : 60;
$this->_now = isset($options['now']) ? $options['now'] : time();
$config = JFactory::getConfig();
$this->_hash = $config->get('config.secret');
// if its not the first instance of the joomfish db cache then check if it should be cleaned and otherwise garbage collect
if (!isset($expiredCacheCleaned)) {
// check a file in the 'file' cache to check if we should remove all our db cache entries since cache manage doesn't handle anything other than file caches
$conf = JFactory::getConfig();
$cachebase = $conf->get('cache_path', JPATH_ROOT . DS . 'cache');
$cachepath = $cachebase . DS . "falang-cache";
if (!JFolder::exists($cachepath)) {
JFolder::create($cachepath);
}
$cachefile = $cachepath . DS . "cachetest.txt";
jimport("joomla.filesystem.file");
if (!JFile::exists($cachefile) || JFile::read($cachefile) != "valid") {
// clean out the whole cache
$this->cleanCache();
//sbou TODO uncomment write and solve problem
JFile::write($cachefile, "valid");
}
$this->gc();
}
$expiredCacheCleaned = true;
}
示例8: disableInfoMode
/**
*
* Disable JT3 infomode
*
* @return: Save setting to file params.ini
*/
public function disableInfoMode()
{
JSNFactory::localimport('libraries.joomlashine.database');
$template = JSNDatabase::getDefaultTemplate();
$client = JApplicationHelper::getClientInfo($template->client_id);
$file = $client->path . '/templates/' . $template->element . '/params.ini';
$data = JFile::read($file);
$data = explode("\n", $data);
$params = array();
$needChange = false;
foreach ($data as $val) {
$spos = strpos($val, "=");
$key = substr($val, 0, $spos);
$value = substr($val, $spos + 1, strlen($val) - $spos);
if ($key == 'infomode') {
if ($value == '"1"') {
$value = '"0"';
$needChange = true;
}
}
$params[$key] = $value;
}
if ($needChange) {
$data = array();
foreach ($params as $key => $val) {
$data[] = $key . '=' . $val;
}
$data = implode("\n", $data);
if (JFile::exists($file)) {
@chmod($file, 0777);
}
JFile::write($file, $data);
}
}
示例9: doExecute
/**
* Entry point for CLI script
*
* @return void
*
* @since 3.0
*/
public function doExecute()
{
ini_set("max_execution_time", 300);
jimport('joomla.filesystem.archive');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$config = JFactory::getConfig();
$username = $config->get('user');
$password = $config->get('password');
$database = $config->get('db');
echo 'Exporting database...
';
exec("mysqldump --user={$username} --password={$password} --quick --add-drop-table --add-locks --extended-insert --lock-tables --all {$database} > " . JPATH_SITE . "/database-backup.sql");
$zipFilesArray = array();
$dirs = JFolder::folders(JPATH_SITE, '.', true, true);
array_push($dirs, JPATH_SITE);
echo 'Collecting files...
';
foreach ($dirs as $dir) {
$files = JFolder::files($dir, '.', false, true);
foreach ($files as $file) {
$data = JFile::read($file);
$zipFilesArray[] = array('name' => str_replace(JPATH_SITE . '/', '', $file), 'data' => $data);
}
}
$zip = JArchive::getAdapter('zip');
echo 'Creating zip...
';
$archive = JPATH_SITE . '/backups/' . date('Ymd') . '-backup.zip';
$zip->create($archive, $zipFilesArray);
echo 'Backup created ' . $archive . '
';
}
示例10: getOptions
protected function getOptions()
{
$options = array();
if (defined('JMF_TPL_PATH')) {
$path = JMF_TPL_PATH . DIRECTORY_SEPARATOR . 'tpl';
$files = JFolder::files($path, '.php');
if (is_array($files)) {
$app = JFactory::getApplication();
$styleid = $app->input->get('id', null, 'int');
$file = JPath::clean(JMF_TPL_PATH . '/assets/style/assigns-' . $styleid . '.json');
if (!is_dir(dirname($file))) {
JFolder::create(dirname($file));
}
$assigns = new JRegistry();
// get current layout assigns settings
if (JFile::exists($file)) {
$assigns->loadString(JFile::read($file));
} else {
$assigns->set(0, !empty($this->value) ? $this->value : 'default');
$data = $assigns->toString();
if (!@JFile::write($file, $data)) {
$app->enqueueMessage(JText::sprintf('PLG_SYSTEM_JMFRAMEWORK_CAN_NOT_WRITE_TO_FILE', $file), 'error');
}
}
$arr_assigns = $assigns->toArray();
foreach ($files as $file) {
$name = JFile::stripExt($file);
$options[] = JHtml::_('select.option', $name, $name . ($name == $arr_assigns[0] ? ' [DEFAULT]' : ''));
}
}
}
return $options;
}
示例11: compile
/**
* Main compiler code that compiles javascript files.
*
* @since 1.0
* @access public
* @param bool Determines if the compiler should also minify the javascript codes
* @return
*/
public function compile($section = 'site', $minify = false)
{
$compiler = $this->getCompiler();
// Create a master manifest containing all the scripts
$manifest = new stdClass();
$manifest->adapter = 'EasyBlog';
$manifest->script = array();
// Get a list of all the js files in the "scripts" folder
jimport('joomla.filesystem.folder');
// Read the dependencies file
$dependenciesFile = EASYBLOG_SCRIPTS . '/dependencies.json';
$contents = JFile::read($dependenciesFile);
$dependencies = json_decode($contents);
// Nothing to compile so skip this altogether.
if (!isset($dependencies->{$section})) {
return;
}
// Set compiler options
$options = array("static" => EASYBLOG_SCRIPTS . '/' . $section . '-' . $this->version . '.static', "optimized" => EASYBLOG_SCRIPTS . '/' . $section . '-' . $this->version . '.optimized', "minify" => $minify);
$compiler->exclude = self::$exclusion;
// Include everything in composer to speed up load time.
// Doesn't matter if the static composer script is large.
if ($section == 'composer') {
$compiler->exclude = array();
}
// Compiler scripts
return $compiler->compile($dependencies->{$section}, $options);
}
示例12: display
/**
* Raw view display method, outputs one image
*
* @param string $tpl The name of the template file to parse
* @return void
* @since 1.5.5
*/
public function display($tpl = null)
{
jimport('joomla.filesystem.file');
$type = JRequest::getWord('type', 'thumb');
$image = $this->get('Data');
$img = $this->_ambit->getImg($type . '_path', $image);
if (!JFile::exists($img)) {
$this->_mainframe->redirect(JRoute::_('index.php', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_IMAGE_NOT_EXIST'), 'error');
}
$info = getimagesize($img);
switch ($info[2]) {
case 1:
$mime = 'image/gif';
break;
case 2:
$mime = 'image/jpeg';
break;
case 3:
$mime = 'image/png';
break;
default:
JError::raiseError(404, JText::sprintf('COM_JOOMGALLERY_COMMON_MSG_MIME_NOT_ALLOWED', $info[2]));
break;
}
// Set mime encoding
$this->_doc->setMimeEncoding($mime);
// Set header to specify the file name
$disposition = 'inline';
JResponse::setHeader('Content-disposition', $disposition . '; filename=' . basename($img));
echo JFile::read($img);
}
示例13: isThereLibrary
/**
* @brief Valida si se debe instalar o no la librerai, esto sucede siempre y cuando
* no encuentre libreria o la version sea menor a la que ya existe.
* @return bool
*/
function isThereLibrary()
{
if (JFolder::exists(JPATH_SITE . DS . 'libraries' . DS . 'Amadeus')) {
if (JFile::exists(JPATH_SITE . DS . 'libraries' . DS . 'Amadeus' . DS . 'Amadeus.php')) {
require_once JPATH_SITE . DS . 'libraries' . DS . 'Amadeus' . DS . 'Amadeus.php';
$version = Amadeus::getVersion();
$mylib = JFile::read(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rotator' . DS . 'library' . DS . 'Amadeus' . DS . 'Amadeus.php');
preg_match('/[\'"](\\d+\\.\\d+\\.\\d+)[\'"]/', $mylib, $myversion);
global $_version;
$_version = '<h4>Requerimientos de Libreria:</h4>';
$_version .= "<span style='padding: 0 7px;'></span>Versión Actual : <b>" . $version . "</b><br />";
$_version .= "<span style='padding: 0 7px;'></span>Versión Requerida : <b>" . $myversion[1] . "</b>";
$myversion = explode('.', $myversion[1]);
$version = explode('.', $version);
if ($myversion[0] > $version[0]) {
return true;
} elseif ($myversion[0] == $version[0] && $myversion[1] > $version[1]) {
return true;
} elseif ($myversion[0] == $version[0] && $myversion[1] == $version[1] && $myversion[2] > $version[2]) {
return true;
}
return false;
}
return true;
}
return true;
}
示例14: _renderStatus
public function _renderStatus()
{
$date = JFactory::getDate();
$jparam = new JConfig();
if (!JFile::exists(JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'community.xml')) {
return false;
}
if (JFile::exists($jparam->tmp_path . DS . 'jomsocialupdate.ini')) {
$lastcheckdate = JFile::read($jparam->tmp_path . DS . 'jomsocialupdate.ini');
} else {
$lastcheckdate = $date->toFormat();
}
JFile::write($jparam->tmp_path . DS . 'jomsocialupdate.ini', $lastcheckdate);
$dayInterval = 1;
// days
$currentdate = $date->toFormat();
$checkVersion = strtotime($currentdate) > strtotime($lastcheckdate) + $dayInterval * 60 * 60 * 24;
// Load language
$lang = JFactory::getLanguage();
$lang->load('com_community', JPATH_ROOT . DS . 'administrator');
$button = $this->_getButton($checkVersion);
$html = JResponse::getBody();
$html = str_replace('<div id="module-status">', '<div id="module-status">' . $button, $html);
// Load AJAX library for the back end.
$jax = new JAX(rtrim(JURI::root(), '/') . '/plugins/system/pc_includes');
$jax->setReqURI(rtrim(JURI::root(), '/') . '/administrator/index.php');
$jaxScript = $jax->getScript();
JResponse::setBody($html . $jaxScript);
}
示例15: getInput
public function getInput()
{
$this->_templates = JPATH_ROOT . DS . 'modules' . DS . 'mod_rokfeaturetable' . DS . 'templates';
$this->_jtemplate = $this->_getCurrentTemplatePath();
$output = "";
jimport('joomla.filesystem.file');
if (JFolder::exists($this->_templates)) {
$files = JFolder::files($this->_templates, "\\.txt", true, true);
if (JFolder::exists($this->_jtemplate)) {
$jfiles = JFolder::files($this->_jtemplate, "\\.txt", true, true);
if (count($jfiles)) {
$this->merge($files, $jfiles);
}
}
if (count($files)) {
$output = "<select id='templates'>\n";
$output .= "<option value='_select_' class='disabled' selected='selected'>Select a Template</option>";
foreach ($files as $file) {
$title = JFile::stripExt(JFile::getName($file));
$title = str_replace("-", " ", str_replace("_", " ", $title));
$title = ucwords($title);
$output .= "<option value='" . JFile::read($file) . "'>" . $title . "</option>";
}
$output .= "</select>\n";
$output .= "<span id='import-button' class='action-import'><span>import</span></span>\n";
}
} else {
$output = "Templates folder was not found.";
}
return $output;
}