Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/11/2013 in all areas

  1. Little update on dev branch: The default admin theme now comes with an autocomplete search. If you are superuser, it will include templates, fields and users in the search as well. Once 2.4 goes stable, I'll assist with implementing this in other admin themes too.
    16 points
  2. The Organization of American Historians just converted its website to Processwire: http://www.oah.org/ Founded in 1907 and with its headquarters located in Bloomington, Indiana, the OAH is the largest professional society dedicated to the teaching and study of American history. — Michael Regoli, OAH
    7 points
  3. Font Awesome Page Label (almost stable version) Yet another PageListLabel module, why? Font Awesome is really awesome, hundreds of high quality icons, ready to use. (Don't we all know how cool icon fonts are.) I wished to use icons in conjunction with the other PageList modules out there. (Page List Better Labels, Page List Image Label & Page List Show Page Id ) I wanted the possibility to style the icons individually with CSS. Showing icons triggered bij template name, but can be overruled bij Page ID. (Trash Page, 404 Page not found etc.) I wanted a better file or folder indication in the PageList tree. Download: github modules directory
    6 points
  4. Any of those methods is valid. The only thing that you are doing wrong, either for readability or performance, is getting the page lot's of times "$pages->get($taskId)". So, if I would change your first block of code it would look like this: $taskId = (int) $input->post->task[$checked_player]; // extra tip. The (int) makes sure you get an integer $myPage = $pages->get($taskId); // get the page only once if ( $myPage->id ) { // if page exists // Get the task bonuses $task = $myPage->title; $new_XP = $myPage->XP; $new_HP = $myPage->HP; $new_GC = $myPage->GC; // Do the math $player->XP = $player->XP + $new_XP; $player->HP = $player->HP + $new_HP; $player->GC = $player->GC + $new_GC; } Or, and maybe now it makes more sense: $taskId = (int) $input->post->task[$checked_player]; $myPage = $pages->get($taskId); if ( $myPage->id ) { // Get the task bonuses $task = $myPage->title; // <- do you need this here? // Do the math $player->XP = $player->XP + $myPage->XP; $player->HP = $player->HP + $myPage->HP; $player->GC = $player->GC + $myPage->GC; } Edit: I left this in the "getting started" forum because you have some PW specific issues there.
    5 points
  5. Hey, I've got a new Avatar, too And I wear kind of a beard! (if you can call it a beard when you're 17 years old )
    4 points
  6. Your're looking at the page tree of ProcessWire. It represents the structure you also see on the page itself. As you mentioned, the first Page (/) with the house icon is the start site. You can't delete this page, because everything within PW is a child of this (even the admin pages itself). In the default installation, this page has the template "home". You could change this but you don't have to (and also it will cause trouble with permissions...). In the PW admin, go to Setup->Templates to change the fields of the home template. Open Setup->Fields to edit or add new fields you want to use in the home template. We can find the template file for home under the template directory in the PW installation path: /site/templates/home.php . Open it and you will see the markup for the start page. As in the tutorials, you can change everything here and build your own customized start page. Basically, you just overwrite the default home template with your own fields and templatefile. You could try to just download the blank profile and instead of installing a fresh PW, just replace the content of the site/templates folder. After that, you can delete all example pages from the admin and customize the home template.
    4 points
  7. Nice addition! Sometimes I got a feeling there are multiple Ryans. Some might have travelled form other dimensions. Thanks again for the continuous development of great additions.
    3 points
  8. It's urlSegmentsStr or urlSegmentStr (typo)
    3 points
  9. I made you one like mine based on your picture
    2 points
  10. Avatars are for ugly people.
    2 points
  11. At least he hasx a avatar.
    2 points
  12. Martijn, you are 3 months late
    2 points
  13. try $input->urlSegmentsStr $input->urlSegmentStr #280 WireInput.php
    2 points
  14. It's not like that PW need to step through a forest to look for tree with a number on it. It has google earth showing it with a bubble "here I am".
    2 points
  15. Try removing baseUrl from your renderPager options array. If you set it to an empty string, as you currently have, it will ignore your URL segments. The documentation says the default is "blank", which could lead one to believe it means an empty string or null. I quickly peeked under the hood of the module, and it seems the default is not really empty/blank; rather, it seems to detect the full current page URL including segements, so you can just omit it completely in the options.
    2 points
  16. Menu Builder As of 29 December 2017 ProcessWire versions earlier than 3.x are not supported Modules Directory Project Page Read Me (How to install, use, etc..) For highly customisable menus, please see this post. If you want a navigation that mirrors your ProcessWire page tree, the system allows you to easily create recursive menus using either vanilla PHP or Soma's great MarkupSimpleNavigation. In some cases, however, you may wish to create menus that: 1. Do not mirror you site's page tree (hirarchies and ancestry); and 2. You can add custom links (external to your site) to. That is primarily where Menu Builder comes in. It is also helpful if you: 3. Prefer creating menus via drag and drop 4. Have a need for menus (or other listings) that will be changing regularly or that you want to allow your admin users to edit. The issue of custom menus is not new here in the forums. The difference is that this module allows you to easily create such menus via drag and drop in the Admin. Actually, you can even use it to just create some list if you wanted to. In the backend, the module uses the jQueryUI plugin nestedSortable by Manuele J Sarfatti for the drag and drop and is inspired in part by the WP Custom Menu feature. Please read the Read Me completely before using this module. For Complex or highly-customised menus, it is recommended to use the getMenuItems() method as detailed in this post. Features Ability to create menus that do not mirror your ProcessWire Page Tree hierarchy/structure Menus can contain both ProcessWire pages and custom links Create menu hierarchies and nesting via drag and drop Easily add CSS IDs and Classes to each menu item on creating the menu items (both custom and from ProcessWire pages) or post creation. Optionally set custom links to open in a new tab Change menu item titles built from ProcessWire pages (without affecting the original page). E.g. if you have a page titled 'About Us' but you want the menu item title to be 'About' Readily view the structure and settings for each menu item Menus stored as pages (note: just the menu, not the items!) Menu items stored as JSON in a field in the menu pages (empty values not stored) Add menu items from ProcessWire pages using page fields (option to choose between PageAutocomplete and AsmSelect [default]) or a Selector (e.g. template=basic-page, limit=20, sort=title). For page fields, you can specify a selector to return only those specified pages for selection in the page field (i.e. asm and autocomplete) For superusers, optionally allow markup in your menu titles, e.g. <span>About</span> Menu settings for nestedSortable - e.g. maxLevels (limit nesting levels) Advanced features (e.g. add pages via selector, menu settings) currently permissible to superadmins only (may change to be permission-based) Delete single or all menu items without deleting the menu itself Lock down menus for editing Highly configurable MarkupMenuBuilder - e.g. can pass menu id, title, name or array to render(); Passing an array means you can conditionally manipulate it before rendering, e.g. make certain menu branches visible only to certain users [the code is up to you!] Optionally grab menu items only (as a Menu object WireArray or a normal array) and use your own code to create custom highly complex menus to meet any need. More... In the backend, ProcessMenuBuilder does the menu creation. For the frontend, menus are displayed using MarkupMenuBuilder. Credits In this module's infancy (way back!), I wanted to know more about ProcessWire modules as well as improve my PHP skills. As they say, what better way to learn than to actually create something? So, I developed this module (instead of writing PW tutorials as promised, tsk, tsk, naughty, naughty!) in my own summer of code . Props to Wanze, Soma, Pete, Antti and Ryan whose modules I studied (read copied ) to help in my module development and to Teppo for his wonderful write-up on the "Anatomy of fields in ProcessWire" that vastly improved my knowledge and understanding of how PW works. Diogo and marcus for idea about using pages (rather than a custom db table), onjegolders for his helpful UI comments, Martijn Geerts, OrganizedFellow, dazzyweb and Mike Anthony for 'pushing me' to complete this module and netcarver for help with the code. Screens
    1 point
  17. I open this topic because in another one (http://processwire.com/talk/topic/1732-shop-for-processwire-apeisa/) there was a discussion going on that -in my point of view- went off-topic. Here's what it's all about: Say you want to create a module that needs some additional scripts/stylesheets what is the best way to accomplish that? Right now I only know three ways (which all have their weaknesses): First: Just edit the head.inc and include those scripts in the head-tag. OK, this is pretty easy but it has two drawbacks: - The scripts are now on every page (in the front-end) - You have to edit the head.inc* Second: Include <?php foreach($config->scripts->unique() as $file) echo "\n\t<script type='text/javascript' src='$file'></script>"; ?> in your head.inc and add the scripts from your module with $this->config->scripts->add($this->config->urls->PaymentExample . "script.js"); This seems pretty neat because the scripts will only be included where they are needed, but: - It is not very flexible. What about in-site scripts? - You have to edit the head.inc* Third: Use the hooking- mechanism of PW by adding $this->addHookAfter('Page::render', $this, 'addScripts'); to the init- function of your module. This is the addScripts function: public function addScripts($event) { $page = $event->object; // don't add this to the admin pages if($page->template == 'admin') return; //other mechanisms to ensure the script only loads when this module was called in the front-end $additionalHeadScripts = '[myScripts...]'; $event->return = str_replace("</head>", $additionalHeadScripts.'</head>', $event->return); } Of course this approach also has its drawbacks: - It is a bit difficult - It probably makes your PW installation run a bit slower because the addScripts- Methods gets called on every page request. *Why is it a bad thing to edit the head.inc to provide scripts/stylesheets for your module? I personally think if you want to distribute a module the admin that wants to integrate this module should just hit the install button and do some configurations and that's it. This is called usability and I believe in it. In my opinion it is not user/admin friendly if you have to pack a readme file to the module that says "but first you have to alter your template file to make that module work"... That said, if <?php foreach($config->scripts->unique() as $file) echo "\n\t<script type='text/javascript' src='$file'></script>"; ?> was already in the default template head.inc file I would not hesitate one second to use the second approach for my module. Because if an admin creates his/her own template and it is not based on the default template it's his/her fault... So, what do you think? Which is the best approach for you and why? Or do you have another approach? Maybe it would also be a good thing if there was something in the API that we could use for this need. A more standardized approach?
    1 point
  18. Awhile back, I made an Ajax API for querying pages in the admin via the ProcessPageSearch module. It is used by [for example] the PageAutocomplete Inputfield. I thought this capability would be useful on the front-end too, so this module brings it to the front-end as a page in your site that you can put wherever you want to. The way you use it is exactly the same as the one in ProcessPageSearch, but this one is a little more strict, given that it's publicly available on the front-end. By "more strict" I mean that you have to define what you want to allow in terms of input and output in the module's configuration. The web service takes it's query from GET variables in the URL and returns results in JSON format. It installs a page called /service-pages/ in your site, and you are welcome to move that page wherever you want. Here is the official page at modules.processwire.com: http://modules.processwire.com/modules/service-pages/ Once installed, you should view the /service-pages/ page that it installs because it outputs detailed instructions and examples on how to use it in your own projects. But here's a few excerpts from what you'll find on that instructions page: Input The /service-pages/ page can be queried with GET variables in the URL to return JSON-format results. The query string should follow a ProcessWire selector format ([field][operator][value]), but modified a bit for use in a URL query string. Here are a few format examples: Specify a single value: ?field=value Specify multiple fields and values to match: ?field1=value1&field2=value2&field3=value3 Specify multiple fields where at least one must match the value. Note use of "," rather than "|", something we had to settle for to make it work as a URL key: ?field1,field2,field3=value Specify one field with multiple possible values (it's fine to use "|" as a separator here): ?field=value1|value2|value3 Note that unlike regular ProcessWire selectors, multiple field=value sets are split with an ampersand "&" rather than a comma ",". Allowed Values The allowed values for field are set with the module configuration. You may also specify the following modifier keyword=value pairs: sort=[field] (Specify field name to sort results by) debug=1 (Enables debug mode producing human readable output) limit=[n] (Specify the max number of pages to return) start=[n] (Specify the result number to start with) include=hidden (Include pages that are 'hidden') Allowed operators The operator demonstrated by the "=" sign in the examples above may be replaced with any of the following operators in the query string: = Equal to != Not equal to < Less than > Greater than <= Less than or equal to >= Greater than or equal to *= Contains the exact word or phrase ~= Contains all the words %= Contains the exact word or phrase (using slower SQL LIKE) ^= Contains the exact word or phrase at the beginning of the field $= Contains the exact word or phrase at the end of the field As an example, this ProcessWire selector: template=property, body*=luxury, bedrooms>5, bathrooms<=3 ...would be specified as a query string to this web service like this: ?template=property&body*=luxury&bedrooms>5&bathrooms<=3 Allowed templates For security, the search will only be performed on pages using templates that are defined in the module's configuration. Output The returned value is a JSON format string in the following format (populated with example values): { selector: "title*=something, template=basic-page, limit=50", total: 2, limit: 50, start: 0, matches: [ { id: 1002, parent_id: 4525, template: "basic-page", path: "/test/hello/", name: "hello" }, { id: 1005, parent_id: 4525, template: "basic-page", path: "/test/contact/", name: "Contact Us" } ] } Each of the 'matches' values will also include all the fields you have specified to appear with the ServicePages module configuration. If an error in the query prevented it from being performed, a JSON string in this format will be returned: { errors: [ "Error message 1", "Error message 2 (if there was one)", "And so on..." ] } The web service honors user view permissions. As a result, if you are accessing this service from a superuser account, you are likely to get pages that others users may not see. Superusers get an "include=all" automatically, unless you override it with an "include=hidden". Returned field values The following field values will be returned for all matched pages: id (integer) parent_id (integer) template (string) path (string) name (string) Any other fields may be included from the module's configuration screen. Pagination To paginate, simplify add a "page[n]" url segment to the request URL, i.e. /service-pages/page2/?template=basic-page&sort=name
    1 point
  19. Making a multilingual site with an extranet, very snappy with Processwire. http://www.goer.fi/ design by Nordenswan & Siirilä http://www.nordenswansiirila.fi/ -- Mikael
    1 point
  20. A responsive and minimalist photographer portfolio. http://mikael.siirila.net/ (and if you like the photos, follow me at http://www.facebook.com/mikaelsiirila/) -- Mikael
    1 point
  21. @apeisa Nothing to worry about... I'm now also already 27 and also don't have much of a beard Let's see the good side: You don't have to shave that often
    1 point
  22. Well.. My photo was about 10 years old already, so changed to more recent one. I try to grow beard too, but for some reason my beard has been pretty same since teenage... promising start, but nothing to be proud at this age.
    1 point
  23. Hi, this my first site I built with ProcessWire. It's not hyper complex and it has its flaws I know =) http://www.kuban.de I should mention that PW is not running on the server but rather a static HTML output I generated from my local install. I am still managing any changes through PW and then generate the output again. I used Sitesucker for that (it's a Mac tool similar to httrack). This method is discussed here. Modules used: FieldtypeCropImage MarkupCustomPageList ModulesManager ProcessBatcher ProcessPageDelete
    1 point
  24. Thanks to Diogo I met my avatar.
    1 point
  25. Moved some posts that where polluting this one (also my fault ) http://processwire.com/talk/topic/4479-avatar-for-pwired/. Sorry for that Manaus.
    1 point
  26. Is it... can it be.. our Diogo?
    1 point
  27. I know a woman Ana Russo, with a son Diogo. She's livin in Lisbon. She's special & her son was very smart considered his age (at that time). Havent seen her in years !
    1 point
  28. My parents did You erased your previous comment, but now it's too late edit: now you put your comment back there and erased what you wrote after. Makes my post seem a bit schizophrenic
    1 point
  29. Excellent information. I too have just successfully installed Processwire on Windows Server 2008 running IIS 7. Thanks to everybody posting on this page. Extra information from my situation in case somebody else is running into similar issues. I had never even heard of this CMS until I was told I needed to install it to host a web site for a subsidiary. I had previously installed PHP and MySQL on the system and really didn't feel like installing Apache if I didn't need to do so. I took a leap of faith after reading on the Requirements page that "A user has reported that that were able to install ProcessWire on IIS 7 in Windows 7." Issues and Resolutions Rename /site-default to /site The files you download for Processwire include the folder "site-default", just rename the folder as requested. I was looking to see how IIS interpreted the default web site and was confused immediately. It's a real simple request when you know what it means. Error 500 reported within the browser Immediately I got the 500 error in the browser. That didn't mean much to me so I executed the PHP script from command line. Open a command prompt and navigate to the directory in which you are installing Processwire type full path to php.exe or php-cgi.exe and then install.php e.g. C:\myphpfolder\php.exe install.php This will report the error generated in the script and not just the generic 500 error. In my case PW could not find MySQL on the host. Error 2002 No such host is known (Database connection error) I did a bunch of searching for this. The error actually occurred in the /wire/core/ProcessWire.php file. In review of the code I realized it was parsing the page location to find the "localhost" name. In my case I was not using the default website and I had another name not recognized by (I assume) the hosts file (C:\Windows\System32\drivers\etc). After thinking about it now, I could have probably added the name I had in the hosts file. My resolution was to "Add Application" within the Default Website in IIS pointing to the install location. Now localhost is a valid host name and MySQL could be located. Error 404 file or folder The Processwire home page was fine, but no sub-directory calls worked. That's when I found this post. I took nikola's suggestion: "Download URL Rewrite Module 2.0 for IIS from http://www.iis.net/download/urlrewrite and install it" I downloaded the web.config file he provided and placed it in the Processwire root I removed the <add sequence="module" /> entry as stated by jamestflynn Then finally incorporated the suggestions by zlojkashtan as I understood why that would be important The default site is running. The URL rewrites are working. You guys are awesome.
    1 point
  30. For those working with pagination and several urlSegments. This seems to be pretty bulletproof: $currentUrl = $page->url.$input->urlSegmentsStr."/"; $pagination = $results->renderPager(array('baseUrl' => $currentUrl));
    1 point
  31. If the module needs JS/CSS in the frontend (e.g. in templates), I don't see any solution other than let the dev add those scripts himself or using the Page::render hook, assuming that the module is autoload. Why? Because the module creator can't know your template structure. There are lots of different approaches, using a head.inc file is just one of them. Adding the scripts/styles to the config arrays will only work if those arrays are used to output the scripts in the templates. This is because Pw does not force you how to generate the markup, it's pure freedom
    1 point
  32. COMING FROM MODX Link1: You've been using MODX but now you've found ProcessWire. It’s totally amazed you and you can’t wait to get started. But…you are wondering where everything is. If this is you, read on… http://processwire.c...ning-from-modx/ Link2: A MODX refugee: questions on features of ProcessWire http://processwire.c...of-processwire/ Link3: Code comparison between modx and processwire. http://processwire.c...ge-2#entry30349 More here: http://processwire.com/talk/topic/4173-grouped-forum-posts-links-articles-tutorials-code-snippets/
    1 point
  33. @vxda: and of course, for resizing you don't need the Pageimage Manipulator. It is enough to call ->width() on a pageimage: // example $pageimage = $myNewsItem->images->first->width(313)->url; But also your variable names are a bit confusing: your variable $pageimage contains only the URL. I would change this to avoid confusion: // example $pageimage = $myNewsItem->images->first->width(313); // and then $out .= "<img src='{$pageimage->url}' alt='' />"; References on how to work with images: http://processwire.com/api/fieldtypes/images/ http://processwire.com/tutorials/quick-start/images/ http://processwire.com/talk/topic/10-how-do-i-interact-with-the-image-field-in-processwire/
    1 point
  34. On this line you are overriding the array news, by assigning the individual item to it. Change one of those variables to something different. Don't forget to change all occurrences of it.
    1 point
  35. While creating my own payment module I made an interesting discovery: It is not possible to add a page render hook to the payment module because it will result in an internal server error (500). Checking the error log: Error: Call to a member function getModuleConfigData() on a non-object (line 14 of [...]\site\modules\Shop-for-ProcessWire-master\PaymentAbstract.php) [edit:] The problem is if you want the page render hook to work you have to set autoload to true. This results loading the module with every page requests. As soon as PW loads the custom payment module it also loads PaymentAbstract because the custom payment module inherits from PaymentAbstract. So the PaymentAbstract constructor gets called but because it is in the wrong context (because maybe the user is request a page from the backend or so) some objects are missing... [edit-end] So I altered the PaymentAbstract.php constructor checking first if $this->modules exists: if($this->modules) { $data = $this->modules->getModuleConfigData('ShoppingCheckout'); if (!isset($data['completedUrlSegment'])) { $module = $this->modules->get('ShoppingCheckout'); $data = $module::getDefaultData(); } $page = $this->page; $this->currentUrl = $page->url . $data['paymentUrlSegment'] . '/'; $this->completedUrl = $page->url . $data['completedUrlSegment'] . '/'; } I'm not sure if this is the best solution but it works for me. @apeisa: If you think this is a good solution it might be a good idea to fix it in the github as well...
    1 point
  36. The first one. Keep in mind that getting pages by ID if difficult to read. (needs comments most of the time) If it are your own pages & the page is deleted, your script won't work anymore.
    1 point
  37. Pushed partial compatibility with 2.3.4, almost finished, also addressed most of your concerns I think. Thanks Manfred. EDIT: Should be fully compatible now with some additional improvements.
    1 point
  38. Based on the information: yes and yes. If you can't (or are not willing to) pull it off alone you can post it on the jobboard. An intranet can be so many things, so we have to know a little bit more.
    1 point
  39. Awesome job Adrian! I can't wait to use this one. I'd be using it right now if I weren't holding a baby in one arm and typing with the other. But I did browse the code and thought it looked great.
    1 point
  40. It seems to me that whoever created that database in the first place is trying to be too atomic (http://en.wikipedia.org/wiki/Atomicity_(database_systems)). You could replace all the fields containing eg. with something like Ryan's Google Map Marker fieldtype (http://modules.processwire.com/modules/fieldtype-map-marker/), such that room description (Master Bedroom) and the 2 dimensions are contained in one fieldtype, being reused for the different rooms. I think this might reduce the number of different fields required.
    1 point
  41. There's a fair percentage of the population up here who are climbers. While I don't count myself as one of them I'm happy to photograph the mad bastards : http://martywalker.com.au/blue-mountains/blackheath/climber/
    1 point
  42. my problem was solved only with the abobe code take a look at this snippet at the end of the page, in his mail $header he adds .'Content-Type: text/plain; charset=utf-8'."\r\n"; see the link below http://ncona.com/2011/06/using-utf-8-characters-on-an-e-mail-subject/
    1 point
  43. Adrian, it looks to me like you've done a beautiful job coding and documenting this module–nice work! I really like what I see here. I had once starting building a phone Fieldtype and gave up after discovering the crazy number of formats out there. So lots of respect to you for sticking with it and producing something complete and very well done here. Here are my only suggestions (minor): It might be nice to add a __toString() method to your Phone class, so when someone does "echo $page->phone"; they get a formatted (default) string. I'm thinking the country and extension inputs may not be applicable to all potential users–maybe there could be a way to turn them off? Related to input again, it's a little unusual (in my locale) to split out the components of phone numbers into separate fields. Though the coder side of me likes that you've done that here. But wonder if there might be some alternate input option that lets you populate it in one field and have a processInput that separates it out into the parts with a preg_split('/[^\d]/', $phone) or something.
    1 point
  44. You only need curly braces when using variables inside strings, like here "<li><a$class href='{$child->url}'>{$child->title}</a></li>". In your second case you only use PHP when giving the value to the variable, there's no string so you don't have to use curly braces. edit: also, using the curly braces, even if only for a simple variable "I had {$number} coffees today", makes it more readable.
    1 point
  45. Curly brackets are a PHP thing, not specifically PW. This is an example I am using right now. I am in a foreach loop which is "$data as $np". $np contains a "page_template" item. I want to get the template from the $templates variable that matches the name returned by $np->page_template. If I didn't have the curlies, it would treat $np and page_template separately and wouldn't work. I think basically you can say that the curly brackets evaluate what is inside first. $templates->{$np->page_template} That is a terribly worded explanation, but hopefully it makes some sense
    1 point
  46. @Ryan: I have send a pull request for the imageSizer because Roope has found an issue and I have found one some too. Also I have added linearized gamma workflow to get better / brighter results. (more about gamma errors in picture scaling). I have setup a local page for testing the results of different resizes with different options. Also a check if transparency with gif and png is respected. This will be useful with further testing ( Screenshot ) EDIT: @Ryan, meanwhile I have rewritten the ___resize method and it seems to work very well with all kinds of image dimensions: http://nogajski.de/priv/postings/rearrangedImageSizer.html should I commit this to the previous opened pull request? I have three parts put into separate methods: prepareImageLayer writeIPTC getCropDimensions and thats the rewritten ___resize method: /** * Resize the image proportionally to the given width/height * * Note: Some code used in this method is adapted from code found in comments at php.net for the GD functions * * @param int $targetWidth Target width in pixels, or 0 for proportional to height * @param int $targetHeight Target height in pixels, or 0 for proportional to width. Optional-if not specified, 0 is assumed. * @return bool True if the resize was successful * * @todo this method has become too long and needs to be split into smaller dedicated parts * */ public function ___resize($targetWidth, $targetHeight = 0) { $orientations = null; // @horst $needRotation = $this->autoRotation !== true ? false : ($this->checkOrientation($orientations) && (!empty($orientations[0]) || !empty($orientations[1])) ? true : false); $source = $this->filename; $dest = str_replace("." . $this->extension, "_tmp." . $this->extension, $source); $image = null; switch($this->imageType) { // @teppo case IMAGETYPE_GIF: $image = @imagecreatefromgif($source); break; case IMAGETYPE_PNG: $image = @imagecreatefrompng($source); break; case IMAGETYPE_JPEG: $image = @imagecreatefromjpeg($source); break; } if(!$image) return false; if($needRotation) { // @horst (Rotation is executed first because it can change width and height dimensions!) $image = $this->imRotate($image, $orientations[0]); if($orientations[0] == 90 || $orientations[0] == 270) { // we have to swap width & height now! $tmp = array($targetWidth, $targetHeight); $targetWidth = $tmp[1]; $targetHeight = $tmp[0]; $tmp = array($this->getWidth(), $this->getHeight()); $this->setImageInfo($tmp[1], $tmp[0]); } if($orientations[1] > 0) { $image = $this->imFlip($image, ($orientations[1] == 2 ? true : false)); } } // if we need to _scale_ an image we can get better results with first linearize the gamma curve // and convert back later, - after manipulations are finished - // but we cannot use it together with (transparent) PNG $linearizedGamma = false; // get all dimensions at first, before any image operation list($gdWidth, $gdHeight, $targetWidth, $targetHeight) = $this->getResizeDimensions($targetWidth, $targetHeight); $w1 = ($gdWidth / 2) - ($targetWidth / 2); $h1 = ($gdHeight / 2) - ($targetHeight / 2); $this->getCropDimensions($w1, $h1, $gdWidth, $targetWidth, $gdHeight, $targetHeight); // now lets check what operations are necessary: if($gdWidth==$targetWidth && $gdWidth==$this->image['width'] && $gdHeight==$this->image['height'] && $gdHeight==$targetHeight) { // this is the case if the original size is requested or a greater size but upscaling is set to false. // we only need one operation and without resampling, just copy! $thumb = imagecreatetruecolor($gdWidth, $gdHeight); $this->prepareImageLayer($thumb, $image); imagecopy($thumb, $image, 0, 0, 0, 0, $targetWidth, $targetHeight); $this->sharpening = 'none'; // no need for sharpening because we use original copy without scaling } elseif($gdWidth==$targetWidth && $gdHeight==$targetHeight) { // this is the case if we scale up or down without cropping // we need one operation with resampling. if($this->imageType != IMAGETYPE_PNG) { imagegammacorrect($image, 2.0, 1.0); // linearize gamma to 1.0 $linearizedGamma = true; } $thumb = imagecreatetruecolor($gdWidth, $gdHeight); $this->prepareImageLayer($thumb, $image); imagecopyresampled($thumb, $image, 0, 0, 0, 0, $gdWidth, $gdHeight, $this->image['width'], $this->image['height']); } else { // we use two steps if we scale up or down and also need to crop! if($this->imageType != IMAGETYPE_PNG) { imagegammacorrect($image, 2.0, 1.0); // linearize gamma to 1.0 $linearizedGamma = true; } $thumb2 = imagecreatetruecolor($gdWidth, $gdHeight); $this->prepareImageLayer($thumb2, $image); imagecopyresampled($thumb2, $image, 0, 0, 0, 0, $gdWidth, $gdHeight, $this->image['width'], $this->image['height']); $thumb = imagecreatetruecolor($targetWidth, $targetHeight); $this->prepareImageLayer($thumb, $image); imagecopyresampled($thumb, $thumb2, 0, 0, $w1, $h1, $targetWidth, $targetHeight, $targetWidth, $targetHeight); imagedestroy($thumb2); } if($this->sharpening && $this->sharpening != 'none') $thumb = $this->imSharpen($thumb, $this->sharpening); // @horst // write to file $result = false; switch($this->imageType) { case IMAGETYPE_GIF: if($linearizedGamma) { imagegammacorrect($thumb, 1.0, 2.0); // correct gamma from linearized 1.0 back to 2.0 } $result = imagegif($thumb, $dest); break; case IMAGETYPE_PNG: // convert 1-100 (worst-best) scale to 0-9 (best-worst) scale for PNG $quality = round(abs(($this->quality - 100) / 11.111111)); $result = imagepng($thumb, $dest, $quality); break; case IMAGETYPE_JPEG: if($linearizedGamma) { imagegammacorrect($thumb, 1.0, 2.0); // correct gamma from linearized 1.0 back to 2.0 } $result = imagejpeg($thumb, $dest, $this->quality); break; } @imagedestroy($image); @imagedestroy($thumb); if($result === false) { if(is_file($dest)) @unlink($dest); return false; } unlink($source); rename($dest, $source); $this->writeIPTC(); // @horst: if we've retrieved IPTC-Metadata from sourcefile, we write it back now $this->loadImageInfo($this->filename); $this->modified = true; return true; }
    1 point
  47. The client doesn't even want a CMS (and presumably isn't paying for it) yet you choose to built it out in ProcessWire for convenience. I like that. I would do the same thing, but it makes me smile to hear that others are using ProcessWire even when the project doesn't call for a CMS, simply because it's more convenient than building it without.
    1 point
  48. After adding this piece of code I had a problem with the URLs (/information/, /show-all/ etc. ). This manifested itself even in the names of pictures.(trash.png, showreel.png) The problem is that you forgot to put the points. Right? <denyUrlSequences> <add sequence=".inc" /> <add sequence=".info" /> <add sequence=".sh" /> <add sequence=".sql" /> <add sequence="\..*" /> </denyUrlSequences>
    1 point
  49. Heres the code I used to truncate and to make sure it ends in a word (so association wont become ass...), maybe it could be of some use as well as Ryan's example : <?php if (strlen($vDescription) > 16) { $shortDescription = substr($vDescription, 0, 16); // truncate string $shortDescription = substr($shortDescription, 0, strrpos($shortDescription, ' '))."…<br /><a href='{$vehicle->url}'> Read more</a>"; // make sure it ends in a word } else {$shortDescription = $vDescription;}
    1 point
×
×
  • Create New...