URLを生成する
@param  string $table_name テーブル名
@param  string $row_id 表示する行のID値
@param  string $action actionスイッチ
@return string URL文字列
358720
public function generate_url($table_name = null, $row_id = null, $action = null){
		if( strlen( $table_name ) && !strlen( $row_id ) && $action == 'create' ){
			return @$_SERVER['SCRIPT_NAME'].'/'.$table_name.'/:create/';
		}
		if( strlen( $table_name ) && strlen( $row_id ) && strlen( $action ) ){
			return @$_SERVER['SCRIPT_NAME'].'/'.$table_name.'/'.$row_id.'/'.$action.'/';
		}
		if( strlen( $table_name ) && strlen( $row_id ) ){
			return @$_SERVER['SCRIPT_NAME'].'/'.$table_name.'/'.$row_id.'/';
		}
		if( strlen( $table_name ) ){
			return @$_SERVER['SCRIPT_NAME'].'/'.$table_name.'/';
		}
		return @$_SERVER['SCRIPT_NAME'].'/';
	}
984824
public static function render_list_table_page($page_title, $list_table)
    {
        // We pass the class to filters & actions
        $list_table_class = get_class($list_table);

        // Get stuff
        $pagenum = $list_table->get_pagenum();
        $action  = $list_table->current_action();

        if ($action) {
            check_admin_referer('bulk-posts');

            $sendback = remove_query_arg(array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer());

            // Comment this
            if (!$sendback) {
                $sendback = admin_url('admin.php?page=test-venues');
            }

            // Add the current page to the sendback URL
            $sendback = add_query_arg('paged', $pagenum, $sendback);

            // ?
            if (strpos($sendback, 'post.php') !== false) {
                $sendback = admin_url($post_new_file);
            }

            // Get the post ids to operate on
            if ('delete_all' == $doaction) {
                $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);

                if (get_post_status_object($post_status)) {
                    $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status));
                }

                $doaction = 'delete';
            } elseif (isset($_REQUEST['media'])) {
                $post_ids = $_REQUEST['media'];
            } elseif (isset($_REQUEST['ids'])) {
                $post_ids = explode(',', $_REQUEST['ids']);
            } elseif (!empty($_REQUEST['post'])) {
                $post_ids = array_map('intval', $_REQUEST['post']);
            }

            if (!isset($post_ids)) {
                wp_redirect($sendback);
                exit;
            }

            // Plugins need to do their thing here
            do_action('wporm:list_table:action', $action, $post_ids, $list_table, $list_table_class);

            // Redirect the user
            $sendback = remove_query_arg([
                'action',
                'action2',
                'tags_input',
                'post_author',
                'comment_status',
                'ping_status',
                '_status',
                'post',
                'bulk_edit',
                'post_view'
            ], $sendback);

            wp_redirect($sendback);
            exit;
        }  elseif (!empty($_REQUEST['_wp_http_referer'])) {
            wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI'])));
            exit;
        }

        $list_table->prepare_items();

        require ABSPATH . 'wp-admin/admin-header.php';
        require __DIR__ . '/../views/list-table.php';
    }
530293
private function sqlsrv_fetchrow($query_id) {
        $row = sqlsrv_fetch_array($query_id, SQLSRV_FETCH_NUMERIC);
        if ($row === false) {
            $dberr = $this->get_last_error();
            return false;
        }

        foreach ($row as $key => $value) {
            $row[$key] = ($value === ' ' || $value === NULL) ? '' : $value;
        }
        return $row;
    }
516954
public function getView(int $row, array $row_data, Linker $linker): string
    {
        $value = $this->getCellData($row_data);
        $cell_data = '<form action="'. $this->getParsedHref($row_data, $linker) .'" method="post"><input onclick="'. ($this->onclick ?: 'this.form.submit();') .'" type="radio"'. ($value ? ' checked="checked"' : '') .' name="input" class="noBorder" value="'. htmlspecialchars($value, ENT_QUOTES) .'"></form>';

        return $this->getCellView($cell_data, $row_data);
    }
