Commit 36d1807a8199e58578355b0d3f3997bb696a9ad5

Authored by Yarik
1 parent efba3882

Big commit.

Showing 256 changed files with 5748 additions and 9843 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 256 files are displayed.

.gitignore
... ... @@ -20,3 +20,7 @@ phpunit.phar
20 20 /phpunit.xml
21 21 /.vagrant
22 22 /vendor/
  23 +/fordelete.txt
  24 +/done.txt
  25 +/certificates.php
  26 +/backup
... ...
.htaccess
... ... @@ -2,7 +2,7 @@ AddDefaultCharset utf-8
2 2 <IfModule mod_rewrite.c>
3 3  
4 4  
5   -# Options +FollowSymlinks
  5 + Options +FollowSymlinks
6 6  
7 7 RewriteEngine On
8 8  
... ...
collection.php renamed to _collection.php
... ... @@ -42,10 +42,13 @@
42 42 <td>2,48</td>
43 43 </tr>
44 44 </table>
  45 + <div class="style">
  46 + <a class="to_order" href="#">ะ—ะฐะบะฐะทะฐั‚ัŒ ะพะฑั€ะฐะทะตั†</a>
  47 + </div>
45 48 </div>
46 49 </div>
47   - <div class="col-xs-12 col-sm-5 col-md-5">
48   - <ul class="style">
  50 + <div class="col-xs-12 col-sm-8 col-md-6 col-lg-5 collection-list">
  51 + <ul>
49 52 <li class="active">
50 53 <a href="#">
51 54 <div><img src="images/img_garbage/img-laminate-2.jpg" alt=""></div>
... ... @@ -86,57 +89,82 @@
86 89 </div>
87 90 </div>
88 91 <div class="row">
89   - <div class="col-xs-12 col-sm-12 articles_data-title marginbottom-15">
90   - <div class="articles-title">ะŸั€ะพะดัƒะบั‚ั‹, ะธัะฟะพะปัŒะทัƒะตะผั‹ะต ะฒ ะดะฐะฝะฝะพะผ ะฟั€ะพะตะบั‚ะต</div>
91   - </div>
92   - <div class="style project-brands_">
93   - <ul class="style brands-list">
94   - <li>
95   - <a href="#">
96   - <div><img src="images/img_garbage/img-laminate-2.jpg" alt=""></div>
97   - <p>ะ”ัƒะฑ ั‚ั€ะธะปะพะณะธั ะบะฐะฟัƒั‡ะธะฝะพ</p>
98   - </a>
99   - </li>
100   - <li>
101   - <a href="#">
102   - <div><img src="images/img_garbage/img-laminate-3.jpg" alt=""></div>
103   - <p>ะกะพัะฝะฐ ัะฐั…ะฐั€ะฐ</p>
104   - </a>
105   - </li>
106   - <li>
107   - <a href="#">
108   - <div><img src="images/img_garbage/img-laminate-4.jpg" alt=""></div>
109   - <p>ะ”ัƒะฑ ะณะฐั€ั€ะธัะพะฝ ะฝะฐั‚ัƒั€</p>
110   - </a>
111   - </li>
112   - <li>
113   - <a href="#">
114   - <div><img src="images/img_garbage/img-laminate-5.jpg" alt=""></div>
115   - <p>ะ”ัƒะฑ ะบะพะปัŒะผะฐั€ัะบะธะน</p>
116   - </a>
117   - </li>
118   - <li>
119   - <a href="#">
120   - <div><img src="images/img_garbage/img-laminate-6.jpg" alt=""></div>
121   - <p>ะ”ัƒะฑ ั€ัƒัั‚ะธะบะฐะปัŒะฝั‹ะน</p>
122   - </a>
123   - </li>
124   - <li>
125   - <a href="#">
126   - <div><img src="images/img_garbage/img-laminate-7.jpg" alt=""></div>
127   - <p>ะšะฐัˆั‚ะฐะฝ ะฑะตะปั‹ะน ะถะธั€ะพะฝะฐ</p>
128   - </a>
129   - </li>
  92 + <div class="col-xs-12 col-sm-12 collect-tabs">
  93 + <ul class="list-tabs">
  94 + <li><span>ะขะตั…ะฝะธั‡ะตัะบะธะต ั…ะฐั€ะฐะบั‚ะตั€ะธัั‚ะธะบะธ</span></li>
  95 + <li><span>ะกะตั€ั‚ะธั„ะธะบะฐั‚ั‹</span></li>
  96 + <li><span>ะœะพะฝั‚ะฐะถ, ัƒะฑะพั€ะบะฐ, ัƒั…ะพะด</span></li>
  97 + <li><span>ะ“ะฐะปะตั€ะตั ะพะฑัŠะตะบั‚ะพะฒ</span></li>
130 98 </ul>
  99 + <div class="style t_content_wr">
  100 + <div class="tabs-content">
  101 + <p><span style="font-weight: 700;">ะ‘ะฐะทะฐ ะดะฐะฝะฝั‹ั…</span></p>
  102 + <p>ะคะพั€ะฑะพ ะพะฑะปะฐะดะฐะตั‚ ะฑะพะปัŒัˆะธะผ ั€ะฐะทะฝะพะพะฑั€ะฐะทะธะตะผ ั€ะตะบะปะฐะผะฝะพะน ะธ ั‚ะตั…ะฝะธั‡ะตัะบะพะน ะดะพะบัƒะผะตะฝั‚ะฐั†ะธะธ ะดะปั ะบะฐะถะดะพะณะพ ะธะท ัะฒะพะธั… ะฟะพะบั€ั‹ั‚ะธะน. ะ”ะพะบัƒะผะตะฝั‚ ะผะพะถะฝะพ ะฝะฐะนั‚ะธ, ะฟั€ะพะนะดั ะฟะพ ััั‹ะปะบะต ะฒั‹ะฑั€ะฐะฝะฝะพะณะพ ะฟั€ะพะดัƒะบั‚ะฐ, ะฟะพัะปะต ัั‚ะพะณะพ ะผะพะถะฝะพ ะฑัƒะดะตั‚
  103 + <a href="#" download>ัะบะฐั‡ะฐั‚ัŒ ะฝะตะพะฑั…ะพะดะธะผั‹ะน ั„ะฐะนะป</a>.</p>
  104 + <p>ะ’ั‹ ั‚ะฐะบะถะต ะผะพะถะตั‚ะต ัะบะฐั‡ะฐั‚ัŒ ั‚ะฐะฑะปะธั†ัƒ ั <a href="#" download>ั‚ะตั…ะฝะธั‡ะตัะบะธะผะธ ั…ะฐั€ะฐะบั‚ะตั€ะธัั‚ะธะบะฐะผะธ</a></p>
  105 + </div>
  106 + <div class="tabs-content">
  107 + <div class="row">
  108 + <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
  109 + <iframe class="certificate" frameborder="0" src="http://docs.google.com/gview?url=http://witex.ua/files/witex_sohranenie_ykladka.pdf&embedded=true"></iframe>
  110 + </div>
  111 + <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
  112 + <iframe class="certificate" frameborder="0" src="http://docs.google.com/gview?url=http://witex.ua/files/garant.pdf&embedded=true"></iframe>
  113 + </div>
  114 + <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
  115 + <iframe class="certificate" frameborder="0" src="http://docs.google.com/gview?url=http://witex.ua/files/garant.pdf&embedded=true"></iframe>
  116 + </div>
  117 + <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
  118 + <iframe class="certificate" frameborder="0" src="http://docs.google.com/gview?url=http://witex.ua/files/garant.pdf&embedded=true"></iframe>
  119 + </div>
  120 + </div>
  121 + </div>
  122 + <div class="tabs-content">
  123 + <p>ะŸะพะฒะตั€ั…ะฝะพัั‚ัŒ ะฑะตััˆะพะฒะฝะพะณะพ ะฟะพะปะฐ ะธะปะธ ะฟะพะปะฐ ะฝะฐ ะพัะฝะพะฒะต ะผะธะฝะตั€ะฐะปะพะฒ ะดะพะปะถะฝะฐ ะฟะพะปะฝะพัั‚ัŒัŽ ะฟะพะบั€ั‹ะฒะฐั‚ัŒัั ะฒะปะฐะณะพะทะฐั‰ะธั‚ะฝะพะน ะฟะพะปะธัั‚ะธะปะตะฝะพะฒะพะน ะฟะปะตะฝะบะพะน ั‚ะพะปั‰ะธะฝะพะน 0,2 ะผะผ. ะŸั€ะธ ัั‚ะพะผ ะฝะฐ ัั‚ั‹ะบะฐั… ะฟะพะปะพัั‹ ะฟะปะตะฝะบะธ ะดะพะปะถะฝั‹ ัƒะบะปะฐะดั‹ะฒะฐั‚ัŒัั ั ะฝะฐั…ะปะตัั‚ะพะผ ะฝะต ะผะตะฝะตะต 20 ัะผ.</p>
  124 + <p>ะ”ะปั ะฒัะตั… ะฟะพะฒะตั€ั…ะฝะพัั‚ะตะน ั€ะตะบะพะผะตะฝะดัƒะตั‚ัั ัะพะพั‚ะฒะตั‚ัั‚ะฒัƒัŽั‰ะฐั ะฟะพะดะปะพะถะบะฐ. ะŸะพะดะปะพะถะบะฐ ัƒะบะปะฐะดั‹ะฒะฐะตั‚ัั ะฒัั‚ั‹ะบ, ั‚ะพ ะตัั‚ัŒ ะฑะตะท ะฝะฐั…ะปะตัั‚ะฐ. ะŸั€ะธ ัƒะบะปะฐะดะบะต ะธัะบัƒััั‚ะฒะตะฝะฝะพะณะพ ะฟะฐั€ะบะตั‚ะฐ, ะธะผะตัŽั‰ะตะณะพ ะฝะฐ ะพะฑะพั€ะพั‚ะฝะพะน ัั‚ะพั€ะพะฝะต ะทะฒัƒะบะพะฟะพะณะปะพั‰ะฐัŽั‰ัƒัŽ ะฟะพะดะบะปะฐะดะบัƒ, ะดะพะฟะพะปะฝะธั‚ะตะปัŒะฝะฐั ะฟะพะดะปะพะถะบะฐ ะฝะต ะฝัƒะถะฝะฐ (ะบะฐัˆะธั€ะพะฒะฐะฝะฝะฐั ะฟะพะดะบะปะฐะดะบะฐ ะะ• ะทะฐะผะตะฝัะตั‚ ะฟะพะปะธัั‚ะธะปะตะฝะพะฒัƒัŽ ะฟะปะตะฝะบัƒ ะฝะฐ ะฟะพะฒะตั€ั…ะฝะพัั‚ัั… ะฝะฐ ะพัะฝะพะฒะต ะผะธะฝะตั€ะฐะปะพะฒ!).ะญะปะตะผะตะฝั‚ั‹ ะฟะฐั€ะบะตั‚ะฐ ะฒัะตะณะดะฐ ัƒะบะปะฐะดั‹ะฒะฐัŽั‚ัั ะบะฐะบ ะฟะปะฐะฒะฐัŽั‰ะธะต.</p>
  125 + <p>ะะตะฟะพะดะฒะธะถะฝะพะต ัะบั€ะตะฟะปะตะฝะธะต ะฟะพะปะพะฒะธั† ั ะฟะพะฒะตั€ั…ะฝะพัั‚ัŒัŽ ะดะปั ัƒะบะปะฐะดะบะธ (ะบะปะตะน, ัˆัƒั€ัƒะฟั‹, ะณะฒะพะทะดะธ) ะฝะต ะดะพะฟัƒัะบะฐะตั‚ัั. ะœะธะฝะธะผะฐะปัŒะฝั‹ะน ัะดะฒะธะณ ะณะพะปะพะฒะฝั‹ั… ัั‚ั‹ะบะพะฒ ะฟะพะปะพะฒะธั† ัะพัะตะดะฝะธั… ั€ัะดะพะฒ - 200 ะผะผ.</p>
  126 + <p>ะšะพะผะฟะตะฝัะฐั†ะธะพะฝะฝั‹ะน ะทะฐะทะพั€ ัƒ ะฒัะตั… ั‚ะฒะตั€ะดั‹ั… ัั‚ั€ะพะธั‚ะตะปัŒะฝั‹ั… ะฟะพะฒะตั€ั…ะฝะพัั‚ะตะน โ€“ 8-10 ะผะผ.<br />
  127 + ะ’ะพ ะฒัะตั… ะดะฒะตั€ะฝั‹ั… ะฟั€ะพะตะผะฐั…, ะฟะตั€ะตั…ะพะดะฐั…, ะฟะพะผะตั‰ะตะฝะธัั… ัะพ ัะปะพะถะฝะพะน ะบะพะฝั„ะธะณัƒั€ะฐั†ะธะตะน, ะฐ ั‚ะฐะบะถะต ะฟะพะผะตั‰ะตะฝะธัั…, ะธะผะตัŽั‰ะธั… ะฑะพะปะตะต 10 ะผ ะฒ ะดะปะธะฝัƒ ะธะปะธ ัˆะธั€ะธะฝัƒ, ะฝะตะพะฑั…ะพะดะธะผะพ ะฒัั‚ะฐะฒะปัั‚ัŒ ะฟะตั€ะตั…ะพะดะฝะธะบะธ/ะฟะพั€ะพะถะบะธ. </p>
  128 + <p>
  129 + 1. ะŸั€ะพะฒะตั€ัŒั‚ะต, ะฝะต ะฟะพะฒั€ะตะถะดะตะฝั‹ ะปะธ ัะปะตะผะตะฝั‚ั‹ ะฝะฐะฟะพะปัŒะฝั‹ั… ะฟะพะบั€ั‹ั‚ะธะน, ะฝะตั‚ ะปะธ ะฝะฐ ะฝะธั… ะดะตั„ะตะบั‚ะพะฒ.<br />
  130 + ะ ะฐััะผะพั‚ั€ะธั‚ะต ัˆะฟัƒะฝั‚ะพะฒะฐะฝะธะต ะฟะฐะฝะตะปะตะน, ะฝะฐะนะดะธั‚ะต ะฝะฐ ะฟะฐะฝะตะปะธ ะฟะฐะท ะธ ะณั€ะตะฑะตะฝัŒ.<br />
  131 + ะะฐั‡ะฝะธั‚ะต ัƒะบะปะฐะดะบัƒ ะฟะตั€ะฒะพะณะพ ั€ัะดะฐ ะฟะฐะฝะตะปะตะน ั ะดะฐะปัŒะฝะตะณะพ ะปะตะฒะพะณะพ ัƒะณะปะฐ ะฟะพะผะตั‰ะตะฝะธั. ะฃะบะปะฐะดั‹ะฒะฐะนั‚ะต ั‚ะฐะบ, ั‡ั‚ะพะฑั‹ ะพะฑะต ัั‚ะพั€ะพะฝั‹ ะฟะฐะฝะตะปะธ ั ะณั€ะตะฑะฝะตะผ ะฑั‹ะปะธ ะพะฑั€ะฐั‰ะตะฝั‹ ะบ ัั‚ะตะฝะต. ะะฐั‡ะธะฝะฐั ัƒะบะปะฐะดะบัƒ, ัƒัั‚ะฐะฝะพะฒะธั‚ะต ั€ะฐัะฟะพั€ะบะธ ะดะปั ัะพะฑะปัŽะดะตะฝะธั ั€ะฐััั‚ะพัะฝะธั ะพั‚ ัั‚ะตะฝั‹. ะฃะบะปะฐะดั‹ะฒะฐะนั‚ะต ะฟะพะบั€ั‹ั‚ะธะต ัะปะตะดัƒัŽั‰ะธะผ ะพะฑั€ะฐะทะพะผ: ะบ ะฟะตั€ะฒะพะผัƒ ะธ ะบะฐะถะดะพะผัƒ ะฟะพัะปะตะดัƒัŽั‰ะตะผัƒ ัƒะปะพะถะตะฝะฝะพะผัƒ ัะปะตะผะตะฝั‚ัƒ ะฟั€ะธะบะปะฐะดั‹ะฒะฐะนั‚ะต ะฝะพะฒัƒัŽ ะฟะฐะฝะตะปัŒ, ะฟะพะด ัƒะณะปะพะผ ะฒะฒะพะดั ะตะต ะณั€ะตะฑะฝะตะผ ะฒ ัˆะฟัƒะฝั‚ ัƒะถะต ัƒะปะพะถะตะฝะฝะพะณะพ ัะปะตะผะตะฝั‚ะฐ. ะ—ะฐั‚ะตะผ ะพะฟัƒัะบะฐะนั‚ะต ัƒะบะปะฐะดั‹ะฒะฐะตะผัƒัŽ ะฟะฐะฝะตะปัŒ ะดะพ ั‚ะตั… ะฟะพั€, ะฟะพะบะฐ ะพะฝะฐ ะฟะพะปะฝะพัั‚ัŒัŽ ะฝะต ะปัะถะตั‚ ะฝะฐ ะฟะพะป.
  132 + </p>
  133 + <p>2. ะžั‚ะผะตั‚ัŒั‚ะต ะฝะฐ ะฟะพัะปะตะดะฝะตะน ะฟะฐะฝะตะปะธ ะฟะตั€ะฒะพะณะพ ั€ัะดะฐ ั‚ั€ะตะฑัƒะตะผัƒัŽ ะดะปะธะฝัƒ (ัƒะบะปะฐะดั‹ะฒะฐะนั‚ะต ะณั€ะตะฑะตะฝัŒ ะบ ะณั€ะตะฑะฝัŽ) ะธ ะพั‚ะฟะธะปะธั‚ะต ะฟะฐะฝะตะปัŒ ะฟะพ ะผะฐั€ะบะธั€ะพะฒะบะต. ะะฐั‡ะฝะธั‚ะต ัƒะบะปะฐะดะบัƒ ะฒั‚ะพั€ะพะณะพ ั€ัะดะฐ ั ะพัั‚ะฐั‚ะบะฐ ะฟะพัะปะตะดะฝะตะน ะฟะฐะฝะตะปะธ ะฟะตั€ะฒะพะณะพ ั€ัะดะฐ, ะตัะปะธ ะตะต ะดะปะธะฝะฐ ะฝะต ะผะตะฝัŒัˆะต 200 ะผะผ. ะฃะบะปะฐะดะบัƒ ะฒัะตั… ะฟะพัะปะตะดัƒัŽั‰ะธั… ั€ัะดะพะฒ ัะปะตะดัƒะตั‚ ะฝะฐั‡ะธะฝะฐั‚ัŒ ั ะพัั‚ะฐั‚ะบะฐ ะฟะฐะฝะตะปะธ ะฟั€ะตะดั‹ะดัƒั‰ะตะณะพ ั€ัะดะฐ.<br />
  134 + ะ’ะฝะธะผะฐะฝะธะต! ะŸั€ะธ ัƒะบะปะฐะดะบะต ั‚ะพั€ั†ะตะฒั‹ะต ัั‚ั‹ะบะธ ะฟะฐะฝะตะปะตะน ะบะฐะถะดะพะณะพ ะฟะพัะปะตะดัƒัŽั‰ะตะณะพ ั€ัะดะฐ ะดะพะปะถะฝั‹ ะฑั‹ั‚ัŒ ัะผะตั‰ะตะฝั‹ ะผะธะฝะธะผัƒะผ ะฝะฐ 200 ะผะผ ะพั‚ะฝะพัะธั‚ะตะปัŒะฝะพ ัั‚ั‹ะบะพะฒ ะฟะฐะฝะตะปะตะน ะฟั€ะตะดั‹ะดัƒั‰ะตะณะพ ั€ัะดะฐ. ะฃะบะปะฐะดั‹ะฒะฐั ะฟะพะบั€ั‹ั‚ะธั ั ั„ะฐัะบะพะน ะธ/ะธะปะธ ะพัะพะฑั‹ะผ ะดะตะบะพั€ะพะผ (ะฝะฐะฟั€ะธะผะตั€, ะธะผะธั‚ะธั€ัƒัŽั‰ะธะผ ะฟะปะธั‚ะบัƒ) ะฝะตะพะฑั…ะพะดะธะผะพ ัะปะตะดะธั‚ัŒ, ั‡ั‚ะพะฑั‹ ัะผะตั‰ะตะฝะธะต ะฑั‹ะปะพ ั€ะฐะฒะฝะพะผะตั€ะฝั‹ะผ ะธ ัะพะพั‚ะฒะตั‚ัั‚ะฒะพะฒะฐะปะพ ั„ะฐัะบะต ะธ ั€ะธััƒะฝะบัƒ.</p>
  135 + <p>3. ะ—ะฐะบะพะฝั‡ะธะฒ ะฟะตั€ะฒั‹ะน ั€ัะด, ะธัะฟะพะปัŒะทัƒะนั‚ะต ะพัั‚ะฐั‚ะพะบ ะฟะพัะปะตะดะฝะตะน ะฟะฐะฝะตะปะธ ะดะปั ะฝะฐั‡ะฐะปะฐ ัƒะบะปะฐะดะบะธ ะฒั‚ะพั€ะพะณะพ ั€ัะดะฐ. ะ’ั‹ ะผะพะถะตั‚ะต ั‚ะฐะบะถะต ะฝะฐั‡ะฐั‚ัŒ ั ะพั‚ั€ะตะทะบะฐ ะฟะฐะฝะตะปะธ, ะฟะพะดะพะณะฝะฐะฝะฝะพะณะพ ะฟะพ ะดะปะธะฝะต ะบ ั€ะธััƒะฝะบัƒ ะดะตะบะพั€ะฐ ะธะปะธ ั„ะฐัะบะต ะฟะพะบั€ั‹ั‚ะธั.<br />
  136 + ะ’ะฒะตะดะธั‚ะต ะณั€ะตะฑะตะฝัŒ ะฝะพะฒะพะน ะฟะฐะฝะตะปะธ ะฒ ะฟะฐะท ะฟะตั€ะฒะพะณะพ ัะปะตะผะตะฝั‚ะฐ ะฟะตั€ะฒะพะณะพ ั€ัะดะฐ, ะฒัะต ะฟะพัะปะตะดัƒัŽั‰ะธะต ะฟะฐะฝะตะปะธ ัั‚ะพะณะพ ั€ัะดะฐ ัะพะตะดะธะฝัะนั‚ะต ะบะพั€ะพั‚ะบะธะผะธ ัั‚ะพั€ะพะฝะฐะผะธ, ะบะฐะบ ะพะฟะธัะฐะฝะพ ะฒั‹ัˆะต, ะฟะพะบะฐ ะฝะต ัƒะปะพะถะธั‚ะต ะฒะตััŒ ั€ัะด. ะขะตะฟะตั€ัŒ ะฒัะต ะบะพั€ะพั‚ะบะธะต ัั‚ะพั€ะพะฝั‹ ะฟะฐะฝะตะปะตะน ัั‚ะพะณะพ ั€ัะดะฐ ะฟะพะดะพะณะฝะฐะฝั‹ ะธ ัะพะตะดะธะฝะตะฝั‹ ะดั€ัƒะณ ั ะดั€ัƒะณะพะผ. ะกะปะตะณะบะฐ ะฟั€ะธะฟะพะดะฝะธะผะธั‚ะต ะฟะตั€ะฒัƒัŽ ะฟะฐะฝะตะปัŒ (ะพั‚ั€ะตะทะพะบ ะฟะฐะฝะตะปะธ) ั€ัะดะฐ, ัะพะตะดะธะฝะธั‚ะต ะตะต ะดะปะธะฝะฝะพะน ัั‚ะพั€ะพะฝะพะน ั ัะพะพั‚ะฒะตั‚ัั‚ะฒัƒัŽั‰ะตะน ะฟะฐะฝะตะปัŒัŽ ะฟะตั€ะฒะพะณะพ ั€ัะดะฐ. ะŸั€ะพะดะตะปั‹ะฒะฐะนั‚ะต ั‚ะพ ะถะต ัะฐะผะพะต ั ะดั€ัƒะณะธะผะธ ะฟะฐะฝะตะปัะผะธ ะฒั‚ะพั€ะพะณะพ ั€ัะดะฐ, ะฟะพะบะฐ ะฝะต ัะพะตะดะธะฝะธั‚ะต ะฒะตััŒ ะฒั‚ะพั€ะพะน ั€ัะด ั ะฟะตั€ะฒั‹ะผ. ะกะปะตะดะธั‚ะต ะทะฐ ั‚ะตะผ, ั‡ั‚ะพะฑั‹ ะฟั€ะธ ัั‚ะพะผ ะฝะต ัะดะฒะธะณะฐะปะธััŒ ั‚ะพั€ั†ั‹ ะบะพั€ะพั‚ะบะธั… ัั‚ะพั€ะพะฝ ะฟะฐะฝะตะปะตะน ะฒั‚ะพั€ะพะณะพ ั€ัะดะฐ.
  137 + </p>
  138 + <p>4. ะŸั€ะพะดะพะปะถะฐะนั‚ะต ัƒะบะปะฐะดะบัƒ ะฟะพะบั€ั‹ั‚ะธั, ะบะฐะบ ะพะฟะธัะฐะฝะพ ะฒั‹ัˆะต - ัะปะตะผะตะฝั‚ ะทะฐ ัะปะตะผะตะฝั‚ะพะผ, ั€ัะด ะทะฐ ั€ัะดะพะผ.</p>
  139 + <p>5. ะ”ะปั ั‚ะพะณะพ, ั‡ั‚ะพะฑั‹ ัƒะปะพะถะธั‚ัŒ ะฟะพัะปะตะดะฝะธะน ั€ัะด, ั€ะฐะทะผะตัั‚ะธั‚ะต ะฟะพะดะปะตะถะฐั‰ะธะน ัƒัั‚ะฐะฝะพะฒะบะต ัะปะตะผะตะฝั‚ ั‚ะพั‡ะฝะพ ะฝะฐ ะฟั€ะตะดะฟะพัะปะตะดะฝะตะผ ั€ัะดัƒ. ะŸั€ะธ ะฟะพะผะพั‰ะธ ะพั‚ั€ะตะทะบะฐ ะฟะฐะฝะตะปะธ (ัˆะธั€ะธะฝะฐ ัั‚ั‹ะบะฐ + ัˆะธั€ะธะฝะฐ ะทะฐะทะพั€ะฐ) ะผะพะถะฝะพ ะฟะตั€ะตะฝะตัั‚ะธ ะฝะฐ ัƒะบะปะฐะดั‹ะฒะฐะตะผั‹ะน ัะปะตะผะตะฝั‚ ะบะพะฝั‚ัƒั€ ัั‚ะตะฝั‹ ั ัƒั‡ะตั‚ะพะผ ะฟะปะฐะฝะธั€ัƒะตะผะพะณะพ ะทะฐะทะพั€ะฐ.</p>
  140 + </div>
  141 + <div class="tabs-content">
  142 + <ul class="gall-1">
  143 + <li class="col-xs-12 col-sm-4 col-md-4 col-lg-4" data-src="images/img_garbage/gallery/img-1.jpg">
  144 + <a href="">
  145 + <img class="img-responsive" src="images/img_garbage/gallery/collect-gal-min-1.jpg">
  146 + </a>
  147 + </li>
  148 + <li class="col-xs-12 col-sm-4 col-md-4 col-lg-4" data-src="images/img_garbage/gallery/img-2.jpg">
  149 + <a href="">
  150 + <img class="img-responsive" src="images/img_garbage/gallery/collect-gal-min-2.jpg">
  151 + </a>
  152 + </li>
  153 + <li class="col-xs-12 col-sm-4 col-md-4 col-lg-4" data-src="images/img_garbage/gallery/img-4.jpg">
  154 + <a href="">
  155 + <img class="img-responsive" src="images/img_garbage/gallery/collect-gal-min-3.jpg">
  156 + </a>
  157 + </li>
  158 + <li class="col-xs-12 col-sm-4 col-md-4 col-lg-4" data-src="images/img_garbage/gallery/img-3.jpg">
  159 + <a href="">
  160 + <img class="img-responsive" src="images/img_garbage/gallery/collect-gal-min-4.jpg">
  161 + </a>
  162 + </li>
  163 + </ul>
  164 + </div>
  165 + </div>
