Example #1
0
    ?>
><?php 
    echo $type;
    ?>
</option>
                            <?php 
}
?>
                            
                        </select>
                    </li>
                    <li>
                        <select name="filter[priority]" class="form-control" onchange="this.form.submit();">
                            <option value="">All Priorities</option>
                            <?php 
foreach (\Dsc\Mongo\Collections\Logs::distinctPriorities() as $type) {
    ?>
                            	<option value="<?php 
    echo $type;
    ?>
" <?php 
    if ($state->get('filter.priority') == $type) {
        echo "selected='selected'";
    }
    ?>
><?php 
    echo $type;
    ?>
</option>
                            <?php 
}
Example #2
0
 /**
  * \T (tab) delimited feed of products
  * 
  * http://www.pepperjamnetwork.com/doc/product_feed_advanced.html
  * 
  */
 public function productsTxt()
 {
     $settings = \Shop\Models\Settings::fetch();
     if (!$settings->{'feeds.pepperjam_products.enabled'}) {
         return;
     }
     $this->app->set('CACHE', true);
     $cache = \Cache::instance();
     $cache_period = 3600 * 24;
     if ($cache->exists('pepperjam.products_text', $string)) {
         header('Content-Type: text/plain; charset=utf-8');
         echo $string;
         exit;
     }
     $base = \Dsc\Url::base();
     $model = (new \Shop\Models\Products())->setState('filter.published_today', true)->setState('filter.inventory_status', 'in_stock')->setState('filter.publication_status', 'published');
     $conditions = $model->conditions();
     $conditions['product_type'] = array('$nin' => array('giftcard', 'giftcards'));
     $cursor = \Shop\Models\Products::collection()->find($conditions)->sort(array('title' => 1));
     //->limit(10);
     /**
      * name	sku	buy_url	image_url	description_short	description_long	price	manufacturer
      */
     $column_headers = array('name', 'sku', 'buy_url', 'image_url', 'description_short', 'description_long', 'price', 'manufacturer');
     $string = implode("\t", $column_headers) . "\r\n";
     foreach ($cursor as $product_doc) {
         $product = new \Shop\Models\Products($product_doc);
         foreach ($product->variantsInStock() as $variant) {
             $valid = true;
             $price = $product->price($variant['id']);
             // Skip products where price == 0.00
             if (empty($price)) {
                 continue;
             }
             $pieces = array('name' => null, 'sku' => null, 'buy_url' => null, 'image_url' => null, 'description_short' => null, 'description_long' => null, 'price' => null, 'manufacturer' => null);
             $pieces['name'] = $product->title;
             $sku = $variant['sku'] ? $variant['sku'] : $product->{'tracking.sku'};
             if (!$sku) {
                 $sku = $variant['id'];
             }
             $pieces['sku'] = $sku;
             $pieces['buy_url'] = $base . 'shop/product/' . $product->slug . '?variant_id=' . $variant['id'];
             // image_link
             if ($image = $variant['image'] ? $variant['image'] : $product->{'featured_image.slug'}) {
                 $pieces['image_url'] = $base . 'asset/' . $image;
             }
             $pieces['description_short'] = $product->title . ' ';
             if ($attribute_title = \Dsc\ArrayHelper::get($variant, 'attribute_title')) {
                 $pieces['description_short'] .= $attribute_title;
             }
             $pieces['description_short'] = trim($pieces['description_short']);
             $pieces['description_long'] = strip_tags($product->getAbstract());
             $pieces['price'] = $price;
             if ($brand = $settings->{'feeds.pepperjam_products.brand'}) {
                 $pieces['manufacturer'] = $brand;
             }
             global $product;
             //walk peices logging empty values and omiting them
             array_walk($pieces, function (&$value, $key) {
                 global $product;
                 if (empty($value)) {
                     \Dsc\Mongo\Collections\Logs::add($product->title . ' | ID: ' . $product->id . ' is missing ' . $key, 'WARNING', 'PepperJam');
                     $valid = false;
                 }
             });
             if ($valid) {
                 $string .= implode("\t", $pieces) . "\r\n";
             }
         }
     }
     $cache->set('pepperjam.products_text', $string, $cache_period);
     header('Content-Type: text/plain; charset=utf-8');
     echo $string;
     exit;
 }
Example #3
0
 /**
  *
  */
 private function buildLessCss()
 {
     $f3 = \Base::instance();
     $global_app_name = \Base::instance()->get('APP_NAME');
     $source_files = (array) $f3->get($global_app_name . '.dsc.minify.lesscss.sources');
     $less_files = array();
     if (!empty($source_files)) {
         $less = new \lessc();
         $n = 0;
         foreach ($source_files as $source_file) {
             $source = $source_file[0];
             $destination = !empty($source_file[1]) ? $source_file[1] : $f3->get('TEMP') . basename($source) . ".css";
             try {
                 if ($less->compileFile($source, $destination) !== false) {
                     $less_files[] = $destination;
                 }
             } catch (\Exception $e) {
                 \Dsc\Mongo\Collections\Logs::add($e->getMessage(), 'ERROR', __CLASS__ . '::' . __METHOD__);
             }
             $n++;
         }
     }
     return $less_files;
 }
Example #4
0
 /**
  * Make a Log entry in the logger
  * 
  * @param unknown $message
  * @param string $priority
  * @param string $category
  */
 public static function log($message, $priority = 'INFO', $category = 'General')
 {
     return \Dsc\Mongo\Collections\Logs::add($message, $priority, $category);
 }