public function __construct()
 {
     parent::__construct(AO::getSingleton('core/resource')->getConnection('directory_read'));
     $this->_countryTable = AO::getSingleton('core/resource')->getTableName('directory/country');
     $this->_select->from(array('country' => $this->_countryTable));
     $this->setItemObjectClass(AO::getConfig()->getModelClassName('directory/country'));
 }
Пример #2
0
 /**
  * Init configuration for webservices api
  *
  * @return Mage_Api_Model_Config
  */
 protected function _construct()
 {
     if (AO::app()->useCache('config_api')) {
         if ($this->loadCache()) {
             return $this;
         }
     }
     $mergeConfig = AO::getModel('core/config_base');
     $config = AO::getConfig();
     $modules = $config->getNode('modules')->children();
     // check if local modules are disabled
     $disableLocalModules = (string) $config->getNode('global/disable_local_modules');
     $disableLocalModules = !empty($disableLocalModules) && ('true' === $disableLocalModules || '1' === $disableLocalModules);
     $configFile = $config->getModuleDir('etc', 'Mage_Api') . DS . 'api.xml';
     if ($mergeConfig->loadFile($configFile)) {
         $config->extend($mergeConfig, true);
     }
     foreach ($modules as $modName => $module) {
         if ($module->is('active')) {
             if ($disableLocalModules && 'local' === (string) $module->codePool || $modName == 'Mage_Api') {
                 continue;
             }
             $configFile = $config->getModuleDir('etc', $modName) . DS . 'api.xml';
             if ($mergeConfig->loadFile($configFile)) {
                 $config->extend($mergeConfig, true);
             }
         }
     }
     $this->setXml($config->getNode('api'));
     if (AO::app()->useCache('config_api')) {
         $this->saveCache();
     }
     return $this;
 }
 /**
  * Retrieve Default desplay Currency value for current scope
  *
  * @return string
  */
 protected function _getCurrencyDefault()
 {
     if (!($value = $this->getData('groups/options/fields/default/value'))) {
         $value = AO::getConfig()->getNode(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT, $this->getScope(), $this->getScopeId());
     }
     return strval($value);
 }
Пример #4
0
 public function globalSearchAction()
 {
     $searchModules = AO::getConfig()->getNode("adminhtml/global_search");
     $items = array();
     if (!AO::getSingleton('admin/session')->isAllowed('admin/global_search')) {
         $items[] = array('id' => 'error', 'type' => 'Error', 'name' => AO::helper('adminhtml')->__('Access Deny'), 'description' => AO::helper('adminhtml')->__('You have not enought permissions to use this functionality.'));
         $totalCount = 1;
     } else {
         if (empty($searchModules)) {
             $items[] = array('id' => 'error', 'type' => 'Error', 'name' => AO::helper('adminhtml')->__('No search modules registered'), 'description' => AO::helper('adminhtml')->__('Please make sure that all global admin search modules are installed and activated.'));
             $totalCount = 1;
         } else {
             $start = $this->getRequest()->getParam('start', 1);
             $limit = $this->getRequest()->getParam('limit', 10);
             $query = $this->getRequest()->getParam('query', '');
             foreach ($searchModules->children() as $searchConfig) {
                 $className = $searchConfig->getClassName();
                 if (empty($className)) {
                     continue;
                 }
                 $searchInstance = new $className();
                 $results = $searchInstance->setStart($start)->setLimit($limit)->setQuery($query)->load()->getResults();
                 $items = array_merge_recursive($items, $results);
             }
             $totalCount = sizeof($items);
         }
     }
     $block = $this->getLayout()->createBlock('adminhtml/template')->setTemplate('system/autocomplete.phtml')->assign('items', $items);
     $this->getResponse()->setBody($block->toHtml());
 }
Пример #5
0
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     $this->getLayout()->createBlock('catalog/breadcrumbs');
     if ($headBlock = $this->getLayout()->getBlock('head')) {
         if ($title = $this->getCurrentCategory()->getMetaTitle()) {
             $headBlock->setTitle($title);
         }
         if ($description = $this->getCurrentCategory()->getMetaDescription()) {
             $headBlock->setDescription($description);
         }
         if ($keywords = $this->getCurrentCategory()->getMetaKeywords()) {
             $headBlock->setKeywords($keywords);
         }
         /*
         want to show rss feed in the url
         */
         if ($this->IsRssCatalogEnable() && $this->IsTopCategory()) {
             $title = $this->helper('rss')->__('%s RSS Feed', $this->getCurrentCategory()->getName());
             $headBlock->addItem('rss', $this->getRssLink(), 'title="' . $title . '"');
         }
     }
     if ($layout = $this->getCurrentCategory()->getPageLayout()) {
         if ($template = (string) AO::getConfig()->getNode('global/cms/layouts/' . $layout . '/template')) {
             $this->getLayout()->getBlock('root')->setTemplate($template);
         }
     }
     return $this;
 }