131 166 </div>
132 167 </div>
133   -
134   -
135   -
136   -
137   -
138   -
139   -
140 168 </div>
141 169 </div>
142 170  
... ...
backend/config/main.php
... ... @@ -168,7 +168,7 @@ return [
168 168 'product/manage/<action>' => 'product/manage/<action>',
169 169 'product/<controller>/<action>/<product_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'product/<controller>/<action>',
170 170 'product/<controller>/<action>/<product_id:[A-Za-z0-9_-]+>/' => 'product/<controller>/<action>',
171   - 'product/<action>/<product_id:[A-Za-z0-9_-]+>' => 'product/<action>',
  171 +// 'product/<action>/<product_id:[A-Za-z0-9_-]+>' => 'product/<action>',
172 172 'seo-dynamic/<action>/<seo_category_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'seo-dynamic/<action>',
173 173 'seo-dynamic/<action>/<seo_category_id:[A-Za-z0-9_-]+>' => 'seo-dynamic/<action>',
174 174 ]
... ...
backend/controllers/ArticlesController.php
... ... @@ -113,6 +113,7 @@ class ArticlesController extends Controller
113 113 $model = $this->findModel($id);
114 114  
115 115 if ($model->load(Yii::$app->request->post())) {
  116 +
116 117 if ( ($image = UploadedFile::getInstance($model, 'image')) ) {
117 118 $model->image = $image->name;
118 119 }
... ...
backend/controllers/CommentController.php deleted
1   -<?php
2   -
3   -namespace backend\controllers;
4   -
5   -use developeruz\db_rbac\behaviors\AccessBehavior;
6   -use Yii;
7   -use common\modules\comment\models\Comment;
8   -use backend\models\CommentSearch;
9   -use yii\web\Controller;
10   -use yii\web\NotFoundHttpException;
11   -use yii\filters\VerbFilter;
12   -
13   -/**
14   - * CommentController implements the CRUD actions for Comment model.
15   - */
16   -class CommentController extends Controller
17   -{
18   - /**
19   - * @inheritdoc
20   - */
21   - public function behaviors()
22   - {
23   - return [
24   - 'access'=>[
25   - 'class' => AccessBehavior::className(),
26   - 'rules' =>
27   - ['site' =>
28   - [
29   - [
30   - 'actions' => ['login', 'error'],
31   - 'allow' => true,
32   - ]
33   - ]
34   - ]
35   - ],
36   - 'verbs' => [
37   - 'class' => VerbFilter::className(),
38   - 'actions' => [
39   - 'delete' => ['POST'],
40   - ],
41   - ],
42   - ];
43   - }
44   -
45   - /**
46   - * Lists all Comment models.
47   - * @return mixed
48   - */
49   - public function actionIndex()
50   - {
51   - $searchModel = new CommentSearch();
52   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
53   - $query = $dataProvider->query;
54   - $query->with(['rating', 'user']);
55   - $sort = $dataProvider->sort;
56   - $sort->defaultOrder = [
57   - 'status' => SORT_ASC,
58   - ];
59   -
60   - return $this->render('index', [
61   - 'searchModel' => $searchModel,
62   - 'dataProvider' => $dataProvider,
63   - ]);
64   - }
65   -
66   - /**
67   - * Displays a single Comment model.
68   - * @param integer $id
69   - * @return mixed
70   - */
71   -// public function actionView($id)
72   -// {
73   -// return $this->render('view', [
74   -// 'model' => $this->findModel($id),
75   -// ]);
76   -// }
77   -
78   - /**
79   - * Creates a new Comment model.
80   - * If creation is successful, the browser will be redirected to the 'view' page.
81   - * @return mixed
82   - */
83   -// public function actionCreate()
84   -// {
85   -// $model = new Comment();
86   -//
87   -// if ($model->load(Yii::$app->request->post()) && $model->save()) {
88   -// return $this->redirect(['view', 'id' => $model->comment_id]);
89   -// } else {
90   -// return $this->render('create', [
91   -// 'model' => $model,
92   -// ]);
93   -// }
94   -// }
95   -
96   - /**
97   - * Updates an existing Comment model.
98   - * If update is successful, the browser will be redirected to the 'view' page.
99   - * @param integer $id
100   - * @return mixed
101   - */
102   - public function actionUpdate($id)
103   - {
104   - $model = $this->findModel($id);
105   -
106   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
107   - return $this->redirect(['view', 'id' => $model->comment_id]);
108   - } else {
109   - return $this->render('update', [
110   - 'model' => $model,
111   - ]);
112   - }
113   - }
114   -
115   - public function actionApprove($id) {
116   - $model = $this->findModel($id);
117   - $model->status = Comment::STATUS_ACTIVE;
118   - $model->save(false);
119   -
120   - return $this->redirect(['index']);
121   - }
122   -
123   - public function actionDisapprove($id) {
124   - $model = $this->findModel($id);
125   - $model->status = Comment::STATUS_HIDDEN;
126   - $model->save(false);
127   -
128   - return $this->redirect(['index']);
129   - }
130   -
131   - /**
132   - * Deletes an existing Comment model.
133   - * If deletion is successful, the browser will be redirected to the 'index' page.
134   - * @param integer $id
135   - * @return mixed
136   - */
137   - public function actionDelete($id)
138   - {
139   - $this->findModel($id)->delete();
140   -
141   - return $this->redirect(['index']);
142   - }
143   -
144   - /**
145   - * Finds the Comment model based on its primary key value.
146   - * If the model is not found, a 404 HTTP exception will be thrown.
147   - * @param integer $id
148   - * @return Comment the loaded model
149   - * @throws NotFoundHttpException if the model cannot be found
150   - */
151   - protected function findModel($id)
152   - {
153   - if (($model = Comment::findOne($id)) !== null) {
154   - return $model;
155   - } else {
156   - throw new NotFoundHttpException('The requested page does not exist.');
157   - }
158   - }
159   -}
backend/controllers/BlogController.php renamed to backend/controllers/ProjectController.php
1   -<?php
2   -
3   -namespace backend\controllers;
4   -use developeruz\db_rbac\behaviors\AccessBehavior;
5   -use common\models\Fields;
6   -use Yii;
7   -use common\models\Blog;
8   -use common\models\BlogSearch;
9   -use yii\web\Controller;
10   -use yii\web\NotFoundHttpException;
11   -use yii\filters\VerbFilter;
12   -use yii\filters\AccessControl;
13   -/**
14   - * BlogController implements the CRUD actions for Blog model.
15   - */
16   -class BlogController extends Controller
17   -{
18   -
19   - /**
20   - * @inheritdoc
21   - */
22   - public function behaviors()
23   - {
24   - return [
25   - 'access'=>[
26   - 'class' => AccessBehavior::className(),
27   - 'rules' =>
28   - ['site' =>
29   - [
30   - [
31   - 'actions' => ['login', 'error'],
32   - 'allow' => true,
33   - ]
34   - ]
35   - ]
36   - ],
37   - 'verbs' => [
38   - 'class' => VerbFilter::className(),
39   - 'actions' => [
40   - 'logout' => ['post'],
41   - ],
42   - ],
43   - ];
44   - }
45   -
46   - /**
47   - * Lists all Blog models.
48   - * @return mixed
49   - */
50   - public function actionIndex()
51   - {
52   - $searchModel = new BlogSearch();
53   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
54   -
55   - return $this->render('index', [
56   - 'searchModel' => $searchModel,
57   - 'dataProvider' => $dataProvider,
58   - ]);
59   - }
60   -
61   - /**
62   - * Displays a single Blog model.
63   - * @param integer $id
64   - * @return mixed
65   - */
66   - public function actionView($id)
67   - {
68   - return $this->render('view', [
69   - 'model' => $this->findModel($id),
70   - ]);
71   - }
72   -
73   - /**
74   - * Creates a new Blog model.
75   - * If creation is successful, the browser will be redirected to the 'view' page.
76   - * @return mixed
77   - */
78   - public function actionCreate()
79   - {
80   - $model = new Blog();
81   -
82   - if ($model->load(Yii::$app->request->post())) {
83   -
84   - Fields::saveFieldData(Yii::$app->request->post('Fields'), $model->blog_id, Blog::className(), 'ru');
85   -
86   - if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
87   - $model->cover = $image->name;
88   - }
89   -
90   - if ($model->save() && $image) {
91   - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));
92   - }
93   -
94   - return $this->redirect(['view', 'id' => $model->blog_id]);
95   - } else {
96   - return $this->render('create', [
97   - 'model' => $model,
98   - ]);
99   - }
100   - }
101   -
102   - /**
103   - * Updates an existing Blog model.
104   - * If update is successful, the browser will be redirected to the 'view' page.
105   - * @param integer $id
106   - * @return mixed
107   - */
108   - public function actionUpdate($id)
109   - {
110   - $model = $this->findModel($id);
111   -
112   - if ($model->load(Yii::$app->request->post())) {
113   -
114   - Fields::saveFieldData(Yii::$app->request->post('Fields'), $model->blog_id, Blog::className(), 'ru');
115   -
116   - if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
117   - $model->cover = $image->name;
118   - }
119   -
120   - if ($model->save() && $image) {
121   - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));
122   - }
123   -
124   - return $this->redirect(['view', 'id' => $model->blog_id]);
125   - } else {
126   - return $this->render('update', [
127   - 'model' => $model,
128   - ]);
129   - }
130   - }
131   -
132   - /**
133   - * Deletes an existing Blog model.
134   - * If deletion is successful, the browser will be redirected to the 'index' page.
135   - * @param integer $id
136   - * @return mixed
137   - */
138   - public function actionDelete($id)
139   - {
140   - $this->findModel($id)->delete();
141   -
142   - return $this->redirect(['index']);
143   - }
144   -
145   - /**
146   - * Finds the Blog model based on its primary key value.
147   - * If the model is not found, a 404 HTTP exception will be thrown.
148   - * @param integer $id
149   - * @return Blog the loaded model
150   - * @throws NotFoundHttpException if the model cannot be found
151   - */
152   - protected function findModel($id)
153   - {
154   - if (($model = Blog::findOne($id)) !== null) {
155   - return $model;
156   - } else {
157   - throw new NotFoundHttpException('The requested page does not exist.');
158   - }
159   - }
160   -}
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use common\models\Project;
  6 +use common\models\ProjectImage;
  7 +use common\models\ProjectSearch;
  8 +use Yii;
  9 +use yii\web\Controller;
  10 +use yii\web\NotFoundHttpException;
  11 +use yii\filters\VerbFilter;
  12 +use developeruz\db_rbac\behaviors\AccessBehavior;
  13 +use yii\web\UploadedFile;
  14 +
  15 +/**
  16 + * ProjectController implements the CRUD actions for Project model.
  17 + */
  18 +class ProjectController extends Controller
  19 +{
  20 + /**
  21 + * @inheritdoc
  22 + */
  23 + public function behaviors()
  24 + {
  25 + return [
  26 + 'access'=>[
  27 + 'class' => AccessBehavior::className(),
  28 + 'rules' =>
  29 + ['site' =>
  30 + [
  31 + [
  32 + 'actions' => ['login', 'error'],
  33 + 'allow' => true,
  34 + ]
  35 + ]
  36 + ]
  37 + ],
  38 + 'verbs' => [
  39 + 'class' => VerbFilter::className(),
  40 + 'actions' => [
  41 + 'delete' => ['POST'],
  42 + ],
  43 + ],
  44 + ];
  45 + }
  46 +
  47 + /**
  48 + * Lists all Project models.
  49 + * @return mixed
  50 + */
  51 + public function actionIndex()
  52 + {
  53 + $searchModel = new ProjectSearch();
  54 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  55 +
  56 + return $this->render('index', [
  57 + 'searchModel' => $searchModel,
  58 + 'dataProvider' => $dataProvider,
  59 + ]);
  60 + }
  61 +
  62 + /**
  63 + * Displays a single Project model.
  64 + * @param integer $id
  65 + * @return mixed
  66 + */
  67 + public function actionView($id)
  68 + {
  69 + return $this->render('view', [
  70 + 'model' => $this->findModel($id),
  71 + ]);
  72 + }
  73 +
  74 + /**
  75 + * Creates a new Project model.
  76 + * If creation is successful, the browser will be redirected to the 'view' page.
  77 + * @return mixed
  78 + */
  79 + public function actionCreate()
  80 + {
  81 + $model = new Project();
  82 + if ($model->load(Yii::$app->request->post())) {
  83 + $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload');
  84 + if ($model->save()) {
  85 + if ($model->imagesUpload && (($images = $model->imagesUpload()) !== FALSE)) {
  86 + foreach ($images as $image) {
  87 + $imageModel = new ProjectImage();
  88 + $imageModel->project_id = $model->project_id;
  89 + $imageModel->image = $image;
  90 + $imageModel->save();
  91 + }
  92 + }
  93 + return $this->redirect(['view', 'id' => $model->project_id]);
  94 + }
  95 + }
  96 + return $this->render('create', [
  97 + 'model' => $model,
  98 + ]);
  99 + }
  100 +
  101 + /**
  102 + * Updates an existing Project model.
  103 + * If update is successful, the browser will be redirected to the 'view' page.
  104 + * @param integer $id
  105 + * @return mixed
  106 + */
  107 + public function actionUpdate($id)
  108 + {
  109 + $model = $this->findModel($id);
  110 + if ($model->load(Yii::$app->request->post())) {
  111 + $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload');
  112 + if ($model->save()) {
  113 + if ($model->imagesUpload && (($images = $model->imagesUpload()) !== FALSE)) {
  114 + foreach ($images as $image) {
  115 + $imageModel = new ProjectImage();
  116 + $imageModel->project_id = $model->project_id;
  117 + $imageModel->image = $image;
  118 + $imageModel->save();
  119 + }
  120 + }
  121 + return $this->redirect(['view', 'id' => $model->project_id]);
  122 + }
  123 + }
  124 + return $this->render('update', [
  125 + 'model' => $model,
  126 + ]);
  127 + }
  128 +
  129 + /**
  130 + * Deletes an existing Project model.
  131 + * If deletion is successful, the browser will be redirected to the 'index' page.
  132 + * @param integer $id
  133 + * @return mixed
  134 + */
  135 + public function actionDelete($id)
  136 + {
  137 + $this->findModel($id)->delete();
  138 +
  139 + return $this->redirect(['index']);
  140 + }
  141 +
  142 + public function actionDelimg($id) {
  143 + $model = ProjectImage::findOne($id);
  144 + if(empty($model)) {
  145 + throw new NotFoundHttpException();
  146 + }
  147 + $model->delete();
  148 + return '1';
  149 + }
  150 +
  151 + /**
  152 + * Finds the Project model based on its primary key value.
  153 + * If the model is not found, a 404 HTTP exception will be thrown.
  154 + * @param integer $id
  155 + * @return Project the loaded model
  156 + * @throws NotFoundHttpException if the model cannot be found
  157 + */
  158 + protected function findModel($id)
  159 + {
  160 + if (($model = Project::findOne($id)) !== null) {
  161 + return $model;
  162 + } else {
  163 + throw new NotFoundHttpException('The requested page does not exist.');
  164 + }
  165 + }
  166 +}
... ...
backend/controllers/SiteController.php
1 1 <?php
2 2 namespace backend\controllers;
3 3 use common\modules\product\models\ProductImage;
4   -use developeruz\db_rbac\behaviors\AccessBehavior;
5 4 use common\modules\product\models\Brand;
6 5 use common\modules\product\models\Category;
7 6 use common\modules\product\models\Product;
8 7 use common\modules\product\models\ProductVariant;
9   -use common\modules\product\models\ProductVariantType;
10 8 use Yii;
11   -use yii\filters\AccessControl;
12 9 use yii\helpers\Url;
13 10 use yii\web\Controller;
14 11 use backend\models\LoginForm;
15 12 use yii\filters\VerbFilter;
16   -use common\models\Blog;
17 13 /**
18 14 * Site controller
19 15 */
... ... @@ -70,14 +66,7 @@ class SiteController extends Controller
70 66  
71 67 public function actionIndex()
72 68 {
73   - $blog = new Blog();
74   - $post = \Yii::$app->request->post();
75   - if($blog->load($post)) {
76   - $blog->save();
77   - }
78   - return $this->render('index',[
79   - 'blog' => $blog
80   - ]);
  69 + return $this->render('index');
81 70 }
82 71  
83 72 public function actionLogin()
... ... @@ -307,25 +296,6 @@ class SiteController extends Controller
307 296 $resizeObj->resizeImage (370, 370, 'auto');
308 297 $resizeObj->saveImage ($dir.'/big/' . $mod_image, 100);
309 298 }
310   -
311   - $product_variant_type_name = '';
312   - if (! empty ($mod_color))
313   - $product_variant_type_name = 'ะฆะฒะตั‚';
314   - elseif (! empty ($mod_size))
315   - $product_variant_type_name = 'ะ ะฐะทะผะตั€';
316   -
317   - // ===== Set variant type ====
318   - if ( $product_variant_type_name ) {
319   - if ( ($product_variant_type = ProductVariantType::find()->filterWhere(['ilike', 'name', $product_variant_type_name])->one()) !== null ) {
320   - $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id;
321   - } else {
322   - // Create brand
323   - $product_variant_type = new ProductVariantType();
324   - $product_variant_type->name = $product_variant_type_name;
325   - $product_variant_type->save();
326   - $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id;
327   - }
328   - }
329 299 }
330 300 }
331 301  
... ...
backend/models/CommentSearch.php deleted
1   -<?php
2   -
3   -namespace backend\models;
4   -
5   -use Yii;
6   -use yii\base\Model;
7   -use yii\data\ActiveDataProvider;
8   -use common\modules\comment\models\Comment;
9   -
10   -/**
11   - * CommentSearch represents the model behind the search form about `common\modules\comment\models\Comment`.
12   - */
13   -class CommentSearch extends Comment
14   -{
15   - /**
16   - * @inheritdoc
17   - */
18   - public function rules()
19   - {
20   - return [
21   - [['comment_id', 'user_id', 'comment_pid', 'status', 'model_id'], 'integer'],
22   - [['text', 'user_name', 'user_email', 'date_add', 'date_update', 'date_delete', 'model'], 'safe'],
23   - ];
24   - }
25   -
26   - /**
27   - * @inheritdoc
28   - */
29   - public function scenarios()
30   - {
31   - // bypass scenarios() implementation in the parent class
32   - return Model::scenarios();
33   - }
34   -
35   - /**
36   - * Creates data provider instance with search query applied
37   - *
38   - * @param array $params
39   - *
40   - * @return ActiveDataProvider
41   - */
42   - public function search($params)
43   - {
44   - $query = Comment::find();
45   -
46   - // add conditions that should always apply here
47   -
48   - $dataProvider = new ActiveDataProvider([
49   - 'query' => $query,
50   - ]);
51   -
52   - $this->load($params);
53   -
54   - if (!$this->validate()) {
55   - // uncomment the following line if you do not want to return any records when validation fails
56   - // $query->where('0=1');
57   - return $dataProvider;
58   - }
59   -
60   - // grid filtering conditions
61   - $query->andFilterWhere([
62   - 'comment_id' => $this->comment_id,
63   - 'user_id' => $this->user_id,
64   - 'comment_pid' => $this->comment_pid,
65   - 'status' => $this->status,
66   - 'date_add' => $this->date_add,
67   - 'date_update' => $this->date_update,
68   - 'date_delete' => $this->date_delete,
69   - 'model_id' => $this->model_id,
70   - ]);
71   -
72   - $query->andFilterWhere(['like', 'text', $this->text])
73   - ->andFilterWhere(['like', 'user_name', $this->user_name])
74   - ->andFilterWhere(['like', 'user_email', $this->user_email])
75   - ->andFilterWhere(['like', 'model', $this->model]);
76   -
77   - return $dataProvider;
78   - }
79   -}
backend/models/Label.php
1 1 <?php
2 2  
3 3 namespace backend\models;
4   -use Yii;
5   -
6 4  
7 5 class Label extends \yii\db\ActiveRecord
8 6 {
... ... @@ -11,15 +9,8 @@ class Label extends \yii\db\ActiveRecord
11 9 {
12 10 return 'orders_label';
13 11 }
14   -
15   -
  12 +
16 13 public function getNl(){
17 14 return $this->name;
18   - }
19   -
20   -
21   -
22   -
23   -
24   -
  15 + }
25 16 }
... ...
backend/models/Orders.php
1 1 <?php
2   -
3   -namespace backend\models;
4   -use common\models\Customer;
5   -use Yii;
6   -
7   -class Orders extends \yii\db\ActiveRecord
8   -{
9   - public $labels;
10   - public static function tableName()
  2 +
  3 + namespace backend\models;
  4 +
  5 + use common\models\Customer;
  6 +
  7 + class Orders extends \yii\db\ActiveRecord
11 8 {
12   - return 'orders';
13   - }
14   -
15   - public function rules()
16   - {
17   - return [
18   - [['name'], 'required'],
19   - [['user_id','adress','body','total','status','email',
20   - 'comment','labels','pay','date_dedline','phone','phone2','numbercard','delivery',
21   - 'declaration','stock','consignment','payment', 'insurance',
22   - 'amount_imposed','shipping_by','city','date_time', 'id' ], 'safe'],
23   - //[['image'], 'file', 'extensions'=>'jpg, gif, png', 'skipOnEmpty'=>true],
24   - ];
25   - }
26   -
27   - public function attributeLabels()
28   - {
29   - return [
30   - 'id'=>'โ„– ะทะฐะบะฐะทะฐ',
31   - 'name'=>'ะคะ˜ะž',
32   - 'phone'=>'ะขะตะปะตั„ะพะฝ',
33   - 'phone2'=>'ะขะตะปะตั„ะพะฝ 2',
34   - 'adress'=>'ะะดั€ะตั',
35   - 'body'=>'ะกะพะพะฑั‰ะตะฝะธะต',
36   - 'reserve'=>'ะ ะตะทะตั€ะฒ',
37   - 'status'=>'ะกั‚ะฐั‚ัƒั',
38   - 'email'=>'E-mail',
39   - 'total'=>'ะกัƒะผะผะฐ',
40   - 'labels'=>'ะœะตั‚ะบะธ',
41   - 'label'=>'ะœะตั‚ะบะฐ',
42   - 'comment'=>'ะšะพะผะผะตะฝั‚ะฐั€ะธะน ะผะตะฝะตะดะถะตั€ะฐ',
43   - 'date_dedline'=>'ะ”ะตะดะปะฐะนะฝ',
44   - 'numbercard'=>'โ„– ะบะฐั€ั‚ะพั‡ะบะธ',
45   - 'delivery'=>'ะ”ะพัั‚ะฐะฒะบะฐ',
46   - 'declaration'=>'ะ”ะตะบะปะฐั€ะฐั†ะธั โ„–',
47   - 'stock'=>'โ„– ัะบะปะฐะดะฐ',
48   - 'consignment'=>'โ„– ะฝะฐะบะปะฐะดะฝะพะน',
49   - 'payment'=>'ะกะฟะพัะพะฑ ะพะฟะปะฐั‚ั‹',
50   - 'insurance'=>'ะกั‚ั€ะฐั…ะพะฒะบะฐ',
51   - 'amount_imposed'=>'ะกัƒะผะผะฐ ะฝะฐะปะพะถะตะฝะฝะพะณะพ',
52   - 'shipping_by'=>'ะžั‚ะฟั€ะฐะฒะบะฐ ะทะฐ ัั‡ะตั‚',
53   - 'city'=>'ะ“ะพั€ะพะด'
54   - ];
55   - }
56 9  
57   - public function beforeSave($insert) {
58   - return parent::beforeSave($insert);
59   - }
  10 + public $labels;
60 11  
61   - public function beforeDelete() {
62   - return parent::beforeDelete();
  12 + public static function tableName()
  13 + {
  14 + return 'orders';
63 15 }
64 16  
65   - public function getUser()
66   - {
67   - return $this->hasOne(Customer::className(), ['id' => 'user_id']);
  17 + public function rules()
  18 + {
  19 + return [
  20 + [
  21 + [ 'name' ],
  22 + 'required',
  23 + ],
  24 + [
  25 + [
  26 + 'user_id',
  27 + 'adress',
  28 + 'body',
  29 + 'total',
  30 + 'status',
  31 + 'email',
  32 + 'comment',
  33 + 'labels',
  34 + 'pay',
  35 + 'date_dedline',
  36 + 'phone',
  37 + 'phone2',
  38 + 'numbercard',
  39 + 'delivery',
  40 + 'declaration',
  41 + 'stock',
  42 + 'consignment',
  43 + 'payment',
  44 + 'insurance',
  45 + 'amount_imposed',
  46 + 'shipping_by',
  47 + 'city',
  48 + 'date_time',
  49 + 'id',
  50 + ],
  51 + 'safe',
  52 + ],
  53 + ];
  54 + }
  55 +
  56 + public function attributeLabels()
  57 + {
  58 + return [
  59 + 'id' => 'โ„– ะทะฐะบะฐะทะฐ',
  60 + 'name' => 'ะคะ˜ะž',
  61 + 'phone' => 'ะขะตะปะตั„ะพะฝ',
  62 + 'phone2' => 'ะขะตะปะตั„ะพะฝ 2',
  63 + 'adress' => 'ะะดั€ะตั',
  64 + 'body' => 'ะกะพะพะฑั‰ะตะฝะธะต',
  65 + 'reserve' => 'ะ ะตะทะตั€ะฒ',
  66 + 'status' => 'ะกั‚ะฐั‚ัƒั',
  67 + 'email' => 'E-mail',
  68 + 'total' => 'ะกัƒะผะผะฐ',
  69 + 'labels' => 'ะœะตั‚ะบะธ',
  70 + 'label' => 'ะœะตั‚ะบะฐ',
  71 + 'comment' => 'ะšะพะผะผะตะฝั‚ะฐั€ะธะน ะผะตะฝะตะดะถะตั€ะฐ',
  72 + 'date_dedline' => 'ะ”ะตะดะปะฐะนะฝ',
  73 + 'numbercard' => 'โ„– ะบะฐั€ั‚ะพั‡ะบะธ',
  74 + 'delivery' => 'ะ”ะพัั‚ะฐะฒะบะฐ',
  75 + 'declaration' => 'ะ”ะตะบะปะฐั€ะฐั†ะธั โ„–',
  76 + 'stock' => 'โ„– ัะบะปะฐะดะฐ',
  77 + 'consignment' => 'โ„– ะฝะฐะบะปะฐะดะฝะพะน',
  78 + 'payment' => 'ะกะฟะพัะพะฑ ะพะฟะปะฐั‚ั‹',
  79 + 'insurance' => 'ะกั‚ั€ะฐั…ะพะฒะบะฐ',
  80 + 'amount_imposed' => 'ะกัƒะผะผะฐ ะฝะฐะปะพะถะตะฝะฝะพะณะพ',
  81 + 'shipping_by' => 'ะžั‚ะฟั€ะฐะฒะบะฐ ะทะฐ ัั‡ะตั‚',
  82 + 'city' => 'ะ“ะพั€ะพะด',
  83 + ];
68 84 }
69 85  
70   -
  86 + public function getUser()
  87 + {
  88 + return $this->hasOne(Customer::className(), [ 'id' => 'user_id' ]);
  89 + }
71 90  
72   -}
73 91 \ No newline at end of file
  92 + }
74 93 \ No newline at end of file
... ...
backend/models/OrdersProducts.php
1 1 <?php
2   -
3   -namespace backend\models;
4   -use common\modules\product\models\ProductVariant;
5   -use Yii;
6   -
7   -class OrdersProducts extends \yii\db\ActiveRecord
8   -{
9 2  
10   - public static function tableName()
11   - {
12   - return 'orders_products';
13   - }
  3 + namespace backend\models;
14 4  
15   - public function rules()
16   - {
17   - return [
18   - [['sku','count','order_id'], 'required'],
19   - ];
20   - }
  5 + use common\modules\product\models\ProductVariant;
21 6  
22   - public function attributeLabels()
23   - {
24   - return [
25   - 'product_name'=>'ะŸั€ะพะดัƒะบั‚',
26   - 'name'=>'ะ’ะธะด',
27   - 'art'=>'ะั€ั‚ะธะบัƒะป',
28   - 'cost'=>'ะฆะตะฝะฐ ะทะฐ ะพะดะธะฝ',
29   - 'count'=>'ะšะพะป.',
30   - 'sum_cost'=>'ะกัƒะผะผะฐ',
31   - ];
32   - }
33   -
34   - public function getMod()
35   - {
36   - return $this->hasOne(ProductVariant::className(), ['product_variant_id' => 'mod_id']);
37   - }
38   -}
39 7 \ No newline at end of file
  8 + class OrdersProducts extends \yii\db\ActiveRecord
  9 + {
  10 +
  11 + public static function tableName()
  12 + {
  13 + return 'orders_products';
  14 + }
  15 +
  16 + public function rules()
  17 + {
  18 + return [
  19 + [
  20 + [
  21 + 'sku',
  22 + 'count',
  23 + 'order_id',
  24 + ],
  25 + 'required',
  26 + ],
  27 + ];
  28 + }
  29 +
  30 + public function attributeLabels()
  31 + {
  32 + return [
  33 + 'product_name' => 'ะŸั€ะพะดัƒะบั‚',
  34 + 'name' => 'ะ’ะธะด',
  35 + 'art' => 'ะั€ั‚ะธะบัƒะป',
  36 + 'cost' => 'ะฆะตะฝะฐ ะทะฐ ะพะดะธะฝ',
  37 + 'count' => 'ะšะพะป.',
  38 + 'sum_cost' => 'ะกัƒะผะผะฐ',
  39 + ];
  40 + }
  41 +
  42 + public function getMod()
  43 + {
  44 + return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'mod_id' ]);
  45 + }
  46 + }
