Skip to content

Instantly share code, notes, and snippets.

@kongondo
kongondo / example-recursive-function1a.php
Last active August 30, 2023 08:45
Menu Builder getMenuItems() Examples
<?php
/**
* Builds a nested list (menu items) of a single menu.
*
* A recursive function to display nested list of menu items.
*
* @access private
* @param Int $parent ID of menu item.
* @param Array $menu Object of menu items to display.
@kongondo
kongondo / MimeTypes.php
Created February 19, 2016 18:58 — forked from nimasdj/MimeTypes.php
List of MimeTypes mapped to file extensions
<?php
// I made this array by joining all the following lists + .php extension which is missing in all of them.
// please contribute to this list to make it as accurate and complete as possible.
// https://gist.github.com/plasticbrain/3887245
// http://pastie.org/5668002
// http://pastebin.com/iuTy6K6d
// total: 1223 extensions as of 16 November 2015
$mime_types = array(
'3dm' => array('x-world/x-3dmf'),
'3dmf' => array('x-world/x-3dmf'),
@kongondo
kongondo / remote-file-copy.php
Created January 14, 2016 13:01
Remote file copying with progress reporting in PHP.
<?php
/*
* Remote File Copy PHP Script 2.0.0
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
@kongondo
kongondo / Multisite.module.php
Last active August 29, 2015 14:27 — forked from LostKobrakai/Multisite.module.php
Multisite routing for ProcessWire
<?php
// source: https://processwire.com/talk/topic/680-multiple-sites-from-one-install/?p=8778
class Multisite extends WireData implements Module, ConfigurableModule {
public static function getModuleInfo() {
return array(
'title' => 'Multisite',
'version' => 1,
@kongondo
kongondo / blogCleaner
Last active August 29, 2015 14:14
Blog 2 Cleanup Utility in case you mistakenly uninstalled Blog without first running the inbuilt Cleanup Utility
<?php
/**
*
* CONTEXT: This is a utility class for 'cleaning-up' Blog in case you uninstalled Blog without first running its inbuilt Cleanup utility.
*
* WARNING: The utility will irreversibly delete the following Blog Components
* Fields (blog_xxx)
* Templates (blog-xxx)
* Optionally Template Files (in case you installed the blank/demo Template Files) (blog-xxx.php/inc)
@kongondo
kongondo / renderPosts
Last active June 21, 2021 02:53
ProcessWire. MarkupBlog's renderPosts() as an independent reusable and editable function outside Blog
function renderPosts($posts, $small = false, Array $options = null) {
$blogConfigs = wire('modules')->getModuleConfigData('ProcessBlog');
//intialise some properties from ProcessBlog config
$commentsUse = $blogConfigs['commentsUse'];
$authorsPage = wire('pages')->get($blogConfigs['blog-authors']);
$settingsPage = wire('pages')->get($blogConfigs['blog-settings']);
@kongondo
kongondo / member.login.php
Last active August 29, 2015 14:00
ProcessWire: Code example - front-end system to handle logins, password resets and changing passwords
<?php
/*
Code by Ryan Cramer
Integrating a member visitor login form
https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?p=15919
*/
/*
I recently had to setup front-end system to handle logins, password resets and changing passwords, so here's about how it was done. This should be functional code, but consider it pseudocode as you may need to make minor adjustments here and there. Please let me know if anything that doesn't compile and I'll correct it here.
<?php
/**
* Adding other types of save buttons for page edit form.
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
* http://www.processwire.com
@kongondo
kongondo / hide-page-tree.php
Last active December 10, 2018 03:17
ProcessWire. Code to hide page tree in the admin
<?php
/*
CODE COPIED FROM https://processwire.com/talk/topic/6142-hide-page-tree-in-the-admin/
One hook returns false for Page::viewable() for the ProcessPageList page.
Another Hook can be used to redirect users to a custom admin page after login.
*/
// This needs to be an autoload module
public function init() {
@kongondo
kongondo / data.php
Created March 12, 2014 00:41 — forked from jjb3rd/data.php
<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2012 - John Becker, Beckersoft, Inc.
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
class TableData {