本文整理汇总了PHP中modResource::filterPathSegment方法的典型用法代码示例。如果您正苦于以下问题:PHP modResource::filterPathSegment方法的具体用法?PHP modResource::filterPathSegment怎么用?PHP modResource::filterPathSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modResource
的用法示例。
在下文中一共展示了modResource::filterPathSegment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromArray
public function fromArray($config)
{
if (isset($config['pagetitle'])) {
$this->pagetitle = $config['pagetitle'];
} else {
$this->config->error->addError('Resources - pagetitle is not set', true);
return false;
}
if (isset($config['alias'])) {
$this->alias = $config['alias'];
} else {
$this->alias = modResource::filterPathSegment($this->modx, $this->pagetitle);
}
if (isset($config['setAsHome'])) {
$this->setAsHome = intval($config['setAsHome']);
}
if (isset($config['parent'])) {
$this->parent = $config['parent'];
}
if (isset($config['suffix'])) {
$this->suffix = $config['suffix'];
}
if (isset($config['context_key'])) {
$this->context_key = $config['context_key'];
}
if (isset($config['template'])) {
$this->template = $config['template'];
}
if (isset($config['class_key'])) {
$this->class_key = $config['class_key'];
}
if (isset($config['content_type'])) {
$this->content_type = $config['content_type'];
}
if (isset($config['longtitle'])) {
$this->longtitle = $config['longtitle'];
}
if (isset($config['description'])) {
$this->description = $config['description'];
}
if (isset($config['menutitle'])) {
$this->menutitle = $config['menutitle'];
}
if (isset($config['published'])) {
$this->published = intval($config['published']);
}
if (isset($config['isfolder'])) {
$this->isfolder = intval($config['isfolder']);
}
if (isset($config['introtext'])) {
$this->introtext = $config['introtext'];
}
if (isset($config['richtext'])) {
$this->richtext = intval($config['richtext']);
}
if (isset($config['menuindex'])) {
$this->menuindex = intval($config['menuindex']);
}
if (isset($config['searchable'])) {
$this->searchable = intval($config['searchable']);
}
if (isset($config['cacheable'])) {
$this->cacheable = intval($config['cacheable']);
}
if (isset($config['deleted'])) {
$this->deleted = intval($config['deleted']);
}
if (isset($config['hidemenu'])) {
$this->hidemenu = intval($config['hidemenu']);
}
if (isset($config['hide_children_in_tree'])) {
$this->hide_children_in_tree = intval($config['hide_children_in_tree']);
}
if (isset($config['show_in_tree'])) {
$this->show_in_tree = intval($config['show_in_tree']);
}
if (isset($config['link_attributes'])) {
$this->link_attributes = $config['link_attributes'];
}
if (isset($config['tvs']) && is_array($config['tvs'])) {
foreach ($config['tvs'] as $tv) {
if (!isset($tv['name'])) {
$this->config->error->addError('Resources - TV - name is not set', true);
return false;
}
if (!isset($tv['value'])) {
$tv['value'] = '';
}
if (isset($tv['file'])) {
$file = $this->config->getPackagePath();
$file .= '/core/components/' . $this->config->getLowCaseName() . '/resources/' . $tv['file'];
if (file_exists($file)) {
$tv['value'] = file_get_contents($file);
}
}
$this->tvs[$tv['name']] = $tv;
}
}
if (isset($config['others']) && is_array($config['others'])) {
foreach ($config['others'] as $other) {
//.........这里部分代码省略.........
示例2: filterPathSegment
/**
* Uses the modResource::filterPathSegment method if available for cleaning a file path.
* When it is not available (pre MODX 2.3) it uses a fake resource to call its cleanAlias method
*
* @param $path
* @return string
*/
protected function filterPathSegment($path)
{
if ($this->_useResource === null) {
$resource = $this->modx->newObject('modResource');
if (method_exists($resource, 'filterPathSegment')) {
$this->_useResource = false;
} else {
$this->_useResource = true;
$this->_resource = $resource;
}
}
$options = array('friendly_alias_lowercase_only' => false);
if ($this->_useResource) {
return $this->_resource->cleanAlias($path, $options);
}
return \modResource::filterPathSegment($this->modx, $path, $options);
}
示例3: prepareFiles
/**
* Prepare file name (prevent accidental overwrites)
*/
private function prepareFiles($prefix)
{
$files = $_FILES;
$fastuploadtv_translit = (bool) $this->modx->getOption('fastuploadtv.translit', null, false);
$fat = $this->modx->getOption('friendly_alias_translit');
$friendly_alias_translit = empty($fat) || $fat == 'none' ? false : true;
foreach ($files as &$file) {
$pathInfo = pathinfo($file['name']);
$ext = $pathInfo['extension'];
$filename = $this->getProperty('prefixFilename') == 'true' ? $prefix : $prefix . $pathInfo['filename'];
$filename = $this->parsePlaceholders($filename);
if ($fastuploadtv_translit) {
$filename = modResource::filterPathSegment($this->modx, $filename);
// cleanAlias (translate)
if ($friendly_alias_translit) {
$filename = preg_replace('/[^A-Za-z0-9_-]/', '', $filename);
// restrict segment to alphanumeric characters only
}
$filename = preg_replace('/-{2,}/', '-', $filename);
// remove double symbol "-"
$filename = trim($filename, '-');
// remove first symbol "-"
$ext = strtolower($ext);
}
$file['name'] = $filename . '.' . $ext;
}
return $files;
}
示例4: cleanAlias
/**
* @param string $alias
*
* @return string
*/
public function cleanAlias($alias = '')
{
return modResource::filterPathSegment($this->modx, $alias);
}
示例5: empty
$modx->regClientStartupScript($js . 'FastUploadTV.js');
$modx->regClientStartupScript($js . 'FastUploadTV.form.FastUploadTVField.js');
break;
case 'OnMODXInit':
$mTypes = $modx->getOption('manipulatable_url_tv_output_types', null, 'image,file') . ',fastuploadtv';
$modx->setOption('manipulatable_url_tv_output_types', $mTypes);
break;
case 'OnFileManagerUpload':
if ((bool) $modx->getOption('fastuploadtv.translit', null, false)) {
$fat = $modx->getOption('friendly_alias_translit');
$friendly_alias_translit = empty($fat) || $fat == 'none' ? false : true;
foreach ($files as $file) {
if ($file['error'] == 0) {
$pathInfo = pathinfo($file['name']);
$oldPath = $directory . $file['name'];
$filename = modResource::filterPathSegment($modx, $pathInfo['filename']);
// cleanAlias (translate)
if ($friendly_alias_translit) {
$filename = preg_replace('/[^A-Za-z0-9_-]/', '', $filename);
// restrict segment to alphanumeric characters only
}
$filename = preg_replace('/-{2,}/', '-', $filename);
// remove double symbol "-"
$filename = trim($filename, '-');
// remove first symbol "-"
$newPath = $filename . '.' . strtolower($pathInfo['extension']);
$source->renameObject($oldPath, $newPath);
}
}
}
break;