Skip to content

Commit

Permalink
Dev: replaced "path" field by "folder"
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jul 11, 2017
1 parent d8dbca0 commit 6eeec00
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions application/models/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public function rules()
array('owner_id, extends_templates_id', 'numerical', 'integerOnly'=>true),
array('name, author', 'length', 'max'=>150),
array('author_email, author_url', 'length', 'max'=>255),
array('version, path', 'length', 'max'=>45),
array('version, folder', 'length', 'max'=>45),
array('creation_date, copyright, license, description, last_update', 'safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, name, creation_date, author, author_email, author_url, copyright, license, version, description, last_update, path, owner_id, extends_templates_id', 'safe', 'on'=>'search'),
array('id, name, creation_date, author, author_email, author_url, copyright, license, version, description, last_update, folder, owner_id, extends_templates_id', 'safe', 'on'=>'search'),
);
}

Expand Down Expand Up @@ -89,7 +89,7 @@ public function attributeLabels()
'version' => 'Version',
'description' => 'Description',
'last_update' => 'Last Update',
'path' => 'Path',
'folder' => 'folder',
'owner_id' => 'Owner',
'extends_templates_id' => 'Extends Templates',
);
Expand Down Expand Up @@ -125,7 +125,7 @@ public static function templateNameFilter($sTemplateName)
/* Validate if template is OK in user dir, DIRECTORY_SEPARATOR not needed "/" is OK */
$oTemplate = self::model()->find('name=:name', array(':name'=>$sTemplateName));

if(is_object($oTemplate) && is_file(Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->path.DIRECTORY_SEPARATOR.'config.xml')) {
if(is_object($oTemplate) && is_file(Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->folder.DIRECTORY_SEPARATOR.'config.xml')) {
return $sTemplateName;
}

Expand Down Expand Up @@ -168,10 +168,10 @@ public static function getTemplatePath($sTemplateName = "")
$oTemplate = self::model()->find('name=:name', array(':name'=>$sTemplateName));

if (self::isStandardTemplate($sTemplateName)) {
return $aTemplatePath[$sTemplateName] = Yii::app()->getConfig("standardtemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->path;
return $aTemplatePath[$sTemplateName] = Yii::app()->getConfig("standardtemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->folder;
}
else {
return $aTemplatePath[$sTemplateName] = Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->path;
return $aTemplatePath[$sTemplateName] = Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->folder;
}
}

Expand Down Expand Up @@ -232,10 +232,10 @@ public static function getTemplateURL($sTemplateName="")

if (is_object($oTemplate)){
if (self::isStandardTemplate($sTemplateName)) {
return $aTemplateUrl[$sTemplateName]=Yii::app()->getConfig("standardtemplaterooturl").'/'.$oTemplate->path.'/';
return $aTemplateUrl[$sTemplateName]=Yii::app()->getConfig("standardtemplaterooturl").'/'.$oTemplate->folder.'/';
}
else {
return $aTemplateUrl[$sTemplateName]=Yii::app()->getConfig("usertemplaterooturl").'/'.$oTemplate->path.'/';
return $aTemplateUrl[$sTemplateName]=Yii::app()->getConfig("usertemplaterooturl").'/'.$oTemplate->folder.'/';
}
}else{
return '';
Expand Down Expand Up @@ -263,7 +263,7 @@ public static function getTemplateList()
$oTemplate = self::model()->find('name=:name', array(':name'=>$sTemplateName));

if (is_object($oTemplate)){
$aTemplateList[$sTemplateName] = $standardTemplateRootDir.DIRECTORY_SEPARATOR.$oTemplate->path;
$aTemplateList[$sTemplateName] = $standardTemplateRootDir.DIRECTORY_SEPARATOR.$oTemplate->folder;
}
}

Expand All @@ -275,7 +275,8 @@ public static function getTemplateList()
&& $sTemplatePath != ".." && $sTemplatePath!=".svn"
&& (file_exists("{$sUserTemplateRootDir}/{$sTemplatePath}/config.xml"))) {

$oTemplate = self::model()->find('path=:path', array(':path'=>$sTemplatePath));
// TODO: explode $sTemplatePath
$oTemplate = self::model()->find('folder=:folder', array(':folder'=>$sTemplatePath));

if (is_object($oTemplate)){
$aTemplateList[$oTemplate->name] = $sUserTemplateRootDir.DIRECTORY_SEPARATOR.$sTemplatePath;
Expand Down Expand Up @@ -307,8 +308,8 @@ public static function getTemplateListWithPreviews()
$oTemplate = self::model()->find('name=:name', array(':name'=>$sTemplateName));

if (is_object($oTemplate)) {
$aTemplateList[$sTemplateName]['directory'] = $standardtemplaterootdir.DIRECTORY_SEPARATOR.$oTemplate->path;
$aTemplateList[$sTemplateName]['preview'] = $standardtemplaterooturl.'/'.$oTemplate->path.'/preview.png';
$aTemplateList[$sTemplateName]['directory'] = $standardtemplaterootdir.DIRECTORY_SEPARATOR.$oTemplate->folder;
$aTemplateList[$sTemplateName]['preview'] = $standardtemplaterooturl.'/'.$oTemplate->folder.'/preview.png';
}
}

Expand All @@ -318,7 +319,7 @@ public static function getTemplateListWithPreviews()
if (!is_file("$usertemplaterootdir/$sTemplatePath") && $sTemplatePath != "." && $sTemplatePath != ".." && $sTemplatePath!=".svn") {


$oTemplate = self::model()->find('path=:path', array(':path'=>$sTemplatePath));
$oTemplate = self::model()->find('folder=:folder', array(':folder'=>$sTemplatePath));

if (is_object($oTemplate)){
$aTemplateList[$oTemplate->name]['directory'] = $sUserTemplateRootDir.DIRECTORY_SEPARATOR.$sTemplatePath;
Expand Down Expand Up @@ -444,7 +445,7 @@ public function search()
$criteria->compare('version',$this->version,true);
$criteria->compare('description',$this->description,true);
$criteria->compare('last_update',$this->last_update,true);
$criteria->compare('path',$this->path,true);
$criteria->compare('folder',$this->folder,true);
$criteria->compare('owner_id',$this->owner_id);
$criteria->compare('extends_templates_id',$this->extends_templates_id);

Expand Down

0 comments on commit 6eeec00

Please sign in to comment.