40 47 \ No newline at end of file
... ...
backend/models/OrdersSearch.php
... ... @@ -2,10 +2,8 @@
2 2  
3 3 namespace backend\models;
4 4  
5   -use Yii;
6 5 use yii\base\Model;
7 6 use yii\data\ActiveDataProvider;
8   -use backend\models\Orders;
9 7  
10 8 /**
11 9 * OrdersSearch represents the model behind the search form about `backend\models\Orders`.
... ...
backend/models/User.php
1 1 <?php
2   -
3   -namespace backend\models;
4   -
5   -use developeruz\db_rbac\interfaces\UserRbacInterface;
6   -use common\models\Share;
7   -use common\modules\comment\models\Comment;
8   -use common\modules\comment\models\Rating;
9   -use yii\base\NotSupportedException;
10   -use Yii;
11   -use yii\behaviors\TimestampBehavior;
12   -use yii\db\ActiveRecord;
13   -use yii\web\IdentityInterface;
14   -/**
15   - * This is the model class for table "user".
16   - *
17   - * @property integer $id
18   - * @property string $username
19   - * @property string $auth_key
20   - * @property string $password_hash
21   - * @property string $password_reset_token
22   - * @property string $email
23   - * @property integer $status
24   - * @property integer $created_at
25   - * @property integer $updated_at
26   - *
27   - * @property Comment[] $comments
28   - * @property Rating[] $ratings
29   - * @property Share[] $shares
30   - */
31   -class User extends ActiveRecord implements UserRbacInterface, IdentityInterface
32   -{
33   -
34   - const STATUS_DELETED = 0;
35   - const STATUS_ACTIVE = 10;
36   - public $password;
37   -
  2 +
  3 + namespace backend\models;
  4 +
  5 + use developeruz\db_rbac\interfaces\UserRbacInterface;
  6 + use common\models\Share;
  7 + use common\modules\comment\models\CommentModel;
  8 + use common\modules\comment\models\RatingModel;
  9 + use yii\base\NotSupportedException;
  10 + use Yii;
  11 + use yii\behaviors\TimestampBehavior;
  12 + use yii\db\ActiveRecord;
  13 + use yii\web\IdentityInterface;
  14 +
38 15 /**
39   - * @inheritdoc
  16 + * This is the model class for table "user".
  17 + * @property integer $id
  18 + * @property string $username
  19 + * @property string $auth_key
  20 + * @property string $password_hash
  21 + * @property string $password_reset_token
  22 + * @property string $email
  23 + * @property integer $status
  24 + * @property integer $created_at
  25 + * @property integer $updated_at
  26 + * @property CommentModel[] $comments
  27 + * @property RatingModel[] $ratings
  28 + * @property Share[] $shares
40 29 */
41   - public static function tableName()
42   - {
43   - return 'user';
44   - }
45   -
46   - /**
47   - * @inheritdoc
48   - */
49   - public function rules()
50   - {
51   - return [
52   - [['username', 'password', 'email'], 'required'],
53   - [['status', 'created_at', 'updated_at'], 'integer'],
54   - [['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
55   - [['auth_key'], 'string', 'max' => 32],
56   - [['password_reset_token'], 'unique'],
57   - ['email', 'unique', 'targetClass' => '\backend\models\User', 'message' => Yii::t('app','message',[
58   - 'field' => 'Email'
59   - ])],
60   - ];
61   - }
62   -
63   -
64   - /**
65   - * @inheritdoc
66   - */
67   - public function behaviors()
68   - {
69   - return [
70   - TimestampBehavior::className(),
71   - [
72   - 'class' => 'common\behaviors\ShowImage',
73   - ],
74   - ];
75   - }
76   -
77   -
78   - public function beforeSave($insert)
79   - {
80   - $this->setPassword($this->password);
81   - $this->generateAuthKey();
82   - return parent::beforeSave($insert);
83   - }
84   -
85   -
86   -
87   - /**
88   - * @inheritdoc
89   - */
90   - public function attributeLabels()
91   - {
92   - return [
93   - 'id' => 'ID',
94   - 'username' => 'Username',
95   - 'auth_key' => 'Auth Key',
96   - 'password_hash' => 'Password Hash',
97   - 'password_reset_token' => 'Password Reset Token',
98   - 'email' => 'Email',
99   - 'status' => 'Status',
100   - 'created_at' => 'Created At',
101   - 'updated_at' => 'Updated At',
102   - ];
103   - }
104   -
105   -
106   - /**
107   - * Generates "remember me" authentication key
108   - */
109   - public function generateAuthKey()
110   - {
111   - $this->auth_key = Yii::$app->security->generateRandomString();
112   - }
113   -
114   - /**
115   - * Generates password hash from password and sets it to the model
116   - *
117   - * @param string $password
118   - */
119   - public function setPassword($password)
120   - {
121   - $this->password_hash = Yii::$app->security->generatePasswordHash($password);
122   - }
123   -
124   -
125   -
126   -
127   -
128   - public function getRole(){
129   - return !empty($this->id) ? \Yii::$app->authManager->getRolesByUser($this->id) : "";
130   - }
131   -
132   - /**
133   - * @inheritdoc
134   - */
135   - public function getId()
136   - {
137   - return $this->getPrimaryKey();
138   - }
139   -
140   - /**
141   - * @inheritdoc
142   - */
143   - public function getAuthKey()
144   - {
145   - return $this->auth_key;
146   - }
147   -
148   - /**
149   - * @inheritdoc
150   - */
151   - public function validateAuthKey($authKey)
152   - {
153   - return $this->getAuthKey() === $authKey;
154   - }
155   -
156   -
157   - /**
158   - * @inheritdoc
159   - */
160   - public static function findIdentityByAccessToken($token, $type = null)
161   - {
162   - throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
163   - }
164   -
165   - /**
166   - * @inheritdoc
167   - */
168   - public static function findIdentity($id)
169   - {
170   - return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);
171   - }
172   -
173   - /**
174   - * @return \yii\db\ActiveQuery
175   - */
176   - public function getComments()
177   - {
178   - return $this->hasMany(Comment::className(), ['user_id' => 'id']);
179   - }
180   -
181   - /**
182   - * @return \yii\db\ActiveQuery
183   - */
184   - public function getRatings()
185   - {
186   - return $this->hasMany(Rating::className(), ['user_id' => 'id']);
187   - }
188   -
189   - /**
190   - * @return \yii\db\ActiveQuery
191   - */
192   - public function getShares()
193   - {
194   - return $this->hasMany(Share::className(), ['user_id' => 'id']);
195   - }
196   -
197   -
198   - public function getUserName()
199   - {
200   - return $this->username;
  30 + class User extends ActiveRecord implements UserRbacInterface, IdentityInterface
  31 + {
  32 +
  33 + const STATUS_DELETED = 0;
  34 + const STATUS_ACTIVE = 10;
  35 +
  36 + public $password;
  37 +
  38 + /**
  39 + * @inheritdoc
  40 + */
  41 + public static function tableName()
  42 + {
  43 + return 'user';
  44 + }
  45 +
  46 + /**
  47 + * @inheritdoc
  48 + */
  49 + public function rules()
  50 + {
  51 + return [
  52 + [
  53 + [
  54 + 'username',
  55 + 'password',
  56 + 'email',
  57 + ],
  58 + 'required',
  59 + ],
  60 + [
  61 + [
  62 + 'status',
  63 + 'created_at',
  64 + 'updated_at',
  65 + ],
  66 + 'integer',
  67 + ],
  68 + [
  69 + [
  70 + 'username',
  71 + 'password_hash',
  72 + 'password_reset_token',
  73 + 'email',
  74 + ],
  75 + 'string',
  76 + 'max' => 255,
  77 + ],
  78 + [
  79 + [ 'auth_key' ],
  80 + 'string',
  81 + 'max' => 32,
  82 + ],
  83 + [
  84 + [ 'password_reset_token' ],
  85 + 'unique',
  86 + ],
  87 + [
  88 + 'email',
  89 + 'unique',
  90 + 'targetClass' => '\backend\models\User',
  91 + 'message' => Yii::t('app', 'message', [
  92 + 'field' => 'Email',
  93 + ]),
  94 + ],
  95 + ];
  96 + }
  97 +
  98 + /**
  99 + * @inheritdoc
  100 + */
  101 + public function behaviors()
  102 + {
  103 + return [
  104 + TimestampBehavior::className(),
  105 + [
  106 + 'class' => 'common\behaviors\ShowImage',
  107 + ],
  108 + ];
  109 + }
  110 +
  111 + public function beforeSave($insert)
  112 + {
  113 + $this->setPassword($this->password);
  114 + $this->generateAuthKey();
  115 + return parent::beforeSave($insert);
  116 + }
  117 +
  118 + /**
  119 + * @inheritdoc
  120 + */
  121 + public function attributeLabels()
  122 + {
  123 + return [
  124 + 'id' => 'ID',
  125 + 'username' => 'Username',
  126 + 'auth_key' => 'Auth Key',
  127 + 'password_hash' => 'Password Hash',
  128 + 'password_reset_token' => 'Password Reset Token',
  129 + 'email' => 'Email',
  130 + 'status' => 'Status',
  131 + 'created_at' => 'Created At',
  132 + 'updated_at' => 'Updated At',
  133 + ];
  134 + }
  135 +
  136 + /**
  137 + * Generates "remember me" authentication key
  138 + */
  139 + public function generateAuthKey()
  140 + {
  141 + $this->auth_key = Yii::$app->security->generateRandomString();
  142 + }
  143 +
  144 + /**
  145 + * Generates password hash from password and sets it to the model
  146 + *
  147 + * @param string $password
  148 + */
  149 + public function setPassword($password)
  150 + {
  151 + $this->password_hash = Yii::$app->security->generatePasswordHash($password);
  152 + }
  153 +
  154 + public function getRole()
  155 + {
  156 + return !empty( $this->id ) ? \Yii::$app->authManager->getRolesByUser($this->id) : "";
  157 + }
  158 +
  159 + /**
  160 + * @inheritdoc
  161 + */
  162 + public function getId()
  163 + {
  164 + return $this->getPrimaryKey();
  165 + }
  166 +
  167 + /**
  168 + * @inheritdoc
  169 + */
  170 + public function getAuthKey()
  171 + {
  172 + return $this->auth_key;
  173 + }
  174 +
  175 + /**
  176 + * @inheritdoc
  177 + */
  178 + public function validateAuthKey($authKey)
  179 + {
  180 + return $this->getAuthKey() === $authKey;
  181 + }
  182 +
  183 + /**
  184 + * @inheritdoc
  185 + */
  186 + public static function findIdentityByAccessToken($token, $type = NULL)
  187 + {
  188 + throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
  189 + }
  190 +
  191 + /**
  192 + * @inheritdoc
  193 + */
  194 + public static function findIdentity($id)
  195 + {
  196 + return static::findOne([
  197 + 'id' => $id,
  198 + 'status' => self::STATUS_ACTIVE,
  199 + ]);
  200 + }
  201 +
  202 + /**
  203 + * @return \yii\db\ActiveQuery
  204 + */
  205 + public function getComments()
  206 + {
  207 + return $this->hasMany(CommentModel::className(), [ 'user_id' => 'id' ]);
  208 + }
  209 +
  210 + /**
  211 + * @return \yii\db\ActiveQuery
  212 + */
  213 + public function getRatings()
  214 + {
  215 + return $this->hasMany(RatingModel::className(), [ 'user_id' => 'id' ]);
  216 + }
  217 +
  218 + /**
  219 + * @return \yii\db\ActiveQuery
  220 + */
  221 + public function getShares()
  222 + {
  223 + return $this->hasMany(Share::className(), [ 'user_id' => 'id' ]);
  224 + }
  225 +
  226 + public function getUserName()
  227 + {
  228 + return $this->username;
  229 + }
  230 +
201 231 }
202   -
203   -
204   -}
... ...
backend/models/UserSearch.php
1 1 <?php
2   -
3   -namespace backend\models;
4   -
5   -use Yii;
6   -use yii\base\Model;
7   -use yii\data\ActiveDataProvider;
8   -use backend\models\User;
9   -
10   -/**
11   - * UserSearch represents the model behind the search form about `backend\models\User`.
12   - */
13   -class UserSearch extends User
14   -{
  2 +
  3 + namespace backend\models;
  4 +
  5 + use yii\base\Model;
  6 + use yii\data\ActiveDataProvider;
  7 +
15 8 /**
16   - * @inheritdoc
  9 + * UserSearch represents the model behind the search form about `backend\models\User`.
17 10 */
18   - public function rules()
  11 + class UserSearch extends User
19 12 {
20   - return [
21   - [['id', 'status', 'created_at', 'updated_at'], 'integer'],
22   - [['username', 'auth_key', 'password_hash', 'password_reset_token', 'email'], 'safe'],
23   - ];
24   - }
25   -
26   - /**
27   - * @inheritdoc
28   - */
29   - public function scenarios()
30   - {
31   - // bypass scenarios() implementation in the parent class
32   - return Model::scenarios();
33   - }
34   -
35   - /**
36   - * Creates data provider instance with search query applied
37   - *
38   - * @param array $params
39   - *
40   - * @return ActiveDataProvider
41   - */
42   - public function search($params)
43   - {
44   - $query = User::find();
45   -
46   - // add conditions that should always apply here
47   -
48   - $dataProvider = new ActiveDataProvider([
49   - 'query' => $query,
50   - ]);
51   -
52   - $this->load($params);
53   -
54   - if (!$this->validate()) {
55   - // uncomment the following line if you do not want to return any records when validation fails
56   - // $query->where('0=1');
  13 +
  14 + /**
  15 + * @inheritdoc
  16 + */
  17 + public function rules()
  18 + {
  19 + return [
  20 + [
  21 + [
  22 + 'id',
  23 + 'status',
  24 + 'created_at',
  25 + 'updated_at',
  26 + ],
  27 + 'integer',
  28 + ],
  29 + [
  30 + [
  31 + 'username',
  32 + 'auth_key',
  33 + 'password_hash',
  34 + 'password_reset_token',
  35 + 'email',
  36 + ],
  37 + 'safe',
  38 + ],
  39 + ];
  40 + }
  41 +
  42 + /**
  43 + * @inheritdoc
  44 + */
  45 + public function scenarios()
  46 + {
  47 + // bypass scenarios() implementation in the parent class
  48 + return Model::scenarios();
  49 + }
  50 +
  51 + /**
  52 + * Creates data provider instance with search query applied
  53 + *
  54 + * @param array $params
  55 + *
  56 + * @return ActiveDataProvider
  57 + */
  58 + public function search($params)
  59 + {
  60 + $query = User::find();
  61 +
  62 + // add conditions that should always apply here
  63 +
  64 + $dataProvider = new ActiveDataProvider([
  65 + 'query' => $query,
  66 + ]);
  67 +
  68 + $this->load($params);
  69 +
  70 + if(!$this->validate()) {
  71 + // uncomment the following line if you do not want to return any records when validation fails
  72 + // $query->where('0=1');
  73 + return $dataProvider;
  74 + }
  75 +
  76 + // grid filtering conditions
  77 + $query->andFilterWhere([
  78 + 'id' => $this->id,
  79 + 'status' => $this->status,
  80 + 'created_at' => $this->created_at,
  81 + 'updated_at' => $this->updated_at,
  82 + ]);
  83 +
  84 + $query->andFilterWhere([
  85 + 'like',
  86 + 'username',
  87 + $this->username,
  88 + ])
  89 + ->andFilterWhere([
  90 + 'like',
  91 + 'auth_key',
  92 + $this->auth_key,
  93 + ])
  94 + ->andFilterWhere([
  95 + 'like',
  96 + 'password_hash',
  97 + $this->password_hash,
  98 + ])
  99 + ->andFilterWhere([
  100 + 'like',
  101 + 'password_reset_token',
  102 + $this->password_reset_token,
  103 + ])
  104 + ->andFilterWhere([
  105 + 'like',
  106 + 'email',
  107 + $this->email,
  108 + ]);
  109 +
57 110 return $dataProvider;
58 111 }
59   -
60   - // grid filtering conditions
61   - $query->andFilterWhere([
62   - 'id' => $this->id,
63   - 'status' => $this->status,
64   - 'created_at' => $this->created_at,
65   - 'updated_at' => $this->updated_at,
66   - ]);
67   -
68   - $query->andFilterWhere(['like', 'username', $this->username])
69   - ->andFilterWhere(['like', 'auth_key', $this->auth_key])
70   - ->andFilterWhere(['like', 'password_hash', $this->password_hash])
71   - ->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])
72   - ->andFilterWhere(['like', 'email', $this->email]);
73   -
74   - return $dataProvider;
75 112 }
76   -}
... ...
backend/views/articles/_form.php
... ... @@ -21,8 +21,7 @@ use yii\jui\DatePicker;
21 21  
22 22 <?= $form->field($model, 'date')
23 23 ->widget(DatePicker::className(), [
24   - 'dateFormat' => 'yyyy-MM-dd',
25   - 'clientOptions' => [ 'minDate' => 1 ],
  24 + 'dateFormat' => 'dd-MM-yyyy',
26 25 ]) ?>
27 26 <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
28 27  
... ... @@ -35,7 +34,16 @@ use yii\jui\DatePicker;
35 34 ]
36 35 )
37 36 ]) ?>
38   -
  37 +
  38 + <?= $form->field($model, 'body_preview')->widget(CKEditor::className(),
  39 + [
  40 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
  41 + 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
  42 + 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
  43 + 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
  44 + ]
  45 + )
  46 + ]) ?>
39 47  
40 48 <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [
41 49 'language' => 'ru',
... ...
backend/views/blog/index.php deleted
1   -<?php
2   -
3   -use yii\helpers\Html;
4   -use yii\grid\GridView;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $searchModel common\models\BlogSearch */
8   -/* @var $dataProvider yii\data\ActiveDataProvider */
9   -
10   -$this->title = 'Blogs';
11   -$this->params['breadcrumbs'][] = $this->title;
12   -?>
13   -<div class="blog-index">
14   -
15   - <h1><?= Html::encode($this->title) ?></h1>
16   - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
17   -
18   - <p>
19   - <?= Html::a('Create Blog', ['create'], ['class' => 'btn btn-success']) ?>
20   - </p>
21   - <?= GridView::widget([
22   - 'dataProvider' => $dataProvider,
23   - 'filterModel' => $searchModel,
24   - 'columns' => [
25   - ['class' => 'yii\grid\SerialColumn'],
26   -
27   - 'blog_id',
28   - 'user_id',
29   - 'name',
30   - 'link',
31   - 'date_add',
32   - // 'user_add_id',
33   - // 'view_count',
34   - // 'description:ntext',
35   - // 'cover',
36   -
37   - ['class' => 'yii\grid\ActionColumn'],
38   - ],
39   - ]); ?>
40   -</div>
backend/views/blog/view.php deleted
1   -<?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\DetailView;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Blog */
8   -
9   -$this->title = $model->name;
10   -$this->params['breadcrumbs'][] = ['label' => 'Blogs', 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
12   -?>
13   -<div class="blog-view">
14   -
15   - <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <p>
18   - <?= Html::a('Update', ['update', 'id' => $model->blog_id], ['class' => 'btn btn-primary']) ?>
19   - <?= Html::a('Delete', ['delete', 'id' => $model->blog_id], [
20   - 'class' => 'btn btn-danger',
21   - 'data' => [
22   - 'confirm' => 'Are you sure you want to delete this item?',
23   - 'method' => 'post',
24   - ],
25   - ]) ?>
26   - </p>
27   -
28   - <?= DetailView::widget([
29   - 'model' => $model,
30   - 'attributes' => [
31   - 'blog_id',
32   - 'user_id',
33   - 'name',
34   - 'link',
35   - 'date_add',
36   - 'user_add_id',
37   - 'view_count',
38   - 'description:ntext',
39   - 'cover',
40   - ],
41   - ]) ?>
42   -
43   -</div>
backend/views/brand/_search.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\modules\product\models\BrandSearch */
8   -/* @var $form yii\widgets\ActiveForm */
  2 +
  3 + use yii\helpers\Html;
  4 + use yii\widgets\ActiveForm;
  5 +
  6 + /**
  7 + * @var $this yii\web\View
  8 + * @var $model common\modules\product\models\BrandSearch
  9 + * @var $form yii\widgets\ActiveForm
  10 + */
9 11 ?>
10 12  
11 13 <div class="brand-search">
12   -
  14 +
13 15 <?php $form = ActiveForm::begin([
14   - 'action' => ['index'],
  16 + 'action' => [ 'index' ],
15 17 'method' => 'get',
16 18 ]); ?>
17   -
  19 +
18 20 <?= $form->field($model, 'brand_id') ?>
19   -
20   - <?= $form->field($model, 'brand_name_id') ?>
21   -
  21 +
22 22 <?= $form->field($model, 'alias') ?>
23   -
  23 +
24 24 <?= $form->field($model, 'image') ?>
25   -
  25 +
26 26 <?= $form->field($model, 'meta_title') ?>
27   -
28   - <?php // echo $form->field($model, 'meta_desc') ?>
29   -
30   - <?php // echo $form->field($model, 'meta_robots') ?>
31   -
32   - <?php // echo $form->field($model, 'seo_text') ?>
33   -
  27 +
34 28 <div class="form-group">
35   - <?= Html::submitButton(Yii::t('product', 'Search'), ['class' => 'btn btn-primary']) ?>
36   - <?= Html::resetButton(Yii::t('product', 'Reset'), ['class' => 'btn btn-default']) ?>
  29 + <?= Html::submitButton(Yii::t('product', 'Search'), [ 'class' => 'btn btn-primary' ]) ?>
  30 + <?= Html::resetButton(Yii::t('product', 'Reset'), [ 'class' => 'btn btn-default' ]) ?>
37 31 </div>
38   -
  32 +
39 33 <?php ActiveForm::end(); ?>
40 34  
41 35 </div>
... ...
backend/views/brand/view.php
... ... @@ -29,7 +29,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
29 29 'model' => $model,
30 30 'attributes' => [
31 31 'brand_id',
32   - 'brand_name_id',
33 32 'alias',
34 33 'imageUrl:image',
35 34 'meta_title',
... ...
backend/views/category/_form.php
... ... @@ -30,6 +30,9 @@ use kartik\select2\Select2;
30 30 ]
31 31 ])->label(Yii::t('product', 'Parent category')) ?>
32 32  
  33 + <?php
  34 + /* Tax group - add to controller
  35 + ?>
33 36 <?= $form->field($model, 'taxGroup')->widget(Select2::className(), [
34 37 'data' => \yii\helpers\ArrayHelper::map(\common\modules\rubrication\models\TaxGroup::find()->all(), 'tax_group_id', 'name'),
35 38 'language' => 'ru',
... ... @@ -42,6 +45,8 @@ use kartik\select2\Select2;
42 45 ],
43 46 ]
44 47 ) ?>
  48 + */
  49 + ?>
45 50  
46 51 <?= $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
47 52 'language' => 'ru',
... ... @@ -77,10 +82,6 @@ use kartik\select2\Select2;
77 82 )
78 83 ]) ?>
79 84  
80   - <?php if (!empty($model) && $model->depth == 2) :?>
81   - <?= $form->field($model, 'populary')->checkbox() ?>
82   - <?php endif?>
83   -
84 85 <div class="form-group">
85 86 <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
86 87 <?php if ($model->isNewRecord) :?>
... ...
backend/views/category/_search.php
... ... @@ -25,20 +25,6 @@ use yii\widgets\ActiveForm;
25 25  
26 26 <?= $form->field($model, 'image') ?>
27 27  
28   - <?php // echo $form->field($model, 'meta_title') ?>
29   -
30   - <?php // echo $form->field($model, 'meta_desc') ?>
31   -
32   - <?php // echo $form->field($model, 'meta_robots') ?>
33   -
34   - <?php // echo $form->field($model, 'seo_text') ?>
35   -
36   - <?php // echo $form->field($model, 'category_name_id') ?>
37   -
38   - <?php // echo $form->field($model, 'product_unit_id') ?>
39   -
40   - <?php // echo $form->field($model, 'alias') ?>
41   -
42 28 <div class="form-group">
43 29 <?= Html::submitButton(Yii::t('product', 'Search'), ['class' => 'btn btn-primary']) ?>
44 30 <?= Html::resetButton(Yii::t('product', 'Reset'), ['class' => 'btn btn-default']) ?>
... ...
backend/views/category/index.php
1 1 <?php
2   -
3   -use yii\helpers\Html;
4   -use kartik\grid\GridView;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $searchModel common\modules\product\models\CategorySearch */
8   -/* @var $dataProvider yii\data\ActiveDataProvider */
9   -
10   -$this->title = Yii::t('product', 'Categories');
11   -$this->params['breadcrumbs'][] = $this->title;
  2 +
  3 + use yii\helpers\Html;
  4 + use kartik\grid\GridView;
  5 +
  6 + /**
  7 + * @var $this yii\web\View
  8 + * @var $searchModel common\modules\product\models\CategorySearch
  9 + * @var $dataProvider yii\data\ActiveDataProvider
  10 + */
  11 + $this->title = Yii::t('product', 'Categories');
  12 + $this->params[ 'breadcrumbs' ][] = $this->title;
12 13 ?>
13 14 <div class="category-index">
14   -
  15 +
15 16 <h1><?= Html::encode($this->title) ?></h1>
16   - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
17   -
  17 +
18 18 <p>
19   - <?= Html::a(Yii::t('product', 'Create Category'), ['create'], ['class' => 'btn btn-success']) ?>
  19 + <?= Html::a(Yii::t('product', 'Create Category'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
20 20 </p>
21 21 <?= GridView::widget([
22 22 'dataProvider' => $dataProvider,
23   -// 'filterModel' => $searchModel,
24   - 'columns' => [
25   - ['class' => 'yii\grid\SerialColumn'],
  23 + 'columns' => [
  24 + [ 'class' => 'yii\grid\SerialColumn' ],
26 25 [
27   - 'label'=> Yii::t('product', 'Name'),
28   - 'content'=>function($data){
  26 + 'label' => Yii::t('product', 'Name'),
  27 + 'content' => function($data) {
29 28 $op = [];
30   - foreach($data->getParents()->all() as $parent) {
  29 + foreach($data->getParents()
  30 + ->all() as $parent) {
31 31 $op[] = $parent->name;
32 32 }
33 33 $op[] = $data->name;
34 34 return implode('&nbsp;&rarr;&nbsp;', $op);
35   -// return str_repeat('-', $data->depth) .'&nbsp;'. $data->name;
36   - }
  35 + },
37 36 ],
38 37 [
39   - 'class' => 'yii\grid\ActionColumn',
40   - 'template' => '{view} {update} {delete} {populary}',
41   - 'buttons' => [
42   - 'populary' => function ($url, $model) {
43   - if ($model->depth == 2) {
44   - return Html::a('<span class="glyphicon glyphicon-star' . ($model->populary ? '' : '-empty') . '"></span>', $url, [
45   - 'title' => Yii::t('product', ($model->populary ? 'Set not populary' : 'Set populary')),
46   - ]);
47   - }
48   - },
49   - ],
50   - 'urlCreator' => function ($action, $model, $key, $index) {
51   - switch ($action) {
52   - case 'populary':
53   - return \yii\helpers\Url::to(['category/populary', 'id' => $model->category_id]);
54   - break;
  38 + 'class' => 'yii\grid\ActionColumn',
  39 + 'template' => '{view} {update} {delete}',
  40 + 'urlCreator' => function($action, $model, $key, $index) {
  41 + switch($action) {
55 42 case 'view':
56   - return \yii\helpers\Url::to(['category/view', 'id' => $model->category_id]);
  43 + return \yii\helpers\Url::to([
  44 + 'category/view',
  45 + 'id' => $model->category_id,
  46 + ]);
57 47 break;
58 48 case 'update':
59   - return \yii\helpers\Url::to(['category/update', 'id' => $model->category_id]);
  49 + return \yii\helpers\Url::to([
  50 + 'category/update',
  51 + 'id' => $model->category_id,
  52 + ]);
60 53 break;
61 54 case 'delete':
62   - return \yii\helpers\Url::to(['category/delete', 'id' => $model->category_id]);
  55 + return \yii\helpers\Url::to([
  56 + 'category/delete',
  57 + 'id' => $model->category_id,
  58 + ]);
63 59 break;
64 60 }
65   - }
  61 + return '';
  62 + },
66 63 ],
67 64 ],
68   - 'panel' => [
69   - 'type'=>'success',
  65 + 'panel' => [
  66 + 'type' => 'success',
70 67 ],
71 68 ]); ?>
72 69 </div>
... ...
backend/views/category/view.php
... ... @@ -42,10 +42,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
42 42 'meta_robots',
43 43 'h1',
44 44 'seo_text:ntext',
45   - 'category_name_id',
46 45 'product_unit_id',
47 46 'alias',
48   -
49 47 ],
50 48 ]) ?>
51 49  
... ...
backend/views/comment/_form.php deleted
1   -<?php
2   -
3   - use common\modules\comment\models\Comment;
4   - use yii\helpers\Html;
5   - use yii\widgets\ActiveForm;
6   -
7   - /* @var $this yii\web\View */
8   - /* @var $model Comment */
9   - /* @var $form yii\widgets\ActiveForm */
10   - $status_list = [
11   - Comment::STATUS_ACTIVE => 'ะะบั‚ะธะฒะฝั‹ะน',
12   - Comment::STATUS_HIDDEN => 'ะะพะฒั‹ะน',
13   - Comment::STATUS_DELETED => 'ะฃะดะฐะปะตะฝะฝั‹ะน',
14   - ]
15   -?>
16   -
17   -<div class="comment-form">
18   -
19   - <?php $form = ActiveForm::begin(); ?>
20   -
21   - <?= $form->field($model, 'text')
22   - ->textarea([ 'rows' => 6 ]) ?>
23   -
24   - <?= $form->field($model, 'status')
25   - ->dropDownList($status_list) ?>
26   -
27   - <div class="form-group">
28   - <?= Html::submitButton('ะžะฑะฝะพะฒะธั‚ัŒ', [ 'class' => 'btn btn-primary' ]) ?>
29   - </div>
30   -
31   - <?php ActiveForm::end(); ?>
32   -
33   -</div>
backend/views/comment/_search.php deleted
1   -<?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model backend\models\CommentSearch */
8   -/* @var $form yii\widgets\ActiveForm */
9   -?>
10   -
11   -<div class="comment-search">
12   -
13   - <?php $form = ActiveForm::begin([
14   - 'action' => ['index'],
15   - 'method' => 'get',
16   - ]); ?>
17   -
18   - <?= $form->field($model, 'comment_id') ?>
19   -
20   - <?= $form->field($model, 'text') ?>
21   -
22   - <?= $form->field($model, 'user_id') ?>
23   -
24   - <?= $form->field($model, 'user_name') ?>
25   -
26   - <?= $form->field($model, 'user_email') ?>
27   -
28   - <?php // echo $form->field($model, 'comment_pid') ?>
29   -
30   - <?php // echo $form->field($model, 'status') ?>
31   -
32   - <?php // echo $form->field($model, 'date_add') ?>
33   -
34   - <?php // echo $form->field($model, 'date_update') ?>
35   -
36   - <?php // echo $form->field($model, 'date_delete') ?>
37   -
38   - <?php // echo $form->field($model, 'model') ?>
39   -
40   - <?php // echo $form->field($model, 'model_id') ?>
41   -
42   - <div class="form-group">
43   - <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
44   - <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
45   - </div>
46   -
47   - <?php ActiveForm::end(); ?>
48   -
49   -</div>
backend/views/comment/index.php deleted
1   -<?php
2   -
3   - use common\modules\comment\models\Comment;
4   - use yii\helpers\Html;
5   - use yii\grid\GridView;
6   - use yii\helpers\Url;
7   -
8   - /* @var $this yii\web\View */
9   - /* @var $dataProvider yii\data\ActiveDataProvider */
10   -
11   - $this->title = 'ะšะพะผะผะตะฝั‚ั‹';
12   - $this->params[ 'breadcrumbs' ][] = $this->title;
13   -?>
14   -<div class="comment-index">
15   -
16   - <h1><?= Html::encode($this->title) ?></h1>
17   -
18   - <?= GridView::widget([
19   - 'dataProvider' => $dataProvider,
20   - 'columns' => [
21   - [
22   - 'class' => 'yii\grid\ActionColumn',
23   - 'template' => '{approve} {update} {delete}',
24   - 'buttons' => [
25   - 'approve' => function($url, $model, $key) {
26   - /**
27   - * @var Comment $model
28   - */
29   - $options = array_merge([
30   - 'title' => "ะŸะพะดั‚ะฒะตั€ะดะธั‚ัŒ",
31   - 'aria-label' => "ะŸะพะดั‚ะฒะตั€ะดะธั‚ัŒ",
32   - 'data-confirm' => "ะšะพะผะผะตะฝั‚ะฐั€ะธะน ะธ ะพั†ะตะฝะบะฐ ะพั‚ะพะฑั€ะฐะทะธั‚ัั ะฝะฐ ะฟัƒะฑะปะธั‡ะฝะพะน ั‡ะฐัั‚ะธ ัะฐะนั‚ะฐ, ะฟะพะดั‚ะฒะตั€ะดะธั‚ัŒ?",
33   - 'data-method' => 'post',
34   - 'data-pjax' => '0',
35   - ]);
36   - $glyphicon = 'glyphicon-ok';
37   - if($model->status == $model::STATUS_ACTIVE) {
38   - $url = Url::to(['comment/disapprove', 'id' => $model->comment_id]);
39   - $glyphicon = 'glyphicon-remove';
40   - }
41   - return Html::a('<span class="glyphicon '.$glyphicon.'"></span>', $url, $options);
42   - }
43   - ]
44   - ],
45   - 'comment_id',
46   - [
47   - 'attribute' => 'rating.value',
48   - 'label' => 'ะžั†ะตะฝะบะฐ',
49   - ],
50   - 'text:ntext',
51   - [
52   - 'content' => function($model) {
53   - /**
54   - * @var Comment $model
55   - */
56   - if(!empty( $model->user )) {
57   - return $model->user->username . " (ID: " . $model->user->id . ")";
58   - } else {
59   - return $model->user_name . " (ะ“ะพัั‚ัŒ: " . $model->user_email . ")";
60   - }
61   - },
62   - 'label' => 'ะŸะพะปัŒะทะพะฒะฐั‚ะตะปัŒ',
63   - ],
64   - [
65   - 'attribute' => 'status',
66   - 'value' => function($model) {
67   - /**
68   - * @var Comment $model
69   - */
70   - $status = '';
71   - switch($model->status) {
72   - case Comment::STATUS_ACTIVE:
73   - $status = 'ะะบั‚ะธะฒะฝั‹ะน';
74   - break;
75   - case Comment::STATUS_HIDDEN:
76   - $status = 'ะะพะฒั‹ะน';
77   - break;
78   - case Comment::STATUS_DELETED:
79   - $status = 'ะฃะดะฐะปะตะฝะฝั‹ะน';
80   - break;
81   - default:
82   - $status = 'ะะตะธะทะฒะตัั‚ะฝะพ';
83   - };
84   - return $status;
85   - },
86   - ],
87   - 'date_add',
88   - [
89   - 'attribute' => 'model',
90   - 'value' => function($model) {
91   - /**
92   - * @var Comment $model
93   - */
94   - return $model->model . " (ID: " . $model->model_id . ")";
95   - },
96   - ],
97   - ],
98   - ]); ?>
99   -</div>
backend/views/comment/update.php deleted
1   -<?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\modules\comment\models\Comment */
7   -
8   -$this->title = 'ะ ะตะดะฐะบั‚ะธั€ะพะฒะฐั‚ัŒ ะบะพะผะผะตะฝั‚: ' . $model->comment_id;
9   -$this->params['breadcrumbs'][] = ['label' => 'ะšะพะผะผะตะฝั‚ะฐั€ะธะธ', 'url' => ['index']];
10   -$this->params['breadcrumbs'][] = ['label' => $model->comment_id, 'url' => ['view', 'id' => $model->comment_id]];
11   -$this->params['breadcrumbs'][] = 'ะ ะตะดะฐะบั‚ะธั€ะพะฒะฐั‚ัŒ';
12   -?>
13   -<div class="comment-update">
14   -
15   - <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <?= $this->render('_form', [
18   - 'model' => $model,
19   - ]) ?>
20   -
21   -</div>
backend/views/customer/_form.php
... ... @@ -7,7 +7,6 @@ use yii\widgets\ActiveForm;
7 7 /* @var $model common\models\Customer */
8 8 /* @var $form yii\widgets\ActiveForm */
9 9 ?>
10   -
11 10 <div class="customer-form">
12 11  
13 12 <?php $form = ActiveForm::begin(); ?>
... ... @@ -23,10 +22,8 @@ use yii\widgets\ActiveForm;
23 22 <?= $form->field($model, 'surname')->textInput(['maxlength' => true]) ?>
24 23  
25 24 <?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
26   -
27   - <?= $form->field($model, 'date_time')->textInput() ?>
28   -
29   - <?= $form->field($model, 'sex')->textInput(['maxlength' => true]) ?>
  25 +
  26 + <?= $form->field($model, 'gender')->textInput(['maxlength' => true]) ?>
30 27  
31 28 <?= $form->field($model, 'birth_day')->textInput() ?>
32 29  
... ...
backend/views/customer/_search.php
... ... @@ -25,22 +25,6 @@ use yii\widgets\ActiveForm;
25 25  
26 26 <?= $form->field($model, 'surname') ?>
27 27  
28   - <?php // echo $form->field($model, 'phone') ?>
29   -
30   - <?php // echo $form->field($model, 'date_time') ?>
31   -
32   - <?php // echo $form->field($model, 'sex') ?>
33   -
34   - <?php // echo $form->field($model, 'birth_day') ?>
35   -
36   - <?php // echo $form->field($model, 'birth_month') ?>
37   -
38   - <?php // echo $form->field($model, 'birth_year') ?>
39   -
40   - <?php // echo $form->field($model, 'body') ?>
41   -
42   - <?php // echo $form->field($model, 'group_id') ?>
43   -
44 28 <div class="form-group">
45 29 <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
46 30 <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
... ...
backend/views/customer/index.php
... ... @@ -26,17 +26,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
26 26  
27 27 'id',
28 28 'username',
29   - 'password',
30 29 'name',
31 30 'surname',
32   - // 'phone',
33   - // 'date_time',
34   - // 'sex',
35   - // 'birth_day',
36   - // 'birth_month',
37   - // 'birth_year',
38   - // 'body:ntext',
39   - // 'group_id',
  31 + 'phone',
40 32  
41 33 ['class' => 'yii\grid\ActionColumn'],
42 34 ],
... ...
backend/views/customer/view.php
... ... @@ -30,12 +30,10 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
30 30 'attributes' => [
31 31 'id',
32 32 'username',
33   - 'password',
34 33 'name',
35 34 'surname',
36 35 'phone',
37   - 'date_time',
38   - 'sex',
  36 + 'gender',
39 37 'birth_day',
40 38 'birth_month',
41 39 'birth_year',
... ...
backend/views/event/_form.php
... ... @@ -35,7 +35,7 @@ use mihaildev\elfinder\ElFinder;
35 35 <?= $form->field($model, 'end_at')
36 36 ->widget(DatePicker::className(), [
37 37 'pluginOptions' => [
38   - 'format' => 'dd-M-yyyy',
  38 + 'format' => 'dd-mm-yyyy',
39 39 'todayHighlight' => true
40 40 ]]) ?>
41 41  
... ...
backend/views/layouts/main-sidebar.php
... ... @@ -102,6 +102,12 @@ use yii\widgets\Menu;
102 102 'options' => ['class'=>\Yii::$app->user->can('event') ? '' :'hide'],
103 103 ],
104 104 [
  105 + 'label' => 'ะŸั€ะพะตะบั‚ั‹',
  106 + 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-pencil"></i> <span>{label}</span></a>',
  107 + 'url' => ['/project'],
  108 + 'options' => ['class'=>\Yii::$app->user->can('event') ? '' :'hide'],
  109 + ],
  110 + [
105 111 'label' => 'ะกั‚ะฐั‚ัŒะธ',
106 112 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-pencil"></i> <span>{label}</span></a>',
107 113 'url' => ['/articles/index'],
... ...
backend/views/orders/_form.php
... ... @@ -30,7 +30,9 @@ use kartik\date\DatePicker;
30 30 <?= $form->field($model, 'numbercard') ?>
31 31  
32 32 <?= $form->field($model, 'body')->textArea(['rows' => '3']) ?>
33   -<!-- --><?//= $form->field($model, 'delivery')->dropDownList(ArrayHelper::map(Delivery::find()->asArray()->all(), 'id', 'title')) ?>
  33 +
  34 + <?php /* $form->field($model, 'delivery')->dropDownList(ArrayHelper::map(Delivery::find()->asArray()->all(), 'id', 'title')) */ ?>
  35 +
34 36 <?= $form->field($model, 'declaration') ?>
35 37  
36 38 <?= $form->field($model, 'stock') ?>
... ...
backend/views/orders/show.php
... ... @@ -47,7 +47,7 @@ use kartik\date\DatePicker;
47 47 <?= $form->field($model, 'date_dedline')
48 48 ->widget(DatePicker::className(), [
49 49 'pluginOptions' => [
50   - 'format' => 'dd-M-yyyy',
  50 + 'format' => 'dd-mm-yyyy',
51 51 'todayHighlight' => true
52 52 ]]) ?>
53 53  
... ...
backend/views/page/_form.php
... ... @@ -37,6 +37,8 @@ use mihaildev\elfinder\ElFinder;
37 37 <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
38 38  
39 39 <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
  40 +
  41 + <?= $form->field($model, 'in_menu')->checkbox() ?>
40 42  
41 43 <div class="form-group">
42 44 <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
... ...
backend/views/blog/_form.php renamed to backend/views/project/_form.php
1   -<?php
2   -
3   -use common\widgets\FieldEditor;
4   -use yii\helpers\Html;
5   -use yii\widgets\ActiveForm;
6   -use common\modules\file\widgets\ImageUploader;
7   -use mihaildev\ckeditor\CKEditor;
8   -use mihaildev\elfinder\ElFinder;
9   -use common\components\Request;
10   -
11   -/* @var $this yii\web\View */
12   -/* @var $model common\models\Blog */
13   -/* @var $form yii\widgets\ActiveForm */
14   -?>
15   -
16   -<div class="blog-form">
17   -
18   - <?php $form = ActiveForm::begin([
19   - 'enableClientValidation' => false,
20   - 'options' => ['enctype' => 'multipart/form-data']
21   - ]); ?>
22   -
23   - <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
24   -
25   - <?= $form->field($model, 'link')->textInput(['maxlength' => true]) ?>
26   -
27   - <?= $form->field($model, 'description')->widget(CKEditor::className(),
28   - [
29   - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
30   - 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
31   - 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
32   - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
33   - ]
34   - )
35   - ]) ?>
36   -
37   - <?= $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
38   - 'language' => 'ru',
39   - 'options' => [
40   - 'accept' => 'image/*',
41   - 'multiple' => false,
42   - ],
43   - 'pluginOptions' => [
44   - 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
45   - 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
46   - 'overwriteInitial' => true,
47   - 'showRemove' => false,
48   - 'showUpload' => false,
49   - 'previewFileType' => 'image',
50   - ],
51   - ]); ?>
52   -
53   - <?= FieldEditor::widget([
54   - 'template' => 'education',
55   - 'item_id' => $model->blog_id,
56   - 'model' => 'common\models\Blog',
57   - 'language' => 'ru',
58   - ]); ?>
59   - <div class="form-group">
60   - <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
61   - </div>
62   -
63   - <?php ActiveForm::end(); ?>
64   -
65   -</div>
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +use mihaildev\ckeditor\CKEditor;
  6 +use mihaildev\elfinder\ElFinder;
  7 +use yii\jui\DatePicker;
  8 +/* @var $this yii\web\View */
  9 +/* @var $model common\models\Project */
  10 +/* @var $form yii\widgets\ActiveForm */
  11 +?>
  12 +
  13 +<div class="articles-form">
  14 +
  15 + <?php $form = ActiveForm::begin([
  16 + 'options' => ['enctype' => 'multipart/form-data']
  17 + ]); ?>
  18 +
  19 +
  20 + <?= $form->field($model, 'date_add')
  21 + ->widget(DatePicker::className(), [
  22 + 'dateFormat' => 'dd-MM-yyyy',
  23 + ]) ?>
  24 +
  25 + <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
  26 +
  27 + <?= $form->field($model, 'link')->textInput(['maxlength' => true]) ?>
  28 +
  29 + <?= $form->field($model, 'description')->widget(CKEditor::className(),
  30 + [
  31 + 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
  32 + 'preset' => 'full', //ั€ะฐะทั€ะฐะฑะพั‚ะฐะฝะฝั‹ ัั‚ะฐะฝะดะฐั€ั‚ะฝั‹ะต ะฝะฐัั‚ั€ะพะนะบะธ basic, standard, full ะดะฐะฝะฝัƒัŽ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ะฝะต ะพะฑัะทะฐั‚ะตะปัŒะฝะพ ะธัะฟะพะปัŒะทะพะฒะฐั‚ัŒ
  33 + 'inline' => false, //ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ false]),
  34 + 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
  35 + ]
  36 + )
  37 + ]) ?>
  38 +
  39 + <?= $form->field($model, 'imagesUpload[]')->widget(\kartik\file\FileInput::className(), [
  40 + 'language' => 'ru',
  41 + 'options' => [
  42 + 'accept' => 'image/*',
  43 + 'multiple' => true,
  44 + ],
  45 + 'pluginOptions' => [
  46 + 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
  47 + 'initialPreview' => !empty($model->imagesHTML) ? $model->imagesHTML : [],
  48 + 'initialPreviewConfig' => $model->imagesConfig,
  49 + 'overwriteInitial' => false,
  50 + 'showRemove' => false,
  51 + 'showUpload' => false,
  52 + 'uploadAsync' => !empty($model->project_id),
  53 + 'previewFileType' => 'image',
  54 + ],
  55 + ]); ?>
  56 +
  57 + <div class="form-group">
  58 + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  59 + </div>
  60 +
  61 + <?php ActiveForm::end(); ?>
  62 +
  63 +</div>