609813
static function run($module_name = null, $controller_name = null, $action = null) {
        try {
            $request = self::getRequest();
            if (self::getConfig()->get('security.csrf_defender')) {
                if ($request->isPost()) {
                    $csrf_token = $request->getPost('_csrftoken');
                    if ($csrf_token != $request->getCookie('_csrftoken')) {
                        exit('CsrfToken Invalid!');
                    }
                } else {
                    if (!$request->hasCookie('_csrftoken')) {
                        setcookie('_csrftoken', \Hiano\Token\Token::generate('_csrftoken'), 0, '/');
                    }
                }
            }


            $module_name or $module_name = self::getModuleName(); // $request->getParameter('module');
            $controller_name or $controller_name = self::getControllerName(); // $request->getParameter('controller');
            $action or $action = self::getActionName(); // $request->getParameter('action');

            $app_path = realpath(HIANO_APP_PATH);
            $controller_dir = $app_path . '/Controller/';
            $view_dir = $app_path . '/View/';
            $module_main_file = $controller_dir . ucfirst($module_name) . '/main.php';
            if (file_exists($module_main_file)) {
                include $module_main_file;
            }

            $view = self::getView();

            $view->set('app', array(
                'parameter' => $request->getParameter(),
                'post' => $request->getPost(),
                'cookie' => $request->getCookie(),
                'session' => $_SESSION,
                'server' => $_SERVER,
                'csrf' => array(
                    'name' => '_csrftoken',
                    'value' => $request->getCookie('_csrftoken')
                )
            ));

            $tpl_dir = $view_dir . '/' . ucfirst($module_name) . '/' . ucfirst($controller_name);
            $view->addTemplateDir($view_dir);
            $view->addTemplateDir($tpl_dir);
            $view->setTemplate($action);


            $ctrl = self::getController($module_name, $controller_name, $request, $view);
            $filter_chain = new Filter\FilterChain(function() use ($ctrl, $view) {
                $action_ret = self::dispatchAction($ctrl, self::getActionName());
                if (is_array($action_ret)) {
                    echo json_encode($action_ret);
                } elseif (is_string($action_ret)) {
                    echo $action_ret;
                } elseif ($action_ret === TRUE or $action_ret === NULL) {
                    $view->display();
                } elseif ($action_ret === FALSE) {
                    //do nothing
                } else {
                    throw new \Exception('错误的动作返回值！');
                }
            });
            if ($filters = self::$filter) {
                $filter_count = count($filters);
                for ($i = 0; $i < $filter_count; $i++) {
                    $f = self::loadFilter($filters[$i]);
                    $filter_chain->addFilter($f);
                }
            }
            $filter_chain->execute();
        } catch (Controller\NoActionException $e) {
            self::forward404();
        } catch (Controller\NoControllerException $e) {
            self::forward404();
        } catch (Controller\NoModuleException $e) {
            self::forward404();
        } catch (\Hiano\RedirectException $e) {
            call_user_func(self::$redirect_handler, $e);
        } catch (StopException $e) {
            
        } catch (\Hiano\ErrorException $e) {
            call_user_func(self::$error_handler, $e);
        }
    }
988291
public function handleActions($topic_id, $action)
    {
        $action = Container::get('hooks')->fire('model.topic.handle_actions_start', $action, $topic_id);

        // If action=new, we redirect to the first new post (if any)
        if ($action == 'new') {
            if (!User::get()->is_guest) {
                // We need to check if this topic has been viewed recently by the user
                $tracked_topics = Track::getTrackedTopics();
                $last_viewed = isset($tracked_topics['topics'][$topic_id]) ?
                    $tracked_topics['topics'][$topic_id] : User::get()->last_visit;

                $first_new_post_id = DB::forTable('posts')
                                        ->where('topic_id', $topic_id)
                                        ->where_gt('posted', $last_viewed)
                                        ->min('id');

                $first_new_post_id = Container::get('hooks')
                    ->fire('model.topic.handle_actions_first_new', $first_new_post_id);

                if ($first_new_post_id) {
                    return Router::redirect(
                        Router::pathFor('viewPost', ['pid' => $first_new_post_id]).'#p'.$first_new_post_id
                    );
                }
            }

            // If there is no new post, we go to the last post
            $action = 'last';
        }

        // If action=last, we redirect to the last post
        if ($action == 'last') {
            $last_post_id = DB::forTable('posts')
                                ->where('topic_id', $topic_id)
                                ->max('id');

            $last_post_id = Container::get('hooks')->fire('model.topic.handle_actions_last_post', $last_post_id);

            if ($last_post_id) {
                return Router::redirect(Router::pathFor('viewPost', ['pid' => $last_post_id]).'#p'.$last_post_id);
            }
        }

        Container::get('hooks')->fire('model.topic.handle_actions', $action, $topic_id);
    }
