Skip to content

Instantly share code, notes, and snippets.

@snetty
snetty / _form_field_checkboxlist.htm
Created January 16, 2013 13:12
add search to frm_checkboxlist's
<?
$dbName = $this->formGetFieldDbName($form_field->dbName, $this->viewData['form_model']);
$options = $this->formFieldGetOptions($form_field->dbName, $this->viewData['form_model']);
$list_search_prompt = isset($form_field->list_search_prompt) ? $form_field->list_search_prompt : 'Search ' . strtolower($dbName) . '...';
$list_load_indicator = isset($form_field->list_load_indicator) ? $form_field->list_load_indicator : 'phproad/resources/images/form_load_50x50.gif';
$container_id = $dbName.'_cb_container';
?>
@snetty
snetty / gist:4721536
Created February 6, 2013 09:55
set default shipping and payment methods in lemonstand
public function extend_order_model($order){
if($order->is_new_record()){
$order->shipping_method = Shop_ShippingOption::create()->find_by_ls_api_code('no_shipping_required');
$order->payment_method = Shop_PaymentMethod::create()->find_by_ls_api_code('default');
}
}
@snetty
snetty / php_datetime_default_format
Created February 6, 2013 11:37
Phpr_DateTime load default format
Phpr::$lang->date(Phpr_DateTime $date, '%F %X');
$this->list_custom_body_cells = PATH_APP . '/modules/hosting/controllers/hosting_domains/_list_body_front_cells.htm';
$this->list_custom_head_cells = PATH_APP . '/modules/hosting/controllers/hosting_domains/_list_head_front_cells.htm';
$this->list_handle_row_click = false; #switches to double click
@snetty
snetty / easy_string_search_functions.php
Created March 1, 2013 12:42
easy to remember string search functions
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}
function begins_with($haystack, $needle){
return strpos($haystack, $needle) === 0;
}
function ends_with($haystack, $needle){
return strlen($haystack) - strlen($needle) === strrpos($haystack,$needle);
@snetty
snetty / blahblah_module.php
Last active December 14, 2015 09:19
improves the auto footprints class by adding a "last interaction" column
Backend::$events->addEvent('core:onBeforeListRecordDisplay', $this, 'extend_auto_footprints');
public function extend_auto_footprints($controller, $model_class, $model){
$controller->list_cell_individual_partial['last_interaction'] = 'modules/hosting/controllers/partials/last_interaction.htm';
}
@snetty
snetty / extended_activerecord.php
Created May 21, 2013 12:09
Import form fields and columns from one model to another
<?php
class Extended_ActiveRecord extends Db_ActiveRecord{
public function import_column_definitions(Db_ActiveRecord $model, $context=null){
My_Helper::import_column_definitions($model, $this, $context);
}
public function import_form_field_definitions(Db_ActiveRecord $model, $context=null, $force_tab=null){
My_Helper::import_form_field_definitions($model, $this, $context, $force_tab);
}
@snetty
snetty / pagination
Created November 8, 2013 09:57
Lemonstand Pagination for Bootstrap
<?
$curPageIndex = $pagination->getCurrentPageIndex();
$pageNumber = $pagination->getPageCount();
$suffix = isset($suffix) ? $suffix : null;
?>
<? if($pageNumber != 1) : ?>
<div class="text-center">
<ul class="pagination">
<li>
<a href="#" class="disabled">
@snetty
snetty / blog:archive
Created November 8, 2013 09:59
lemonstand pagination usage
<?
$page_index = $this->request_param(-1, 1) - 1;
$records_per_page = 5;
$pagination = $posts->paginate($page_index, $records_per_page);
$posts = $posts->find_all();
?>
<? if($posts->count() != 0) : ?>
<div class="post_list">
<? foreach ($posts as $post): ?>
<? $this->render_partial('blog:post', array('post' => $post, 'base_url'=>$base_url, 'post_designation' => $post_designation)); ?>
<? $parents = $this->page->navigation_parents(false); ?>
<div class="breadcrumbs hidden-print">
<div class="container">
<ol class="breadcrumb">
<? $why = array(); $home = CMS_Page::findByUrl('/', $why); ?>
<li><a href="<?= $home->url ?>"><?= $home->navigation_label() ?></a></li>
<? foreach ($parents as $parent) : ?>
<li><a href="<?= $parent->url ?>"><?= $parent->navigation_label() ?></a></li>
<? endforeach; ?>