Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/24/2015 in all areas

  1. In PhpStorm you can get autocompletion and typehinting for wire function calls if you add a file with the following content somewhere to your project. Jetbrains suggests naming this file '.phpstorm.meta.php' and adding it to the root of your project, but it should work anywhere else too. I had to re-open the project after adding the file. <?php /** * ProcessWire PhpStorm Meta * * This file is not a CODE, it makes no sense and won't run or validate * Its AST serves PhpStorm IDE as DATA source to make advanced type inference decisions. * * @see https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata */ namespace PHPSTORM_META { $STATIC_METHOD_TYPES = [ \wire('') => [ '' == '@', 'config' instanceof Config, 'wire' instanceof ProcessWire, 'log' instanceof WireLog, 'notices' instanceof Notices, 'sanitizer' instanceof \Sanitizer, 'database' instanceof \WireDatabasePDO, 'db' instanceof \DatabaseMysqli, 'cache' instanceof \MarkupCache, 'modules' instanceof \Modules, 'procache' instanceof \ProCache, 'fieldtypes' instanceof \Fieldtypes, 'fields' instanceof \Fields, 'fieldgroups' instanceof \Fieldgroups, 'templates' instanceof \Templates, 'pages' instanceof \Pages, 'permissions' instanceof \ Permissions, 'roles' instanceof \Roles, 'users' instanceof \Users, 'user' instanceof \User, 'session' instanceof \Session, 'input' instanceof \WireInput, 'languages' instanceof \Languages, 'page' instanceof \Page, ] ]; }
    6 points
  2. It's ProcessWire Use: $pageFile->filename; // Path & Filename $pageFile->basename; // Filename without path $pageFile->filesize; // Size in bytes $pageFile->filesizeStr; // Human readable Filesize
    3 points
  3. I am sure Wanze will be able to offer up a solution to get the filesize from the path. I just wanted to chime in with a nice function for converting to human readable filesizes: http://jeffreysambells.com/2012/10/25/human-readable-filesize-php function human_filesize($bytes, $decimals = 2) { $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); $factor = floor((strlen($bytes) - 1) / 3); return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor]; }
    3 points
  4. If you're already inserting the message with jQuery, maybe it's easier to solve it also with jQuery. Just make sure masonry is called after you insert the element. By after I mean Javascript's after, not just after in the code, see my example http://codepen.io/diogo-ed/pen/LVwRyB
    2 points
  5. I've explained your selector below: // Get a page with ID 1035, // Sort that page with ID 1035 (You can't sort 1 page) // include page 1035 even when it is hidden (Get will always get the page, regardless if it is hidden) // Get the children of the page with ID 1035. (Will only get the visible pages) $stellen = $pages->get("1035", "sort=sort", "include=hidden")->children; I do think you want something like this: // Find pages with the 1035 parent // Sort it // Include the hidden children $stellen = $pages->find("parent.id=1035, sort=sort, include=hidden");
    2 points
  6. I also change line 63 in the module to: $storageLocation = $this->wire('config')->paths->root.rtrim($field->get('storageLocation'), '/') . '/'; So my secure file path is relative to my web root: eg: ../secure_files/ Which is just one level down from my web root, and is easily configured on most shared hosts. Just saves a bit of time working out absolute paths on shared accounts. Might be an option within the module to select "Relative path to Processwire root" or "Absolute Path"
    2 points
  7. A ProcessWire Fieldtype storing files in a customized location, outside the web root. This module is primarily useful if you need to store sensitive data which should not be accessible directly from the web. Normally, ProcessWire stores all files under /site/assets/files. Direct URL access to these files can be restriced by setting $config->pagefileSecure = true. Still you need to make sure that your template permissions are setup correctly. If something goes wrong, those files could be accessed from outside. GitHub: https://github.com/wanze/FieldtypeSecureFile Modules Directory: http://modules.processwire.com/modules/fieldtype-secure-file/ How does it work? After installing this module, you can create a new field of type SecureFile. Enter your configuration under the "Details" section when editing the field: Storage Location Enter a path outside the web root where the files are stored. You need to create the directory manually. Also make sure that the user running the web server has write permission. Roles allowing to download a secure file Users with a role selected here are able to download the files if a download is requested via the API. Allow Download in Admin If checked, users having a role selected above can download the files when editing a page. I needed this functionality for a recent project, so I created this module and thought to share it, mabye this is useful for someone else Consider it beta, I'm using it on one site but I'm sure it could be improved here and there. Feel free to suggest additional features! Cheers
    1 point
  8. Hi guys, Been "kicking the tyres" on some UI tweaks to the PW image fields and modal windows. Many of these are in-progress designs and to be straight, none of the designs are entirely resolved. At this stage, I thought I'd throw them up (poor choice of words!) and maybe someone can take them further or offer some fresh eyes. I'm not a developer so making these a reality is impossible for me. They're flat designs. Why? PW is an amazing experience for editors. It's just so elegant and beautifully realised (especially with Reno Theme) that often, my training sessions with clients are very brief. One area which does cause friction though has always been concerned images, image fields and image modals. Especially with the latest image modules, I think a lot of inconsistency has crept into the UI. Hopefully these designs can help improve things a bit. A tiny part of the design work is influenced by a similar idea I had for MODX but which never progressed. 1A. Current Image Modal Editor has clicked 'Add image' icon in CK editor. Issues: I believe the Upload Image button can be better placed. It's not clear to users that they have a choice of two actions (Select an Image OR Upload one) To help solve this, I thought we could: Place available images under a Choose tab Create another tab titled Upload Rename modal to just Image (from Select Image) tweak slightly the Images on page path to be less prominent The following image illustrates the result. Clicking the Upload tab would result in: In the above image I've created toggle-able accordians for Drag and Drop and Manual upload. This follows closely the UI an editor is presented with when choosing Insert Link within CK Editor. IE Link to URL, Select Page and Select File and the extra Attributes tab. So overall, it's more consistent. 1B. Alternative to above - combined Select and Drag/Drop I thought it might be worth exploring what modal would look like with no tabs and a single UI for both Selecting an image and Drag/Dropping. 1C. The Image field I then moved onto looking at the Image field in PW. So currently it looks like this (below) for a simple image field called Image Gallery. So although the current Image field works great, I wondered if there was a way to simplify it by Making the drag/drop more visual and obvious Moving the Choose Files button and removing the No file chosen text and the file types allowed Here's the result. Admittedly, this treatment adds more height to the overall field. Here's how it looks when images are uploading (slightly smaller plus icon and "drag and drop..." text. To be honest, I can't recall what other changes I made there! And here's a proposed layout for when there are multiple images. This includes image titles grid layout mouse-over for edit and delete options/buttons 2. Cropping Next thing I looked at was cropping. Native cropping introduced recently is one of my clients favourite features and time-savers and I wondered if things could be improved a little. So heres the current layout (this may have changed further recently) And here's my proposal. Changes are: Width, height and X and Y fields are moved below the image Apply and Cancel placed bottom right of the image Save Crop should be titled Apply. I think that's less confusing as in some instances there are so many Save options Save and Replace should be greyed out further In addition to this, I thought it'd be neat if we had the free-form cropping function introduced by Ryan combined with some kind of list of pre-sets (displayed on right hand side). Forgive the croptions label (Crop + Options pun - I was tired!) The benfit of this I think is that Modules such as CoppableImage and native Crop would be unified in a single UI. Presets (on right) could be a few out-of-the-box presets which come natively. Croptions houses any crop ratios defined in image modules. if CopppableImage isn't installed, they just don't display.. That's it. I wish I'd more time to work on this but it's at the stage where it's ready for some initial thoughts. Hope you guys like.
    1 point
  9. The ProcessWire image plugin used in CKEditor has some great features that give editors a lot of options when inserting images into RTE fields. Giving site editors this much control is good if those editors are technically literate and make wise layout decisions. In my experience this is often not the case. Rather than let editors choose to center an image here, insert a 3000px image there, upscale an image here, link to an original there, etc, I'd rather be able to set up some predefined options and then let editors choose from them when inserting an image. And I'd like to have those options be reflected in the appearance of images inside the RTE window after the image has been inserted - so a "full-width" image appears as such, "logo" image is small and floats right, etc. In other systems I've achieved this through the use of classes: when inserting an image editors choose from a dropdown of classes. These classes can then be used to control the appearance of images in the RTE window (via custom CSS styles for the RTE) and used to determine the final frontend result via PHP processing or jQuery selectors. A couple of ways the Page Edit Image module could be enhanced... Simple Allow custom classes to be added to images when they are inserted, just like the Page Edit Link module does.This would allow custom styles to be applied in the RTE window, and site developers could write their own Textformatter modules to apply different markup based on class or do things client-side with jQuery. Even better! Provide an interface in the module configuration that allows image "profiles" to be defined. Useful options would be:resizing cropping create link to enlargement (with resizing options for enlargement - the current option of linking to the original isn't ideal because the original is often much larger than needed). CSS rules for the profile to apply in the RTE window (float, width, etc)
    1 point
  10. If you're using the masonry package you should also take a look at the stamp option, which doesn't depend on the item order. At best your message should be the first item, if something on the javascript side fails, that it's still at the top and not buried beneath lots of thumbnails.
    1 point
  11. The easiest thing could be saving the page to be inserted into a variable before the loop, and using a counter inside the loop to output the page if the counter reaches the number you need. Otherwise you could use the "slice" and "and" methods of PageArray to construct your custom array of pages before the loop.
    1 point
  12. It's because default language does have an id, but the field for the default language doesn't use it. So you have: - lang: default, id: 1017, field: name - lang: other, id: 1019, field: name1019 - lang: third, id: 1020, field: name1020 So, if you just tried get("name$langId") for default language, you'd try to access "name1017", which doesn't exist.
    1 point
  13. Hello @ all, in the past I had the problem that I wanted to add additional markup and manipulations to images that were added with the editor to my body field. My aim was to add Bootstrap framework classes to my images and to add additional containers for certain CSS3 effects. I have tried several ways with dom manipulation, jquery and other php manipulations, but all of them dont satisfy my exact needs. After searching Google i found a php library called "PHP Query" which works similar to jQuery but on serverside. After several tests it seems to me the best way for complex manipulations and so I decided to make a simple textformatter module. It consists of 2 files: the phpquery.php file for the library and the the module file itself which contains the manipulations The php query library file can be found at https://code.google.com/p/phpquery/downloads/list The module file: <?php /** * TextformatterPhpqueryImageFieldMarkupManipulator (1.0.0) * A textformatter module to change the markup of images added via editor with the help of the PHPQuery library. * * @author Kern Juergen * * ProcessWire 2.x * Copyright (C) 2011 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class TextformatterPhpqueryImageFieldMarkupManipulator extends Textformatter { public static function getModuleInfo() { return array( 'title' => "TextformatterPhpqueryImageFieldMarkupManipulator", 'version' => "1.0.0", 'summary' => "A textformatter module to change the markup of images added via editor with the help of the PHPQuery library (https://code.google.com/p/phpquery/).", 'author' => "Kern Juergen", 'href' => "", 'permission' => array( "" ), 'autoload' => false, 'singular' => false, 'permanent' => false, 'requires' => array( "PHP>=5.4.0", "ProcessWire>=2.5.28" ) ); } public function format(&$str) { require('phpQuery.php'); $id = $this->page;//grab the page id $galleryid = 'gallery-' . $id;// create the gallery $document = phpQuery::newDocumentHTML($str); // Selects all image elements added via editor $matches = $document->find('img'); foreach ($matches as $match) { //starting manipulations - examples (you can find more and a documentation at https://code.google.com/p/phpquery/wiki/Manual) pq('a > img')->addClass('linked'); //add linked class to all linked images pq('img')->addClass('img-responsive')->addClass('thumbnail'); //add thumbnail and responsive class to all images pq('.linked')->removeClass('thumbnail'); pq('a > img')->wrap('<span class="scalecontainer"></span>')->before('<span class="roll"></span>'); //add additional markup to images with links pq('img')->parents('a')->addClass('thumbnail')->attr('data-lightbox', $galleryid); //add thumbnail class to the link to the larger version and the data attribute pq("a > span > img.align_left)")->parents('a')->addClass('align_left'); pq("a > span > img.align_right)")->parents('a')->addClass('align_right'); pq("a > span > img.align_center)")->parents('a')->addClass('align_center'); pq("p > a.align_center)")->wrap('<div class="image-center"></div>'); pq("p > img.align_center)")->wrap('<div class="image-center"></div>'); //end manipulations } $str = $document; } } The module file includes the phpquery with the require command. $matches = $document->find('img');// Selects all the images This line of code grabs all images //starting manipulations - you will find more info at https://code.google.com/p/phpquery/ //These are some manipulations pq('a > img')->addClass('linked');//add linked class to all linked images pq('img')->addClass('img-responsive')->addClass('thumbnail');//add thumbnail and responsive class to all images pq('.linked')->removeClass('thumbnail'); //remove class thumbnail on linked images pq('a > img')->wrap( '<span class="scalecontainer"></span>' )->before('<span class="roll"></span>'); //add additional markup to images with links pq('img')->parents('a')->addClass('thumbnail')->attr('data-lightbox', $galleryid); //add thumbnail class to the link to the larger version and the data attribute pq("a > span > img.align_left)")->parents('a')->addClass('align_left'); pq("a > span > img.align_right)")->parents('a')->addClass('align_right'); pq("a > span > img.align_center)")->parents('a')->addClass('align_center'); pq("p > a.align_center)")->wrap( '<div class="image-center"></div>' ) ; pq("p > img.align_center)")->wrap( '<div class="image-center"></div>' ) ; //end manipulations This is the manipulation section. You can find a lot of examples at the php Query site. The best is that you can use CSS3 selectors to match a certain element on the page. This makes it much easier. I only posted this module for others who are interested in manipulating images. You use it at your own risk and I doesnt make it public on Github. The manipulations are only for my purpose and you can make your own. Just write it between "//These are some manipulations" and "//end manipulations". Install the module at site/modules/ and add this textformatter module to your editor field. All the images added with the editor will be manipulated in an elegant way. Best regards Jürgen PS.: I am not a skilled PHP pro, I have never learned it at a professional level. So if anybody has improvements please post it here Edit: The include of the phpquery.php file should usualy be at the top of the module file, but in this case it can make problems during the installation of the textformatter. This is the reason why I added it inside the function. If you run into problems after the installation please add this line of code to the top and everything works fine. TextformatterPHPqueryImageFieldMarkupManipulator.zip
    1 point
  14. You can get user created and modified for a page with <?php $page->createdUser->name; $page->modifiedUser->name; $page would be $child in your code
    1 point
×
×
  • Create New...