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


PHP AO::getBaseDir方法代码示例

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


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

示例1: downloadCustomOptionAction

 /**
  * Custom options downloader
  */
 public function downloadCustomOptionAction()
 {
     $quoteItemOptionId = $this->getRequest()->getParam('id');
     $secretKey = $this->getRequest()->getParam('key');
     $option = AO::getModel('sales/quote_item_option')->load($quoteItemOptionId);
     if ($option->getId()) {
         try {
             $info = unserialize($option->getValue());
             if ($secretKey != $info['secret_key']) {
                 throw new Exception();
             }
             $filePath = AO::getBaseDir() . $info['order_path'];
             if (!is_file($filePath) || !is_readable($filePath)) {
                 // try get file from quote
                 $filePath = AO::getBaseDir() . $info['quote_path'];
                 if (!is_file($filePath) || !is_readable($filePath)) {
                     throw new Exception();
                 }
             }
             $this->getResponse()->setHttpResponseCode(200)->setHeader('Pragma', 'public', true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Content-type', $info['type'], true)->setHeader('Content-Length', $info['size'])->setHeader('Content-Disposition', 'inline' . '; filename=' . $info['title']);
             $this->getResponse()->clearBody();
             $this->getResponse()->sendHeaders();
             readfile($filePath);
         } catch (Exception $e) {
             $this->_forward('noRoute');
         }
     } else {
         $this->_forward('noRoute');
     }
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:33,代码来源:DownloadController.php

示例2: install

 public function install()
 {
     $data = $this->getConfigData();
     foreach (AO::getModel('core/config')->getDistroServerVars() as $index => $value) {
         if (!isset($data[$index])) {
             $data[$index] = $value;
         }
     }
     if (isset($data['unsecure_base_url'])) {
         $data['unsecure_base_url'] .= substr($data['unsecure_base_url'], -1) != '/' ? '/' : '';
         if (!$this->_getInstaller()->getDataModel()->getSkipBaseUrlValidation()) {
             $this->_checkUrl($data['unsecure_base_url']);
         }
     }
     if (isset($data['secure_base_url'])) {
         $data['secure_base_url'] .= substr($data['secure_base_url'], -1) != '/' ? '/' : '';
         if (!empty($data['use_secure']) && !$this->_getInstaller()->getDataModel()->getSkipUrlValidation()) {
             $this->_checkUrl($data['secure_base_url']);
         }
     }
     $data['date'] = self::TMP_INSTALL_DATE_VALUE;
     $data['key'] = self::TMP_ENCRYPT_KEY_VALUE;
     $data['var_dir'] = $data['root_dir'] . '/var';
     $data['use_script_name'] = isset($data['use_script_name']) ? 'true' : 'false';
     $this->_getInstaller()->getDataModel()->setConfigData($data);
     $template = file_get_contents(AO::getBaseDir('etc') . DS . 'local.xml.template');
     foreach ($data as $index => $value) {
         $template = str_replace('{{' . $index . '}}', '<![CDATA[' . $value . ']]>', $template);
     }
     file_put_contents($this->_localConfigFile, $template);
     chmod($this->_localConfigFile, 0777);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:32,代码来源:Installer_Config.php

示例3: _fetchPackages

 /**
  * Get all packages identifiers
  *
  * @return array
  */
 protected function _fetchPackages()
 {
     $baseDir = AO::getBaseDir('var') . DS . 'pear';
     $files = array();
     $this->_collectRecursive($baseDir, $files);
     $result = array();
     foreach ($files as $file) {
         $file = preg_replace(array('/^' . preg_quote($baseDir . DS, '/') . '/', '/\\.(xml|ser)$/'), '', $file);
         $result[] = array('filename' => $file, 'filename_id' => $file);
     }
     return $result;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:17,代码来源:Extension_Collection.php

示例4: getUrl

 public function getUrl($object, $size = null)
 {
     $url = false;
     $image = $object->getData($this->getAttribute()->getAttributeCode());
     if (!is_null($size) && file_exists(AO::getBaseDir('media') . DS . 'catalog' . DS . 'product' . DS . $size . DS . $image)) {
         # resized image is cached
         $url = AO::getBaseUrl('media') . 'catalog/product/' . $size . '/' . $image;
     } elseif (!is_null($size)) {
         # resized image is not cached
         $url = AO::getBaseUrl() . 'catalog/product/image/size/' . $size . '/' . $image;
     } elseif ($image) {
         # using original image
         $url = AO::getBaseUrl('media') . 'catalog/product/' . $image;
     }
     return $url;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:16,代码来源:Product_Attribute_Frontend_Image.php

示例5: create

 /**
  * Create new image for product and return image filename
  *
  * @param int|string $productId
  * @param array $data
  * @param string|int $store
  * @return string
  */
 public function create($productId, $data, $store = null)
 {
     $product = $this->_initProduct($productId, $store);
     $gallery = $this->_getGalleryAttribute($product);
     if (!isset($data->file) || !isset($data->file->mime) || !isset($data->file->content)) {
         $this->_fault('data_invalid', AO::helper('catalog')->__('Image not specified.'));
     }
     if (!isset($this->_mimeTypes[$data->file->mime])) {
         $this->_fault('data_invalid', AO::helper('catalog')->__('Invalid image type.'));
     }
     $fileContent = @base64_decode($data->file->content, true);
     if (!$fileContent) {
         $this->_fault('data_invalid', AO::helper('catalog')->__('Image content is not valid base64 data.'));
     }
     unset($data->file->content);
     $tmpDirectory = AO::getBaseDir('var') . DS . 'api' . DS . $this->_getSession()->getSessionId();
     $fileName = 'image.' . $this->_mimeTypes[$data->file->mime];
     $ioAdapter = new Varien_Io_File();
     try {
         // Create temporary directory for api
         $ioAdapter->checkAndCreateFolder($tmpDirectory);
         $ioAdapter->open(array('path' => $tmpDirectory));
         // Write image file
         $ioAdapter->write($fileName, $fileContent, 0666);
         unset($fileContent);
         // Adding image to gallery
         $file = $gallery->getBackend()->addImage($product, $tmpDirectory . DS . $fileName, null, true);
         // Remove temporary directory
         $ioAdapter->rmdir($tmpDirectory, true);
         $_imageData = $this->_prepareImageData($data);
         $gallery->getBackend()->updateImage($product, $file, $_imageData);
         if (isset($data->types)) {
             $gallery->getBackend()->setMediaAttribute($product, $data->types, $file);
         }
         $product->save();
     } catch (Mage_Core_Exception $e) {
         $this->_fault('not_created', $e->getMessage());
     } catch (Exception $e) {
         $this->_fault('not_created', AO::helper('catalog')->__('Can\'t create image.'));
     }
     return $gallery->getBackend()->getRenamedImage($file);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:50,代码来源:Product_Attribute_Media_Api_V2.php

示例6: beforeSave

 /**
  * Enter description here...
  *
  * @param Varien_Object $object
  */
 public function beforeSave($object)
 {
     $value = $object->getData($this->getAttribute()->getName());
     if (is_array($value) && !empty($value['delete'])) {
         $object->setData($this->getAttribute()->getName(), '');
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
         return;
     }
     $path = AO::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
     try {
         $uploader = new Varien_File_Uploader($this->getAttribute()->getName());
         $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
         $uploader->setAllowRenameFiles(true);
         $uploader->save($path);
         $object->setData($this->getAttribute()->getName(), $uploader->getUploadedFileName());
         $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
     } catch (Exception $e) {
         /** @TODO ??? */
         return;
     }
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:26,代码来源:Category_Attribute_Backend_Image.php

示例7: start

 public function start()
 {
     if (VPROF) {
         Varien_Profiler::start(__METHOD__ . '/setOptions');
     }
     $options = array('save_path' => AO::getBaseDir('session'), 'use_only_cookies' => 'off');
     if ($this->getCookieDomain()) {
         $options['cookie_domain'] = $this->getCookieDomain();
     }
     if ($this->getCookiePath()) {
         $options['cookie_path'] = $this->getCookiePath();
     }
     if ($this->getCookieLifetime()) {
         $options['cookie_lifetime'] = $this->getCookieLifetime();
     }
     Zend_Session::setOptions($options);
     if (VPROF) {
         Varien_Profiler::stop(__METHOD__ . '/setOptions');
     }
     /*
             if (VPROF) Varien_Profiler::start(__METHOD__.'/setHandler');
             $sessionResource = AO::getResourceSingleton('core/session');
             if ($sessionResource->hasConnection()) {
             	Zend_Session::setSaveHandler($sessionResource);
             }
             if (VPROF) Varien_Profiler::stop(__METHOD__.'/setHandler');
     */
     if (VPROF) {
         Varien_Profiler::start(__METHOD__ . '/start');
     }
     Zend_Session::start();
     if (VPROF) {
         Varien_Profiler::stop(__METHOD__ . '/start');
     }
     return $this;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:36,代码来源:Session_Abstract_Zend.php

示例8: installAction

 public function installAction()
 {
     $params = array('comment' => AO::helper('adminhtml')->__("Pending installation...") . "\r\n\r\n");
     if ($this->getRequest()->getParam('do')) {
         switch ($this->getRequest()->getParam('file_type')) {
             case 'local':
                 if (empty($_FILES['local']['tmp_name'])) {
                     $params['comment'] = AO::helper('adminhtml')->__("Error uploading the file") . "\r\n\r\n";
                     break;
                 }
                 $tmpDir = AO::getBaseDir('var') . DS . 'pear';
                 if (!is_dir($tmpDir)) {
                     mkdir($tmpDir, 0777, true);
                 }
                 $pkg = $tmpDir . DS . $_FILES['local']['name'];
                 move_uploaded_file($_FILES['local']['tmp_name'], $pkg);
                 break;
             case 'remote':
                 $pkg = $this->getRequest()->getParam('remote');
                 if (empty($pkg)) {
                     $params['comment'] = AO::helper('adminhtml')->__("Invalid URL") . "\r\n\r\n";
                 }
                 break;
         }
         if (!empty($pkg)) {
             $params['comment'] = AO::helper('adminhtml')->__("Installing {$pkg}, please wait...") . "\r\n\r\n";
             $params['command'] = 'install';
             $params['options'] = array();
             $params['params'] = array($pkg);
         }
     }
     $result = Varien_Pear::getInstance()->runHtmlConsole($params);
     if (!$result instanceof PEAR_Error) {
         AO::getModel('adminhtml/extension')->clearAllCache();
     }
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:36,代码来源:FileController.php

示例9: _loadFiles

 protected function _loadFiles()
 {
     if (!$this->_isLoaded) {
         $readPath = AO::getBaseDir('var') . DS . "backups";
         $ioProxy = new Varien_Io_File();
         try {
             $ioProxy->open(array('path' => $readPath));
         } catch (Exception $e) {
             $ioProxy->mkdir($readPath, 0777);
             $ioProxy->chmod($readPath, 0777);
             $ioProxy->open(array('path' => $readPath));
         }
         if (!is_file($readPath . DS . ".htaccess")) {
             // Deny from reading in browser
             $ioProxy->write(".htaccess", "deny from all", 0644);
         }
         $list = $ioProxy->ls(Varien_Io_File::GREP_FILES);
         $fileExtension = constant($this->_itemObjectClass . "::BACKUP_EXTENSION");
         foreach ($list as $entry) {
             if ($entry['filetype'] == $fileExtension) {
                 $item = new $this->_itemObjectClass();
                 $item->load($entry['text'], $readPath);
                 $item->setSize($entry['size']);
                 if ($this->_checkCondition($item)) {
                     $this->addItem($item);
                 }
             }
         }
         $this->_totalRecords = count($this->_items);
         if ($this->_totalRecords > 1) {
             usort($this->_items, array(&$this, 'compareByTypeOrDate'));
         }
         $this->_isLoaded = true;
     }
     return $this;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:36,代码来源:Fs_Collection.php

示例10: renderView

 /**
  * Render block
  *
  * @return string
  */
 public function renderView()
 {
     if (VPROF) {
         Varien_Profiler::start(__METHOD__);
     }
     $this->setScriptPath(AO::getBaseDir('design'));
     $params = array('_relative' => true);
     if ($area = $this->getArea()) {
         $params['_area'] = $area;
     }
     $templateName = Mage_Core_Model_Design_Package::getDesign()->getTemplateFilename($this->getTemplate(), $params);
     $templateName = scrunchName($templateName, 5);
     //var_dump($templateName);
     //var_dump(get_class($this));
     $html = $this->fetchView($templateName);
     if (VPROF) {
         Varien_Profiler::stop(__METHOD__);
     }
     return $html;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:25,代码来源:Template.php

示例11: releaseAction

 public function releaseAction()
 {
     #Varien_Pear::getInstance()->runHtmlConsole(array('command'=>'list-channels'));
     if (empty($_POST)) {
         $serFiles = @glob(AO::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 = AO::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;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:61,代码来源:CustomController.php

示例12: _backupDatabase

 /**
  * Backup database
  *
  * @param string $failPath redirect path if backup failed
  * @param array $arguments
  * @return Mage_Adminhtml_System_StoreController
  */
 protected function _backupDatabase($failPath, $arguments = array())
 {
     if (!$this->getRequest()->getParam('create_backup')) {
         return $this;
     }
     try {
         $backupDb = AO::getModel('backup/db');
         $backup = AO::getModel('backup/backup')->setTime(time())->setType('db')->setPath(AO::getBaseDir('var') . DS . 'backups');
         $backupDb->createBackup($backup);
         $this->_getSession()->addSuccess(AO::helper('backup')->__('Database was successfuly backed up.'));
     } catch (Mage_Core_Exception $e) {
         $this->_getSession()->addError($e->getMessage());
         $this->_redirect($failPath, $arguments);
         return;
     } catch (Exception $e) {
         $this->_getSession()->addException($e, AO::helper('backup')->__('Unable to create backup. Please, try again later.'));
         $this->_redirect($failPath, $arguments);
         return;
     }
     return $this;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:28,代码来源:StoreController.php

示例13: getTemplateFile

 /**
  * Retrive translated template file
  *
  * @param string $file
  * @param string $type
  * @param string $localeCode
  * @return string
  */
 public function getTemplateFile($file, $type, $localeCode = null)
 {
     if (is_null($localeCode) || preg_match('/[^a-zA-Z_]/', $localeCode)) {
         $localeCode = $this->getLocale();
     }
     $filePath = AO::getBaseDir('locale') . DS . $localeCode . DS . 'template' . DS . $type . DS . $file;
     if (!file_exists($filePath)) {
         // If no template specified for this locale, use store default
         $filePath = AO::getBaseDir('locale') . DS . AO::app()->getLocale()->getDefaultLocale() . DS . 'template' . DS . $type . DS . $file;
     }
     if (!file_exists($filePath)) {
         // If no template specified as  store default locale, use en_US
         $filePath = AO::getBaseDir('locale') . DS . Mage_Core_Model_Locale::DEFAULT_LOCALE . DS . 'template' . DS . $type . DS . $file;
     }
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->open(array('path' => AO::getBaseDir('locale')));
     return (string) $ioAdapter->read($filePath);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:26,代码来源:Translate.php

示例14: getCache

 /**
  * Retrieve cache object
  *
  * @return Zend_Cache_Core
  */
 public function getCache()
 {
     if (!$this->_cache) {
         $backend = strtolower((string) AO::getConfig()->getNode('global/cache/backend'));
         if (extension_loaded('apc') && ini_get('apc.enabled') && $backend == 'apc') {
             $backend = 'Apc';
             $backendAttributes = array('cache_prefix' => (string) AO::getConfig()->getNode('global/cache/prefix'));
         } elseif ('memcached' == $backend && extension_loaded('memcache')) {
             $backend = 'Memcached';
             $memcachedConfig = AO::getConfig()->getNode('global/cache/memcached');
             $backendAttributes = array('compression' => (bool) $memcachedConfig->compression, 'cache_dir' => (string) $memcachedConfig->cache_dir, 'hashed_directory_level' => (string) $memcachedConfig->hashed_directory_level, 'hashed_directory_umask' => (string) $memcachedConfig->hashed_directory_umask, 'file_name_prefix' => (string) $memcachedConfig->file_name_prefix, 'servers' => array());
             foreach ($memcachedConfig->servers->children() as $serverConfig) {
                 $backendAttributes['servers'][] = array('host' => (string) $serverConfig->host, 'port' => (string) $serverConfig->port, 'persistent' => (string) $serverConfig->persistent);
             }
         } else {
             $backend = 'File';
             $backendAttributes = array('cache_dir' => AO::getBaseDir('cache'), 'hashed_directory_level' => 1, 'hashed_directory_umask' => 0777, 'file_name_prefix' => 'mage');
         }
         $lifetime = AO::getConfig()->getNode('global/cache/lifetime');
         if ($lifetime !== false) {
             $lifetime = (int) $lifetime;
         } else {
             $lifetime = 7200;
         }
         $this->_cache = Zend_Cache::factory('Core', $backend, array('caching' => true, 'lifetime' => $lifetime, 'automatic_cleaning_factor' => 0), $backendAttributes);
     }
     return $this->_cache;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:33,代码来源:App.php

示例15: getSessionSavePath

 /**
  * Get sesssion save path
  *
  * @return string
  */
 public function getSessionSavePath()
 {
     return AO::getBaseDir('session');
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:9,代码来源:Session_Abstract_Varien.php


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