/** * Post a comment action */ public function postAction() { $challenge = $this->getRequest()->getPost('recaptcha_challenge_field'); $field = $this->getRequest()->getPost('recaptcha_response_field'); $post = $this->getPost(); $data = new Varien_Object($this->getRequest()->getPost()); try { Mage::getSingleton('wordpress/session')->setPostCommentData($post, $data->getAuthor(), $data->getEmail(), $data->getUrl(), $data->getComment()); if (Mage::helper('wordpress/recaptcha')->isEnabled()) { if (!Mage::helper('wordpress/recaptcha')->isValidValue($challenge, $field, true)) { throw new Exception($this->getCaptchaErrorMessage()); } } $comment = $post->postComment($data->getAuthor(), $data->getEmail(), $data->getUrl(), $data->getComment()); if (!$comment) { throw new Exception($this->getCommentErrorMessage()); } Mage::getSingleton('wordpress/session')->removePostCommentData($post); Mage::getSingleton('core/session')->addSuccess($this->__($this->getCommentSuccessMessage())); } catch (Exception $e) { Mage::getSingleton('core/session')->addError($this->__($e->getMessage())); } $this->_redirectUrl($post->getPermalink()); }
/** * Renders grid column * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { $readDetailsHtml = $row->getUrl() ? '<a target="_blank" href="' . $row->getUrl() . '">' . Mage::helper('Mage_AdminNotification_Helper_Data')->__('Read Details') . '</a> | ' : ''; $markAsReadHtml = !$row->getIsRead() ? '<a href="' . $this->getUrl('*/*/markAsRead/', array('_current' => true, 'id' => $row->getId())) . '">' . Mage::helper('Mage_AdminNotification_Helper_Data')->__('Mark as Read') . '</a> | ' : ''; $encodedUrl = $this->helper('Mage_Core_Helper_Url')->getEncodedUrl(); return sprintf('%s%s<a href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>', $readDetailsHtml, $markAsReadHtml, $this->getUrl('*/*/remove/', array('_current' => true, 'id' => $row->getId(), Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $encodedUrl)), Mage::helper('Mage_AdminNotification_Helper_Data')->__('Are you sure?'), Mage::helper('Mage_AdminNotification_Helper_Data')->__('Remove')); }
/** * Renders grid column * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { if (!$row->getIsRead()) { return sprintf('<a target="_blank" href="%s">%s</a> | <a href="%s">%s</a> | <a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $row->getUrl(), AO::helper('adminnotification')->__('Read Details'), $this->getUrl('*/*/markAsRead/', array('_current' => true, 'id' => $row->getId())), AO::helper('adminnotification')->__('Mark as Read'), $this->getUrl('*/*/remove/', array('_current' => true, 'id' => $row->getId())), AO::helper('adminnotification')->__('Are you sure?'), AO::helper('adminnotification')->__('Remove')); } else { return sprintf('<a target="_blank" href="%s">%s</a> | <a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $row->getUrl(), AO::helper('adminnotification')->__('Read Details'), $this->getUrl('*/*/remove/', array('_current' => true, 'id' => $row->getId())), AO::helper('adminnotification')->__('Are you sure?'), AO::helper('adminnotification')->__('Remove')); } }
protected function _prepareForm() { $form = new Varien_Data_Form(); if (Mage::registry('gomage_feed')) { $item = Mage::registry('gomage_feed'); } else { $item = new Varien_Object(); } $this->setForm($form); $fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Item information'))); $headerBar = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('label' => Mage::helper('catalog')->__('Feed Pro Help'), 'class' => 'go', 'id' => 'feed_pro_help', 'onclick' => 'window.open(\'http://www.gomage.com/faq/extensions/feed-pro\')')); $fieldset->setHeaderBar($headerBar->toHtml()); $fieldset->addField('type', 'hidden', array('name' => 'type')); $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true, 'note' => $this->__('e.g. "Google Base", "Yahoo! Store"...'))); if ($item->getId() && ($url = $item->getUrl())) { $fieldset->addField('comments', 'note', array('label' => $this->__('Access Url'), 'title' => $this->__('Access Url'), 'text' => '<a href="' . $url . '" target="_blank">' . $url . '</a>')); } $fieldset->addField('filename', 'text', array('name' => 'filename', 'label' => $this->__('Filename'), 'title' => $this->__('Filename'), 'required' => false, 'note' => $this->__('e.g. "productfeed.csv", "productfeed.xml"...'))); $fieldset->addField('store_id', 'select', array('label' => $this->__('Store View'), 'required' => true, 'name' => 'store_id', 'values' => Mage::getModel('gomage_feed/adminhtml_system_config_source_store')->getStoreValuesForForm())); if (!$item->getType() && $this->getRequest()->getParam('type')) { $item->setType($this->getRequest()->getParam('type')); } $form->setValues($item->getData()); return parent::_prepareForm(); }
public function render(Varien_Object $row) { $url = $row->getUrl(); if ($url) { return '<a href="' . $url . '" target="_blank">' . $row->getFilenameWithExt() . '</a>'; } return $row->getFilenameWithExt(); }
/** * Redirects to custom url after logout if set in system > configuration > customer > startup * * @param Varien_Event_Observer $observer * @return $this */ public function logoutRedirect(Varien_Event_Observer $observer) { if (!Mage::getStoreConfigFlag('customer/startup/redirect_logout')) { return $this; } $transportObj = new Varien_Object(array('url' => Mage::getStoreConfig('customer/startup/redirect_logout_url'), 'code' => 302)); Mage::dispatchEvent('ambimax_logoutredirect', array('data' => $transportObj)); /** @var Mage_Customer_AccountController $controller */ $controller = $observer->getControllerAction(); $controller->getResponse()->setRedirect($transportObj->getUrl(), $transportObj->getCode()); }
/** * Render information about menu item * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { $helper = Mage::helper('menu'); switch ($row->getType()) { case VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::LINK_INTERNAL: return '<strong>' . $helper->__('Path') . ':</strong> ' . $row->getUrl(); break; case VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::LINK_EXTERNAL: return '<strong>' . $helper->__('Link') . ':</strong> ' . $row->getUrl(); break; case VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::CATEGORY: return '<strong>' . $helper->__('Category') . ':</strong> ' . Mage::getModel('catalog/category')->load($row->getDefaultCategory(), array('name'))->getName() . ' <strong>' . $helper->__('Show Children') . ':</strong> ' . ($row->getShowChildren() ? $helper->__('Yes') : $helper->__('No')) . ($row->getUrl() ? ' <strong>' . $helper->__('Path') . ':</strong> ' . $row->getUrl() : ''); break; case VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::ATTRIBUTE: return '<strong>' . $helper->__('Attribute code') . ':</strong> ' . $row->getSourceAttribute() . ' <strong>' . $helper->__('Category') . ':</strong> ' . Mage::getModel('catalog/category')->load($row->getDefaultCategory(), array('name'))->getName(); break; default: return ''; } }
public function download(Varien_Object $connectionInfo, $target) { $url = $connectionInfo->getUrl(); if (!$url) { Mage::throwException($this->_getLog()->__("No valid URL given: %s", $url)); } $this->_log($this->_getLog()->__("Downloading file %s from %s, to %s", basename($url), $url, $target)); $targetInfo = pathinfo($target); $filename = isset($targetInfo['extension']) ? basename($target) : basename(parse_url($url, PHP_URL_PATH)); $path = $this->_getTargetPath(dirname($target), $filename); $fp = fopen($path, 'w+'); //This is the file where we save the information $cookie = tempnam(Mage::getBaseDir('tmp'), "CURLCOOKIE"); $ch = curl_init($url); //Here is the file we are downloading, replace spaces with %20 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1"); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt($ch, CURLOPT_ENCODING, ""); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_exec($ch); $response = curl_getinfo($ch); curl_close($ch); fclose($fp); if ($response['http_code'] == 301 || $response['http_code'] == 302) { if ($headers = get_headers($response['url'])) { foreach ($headers as $value) { if (substr(strtolower($value), 0, 9) == "location:") { $connectionInfo->setUrl(trim(substr($value, 9, strlen($value)))); Mage::throwException($this->_getLog()->__("Retrying with forwarded URL: %s", $connectionInfo->getUrl())); return $this->download($connectionInfo, $target); } } } } return null; }
public function render(Varien_Object $row) { if (!Mage::getModel('magenotification/magenotification')->is_existedUrl($row->getUrl())) { return parent::render($row); } $read_url = $this->getUrl('magenotification/adminhtml_magenotification/readdetail', array('id' => $row->getId())); if (!$row->getIsRead()) { return sprintf('<a target="_blank" href="%s">%s</a> | <a href="%s">%s</a> | <a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $read_url, Mage::helper('adminnotification')->__('Read Details'), $this->getUrl('*/*/markAsRead/', array('_current' => true, 'id' => $row->getId())), Mage::helper('adminnotification')->__('Mark as Read'), $this->getUrl('*/*/remove/', array('_current' => true, 'id' => $row->getId())), Mage::helper('adminnotification')->__('Are you sure?'), Mage::helper('adminnotification')->__('Remove')); } else { return sprintf('<a target="_blank" href="%s">%s</a> | <a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $read_url, Mage::helper('adminnotification')->__('Read Details'), $this->getUrl('*/*/remove/', array('_current' => true, 'id' => $row->getId())), Mage::helper('adminnotification')->__('Are you sure?'), Mage::helper('adminnotification')->__('Remove')); } }
/** * Add new massaction item * * $item = array( * 'label' => string, * 'complete' => string, // Only for ajax enabled grid (optional) * 'url' => string, * 'confirm' => string, // text of confirmation of this action (optional) * 'additional' => string // (optional) * ); * * @param string $itemId * @param array|Varien_Object $item * @return Mage_Backend_Block_Widget_Grid_Massaction_Abstract */ public function addItem($itemId, $item) { if (is_array($item)) { $item = new Varien_Object($item); } if ($item instanceof Varien_Object) { $item->setId($itemId); $item->setUrl($this->getUrl($item->getUrl())); $this->_items[$itemId] = $item; } return $this; }
/** * Additionally check for session messages in several domains case * * @param string $url * @param int $code * @return Mage_Core_Controller_Response_Http */ public function setRedirect($url, $code = 302) { /** * Use single transport object instance */ if (self::$_transportObject === null) { self::$_transportObject = new Varien_Object(); } self::$_transportObject->setUrl($url); self::$_transportObject->setCode($code); Mage::dispatchEvent('controller_response_redirect', array('response' => $this, 'transport' => self::$_transportObject)); return parent::setRedirect(self::$_transportObject->getUrl(), self::$_transportObject->getCode()); }
public function saveAction() { $data = $this->getRequest()->getParams(); $uploader = new Mage_Core_Model_File_Uploader('file'); $uploader->setAllowedExtensions(array('csv')); $uploader->setAllowRenameFiles(true); $path = Mage::getBaseDir('var') . DS . 'import'; if (!file_exists($path)) { mkdir($path, 0777); } try { $result = $uploader->save($path); $fullPath = $result['path'] . DS . $result['file']; $csv = new Varien_File_Csv(); $data = $csv->getData($fullPath); $items = array(); if (count($data) > 1) { for ($i = 1; $i < count($data); $i++) { $item = array(); for ($j = 0; $j < count($data[0]); $j++) { if (isset($data[$i][$j]) && trim($data[$i][$j]) != '') { $item[strtolower($data[0][$j])] = $data[$i][$j]; } } $items[] = $item; } } $resource = Mage::getSingleton('core/resource'); $writeConnection = $resource->getConnection('core_write'); $table = $resource->getTableName('seoautolink/link'); $table2 = $resource->getTableName('seoautolink/link_store'); $i = 0; foreach ($items as $item) { if (!isset($item['keyword'])) { continue; } $item = new Varien_Object($item); $query = "REPLACE {$table} SET\n keyword = '" . addslashes($item->getKeyword()) . "',\n url = '" . addslashes($item->getUrl()) . "',\n url_title = '" . addslashes($item->getUrlTitle()) . "',\n url_target = '" . addslashes($item->getUrlTarget()) . "',\n is_nofollow = '" . (int) $item->getIsNofollow() . "',\n max_replacements = '" . (int) $item->getMaxReplacements() . "',\n sort_order = '" . (int) $item->getSortOrder() . "',\n occurence = '" . (int) $item->getOccurence() . "',\n is_active = '" . (int) $item->getIsActive() . "',\n created_at = '" . now() . "',\n updated_at = '" . now() . "';\n REPLACE {$table2} SET\n store_id = '" . (int) $item->getStoreId() . "',\n link_id = LAST_INSERT_ID();\n "; $writeConnection->query($query); $i++; } Mage::getSingleton('adminhtml/session')->addSuccess('' . $i . ' records were inserted or updated'); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } $this->_redirect('*/*/'); }
public function render(Varien_Object $feed) { $html = ''; $state = $feed->getGenerator()->getState(); if ($feed->getIsActive()) { if ($state->isReady()) { if ($feed->getUrl()) { $html = $this->getStatusHtml('notice', 'Ready'); } else { $html = $this->getStatusHtml('critical', 'Not generated'); } } elseif ($state->isError()) { $html = $this->getStatusHtml('critical', 'Error'); } elseif ($state->isProcessing()) { $html = $this->getStatusHtml('major', 'Processing', $state->toHtml()); } } else { $html = $this->getStatusHtml('minor', 'Disabled'); } return $html; }
protected function _prepareForm() { $form = new Varien_Data_Form(); if (Mage::registry('ranvi_feed')) { $item = Mage::registry('ranvi_feed'); } else { $item = new Varien_Object(); } $this->setForm($form); $fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Item information'))); $fieldset->addField('type', 'hidden', array('name' => 'type')); $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true)); if ($item->getId() && ($url = $item->getUrl())) { $fieldset->addField('comments', 'note', array('label' => $this->__('Access Url'), 'title' => $this->__('Access Url'), 'text' => '<a href="' . $url . '" target="_blank">' . $url . '</a>')); } $fieldset->addField('filename', 'text', array('name' => 'filename', 'label' => $this->__('Filename'), 'title' => $this->__('Filename'), 'required' => false)); $fieldset->addField('store_id', 'select', array('label' => $this->__('Store View'), 'required' => true, 'name' => 'store_id', 'values' => Mage::getModel('ranvi_feed/adminhtml_system_config_source_store')->getStoreValuesForForm())); if (!$item->getType() && $this->getRequest()->getParam('type')) { $item->setType($this->getRequest()->getParam('type')); } $form->setValues($item->getData()); return parent::_prepareForm(); }
/** * Tag page * * @param Varien_Object $tag */ public function processRouteWordpressPostTagView($tag) { $meta = new Varien_Object(array('title' => $this->getTitleTaxPostTag(), 'description' => $this->getMetadescTaxPostTag(), 'keywords' => $this->getMetakeyTaxPostTag(), 'robots' => $this->getNoindexTaxPostTag() ? 'noindex,follow' : '')); $this->_applyMeta($meta->getData()); $this->_applyOpenGraph(array('type' => 'object', 'url' => $tag->getUrl(), 'title' => $this->_rewriteString($meta->getTitle()))); return $this; }
/** * Get item URL * * In most cases should be overriden in descendant blocks * * @param Varien_Object $item * @return string */ public function getItemUrl($item) { return $item->getUrl(); }
/** * get attribute values array with 'label' and 'href' * * @param VF_CustomMenu_Model_Menu $item * @return array */ protected function _getAttributeValueItems(VF_CustomMenu_Model_Menu $item) { $items = array(); if ($item->getSourceAttribute()) { /** @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $item->getSourceAttribute()); /** @var $indexAttribute Mage_CatalogIndex_Model_Attribute */ $indexAttribute = Mage::getSingleton('catalogindex/attribute'); /** @var $rootCategory Mage_Catalog_Model_Category */ $rootCategory = Mage::getModel('catalog/category')->load($item->getDefaultCategoryId()); $entityFilter = $rootCategory->getProductCollection()->getSelect()->distinct(); $activeOptions = array_keys($indexAttribute->getCount($attribute, $entityFilter)); if ($attribute->usesSource()) { $allOptions = $attribute->getSource()->getAllOptions(false); foreach ($allOptions as $_option) { if (in_array($_option['value'], $activeOptions)) { $route = 'catalog/category/view'; $params = array('id' => $rootCategory->getId(), '_query' => array($attribute->getAttributeCode() => $_option['value']), '_use_rewrite' => true); $result = new Varien_Object(); Mage::dispatchEvent('custom_menu_popup_update_item_url', array('route' => $route, 'params' => $params, 'result' => $result)); if ($result->getUrl()) { $href = $result->getUrl(); } else { $href = $rootCategory->getUrl() . '?' . http_build_query($params['_query']); } $_option['href'] = $href; $items[] = $_option; } } } } return $items; }
/** * Process the SEO values for the blog view page * * @param Varien_Object $object * @param string $type * @param Varien_Object $page */ protected function _applyPostPageLogic($object, $type = 'post') { $meta = new Varien_Object(array('title' => $this->_getTitleFormat($type), 'description' => trim($this->getData('metadesc_' . $type)), 'keywords' => trim($this->getData('metakey_' . $type)))); if (($value = trim($object->getMetaValue('_yoast_wpseo_title'))) !== '') { $data = $this->getRewriteData(); $data['title'] = $value; $this->setRewriteData($data); } if (($value = trim($object->getMetaValue('_yoast_wpseo_metadesc'))) !== '') { $meta->setDescription($value); } if (($value = trim($object->getMetaValue('_yoast_wpseo_metakeywords'))) !== '') { $meta->setKeywords($value); } $robots = array(); $noIndex = (int) $object->getMetaValue('_yoast_wpseo_meta-robots-noindex'); if ($noIndex === 0) { $robots['index'] = ''; } else { if ($noIndex === 1) { $robots['noindex'] = ''; } else { if ($noIndex === 2) { $robots['index'] = ''; } else { if ($this->getNoindexPost()) { $robots['noindex'] = ''; } } } } if ($object->getMetaValue('_yoast_wpseo_meta-robots-nofollow')) { $robots['nofollow'] = ''; } else { $robots['follow'] = ''; } if (($advancedRobots = trim($object->getMetaValue('_yoast_wpseo_meta-robots-adv'))) !== '') { if ($advancedRobots !== 'none') { $robots = explode(',', $advancedRobots); } } $robots = array_keys($robots); if (count($robots) > 0) { $meta->setRobots(implode(',', $robots)); } $this->_applyMeta($meta->getData()); if (($headBlock = $this->_getHeadBlock()) !== false) { if ($canon = $object->getMetaValue('_yoast_wpseo_canonical')) { $headBlock->removeItem('link_rel', $object->getUrl()); $headBlock->addItem('link_rel', $canon, 'rel="canonical"'); } $this->_addGooglePlusLinkRel($object->getAuthor()); } if ($this->getOpengraph() === 'on') { $this->_addOpenGraphTags($object, $type); } return $this; }
/** * Author page * * @param Varien_Object $author */ public function processRouteWordpressAuthorView($author) { if ($this->getDisableAuthor()) { $this->_redirect(Mage::helper('wordpress')->getBlogRoute()); } $meta = new Varien_Object(array('title' => $this->getTitleAuthorWpseo(), 'description' => $this->getMetadescAuthorWpseo(), 'keywords' => $this->getMetakeyAuthorWpseo(), 'robots' => $this->getNoindexAuthorWpseo() ? 'noindex,follow' : '')); $this->_applyMeta($meta->getData()); $this->_applyOpenGraph(array('type' => 'object', 'title' => $this->_rewriteString($this->getTitleAuthorWpseo()), 'url' => $author->getUrl())); return $this; }
/** * get image dimensions * * @param Varien_Object $mageImage * @return array */ protected function _getImageDimension(Varien_Object $mageImage) { return array_combine(['width', 'height'], array_slice(getimagesize(file_exists($mageImage->getPath()) ? $mageImage->getPath() : $mageImage->getUrl()), 0, 2)); }
public function render(Varien_Object $row) { return sprintf('<a href="%s">%s</a>', $row->getUrl('usernamagementadmin/plugin/edit', array('id' => $row->getPluginId())), $row->getPluginName()); }
public function render(Varien_Object $feed) { if ($url = $feed->getUrl()) { return sprintf('<a href="%s" target="_blank">%s</a>', $url, $url); } }
/** * Renders grid column * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { $url = $row->getUrl(); return sprintf('<a target="_blank" href="' . $url . '">' . $row->getData($this->getColumn()->getIndex()) . '</a>'); }
/** * Validate a single plugin * * @param Varien_Object $params * @return void */ protected function _validatePlugin(Varien_Object $params) { if ($params->getCurrentVersion() && version_compare($params->getNewVersion(), $params->getCurrentVersion(), '>')) { throw Fishpig_Wordpress_Exception::warning($params->getName(), $this->__('You have version %s installed. Update to %s.', $params->getCurrentVersion(), sprintf('<a href="%s" target="_blank">%s</a>', $params->getUrl(), $params->getNewVersion()))); } if ($params->getId() && !$params->getCurrentVersion()) { if (Mage::helper('wordpress')->isPluginEnabled($params->getId())) { throw Fishpig_Wordpress_Exception::warning($params->getName(), $this->__('Extension required for plugin to work. ') . $this->__('Install %s', sprintf('<a href="%s" target="_blank">extension</a>.', $params->getUrl()))); } } return $this; }
/** * Renders grid column * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { $readDetailsHtml = $row->getUrl() ? '<a target="_blank" href="' . $row->getUrl() . '">' . Mage::helper('adminnotification')->__('Read Details') . '</a> | ' : ''; $markAsReadHtml = !$row->getIsRead() ? '<a href="' . $this->getUrl('*/*/markAsRead/', array('_current' => true, 'id' => $row->getId())) . '">' . Mage::helper('adminnotification')->__('Mark as Read') . '</a> | ' : ''; return sprintf('%s%s<a href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>', $readDetailsHtml, $markAsReadHtml, $this->getUrl('*/*/remove/', array('_current' => true, 'id' => $row->getId())), Mage::helper('adminnotification')->__('Are you sure?'), Mage::helper('adminnotification')->__('Remove')); }