mirror of
https://github.com/processwire/processwire.git
synced 2025-08-24 23:31:01 +02:00
Fix issue processwire/processwire-issues#351 Fix Process.php setViewFile() method typo, and behavior improvements
This commit is contained in:
@@ -125,7 +125,8 @@ abstract class Process extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
* When any execute() method returns a string, it us used as the actual output.
|
* When any execute() method returns a string, it us used as the actual output.
|
||||||
* When the method returns an associative array, it is considered an array of variables
|
* When the method returns an associative array, it is considered an array of variables
|
||||||
* to send to the output view layer.
|
* to send to the output view layer. Returned array must not be empty, otherwise it cannot
|
||||||
|
* be identified as an associative array.
|
||||||
*
|
*
|
||||||
* This execute() method is called when no URL segments are present. You may have any
|
* This execute() method is called when no URL segments are present. You may have any
|
||||||
* number of execute() methods, i.e. `executeFoo()` would be called for the URL `./foo/`
|
* number of execute() methods, i.e. `executeFoo()` would be called for the URL `./foo/`
|
||||||
@@ -134,7 +135,10 @@ abstract class Process extends WireData implements Module {
|
|||||||
* @return string|array
|
* @return string|array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function ___execute() { }
|
public function ___execute() {
|
||||||
|
return ''; // if returning output directly
|
||||||
|
// return array('name' => 'value'); // if populating a view
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hookable method automatically called after execute() method has finished.
|
* Hookable method automatically called after execute() method has finished.
|
||||||
@@ -188,7 +192,7 @@ abstract class Process extends WireData implements Module {
|
|||||||
* ~~~~~
|
* ~~~~~
|
||||||
*
|
*
|
||||||
* @param string $headline
|
* @param string $headline
|
||||||
* @return this
|
* @return $this
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function ___headline($headline) {
|
public function ___headline($headline) {
|
||||||
@@ -204,7 +208,7 @@ abstract class Process extends WireData implements Module {
|
|||||||
* ~~~~~
|
* ~~~~~
|
||||||
*
|
*
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @return this
|
* @return $this
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function ___browserTitle($title) {
|
public function ___browserTitle($title) {
|
||||||
@@ -221,7 +225,7 @@ abstract class Process extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
* @param string $href URL of breadcrumb
|
* @param string $href URL of breadcrumb
|
||||||
* @param string $label Label for breadcrumb
|
* @param string $label Label for breadcrumb
|
||||||
* @return this
|
* @return $this
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function ___breadcrumb($href, $label) {
|
public function ___breadcrumb($href, $label) {
|
||||||
@@ -299,8 +303,8 @@ abstract class Process extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
* #pw-group-module-interface
|
* #pw-group-module-interface
|
||||||
*
|
*
|
||||||
* @param $fromVersion Previous version
|
* @param int|string $fromVersion Previous version
|
||||||
* @param $toVersion New version
|
* @param int|string $toVersion New version
|
||||||
* @throws WireException if upgrade fails
|
* @throws WireException if upgrade fails
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -493,10 +497,15 @@ abstract class Process extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function setViewFile($file) {
|
public function setViewFile($file) {
|
||||||
$path = $this->wire('config')->paths . $this->className();
|
if(strpos($file, '..') !== false) throw new WireException("Invalid view file (relative paths not allowed)");
|
||||||
if(strpos($file, $path) !== 0) $file = $path . ltrim($file, '/');
|
$config = $this->wire('config');
|
||||||
if(strpos($file, '..') !== false) throw new WireException("Invalid view file");
|
if(strpos($file, $config->paths->root) === 0 && is_file($file)) {
|
||||||
if(!is_file($file)) throw new WireException("View file $file does not exist");
|
// full path filename already specified, nothing to auto-determine
|
||||||
|
} else {
|
||||||
|
$path = $config->paths($this->className());
|
||||||
|
if($path && strpos($file, $path) !== 0) $file = $path . ltrim($file, '/\\');
|
||||||
|
if(!is_file($file)) throw new WireException("View file '$file' does not exist");
|
||||||
|
}
|
||||||
$this->_viewFile = $file;
|
$this->_viewFile = $file;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@@ -267,7 +267,7 @@ class ProcessController extends Wire {
|
|||||||
}
|
}
|
||||||
if(is_array($content)) {
|
if(is_array($content)) {
|
||||||
// array of returned content indicates variables to send to a view
|
// array of returned content indicates variables to send to a view
|
||||||
if(count($content)) {
|
if(count($content) || $this->process->getViewFile()) {
|
||||||
$viewFile = $this->getViewFile($this->process, $method);
|
$viewFile = $this->getViewFile($this->process, $method);
|
||||||
if($viewFile) {
|
if($viewFile) {
|
||||||
// get output from a separate view file
|
// get output from a separate view file
|
||||||
|
Reference in New Issue
Block a user