Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simplify ApplicationAbstracts

  • Loading branch information...
commit 7290bfbf632f4ecfc4f72cd51ec12ac81ba85db2 1 parent a5aeb04
@haraldpdl haraldpdl authored
View
54 osCommerce/OM/Core/ApplicationAbstract.php
@@ -11,6 +11,7 @@
abstract class ApplicationAbstract {
protected $_page_contents = 'main.php';
protected $_page_title;
+ protected $_ignored_actions = array();
abstract protected function initialize();
@@ -29,5 +30,58 @@ public function getPageContent() {
public function setPageContent($filename) {
$this->_page_contents = $filename;
}
+
+ public function siteApplicationActionExists($action) {
+ return class_exists('osCommerce\\OM\\Core\\Site\\' . OSCOM::getSite() . '\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . $action);
+ }
+
+ public function ignoreAction($key) {
+ $this->_ignored_actions[] = $key;
+ }
+
+ public function runActions() {
+ $action = null;
+ $action_index = 1;
+
+ if ( count($_GET) > 1 ) {
+ $requested_action = HTML::sanitize(basename(key(array_slice($_GET, 1, 1, true))));
+
+ if ( $requested_action == OSCOM::getSiteApplication() ) {
+ $requested_action = null;
+
+ if ( count($_GET) > 2 ) {
+ $requested_action = HTML::sanitize(basename(key(array_slice($_GET, 2, 1, true))));
+
+ $action_index = 2;
+ }
+ }
+
+ if ( !empty($requested_action) && self::siteApplicationActionExists($requested_action) ) {
+ $action = $requested_action;
+ }
+ }
+
+ if ( isset($action) ) {
+ call_user_func(array('osCommerce\\OM\\Core\\Site\\' . OSCOM::getSite() . '\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . $action, 'execute'), $this);
+
+ $action_index++;
+
+ if ( $action_index < count($_GET) ) {
+ $action = array($action);
+
+ for ( $i = $action_index, $n = count($_GET); $i < $n; $i++ ) {
+ $subaction = HTML::sanitize(basename(key(array_slice($_GET, $i, 1, true))));
+
+ if ( !in_array($subaction, $this->_ignored_actions) && self::siteApplicationActionExists(implode('\\', $action) . '\\' . $subaction) ) {
+ call_user_func(array('osCommerce\\OM\\Core\\Site\\' . OSCOM::getSite() . '\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . implode('\\', $action) . '\\' . $subaction, 'execute'), $this);
+
+ $action[] = $subaction;
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ }
}
?>
View
49 osCommerce/OM/Core/Site/Admin/ApplicationAbstract.php
@@ -20,62 +20,17 @@
protected $_sort_order;
public function __construct($process = true) {
- $OSCOM_Session = Registry::get('Session');
+ $this->ignoreAction(Registry::get('Session')->getName());
$this->initialize();
if ( $process === true ) {
$this->process();
- $action = null;
- $action_index = 1;
-
- if ( count($_GET) > 1 ) {
- $requested_action = HTML::sanitize(basename(key(array_slice($_GET, 1, 1, true))));
-
- if ( $requested_action == OSCOM::getSiteApplication() ) {
- $requested_action = null;
-
- if ( count($_GET) > 2 ) {
- $requested_action = HTML::sanitize(basename(key(array_slice($_GET, 2, 1, true))));
-
- $action_index = 2;
- }
- }
-
- if ( !empty($requested_action) && self::siteApplicationActionExists($requested_action) ) {
- $action = $requested_action;
- }
- }
-
- if ( isset($action) ) {
- call_user_func(array('osCommerce\\OM\\Core\\Site\\Admin\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . $action, 'execute'), $this);
-
- $action_index++;
-
- if ( $action_index < count($_GET) ) {
- $action = array($action);
-
- for ( $i = $action_index, $n = count($_GET); $i < $n; $i++ ) {
- $subaction = HTML::sanitize(basename(key(array_slice($_GET, $i, 1, true))));
-
- if ( $subaction != $OSCOM_Session->getName() && self::siteApplicationActionExists(implode('\\', $action) . '\\' . $subaction) ) {
- call_user_func(array('osCommerce\\OM\\Core\\Site\\Admin\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . implode('\\', $action) . '\\' . $subaction, 'execute'), $this);
-
- $action[] = $subaction;
- } else {
- break;
- }
- }
- }
- }
+ $this->runActions();
}
}
- public function siteApplicationActionExists($action) {
- return class_exists('osCommerce\\OM\\Core\\Site\\' . OSCOM::getSite() . '\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . $action);
- }
-
public function canLinkTo() {
return $this->_link_to;
}
View
49 osCommerce/OM/Core/Site/Shop/ApplicationAbstract.php
@@ -14,60 +14,15 @@
abstract class ApplicationAbstract extends \osCommerce\OM\Core\ApplicationAbstract {
public function __construct($process = true) {
- $OSCOM_Session = Registry::get('Session');
+ $this->ignoreAction(Registry::get('Session')->getName());
$this->initialize();
if ( $process === true ) {
$this->process();
- $action = null;
- $action_index = 1;
-
- if ( count($_GET) > 1 ) {
- $requested_action = HTML::sanitize(basename(key(array_slice($_GET, 1, 1, true))));
-
- if ( $requested_action == OSCOM::getSiteApplication() ) {
- $requested_action = null;
-
- if ( count($_GET) > 2 ) {
- $requested_action = HTML::sanitize(basename(key(array_slice($_GET, 2, 1, true))));
-
- $action_index = 2;
- }
- }
-
- if ( !empty($requested_action) && self::siteApplicationActionExists($requested_action) ) {
- $action = $requested_action;
- }
- }
-
- if ( isset($action) ) {
- call_user_func(array('osCommerce\\OM\\Core\\Site\\Shop\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . $action, 'execute'), $this);
-
- $action_index++;
-
- if ( $action_index < count($_GET) ) {
- $action = array($action);
-
- for ( $i = $action_index, $n = count($_GET); $i < $n; $i++ ) {
- $subaction = HTML::sanitize(basename(key(array_slice($_GET, $i, 1, true))));
-
- if ( $subaction != $OSCOM_Session->getName() && self::siteApplicationActionExists(implode('\\', $action) . '\\' . $subaction) ) {
- call_user_func(array('osCommerce\\OM\\Core\\Site\\Shop\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . implode('\\', $action) . '\\' . $subaction, 'execute'), $this);
-
- $action[] = $subaction;
- } else {
- break;
- }
- }
- }
- }
+ $this->runActions();
}
}
-
- public function siteApplicationActionExists($action) {
- return class_exists('osCommerce\\OM\\Core\\Site\\Shop\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . $action);
- }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.