... ...
backend/views/blog/_search.php renamed to backend/views/project/_search.php
1   -<?php
2   -
3   -use yii\helpers\Html;
4   -use yii\widgets\ActiveForm;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\BlogSearch */
8   -/* @var $form yii\widgets\ActiveForm */
9   -?>
10   -
11   -<div class="blog-search">
12   -
13   - <?php $form = ActiveForm::begin([
14   - 'action' => ['index'],
15   - 'method' => 'get',
16   - ]); ?>
17   -
18   - <?= $form->field($model, 'blog_id') ?>
19   -
20   - <?= $form->field($model, 'user_id') ?>
21   -
22   - <?= $form->field($model, 'name') ?>
23   -
24   - <?= $form->field($model, 'link') ?>
25   -
26   - <?= $form->field($model, 'date_add') ?>
27   -
28   - <?php // echo $form->field($model, 'user_add_id') ?>
29   -
30   - <?php // echo $form->field($model, 'view_count') ?>
31   -
32   - <?php // echo $form->field($model, 'description') ?>
33   -
34   - <?php // echo $form->field($model, 'cover') ?>
35   -
36   - <div class="form-group">
37   - <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
38   - <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
39   - </div>
40   -
41   - <?php ActiveForm::end(); ?>
42   -
43   -</div>
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\ArticlesSearch */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="articles-search">
  12 +
  13 + <?php $form = ActiveForm::begin([
  14 + 'action' => ['index'],
  15 + 'method' => 'get',
  16 + ]); ?>
  17 +
  18 + <?= $form->field($model, 'id') ?>
  19 +
  20 + <?= $form->field($model, 'date') ?>
  21 +
  22 + <?= $form->field($model, 'title') ?>
  23 +
  24 + <?= $form->field($model, 'body') ?>
  25 +
  26 + <?= $form->field($model, 'image') ?>
  27 +
  28 + <?php // echo $form->field($model, 'translit') ?>
  29 +
  30 + <?php // echo $form->field($model, 'meta_title') ?>
  31 +
  32 + <?php // echo $form->field($model, 'meta_keywords') ?>
  33 +
  34 + <?php // echo $form->field($model, 'meta_description') ?>
  35 +
  36 + <?php // echo $form->field($model, 'seo_text') ?>
  37 +
  38 + <?php // echo $form->field($model, 'h1') ?>
  39 +
  40 + <div class="form-group">
  41 + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
  42 + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
  43 + </div>
  44 +
  45 + <?php ActiveForm::end(); ?>
  46 +
  47 +</div>
... ...
backend/views/blog/create.php renamed to backend/views/project/create.php
1   -<?php
2   -
3   -use yii\helpers\Html;
4   -
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $model common\models\Blog */
8   -
9   -$this->title = 'Create Blog';
10   -$this->params['breadcrumbs'][] = ['label' => 'Blogs', 'url' => ['index']];
11   -$this->params['breadcrumbs'][] = $this->title;
12   -?>
13   -<div class="blog-create">
14   -
15   - <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <?= $this->render('_form', [
18   - 'model' => $model,
19   - ]) ?>
20   -
21   -</div>
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\Articles */
  8 +
  9 +$this->title = 'Create Project';
  10 +$this->params['breadcrumbs'][] = ['label' => 'Projects', 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="articles-create">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <?= $this->render('_form', [
  18 + 'model' => $model,
  19 + ]) ?>
  20 +
  21 +</div>
... ...
common/modules/product/views/product-variant-type/index.php renamed to backend/views/project/index.php
... ... @@ -4,27 +4,27 @@ use yii\helpers\Html;
4 4 use yii\grid\GridView;
5 5  
6 6 /* @var $this yii\web\View */
7   -/* @var $searchModel common\modules\product\models\ProductVariantTypeSearch */
  7 +/* @var $searchModel common\models\ArticlesSearch */
8 8 /* @var $dataProvider yii\data\ActiveDataProvider */
9 9  
10   -$this->title = Yii::t('product', 'Product Variant Types');
  10 +$this->title = 'Project';
11 11 $this->params['breadcrumbs'][] = $this->title;
12 12 ?>
13   -<div class="product-variant-type-index">
  13 +<div class="articles-index" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
14 14  
15   - <h1><?= Html::encode($this->title) ?></h1>
16   - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  15 + <h1 itemprop="title"><?= Html::encode($this->title) ?></h1>
17 16  
18 17 <p>
19   - <?= Html::a(Yii::t('product', 'Create Product Variant Type'), ['create'], ['class' => 'btn btn-success']) ?>
  18 + <?= Html::a('Create Project', ['create'], ['class' => 'btn btn-success']) ?>
20 19 </p>
21 20 <?= GridView::widget([
22 21 'dataProvider' => $dataProvider,
23 22 'filterModel' => $searchModel,
24 23 'columns' => [
25 24 ['class' => 'yii\grid\SerialColumn'],
26   - 'name',
27   - 'name2',
  25 + 'project_id',
  26 + 'date_add:date',
  27 + 'title',
28 28  
29 29 ['class' => 'yii\grid\ActionColumn'],
30 30 ],
... ...
backend/views/blog/update.php renamed to backend/views/project/update.php
1   -<?php
2   -
3   -use yii\helpers\Html;
4   -
5   -/* @var $this yii\web\View */
6   -/* @var $model common\models\Blog */
7   -
8   -$this->title = 'Update Blog: ' . ' ' . $model->name;
9   -$this->params['breadcrumbs'][] = ['label' => 'Blogs', 'url' => ['index']];
10   -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->blog_id]];
11   -$this->params['breadcrumbs'][] = 'Update';
12   -?>
13   -<div class="blog-update">
14   -
15   - <h1><?= Html::encode($this->title) ?></h1>
16   -
17   - <?= $this->render('_form', [
18   - 'model' => $model,
19   - ]) ?>
20   -
21   -</div>
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $model common\models\Project */
  7 +
  8 +$this->title = 'Update Project: ' . $model->title;
  9 +$this->params['breadcrumbs'][] = ['label' => 'Project', 'url' => ['index']];
  10 +$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->project_id]];
  11 +$this->params['breadcrumbs'][] = 'Update';
  12 +?>
  13 +<div class="articles-update">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <?= $this->render('_form', [
  18 + 'model' => $model,
  19 + ]) ?>
  20 +
  21 +</div>
... ...
backend/views/comment/view.php renamed to backend/views/project/view.php
... ... @@ -4,19 +4,19 @@ use yii\helpers\Html;
4 4 use yii\widgets\DetailView;
5 5  
6 6 /* @var $this yii\web\View */
7   -/* @var $model common\modules\comment\models\Comment */
  7 +/* @var $model common\models\Project */
8 8  
9   -$this->title = $model->comment_id;
10   -$this->params['breadcrumbs'][] = ['label' => 'Comments', 'url' => ['index']];
  9 +$this->title = $model->title;
  10 +$this->params['breadcrumbs'][] = ['label' => 'Project', 'url' => ['index']];
11 11 $this->params['breadcrumbs'][] = $this->title;
12 12 ?>
13   -<div class="comment-view">
  13 +<div class="articles-view" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
14 14  
15   - <h1><?= Html::encode($this->title) ?></h1>
  15 + <h1 itemprop="title"><?= Html::encode($this->title) ?></h1>
16 16  
17 17 <p>
18   - <?= Html::a('Update', ['update', 'id' => $model->comment_id], ['class' => 'btn btn-primary']) ?>
19   - <?= Html::a('Delete', ['delete', 'id' => $model->comment_id], [
  18 + <?= Html::a('Update', ['update', 'id' => $model->project_id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a('Delete', ['delete', 'id' => $model->project_id], [
20 20 'class' => 'btn btn-danger',
21 21 'data' => [
22 22 'confirm' => 'Are you sure you want to delete this item?',
... ... @@ -28,18 +28,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
28 28 <?= DetailView::widget([
29 29 'model' => $model,
30 30 'attributes' => [
31   - 'comment_id',
32   - 'text:ntext',
33   - 'user_id',
34   - 'user_name',
35   - 'user_email:email',
36   - 'comment_pid',
37   - 'status',
38   - 'date_add',
39   - 'date_update',
40   - 'date_delete',
41   - 'model',
42   - 'model_id',
  31 + 'project_id',
  32 + 'date_add:date',
  33 + 'title',
43 34 ],
44 35 ]) ?>
45 36  
... ...
backend/web/js/fieldWidget.js deleted
1   -$(function(){
2   - $.each($('.delete-field-item'), function(index, value) {
3   - var container = $(value).parents('.field_list').first();
4   - var count = $(container).find('.form-group').length;
5   - if(count <= 1) {
6   - $(container).find('.delete-field-item').addClass('hidden');
7   - }
8   - });
9   - $(document).on('click', '.delete-field-item', function(){
10   - var container = $(this).parents('.field_list').first();
11   - $(this).parent('.form-group').remove();
12   - var count = $(container).find('.form-group').length;
13   - if(count <= 1) {
14   - $(container).find('.delete-field-item').addClass('hidden');
15   - }
16   - });
17   - $(document).on('click', '[class*=add_field_w]', function() {
18   - var container = $(this).siblings('.field_list').first();
19   - var count = $(container).find('.form-group').length;
20   - if(count > 1) {
21   - $(container).find('.delete-field-item').removeClass('hidden');
22   - }
23   - });
24   -});
25 0 \ No newline at end of file
common/behaviors/SaveImgBehavior.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 +namespace common\behaviors;
  4 +
  5 +use common\modules\comment\models\CommentModel;
  6 +use yii\base\Behavior;
  7 +use yii\db\ActiveRecord;
  8 +use yii\web\UploadedFile;
  9 +/**
  10 + * Class RatingBehavior
  11 + * @property CommentModel $owner
  12 + * @package common\behaviors
  13 + */
  14 +class SaveImgBehavior extends Behavior
  15 +{
  16 +
  17 +
  18 + public $directory;
  19 +
  20 + public function events()
  21 + {
  22 + return [
  23 + ActiveRecord::EVENT_BEFORE_UPDATE => 'beforeUpdate',
  24 + ActiveRecord::EVENT_BEFORE_INSERT => 'beforeInsert',
  25 + ];
  26 + }
  27 +
  28 + public function beforeUpdate($event)
  29 + {
  30 +
  31 +
  32 + if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) {
  33 + $this->owner->image = $image->name;
  34 + }
  35 +
  36 + if(!$this->owner->image){
  37 + $this->owner->image = $this->owner->getOldAttribute('image');
  38 + }
  39 +
  40 +
  41 + if ($image) {
  42 + $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/');
  43 +
  44 + if(!is_dir($imgDir)) {
  45 + mkdir($imgDir, 0755, true);
  46 + }
  47 +
  48 + $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name));
  49 + }
  50 + }
  51 +
  52 +
  53 + public function beforeInsert($event)
  54 + {
  55 +
  56 +
  57 + if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) {
  58 + $this->owner->image = $image->name;
  59 + }
  60 +
  61 +
  62 +
  63 + if ($image) {
  64 + $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/');
  65 +
  66 + if(!is_dir($imgDir)) {
  67 + mkdir($imgDir, 0755, true);
  68 + }
  69 +
  70 + $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name));
  71 + }
  72 + }
  73 +
  74 +
  75 +
  76 + public function getImageFile() {
  77 + return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image;
  78 + }
  79 +
  80 + public function getImageUrl() {
  81 + return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image;
  82 + }
  83 +}
0 84 \ No newline at end of file
... ...
common/components/artboximage/ArtboxImageHelper.php
... ... @@ -6,7 +6,6 @@ use Yii;
6 6 use yii\base\Object;
7 7 use yii\helpers\ArrayHelper;
8 8 use yii\helpers\Html;
9   -use yii\web\HttpException;
10 9  
11 10 class ArtboxImageHelper extends Object {
12 11 /** @var ArtboxImage $imageDriver */
... ...
common/components/artboxtree/ArtboxTreeBehavior.php
... ... @@ -2,8 +2,6 @@
2 2  
3 3 namespace common\components\artboxtree;
4 4  
5   -use common\modules\rubrication\models\TaxOption;
6   -use Yii;
7 5 use yii\base\Behavior;
8 6 use yii\base\Exception;
9 7 use yii\base\NotSupportedException;
... ...
common/components/artboxtree/ArtboxTreeQueryTrait.php
... ... @@ -2,8 +2,6 @@
2 2  
3 3 namespace common\components\artboxtree;
4 4  
5   -use common\components\artboxtree\ArtboxTreeHelper;
6   -
7 5 trait ArtboxTreeQueryTrait {
8 6  
9 7 static public $cache_tree = [];
... ...
common/config/main.php
... ... @@ -156,6 +156,18 @@
156 156 'height' => 110,
157 157 ],
158 158 ],
  159 + 'article_list' => [
  160 + 'resize' => [
  161 + 'width' => 555,
  162 + 'height' => 299,
  163 + ],
  164 + ],
  165 + 'project_list' => [
  166 + 'resize' => [
  167 + 'width' => 165,
  168 + 'height' => 100,
  169 + ],
  170 + ],
159 171 ]
160 172 ],
161 173 'basket' => [
... ...
common/models/Articles.php
... ... @@ -2,7 +2,7 @@
2 2  
3 3 namespace common\models;
4 4  
5   -use common\behaviors\RatingBehavior;
  5 +use common\behaviors\SaveImgBehavior;
6 6 use common\modules\comment\models\CommentModel;
7 7 use Yii;
8 8  
... ... @@ -10,7 +10,7 @@ use Yii;
10 10 * This is the model class for table "articles".
11 11 *
12 12 * @property integer $id
13   - * @property string $date
  13 + * @property integer $date
14 14 * @property string $title
15 15 * @property string $body
16 16 * @property string $image
... ... @@ -20,6 +20,7 @@ use Yii;
20 20 * @property string $meta_description
21 21 * @property string $seo_text
22 22 * @property string $h1
  23 + * @property string $body_preview
23 24 */
24 25 class Articles extends \yii\db\ActiveRecord
25 26 {
... ... @@ -45,6 +46,9 @@ class Articles extends \yii\db\ActiveRecord
45 46 'out_attribute' => 'translit',
46 47 'translit' => true
47 48 ],
  49 + [
  50 + 'class' => SaveImgBehavior::className(),
  51 + ],
48 52 ];
49 53 }
50 54  
... ... @@ -54,12 +58,18 @@ class Articles extends \yii\db\ActiveRecord
54 58 public function rules()
55 59 {
56 60 return [
  61 + [['date'], 'default', 'value' => function() {
  62 + return time();
  63 + }],
57 64 [['date'], 'safe'],
58 65 [['title', 'body'], 'required'],
59   - [['body', 'seo_text'], 'string'],
  66 + [['body', 'body_preview', 'seo_text'], 'string'],
60 67 [['title', 'image', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255],
61 68 [['imageUpload'], 'safe'],
62 69 [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
  70 + [['date'], 'filter', 'filter' => function($value) {
  71 + return strtotime($value)?:time();
  72 + }],
63 73 ];
64 74 }
65 75  
... ... @@ -73,6 +83,7 @@ class Articles extends \yii\db\ActiveRecord
73 83 'date' => 'Date',
74 84 'title' => 'Title',
75 85 'body' => 'Body',
  86 + 'body_preview' => 'Body preview',
76 87 'image' => 'Image',
77 88 'imageUrl' => Yii::t('app', 'Image'),
78 89 'translit' => 'Translit',
... ...
common/models/ArticlesSearch.php
... ... @@ -19,7 +19,7 @@ class ArticlesSearch extends Articles
19 19 {
20 20 return [
21 21 [['id'], 'integer'],
22   - [['date', 'title', 'body', 'image', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'seo_text', 'h1'], 'safe'],
  22 + [['title', 'body', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'seo_text', 'h1'], 'safe'],
23 23 ];
24 24 }
25 25  
... ... @@ -60,12 +60,10 @@ class ArticlesSearch extends Articles
60 60 // grid filtering conditions
61 61 $query->andFilterWhere([
62 62 'id' => $this->id,
63   - 'date' => $this->date,
64 63 ]);
65 64  
66 65 $query->andFilterWhere(['like', 'title', $this->title])
67 66 ->andFilterWhere(['like', 'body', $this->body])
68   - ->andFilterWhere(['like', 'image', $this->image])
69 67 ->andFilterWhere(['like', 'translit', $this->translit])
70 68 ->andFilterWhere(['like', 'meta_title', $this->meta_title])
71 69 ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])
... ...
common/models/Blog.php deleted
1   -<?php
2   -
3   - namespace common\models;
4   -
5   - use Yii;
6   - use yii\behaviors\BlameableBehavior;
7   - use yii\behaviors\TimestampBehavior;
8   - use yii\db\Expression;
9   -
10   - /**
11   - * This is the model class for table "blog".
12   - * @property integer $blog_id
13   - * @property integer $user_id
14   - * @property string $name
15   - * @property string $link
16   - * @property string $date_add
17   - * @property integer $user_add_id
18   - * @property integer $view_count
19   - * @property string $description
20   - * @property string $cover
21   - */
22   - class Blog extends \yii\db\ActiveRecord
23   - {
24   - public $imageUpload;
25   -
26   - /**
27   - * @inheritdoc
28   - */
29   - public static function tableName()
30   - {
31   - return 'blog';
32   - }
33   -
34   -
35   - /**
36   - * @inheritdoc
37   - */
38   - public function behaviors()
39   - {
40   - return [
41   - [
42   - 'class' => BlameableBehavior::className(),
43   - 'createdByAttribute' => 'user_id',
44   - 'updatedByAttribute' => false,
45   - ],
46   - [
47   - 'class' => TimestampBehavior::className(),
48   - 'createdAtAttribute' => 'date_add',
49   - 'updatedAtAttribute' => false,
50   - 'value' => new Expression('NOW()'),
51   - ],
52   - 'slug' => [
53   - 'class' => 'common\behaviors\Slug',
54   - 'in_attribute' => 'name',
55   - 'out_attribute' => 'link',
56   - 'translit' => true
57   - ]
58   - ];
59   - }
60   -
61   - /**
62   - * @inheritdoc
63   - */
64   - public function rules()
65   - {
66   - return [
67   - [
68   - [ 'name', 'description' ],
69   - 'required',
70   - ],
71   - [
72   - [ 'description' ],
73   - 'string',
74   - ],
75   - [
76   - [
77   - 'name',
78   - 'link',
79   - 'cover',
80   - ],
81   - 'string',
82   - 'max' => 255,
83   - ],
84   - [['imageUpload'], 'safe'],
85   - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
86   - ];
87   - }
88   -
89   - public function getDateCreate(){
90   - return date('Y-m-d',strtotime($this->date_add));
91   - }
92   -
93   - /**
94   - * @inheritdoc
95   - */
96   - public function attributeLabels()
97   - {
98   - return [
99   - 'blog_id' => Yii::t('app', 'blog_id'),
100   - 'user_id' => Yii::t('app', 'user_id'),
101   - 'name' => Yii::t('app', 'name'),
102   - 'link' => Yii::t('app', 'link'),
103   - 'date_add' => Yii::t('app', 'date_add'),
104   - 'user_add_id' => Yii::t('app', 'user_add_id'),
105   - 'view_count' => Yii::t('app', 'view_count'),
106   - 'description' => Yii::t('app', 'description'),
107   - 'cover' => Yii::t('app', 'cover'),
108   - 'image' => Yii::t('app', 'cover'),
109   - 'imageUrl' => Yii::t('app', 'cover'),
110   - ];
111   - }
112   -
113   - public function getImageFile() {
114   - return empty($this->image) ? null : Yii::getAlias('@imagesDir/brands/'. $this->image);
115   - }
116   -
117   - public function getImageUrl()
118   - {
119   - return empty($this->image) ? null : Yii::getAlias('@imagesUrl/brands/' . $this->image);
120   - }
121   - }
common/models/BlogSearch.php deleted
1   -<?php
2   -
3   - namespace common\models;
4   -
5   - use Yii;
6   - use yii\base\Model;
7   - use yii\bootstrap\ActiveForm;
8   - use yii\data\ActiveDataProvider;
9   - use common\models\Blog;
10   - use yii\db\ActiveQuery;
11   - use yii\db\ActiveRecord;
12   -
13   - /**
14   - * BlogSearch represents the model behind the search form about `common\models\Blog`.
15   - */
16   - class BlogSearch extends Blog
17   - {
18   -
19   - public $date_add_from;
20   - public $date_add_to;
21   - /**
22   - * @inheritdoc
23   - */
24   - public function rules()
25   - {
26   - return [
27   - [
28   - [
29   - 'blog_id',
30   - 'user_id',
31   - 'user_add_id',
32   - 'view_count',
33   - ],
34   - 'integer',
35   - ],
36   - [
37   - [
38   - 'name',
39   - 'link',
40   - 'date_add',
41   - 'description',
42   - 'cover',
43   - 'date_add_from',
44   - 'date_add_to',
45   - ],
46   - 'safe',
47   - ],
48   - [
49   - [
50   - 'date_add_from',
51   - ],
52   - 'default',
53   - 'value' => date('Y-m-d', 0),
54   - ],
55   - [
56   - [
57   - 'date_add_to',
58   - ],
59   - 'default',
60   - 'value' => date('Y-m-d'),
61   - ],
62   - ];
63   - }
64   -
65   - /**
66   - * @inheritdoc
67   - */
68   - public function scenarios()
69   - {
70   - // bypass scenarios() implementation in the parent class
71   - return Model::scenarios();
72   - }
73   -
74   - /**
75   - * Creates data provider instance with search query applied
76   - *
77   - * @param array $params
78   - *
79   - * @return ActiveDataProvider
80   - */
81   - public function search($params)
82   - {
83   - $query = Blog::find();
84   -
85   - // add conditions that should always apply here
86   -
87   - $dataProvider = new ActiveDataProvider([
88   - 'query' => $query,
89   - ]);
90   -
91   - $this->load($params);
92   -
93   - if(!$this->validate()) {
94   - // uncomment the following line if you do not want to return any records when validation fails
95   - // $query->where('0=1');
96   - return $dataProvider;
97   - }
98   -
99   - $query->andWhere([ 'user_id' => \Yii::$app->user->getId() ]);
100   -
101   - // grid filtering conditions
102   - $query->andFilterWhere([
103   - 'blog_id' => $this->blog_id,
104   - 'date_add' => $this->date_add,
105   - 'user_add_id' => $this->user_add_id,
106   - 'view_count' => $this->view_count,
107   - ]);
108   -
109   - $query->andFilterWhere([
110   - 'between',
111   - 'date_add',
112   - $this->date_add_from,
113   - (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d')
114   - ]);
115   -
116   - $query->andFilterWhere([
117   - 'like',
118   - 'name',
119   - $this->name,
120   - ])
121   - ->andFilterWhere([
122   - 'like',
123   - 'description',
124   - $this->description,
125   - ])
126   - ->andFilterWhere([
127   - 'like',
128   - 'cover',
129   - $this->cover,
130   - ]);
131   -
132   - return $dataProvider;
133   - }
134   -
135   - }
common/models/Customer.php
... ... @@ -13,7 +13,6 @@ use Yii;
13 13 * @property string $name
14 14 * @property string $surname
15 15 * @property string $phone
16   - * @property string $date_time
17 16 * @property string $gender
18 17 * @property integer $birth_day
19 18 * @property integer $birth_month
... ... @@ -27,9 +26,6 @@ use Yii;
27 26 * @property integer $created_at
28 27 * @property integer $updated_at
29 28 *
30   - * @property ArtboxComment[] $artboxComments
31   - * @property ArtboxCommentRating[] $artboxCommentRatings
32   - * @property ArtboxLike[] $artboxLikes
33 29 * @property Share[] $shares
34 30 */
35 31 class Customer extends User implements \yii\web\IdentityInterface
... ... @@ -49,7 +45,7 @@ class Customer extends User implements \yii\web\IdentityInterface
49 45 {
50 46 return [
51 47 [['username', 'password_hash'], 'required'],
52   - [['date_time'], 'safe'],
  48 + [['password'], 'safe'],
53 49 [['birth_day', 'birth_month', 'birth_year', 'group_id', 'status', 'created_at', 'updated_at'], 'integer'],
54 50 [['body'], 'string'],
55 51 [['status'],'default', 'value' => '10'],
... ... @@ -69,7 +65,6 @@ class Customer extends User implements \yii\web\IdentityInterface
69 65 'name' => 'Name',
70 66 'surname' => 'Surname',
71 67 'phone' => 'Phone',
72   - 'date_time' => 'Date Time',
73 68 'gender' => 'Gender',
74 69 'birth_day' => 'Birth Day',
75 70 'birth_month' => 'Birth Month',
... ... @@ -88,30 +83,6 @@ class Customer extends User implements \yii\web\IdentityInterface
88 83 /**
89 84 * @return \yii\db\ActiveQuery
90 85 */
91   - public function getArtboxComments()
92   - {
93   - return $this->hasMany(ArtboxComment::className(), ['user_id' => 'id']);
94   - }
95   -
96   - /**
97   - * @return \yii\db\ActiveQuery
98   - */
99   - public function getArtboxCommentRatings()
100   - {
101   - return $this->hasMany(ArtboxCommentRating::className(), ['user_id' => 'id']);
102   - }
103   -
104   - /**
105   - * @return \yii\db\ActiveQuery
106   - */
107   - public function getArtboxLikes()
108   - {
109   - return $this->hasMany(ArtboxLike::className(), ['user_id' => 'id']);
110   - }
111   -
112   - /**
113   - * @return \yii\db\ActiveQuery
114   - */
115 86 public function getShares()
116 87 {
117 88 return $this->hasMany(Share::className(), ['user_id' => 'id']);
... ... @@ -132,5 +103,8 @@ class Customer extends User implements \yii\web\IdentityInterface
132 103 return $this->username. ' '.$this->surname;
133 104 }
134 105  
  106 + public function getPassword() {
  107 + return false;
  108 + }
135 109  
136 110 }
... ...
common/models/CustomerSearch.php
... ... @@ -19,7 +19,7 @@ class CustomerSearch extends Customer
19 19 {
20 20 return [
21 21 [['id', 'birth_day', 'birth_month', 'birth_year', 'group_id'], 'integer'],
22   - [['username', 'name', 'surname', 'phone', 'date_time', 'body'], 'safe'],
  22 + [['username', 'name', 'surname', 'phone', 'body'], 'safe'],
23 23 ];
24 24 }
25 25  
... ... @@ -60,7 +60,6 @@ class CustomerSearch extends Customer
60 60 // grid filtering conditions
61 61 $query->andFilterWhere([
62 62 'id' => $this->id,
63   - 'date_time' => $this->date_time,
64 63 'birth_day' => $this->birth_day,
65 64 'birth_month' => $this->birth_month,
66 65 'birth_year' => $this->birth_year,
... ...
common/models/Event.php
... ... @@ -46,7 +46,7 @@ class Event extends \yii\db\ActiveRecord
46 46 'translit' => true
47 47 ],
48 48 [
49   - 'class' => 'common\behaviors\ShowImage',
  49 + 'class' => 'common\behaviors\ShowImage',
50 50 ],
51 51 ];
52 52 }
... ...
common/models/Fields.php deleted
1   -<?php
2   -
3   -namespace common\models;
4   -
5   -use Yii;
6   -use yii\helpers\ArrayHelper;
7   -
8   -/**
9   - * This is the model class for table "{{%fields}}".
10   - *
11   - * @property integer $id
12   - * @property string $table_name
13   - * @property integer $table_id
14   - * @property string $value
15   - * @property string $field_name
16   - * @property string $field_type
17   - * @property string $language
18   - * @property string $parent_key
19   - * @property string $key
20   - */
21   -class Fields extends \yii\db\ActiveRecord
22   -{
23   - /**
24   - * @inheritdoc
25   - */
26   - public static function tableName()
27   - {
28   - return '{{%fields}}';
29   - }
30   -
31   - /**
32   - * @inheritdoc
33   - */
34   - public function rules()
35   - {
36   - return [
37   - [['table_name', 'table_id',], 'required'],
38   - [['table_id','parent_key','key'], 'integer'],
39   - [['table_name', 'value', 'field_name','field_type','language'], 'string', 'max' => 255]
40   - ];
41   - }
42   -
43   - /**
44   - * @inheritdoc
45   - */
46   - public function attributeLabels()
47   - {
48   - return [
49   - 'id' => 'ID',
50   - 'table_name' => 'Model Name',
51   - 'table_id' => 'Model ID',
52   - 'value' => 'Value',
53   - 'field_name' => 'Field Name',
54   - 'language' => 'Language',
55   - ];
56   - }
57   -
58   - public static function getData($id, $model, $type){
59   - $data = ArrayHelper::toArray(self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->all());
60   - $result = [];
61   - for($i=0; $i < count($data); $i ++){
62   - $result[$data[$i]['parent_key']][$data[$i]['field_name']] = $data[$i]['value'];
63   - }
64   -
65   - return $result;
66   - }
67   -
68   -
69   - /**
70   - * @param $post - array with field data
71   - * @param $table_id - row id in model table
72   - * @param $table_name - madel table name
73   - * @param $language - language id
74   - */
75   -
76   - public static function saveFieldData($post,$table_id,$table_name, $language){
77   -
78   - self::deleteAll(['table_id'=>$table_id, 'table_name'=>$table_name, 'language' => $language, 'field_type' => array_keys($post)]);
79   -
80   - if($post){
81   -
82   -
83   - foreach($post as $k => $field){
84   -
85   -
86   -
87   - foreach($field as $parent_key => $row){
88   -
89   - foreach($row as $key => $value){
90   -
91   - $field_model = new Fields();
92   - $field_model->field_name = array_keys($value)[0];
93   - $field_model->value = $value[array_keys($value)[0]];
94   - $field_model->table_name = $table_name;
95   - $field_model->table_id = $table_id;
96   - $field_model->field_type = $k;
97   - $field_model->language = 'ru';
98   - $field_model->parent_key = $parent_key;
99   - $field_model->key = $key;
100   - $field_model->save();
101   - }
102   -
103   - }
104   - }
105   - }
106   - }
107   -
108   -
109   - /**
110   - * @param $post - array with field data
111   - * @param $table_id - row id in model table
112   - * @param $table_name - madel table name
113   - * @param $language - language id
114   - */
115   -
116   - public static function saveFieldVideoData($post,$table_id,$table_name, $language){
117   -
118   - self::deleteAll(['table_id'=>$table_id, 'table_name'=>$table_name, 'language' => $language, 'field_type' => array_keys($post)]);
119   -
120   - if($post){
121   -
122   -
123   - foreach($post as $k => $field){
124   -
125   -
126   -
127   - foreach($field as $parent_key => $row){
128   -
129   - foreach($row as $key => $value){
130   -
131   - preg_match('/src=\"(.[^"]*)\"/', $value[array_keys($value)[0]], $video_url);
132   -
133   - if(isset($video_url[1]) && !empty($video_url[1])){
134   -
135   - $field_model = new Fields();
136   - $field_model->field_name = array_keys($value)[0];
137   - $field_model->value = $video_url[1].'?showinfo=0&autoplay=0';
138   - $field_model->table_name = $table_name;
139   - $field_model->table_id = $table_id;
140   - $field_model->field_type = $k;
141   - $field_model->language = 'ru';
142   - $field_model->parent_key = $parent_key;
143   - $field_model->key = $key;
144   - $field_model->save();
145   -
146   - }
147   -
148   -
149   - }
150   -
151   - }
152   - }
153   - }
154   - }
155   -}
common/models/Orders.php
... ... @@ -49,6 +49,26 @@
49 49 'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/',
50 50 'on' => self::SCENARIO_QUICK,
51 51 ],
  52 + [
  53 + [
  54 + 'phone2',
  55 + 'numbercard',
  56 + 'body',
  57 + 'declaration',
  58 + 'stock',
  59 + 'consignment',
  60 + 'payment',
  61 + 'insurance',
  62 + 'amount_imposed',
  63 + 'shipping_by',
  64 + 'city',
  65 + 'adress',
  66 + 'total',
  67 + 'status',
  68 + ],
  69 + 'string',
  70 + 'max' => 255,
  71 + ],
