mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 09:14:58 +02:00
Various unrelated minor updates to numerous classes/files (phpdoc, typo fixes, and related)
This commit is contained in:
@@ -1213,6 +1213,18 @@ class Pagefile extends WireData {
|
|||||||
return isset($this->extras[$name]) ? $this->extras[$name] : null;
|
return isset($this->extras[$name]) ? $this->extras[$name] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures that isset() and empty() work for dynamic class properties
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __isset($key) {
|
||||||
|
if(parent::__isset($key)) return true;
|
||||||
|
return $this->get($key) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug info
|
* Debug info
|
||||||
*
|
*
|
||||||
|
@@ -235,7 +235,7 @@ class TemplateFile extends WireData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the template -- execute it and return it's output
|
* Render the template -- execute it and return its output
|
||||||
*
|
*
|
||||||
* @return string The output of the Template File
|
* @return string The output of the Template File
|
||||||
* @throws WireException if template file doesn't exist
|
* @throws WireException if template file doesn't exist
|
||||||
|
@@ -722,7 +722,7 @@ function InputfieldRepeater($) {
|
|||||||
var $deleteControl = $delete.clone(true);
|
var $deleteControl = $delete.clone(true);
|
||||||
var $collapseControl = $t.find('.toggle-icon');
|
var $collapseControl = $t.find('.toggle-icon');
|
||||||
$controls.prepend($collapseControl);
|
$controls.prepend($collapseControl);
|
||||||
if(allowSettings) {
|
if($t.closest('.InputfieldRepeater').hasClass('InputfieldRepeaterHasSettings')) { // intentionally not using allowSettings var
|
||||||
var $settingsToggle = $("<i class='fa fa-gear InputfieldRepeaterSettingsToggle ui-priority-secondary'></i>")
|
var $settingsToggle = $("<i class='fa fa-gear InputfieldRepeaterSettingsToggle ui-priority-secondary'></i>")
|
||||||
.attr('title', cfg.labels.settings);
|
.attr('title', cfg.labels.settings);
|
||||||
$controls.prepend($settingsToggle);
|
$controls.prepend($settingsToggle);
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -31,6 +31,7 @@ class RepeaterPageArray extends PageArray {
|
|||||||
public function __construct(Page $parent, Field $field) {
|
public function __construct(Page $parent, Field $field) {
|
||||||
$this->setParent($parent);
|
$this->setParent($parent);
|
||||||
$this->setField($field);
|
$this->setField($field);
|
||||||
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setParent(Page $parent) { $this->parent = $parent; }
|
public function setParent(Page $parent) { $this->parent = $parent; }
|
||||||
@@ -60,7 +61,8 @@ class RepeaterPageArray extends PageArray {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getNewItem() {
|
public function getNewItem() {
|
||||||
|
/** @var FieldtypeRepeater $fieldtype */
|
||||||
|
$fieldtype = $this->field->type;
|
||||||
$page = null;
|
$page = null;
|
||||||
$of = $this->parent->of(false);
|
$of = $this->parent->of(false);
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ class RepeaterPageArray extends PageArray {
|
|||||||
|
|
||||||
if(is_null($page)) {
|
if(is_null($page)) {
|
||||||
// no ready item available, get a new one
|
// no ready item available, get a new one
|
||||||
$page = $this->field->type->getBlankRepeaterPage($this->parent, $this->field);
|
$page = $fieldtype->getBlankRepeaterPage($this->parent, $this->field);
|
||||||
$this->add($page);
|
$this->add($page);
|
||||||
} else {
|
} else {
|
||||||
$this->trackChange('add');
|
$this->trackChange('add');
|
||||||
|
@@ -538,7 +538,7 @@ class ProcessLogger extends Process {
|
|||||||
if(ctype_digit($qty)) {
|
if(ctype_digit($qty)) {
|
||||||
$text .= "<br />" .
|
$text .= "<br />" .
|
||||||
"<span class='detail'>" .
|
"<span class='detail'>" .
|
||||||
sprintf($this->_n('Plus %d ealier duplicate ', 'Plus %d earlier duplicates', $qty), $qty) .
|
sprintf($this->_n('Plus %d earlier duplicate ', 'Plus %d earlier duplicates', $qty), $qty) .
|
||||||
"</span>";
|
"</span>";
|
||||||
} else {
|
} else {
|
||||||
// oops, restore
|
// oops, restore
|
||||||
|
@@ -22,10 +22,13 @@ function initPageEditForm() {
|
|||||||
$("#ProcessPageEdit").submit();
|
$("#ProcessPageEdit").submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
$(document).on('click', '#AddPageBtn', function() {
|
$(document).on('click', '#AddPageBtn', function() {
|
||||||
// prevent Firefox from sending two requests for same click
|
// prevent Firefox from sending two requests for same click
|
||||||
return false;
|
return false;
|
||||||
}).on('click', 'button[type=submit]', function(e) {
|
});
|
||||||
|
*/
|
||||||
|
$(document).on('click', 'button[type=submit]', function(e) {
|
||||||
// alert user when they try to save and an upload is in progress
|
// alert user when they try to save and an upload is in progress
|
||||||
if($('body').hasClass('pw-uploading')) {
|
if($('body').hasClass('pw-uploading')) {
|
||||||
return confirm($('#ProcessPageEdit').attr('data-uploading'));
|
return confirm($('#ProcessPageEdit').attr('data-uploading'));
|
||||||
|
@@ -1 +1 @@
|
|||||||
function initPageEditForm(){$("#ProcessPageEdit:not(.ProcessPageEditSingleField)").WireTabs({items:$("#ProcessPageEdit > .Inputfields > .InputfieldWrapper"),id:"PageEditTabs",skipRememberTabIDs:["ProcessPageEditDelete"]});$("#submit_delete").click(function(){if(!$("#delete_page").is(":checked")){$("#wrap_delete_page label").effect("highlight",{},500);return}$(this).before("<input type='hidden' name='submit_delete' value='1' />");$("#ProcessPageEdit").submit()});$(document).on("click","#AddPageBtn",function(){return false}).on("click","button[type=submit]",function(g){if($("body").hasClass("pw-uploading")){return confirm($("#ProcessPageEdit").attr("data-uploading"))}});if(typeof InputfieldSubmitDropdown!="undefined"){var f=$("ul.pw-button-dropdown:not(.pw-button-dropdown-init)");$("button[type=submit]").each(function(){var h=$(this);var g=h.attr("name");if(h.hasClass("pw-no-dropdown")){return}if(g.indexOf("submit")==-1||g.indexOf("_draft")>-1){return}if(g.indexOf("_save")==-1&&g.indexOf("_publish")==-1){return}InputfieldSubmitDropdown.init(h,f)})}var e=$("#_ProcessPageEditView");var b=$("#_ProcessPageEditViewDropdown");var a=e.css("color");$("#_ProcessPageEditViewDropdownToggle").css("color",a);e.click(function(){var g=e.attr("data-action");if(g=="this"||g=="new"||!g.length){return true}b.find(".page-view-action-"+g+" > a").click();return false});var d=$("#template");var c=d.val();d.on("change",function(){if($(this).val()==c){$(".pw-button-dropdown-toggle").trigger("pw-button-dropdown-on")}else{$(".pw-button-dropdown-toggle").trigger("pw-button-dropdown-off")}});$(document).on("wiretabclick",function(i,h,g){if(h.attr("id")=="ProcessPageEditDelete"){$(".InputfieldSubmit:not(#wrap_submit_delete):visible").addClass("pw-hidden-tmp").hide()}else{if(g.attr("id")=="ProcessPageEditDelete"){$(".InputfieldSubmit.pw-hidden-tmp").removeClass("pw-hidden-tmp").show()}}})};
|
function initPageEditForm(){$("#ProcessPageEdit:not(.ProcessPageEditSingleField)").WireTabs({items:$("#ProcessPageEdit > .Inputfields > .InputfieldWrapper"),id:"PageEditTabs",skipRememberTabIDs:["ProcessPageEditDelete"]});$("#submit_delete").click(function(){if(!$("#delete_page").is(":checked")){$("#wrap_delete_page label").effect("highlight",{},500);return}$(this).before("<input type='hidden' name='submit_delete' value='1' />");$("#ProcessPageEdit").submit()});$(document).on("click","button[type=submit]",function(e){if($("body").hasClass("pw-uploading")){return confirm($("#ProcessPageEdit").attr("data-uploading"))}});if(typeof InputfieldSubmitDropdown!="undefined"){var $dropdownTemplate=$("ul.pw-button-dropdown:not(.pw-button-dropdown-init)");$("button[type=submit]").each(function(){var $button=$(this);var name=$button.attr("name");if($button.hasClass("pw-no-dropdown"))return;if(name.indexOf("submit")==-1||name.indexOf("_draft")>-1)return;if(name.indexOf("_save")==-1&&name.indexOf("_publish")==-1)return;InputfieldSubmitDropdown.init($button,$dropdownTemplate)})}var $viewLink=$("#_ProcessPageEditView");var $viewMenu=$("#_ProcessPageEditViewDropdown");var color=$viewLink.css("color");$("#_ProcessPageEditViewDropdownToggle").css("color",color);$viewLink.click(function(){var action=$viewLink.attr("data-action");if(action=="this"||action=="new"||!action.length)return true;$viewMenu.find(".page-view-action-"+action+" > a").click();return false});var $template=$("#template");var templateID=$template.val();$template.on("change",function(){if($(this).val()==templateID){$(".pw-button-dropdown-toggle").trigger("pw-button-dropdown-on")}else{$(".pw-button-dropdown-toggle").trigger("pw-button-dropdown-off")}});$(document).on("wiretabclick",function(event,$newTab,$oldTab){if($newTab.attr("id")=="ProcessPageEditDelete"){$(".InputfieldSubmit:not(#wrap_submit_delete):visible").addClass("pw-hidden-tmp").hide()}else if($oldTab.attr("id")=="ProcessPageEditDelete"){$(".InputfieldSubmit.pw-hidden-tmp").removeClass("pw-hidden-tmp").show()}})}
|
@@ -13,6 +13,7 @@
|
|||||||
* @property int $created datetime created (unix timestamp)
|
* @property int $created datetime created (unix timestamp)
|
||||||
* @property int $modified datetime created (unix timestamp)
|
* @property int $modified datetime created (unix timestamp)
|
||||||
* @property int $qty quantity of times this notification has been repeated
|
* @property int $qty quantity of times this notification has been repeated
|
||||||
|
* @property array $flagNames Notification flag names
|
||||||
*
|
*
|
||||||
* data encoded vars, all optional
|
* data encoded vars, all optional
|
||||||
* ===============================
|
* ===============================
|
||||||
@@ -114,7 +115,7 @@ class Notification extends WireData {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Fluent interface methods
|
* Fluent interface methods
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -189,7 +190,7 @@ class Notification extends WireData {
|
|||||||
*
|
*
|
||||||
* @param string|int $name Flag to set
|
* @param string|int $name Flag to set
|
||||||
* @param bool $add True to add flag, false to remove
|
* @param bool $add True to add flag, false to remove
|
||||||
* @return this
|
* @return self
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function setFlag($name, $add = true) {
|
public function setFlag($name, $add = true) {
|
||||||
@@ -222,8 +223,8 @@ class Notification extends WireData {
|
|||||||
/**
|
/**
|
||||||
* Add the given flag name(s) (shortcut for setFlag)
|
* Add the given flag name(s) (shortcut for setFlag)
|
||||||
*
|
*
|
||||||
* @param $name One or more space-separated flag names
|
* @param string $name One or more space-separated flag names
|
||||||
* @return this
|
* @return self
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function addFlag($name) {
|
public function addFlag($name) {
|
||||||
@@ -233,8 +234,8 @@ class Notification extends WireData {
|
|||||||
/**
|
/**
|
||||||
* Remove the given flag name(s) (shortcut for setFlag)
|
* Remove the given flag name(s) (shortcut for setFlag)
|
||||||
*
|
*
|
||||||
* @param $name One or more space-separated flag names
|
* @param string $name One or more space-separated flag names
|
||||||
* @return this
|
* @return self
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function removeFlag($name) {
|
public function removeFlag($name) {
|
||||||
@@ -246,7 +247,7 @@ class Notification extends WireData {
|
|||||||
*
|
*
|
||||||
* @param string $names space separated string of flag names
|
* @param string $names space separated string of flag names
|
||||||
* @param bool $add True to add, false to remove
|
* @param bool $add True to add, false to remove
|
||||||
* @return $this
|
* @return self
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function setFlags($names, $add = true) {
|
public function setFlags($names, $add = true) {
|
||||||
@@ -284,7 +285,7 @@ class Notification extends WireData {
|
|||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return this
|
* @return self|Notification|WireData
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function set($key, $value) {
|
public function set($key, $value) {
|
||||||
|
@@ -25,6 +25,7 @@ class NotificationArray extends WireArray {
|
|||||||
*/
|
*/
|
||||||
public function __construct(Page $page) {
|
public function __construct(Page $page) {
|
||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +43,7 @@ class NotificationArray extends WireArray {
|
|||||||
* Add a Notification instance to this NotificationArray
|
* Add a Notification instance to this NotificationArray
|
||||||
*
|
*
|
||||||
* @param Notification $item
|
* @param Notification $item
|
||||||
* @return $this
|
* @return self|NotificationArray|WireArray
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function add($item) {
|
public function add($item) {
|
||||||
|
@@ -124,11 +124,13 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
protected function testProgressNotification() {
|
protected function testProgressNotification() {
|
||||||
|
|
||||||
$session = $this->wire('session');
|
$session = $this->wire('session');
|
||||||
|
/** @var NotificationArray $notifications */
|
||||||
$notifications = $this->wire('user')->notifications();
|
$notifications = $this->wire('user')->notifications();
|
||||||
|
|
||||||
if($this->wire('input')->get('test_progress')) {
|
if($this->wire('input')->get('test_progress')) {
|
||||||
// start new progress bar notification
|
// start new progress bar notification
|
||||||
|
|
||||||
|
/** @var Notification $notification */
|
||||||
$notification = $this->wire('user')->notifications()->message('Testing progress bar notification');
|
$notification = $this->wire('user')->notifications()->message('Testing progress bar notification');
|
||||||
$notification->progress = 0;
|
$notification->progress = 0;
|
||||||
$notification->flag('annoy');
|
$notification->flag('annoy');
|
||||||
@@ -431,6 +433,7 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
if($type == 'message') $title = sprintf($this->_n('%d new message', '%d new messages', $qty), $qty);
|
if($type == 'message') $title = sprintf($this->_n('%d new message', '%d new messages', $qty), $qty);
|
||||||
else if($type == 'warning') $title = sprintf($this->_n('%d new warning', '%d new warnings', $qty), $qty);
|
else if($type == 'warning') $title = sprintf($this->_n('%d new warning', '%d new warnings', $qty), $qty);
|
||||||
else if($type == 'error') $title = sprintf($this->_n('%d new error', '%d new errors', $qty), $qty);
|
else if($type == 'error') $title = sprintf($this->_n('%d new error', '%d new errors', $qty), $qty);
|
||||||
|
else $title = '';
|
||||||
$icon = $this->get("icon" . ucfirst($type));
|
$icon = $this->get("icon" . ucfirst($type));
|
||||||
$out .= 'Notifications._ghost({"id":"","title":"' . $title . '","icon":"' . $icon . '","flagNames":"' . $type . ' notice"});';
|
$out .= 'Notifications._ghost({"id":"","title":"' . $title . '","icon":"' . $icon . '","flagNames":"' . $type . ' notice"});';
|
||||||
}
|
}
|
||||||
@@ -476,6 +479,7 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
else if($notice instanceof NoticeError) $type = 'error';
|
else if($notice instanceof NoticeError) $type = 'error';
|
||||||
else $type = 'message';
|
else $type = 'message';
|
||||||
|
|
||||||
|
/** @var NotificationArray $notifications */
|
||||||
$notifications = $this->wire('user')->notifications();
|
$notifications = $this->wire('user')->notifications();
|
||||||
if(!$notifications) return false;
|
if(!$notifications) return false;
|
||||||
|
|
||||||
@@ -521,11 +525,15 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Adds automatic notification for every 404
|
* Adds automatic notification for every 404
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hook404(HookEvent $event) {
|
public function hook404(HookEvent $event) {
|
||||||
|
|
||||||
|
/** @var Page $page */
|
||||||
$page = $event->arguments(0);
|
$page = $event->arguments(0);
|
||||||
$url = $event->arguments(1);
|
$url = $event->arguments(1);
|
||||||
|
/** @var User $user */
|
||||||
$user = $this->getSystemUser();
|
$user = $this->getSystemUser();
|
||||||
if(!$user->id) return;
|
if(!$user->id) return;
|
||||||
|
|
||||||
@@ -542,6 +550,7 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
if(empty($referer)) $referer = "unknown";
|
if(empty($referer)) $referer = "unknown";
|
||||||
if(empty($useragent)) $useragent = "unknown";
|
if(empty($useragent)) $useragent = "unknown";
|
||||||
|
|
||||||
|
/** @var NotificationArray $notifications */
|
||||||
$notifications = $user->notifications();
|
$notifications = $user->notifications();
|
||||||
$notification = $notifications->warning(sprintf($this->_('404 occurred: %s'), $url));
|
$notification = $notifications->warning(sprintf($this->_('404 occurred: %s'), $url));
|
||||||
$notification->expires = 30;
|
$notification->expires = 30;
|
||||||
@@ -560,6 +569,8 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Creates a notifications() method with the user
|
* Creates a notifications() method with the user
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookUserNotifications(HookEvent $event) {
|
public function hookUserNotifications(HookEvent $event) {
|
||||||
$user = $event->object;
|
$user = $event->object;
|
||||||
@@ -574,10 +585,13 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Automatic notification for logins
|
* Automatic notification for logins
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookLogin(HookEvent $event) {
|
public function hookLogin(HookEvent $event) {
|
||||||
$user = $this->getSystemUser();
|
$user = $this->getSystemUser();
|
||||||
if(!$user->id) return;
|
if(!$user->id) return;
|
||||||
|
/** @var NotificationArray $notifications */
|
||||||
$notifications = $user->notifications();
|
$notifications = $user->notifications();
|
||||||
|
|
||||||
$loginUser = $event->return;
|
$loginUser = $event->return;
|
||||||
@@ -611,6 +625,7 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
$user = $this->getSystemUser();
|
$user = $this->getSystemUser();
|
||||||
if(!$user->id) return;
|
if(!$user->id) return;
|
||||||
$logoutUser = $event->arguments(0);
|
$logoutUser = $event->arguments(0);
|
||||||
|
/** @var NotificationArray $notifications */
|
||||||
$notifications = $user->notifications();
|
$notifications = $user->notifications();
|
||||||
$notifications->message(sprintf($this->_('User logged out: %s'), $logoutUser->name));
|
$notifications->message(sprintf($this->_('User logged out: %s'), $logoutUser->name));
|
||||||
$notifications->save();
|
$notifications->save();
|
||||||
@@ -619,7 +634,7 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Return the user that receives system notifications
|
* Return the user that receives system notifications
|
||||||
*
|
*
|
||||||
* @return null
|
* @return User
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getSystemUser() {
|
public function getSystemUser() {
|
||||||
@@ -708,6 +723,7 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
$times = $this->wire('cache')->get($processKey);
|
$times = $this->wire('cache')->get($processKey);
|
||||||
if($times) {
|
if($times) {
|
||||||
list($created, $modified) = explode(':', $times);
|
list($created, $modified) = explode(':', $times);
|
||||||
|
if($modified) {} // unused
|
||||||
$value = $created . ":" . time();
|
$value = $created . ":" . time();
|
||||||
} else {
|
} else {
|
||||||
$value = time() . ":" . time();
|
$value = time() . ":" . time();
|
||||||
@@ -761,6 +777,7 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
protected function checkProcessKey($processKey) {
|
protected function checkProcessKey($processKey) {
|
||||||
|
|
||||||
list($prefix, $className, $pageID, $userID, $windowName) = explode('.', $processKey);
|
list($prefix, $className, $pageID, $userID, $windowName) = explode('.', $processKey);
|
||||||
|
if($userID) {} // unused
|
||||||
|
|
||||||
// locate all currently active processKeys editing $page
|
// locate all currently active processKeys editing $page
|
||||||
$processKeys = $this->wire('cache')->get("$prefix.$className.$pageID.*");
|
$processKeys = $this->wire('cache')->get("$prefix.$className.$pageID.*");
|
||||||
@@ -774,6 +791,7 @@ class SystemNotifications extends WireData implements Module {
|
|||||||
|
|
||||||
list($created, $modified) = explode(":", $times);
|
list($created, $modified) = explode(":", $times);
|
||||||
list($_prefix, $_className, $_pageID, $_userID, $_windowName) = explode('.', $_processKey);
|
list($_prefix, $_className, $_pageID, $_userID, $_windowName) = explode('.', $_processKey);
|
||||||
|
if($modified || $_prefix || $_className || $_pageID) {} // unused
|
||||||
$recordNotify = false;
|
$recordNotify = false;
|
||||||
|
|
||||||
if($_userID == $this->wire('user')->id) {
|
if($_userID == $this->wire('user')->id) {
|
||||||
|
Reference in New Issue
Block a user