409847
private static function processColumnsInput($table, $row_id=false) {

		//metadata
		$return = [];

		if (property_exists($table->fields, 'updated_at')) $return['updated_at'] = new DateTime;
		if (property_exists($table->fields, 'updated_by')) $return['updated_by'] = Auth::user()->id;

		if (!$row_id) {
			if (property_exists($table->fields, 'created_at')) $return['created_at'] = new DateTime;
			if (property_exists($table->fields, 'created_by')) $return['created_by'] = Auth::user()->id;
			if (property_exists($table->fields, 'precedence')) $return['precedence'] = DB::table($table->name)->max('precedence') + 1;
		}
		
		//loop through the fields
		foreach ($table->fields as $field) {
			if ($field->hidden || in_array($field->type, self::$relation_field_types)) continue;

			//always trim whitespace
			$return[$field->name] = trim(Request::input($field->name));

			//first decide whether value is null
			if ($field->type == 'checkbox') {
				
				$return[$field->name] = !empty($return[$field->name]); //checkboxes are true or false, never null
			
			} elseif ($field->type != 'slug' && empty($return[$field->name]) && ($return[$field->name] !== '0') && !$field->required) {
				
				$return[$field->name] = null;

			} else {

				if ($field->type == 'date') {
					
					$return[$field->name] = date('Y-m-d', strtotime($return[$field->name]));
					
				} elseif ($field->type == 'datetime') {
					
					$return[$field->name] = date('Y-m-d H:i:s', strtotime($return[$field->name]));
					
				} elseif ($field->type == 'image') {
	
					if ($row_id) {
						# Unset any old file associations (will get cleaned up later)
						DB::table(config('center.db.files'))
							->where('table', $table->name)
							->where('field', $field->name)
							->where('row_id', $row_id)
							->update(['row_id'=>null]);
					}
	
				} elseif ($field->type == 'phone') {
					
					$return[$field->name] = preg_replace('/[^0-9]/', '', $return[$field->name]);

				} elseif ($field->type == 'slug') {

					//determine where slug is coming from
					if (Request::input($field->name) !== null) { //Request::has() will return false on empty string
						$value = Request::input($field->name);
					} elseif (Request::has($table->fields->{$field->name}->source)) {
						$value = Request::input($table->fields->{$field->name}->source);
					} else {
						$value = date('Y-m-d');
					}
			
					//get other values to check uniqueness
					if ($row_id) {
						$uniques = DB::table($table->name)->where('id', '<>', $row_id)->lists($field->name);						
					} else {
						$uniques = DB::table($table->name)->lists($field->name);						
					}
			
					//add unique, formatted slug to the insert batch
					$return[$field->name] = Slug::make($value, $uniques);
					
				} elseif ($field->type == 'time') {
					
					$return[$field->name] = date('H:i:s', strtotime($return[$field->name]));

				}

			}
		}

		return $return;
	}
