This library/program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ------------------------------------------------------------------------
コード例 #1
0
ファイル: ActionGroup.php プロジェクト: loic425/Sylius
 /**
  * @param Action $action
  */
 public function addAction(Action $action)
 {
     if ($this->hasAction($name = $action->getName())) {
         throw new \InvalidArgumentException(sprintf('Action "%s" already exists.', $name));
     }
     $this->actions[$name] = $action;
 }
コード例 #2
0
 /**
  * Available paths from current state.
  *
  * @return array
  */
 public function getNextStates()
 {
     $maxMissionaries = $this->missionariesRight;
     if ($this->boatLocation == 'left') {
         $maxMissionaries = $this->missionariesLeft;
     }
     $maxCannibals = $this->cannibalsRight;
     if ($this->boatLocation == 'left') {
         $maxCannibals = $this->cannibalsLeft;
     }
     $maxMissionaries = min(BOAT_SIZE, $maxMissionaries);
     $maxCannibals = min(BOAT_SIZE, $maxCannibals);
     $states = [];
     for ($missionaries = 0; $missionaries <= $maxMissionaries; ++$missionaries) {
         for ($cannibals = 0; $cannibals <= $maxCannibals; ++$cannibals) {
             if ($missionaries == 0 && $cannibals == 0) {
                 continue;
             }
             if ($missionaries + $cannibals > BOAT_SIZE) {
                 continue;
             }
             $action = new Action($missionaries, $cannibals);
             if ($action->isValidAction()) {
                 $state = clone $this;
                 $state = $state->transfer($missionaries, $cannibals);
                 $node = new Node($state, $this, $action, 0, 0);
                 array_push($states, $node);
             }
         }
     }
     return $states;
 }
コード例 #3
0
ファイル: router.php プロジェクト: brunoxu/mycncart
 public function index()
 {
     // Route
     if (isset($this->request->get['route']) && $this->request->get['route'] != 'startup/router') {
         $route = $this->request->get['route'];
     } else {
         $route = $this->config->get('action_default');
     }
     $data = array();
     // Sanitize the call
     $route = preg_replace('/[^a-zA-Z0-9_\\/]/', '', (string) $route);
     // Trigger the pre events
     $result = $this->event->trigger('controller/' . $route . '/before', array(&$route, &$data));
     if (!is_null($result)) {
         return $result;
     }
     $action = new Action($route);
     // Any output needs to be another Action object.
     $output = $action->execute($this->registry, $data);
     // Trigger the post events
     $result = $this->event->trigger('controller/' . $route . '/after', array(&$route, &$output));
     if (!is_null($result)) {
         return $result;
     }
     return $output;
 }
コード例 #4
0
 function onEndShowScripts(Action $action)
 {
     $action->inlineScript('var infinite_scroll_on_next_only = ' . ($this->on_next_only ? 'true' : 'false') . ';');
     $action->inlineScript('var ajax_loader_url = "' . $this->path('ajax-loader.gif') . '";');
     $action->script($this->path('jquery.infinitescroll.js'));
     $action->script($this->path('infinitescroll.js'));
 }
コード例 #5
0
 function init($mySql, $queries, $lang, $module, $idUrl)
 {
     $HelperOther = new HelperOther();
     $Details = new Details();
     $Action = new Action();
     $entry = $mySql->fetch_row($queries->selectById($mySql, $module, $idUrl));
     $getColumn = $queries->selectAll($mySql, $module);
     $layout = $Details->debut($lang, $module);
     for ($i = 0; $i < $mySql->num_fields($getColumn); $i++) {
         $column = $mySql->fetch_field($getColumn);
         $column = $column->name;
         $details = $entry[$i];
         if ($Action->exclusion($module, $column)) {
             $field = $HelperOther->findField($column);
             @(!(include_once 'controller/fields/' . $field . '.class.php'));
             if (class_exists($field)) {
                 $getValue = new $field($lang, $module, $details, $column, DETAIL);
                 $details = $getValue->details;
                 $layout .= $Details->detail($details);
             }
         }
     }
     $layout .= $Details->fin();
     return $layout;
 }
