本文整理汇总了PHP中PerchUtil::file_path方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::file_path方法的具体用法?PHP PerchUtil::file_path怎么用?PHP PerchUtil::file_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchUtil
的用法示例。
在下文中一共展示了PerchUtil::file_path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_inputs
public function render_inputs($details = array())
{
if (!class_exists('PerchGallery_Albums')) {
require_once PerchUtil::file_path(PERCH_PATH . '/addons/apps/perch_gallery/PerchGallery_Albums.class.php');
require_once PerchUtil::file_path(PERCH_PATH . '/addons/apps/perch_gallery/PerchGallery_Album.class.php');
}
$id = $this->Tag->input_id();
$val = '';
if (isset($details[$id]) && $details[$id] != '') {
$json = $details[$id];
$val = $json['albumSlug'];
}
$API = new PerchAPI(1, 'perch_gallery');
$Albums = new PerchGallery_Albums($API);
$albums = $Albums->return_all();
$opts = array();
$opts[] = array('label' => '', 'value' => '');
if (PerchUtil::count($albums)) {
foreach ($albums as $Album) {
$opts[] = array('label' => $Album->albumTitle(), 'value' => $Album->albumSlug());
}
}
if (PerchUtil::count($opts)) {
$s = $this->Form->select($id, $opts, $val);
} else {
$s = '-';
}
return $s;
}
示例2: write_file
public function write_file($file, $name)
{
$filename = PerchUtil::tidy_file_name($name);
if (strpos($filename, '.php') !== false) {
$filename .= '.txt';
}
// diffuse PHP files
if (strpos($filename, '.phtml') !== false) {
$filename .= '.txt';
}
// diffuse PHP files
$target = PerchUtil::file_path($this->file_path . '/' . $filename);
if (file_exists($target)) {
$dot = strrpos($filename, '.');
$filename_a = substr($filename, 0, $dot);
$filename_b = substr($filename, $dot);
$count = 1;
while (file_exists(PerchUtil::file_path($this->file_path . '/' . PerchUtil::tidy_file_name($filename_a . '-' . $count . $filename_b)))) {
$count++;
}
$filename = PerchUtil::tidy_file_name($filename_a . '-' . $count . $filename_b);
$target = PerchUtil::file_path($this->file_path . '/' . $filename);
}
PerchUtil::move_uploaded_file($file, $target);
return array('name' => $filename, 'path' => $target);
}
示例3: set
public function set($file, $namespace, $default_fields = false)
{
$Perch = Perch::fetch();
// called to make sure constants are defined.
if ($file && substr($file, -5) !== '.html') {
$file .= '.html';
}
$this->namespace = $namespace;
if (strpos($file, '~') !== false) {
$local_file = PerchUtil::file_path(PERCH_PATH . '/addons/apps/' . substr($file, strpos($file, '~') + 1));
$user_file = PerchUtil::file_path(PERCH_TEMPLATE_PATH . substr($file, strpos($file, 'templates') + 9));
} else {
$local_file = PerchUtil::file_path(PERCH_PATH . '/addons/apps/' . $this->app_id . '/templates/' . $file);
$user_file = PerchUtil::file_path(PERCH_TEMPLATE_PATH . '/' . $file);
}
if (file_exists($user_file)) {
$template_file = $user_file;
} else {
$template_file = $local_file;
}
$this->Template = new PerchTemplate($template_file, $namespace, $relative_path = false);
$this->Template->enable_encoding();
$this->Template->apply_post_processing = true;
if ($default_fields) {
$this->Template->append($default_fields);
}
$this->file = $this->Template->file;
return $this->Template->status;
}
示例4: _compile_stylesheet
private function _compile_stylesheet($file)
{
PerchUtil::debug('Compiling SASS file: ' . $file, 'notice');
if (!$this->_site_path) {
$login_path_parts = explode('/', PERCH_LOGINPATH);
$path_parts = explode(DIRECTORY_SEPARATOR, PERCH_PATH);
foreach ($login_path_parts as $part) {
if ($part != '') {
array_pop($path_parts);
}
}
$path = implode(DIRECTORY_SEPARATOR, $path_parts);
$this->_site_path = $path;
}
$compiled_name = PerchUtil::file_path(PERCH_RESFILEPATH . '/' . $this->_get_compiled_name($file));
include_once 'SassParser.php';
$syntax = substr($file, -4, 4);
$options = array('style' => 'expanded', 'cache' => FALSE, 'syntax' => $syntax, 'debug' => FALSE, 'callbacks' => array('warn' => 'warn', 'debug' => 'debug'));
// Execute the compiler.
$parser = new SassParser($options);
try {
file_put_contents($compiled_name, $parser->toCss(PerchUtil::file_path($this->_site_path . $file)));
} catch (Exception $e) {
PerchUtil::debug($e->getMessage(), 'error');
}
}
示例5: __construct
function __construct($file = false, $namespace = 'content', $relative_path = true)
{
$Perch = Perch::fetch();
// required to define constants
if ($file && substr($file, -5) !== '.html') {
$file .= '.html';
}
$this->current_file = $file;
$this->namespace = $namespace;
if ($file && $relative_path) {
$file = PerchUtil::file_path(PERCH_TEMPLATE_PATH . '/' . $file);
}
if ($file != false && file_exists($file)) {
$this->file = $file;
$this->template = $file;
PerchUtil::debug('Using template: ' . str_replace(PERCH_PATH, '', $file), 'template');
$this->status = 200;
$this->file_path = pathinfo($file, PATHINFO_DIRNAME);
} else {
if ($file != false) {
PerchUtil::debug('Template file not found: ' . $file, 'template-error');
}
$this->status = 404;
}
// Mock up fallback functions if server doesn't have mbstring
$this->mb_fallback();
}
示例6: set_template
public function set_template($template)
{
$this->template = $template;
$type = PerchUtil::file_extension($template);
if (!$type) {
$type = 'txt';
$template .= '.txt';
$this->html = false;
} else {
if ($type == 'html') {
$this->html = true;
}
}
if (isset($this->app_id)) {
$local_file = PerchUtil::file_path(PERCH_PATH . '/addons/apps/' . $this->app_id . '/templates/' . $template);
} else {
$local_file = false;
}
$user_file = PerchUtil::file_path(PERCH_TEMPLATE_PATH . '/' . $template);
$core_file = PerchUtil::file_path(PERCH_CORE . '/emails/' . $template);
if (file_exists($user_file)) {
$this->template_path = $user_file;
} elseif (file_exists($local_file)) {
$this->template_path = $local_file;
} else {
$this->template_path = $core_file;
}
PerchUtil::debug('Using email template: ' . $this->template_path . ' (' . $type . ')', 'template');
}
示例7: icons
/**
* Return a list of icon files as an array
*
* @return array
*/
public function icons()
{
$return = array();
foreach ($this->iconMap as $event => $filename) {
$return[$event] = PerchUtil::file_path($this->api->app_path() . '/' . $this->icon_dir . '/' . $filename . $this->icon_ext);
}
return $return;
}
示例8: delete
/**
* Delete the template, along with its file
* @return nothing
*/
public function delete()
{
$file = PerchUtil::file_path(PERCH_TEMPLATE_PATH . '/pages/' . $this->templatePath());
if (!PERCH_RUNWAY && file_exists($file)) {
unlink($file);
}
parent::delete();
}
示例9: expire_all
public static function expire_all()
{
$files = glob(PerchUtil::file_path(PERCH_RESFILEPATH . '/perch_blog.*.cache'));
if (PerchUtil::count($files)) {
foreach ($files as $filename) {
unlink($filename);
}
}
}
示例10: load_bucket_list
public static function load_bucket_list()
{
$bucket_list_file = PerchUtil::file_path(PERCH_PATH . '/config/buckets.php');
if (file_exists($bucket_list_file)) {
self::$bucket_list = (include $bucket_list_file);
if (self::$bucket_list == false) {
self::$bucket_list = array();
}
} else {
self::$bucket_list = array();
}
}
示例11: delete
public function delete()
{
if ($this->clean_resources && !$this->resourceInLibrary()) {
$Perch = Perch::fetch();
$bucket = $Perch->get_resource_bucket($this->resourceBucket());
$file_path = PerchUtil::file_path($bucket['file_path'] . '/' . $this->resourceFile());
if (file_exists($file_path) && !is_dir($file_path)) {
unlink($file_path);
PerchUtil::debug('Deleting resource: ' . $file_path);
}
}
return parent::delete();
}
示例12: attempt_install
public function attempt_install()
{
PerchUtil::debug('Attempting app installation: ' . $this->api->app_id);
$sql = 'SHOW TABLES LIKE "' . $this->table . '"';
$result = $this->db->get_value($sql);
if ($result == false) {
$activation_file = PerchUtil::file_path(PERCH_PATH . '/addons/apps/' . $this->api->app_id . '/activate.php');
if (file_exists($activation_file)) {
$API = $this->api;
return include $activation_file;
}
}
return false;
}
示例13: set_template
public function set_template($template, $namespace = 'email')
{
$this->template = $template;
$this->template_ns = $namespace;
$type = PerchUtil::file_extension($template);
if (!$type) {
$type = 'txt';
$template .= '.txt';
$this->html = false;
} else {
if ($type == 'html') {
$this->html = true;
}
}
if (isset($this->app_id)) {
$local_file = PerchUtil::file_path(PERCH_PATH . '/addons/apps/' . $this->app_id . '/templates/' . $template);
} else {
$local_file = false;
}
$user_file = PerchUtil::file_path(PERCH_TEMPLATE_PATH . '/' . $template);
$core_file = PerchUtil::file_path(PERCH_CORE . '/emails/' . $template);
if (file_exists($user_file)) {
$this->template_path = $user_file;
} elseif (file_exists($local_file)) {
$this->template_path = $local_file;
} else {
$this->template_path = $core_file;
}
PerchUtil::debug('Using email template: ' . $this->template_path . ' (' . $type . ')', 'template');
// detect type
if (file_exists($this->template_path)) {
$template_contents = file_get_contents($this->template_path);
} else {
$template_contents = '';
}
if (strpos($template_contents, '<perch:') !== false) {
$this->template_method('perch');
} else {
$this->template_method('dollar');
}
}
示例14: get_available_buckets
public function get_available_buckets()
{
$sql = 'SELECT DISTINCT resourceBucket FROM ' . $this->table . '
WHERE resourceAWOL=0 AND resourceType !="" ORDER BY resourceType ASC';
$list = $this->db->get_rows_flat($sql);
if (!$list) {
$list = array();
}
$bucket_list_file = PerchUtil::file_path(PERCH_PATH . '/config/buckets.php');
if (file_exists($bucket_list_file)) {
$bucket_list = (include $bucket_list_file);
if (PerchUtil::count($bucket_list)) {
foreach ($bucket_list as $key => $val) {
if (!in_array($key, $list)) {
$list[] = $key;
}
}
}
}
return $list;
}
示例15: load_translation_files
/**
* Load files from translation directory and converts to dot notation
*
* @return Data
*/
private function load_translation_files()
{
$base_path = PerchUtil::file_path(PERCH_PATH . '/' . $this->translation_dir);
$dir_iterator = new RecursiveDirectoryIterator($base_path, FilesystemIterator::SKIP_DOTS);
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::CHILD_FIRST);
$files = array();
foreach ($iterator as $fileinfo) {
if ($fileinfo->getExtension() == 'php') {
$file_path = PerchUtil::file_path($fileinfo->getPathname());
if ($fileinfo->isDir()) {
$path = array($fileinfo->getFilename() => array());
} else {
$path = array(PerchUtil::strip_file_extension($fileinfo->getFilename()) => $this->load_translation_data($file_path));
}
for ($depth = $iterator->getDepth() - 1; $depth >= 0; $depth--) {
$path = array($iterator->getSubIterator($depth)->current()->getFilename() => $path);
}
$files = array_merge_recursive($files, $path);
}
}
return new Data($files);
}