本文整理汇总了PHP中Hubzero\Utility\String::pad方法的典型用法代码示例。如果您正苦于以下问题:PHP String::pad方法的具体用法?PHP String::pad怎么用?PHP String::pad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\Utility\String
的用法示例。
在下文中一共展示了String::pad方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param integer $scope_id Scope ID (group, course, etc.)
* @return void
*/
public function __construct($scope_id = 0)
{
$this->set('scope_id', $scope_id);
$this->_segments['id'] = $scope_id;
$this->_segments['active'] = 'blog';
$this->_item = Profile::getInstance($scope_id);
$config = Plugin::params('members', 'blog');
$id = String::pad($this->get('scope_id'));
$this->set('path', str_replace('{{uid}}', $id, $config->get('uploadpath', '/site/members/{{uid}}/blog')));
$this->set('scope', $this->get('scope_id') . '/blog');
$this->set('option', $this->_segments['option']);
}
示例2: displayTask
/**
* Display a form for uploading an image and any data for current uploaded image
*
* @param string $file Image name
* @param integer $id User ID
* @return void
*/
public function displayTask($file = '', $id = 0)
{
// Do have an ID or do we need to get one?
if (!$id) {
$id = Request::getInt('id', 0);
}
$dir = String::pad($id);
// Do we have a file or do we need to get one?
$file = $file ?: Request::getVar('file', '');
// Build the directory path
$path = $this->path . DS . $dir;
// Output view
$this->view->set('title', $this->_title)->set('webpath', $this->config->get('uploadpath', '/site/quotes'))->set('default_picture', $this->config->get('defaultpic', '/core/components/com_feedback/site/assets/img/contributor.gif'))->set('path', $dir)->set('file', $file)->set('file_path', $path)->set('id', $id)->setErrors($this->getErrors())->setLayout('display')->display();
}
示例3: defined
* @author Shawn Rice <zooley@purdue.edu>
* @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
* @license http://opensource.org/licenses/MIT MIT
*/
// No direct access
defined('_HZEXEC_') or die;
$database = App::get('db');
$jt = new \Components\Jobs\Tables\JobType($database);
$jc = new \Components\Jobs\Tables\JobCategory($database);
$profile = \Hubzero\User\Profile::getInstance($this->seeker->uid);
$jobtype = $jt->getType($this->seeker->sought_type, strtolower(Lang::txt('COM_JOBS_TYPE_ANY')));
$jobcat = $jc->getCat($this->seeker->sought_cid, strtolower(Lang::txt('COM_JOBS_CATEGORY_ANY')));
$title = Lang::txt('COM_JOBS_ACTION_DOWNLOAD') . ' ' . $this->seeker->name . ' ' . ucfirst(Lang::txt('COM_JOBS_RESUME'));
// Get the configured upload path
$base_path = DS . trim($this->params->get('webpath', '/site/members'), DS);
$path = $base_path . DS . \Hubzero\Utility\String::pad($this->seeker->uid);
if (!is_dir(PATH_APP . $path)) {
if (!Filesystem::makeDirectory(PATH_APP . $path)) {
$path = '';
}
}
$resume = is_file(PATH_APP . $path . DS . $this->seeker->filename) ? $path . DS . $this->seeker->filename : '';
?>
<div class="aboutme<?php
echo $this->seeker->mine && $this->list ? ' mine' : '';
echo isset($this->seeker->shortlisted) && $this->seeker->shortlisted ? ' shortlisted' : '';
?>
">
<div class="thumb">
<img src="<?php
echo $profile->getPicture();
示例4: downloadTask
/**
* Download a file
*
* @return void
*/
public function downloadTask()
{
//get vars
$id = Request::getInt('id', 0);
//check to make sure we have an id
if (!$id || $id == 0) {
return;
}
//Load member profile
$member = Member::oneOrFail($id);
// check to make sure we have member profile
if (!$member) {
return;
}
//get the file name
// make sure to leave out any query params (ex. ?v={timestamp})
$uri = Request::getVar('SCRIPT_URL', '', 'server');
if (strstr($uri, 'Image:')) {
$file = str_replace('Image:', '', strstr($uri, 'Image:'));
} elseif (strstr($uri, 'File:')) {
$file = str_replace('File:', '', strstr($uri, 'File:'));
}
//decode file name
$file = urldecode($file);
// build base path
$base_path = $this->filespace() . DS . \Hubzero\Utility\String::pad($member->get('id'), 5);
//if we are on the blog
if (Request::getVar('active', 'profile') == 'blog') {
// @FIXME Check still needs to occur for non-public entries
//authorize checks
/*if ($this->_authorize() != 'admin')
{
if (User::get('id') != $member->get('id'))
{
App::abort(403, Lang::txt('You are not authorized to download the file: ') . ' ' . $file);
}
}*/
//get the params from the members blog plugin
$blog_params = Plugin::params('members', 'blog');
//build the base path to file based of upload path param
$base_path = str_replace('{{uid}}', \Hubzero\Utility\String::pad($member->get('id'), 5), $blog_params->get('uploadpath'));
}
//build file path
$file_path = $base_path . DS . $file;
// Ensure the file exist
if (!file_exists(PATH_APP . DS . $file_path)) {
App::abort(404, Lang::txt('The requested file could not be found: ') . ' ' . $file);
return;
}
// Serve up the image
$xserver = new \Hubzero\Content\Server();
$xserver->filename(PATH_APP . DS . $file_path);
$xserver->disposition('attachment');
$xserver->acceptranges(false);
// @TODO fix byte range support
//serve up file
if (!$xserver->serve()) {
// Should only get here on error
App::abort(404, Lang::txt('An error occured while trying to output the file'));
}
exit;
}
示例5: getMembersPath
/**
* Get path to member dir (for provisioned projects)
*
* @return string
*/
public function getMembersPath()
{
// Get members config
$mconfig = Component::params('com_members');
// Build upload path
$dir = \Hubzero\Utility\String::pad($this->_uid);
$path = DS . trim($mconfig->get('webpath', '/site/members'), DS) . DS . $dir . DS . 'files';
if (!is_dir(PATH_APP . $path)) {
if (!Filesystem::makeDirectory(PATH_APP . $path, 0755, true, true)) {
$this->setError(Lang::txt('UNABLE_TO_CREATE_UPLOAD_PATH'));
return;
}
}
return PATH_APP . $path;
}
示例6: getDiskUsage
/**
* Get disk space
*
* @param array $rows Publications objet array
*
* @return integer
*/
public static function getDiskUsage($rows = array())
{
$used = 0;
if (!empty($rows)) {
$pubconfig = Component::params('com_publications');
$base = trim($pubconfig->get('webpath'), DS);
foreach ($rows as $row) {
$path = DS . $base . DS . \Hubzero\Utility\String::pad($row->id);
$used = $used + self::computeDiskUsage($path, PATH_APP, false);
}
}
return $used;
}
示例7: picture
/**
* Get a path or URL to a user pciture
*
* @param integer $id
* @param string $name
* @param string $email
* @param bool $thumbnail
* @return string
*/
public function picture($id, $name, $email, $thumbnail = true)
{
$processor = new Processor();
$size = $this->pictureSize;
$file = $this->pictureName;
if ($thumbnail) {
$size = $this->thumbnailSize;
$file = $this->thumbnailName;
}
$dir = $this->path . DIRECTORY_SEPARATOR . String::pad($id, 5) . DIRECTORY_SEPARATOR;
$path = $dir . $file;
if (file_exists($path)) {
return with(new Moderator($path))->getUrl();
}
// If the name has a space
if (strstr($name, ' ')) {
$parts = explode(' ', $name);
$first = array_shift($parts);
$last = array_pop($parts);
$initials = substr($first, 0, 1) . substr($last, 0, 1);
} else {
$initials = substr($name, 0, 2);
}
$initials = strtoupper(trim($initials));
$image = $processor->getImageData($initials, $size, $this->color);
if (!is_dir($dir)) {
@mkdir($dir, 0755, true);
}
@file_put_contents($path, $image);
if (!file_exists($path)) {
return sprintf('data:image/png;base64,%s', base64_encode($image));
}
return with(new Moderator($path))->getUrl();
}
示例8: picture
/**
* Get a path or URL to a user pciture
*
* @param integer $id
* @param string $name
* @param string $email
* @param bool $thumbnail
* @return string
*/
public function picture($id, $name, $email, $thumbnail = true)
{
$file = $this->pictureName;
if ($thumbnail) {
$file = $this->thumbnailName;
}
$path = $this->path . DIRECTORY_SEPARATOR . String::pad($id, 5) . DIRECTORY_SEPARATOR . $file;
if (file_exists($path)) {
return with(new Moderator($path))->getUrl();
}
return '';
}
示例9: displayTask
/**
* Display a user's profile picture
*
* @param string $file File name
* @param integer $id User ID
* @return void
*/
public function displayTask($file = '', $id = 0)
{
// Incoming
if (!$id) {
$id = Request::getInt('id', 0, 'get');
}
$this->view->id = $id;
if (!$file) {
$file = Request::getVar('file', '', 'get');
}
$this->view->file = $file;
// Build the file path
$dir = \Hubzero\Utility\String::pad($id);
$path = PATH_APP . DS . $this->filespace() . DS . $dir;
// Output HTML
$this->view->webpath = '/' . $this->filespace();
$this->view->default_picture = $this->config->get('defaultpic', '/core/components/com_members/site/assets/img/profile.gif');
$this->view->path = $dir;
$this->view->file_path = $path;
foreach ($this->getErrors() as $error) {
$this->view->setError($error);
}
$this->view->setLayout('display');
$this->view->display();
}
示例10: _buildPathFromDate
/**
* Build a path from a creation date (0000-00-00 00:00:00)
*
* @param string $date Resource created date
* @param integer $id Resource ID
* @param string $base Base path to prepend
* @return string
*/
private function _buildPathFromDate($date, $id, $base = '')
{
if ($date && preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})/", $date, $regs)) {
$date = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
}
if ($date) {
$dir_year = Date::of($date)->format('Y');
$dir_month = Date::of($date)->format('m');
} else {
$dir_year = Date::format('Y');
$dir_month = Date::format('m');
}
$dir_id = String::pad($id);
$path = $base . DS . $dir_year . DS . $dir_month . DS . $dir_id;
return $path;
}
示例11: relativepath
/**
* Build and return the relative path to resource file storage
*
* @return string
*/
public function relativepath()
{
$date = $this->get('created');
if ($date && preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})/", $date, $regs)) {
$date = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
}
if ($date) {
$dir_year = Date::of($date)->format('Y');
$dir_month = Date::of($date)->format('m');
if (!is_dir($this->basepath() . DS . $dir_year . DS . $dir_month . DS . String::pad($this->get('id'))) && intval($dir_year) <= 2013 && intval($dir_month) <= 11) {
$dir_year = Date::of($date)->toLocal('Y');
$dir_month = Date::of($date)->toLocal('m');
}
} else {
$dir_year = Date::of('now')->format('Y');
$dir_month = Date::of('now')->format('m');
}
return $dir_year . DS . $dir_month . DS . String::pad($this->get('id'));
}
示例12: removeTask
/**
* Removes a profile entry, associated picture, and redirects to main listing
*
* @return void
*/
public function removeTask()
{
// Check for request forgeries
Request::checkToken();
// Incoming
$ids = Request::getVar('ids', array());
// Do we have any IDs?
if (!empty($ids)) {
// Loop through each ID and delete the necessary items
foreach ($ids as $id) {
$id = intval($id);
// Delete any associated pictures
$path = PATH_APP . DS . trim($this->config->get('webpath', '/site/members'), DS) . DS . \Hubzero\Utility\String::pad($id);
if (!file_exists($path . DS . $file) or !$file) {
$this->setError(Lang::txt('COM_MEMBERS_FILE_NOT_FOUND'));
} else {
unlink($path . DS . $file);
}
// Remove any contribution associations
$assoc = new \Components\Members\Tables\Association($this->database);
$assoc->authorid = $id;
$assoc->deleteAssociations();
// Remove the profile
$profile = new Profile();
$profile->load($id);
$profile->delete();
}
}
// Output messsage and redirect
App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_REMOVED'));
}
示例13: removeTask
/**
* Delete a file
*
* @return void
*/
public function removeTask()
{
// Check for request forgeries
Request::checkToken('get');
// Incoming member ID
$id = Request::getInt('id', 0);
if (!$id) {
$this->setError(Lang::txt('COM_MEMBERS_NO_ID'));
return $this->displayTask($id);
}
// Incoming file
$file = Request::getVar('file', '');
if (!$file) {
$this->setError(Lang::txt('COM_MEMBERS_NO_FILE'));
return $this->displayTask($id);
}
// Build the file path
$dir = String::pad($id);
$path = PATH_APP . DS . trim($this->config->get('webpath', '/site/members'), DS) . DS . $dir;
// if we have file
if (!file_exists($path . DS . $file) or !$file) {
$this->setError(Lang::txt('COM_MEMBERS_FILE_NOT_FOUND'));
} else {
$ih = new \Components\Members\Helpers\ImgHandler();
// Attempt to delete the file
if (!Filesystem::delete($path . DS . $file)) {
$this->setError(Lang::txt('COM_MEMBERS_UNABLE_TO_DELETE_FILE'));
return $this->displayTask($id);
}
// Get the file thumbnail name
if ($file == 'profile.png') {
$curthumb = 'thumb.png';
}
// Remove the thumbnail
if (file_exists($path . DS . $curthumb)) {
if (!Filesystem::delete($path . DS . $curthumb)) {
$this->setError(Lang::txt('COM_MEMBERS_UNABLE_TO_DELETE_FILE'));
return $this->displayTask($file, $id);
}
}
}
$this->displayTask($id);
}
示例14: foreach
echo $current->datetime;
?>
"><?php
echo Date::of($current->datetime)->toLocal('M Y');
?>
</time></span></span>
</p>
</div>
<div class="col span9 omega usage-stat">
<div class="chart-wrap">
<div id="chart-downloads" class="chart line"><?php
$sparkline = '<span class="sparkline">' . "\n";
foreach ($results as $result) {
$height = $downhighest ? round($result->primary_accesses / $downhighest * 100) : 0;
$sparkline .= "\t" . '<span class="index">';
$sparkline .= '<span class="count" style="height: ' . $height . '%;" title="20' . $result->year . '-' . \Hubzero\Utility\String::pad($result->month, 2) . ': ' . $result->primary_accesses . '">';
$sparkline .= number_format($result->primary_accesses);
$sparkline .= '</span> ';
$sparkline .= '</span>' . "\n";
}
$sparkline .= '</span>' . "\n";
echo $sparkline;
?>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
if (!jq) {
示例15: picture
/**
* Get a path or URL to a user pciture
*
* @param integer $id
* @param string $name
* @param string $email
* @param bool $thumbnail
* @return string
*/
public function picture($id, $name, $email, $thumbnail = true)
{
$processor = new Processor();
$size = $this->pictureSize;
$file = $this->pictureName;
if ($thumbnail) {
$size = $this->thumbnailSize;
$file = $this->thumbnailName;
}
$dir = $this->path . DIRECTORY_SEPARATOR . String::pad($id, 5) . DIRECTORY_SEPARATOR;
$path = $dir . $file;
if (file_exists($path)) {
return with(new Moderator($path))->getUrl();
}
$image = $processor->getImageData($email, $size, $this->color);
if (!is_dir($dir)) {
@mkdir($dir, 0755, true);
}
@file_put_contents($path, $image);
if (!file_exists($path)) {
return sprintf('data:image/png;base64,%s', base64_encode($image));
}
return with(new Moderator($path))->getUrl();
}