コード例 #6
0
ファイル: twitterbot.php プロジェクト: carriercomm/Twitterbot
 /**
  * Sorts the actions based on which is to execute next.
  * @param Action $a
  * @param Action $b
  * @return -1 if $a < $b, 1 if $a > $b, 0 if $a == $b
  */
 private function nextAttemptSort($a, $b)
 {
     if ($a->getNextAttempt() == $b->getNextAttempt()) {
         return 0;
     }
     return $a->getNextAttempt() < $b->getNextAttempt() ? -1 : 1;
 }
コード例 #7
0
 public function get()
 {
     $action = new Action('common/order_status');
     $data = $action->execute($this->registry);
     $response['order_status'] = $data['order_status'];
     $this->response->setOutput($response);
 }
コード例 #8
0
ファイル: router.php プロジェクト: web3d/mincart
 public function index()
 {
     // Route
     if (isset($this->request->get['route']) && $this->request->get['route'] != 'startup/router') {
         $route = $this->request->get['route'];
     } else {
         $route = $this->config->get('action_default');
     }
     // Sanitize the call
     $route = str_replace('../', '', (string) $route);
     // Trigger the pre events
     $result = $this->event->trigger('controller/' . $route . '/before', array(&$route, &$data));
     if (!is_null($result)) {
         return $result;
     }
     // We dont want to use the loader class as it would make an controller callable.
     $action = new Action($route);
     // Any output needs to be another Action object.
     $output = $action->execute($this->registry);
     // Trigger the post events
     $result = $this->event->trigger('controller/' . $route . '/after', array(&$route, &$data, &$output));
     if (!is_null($result)) {
         return $result;
     }
     return $output;
 }
コード例 #9
0
 protected function add(Action $action)
 {
     if (isset($this->actions[$action->getName()])) {
         throw new \InvalidArgumentException(sprintf('The action "%s" already exists.', $action->getName()));
     }
     $this->actions[$action->getName()] = $action;
 }
コード例 #10
0
ファイル: route.php プロジェクト: mif32/opencart
 public function index()
 {
     // Route
     if (isset($this->request->get['route'])) {
         $route = $this->request->get['route'];
     } else {
         $route = 'common/dashboard';
     }
     $data = array();
     // Sanitize the call
     $route = str_replace('../', '', (string) $route);
     // Trigger the pre events
     $result = $this->event->trigger('controller/' . $route . '/before', array(&$route, &$data));
     if (!is_null($result)) {
         return $result;
     }
     $action = new Action($route);
     // Any output needs to be another Action object.
     $output = $action->execute($this->registry, $data);
     // Trigger the post events
     $result = $this->event->trigger('controller/' . $route . '/after', array(&$route, &$output));
     if (!is_null($result)) {
         return $result;
     }
     return $output;
 }
コード例 #11
0
 /**
  * Resource methods
  */
 public function get()
 {
     $action = new Action('common/language');
     $data = $action->execute($this->registry);
     $response['languages'] = $this->processLanguages($data['languages']);
     $this->response->setOutput($response);
 }
コード例 #12
0
 public function get()
 {
     $action = new Action('common/length');
     $data = $action->execute($this->registry);
     $response['length_units'] = $data['length_units'];
     $this->response->setOutput($response);
 }
コード例 #13
0
 /**
  * Menu item for personal subscriptions/groups area
  *
  * @param Action $action action being executed
  *
  * @return boolean hook return
  */
 function onEndAccountSettingsNav($action)
 {
     $action_name = $action->trimmed('action');
     common_debug("ACTION NAME = " . $action_name);
     $action->menuItem(common_local_url('mirrorsettings'), _m('MENU', 'Mirroring'), _m('Configure mirroring of posts from other feeds'), $action_name === 'mirrorsettings');
     return true;
 }
コード例 #14
0
 protected function populateFromOptions($options)
 {
     foreach ($options as $name => $attrs) {
         $action = new Action($name);
         if (isset($attrs['route_pattern'])) {
             $action->setRoute($attrs['route_name'], $attrs['route_pattern'], array());
         }
         if (isset($attrs['text'])) {
             $action->setText($attrs['text']);
         }
         if (isset($attrs['icon'])) {
             $action->setButtonIcon($attrs['icon']);
         }
         if (isset($attrs['style'])) {
             $action->setButtonStyle($attrs['style']);
         }
         if (isset($attrs['dialog'])) {
             $action->setDialog($attrs['dialog']['title'], $attrs['dialog']['message']);
         }
         if (isset($attrs['trans_domain'])) {
             $action->setTransDomain($attrs['trans_domain']);
         }
         if (isset($attrs['template'])) {
             $action->setTemplate($attrs['template']);
         }
         if (isset($attrs['roles'])) {
             $action->setRoles($attrs['roles']);
         }
         $this->add($action);
     }
 }
