本文整理汇总了PHP中Varien_Pear类的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Pear类的具体用法?PHP Varien_Pear怎么用?PHP Varien_Pear使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Varien_Pear类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkDownloads
public function checkDownloads()
{
$pear = new Varien_Pear();
$pkg = new PEAR_PackageFile($pear->getConfig(), false);
$result = true;
foreach ($this->getPackages() as $package) {
$obj = $pkg->fromAnyFile($package, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($obj)) {
$uinfo = $obj->getUserInfo();
if (is_array($uinfo)) {
foreach ($uinfo as $message) {
if (is_array($message)) {
$message = $message['message'];
}
Mage::getSingleton('Mage_Install_Model_Session')->addError($message);
}
} else {
print_r($obj->getUserInfo());
#Mage::getSingleton('Mage_Install_Model_Session')->addError($message);
}
$result = false;
}
}
return $result;
}
示例2: outputAction
public function outputAction()
{
$pear = Varien_Pear::getInstance();
$input = $this->getRequest()->getParam('argv');
$argv = preg_split('#\\s+#', $input);
$command = false;
$options = array();
$params = array();
foreach ($argv as $arg) {
if ($arg[0] === '-') {
$opt = '';
if ($arg[1] === '-') {
$opt = substr($arg, 2);
}
if ($opt) {
$options[$opt] = 1;
}
} elseif (empty($command)) {
$command = $arg;
} else {
$params[] = $arg;
}
}
$run = new Varien_Object();
if ($command) {
$run->setComment(Mage::helper('adminhtml')->__('Running:') . ' "' . $input . '"' . "\r\n\r\n");
$run->setCommand($command);
$run->setOptions($options);
$run->setParams($params);
} else {
$run->setComment(Mage::helper('adminhtml')->__('Invalid input:') . ' "' . $input . '"' . "\r\n\r\n");
}
$pear->runHtmlConsole($run);
}
示例3: initForm
public function initForm()
{
$pear = Varien_Pear::getInstance();
$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('cache_enable', array('legend' => AO::helper('adminhtml')->__('PEAR config')));
$fieldset->addField('preferred_state', 'select', array('name' => 'preferred_state', 'label' => AO::helper('adminhtml')->__('Preferred state'), 'value' => $pear->getConfig()->get('preferred_state'), 'options' => AO::getModel('adminhtml/extension')->getStabilityOptions()));
$this->setForm($form);
return $this;
}
示例4: upgradeAllAction
public function upgradeAllAction()
{
$params = array('comment' => Mage::helper('adminhtml')->__("Upgrading all packages, please wait...") . "\r\n\r\n");
if ($this->getRequest()->getParam('do')) {
$params['command'] = 'upgrade';
$params['options'] = array();
$params['params'] = array($pkg);
}
$result = Varien_Pear::getInstance()->runHtmlConsole($params);
if (!$result instanceof PEAR_Error) {
Mage::app()->cleanCache();
}
}
示例5: _fetchPackages
protected function _fetchPackages()
{
// fetch installed packages
$pear = Varien_Pear::getInstance();
$channels = Mage::getModel('adminhtml/extension')->getKnownChannels();
#$channels = array('var-dev.varien.com'=>1);#, 'pear.php.net'=>1);
$channelData = array();
foreach ($channels as $channel => $name) {
$data = array();
if (Mage::app()->useCache('pear')) {
$channelKey = 'PEAR_channel_packages_' . preg_replace('#[^a-z0-9]+#', '_', $channel);
$data = unserialize(Mage::app()->loadCache($channelKey));
}
if (empty($data)) {
$pear->getFrontend()->clear();
$pear->run('list-all', array('channel' => $channel));
$output = $pear->getOutput();
if (empty($output)) {
continue;
}
$data = $output[0]['output'];
if (Mage::app()->useCache('pear')) {
Mage::app()->saveCache(serialize($data), $channelKey, array('pear'), 3600);
}
}
$channelData[$channel] = $data;
}
// load available packages into array
$packages = array();
foreach ($channelData as $channel) {
if (!isset($channel['headline'])) {
continue;
}
if (!empty($channel['data'])) {
foreach ($channel['data'] as $category => $pkglist) {
foreach ($pkglist as $pkg) {
$pkgNameArr = explode('/', $pkg[0]);
$pkgName = isset($pkgNameArr[1]) ? $pkgNameArr[1] : $pkgNameArr[0];
$packages[] = array('id' => $channel['channel'] . '|' . $pkgName, 'category' => $category, 'channel' => $channel['channel'], 'name' => $pkgName, 'remote_version' => isset($pkg[1]) ? $pkg[1] : '', 'local_version' => isset($pkg[2]) ? $pkg[2] : '', 'summary' => isset($pkg[3]) ? $pkg[3] : '');
}
}
}
}
return $packages;
}
示例6: saveAction
public function saveAction()
{
$pear = Varien_Pear::getInstance();
$error = Mage::helper('adminhtml')->__("Unknown error");
$state = $this->getRequest()->getPost('preferred_state');
if (!empty($state)) {
$session = Mage::getSingleton('adminhtml/session');
$result = $pear->run('config-set', array(), array('preferred_state', $state));
if ($result instanceof PEAR_Error) {
$error = $result->getMessage();
} else {
$error = false;
}
}
if ($error) {
$session->addError($result->getMessage());
} else {
$session->addSuccess(Mage::helper('adminhtml')->__("PEAR Configuration was successfully saved"));
}
$this->_redirect('*/*');
}
示例7: createPackage
public function createPackage()
{
$pear = Varien_Pear::getInstance();
$dir = Mage::getBaseDir('var') . DS . 'pear';
if (!Mage::getConfig()->createDirIfNotExists($dir)) {
return false;
}
$curDir = getcwd();
chdir($dir);
$result = $pear->run('mage-package', array(), array('package.xml'));
chdir($curDir);
if ($result instanceof PEAR_Error) {
return $result;
}
return true;
}
示例8: __construct
public function __construct()
{
$this->_pear = Varien_Pear::getInstance();
}
示例9: massInstallRunAction
public function massInstallRunAction()
{
$params = array('comment' => Mage::helper('adminhtml')->__("Installing selected packages, please wait...") . "\r\n\r\n");
if ($this->getRequest()->getParam('do')) {
$params['command'] = 'install';
$params['options'] = array();
$packages = array();
foreach ($this->getRequest()->getPost('package') as $package) {
$packages[] = str_replace('|', '/', $package);
}
$params['params'] = $packages;
}
$result = Varien_Pear::getInstance()->runHtmlConsole($params);
if (!$result instanceof PEAR_Error) {
Mage::app()->cleanCache();
}
Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
}
示例10: installAction
public function installAction()
{
$pear = Varien_Pear::getInstance();
$params = array('comment' => Mage::helper('install')->__("Downloading and installing Magento, please wait...") . "\r\n\r\n");
if ($this->getRequest()->getParam('do')) {
if ($state = $this->getRequest()->getParam('state', 'beta')) {
$result = $pear->runHtmlConsole(array('comment' => Mage::helper('install')->__("Setting preferred state to: %s", $state) . "\r\n\r\n", 'command' => 'config-set', 'params' => array('preferred_state', $state)));
if ($result instanceof PEAR_Error) {
$this->installFailureCallback();
exit;
}
}
$params['command'] = 'install';
$params['options'] = array('onlyreqdeps' => 1);
$params['params'] = Mage::getModel('install/installer_pear')->getPackages();
$params['success_callback'] = array($this, 'installSuccessCallback');
$params['failure_callback'] = array($this, 'installFailureCallback');
}
$pear->runHtmlConsole($params);
Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
}
示例11: releaseAction
public function releaseAction()
{
#Varien_Pear::getInstance()->runHtmlConsole(array('command'=>'list-channels'));
if (empty($_POST)) {
$serFiles = @glob(Mage::getBaseDir('var') . DS . 'pear' . DS . '*.ser');
if (!$serFiles) {
return;
}
$pkg = new Varien_Object();
echo '<html><head><style type="text/css">* { font:normal 12px Arial }</style></head>
<body><form method="post"><table border="1" cellpadding="3" cellspacing="0"><thead>
<tr><th>Update/Package</th><th>Version</th><th>State</th></tr>
</thead><tbody>';
foreach ($serFiles as $i => $file) {
$serialized = file_get_contents($file);
$pkg->setData(unserialize($serialized));
$n = $pkg->getName();
echo '<tr><td><input type="checkbox" name="pkgs[' . $i . '][name]" id="pkg_' . $i . '" value="' . $n . '"/>
<label for="pkg_' . $i . '">' . $n . '</label>
<input type="hidden" name="pkgs[' . $i . '][file]" value="' . $file . '"/>
</td>
<td><input name="pkgs[' . $i . '][release_version]" value="' . $pkg->getData('release_version') . '"/></td>
<td><input name="pkgs[' . $i . '][release_stability]" value="' . $pkg->getData('release_stability') . '"/></td>
</tr>';
#echo "<pre>"; print_r($pkg->getData()); echo "</pre>"; exit;
}
echo '</tbody></table><button type="submit">Save and Generate Packages</button></form></body></html>';
} else {
@set_time_limit(0);
ob_implicit_flush();
foreach ($_POST['pkgs'] as $r) {
if (empty($r['name'])) {
continue;
}
echo "<hr/><h4>" . $r['name'] . "</h4>";
$ext = Mage::getModel('adminhtml/extension');
$ext->setData(unserialize(file_get_contents($r['file'])));
$ext->setData('release_version', $r['release_version']);
$ext->setData('release_stability', $r['release_stability']);
#echo "<pre>"; print_r($ext->getData()); echo "</pre>";
$result = $ext->savePackage();
if (!$result) {
echo "ERROR while creating the package";
continue;
} else {
echo "Package created; ";
}
$result = $ext->createPackage();
$pear = Varien_Pear::getInstance();
if ($result) {
$data = $pear->getOutput();
print_r($data[0]['output']);
} else {
echo "ERROR:";
print_r($result->getMessage());
}
}
echo '<hr/><a href="' . $_SERVER['REQUEST_URI'] . '">Refresh</a>';
}
exit;
}
示例12: createPackage
public function createPackage()
{
$pear = Varien_Pear::getInstance();
$dir = Mage::getBaseDir('var') . DS . 'pear';
$result = $pear->run('mage-package', array('targetdir' => $dir), array($dir . '/package.xml'));
if ($result instanceof PEAR_Error) {
return $result;
}
return true;
}
示例13: testAction
public function testAction()
{
Varien_Pear::getInstance()->runHtmlConsole(array('command' => 'list-channels'));
}
示例14: getInstance
public function getInstance()
{
if (!self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}