当前位置: 首页>>代码示例>>PHP>>正文


PHP PEAR_Installer_Role::getValidRoles方法代码示例

本文整理汇总了PHP中PEAR_Installer_Role::getValidRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Installer_Role::getValidRoles方法的具体用法?PHP PEAR_Installer_Role::getValidRoles怎么用?PHP PEAR_Installer_Role::getValidRoles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PEAR_Installer_Role的用法示例。


在下文中一共展示了PEAR_Installer_Role::getValidRoles方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerRoles

 /**
  * Scan through the Command directory looking for classes
  * and see what commands they implement.
  * @param string which directory to look for classes, defaults to
  *               the Installer/Roles subdirectory of
  *               the directory from where this file (__FILE__) is
  *               included.
  *
  * @return bool TRUE on success, a PEAR error on failure
  * @access public
  * @static
  */
 function registerRoles($dir = null)
 {
     $GLOBALS['_PEAR_INSTALLER_ROLES'] = array();
     $parser = new PEAR_XMLParser();
     if ($dir === null) {
         $dir = dirname(__FILE__) . '/Role';
     }
     if (!file_exists($dir) || !is_dir($dir)) {
         return PEAR::raiseError("registerRoles: opendir({$dir}) failed");
     }
     $dp = @opendir($dir);
     if (empty($dp)) {
         return PEAR::raiseError("registerRoles: opendir({$dir}) failed");
     }
     while ($entry = readdir($dp)) {
         if ($entry[0] == '.' || substr($entry, -4) != '.xml') {
             continue;
         }
         $class = "PEAR_Installer_Role_" . substr($entry, 0, -4);
         // List of roles
         if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'][$class])) {
             $file = "{$dir}/{$entry}";
             $parser->parse(file_get_contents($file));
             $data = $parser->getData();
             if (!is_array($data['releasetypes'])) {
                 $data['releasetypes'] = array($data['releasetypes']);
             }
             $GLOBALS['_PEAR_INSTALLER_ROLES'][$class] = $data;
         }
     }
     closedir($dp);
     ksort($GLOBALS['_PEAR_INSTALLER_ROLES']);
     PEAR_Installer_Role::getBaseinstallRoles(true);
     PEAR_Installer_Role::getInstallableRoles(true);
     PEAR_Installer_Role::getPhpRoles(true);
     PEAR_Installer_Role::getValidRoles('****', true);
     return true;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:50,代码来源:Role.php