コード例 #15
0
 /**
  * Will try and find a validation profile for the action provided
  * 
  * @param Action $action
  * @return ValidationProfile
  * @throws ValidationException
  */
 public function getValidationProfile(Action $action)
 {
     if (!isset($this->profiles[$action->getName()])) {
         throw new ValidationException("Could not find a validation profile for action: [{$action->getName()}]");
     }
     return $this->profiles[$action->getName()];
 }
コード例 #16
0
 /**
  * Resource methods
  */
 public function get()
 {
     $action = new Action('common/currency');
     $data = $action->execute($this->registry);
     $response['currencies'] = $this->processCurrencies($data['currencies']);
     $this->response->setOutput($response);
 }
コード例 #17
0
 /**
  * Subaction handler - manages the action and delegates control to the proper
  * sub-action.
  *
  * What it does:
  * - It loads both the Themes and Settings language files.
  * - Checks the session by GET or POST to verify the sent data.
  * - Requires the user to not be a guest.
  * - Accessed via ?action=admin;area=theme.
  *
  * @see Action_Controller::action_index()
  */
 public function action_index()
 {
     global $txt, $context;
     if (isset($_REQUEST['api'])) {
         return $this->action_index_api();
     }
     // Load the important language files...
     loadLanguage('ManageThemes');
     loadLanguage('Settings');
     require_once SUBSDIR . '/Action.class.php';
     // No guests in here.
     is_not_guest();
     // Theme administration, removal, choice, or installation...
     $subActions = array('admin' => array($this, 'action_admin', 'permission' => 'admin_forum'), 'list' => array($this, 'action_list', 'permission' => 'admin_forum'), 'reset' => array($this, 'action_options', 'permission' => 'admin_forum'), 'options' => array($this, 'action_options', 'permission' => 'admin_forum'), 'install' => array($this, 'action_install', 'permission' => 'admin_forum'), 'remove' => array($this, 'action_remove', 'permission' => 'admin_forum'), 'pick' => array($this, 'action_pick'), 'edit' => array($this, 'action_edit', 'permission' => 'admin_forum'), 'copy' => array($this, 'action_copy', 'permission' => 'admin_forum'), 'themelist' => array($this, 'action_themelist', 'permission' => 'admin_forum'), 'browse' => array($this, 'action_browse', 'permission' => 'admin_forum'));
     // Action controller
     $action = new Action('manage_themes');
     // @todo Layout Settings?
     if (!empty($context['admin_menu_name'])) {
         $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['themeadmin_title'], 'description' => $txt['themeadmin_description'], 'tabs' => array('admin' => array('description' => $txt['themeadmin_admin_desc']), 'list' => array('description' => $txt['themeadmin_list_desc']), 'reset' => array('description' => $txt['themeadmin_reset_desc']), 'edit' => array('description' => $txt['themeadmin_edit_desc']), 'themelist' => array('description' => $txt['themeadmin_edit_desc']), 'browse' => array('description' => $txt['themeadmin_edit_desc'])));
     }
     // Follow the sa or just go to administration, call integrate_sa_manage_themes
     $subAction = $action->initialize($subActions, 'admin');
     // Default the page title to Theme Administration by default.
     $context['page_title'] = $txt['themeadmin_title'];
     $context['sub_action'] = $subAction;
     // Go to the action, if you have permissions
     $action->dispatch($subAction);
 }
