Skip to content

Instantly share code, notes, and snippets.

View Da-Fecto's full-sized avatar

Martijn Geerts Da-Fecto

View GitHub Profile
/**
* OpenSSL encrypt/decrypt for ProcessWire
*
* $encryptDecrypt = new \ProcessWire\OpenSSLencryptDecrypt();
* $encrypted = $encryptDecrypt->encrypt('My Text');
* $decrypted = $encryptDecrypt->decrypt($encrypted);
*/
class OpenSSLencryptDecrypt extends Wire {
/**
// $pfields = $page->templates->fields;
$fg = $fieldgroups->get('item');
$allFields = $fg->fields->getAll();
$item = $pages->get('template=item');
$allFields = $item->template->fields;
$lorem_long = array(
<?php namespace ProcessWire;
require($config->paths->templates . 'Spout/Autoloader/autoload.php');
use Box\Spout\Writer\WriterFactory;
use Box\Spout\Common\Type;
@Da-Fecto
Da-Fecto / live-page-name.js
Created January 17, 2016 18:06
Live typed pagename.
/**
* Mapping 01
*
* Text manipulator for the set name. The set name must be compatible with Page name.
*
*/
$(function () {
/**
* Build valid/restricted filenames
@Da-Fecto
Da-Fecto / conditional-sql.php
Created November 19, 2015 09:16
Conditional SQL on config
/**
* Installer: HTTP Hosts Whitelist
*
*/
$config->httpHosts = array('domain-01.dev', 'domain-02.dev', 'domain-03.dev', 'domain-04.ext');
/**
* Development settings (Switch settings based on domainname.)
*
@Da-Fecto
Da-Fecto / DescriptionNoteVariables.php
Created October 19, 2015 05:33
Replace PW page variable in field descriptions and notes, eg: [Click Here]({page.parent.url}) for creating a link to the parent page.
<?php
/**
* Replace PW page variable in field descriptions and notes, eg: [Click Here]({page.parent.url})
* for creating a link to the parent page.
*
* @author adrianbj (https://gist.github.com/adrianbj/5dc1c00f1617b2639319)
*/
class DescriptionNoteVariables extends WireData implements Module {
<?php
function getPartial($path_to_file) {
ob_start();
include($path_to_file);
return ob_get_clean();
}
$partial = getPartial($config->urls->templates . 'partials/myfile.php');
<?php
array('icon-glass','music','search','envelope-alt','heart','star','star-empty','user','film','th-large','zoom-out','off','signal','cog','trash','home','file-alt','time','road','download-alt','refresh','list-alt','lock','flag','headphones','volume-off','volume-down','volume-up','qrcode','camera','font','bold','italic','text-height','text-width','align-left',''align-center','align-right','align-justify','pencil','map-marker','adjust','tint','edit','share','check','move','step-backward','fast-backward','fast-forward','step-forward','eject','chevron-left','chevron-right','plus-sign','minus-sign','remove-sign','ok-sign','question-sign','arrow-left','arrow-right','arrow-up','arrow-down','share-alt','resize-full','resize-small','plus','minus','asterisk','eye-close','warning-sign','plane','calendar','random','comment','magnet','chevron-up','chevron-down','retweet','bar-chart','twitter-sign','facebook-sign','camera-retro','key','cogs','comments','thumbs-up-alt','thumbs-down-alt','star-half','signin','trophy','gi
<?php
// Module from ryan....
class CustomPageRoles extends WireData implements Module {
/**
* Provide information about this module to ProcessWire
*
*/
// author: 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];
}