예제 #1
0
파일: list.php 프로젝트: dioscouri/f3-shop
            <div class="list-group-item">
                
                <div class="row">
                    <div class="col-xs-2 col-md-1">
                        <input type="checkbox" class="icheck-input icheck-id" name="ids[]" value="<?php 
        echo $item->id;
        ?>
">
                    </div>
                    <div class="col-xs-10 col-md-3">
                        <?php 
        if ($item->groups) {
            ?>
                        <div class="pull-right">
                            <span class='label label-default'><?php 
            echo implode("</span> <span class='label label-default'>", \Dsc\ArrayHelper::getColumn((array) $item->groups, 'title'));
            ?>
</span>
                        </div>
                        <?php 
        }
        ?>
                        
                        
                        <h4>
                            <a href="./admin/shop/campaign/read/<?php 
        echo $item->id;
        ?>
">
                                <?php 
        echo $item->ancestorsIndentedTitle();
예제 #2
0
            dataType: 'json',
            data: function (term, page) {
                return {
                    q: term
                };
            },
            results: function (data, page) {
                return {results: data.results};
            }
        }
        <?php 
if ($flash->old('groups')) {
    ?>
        , initSelection : function (element, callback) {
            var data = <?php 
    echo json_encode(\Users\Models\Groups::forSelection(array('_id' => array('$in' => array_map(function ($input) {
        return new \MongoId($input);
    }, \Dsc\ArrayHelper::getColumn((array) $flash->old('groups'), 'id'))))));
    ?>
;
            callback(data);            
        }
        <?php 
}
?>
    });

});
</script>

<hr/>
예제 #3
0
<?php

