本文整理汇总了PHP中CFile::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::getContent方法的具体用法?PHP CFile::getContent怎么用?PHP CFile::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::getContent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIncludedFileContents
function getIncludedFileContents($short_fname)
{
$file = new CFile(dirname(__FILE__) . '/includes/' . $short_fname);
return $file->getContent();
}
示例2: while
/**
* Function for extracting images from
* html source. This function will look
* through the html code supplied by add_html()
* and find any file that ends in one of the
* extensions defined in $obj->image_types.
* If the file exists it will read it in and
* embed it, (not an attachment).
*
* @author Dan Allen
*/
function _findHtmlImages($images_dir)
{
// Build the list of image extensions
while (list($key, ) = each($this->image_types)) {
$extensions[] = $key;
}
preg_match_all('/(?:"|\')([^"\']+\\.(' . implode('|', $extensions) . '))(?:"|\')/Ui', $this->html, $images);
for ($i = 0; $i < count($images[1]); $i++) {
if (file_exists($images_dir . $images[1][$i])) {
$html_images[] = $images[1][$i];
$this->html = str_replace($images[1][$i], basename($images[1][$i]), $this->html);
}
}
if (!empty($html_images)) {
// If duplicate images are embedded, they may show up as attachments, so remove them.
$html_images = array_unique($html_images);
sort($html_images);
for ($i = 0; $i < count($html_images); $i++) {
$file = new CFile($images_dir . $html_images[$i]);
if ($image = $file->getContent()) {
$ext = _ml_substr($html_images[$i], _ml_strrpos($html_images[$i], '.') + 1);
$content_type = $this->image_types[_ml_strtolower($ext)];
$this->addHtmlImage($image, basename($html_images[$i]), $content_type);
}
}
}
}
示例3: fill
/**
* Reads given template file contents.
* It prepares it for filling.
* It fills it with template variables values provided.
* It does special HTML formatting if needed, e.g. draw red debug template frames.
*
*
* @param string $folder_name Template file path: full folder path.
* @param string $tmpl_short_filename Template file path: file name.
* @param arrat $vars Template variables values.
* @return string template html contents with tags replaced with their values.
*/
function fill($folder_name, $tmpl_short_filename, $vars, $customer_zone = false)
{
//Open file, read contents, replace tags.
$this->PreviousTemplateFilename = $this->CurrentTemplateFilename;
if ($customer_zone) {
$this->CurrentTemplateFilename = getTemplateFileAbsolutePath($this->TemplateDirPrefix . $folder_name . $tmpl_short_filename);
} else {
$this->CurrentTemplateFilename = $this->TemplateDirPrefix . $folder_name . "views/admin/templates/" . $tmpl_short_filename;
if (!is_file($this->CurrentTemplateFilename)) {
$this->CurrentTemplateFilename = $this->TemplateDirPrefix . $folder_name . $tmpl_short_filename;
}
if (!is_file($this->CurrentTemplateFilename)) {
$this->CurrentTemplateFilename = modApiFunc('application', 'getAppIni', 'PATH_ADMIN_TPLS_VIEWS') . $folder_name . $tmpl_short_filename;
}
}
$code_to_include = $this->getCachedCode($this->CurrentTemplateFilename);
if ($code_to_include === null) {
$tpl_file = new CFile($this->CurrentTemplateFilename);
$code_to_include = $tpl_file->getContent();
// , ( > 128)
$code_to_include = convertTemplate($code_to_include);
if ($code_to_include === FALSE) {
CTrace::backtrace();
_fatal("TMPL_FILLER_ERROR_CANNOT_READ_FILE", $this->CurrentTemplateFilename);
}
$code_to_include = '?>' . $this->removeTemplateWrapper($code_to_include);
$this->saveInCache($this->CurrentTemplateFilename, $code_to_include);
}
$text = $this->includeTmplCode($code_to_include);
$_vars = array();
foreach ($vars as $key => $value) {
$_vars['{' . $key . '}'] = $value;
}
$text = strtr($text, $_vars);
$text = $this->addCrossSiteProtectinField($text);
return $text;
}
示例4: prepareTemplateToFill
function prepareTemplateToFill($tmpl_file)
{
$cache_result = $this->prepared_template_cache->read($tmpl_file);
if ($cache_result !== null) {
return $cache_result;
} else {
//Open file, read contents, replace tags.
$this->CurrentTemplateFilename = $tmpl_file;
$tpl_file = new CFile($this->CurrentTemplateFilename);
$text = $tpl_file->getContent();
if ($text === FALSE) {
CTrace::backtrace();
_fatal("TMPL_FILLER_ERROR_CANNOT_READ_FILE", $this->CurrentTemplateFilename);
}
$text = $this->removeTemplateWrapper($text);
// find and modify all the image references.
// for customer zone only
$zone = modApiFunc('Users', 'getZone');
if ($zone == 'CustomerZone') {
$text = $this->replaceImages($text);
}
$this->prepared_template_cache->write($tmpl_file, $text);
return $text;
}
}
示例5: outputPageByMap
function outputPageByMap($page)
{
global $__TPL_DIR__, $__TPL_URL__, $application;
$page = basename($page);
$map_file = modApiFunc('Layout_CMS', 'getThemePath') . 'map.ini';
$use_cached = false;
if (file_exists($map_file)) {
$ini_cache = $application->getIniCache();
$map_mtime = filemtime($map_file);
if ($map_mtime == $ini_cache->read($map_file . '-mtime')) {
$map = $ini_cache->read($map_file);
$use_cached = true;
} else {
CProfiler::ioStart($map_file, 'parse');
$map = parse_ini_file($map_file, true);
CProfiler::ioStop();
$ini_cache->write($map_file . '-mtime', $map_mtime);
$ini_cache->write($map_file, $map);
}
} else {
$map = modApiFunc('Layout_CMS', 'generateMap', $page);
}
if (isset($map['default'])) {
$map_default = $map['default'];
}
if (isset($map[$page])) {
$map = array_merge($map_default, $map[$page]);
} else {
_fatal("The page [{$page}] not found in the map file [{$map_file}]");
}
$template_path = getTemplateFileAbsolutePath('pages/templates/' . $map['template']);
$tpl_cache = $application->getTplCache();
$template_mtime = filemtime($template_path);
if ($template_mtime == $tpl_cache->read($template_path . '-mtime')) {
$template_content = $tpl_cache->read($template_path);
} else {
$template_file = new CFile($template_path);
$template_content = $template_file->getContent();
$tpl_cache->write($template_path . '-mtime', $template_mtime);
$tpl_cache->write($template_path, $template_content);
$use_cached = false;
}
if ($use_cached) {
$contents = $tpl_cache->read($template_path . '-' . $page);
}
if (!isset($contents)) {
$replace = array();
foreach ($map as $k => $v) {
$replace['#' . $k . '#'] = $v;
$replace['[' . $k . ']'] = htmlentities($v, ENT_QUOTES);
}
$contents = '?>' . strtr($template_content, $replace);
$tpl_cache->write($template_path . '-' . $page, $contents);
}
ob_start();
eval($contents);
$contents = ob_get_contents();
ob_end_clean();
$contents = str_replace('<br>', '<br/>', $contents);
return $contents;
}
示例6: settype
function _prepare_post_body($formvars, $formfiles)
{
settype($formvars, "array");
settype($formfiles, "array");
$postdata = '';
if (count($formvars) == 0 && count($formfiles) == 0) {
return;
}
switch ($this->_submit_type) {
case "application/x-www-form-urlencoded":
reset($formvars);
while (list($key, $val) = each($formvars)) {
if (is_array($val) || is_object($val)) {
while (list($cur_key, $cur_val) = each($val)) {
$postdata .= urlencode($key) . "[]=" . urlencode($cur_val) . "&";
}
} else {
$postdata .= urlencode($key) . "=" . urlencode($val) . "&";
}
}
break;
case "multipart/form-data":
$this->_mime_boundary = "Snoopy" . md5(uniqid(microtime()));
reset($formvars);
while (list($key, $val) = each($formvars)) {
if (is_array($val) || is_object($val)) {
while (list($cur_key, $cur_val) = each($val)) {
$postdata .= "--" . $this->_mime_boundary . "\r\n";
$postdata .= "Content-Disposition: form-data; name=\"{$key}\\[\\]\"\r\n\r\n";
$postdata .= "{$cur_val}\r\n";
}
} else {
$postdata .= "--" . $this->_mime_boundary . "\r\n";
$postdata .= "Content-Disposition: form-data; name=\"{$key}\"\r\n\r\n";
$postdata .= "{$val}\r\n";
}
}
reset($formfiles);
while (list($field_name, $file_names) = each($formfiles)) {
settype($file_names, "array");
while (list(, $file_name) = each($file_names)) {
$file = new CFile($file_name);
$file_content = $file->getContent();
if (!$file_content) {
continue;
}
$base_name = basename($file_name);
$postdata .= "--" . $this->_mime_boundary . "\r\n";
$postdata .= "Content-Disposition: form-data; name=\"{$field_name}\"; filename=\"{$base_name}\"\r\n\r\n";
$postdata .= "{$file_content}\r\n";
}
}
$postdata .= "--" . $this->_mime_boundary . "--\r\n";
break;
}
return $postdata;
}