Jump to content

kixe

Members
  • Posts

    802
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by kixe

  1. Email Verification This module provides functions to validate email adresses and hosts. The module generates a textfile for blacklisted mailhosts (trashmail), which will be always up to date. Download https://modules.processwire.com/modules/email-verification/ API // get module $mailcheck = $modules->get('EmailVerification'); // return bool/ string - automatted update of blacklist file $mailcheck->blacklisted(email|domain) // return bool - validate a top level domain, checks against IANA list $mailcheck->validTLD(tld) // return array of punycoded TLDs - cyclic updated, data pulled from IANA $mailcheck->getTLDs(cycle=2592000) // return bool - checks syntax converts to punycode $mailcheck->validDomainName(domain); // return bool - checks punycode encoded syntax $mailcheck->validHostName(host); // return bool - checks syntax and accessibility $mailcheck->validHost(email|domain) // add a single value to blacklist $mailcheck->addToBlacklist(email|domain) USAGE $mailcheck = $modules->get('EmailCheck'); $email = 'susi@trashmail.com'; if($mailcheck->blacklisted($email)) echo 'Email Provider not allowed'; if(!$mailcheck->validHost($email)) echo 'Mailhost not available'; Example blacklist file: blacklist.txt
  2. @kongondo you are right. I found only 2 Admin themes based on module. Something is buggy in the uninstall method. Made some changes. Works now ... //in: site/modules/AdminThemeCustom.module and: wire/modules/AdminTheme/AdminThemeDefault public static function getModuleInfo() { return array( //something else 'autoload' => 'template=admin', 'singular' => true ); } //in wire/core/AdminTheme.php public function ___uninstall() { //must be 2 not 1 because there are 2 themes before uninstallation if(self::$numAdminThemes > 2) return; //add this line which allows also to uninstall default Admin Theme, fallback to wire/template-admin/ if(!$this->wire('fields')->get('admin_theme')) return; ...... No need to call uninstall() from custom module.
  3. Remove of field admin_theme didn't work after uninstall of last custom AdminTheme. I tried to call the uninstall() function of AdminTheme.php by adding a function in MyCustomAdminTheme.module. This function should remove the field from the templates and delete the field. But this didn't work. Whats wrong? public function ___uninstall() { parent::___uninstall(); } notice Most of the existing third party AdminThemes don't call the uninstall routine. While Playing around with the themes I uninstalled default theme in Modules to get the basic default admin theme (wire/templates-admin) Couldn't see the content under Modules Tab. Worked after updating wire/templates-admin/scripts/main.js.
  4. This module is no longer updated. Because the feature is included in Core (2.4.18 dev) now. Thanks for using it.
  5. thanks ... it still lacks many large stones in my personal php wall. But it is easier to learn in the PW Surrounding then elsewhere. Isn't it?
  6. tried to hook, but didn't work, then I realized only two undescores. Shouldn't this to be hookable, since $event object is only used in hooks? Is there an underscore missing? wire/core/HookEvent.php /** * Return a string representing the HookEvent * */ public function __toString() { $s = $this->object->className() . '::' . $this->method . '('; foreach($this->arguments as $a) $s .= is_string($a) ? '"' . $a . '", ' : "$a, "; $s = rtrim($s, ", ") . ")"; return $s; }
  7. tried to remove all classes from Inputfield and set one single new class. Expected class="loggy" get class="loggy InputfieldMaxWidth". Why? Which method will remove all classes persistent? $form = $modules->get('ProcessLogin'); $form->addHookAfter('buildLoginForm',null, function ($event) { $new = $event->return; $new->get('login_pass')->removeAttr('class'); // removes: class="whatever" $new->get('login_pass')->setAttribute('class','loggy');// adds: class="loggy InputfieldMaxWidth" and not class="loggy" $event->return = $new; }); echo $form->execute();
  8. @sforsman thats exactly I wanted to unleash with the topic. Didn't expect to get a solution so quick. I tried it out. Great work, thats what we need. I made few and tiny adjustments since I am still using PHP 5.3. // We need to hook field save to check if our database field is up to date $this->addHookAfter('ProcessField::fieldSaved', function ($event) { $field = $event->arguments(0); if($field->type instanceof FieldtypeDecimal) { // We could use $this inside here, if we could expect everybody to have PHP 5.4 $m = wire('modules')->get(__CLASS__); $result = $m->syncSchema($field); // We just add a message if the database was actually modified if($result === true) $field->message(__('Database schema was updated.')); } }); 'instanceof self' didn't work I switched it to the class name. Message is a method of field object, no need to use $this. And generally it is nice to make the messages translatable.So its already done
  9. Little modification which works proper and doesn't need a hook to prevent from redirecting. Only thing which I couldn't get work is to display the Error Exception thrown by Login Throttle - Solutions welcome. complete template: <?php /** * Frontend Login template * */ include("./head.inc"); try { if($user->isLoggedin()) { if(isset($_GET['logout'])) $modules->get('ProcessLogin')->executeLogout(); // redirect user with page-edit permission to admin otherwise to root-page else echo "<a href='{$page->url}?logout'>{$user->name} logout</a>";// no redirect because module isn't called again } else { echo $modules->get('ProcessLogin')->execute(); if($notices->last()) echo '<br/><strong>'.$notices->last().'</strong>'; // error message from ProcessLogin //var_dump($session->getAll()); } } catch(Exception $e) { echo $e->getMessage(); } include("./foot.inc"); If you use echo $modules->get('ProcessProfile')->execute(); take care about setting the permissions right and give the frontend-user not page-edit role. Hide role-field and admin-template-field and maybe some others in the module settings. You should also set the validation of all fields shown in frontend very strict. Go here: fields > input > strip tags and fields > input > pattern Check security carfully. Like Adrian I have still some doubts about this way is a save one ... But I think it is good to test in this direction. I am playing around also with process fields (like in admin template) in frontend - just for development. To have easy access to the good stuff of backend in frontend.
  10. I started a new topic here: https://processwire.com/talk/topic/7542-development-fieldtypefloat-fieldtypedecimal/
  11. I started a new topic here: https://processwire.com/talk/topic/7542-development-fieldtypefloat-fieldtypedecimal/
  12. I started a new topic here: https://processwire.com/talk/topic/7542-development-fieldtypefloat-fieldtypedecimal/
  13. Since some others and me have been run into problems with FieldtypeFloat. I want to start a discussion with the purpose to get a consistent FieldtypeFloat and/or to create a new Fieldtype maybe called FieldtypeDecimal to store exact values maybe for currencies. First I will assume some known problems. precision Values of Type Float are stored in most of the Mysql Installations with a precision of 6 by default. PW FieldtypeFloat uses Type float() in the Mysql Database This could cause some problems. For easy understanding look at this table. +---------------+----------------+--------------------------------------------------+ | input | float() | decimal(10,2) | +---------------+----------------+--------------------------------------------------+ | 1234.56 | 1234.56 | 1234.56 | +---------------+----------------+--------------------------------------------------+ | 123456.78 | 123457 | 123456.78 | +---------------+----------------+--------------------------------------------------+ | 12345678 | 12345600 | 12345678.00 | +---------------+----------------+--------------------------------------------------+ | 1.23456789 | 1.23457 | 1.23 | +---------------+----------------+--------------------------------------------------+ | 12345678912345| 12345600000000 | ERROR SQLSTATE[22003]: Numeric value out of range| +---------------+----------------+--------------------------------------------------+ As an example in Apeisas Shoppingcart Module exists a field sc_price of type float(). This field allows a maximum value of 9999.99 Euro Dollar or whatever. Don't use it to sell cars like Ferrari. Try to store the input values of the preceding table in a PW Field of Type Float in your surrounding and look what you get after saving. Threads treating the same problem https://processwire.com/talk/topic/3888-float-field-rounding-problem/ https://processwire.com/talk/topic/86-float-field-rounding rounding Mysql will round anyway the float value to precision. So it is not necessary to round the value in php before storing. To store exact Values it is better to use Type decimal(M,D) where M is the lenght and D the number of digits. Thread treating the same problem https://processwire.com/talk/topic/86-float-field-rounding format We had already some discussion about local settings, storing and output of PHP-Values of Type (float). And Ryan did some Adjustments with number_format. But I don't trust completely, thats why I am using Textfields to store numbers. Would be nice to have a consistent Fieldtype working in different local-settings. Thread treating the same problem https://processwire.com/talk/topic/4123-decimal-point-changed-to-in-base-of-setlocale/ https://processwire.com/talk/topic/86-float-field-rounding What is a float (floating point value), what is decimal? A float is an approximate value and exactly like this it is stored in Mysql. For more understanding two examples. 1. example CREATE TABLE `test` ( `test_float` float(10,2) NOT NULL, `test_decimal` decimal(10,2) NOT NULL ); INSERT INTO `test` (`test_float`, `test_decimal`) VALUES (5.43, 5.43); SELECT (test_float * 1.0000000) AS f, (test_decimal * 1.0000000) AS d FROM test; This will result the following: f = 5.4299998 and d = 5.430000000 source: http://netzgewe.be/2012/03/mysql-und-waehrungsbetraege-float-vs-decimal/ (german) 2. example mysql> create table numbers (a decimal(10,2), b float); mysql> insert into numbers values (100, 100); mysql> select @a := (a/3), @b := (b/3), @a * 3, @b * 3 from numbers \G *************************** 1. row *************************** @a := (a/3): 33.333333333 @b := (b/3): 33.333333333333 @a + @a + @a: 99.999999999000000000000000000000 @b + @b + @b: 100 source: http://stackoverflow.com/questions/5150274/difference-between-float-and-decimal-data-type INFO & LEARNING http://stackoverflow.com/questions/5150274/difference-between-float-and-decimal-data-type http://stackoverflow.com/questions/4520620/float-precision-problem-in-mysql http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html INTENTION The intention of this thread is to discuss good solutions for a consistent working FieldtypeFloat which makes clear to Everybody what it is via description. Furthermore to build a new Fieldtype with setting options of total lenght and decimal places. NOTES Please use this thread rather for development than as a help forum. BTW I am not an expert in Mysql PHP or whatever. Maybe there are some guys in the forum which could put the real good stuff here. Thanks a lot and lets go.
  14. This makes the messages visible. found here: https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?p=50501 My post was not ready to use. Sorry. Just another approach. If I have something working well and secure I will post it here. Another way is to start from here. @Adrian: Thanks for the hint.
  15. Hi Adrian, oops ... thanks for correction. I didn't tested it well. To hide the Continue and get a Logout link instead this should work if (isset($_GET['logout'])) { $session->logout(); $session->redirect($page->url); } if($user->isLoggedin()) { echo "<a href='{$page->url}?logout'>Logout</a>"; } else { echo $login->execute(); } It should be possible to set show/hide user-template-fields in the User-Profil with the Module-Settings or is this not selectable for custom admin-themes? in the example below I put some more fields to the user template. modules > Process User Profile > Settings
  16. Another possible and very simple way to setup a Frontend-login: Use the ProcessLogin.module from core within a login Template. <?php /** * Frontend Login template * */ include("./head.inc"); echo = $modules->get('ProcessLogin')->execute(); include("./foot.inc"); or to prevent from redirecting with a few lines more code <?php /** * Frontend Login template * */ include("./head.inc"); //to prevent from redirecting to backend, happens anyway only if loggedIn User has permission page-edit function noRedirect($event) { $event->replace = true; $event->return = $config->urls->root; } $login = $modules->get('ProcessLogin'); $login->addHookAfter('afterLoginRedirect', null, 'noRedirect'); echo $login->execute(); include("./foot.inc"); same works with Profile after login echo $modules->get('ProcessProfile')->execute(); Don't reinvent the wheel like me very often. To customize the output look here http://processwire.com/api/hooks/
  17. Hi Ole, create new permission called 'field-admin' add this permission to the role you named 'Editor User' The Editor will get the Tab 'Setup' with Submenu 'Fields' Now he can add/edit field settings. Unfortunately for all fields like admin If you want to limit the list to only a few field, then you have to write your first module which hooks in 'ProcessField.module'. Its more for advanced PW Users ... but just in case: - take the following module (tested in PW 2.4.18) put it in site/modules Folder - install module - create new permission called 'field-editor' - add this permission to the role you named 'Editor User' or what ever - create a new page 'MyFieldeditor' under admin/setup/ with template admin. - select Process: ProcessFieldEditor - now the 'Editor User' will find a Setup Tab with Submenu 'MyFieldeditor' - only the fields you have set in the Module will be visible in the list <?php /** * ProcessWire Module * * * first approach by kixe * */ class ProcessFieldEditor extends ProcessField implements ConfigurableModule { public static function getModuleInfo() { return array( 'title' => __('Fields', __FILE__), 'summary' => __('Edit settings of individual fields by Role field-editor', __FILE__), 'version' => 100, 'permission' => 'field-editor', // add this permission if you want this Process available for roles other than Superuser 'icon' => 'cube', ); } /** * settings * IDs of fields to show in the table * better to make a configurable module */ protected $data = array(164,123,111); protected function ___getCustomListTable($fields) { $table = $this->modules->get("MarkupAdminDataTable"); $headerRow = array( $this->_x('Name', 'list thead'), $this->_x('Label', 'list thead'), $this->_x('Type', 'list thead'), $this->_x('Templates', 'list thead quantity') ); $table->headerRow($headerRow); $table->setEncodeEntities(false); $numRows = 0; foreach($fields as $field) { if (!in_array($field->id,$this->data)) continue; $row = $this->getListTableRow($field); if(!empty($row)) { $table->row($row); $numRows++; } } if(!$numRows) $table->row(array($this->_("No fields matched your filter"))); return $table; } /** * Render a list of fields set in modules configuration * */ public function ___execute() { $out .= $this->getCustomListTable($this->fields)->render(); $out .= "\n</div><!--/#ProcessFieldList-->"; return $out; } } I put it together quickly. So no guarantee. Just a first approach to show one of millions possibilities to customize Processwire very easy. Thats why it is genious and I like it so much.
  18. Thanks for your help. It works with last dev.
  19. Hi Nico, Module downloaded & installed, got confirmation for this. Not visible in Modules, not visible in ModulesManager either Delete button is there, but got Error: 'The requested process does not exist' after trigger. Modul exists in site/modules/folder What happend??? (PW 2.4 Master-branch) It works with last dev ...
  20. Tried to install the module, got this: Error: Class EmailNewUser contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Module::getModuleInfo)
  21. You are right. Thanks ...
  22. Just to know: Map Marker Fieldtype doesn't work together with Firefox- Add-on: HTTPS Everywhere. (Version: Firefox 28.0 Mac, HTTPS Everywhere 3.5)
  23. Hi, you didn't understand me right. In generally you have 2 options: Module or Template. Module: There exists a sitemap-module made by Pete. Module-Download and Instructions on the modules page: http://modules.processwire.com/modules/markup-sitemap-xml/ Template: Template made by Ryan: https://processwire.com/talk/topic/3846-how-do-i-create-a-sitemapxml/ Both can be used on single and multi-language sites. Use Module OR Template. The template, which you can download from my post above is a modification of Ryans Template and works only on multilanguage sites, don't use it together with the hard coded sitemap-index I have posted. I don't use twig and I don't know how to implement it in PW. But I think it is easier and faster just to use php-Templates with PW-Api. Read PW Instructions and you will see how easy the use is. If you want to talk about twig, Hanna Code or whatever find the right thread or start a new one.
  24. Hi mike-anthony, welcome to the forum. Did you follow Ryans instructions? Do you use it with multi language site? 1. Copy this file to /site/templates/sitemap-xml.php 2. Add the new template from the admin. Under the "URLs" section, set it to NOT use trailing slashes. 3. Create a new page at the root level, use your sitemap-xml template and name the page "sitemap.xml". more: http://processwire.c...e-a-sitemapxml/ Just to be clear. This (download link from my post 19 March 2014) is a modified Version of Ryans Template with multi language support recommended by google. I don't use it by myself. I have a hard-coded sitemap-index and use Ryans Template for language specific sitemaps, which works perfectly. <?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap> <loc>http://example.com/de/sitemap.xml</loc> </sitemap> <sitemap> <loc>http://example.com/en/sitemap.xml</loc> </sitemap> </sitemapindex> <!-- call this file sitemap.xml put it in the root directory -->
  25. I think there is a bug in ProcessPageAdd Module. PW 2.4.0 If I try to add an Page by selecting a template with the big button on the right side in Admin 'Add New' and no parent site is given as GET Parameter like: http://example.org/admin/page/add/?template_id=37 the form will appear not complete and without submit button. EDIT: 10 min later .... Ah, its not the module its the Javascript ProcessPageAdd.js. If there is only one page in the list to select, the selection cannot be changed, and the submit button doesn't appear.
×
×
  • Create New...