コード例 #18
0
 /**
  * This is the dispatcher of smileys administration.
  *
  * @uses ManageSmileys language
  * @uses ManageSmileys template
  * @see Action_Controller::action_index()
  */
 public function action_index()
 {
     global $context, $txt, $modSettings;
     loadLanguage('ManageSmileys');
     loadTemplate('ManageSmileys');
     $subActions = array('addsmiley' => array($this, 'action_addsmiley', 'enabled' => !empty($modSettings['smiley_enable']), 'permission' => 'manage_smileys'), 'editicon' => array($this, 'action_editicon', 'enabled' => !empty($modSettings['messageIcons_enable']), 'permission' => 'manage_smileys'), 'editicons' => array($this, 'action_editicon', 'enabled' => !empty($modSettings['messageIcons_enable']), 'permission' => 'manage_smileys'), 'editsets' => array($this, 'action_edit', 'permission' => 'admin_forum'), 'editsmileys' => array($this, 'action_editsmiley', 'enabled' => !empty($modSettings['smiley_enable']), 'permission' => 'manage_smileys'), 'import' => array($this, 'action_edit', 'permission' => 'manage_smileys'), 'modifyset' => array($this, 'action_edit', 'permission' => 'manage_smileys'), 'modifysmiley' => array($this, 'action_editsmiley', 'enabled' => !empty($modSettings['smiley_enable']), 'permission' => 'manage_smileys'), 'setorder' => array($this, 'action_setorder', 'enabled' => !empty($modSettings['smiley_enable']), 'permission' => 'manage_smileys'), 'settings' => array($this, 'action_smileySettings_display', 'permission' => 'manage_smileys'), 'install' => array($this, 'action_install', 'permission' => 'manage_smileys'));
     // Action controller
     $action = new Action('manage_smileys');
     // Set the smiley context.
     $this->_initSmileyContext();
     // Load up all the tabs...
     $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['smileys_manage'], 'help' => 'smileys', 'description' => $txt['smiley_settings_explain'], 'tabs' => array('editsets' => array('description' => $txt['smiley_editsets_explain']), 'addsmiley' => array('description' => $txt['smiley_addsmiley_explain']), 'editsmileys' => array('description' => $txt['smiley_editsmileys_explain']), 'setorder' => array('description' => $txt['smiley_setorder_explain']), 'editicons' => array('description' => $txt['icons_edit_icons_explain']), 'settings' => array('description' => $txt['smiley_settings_explain'])));
     // Default the sub-action to 'edit smiley settings'. call integrate_sa_manage_smileys
     $subAction = $action->initialize($subActions, 'editsets');
     // Set up the template
     $context['page_title'] = $txt['smileys_manage'];
     $context['sub_action'] = $subAction;
     // Some settings may not be enabled, disallow these from the tabs as appropriate.
     if (empty($modSettings['messageIcons_enable'])) {
         $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true;
     }
     if (empty($modSettings['smiley_enable'])) {
         $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true;
         $context[$context['admin_menu_name']]['tab_data']['tabs']['editsmileys']['disabled'] = true;
         $context[$context['admin_menu_name']]['tab_data']['tabs']['setorder']['disabled'] = true;
     }
     // Call the right function for this sub-action.
     $action->dispatch($subAction);
 }
コード例 #19
0
 function init($mySql, $queries, $lang, $module, $module_dispatch, $idUrl, $categorie, $ss_categorie, $search, $sort, $order, $page)
 {
     $HelperOther = new HelperOther();
     $Updates = new Updates();
     $Action = new Action();
     $entry = $mySql->fetch_row($queries->selectById($mySql, $module_dispatch, $idUrl));
     $getColumn = $queries->selectAll($mySql, $module_dispatch);
     $layout = $Updates->debut($lang, $module, $module_dispatch, $idUrl, $categorie, $ss_categorie, $search, $sort, $order, $page);
     for ($i = 0; $i < $mySql->num_fields($getColumn); $i++) {
         // Boucle sur les colonnes
         $column = $mySql->fetch_field($getColumn);
         $column = $column->name;
         $update = $entry[$i];
         if ($Action->exclusion($module, $column)) {
             $field = $HelperOther->findField($column);
             @(!(include_once 'controller/fields/' . $field . '.class.php'));
             if (class_exists($field)) {
                 $getValue = new $field($lang, $module_dispatch, $update, $column, UPDATE);
                 $update = $getValue->update;
                 $layout .= $Updates->update($update);
             }
         }
     }
     $layout .= $Updates->fin($lang, $module_dispatch);
     return $layout;
 }
コード例 #20
0
ファイル: loader.php プロジェクト: LinuxJedi/arastta
 public function controller($route, $args = array())
 {
     $this->trigger->fire('pre.load.controller', array(&$route, &$args));
     $action = new Action($route, $args);
     $ret = $action->execute($this->registry);
     $this->trigger->fire('post.load.controller', array(&$route, &$ret));
     return $ret;
 }