1045987
protected function col_url($row) {
        global $OUTPUT;

        // Build the link to latest run for the script
        $scripturl = new moodle_url('/admin/tool/profiling/index.php', array('script' => $row->url, 'listurl' => $row->url));
        $scriptaction = $OUTPUT->action_link($scripturl, $row->url);

        // Decide, based on $this->listurlmode which actions to show
        if ($this->listurlmode) {
            $detailsaction = '';
        } else {
            // Build link icon to script details (pix + url + actionlink)
            $detailsimg = $OUTPUT->pix_icon('t/right', get_string('profilingfocusscript', 'tool_profiling', $row->url));
            $detailsurl = new moodle_url('/admin/tool/profiling/index.php', array('listurl' => $row->url));
            $detailsaction = $OUTPUT->action_link($detailsurl, $detailsimg);
        }

        return $scriptaction . '&nbsp;' . $detailsaction;
    }
1080914
function Link($action = null) {
		$cur = Controller::curr();
		if ($cur instanceof ExternalContentPage_Controller) {
			return $cur->data()->LinkFor($this, 'view');
		}
		return ExternalContentPage_Controller::URL_STUB . '/view/' . $this->ID;
	}
776187
public function destroy($table, $row_id) {
		$table = config('center.tables.' . $table);

		# Security
		if (!isset($table->name)) {
			return redirect()->action('\LeftRight\Center\Controllers\TableController@index')->with('error', trans('center::site.table_does_not_exist'));
		}

		DB::table($table->name)->where('id', $row_id)->delete();

		return Redirect::to(Trail::last(action('\LeftRight\Center\Controllers\RowController@index', $table->name)));
	}
697514
public function getJs(string $table_id): string
    {
        ob_start();
        $this->getTreeJs();

        if (!$this->ajax_path) {
            $this->ajax_path = '?p='. P .'&do=' . P_DO;
        }

        ?>
        <script>
            var <?= $this->js_object_name ?> =
            new TableTree('<?= $table_id ?>', <?=json_encode($this->child_ids)?>, <?= json_encode($this->js_object_name, JSON_OBJECT_AS_ARRAY) ?>, '<?= $this->ajax_path ?>', <?= (int)$this->ajax ?>, <?= (int)$this->save_inner_state ?>);
        </script><?php

        return ob_get_clean();
    }
1129951
public function addRoute( $uri, $controller_action )
    {
        $routeOptions = [];
        $routeOptions["uri"] = $uri;
        $routeOptions["controller_action"] = $controller_action;

        $routeDefinition = function() use ($routeOptions) {
            return $this->_createRoute( $routeOptions );
        };

        $this->_routeDefinitions[] = $routeDefinition;
    }
731560
public function getView(int $row, array $row_data, Linker $linker): string
    {
        $linker_array = ['do' => '_accept', 'id' => $row_data['id']];
        $value = $this->getCellData($row_data);

        $cell_data = '<form action="' . $this->getParsedHref($row_data, $linker, $linker_array) . '" method="post"><input onclick="this.form.submit();" type="checkbox"' . ($value ? ' checked="checked" disabled="disabled"' : '') . ' name="input" value="1"></form>';

        return $this->getCellView($cell_data, $row_data);
    }
1065220
protected function getActionUrl($action) : string
    {
        $context = Context::getInstance();
        return $context->getUrl($context->getParameter('controller_path') . $action);
    }
85902
public static function saveImage($table_name, $field_name, $file_name, $row_id=null, $extension=null) {
		return FileController::saveImage($table_name, $field_name, $file_name, $row_id, $extension);
	}
17768
public function row(& $db_row, Pager & $pager = null, $navID = 0)
    {
        if (!empty($db_row->onetoone['_structure'])) {
            m()->cmsnav($db_row->onetoone['_structure']);
        }
        // Render field row
        return m()
            ->view('table/row/index')
            ->set($db_row, 'field')
            ->set($pager)
            ->navID($navID)
        ->output();
    }
501038
protected function overrideAction($action, $id = null) {
        $overrides = Configure::read('Admin.actionOverrides');
        $model = $this->Model->qualifiedName;

        if (empty($overrides[$model][$action])) {
            return false;
        }

        $url = (array) $overrides[$model][$action];
        $url[] = $id;

        $response = $this->requestAction($url, array(
            'autoRender' => true,
            'bare' => false,
            'return' => true,
            'override' => true,
            'data' => $this->request->data
        ));

        $this->autoRender = false;
        $this->response->body($response);

        return true;
    }