Пример #6
0
 /**
  * Load Acl resources from config
  *
  * @param Mage_Admin_Model_Acl $acl
  * @param Mage_Core_Model_Config_Element $resource
  * @param string $parentName
  * @return Mage_Admin_Model_Config
  */
 public function loadAclResources(Mage_Admin_Model_Acl $acl, $resource = null, $parentName = null)
 {
     if (is_null($resource)) {
         $resource = AO::getConfig()->getNode("adminhtml/acl/resources");
         $resourceName = null;
     } else {
         $resourceName = (is_null($parentName) ? '' : $parentName . '/') . $resource->getName();
         $acl->add(AO::getModel('admin/acl_resource', $resourceName), $parentName);
     }
     if (isset($resource->all)) {
         $acl->add(AO::getModel('admin/acl_resource', 'all'), null);
     }
     if (isset($resource->admin)) {
         $children = $resource->admin;
     } elseif (isset($resource->children)) {
         $children = $resource->children->children();
     }
     if (empty($children)) {
         return $this;
     }
     foreach ($children as $res) {
         $this->loadAclResources($acl, $res, $resourceName);
     }
     return $this;
 }
Пример #7
0
 public function fetchRatesAction()
 {
     try {
         $service = $this->getRequest()->getParam('rate_services');
         $this->_getSession()->setCurrencyRateService($service);
         if (!$service) {
             throw new Exception(AO::helper('adminhtml')->__('Invalid Import Service Specified'));
         }
         try {
             $importModel = AO::getModel(AO::getConfig()->getNode('global/currency/import/services/' . $service . '/model')->asArray());
         } catch (Exception $e) {
             AO::throwException(AO::helper('adminhtml')->__('Unable to initialize import model'));
         }
         $rates = $importModel->fetchRates();
         $errors = $importModel->getMessages();
         if (sizeof($errors) > 0) {
             foreach ($errors as $error) {
                 AO::getSingleton('adminhtml/session')->addWarning($error);
             }
             AO::getSingleton('adminhtml/session')->addWarning(AO::helper('adminhtml')->__('All possible rates were fetched, click on "Save" to apply'));
         } else {
             AO::getSingleton('adminhtml/session')->addSuccess(AO::helper('adminhtml')->__('All rates were fetched, click on "Save" to apply'));
         }
         AO::getSingleton('adminhtml/session')->setRates($rates);
     } catch (Exception $e) {
         AO::getSingleton('adminhtml/session')->addError($e->getMessage());
     }
     $this->_redirect('*/*/');
 }
 public function render(Varien_Data_Form_Element_Abstract $element)
 {
     $html = $this->_getHeaderHtml($element);
     $renderer = AO::getBlockSingleton('adminhtml/system_config_form_field');
     $attributes = AO::getConfig()->getNode(self::XML_PATH_IMAGE_TYPES)->asArray();
     foreach ($attributes as $key => $attribute) {
         /**
          * Watermark size field
          */
         $field = new Varien_Data_Form_Element_Text();
         $field->setName("groups[watermark][fields][{$key}_size][value]")->setForm($this->getForm())->setLabel(AO::helper('adminhtml')->__('Size for %s', $attribute['title']))->setRenderer($renderer);
         $html .= $field->toHtml();
         /**
          * Watermark upload field
          */
         $field = new Varien_Data_Form_Element_Imagefile();
         $field->setName("groups[watermark][fields][{$key}_image][value]")->setForm($this->getForm())->setLabel(AO::helper('adminhtml')->__('Watermark File for %s', $attribute['title']))->setRenderer($renderer);
         $html .= $field->toHtml();
         /**
          * Watermark position field
          */
         $field = new Varien_Data_Form_Element_Select();
         $field->setName("groups[watermark][fields][{$key}_position][value]")->setForm($this->getForm())->setLabel(AO::helper('adminhtml')->__('Position of Watermark for %s', $attribute['title']))->setRenderer($renderer)->setValues(AO::getSingleton('adminhtml/system_config_source_catalog_product_watermark_position')->toOptionArray());
         $html .= $field->toHtml();
     }
     $html .= $this->_getFooterHtml($element);
     return $html;
 }
 public function getFields()
 {
     if (!$this->_fields) {
         $this->_fields = AO::getConfig()->getFieldset('customer_dataflow', 'admin');
     }
     return $this->_fields;
 }