コード例 #21
0
ファイル: ActionTest.php プロジェクト: koskelin/siren-domain
 public function testField()
 {
     $field = new Field('orderNumber');
     $action = new Action('add-item', 'http://api.x.io/orders/42/items');
     $action->addField($field);
     $expectedJson = json_encode(array('name' => 'add-item', 'href' => 'http://api.x.io/orders/42/items', 'method' => 'GET', 'type' => 'application/x-www-form-urlencoded', 'fields' => array(array('name' => 'orderNumber', 'type' => 'text'))));
     $this->assertJsonStringEqualsJsonString($expectedJson, json_encode($action));
 }
コード例 #22
0
ファイル: ModPlusPlugin.php プロジェクト: Grasia/bolotweet
 /**
  * Load JS at runtime if we're logged in.
  *
  * @param Action $action
  * @return boolean hook result
  */
 function onEndShowScripts($action)
 {
     $user = common_current_user();
     if ($user) {
         $action->script($this->path('modplus.js'));
     }
     return true;
 }
コード例 #23
0
ファイル: Processor.php プロジェクト: ceko/concrete5-1
 public function finish()
 {
     $tasks = $this->getTasks();
     foreach ($tasks as $task) {
         $action = new Action($this, $this->target, $task[1]);
         $action->finish();
     }
 }
コード例 #24
0
 /**
  * Link in a JavaScript script for the whitelist invite form
  *
  * @param Action $action Action being shown
  *
  * @return boolean hook flag
  */
 function onEndShowStatusNetScripts($action)
 {
     $name = $action->arg('action');
     if ($name == 'invite') {
         $action->script($this->getPath() . '/js/whitelistinvite.js');
     }
     return true;
 }
コード例 #25
0
 /**
  * Execute a single Action. The Action's <method>Action::onInit</method> will be called,
  * then its <class>AccessController</class> will be queried if the action can be executed,
  * and, if allowed, its <method>Action::process</method> will be called. If the action cannot
  * be executed in the current environment, then an <class>AccessDeniedException</class>
  * will be thrown
  * @param  Action $action  the action to execute
  * @throws  AccessDeniedException  if the action cannot be executed
  */
 static function process(Action $action) {
   $action->onInit();
   $ac = $action->getAccessController();
   if(is_null($ac) || ($ac->isAccessible())) {
     $action->process();
   } else {
     throw new AccessDeniedException('Action access controller (' . get_class($ac) . ') forbids this action', 0, $action);
   }
 }
コード例 #26
0
ファイル: loader.php プロジェクト: sachiv-logiciel/armit
 public function controller($route, $args = array())
 {
     if ($this->factory) {
         $action = $this->factory->newAction($route, $args);
     } else {
         $action = new Action($route, $args);
     }
     return $action->execute($this->registry);
 }
コード例 #27
0
 protected function confirmPayment($paymentMethodCode)
 {
     // Do not intercept view data because the mail send to user when confirming the order
     // may contain html from templates which are loaded through the loader's view method.
     $this->load->setInterceptViewData(false);
     // Internally execute the confirmation route.
     $action = new Action($this->payment->getPaymentConfirmationRoute($paymentMethodCode));
     $action->execute($this->registry);
 }
コード例 #28
0
ファイル: loader.php プロジェクト: bitst0rm/opencart
 public function controller($route)
 {
     // function arguments
     $args = func_get_args();
     // Remove the route
     array_shift($args);
     $action = new Action($route, $args);
     return $action->execute($this->registry);
 }
コード例 #29
0
ファイル: HasAction.php プロジェクト: powman/zfpadrao
 private function verificarAcao($ch_modulo, $ch_controller, $ch_action)
 {
     $modulo = new Modulo();
     $controller = new Controller();
     $action = new Action();
     $id_modulo = $modulo->getIdModuloByCh($ch_modulo);
     $id_controller = $controller->getIdControllerByCh($ch_controller);
     $action->verificarAcao($id_modulo, $id_controller, $ch_action);
 }
コード例 #30
0
ファイル: event.php プロジェクト: yariknechyporuk/granika
 /**
  * @param string $key
  * @param array  $arg
  *
  * @return void
  */
 public function trigger($key, &$arg = array())
 {
     if (isset($this->data[$key])) {
         foreach ($this->data[$key] as $event) {
             $action = new Action($event, $arg);
             $action->execute($this->registry);
         }
     }
 }