Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Php7 fixes #1927

Closed
wants to merge 8 commits into from
26 changes: 24 additions & 2 deletions web/concrete/core/libraries/attribute/view.php
Expand Up @@ -94,7 +94,7 @@ public function render($view, $return = false) {
ob_start();
}

@Loader::element(DIRNAME_ATTRIBUTES . '/' . $view . '_header', array('type' => $this->attributeType));
$this->includeHeader($view);

$js = $this->attributeType->getAttributeTypeFileURL($view . '.js');
$css = $this->attributeType->getAttributeTypeFileURL($view . '.css');
Expand Down Expand Up @@ -126,12 +126,34 @@ public function render($view, $return = false) {
include($file);
}

@Loader::element(DIRNAME_ATTRIBUTES . '/' . $view . '_footer', array('type' => $this->attributeType));
$this->includeFooter($view);

if ($return) {
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
}

/**
*
* @param $view string
*/
protected function includeHeader($view) {
if ($_file = Environment::get()->getPath(DIRNAME_ATTRIBUTES . '/' . $view . '_header.php')) {
$type = $this->attributeType;
include($_file);
}
}

/**
*
* @param $view string
*/
protected function includeFooter($view) {
if ($_file = Environment::get()->getPath(DIRNAME_ATTRIBUTES . '/' . $view . '_footer.php')) {
$type = $this->attributeType;
include($_file);
}
}
}
7 changes: 3 additions & 4 deletions web/concrete/core/libraries/loader.php
Expand Up @@ -72,24 +72,23 @@ protected static function legacyModel($model) {
/**
* @access private
*/
public function packageElement($file, $pkgHandle, $args = null) {
public static function packageElement($file, $pkgHandle, $args = null) {
self::element($file, $args, $pkgHandle);
}

/**
* Loads an element from C5 or the site
*/
public function element($_file, $args = null, $_pkgHandle= null) {
public static function element($_file, $args = null, $_pkgHandle= null) {
if (is_array($args)) {
$collisions = array_intersect(array('_file', '_pkgHandle'), array_keys($args));
if ($collisions) {
throw new Exception(t("Illegal variable name '%s' in element args.", implode(', ', $collisions)));
}
$collisions = null;
extract($args);
}

include(Environment::get()->getPath(DIRNAME_ELEMENTS . '/' . $_file . '.php', $_pkgHandle));
View::getInstance()->includeFileInScope(Environment::get()->getPath(DIRNAME_ELEMENTS . '/' . $_file . '.php', $_pkgHandle), (array) $args);
}

/**
Expand Down
17 changes: 16 additions & 1 deletion web/concrete/core/libraries/view.php
Expand Up @@ -36,7 +36,12 @@ class Concrete5_Library_View extends Object {
* @var bool
*/
protected $disableContentInclude = false;


/**
* @var string
*/
protected $viewFile;

/**
* controller used by this particular view
* @access public
Expand Down Expand Up @@ -1005,4 +1010,14 @@ public function render($view, $args = null) {
}

}

/**
*
* @param $file string Full file path as string
*/
public function includeFileInScope($file, $args = array()) {
$this->viewFile = $file;
extract($args);
include($this->viewFile);
}
}
4 changes: 2 additions & 2 deletions web/concrete/dispatcher.php
Expand Up @@ -10,9 +10,9 @@
}

if(defined("E_DEPRECATED")) {
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); // E_DEPRECATED required for php 5.3.0 because of depreciated function calls in 3rd party libs (adodb).
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_WARNING & ~E_DEPRECATED); // E_DEPRECATED required for php 5.3.0 because of depreciated function calls in 3rd party libs (adodb).
} else {
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_WARNING);
}

## Startup check ##
Expand Down