Ejemplo n.º 1
0
 /**
  * Outputs a table with the currently detected set of modules on
  *
  * @version 1.0
  * @since   1.0.0
  * @author  Dan Aldridge
  * 
  * @return  void
  */
 public function modules()
 {
     $objSQL = Core_Classes_coreObj::getDBO();
     $objTPL = Core_Classes_coreObj::getTPL();
     $objModule = Core_Classes_coreObj::getModule();
     $objTPL->set_filenames(array('body' => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl', 'panel' => cmsROOT . 'modules/core/views/admin/modules/default/module_list.tpl'));
     $files = glob(sprintf('%smodules/*', cmsROOT));
     foreach ($files as $file) {
         $moduleName = str_replace('modules/', '', $file);
         // Determine the status of the module
         if (parent::moduleExists($moduleName) === false) {
             continue;
         }
         $query = $objSQL->queryBuilder()->select('*')->from('#__modules')->where('name', '=', $moduleName)->build();
         $row = $objSQL->fetchLine($query);
         $moduleInstalled = parent::moduleInstalled($moduleName);
         if (empty($row) || $moduleInstalled === false) {
             $details = $objModule->getModuleDetails($moduleName);
             if (!empty($details)) {
                 $version = $details['version'];
                 $hash = $details['hash'];
             }
         }
         $objTPL->assign_block_vars('module', array('NAME' => $moduleName, 'VERSION' => $version, 'HASH' => $hash, 'STATUS' => $moduleInstalled === false ? 'Not Installed' : 'Installed', 'STATUS_ICON' => $moduleInstalled === false ? 'default' : 'success'));
     }
     $objTPL->parse('panel', false);
     Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'Module List', 'CONTENT' => $objTPL->get_html('panel', false), 'ICON' => 'icon-th-list')));
 }
Ejemplo n.º 2
0
 /**
  * Install a block from a Module method
  *
  * @version 1.0
  * @since   1.0
  * @author  Daniel Noel-Davies
  *
  * @param   string  $var       Parameter Description
  *
  */
 public function installFromModule($module, $method)
 {
     $objModule = Core_Classes_coreObj::getModule();
     $objSQL = Core_Classes_coreObj::getDBO();
     $details = $objModule->getDetails($module);
     // Check method is callable and the module is enabled
     // Not okay
     if ($details === false || $objModule->moduleInstalled() === false) {
         // Error + return false
         trigger_error('Module x is not installed, No block was created');
         return false;
     }
     $data = array('uniqueid' => randcode(8), 'label' => '', 'title' => '', 'region_name' => '', 'order' => '', 'enabled' => '', 'info' => json_encode(), 'args' => json_encode(), 'whitelist' => '', 'content' => '');
     // Add into db + display status
     $query = $objSQL->queryBuilder()->insertInto('#__blocks')->set($data)->build();
     $result = $objSQL->insert($query);
     if ($result) {
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
/**
 * Displays a formatted error on screen.
 *
 * @version 3.0
 * @since   1.0.0
 */
function msg($msg_type, $message, $tplVar = NULL, $title = NULL)
{
    $objPage = Core_Classes_coreObj::getPage();
    $objTPL = Core_Classes_coreObj::getTPL();
    $objModule = Core_Classes_coreObj::getModule();
    if (!is_object($objTPL) || !is_object($objPage)) {
        echo $message;
        exit;
    }
    $handle = '__msg_' . ($tplVar === NULL ? rand(0, 1000) : $tplVar);
    $handle = is_object($objModule) && $tplVar == 'body' ? 'body' : $handle;
    $objTPL->set_filenames(array($handle => cmsROOT . 'modules/core/views/module/message/default.tpl'));
    switch (strtolower($msg_type)) {
        case 'fail':
            $img = '/' . root() . 'images/fail.png';
            $type = 'error';
            break;
        case 'ok':
            $img = '/' . root() . 'images/ok.png';
            $type = 'status';
            break;
        case 'info':
            $img = '/' . root() . 'images/info.png';
            $type = 'warning';
            break;
        default:
            $img = NULL;
            break;
    }
    $objTPL->assign_vars(array('L_MSG_TYPE' => is_empty($title) ? langVar('MSG_' . strtoupper($msg_type)) : $title, 'L_MSG' => $message, 'IMG' => isset($img) && !is_empty($img) ? '<img src="' . $img . '" style="height: 48px; width: 48px;">' : '', 'ALIGN' => 'left', 'TYPE' => $type));
    if ($tplVar === NULL) {
        $objTPL->parse($handle);
    } else {
        if ($tplVar == 'return') {
            return $objTPL->get_html($handle);
        } else {
            if ($handle == 'body') {
                $objTPL->parse($handle, false);
            } else {
                $objTPL->assign_var_from_handle($tplVar, $handle);
            }
        }
    }
}