52 72 ];
53 73 }
54 74  
... ...
common/models/Page.php
1 1 <?php
2   -
3   -namespace common\models;
4   -
5   -use Yii;
6   -
7   -/**
8   - * This is the model class for table "page".
9   - *
10   - * @property integer $id
11   - * @property string $translit
12   - * @property string $title
13   - * @property string $body
14   - * @property string $meta_title
15   - * @property string $meta_keywords
16   - * @property string $meta_description
17   - * @property string $seo_text
18   - * @property string $h1
19   - */
20   -class Page extends \yii\db\ActiveRecord
21   -{
  2 +
  3 + namespace common\models;
  4 +
22 5 /**
23   - * @inheritdoc
  6 + * This is the model class for table "page".
  7 + * @property integer $id
  8 + * @property string $translit
  9 + * @property string $title
  10 + * @property string $body
  11 + * @property string $meta_title
  12 + * @property string $meta_keywords
  13 + * @property string $meta_description
  14 + * @property string $seo_text
  15 + * @property string $h1
  16 + * @property bool $in_menu
24 17 */
25   - public static function tableName()
  18 + class Page extends \yii\db\ActiveRecord
26 19 {
27   - return 'page';
  20 +
  21 + /**
  22 + * @inheritdoc
  23 + */
  24 + public static function tableName()
  25 + {
  26 + return 'page';
  27 + }
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
  32 + public function behaviors()
  33 + {
  34 + return [
  35 + 'slug' => [
  36 + 'class' => 'common\behaviors\Slug',
  37 + 'in_attribute' => 'title',
  38 + 'out_attribute' => 'translit',
  39 + 'translit' => true,
  40 + ],
  41 + ];
  42 + }
  43 +
  44 + /**
  45 + * @inheritdoc
  46 + */
  47 + public function rules()
  48 + {
  49 + return [
  50 + [
  51 + [
  52 + 'body',
  53 + 'seo_text',
  54 + ],
  55 + 'string',
  56 + ],
  57 + [
  58 + [
  59 + 'translit',
  60 + 'title',
  61 + 'meta_title',
  62 + 'meta_keywords',
  63 + 'meta_description',
  64 + 'h1',
  65 + ],
  66 + 'string',
  67 + 'max' => 255,
  68 + ],
  69 + [
  70 + [
  71 + 'in_menu',
  72 + ],
  73 + 'boolean',
  74 + ],
  75 + ];
  76 + }
  77 +
  78 + public function getPageTranslit($page)
  79 + {
  80 + return self::find()
  81 + ->where([ 'translit' => $page ])
  82 + ->one();
  83 +
  84 + }
  85 +
  86 + /**
  87 + * @inheritdoc
  88 + */
  89 + public function attributeLabels()
  90 + {
  91 + return [
  92 + 'id' => 'ID',
  93 + 'translit' => 'Translit',
  94 + 'title' => 'Title',
  95 + 'body' => 'Body',
  96 + 'meta_title' => 'Meta Title',
  97 + 'meta_keywords' => 'Meta Keywords',
  98 + 'meta_description' => 'Meta Description',
  99 + 'seo_text' => 'Seo Text',
  100 + 'h1' => 'H1',
  101 + 'in_menu' => 'Show in menu',
  102 + ];
  103 + }
28 104 }
29   - /**
30   - * @inheritdoc
31   - */
32   - public function behaviors()
33   - {
34   - return [
35   - 'slug' => [
36   - 'class' => 'common\behaviors\Slug',
37   - 'in_attribute' => 'title',
38   - 'out_attribute' => 'translit',
39   - 'translit' => true
40   - ]
41   - ];
42   - }
43   - /**
44   - * @inheritdoc
45   - */
46   - public function rules()
47   - {
48   - return [
49   - [['body', 'seo_text'], 'string'],
50   - [['translit', 'title', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255],
51   - ];
52   - }
53   - public function getPageTranslit($page){
54   - return self::find()
55   - ->where(['translit' => $page])
56   - ->one();
57   -
58   - }
59   - /**
60   - * @inheritdoc
61   - */
62   - public function attributeLabels()
63   - {
64   - return [
65   - 'id' => 'ID',
66   - 'translit' => 'Translit',
67   - 'title' => 'Title',
68   - 'body' => 'Body',
69   - 'meta_title' => 'Meta Title',
70   - 'meta_keywords' => 'Meta Keywords',
71   - 'meta_description' => 'Meta Description',
72   - 'seo_text' => 'Seo Text',
73   - 'h1' => 'H1',
74   - ];
75   - }
76   -}
... ...
common/models/PageSearch.php
... ... @@ -2,10 +2,8 @@
2 2  
3 3 namespace common\models;
4 4  
5   -use Yii;
6 5 use yii\base\Model;
7 6 use yii\data\ActiveDataProvider;
8   -use common\models\Page;
9 7  
10 8 /**
11 9 * PageSearch represents the model behind the search form about `common\models\Page`.
... ...
common/models/Project.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +/**
  6 + * This is the model class for table "project".
  7 + *
  8 + * @property integer $project_id
  9 + * @property string $title
  10 + * @property string $link
  11 + * @property string $description
  12 + * @property integer $date_add
  13 + * @property ProjectImage[] $images
  14 + * @property array $imagesConfig
  15 + */
  16 +class Project extends \yii\db\ActiveRecord
  17 +{
  18 +
  19 + public $imagesUpload = [];
  20 +
  21 + /**
  22 + * @inheritdoc
  23 + */
  24 + public static function tableName()
  25 + {
  26 + return 'project';
  27 + }
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
  32 + public function behaviors()
  33 + {
  34 + return [
  35 + 'slug' => [
  36 + 'class' => 'common\behaviors\Slug',
  37 + 'in_attribute' => 'title',
  38 + 'out_attribute' => 'link',
  39 + 'translit' => true
  40 + ],
  41 + ];
  42 + }
  43 +
  44 + /**
  45 + * @inheritdoc
  46 + */
  47 + public function rules()
  48 + {
  49 + return [
  50 + [['date_add'], 'default', 'value' => function() {
  51 + return time();
  52 + }],
  53 + [['title'], 'required'],
  54 + [['description'], 'string'],
  55 + [['date_add', 'imagesUpload'], 'safe'],
  56 + [['title', 'link'], 'string', 'max' => 255],
  57 + [['date_add'], 'filter', 'filter' => function($value) {
  58 + return strtotime($value)?:time();
  59 + }],
  60 + ];
  61 + }
  62 +
  63 + /**
  64 + * @inheritdoc
  65 + */
  66 + public function attributeLabels()
  67 + {
  68 + return [
  69 + 'project_id' => 'Project ID',
  70 + 'title' => 'Title',
  71 + 'link' => 'Link',
  72 + 'description' => 'Description',
  73 + 'date_add' => 'Date Add',
  74 + 'images' => 'Images',
  75 + ];
  76 + }
  77 +
  78 + public function getImages()
  79 + {
  80 + return $this->hasMany(ProjectImage::className(), [ 'project_id' => 'project_id' ]);
  81 + }
  82 +
  83 + public function getImagesHTML()
  84 + {
  85 + $op = [];
  86 + if($this->images) {
  87 + foreach($this->images as $image) {
  88 + $op[] = \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'admin_thumb');
  89 + }
  90 + }
  91 + return $op;
  92 + }
  93 +
  94 + public function getImagesConfig()
  95 + {
  96 + $op = [];
  97 + if($this->images) {
  98 + foreach($this->images as $image) {
  99 + $op[] = [
  100 + 'caption' => $image->image,
  101 + 'width' => '120px',
  102 + 'url' => \yii\helpers\Url::to([
  103 + '/project/delimg',
  104 + 'id' => $image->project_image_id,
  105 + ]),
  106 + 'key' => $image->project_image_id,
  107 + 'extra' => [
  108 + 'id' => $image->project_image_id,
  109 + ],
  110 + ];
  111 + }
  112 + }
  113 + return $op;
  114 + }
  115 +
  116 + public function imagesUpload()
  117 + {
  118 + if($this->validate()) {
  119 + $images = [];
  120 + foreach($this->imagesUpload as $image) {
  121 + $imageName = $image->baseName . '.' . $image->extension;
  122 + $i = 0;
  123 + while(file_exists(\Yii::getAlias('@storage/projects/' . $imageName))) {
  124 + $i++;
  125 + $imageName = $image->baseName . '_' . $i . '.' . $image->extension;
  126 + }
  127 + $imgDir = \Yii::getAlias('@storage/projects/');
  128 + if(!is_dir($imgDir)) {
  129 + mkdir($imgDir, 0755, true);
  130 + }
  131 +
  132 + $image->saveAs($imgDir . $imageName);
  133 + $images[] = $imageName;
  134 + }
  135 + return $images;
  136 + } else {
  137 + return false;
  138 + }
  139 + }
  140 +}
