-
Posts
4,077 -
Joined
-
Last visited
-
Days Won
87
Everything posted by horst
-
There are always executed checks like isViewable, isEditable, isWhatEverNeeded in the context of the current $user. So, everything is fine, if a Superuser is able to access those pages.
-
Have a look into Functions.php line 805, function wireMail(): $mail = null; $modules = wire('modules'); // attempt to locate an installed module that overrides WireMail foreach($modules as $module) { $parents = class_parents("$module"); if(in_array('WireMail', $parents) && $modules->isInstalled("$module")) { $mail = wire('modules')->get("$module"); break; } } // if no module found, default to WireMail if(is_null($mail)) $mail = new WireMail();
-
Great! Please, can you add it to the modules directory too? It's done in less then 2 minutes, as you have it in a github repo.
-
Hey, you are all right. We have had another issue with authentication and the test, where the original SMTP-class also allowed the missing of authentication. In this regard, the user could successfully pass the test (connecting to the server, IP + Port) without providing authentication credentials. Therefore I have hacked the original class with this code you have posted above. (assuming there will be no open relay servers out there in 2015) But yep, now you comes along here. I will have a closer look to it and provide a better fix. (apropriate for both situations). In the meantime you can A) comment the part in the code, or B) don't use the test anymore on tis server. Thanks for your help.
-
Check if $user is logged in without renewing cookie
horst replied to thomas's topic in API & Templates
Hi thomas, I'm not sure if my thougths are helpful and also if I got it right what you need to achieve. You have a js app that "talks" to the server, (through ajax or alike?) when it has to read or save data through PW? Why would you trigger poll requests if you don't have anything to do for the app or server? I mean, you can check on top of each regular request that needs to interact with PW as logged in user if he still is logged in, and if not, redirect to the login screen. (maybe?) Or maybe you can set a special session variable (timestamp) for logged in users that gets updated only on regular requests, not on poll requests. This session var needs to be used / bind for the logout timeout then. (but also don't know which hook would be needed for that) When reading my answer now, it doesn't look very helpful at all. (but I have tried it!) -
What system you are using? Win > 7 ? And what server setup you are using? (Mamp, Wamp XAMP, etc)
-
Hehe, this is the time zone advantage! +02:00
-
Hi @ukyo, maybe there are optimization possibilities in your workflow. If you don't mind, I write down some thoughts ? 1) if you don't want send your original (master) image through the browser, (what I highly recommend), upload it with the max quality setting you can. (Speaking on JPEG only here in this regard). 2) try to reduce the image processing steps to a minimum. In your example you first call size with original width. This triggers a complete image manipulation including creation of a diskfile with the exact dimensions of the original image. But with a lower quality (depending of your default settings, maybe: 90). This lesser quality version is then loaded into pim2 and gets watermarked, and again saved with default value for quality. This is repeated once again for the $sSizeImage. Better would be to A) use quality 100 for all intermediate steps and only save the last one with your desired endquality. I would create one fullsize variation with the watermark logo. // creates a copy of the original, but with watermark and suffix "wmi" $wmiImage = $image->pim2Load('wmi')->watermarkLogo($wmPath, 'c', '2')->setQuality(100)->setSharpening('none')->pimSave(); Now use this wmi image (variation) for your resized versions: // create an image 1130x500 $sSizeImage1 = $wmiImage->size(1130, 500); // create an image max width 300 $sSizeImage2 = $wmiImage->width(300); // and so on, ... This way you have the original image plus one fullsize with watermark and one variation for every output image.
-
choosing a cms your organization will love, read here, (and also see the first posted comment)
-
There were other voices here in that thread If you like, I can do, but I'm not sure that it is really helpful.
-
Hi jlahijani, the only thing what should have influence on that is defaultGamma. Have you tried 2.2 ? Also the master images should be max possible quality (Photoshop quality 12) The output colorspace must be sRGB, regardless if with or without embedded icc profile. Can you tell the GD lib version and the used PHP version?
-
Really? I thought we don't put alpha state modules into the directory? Wouldn't it be better to put the URL from the forum thread and GitHub repo into the modules description, if it isn't already there? The module is only half way ready, but most of the part what needs to be finished cannot be done by me. So, when it is in the directory, it gets more attention and, I believe, more requests for to make it fit into the UI, and let it also have all the fine new stuff that the core image field has, etc, etc. All what I can't do.
-
Tremendous Url Field ?
-
I think this must work: $pa = new PageArray(); // use a PageArray to collect all subject pages foreach($pages->find("template=subject") as $subject) { // iterate over all subject pages $subject->set('myCount', $pages->find("template=artworks, subjects=$subject")->count); // add a temporary property to it that holds the total number of linked items $pa->add($subject); // add it to the PageArray } foreach($pa->sort("-myCount") as $item) { // sort the PageArray descending by total number and echo the title and count echo "<li>{$item->title} ({$item->myCount})</li>"; }
-
Page on save:: copy field value into (hidden) field
horst replied to matjash's topic in General Support
@renobird: ah, now I see what was the real problem. Haven't realized it before. -
Page on save:: copy field value into (hidden) field
horst replied to matjash's topic in General Support
You cannot (simply) save within the hook that is called after save. You need to avoid endless loop. Add a temporary property to the page object you have altered and check for this in the beginning of the hook method: if (page->imAlreadyDone) return; // is already altered if ($page->template != "nepremicnine-vnos") return; // is the wrong page type $page->cenaStara = $page->cena; // alter data $page->imAlreadyDone = true; // flag page as altered $page->save("cenaStara"); // save -
Image fields stop saving descriptions after a while
horst replied to OviS's topic in General Support
One thing that I spotted in this thread is the change and cycle through different image fields and PW version on one Site at least, PW 2.3 to PW 2.6 now. Also the use of cropableimages, what is clearly signed as alpha state. There were some changes needed and done to the naming scheme of image variations between PW 2.4 to 2.5 and also 2.5 to 2.6. So I believe that not all 3rd party image fileds are up to date with that. And that switching between different versions, forth and back, and than change PW versions too somewhere in between, maybe this can render a DB corrupt in some parts. At least I have had some weirdness with image fields too in the past, but that definetly was produced by switching and hoping through different image fields and PW versions, including the use of third party alpha modules. (not proper functional install / uninstall routines, maybe a server - / DB connection interrupt at the wrong second, all this can be an initial point for a damage in the DB) I don't think it has to do with the base core image field (since) PW 2.3 or earlier. How many installations out there with PW? How many people are arriving here with a problem like that? Not to be able to change / save images and / or descriptions, there would be more reports here to read. Sorry that it doesn't help in any of the problems -
How have you linked the pages to the subjects? WIth which field(s)? Do you use an InputfieldPage for that? What does this function do: findartworks("subjects=$subject, limit=1") ? You call it two times.
-
There is a setting in the Input Tab, named Extra Allowed Content, where you can define what shouldn't be stripped by CKEditor. On the other hand, if it is your side and you are the maintainer, just swicth off the use of ACF !
-
All you have changed in the script looks good, but ... ;-) ... the only thing what doesn't seem right is your main template dams (what I have named rccdams). This must be used for the combining (normal) dam pages. It cannot be used for a Inputfield of type "Page". You need to have that main template dam (or even dams and dam, if you give the parent page of all your dams an own template too.) The main template you need to refer to in the script is the dam template. This is used for all your dam objects. It will hold all other fields in the edit screen for the maintainers of the data. All other fields mean: all InputfieldPage, all InputFieldText, all inputFieldInteger, all InputFieldDatetime that contains data belonging to a (single) dam. Templates and fields of type InputFieldPage for (type, owner, country, purpose) needs to be created manually, before running the import part. (This looks good in your script config) All fields other than that of type InputfieldPage will be created by the createFields Action of the importer script. You need to run this action first. (looks also good in your script config) All other things, e.g. if you want to use more / other fields of type InputfiledPage depends on you. You should look and play a bit with the starter profile I have provided earlier. It shows some purposes as categories and how to use them with a multiple categories InputfieldPage that can be added to single dams. Also there is a single category InputfieldPage to study and play with. In my example, I have used the FIW exmple you provided in an above post. So, if you now do not have this field, you also can specify some source-fieldnames that you don't want to use as single inputfields but first gather their data, and put it together in a way that it fits to the purpose filed I have build, or you change the purpose field to match other criterias. My purposes categories do not only have a title field but also a subtitle field. You can see all this in the site profile. It's easy! And, if you have ran the import and the resulting data isn't what you expected, you once can run the deleteImportedData action to clear it out, change the config or change fetching and preparing the data of that particular part(s). And finally run the importer again. Good luck.
-
Maybe it is what is said here in the first answer: http://stackoverflow.com/questions/10338279/unable-to-show-fancybox-title ?? put the description in the title attribute of the a tag, not into the alt attribute of the img tag. >> unproofed, only found!
- 75 replies
-
- 1
-
- site profile
- responsive
-
(and 2 more)
Tagged with:
-
Hi, a very useful Modul(ette). Primarily, it is not the "amount" of code what tells about the "weight" of a module. ------ BTW, when having a look at Github, I spotted DIRECTORY_SEPARATOR in URLs for script and style loading. Shouldn't it be a simple / (slash) instead?
-
Hi Tony, I have attached a site-profile as example. It has some data in it that was populated with the following importer script. In the site profile I have created the dam_type and the dam_purpose categories and page fields. The dam_purpose was created as Multiple categories and there will be no items added automaticaly during import. The dam_type will be added automaticaly during install. there is only the templates and the parent created manually. Inspect the profile and look through the importer script, it has all needed comments. After playing around with it, I'm sure you can adapt it to suite your needs. site-rccdams-starter.zip save this besides your PW index.php and call it after you have logged in as superuser: <?php $GLOBALS['templateName'] = 'rccdams'; // the name of the template you use $GLOBALS['oldrccid'] = 'rccid'; // the fieldname in PW which stores the id from the source DB $GLOBALS['parentPath'] = '/rcc_dams/'; // add the path you want the pages stored, e.g. "/rccdams/" or that like, but check that you already have created this (parent) page in PW!! // the templates and parent pages for the categories needs to be created manually before the import action is used!! // also don't forgett to assign them to the rccdams template !! $categoryPages = array( 'dam_type' => array( 'nameOfParentTemplate' => 'dam_type_category_parent', 'nameOfChildTemplate' => 'dam_type_category' ), 'dam_owner' => array( 'nameOfParentTemplate' => '', 'nameOfChildTemplate' => '' ), 'dam_country' => array( 'nameOfParentTemplate' => '', 'nameOfChildTemplate' => '' ), 'dam_purpose' => array( 'nameOfParentTemplate' => 'dam_purpose_category_parent', 'nameOfChildTemplate' => 'dam_purpose_category' ) ); # # ATTENTION: SELECT AN ACTION HERE !! # # select an action you want to proceed by comment uncomment the following two lines # $ACTION = 'deleteImportedPages'; #$ACTION = 'createFields'; #$ACTION = 'importData'; // provide the credentials to connect to the Source-DB, including DB name and Table name $MYSQL = array(); $MYSQL['host'] = '127.0.0.1'; $MYSQL['user'] = ''; $MYSQL['pass'] = ''; $MYSQL['dbname'] = 'rccdams_db'; $MYSQL['tablename'] = 'rccdams_db'; // a list with all the fields and the their types, you want create / import into PW $rccdams_fields = array( 'dam_type' => 'Page', 'dam_country' => 'Page', 'dam_owner' => 'Page', 'dam_purpose' => 'Page', 'rccid' => 'Integer', 'dam_name' => 'Text', 'river' => 'Text', 'capacity' => 'Text', 'cd_proj_start' => 'Datetime', 'cd_proj_start_d' => 'Integer', 'cd_proj_start_m' => 'Integer', 'cd_proj_start_y' => 'Integer', 'cd_rcc_start' => 'Datetime', 'cd_rcc_start_d' => 'Integer', 'cd_rcc_start_m' => 'Integer', 'cd_rcc_start_y' => 'Integer', 'cd_proj_fin' => 'Datetime', 'cd_proj_fin_d' => 'Integer', 'cd_proj_fin_m' => 'Integer', 'cd_proj_fin_y' => 'Integer', 'cd_rcc_fin' => 'Datetime', 'cd_rcc_fin_d' => 'Integer', 'cd_rcc_fin_m' => 'Integer', 'cd_rcc_fin_y' => 'Integer' ); // I'm not sure if all the _d, _m, _y fields are needed. Maybe you only need the 4 Datetime fields! // you can adapt the list to suite your needs ############### READY with config part ########################### $GLOBALS['categoryPages'] = $categoryPages; $timeLimit = (60 * 5); // give it a bit more time than the default 30 seconds $ignoreUserAbort = false; // prepare server for plaintext output if(function_exists('apache_setenv')) @apache_setenv('no-gzip', '1'); @ini_set('zlib.output_compression', 'Off'); @ini_set('output_buffering ', '0'); @ini_set('implicit_flush', '1'); @ob_implicit_flush(true); @ob_end_flush(); if(isset($_SERVER['HTTP_HOST'])) { header('Content-Type: text/plain'); } // Bootstrap ProcessWire require_once('./index.php'); // security check if the current user is a SuperUser, comment the next line out, if you run this script from CLI if (!wire('user')->isSuperuser()) die('ACCESS DENIED!'); ignore_user_abort($ignoreUserAbort); set_time_limit(intval($timeLimit)); // Assign API variables to make things a little easier $fields = wire("fields"); $templates = wire("templates"); $modules = wire("modules"); $sanitizer = wire("sanitizer"); $pages = wire("pages"); echo "\n$ACTION\n"; if ('deleteImportedPages' == $ACTION) { echo "\n"; // we drop all imported pages foreach($pages->find("template={$GLOBALS['templateName']},include=all") as $p) { echo " - now drop {$p->title}\n"; $p->delete(); } echo "\nREADY!\n"; exit(); } if ('createFields' == $ACTION) { echo "\n"; // (1) first get the rccdam template $t = $templates->$GLOBALS['templateName']; if (!$t) { $fg = new Fieldgroup(); $fg->add("title"); $fg->save(); $t = new Template(); $t->name = $GLOBALS['templateName']; $t->fieldgroup = $fg; $t->save(); } // (2) loop through the field list and create those that are missing foreach($rccdams_fields as $name => $type) { echo " - $name :: $type\n"; if ('page' == strtolower($type)) continue; // field of type Page, this need to be created manually $f = $fields->$name; if (!$fields->$name) { // create a new field $f = new Field(); $f->type = $modules->get("Fieldtype" . $type); $f->name = $name; $f->save(); echo " successfully created\n"; } // add it to the rccdam template $t->fieldgroup->add($f); $t->fieldgroup->save(); $t->save(); } echo "\nREADY!\n"; exit(); } if ('importData' == $ACTION) { echo "\n"; // (1) connect to Source-DB $MY_sql = mysql_connect($MYSQL['host'], $MYSQL['user'], $MYSQL['pass']); if($MY_sql) { echo "- connected with MySQL Server\n"; $MY_sql_db = mysql_select_db($MYSQL['dbname'], $MY_sql); if($MY_sql_db) { echo "- connected with source DB\n"; $MY_sql_result = mysql_query("SELECT * FROM {$MYSQL['tablename']}", $MY_sql); if (is_resource($MY_sql_result)) { echo "- found the Table\n\n"; $t = $templates->$GLOBALS['templateName']; while($row = mysql_fetch_array($MY_sql_result, MYSQL_ASSOC)) { // (2) process all records of source table echo " -- fetched row with id {$row['id']}\n"; if (!isValidImportRecord($row)) continue; // this one is already present in PW, so skip further processing // we have data for a new page echo " this one needs to be imported\n"; $p = new Page(); // create a new page and assign the minimum required params: template, parent and title! $p->template = $t; $p->parent = $pages->get($GLOBALS['parentPath']); $p->$GLOBALS['oldrccid'] = $row['id']; $p->title = $row['dam_name']; // now loop through all source data fields foreach($row as $fieldname => $data) { if (!isset($rccdams_fields[$fieldname])) continue; // skip source data fields that are not defined in the $rccdams_fields array!! if (!$t->fieldgroup->$fieldname) continue; // skip source data when there is no field in our template // check which type we need in PW for this if ('Page' != $rccdams_fields[$fieldname]) { // we can simply add the source data into the target field, but pass it once through the sanitizer or typecast it to integer $data = 'Integer' == $rccdams_fields[$fieldname] ? (int)$data : $sanitizer->text($data); $p->$fieldname = $data; } else { // we have a Pagefield, we need to act accordingly, // here in the starter script I only work with dam_type and dam_purpose // the other needs to be added by you, switch($fieldname) { case 'dam_type': // this must be a single category Page !! in Details Tab it must set to SIngle Page or empty NullPage !! // we want create child pages for this category automatically, therefore // we need to check if there is already a child page, fetch this or create a new one: $data = $sanitizer->text($data); $cp = getCategoryPage('dam_type', $data); $p->$fieldname = $cp; break; case 'dam_owner': break; case 'dam_country': break; case 'dam_purpose': // this is a Multi-Items-Category and it has shortcuts in the source DB $data = strtolower(trim($sanitizer->text($data))); $cpa = getCategoryPagesPurpose($data); $p->$fieldname = $cpa; break; } } } $p->save(); echo " saved into DB!\n\n"; } mysql_free_result($MY_sql_result); } } } mysql_close($MY_sql); echo "\nREADY!\n"; exit(); } function isValidImportRecord($row) { // we check for a page with the rccdams template and the original id, (what we have stored under rccid with every imported page) $page = wire('pages')->get("template={$GLOBALS['templateName']},{$GLOBALS['oldrccid']}={$row['id']}"); // if a $page with ID greater than zero is found, we already have this page imported and want to skip it here, therefor we retun false! return $page->id > 0 ? false : true; } function getCategoryPage($name, $data) { $nameOfParentTemplate = $GLOBALS['categoryPages'][$name]['nameOfParentTemplate']; $nameOfChildTemplate = $GLOBALS['categoryPages'][$name]['nameOfChildTemplate']; // if there is no data in the source record, we return a NullPage Object if (empty($data)) { $cp = new NullPage(); } else { // if we have this page already in PW, we return it $cp = wire('pages')->get("template={$nameOfChildTemplate},name=" . wire('sanitizer')->pageName($data)); if (0 == $cp->id) { // if it ins't already there, we create it $cp = new Page(); $cp->of(false); $cp->template = $nameOfChildTemplate; $cp->parent = wire('pages')->get("template={$nameOfParentTemplate}"); $cp->title = $data; $cp->save(); } } return $cp; } function getCategoryPagesPurpose($data) { $nameOfChildTemplate = $GLOBALS['categoryPages']['dam_purpose']['nameOfChildTemplate']; $cpa = new PageArray(); // create an empty PageArray if (empty($data)) return $cpa; // if we have no source data, return empty PageArray for($i = 0; $i < strlen($data); $i++) { // add category pages to the array $cp = wire('pages')->get("template={$nameOfChildTemplate},name={$data[$i]}"); $cpa->add($cp); } return $cpa; } EDIT: I added the $ACTION "deleteImportedPages" to the script, and a few more comments. Please use this from above and not this that ships in the ZIP archive.
-
is Key-binding for STRG-S in Admin-Editpage possible?
horst replied to Pauline's topic in Getting Started
- interesting, but Google doesn't translate it correct: https://translate.google.de/?hl=en#auto/en/%D0%9F%D1%80%D0%BE%D1%86%D0%B5%D1%81%D1%81%D0%A8%D0%B8%D1%80%D0%B5 -
You can add a textformatter to that Field. drop the following code into a file named and located at site/modules/TextformatterRemoveEncodedSpaces/TextformatterRemoveEncodedSpaces.module <?php class TextformatterRemoveEncodedSpaces extends Textformatter { public static function getModuleInfo() { return array( 'title' => 'Remove Encoded Spaces ()', 'version' => '0.0.1', 'summary' => 'Removes that weird encoded spaces (& #160 from my Textareas!' ); } public function format(&$str) { $search = array( ' ' ); $replace = array( ' ' ); $str = str_replace($search, $replace, $str); } } install it and add it to the output of your textarea field.