function getSearchResults($function_name, $description = TRUE)
 {
     $this->db - like('Name', $function_name);
     $this->db - orderby('Name');
     $query = $this->db->get('Items');
     if ($query->num_rows() > 0) {
         $output = '<ul>';
         foreach ($query->result() as $function_info) {
             if ($description) {
                 $output .= '<li><strong>' . $function_info->name . '</strong></>';
                 $output .= $function_info->function_description . '</li>';
             } else {
                 $output .= '<li>' . $function_info->function_name . '</li>';
             }
         }
         $output = '</ul>';
         return $output;
     } else {
         return '<p> Sorry No Search Results </p>';
     }
 }
Example #2
0
 /**
  * Model definition.
  */
 function define()
 {
     // Fields.
     $this->fields = array('id', 'slug', 'name', 'fields', 'inputs', 'subscribers', 'date_created', 'date_updated', 'fields' => function ($channel) {
         return orderby($channel['fields'], 'sort');
     }, 'fields_by_id' => function ($channel) {
         return Channels::get_fields_by_id($channel);
     }, 'entries' => function ($channel) {
         return get("/entries", array('channel_id' => $channel['id']));
     }, 'entry_count' => function ($channel) {
         return get("/entries/:count", array('channel_id' => $channel['id']));
     });
     $this->search_fields = array('name');
     // Indexes.
     $this->indexes = array('id' => 'unique', 'slug' => 'unique');
     // Query defaults.
     $this->query = array('order' => 'name ASC');
     // Validate.
     $this->validate = array('required' => array('name', 'slug'), 'unique' => array('slug'), ':fields' => array('required' => array('id', 'name', 'type'), 'unique' => array('id')));
     // Event binds.
     $this->binds = array('POST' => function ($event) {
         $data =& $event['data'];
         // Auto slug?
         if ($data['name'] && !$data['slug']) {
             $data['slug'] = hyphenate($data['name']);
         }
     }, 'POST.fields' => function ($event) {
         $data =& $event['data'];
         // Default field ID to underscored field name.
         if (isset($data['name']) && !$data['id']) {
             $data['id'] = underscore($data['name']);
         }
     });
 }
Example #3
0
     }
     editThread($threadid);
     break;
 case "submit_link":
     $link = "";
     if (isset($_REQUEST['link'])) {
         $link = $_REQUEST['link'];
     }
     submitLink($link);
     break;
 case "orderby":
     $orderby = "";
     if (isset($_REQUEST['orderby'])) {
         $orderby = $_REQUEST['orderby'];
     }
     orderby($orderby);
     break;
 case "interests_option":
     $orinterests_optionderby = "";
     if (isset($_REQUEST['interests_option'])) {
         $interests_option = $_REQUEST['interests_option'];
     }
     interests_option($interests_option);
     break;
 case "load_recent_category_topics":
     $categoryid = "";
     if (isset($_REQUEST['categoryid'])) {
         $categoryid = $_REQUEST['categoryid'];
     }
     loadRecentCategoryTopics($categoryid);
     break;
