diff --git a/wire/core/Pages.php b/wire/core/Pages.php index 43da4f20..a80cb7da 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 @@ -730,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) { @@ -796,7 +783,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 * @@ -807,8 +793,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); @@ -826,7 +811,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"); } @@ -1107,7 +1092,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}"); @@ -1383,11 +1368,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; @@ -1430,15 +1414,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 @@ -1610,7 +1586,6 @@ public function sortfields() { */ public function __get($key) { if($key == 'outputFormatting') return $this->outputFormatting; - if($key == 'cloning') return $this->cloning; return parent::__get($key); } diff --git a/wire/modules/Inputfield/InputfieldPassword.module b/wire/modules/Inputfield/InputfieldPassword.module index 8a17a363..d0733c7a 100644 --- a/wire/modules/Inputfield/InputfieldPassword.module +++ b/wire/modules/Inputfield/InputfieldPassword.module @@ -107,7 +107,7 @@ 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($name); if($f) $inputfields->remove($f); 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 .= "
"; - if($links) $out .= "$links
"; + if($links) $out .= $links; return $out; } } diff --git a/wire/modules/Process/ProcessModule/ProcessModule.module b/wire/modules/Process/ProcessModule/ProcessModule.module index 39d43dc4..66cf2ae8 100644 --- a/wire/modules/Process/ProcessModule/ProcessModule.module +++ b/wire/modules/Process/ProcessModule/ProcessModule.module @@ -1209,6 +1209,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));