3 次代码提交 5e87f15563 ... 30a2ec16ab

作者 SHA1 备注 提交日期
  cedric 30a2ec16ab new test file 11 月之前
  cedric bfc8d21de0 add create folder img 11 月之前
  cedric 44453620c7 add static fonction 11 月之前
共有 3 个文件被更改,包括 39 次插入2 次删除
  1. 4 1
      classes/chcreaimages.php
  2. 1 1
      classes/chcreapost.php
  3. 34 0
      tests/test.php

+ 4 - 1
classes/chcreaimages.php

@@ -130,11 +130,14 @@ class Chcreaimages extends ObjectModel
 
 	public function getPath($dir=null)
 	{
+		if( !file_exists(chcrea_img_dir)) {
+			mkdir(chcrea_img_dir);
+		}
 		if($dir == null) {
 			$dir = chcrea_img_dir.$this->id_chcreaposts.'/';
 			if ( !file_exists($dir) ) {
 				$oldmask = umask(000);
-				mkdir($dir                                                                                                                                                                                                                    );
+				mkdir($dir);
 				chmod($dir, 0775);
 				umask($oldmask);
 			}

+ 1 - 1
classes/chcreapost.php

@@ -527,7 +527,7 @@ class Chcreapost extends ObjectModel
 	 * 
 	 * @return [type]
 	 */
-	protected function getViewedProducts($productIds)
+	protected static function getViewedProducts($productIds)
 	{
 		if (!empty($productIds)) {
 			$context = Context::getContext();

+ 34 - 0
tests/test.php

@@ -0,0 +1,34 @@
+<?php
+
+
+include(dirname(__FILE__).'/../../../config/config.inc.php');
+
+$context->controller = new stdClass();
+$context->controller->controller_type = ['test'];
+
+require_once(dirname(__FILE__) . '/../classes/chcreaimages.php');
+
+$id_post  = 1;
+/*
+if (!file_exists(chcrea_img_dir)) {
+    print(chcrea_img_dir." exist\n");
+} else {
+    print(chcrea_img_dir." non\n");
+}
+
+$path = chcrea_img_dir.$id_post.'/';
+print($path);
+
+mkdir($path);
+
+print("\n");
+*/
+$obj = new Chcreaimages();
+$obj->id_chcreaposts = $id_post;
+
+print($obj->getPath());
+
+
+
+
+