Пример #10
0
 public function scheduledUpdateCurrencyRates($schedule)
 {
     $importWarnings = array();
     if (!AO::getStoreConfig(self::IMPORT_ENABLE) || !AO::getStoreConfig(self::CRON_STRING_PATH)) {
         return;
     }
     $service = AO::getStoreConfig(self::IMPORT_SERVICE);
     if (!$service) {
         $importWarnings[] = AO::helper('directory')->__('FATAL ERROR:') . ' ' . AO::helper('directory')->__('Invalid Import Service Specified');
     }
     try {
         $importModel = AO::getModel(AO::getConfig()->getNode('global/currency/import/services/' . $service . '/model')->asArray());
     } catch (Exception $e) {
         $importWarnings[] = AO::helper('directory')->__('FATAL ERROR:') . ' ' . AO::throwException(AO::helper('directory')->__('Unable to initialize import model'));
     }
     $rates = $importModel->fetchRates();
     $errors = $importModel->getMessages();
     if (sizeof($errors) > 0) {
         foreach ($errors as $error) {
             $importWarnings[] = AO::helper('directory')->__('WARNING:') . ' ' . $error;
         }
     }
     if (sizeof($importWarnings) == 0) {
         AO::getModel('directory/currency')->saveRates($rates);
     } else {
         $translate = AO::getSingleton('core/translate');
         /* @var $translate Mage_Core_Model_Translate */
         $translate->setTranslateInline(false);
         /* @var $mailTemplate Mage_Core_Model_Email_Template */
         $mailTemplate = AO::getModel('core/email_template');
         $mailTemplate->setDesignConfig(array('area' => 'frontend'))->sendTransactional(AO::getStoreConfig(self::XML_PATH_ERROR_TEMPLATE), AO::getStoreConfig(self::XML_PATH_ERROR_IDENTITY), AO::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT), null, array('warnings' => join("\n", $importWarnings)));
         $translate->setTranslateInline(true);
     }
 }
Пример #11
0
 public function saveAction()
 {
     $request = $this->getRequest();
     $template = AO::getModel('core/email_template');
     if ($id = (int) $request->getParam('id')) {
         $template->load($id);
     }
     try {
         $template->setTemplateSubject($request->getParam('template_subject'))->setTemplateCode($request->getParam('template_code'))->setTemplateText($request->getParam('template_text'))->setModifiedAt(AO::getSingleton('core/date')->gmtDate());
         if (!$template->getId()) {
             $type = constant(AO::getConfig()->getModelClassName('core/email_template') . "::TYPE_HTML");
             $template->setTemplateType($type);
         }
         if ($this->getRequest()->getParam('_change_type_flag')) {
             $type = constant(AO::getConfig()->getModelClassName('core/email_template') . "::TYPE_TEXT");
             $template->setTemplateType($type);
         }
         $template->save();
         $this->_redirect('*/*');
     } catch (Exception $e) {
         AO::getSingleton('adminhtml/session')->setData('email_template_form_data', $this->getRequest()->getParams());
         AO::getSingleton('adminhtml/session')->addError($e->getMessage());
         $this->_forward('new');
     }
 }
 public function __construct()
 {
     parent::__construct(AO::getSingleton('core/resource')->getConnection('core_read'));
     $this->_templateTable = AO::getSingleton('core/resource')->getTableName('core/email_template');
     $this->_select->from($this->_templateTable, array('template_id', 'template_code', 'template_type', 'template_subject', 'template_sender_name', 'template_sender_email', 'added_at', 'modified_at'));
     $this->setItemObjectClass(AO::getConfig()->getModelClassName('core/email_template'));
 }
 public function __construct()
 {
     parent::__construct(AO::getSingleton('core/resource')->getConnection('admin_read'));
     $this->_roleTable = AO::getSingleton('core/resource')->getTableName('admin/role');
     $this->_select->from($this->_roleTable);
     $this->setItemObjectClass(AO::getConfig()->getModelClassName('admin/acl_role'));
 }
 /**
  * Prepare form for render
  */
 public function renderPrepare($template)
 {
     $form = new Varien_Data_Form();
     if ($this->getRequest()->isPost()) {
         $post = $this->getRequest()->getPost();
         if (isset($post['template_id'])) {
             unset($post['template_id']);
         }
         if (isset($post['template_type'])) {
             unset($post['template_type']);
         }
         $template->addData($post);
     }
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => AO::helper('newsletter')->__('Template Information'), 'class' => 'fieldset-wide'));
     $fieldset->addField('code', 'text', array('name' => 'code', 'label' => AO::helper('newsletter')->__('Template Name'), 'title' => AO::helper('newsletter')->__('Template Name'), 'class' => 'required-entry', 'required' => true, 'value' => $template->getTemplateCode()));
     $fieldset->addField('subject', 'text', array('name' => 'subject', 'label' => AO::helper('newsletter')->__('Template Subject'), 'title' => AO::helper('newsletter')->__('Template Subject'), 'class' => 'required-entry', 'required' => true, 'value' => $template->getTemplateSubject()));
     $fieldset->addField('sender_name', 'text', array('name' => 'sender_name', 'label' => AO::helper('newsletter')->__('Sender Name'), 'title' => AO::helper('newsletter')->__('Sender Name'), 'class' => 'required-entry', 'required' => true, 'value' => $template->getTemplateSenderName()));
     $fieldset->addField('sender_email', 'text', array('name' => 'sender_email', 'label' => AO::helper('newsletter')->__('Sender Email'), 'title' => AO::helper('newsletter')->__('Sender Email'), 'class' => 'required-entry validate-email', 'required' => true, 'value' => $template->getTemplateSenderEmail()));
     $txtType = constant(AO::getConfig()->getModelClassName('newsletter/template') . '::TYPE_TEXT');
     $fieldset->addField('text', 'editor', array('name' => 'text', 'wysiwyg' => $template->getTemplateType() != $txtType, 'label' => AO::helper('newsletter')->__('Template Content'), 'title' => AO::helper('newsletter')->__('Template Content'), 'theme' => 'advanced', 'class' => 'required-entry', 'required' => true, 'state' => 'html', 'value' => $template->getTemplateText(), 'style' => 'height:36em;'));
     if ($template->getId()) {
         // If edit add id
         $form->addField('id', 'hidden', array('name' => 'id', 'value' => $template->getId()));
     }
     if ($values = AO::getSingleton('adminhtml/session')->getData('newsletter_template_form_data', true)) {
         $form->setValues($values);
     }
     $this->setForm($form);
     return $this;
 }
