Skip to content

Instantly share code, notes, and snippets.

View tedkulp's full-sized avatar

Ted Kulp tedkulp

View GitHub Profile
<?php
if (!function_exists('getPageChooser')) {
function getPageChooser($pageLinks=array(), $activeIndexNumber=0, $previousText="Previous", $nextText="Next", $firstVisableNumber=1) {
// This function takes an array with links and makes a nice page chooser from it.
// The index of the array is 0 based, so is the activeIndexNumber.
// Make firstVisableNumber 0 if you want to see pagenumbers start with 0 (Why would you???).
$pagermenu = array();
if (!is_array($pageLinks)) return "";
$pageLinksCount = count($pageLinks);
<?php
#-------------------------------------------------------------------------
# Module: Cart - A simple example frontend form module
# Version: 1.0, calguy1000 <calguy1000@cmsmadesimple.org>
#
#-------------------------------------------------------------------------
# CMS - CMS Made Simple is (c) 2005 by Ted Kulp (wishy@cmsmadesimple.org)
# This project's homepage is: http://www.cmsmadesimple.org
# The module's homepage is: http://dev.cmsmadesimple.org/projects/skeleton/
#
<?php
include 'lib/silk/silk.api.php';
SilkDatabase::connect('mysql://root:@localhost/cms_innodb', true, true, 'cms_');
$users = orm('user')->find_all(array('order' => "id ASC"));
var_dump($users[0]->full_name());
var_dump($users[0]->groups[0]->name);
<?php
include_once('lib/silk/silk.api.php');
$config = SilkYaml::load(join_path(ROOT_DIR, 'config', 'setup.yml'));
include_once('config/routes.php');
//SilkDatabase::connect($config['database']['dsn'], $config['debug'], true, $config['database']['prefix']);
We couldn’t find that file to show.
<?php
class TestController extends SilkControllerBase
{
function test_action($params)
{
$this->set('test', 'Controller Works!');
}
function test_ajax($params)
As I've worked on CMSMS 2.0, I've run into a few recurring issues
that I didn't quite have an answer or reason for yet...
1. I wrote a lot of very generic pieces of code in order to make 2.0
easier to develop in the long run. I think I might've gone overboard
a bit. I wasn't ever sure why.
2. As a professional developer, I kept running into issues where I wanted
to use some of that code for other stuff. And it was too difficult to just
pull out the piece I needed and didn't do it.
<?php
class LoginController extends SilkControllerBase
{
function index($params)
{
$user_session = new SilkUserSession($params['login']);
if ($user_session->login())
{
//redirect('')
<?php
//Automatically add some component routes -- see docs for details
//SilkRoute::build_default_component_routes();
SilkRoute::register_route("/admin/:controller/:action/:id", array("component" => 'admin'));
SilkRoute::register_route("/admin/:controller/:action", array("id" => '', "component" => 'admin'));
SilkRoute::register_route("/admin/:controller", array("id" => '', 'action' => 'index', "component" => 'admin'));
//Catch-all goes here
<?php
//Automatically add some component routes -- see docs for details
//SilkRoute::build_default_component_routes();
SilkRoute::register_route("/admin/:controller/:action/:id", array("component" => 'admin'));
SilkRoute::register_route("/admin/:controller/:action", array("id" => '', "component" => 'admin'));
SilkRoute::register_route("/admin/:controller", array("id" => '', 'action' => 'index', "component" => 'admin'));
//Catch-all goes here