if ($categories = \Shop\Models\Categories::find()) {
    ?>
<div>

<select name="category_ids[]" class="select2" >

    <?php 
    $current = \Dsc\ArrayHelper::getColumn((array) $flash->old('categories'), 'id');
    ?>
    <?php 
    foreach ($categories as $one) {
        ?>
    <option value="<?php 
        echo $one->_id;
        ?>
" <?php 
        if (in_array($one->_id, $current)) {
            echo "selected='selected'";
        }
        ?>
>
        <?php 
        echo @str_repeat("&ndash;", substr_count(@$one->path, "/") - 1) . " " . $one->title;
        ?>
    </option>
    <?php 
    }
    ?>
 
예제 #4
0
                                <p>
                                    <label>SKU:</label> <?php 
            echo $item->{'tracking.sku'};
            ?>
                                </p>
                                <?php 
        }
        ?>
                                
                                <?php 
        if ($item->{'categories'}) {
            ?>
                    			<p>			                        			
                    				<label>Categories:</label>
									<span class='label label-warning'><?php 
            echo implode("</span> <span class='label label-warning'>", \Dsc\ArrayHelper::getColumn((array) $item->{'categories'}, 'title'));
            ?>
</span>
                    			</p>                                
                                <?php 
        }
        ?>
                                
                                <?php 
        if ($item->{'tags'}) {
            ?>
                    			<p>
                    				<label>Tags:</label>
									<span class='label label-info'><?php 
            echo implode("</span> <span class='label label-info'>", (array) $item->tags);
            ?>
예제 #5
0
파일: Nested.php 프로젝트: dioscouri/f3-lib
 /**
  * Move this model one position to the right in the same level of the tree
  * 
  * @return \Dsc\Mongo\Collections\Nested
  */
 public function moveDown()
 {
     $this->rebuildTree($this->tree);
     // Get the sibling immediately to the left of this node
     $sibling = (new static())->load(array('tree' => $this->tree, 'lft' => $this->rgt + 1));
     // fail of no sibling found
     if (empty($sibling->id)) {
         return $this;
     }
     $ids = array();
     // Get the primary keys of descendant nodes, including this node's
     if ($descendants = $this->getDescendants()) {
         $ids = \Dsc\ArrayHelper::getColumn($descendants, '_id');
     }
     $width = (int) ($this->rgt - $this->lft + 1);
     $sibling_width = (int) ($sibling->rgt - $sibling->lft + 1);
     // Shift left and right values for the node and its children.
     $result = $this->collection()->update(array('lft' => array('$gte' => $this->lft, '$lte' => $this->rgt), 'tree' => $this->tree), array('$inc' => array('lft' => $sibling_width, 'rgt' => $sibling_width)), array('multiple' => true));
     // Shift left and right values for the sibling and its children
     // explicitly excluding the node's descendants
     $result = $this->collection()->update(array('_id' => array('$nin' => $ids), 'lft' => array('$gte' => $sibling->lft, '$lte' => $sibling->rgt), 'tree' => $this->tree), array('$inc' => array('lft' => -$width, 'rgt' => -$width)), array('multiple' => true));
     return $this;
 }
예제 #6
0
파일: left.php 프로젝트: WLR86/f3-admin
        <?php 
$pieces = explode('?', \Dsc\Pagination::checkRoute(str_replace($BASE, '', $URI)));
$current = $pieces[0];
$list = (new \Admin\Models\Nav\Primary())->setState('filter.root', false)->setState('filter.tree', \Admin\Models\Settings::fetch()->get('admin_menu_id'))->setState('order_clause', array('tree' => 1, 'lft' => 1))->getItems();
// push the default to the beginning of the list
array_unshift($list, new \Admin\Models\Nav\Primary(array('route' => './admin', 'title' => 'Dashboard', 'icon' => 'fa-home', 'depth' => 2)));
?>
        
        <ul>
        <?php 
foreach ($list as $key => $item) {
    if (!($hasAccess = \Dsc\System::instance()->get('acl')->isAllowed($identity->role, $item->route, '*'))) {
        continue;
    }
    $class = !empty($item->class) ? $item->class : 'menu-item';
    $selected = $current == $item->route || !empty($item->base) && strpos($current, $item->base . '/') !== false || \Dsc\String::inStrings(\Dsc\ArrayHelper::getColumn($item->getDescendants(), 'route'), $current);
    if ($selected || $current == str_replace('./', '/', $item->route)) {
        $class .= " active open";
    }
    if ($item->hasDescendants()) {
        $class .= " dropdown";
    }
    if (empty($item->route)) {
        $item->route = 'javascript:void(0);';
    } elseif ($item->route[0] == '/') {
        $item->route = '.' . $item->route;
    }
    echo '<li data-depth="' . $item->getDepth() . '" class="' . $class . '">';
    // is this a module?
    // or just a regular link?
    echo '<a href="' . $item->route . '" style="">';
예제 #7
0
파일: list.php 프로젝트: dioscouri/f3-blog
		                        			</div>
		                        			<div>
		                        				<label>Author:</label> <a href="./admin/user/edit/<?php 
        echo $item->{'author.id'};
        ?>
" title="<?php 
        echo $item->{'author.name'};
        ?>
"><?php 
        echo $item->{'author.name'};
        ?>
</a>
		                        			</div>
		                        			<div>
			                        			<?php 
        $categories = \Dsc\ArrayHelper::getColumn((array) $item->categories, 'title');
        ?>
		                        				<label>Categories:</label>
												<span class='label label-warning'><?php 
        echo implode("</span> <span class='label label-warning'>", (array) $categories);
        ?>
</span>
		                        			</div>
		                        			<div>
		                        				<label>Tags:</label>
												<span class='label label-info'><?php 
        echo implode("</span> <span class='label label-info'>", (array) $item->tags);
        ?>
</span>
		                        			</div>
		                        		</div>
예제 #8
0
</div>
                                    <div><label>Attributes:</label> <?php 
        echo (int) $item->{'attributes_count'};
        ?>
</div>
                                </div>
                            </div>
                        </div>
                        
                        <?php 
        if ($item->{'categories'}) {
            ?>
                        <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-12">
                                <label>Categories:</label> <?php 
            echo implode(", ", \Dsc\ArrayHelper::getColumn((array) $item->{'categories'}, 'title'));
            ?>
                            </div>
                        </div>
                        <?php 
        }
        ?>
                        
                        <?php 
        if ($item->{'tags'}) {
            ?>
                        <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-12">
                                <label>Tags:</label> <?php 
            echo implode(", ", (array) $item->{'tags'});
            ?>
예제 #9
0
			<i class="fa fa-dashboard"></i>
			Dashboard
		</a>	
	</li>
	
	<?php 
if ($items) {
    foreach ($items as $item) {
        ?>
	<li  <?php 
        if (!empty($item->id)) {
            echo 'id="' . $item->id . '"';
        }
        ?>
   class="<?php 
        if ($current == $item->route || !empty($item->base) && strpos($current, $item->base) !== false || \Dsc\String::inStrings(\Dsc\ArrayHelper::getColumn($item->children, 'route'), $current)) {
            echo 'active';
        }
        ?>
 <?php 
        echo !empty($item->children) ? 'dropdown' : null;
        ?>
 ">
		<a href="<?php 
        echo !empty($item->children) ? 'javascript:;' : '.' . $item->route;
        ?>
">
			<?php 
        if (!empty($item->icon)) {
            ?>
<i class="<?php 
예제 #10
0
<?php

if (!empty($groups)) {
    ?>

<div class="max-height-200 list-group-item">
	<?php 
    $current = \Dsc\ArrayHelper::getColumn((array) $flash->old('groups'), 'id');
    ?>
    <?php 
    foreach ($groups as $one) {
        ?>
    <div class="checkbox">
        <label>
            <input type="checkbox" name="groups[]" class="icheck-input" value="<?php 
        echo $one->_id;
        ?>
" <?php 
        if (in_array($one->_id, $current)) {
            echo "checked='checked'";
        }
        ?>
>
            <?php 
        echo $one->title;
        ?>
        </label>
    </div>
    <?php 
    }
    ?>
예제 #11
0
 /**
  * Returns an array of the product's variants, indexed by key
  * where key is an alphabetized, hyphenated string of each attribute's MongoId
  * 
  * @param unknown $cast
  * @return multitype:|multitype:multitype:string unknown multitype:Ambigous <string, unknown>
  */
 public static function buildVariants($cast)
 {
     $result = array();
     if (is_object($cast) && method_exists($cast, 'cast')) {
         $cast = $cast->cast();
     }
     if (!is_array($cast)) {
         return $result;
     }
     if (empty($cast['attributes'])) {
         // build the variants array for just the single variant
         $mongo_id = (string) new \MongoId();
         if (!empty($cast['variants'])) {
             $variants = array_values($cast['variants']);
             $mongo_id = !empty($variants[0]['id']) ? (string) $variants[0]['id'] : $mongo_id;
         }
         $variant = new \Shop\Models\Prefabs\Variant(array('id' => $mongo_id, 'key' => $mongo_id, 'attributes' => array(), 'attribute_titles' => array(), 'quantity' => (int) \Dsc\ArrayHelper::get($cast, 'quantities.manual')));
         $result[] = $variant->cast();
         return $result;
     }
     $ids = array();
     $traits = array();
     foreach ($cast['attributes'] as $attribute) {
         foreach ($attribute['options'] as $option) {
             $id = (string) $option['id'];
             if (empty($ids[$id])) {
                 if (is_numeric($option['value'])) {
                     $ids[$id] = $attribute['title'] . ": " . $option['value'];
                 } else {
                     $ids[$id] = $option['value'];
                 }
             }
         }
         $traits[] = \Dsc\ArrayHelper::getColumn($attribute['options'], 'id');
     }
     $combos = self::getCombinations("", $traits, 0, $combos);
     foreach ($combos as $key => $values) {
         $titles = array();
         foreach ($values as $id) {
             $titles[] = $ids[$id];
         }
         sort($combos[$key]);
         $key_values = explode('.', $key);
         sort($key_values);
         $sorted_key = implode('-', $key_values);
         /*
         $md5_key = md5($sorted_key);
         */
         $mongo_id = (string) new \MongoId();
         /*
         $result[$sorted_key] = array(
             'id' => $mongo_id,
             'key' => $sorted_key,
         	'attributes' => $combos[$key],
             'titles' => $titles
         );
         */
         $result[$sorted_key] = (new \Shop\Models\Prefabs\Variant(array('id' => $mongo_id, 'key' => $sorted_key, 'attributes' => $combos[$key], 'attribute_titles' => $titles)))->cast();
     }
     return $result;
 }
예제 #12
0
파일: Posts.php 프로젝트: dioscouri/f3-blog
 public function getRelatedPosts($limit = 12)
 {
     $model = new static();
     $model->setState('filter.published_today', true)->setState('filter.publication_status', 'published');
     $conditions = $model->conditions();
     // convert the set states to conditions
     $model->setCondition('_id', array('$ne' => new \MongoId((string) $this->id)))->setParam('limit', $limit);
     $categories = array();
     if (!empty($this->{'categories'})) {
         $categories = \Dsc\ArrayHelper::getColumn((array) $this->{'categories'}, 'id');
     }
     if (!empty($categories)) {
         $model->setCondition('categories', array('$elemMatch' => array('id' => array('$in' => $categories))));
     }
     return $model->getItems();
 }
예제 #13
0
 public function generateCodes($prefix, $len, $num)
 {
     $prefix = strtolower($prefix);
     $num_chars = count($this->__chars);
     $possible_codes = pow($num_chars, $len);
     if ($possible_codes < $num) {
         throw new \Exception("With length of " . $len . ' you can generate only ' . $possible_codes . '.');
     }
     $codes = array_values((array) $this->{'codes.list'});
     for ($i = 0; $i < $num; $i++) {
         $suffix = '';
         $notUnique = true;
         while ($notUnique) {
             for ($j = 0; $j < $len; $j++) {
                 $suffix .= $this->__chars[rand(0, $num_chars - 1)];
             }
             $code = strtolower($prefix . $suffix);
             $all_codes = \Dsc\ArrayHelper::getColumn($codes, 'code');
             $notUnique = in_array($code, $all_codes);
         }
         $codes[] = array('code' => $code, 'used' => 0);
     }
     $this->{'codes.list'} = $codes;
     $this->{'codes.prefix'} = $prefix;
     $this->{'codes.length'} = $len;
     $this->save();
 }
예제 #14
0
 /**
  * Displays an order confirmation page
  */
 public function confirmation()
 {
     $just_completed_order_id = \Dsc\System::instance()->get('session')->get('shop.just_completed_order_id');
     if (!empty($just_completed_order_id)) {
         try {
             $order = (new \Shop\Models\Orders())->load(array('_id' => new \MongoId((string) $just_completed_order_id)));
             if (empty($order->id)) {
                 throw new \Exception();
             }
             /**
              * Start Activity Tracking
              */
             $properties = array('order_id' => (string) $order->id, 'order_number' => (string) $order->number, 'Grand Total' => (string) $order->grand_total, 'Credit Total' => (string) $order->credit_total, 'Products' => array(), 'Coupons' => \Dsc\ArrayHelper::getColumn((array) $order->coupons, 'code'), 'Auto Coupons' => \Dsc\ArrayHelper::getColumn((array) $order->auto_coupons, 'code'));
             $identity = $this->getIdentity();
             if ($identity->guest) {
                 $properties['guest'] = true;
             }
             foreach ($order->items as $item) {
                 $product = array();
                 $product['Product Name'] = \Dsc\ArrayHelper::get($item, 'product.title');
                 if (\Dsc\ArrayHelper::get($item, 'attribute_title')) {
                     $product['Variant'] = \Dsc\ArrayHelper::get($item, 'attribute_title');
                 }
                 $properties['Products'][] = $product;
             }
             \Shop\Models\Activities::track('Completed Checkout', $properties);
             $abandoned_cart = \Dsc\System::instance()->get('session')->get('shop.notification_email');
             if ($abandoned_cart == 1) {
                 // checkedout abandoned cart
                 \Shop\Models\Activities::track('Completed Checkout Abandoned Email');
                 \Dsc\System::instance()->get('session')->set('shop.notification_email', 0);
             }
             /**
              * END Activity Tracking
              */
             // check coupons and discard used generated codes
             if (count($order->coupons)) {
                 foreach ($order->coupons as $coupon) {
                     if (!empty($coupon['generated_code'])) {
                         \Shop\Models\Coupons::collection()->update(array('_id' => new \MongoId((string) $coupon['_id']), 'codes.list.code' => (string) $coupon['generated_code']), array('$set' => array('codes.list.$.used' => 1)));
                     }
                 }
             }
             if (count($order->auto_coupons)) {
                 foreach ($order->auto_coupons as $coupon) {
                     if (!empty($coupon['generated_code'])) {
                         \Shop\Models\Coupons::collection()->update(array('_id' => new \MongoId((string) $coupon['_id']), 'codes.list.code' => (string) $coupon['generated_code']), array('$set' => array('codes.list.$.used' => 1)));
                     }
                 }
             }
         } catch (\Exception $e) {
             // TODO Handle when it's an invalid order
         }
         if (!empty($order->id)) {
             \Base::instance()->set('order', $order);
         }
     }
     $this->app->set('meta.title', 'Order Confirmation | Checkout');
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Shop/Site/Views::confirmation/index.php');
     \Dsc\System::instance()->get('session')->set('shop.just_completed_order', false);
     \Dsc\System::instance()->get('session')->set('shop.just_completed_order_id', null);
 }