Example #4
0
 /**
  * Model definition.
  */
 function define()
 {
     // Fields.
     $this->fields = array('id', 'order_id', 'name', 'phone', 'address', 'city', 'state', 'zip', 'country', 'method', 'tracking', 'items', 'date_created', 'date_updated', 'items' => function ($shipment) {
         return get("/products", array(':with' => $shipment['items']));
     }, 'order' => function ($shipment) {
         return get("/orders/{$shipment['order_id']}");
     }, 'carrier' => function ($shipment) {
         return Shipments::get_carrier($shipment);
     });
     $this->search_fields = array('name', 'address');
     // Validate.
     $this->validate = array('required' => array('order_id', 'name', 'address', 'city', 'state', 'method', 'tracking'), ':items' => array('required' => array('id', 'quantity')));
     // Event binds.
     $this->binds = array('GET' => function ($event, $model) {
         $params =& $event['data'];
         // Get shipping methods?
         if ($event['id'] == "methods") {
             $methods = array();
             // Trigger special context event.
             $methods = trigger('shipments', 'methods', $methods, $params, $model);
             // Process default shipping methods?
             if (empty($methods)) {
                 $methods = Shipments::process_default_methods($methods, $params);
             }
             // No methods exist?
             if (!empty($methods)) {
                 // Order methods by price.
                 if ($params) {
                     $methods = orderby($methods, 'price');
                 }
                 // Direct result.
                 return array('result' => $methods);
             }
             return false;
         }
     }, 'POST' => function ($event) {
         $data =& $event['data'];
         if ($data['order_id'] && ($order = get("/orders/{$data['order_id']}"))) {
             // Default data from order.
             $data = array_merge((array) $order['shipping'], $data);
             $data['name'] = $data['name'] ?: $order['name'];
             $data['phone'] = $data['phone'] ?: $order['phone'];
             // Filter shipment items.
             $shipment_items = array();
             foreach ($order['items'] as $order_item_id => $item) {
                 // Specific items? Otherwise defaults to all order items.
                 if (is_array($data['items'])) {
                     $add_this_item = false;
                     foreach ($data['items'] as $data_item) {
                         if (is_array($data_item) && $data_item['order_item_id'] == $order_item_id) {
                             $add_this_item = true;
                         }
                     }
                     if ($add_this_item === false) {
                         continue;
                     }
                 }
                 // Bundle?
                 if ($item['items']) {
                     foreach ($item['items'] as $i) {
                         $shipment_items[++$ship_item_id] = array('id' => $i['id'], 'quantity' => $i['quantity'] * $item['quantity'], 'order_item_id' => $order_item_id);
                     }
                 } else {
                     $shipment_items[++$ship_item_id] = array('id' => $item['id'], 'quantity' => $item['quantity'], 'order_item_id' => $order_item_id);
                 }
             }
             // Filtered.
             $data['items'] = $shipment_items;
         }
     }, 'PUT, POST' => function ($event, $model) {
         $data =& $event['data'];
         if ($data['items']) {
             // Clean items data if ID missing.
             foreach ((array) $data['items'] as $id => $item) {
                 if (!$item['id'] || !$item['quantity']) {
                     unset($data['items'][$id]);
                 }
             }
             // Shipment requires at least 1 item.
             if (count($data['items']) == 0) {
                 $model->error('Must contain at least one item', 'items');
             }
         }
     }, 'after:POST, after:PUT' => function ($result, $event) {
         $data =& $event['data'];
         if ($result) {
             // Send shipment e-mail?
             if ($data[':email']) {
                 $settings = get("/settings/emails/shipment");
                 if ($settings !== false) {
                     $settings['shipment'] = $result;
                     $settings['to'] = $result['order']['account']['email'];
                     // Default subject?
                     if ($settings['subject']) {
                         $settings['subject'] .= ' #' . $result['order']['id'];
                     }
                     // Override default email?
                     if (is_array($data[':email'])) {
                         $settings = array_merge($settings, $data[':email']);
                     }
                     post("/emails/shipment", $settings);
                 }
             }
             if ($result['order_id']) {
                 // Set date_shipped on order?
                 if (!$result['order']['date_shipped']) {
                     put("/orders/{$result['order_id']}", array('date_shipped' => $result['date_created']));
                 } else {
                     if ($result['is_cancelled']) {
                         if (count($result['order']['shipments']) == 1) {
                             put("/orders/{$result['order_id']}", array('date_shipped' => null));
                         }
                     }
                 }
             }
         }
     }, 'after:DELETE' => function ($result, $event) {
         if ($result) {
             // Last shipment of an order? Unset date shipped.
             if ($result['order']['shipments']['count'] == 0) {
                 put("/orders/{$result['order_id']}", array('date_shipped' => null));
             }
         }
     });
 }