... ...
common/models/ProjectImage.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +/**
  6 + * This is the model class for table "project_image".
  7 + *
  8 + * @property integer $project_image_id
  9 + * @property integer $project_id
  10 + * @property string $image
  11 + * @property string $alt
  12 + * @property string $title
  13 + *
  14 + * @property Project $project
  15 + */
  16 +class ProjectImage extends \yii\db\ActiveRecord
  17 +{
  18 + /**
  19 + * @inheritdoc
  20 + */
  21 + public static function tableName()
  22 + {
  23 + return 'project_image';
  24 + }
  25 +
  26 + /**
  27 + * @inheritdoc
  28 + */
  29 + public function rules()
  30 + {
  31 + return [
  32 + [['project_id'], 'required'],
  33 + [['project_id'], 'integer'],
  34 + [['image', 'alt', 'title'], 'string', 'max' => 255],
  35 + [['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'project_id']],
  36 + ];
  37 + }
  38 +
  39 + /**
  40 + * @inheritdoc
  41 + */
  42 + public function attributeLabels()
  43 + {
  44 + return [
  45 + 'project_image_id' => 'Project Image ID',
  46 + 'project_id' => 'Project ID',
  47 + 'image' => 'Image',
  48 + 'alt' => 'Alt',
  49 + 'title' => 'Title',
  50 + ];
  51 + }
  52 +
  53 + /**
  54 + * @return \yii\db\ActiveQuery
  55 + */
  56 + public function getProject()
  57 + {
  58 + return $this->hasOne(Project::className(), ['project_id' => 'project_id']);
  59 + }
  60 +
  61 + /**
  62 + * fetch stored image file name with complete path
  63 + * @return string
  64 + */
  65 + public function getImageFile()
  66 + {
  67 + return isset($this->image) ? '/storage/projects/' . $this->image : null;
  68 + }
  69 +
  70 + /**
  71 + * fetch stored image url
  72 + * @return string
  73 + */
  74 + public function getImageUrl()
  75 + {
  76 + // return a default image placeholder if your source image is not found
  77 + return isset($this->image) ? '/storage/projects/'. $this->image : '/storage/no-photo.png';
  78 + }
  79 +
  80 + public function deleteImage() {
  81 + $file = $this->getImageFile();
  82 +
  83 + // check if file exists on server
  84 + if (empty($file) || !file_exists($file)) {
  85 + return false;
  86 + }
  87 +
  88 + // check if uploaded file can be deleted on server
  89 + if (!unlink($file)) {
  90 + return false;
  91 + }
  92 +
  93 + // if deletion successful, reset your file attributes
  94 + $this->image = null;
  95 + $this->filename = null;
  96 +
  97 + return true;
  98 + }
  99 +
  100 + public function beforeDelete()
  101 + {
  102 + if (parent::beforeDelete()) {
  103 + $this->deleteImage();
  104 + return true;
  105 + } else {
  106 + return false;
  107 + }
  108 + }
  109 +}
... ...
common/modules/product/models/ProductVariantTypeSearch.php renamed to common/models/ProjectSearch.php
1 1 <?php
2 2  
3   -namespace common\modules\product\models;
  3 +namespace common\models;
4 4  
5 5 use Yii;
6 6 use yii\base\Model;
7 7 use yii\data\ActiveDataProvider;
8   -use common\modules\product\models\ProductVariantType;
  8 +use common\models\Project;
9 9  
10 10 /**
11   - * ProductVariantTypeSearch represents the model behind the search form about `common\modules\product\models\ProductVariantType`.
  11 + * ProjectSearch represents the model behind the search form about `common\models\Project`.
12 12 */
13   -class ProductVariantTypeSearch extends ProductVariantType
  13 +class ProjectSearch extends Project
14 14 {
15 15 /**
16 16 * @inheritdoc
... ... @@ -18,8 +18,8 @@ class ProductVariantTypeSearch extends ProductVariantType
18 18 public function rules()
19 19 {
20 20 return [
21   - [['product_variant_type_id'], 'integer'],
22   - [['name', 'name2'], 'safe'],
  21 + [['project_id', 'date_add'], 'integer'],
  22 + [['title', 'link', 'description'], 'safe'],
23 23 ];
24 24 }
25 25  
... ... @@ -41,7 +41,7 @@ class ProductVariantTypeSearch extends ProductVariantType
41 41 */
42 42 public function search($params)
43 43 {
44   - $query = ProductVariantType::find();
  44 + $query = Project::find();
45 45  
46 46 // add conditions that should always apply here
47 47  
... ... @@ -59,11 +59,13 @@ class ProductVariantTypeSearch extends ProductVariantType
59 59  
60 60 // grid filtering conditions
61 61 $query->andFilterWhere([
62   - 'product_variant_type_id' => $this->product_variant_type_id,
  62 + 'project_id' => $this->project_id,
  63 + 'date_add' => $this->date_add,
63 64 ]);
64 65  
65   - $query->andFilterWhere(['like', 'name', $this->name])
66   - ->andFilterWhere(['like', 'name2', $this->name2]);
  66 + $query->andFilterWhere(['like', 'title', $this->title])
  67 + ->andFilterWhere(['like', 'link', $this->link])
  68 + ->andFilterWhere(['like', 'description', $this->description]);
67 69  
68 70 return $dataProvider;
69 71 }
... ...
common/modules/blog/Module.php deleted
1   -<?php
2   -namespace common\modules\blog;
3   -
4   -use yii\base\BootstrapInterface;
5   -
6   -class Module extends \yii\base\Module
7   -{
8   - public function init()
9   - {
10   - parent::init();
11   -
12   - \Yii::configure($this, require(__DIR__.'/config.php'));
13   - }
14   -
15   -}
common/modules/blog/behaviors/Autocomplete.php deleted
1   -<?php
2   -namespace common\modules\blog\behaviors;
3   -
4   -use common\models\Tools;
5   -use yii\db\ActiveRecord;
6   -use yii\base\Behavior;
7   -use yii\helpers\StringHelper;
8   -
9   -/**
10   - * ะšะปะฐัั ะดะปั ะฐะฒั‚ะพะทะฐะฟะพะปะฝะตะฝะธั ะฟะพะปะตะน ะฝะตะบะธะผะธ ะดะฐะฝะฝั‹ะผะธ ะธะปะธ ะธั… ั„ะพั€ะผะฐั‚ะธั€ะพะฒะฐะฝะธั
11   - *
12   - * ะšะปะฐั ะฟั€ะตะดะฝะฐะทะฝะฐั‡ะตะฝ ะดะปั ะทะฐะฟะพะปะฝะตะฝะธั ะฟะพะปะตะน ะดะฐะฝะฝั‹ะผะธ ะธะปะธ ั„ะพั€ะผะฐั‚ะธั€ะพะฒะฐะฝะธั ะดะฐะฝะฝั‹ั…
13   - *
14   - */
15   -
16   -class Autocomplete extends Behavior
17   -{
18   - /**
19   - * ะั‚ั€ะธะฑัƒั‚ั‹ ะดะปั ะพะฑั€ะฐะฑะพั‚ะบะธ
20   - *
21   - * ะั‚ั€ะธะฑัƒั‚ั‹ ัั‡ะธั‚ั‹ะฒะฐัŽั‚ัั ะฐะฒั‚ะพะผะฐั‚ะธั‡ะตัะบะธ ั ะฝะฐัั‚ั€ะพะตะบ ะฟะพะฒะตะดะตะฝะธั ะฒ ะบะพะฝะบั€ะตั‚ะฝะพะผ ะพะฑัŒะตะบั‚ะต.
22   - * ะ˜ะผะตะตั‚ ะฒะธะด ะฐััะพั†ะธะฐั‚ะธะฒะฝะพะณะพ ะผะฐััะธะฒะฐ, ะณะดะต ะบะปัŽั‡ - ะผะตั‚ะพะด ะฐะฒั‚ะพะทะฐะฟะพะปะฝะตะฝะธั, ะฐ ะทะฝะฐั‡ะตะฝะธะต - ะผะฐััะธะฒ, ะบะฐะถะดั–ะน ั”ะปะตะผะตะฝั‚
23   - * ะบะพั‚ะพั€ะพะณะพ - ัะฒะพะนัั‚ะฒะพ ะพะฑัŒะตะบั‚ะฐ ะดะปั ะพะฑั€ะฐะฑะพั‚ะบะธ, ะผะพะถะตั‚ ะฒะบะปัŽั‡ะฐั‚ัŒ ะผะฐััะธะฒ - ะฟะตั€ะฒั‹ะน ั”ะปะตะผะตะฝั‚ ะบะพั‚ะพั€ะพะณะพ ัะฒะพะนัั‚ะฒะพ,
24   - * ะฐ ะดะฐะปัŒะฝะตะนัˆะธะต ะบะพะฝั„ะธะณัƒั€ะฐั†ะธะธ.
25   - *
26   - * @var array ะััะพั†ะธะฐั‚ะธะฒะฝั‹ ะผะฐััะธะฒ [key(ะผะตั‚ะพะด ะทะฐะฟะพะปะฝะตะฝะธั) => [[0 => property(ัะฒะพะนัั‚ะฒะพ ะพะฑัŒะตะบั‚ะฐ), ... ะดะพะฟะพะปะฝะธั‚ะตะปัŒะฝั‹ะต
27   - * ะฝะฐัั‚ั€ะพะนะบะธ]], ...[]]
28   - *
29   - */
30   - public $attributes;
31   -
32   - /**
33   - * ะกะพะฑั‹ั‚ะธั
34   - *
35   - * ะกะพะฑั‹ั‚ะธั ะฝะฐ ะบะพั‚ะพั€ั‹ะต ะดะพะปะถะฝะพ ัั€ะฐะฑะฐั‚ั‹ะฒะฐั‚ัŒ ะฟะพะฒะตะดะตะฝะธะต. ะ—ะฐะดะฐะตั‚ัั ะฐััะพั†ะธะฐั‚ะธะฒะฝั‹ะน ะผะฐััะธะฒ, ะฒ ะบะพั‚ะพั€ะพะผ ะบะปัŽั‡ - ัะพะฑั‹ั‚ะธะต
36   - * ัะฒัะทะฐะฝะฝะพะณะพ ะพะฑัŒะตะบั‚ะฐ, ะฐ ะทะฝะฐั‡ะตะฝะธะต - ะผะตั‚ะพะด, ะบะพั‚ะพั€ั‹ะน ะฒั‹ะทั‹ะฒะฐะตั‚ัั ะฟั€ะธ ัั‚ะพะผ ัะพะฑั‹ั‚ะธะธ
37   - *
38   - * @return array [key(event) => val(method)]
39   - *
40   - */
41   - public function events()
42   - {
43   - return [
44   - ActiveRecord::EVENT_BEFORE_INSERT => 'autocomplete',
45   - ActiveRecord::EVENT_BEFORE_UPDATE => 'autocomplete',
46   - ];
47   - }
48   -
49   - /**
50   - * ะกะพะฑั‹ั‚ะธั
51   - *
52   - * ะกะพะฑั‹ั‚ะธั ะฝะฐ ะบะพั‚ะพั€ั‹ะต ะดะพะปะถะฝะพ ัั€ะฐะฑะฐั‚ั‹ะฒะฐั‚ัŒ ะฟะพะฒะตะดะตะฝะธะต. ะ—ะฐะดะฐะตั‚ัั ะฐััะพั†ะธะฐั‚ะธะฒะฝั‹ะน ะผะฐััะธะฒ, ะฒ ะบะพั‚ะพั€ะพะผ ะบะปัŽั‡ - ัะพะฑั‹ั‚ะธะต
53   - * ัะฒัะทะฐะฝะฝะพะณะพ ะพะฑัŒะตะบั‚ะฐ, ะฐ ะทะฝะฐั‡ะตะฝะธะต - ะผะตั‚ะพะด, ะบะพั‚ะพั€ั‹ะน ะฒั‹ะทั‹ะฒะฐะตั‚ัั ะฟั€ะธ ัั‚ะพะผ ัะพะฑั‹ั‚ะธะธ
54   - * ะ”ะพัั‚ัƒะฟะฝั‹ะต ะฐะฒั‚ะพะทะฐะฟะพะปะฝะตะฝะธั:
55   - * ['translit' => ['prop1', ... 'prop2']],
56   - * ะณะดะต prop - ัะฒะพะนัั‚ะฒะพ ะฟะพะดะปะตะถะฐั‰ะตะต ั‚ั€ะฐะฝัะปะธั‚ะตั€ะฐั†ะธะธ
57   - * ['repeat' => [[string 'prop1', string 'target1', boolean 'skipFilled', int 'count', boolean 'truncate', string 'suffix'], ...[]],
58   - * ะณะดะต prop - ัะฒะพะนัั‚ะฒะพ ะดะปั ะฟั€ะตะพะฑั€ะฐะทะพะฒะฐะฝะธั,
59   - * target - ัะฒะพะนัั‚ะฒะพ ั ะบะพั‚ะพั€ะพะณะพ ะฒะทัั‚ัŒ ะดะฐะฝะฝั‹ะต,
60   - * count - ั‡ะธัะปะพ ะดะปั ะฟั€ะตะพะฑั€ะฐะทะพะฒะฐะฝะธั,
61   - * skipFilled - ะฟั€ะพะฟัƒัั‚ะธั‚ัŒ ะฝะตะฟัƒัั‚ั‹ะต,
62   - * truncate - true - ะพะฑั€ะตะทะฐั‚ัŒ ะฟะพ ัะปะพะฒะฐะผ, false - ะฟะพ ัะธะผะฒะพะปะฐะผ,
63   - * suffix - ััƒั„ั„ะธะบั, ะบะพั‚ะพั€ั‹ะน ะดะพะฑะฐะฒะธั‚ัŒ ะฟะพัะปะต ะพะฑั€ะตะทะบะธ
64   - *
65   - * @param mixed $event Yii ะพะฑัŒะตะบั‚ ัะฒะพะนัั‚ะฐ https://github.com/yiisoft/yii2/blob/master/docs/guide-ru/concept-events.md
66   - *
67   - */
68   - public function autocomplete($event)
69   - {
70   - if(!empty($this->attributes['translit'])) {
71   - foreach($this->attributes['translit'] as $translit) {
72   - if($this->owner->hasAttribute($translit)) {
73   - $this->owner->$translit = Tools::translit($this->owner->$translit);
74   - }
75   - }
76   - }
77   - if(!empty($this->attributes['repeat'])) {
78   - foreach($this->attributes['repeat'] as $repeat) {
79   - if(is_array($repeat) && $this->owner->hasAttribute($repeat[0]) && $this->owner->hasAttribute($repeat[1]) && is_int($repeat[3]) && (empty($this->owner->$repeat[0]) || $repeat[2])) {
80   - $suffix = $repeat[5]?:'';
81   - $truncate = $repeat[4]?'truncateWords':'truncate';
82   - $this->owner->$repeat[0] = StringHelper::$truncate($this->owner->$repeat[1], $repeat[3], $suffix);
83   - }
84   - }
85   - }
86   - }
87   -}
88 0 \ No newline at end of file
common/modules/blog/config.php deleted
1   -<?php
2   -return [
3   - 'components' => [
4   -
5   - ],
6   - 'params' => [
7   - 'test' => 'Hello',
8   - ],
9   -];
common/modules/blog/controllers/AjaxController.php deleted
1   -<?php
2   -namespace common\modules\blog\controllers;
3   -
4   -use common\models\Language;
5   -use common\modules\blog\models\ArticleCategory;
6   -use common\modules\blog\models\ArticleCategoryLang;
7   -use common\modules\blog\models\ArticleCategoryMedia;
8   -use common\modules\blog\models\ArticleLang;
9   -use common\modules\blog\models\ArticleMedia;
10   -use yii\base\InvalidParamException;
11   -use yii\web\Controller;
12   -use yii\web\ForbiddenHttpException;
13   -use yii\web\NotFoundHttpException;
14   -
15   -class AjaxController extends Controller
16   -{
17   - public function beforeAction($action)
18   - {
19   - if(!\Yii::$app->request->getIsAjax()) {
20   - //throw new ForbiddenHttpException('Permission denied');
21   - }
22   -
23   - if(!parent::beforeAction($action)) {
24   - return false;
25   - }
26   -
27   - return true;
28   - }
29   -
30   - public function actionCategoryForm($language_id, $widget_id)
31   - {
32   - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one();
33   - if(!$model) {
34   - throw new NotFoundHttpException('Language not found');
35   - }
36   - $category_lang = new ArticleCategoryLang();
37   - return $this->renderAjax('_category_form', ['model' => $model, 'category_lang' => $category_lang, 'widget_id' => $widget_id]);
38   - }
39   -
40   - public function actionArticleForm($language_id, $widget_id)
41   - {
42   - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one();
43   - if(!$model) {
44   - throw new NotFoundHttpException('Language not found');
45   - }
46   - $article_lang = new ArticleLang();
47   - return $this->renderAjax('_article_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id]);
48   - }
49   -
50   - public function actionArticleMediaForm($language_id, $widget_id, $type)
51   - {
52   - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one();
53   - if(!$model) {
54   - throw new NotFoundHttpException('Language not found');
55   - }
56   - if(!in_array($type, ['full', 'preview'])) {
57   - throw new InvalidParamException('Type must only be full/preview');
58   - }
59   - $article_lang = new ArticleMedia();
60   - return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]);
61   - }
62   -
63   - public function actionArticleCategoryMediaForm($language_id, $widget_id, $type)
64   - {
65   - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one();
66   - if(!$model) {
67   - throw new NotFoundHttpException('Language not found');
68   - }
69   - if(!in_array($type, ['full', 'preview'])) {
70   - throw new InvalidParamException('Type must only be full/preview');
71   - }
72   - $article_lang = new ArticleCategoryMedia();
73   - return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]);
74   - }
75   -
76   - public function actionRemoveImage()
77   - {
78   - $post = \Yii::$app->request->post();
79   - if(!empty($post['article_media_id'])) {
80   - $article_media = ArticleMedia::findOne($post['article_media_id']);
81   - if($post['remove_media']) {
82   - $media = $article_media->media->delete();
83   - }
84   - if(!empty($article_media)) {
85   - $article_media->delete();
86   - }
87   - return true;
88   - } else {
89   - return false;
90   - }
91   - }
92   -
93   - public function actionRemoveCategoryImage()
94   - {
95   - $post = \Yii::$app->request->post();
96   - if(!empty($post['category_media_id'])) {
97   - $category_media = ArticleCategoryMedia::findOne($post['category_media_id']);
98   - if($post['remove_media']) {
99   - $media = $category_media->media->delete();
100   - }
101   - if(!empty($category_media)) {
102   - $category_media->delete();
103   - }
104   - return true;
105   - } else {
106   - return false;
107   - }
108   - }
109   -
110   - public function actionRemoveImageCategory()
111   - {
112   - $post = \Yii::$app->request->post();
113   - if(!empty($post['category_media_id'])) {
114   - $category_media = ArticleCategoryMedia::findOne($post['category_media_id']);
115   - if($post['remove_media']) {
116   - $media = $category_media->media->delete();
117   - }
118   - if(!empty($category_media)) {
119   - $category_media->delete();
120   - }
121   - return true;
122   - } else {
123   - return false;
124   - }
125   - }
126   -
127   - public function actionMultilangForm($model, $ajaxView, $widget_id, $language_id = NULL)
128   - {
129   - $model = new $model(['language_id' => $language_id]);
130   - return $this->renderAjax($ajaxView, ['model' => $model, 'widget_id' => $widget_id]);
131   - }
132   -
133   -}
common/modules/blog/controllers/ArticleController.php deleted
1   -<?php
2   -namespace common\modules\blog\controllers;
3   -
4   -use common\components\rules\CommentRule;
5   -use common\components\rules\DeleteRule;
6   -use common\components\rules\UpdateRule;
7   -use common\components\rules\ViewRule;
8   -use common\models\Language;
9   -use common\modules\blog\models\Article;
10   -use common\modules\blog\models\ArticleLang;
11   -use common\modules\blog\models\ArticleMedia;
12   -use common\modules\blog\models\ArticleToCategory;
13   -use yii\data\ActiveDataProvider;
14   -use yii\rbac\DbManager;
15   -use yii\web\Controller;
16   -use yii\web\UploadedFile;
17   -
18   -class ArticleController extends Controller
19   -{
20   -
21   - public function actionIndex()
22   - {
23   - $dataProvider = new ActiveDataProvider([
24   - 'query' => Article::find(),
25   - 'pagination' => [
26   - 'pageSize' => 1,
27   - ],
28   - ]);
29   - return $this->render('index', ['dataProvider' => $dataProvider]);
30   - }
31   -
32   - public function actionCreate()
33   - {
34   - $article_langs = array();
35   - $article = new Article();
36   - $default_lang = Language::getDefaultLang();
37   - $images = array();
38   - $images[$default_lang->language_id]['full'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_FULL]);
39   - $images[$default_lang->language_id]['preview'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_PREVIEW]);
40   - $images[0]['additional'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
41   - $article->loadDefaultValues();
42   - $langs = Language::getActiveLanguages();
43   - $isValid = false;
44   - if(!empty(\Yii::$app->request->post())) {
45   - $isValid = true;
46   - $article->load(\Yii::$app->request->post());
47   - $article->user_id = \Yii::$app->user->getId();
48   - $isValid = $article->validate();
49   - foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) {
50   - foreach($value as $type => $fields) {
51   - $images[$lang][$type] = new ArticleMedia(['scenario' => $type]);
52   - $images[$lang][$type]->type = $type;
53   - $images[$lang][$type]->language_id = $lang;
54   - $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
55   - $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
56   - }
57   - }
58   - $images[0]['additional']->language_id = 0;
59   - $images[0]['additional']->type = 'additional';
60   - $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile");
61   - if(empty(\Yii::$app->request->post()['ArticleLang'])) {
62   - $article_langs[$default_lang->language_id] = new ArticleLang();
63   - $isValid = ArticleLang::validateMultiple($article_langs) && $isValid;
64   - } else {
65   - foreach(\Yii::$app->request->post()['ArticleLang'] as $index => $article_lang) {
66   - $article_langs[$index] = new ArticleLang();
67   - }
68   - ArticleLang::loadMultiple($article_langs, \Yii::$app->request->post());
69   - $isValid = ArticleLang::validateMultiple($article_langs) && $isValid;
70   - }
71   - } else {
72   - $article_langs[$default_lang->language_id] = new ArticleLang();
73   - }
74   - if($isValid) {
75   - $article->save(false);
76   - $article_categories = \Yii::$app->request->post('Article')['articleCategoriesArray'];
77   - if(!empty($article_categories)) {
78   - foreach($article_categories as $article_category) {
79   - $articletocategory[$article_category] = new ArticleToCategory();
80   - $articletocategory[$article_category]->article_category_id = $article_category;
81   - $articletocategory[$article_category]->link('article', $article);
82   - }
83   - }
84   - $first = 1;
85   - foreach($images as $lang => $value) {
86   - foreach($value as $type => $fields) {
87   - $images[$lang][$type]->upload($article->article_id);
88   - if($first && $type != 'additional') {
89   - $media_clone = clone $images[$lang][$type];
90   - $media_clone->setIsNewRecord(true);
91   - unset($media_clone->article_media_id);
92   - $media_clone->language_id = 0;
93   - $media_clone->upload($article->article_id);
94   - unset($media_clone);
95   - $first = 0;
96   - }
97   - }
98   - }
99   - $first = 1;
100   - foreach($article_langs as $article_lang) {
101   - if($first) {
102   - $article_lang_clone = clone $article_lang;
103   - $article_lang_clone->language_id = 0;
104   - $article_lang_clone->link('article', $article);
105   - unset($article_lang_clone);
106   - }
107   - $article_lang->link('article', $article);
108   - $first = 0;
109   - }
110   - echo "ok";
111   - //$this->redirect('index');
112   - } else {
113   - return $this->render('create', [
114   - 'article_langs' => $article_langs,
115   - 'article' => $article,
116   - 'langs' => $langs,
117   - 'images' => $images
118   - ]);
119   - }
120   - }
121   -
122   - public function actionUpdate($id)
123   - {
124   - $article = Article::findOne($id);
125   - $imagestack = $article->getArticleMedia()->all();
126   - $images = [];
127   - $images[0]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
128   - $images[0]['additional'][0]->type = 'additional';
129   - $images[0]['additional'][0]->language_id = 0;
130   - foreach($imagestack as $image) {
131   - if(in_array($image->type, ['full', 'preview'])) {
132   - $images[$image->language_id][$image->type] = $image;
133   - $images[$image->language_id][$image->type]->scenario = $image->type;
134   - } else {
135   - $images[$image->language_id][$image->type][$image->article_media_id] = $image;
136   - $images[$image->language_id][$image->type][$image->article_media_id]->scenario = $image->type;
137   - }
138   - }
139   - foreach($images as $lang => $value) {
140   - $images[$lang]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
141   - }
142   - $article_langs = $article->getArticleLangs()->where(['>=', 'language_id', '1'])->indexBy('language_id')->all();
143   - $langs = Language::getActiveLanguages();
144   - $default_lang = Language::getDefaultLang();
145   - $isValid = false;
146   - if(!empty(\Yii::$app->request->post())) {
147   - $isValid = true;
148   - $article->load(\Yii::$app->request->post());
149   - ArticleToCategory::deleteAll(['article_id' => $article->article_id]);
150   - $article_categories = \Yii::$app->request->post('Article')['articleCategoriesArray'];
151   - if(!empty($article_categories)) {
152   - foreach($article_categories as $article_category) {
153   - $articletocategory[$article_category] = new ArticleToCategory();
154   - $articletocategory[$article_category]->article_category_id = $article_category;
155   - $articletocategory[$article_category]->link('article', $article);
156   - }
157   - }
158   - $isValid = $article->validate();
159   - $images[0]['additional'][0]->type = 'additional';
160   - $images[0]['additional'][0]->language_id = 0;
161   - $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile");
162   - $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid;
163   - foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) {
164   - foreach($value as $type => $fields) {
165   - if(!in_array($type, ['full', 'preview'])) continue;
166   - $images[$lang][$type] = new ArticleMedia(['scenario' => $type]);
167   - $images[$lang][$type]->language_id = $lang;
168   - $images[$lang][$type]->type = $type;
169   - $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
170   - $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
171   - }
172   - }
173   - if(empty(\Yii::$app->request->post()['ArticleLang'])) {
174   - $isValid = ArticleLang::validateMultiple($article_langs) && $isValid;
175   - } else {
176   - foreach(\Yii::$app->request->post()['ArticleLang'] as $index => $article_lang) {
177   - if (!array_key_exists($index, $article_langs)) {
178   - $article_langs[$index] = new ArticleLang();
179   - $article_langs[$index]->article_id = $article->article_id;
180   - }
181   - }
182   - ArticleLang::loadMultiple($article_langs, \Yii::$app->request->post());
183   - $isValid = ArticleLang::validateMultiple($article_langs) && $isValid;
184   - }
185   - }
186   - if($isValid) {
187   - $article->save(false);
188   - foreach($images as $lang => $value) {
189   - foreach($value as $type => $fields) {
190   - if($type == 'additional') {
191   - $images[$lang][$type][0]->upload($article->id);
192   - } else {
193   - if(!empty($images[$lang][$type]->imageFile)) {
194   - $images[$lang][$type]->replace($article->article_id);
195   - }
196   - }
197   - }
198   - }
199   - foreach($article_langs as $article_lang) {
200   - $article_lang->save(false);
201   - }
202   - echo "ok";
203   - //$this->redirect('index');
204   - } else {
205   - return $this->render('update', [
206   - 'article_langs' => $article_langs,
207   - 'article' => $article,
208   - 'langs' => $langs,
209   - 'images' => $images
210   - ]);
211   - }
212   - }
213   -
214   - public function actionDelete($id)
215   - {
216   - $this->findModel($id)->delete();
217   - return $this->redirect(['index']);
218   - }
219   -
220   - protected function findModel($id)
221   - {
222   - if (($model = Article::findOne($id)) !== null) {
223   - return $model;
224   - } else {
225   - throw new NotFoundHttpException('The requested page does not exist.');
226   - }
227   - }
228   -}
common/modules/blog/controllers/CategoryController.php deleted
1   -<?php
2   -namespace common\modules\blog\controllers;
3   -
4   -use common\models\Language;
5   -use common\modules\blog\models\Article;
6   -use common\modules\blog\models\ArticleCategory;
7   -use common\modules\blog\models\ArticleCategoryLang;
8   -use common\modules\blog\models\ArticleCategoryMedia;
9   -use common\modules\blog\models\ArticleLang;
10   -use yii\data\ActiveDataProvider;
11   -use yii\filters\VerbFilter;
12   -use yii\web\Controller;
13   -use yii\web\NotFoundHttpException;
14   -use yii\web\UploadedFile;
15   -
16   -class CategoryController extends Controller
17   -{
18   - public function behaviors()
19   - {
20   - return [
21   - 'verbs' => [
22   - 'class' => VerbFilter::className(),
23   - 'actions' => [
24   - 'delete' => ['post']
25   - ]
26   - ]
27   - ];
28   - }
29   -
30   - public function actionIndex()
31   - {
32   - $dataProvider = new ActiveDataProvider([
33   - 'query' => ArticleCategory::find(),
34   - 'pagination' => [
35   - 'pageSize' => 1,
36   - ],
37   - ]);
38   - return $this->render('index', ['dataProvider' => $dataProvider]);
39   - }
40   -
41   - public function actionCreate()
42   - {
43   - $category_langs = array();
44   - $category = new ArticleCategory();
45   - $default_lang = Language::getDefaultLang();
46   - $images = array();
47   - $images[$default_lang->language_id]['full'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_FULL]);
48   - $images[$default_lang->language_id]['preview'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_PREVIEW]);
49   - $images[0]['additional'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
50   - $category->loadDefaultValues();
51   - $langs = Language::getActiveLanguages();
52   - $isValid = false;
53   - if(!empty(\Yii::$app->request->post())) {
54   - $isValid = true;
55   - $category->load(\Yii::$app->request->post());
56   - $isValid = $category->validate();
57   - foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) {
58   - foreach($value as $type => $fields) {
59   - $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]);
60   - $images[$lang][$type]->type = $type;
61   - $images[$lang][$type]->language_id = $lang;
62   - $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
63   - $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
64   - }
65   - }
66   - $images[0]['additional']->language_id = 0;
67   - $images[0]['additional']->type = 'additional';
68   - $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile");
69   - if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) {
70   - $category_langs[$default_lang->language_id] = new ArticleCategoryLang();
71   - $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid;
72   - } else {
73   - foreach(\Yii::$app->request->post()['ArticleCategoryLang'] as $index => $category_lang) {
74   - $category_langs[$index] = new ArticleCategoryLang();
75   - }
76   - ArticleCategoryLang::loadMultiple($category_langs, \Yii::$app->request->post());
77   - $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid;
78   - }
79   - } else {
80   - $category_langs[$default_lang->language_id] = new ArticleCategoryLang();
81   - }
82   - if($isValid) {
83   - $category->save(false);
84   - $first = 1;
85   - foreach($images as $lang => $value) {
86   - foreach($value as $type => $fields) {
87   - $images[$lang][$type]->upload($category->article_category_id);
88   - if($first && $type != 'additional') {
89   - $media_clone = clone $images[$lang][$type];
90   - $media_clone->setIsNewRecord(true);
91   - unset($media_clone->article_category_media_id);
92   - $media_clone->language_id = 0;
93   - $media_clone->upload($category->article_category_id);
94   - unset($media_clone);
95   - $first = 0;
96   - }
97   - }
98   - }
99   - $first = 1;
100   - foreach($category_langs as $category_lang) {
101   - if($first) {
102   - $category_lang_clone = clone $category_lang;
103   - $category_lang_clone->language_id = 0;
104   - $category_lang_clone->link('category', $category);
105   - unset($category_lang_clone);
106   - }
107   - $category_lang->link('category', $category);
108   - $first = 0;
109   - }
110   - echo "ok";
111   - //$this->redirect('index');
112   - } else {
113   - return $this->render('create', [
114   - 'category_langs' => $category_langs,
115   - 'category' => $category,
116   - 'langs' => $langs,
117   - 'images' => $images
118   - ]);
119   - }
120   - }
121   -
122   - public function actionUpdate($id)
123   - {
124   - $category = ArticleCategory::findOne($id);
125   - $imagestack = $category->getArticleCategoryMedia()->all();
126   - $images = [];
127   - $images[0]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
128   - $images[0]['additional'][0]->type = 'additional';
129   - $images[0]['additional'][0]->language_id = 0;
130   - foreach($imagestack as $image) {
131   - if(in_array($image->type, ['full', 'preview'])) {
132   - $images[$image->language_id][$image->type] = $image;
133   - $images[$image->language_id][$image->type]->scenario = $image->type;
134   - } else {
135   - $images[$image->language_id][$image->type][$image->article_category_media_id] = $image;
136   - $images[$image->language_id][$image->type][$image->article_category_media_id]->scenario = $image->type;
137   - }
138   - }
139   - foreach($images as $lang => $value) {
140   - $images[$lang]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
141   - }
142   - $category_langs = $category->getArticleCategoryLangs()->where(['>=', 'language_id', '1'])->indexBy('language_id')->all();
143   - $langs = Language::getActiveLanguages();
144   - $default_lang = Language::getDefaultLang();
145   - $isValid = false;
146   - if(!empty(\Yii::$app->request->post())) {
147   - $isValid = true;
148   - $category->load(\Yii::$app->request->post());
149   - $isValid = $category->validate();
150   - $images[0]['additional'][0]->type = 'additional';
151   - $images[0]['additional'][0]->language_id = 0;
152   - $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile");
153   - $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid;
154   - foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) {
155   - foreach($value as $type => $fields) {
156   - if(!in_array($type, ['full', 'preview'])) continue;
157   - $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]);
158   - $images[$lang][$type]->language_id = $lang;
159   - $images[$lang][$type]->type = $type;
160   - $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
161   - $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
162   - }
163   - }
164   - if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) {
165   - $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid;
166   - } else {
167   - foreach(\Yii::$app->request->post()['ArticleCategoryLang'] as $index => $category_lang) {
168   - if(!array_key_exists($index, $category_langs)) {
169   - $category_langs[$index] = new ArticleCategoryLang();
170   - $category_langs[$index]->article_category_id = $category->article_category_id;
171   - }
172   - }
173   - ArticleCategoryLang::loadMultiple($category_langs, \Yii::$app->request->post());
174   - $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid;
175   - }
176   - }
177   - if($isValid) {
178   - $category->save(false);
179   - foreach($images as $lang => $value) {
180   - foreach($value as $type => $fields) {
181   - if($type == 'additional') {
182   - $images[$lang][$type][0]->upload($category->article_category_id);
183   - } else {
184   - if(!empty($images[$lang][$type]->imageFile)) {
185   - $images[$lang][$type]->replace($category->article_category_id);
186   - }
187   - }
188   - }
189   - }
190   - foreach($category_langs as $category_lang) {
191   - $category_lang->save(false);
192   - }
193   - echo "ok";
194   - //$this->redirect('index');
195   - } else {
196   - return $this->render('update', [
197   - 'category_langs' => $category_langs,
198   - 'category' => $category,
199   - 'langs' => $langs,
200   - 'images' => $images
201   - ]);
202   - }
203   - }
204   -
205   - public function actionDelete($id)
206   - {
207   - $this->findModel($id)->delete();
208   - return $this->redirect(['index']);
209   - }
210   -
211   - protected function findModel($id)
212   - {
213   - if (($model = ArticleCategory::findOne($id)) !== null) {
214   - return $model;
215   - } else {
216   - throw new NotFoundHttpException('The requested page does not exist.');
217   - }
218   - }
219   -}
common/modules/blog/controllers/DefaultController.php deleted
1   -<?php
2   -namespace common\modules\blog\controllers;
3   -
4   -use yii\web\Controller;
5   -
6   -class DefaultController extends Controller
7   -{
8   - public function actionIndex()
9   - {
10   - return $this->render('index');
11   - }
12   -}
common/modules/blog/controllers/MediaController.php deleted
1   -<?php
2   -namespace common\modules\blog\controllers;
3   -
4   -use common\models\Media;
5   -use common\modules\blog\models\Article;
6   -use yii\web\Controller;
7   -use yii\web\UploadedFile;
8   -
9   -class MediaController extends Controller
10   -{
11   - public function actionIndex()
12   - {
13   - $model = new Media();
14   - if(\Yii::$app->request->isPost) {
15   - $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
16   - if($model->upload()) {
17   - return true;
18   - } else {
19   - return false;
20   - }
21   - }
22   - return $this->render('index', ['model' => $model]);
23   - }
24   -
25   - public function actionCreate()
26   - {
27   -
28   - }
29   -
30   - public function actionUpdate($id)
31   - {
32   -
33   - }
34   -
35   - public function actionDelete($id)
36   - {
37   - $model = Media::findOne($id);
38   - return $model->delete();
39   - }
40   -
41   - protected function findModel($id)
42   - {
43   -
44   - }
45   -}
common/modules/blog/controllers/TestController.php deleted
1   -<?php
2   -namespace common\modules\blog\controllers;
3   -
4   -use common\models\Language;
5   -use common\modules\blog\models\ArticleLang;
6   -use yii\console\Controller;
7   -
8   -class TestController extends Controller
9   -{
10   - public function actionIndex()
11   - {
12   - $default_lang = Language::getDefaultLang();
13   - $model[$default_lang->language_id] = new ArticleLang();
14   - $model[3] = new ArticleLang();
15   - return $this->render('index', ['model' => $model]);
16   - }
17   -}
18 0 \ No newline at end of file
common/modules/blog/models/Article.php deleted
1   -<?php
2   -
3   -namespace common\modules\blog\models;
4   -
5   -use common\models\ActiveRecordRule;
6   -use common\models\Media;
7   -use common\models\User;
8   -use common\modules\blog\behaviors\Autocomplete;
9   -use Yii;
10   -use yii\db\Query;
11   -
12   -/**
13   - * This is the model class for table "article".
14   - *
15   - * @property integer $article_id
16   - * @property integer $sort
17   - * @property string $date_add
18   - * @property string $date_update
19   - * @property string $code
20   - * @property integer $user_id
21   - * @property string $tag
22   - * @property integer $article_pid
23   - * @property integer $status
24   - * @property integer $comment
25   - * @property integer $vote
26   - *
27   - * @property Article $parent
28   - * @property Article[] $articles
29   - * @property User $user
30   - * @property ArticleLang[] $articleLangs
31   - * @property ArticleMedia[] $articleMedia
32   - * @property ArticleToCategory[] $articleToCategories
33   - * @property Media[] $media
34   - */
35   -class Article extends ActiveRecordRule
36   -{
37   - /**
38   - * @inheritdoc
39   - */
40   - public static function tableName()
41   - {
42   - return 'article';
43   - }
44   -
45   - public function behaviors()
46   - {
47   - return [
48   - [
49   - 'class' => Autocomplete::className(),
50   - 'attributes' => [
51   - 'translit' => ['code'],
52   - ]
53   - ]
54   - ];
55   - }
56   - /**
57   - * @inheritdoc
58   - */
59   - public function rules()
60   - {
61   - return [
62   - [['sort', 'article_pid', 'status', 'comment', 'vote'], 'integer'],
63   - [['date_add', 'date_update'], 'safe'],
64   - [['code'], 'required'],
65   - [['code', 'tag'], 'string']
66   - ];
67   - }
68   -
69   - /**
70   - * @inheritdoc
71   - */
72   - public function attributeLabels()
73   - {
74   - return [
75   - 'article_id' => Yii::t('app', 'ID'),
76   - 'sort' => Yii::t('app', 'Sort'),
77   - 'date_add' => Yii::t('app', 'Create At'),
78   - 'date_update' => Yii::t('app', 'Update At'),
79   - 'code' => Yii::t('app', 'Code'),
80   - 'user_id' => Yii::t('app', 'Author'),
81   - 'tag' => Yii::t('app', 'Tags'),
82   - 'article_pid' => Yii::t('app', 'Parent ID'),
83   - 'status' => Yii::t('app', 'Active'),
84   - 'comment' => Yii::t('app', 'Comments'),
85   - 'vote' => Yii::t('app', 'Voting'),
86   - ];
87   - }
88   -
89   - /**
90   - * @return \yii\db\ActiveQuery
91   - */
92   - public function getParent()
93   - {
94   - return $this->hasOne(Article::className(), ['article_id' => 'article_pid']);
95   - }
96   -
97   - /**
98   - * @return \yii\db\ActiveQuery
99   - */
100   - public function getArticles()
101   - {
102   - return $this->hasMany(Article::className(), ['article_pid' => 'article_id']);
103   - }
104   -
105   - /**
106   - * @return \yii\db\ActiveQuery
107   - */
108   - public function getUser()
109   - {
110   - return $this->hasOne(User::className(), ['id' => 'user_id']);
111   - }
112   -
113   - /**
114   - * @return \yii\db\ActiveQuery
115   - */
116   - public function getArticleLangs()
117   - {
118   - return $this->hasMany(ArticleLang::className(), ['article_id' => 'article_id']);
119   - }
120   -
121   - /**
122   - * @return \yii\db\ActiveQuery
123   - */
124   - public function getArticleMedia()
125   - {
126   - return $this->hasMany(ArticleMedia::className(), ['article_id' => 'article_id']);
127   - }
128   -
129   - public function getMedia()
130   - {
131   - return $this->hasMany(Media::className(), ['article_id' => 'media_id'])->via('articleMedia');
132   - }
133   - /**
134   - * @return \yii\db\ActiveQuery
135   - */
136   - public function getArticleToCategories()
137   - {
138   - return $this->hasMany(ArticleToCategory::className(), ['article_id' => 'article_id']);
139   - }
140   -
141   - public function getArticleCategories()
142   - {
143   - return $this->hasMany(ArticleCategory::className(), ['article_category_id' => 'article_category_id'])->viaTable('article_to_category', ['article_id' => 'article_category_id']);
144   - }
145   -
146   - public static function findArticleDropdown($id)
147   - {
148   - $query = new Query();
149   - return $query->select(['l.name', 'a.article_id'])
150   - ->from(['article a'])
151   - ->leftJoin(['article_lang l'], 'a.article_id = l.article_id')
152   - ->where(['l.language_id' => 0, 'a.status' => 1])
153   - ->andWhere(['not', ['a.article_id' => $id]])
154   - ->indexBy('article_id')
155   - ->column();
156   - }
157   -
158   - public function getArticleCategoriesArray()
159   - {
160   - return $this->getArticleToCategories()->select('article_category_id')->column();
161   - }
162   -
163   -}
common/modules/blog/models/ArticleCategory.php deleted
1   -<?php
2   -
3   -namespace common\modules\blog\models;
4   -
5   -use common\modules\blog\behaviors\Autocomplete;
6   -use Yii;
7   -use yii\behaviors\TimestampBehavior;
8   -use yii\db\ActiveRecord;
9   -use yii\db\Query;
10   -
11   -/**
12   - * This is the model class for table "article_category".
13   - *
14   - * @property integer $article_category_id
15   - * @property integer $status
16   - * @property integer $sort
17   - * @property string $code
18   - * @property string $date_add
19   - * @property string $date_update
20   - * @property string $tag
21   - * @property integer $artucle_category_pid
22   - *
23   - * @property Article[] $articles
24   - * @property ArticleCategory $parent
25   - * @property ArticleCategory[] $articleCategories
26   - * @property ArticleCategoryLang[] $articleCategoryLangs
27   - * @property ArticleCategoryMedia[] $articleCategoryMedia
28   - */
29   -class ArticleCategory extends ActiveRecord
30   -{
31   - /**
32   - * @inheritdoc
33   - */
34   - public static function tableName()
35   - {
36   - return 'article_category';
37   - }
38   -
39   - public function behaviors()
40   - {
41   - return [
42   - [
43   - 'class' => Autocomplete::className(),
44   - 'attributes' => [
45   - 'translit' => ['code'],
46   - ]
47   - ]
48   - ];
49   - }
50   - /**
51   - * @inheritdoc
52   - */
53   - public function rules()
54   - {
55   - return [
56   - [['status', 'sort', 'article_category_pid'], 'integer'],
57   - [['code'], 'required'],
58   - [['code', 'tag'], 'string'],
59   - [['date_add', 'date_update'], 'safe'],
60   - [['status'], 'boolean'],
61   - ];
62   - }
63   -
64   - /**
65   - * @inheritdoc
66   - */
67   - public function attributeLabels()
68   - {
69   - return [
70   - 'article_category_id' => Yii::t('app', 'ID'),
71   - 'status' => Yii::t('app', 'Active'),
72   - 'sort' => Yii::t('app', 'Sort'),
73   - 'code' => Yii::t('app', 'Code'),
74   - 'date_add' => Yii::t('app', 'Created At'),
75   - 'date_update' => Yii::t('app', 'Updated At'),
76   - 'tag' => Yii::t('app', 'Tags'),
77   - 'article_category_pid' => Yii::t('app', 'Parent ID'),
78   - ];
79   - }
80   -
81   - /**
82   - * @return \yii\db\ActiveQuery
83   - */
84   - public function getArticles()
85   - {
86   - return $this->hasMany(Article::className(), ['article_id' => 'article_id'])->viaTable('article_to_category', ['article_category_id' => 'article_category_id']) ;
87   - }
88   -
89   - /**
90   - * @return \yii\db\ActiveQuery
91   - */
92   - public function getParent()
93   - {
94   - return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_pid']);
95   - }
96   -
97   - /**
98   - * @return \yii\db\ActiveQuery
99   - */
100   - public function getArticleCategories()
101   - {
102   - return $this->hasMany(ArticleCategory::className(), ['article_category_pid' => 'article_category_id']);
103   - }
104   -
105   - /**
106   - * @return \yii\db\ActiveQuery
107   - */
108   - public function getArticleCategoryLangs()
109   - {
110   - return $this->hasMany(ArticleCategoryLang::className(), ['article_category_id' => 'article_category_id']);
111   - }
112   -
113   - /**
114   - * @return \yii\db\ActiveQuery
115   - */
116   - public function getArticleCategoryMedia()
117   - {
118   - return $this->hasMany(ArticleCategoryMedia::className(), ['article_category_id' => 'article_category_id']);
119   - }
120   -
121   - public static function findArticleCategoryDropdown($id)
122   - {
123   - $query = new Query();
124   - return $query->select(['l.name', 'c.article_category_id'])
125   - ->from(['article_category c'])
126   - ->leftJoin(['article_category_lang l'], 'c.article_category_id = l.article_category_id')
127   - ->where(['l.language_id' => 0, 'c.status' => 1])
128   - ->andWhere(['not', ['c.article_category_id' => $id]])
129   - ->indexBy('article_category_id')
130   - ->column();
131   - }
132   -
133   -}
common/modules/blog/models/ArticleCategoryLang.php deleted
1   -<?php
2   -
3   -namespace common\modules\blog\models;
4   -
5   -use common\modules\blog\behaviors\Autocomplete;
6   -use Yii;
7   -
8   -/**
9   - * This is the model class for table "article_category_lang".
10   - *
11   - * @property integer $article_category_language_id
12   - * @property integer $language_id
13   - * @property integer $article_category_id
14   - * @property string $text
15   - * @property string $preview
16   - * @property string $seo_url
17   - * @property string $name
18   - * @property string $meta_title
19   - * @property string $meta_descr
20   - * @property string $meta_keyword
21   - * @property string $h1_tag
22   - * @property string $tag
23   - *
24   - * @property ArticleCategory $category
25   - * @property Language $lang
26   - */
27   -class ArticleCategoryLang extends \yii\db\ActiveRecord
28   -{
29   - /**
30   - * @inheritdoc
31   - */
32   - public static function tableName()
33   - {
34   - return 'article_category_lang';
35   - }
36   -
37   - public function behaviors()
38   - {
39   - return [
40   - [
41   - 'class' => Autocomplete::className(),
42   - 'attributes' => [
43   - 'repeat' => [['preview', 'text', false, 5, true, '...']],
44   - ]
45   - ]
46   - ];
47   - }
48   - /**
49   - * @inheritdoc
50   - */
51   - public function rules()
52   - {
53   - return [
54   - [['language_id', 'article_category_id'], 'integer'],
55   - [['text', 'name'], 'required'],
56   - [['text', 'preview', 'seo_url', 'name', 'meta_title', 'meta_descr', 'meta_keyword', 'h1_tag', 'tag'], 'string'],
57   - ['seo_url', function($attribute, $params) {
58   - $pattern = "/^[a-zA-Z\d_-]+$/";
59   - if(!preg_match($pattern, $this->$attribute)) {
60   - $this->addError($attribute, Yii::t('app', "Pattern doesn't match."));
61   - }
62   - }]
63   - ];
64   - }
65   -
66   - /**
67   - * @inheritdoc
68   - */
69   - public function attributeLabels()
70   - {
71   - return [
72   - 'article_category_language_id' => Yii::t('app', 'ID'),
73   - 'language_id' => Yii::t('app', 'Lang ID'),
74   - 'article_category_id' => Yii::t('app', 'Category ID'),
75   - 'text' => Yii::t('app', 'Text'),
76   - 'preview' => Yii::t('app', 'Preview'),
77   - 'seo_url' => Yii::t('app', 'Seo Url'),
78   - 'name' => Yii::t('app', 'Name'),
79   - 'meta_title' => Yii::t('app', 'Meta Title'),
80   - 'meta_descr' => Yii::t('app', 'Meta Descr'),
81   - 'meta_keyword' => Yii::t('app', 'Meta Keywords'),
82   - 'h1_tag' => Yii::t('app', 'H1 Tag'),
83   - 'tag' => Yii::t('app', 'Tags'),
84   - ];
85   - }
86   -
87   - /**
88   - * @return \yii\db\ActiveQuery
89   - */
90   - public function getCategory()
91   - {
92   - return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_id']);
93   - }
94   -
95   - /**
96   - * @return \yii\db\ActiveQuery
97   - */
98   - public function getLang()
99   - {
100   - return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
101   - }
102   -}
common/modules/blog/models/ArticleCategoryMedia.php deleted
1   -<?php
2   -
3   -namespace common\modules\blog\models;
4   -
5   -use common\models\Media;
6   -use Yii;
7   -
8   -/**
9   - * This is the model class for table "article_category_media".
10   - *
11   - * @property integer $article_category_media_id
12   - * @property integer $article_category_id
13   - * @property integer $media_id
14   - * @property string $media_alt
15   - * @property string $media_title
16   - * @property string $media_caption
17   - * @property string $type
18   - * @property string $language_id
19   - *
20   - * @property ArticleCategory $category
21   - * @property Media $media
22   - * @property Language $lang
23   - */
24   -class ArticleCategoryMedia extends \yii\db\ActiveRecord
25   -{
26   - const SCENARIO_FULL = 'full';
27   - const SCENARIO_PREVIEW = 'preview';
28   - const SCENARIO_ADDITIONAL = 'additional';
29   - public $imageFile;
30   - /**
31   - * @inheritdoc
32   - */
33   - public static function tableName()
34   - {
35   - return 'article_category_media';
36   - }
37   -
38   - public function scenarios()
39   - {
40   - $scenarios = parent::scenarios();
41   - $scenarios[self::SCENARIO_FULL] = ['article_category_media_id', 'article_category_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile'];
42   - $scenarios[self::SCENARIO_PREVIEW] = ['article_category_media_id', 'article_category_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile'];
43   - $scenarios[self::SCENARIO_ADDITIONAL] = ['article_category_media_id', 'article_category_id', 'media_id', 'type', 'imageFile'];
44   - return $scenarios;
45   - }
46   -
47   - /**
48   - * @inheritdoc
49   - */
50   - public function rules()
51   - {
52   - return [
53   - [['article_category_id', 'media_id'], 'required'],
54   - [['article_category_id', 'media_id'], 'integer'],
55   - [['media_alt', 'media_title', 'media_caption'], 'string'],
56   - [['type'], 'string', 'max' => 10],
57   - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_FULL],
58   - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_PREVIEW],
59   - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'maxFiles' => 10, 'on' => self::SCENARIO_ADDITIONAL]
60   - ];
61   - }
62   -
63   - /**
64   - * @inheritdoc
65   - */
66   - public function attributeLabels()
67   - {
68   - return [
69   - 'article_category_media_id' => Yii::t('app', 'ID'),
70   - 'article_category_id' => Yii::t('app', 'Category ID'),
71   - 'media_id' => Yii::t('app', 'Media ID'),
72   - 'media_alt' => Yii::t('app', 'Media Alt'),
73   - 'media_title' => Yii::t('app', 'Media Title'),
74   - 'media_caption' => Yii::t('app', 'Media Caption'),
75   - 'type' => Yii::t('app', 'Type'),
76   - 'imageFile' => Yii::t('app', 'Image File'),
77   - 'language_id' => Yii::t('app', 'Language ID'),
78   - ];
79   - }
80   -
81   - /**
82   - * @return \yii\db\ActiveQuery
83   - */
84   - public function getCategory()
85   - {
86   - return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_id']);
87   - }
88   -
89   - /**
90   - * @return \yii\db\ActiveQuery
91   - */
92   - public function getMedia()
93   - {
94   - return $this->hasOne(Media::className(), ['media_id' => 'media_id']);
95   - }
96   -
97   - public function upload($category_id)
98   - {
99   - $this->article_category_id = $category_id;
100   - if(is_array($this->imageFile)) {
101   - $ok = true;
102   - foreach($this->imageFile as $image) {
103   - $media_category = clone $this;
104   - $media = new Media();
105   - $media->imageFile = $image;
106   - $media->upload();
107   - $media_category->media_id = $media->media_id;
108   - $ok = $media_category->save() && $ok;
109   - unset($media_category);
110   - }
111   - return $ok;
112   - } elseif(!empty($this->imageFile)) {
113   - $media = new Media();
114   - $media->imageFile = $this->imageFile;
115   - $media->upload();
116   - $this->media_id = $media->media_id;
117   - return $this->save();
118   - }
119   - }
120   -
121   - public function replace($category_id, $removeMedia = false)
122   - {
123   - $this->article_category_id = $category_id;
124   - if($removeMedia) {
125   - $category_media = ArticleCategoryMedia::find()->select('media_id')->where(['article_category_id' => $this->article_category_id, 'type' => $this->type])->column();
126   - $media = array();
127   - foreach($category_media as $media_id) {
128   - $media[] = Media::findOne(['media_id' => $media_id]);
129   - }
130   - $media = array_unique($media);
131   - foreach($media as $one_media) {
132   - if($one_media instanceof Media) {
133   - $one_media->delete();
134   - }
135   - }
136   - unset($media);
137   - unset($category_media);
138   - }
139   - if(is_array($this->imageFile)) {
140   - $ok = true;
141   - foreach($this->imageFile as $image) {
142   - $media_category = clone $this;
143   - $media = new Media();
144   - $media->imageFile = $image;
145   - $media->upload();
146   - $media_category->media_id = $media->media_id;
147   - $ok = $media_category->save() && $ok;
148   - unset($media_category);
149   - }
150   - return $ok;
151   - } elseif(!empty($this->imageFile)) {
152   - ArticleCategoryMedia::deleteAll(['category_id' => $this->article_category_id, 'type' => $this->type]);
153   - $media = new Media();
154   - $media->imageFile = $this->imageFile;
155   - $media->upload();
156   - $this->media_id = $media->media_id;
157   - $this->setIsNewRecord(true);
158   - return $this->save();
159   - }
160   - }
161   -
162   -}
common/modules/blog/models/ArticleLang.php deleted
1   -<?php
2   -
3   -namespace common\modules\blog\models;
4   -
5   -use Yii;
6   -use common\models\Language;
7   -
8   -/**
9   - * This is the model class for table "article_lang".
10   - *
11   - * @property integer $article_language_id
12   - * @property integer $language_id
13   - * @property integer $article_id
14   - * @property string $text
15   - * @property string $seo_url
16   - * @property string $name
17   - * @property string $preview
18   - * @property string $meta_title
19   - * @property string $meta_descr
20   - * @property string $meta_keyword
21   - * @property string $h1_tag
22   - * @property string $tag
23   - *
24   - * @property Article $article
25   - * @property Language $lang
26   - */
27   -class ArticleLang extends \yii\db\ActiveRecord
28   -{
29   - /**
30   - * @inheritdoc
31   - */
32   - public static function tableName()
33   - {
34   - return 'article_lang';
35   - }
36   -
37   - /**
38   - * @inheritdoc
39   - */
40   - public function rules()
41   - {
42   - return [
43   - [['language_id', 'text', 'name'], 'required'],
44   - [['language_id', 'article_id'], 'integer'],
45   - [['text', 'seo_url', 'name', 'preview', 'meta_title', 'meta_descr', 'meta_keyword', 'h1_tag', 'tag'], 'string']
46   - ];
47   - }
48   -
49   - /**
50   - * @inheritdoc
51   - */
52   - public function attributeLabels()
53   - {
54   - return [
55   - 'article_language_id' => Yii::t('app', 'ID'),
56   - 'language_id' => Yii::t('app', 'Lang ID'),
57   - 'article_id' => Yii::t('app', 'Article ID'),
58   - 'text' => Yii::t('app', 'Text'),
59   - 'seo_url' => Yii::t('app', 'Seo Url'),
60   - 'name' => Yii::t('app', 'Name'),
61   - 'preview' => Yii::t('app', 'Preview'),
62   - 'meta_title' => Yii::t('app', 'Meta Title'),
63   - 'meta_descr' => Yii::t('app', 'Meta Descr'),
64   - 'meta_keyword' => Yii::t('app', 'Meta Keywords'),
65   - 'h1_tag' => Yii::t('app', 'H1 Tag'),
66   - 'tag' => Yii::t('app', 'Tags'),
67   - ];
68   - }
69   -
70   - /**
71   - * @return \yii\db\ActiveQuery
72   - */
73   - public function getArticle()
74   - {
75   - return $this->hasOne(Article::className(), ['article_id' => 'article_id']);
76   - }
77   -
78   - /**
79   - * @return \yii\db\ActiveQuery
80   - */
81   - public function getLang()
82   - {
83   - return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
84   - }
85   -}
common/modules/blog/models/ArticleMedia.php deleted
1   -<?php
2   -
3   -namespace common\modules\blog\models;
4   -
5   -use common\models\Media;
6   -use Yii;
7   -use yii\web\UploadedFile;
8   -
9   -/**
10   - * This is the model class for table "article_media".
11   - *
12   - * @property integer $article_media_id
13   - * @property integer $article_id
14   - * @property integer $media_id
15   - * @property string $type
16   - * @property string $media_alt
17   - * @property string $media_title
18   - * @property string $media_caption
19   - * @property integer $language_id
20   - *
21   - * @property Article $article
22   - * @property Media $media
23   - */
24   -class ArticleMedia extends \yii\db\ActiveRecord
25   -{
26   - const SCENARIO_FULL = 'full';
27   - const SCENARIO_PREVIEW = 'preview';
28   - const SCENARIO_ADDITIONAL = 'additional';
29   - public $imageFile;
30   - /**
31   - * @inheritdoc
32   - */
33   - public static function tableName()
34   - {
35   - return 'article_media';
36   - }
37   -
38   - public function scenarios()
39   - {
40   - $scenarios = parent::scenarios();
41   - $scenarios[self::SCENARIO_FULL] = ['article_media_id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile', 'language_id'];
42   - $scenarios[self::SCENARIO_PREVIEW] = ['article_media_id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile', 'language_id'];
43   - $scenarios[self::SCENARIO_ADDITIONAL] = ['article_media_id', 'article_id', 'media_id', 'type', 'imageFile', 'language_id'];
44   - return $scenarios;
45   - }
46   -
47   - /**
48   - * @inheritdoc
49   - */
50   - public function rules()
51   - {
52   - return [
53   - [['article_id', 'media_id'], 'required'],
54   - [['article_id', 'media_id', 'language_id'], 'integer'],
55   - [['media_alt', 'media_title', 'media_caption'], 'string'],
56   - [['type'], 'string', 'max' => 10],
57   - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_FULL],
58   - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_PREVIEW],
59   - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'maxFiles' => 10, 'on' => self::SCENARIO_ADDITIONAL]
60   - ];
61   - }
62   -
63   - /**
64   - * @inheritdoc
65   - */
66   - public function attributeLabels()
67   - {
68   - return [
69   - 'article_media_id' => Yii::t('app', 'ID'),
70   - 'article_id' => Yii::t('app', 'Article ID'),
71   - 'media_id' => Yii::t('app', 'Media ID'),
72   - 'type' => Yii::t('app', 'Type'),
73   - 'media_alt' => Yii::t('app', 'Media Alt'),
74   - 'media_title' => Yii::t('app', 'Media Title'),
75   - 'media_caption' => Yii::t('app', 'Media Caption'),
76   - 'imageFile' => Yii::t('app', 'Image File'),
77   - ];
78   - }
79   -
80   - /**
81   - * @return \yii\db\ActiveQuery
82   - */
83   - public function getArticle()
84   - {
85   - return $this->hasOne(Article::className(), ['article_id' => 'article_id']);
86   - }
87   -
88   - /**
89   - * @return \yii\db\ActiveQuery
90   - */
91   - public function getMedia()
92   - {
93   - return $this->hasOne(Media::className(), ['media_id' => 'media_id']);
94   - }
95   -
96   - public function upload($article_id)
97   - {
98   - $this->article_id = $article_id;
99   - if(is_array($this->imageFile)) {
100   - $ok = true;
101   - foreach($this->imageFile as $image) {
102   - $media_article = clone $this;
103   - $media = new Media();
104   - $media->imageFile = $image;
105   - $media->upload();
106   - $media_article->media_id = $media->media_id;
107   - $ok = $media_article->save() && $ok;
108   - unset($media_article);
109   - }
110   - return $ok;
111   - } elseif(!empty($this->imageFile)) {
112   - $media = new Media();
113   - $media->imageFile = $this->imageFile;
114   - $media->upload();
115   - $this->media_id = $media->media_id;
116   - return $this->save();
117   - }
118   - }
119   -
120   - public function replace($article_id, $removeMedia = false)
121   - {
122   - $this->article_id = $article_id;
123   - if($removeMedia && !$this->getIsNewRecord()) {
124   - $article_media = ArticleMedia::find()->select('media_id')->where(['article_id' => $this->article_id, 'type' => $this->type, 'language_id' => $this->language_id])->column();
125   - $media = array();
126   - foreach($article_media as $media_id) {
127   - $media[] = Media::findOne(['media_id' => $media_id]);
128   - }
129   - $media = array_unique($media);
130   - foreach($media as $one_media) {
131   - if($one_media instanceof Media) {
132   - $one_media->delete();
133   - }
134   - }
135   - unset($media);
136   - unset($article_media);
137   - }
138   - if(is_array($this->imageFile)) {
139   - $ok = true;
140   - foreach($this->imageFile as $image) {
141   - $media_article = clone $this;
142   - $media = new Media();
143   - $media->imageFile = $image;
144   - $media->upload();
145   - $media_article->media_id = $media->media_id;
146   - $ok = $media_article->save() && $ok;
147   - unset($media_article);
148   - }
149   - return $ok;
150   - } elseif(!empty($this->imageFile)) {
151   - ArticleMedia::deleteAll(['article_id' => $this->article_id, 'type' => $this->type, 'language_id' => $this->language_id]);
152   - $media = new Media();
153   - $media->imageFile = $this->imageFile;
154   - $media->upload();
155   - $this->media_id = $media->media_id;
156   - $this->setIsNewRecord(true);
157   - return $this->save();
158   - }
159   - }
160   -
161   -}
common/modules/blog/models/ArticleToCategory.php deleted
1   -<?php
2   -
3   -namespace common\modules\blog\models;
4   -
5   -use Yii;
6   -
7   -/**
8   - * This is the model class for table "article_to_category".
9   - *
10   - * @property integer $article_id
11   - * @property integer $article_category_id
12   - *
13   - * @property Article $article
14   - * @property ArticleCategory $category
15   - */
16   -class ArticleToCategory extends \yii\db\ActiveRecord
17   -{
18   - /**
19   - * @inheritdoc
20   - */
21   - public static function tableName()
22   - {
23   - return 'article_to_category';
24   - }
25   -
26   - /**
27   - * @inheritdoc
28   - */
29   - public function rules()
30   - {
31   - return [
32   - [['article_id', 'article_category_id'], 'integer']
33   - ];
34   - }
35   -
36   - /**
37   - * @inheritdoc
38   - */
39   - public function attributeLabels()
40   - {
41   - return [
42   - 'article_id' => Yii::t('app', 'Article ID'),
43   - 'article_category_id' => Yii::t('app', 'Category ID'),
44   - ];
45   - }
46   -
47   - /**
48   - * @return \yii\db\ActiveQuery
49   - */
50   - public function getArticle()
51   - {
52   - return $this->hasOne(Article::className(), ['article_id' => 'article_id']);
53   - }
54   -
55   - /**
56   - * @return \yii\db\ActiveQuery
57   - */
58   - public function getCategory()
59   - {
60   - return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_id']);
61   - }
62   -}
common/modules/blog/views/ajax/_article_form.php deleted
1   -<?php
2   -
3   -use yii\bootstrap\ActiveField;
4   -use mihaildev\ckeditor\CKEditor;
5   -
6   -if(empty($form)) {
7   - $new_form = true;
8   - $form = \yii\bootstrap\ActiveForm::begin();
9   -}
10   -?>
11   -<div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>">
12   -
13   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?>
14   -
15   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?>
16   -
17   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]preview", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?>
18   -
19   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]seo_url"]))->textInput() ?>
20   -
21   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]name"]))->textInput() ?>
22   -
23   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]meta_title"]))->textInput() ?>
24   -
25   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?>
26   -
27   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]meta_keyword"]))->textInput() ?>
28   -
29   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?>
30   -
31   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]tag"]))->textInput() ?>
32   -
33   -</div>
34   -<?php
35   - if($new_form) {
36   - $form->end();
37   - }
38   -?>
common/modules/blog/views/ajax/_article_form_test.php deleted
1   -<?php
2   -
3   -use yii\bootstrap\ActiveField;
4   -use mihaildev\ckeditor\CKEditor;
5   - //ะ•ัะปะธ ัั‚ะพ ะฝะต AJAX ะทะฐะฟั€ะพั, ั‚ะพ ะฟะตั€ะตะผะตะฝะฝะฐั $form ะฑัƒะดะตั‚ ะพะฟั€ะตะดะตะปะตะฝะฐ ะธ ะฝะฐะผ ะฝะต ะฟั€ะธะดะตั‚ัั ะณะตะฝะตั€ะธั€ะพะฒะฐั‚ัŒ ั„ะพั€ะผัƒ.
6   -if(empty($form)) {
7   - $new_form = true;
8   - $form = \yii\bootstrap\ActiveForm::begin();
9   -}
10   -?>
11   -<div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>">
12   -
13   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?>
14   -
15   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?>
16   -
17   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]preview", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?>
18   -
19   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]seo_url"]))->textInput() ?>
20   -
21   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]name"]))->textInput() ?>
22   -
23   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]meta_title"]))->textInput() ?>
24   -
25   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?>
26   -
27   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]meta_keyword"]))->textInput() ?>
28   -
29   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?>
30   -
31   - <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]tag"]))->textInput() ?>
32   -
33   -</div>
34   -<?php
35   - if($new_form) {
36   - $form->end();
37   - }
38   -?>
common/modules/blog/views/ajax/_article_media_form.php deleted
1   -<?php
2   -
3   -use yii\bootstrap\ActiveField;
4   -use mihaildev\ckeditor\CKEditor;
5   -
6   -$form = \yii\bootstrap\ActiveForm::begin();
7   -?>
8   -<div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>">
9   -
10   - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?>
11   -
12   - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]imageFile"]))->fileInput(['class' => 'image_inputs_field']) ?>
13   -
14   -</div>
15   -<?php
16   -$form->end();
17   -?>
common/modules/blog/views/ajax/_category_form.php deleted
1   -<?php
2   -
3   -use yii\bootstrap\ActiveField;
4   -use mihaildev\ckeditor\CKEditor;
5   -
6   -$form = \yii\bootstrap\ActiveForm::begin();
7   -?>
8   -<div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>">
9   -
10   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?>
11   -
12   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?>
13   -
14   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]preview", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?>
15   -
16   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]seo_url"]))->textInput() ?>
17   -
18   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]name"]))->textInput() ?>
19   -
20   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]meta_title"]))->textInput() ?>
21   -
22   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?>
23   -
24   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]meta_keyword"]))->textInput() ?>
25   -
26   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?>
27   -
28   - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]tag"]))->textInput() ?>
29   -
30   -</div>
31   -<?php
32   -$form->end();
33   -?>
common/modules/blog/views/article/_form.php deleted
1   -<?php
2   -use common\modules\blog\models\ArticleCategory;
3   -use common\modules\blog\models\ArticleMedia;
4   -use common\widgets\Multilang;
5   - use common\widgets\Multilanguage;
6   - use yii\bootstrap\ActiveForm;
7   -use common\modules\blog\models\Article;
8   -use yii\bootstrap\Html;
9   -use mihaildev\ckeditor\CKEditor;
10   -use yii\helpers\Json;
11   -use yii\helpers\Url;
12   -use yii\widgets\Pjax;
13   -
14   -$def_lang = array_keys($langs)[0];
15   -$uploaddir = \Yii::getAlias('@saveImageDir');
16   -?>
17   -<div class="article-form">
18   -
19   - <?php $form = \yii\bootstrap\ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
20   -
21   - <?= $form->field($article, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?>
22   -
23   - <?= $form->field($article, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?>
24   -
25   - <?= $form->field($article, 'sort')->input('number') ?>
26   -
27   - <?= $form->field($article, 'article_pid')
28   - ->dropDownList(Article::findArticleDropdown($article->article_id), ['prompt' => Yii::t('app', 'Select parent')]) ?>
29   -
30   - <?= $form->field($article, 'articleCategoriesArray')
31   - ->dropDownList(ArticleCategory::findArticleCategoryDropdown(NULL), ['multiple' => 'multiple'])->label(\Yii::t('app', 'Article Categories Array')); ?>
32   -
33   - <?= $form->field($article, 'status')->checkbox() ?>
34   -
35   - <ul class="nav nav-tabs" id="image-tabs" role="tablist">
36   - <li role="image_inputs" class="active" data-type="full"><a href="#image-full" aria-controls="image-full" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'full')?></span></a></li>
37   - <li role="image_inputs" class="" data-type="preview"><a href="#image-preview" aria-controls="image-preview" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'preview')?></span></a></li>
38   - <li role="image_inputs" class="" data-type="additional"><a href="#image-additional" aria-controls="image-additional" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'additional')?></span></a></li>
39   - </ul>
40   - <div class="tab-content image-tab-content">
41   - <div role="" class="tab-pane active main-tab" id="image-full">
42   - <?php
43   - $imagelang = Multilang::begin([
44   - 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=full']),
45   - 'form' => $form,
46   - 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'full'])->indexBy('language_id')->all()
47   - ]);
48   - $first = 1;
49   - foreach($images as $lang => $value) {
50   - if(!array_key_exists('full', $value)) continue;
51   - ?>
52   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
53   - <?php
54   - echo $form->field($images[$lang]['full'], "[{$lang}][full]language_id")->label(false)->hiddenInput(['value' => $lang]);
55   - echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']);
56   - if(!empty($images[$lang]['full']->article_media_id)) {
57   - echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>";
58   - }
59   - ?>
60   - </div>
61   - <?php
62   - $first = 0;
63   - }
64   - $imagelang->end();
65   - ?>
66   - </div>
67   - <div role="" class="tab-pane" id="image-preview">
68   - <?php
69   - $imagelang = Multilang::begin([
70   - 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=preview']),
71   - 'form' => $form,
72   - 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'preview'])->indexBy('language_id')->all()
73   - ]);
74   - $first = 1;
75   - foreach($images as $lang => $value) {
76   - if(!array_key_exists('preview', $value)) continue;
77   - ?>
78   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
79   - <?php
80   - echo $form->field($images[$lang]['preview'], "[{$lang}][preview]language_id")->label(false)->hiddenInput(['value' => $lang]);
81   - echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']);
82   - if(!empty($images[$lang]['preview']->article_media_id)) {
83   - echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>";
84   - }
85   - ?>
86   - </div>
87   - <?php
88   - $first = 0;
89   - }
90   - $imagelang->end();
91   - ?>
92   - </div>
93   - <div role="" class="tab-pane" id="image-additional">
94   - <?php
95   - echo $form->field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
96   - if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) {
97   - foreach($images[0]['additional'] as $onefield => $oneimage) {
98   - if($onefield) {
99   - ?>
100   - <div class="additional_image_container">
101   - <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
102   - <a
103   - href="<?= Url::to(['ajax/remove-image']) ?>"
104   - class="remove_image glyphicon glyphicon-remove-circle"
105   - data-params='<?= Json::encode(['article_media_id' => $oneimage->article_media_id, 'remove_media' => true]) ?>',
106   - ></a>
107   - </div>
108   - <?php
109   - }
110   - }
111   - }
112   - ?>
113   - </div>
114   - </div>
115   -
116   - <hr>
117   -
118   - <?php
119   - echo Multilanguage::widget([
120   - 'data' => $article_langs,
121   - 'form' => $form,
122   - 'ajaxView' => '@common/modules/blog/views/ajax/_article_form',
123   - ]);
124   - /*
125   - $multilang = Multilang::begin(['ajaxpath' => Url::to(['/blog/ajax/article-form']), 'form' => $form, 'data_langs' => $article_langs]);
126   - ?>
127   - <?php
128   - $first = 1;
129   - foreach($article_langs as $index => $article_lang) {
130   - ?>
131   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$multilang->id?>-<?=$index?>">
132   -
133   - <?= $form->field($article_langs[$index], "[$index]language_id")->label(false)->hiddenInput(['value' => $index]) ?>
134   -
135   - <?= $form->field($article_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>
136   -
137   - <?= $form->field($article_langs[$index], "[$index]preview")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>
138   -
139   - <?= $form->field($article_langs[$index], "[$index]seo_url")->textInput() ?>
140   -
141   - <?= $form->field($article_langs[$index], "[$index]name")->textInput() ?>
142   -
143   - <?= $form->field($article_langs[$index], "[$index]meta_title")->textInput() ?>
144   -
145   - <?= $form->field($article_langs[$index], "[$index]meta_descr")->textarea(); ?>
146   -
147   - <?= $form->field($article_langs[$index], "[$index]meta_keywords")->textInput() ?>
148   -
149   - <?= $form->field($article_langs[$index], "[$index]h1_tag")->textInput() ?>
150   -
151   - <?= $form->field($article_langs[$index], "[$index]tags")->textInput() ?>
152   -
153   - </div>
154   - <?php
155   - $first = 0;
156   - }
157   - ?>
158   - <?php
159   - $multilang->end();
160   - */
161   - ?>
162   -
163   - <div class="form-group">
164   - <?= Html::submitButton($article->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $article->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
165   - </div>
166   -
167   - <?php ActiveForm::end(); ?>
168   -
169   -</div>
170   -<script>
171   - var confirm_message = '<?= \Yii::t('app', 'Remove image?') ?>';
172   -</script>
173 0 \ No newline at end of file
common/modules/blog/views/article/create.php deleted
1   -<?php
2   -use yii\helpers\Html;
3   -
4   -$this->title = Yii::t('app', 'Article create');
5   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Articles'), 'url' => ['index']];
6   -$this->params['breadcrumbs'][] = $this->title;
7   -?>
8   -<div class="article-create">
9   -
10   - <h1><?= Html::encode($this->title) ?></h1>
11   -
12   - <?= $this->render('_form', [
13   - 'article_langs' => $article_langs,
14   - 'article' => $article,
15   - 'langs' => $langs,
16   - 'images' => $images
17   - ]) ?>
18   -
19   -</div>
common/modules/blog/views/article/index.php deleted
1   -<?php
2   -use yii\grid\ActionColumn;
3   -use yii\grid\Column;
4   -use yii\grid\GridView;
5   -use common\modules\blog\models\Article;
6   -use common\models\Language;
7   -
8   -echo GridView::widget([
9   - 'dataProvider' => $dataProvider,
10   - 'columns' => [
11   - 'article_id',
12   - 'code',
13   - 'date_add',
14   - [
15   - 'value' => function($data) {
16   - return $data->user->firstname.' '.$data->user->lastname;
17   - },
18   - 'header' => Yii::t('app', 'Author')
19   - ],
20   - [
21   - 'class' => Column::className(),
22   - 'header' => Yii::t('app', 'Name'),
23   - 'content' => function($model, $key, $index, $column) {
24   - return $model->getArticleLangs()->where(['language_id' => Language::getDefaultLang()->language_id])->one()->name;
25   - }
26   - ],
27   - [
28   - 'class' => ActionColumn::className(),
29   - 'template' => '{update} {delete}'
30   - ]
31   - ]
32   -]);
33 0 \ No newline at end of file
common/modules/blog/views/article/update.php deleted
1   -<?php
2   -use yii\helpers\Html;
3   -
4   -$this->title = Yii::t('app', 'Article update');
5   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Articles'), 'url' => ['index']];
6   -$this->params['breadcrumbs'][] = $this->title;
7   -?>
8   -<div class="article-create">
9   -
10   - <h1><?= Html::encode($this->title) ?></h1>
11   - <?= $this->render('_form', [
12   - 'article_langs' => $article_langs,
13   - 'article' => $article,
14   - 'langs' => $langs,
15   - 'images' => $images
16   - ]) ?>
17   -
18   -</div>
common/modules/blog/views/category/_form.php deleted
1   -<?php
2   -use common\modules\blog\models\ArticleCategoryMedia;
3   -use common\widgets\Multilang;
4   -use yii\bootstrap\ActiveForm;
5   -use common\modules\blog\models\ArticleCategory;
6   -use yii\bootstrap\Html;
7   -use mihaildev\ckeditor\CKEditor;
8   -use yii\helpers\Json;
9   -use yii\helpers\Url;
10   -
11   -$def_lang = array_keys($langs)[0];
12   -$uploaddir = \Yii::getAlias('@saveImageDir');
13   -?>
14   -<div class="category-form">
15   -
16   - <?php $form = \yii\bootstrap\ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
17   -
18   - <?= $form->field($category, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?>
19   -
20   - <?= $form->field($category, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?>
21   -
22   - <?= $form->field($category, 'sort')->input('number') ?>
23   -
24   - <?= $form->field($category, 'article_category_pid')
25   - ->dropDownList(ArticleCategory::findArticleCategoryDropdown($category->article_category_id), ['prompt' => Yii::t('app', 'Select parent')]) ?>
26   -
27   - <?= $form->field($category, 'status')->checkbox() ?>
28   -
29   - <ul class="nav nav-tabs" id="image-tabs" role="tablist">
30   - <li role="image_inputs" class="active" data-type="full"><a href="#image-full" aria-controls="image-full" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'full')?></span></a></li>
31   - <li role="image_inputs" class="" data-type="preview"><a href="#image-preview" aria-controls="image-preview" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'preview')?></span></a></li>
32   - <li role="image_inputs" class="" data-type="additional"><a href="#image-additional" aria-controls="image-additional" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'additional')?></span></a></li>
33   - </ul>
34   - <div class="tab-content image-tab-content">
35   - <div role="" class="tab-pane active main-tab" id="image-full">
36   - <?php
37   - $imagelang = Multilang::begin([
38   - 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=full']),
39   - 'form' => $form,
40   - 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'full'])->indexBy('language_id')->all()
41   - ]);
42   - $first = 1;
43   - foreach($images as $lang => $value) {
44   - if(!array_key_exists('full', $value)) continue;
45   - ?>
46   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
47   - <?php
48   - echo $form->field($images[$lang]['full'], "[{$lang}][full]language_id")->label(false)->hiddenInput(['value' => $lang]);
49   - echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']);
50   - if(!empty($images[$lang]['full']->article_category_media_id)) {
51   - echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>";
52   - }
53   - ?>
54   - </div>
55   - <?php
56   - $first = 0;
57   - }
58   - $imagelang->end();
59   - ?>
60   - </div>
61   - <div role="" class="tab-pane" id="image-preview">
62   - <?php
63   - $imagelang = Multilang::begin([
64   - 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=preview']),
65   - 'form' => $form,
66   - 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'preview'])->indexBy('language_id')->all()
67   - ]);
68   - $first = 1;
69   - foreach($images as $lang => $value) {
70   - if(!array_key_exists('preview', $value)) continue;
71   - ?>
72   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
73   - <?php
74   - echo $form->field($images[$lang]['preview'], "[{$lang}][preview]language_id")->label(false)->hiddenInput(['value' => $lang]);
75   - echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']);
76   - if(!empty($images[$lang]['preview']->article_category_media_id)) {
77   - echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>";
78   - }
79   - ?>
80   - </div>
81   - <?php
82   - $first = 0;
83   - }
84   - $imagelang->end();
85   - ?>
86   - </div>
87   - <div role="" class="tab-pane" id="image-additional">
88   - <?php
89   - echo $form->field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
90   - if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) {
91   - foreach($images[0]['additional'] as $onefield => $oneimage) {
92   - if($onefield) {
93   - ?>
94   - <div class="additional_image_container">
95   - <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
96   - <a
97   - href="<?= Url::to(['ajax/remove-image']) ?>"
98   - class="remove_image glyphicon glyphicon-remove-circle"
99   - data-params='<?= Json::encode(['article_category_media_id' => $oneimage->article_category_media_id, 'remove_media' => true]) ?>',
100   - ></a>
101   - </div>
102   - <?php
103   - }
104   - }
105   - }
106   - ?>
107   - </div>
108   - </div>
109   -
110   - <hr>
111   -
112   - <?php
113   - $multilang = Multilang::begin(['ajaxpath' => Url::to(['/blog/ajax/category-form']), 'form' => $form, 'data_langs' => $category_langs])
114   - ?>
115   - <?php
116   - $first = 1;
117   - foreach($category_langs as $index => $category_lang) {
118   - ?>
119   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="lang-<?=$index?>">
120   - <?= $form->field($category_langs[$index], "[$index]language_id")->label(false)->hiddenInput(['value' => $index]) ?>
121   -
122   - <?= $form->field($category_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>
123   -
124   - <?= $form->field($category_langs[$index], "[$index]preview")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>
125   -
126   - <?= $form->field($category_langs[$index], "[$index]seo_url")->textInput() ?>
127   -
128   - <?= $form->field($category_langs[$index], "[$index]name")->textInput() ?>
129   -
130   - <?= $form->field($category_langs[$index], "[$index]meta_title")->textInput() ?>
131   -
132   - <?= $form->field($category_langs[$index], "[$index]meta_descr")->textarea(); ?>
133   -
134   - <?= $form->field($category_langs[$index], "[$index]meta_keyword")->textInput() ?>
135   -
136   - <?= $form->field($category_langs[$index], "[$index]h1_tag")->textInput() ?>
137   -
138   - <?= $form->field($category_langs[$index], "[$index]tag")->textInput() ?>
139   -
140   - </div>
141   - <?php
142   - $first = 0;
143   - }
144   - ?>
145   - <?php
146   - $multilang->end();
147   - ?>
148   -
149   - <div class="form-group">
150   - <?= Html::submitButton($category->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $category->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
151   - </div>
152   -
153   - <?php ActiveForm::end(); ?>
154   -
155   -</div>
156   -<script>
157   - var confirm_message = '<?= \Yii::t('app', 'Remove image?') ?>';
158   -</script>
159 0 \ No newline at end of file
common/modules/blog/views/category/create.php deleted
1   -<?php
2   -use yii\helpers\Html;
3   -
4   -$this->title = Yii::t('app', 'Category create');
5   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Categories'), 'url' => ['index']];
6   -$this->params['breadcrumbs'][] = $this->title;
7   -?>
8   -<div class="category-create">
9   -
10   - <h1><?= Html::encode($this->title) ?></h1>
11   -
12   - <?= $this->render('_form', [
13   - 'category_langs' => $category_langs,
14   - 'category' => $category,
15   - 'langs' => $langs,
16   - 'images' => $images
17   - ]) ?>
18   -
19   -</div>
common/modules/blog/views/category/index.php deleted
1   -<?php
2   -use yii\grid\ActionColumn;
3   -use yii\grid\Column;
4   -use yii\grid\GridView;
5   -use common\modules\blog\models\Article;
6   -use common\models\Language;
7   -echo GridView::widget([
8   - 'dataProvider' => $dataProvider,
9   - 'columns' => [
10   - 'article_category_id',
11   - 'code',
12   - 'date_add',
13   - 'date_update',
14   - [
15   - 'class' => Column::className(),
16   - 'header' => Yii::t('app', 'Name'),
17   - 'content' => function($model, $key, $index, $column) {
18   - return $model->getArticleCategoryLangs()->orderBy(['language_id' => 'ASC'])->one()->name;
19   - }
20   - ],
21   - [
22   - 'class' => ActionColumn::className(),
23   - 'template' => '{update} {delete}'
24   - ]
25   - ]
26   -]);
27 0 \ No newline at end of file
common/modules/blog/views/category/update.php deleted
1   -<?php
2   -use yii\helpers\Html;
3   -
4   -$this->title = Yii::t('app', 'Update category');
5   -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Categories'), 'url' => ['index']];
6   -$this->params['breadcrumbs'][] = $this->title;
7   -?>
8   -<div class="category-create">
9   -
10   - <h1><?= Html::encode($this->title) ?></h1>
11   - <?= $this->render('_form', [
12   - 'category_langs' => $category_langs,
13   - 'category' => $category,
14   - 'langs' => $langs,
15   - 'images' => $images
16   - ]) ?>
17   -
18   -</div>
common/modules/blog/views/default/index.php deleted
1   -<?php
2   -
3   -use yii\behaviors\BlameableBehavior;
4   -use yii\web\Application;
5   -
6   -$behavior = new BlameableBehavior();
7   -var_dump($behavior->value);
8 0 \ No newline at end of file
common/modules/blog/views/media/index.php deleted
1   -<?php
2   -
3   -use yii\bootstrap\ActiveForm;
4   -use yii\bootstrap\Html;
5   -
6   -$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
7   -
8   -echo $form->field($model, 'imageFile')->fileInput(['multiple' => 'multiple']);
9   -
10   -?>
11   - <img id="blah" src="#" alt="your image">
12   -<div class="form-group">
13   - <?= Html::submitButton(Yii::t('app', 'Create'), ['class' => 'btn btn-success']) ?>
14   -</div>
15   -<?php
16   -ActiveForm::end();
17   -?>
18   -<script>
19   - function readURL(input) {
20   - if (input.files && input.files[1]) {
21   - var reader = new FileReader();
22   -
23   - reader.onload = function (e) {
24   - $('#blah')
25   - .attr('src', e.target.result)
26   - .width(150);
27   - };
28   -
29   - reader.readAsDataURL(input.files[1]);
30   - }
31   - }
32   - $(function() {
33   - $(document).on('change', 'input[type=file]', function() {
34   - readURL(this);
35   - });
36   - });
37   -</script>
common/modules/blog/views/test/index.php deleted
1   -<?php
2   - use common\widgets\Multilanguage;
3   - use yii\bootstrap\ActiveForm;
4   -
5   -$form = ActiveForm::begin();
6   -echo Multilanguage::widget([
7   - 'data' => $model,
8   - 'form' => $form,
9   - 'ajaxView' => '@common/modules/blog/views/ajax/_article_form_test',
10   -]);
11   -$form->end();
12 0 \ No newline at end of file
common/modules/product/CatalogUrlManager.php
... ... @@ -5,8 +5,6 @@ namespace common\modules\product;
5 5  
6 6 use common\modules\product\models\CategorySearch;
7 7 use common\modules\product\models\ProductSearch;
8   -
9   -use Yii;
10 8 use yii\helpers\Url;
11 9 use yii\web\HttpException;
12 10 use yii\web\UrlRuleInterface;
... ...
common/modules/product/behaviors/FilterBehavior.php
... ... @@ -4,18 +4,20 @@ namespace common\modules\product\behaviors;
4 4  
5 5  
6 6 use common\modules\product\models\ProductOption;
7   -use common\modules\rubrication\models\TaxGroup;
8 7 use common\modules\rubrication\models\TaxOption;
9 8 use yii\base\Behavior;
10   -
11   -use Yii;
12   -
  9 +use yii\db\ActiveRecord;
13 10  
14 11 class FilterBehavior extends Behavior {
15 12  
16 13 public function getFilters(){
17   -
18   - return $this->owner->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id'])
  14 +
  15 + /**
  16 + * @var ActiveRecord $owner
  17 + */
  18 + $owner = $this->owner;
  19 +
  20 + return $owner->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id'])
19 21 ->viaTable(ProductOption::tableName(),[ 'product_id'=> $this->owner->tableSchema->primaryKey[0]])
20 22 ->joinWith('taxGroup')->all();
21 23 }
... ...
common/modules/product/controllers/ManageController.php
1 1 <?php
2   -
3   -namespace common\modules\product\controllers;
4   -
5   -use common\modules\product\helpers\ProductHelper;
6   -use common\modules\product\models\Category;
7   -use common\modules\product\models\Export;
8   -use common\modules\product\models\Import;
9   -use common\modules\product\models\ProductImage;
10   -use common\modules\product\models\ProductVariant;
11   -use Yii;
12   -use common\modules\product\models\Product;
13   -use common\modules\product\models\ProductSearch;
14   -use yii\web\Controller;
15   -use yii\web\NotFoundHttpException;
16   -use yii\filters\VerbFilter;
17   -use common\modules\product\models\Brand;
18   -use yii\web\UploadedFile;
19   -
20   -/**
21   - * ManageController implements the CRUD actions for Product model.
22   - */
23   -class ManageController extends Controller
24   -{
  2 +
  3 + namespace common\modules\product\controllers;
  4 +
  5 + use common\modules\product\models\Export;
  6 + use common\modules\product\models\Import;
  7 + use common\modules\product\models\ProductImage;
  8 + use common\modules\product\models\ProductVariant;
  9 + use Yii;
  10 + use common\modules\product\models\Product;
  11 + use common\modules\product\models\ProductSearch;
  12 + use yii\web\Controller;
  13 + use yii\web\NotFoundHttpException;
  14 + use yii\filters\VerbFilter;
  15 + use yii\web\UploadedFile;
  16 +
25 17 /**
26   - * @inheritdoc
  18 + * ManageController implements the CRUD actions for Product model.
27 19 */
28   - public function behaviors()
  20 + class ManageController extends Controller
29 21 {
30   - return [
31   - 'verbs' => [
32   - 'class' => VerbFilter::className(),
33   - 'actions' => [
34   - 'delete' => ['POST'],
  22 +
  23 + /**
  24 + * @inheritdoc
  25 + */
  26 + public function behaviors()
  27 + {
  28 + return [
  29 + 'verbs' => [
  30 + 'class' => VerbFilter::className(),
  31 + 'actions' => [
  32 + 'delete' => [ 'POST' ],
  33 + ],
35 34 ],
36   - ],
37   - ];
38   - }
39   -
40   - public function actionDev() {
41   - foreach (ProductVariant::find()->where(['>', 'price_old', 0])->all() as $item) {
42   - if ($item->price >= $item->price_old || $item->price == 0)
43   - print $item->price .' | '. $item->price_old ."<br>\n";
  35 + ];
  36 + }
  37 +
  38 + public function actionDev()
  39 + {
  40 + foreach(ProductVariant::find()
  41 + ->where([
  42 + '>',
  43 + 'price_old',
  44 + 0,
  45 + ])
  46 + ->all() as $item) {
  47 + if($item->price >= $item->price_old || $item->price == 0) {
  48 + print $item->price . ' | ' . $item->price_old . "<br>\n";
  49 + }
  50 + }
  51 + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~';
44 52 }
45   - print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~';
46   - }
47   -
48   - /**
49   - * Lists all Product models.
50   - * @return mixed
51   - */
52   - public function actionIndex()
53   - {
54   - $searchModel = new ProductSearch();
55   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
56   -
57   - return $this->render('index', [
58   - 'searchModel' => $searchModel,
59   - 'dataProvider' => $dataProvider,
60   - ]);
61   - }
62   -
63   - /**
64   - * Displays a single Product model.
65   - * @param integer $id
66   - * @return mixed
67   - */
68   - public function actionView($id)
69   - {
70   - return $this->render('view', [
71   - 'model' => $this->findModel($id),
72   - ]);
73   - }
74   -
75   - /**
76   - * Creates a new Product model.
77   - * If creation is successful, the browser will be redirected to the 'view' page.
78   - * @return mixed
79   - */
80   - public function actionCreate()
81   - {
82   - $model = new Product();
83 53  
84   - if ($model->load(Yii::$app->request->post())) {
85   - $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload');
86   -
87   - if ($model->save() && $model->imagesUpload) {
88   -
89   - $imgDir = Yii::getAlias('@storage/articles/');
90   -
91   - if ( ($images = $model->imagesUpload()) !== FALSE) {
92   - foreach ($images as $image) {
93   - $imageModel = new ProductImage();
94   - $imageModel->product_id = $model->product_id;
95   - $imageModel->image = $image;
96   - $imageModel->save();
  54 + /**
  55 + * Lists all Product models.
  56 + * @return mixed
  57 + */
  58 + public function actionIndex()
  59 + {
  60 + $searchModel = new ProductSearch();
  61 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  62 +
  63 + return $this->render('index', [
  64 + 'searchModel' => $searchModel,
  65 + 'dataProvider' => $dataProvider,
  66 + ]);
  67 + }
  68 +
  69 + /**
  70 + * Displays a single Product model.
  71 + *
  72 + * @param integer $id
  73 + *
  74 + * @return mixed
  75 + */
  76 + public function actionView($id)
  77 + {
  78 + return $this->render('view', [
  79 + 'model' => $this->findModel($id),
  80 + ]);
  81 + }
  82 +
  83 + /**
  84 + * Creates a new Product model.
  85 + * If creation is successful, the browser will be redirected to the 'view' page.
  86 + * @return mixed
  87 + */
  88 + public function actionCreate()
  89 + {
  90 + $model = new Product();
  91 +
  92 + if($model->load(Yii::$app->request->post())) {
  93 + $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload');
  94 +
  95 + if($model->save()) {
  96 +
  97 + if(!empty( $model->imagesUpload ) && ( ( $images = $model->imagesUpload() ) !== false )) {
  98 + foreach($images as $image) {
  99 + $imageModel = new ProductImage();
  100 + $imageModel->product_id = $model->product_id;
  101 + $imageModel->image = $image;
  102 + $imageModel->save();
  103 + }
97 104 }
  105 +
  106 + return $this->redirect([
  107 + 'view',
  108 + 'id' => $model->product_id,
  109 + ]);
98 110 }
99   -
100   - return $this->redirect(['view', 'id' => $model->product_id]);
101 111 }
102   - } else {
103 112 return $this->render('create', [
104 113 'model' => $model,
105 114 ]);
106 115 }
107   - }
108   -
109   - /**
110   - * Updates an existing Product model.
111   - * If update is successful, the browser will be redirected to the 'view' page.
112   - * @param integer $id
113   - * @return mixed
114   - */
115   - public function actionUpdate($id)
116   - {
117   - $model = $this->findModel($id);
118   - if ($model->load(Yii::$app->request->post())) {
119   - $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload');
120   - if ($model->save()) {
121   -// foreach ($model->images as $image) {
122   -// $image->delete();
123   -// }
124   - if ( ($images = $model->imagesUpload()) !== FALSE) {
125   - foreach ($images as $image) {
126   - $imageModel = new ProductImage();
127   - $imageModel->product_id = $model->product_id;
128   - $imageModel->image = $image;
129   - $imageModel->save();
  116 +
  117 + /**
  118 + * Updates an existing Product model.
  119 + * If update is successful, the browser will be redirected to the 'view' page.
  120 + *
  121 + * @param integer $id
  122 + *
  123 + * @return mixed
  124 + */
  125 + public function actionUpdate($id)
  126 + {
  127 + $model = $this->findModel($id);
  128 + if($model->load(Yii::$app->request->post())) {
  129 + $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload');
  130 + if($model->save()) {
  131 + if(!empty( $model->imagesUpload ) && ( ( $images = $model->imagesUpload() ) !== false )) {
  132 + foreach($images as $image) {
  133 + $imageModel = new ProductImage();
  134 + $imageModel->product_id = $model->product_id;
  135 + $imageModel->image = $image;
  136 + $imageModel->save();
  137 + }
130 138 }
  139 +
  140 + return $this->redirect([
  141 + 'view',
  142 + 'id' => $model->product_id,
  143 + ]);
131 144 }
132   -
133   - return $this->redirect(['view', 'id' => $model->product_id]);
134 145 }
135   - } else {
136 146 $groups = $model->getTaxGroupsByLevel(0);
137   -
  147 +
138 148 return $this->render('update', [
139   - 'model' => $model,
  149 + 'model' => $model,
140 150 'groups' => $groups,
141 151 ]);
142 152 }
143   - }
144   -
145   - /**
146   - * Deletes an existing Product model.
147   - * If deletion is successful, the browser will be redirected to the 'index' page.
148   - * @param integer $id
149   - * @return mixed
150   - */
151   - public function actionDelete($id)
152   - {
153   - $this->findModel($id)->delete();
154   -
155   - return $this->redirect(['index']);
156   - }
157   -
158   - public function actionDelimg($id)
159   - {
160   - $image = ProductImage::findOne($id);
161   -
162   - if ($image) {
163   - $image->delete();
  153 +
  154 + /**
  155 + * Deletes an existing Product model.
  156 + * If deletion is successful, the browser will be redirected to the 'index' page.
  157 + *
  158 + * @param integer $id
  159 + *
  160 + * @return mixed
  161 + */
  162 + public function actionDelete($id)
  163 + {
  164 + $this->findModel($id)
  165 + ->delete();
  166 +
  167 + return $this->redirect([ 'index' ]);
164 168 }
165   -
166   - print '1';
167   - exit;
168   - }
169   -
170   - public function actionIs_top($id) {
171   - $model = $this->findModel($id);
172   -
173   - $model->is_top = intval(empty($model->is_top));
174   -
175   - $model->save(false, ['is_top']);
176   -
177   - return $this->redirect(['index']);
178   - }
179   -
180   - public function actionIs_new($id) {
181   - $model = $this->findModel($id);
182   -
183   - $model->is_new = intval(empty($model->is_new));
184   -
185   - $model->save(false, ['is_new']);
186   -
187   - return $this->redirect(['index']);
188   - }
189   -
190   - public function actionAkciya($id) {
191   - $model = $this->findModel($id);
192   -
193   - $model->akciya = intval(empty($model->akciya));
194   -
195   - $model->save(false, ['akciya']);
196   -
197   - return $this->redirect(['index']);
198   - }
199   -
200   - public function actionImport() {
201   - $model = new Import();
202   -
203   - if ($model->load(Yii::$app->request->post())) {
204   - $file = UploadedFile::getInstances($model, 'file');
205   - $method = 'go'. ucfirst($model->type);
206   - $target = Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFile'. ucfirst($model->type));
207   - if (empty($file)) {
208   - $model->errors[] = 'File not upload';
209   - } elseif ($method == 'goPrices' && $file[0]->name != 'file_1.csv') {
210   - $model->errors[] = 'File need "file_1.csv"';
211   - } elseif ($method == 'goProducts' && $file[0]->name == 'file_1.csv') {
212   - $model->errors[] = 'File can not "file_1.csv"';
213   - } elseif ($model->validate() && $file[0]->saveAs($target)) {
214   - // PROCESS PAGE
215   - return $this->render('import-process', [
216   - 'model' => $model,
217   - 'method' => $model->type,
218   - 'target' => $target,
219   - ]);
220   -// $model->$method();
221   - } else {
222   - $model->errors[] = 'File can not be upload or other error';
  169 +
  170 + public function actionDelimg($id)
  171 + {
  172 + $image = ProductImage::findOne($id);
  173 +
  174 + if($image) {
  175 + $image->delete();
223 176 }
  177 +
  178 + print '1';
  179 + exit;
224 180 }
225   -
226   - return $this->render('import', [
227   - 'model' => $model,
228   - ]);
229   - }
230   -
231   - public function actionProducts() {
232   - $from = Yii::$app->request->get('from', 0);
233   -
234   - $model = new Import();
235   -
236   - if (Yii::$app->request->isAjax) {
237   - Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
238   - return $model->goProducts($from, 10);
  181 +
  182 + public function actionIs_top($id)
  183 + {
  184 + $model = $this->findModel($id);
  185 +
  186 + $model->is_top = intval(empty( $model->is_top ));
  187 +
  188 + $model->save(false, [ 'is_top' ]);
  189 +
  190 + return $this->redirect([ 'index' ]);
239 191 }
240   - }
241   -
242   - public function actionPrices() {
243   - $from = Yii::$app->request->get('from', 0);
244   -
245   - $model = new Import();
246   -
247   - if (Yii::$app->request->isAjax) {
248   - Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
249   - return $model->goPrices($from, 10);
  192 +
  193 + public function actionIs_new($id)
  194 + {
  195 + $model = $this->findModel($id);
  196 +
  197 + $model->is_new = intval(empty( $model->is_new ));
  198 +
  199 + $model->save(false, [ 'is_new' ]);
  200 +
  201 + return $this->redirect([ 'index' ]);
250 202 }
251   - }
252   -
253   - public function actionExport() {
254   - $model = new Export();
255   - if (($file = $model->process(Yii::getAlias('@uploadDir')))) {
256   - return Yii::$app->response->sendFile($file)->send();
  203 +
  204 + public function actionAkciya($id)
  205 + {
  206 + $model = $this->findModel($id);
  207 +
  208 + $model->akciya = intval(empty( $model->akciya ));
  209 +
  210 + $model->save(false, [ 'akciya' ]);
  211 +
  212 + return $this->redirect([ 'index' ]);
257 213 }
258   - throw new NotFoundHttpException('Error');
259   - }
260   -
261   - /**
262   - * Finds the Product model based on its primary key value.
263   - * If the model is not found, a 404 HTTP exception will be thrown.
264   - * @param integer $id
265   - * @return Product the loaded model
266   - * @throws NotFoundHttpException if the model cannot be found
267   - */
268   - protected function findModel($id)
269   - {
270   - if (($model = Product::findOne($id)) !== null) {
271   - return $model;
272   - } else {
273   - throw new NotFoundHttpException('The requested page does not exist.');
  214 +
  215 + public function actionImport()
  216 + {
  217 + $model = new Import();
  218 +
  219 + if($model->load(Yii::$app->request->post())) {
  220 + $file = UploadedFile::getInstances($model, 'file');
  221 + $method = 'go' . ucfirst($model->type);
  222 + $target = Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFile' . ucfirst($model->type));
  223 + if(empty( $file )) {
  224 + $model->errors[] = 'File not upload';
  225 + } elseif($method == 'goPrices' && $file[ 0 ]->name != 'file_1.csv') {
  226 + $model->errors[] = 'File need "file_1.csv"';
  227 + } elseif($method == 'goProducts' && $file[ 0 ]->name == 'file_1.csv') {
  228 + $model->errors[] = 'File can not "file_1.csv"';
  229 + } elseif($model->validate() && $file[ 0 ]->saveAs($target)) {
  230 + // PROCESS PAGE
  231 + return $this->render('import-process', [
  232 + 'model' => $model,
  233 + 'method' => $model->type,
  234 + 'target' => $target,
  235 + ]);
  236 + // $model->$method();
  237 + } else {
  238 + $model->errors[] = 'File can not be upload or other error';
  239 + }
  240 + }
  241 +
  242 + return $this->render('import', [
  243 + 'model' => $model,
  244 + ]);
  245 + }
  246 +
  247 + public function actionProducts()
  248 + {
  249 + $from = Yii::$app->request->get('from', 0);
  250 +
  251 + $model = new Import();
  252 +
  253 + if(Yii::$app->request->isAjax) {
  254 + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
  255 + return $model->goProducts($from, 10);
  256 + }
  257 + }
  258 +
  259 + public function actionPrices()
  260 + {
  261 + $from = Yii::$app->request->get('from', 0);
  262 +
  263 + $model = new Import();
  264 +
  265 + if(Yii::$app->request->isAjax) {
  266 + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
  267 + return $model->goPrices($from, 10);
  268 + }
  269 + }
  270 +
  271 + public function actionExport()
  272 + {
  273 + $model = new Export();
  274 + if(( $file = $model->process(Yii::getAlias('@uploadDir')) )) {
  275 + return Yii::$app->response->sendFile($file)
  276 + ->send();
  277 + }
  278 + throw new NotFoundHttpException('Error');
  279 + }
  280 +
  281 + /**
  282 + * Finds the Product model based on its primary key value.
  283 + * If the model is not found, a 404 HTTP exception will be thrown.
  284 + *
  285 + * @param integer $id
  286 + *
  287 + * @return Product the loaded model
  288 + * @throws NotFoundHttpException if the model cannot be found
  289 + */
  290 + protected function findModel($id)
  291 + {
  292 + if(( $model = Product::findOne($id) ) !== NULL) {
  293 + return $model;
  294 + } else {
  295 + throw new NotFoundHttpException('The requested page does not exist.');
  296 + }
274 297 }
275 298 }
276   -}
... ...
common/modules/product/controllers/ProductVariantTypeController.php deleted
1   -<?php
2   -
3   -namespace common\modules\product\controllers;
4   -
5   -use Yii;
6   -use common\modules\product\models\ProductVariantType;
7   -use common\modules\product\models\ProductVariantTypeSearch;
8   -use yii\web\Controller;
9   -use yii\web\NotFoundHttpException;
10   -use yii\filters\VerbFilter;
11   -
12   -/**
13   - * ProductVariantTypeController implements the CRUD actions for ProductVariantType model.
14   - */
15   -class ProductVariantTypeController extends Controller
16   -{
17   - /**
18   - * @inheritdoc
19   - */
20   - public function behaviors()
21   - {
22   - return [
23   - 'verbs' => [
24   - 'class' => VerbFilter::className(),
25   - 'actions' => [
26   - 'delete' => ['POST'],
27   - ],
28   - ],
29   - ];
30   - }
31   -
32   - /**
33   - * Lists all ProductVariantType models.
34   - * @return mixed
35   - */
36   - public function actionIndex()
37   - {
38   - $searchModel = new ProductVariantTypeSearch();
39   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
40   -
41   - return $this->render('index', [
42   - 'searchModel' => $searchModel,
43   - 'dataProvider' => $dataProvider,
44   - ]);
45   - }
46   -
47   - /**
48   - * Displays a single ProductVariantType model.
49   - * @param integer $id
50   - * @return mixed
51   - */
52   - public function actionView($id)
53   - {
54   - return $this->render('view', [
55   - 'model' => $this->findModel($id),
56   - ]);
57   - }
58   -
59   - /**
60   - * Creates a new ProductVariantType model.
61   - * If creation is successful, the browser will be redirected to the 'view' page.
62   - * @return mixed
63   - */
64   - public function actionCreate()
65   - {
66   - $model = new ProductVariantType();
67   -
68   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
69   - return $this->redirect(['view', 'id' => $model->product_variant_type_id]);
70   - } else {
71   - return $this->render('create', [
72   - 'model' => $model,
73   - ]);
74   - }
75   - }
76   -
77   - /**
78   - * Updates an existing ProductVariantType model.
79   - * If update is successful, the browser will be redirected to the 'view' page.
80   - * @param integer $id
81   - * @return mixed
82   - */
83   - public function actionUpdate($id)
84   - {
85   - $model = $this->findModel($id);
86   -
87   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
88   - return $this->redirect(['view', 'id' => $model->product_variant_type_id]);
89   - } else {
90   - return $this->render('update', [
91   - 'model' => $model,
92   - ]);
93   - }
94   - }
95   -
96   - /**
97   - * Deletes an existing ProductVariantType model.
98   - * If deletion is successful, the browser will be redirected to the 'index' page.
99   - * @param integer $id
100   - * @return mixed
101   - */
102   - public function actionDelete($id)
103   - {
104   - $this->findModel($id)->delete();
105   -
106   - return $this->redirect(['index']);
107   - }
108   -
109   - /**
110   - * Finds the ProductVariantType model based on its primary key value.
111   - * If the model is not found, a 404 HTTP exception will be thrown.
112   - * @param integer $id
113   - * @return ProductVariantType the loaded model
114   - * @throws NotFoundHttpException if the model cannot be found
115   - */
116   - protected function findModel($id)
117   - {
118   - if (($model = ProductVariantType::findOne($id)) !== null) {
119   - return $model;
120   - } else {
121   - throw new NotFoundHttpException('The requested page does not exist.');
122   - }
123   - }
124   -}
common/modules/product/controllers/VariantController.php
... ... @@ -9,6 +9,7 @@ use common\modules\product\models\ProductVariant;
9 9 use common\modules\product\models\ProductVariantListSearch;
10 10 use common\modules\product\models\Stock;
11 11 use Yii;
  12 +use yii\helpers\ArrayHelper;
12 13 use yii\web\Controller;
13 14 use yii\web\NotFoundHttpException;
14 15 use yii\filters\VerbFilter;
... ... @@ -82,16 +83,80 @@ class VariantController extends Controller
82 83 $model->validate();
83 84  
84 85 if ($model->save()) {
85   -
86   - if ( ($images = $model->imagesUpload()) !== FALSE) {
87   - foreach ($images as $image) {
  86 +
  87 + if ( ($image = UploadedFile::getInstance($model, 'image')) ) {
  88 + $imageModel = ProductImage::find()->where(['product_variant_id' => $model->product_variant_id])->one();
  89 +
  90 + if($imageModel instanceof ProductImage) {
  91 + $imageModel->product_id = $model->product_id;
  92 + $imageModel->product_variant_id = $model->product_variant_id;
  93 + $imageModel->image = $image->name;
  94 + $imageModel->save();
  95 + } else {
88 96 $imageModel = new ProductImage();
89 97 $imageModel->product_id = $model->product_id;
90 98 $imageModel->product_variant_id = $model->product_variant_id;
91   - $imageModel->image = $image;
  99 + $imageModel->image = $image->name;
92 100 $imageModel->save();
93 101 }
  102 +
  103 +
  104 + $imgDir = Yii::getAlias('@storage/products/');
  105 +
  106 + if(!is_dir($imgDir)) {
  107 + mkdir($imgDir, 0755, true);
  108 + }
  109 +
  110 + $image->saveAs(Yii::getAlias('@storage/products/' . $image->name));
  111 + }
  112 +
  113 + $ProductStocks = Yii::$app->request->post('ProductStock');
  114 +
  115 + $total_quantity = 0;
  116 +
  117 + if(!empty($ProductStocks) && is_array($ProductStocks)) {
  118 + $model->unlinkAll('stocks', true);
  119 + $sorted_array = [];
  120 + foreach ($ProductStocks as $subArray) {
  121 + if(!empty($subArray['name']) && !empty($subArray['quantity'])) {
  122 + if(!empty($sorted_array[$subArray['name']])) {
  123 + $sorted_array[$subArray['name']] += $subArray['quantity'];
  124 + } else {
  125 + $sorted_array[$subArray['name']] = $subArray['quantity'];
  126 + }
  127 + }
  128 + }
  129 + $ProductStocks = $sorted_array;
  130 + $stock_names = array_keys($ProductStocks);
  131 + $stocks = Stock::find()->where(['name' => $stock_names])->indexBy('name')->one();
  132 + foreach($ProductStocks as $name => $quantity) {
  133 + $quantity = (int) $quantity;
  134 + if(!array_key_exists($name, $stocks)) {
  135 + $stock = new Stock([
  136 + 'name' => $name
  137 + ]);
  138 + if(!$stock->save()) {
  139 + continue;
  140 + }
  141 + } else {
  142 + $stock = $stocks[$name];
  143 + }
  144 + $psModel = new ProductStock([
  145 + 'product_id' => $model->product_id,
  146 + 'product_variant_id' => $model->product_variant_id,
  147 + 'stock_id' => $stock->stock_id,
  148 + 'quantity' => $quantity,
  149 + ]);
  150 + if($psModel->save()) {
  151 + $total_quantity += $quantity;
  152 + }
  153 + }
  154 + } else {
  155 + $model->unlinkAll('stocks', true);
94 156 }
  157 +
  158 + $model->stock = $total_quantity;
  159 + $model->save();
95 160  
96 161 return $this->redirect(['index', 'product_id' => $product_id]);
97 162 }
... ... @@ -150,41 +215,50 @@ class VariantController extends Controller
150 215  
151 216 $ProductStocks = Yii::$app->request->post('ProductStock');
152 217  
153   - $quantity = 0;
154   -
155   - if(is_array($ProductStocks)){
156   -
157   - foreach($ProductStocks as $index => $ProductStock){
158   - $stock = Stock::find()->where(['name'=>$ProductStock['name']])->one();
159   - if(!$stock instanceof Stock){
160   - $stock = new Stock();
161   - $stock->name = $ProductStock['name'];
162   - $stock->save();
  218 + $total_quantity = 0;
  219 +
  220 + if(!empty($ProductStocks) && is_array($ProductStocks)) {
  221 + $model->unlinkAll('stocks', true);
  222 + $sorted_array = [];
  223 + foreach ($ProductStocks as $subArray) {
  224 + if(!empty($subArray['name']) && !empty($subArray['quantity'])) {
  225 + if(!empty($sorted_array[$subArray['name']])) {
  226 + $sorted_array[$subArray['name']] += $subArray['quantity'];
  227 + } else {
  228 + $sorted_array[$subArray['name']] = $subArray['quantity'];
  229 + }
163 230 }
164   -
165   - $psModel = ProductStock::find()->where(['product_variant_id'=>$model->product_variant_id, 'stock_id' =>$stock->stock_id ])->one();
166   - if(!$psModel instanceof ProductStock){
167   - $psModel = new ProductStock;
168   - $psModel->load(['ProductStock'=>$ProductStock]);
169   - $psModel->stock_id = $stock->stock_id;
170   - $psModel->product_variant_id = $model->product_variant_id;
171   - $psModel->product_id = $model->product->product_id;
172   - $quantity = $quantity + $psModel->quantity;
173   - $psModel->validate();
174   - $psModel->save();
  231 + }
  232 + $ProductStocks = $sorted_array;
  233 + $stock_names = array_keys($ProductStocks);
  234 + $stocks = Stock::find()->where(['name' => $stock_names])->indexBy('name')->one();
  235 + foreach($ProductStocks as $name => $quantity) {
  236 + $quantity = (int) $quantity;
  237 + if(!array_key_exists($name, $stocks)) {
  238 + $stock = new Stock([
  239 + 'name' => $name
  240 + ]);
  241 + if(!$stock->save()) {
  242 + continue;
  243 + }
175 244 } else {
176   - $psModel->load(['ProductStock'=>$ProductStock]);
177   - $quantity = $quantity + $psModel->quantity;
178   - $psModel->save();
  245 + $stock = $stocks[$name];
  246 + }
  247 + $psModel = new ProductStock([
  248 + 'product_id' => $model->product_id,
  249 + 'product_variant_id' => $model->product_variant_id,
  250 + 'stock_id' => $stock->stock_id,
  251 + 'quantity' => $quantity,
  252 + ]);
  253 + if($psModel->save()) {
  254 + $total_quantity += $quantity;
179 255 }
180   -
181 256 }
182 257 } else {
183   - $model->unlinkAll('stocks',true);
  258 + $model->unlinkAll('stocks', true);
184 259 }
185 260  
186   -
187   - $model->stock = $quantity;
  261 + $model->stock = $total_quantity;
188 262 $model->save();
189 263 }
190 264 return $this->redirect(['index', 'product_id'=>$product_id]);
... ...
common/modules/product/helpers/FilterHelper.php
... ... @@ -5,8 +5,6 @@ namespace common\modules\product\helpers;
5 5  
6 6 use common\modules\rubrication\models\TaxGroup;
7 7 use yii\base\Object;
8   -use Yii;
9   -use yii\db\QueryInterface;
10 8 use yii\helpers\ArrayHelper;
11 9  
12 10 class FilterHelper extends Object {
... ...