protected function _saveDefaultImage($deleteIcon = false) { $image_filepath = 'files/attach/xeicon/'; $site_info = Context::get('site_module_info'); if ($site_info->site_srl) { $image_filepath .= $site_info->site_srl . '/'; } if ($deleteIcon) { $info = Rhymix\Framework\Storage::readPHPData($image_filepath . 'default_image.php'); if ($info['filename']) { Rhymix\Framework\Storage::delete(\RX_BASEDIR . $info['filename']); } Rhymix\Framework\Storage::delete($image_filepath . 'default_image.php'); return; } $tmpicon_filepath = \RX_BASEDIR . $image_filepath . 'tmp/default_image.png'; if (file_exists($tmpicon_filepath)) { list($width, $height, $type) = @getimagesize($tmpicon_filepath); switch ($type) { case 'image/gif': $target_filename = $image_filepath . 'default_image.gif'; break; case 'image/jpeg': $target_filename = $image_filepath . 'default_image.jpg'; break; case 'image/png': default: $target_filename = $image_filepath . 'default_image.png'; } Rhymix\Framework\Storage::move($tmpicon_filepath, \RX_BASEDIR . $target_filename); Rhymix\Framework\Storage::writePHPData(\RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . 'default_image.php', array('filename' => $target_filename, 'width' => $width, 'height' => $height)); } }
/** * compiles specified tpl file and execution result in Context into resultant content * @param string $tpl_path path of the directory containing target template file * @param string $tpl_filename target template file's name * @param string $tpl_file if specified use it as template file's full path * @return string Returns compiled result in case of success, NULL otherwise */ public function compile($tpl_path, $tpl_filename, $tpl_file = '') { // store the starting time for debug information $start = microtime(true); // initiation $this->init($tpl_path, $tpl_filename, $tpl_file); // if target file does not exist exit if (!$this->file || !file_exists($this->file)) { $error_message = "Template not found: {$tpl_path}{$tpl_filename}" . ($tpl_file ? " ({$tpl_file})" : ''); trigger_error($error_message, \E_USER_WARNING); return escape($error_message); } // for backward compatibility if (is_null(self::$rootTpl)) { self::$rootTpl = $this->file; } $latest_mtime = max(filemtime($this->file), $this->handler_mtime); // make compiled file if (!file_exists($this->compiled_file) || filemtime($this->compiled_file) < $latest_mtime) { $buff = $this->parse(); if (Rhymix\Framework\Storage::write($this->compiled_file, $buff) === false) { $tmpfilename = tempnam(sys_get_temp_dir(), 'rx-compiled'); if ($tmpfilename === false || Rhymix\Framework\Storage::write($tmpfilename, $buff) === false) { return 'Fatal Error : Cannot create temporary file. Please check permissions.'; } $this->compiled_file = $tmpfilename; } } Rhymix\Framework\Debug::addFilenameAlias($this->file, $this->compiled_file); $output = $this->_fetch($this->compiled_file); // delete tmpfile if (isset($tmpfilename)) { Rhymix\Framework\Storage::delete($tmpfilename); } if ($__templatehandler_root_tpl == $this->file) { $__templatehandler_root_tpl = null; } // store the ending time for debug information $GLOBALS['__template_elapsed__'] += microtime(true) - $start; return $output; }
/** * Remove a file * * @param string $filename path of target file * @return bool Returns TRUE on success or FALSE on failure. */ public static function removeFile($filename) { return Rhymix\Framework\Storage::delete(self::getRealPath($filename)); }