Example #5
0
 /**
  * Model definition.
  */
 function define()
 {
     // Fields.
     $this->fields = array('id', 'slug', 'name', 'price', 'cost', 'sku', 'weight', 'description', 'category_ids', 'variants', 'items', 'stock', 'images', 'is_bundle', 'is_active', 'date_created', 'date_updated', 'items' => function ($product) {
         return get("/products", array(':with' => orderby($product['items'], 'sort')));
     }, 'weight' => function ($product) {
         return Products::get_weight($product);
     }, 'categories' => function ($product) {
         return get("/categories", array('id' => array('$in' => (array) $product['category_ids'])));
     });
     // Search fields.
     $this->search_fields = array('name', 'sku', 'description');
     // Indexes.
     $this->indexes = array('id' => 'unique', 'slug' => 'unique', 'sku');
     // Validate.
     $this->validate = array('required' => array('slug', 'name', 'price'), 'unique' => array('slug', 'sku'), ':items' => array('required' => array('id', 'quantity')));
     // Event binds.
     $this->binds = array('GET' => function ($event) {
         $data =& $event['data'];
         // Get by category ID or slug.
         if ($data['category']) {
             if ($category = get("/categories/{$data['category']}")) {
                 $data['category_ids'] = $category['id'];
                 unset($data['category']);
             } else {
                 // Category not found.
                 return false;
             }
         }
         // Default category sort?
         if (!$data['order'] && is_numeric($data['category_ids'])) {
             $data['order'] = "category_sort.{$data['category_ids']}";
         }
         if ($data['pricing']) {
             // Avoid conflicts with actual pricing field.
             $data[':pricing'] = $data['pricing'];
             unset($data['pricing']);
         }
     }, 'POST' => function ($event) {
         $data =& $event['data'];
         // Auto slug?
         if ($data['name'] && !$data['slug']) {
             $data['slug'] = hyphenate($data['name']);
         }
     }, 'POST, PUT' => function ($event, $model) {
         $data =& $event['data'];
         // Set product categories?
         if (isset($data['categories'])) {
             foreach ((array) $data['categories'] as $category_id) {
                 if (!is_numeric($category_id)) {
                     $category = get("/categories/{$category_id}");
                     $category_id = $category['id'];
                 }
                 if ($category_id) {
                     $data['category_ids'][] = $category_id;
                 }
             }
             unset($data['categories']);
         }
         // Updating category ids?
         if (is_array($data['category_ids'])) {
             sort($data['category_ids']);
         }
     }, 'POST.variants' => function ($event) {
         $data =& $event['data'];
         // Unset default override keys
         if (!$data['sku']) {
             unset($data['sku']);
         }
         if (!$data['price']) {
             unset($data['price']);
         }
     }, 'after:GET' => function ($result, $event) {
         $data =& $event['data'];
         if ($result && $data[':pricing']) {
             // Handle special pricing.
             $result = Products::get_pricing($result, $data[':pricing']);
         }
     });
 }
Example #6
0
<h1 class="center">Sortera filmer</h1>
<p class="center">Alla filmer i databasen:</p>

<?php 
/**
 * Function to create links for sorting
 */
function orderby($column)
{
    return "<span class='orderby'>" . "<a href='?p=moviesort&amp;orderby={$column}&amp;order=asc' class='sortButton'>&darr;</a>" . "<a href='?p=moviesort&amp;orderby={$column}&amp;order=desc' class='sortButton'>&uarr;</a>" . "</span>";
}
$tr = "<tr><th>Rad</th><th>Id " . orderby('id') . "</th><th>Bild</th><th>Titel " . orderby('title') . "</th><th>År " . orderby('year') . "</th><th>Genre</th></tr>";
// Get parameters for sorting
$orderby = isset($_GET['orderby']) ? strtolower($_GET['orderby']) : 'id';
$order = isset($_GET['order']) ? strtolower($_GET['order']) : 'asc';
// Check that incoming is valid
in_array($orderby, array('id', 'title', 'year')) or die('Check: Not valid column.');
in_array($order, array('asc', 'desc')) or die('Check: Not valid sort order.');
//connect to database
$db = new CDatabase($urbax['database']);
//build query-string
$sql = "SELECT * FROM VMovie ORDER BY {$orderby} {$order};";
//run query
$res = $db->ExecuteSelectQueryAndFetchAll($sql);
//build table
echo "<table class='table'>";
echo $tr;
foreach ($res as $i => $row) {
    echo "<tr><td>{$i}</td><td>{$row->id}</td><td><img src='{$row->image}' alt='bild på film' width='100' height='50'></td><td>{$row->title}</td><td>{$row->year}</td><td>{$row->genre}</td></tr>";
}