Пример #15
0
 public function getClassNameByType($type)
 {
     if (strpos($type, '/') !== false) {
         return AO::getConfig()->getModelClassName($type);
     }
     return parent::getClassNameByType($type);
 }
Пример #16
0
 public function hasLocalCopy()
 {
     $dir = AO::getConfig()->getModuleDir('etc', 'Mage_Adminhtml');
     if ($dir && file_exists($dir)) {
         return true;
     }
     return false;
 }
 public function __construct()
 {
     parent::__construct(AO::getSingleton('core/resource')->getConnection('rating_read'));
     $this->_ratingOptionTable = AO::getSingleton('core/resource')->getTableName('rating/rating_option');
     $this->_ratingVoteTable = AO::getSingleton('core/resource')->getTableName('rating/rating_vote');
     $this->_select->from($this->_ratingOptionTable);
     $this->setItemObjectClass(AO::getConfig()->getModelClassName('rating/rating_option'));
 }
Пример #18
0
 public function getRenderer($renderer)
 {
     if (is_string($renderer) && ($className = AO::getConfig()->getBlockClassName($renderer))) {
         return new $className();
     } else {
         return $renderer;
     }
 }
Пример #19
0
 public function getEncryptionKey()
 {
     $key = $this->getData('encryption_key');
     if (is_null($key)) {
         $key = (string) AO::getConfig()->getNode('global/crypt/key');
         $this->setData('encryption_key', $key);
     }
     return $key;
 }
 /**
  * After change Catalog Search Type process
  *
  * @return Mage_Adminhtml_Model_System_Config_Catalog_Search_Type
  */
 protected function _afterSave()
 {
     $newValue = $this->getValue();
     $oldValue = AO::getConfig()->getNode(Mage_CatalogSearch_Model_Fulltext::XML_PATH_CATALOG_SEARCH_TYPE, $this->getScope(), $this->getScopeId());
     if ($newValue != $oldValue) {
         AO::getSingleton('catalogsearch/fulltext')->resetSearchResults();
     }
     return $this;
 }
 public function __construct()
 {
     $resources = AO::getSingleton('core/resource');
     $this->_setIdFieldName('primary_id');
     parent::__construct($resources->getConnection('review_read'));
     $this->_summaryTable = $resources->getTableName('review/review_aggregate');
     $this->_select->from($this->_summaryTable);
     $this->setItemObjectClass(AO::getConfig()->getModelClassName('review/review_summary'));
 }
