Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/smart-sl.../Nextend/Framewor.../Model
File: Section.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Nextend\Framework\Model;
[2] Fix | Delete
[3] Fix | Delete
use Nextend\Framework\Database\AbstractPlatformConnectorTable;
[4] Fix | Delete
use Nextend\Framework\Database\Database;
[5] Fix | Delete
use Nextend\Framework\Plugin;
[6] Fix | Delete
[7] Fix | Delete
class Section {
[8] Fix | Delete
[9] Fix | Delete
/** @var AbstractPlatformConnectorTable */
[10] Fix | Delete
public static $tableSectionStorage;
[11] Fix | Delete
[12] Fix | Delete
public function __construct() {
[13] Fix | Delete
[14] Fix | Delete
self::$tableSectionStorage = Database::getTable("nextend2_section_storage");
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
public static function get($application, $section, $referenceKey = null) {
[18] Fix | Delete
$attributes = array(
[19] Fix | Delete
"application" => $application,
[20] Fix | Delete
"section" => $section
[21] Fix | Delete
);
[22] Fix | Delete
[23] Fix | Delete
if ($referenceKey !== null) {
[24] Fix | Delete
$attributes['referencekey'] = $referenceKey;
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
return self::$tableSectionStorage->findByAttributes($attributes);
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
public static function getById($id, $section = null) {
[31] Fix | Delete
static $cache = array();
[32] Fix | Delete
if ($id === 0) {
[33] Fix | Delete
return null;
[34] Fix | Delete
}
[35] Fix | Delete
if (!isset($cache[$section])) {
[36] Fix | Delete
$cache[$section] = array();
[37] Fix | Delete
} else if (isset($cache[$section][$id])) {
[38] Fix | Delete
return $cache[$section][$id];
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
$cache[$section][$id] = null;
[42] Fix | Delete
if ($section) {
[43] Fix | Delete
Plugin::doAction($section, array(
[44] Fix | Delete
$id,
[45] Fix | Delete
&$cache[$section][$id]
[46] Fix | Delete
));
[47] Fix | Delete
if ($cache[$section][$id]) {
[48] Fix | Delete
return $cache[$section][$id];
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
$cache[$section][$id] = self::$tableSectionStorage->findByAttributes(array(
[53] Fix | Delete
"id" => $id
[54] Fix | Delete
));
[55] Fix | Delete
if ($section && $cache[$section][$id]['section'] != $section) {
[56] Fix | Delete
$cache[$section][$id] = null;
[57] Fix | Delete
[58] Fix | Delete
return $cache[$section][$id];
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
return $cache[$section][$id];
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
public static function getAll($application, $section, $referenceKey = null) {
[65] Fix | Delete
$attributes = array(
[66] Fix | Delete
"application" => $application,
[67] Fix | Delete
"section" => $section
[68] Fix | Delete
);
[69] Fix | Delete
[70] Fix | Delete
if ($referenceKey !== null) {
[71] Fix | Delete
$attributes['referencekey'] = $referenceKey;
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
$rows = self::$tableSectionStorage->findAllByAttributes($attributes, array(
[75] Fix | Delete
"id",
[76] Fix | Delete
"referencekey",
[77] Fix | Delete
"value",
[78] Fix | Delete
"isSystem",
[79] Fix | Delete
"editable"
[80] Fix | Delete
));
[81] Fix | Delete
[82] Fix | Delete
Plugin::doAction($application . $section, array(
[83] Fix | Delete
$referenceKey,
[84] Fix | Delete
&$rows
[85] Fix | Delete
));
[86] Fix | Delete
[87] Fix | Delete
return $rows;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
public static function add($application, $section, $referenceKey, $value, $isSystem = 0, $editable = 1) {
[91] Fix | Delete
$row = array(
[92] Fix | Delete
"application" => $application,
[93] Fix | Delete
"section" => $section,
[94] Fix | Delete
"referencekey" => '',
[95] Fix | Delete
"value" => $value,
[96] Fix | Delete
"isSystem" => $isSystem,
[97] Fix | Delete
"editable" => $editable
[98] Fix | Delete
);
[99] Fix | Delete
[100] Fix | Delete
if ($referenceKey !== null) {
[101] Fix | Delete
$row["referencekey"] = $referenceKey;
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
self::$tableSectionStorage->insert($row);
[105] Fix | Delete
[106] Fix | Delete
return self::$tableSectionStorage->insertId();
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
[110] Fix | Delete
public static function set($application, $section, $referenceKey, $value, $isSystem = 0, $editable = 1) {
[111] Fix | Delete
[112] Fix | Delete
$result = self::getAll($application, $section, $referenceKey);
[113] Fix | Delete
[114] Fix | Delete
if (empty($result)) {
[115] Fix | Delete
return self::add($application, $section, $referenceKey, $value, $isSystem, $editable);
[116] Fix | Delete
} else {
[117] Fix | Delete
$attributes = array(
[118] Fix | Delete
"application" => $application,
[119] Fix | Delete
"section" => $section
[120] Fix | Delete
);
[121] Fix | Delete
[122] Fix | Delete
if ($referenceKey !== null) {
[123] Fix | Delete
$attributes['referencekey'] = $referenceKey;
[124] Fix | Delete
}
[125] Fix | Delete
self::$tableSectionStorage->update(array('value' => $value), $attributes);
[126] Fix | Delete
[127] Fix | Delete
return true;
[128] Fix | Delete
}
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
public static function setById($id, $value) {
[132] Fix | Delete
[133] Fix | Delete
$result = self::getById($id);
[134] Fix | Delete
[135] Fix | Delete
if ($result !== null && $result['editable']) {
[136] Fix | Delete
self::$tableSectionStorage->update(array('value' => $value), array(
[137] Fix | Delete
"id" => $id
[138] Fix | Delete
));
[139] Fix | Delete
[140] Fix | Delete
return true;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
return false;
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
public static function delete($application, $section, $referenceKey = null) {
[147] Fix | Delete
[148] Fix | Delete
$attributes = array(
[149] Fix | Delete
"application" => $application,
[150] Fix | Delete
"section" => $section,
[151] Fix | Delete
"isSystem" => 0
[152] Fix | Delete
);
[153] Fix | Delete
[154] Fix | Delete
if ($referenceKey !== null) {
[155] Fix | Delete
$attributes['referencekey'] = $referenceKey;
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
self::$tableSectionStorage->deleteByAttributes($attributes);
[159] Fix | Delete
[160] Fix | Delete
return true;
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
public static function deleteById($id) {
[164] Fix | Delete
[165] Fix | Delete
self::$tableSectionStorage->deleteByAttributes(array(
[166] Fix | Delete
"id" => $id,
[167] Fix | Delete
"isSystem" => 0
[168] Fix | Delete
));
[169] Fix | Delete
[170] Fix | Delete
return true;
[171] Fix | Delete
}
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
new Section();
[175] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function