From a76e9861c510a4c89cf2070cab511ce33aa885a9 Mon Sep 17 00:00:00 2001 From: kixe Date: Tue, 14 Oct 2014 10:23:32 +0200 Subject: [PATCH 1/6] Update ProcessModule.module Made a Module which adds license and license link to the Modules Info. http://modules.proce...module-license/ but its much cleaner to put it in core https://processwire.com/talk/topic/5906-display-module-license-in-modules-directory/?p=76308 --- wire/modules/Process/ProcessModule/ProcessModule.module | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wire/modules/Process/ProcessModule/ProcessModule.module b/wire/modules/Process/ProcessModule/ProcessModule.module index b40c8fa3..6f44a514 100644 --- a/wire/modules/Process/ProcessModule/ProcessModule.module +++ b/wire/modules/Process/ProcessModule/ProcessModule.module @@ -1187,6 +1187,12 @@ class ProcessModule extends Process { $table->row(array($this->_x('Version', 'edit'), $version)); if(!empty($moduleInfo['created'])) $table->row(array($this->labels['installed_date'], wireRelativeTimeStr($moduleInfo['created']))); if(!empty($moduleInfo['author'])) $table->row(array($this->_x('Author', 'edit'), $moduleInfo['author'])); + if(!empty($moduleInfo['license'])) { + $hreflicense = ''; + if(!empty($moduleInfo['hreflicense'])) { + if(substr($moduleInfo['hreflicense'],0,7) != 'http://') $moduleInfo['hreflicense'] = str_replace($moduleName.'.module','',$filename).$moduleInfo['hreflicense']; + $hreflicense = " - ".$this->_('read more').""; + } $table->row(array($this->_x('Summary', 'edit'), $moduleInfo['summary'])); if($requirementsStr) $table->row(array($this->_x('Requires', 'edit'), $requirementsStr)); if($dependentsStr) $table->row(array($this->_x('Required By', 'edit'), $dependentsStr)); From 9d011139722d7e9012c2efcafb488f9550becf69 Mon Sep 17 00:00:00 2001 From: C-nutzer Date: Wed, 22 Oct 2014 22:26:21 +0200 Subject: [PATCH 2/6] invalid html block-elements not allowed as child of

--- wire/modules/Process/ProcessLogin/ProcessLogin.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wire/modules/Process/ProcessLogin/ProcessLogin.module b/wire/modules/Process/ProcessLogin/ProcessLogin.module index 430ac44a..fc60d0fb 100644 --- a/wire/modules/Process/ProcessLogin/ProcessLogin.module +++ b/wire/modules/Process/ProcessLogin/ProcessLogin.module @@ -176,7 +176,7 @@ class ProcessLogin extends Process { } $home = $this->pages->get("/"); $links .= "

{$home->title}
"; - if($links) $out .= "

$links

