本文整理汇总了PHP中PerchUtil::strip_file_extension方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::strip_file_extension方法的具体用法?PHP PerchUtil::strip_file_extension怎么用?PHP PerchUtil::strip_file_extension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchUtil
的用法示例。
在下文中一共展示了PerchUtil::strip_file_extension方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: log
public function log($app = 'content', $bucket = 'default', $file, $parentID = 0, $resource_key = '', $library_resource = false, $details = false, $AssetMeta = false)
{
if (isset($details['assetID'])) {
$newID = $details['assetID'];
} else {
$data = array('resourceApp' => $app, 'resourceBucket' => $bucket, 'resourceFile' => $file, 'resourceKey' => $resource_key, 'resourceParentID' => $parentID, 'resourceType' => $this->_get_type($file), 'resourceCreated' => date('Y-m-d H:i:s'), 'resourceInLibrary' => $library_resource ? '1' : '0');
if (PerchUtil::count($details)) {
foreach ($details as $key => $val) {
switch ($key) {
case 'w':
$data['resourceWidth'] = $val;
break;
case 'h':
$data['resourceHeight'] = $val;
break;
case 'target_w':
$data['resourceTargetWidth'] = $val;
break;
case 'target_h':
$data['resourceTargetHeight'] = $val;
break;
case 'crop':
$data['resourceCrop'] = $val ? '1' : '0';
break;
case 'density':
$data['resourceDensity'] = $val;
break;
case 'size':
$data['resourceFileSize'] = $val;
break;
case 'mime':
$data['resourceMimeType'] = $val;
break;
case 'title':
$data['resourceTitle'] = $val;
break;
}
}
}
if (!isset($data['resourceTitle'])) {
if ($AssetMeta) {
$data['resourceTitle'] = $AssetMeta->get_title();
} else {
$data['resourceTitle'] = PerchUtil::filename(PerchUtil::strip_file_extension($data['resourceFile']), false);
}
}
$newID = $this->db->insert($this->table, $data, true);
if ($newID == '0') {
$sql = 'SELECT resourceID FROM ' . $this->table . ' WHERE resourceBucket=' . $this->db->pdb($bucket) . ' AND resourceFile=' . $this->db->pdb($file) . ' LIMIT 1';
$newID = $this->db->get_value($sql);
}
// Tags
if ($AssetMeta) {
$tags = $AssetMeta->get_tags();
if (PerchUtil::count($tags)) {
if (!class_exists('PerchAssets_Tags', false)) {
include_once PERCH_CORE . '/apps/assets/PerchAssets_Tags.class.php';
include_once PERCH_CORE . '/apps/assets/PerchAssets_Tag.class.php';
}
$Tags = new PerchAssets_Tags();
$Tags->assign_tag_array($newID, $tags, true);
}
}
}
PerchResources::$logged[] = $newID;
return $newID;
}
示例3: get_meta_data
public function get_meta_data($file_path, $name)
{
if (!class_exists('PerchAssets_MetaData')) {
include_once __DIR__ . '/PerchAssets_MetaData.class.php';
}
$MetaData = new PerchAssets_MetaData();
if (is_callable('iptcparse') && is_callable('getimagesize')) {
$info = array();
getimagesize($file_path);
// once
getimagesize($file_path, $info);
// twice for luck (aka bugs);
if (isset($info['APP13'])) {
$iptc = iptcparse($info['APP13']);
$MetaData->store_iptc($iptc);
}
}
if (!$MetaData->get_title()) {
$title = PerchUtil::filename(PerchUtil::strip_file_extension($name), false);
$MetaData->set_title($title);
}
return $MetaData;
}
示例4: thumbnail_file
public function thumbnail_file($file_path, $width = 150, $height = 150, $suffix = 'thumb')
{
if (class_exists('Imagick')) {
$w = $width;
$h = $height;
$save_as = $this->get_resized_filename($file_path, $w, $h, $suffix, $this->density);
$save_as = PerchUtil::strip_file_extension($save_as) . '.png';
return $this->thumbnail_file_with_imagick($file_path, $save_as, $w, $h);
}
return false;
}
示例5: strrpos
//checking for naughty uploading of php files.
$target = PerchUtil::file_path($targetDir . '/' . $filename);
if (file_exists($target)) {
$ext = strrpos($filename, '.');
$fileName_a = substr($filename, 0, $ext);
$fileName_b = substr($filename, $ext);
$count = 1;
while (file_exists(PerchUtil::file_path($targetDir . '/' . $fileName_a . '_' . $count . $fileName_b))) {
$count++;
}
$filename = $fileName_a . '_' . $count . $fileName_b;
$target = PerchUtil::file_path($targetDir . '/' . $filename);
}
}
PerchUtil::move_uploaded_file($_FILES['upload']['tmp_name'], $target);
$data = array();
$data['imageAlt'] = PerchUtil::strip_file_extension($filename);
$data['albumID'] = $albumID;
$data['imageStatus'] = 'uploading';
$data['imageBucket'] = $bucket['name'];
$Image = $Images->create($data);
if (is_object($Image)) {
$Image->process_versions($filename, $Template, $bucket);
}
$Image->update(array('imageStatus' => 'active'));
$Album = $Albums->find($albumID);
if (is_object($Album)) {
$Album->update_image_count();
}
}
}
示例6: get_lang_options
public static function get_lang_options()
{
$Lang = PerchLang::fetch();
$out = array();
// Addons folder
if (is_dir(PerchUtil::file_path(PERCH_PATH . '/addons/lang'))) {
$lang_dir = PerchUtil::file_path(PERCH_PATH . '/addons/lang');
$files = PerchUtil::get_dir_contents($lang_dir, false);
if (is_array($files)) {
foreach ($files as $file) {
$out[] = PerchUtil::strip_file_extension($file);
}
}
}
// Core folder
$lang_dir = PerchUtil::file_path(PERCH_CORE . '/lang');
if (is_dir($lang_dir)) {
$files = PerchUtil::get_dir_contents($lang_dir, false);
if (is_array($files)) {
foreach ($files as $file) {
$f = PerchUtil::strip_file_extension($file);
if (!in_array($f, $out)) {
$out[] = $f;
}
}
}
}
if (PerchUtil::count($out)) {
sort($out);
return $out;
}
return false;
}
示例7: die
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
fclose($in);
fclose($out);
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
}
// If it's the last chunk
if ($chunks == 0 || $chunk == $chunks - 1) {
$newFileName = str_replace('_uploading_', '', $fileName);
rename($targetDir . DIRECTORY_SEPARATOR . $fileName, $targetDir . DIRECTORY_SEPARATOR . $newFileName);
$albumID = (int) $_REQUEST["albumID"];
$API = new PerchAPI(1.0, 'perch_gallery');
$Images = new PerchGallery_Images($API);
$Template = $API->get('Template');
$Template->set('gallery/image.html', 'gallery');
$data = array();
$data['imageAlt'] = PerchUtil::strip_file_extension($newFileName);
$data['albumID'] = $albumID;
$Image = $Images->create($data);
if (is_object($Image)) {
$Image->process_versions($newFileName, $Template);
}
PerchUtil::set_file_permissions($targetDir . DIRECTORY_SEPARATOR . $newFileName);
//file_put_contents(__DIR__.'/log.txt', strip_tags(PerchUtil::output_debug(true)));
}
// Return JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
示例8: get_title_from_filename
/**
* Attempt to construct a nice(ish) looking title from the file name
* @return [type] [description]
*/
public function get_title_from_filename()
{
$s = $this->resourceFile();
$s = PerchUtil::strip_file_extension($s);
return PerchUtil::filename($s, false);
}
示例9: order_new_pages
/**
* Find newly registered pages, and figure out their position in the tree
*
* @return void
* @author Drew McLellan
*/
public function order_new_pages($_count = 1)
{
$sql = 'SELECT *, REPLACE(pagePath, ' . $this->db->pdb('/' . PERCH_DEFAULT_DOC) . ', \'\') as sortPath FROM ' . $this->table . '
WHERE pageNew=1 ORDER BY LENGTH(sortPath)-LENGTH(REPLACE(sortPath, \'/\', \'\')) ASC';
$rows = $this->db->get_rows($sql);
if (PerchUtil::count($rows)) {
if ($_count > 10) {
return;
}
$pages = $this->return_instances($rows);
foreach ($pages as $Page) {
$data = array();
if (!$Page->pageDepth()) {
$depth = $Page->find_depth();
$data['pageDepth'] = $depth;
} else {
$depth = (int) $Page->pageDepth();
}
$data['pageSortPath'] = PerchUtil::strip_file_extension($Page->sortPath());
if (!$Page->pageParentID()) {
if ($depth == 1) {
$data['pageParentID'] = 0;
} else {
// find parent
$parts = explode('/', $Page->sortPath());
array_pop($parts);
$sections = array();
while (PerchUtil::count($parts)) {
$t = implode('/', $parts);
if ($t) {
$sections[] = $t;
}
array_pop($parts);
}
PerchUtil::debug($Page->sortPath());
$sql = 'SELECT pageID, pageDepth, pageTreePosition FROM ' . $this->table . ' WHERE pageDepth<' . $depth . ' AND pageNew=0 AND pageSortPath IN (' . $this->db->implode_for_sql_in($sections) . ')
ORDER BY LENGTH(pageSortPath)-LENGTH(REPLACE(pageSortPath, \'/\', \'\')) DESC LIMIT 1';
$parent = $this->db->get_row($sql);
if ($parent) {
$data['pageParentID'] = $parent['pageID'];
$data['pageDepth'] = $parent['pageDepth'] + 1;
$depth = $data['pageDepth'];
}
}
} else {
$data['pageParentID'] = $Page->pageParentID();
$sql = 'SELECT pageID, pageDepth, pageTreePosition FROM ' . $this->table . ' WHERE pageID=' . $this->db->pdb((int) $Page->pageParentID()) . ' LIMIT 1';
$parent = $this->db->get_row($sql);
}
if (!isset($data['pageParentID'])) {
$data['pageParentID'] = $Page->pageParentID();
$sql = 'SELECT pageID, pageTreePosition FROM ' . $this->table . ' WHERE pageID=' . $this->db->pdb((int) $Page->pageParentID());
$parent = $this->db->get_row($sql);
// no parent, so reset depth to show at top of tree.
$depth = 1;
$data['pageDepth'] = $depth;
}
if (isset($data['pageParentID'])) {
// order
$sql = 'SELECT COUNT(*) FROM ' . $this->table . ' WHERE pageNew=0 AND pageParentID=' . $this->db->pdb((int) $data['pageParentID']);
$data['pageOrder'] = $this->db->get_count($sql) + 1;
// Tree position
if ($data['pageParentID'] == 0) {
$data['pageTreePosition'] = '000-' . str_pad($data['pageOrder'], 3, '0', STR_PAD_LEFT);
$base = '000-';
} else {
$data['pageTreePosition'] = $parent['pageTreePosition'] . '-' . str_pad($data['pageOrder'], 3, '0', STR_PAD_LEFT);
$base = $parent['pageTreePosition'] . '-';
}
$count = (int) $data['pageOrder'];
while ($this->db->get_count('SELECT COUNT(*) FROM ' . $this->table . ' WHERE pageTreePosition=' . $this->db->pdb($data['pageTreePosition'])) > 0) {
$data['pageTreePosition'] = $base . str_pad($count, 3, '0', STR_PAD_LEFT);
$count++;
}
$data['pageNew'] = 0;
$Page->update($data);
}
}
// recurse
$this->order_new_pages($_count++);
}
return false;
}
示例10: array
$postvars = array('pagePath', 'pageSubpagePath', 'pageHidden', 'pageAccessTags', 'pageAttributeTemplate');
if (PERCH_RUNWAY) {
$postvars[] = 'templateID';
}
$data = $Form->receive($postvars);
if (!isset($data['pageHidden'])) {
$data['pageHidden'] = '0';
}
if (!PERCH_RUNWAY) {
if (!isset($data['pageSubpagePath'])) {
$data['pageSubpagePath'] = false;
}
$data['pageSubpagePath'] = '/' . ltrim($data['pageSubpagePath'], '/');
$_POST['pageSubpagePath'] = $data['pageSubpagePath'];
} else {
$data['pageSortPath'] = PerchUtil::strip_file_extension(str_replace(array('/' . PERCH_DEFAULT_DOC), '', $data['pagePath']));
}
$data['pageModified'] = date('Y-m-d H:i:s');
if (isset($_POST['collections']) && PerchUtil::count($_POST['collections'])) {
$collections = $_POST['collections'];
$new_collections = array();
foreach ($collections as $collection) {
$collection = trim($collection);
$new_collections[] = (int) $collection;
}
if (PerchUtil::count($new_collections)) {
$data['pageCollections'] = implode(',', $new_collections);
}
} else {
$data['pageCollections'] = '';
}