本文整理汇总了PHP中Horde_Registry::callByPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Registry::callByPackage方法的具体用法?PHP Horde_Registry::callByPackage怎么用?PHP Horde_Registry::callByPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Registry
的用法示例。
在下文中一共展示了Horde_Registry::callByPackage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Returns the data
*
* This method may either return a string or a readable stream resource
*
* @return mixed
*/
public function get()
{
list($base) = explode('/', $this->_path);
try {
$items = $this->_registry->callByPackage($base, 'browse', array($this->_path));
} catch (Horde_Exception_NotFound $e) {
throw new DAV\Exception\NotFound($this->_path . ' not found');
} catch (Horde_Exception $e) {
throw new DAV\Exception($e);
}
if (!$items) {
throw new DAV\Exception\NotFound($this->_path . ' not found');
}
$item = reset($items);
$this->_size = strlen($item);
return $item;
}
示例2: _listFolder
/**
* Returns an unsorted file list of the specified directory.
*
* @param string $path The path of the directory.
* @param string|array $filter Regular expression(s) to filter
* file/directory name on.
* @param boolean $dotfiles Show dotfiles?
* @param boolean $dironly Show only directories?
*
* @return array File list.
* @throws Horde_Vfs_Exception
*/
protected function _listFolder($path, $filter = null, $dotfiles = true, $dironly = false)
{
$list = array();
if ($path == '/') {
try {
$apps = $this->_registry->listApps(null, false, Horde_Perms::READ);
} catch (Horde_Exception $e) {
throw new Horde_Vfs_Exception($e->getMessage());
}
foreach ($apps as $app) {
if ($this->_registry->hasMethod('browse', $app)) {
$file = array('name' => $app, 'date' => time(), 'type' => '**dir', 'size' => -1);
$list[] = $file;
}
}
return $list;
}
if (substr($path, 0, 1) == '/') {
$path = substr($path, 1);
}
$pieces = explode('/', $path);
try {
$items = $this->_registry->callByPackage($pieces[0], 'browse', array('path' => $path, 'properties' => array('name', 'browseable', 'contenttype', 'contentlength', 'modified')));
} catch (Horde_Exception $e) {
throw new Horde_Vfs_Exception($e->getMessage());
}
if (!is_array(reset($items))) {
/* We return an object's content. */
throw new Horde_Vfs_Exception('Unknown error');
}
foreach ($items as $sub_path => $i) {
if ($dironly && !$i['browseable']) {
continue;
}
$name = basename($sub_path);
if ($this->_filterMatch($filter, $name)) {
continue;
}
$type = class_exists('Horde_Mime_Magic') ? Horde_Mime_Magic::mimeToExt(empty($i['contenttype']) ? 'application/octet-stream' : $i['contenttype']) : '**none';
$file = array('name' => $name, 'date' => empty($i['modified']) ? 0 : $i['modified'], 'type' => $i['browseable'] ? '**dir' : $type, 'size' => empty($i['contentlength']) ? 0 : $i['contentlength']);
$list[] = $file;
}
return $list;
}
示例3: createFile
/**
* Creates a new file in the directory
*
* @param string $name Name of the file
* @param resource|string $data Initial payload
* @return null|string
*/
public function createFile($name, $data = null)
{
list($app) = explode('/', $this->_path);
if (is_resource($data)) {
$content = new Horde_Stream_Existing(array('stream' => $data));
$type = Horde_Mime_Magic::analyzeData($content->getString(0, 100), $this->_mimedb);
} else {
$content = $data;
$type = Horde_Mime_Magic::analyzeData($content, $this->_mimedb);
}
if (!$type) {
$type = Horde_Mime_Magic::filenameToMime($name);
}
try {
$this->_registry->callByPackage($app, 'put', array($this->_path . '/' . $name, $content, $type));
} catch (Horde_Exception $e) {
throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
}
}