Skip to content

Commit

Permalink
minor adjustements added more files
Browse files Browse the repository at this point in the history
  • Loading branch information
txmodxoops committed May 4, 2015
1 parent 38d3a09 commit d21fae1
Show file tree
Hide file tree
Showing 26 changed files with 1,911 additions and 529 deletions.
353 changes: 175 additions & 178 deletions class/fields.php

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions class/files/TDMCreateAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@
* @package tdmcreate
* @since 2.5.0
* @author Txmod Xoops http://www.txmodxoops.org
* @version $Id: abstract.php 12258 2014-01-02 09:33:29Z timgno $
* @version $Id: TDMCreateAbstract.php 12258 2014-01-02 09:33:29Z timgno $
*/

defined('XOOPS_ROOT_PATH') or die('Restricted access');

/**
* Abstract base class
*/
abstract class TDMCreateAbstract
{
/**
/*
* @var mixed
*/
protected $tdmcreate;

/**
* "module" attribute fot files
*
* @var mixed
Expand Down
48 changes: 30 additions & 18 deletions class/files/TDMCreateArchitecture.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ public function createFilesToBuilding($module)
// Module
$modId = $module->getVar('mod_id');
$moduleDirname = $module->getVar('mod_dirname');
$uploadTablesIcons32 = $this->structure->getUploadPath() . '/images/tables';
$icon32 = 'assets/icons/32';
// Id of tables
$criteriaTables = new CriteriaCompo();
Expand All @@ -252,7 +251,7 @@ public function createFilesToBuilding($module)
unset($criteriaTables);
$ret = array();
//
$table = null;
$table = array();
foreach (array_keys($tables) as $t) {
$tableMid = $tables[$t]->getVar('table_mid');
$tableId = $tables[$t]->getVar('table_id');
Expand All @@ -268,7 +267,7 @@ public function createFilesToBuilding($module)
// Get Table Object
$table = $this->tdmcreate->getHandler('tables')->get($tableId);
// Copy of tables images file
if (file_exists($uploadTableImage = $uploadTablesIcons32 . '/' . $tableImage)) {
if (file_exists($uploadTableImage = TDMC_UPLOAD_IMGTAB_PATH . '/' . $tableImage)) {
$this->structure->copyFile($icon32, $uploadTableImage, $tableImage);
} elseif (file_exists($uploadTableImage = XOOPS_ICONS32_PATH . '/' . $tableImage)) {
$this->structure->copyFile($icon32, $uploadTableImage, $tableImage);
Expand Down Expand Up @@ -300,7 +299,7 @@ public function createFilesToBuilding($module)
// Class Files
$classFiles = ClassFiles::getInstance();
$classFiles->write($module, $table, $tables);
$ret[] = $classFiles->renderFile($tableName . '.php');
$ret[] = $classFiles->renderFile($tableName . '.php');
}
// Creation of user files
if (1 == $tableUser) {
Expand All @@ -321,7 +320,7 @@ public function createFilesToBuilding($module)
if (1 == $module->getVar('mod_admin')) {
// Admin Header File
$adminHeader = AdminHeader::getInstance();
$adminHeader->write($module, $table, 'header.php');
$adminHeader->write($module, $table, $tables, 'header.php');
$ret[] = $adminHeader->render();
// Admin Index File
$adminIndex = AdminIndex::getInstance();
Expand Down Expand Up @@ -381,16 +380,16 @@ public function createFilesToBuilding($module)
$ret[] = $languageBlocks->render();
}
// Creation of admin permission files
if (1 == $table->getVar('table_permissions')) {
// Admin Permissions File
$adminPermissions = AdminPermissions::getInstance();
$adminPermissions->write($module, $tables, 'permissions.php');
$ret[] = $adminPermissions->render();
// Templates Admin Permissions File
$adminTemplatesPermissions = TemplatesAdminPermissions::getInstance();
$adminTemplatesPermissions->write($module, $moduleDirname . '_admin_permissions.tpl');
$ret[] = $adminTemplatesPermissions->render();
}
if (1 == $table->getVar('table_permissions')) {
// Admin Permissions File
$adminPermissions = AdminPermissions::getInstance();
$adminPermissions->write($module, $tables, 'permissions.php');
$ret[] = $adminPermissions->render();
// Templates Admin Permissions File
$adminTemplatesPermissions = TemplatesAdminPermissions::getInstance();
$adminTemplatesPermissions->write($module, $moduleDirname . '_admin_permissions.tpl');
$ret[] = $adminTemplatesPermissions->render();
}
// Creation of notifications files
if (1 == $table->getVar('table_notifications')) {
// Include Notifications File
Expand Down Expand Up @@ -447,7 +446,8 @@ public function createFilesToBuilding($module)
$includeCommentFunctions->write($module, $table, 'comment_functions.php');
$ret[] = $includeCommentFunctions->renderFile();
}
}

}
// Creation of admin files
if (1 == $module->getVar('mod_admin')) {
// Templates Index File
Expand All @@ -464,7 +464,7 @@ public function createFilesToBuilding($module)
$ret[] = $userTemplatesHeader->render();
}
// Creation of user files
if (1 == $module->getVar('mod_user')) {
if ((1 == $module->getVar('mod_user')) && (1 == $table->getVar('table_user'))) {
// User Footer File
$userFooter = UserFooter::getInstance();
$userFooter->write($module, 'footer.php');
Expand All @@ -474,10 +474,22 @@ public function createFilesToBuilding($module)
$userHeader->write($module, $table, $tables, 'header.php');
$ret[] = $userHeader->render();
// User Notification Update File
if ((1 == $module->getVar('mod_notifications'))) {
if ((1 == $module->getVar('mod_notifications')) && (1 == $table->getVar('table_notifications'))) {
$userNotificationUpdate = UserNotificationUpdate::getInstance();
$userNotificationUpdate->write($module, 'notification_update.php');
$ret[] = $userNotificationUpdate->render();
}
// User Print File
if ((1 == $table->getVar('table_print'))) {
$userPrint = UserPrint::getInstance();
$userPrint->write($module, $table, 'print.php');
$ret[] = $userPrint->render();
}
// User Rss File
if ((1 == $table->getVar('table_rss'))) {
$userRss = UserRss::getInstance();
$userRss->write($module, $table, 'rss.php');
$ret[] = $userRss->render();
}
// User Index File
$userIndex = UserIndex::getInstance();
Expand Down
43 changes: 17 additions & 26 deletions class/files/TDMCreateFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* @package tdmcreate
* @since 2.5.0
* @author Txmod Xoops http://www.txmodxoops.org
* @version $Id: file.php 12258 2014-01-02 09:33:29Z timgno $
* @version $Id: TDMCreateFile.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');

require_once 'TDMCreateTableFields.php';
xoops_load('XoopsFile');

/**
Expand Down Expand Up @@ -116,32 +115,24 @@ public static function &getInstance()
return $instance;
}

/*
* @public function create
* @param string $moduleDirname
* @param string $subdir
* @param string $fileName
* @param string $content
* @param mixed $created
* @param mixed $notCreated
* @param string $mode
*/
/**
* @param $moduleDirname
* @param null $subdir
* @param $fileName
* @param string $content
* @param bool $created
* @param bool $notCreated
* @param string $mode
* @public function create
*
* @param $moduleDirname
* @param $subdir
* @param $fileName
* @param $content
* @param $created
* @param $notCreated
* @param $mode
*/
public function create($moduleDirname, $subdir = null, $fileName, $content = '', $created = false, $notCreated = false, $mode = 'w+')
{
$this->setFileName($fileName);
$this->created = $created;
$this->notCreated = $notCreated;
$this->setMode($mode);
$this->setModulePath($moduleDirname);
$this->setRepositoryPath($moduleDirname);
if (!empty($content) && is_string($content)) {
$this->setContent($content);
}
Expand Down Expand Up @@ -175,25 +166,25 @@ private function getPath()
}

/*
* @private function setModulePath
* @private function setRepositoryPath
* @param string $moduleDirname
*/
/**
* @param $moduleDirname
*/
private function setModulePath($moduleDirname)
private function setRepositoryPath($moduleDirname)
{
$this->uploadPath = TDMC_UPLOAD_REPOSITORY_PATH . DIRECTORY_SEPARATOR . $moduleDirname;
}

/*
* @private function getModulePath
* @private function getRepositoryPath
* @param null
*/
/**
* @return string
*/
private function getModulePath()
private function getRepositoryPath()
{
return $this->uploadPath;
}
Expand Down Expand Up @@ -297,9 +288,9 @@ private function getFolderName()
private function getUploadPath()
{
if ($this->getSubDir() != null) {
$ret = $this->getModulePath() . DIRECTORY_SEPARATOR . $this->getSubDir();
$ret = $this->getRepositoryPath() . DIRECTORY_SEPARATOR . $this->getSubDir();
} else {
$ret = $this->getModulePath();
$ret = $this->getRepositoryPath();
}

return $ret;
Expand Down
9 changes: 4 additions & 5 deletions class/files/TDMCreateStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
* @version $Id: TDMCreateStructure.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
xoops_load('XoopsFile');

/**
* Class TDMCreateStructure
*/
class TDMCreateStructure
{
/*
{
/*
* @var mixed
*/
private $xoopsFile;
Expand Down Expand Up @@ -60,7 +58,8 @@ class TDMCreateStructure
*/
public function __construct()
{
$this->xoopsFile = XoopsFile::getInstance();
//parent::__construct();
$this->xoopsFile = XoopsFile::getInstance();
}

/*
Expand Down
35 changes: 11 additions & 24 deletions class/files/TDMCreateTableFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,34 @@
* @package tdmcreate
* @since 2.5.0
* @author Txmod Xoops http://www.txmodxoops.org
* @version $Id: tablefields.php 12258 2014-01-02 09:33:29Z timgno $
* @version $Id: TDMCreateTableFields.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
require_once 'TDMCreateAbstract.php';

/**
* Class TDMCreateTableFields
*/
class TDMCreateTableFields extends TDMCreateAbstract
{
/*
* @var string
*/
protected $tdmcreate;

/*
* @public function constructor
* @param mixed $table
*/
/**
*
* @public function constructor
* @param mixed $table
*/
public function __construct()
{
$this->tdmcreate = TDMCreateHelper::getInstance();
}

/*
* @public function getTableFields
* @param integer $table_id
*/
/**
* @param $table_id
* @return mixed
* @public function getTableFields
* @param $tableId
* @return mixed
*/
public function getTableFields($table_id)
public function getTableFields($tableId)
{
$criteriaFields = new CriteriaCompo();
$criteriaFields->add(new Criteria('field_tid', $table_id));
$fields = $this->tdmcreate->getHandler('fields')->getObjects($criteriaFields);
unset($criteriaFields);
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('field_tid', $tableId));
$fields = $this->tdmcreate->getHandler('fields')->getObjects($criteria);
unset($criteria);

return $fields;
}
Expand Down
18 changes: 14 additions & 4 deletions class/files/admin/AdminHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ public static function &getInstance()
* @param $table
* @param $filename
*/
public function write($module, $table, $filename)
public function write($module, $table, $tables, $filename)
{
$this->setModule($module);
$this->setTable($table);
$this->setTables($tables);
$this->setFileName($filename);
}

Expand All @@ -83,11 +84,11 @@ public function write($module, $table, $filename)
* @param $table
* @return string
*/
private function getAdminHeader($moduleDirname, $table)
private function getAdminHeader($moduleDirname, $table, $tables)
{
$ucfModuleDirname = ucfirst($moduleDirname);
$ret = <<<EOT
\nrequire_once dirname(dirname(dirname(__DIR__))). '/include/cp_header.php';
\ninclude dirname(dirname(dirname(__DIR__))). '/include/cp_header.php';
\$thisPath = dirname(__DIR__);
include_once \$thisPath.'/include/common.php';
\$sysPathIcon16 = '../' . \$GLOBALS['xoopsModule']->getInfo('sysicons16');
Expand All @@ -103,6 +104,14 @@ private function getAdminHeader($moduleDirname, $table)
\${$moduleDirname} = {$ucfModuleDirname}Helper::getInstance();\n
EOT;

}
if (is_array($tables)) {
foreach (array_keys($tables) as $i) {
$tableName = $tables[$i]->getVar('table_name');
$ret .= <<<EOT
\${$tableName}Handler =& \${$moduleDirname}->getHandler('{$tableName}');\n
EOT;
}
}
$ret .= <<<EOT
//
Expand Down Expand Up @@ -145,10 +154,11 @@ public function render()
{
$module = $this->getModule();
$table = $this->getTable();
$tables = $this->getTables();
$filename = $this->getFileName();
$moduleDirname = $module->getVar('mod_dirname');
$content = $this->getHeaderFilesComments($module, $filename);
$content .= $this->getAdminHeader($moduleDirname, $table);
$content .= $this->getAdminHeader($moduleDirname, $table, $tables);

$this->tdmcfile->create($moduleDirname, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);

Expand Down
2 changes: 1 addition & 1 deletion class/files/admin/AdminIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function render()
foreach (array_keys($tables) as $i) {
$tableName = $tables[$i]->getVar('table_name');
$content .= <<<EOT
\${$tableName}Handler =& \${$moduleDirname}->getHandler('{$tableName}');
//\${$tableName}Handler =& \${$moduleDirname}->getHandler('{$tableName}');
\$count_{$tableName} = \${$tableName}Handler->getCount();\n
EOT;
}
Expand Down
Loading

0 comments on commit d21fae1

Please sign in to comment.