Пример #22
0
 public function toOptionArray()
 {
     $types = array();
     foreach (AO::getConfig()->getNode(self::BUNDLE_OPTIONS_TYPES_PATH)->children() as $type) {
         $labelPath = self::BUNDLE_OPTIONS_TYPES_PATH . '/' . $type->getName() . '/label';
         $types[] = array('label' => (string) AO::getConfig()->getNode($labelPath), 'value' => $type->getName());
     }
     return $types;
 }
 /**
  * Constructor
  *
  * Configures collection
  */
 public function __construct()
 {
     parent::__construct(AO::getSingleton('core/resource')->getConnection('newsletter_read'));
     $this->_subscriberTable = AO::getSingleton('core/resource')->getTableName('newsletter/subscriber');
     $this->_queueLinkTable = AO::getSingleton('core/resource')->getTableName('newsletter/queue_link');
     $this->_storeTable = AO::getSingleton('core/resource')->getTableName('core/store');
     $this->_select->from(array('main_table' => $this->_subscriberTable));
     $this->setItemObjectClass(AO::getConfig()->getModelClassName('newsletter/subscriber'));
 }
Пример #24
0
 public function getConvertTable()
 {
     if (is_null($this->_convertTable)) {
         $convertNode = AO::getConfig()->getNode('default/url/convert');
         foreach ($convertNode->children() as $node) {
             $this->_convertTable[strval($node->from)] = strval($node->to);
         }
     }
     return $this->_convertTable;
 }
Пример #25
0
 /**
  * Retreiver factory init, load retreiver settings
  *
  */
 protected function _construct()
 {
     $config = AO::getConfig()->asArray(AO::getConfig()->getNode('global/catalog/product/type'));
     foreach ($config as $type => $data) {
         if (isset($data['index_data_retreiver'])) {
             $this->_retreivers[$type] = $data['index_data_retreiver'];
         }
     }
     $this->_init('catalogindex/retreiver');
 }
 protected function _prepareCollection()
 {
     $allowProductTypes = array();
     foreach (AO::getConfig()->getNode('global/catalog/product/type/grouped/allow_product_types')->children() as $type) {
         $allowProductTypes[] = $type->getName();
     }
     $collection = AO::getModel('catalog/product_link')->useGroupedLinks()->getProductCollection()->setProduct($this->_getProduct())->addAttributeToSelect('*')->addFilterByRequiredOptions()->addAttributeToFilter('type_id', $allowProductTypes);
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
 protected function _getAdditionalElementTypes()
 {
     $result = array('price' => AO::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'), 'image' => AO::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'), 'boolean' => AO::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean'));
     $response = new Varien_Object();
     $response->setTypes(array());
     AO::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response' => $response));
     foreach ($response->getTypes() as $typeName => $typeClass) {
         $result[$typeName] = $typeClass;
     }
     return $result;
 }
 public function toOptionArray()
 {
     $result = array();
     $perPageValues = AO::getConfig()->getNode('frontend/catalog/per_page_values/grid');
     $perPageValues = explode(',', $perPageValues);
     foreach ($perPageValues as $option) {
         $result[] = array('value' => $option, 'label' => $option);
     }
     //$result[] = array('value' => 'all', 'label' => AO::helper('catalog')->__('All'));
     return $result;
 }
 public function __construct()
 {
     parent::__construct(AO::getSingleton('core/resource')->getConnection('directory_read'));
     $this->_countryTable = AO::getSingleton('core/resource')->getTableName('directory/country');
     $this->_regionTable = AO::getSingleton('core/resource')->getTableName('directory/country_region');
     $this->_regionNameTable = AO::getSingleton('core/resource')->getTableName('directory/country_region_name');
     $locale = AO::app()->getLocale()->getLocaleCode();
     $this->_select->from(array('region' => $this->_regionTable), array('region_id' => 'region_id', 'country_id' => 'country_id', 'code' => 'code', 'default_name' => 'default_name'));
     $this->_select->joinLeft(array('rname' => $this->_regionNameTable), "region.region_id=rname.region_id AND rname.locale='{$locale}'", array('name'));
     $this->setItemObjectClass(AO::getConfig()->getModelClassName('directory/region'));
 }
 public function getAllOptions()
 {
     if (!$this->_options) {
         $layouts = array();
         foreach (AO::getConfig()->getNode('global/cms/layouts')->children() as $layoutName => $layoutConfig) {
             $this->_options[] = array('value' => $layoutName, 'label' => (string) $layoutConfig->label);
         }
         array_unshift($this->_options, array('value' => '', 'label' => AO::helper('catalog')->__('No layout updates')));
     }
     return $this->_options;
 }