Jump to content

horst

PW-Moderators
  • Posts

    4,088
  • Joined

  • Last visited

  • Days Won

    88

Everything posted by horst

  1. EDIT: SOLVED: http://processwire.com/talk/topic/4562-module-spex-an-asset-and-template-management-module/#entry46402 I have found a solution with the Spex module, sorry for bothering here! -------------------------------------------------------------------------------------------------------------------------------------------------------- @Pete: thanks for the two columns in Admin! It's really helpfull. But also I run into a little issue with the css filename you use. It is appended a ?v=100 to it, and that seems to crash the Minify module. Haven't investigated further because I use Spex together with Minify and all is new to me. But I'm also wondering why the css of the admin backend is loaded in a front end page? Is this because I'm logged in and all styles & js of the modules get loaded automatically? complete URL to call Minify is: /site/modules/Minify/min/?f=/site/modules/AdminTemplateColumns/AdminTemplateColumns.css?v=100,/site/template/styles/main.css I don't know where the process should be tweaked (admintemplatemodules, minify, spex, pw-styles-loader) but as you have done this one and the Minify module I've thought here is a good place to ask.
  2. It doesn't work with negative numbers. They get corrected to 0 (zero) at some other points in PW, not only at Pages::setupNew()
  3. Pagetree Add New Child Reverse New Pages in Descending Sortorder (newest first) while sortmode can be "Manual Drag-n-Drop" When a site display an overview of the latest posts, news, image-albums, etc. the newest entries should be on top of the list. We can achieve that by using an automated setting for the sortfield e.g. when the page was created = "-created". But this way we are not able to manually move a single page in the tree. This module enables us to do exactly that. It works with manually created pages, with pages created via the API, also when bootstrapped by importer scripts. Pagetree "Newsitems" with 3 newsitems sorted in descending order. New created item 4 is added to the top. To change the order click item 3 and drag it to the top and drop it. How to use it Download the module into your site/modules/ directory and install it. In the config page you find a single textarea field. Here you can enter the templatename or page-ID of the page which children should get reverse added, - optionally followed by a comma and the child-templatename if you need a more precise selector. You can add as many parents as you like, but only one on each line and in this format: TEMPLATE-NAME or PAGE-ID[,CHILDTEMPLATE-NAME]. A few examples: newsitems posts,post 1042 1033,album You want set your template(s) sortfield(s) to 'Manual drag-n-drop' if not have done already. ATTENTION You need to setup the TreeParent and the module config when there are no children in it! Otherwise it will not work! Also disabling the module once you have added children and then add one new page to it will mess up all! (You may think about to install the module as permanent in critical situations.?! see below ->) If you need to install it in a site for an already existing branch, you can do it this way: move / rename your existing branch create a new (empty) branch with the original name move your childpages into the new branch remove the renamed (and now empty) old branch DOWNLOAD - Version 1.0.2 get it from the Modules Directory Want to make it bulletproof? If you are concerned that the module settings could be dropped by other users or that the module itself could be uninstalled by accident, you may edit the module file directly: add the settings to the class constant permanentValue uncomment setting for permanent in the ModuleInfo This way the permanent settings couldn't be dropped by accident. To change it you first need to edit the modules file again. Example: You have two settings in the inputfield of the modules config, without permanent setting: parenttemplate1,childtemplate1 parenttemplate2,childtemplate2 Now you want to have the the first setting become bulletproof permanent: a) you enable the setting in the getModuleInfo, (uncomment setting for permanent) b) you write your permanent settings under the constant permanentValue const permanentValue = "parenttemplate1,childtemplate1"; After both steps, the module cannot get uninstalled anymore (Step a), and the first setting cannot get deleted anymore (Step b), as it is recreated with every call of the configscreen. (See first code line of method getModuleConfigInputfields) If you want to keep both definitions permanent, write them separated with a newline character "\n" : const permanentValue = "parenttemplate1,childtemplate1\nparenttemplate2,childtemplate2"; History of origins create pages via API, how add to the top of tree? Create new child as top sibling rather than bottom? New page on top? Pin Page to Top of Page Tree? move and sort pages with the API
  4. coming back to this: I have made good progress! I do not use the htaccess file in site/assets/files/ anymore but have edited the htaccess file in pw root folder. Somewhere at top of the mod_rewrite directives I have added my lines that should redirect requests to original images to a proxy-script and let others pass through: htaccess with Pim1 and PW < 2.5.11 .htaccess with PW 2.5.11+ / PW 3+ # ----------------------------------------------------------------------------------------------- # CUSTOMSETTING : redirect original images to proxy-script - /pwimg.php?fn=... # ----------------------------------------------------------------------------------------------- RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} (^|/)site/assets/files/(.*?)/ RewriteCond %{REQUEST_FILENAME} \.(jpg|jpeg|gif|png)$ [NC] RewriteCond %{REQUEST_FILENAME} !-piacrop RewriteCond %{REQUEST_FILENAME} !-piacontain RewriteCond %{REQUEST_FILENAME} !-pim2-full RewriteCond %{REQUEST_FILENAME} !-blogthumb RewriteCond %{REQUEST_FILENAME} !.*/.*?\.([0-9]+)x([0-9]+)\.(jpg|png|jpeg|gif)$ [NC] RewriteRule ^(.*)$ pwimg.php?fn=$1 [L] Now from all existing images the originals get redirected to the proxy-script and the others will delivered directly by apache. Requests to none existing imagefiles get answered by a 404. So as everything seems to work fine, the RewriteConditions could be optimized a bit. ---- pwimg.php ---- <?php // check filename $imgFilename = isset($_GET['fn']) ? preg_replace('/[^a-zA-Z0-9_\-\/\.@]/', '', $_GET['fn']) : false; $imgFilename = is_file(dirname(__FILE__) . "/$imgFilename") && is_readable(dirname(__FILE__) . "/$imgFilename") ? dirname(__FILE__) . "/$imgFilename" : false; if (false == $imgFilename) { header('HTTP/1.1 404 Not Found'); exit(2); } // check imagetype $imgType = getImageType($imgFilename); if (false == $imgType) { header('HTTP/1.1 403 Forbidden'); header('Content-type: image/jpeg'); exit(1); } // bootstrap PW require_once(dirname(__FILE__) . '/index.php'); // check user-account if (! wire('user')->hasRole('superuser|editor')) { header('HTTP/1.1 403 Forbidden'); header('Content-type: ' . $imgType); exit(1); } // collect infos $maxAge = (60 * 60 * 2); // 2 hours $imgTimestamp = filemtime($imgFilename); $imgExpiration = intval(time() + $maxAge); // create headers $imgHeaders = array(); $imgHeaders[] = 'Content-type: ' . $imgType; $imgHeaders[] = 'Content-Length: ' . filesize($imgFilename); $imgHeaders[] = 'Date: ' . gmdate('D, d M Y H:i:s',time()) . ' GMT'; $imgHeaders[] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s',$imgTimestamp) . ' GMT'; $imgHeaders[] = 'Expires: ' . gmdate('D, d M Y H:i:s', $imgExpiration) . ' GMT'; $imgHeaders[] = 'pragma: cache'; $imgHeaders[] = "Cache-Control: no-transform, private, s-maxage={$maxAge}, max-age={$maxAge}"; // send headers foreach($imgHeaders as $imgHeader) header($imgHeader); // send file $errorCode = @readfile($imgFilename) === FALSE ? 1 : 0; // and exit exit($errorCode); // --- functions --- function getImageType($fn, $returnAsInteger = false) { $types1 = array(1 => 'gif', 2 => 'jpg', 3 => 'png'); $types2 = array('gif' => 1, 'jpg' => 2, 'jpeg' => 2, 'png' => 3); if (function_exists('exif_imagetype') && isset($types1[@exif_imagetype($fn)])) { $success = $types1[exif_imagetype($fn)]; } if (!isset($success) && function_exists('getimagesize')) { $info = @getimagesize($fn); if (isset($info[2]) && isset($types1[$info[2]])) { $success = $types1[$info[2]]; } } if (!isset($success)) { $extension = strtolower(pathinfo($fn, PATHINFO_EXTENSION)); if (isset($types2[$extension])) { $success = $types1[$types2[$extension]]; } } if (!isset($success)) return false; return true === $returnAsInteger ? $types2[$success] : $success; }
  5. Good find, Yannick!
  6. @Marty: I do this by using a module. It's a copy from somas PageListShowPageId. the PHP code is public function init() { $this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageArchivnummerLabel'); } public function addPageArchivnummerLabel($event) { $page = $event->arguments('page'); if('album'==$page->template) { //$event->return = str_pad(count($page->images), 3, '0', STR_PAD_LEFT) . " " . $event->return; $event->return = $event->return . ' <span class="jhpPageListArchivnummer">' . $page->archivnummer . '</span> ' . ' <span class="jhpPageListImageCount">' . count($page->images) . '</span>'; } } and the CSS is .content .PageListItem > a span + span.jhpPageListImageCount:before { content: 'count: ' !important; } .content .PageListItem > a span + span.jhpPageListArchivnummer:before { content: '' !important; } .content .PageListItem > a span + span.jhpPageListImageCount, .content .PageListItem > a span + span.jhpPageListArchivnummer { font-size:0.9em; background-color:#EEE; color: #777; padding: 2px 5px 1px 5px; border: medium none !important; border-radius: 3px 3px 3px 3px; }
  7. I don't like working with RTEs, especially don't use them together with images. So at least you are right: we shouldn't assume that there isn't embedded width and height in all situations.
  8. @adrian: I don't think that this could make trouble because he searches for "<img " and replaces it with "<img width='150' height='150' " This seems to be 100% robust as every html-image-tag has to begin with <img followed by at least one space
  9. Hi Nik, thanks to clarify. You may have a look into some existing modules that deal with images and textareas: http://modules.processwire.com/categories/photo-video/ for example the ImageInterceptor. Maybe you find code that preg_matches all imagelinks of textareafields. somas Images Manager also deals with textarea fields in some parts: https://github.com/somatonic/ImagesManager/blob/master/ImagesManagerParser.module And if you don't get it to work, please come back here to ask for help. To enhance the script to also support images in textareas is usefull for many other users I think. I think the new code can be go here: // ... // determine which files are valid for the page $valid = array(); foreach ($page->template->fieldgroup as $field) { if ($field->type instanceof FieldtypeTextarea) { // here comes the code to parse the content of textarea for images links that resides in assets/files/idOfCurrentPage/ // all found images must be added to the array $valid! // ... } elseif ($field->type instanceof FieldtypeFile) { // here follows the existent code for files and images fields
  10. try to wrap curly-braces { } around the width and height properties: width='{$image->width(15)->width}' If this doesn't work you may also interrupt your string and concatenate parts together like: "<img width='" . $image->width(150)->width . "' height...>" ------ As a sidenote: I also see that you use <img ...></img> tags, but I think that this isn't valid HTML. I only know <img src='' width='' ... /> this sort of images tags.
  11. Hi NikNak, I don't use images in tinyMCE textarea fields and I do not know how one can embedd them. But I know that this script deletes all images that are not belong to an page-images-field. I have read about to select images from the current page and from other pages in PW within the tinyMCE. This images belong to page-images-fields and don't get deleted. But if you can upload and embedd images only with the tinyMCE and these images resides under /site/assets/files/nnnn/ folders, I guess they are not known by pw and get deleted. To clarify: where do the images reside you are talking about and how did they get there? (sorry if I ask complicated, but I never used images with tinyMCE)
  12. If you use a image with width(150) you also have to call for that variation width and height: $changed_content = str_replace("<img ", "<img width='$image->width(150)->width' height='$image->width(150)->height' ", $changed_content);
  13. special background-color / background-transparency for collapsed fields?
  14. Hi yckart, I guess you are using the basic siteprofile that comes with PW per default. Following is the code of the home-template file. It is located under /site/templates/ and is named home.php. I have added a check for the url segment and the code you need to output a user page, whereas the original code of the home-template completly goes into the else-part: <?php /** * Home template * */ // first lets check if we have a urlSegment1 if( ! empty($input->urlSegment1) ) { // we have a url segment and want to get the page for it // we use ->get() for this, because get returns a single page, whereas ->find() returns an array of pages // but as we use the unique name of the users pages, there only can exist one page with that name $userpage = $pages->get("/users/{$input->urlSegment1}/"); // lets check if we have got a valid page // if PW hasn't found a page, it returns a nullPage and that has always a id 0 if($userpage->id == 0) { // we have no valid page, lets throw a 404 exception throw new Wire404Exception(); } else { // we have a valid page, so lets output the complete users page echo $userpage->render(); } } else { // if there is no url segment, output the homepage include("./head.inc"); echo $page->body; include("./foot.inc"); } This template will work if you use links like "/userpagename/" userpagename is the content of the namefield of your user page. If you have a page /users/foo-bar/, you can call it /foo-bar/ and it will be rendered, if you use /fooBaz/ you will be redirected to a 404 page, and if you call / you go to the homepage. But you also can access the user pages with there native urls: /users/foo-bar/. Hope that helps.
  15. Hi yckart, welcome to the forums. One approach could be using urlSegments: Depending on what template/page you are using under /ca/, you may enable "Allow URL-Segments" under Templates -> YOURcaTemplate -> URLs. - with your users pages you define urls like http://localhost/projects/ca/foo/ instead of http://localhost/projects/ca/users/foo/ - on the /ca/ page you first do a check if there is a URL-Segment ($input->urlSegment1) populated and switch to processing with /users/foo/ - if there is no $input->urlSegment1 process the request like you do it yet with /ca/
  16. EDIT: is OBSOLETE because could be done by Module http://processwire.com/talk/topic/4758-release-pagetree-add-new-childs-reverse/ ----------------------------------------------------------------------------------------------- When a site display an overview of the latest posts, news, images, etc. the newest entries should be on top of the list. We can achieve that by using an automated setting for the sortfield e.g. when the page was created = "-created". This way we are not able to manually move a single page in the tree. But there are needs for people to do that and it is asked for this multiple times here in the forums. E.g. if you display image thumbs and the last five entries don't harmonize well together, you want to move 1-3 pages down or up - but in generally you are very happy with the sortorder -created. Using a workaround like creating a sticky field and check that is very ugly IMO. It isn't reflected in the AdminPageTree and therefor not very intuitive and not very straight forward. While I have found a solution to achieve this "-sort" with importing pages via API, it would be nice to also have it with manually created pages. Viewing the source the situation seems to be that there is a real chance to allow it: sort must be enabled for using reverse sorting direction (sort and -sort) the sort field in Mysql-DB is of type signed integer, maybe negative values could be allowed to achieve that or maybe the startvalue could be between 0 and max?
      • 1
      • Like
  17. ?? Yes, if the first call in a page (template) to display all images by a smaller size than the original sizes, all smaller images must be created first. And if you have e.g. 50 images and every image to resize take 1 second you will run into a timeout after 30 seconds per default. If you want to avoid that you can use the set_time_limit($n) in the loop like I have explained in previous post. Thats one approach to not run into a script-timeout. Once the images are created the complete script will run within a second or less. But there is no drawback to use set_time_limit($n)! Soma has shown another approach, to hook into ajax-upload and do all resizes then. This way all images are allready created / cached before a page is called first time. But if you once change the dimension for the output, you have the same situation as described in the first post: all images are uploaded fine but you have to create 50+ images on the fly. (I suggest to use set_time_limit($n) in the foreach loop ) To limit max-dimensions in field-settings may be a solution in some cases, but not if you e.g. need 300px and 3000px in a site. I'm very interested in a way to do a automated scan for all needed sizes. Here are some lines of code that may be in templates and call images. (to simplify it and to focus on the most common usage, I disregard image-calls from / to other pages / templates): $imgs = $page->images; foreach($imgs as $img) { $img = $img->width < $img->height ? $img->height(600) : $img->width(600); echo "<img src='$img->url' style='width:33%;height:auto' alt='$img->description' />"; } // ... $options = array( 'upscaling' => false, 'cropping' => false, 'sharpening' => 'medium', 'quality' => 84, ); foreach($page->images as $image) { echo "\t<li><a href='{$image->size(800,800,$options)->url}'><img src='$image->width(200)->url' width='$image->width' height='$image->height' alt='$image->description' /></a></li>\n"; } // ... $imgs = $page->images; $options = array('quality'=>75,'sharpening'=>'soft','upscaling'=>true,'cropping'=>true); foreach($imgs as $img) { $options = $img->width < $img->height ? array_merge($options,array('cropping'=>'north')) : $options; // people portraits or landscape ? $img = $img->width(600,$options); echo "<img src='$img->url' style='width:33%;height:auto' alt='$img->description' />"; } And once again - if you have successfully scanned and collected all wanted sizes, this only would work if you never change the dimensions in template after the first images are uploaded to the site. Also I think this is very close to what soma allready has posted and what the OP uses with success. He only has to input the sizes manually into the module. And I think you allready guess what's my suggestion when you want to play save? Yes: call set_time_limit($n) in the loop!
  18. @phil_s: set_time_limit($n) sets the maximum amount of seconds the script may run before it get interrupted! If you set it to zero set_time_limit(0) it may run forever if your server isn't setup to avoid this. But you also don't want to have a script to run forever, because you loose control over it. Therefor it is a good choice to use it with a little amount of seconds in a loop, because it sets the max amount to live with each call again. For example, if the default php server setup for timeout is set to 30 seconds and you have 50 images to process whereas each image will take 2 seconds, your script will crash after the 15th image. BUT, if you call set_time_limit(15) within the foreach loop, all 50 images get processed and the script will run for 100 seconds, - if everything is ok. If the script run into problems with a single image and hangs, it get interuppted 15 seconds after it started to process the damaged image. Conclusion: with this approach you can exceed the default setting a script may run without loosing control.
  19. unfortunately no improvement on Win7 with FF 24. ------ And I have found at Line 147 of futura-main.css that there is missing the Arimo fontname: /*.ui-widget { font-family: Arial,Helvetica,sans-serif; font-size: 1.1em; }*/ /*.ui-widget .ui-widget { font-size: 1em; }*/ .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Arimo,Arial,Helvetica,sans-serif; /* added Arimo as first choice */ font-size: 1em; }
  20. Diogo thank's for explaning. I never have heard of that. - But the "a" is one of the points why I like Muli. ?! But also you are right, with Muli the chance to read it as a "o" is much greater than with Arimo. And at least I have the choice to modify the css-file for my personal use.
  21. with the colors=futura I find it a bit difficult to identify the hidden pages. With the setting of opacity from 0.75 to 0.5 it is much better: .content .PageList .PageListStatusHidden:not(.PageListItemOpen) > a.PageListPage { opacity: 0.5; } /* original: 0.75 */ Have I allready said that I like the new admin theme?
  22. Oh WOW! massive and high improvements and discussion here! I like the results! I want contribute a screenshot to the fonts discussion about Arimo with 0.875em on WIndows 7 etc. AND I want to promote the font Muli instead of Arimo, because allready at this stage the new admintheme is so modern that it suits better with modern font like Muli than with Arimo IMO. Also it seems to be little bit better rendered at 0.875em than Arimo (best click on imgae to view it at 100%):
  23. when I switch in images field from listview to the thumbs view and drag to reorder them, they open a modal window with big sized image after dropping. I would like to disable that. e.g. when in thumb view modal opening is disabled or only available via doubleclick! would be good solutions. Or is this behave only with my firefox 24 ?
  24. No problem! But when I want to be picky, your question was how to reach the last post. That's with the date-link. The dot or star that soma suggested is linked to the first unread post, not the last one. Also the dot-link is gone when read the whole thread, the date-link stays forever!
  25. Ok, I have good working solution I think: set the tree-parent-page sort-setting to "Manual drag-n-drop" when it is empty. (empty == has no children now!) Then with the importer script I use this code: $parent = wire('pages')->get('template=TreeParent'); // get your tree-parent-page $first = $parent->child; // get the first child $p = new Page(); ... $p->sort = (0!=$first->id) ? $first->sort -1 : 99999; $p->save(); that way I get this output with my foreach loop: 99991 :: jh2142 99992 :: jh2141 99993 :: jh2140 99994 :: jh2139 99995 :: jh2138 99996 :: jh2137 99997 :: jh2136 99998 :: jh2135 99999 :: jh2134 and after some manual changes (2134 to top, and 2142 to bottom, and 2135 above 2140) and adding one new page to it with the importer script, I get this: 99990 :: jh2143 99991 :: jh2134 99992 :: jh2141 99993 :: jh2135 99994 :: jh2140 99995 :: jh2139 99996 :: jh2138 99997 :: jh2137 99998 :: jh2136 99999 :: jh2142 You only need to set the startvalue high enough, I think. [ max can be 2.147.483.647 ]
×
×
  • Create New...