示例2: _installFile2

 /**
  * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @param string filename
  * @param array attributes from <file> tag in package.xml
  * @param string path to install the file in
  * @param array options from command-line
  * @access private
  */
 function _installFile2(&$pkg, $file, $atts, $tmp_path, $options)
 {
     if (!isset($this->_registry)) {
         $this->_registry =& $this->config->getRegistry();
     }
     $channel = $pkg->getChannel();
     // {{{ assemble the destination paths
     if (!in_array($atts['attribs']['role'], PEAR_Installer_Role::getValidRoles($pkg->getPackageType()))) {
         return $this->raiseError('Invalid role `' . $atts['attribs']['role'] . "' for file {$file}");
     }
     $role =& PEAR_Installer_Role::factory($pkg, $atts['attribs']['role'], $this->config);
     $err = $role->setup($this, $pkg, $atts['attribs'], $file);
     if (PEAR::isError($err)) {
         return $err;
     }
     if (!$role->isInstallable()) {
         return;
     }
     $info = $role->processInstallation($pkg, $atts['attribs'], $file, $tmp_path);
     if (PEAR::isError($info)) {
         return $info;
     } else {
         list($save_destdir, $dest_dir, $dest_file, $orig_file) = $info;
     }
     $final_dest_file = $installed_as = $dest_file;
     if (isset($this->_options['packagingroot'])) {
         $final_dest_file = $this->_prependPath($final_dest_file, $this->_options['packagingroot']);
     }
     $dest_dir = dirname($final_dest_file);
     $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
     // }}}
     if (empty($this->_options['register-only'])) {
         if (!@is_dir($dest_dir)) {
             if (!$this->mkDirHier($dest_dir)) {
                 return $this->raiseError("failed to mkdir {$dest_dir}", PEAR_INSTALLER_FAILED);
             }
             $this->log(3, "+ mkdir {$dest_dir}");
         }
     }
     $attribs = $atts['attribs'];
     unset($atts['attribs']);
     // pretty much nothing happens if we are only registering the install
     if (empty($this->_options['register-only'])) {
         if (!count($atts)) {
             // no tasks
             if (!file_exists($orig_file)) {
                 return $this->raiseError("file {$orig_file} does not exist", PEAR_INSTALLER_FAILED);
             }
             if (!@copy($orig_file, $dest_file)) {
                 return $this->raiseError("failed to write {$dest_file}", PEAR_INSTALLER_FAILED);
             }
             $this->log(3, "+ cp {$orig_file} {$dest_file}");
             if (isset($attribs['md5sum'])) {
                 $md5sum = md5_file($dest_file);
             }
         } else {
             // file with tasks
             if (!file_exists($orig_file)) {
                 return $this->raiseError("file {$orig_file} does not exist", PEAR_INSTALLER_FAILED);
             }
             if (function_exists('file_get_contents')) {
                 $contents = file_get_contents($orig_file);
             } else {
                 $fp = fopen($orig_file, "r");
                 $contents = @fread($fp, filesize($orig_file));
                 // filesize can be 0
                 fclose($fp);
             }
             if ($contents === false) {
                 $contents = '';
             }
             if (isset($attribs['md5sum'])) {
                 $md5sum = md5($contents);
             }
             foreach ($atts as $tag => $raw) {
                 $tag = str_replace($pkg->getTasksNs() . ':', '', $tag);
                 $task = "PEAR_Task_{$tag}";
                 $task =& new $task($this->config, $this, PEAR_TASK_INSTALL);
                 if (!$task->isScript()) {
                     // scripts are only handled after installation
                     $task->init($raw, $attribs, $pkg->getLastInstalledVersion());
                     $res = $task->startSession($pkg, $contents, $final_dest_file);
                     if ($res === false) {
                         continue;
                         // skip this file
                     }
                     if (PEAR::isError($res)) {
                         return $res;
                     }
                     $contents = $res;
                     // save changes
                 }
//.........这里部分代码省略.........
开发者ID:zseand,项目名称:kloxo,代码行数:101,代码来源:Installer.php

示例3: _invalidFileRole

 function _invalidFileRole($file, $dir, $role)
 {
     $this->_stack->push(__FUNCTION__, 'error', array('file' => $file, 'dir' => $dir, 'role' => $role, 'roles' => PEAR_Installer_Role::getValidRoles($this->_pf->getPackageType())), 'File "%file%" in directory "%dir%" has invalid role "%role%", should be one of %roles%');
 }
开发者ID:racontemoi,项目名称:mamp,代码行数:4,代码来源:Validator.php

示例4: registerRoles

 /**
  * Scan through the Command directory looking for classes
  * and see what commands they implement.
  * @param string which directory to look for classes, defaults to
  *               the Installer/Roles subdirectory of
  *               the directory from where this file (__FILE__) is
  *               included.
  *
  * @return bool TRUE on success, a PEAR error on failure
  * @access public
  * @static
  */
 function registerRoles($dir = null)
 {
     if ($dir === null) {
         $dir = dirname(__FILE__) . '/Role';
     }
     $dp = @opendir($dir);
     if (empty($dp)) {
         return PEAR::raiseError("registerRoles: opendir({$dir}) failed");
     }
     while ($entry = readdir($dp)) {
         if ($entry[0] == '.' || substr($entry, -4) != '.php' || $entry == 'Common.php') {
             continue;
         }
         $class = "PEAR_Installer_Role_" . substr($entry, 0, -4);
         $file = "{$dir}/{$entry}";
         include_once $file;
         // List of roles
         if (empty($GLOBALS['_PEAR_INSTALLER_ROLES'][$class])) {
             $GLOBALS['_PEAR_INSTALLER_ROLES'][$class] = call_user_func(array($class, 'getInfo'));
         }
     }
     @closedir($dp);
     ksort($GLOBALS['_PEAR_INSTALLER_ROLES']);
     PEAR_Installer_Role::getBaseinstallRoles(true);
     PEAR_Installer_Role::getInstallableRoles(true);
     PEAR_Installer_Role::getPhpRoles(true);
     PEAR_Installer_Role::getValidRoles('****', true);
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:dilps,代码行数:41,代码来源:Role.php

示例5: _installFile2

 /**
  * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @param string filename
  * @param array attributes from <file> tag in package.xml
  * @param string path to install the file in
  * @param array options from command-line
  * @access private
  */
 function _installFile2(&$pkg, $file, &$real_atts, $tmp_path, $options)
 {
     $atts = $real_atts;
     if (!isset($this->_registry)) {
         $this->_registry =& $this->config->getRegistry();
     }
     $channel = $pkg->getChannel();
     // assemble the destination paths
     $roles = PEAR_Installer_Role::getValidRoles($pkg->getPackageType());
     if (!in_array($atts['attribs']['role'], $roles)) {
         return $this->raiseError('Invalid role `' . $atts['attribs']['role'] . "' for file {$file}");
     }
     $role =& PEAR_Installer_Role::factory($pkg, $atts['attribs']['role'], $this->config);
     $err = $role->setup($this, $pkg, $atts['attribs'], $file);
     if (PEAR::isError($err)) {
         return $err;
     }
     if (!$role->isInstallable()) {
         return;
     }
     $info = $role->processInstallation($pkg, $atts['attribs'], $file, $tmp_path);
     if (PEAR::isError($info)) {
         return $info;
     }
     list($save_destdir, $dest_dir, $dest_file, $orig_file) = $info;
     if (preg_match('~/\\.\\.(/|\\z)|^\\.\\./~', str_replace('\\', '/', $dest_file))) {
         return $this->raiseError("SECURITY ERROR: file {$file} (installed to {$dest_file}) contains parent directory reference ..", PEAR_INSTALLER_FAILED);
     }
     $final_dest_file = $installed_as = $dest_file;
     if (isset($this->_options['packagingroot'])) {
         $final_dest_file = $this->_prependPath($final_dest_file, $this->_options['packagingroot']);
     }
     $dest_dir = dirname($final_dest_file);
     $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
     if (empty($this->_options['register-only'])) {
         if (!file_exists($dest_dir) || !is_dir($dest_dir)) {
             if (!$this->mkDirHier($dest_dir)) {
                 return $this->raiseError("failed to mkdir {$dest_dir}", PEAR_INSTALLER_FAILED);
             }
             $this->log(3, "+ mkdir {$dest_dir}");
         }
     }
     $attribs = $atts['attribs'];
     unset($atts['attribs']);
     // pretty much nothing happens if we are only registering the install
     $htype = 'md5sum';
     if (empty($this->_options['register-only'])) {
         if (!count($atts)) {
             // no tasks
             if (!file_exists($orig_file)) {
                 return $this->raiseError("file {$orig_file} does not exist", PEAR_INSTALLER_FAILED);
             }
             if (!@copy($orig_file, $dest_file)) {
                 return $this->raiseError("failed to write {$dest_file}: {$php_errormsg}", PEAR_INSTALLER_FAILED);
             }
             $this->log(3, "+ cp {$orig_file} {$dest_file}");
             if (isset($attribs['sha1sum'])) {
                 $hash = sha1_file($dest_file);
                 $htype = 'sha1sum';
             } elseif (isset($attribs['md5sum'])) {
                 $hash = md5_file($dest_file);
                 $htype = 'md5sum';
             }
         } else {
             // file with tasks
             if (!file_exists($orig_file)) {
                 return $this->raiseError("file {$orig_file} does not exist", PEAR_INSTALLER_FAILED);
             }
             $contents = file_get_contents($orig_file);
             if ($contents === false) {
                 $contents = '';
             }
             if (isset($attribs['sha1sum'])) {
                 $hash = sha1($contents);
                 $htype = 'sha1sum';
             } elseif (isset($attribs['md5sum'])) {
                 $hash = md5($contents);
                 $htype = 'md5sum';
             }
             foreach ($atts as $tag => $raw) {
                 $tag = str_replace(array($pkg->getTasksNs() . ':', '-'), array('', '_'), $tag);
                 $task = "PEAR_Task_{$tag}";
                 $task =& new $task($this->config, $this, PEAR_TASK_INSTALL);
                 if (!$task->isScript()) {
                     // scripts are only handled after installation
                     $task->init($raw, $attribs, $pkg->getLastInstalledVersion());
                     $res = $task->startSession($pkg, $contents, $final_dest_file);
                     if ($res === false) {
                         continue;
                         // skip this file
                     }
                     if (PEAR::isError($res)) {
//.........这里部分代码省略.........
开发者ID:cheeepsan,项目名称:pear-core,代码行数:101,代码来源:Installer.php

示例6: addRole

 /**
  * Add an extension/role mapping to the role mapping option
  *
  * Roles influence both where a file is installed and how it is installed.
  * Files with role="data" are in a completely different directory hierarchy
  * from the program files of role="php"
  *
  * In PEAR 1.3b2, these roles are
  * - php (most common)
  * - data
  * - doc
  * - test
  * - script (gives the file an executable attribute)
  * - src
  *
  * @param string $extension file extension
  * @param string $role      file role
  *
  * @return void|PEAR_Error
  * @throws PEAR_PACKAGEFILEMANAGER2_INVALID_ROLE
  * @access public
  * @since  1.6.0a1
  */
 function addRole($extension, $role)
 {
     include_once 'PEAR/Installer/Role.php';
     $roles = PEAR_Installer_Role::getValidRoles($this->getPackageType());
     if (!in_array($role, $roles)) {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER2_INVALID_ROLE, implode($roles, ', '), $role);
     }
     $this->_options['roles'][$extension] = $role;
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:32,代码来源:PackageFileManager2.php


注:本文中的PEAR_Installer_Role::getValidRoles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。