"; + if($links) $out .= $links; return $out; } } From cc5b24e9de41d4fd063051b4c91017a63446cf01 Mon Sep 17 00:00:00 2001 From: C-nutzer Date: Sun, 2 Nov 2014 07:51:02 +0100 Subject: [PATCH 3/6] update 'collapsed' is wrapped in 'visibility' use visibility to remove --- wire/modules/Inputfield/InputfieldPassword.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wire/modules/Inputfield/InputfieldPassword.module b/wire/modules/Inputfield/InputfieldPassword.module index ac2d7ee6..d0733c7a 100644 --- a/wire/modules/Inputfield/InputfieldPassword.module +++ b/wire/modules/Inputfield/InputfieldPassword.module @@ -107,9 +107,9 @@ class InputfieldPassword extends InputfieldText { */ public function ___getConfigInputfields() { $inputfields = parent::___getConfigInputfields(); - $skips = array('collapsed', 'placeholder', 'stripTags', 'pattern'); + $skips = array('visibility', 'placeholder', 'stripTags', 'pattern'); foreach($skips as $name) { - $f = $inputfields->get('collapsed'); + $f = $inputfields->get($name); if($f) $inputfields->remove($f); } return $inputfields; From 34bf0ce34eda206173cfb6c5b44d73d37fd74369 Mon Sep 17 00:00:00 2001 From: C-nutzer Date: Wed, 17 Dec 2014 12:25:20 +0100 Subject: [PATCH 4/6] Name Format Chidren Issue doesn't work as expected extend with featuresName Format Children produces unexpected results --- wire/core/Pages.php | 74 ++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/wire/core/Pages.php b/wire/core/Pages.php index 77cebfc8..458918af 100644 --- a/wire/core/Pages.php +++ b/wire/core/Pages.php @@ -717,30 +717,29 @@ public function ___setupPageName(Page $page, array $options = array()) { } $pageName = ''; - - if(strlen($format)) { - // @todo add option to auto-gen name from any page property/field - - if($format == 'title') { - if(strlen($page->title)) $pageName = $page->title; - else $pageName = $this->untitledPageName; - - } else if(!ctype_alnum($format) && !preg_match('/^[-_a-zA-Z0-9]+$/', $format)) { - // it is a date format - $pageName = date($format); - } else { - - // predefined format - $pageName = $format; - } - } else if(strlen($page->title)) { - $pageName = $page->title; +/* allows 3 types of format for name and title, which could be combined in endless variations each separated by comma + * + * - type date: if function detects # character anywhere in the string conversion: delete #, date($format) + * - type field: if string is a fieldname of the parent page conversion: value of this field + * - type string: if string doesn't fit to the 2 preceeding it will be taken as it is + * + * - all parts (separated by comma) will be composed in the order of setting + * + * + */ - } else { - // no name will be assigned + if(strlen($format)) { + $format = explode(',',$format); + foreach ($format as $autoName) { + $autoName = str_replace('#','',$autoName,$count); // could also any other reserved character + if ($count) $page->title .= date($autoName); + elseif ($page->parent()->$autoName) $page->title .= $page->parent()->$autoName; + else $page->title .= $autoName; + } + $pageName = $page->title; } - + if($pageName == $this->untitledPageName && strpos($page->name, $this->untitledPageName) === 0) { // page already has untitled name, and there's no need to re-assign the untitled name return ''; @@ -1037,7 +1036,7 @@ protected function savePageFinish(Page $page, $isNew, array $options) { } } - if($options['uncacheAll']) $this->uncacheAll(); + if($options['uncacheAll']) $this->uncacheAll($page); // determine whether the pages_access table needs to be updated so that pages->find() // operations can be access controlled. @@ -1102,6 +1101,7 @@ public function ___saveField(Page $page, $field, array $options = array()) { if($value instanceof Pagefiles || $value instanceof Pagefile) $page->filesManager()->save(); $page->trackChange($field->name); + $this->saveFieldReady($page, $field); if($field->type->savePageField($page, $field)) { $page->untrackChange($field->name); if(empty($options['quiet'])) { @@ -1114,6 +1114,7 @@ public function ___saveField(Page $page, $field, array $options = array()) { $query->execute(); } $return = true; + $this->savedField($page, $field); } else { $return = false; } @@ -1350,7 +1351,7 @@ public function ___delete(Page $page, $recursive = false, array $options = array $page->setTrackChanges(false); $page->status = Page::statusDeleted; // no need for bitwise addition here, as this page is no longer relevant $this->deleted($page); - $this->uncacheAll(); + $this->uncacheAll($page); $this->debugLog('delete', $page, true); return true; @@ -1488,10 +1489,12 @@ public function uncache(Page $page) { /** * Remove all pages from the cache. + * + * @param Page $page Optional Page that initiated the uncacheAll * */ - public function uncacheAll() { - + public function uncacheAll(Page $page = null) { + $this->pageFinder = null; unset($this->sortfields); @@ -1503,7 +1506,6 @@ public function uncacheAll() { if(!$page->numChildren) $this->uncache($page); } - $this->pageIdCache = array(); $this->pageSelectorCache = array(); @@ -1700,8 +1702,6 @@ protected function ___restored(Page $page) { } * be executed immediately after this is called. Whereas you don't necessarily know * that when before(save) is called, as an error may prevent it. * - * Note that there is no ___saved() hook because it's already provided by after(save). - * * @param Page $page The page about to be saved * @return array Optional extra data to add to pages save query. * @@ -1831,6 +1831,24 @@ protected function ___unpublishReady(Page $page) { } */ protected function ___found(PageArray $pages, array $details) { } + /** + * Hook called when Pages::saveField is going to execute + * + * @param Page $page + * @param Field $field + * + */ + protected function ___saveFieldReady(Page $page, Field $field) { } + + /** + * Hook called after Pages::saveField successfully executes + * + * @param Page $page + * @param Field $field + * + */ + protected function ___savedField(Page $page, Field $field) { } + } From da66441e4c58988c1354fe9b6f01113e93192b1f Mon Sep 17 00:00:00 2001 From: C-nutzer Date: Wed, 17 Dec 2014 12:59:42 +0100 Subject: [PATCH 5/6] update --- wire/core/Pages.php | 81 ++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 52 deletions(-) diff --git a/wire/core/Pages.php b/wire/core/Pages.php index 3532c9bf..b72e90b1 100644 --- a/wire/core/Pages.php +++ b/wire/core/Pages.php @@ -79,16 +79,6 @@ class Pages extends Wire { */ protected $config = null; - /** - * Are we currently cloning a page? - * - * This is true only when the clone() method is currently in progress. - * - * @var bool - * - */ - protected $cloning = false; - /** * Name for autogenerated page names when fields to generate name aren't populated * @@ -559,11 +549,10 @@ public function count($selectorString, array $options = array()) { * @param Page $page * @param string $reason Text containing the reason why it can't be saved (assuming it's not saveable) * @param string $fieldName Optional fieldname to limit check to. - * @param array $options Options array given to the original save method (optional) * @return bool True if saveable, False if not * */ - public function isSaveable(Page $page, &$reason, $fieldName = '', array $options = array()) { + public function isSaveable(Page $page, &$reason, $fieldName = '') { $saveable = false; $outputFormattingReason = "Call \$page->setOutputFormatting(false) before getting/setting values that will be modified and saved. "; @@ -611,9 +600,8 @@ public function isSaveable(Page $page, &$reason, $fieldName = '', array $options } } - // FAMILY CHECKS - // check for a parent change and whether it is allowed - if($saveable && $page->parentPrevious && $page->parentPrevious->id != $page->parent->id && empty($options['ignoreFamily'])) { + // check for a parent change + if($saveable && $page->parentPrevious && $page->parentPrevious->id != $page->parent->id) { // page was moved if($page->template->noMove && ($page->is(Page::statusSystem) || $page->is(Page::statusSystemID) || !$page->isTrash())) { // make sure the page's template allows moves. only move laways allowed is to the trash, unless page has system status @@ -729,29 +717,30 @@ public function ___setupPageName(Page $page, array $options = array()) { } $pageName = ''; + + if(strlen($format)) { + // @todo add option to auto-gen name from any page property/field + + if($format == 'title') { + if(strlen($page->title)) $pageName = $page->title; + else $pageName = $this->untitledPageName; + + } else if(!ctype_alnum($format) && !preg_match('/^[-_a-zA-Z0-9]+$/', $format)) { + // it is a date format + $pageName = date($format); + } else { + + // predefined format + $pageName = $format; + } -/* allows 3 types of format for name and title, which could be combined in endless variations each separated by comma - * - * - type date: if function detects # character anywhere in the string conversion: delete #, date($format) - * - type field: if string is a fieldname of the parent page conversion: value of this field - * - type string: if string doesn't fit to the 2 preceeding it will be taken as it is - * - * - all parts (separated by comma) will be composed in the order of setting - * - * - */ + } else if(strlen($page->title)) { + $pageName = $page->title; - if(strlen($format)) { - $format = explode(',',$format); - foreach ($format as $autoName) { - $autoName = str_replace('#','',$autoName,$count); // could also any other reserved character - if ($count) $page->title .= date($autoName); - elseif ($page->parent()->$autoName) $page->title .= $page->parent()->$autoName; - else $page->title .= $autoName; - } - $pageName = $page->title; + } else { + // no name will be assigned } - + if($pageName == $this->untitledPageName && strpos($page->name, $this->untitledPageName) === 0) { // page already has untitled name, and there's no need to re-assign the untitled name return ''; @@ -795,7 +784,6 @@ public function ___setupPageName(Page $page, array $options = array()) { * 'quiet' => boolean - When true, modified date and modified_users_id won't be updated (default=false) * 'adjustName' => boolean - Adjust page name to ensure it is unique within its parent (default=false) * 'forceID' => integer - use this ID instead of an auto-assigned on (new page) or current ID (existing page) - * 'ignoreFamily' => boolean - Bypass check of allowed family/parent settings when saving (default=false) * @return bool True on success, false on failure * @throws WireException * @@ -806,8 +794,7 @@ public function ___save(Page $page, $options = array()) { 'uncacheAll' => true, 'resetTrackChanges' => true, 'adjustName' => false, - 'forceID' => 0, - 'ignoreFamily' => false, + 'forceID' => 0 ); $options = array_merge($defaultOptions, $options); @@ -825,7 +812,7 @@ public function ___save(Page $page, $options = array()) { $isNew = $page->isNew(); if($isNew) $this->setupNew($page); - if(!$this->isSaveable($page, $reason, '', $options)) { + if(!$this->isSaveable($page, $reason)) { if($language) $user->language = $language; throw new WireException("Can't save page {$page->id}: {$page->path}: $reason"); } @@ -1106,7 +1093,7 @@ public function ___saveField(Page $page, $field, array $options = array()) { $reason = ''; if($page->isNew()) throw new WireException("Can't save field from a new page - please save the entire page first"); - if(!$this->isSaveable($page, $reason, $field, $options)) throw new WireException("Can't save field from page {$page->id}: {$page->path}: $reason"); + if(!$this->isSaveable($page, $reason, $field)) throw new WireException("Can't save field from page {$page->id}: {$page->path}: $reason"); if($field && (is_string($field) || is_int($field))) $field = $this->fuel('fields')->get($field); if(!$field instanceof Field) throw new WireException("Unknown field supplied to saveField for page {$page->id}"); if(!$page->fields->has($field)) throw new WireException("Page {$page->id} does not have field {$field->name}"); @@ -1382,11 +1369,10 @@ public function ___delete(Page $page, $recursive = false, array $options = array * - forceID (int): force a specific ID * - set (array): Array of properties to set to the clone (you can also do this later) * @return Page the newly cloned page or a NullPage() with id=0 if unsuccessful. - * @throws WireException|Exception on fatal error * */ public function ___clone(Page $page, Page $parent = null, $recursive = true, $options = array()) { - + // if parent is not changing, we have to modify name now if(is_null($parent)) { $parent = $page->parent; @@ -1429,15 +1415,7 @@ public function ___clone(Page $page, Page $parent = null, $recursive = true, $op $o = $copy->outputFormatting; $copy->setOutputFormatting(false); $this->cloneReady($page, $copy); - try { - $this->cloning = true; - $options['ignoreFamily'] = true; // skip family checks during clone - $this->save($copy, $options); - } catch(Exception $e) { - $this->cloning = false; - throw $e; - } - $this->cloning = false; + $this->save($copy, $options); $copy->setOutputFormatting($o); // check to make sure the clone has worked so far @@ -1609,7 +1587,6 @@ public function sortfields() { */ public function __get($key) { if($key == 'outputFormatting') return $this->outputFormatting; - if($key == 'cloning') return $this->cloning; return parent::__get($key); } From dfc561196032609e724ef7f32a8b65dca1d09915 Mon Sep 17 00:00:00 2001 From: C-nutzer Date: Wed, 17 Dec 2014 13:00:41 +0100 Subject: [PATCH 6/6] Name Format Chidren --- wire/core/Pages.php | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/wire/core/Pages.php b/wire/core/Pages.php index b72e90b1..a80cb7da 100644 --- a/wire/core/Pages.php +++ b/wire/core/Pages.php @@ -718,27 +718,26 @@ public function ___setupPageName(Page $page, array $options = array()) { $pageName = ''; - if(strlen($format)) { - // @todo add option to auto-gen name from any page property/field - - if($format == 'title') { - if(strlen($page->title)) $pageName = $page->title; - else $pageName = $this->untitledPageName; - - } else if(!ctype_alnum($format) && !preg_match('/^[-_a-zA-Z0-9]+$/', $format)) { - // it is a date format - $pageName = date($format); - } else { - - // predefined format - $pageName = $format; - } - - } else if(strlen($page->title)) { - $pageName = $page->title; +/* allows 3 types of format for name and title, which could be combined in endless variations each separated by comma + * + * - type date: if function detects # character anywhere in the string conversion: delete #, date($format) + * - type field: if string is a fieldname of the parent page conversion: value of this field + * - type string: if string doesn't fit to the 2 preceeding it will be taken as it is + * + * - all parts (separated by comma) will be composed in the order of setting + * + * + */ - } else { - // no name will be assigned + if(strlen($format)) { + $format = explode(',',$format); + foreach ($format as $autoName) { + $autoName = str_replace('#','',$autoName,$count); // could also any other reserved character + if ($count) $page->title .= date($autoName); + elseif ($page->parent()->$autoName) $page->title .= $page->parent()->$autoName; + else $page->title .= $autoName; + } + $pageName = $page->title; } if($pageName == $this->untitledPageName && strpos($page->name, $this->untitledPageName) === 0) {